leaflet-tual 0.0.0 → 1.0.0

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/react.cjs ADDED
@@ -0,0 +1,4 @@
1
+ "use client";
2
+ "use strict";var Pn=Object.create;var Dt=Object.defineProperty;var Ln=Object.getOwnPropertyDescriptor;var In=Object.getOwnPropertyNames;var Rn=Object.getPrototypeOf,Dn=Object.prototype.hasOwnProperty;var Mn=(e,t)=>{for(var o in t)Dt(e,o,{get:t[o],enumerable:!0})},xo=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of In(t))!Dn.call(e,n)&&n!==o&&Dt(e,n,{get:()=>t[n],enumerable:!(r=Ln(t,n))||r.enumerable});return e};var je=(e,t,o)=>(o=e!=null?Pn(Rn(e)):{},xo(t||!e||!e.__esModule?Dt(o,"default",{value:e,enumerable:!0}):o,e)),En=e=>xo(Dt({},"__esModule",{value:!0}),e);var Un={};Mn(Un,{DEFAULT_ANNOTATION_THEME:()=>Bn,DEFAULT_FONT_SIZE:()=>it,DEFAULT_FONT_SIZE_OPTIONS:()=>Et,DEFAULT_NOTE_BG:()=>at,DEFAULT_NOTE_TEXT:()=>On,DEFAULT_STROKE_COLOR:()=>nt,DEFAULT_STROKE_WIDTH:()=>rt,DEFAULT_STROKE_WIDTH_OPTIONS:()=>Mt,FONT_SIZE_OPTIONS:()=>Nn,InlineShapeLabelEditor:()=>ao,LeafletTual:()=>Sn,NOTE_COLOR_THEMES:()=>ue,NoteOverlay:()=>io,PixelSelect:()=>Ct,STROKE_COLORS:()=>Jt,STROKE_WIDTH_OPTIONS:()=>An,TOOL_TO_ARROW_STYLE:()=>Fe,TextOverlay:()=>lo,TualToolbar:()=>Vt,VERSION:()=>Gn,bindBlockMapDblClick:()=>vt,bindLeafletSync:()=>St,buildArrowItem:()=>Ve,buildRulerItem:()=>vo,calculateGeodesicDistance:()=>At,calculateLineDistance:()=>Wn,calculateZoomFontSize:()=>to,clampNotePosition:()=>jn,clampTextPosition:()=>Fn,computeDefaultControlGeoPoint:()=>lt,constrainAngleTo45Degrees:()=>se,constrainToAspectRatio:()=>ze,createDraftNote:()=>dt,createDraftText:()=>ct,createId:()=>Pe,createLeafletTual:()=>zn,createLeafletTualController:()=>no,distanceToQuadraticBezier:()=>Qt,distanceToSegment:()=>xe,drawArrowHead:()=>Ot,drawTualHandle:()=>we,drawTualLabelPill:()=>ke,formatRealWorldDistance:()=>oo,geoToScreen:()=>te,getCollapseChevronRotation:()=>Kt,getDropdownChevronRotation:()=>Je,getExpandChevronRotation:()=>Xt,getMapDimensions:()=>Le,getQuadraticBezierPoint:()=>kt,getQuadraticEndAngle:()=>st,hitTestArrow:()=>_e,hitTestArrowHandle:()=>Ge,hitTestFreeDraw:()=>Ue,hitTestRuler:()=>Xe,hitTestRulerHandle:()=>Ke,hitTestShape:()=>Ae,hitTestShapeHandle:()=>Ye,paintLeafletTual:()=>Tt,projectArrow:()=>ge,projectFreeDraw:()=>De,projectRuler:()=>be,projectShape:()=>pe,renderArrowOnCanvas:()=>Bt,renderFreeDrawOnCanvas:()=>Wt,renderRulerOnCanvas:()=>Ft,renderShapeOnCanvas:()=>jt,resolveNoteTheme:()=>Hn,screenToGeo:()=>X,startArrowBodyDrag:()=>gt,startArrowDrag:()=>ut,startArrowHandleDrag:()=>ht,startFreeDrawBodyDrag:()=>yt,startFreeDrawDrag:()=>$e,startRulerBodyDrag:()=>wt,startRulerDrag:()=>ft,startRulerHandleDrag:()=>xt,startShapeBodyDrag:()=>bt,startShapeDrag:()=>pt,startShapeHandleDrag:()=>mt,traceArrowPath:()=>Nt,tracePolygonShape:()=>Ht,truncateTualText:()=>eo,useLeafletSync:()=>so,useLeafletTual:()=>co});module.exports=En(Un);var wo={name:"leaflet-tual",version:"1.0.0",description:"Framework-agnostic interactive canvas and annotation toolkit for Leaflet maps \u2014 draw arrows, shapes, freehand sketches, rulers, notes, and text pinned to geo-coordinates. Optional React bindings.",type:"module",sideEffects:!1,main:"./dist/index.cjs",module:"./dist/index.js",types:"./dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:{types:"./dist/index.d.ts",default:"./dist/index.js"},require:{types:"./dist/index.d.cts",default:"./dist/index.cjs"},default:"./dist/index.js"},"./core":{types:"./dist/index.d.ts",import:{types:"./dist/index.d.ts",default:"./dist/index.js"},require:{types:"./dist/index.d.cts",default:"./dist/index.cjs"},default:"./dist/index.js"},"./react":{types:"./dist/react.d.ts",import:{types:"./dist/react.d.ts",default:"./dist/react.js"},require:{types:"./dist/react.d.cts",default:"./dist/react.cjs"},default:"./dist/react.js"},"./package.json":"./package.json"},files:["dist","README.md"],author:"Yusuf Arslan",license:"MIT",repository:{type:"git",url:"git+https://github.com/yusufarsln98/leaflet-tual.git",directory:"packages/leaflet-tual"},bugs:{url:"https://github.com/yusufarsln98/leaflet-tual/issues"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},keywords:["leaflet","leaflet-tual","tual","tuval","canvas","annotation","map-tools","arrows","notes","gis","overlay","framework-agnostic","vanilla-js","react","react-leaflet"],scripts:{build:"tsup",dev:"tsup --watch",lint:"eslint src --ext ts,tsx",typecheck:"tsc --noEmit",format:'prettier --write "src/**/*.{ts,tsx}"',"format:check":'prettier --check "src/**/*.{ts,tsx}"',test:"vitest run","test:watch":"vitest",version:"changeset version",release:"npm run build && changeset publish"},peerDependencies:{leaflet:"^1.9.0",react:"^18.0.0 || ^19.0.0","react-dom":"^18.0.0 || ^19.0.0","react-leaflet":"^4.0.0 || ^5.0.0"},peerDependenciesMeta:{react:{optional:!0},"react-dom":{optional:!0},"react-leaflet":{optional:!0}},devDependencies:{"@changesets/cli":"^2.27.1","@testing-library/dom":"^10.4.0","@testing-library/react":"^16.2.0","@types/leaflet":"^1.9.16","@types/node":"^22.13.0","@types/react":"^19.0.0","@types/react-dom":"^19.0.0",eslint:"^9.20.0","eslint-plugin-react-hooks":"^5.1.0",jsdom:"^26.0.0",leaflet:"^1.9.4",prettier:"^3.5.0",react:"^19.0.0","react-dom":"^19.0.0","react-leaflet":"^5.0.0",tsup:"^8.5.1",typescript:"^5.7.0","typescript-eslint":"^8.24.0",vitest:"^3.0.0"}};var Fe={"arrow-linear":"linear","arrow-curved":"curved","arrow-bi":"bi","arrow-elbow":"elbow","arrow-s-curve":"s-curve"},Jt=["#000000","#4b5563","#2563eb","#dc2626","#16a34a","#d97706","#9333ea","#0891b2"],ue=[{name:"Amber",bg:"#fef9c3",border:"#fde047",header:"#fef08a",text:"#422006"},{name:"Sky",bg:"#e0f2fe",border:"#7dd3fc",header:"#bae6fd",text:"#0c4a6e"},{name:"Emerald",bg:"#dcfce7",border:"#86efac",header:"#bbf7d0",text:"#064e3b"},{name:"Rose",bg:"#ffe4e6",border:"#fda4af",header:"#fecdd3",text:"#881337"},{name:"Violet",bg:"#f3e8ff",border:"#d8b4fe",header:"#e9d5ff",text:"#3b0764"},{name:"Dark Slate",bg:"#1e293b",border:"#334155",header:"#0f172a",text:"#f8fafc"},{name:"Midnight",bg:"#111827",border:"#374151",header:"#030712",text:"#f9fafb"}],nt="#000000",rt=2,Mt=[1,2,3,4,5,6,8,10,12],An=Mt,at="#fef9c3",On="#422006",it=16,Et=[10,12,14,16,18,20,24,28,32,36,40,48],Nn=Et,Bn={selectionGlowColor:"rgba(0, 0, 0, 0.2)",selectionGlowWidth:6,guideLineDash:[4,4],guideLineColor:"rgba(100, 100, 100, 0.6)",guideLineWidth:1.2,endpointHandleColor:"#4f4f4f",controlHandleColor:"#4f4f4f",handleFillColor:"#ffffff",handleRadius:5,handleStrokeWidth:2,shadowColor:"rgba(0, 0, 0, 0.2)",shadowBlur:3,shadowOffsetY:1.5,labelBackgroundColor:"#ffffff",labelTextColor:"#000000",labelFont:"12px system-ui, -apple-system, sans-serif",labelBorderWidth:1,labelBorderRadius:2,labelPaddingX:6,labelPaddingY:18,shapeDefaultFillOpacity:.16,shapeBorderRadius:0};var To=0;function Pe(e="rlc"){To+=1;let t=Math.random().toString(36).slice(2,8);return`${e}-${Date.now().toString(36)}-${To}-${t}`}function te(e,t){let o=e.latLngToContainerPoint([t.lat,t.lng]);return{x:o.x,y:o.y}}function X(e,t){let o=e.containerPointToLatLng([t.x,t.y]);return{lat:o.lat,lng:o.lng}}function ze(e,t,o=1){let r=o>0?o:1,n=t.x-e.x,a=t.y-e.y,l=Math.abs(n),s=Math.abs(a),i=n>=0?1:-1,d=a>=0?1:-1;return l/r>=s?{x:e.x+i*l,y:e.y+d*(l/r)}:{x:e.x+i*(s*r),y:e.y+d*s}}function se(e,t){let o=t.x-e.x,r=t.y-e.y,n=Math.hypot(o,r);if(n===0)return t;let a=Math.atan2(r,o),l=Math.PI/4,s=Math.round(a/l)*l;return{x:e.x+Math.cos(s)*n,y:e.y+Math.sin(s)*n}}function lt(e,t,o=.25){let r=(e.lat+t.lat)/2,n=(e.lng+t.lng)/2,a=t.lat-e.lat,l=t.lng-e.lng;return{lat:r+l*o,lng:n-a*o}}function kt(e,t,o,r){let n=1-r;return{x:n*n*e.x+2*n*r*t.x+r*r*o.x,y:n*n*e.y+2*n*r*t.y+r*r*o.y}}function st(e,t,o){let r=o.x-t.x,n=o.y-t.y;return Math.hypot(r,n)<.001?Math.atan2(o.y-e.y,o.x-e.x):Math.atan2(n,r)}function xe(e,t,o){let r=(o.x-t.x)**2+(o.y-t.y)**2;if(r===0)return Math.hypot(e.x-t.x,e.y-t.y);let n=((e.x-t.x)*(o.x-t.x)+(e.y-t.y)*(o.y-t.y))/r;n=Math.max(0,Math.min(1,n));let a=t.x+n*(o.x-t.x),l=t.y+n*(o.y-t.y);return Math.hypot(e.x-a,e.y-l)}function Qt(e,t,o,r,n=24){let a=1/0,l=t;for(let s=1;s<=n;s+=1){let i=kt(t,o,r,s/n),d=xe(e,l,i);d<a&&(a=d),l=i}return a}function Le(e){if(!e)return null;try{let t=e.getSize?.();if(t&&t.x>0&&t.y>0)return{width:t.x,height:t.y}}catch{}try{let t=e.getContainer?.()?.getBoundingClientRect?.();if(t&&t.width>0&&t.height>0)return{width:t.width,height:t.height}}catch{}return null}function eo(e,t,o){if(!t||o<=0)return"";if(e.measureText(t).width<=o)return t;let r="\u2026";if(e.measureText(r).width>=o)return"";let n=0,a=t.length,l="";for(;n<=a;){let s=Math.floor((n+a)/2),i=t.slice(0,s)+r;e.measureText(i).width<=o?(l=i,n=s+1):a=s-1}return l||r}function to(e=16,t,o=14,r){if(t===null||typeof t!="number")return e;let n=r?.scaleFactor??1.22,a=r?.min??9,l=r?.max??72,s=e*Math.pow(n,t-o);return Math.round(Math.max(a,Math.min(l,s)))}function At(e,t){let r=(t.lat-e.lat)*Math.PI/180,n=(t.lng-e.lng)*Math.PI/180,a=e.lat*Math.PI/180,l=t.lat*Math.PI/180,s=Math.sin(r/2),i=Math.sin(n/2),d=s*s+Math.cos(a)*Math.cos(l)*i*i;return 6371e3*(2*Math.atan2(Math.sqrt(d),Math.sqrt(1-d)))}function oo(e,t="metric"){if(t==="imperial"){let r=e*3.28084;if(r<1e3)return`${Math.round(r)} ft`;let n=r/5280;return`${n>=10?n.toFixed(1):n.toFixed(2)} mi`}if(e<1e3)return`${Math.round(e)} m`;let o=e/1e3;return`${o>=10?o.toFixed(1):o.toFixed(2)} km`}function Wn(e){let t=0;for(let o=0;o<e.length-1;o+=1)t+=At(e[o],e[o+1]);return t}function we(e,t,o,r,n,a=2){e.save(),e.beginPath(),e.arc(t.x,t.y,n,0,Math.PI*2),e.fillStyle=r,e.fill(),e.lineWidth=a,e.strokeStyle=o,e.stroke(),e.restore()}function ke(e,t,o,r,n,a,l){e.save(),e.font=l?.labelFont??"12px system-ui, -apple-system, sans-serif";let s=l?.labelPaddingX??6,i=Math.max(10,a-s*2),d=eo(e,t,i);if(d){let c=e.measureText(d),p=Math.round(c.width+s*2),b=l?.labelPaddingY??18,g=Math.round(o-p/2),f=Math.round(r-b/2),u=l?.labelBorderRadius??2;l?.labelShadowColor&&(e.shadowColor=l.labelShadowColor,e.shadowBlur=l.labelShadowBlur??3),e.fillStyle=l?.labelBackgroundColor??"#ffffff",e.strokeStyle=l?.labelBorderColor??n,e.lineWidth=l?.labelBorderWidth??1,e.beginPath(),typeof e.roundRect=="function"?e.roundRect(g,f,p,b,u):e.rect(g,f,p,b),e.fill(),e.stroke(),e.fillStyle=l?.labelTextColor??"#000000",e.textAlign="center",e.textBaseline="middle",e.fillText(d,o,r)}e.restore()}function Ot(e,t,o,r,n,a=!0){let l=Math.PI/6.5,s=t.x-r*Math.cos(o-l),i=t.y-r*Math.sin(o-l),d=t.x-r*Math.cos(o+l),c=t.y-r*Math.sin(o+l);e.save(),e.setLineDash([]),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(s,i),a?(e.lineTo(d,c),e.closePath(),e.fillStyle=n,e.fill()):(e.moveTo(t.x,t.y),e.lineTo(d,c),e.strokeStyle=n,e.lineWidth=Math.max(2,r/4.5),e.lineCap="round",e.stroke()),e.restore()}function Nt(e,t,o){let{start:r,end:n,control:a}=t;if(e.moveTo(r.x,r.y),o==="curved")e.quadraticCurveTo(a.x,a.y,n.x,n.y);else if(o==="elbow")e.lineTo(a.x,r.y),e.lineTo(a.x,n.y),e.lineTo(n.x,n.y);else if(o==="s-curve"){let l=n.x-r.x,s=n.y-r.y;e.bezierCurveTo(r.x+l*.5,r.y,r.x+l*.5,r.y+s,n.x,n.y)}else e.lineTo(n.x,n.y)}function ge(e,t){let o=te(e,t.start),r=te(e,t.end),n=t.arrowStyle==="curved"||t.arrowStyle==="s-curve",a=t.controlPoint?t.controlPoint:n?lt(t.start,t.end):{lat:(t.start.lat+t.end.lat)/2,lng:(t.start.lng+t.end.lng)/2},l=te(e,a);return{start:o,end:r,control:l}}function Bt(e,t,o,r={}){let{start:n,end:a,control:l}=t,s=Math.hypot(a.x-n.x,a.y-n.y);if(s<2)return;let i=r.theme,d=Math.max(12,o.strokeWidth*3.8),c=Math.atan2(a.y-n.y,a.x-n.x),p=Math.atan2(n.y-a.y,n.x-a.x);if(o.arrowStyle==="curved")c=st(n,l,a),p=st(a,l,n);else if(o.arrowStyle==="elbow"){let f=a.x-l.x,u=a.y-n.y;c=Math.abs(f)>1?Math.atan2(0,f):Math.atan2(u,0);let w=n.x-l.x;p=Math.abs(w)>1?Math.atan2(0,w):Math.atan2(-u,0)}else if(o.arrowStyle==="s-curve"){let f=a.x-n.x;c=st(n,{x:n.x+f*.5,y:a.y},a)}e.save(),r.isPreview&&(e.globalAlpha=.85),r.isSelected&&(e.save(),e.beginPath(),Nt(e,t,o.arrowStyle),e.strokeStyle=i?.selectionGlowColor??"rgba(0, 0, 0, 0.2)",e.lineWidth=o.strokeWidth+(i?.selectionGlowWidth??6),e.lineCap="round",e.lineJoin="round",e.stroke(),e.restore()),e.save(),e.shadowColor=i?.shadowColor??"rgba(0, 0, 0, 0.2)",e.shadowBlur=i?.shadowBlur??3,e.shadowOffsetY=i?.shadowOffsetY??1.5,e.beginPath(),Nt(e,t,o.arrowStyle),e.strokeStyle=o.color,e.lineWidth=o.strokeWidth,e.lineCap="round",e.lineJoin="round";let b=!!(o.dashed||o.arrowStyle==="dashed");e.setLineDash(b?[o.strokeWidth*3,o.strokeWidth*2]:[]),e.stroke();let g=o.headStyle??(o.arrowStyle==="bi"?"both":"triangle");if(g!=="none"&&(Ot(e,a,c,d,o.color,g!=="open"),g==="both"&&Ot(e,n,p,d,o.color,!0)),e.restore(),o.label){let f=typeof i?.labelMinShapeSize=="number"?i.labelMinShapeSize:24;if(f<=0||s>=f){let u=o.arrowStyle==="curved"?kt(n,l,a,.5):o.arrowStyle==="elbow"?{x:l.x,y:(n.y+a.y)/2}:{x:(n.x+a.x)/2,y:(n.y+a.y)/2},w=i?.fitLabelsToShape!==!1,y=i?.labelMaxTextWidth??(w?Math.max(48,Math.min(280,s*1.6)):1/0);ke(e,o.label,Math.round(u.x),Math.round(u.y),o.color,y,i)}}if(r.isSelected){let f=i?.handleRadius??5,u=i?.handleFillColor??"#ffffff",w=i?.endpointHandleColor??"#4f4f4f",y=i?.controlHandleColor??"#767676",x=i?.handleStrokeWidth??2;(o.arrowStyle==="curved"||o.arrowStyle==="elbow")&&(e.save(),e.beginPath(),e.setLineDash(i?.guideLineDash?[...i.guideLineDash]:[4,4]),e.moveTo(n.x,n.y),e.lineTo(l.x,l.y),e.lineTo(a.x,a.y),e.strokeStyle=i?.guideLineColor??"rgba(100, 100, 100, 0.6)",e.lineWidth=i?.guideLineWidth??1.2,e.stroke(),e.restore(),we(e,l,y,u,f+.5,x)),we(e,n,w,u,f,x),we(e,a,w,u,f,x)}e.restore()}function Ge(e,t,o,r=11){return Math.hypot(e.x-t.end.x,e.y-t.end.y)<=r?"end":Math.hypot(e.x-t.start.x,e.y-t.start.y)<=r?"start":(o.arrowStyle==="curved"||o.arrowStyle==="elbow")&&Math.hypot(e.x-t.control.x,e.y-t.control.y)<=r?"control":null}function _e(e,t,o,r=9){let n=Math.max(r,o.strokeWidth/2+6);if(o.arrowStyle==="curved")return Qt(e,t.start,t.control,t.end)<=n;if(o.arrowStyle==="elbow"){let a={x:t.control.x,y:t.start.y},l={x:t.control.x,y:t.end.y};return xe(e,t.start,a)<=n||xe(e,a,l)<=n||xe(e,l,t.end)<=n}return xe(e,t.start,t.end)<=n}function De(e,t){return t.points.map(o=>te(e,o))}function So(e,t){if(t.length===0)return;if(e.moveTo(t[0].x,t[0].y),t.length===1){e.lineTo(t[0].x+.5,t[0].y+.5);return}if(t.length===2){e.lineTo(t[1].x,t[1].y);return}for(let r=1;r<t.length-1;r+=1){let n=(t[r].x+t[r+1].x)/2,a=(t[r].y+t[r+1].y)/2;e.quadraticCurveTo(t[r].x,t[r].y,n,a)}let o=t[t.length-1];e.lineTo(o.x,o.y)}function Wt(e,t,o,r={}){if(t.length===0)return;let n=r.theme;e.save(),r.isPreview&&(e.globalAlpha=.9),r.isSelected&&(e.save(),e.beginPath(),So(e,t),e.strokeStyle=n?.selectionGlowColor??"rgba(0, 0, 0, 0.2)",e.lineWidth=o.strokeWidth+(n?.selectionGlowWidth??6),e.lineCap="round",e.lineJoin="round",e.stroke(),e.restore()),e.save(),e.shadowColor=n?.shadowColor??"rgba(0, 0, 0, 0.2)",e.shadowBlur=n?.shadowBlur??3,e.shadowOffsetY=n?.shadowOffsetY??1,e.beginPath(),So(e,t),e.strokeStyle=o.color,e.lineWidth=o.strokeWidth,e.lineCap="round",e.lineJoin="round",o.dashed?e.setLineDash([o.strokeWidth*3,o.strokeWidth*2]):e.setLineDash([]),e.stroke(),e.restore(),e.restore()}function Ue(e,t,o,r=9){if(t.length===0)return!1;let n=Math.max(r,o.strokeWidth/2+6);if(t.length===1)return Math.hypot(e.x-t[0].x,e.y-t[0].y)<=n;let a=1/0,l=1/0,s=-1/0,i=-1/0;for(let d=0;d<t.length;d+=1){let c=t[d];c.x<a&&(a=c.x),c.y<l&&(l=c.y),c.x>s&&(s=c.x),c.y>i&&(i=c.y)}if(e.x<a-n||e.x>s+n||e.y<l-n||e.y>i+n)return!1;for(let d=0;d<t.length-1;d+=1)if(xe(e,t[d],t[d+1])<=n)return!0;return!1}function Ht(e,t,o,r){let{minX:n,minY:a,maxX:l,maxY:s,width:i,height:d,cx:c,cy:p}=t;if(o==="square"){let b=r?.shapeBorderRadius??0;b>0&&typeof e.roundRect=="function"?e.roundRect(n,a,i,d,b):e.rect(n,a,i,d);return}if(o==="circle"){e.ellipse(c,p,i/2,d/2,0,0,Math.PI*2);return}if(o==="triangle"){e.moveTo(c,a),e.lineTo(l,s),e.lineTo(n,s),e.closePath();return}if(o==="diamond"){e.moveTo(c,a),e.lineTo(l,p),e.lineTo(c,s),e.lineTo(n,p),e.closePath();return}if(o==="hexagon"){let b=i/2,g=d/2;for(let f=0;f<6;f+=1){let u=Math.PI/3*f-Math.PI/6,w=c+b*Math.cos(u),y=p+g*Math.sin(u);f===0?e.moveTo(w,y):e.lineTo(w,y)}e.closePath();return}if(o==="star"){let g=i/2,f=d/2,u=g*.42,w=f*.42;for(let y=0;y<10;y+=1){let x=y%2===0?g:u,h=y%2===0?f:w,T=y*Math.PI/5-Math.PI/2,v=c+x*Math.cos(T),E=p+h*Math.sin(T);y===0?e.moveTo(v,E):e.lineTo(v,E)}e.closePath();return}if(o==="marker"||o==="cloud"){let b=i/2,g=d*.36,f=a+g;e.moveTo(c,s),e.bezierCurveTo(n+i*.05,a+d*.7,n,a+d*.5,n,f),e.ellipse(c,f,b,g,0,Math.PI,0,!1),e.bezierCurveTo(l,a+d*.5,l-i*.05,a+d*.7,c,s),e.closePath();let u=b*.35,w=g*.35;u>=2.5&&w>=2.5&&(e.moveTo(c+u,f),e.ellipse(c,f,u,w,0,Math.PI*2,0,!0),e.closePath());return}if(o==="actor"){let b=Math.min(i,d)*.16,g=a+b+d*.04,f=g+b,u=a+d*.64,w=a+d*.42,y=i*.36,x=i*.32;e.moveTo(c+b,g),e.arc(c,g,b,0,Math.PI*2),e.closePath(),e.moveTo(c,f),e.lineTo(c,u),e.moveTo(c-y,w),e.lineTo(c+y,w),e.moveTo(c,u),e.lineTo(c-x,s),e.moveTo(c,u),e.lineTo(c+x,s)}}function pe(e,t){let o=te(e,t.start),r=te(e,t.end),n=Math.min(o.x,r.x),a=Math.min(o.y,r.y),l=Math.max(o.x,r.x),s=Math.max(o.y,r.y),i=Math.max(4,l-n),d=Math.max(4,s-a);return{start:o,end:r,minX:n,minY:a,maxX:l,maxY:s,width:i,height:d,cx:n+i/2,cy:a+d/2}}function jt(e,t,o,r={}){if(t.width<4&&t.height<4)return;let n=r.theme;if(e.save(),r.isPreview&&(e.globalAlpha=.85),r.isSelected&&(e.save(),e.beginPath(),Ht(e,t,o.shape,n),e.strokeStyle=n?.selectionGlowColor??"rgba(0, 0, 0, 0.2)",e.lineWidth=o.strokeWidth+(n?.selectionGlowWidth??6),e.lineCap="round",e.lineJoin="round",e.stroke(),e.restore()),e.save(),e.shadowColor=n?.shadowColor??"rgba(0, 0, 0, 0.2)",e.shadowBlur=n?.shadowBlur??3,e.shadowOffsetY=n?.shadowOffsetY??1.5,e.beginPath(),Ht(e,t,o.shape,n),o.filled){let a=n?.shapeDefaultFillOpacity??.16,l=Math.round(Math.min(1,Math.max(0,a))*255).toString(16).padStart(2,"0");e.fillStyle=o.fillColor??`${o.color}${l}`,e.fill()}if(e.strokeStyle=o.color,e.lineWidth=o.strokeWidth,e.lineCap="round",e.lineJoin="round",e.setLineDash(o.dashed?[o.strokeWidth*3,o.strokeWidth*2]:[]),e.stroke(),e.restore(),o.label){let a=typeof n?.labelMinShapeSize=="number"?n.labelMinShapeSize:18;if(a<=0||Math.max(t.width,t.height)>=a&&t.width>=8&&t.height>=8){let l=o.shape==="actor"?t.maxY+14:t.cy,s=n?.fitLabelsToShape!==!1,i=n?.labelMaxTextWidth??(s?Math.max(48,Math.min(280,t.width*2.2)):1/0);ke(e,o.label,Math.round(t.cx),Math.round(l),o.color,i,n)}}if(r.isSelected){let a=n?.handleRadius??5,l=n?.handleFillColor??"#ffffff",s=n?.endpointHandleColor??"#4f4f4f",i=n?.handleStrokeWidth??2;e.save(),e.setLineDash(n?.guideLineDash?[...n.guideLineDash]:[4,4]),e.strokeStyle=n?.guideLineColor??"rgba(100, 100, 100, 0.6)",e.lineWidth=n?.guideLineWidth??1.2,e.strokeRect(t.minX,t.minY,t.width,t.height),e.restore(),we(e,t.start,s,l,a,i),we(e,t.end,s,l,a,i)}e.restore()}function Ye(e,t,o=11){return Math.hypot(e.x-t.end.x,e.y-t.end.y)<=o?"end":Math.hypot(e.x-t.start.x,e.y-t.start.y)<=o?"start":null}function Ae(e,t,o=8){return e.x>=t.minX-o&&e.x<=t.maxX+o&&e.y>=t.minY-o&&e.y<=t.maxY+o}function be(e,t){let o=te(e,t.start),r=te(e,t.end),n={x:(o.x+r.x)/2,y:(o.y+r.y)/2},a=Math.hypot(r.x-o.x,r.y-o.y),l=Math.atan2(r.y-o.y,r.x-o.x);return{start:o,end:r,mid:n,lengthPx:a,angle:l}}function Ft(e,t,o,r={}){let{start:n,end:a,mid:l,lengthPx:s,angle:i}=t;if(s<2)return;let d=r.theme;e.save(),r.isPreview&&(e.globalAlpha=.9),r.isSelected&&(e.save(),e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(a.x,a.y),e.strokeStyle=d?.selectionGlowColor??"rgba(0, 0, 0, 0.2)",e.lineWidth=o.strokeWidth+(d?.selectionGlowWidth??6),e.lineCap="round",e.stroke(),e.restore()),e.save(),e.shadowColor=d?.shadowColor??"rgba(0, 0, 0, 0.2)",e.shadowBlur=d?.shadowBlur??3,e.shadowOffsetY=d?.shadowOffsetY??1.5,e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(a.x,a.y),e.strokeStyle=o.color,e.lineWidth=o.strokeWidth,e.lineCap="round",o.dashed?e.setLineDash([o.strokeWidth*3,o.strokeWidth*2]):e.setLineDash([]),e.stroke();let c=i+Math.PI/2,p=Math.max(7,o.strokeWidth*3.2),b=Math.cos(c)*p,g=Math.sin(c)*p;e.beginPath(),e.setLineDash([]),e.moveTo(n.x-b,n.y-g),e.lineTo(n.x+b,n.y+g),e.moveTo(a.x-b,a.y-g),e.lineTo(a.x+b,a.y+g),e.stroke(),e.restore();let f=At(o.start,o.end),u=o.label?o.label:oo(f,o.unit);if(u){let w=d?.fitLabelsToShape!==!1,y=d?.labelMaxTextWidth??(w?Math.max(50,Math.min(300,s*1.5)):1/0);ke(e,u,Math.round(l.x),Math.round(l.y),o.color,y,d)}if(r.isSelected){let w=d?.handleRadius??5,y=d?.handleFillColor??"#ffffff",x=d?.endpointHandleColor??"#4f4f4f",h=d?.handleStrokeWidth??2;we(e,n,x,y,w,h),we(e,a,x,y,w,h)}e.restore()}function Ke(e,t,o=11){return Math.hypot(e.x-t.end.x,e.y-t.end.y)<=o?"end":Math.hypot(e.x-t.start.x,e.y-t.start.y)<=o?"start":null}function Xe(e,t,o,r=9){let n=Math.max(r,o.strokeWidth/2+6);return xe(e,t.start,t.end)<=n}function Hn(e){let t=ue.find(r=>r.bg===e);if(t)return t;let o=e?.startsWith("#")&&e.length===7&&parseInt(e.slice(1),16)<8947848||e==="#111827"||e==="#1e293b"||e==="#0f172a";return{name:"Custom",bg:e,border:o?"rgba(255, 255, 255, 0.16)":"rgba(0, 0, 0, 0.12)",header:o?"rgba(255, 255, 255, 0.08)":"rgba(0, 0, 0, 0.06)",text:o?"#f8fafc":"#0f172a"}}function jn(e,t,o,r,n,a=!0){let l=a!==!1?Le(e):null;if(!l||n||!(t.x>=-120&&t.x<=l.width+120&&t.y>=-120&&t.y<=l.height+120))return t;let i=r?95:o.width??230,d=r?22:o.height??100,c=8,p=16+c,b=Math.max(p,l.width-i+16-c),g=12+c,f=Math.max(g,l.height-d+12-c);return{x:Math.max(p,Math.min(b,t.x)),y:Math.max(g,Math.min(f,t.y))}}function Fn(e,t,o,r,n,a,l=!0){let s=l!==!1?Le(e):null;if(!s||a||!(t.x>=-100&&t.x<=s.width+100&&t.y>=-100&&t.y<=s.height+100))return t;let d=n?35:Math.max(24,(o.text||"Text").length*r/3.6),c=n?11:r/2+4,p=8,b=d+p,g=Math.max(b,s.width-d-p),f=c+p,u=Math.max(f,s.height-c-p);return{x:Math.max(b,Math.min(g,t.x)),y:Math.max(f,Math.min(u,t.y))}}function $e(e,t,o,r,n,a,l,s,i,d,c,p){s.current={screenPoints:[o],geoPoints:[r]},e.dragging.disable(),d();let b=f=>{if(!s.current)return;let u=t.getBoundingClientRect(),w={x:f.clientX-u.left,y:f.clientY-u.top},y=s.current.screenPoints,x=y[y.length-1];Math.hypot(w.x-x.x,w.y-x.y)<2.5||(y.push(w),s.current.geoPoints.push(X(e,w)),i.current===null&&(i.current=window.requestAnimationFrame(()=>{i.current=null,d()})))},g=f=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",g),e.dragging.enable(),i.current!==null&&(window.cancelAnimationFrame(i.current),i.current=null);let u=s.current;s.current=null,u&&u.geoPoints.length>=1?(c({id:Pe("freedraw"),type:"freedraw",points:u.geoPoints,color:n,strokeWidth:a,dashed:l,createdAt:Date.now()}),f.shiftKey||p("select")):d()};window.addEventListener("pointermove",b),window.addEventListener("pointerup",g)}function dt(e,t,o="Field Note"){let r=ue.find(n=>n.bg===t)??ue[0];return{id:Pe("note"),type:"note",position:e,title:o,text:"",backgroundColor:r.bg,textColor:r.text,width:230,createdAt:Date.now()}}function ct(e,t,o,r,n){return{id:Pe("text"),type:"text",position:e,text:"",color:t,initialFontSize:o,baseZoom:n,fontWeight:r,createdAt:Date.now()}}function pt(e,t,o,r,n,a,l,s,i,d,c,p){d({shape:n,startGeo:r,currentGeo:r}),e.dragging.disable();let b=f=>{let u=t.getBoundingClientRect(),w={x:f.clientX-u.left,y:f.clientY-u.top},y=f.shiftKey?ze(o,w,1):w;d({shape:n,startGeo:r,currentGeo:X(e,y)})},g=f=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",g),e.dragging.enable();let u=t.getBoundingClientRect(),w={x:f.clientX-u.left,y:f.clientY-u.top},y=f.shiftKey?ze(o,w,1):w,x=Math.hypot(w.x-o.x,w.y-o.y),h=x>=10?r:X(e,{x:o.x-45,y:o.y-45}),T=x>=10?X(e,y):X(e,{x:o.x+45,y:o.y+45});c({id:Pe("shape"),type:"shape",shape:n,start:h,end:T,color:a,filled:l,strokeWidth:s,dashed:i,createdAt:Date.now()}),d(null),p("select")};window.addEventListener("pointermove",b),window.addEventListener("pointerup",g)}function Ve(e,t,o,r,n,a){return{id:Pe("arrow"),type:"arrow",arrowStyle:e,start:t,end:o,controlPoint:e==="curved"?lt(t,o):e==="elbow"?{lat:(t.lat+o.lat)/2,lng:(t.lng+o.lng)/2}:void 0,color:r,strokeWidth:n,dashed:a,headStyle:e==="bi"?"both":"triangle",createdAt:Date.now()}}function ut(e,t,o,r,n,a,l,s,i,d,c){i({arrowStyle:n,startGeo:r,currentGeo:r}),e.dragging.disable();let p=g=>{let f=t.getBoundingClientRect(),u={x:g.clientX-f.left,y:g.clientY-f.top},w=g.shiftKey?se(o,u):u;i({arrowStyle:n,startGeo:r,currentGeo:X(e,w)})},b=g=>{window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",b),e.dragging.enable();let f=t.getBoundingClientRect(),u={x:g.clientX-f.left,y:g.clientY-f.top},w=g.shiftKey?se(o,u):u;Math.hypot(u.x-o.x,u.y-o.y)>=8&&(d(Ve(n,r,X(e,w),a,l,s)),i(null),c("select"))};window.addEventListener("pointermove",p),window.addEventListener("pointerup",b)}function vo(e,t,o,r,n){return{id:Pe("ruler"),type:"ruler",start:e,end:t,color:o,strokeWidth:r,dashed:n,unit:"metric",createdAt:Date.now()}}function ft(e,t,o,r,n,a,l,s,i,d){s({startGeo:r,currentGeo:r}),e.dragging.disable();let c=b=>{let g=t.getBoundingClientRect(),f={x:b.clientX-g.left,y:b.clientY-g.top},u=b.shiftKey?se(o,f):f;s({startGeo:r,currentGeo:X(e,u)})},p=b=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",p),e.dragging.enable();let g=t.getBoundingClientRect(),f={x:b.clientX-g.left,y:b.clientY-g.top},u=b.shiftKey?se(o,f):f;Math.hypot(f.x-o.x,f.y-o.y)>=8&&(i(vo(r,X(e,u),n,a,l)),s(null),d("select"))};window.addEventListener("pointermove",c),window.addEventListener("pointerup",p)}function Oe(e,t){e.dragging.disable();let o=()=>{e.dragging.enable(),window.removeEventListener("pointermove",t),window.removeEventListener("pointerup",o)};window.addEventListener("pointermove",t),window.addEventListener("pointerup",o)}function ht(e,t,o,r,n,a){Oe(e,l=>{let s=n(l),i=l.shiftKey;if(r==="start"){let d=i?se(o.end,s):s;a(t.id,{start:X(e,d)})}else if(r==="end"){let d=i?se(o.start,s):s;a(t.id,{end:X(e,d)})}else r==="control"&&a(t.id,{controlPoint:X(e,s)})})}function mt(e,t,o,r,n,a){let l=r==="start"?o.end:o.start,s=o.width>4&&o.height>4?o.width/o.height:1;Oe(e,i=>{let d=n(i),c=i.shiftKey?ze(l,d,s):d,p=X(e,c);a(t.id,r==="start"?{start:p}:{end:p})})}function gt(e,t,o,r,n,a){let l=o.start,s=o.end,i=o.control,d=!!t.controlPoint;Oe(e,c=>{let p=n(c),b=p.x-r.x,g=p.y-r.y,f={start:X(e,{x:l.x+b,y:l.y+g}),end:X(e,{x:s.x+b,y:s.y+g})};(t.arrowStyle==="curved"||t.arrowStyle==="elbow")&&d&&(f.controlPoint=X(e,{x:i.x+b,y:i.y+g})),a(t.id,f)})}function bt(e,t,o,r,n,a){let l=o.start,s=o.end;Oe(e,i=>{let d=n(i),c=d.x-r.x,p=d.y-r.y;a(t.id,{start:X(e,{x:l.x+c,y:l.y+p}),end:X(e,{x:s.x+c,y:s.y+p})})})}function yt(e,t,o,r,n,a){Oe(e,l=>{let s=n(l),i=s.x-r.x,d=s.y-r.y;a(t.id,{points:o.map(c=>X(e,{x:c.x+i,y:c.y+d}))})})}function xt(e,t,o,r,n,a){Oe(e,l=>{let s=n(l),i=l.shiftKey;if(r==="start"){let d=i?se(o.end,s):s;a(t.id,{start:X(e,d)})}else if(r==="end"){let d=i?se(o.start,s):s;a(t.id,{end:X(e,d)})}})}function wt(e,t,o,r,n,a){let l=o.start,s=o.end;Oe(e,i=>{let d=n(i),c=d.x-r.x,p=d.y-r.y;a(t.id,{start:X(e,{x:l.x+c,y:l.y+p}),end:X(e,{x:s.x+c,y:s.y+p})})})}function Tt({map:e,canvas:t,width:o,height:r,arrowItems:n,shapeItems:a,freeDrawItems:l,rulerItems:s,selectedId:i,draftShape:d,draftArrow:c,draftRuler:p,draftFreeDraw:b,activeColor:g,strokeWidth:f,dashed:u,shapeFilled:w,annotationTheme:y,arrowTheme:x,isReadOnly:h}){if(!e||!t||o===0||r===0)return;let T=y??x,v=typeof window<"u"&&window.devicePixelRatio||1,E=Math.round(o*v),k=Math.round(r*v);t.width!==E&&(t.width=E),t.height!==k&&(t.height=k);let I=t.getContext("2d");if(I){I.save(),typeof I.scale=="function"&&I.scale(v,v),I.clearRect(0,0,o,r);for(let m of l){let S=De(e,m);Wt(I,S,m,{isSelected:!h&&m.id===i,theme:T})}for(let m of a){let S=pe(e,m);jt(I,S,m,{isSelected:!h&&m.id===i,theme:T})}for(let m of n){let S=ge(e,m);Bt(I,S,m,{isSelected:!h&&m.id===i,theme:T})}for(let m of s){let S=be(e,m);Ft(I,S,m,{isSelected:!h&&m.id===i,theme:T})}if(!h&&b&&b.screenPoints.length>0&&Wt(I,b.screenPoints,{color:g,strokeWidth:f,dashed:u},{isPreview:!0,theme:T}),!h&&d){let m={id:"draft-shape",type:"shape",shape:d.shape,start:d.startGeo,end:d.currentGeo,color:g,filled:w,strokeWidth:f,dashed:u,createdAt:0},S=pe(e,m);jt(I,S,m,{isPreview:!0,isSelected:!0,theme:T})}if(!h&&c){let m={id:"draft-arrow",type:"arrow",arrowStyle:c.arrowStyle,start:c.startGeo,end:c.currentGeo,color:g,strokeWidth:f,dashed:u,createdAt:0},S=ge(e,m);Bt(I,S,m,{isPreview:!0,isSelected:!0,theme:T})}if(!h&&p){let m={id:"draft-ruler",type:"ruler",start:p.startGeo,end:p.currentGeo,color:g,strokeWidth:f,dashed:u,unit:"metric",createdAt:0},S=be(e,m);Ft(I,S,m,{isPreview:!0,isSelected:!0,theme:T})}I.restore()}}function St(e,t){let o=()=>{let r=e.getSize();t({width:r.x,height:r.y})};return o(),e.on("move",o),e.on("zoom",o),e.on("zoomanim",o),e.on("viewreset",o),e.on("resize",o),()=>{e.off("move",o),e.off("zoom",o),e.off("zoomanim",o),e.off("viewreset",o),e.off("resize",o)}}function vt(e){let t=e.getContainer();if(!t)return()=>{};let o=n=>{let a=n.target;if(!a?.closest?.("[data-tual-overlay], input, textarea, select, button, .rlc-overlay"))return;let l=Object.prototype.hasOwnProperty.call(a,"_leaflet_disable_events"),s=a._leaflet_disable_events;a._leaflet_disable_events=!0;let i=!!e.doubleClickZoom?.enabled?.();i&&e.doubleClickZoom.disable(),setTimeout(()=>{l?a._leaflet_disable_events=s:delete a._leaflet_disable_events,i&&e.doubleClickZoom.enable()},0)},r=n=>{if(n.target?.closest?.("textarea, input, select, button, [data-tual-note-resize], .rlc-note-resize-handle")&&e.dragging?.enabled?.()){e.dragging.disable();let l=()=>{e.dragging.enable(),window.removeEventListener("mouseup",l,!0),window.removeEventListener("touchend",l,!0),window.removeEventListener("pointerup",l,!0)};window.addEventListener("mouseup",l,{capture:!0,once:!0}),window.addEventListener("touchend",l,{capture:!0,once:!0}),window.addEventListener("pointerup",l,{capture:!0,once:!0})}};return t.addEventListener("dblclick",o,!0),t.addEventListener("mousedown",r,!0),t.addEventListener("touchstart",r,!0),()=>{t.removeEventListener("dblclick",o,!0),t.removeEventListener("mousedown",r,!0),t.removeEventListener("touchstart",r,!0)}}function no(e={}){let t=Math.max(0,(e.maxHistory??50)-1),o=[],r=e.items??e.initialItems??[],n=[],a=r,l=e.initialTool??"select",s=!!(e.readOnly??!1),i=null,d=!1,c=e.defaultShape??"square",p=!0,b=e.defaultColor??nt,g=e.defaultStrokeWidth??rt,f=!1,u=e.defaultNoteColor??at,w=e.defaultFontSize??it,y="bold",x=new Set,h=()=>{for(let L of x)L(U)},T=L=>{e.onItemsChange?.(L),e.onChange?.(L)},v=(L,O)=>{e.onItemsChangeComplete?.(L,O),e.onChangeComplete?.(L,O),e.onEditEnd?.(L,O),e.onEditComplete?.(L,O),O&&e.onItemChangeComplete?.(O)},E=L=>{let O=L(r);return r=O,T(O),h(),O},k=L=>{if(r===a)return;let O=a;a=r,o=[...o,O].slice(-t),n=[],v(r,L),h()},I=L=>{if(i!==L){let O=i;i=L,d=!1,O!==null&&L===null&&k(),e.onItemSelect?.(r.find(Y=>Y.id===L)??null),h()}},m=L=>{s&&L!=="select"||(l=L,e.onToolChange?.(L),h())},S=L=>{s=!!L,s&&l!=="select"&&(l="select"),h()},R=(L,O)=>{i&&E(Y=>Y.map(ne=>ne.id===i&&L(ne)?O(ne):ne))},B=L=>{s||(c=L,R(O=>O.type==="shape",O=>({...O,shape:L})),h())},F=L=>{s||(p=L,R(O=>O.type==="shape",O=>({...O,filled:L})),h())},G=L=>{s||(b=L,R(O=>O.type!=="note",O=>({...O,color:L})),h())},$=L=>{s||(g=L,R(O=>O.type==="arrow"||O.type==="freedraw"||O.type==="shape"||O.type==="ruler",O=>({...O,strokeWidth:L})),h())},V=L=>{s||(f=L,R(O=>O.type==="arrow"||O.type==="freedraw"||O.type==="shape"||O.type==="ruler",O=>({...O,dashed:L})),h())},C=L=>{if(s)return;u=L;let O=ue.find(Y=>Y.bg===L);R(Y=>Y.type==="note",Y=>({...Y,backgroundColor:L,textColor:O?.text??Y.textColor})),h()},A=L=>{s||(w=L,R(O=>O.type==="text",O=>({...O,initialFontSize:L})),h())},D=L=>{s||(y=L,R(O=>O.type==="text",O=>({...O,fontWeight:L})),h())},P=L=>{d=L,h()},N=L=>{s||(E(O=>[...O,L]),I(L.id),e.onItemCreate?.(L))},_=(L,O)=>{if(s){let ne=Object.keys(O);if(ne.length!==1||ne[0]!=="minimized")return}let Y;E(ne=>ne.map(W=>W.id===L?(Y={...W,...O},Y):W)),Y&&e.onItemChange?.(Y)},H=L=>{s||(E(O=>O.filter(Y=>Y.id!==L)),i===L&&I(null),e.onItemDelete?.(L),k())},K=()=>{!s&&i&&H(i)},Z=()=>{s||(E(()=>[]),I(null),k())},U={get items(){return r},get activeTool(){return l},setActiveTool:m,get readOnly(){return s},setReadOnly:S,get activeShape(){return c},setActiveShape:B,get shapeFilled(){return p},setShapeFilled:F,get selectedId(){return i},setSelectedId:I,get selectedItem(){return r.find(L=>L.id===i)??null},get isEditingLabel(){return d},setEditingLabel:P,get labelEditMode(){return d},setLabelEditMode:P,get activeColor(){return b},setActiveColor:G,get strokeWidth(){return g},setStrokeWidth:$,get dashed(){return f},setDashed:V,get noteColor(){return u},setNoteColor:C,get fontSize(){return w},setFontSize:A,get fontWeight(){return y},setFontWeight:D,addItem:N,updateItem:_,removeItem:H,deleteSelected:K,clearAll:Z,clear:Z,deleteItem:H,setTool:m,selectItem:I,undo:()=>{if(s||o.length===0)return;let L=o[o.length-1];n=[r,...n],o=o.slice(0,-1),r=L,a=L,T(L),v(L,null),h()},redo:()=>{if(s||n.length===0)return;let L=n[0];o=[...o,r],n=n.slice(1),r=L,a=L,T(L),v(L,null),h()},get canUndo(){return!s&&o.length>0},get canRedo(){return!s&&n.length>0},notifyChangeComplete:k,exportJSON:()=>JSON.stringify(r,null,2),importJSON:L=>{if(s)return!1;try{let O=JSON.parse(L);return Array.isArray(O)?(E(()=>O),I(null),k(),!0):!1}catch{return!1}},subscribe(L){return x.add(L),()=>{x.delete(L)}},getState(){return U},destroy(){x.clear()}};return U}function zn(e,t={}){let{controller:o,annotationTheme:r,arrowTheme:n,labels:a,zIndex:l=650,...s}=t,i=o??no(s),d=e.getContainer(),c=document.createElement("div");c.setAttribute("data-tual-overlay","true"),c.style.position="absolute",c.style.inset="0",c.style.pointerEvents="none",c.style.zIndex=String(l),c.style.overflow="hidden";let p=document.createElement("canvas");p.style.position="absolute",p.style.top="0",p.style.left="0",p.style.pointerEvents="none";let b=document.createElement("div");b.style.position="absolute",b.style.inset="0",b.style.pointerEvents="none",c.appendChild(p),c.appendChild(b),d.appendChild(c);let g={width:0,height:0},f=null,u=null,w=null,y={current:null},x={current:null},h=C=>{f=C,I()},T=C=>{u=C,I()},v=C=>{w=C,I()},E=()=>{y.current=null,x.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(x.current),x.current=null)},k=()=>{let C=!i.readOnly&&i.activeTool!=="select";b.style.pointerEvents=C?"auto":"none",b.style.cursor=C?"crosshair":"default",p.style.width=`${g.width}px`,p.style.height=`${g.height}px`},I=()=>{k();let C=i.items;Tt({map:e,canvas:p,width:g.width,height:g.height,arrowItems:C.filter(A=>A.type==="arrow"),shapeItems:C.filter(A=>A.type==="shape"),freeDrawItems:C.filter(A=>A.type==="freedraw"),rulerItems:C.filter(A=>A.type==="ruler"),selectedId:i.selectedId,draftShape:u,draftArrow:f,draftRuler:w,draftFreeDraw:y.current,activeColor:i.activeColor,strokeWidth:i.strokeWidth,dashed:i.dashed,shapeFilled:i.shapeFilled,annotationTheme:r,arrowTheme:n,isReadOnly:i.readOnly})},m=C=>{let A=d.getBoundingClientRect();return{x:C.clientX-A.left,y:C.clientY-A.top}},S=C=>{if(C.button!==0||i.readOnly)return;C.stopPropagation(),C.preventDefault();let A=m(C),D=X(e,A),{activeTool:P,activeShape:N,shapeFilled:_,activeColor:H,strokeWidth:K,dashed:Z,noteColor:q,fontSize:de,fontWeight:ce}=i;if(P==="freedraw"){$e(e,d,A,D,H,K,Z,y,x,I,i.addItem,i.setActiveTool);return}if(P==="shape"){pt(e,d,A,D,N,H,_,K,Z,T,i.addItem,i.setActiveTool);return}if(P==="note"){i.addItem(dt(D,q,a?.noteDefaultTitle??"Field Note")),i.setActiveTool("select");return}if(P==="text"){i.addItem(ct(D,H,de,ce,e.getZoom?.()??14)),i.setActiveTool("select");return}if(P==="ruler"){ft(e,d,A,D,H,K,Z,v,i.addItem,i.setActiveTool);return}let j=Fe[P];if(j)if(!f)ut(e,d,A,D,j,H,K,Z,h,i.addItem,i.setActiveTool);else{let U=te(e,f.startGeo),L=C.shiftKey?se(U,A):A;Math.hypot(L.x-U.x,L.y-U.y)>=4&&i.addItem(Ve(f.arrowStyle,f.startGeo,X(e,L),H,K,Z)),h(null),i.setActiveTool("select")}},R=C=>{if(!f)return;let A=m(C),D=te(e,f.startGeo),P=C.shiftKey?se(D,A):A;h({...f,currentGeo:X(e,P)})},B=C=>{if(C.button!==0||i.readOnly||i.activeTool!=="select"||C.target?.closest("[data-tual-toolbar], [data-tual-note], [data-tual-text], .leaflet-control"))return;let D=m(C),P=i.items,N=P.filter(j=>j.type==="arrow"),_=P.filter(j=>j.type==="shape"),H=P.filter(j=>j.type==="freedraw"),K=P.filter(j=>j.type==="ruler"),Z=i.selectedId,q=N.find(j=>j.id===Z);if(q){let j=ge(e,q),U=Ge(D,j,q);if(U){C.stopPropagation(),C.preventDefault(),ht(e,q,j,U,m,i.updateItem);return}}let de=_.find(j=>j.id===Z);if(de){let j=pe(e,de),U=Ye(D,j);if(U){C.stopPropagation(),C.preventDefault(),mt(e,de,j,U,m,i.updateItem);return}}let ce=K.find(j=>j.id===Z);if(ce){let j=be(e,ce),U=Ke(D,j);if(U){C.stopPropagation(),C.preventDefault(),xt(e,ce,j,U,m,i.updateItem);return}}for(let j=N.length-1;j>=0;j-=1){let U=N[j],L=ge(e,U);if(_e(D,L,U)){C.stopPropagation(),C.preventDefault(),i.setSelectedId(U.id),gt(e,U,L,D,m,i.updateItem);return}}for(let j=_.length-1;j>=0;j-=1){let U=_[j],L=pe(e,U);if(Ae(D,L)){C.stopPropagation(),C.preventDefault(),i.setSelectedId(U.id),bt(e,U,L,D,m,i.updateItem);return}}for(let j=H.length-1;j>=0;j-=1){let U=H[j],L=De(e,U);if(Ue(D,L,U)){C.stopPropagation(),C.preventDefault(),i.setSelectedId(U.id),yt(e,U,L,D,m,i.updateItem);return}}for(let j=K.length-1;j>=0;j-=1){let U=K[j],L=be(e,U);if(Xe(D,L,U)){C.stopPropagation(),C.preventDefault(),i.setSelectedId(U.id),wt(e,U,L,D,m,i.updateItem);return}}Z&&(i.setSelectedId(null),i.notifyChangeComplete())},F=C=>{if(i.readOnly)return;let A=C.target;A&&(A.tagName==="INPUT"||A.tagName==="TEXTAREA"||A.isContentEditable)||(C.key==="Escape"?(f=null,u=null,w=null,E(),i.setSelectedId(null),i.setActiveTool("select"),i.notifyChangeComplete(),I()):(C.key==="Delete"||C.key==="Backspace")&&i.selectedId&&(C.preventDefault(),i.deleteSelected()))};b.addEventListener("pointerdown",S),b.addEventListener("pointermove",R),d.addEventListener("pointerdown",B,{capture:!0}),typeof window<"u"&&window.addEventListener("keydown",F);let G=St(e,C=>{g=C,I()}),$=vt(e),V=i.subscribe(()=>{I()});return I(),{controller:i,container:c,canvas:p,repaint:I,destroy(){b.removeEventListener("pointerdown",S),b.removeEventListener("pointermove",R),d.removeEventListener("pointerdown",B,{capture:!0}),typeof window<"u"&&window.removeEventListener("keydown",F),E(),G(),$(),V(),o||i.destroy(),c.remove()}}}var Gn=wo.version;var Ze=require("react");var ro=require("react/jsx-runtime");function ao({shape:e,map:t,labels:o,onUpdate:r,onClose:n}){let[a,l]=(0,Ze.useState)(e.label??""),s=(0,Ze.useRef)(null);(0,Ze.useEffect)(()=>{s.current?.focus(),s.current?.select()},[]);let i=pe(t,e),d=Math.round(i.cx),c=Math.round(e.shape==="actor"?i.maxY+14:i.cy);return(0,ro.jsx)("div",{"data-tual-inline-shape-label":!0,style:{position:"absolute",left:`${d}px`,top:`${c}px`,transform:"translate(-50%, -50%)",zIndex:1e3,pointerEvents:"auto"},onClick:p=>p.stopPropagation(),onPointerDown:p=>p.stopPropagation(),children:(0,ro.jsx)("input",{ref:s,type:"text","data-tual-shape-label-input":e.id,"data-testid":"inline-shape-label-input","data-label-mode":"true",placeholder:o?.shapeLabelPlaceholder??"Shape label...",value:a,onChange:p=>{l(p.target.value),r(e.id,{label:p.target.value})},onBlur:n,onKeyDown:p=>{(p.key==="Enter"||p.key==="Escape")&&(p.preventDefault(),n())},style:{minWidth:"100px",padding:"2px 6px",borderRadius:"4px",border:"1px solid #2563eb",backgroundColor:"#ffffff",color:"#000000",fontSize:"12px",boxShadow:"0 2px 6px rgba(0, 0, 0, 0.25)",outline:"none"}})})}var Se=je(require("react"),1);function Co(e){let t=ue.find(r=>r.bg===e);if(t)return t;let o=e?.startsWith("#")&&e.length===7&&parseInt(e.slice(1),16)<8947848||e==="#111827"||e==="#1e293b"||e==="#0f172a";return{name:"Custom",bg:e,border:o?"rgba(255, 255, 255, 0.16)":"rgba(0, 0, 0, 0.12)",header:o?"rgba(255, 255, 255, 0.08)":"rgba(0, 0, 0, 0.06)",text:o?"#f8fafc":"#0f172a"}}function Po(e,t,o,r,n,a=!0){let l=a!==!1?Le(e):null;if(!l||n||!(t.x>=-120&&t.x<=l.width+120&&t.y>=-120&&t.y<=l.height+120))return t;let i=r?95:o.width??230,d=r?22:o.height??100,c=8,p=16+c,b=Math.max(p,l.width-i+16-c),g=12+c,f=Math.max(g,l.height-d+12-c);return{x:Math.max(p,Math.min(b,t.x)),y:Math.max(g,Math.min(f,t.y))}}function Lo(e,t,o,r,n,a,l){return l?{transform:"translate(-16px, -12px)"}:o?{transform:"translate(-16px, -12px)",width:"auto",minWidth:"24px",maxWidth:"130px",height:"22px",boxSizing:"border-box",backgroundColor:e.backgroundColor,color:e.textColor||t.text,border:`1px solid ${!n&&r?"#4b5563":t.border}`,borderRadius:"9999px",overflow:"hidden",boxShadow:!n&&r?"0 2px 6px rgba(0, 0, 0, 0.25)":"0 1px 3px rgba(0, 0, 0, 0.12)",fontFamily:"Inter, system-ui, -apple-system, sans-serif",display:"inline-flex",alignItems:"center",padding:"0 8px",gap:"4px",cursor:n?"default":a?"grabbing":"grab",transition:"none"}:{transform:"translate(-16px, -12px)",width:`${e.width??230}px`,boxSizing:"border-box",backgroundColor:e.backgroundColor,color:e.textColor||t.text,border:`1px solid ${!n&&r?"#4b5563":t.border}`,borderRadius:"2px",overflow:"hidden",boxShadow:!n&&r?"0 2px 6px rgba(0, 0, 0, 0.2)":"0 1px 3px rgba(0, 0, 0, 0.12)",fontFamily:"Inter, system-ui, -apple-system, sans-serif",transition:"none"}}var Ie=require("react");function Io(e){let{e:t,item:o,map:r,cardRef:n,textareaRef:a,onSelect:l,onUpdate:s,onComplete:i}=e;t.stopPropagation(),t.preventDefault(),l(o.id),n.current&&(n.current.style.transition="none",n.current.setAttribute("data-resizing","true"));let d=t.currentTarget,c=t.pointerId;try{d?.setPointerCapture?.(c)}catch{}let p=t.clientX,b=t.clientY,g=o.width??230,f=o.height??a.current?.offsetHeight??62;r.dragging.disable();let u=null,w=g,y=f,x=!1,h=typeof process<"u"&&process.env?.NODE_ENV==="test",T=()=>{u=null;let k={width:w};(x||o.height!==void 0)&&(k.height=y),s(o.id,k)},v=k=>{let I=k.clientX-p,m=k.clientY-b;w=Math.max(160,Math.min(600,Math.round(g+I))),y=Math.max(50,Math.min(800,Math.round(f+m))),m!==0&&(x=!0),n.current&&(n.current.style.width=`${w}px`),a.current&&(x||o.height!==void 0)&&(a.current.style.height=`${y}px`),h?T():u===null&&(u=requestAnimationFrame(T))},E=()=>{u!==null&&cancelAnimationFrame(u),n.current&&(n.current.style.transition="none",n.current.removeAttribute("data-resizing")),r.dragging.enable();try{d?.releasePointerCapture?.(c)}catch{}let k={width:w};(x||o.height!==void 0)&&(k.height=y),s(o.id,k),i?.(),window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",E),window.removeEventListener("pointercancel",E)};window.addEventListener("pointermove",v),window.addEventListener("pointerup",E),window.addEventListener("pointercancel",E)}function Ro({item:e,screenPos:t,map:o,readOnly:r,isCompact:n,cardRef:a,textareaRef:l,onSelect:s,onUpdate:i,onComplete:d}){let[c,p]=(0,Ie.useState)(!1),b=(0,Ie.useRef)({dx:0,dy:0}),g=(0,Ie.useRef)(!1),f=(0,Ie.useRef)({x:0,y:0}),u=(0,Ie.useRef)({timer:null}),w=(T,v)=>{u.current.timer&&(clearTimeout(u.current.timer),u.current.timer=null),o.dragging?.enable?.(),a.current&&(a.current.style.transition="none");let E={};T>0&&Math.abs(T-(e.width??230))>2&&(E.width=Math.max(160,Math.min(600,T))),v>0&&Math.abs(v-(e.height??0))>2&&(E.height=Math.max(50,Math.min(800,v))),Object.keys(E).length>0&&(i(e.id,E),d?.())};return(0,Ie.useEffect)(()=>{let T=l.current;if(!T||typeof ResizeObserver>"u")return;let v=new ResizeObserver(k=>{for(let I of k){let m=Math.round(I.borderBoxSize?.[0]?.inlineSize??I.contentRect.width),S=Math.round(I.borderBoxSize?.[0]?.blockSize??I.contentRect.height);if(m<50||S<20)continue;let R=Math.abs(m-(e.width??230)),B=Math.abs(S-(e.height??T.offsetHeight));(R>2||B>2)&&(a.current&&R>2&&(a.current.style.transition="none",a.current.style.width=`${m}px`),o.dragging?.disable?.(),u.current.timer&&clearTimeout(u.current.timer),u.current.timer=setTimeout(()=>{w(m,S)},150))}});v.observe(T);let E=()=>{u.current.timer&&w(l.current?.offsetWidth??0,l.current?.offsetHeight??0)};return window.addEventListener("pointerup",E),window.addEventListener("mouseup",E),()=>{v.disconnect(),window.removeEventListener("pointerup",E),window.removeEventListener("mouseup",E),u.current.timer&&(clearTimeout(u.current.timer),u.current.timer=null)}},[e.id,e.width,e.height,o,i,d]),{isDragging:c,didDragRef:g,commitResize:w,handleHeaderPointerDown:T=>{if(r||T.target.closest("button, input, textarea"))return;T.stopPropagation(),T.preventDefault(),s(e.id),p(!0),g.current=!1,f.current={x:T.clientX,y:T.clientY};let v=o.getContainer().getBoundingClientRect();b.current={dx:T.clientX-v.left-t.x,dy:T.clientY-v.top-t.y},o.dragging.disable();let E=null,k=e.position,I=typeof process<"u"&&process.env?.NODE_ENV==="test",m=()=>{E=null,i(e.id,{position:k})},S=B=>{Math.hypot(B.clientX-f.current.x,B.clientY-f.current.y)>2&&(g.current=!0);let F=B.clientX-v.left-b.current.dx,G=B.clientY-v.top-b.current.dy;a.current&&(a.current.style.left=`${F}px`,a.current.style.top=`${G}px`),k=X(o,{x:F,y:G}),I?m():E===null&&(E=requestAnimationFrame(m))},R=()=>{E!==null&&cancelAnimationFrame(E),p(!1),o.dragging.enable(),g.current&&(i(e.id,{position:k}),d?.()),window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",R),window.removeEventListener("pointercancel",R)};window.addEventListener("pointermove",S),window.addEventListener("pointerup",R),window.addEventListener("pointercancel",R)},handleResizePointerDown:T=>{r||n||Io({e:T,item:e,map:o,cardRef:a,textareaRef:l,onSelect:s,onUpdate:i,onComplete:d})},handleTextareaPointerDown:T=>{T.stopPropagation(),o.dragging.disable();let v=l.current?.offsetWidth??0,E=l.current?.offsetHeight??0;a.current&&(a.current.style.transition="none");let k=()=>{let I=l.current?.offsetWidth??0,m=l.current?.offsetHeight??0;Math.abs(I-v)>2||Math.abs(m-E)>2?w(I,m):(o.dragging?.enable?.(),a.current&&(a.current.style.transition="none")),window.removeEventListener("pointerup",k),window.removeEventListener("mouseup",k)};window.addEventListener("pointerup",k,{once:!0}),window.addEventListener("mouseup",k,{once:!0})}}}var M=require("react/jsx-runtime"),z={select:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"m3 3 7.07 16.97 2.51-7.39 7.39-2.51L3 3z"}),(0,M.jsx)("path",{d:"m13 13 6 6"})]}),freedraw:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}),(0,M.jsx)("path",{d:"m15 5 4 4"})]}),arrowLinear:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"M7 7h10v10"}),(0,M.jsx)("path",{d:"M7 17 17 7"})]}),arrowCurved:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"M4 19C4 10 11 5 20 5"}),(0,M.jsx)("polyline",{points:"15 2 20 5 16 10"})]}),arrowBi:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"M11 19H5v-6"}),(0,M.jsx)("path",{d:"M13 5h6v6"}),(0,M.jsx)("path",{d:"M19 5 5 19"})]}),arrowElbow:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("polyline",{points:"4 18 12 18 12 6 20 6"}),(0,M.jsx)("polyline",{points:"16 2 20 6 16 10"})]}),arrowSCurve:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"M5 19C9 19 11 15 12 12C13 9 15 9 19 5"}),(0,M.jsx)("polyline",{points:"13 5 19 5 19 11"})]}),shapesGroup:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z"}),(0,M.jsx)("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),(0,M.jsx)("circle",{cx:"17.5",cy:"17.5",r:"3.5"})]}),shapeSquare:(0,M.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:(0,M.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"})}),shapeCircle:(0,M.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:(0,M.jsx)("circle",{cx:"12",cy:"12",r:"10"})}),shapeStar:(0,M.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:(0,M.jsx)("path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"})}),shapeActor:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),(0,M.jsx)("circle",{cx:"12",cy:"7",r:"4"})]}),shapeTriangle:(0,M.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:(0,M.jsx)("path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"})}),shapeDiamond:(0,M.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:(0,M.jsx)("path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z"})}),shapeHexagon:(0,M.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:(0,M.jsx)("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})}),shapeMarker:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"}),(0,M.jsx)("circle",{cx:"12",cy:"10",r:"3"})]}),dropdownChevron:(0,M.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:(0,M.jsx)("path",{d:"m6 9 6 6 6-6"})}),ruler:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"M21.3 8.7 8.7 21.3a1 1 0 0 1-1.4 0l-4.6-4.6a1 1 0 0 1 0-1.4L15.3 2.7a1 1 0 0 1 1.4 0l4.6 4.6a1 1 0 0 1 0 1.4Z"}),(0,M.jsx)("path",{d:"m14.5 3.5 2 2"}),(0,M.jsx)("path",{d:"m11.5 6.5 2 2"}),(0,M.jsx)("path",{d:"m8.5 9.5 2 2"}),(0,M.jsx)("path",{d:"m5.5 12.5 2 2"})]}),note:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z"}),(0,M.jsx)("path",{d:"M15 3v5a1 1 0 0 0 1 1h5"})]}),text:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"M12 4v16"}),(0,M.jsx)("path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}),(0,M.jsx)("path",{d:"M9 20h6"})]}),undo:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"M9 14 4 9l5-5"}),(0,M.jsx)("path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11"})]}),redo:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"m15 14 5-5-5-5"}),(0,M.jsx)("path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13"})]}),collapseToolbar:(0,M.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:(0,M.jsx)("path",{d:"m18 15-6-6-6 6"})}),expandToolbar:(0,M.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:(0,M.jsx)("path",{d:"m6 9 6 6 6-6"})}),delete:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"M10 11v6"}),(0,M.jsx)("path",{d:"M14 11v6"}),(0,M.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),(0,M.jsx)("path",{d:"M3 6h18"}),(0,M.jsx)("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),clear:(0,M.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,M.jsx)("path",{d:"m15 9-6 6"}),(0,M.jsx)("path",{d:"m9 9 6 6"})]}),noteExpand:(0,M.jsx)("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:(0,M.jsx)("path",{d:"m6 9 6 6 6-6"})}),noteCollapse:(0,M.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:(0,M.jsx)("path",{d:"M5 12h14"})}),noteDelete:(0,M.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:[(0,M.jsx)("path",{d:"M18 6 6 18"}),(0,M.jsx)("path",{d:"m6 6 12 12"})]}),textBold:(0,M.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",shapeRendering:"geometricPrecision",children:(0,M.jsx)("path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"})})};var Ne=require("react/jsx-runtime");function Do({item:e,theme:t,readOnly:o,unstyled:r,labels:n,icons:a,classNames:l,styles:s,onHeaderPointerDown:i,onCollapse:d,onSelect:c,onUpdate:p,onDelete:b,onComplete:g}){let f=r?{}:{border:"none",background:"transparent",color:e.textColor||t.text,width:"20px",height:"20px",padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"12px",fontWeight:700,lineHeight:1,opacity:.75,borderRadius:"2px",flexShrink:0};return(0,Ne.jsxs)("div",{onPointerDown:i,className:["rlc-note-header",l?.noteHeader].filter(Boolean).join(" "),style:{cursor:o?"default":"grab",...r?{}:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",padding:"6px 8px 6px 10px",backgroundColor:t.header,borderBottom:`1px solid ${t.border}`,boxSizing:"border-box"},...s?.noteHeader},children:[(0,Ne.jsx)("input",{type:"text",readOnly:o,value:e.title??"",placeholder:n?.noteTitlePlaceholder??"Note title...","aria-label":n?.noteTitlePlaceholder??"Note title",title:e.title||n?.noteTitlePlaceholder||"Note",className:["rlc-note-title-input",l?.noteTitleInput].filter(Boolean).join(" "),onFocus:()=>{o||c(e.id)},onBlur:()=>g?.(),onChange:u=>{o||p(e.id,{title:u.target.value})},onPointerDown:u=>u.stopPropagation(),style:{...r?{}:{flex:1,minWidth:0,background:"transparent",border:"none",outline:"none",fontWeight:600,fontSize:"12px",color:e.textColor||t.text,fontFamily:"inherit",cursor:o?"default":"text",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"},...s?.noteTitleInput}}),(0,Ne.jsxs)("div",{className:["rlc-note-header-actions",l?.noteHeaderActions].filter(Boolean).join(" "),style:{...r?{}:{display:"flex",alignItems:"center",gap:"3px",flexShrink:0},...s?.noteHeaderActions},children:[(0,Ne.jsx)("button",{type:"button",title:n?.noteCollapse??"Collapse note","aria-label":n?.noteCollapse??"Collapse note",className:["rlc-note-header-btn",l?.noteHeaderButton].filter(Boolean).join(" "),onClick:u=>{u.stopPropagation(),d()},style:{...f,...s?.noteHeaderButton},children:a?.noteCollapse??z.noteCollapse}),!o&&(0,Ne.jsx)("button",{type:"button",title:n?.noteDelete??"Delete note","aria-label":n?.noteDelete??"Delete note",className:["rlc-note-header-btn","rlc-note-delete-btn",l?.noteHeaderButton,l?.noteDeleteButton].filter(Boolean).join(" "),onClick:u=>{u.stopPropagation(),b(e.id)},style:{...f,...s?.noteHeaderButton,...s?.noteDeleteButton},children:a?.noteDelete??z.noteDelete})]})]})}var Te=require("react/jsx-runtime");function Mo({item:e,theme:t,isCompact:o,isDragging:r,readOnly:n,unstyled:a,labels:l,icons:s,classNames:i,styles:d,textareaRef:c,onHeaderPointerDown:p,onExpandFromCompact:b,onCollapse:g,onSelect:f,onUpdate:u,onDelete:w,onComplete:y,onTextareaPointerDown:x}){return o?(0,Te.jsxs)("div",{onPointerDown:p,className:["rlc-note-header",i?.noteHeader].filter(Boolean).join(" "),style:{cursor:n?"default":r?"grabbing":"grab",display:"inline-flex",alignItems:"center",gap:"4px",width:"100%",height:"100%",userSelect:"none"},children:[(0,Te.jsx)("span",{style:{fontSize:"11px",fontWeight:600,lineHeight:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"90px",color:e.textColor||t.text},title:e.title||l?.noteTitlePlaceholder||"Note",children:e.title||l?.noteTitlePlaceholder||"Note"}),(0,Te.jsx)("button",{type:"button",title:l?.noteExpand??"Expand note","aria-label":l?.noteExpand??"Expand note",className:["rlc-note-header-btn",i?.noteHeaderButton].filter(Boolean).join(" "),onClick:b,style:{border:"none",background:"transparent",color:e.textColor||t.text,width:"12px",height:"12px",padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",opacity:.75,flexShrink:0},children:s?.noteExpand??z.noteExpand})]}):(0,Te.jsxs)(Te.Fragment,{children:[(0,Te.jsx)(Do,{item:e,theme:t,readOnly:n,unstyled:a,labels:l,icons:s,classNames:i,styles:d,onHeaderPointerDown:p,onCollapse:g,onSelect:f,onUpdate:u,onDelete:w,onComplete:y}),(0,Te.jsx)("div",{className:["rlc-note-body",i?.noteBody].filter(Boolean).join(" "),style:{...a?{}:{padding:0},...d?.noteBody},children:(0,Te.jsx)("textarea",{ref:c,readOnly:n,value:e.text,placeholder:l?.noteTextPlaceholder??"Write a note on the map...","aria-label":l?.noteTextPlaceholder??"Note text",rows:3,className:["rlc-note-textarea",i?.noteTextarea].filter(Boolean).join(" "),onFocus:()=>{n||f(e.id)},onBlur:()=>y?.(),onChange:h=>{n||u(e.id,{text:h.target.value})},onPointerDown:x,onMouseDown:h=>h.stopPropagation(),style:{...a?{}:{width:"100%",height:e.height?`${e.height}px`:void 0,boxSizing:"border-box",display:"block",margin:0,background:"transparent",border:"none",borderRadius:0,padding:"6px 10px 8px",outline:"none",resize:n?"none":"both",minWidth:"160px",maxWidth:"600px",minHeight:"56px",maxHeight:"800px",fontSize:"12px",lineHeight:1.45,color:e.textColor||t.text,fontFamily:"inherit",cursor:n?"default":"text"},...d?.noteTextarea}})})]})}var ko=require("react/jsx-runtime");function Eo({item:e,screenPos:t,isSelected:o,isDragging:r,readOnly:n,isCompact:a,cardClassName:l,structuralRootStyle:s,styles:i,renderNote:d,onCardClick:c,onCardDoubleClick:p,handleHeaderPointerDown:b,handleResizePointerDown:g,onSelect:f,onUpdate:u,onDelete:w}){return(0,ko.jsx)("div",{"data-tual-note":e.id,"data-collapsed":a?"true":void 0,"data-compact":a?"true":void 0,"data-selected":!n&&o||void 0,className:l,onClick:c,onDoubleClick:p,onWheel:y=>y.stopPropagation(),style:{...s,...i?.noteCard,...a?{...i?.noteCollapsed,...i?.noteCompact}:void 0,...!n&&o?i?.noteCardSelected:void 0},children:d({item:e,screenPos:t,isSelected:!n&&o,isDragging:r,readOnly:n,isCompact:a,dragHandleProps:{onPointerDown:b,style:{cursor:n?"default":r?"grabbing":"grab"}},resizeHandleProps:{onPointerDown:g,style:{cursor:n||a?"default":"nwse-resize"}},onSelect:()=>{n||f(e.id)},onUpdate:y=>{(!n||Object.keys(y).length<=2&&("minimized"in y||"collapseState"in y))&&u(e.id,y)},onDelete:()=>{n||w(e.id)}})})}var zt=require("react/jsx-runtime"),io=Se.default.memo(function({item:t,screenPos:o,isSelected:r,map:n,readOnly:a=!1,labels:l,icons:s,unstyled:i=!1,classNames:d,styles:c,clampToViewport:p=!0,autoMinimizeZoomThreshold:b,renderNote:g,onSelect:f,onUpdate:u,onDelete:w,onComplete:y}){let x=(0,Se.useRef)(null),h=(0,Se.useRef)(null),T=typeof n?.getZoom=="function"?n.getZoom():null,[v,E]=(0,Se.useState)(!1),k=(0,Se.useRef)(T);(0,Se.useEffect)(()=>{T!==null&&(k.current!==null&&k.current!==T&&E(!1),k.current=T)},[T]);let I=typeof b=="number"&&T!==null&&!v&&T<b,m=!v&&(I||t.collapseState==="compact"||t.collapseState==="collapsed"||t.minimized===!0||t.minimized==="compact"),{isDragging:S,didDragRef:R,handleHeaderPointerDown:B,handleResizePointerDown:F,handleTextareaPointerDown:G}=Ro({item:t,screenPos:o,map:n,readOnly:a,isCompact:m,cardRef:x,textareaRef:h,onSelect:f,onUpdate:u,onComplete:y});(0,Se.useEffect)(()=>{let H=x.current;if(!H)return;let K=Z=>{let q=Z.target;q?.closest(".rlc-note-header")&&!q.closest("button, input")||Z.stopPropagation()};return H.addEventListener("mousedown",K),H.addEventListener("touchstart",K),()=>{H.removeEventListener("mousedown",K),H.removeEventListener("touchstart",K)}},[]);let $=H=>{H?.stopPropagation(),E(!0),a||f(t.id),u(t.id,{minimized:!1})},V=Co(t.backgroundColor),{x:C,y:A}=Po(n,o,t,m,S,p),D={position:"absolute",left:`${C}px`,top:`${A}px`,pointerEvents:"auto",zIndex:!a&&r?30:20,userSelect:a?"text":"none"},P=["rlc-note-card",m?"rlc-note-compact rlc-note-collapsed":void 0,d?.noteCard,m?d?.noteCompact:void 0,m?d?.noteCollapsed:void 0,!a&&r?d?.noteCardSelected:void 0].filter(Boolean).join(" "),N=H=>{if(H.stopPropagation(),R.current){R.current=!1;return}if(m){$(H);return}a||f(t.id)},_=H=>{if(H.stopPropagation(),R.current){R.current=!1;return}m&&$(H)};return g?(0,zt.jsx)(Eo,{item:t,screenPos:o,isSelected:r,isDragging:S,readOnly:a,isCompact:m,cardClassName:P,structuralRootStyle:D,styles:c,renderNote:g,onCardClick:N,onCardDoubleClick:_,handleHeaderPointerDown:B,handleResizePointerDown:F,onSelect:f,onUpdate:u,onDelete:w}):(0,zt.jsx)("div",{ref:x,"data-tual-note":t.id,"data-collapsed":m?"true":void 0,"data-compact":m?"true":void 0,"data-selected":!a&&r||void 0,"data-dragging":S||void 0,className:P,onClick:N,onDoubleClick:_,onWheel:H=>H.stopPropagation(),style:{...D,...Lo(t,V,m,r,a,S,i),...c?.noteCard,...m?{borderRadius:"9999px",...c?.noteCollapsed,...c?.noteCompact}:void 0,...!a&&r?c?.noteCardSelected:void 0},children:(0,zt.jsx)(Mo,{item:t,theme:V,isCompact:m,isDragging:S,readOnly:a,unstyled:i,labels:l,icons:s,classNames:d,styles:c,textareaRef:h,onHeaderPointerDown:B,onExpandFromCompact:$,onCollapse:()=>{E(!1),u(t.id,{minimized:!0})},onSelect:f,onUpdate:u,onDelete:w,onComplete:y,onTextareaPointerDown:G})})});var ye=je(require("react"),1);function Ao(e,t,o,r,n,a,l=!0){let s=l!==!1?Le(e):null;if(!s||a||!(t.x>=-100&&t.x<=s.width+100&&t.y>=-100&&t.y<=s.height+100))return t;let d=n?35:Math.max(24,(o.text||"Text").length*r/3.6),c=n?11:r/2+4,p=8,b=d+p,g=Math.max(b,s.width-d-p),f=c+p,u=Math.max(f,s.height-c-p);return{x:Math.max(b,Math.min(g,t.x)),y:Math.max(f,Math.min(u,t.y))}}function Oo(e,t,o,r){return e?r?"pointer":"default":t?"text":o?"grabbing":r?"pointer":"grab"}var qe=require("react");function No({item:e,screenPos:t,map:o,readOnly:r,isEditing:n,onSelect:a,onUpdate:l}){let[s,i]=(0,qe.useState)(!1),d=(0,qe.useRef)({dx:0,dy:0}),c=(0,qe.useRef)(!1),p=(0,qe.useRef)({x:0,y:0});return{isDragging:s,didDragRef:c,handlePointerDown:g=>{if(r||n||g.target.closest("button, textarea, input"))return;g.stopPropagation(),g.preventDefault(),a(e.id),i(!0),c.current=!1,p.current={x:g.clientX,y:g.clientY};let f=o.getContainer().getBoundingClientRect();d.current={dx:g.clientX-f.left-t.x,dy:g.clientY-f.top-t.y},o.dragging.disable();let u=y=>{Math.hypot(y.clientX-p.current.x,y.clientY-p.current.y)>2&&(c.current=!0);let x=y.clientX-f.left-d.current.dx,h=y.clientY-f.top-d.current.dy;l(e.id,{position:X(o,{x,y:h})})},w=()=>{i(!1),o.dragging.enable(),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",w)};window.addEventListener("pointermove",u),window.addEventListener("pointerup",w)}}}var Gt=require("react/jsx-runtime");function Bo({item:e,map:t,isCompact:o,isEditing:r,isSelected:n,readOnly:a,unstyled:l,dynamicFontSize:s,labels:i,classNames:d,styles:c,inputRef:p,setIsEditing:b,onUpdate:g,onComplete:f}){if(o)return(0,Gt.jsx)("div",{"data-compact":"true",className:["rlc-text-display","rlc-text-compact-pill",d?.textDisplay,d?.textCompact].filter(Boolean).join(" "),style:{...l?{}:{display:"inline-flex",alignItems:"center",height:"22px",padding:"0 8px",backgroundColor:e.backgroundColor??"#ffffff",color:e.color,border:`1px solid ${e.color?`${e.color}40`:"#cbd5e1"}`,borderRadius:"9999px",fontSize:"11px",fontWeight:600,lineHeight:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"120px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.12)",cursor:"pointer",userSelect:"none"},...c?.textDisplay,...c?.textCompact},title:e.text||"Text",children:e.text||i?.textEmptyFallback||"Text"});let u=()=>{b(!1),e.text.trim()||g(e.id,{text:i?.textEmptyFallback??"Label"}),f?.()};return r?(0,Gt.jsx)("textarea",{ref:p,value:e.text,placeholder:i?.textPlaceholder??"Type text...","aria-label":i?.textPlaceholder??"Map text annotation",rows:Math.max(1,e.text.split(`
3
+ `).length),className:["rlc-text-input",d?.textInput].filter(Boolean).join(" "),onChange:w=>g(e.id,{text:w.target.value}),onBlur:u,onKeyDown:w=>{(w.key==="Escape"||w.key==="Enter"&&!w.shiftKey)&&(w.preventDefault(),u())},onPointerDown:w=>{w.stopPropagation(),t.dragging.disable();let y=()=>{t.dragging.enable(),window.removeEventListener("pointerup",y)};window.addEventListener("pointerup",y)},onMouseDown:w=>{w.stopPropagation(),t.dragging.disable();let y=()=>{t.dragging.enable(),window.removeEventListener("mouseup",y)};window.addEventListener("mouseup",y)},style:{fontSize:`${s}px`,fontWeight:e.fontWeight??"bold",color:e.color,...l?{}:{minWidth:"80px",padding:"2px 4px",backgroundColor:"#ffffff",border:"1px solid #767676",borderRadius:"2px",outline:"none",fontFamily:"inherit",resize:"both",lineHeight:1.25,boxShadow:"none"},...c?.textInput}}):(0,Gt.jsx)("div",{className:["rlc-text-display",d?.textDisplay].filter(Boolean).join(" "),style:{fontSize:`${s}px`,fontWeight:e.fontWeight??"bold",color:e.color,...l?{}:{padding:"2px 4px",backgroundColor:e.backgroundColor??"#ffffff",borderRadius:"2px",border:!a&&n?"1px dashed #767676":"1px solid transparent",boxShadow:"none",whiteSpace:"pre-wrap",lineHeight:1.25},...c?.textDisplay},children:e.text||(a?"":i?.textEmptyFallback??"Double-click to edit")})}var Ho=require("react/jsx-runtime");function Wo({item:e,screenPos:t,isSelected:o,isEditing:r,isDragging:n,readOnly:a,isCompact:l,dynamicFontSize:s,dragHandleProps:i,wrapperClassName:d,structuralWrapperStyle:c,styles:p,renderText:b,onClick:g,onDoubleClick:f,setIsEditing:u,onSelect:w,onUpdate:y,onDelete:x}){return(0,Ho.jsx)("div",{"data-tual-text":e.id,"data-compact":l?"true":void 0,"data-selected":!a&&o||void 0,className:d,onClick:g,onDoubleClick:f,onWheel:h=>h.stopPropagation(),style:{...c,...p?.textWrapper,...l?p?.textCompact:void 0,...!a&&o?p?.textWrapperSelected:void 0},children:b({item:e,screenPos:t,isSelected:!a&&o,isEditing:!a&&r,isDragging:n,readOnly:a,isCompact:l,dynamicFontSize:s,setIsEditing:u,dragHandleProps:i,onSelect:()=>{a||w(e.id)},onUpdate:h=>{a||y(e.id,h)},onDelete:()=>{a||x(e.id)}})})}var _t=require("react/jsx-runtime"),lo=ye.default.memo(function({item:t,screenPos:o,isSelected:r,isEditingLabel:n,map:a,readOnly:l=!1,labels:s,icons:i,unstyled:d=!1,classNames:c,styles:p,clampToViewport:b=!0,autoMinimizeZoomThreshold:g,renderText:f,onSelect:u,onUpdate:w,onDelete:y,onComplete:x}){let[h,T]=(0,ye.useState)(!l&&t.text===""),[v,E]=(0,ye.useState)(!1),k=(0,ye.useRef)(null),{isDragging:I,didDragRef:m,handlePointerDown:S}=No({item:t,screenPos:o,map:a,readOnly:l,isEditing:h,onSelect:u,onUpdate:w}),R=typeof a?.getZoom=="function"?a.getZoom():null,B=(0,ye.useRef)(R),F=t.initialFontSize??t.fontSize??16,G=t.baseZoom??14,$=to(F,R,G);(0,ye.useEffect)(()=>{R!==null&&(B.current!==null&&B.current!==R&&E(!1),B.current=R)},[R]);let C=typeof g=="number"&&R!==null&&R<g&&!r&&!h&&!v;(0,ye.useEffect)(()=>{r&&n&&!l&&T(!0)},[r,n,l]),(0,ye.useEffect)(()=>{h&&k.current&&(k.current.focus(),k.current.select())},[h]);let A=Oo(l,h,I,C),D={onPointerDown:S,style:{cursor:A}},P=["rlc-text-wrapper",C?"rlc-text-compact":void 0,c?.textWrapper,C?c?.textCompact:void 0,!l&&r?c?.textWrapperSelected:void 0].filter(Boolean).join(" "),{x:N,y:_}=Ao(a,o,t,$,C,I,b),H={position:"absolute",left:`${N}px`,top:`${_}px`,transform:"translate(-50%, -50%)",pointerEvents:"auto",zIndex:!l&&r?28:18,cursor:A,userSelect:l||h?"text":"none"},K=q=>{if(q.stopPropagation(),m.current){m.current=!1;return}C&&E(!0),l||u(t.id)},Z=q=>{q.stopPropagation(),C&&E(!0),l||(u(t.id),T(!0))};return f?(0,_t.jsx)(Wo,{item:t,screenPos:o,isSelected:r,isEditing:h,isDragging:I,readOnly:l,isCompact:C,dynamicFontSize:$,dragHandleProps:D,wrapperClassName:P,structuralWrapperStyle:H,styles:p,renderText:f,onClick:K,onDoubleClick:Z,setIsEditing:q=>{l||T(q)},onSelect:u,onUpdate:w,onDelete:y}):(0,_t.jsx)("div",{"data-tual-text":t.id,"data-compact":C?"true":void 0,"data-selected":!l&&r||void 0,className:P,onPointerDown:S,onClick:K,onDoubleClick:Z,onWheel:q=>q.stopPropagation(),style:{...H,...d?{}:{fontFamily:"Inter, system-ui, -apple-system, sans-serif"},...p?.textWrapper,...C?p?.textCompact:void 0,...!l&&r?p?.textWrapperSelected:void 0},children:(0,_t.jsx)(Bo,{item:t,map:a,isCompact:C,isEditing:h,isSelected:r,readOnly:l,unstyled:d,dynamicFontSize:$,labels:s,classNames:c,styles:p,inputRef:k,setIsEditing:T,onUpdate:w,onComplete:x})})});var Ut=require("react");function so(e){let[t,o]=(0,Ut.useState)({width:0,height:0,tick:0});return(0,Ut.useEffect)(()=>{if(e)return St(e,({width:r,height:n})=>{o(a=>({width:r,height:n,tick:a.tick+1}))})},[e]),t}var ee=require("react");var fe=require("react");function jo(e){let{initialItems:t=[],items:o,maxHistory:r=50}=e,n=Math.max(0,r-1),a=(0,fe.useRef)(e);a.current=e;let[l,s]=(0,fe.useState)({past:[],present:t,future:[]}),i=(0,fe.useRef)(l);i.current=l;let d=o??l.present,c=(0,fe.useRef)(d);c.current=d;let p=(0,fe.useRef)(d),b=(0,fe.useCallback)(x=>{a.current.onItemsChange?.(x),a.current.onChange?.(x)},[]),g=(0,fe.useCallback)((x,h)=>{a.current.onItemsChangeComplete?.(x,h),a.current.onChangeComplete?.(x,h),a.current.onEditEnd?.(x,h),a.current.onEditComplete?.(x,h),h&&a.current.onItemChangeComplete?.(h)},[]),f=(0,fe.useCallback)(x=>{let h=x(c.current);return c.current=h,b(h),s(T=>({...T,present:h})),h},[b]),u=(0,fe.useCallback)(x=>{let h=c.current;if(h===p.current)return;let T=p.current;p.current=h,s(v=>({past:[...v.past,T].slice(-n),present:h,future:[]})),g(h,x)},[n,g]),w=(0,fe.useCallback)(x=>{x||s(h=>{if(h.past.length===0)return h;let T=h.past[h.past.length-1];return c.current=T,p.current=T,b(T),g(T,null),{past:h.past.slice(0,-1),present:T,future:[h.present,...h.future]}})},[b,g]),y=(0,fe.useCallback)(x=>{x||s(h=>{if(h.future.length===0)return h;let T=h.future[0];return c.current=T,p.current=T,b(T),g(T,null),{past:[...h.past,h.present],present:T,future:h.future.slice(1)}})},[b,g]);return{items:d,history:l,historyRef:i,callbacksRef:a,commitItems:f,notifyChangeComplete:u,undo:w,redo:y}}var ae=require("react");function Fo(e){let{defaultColor:t=nt,defaultStrokeWidth:o=rt,defaultNoteColor:r=at,defaultFontSize:n=it,defaultShape:a="square",readOnly:l,selectedId:s,commitItems:i}=e,[d,c]=(0,ae.useState)(a),[p,b]=(0,ae.useState)(!0),[g,f]=(0,ae.useState)(t),[u,w]=(0,ae.useState)(o),[y,x]=(0,ae.useState)(!1),[h,T]=(0,ae.useState)(r),[v,E]=(0,ae.useState)(n),[k,I]=(0,ae.useState)("bold"),m=(0,ae.useCallback)((A,D)=>{s&&i(P=>P.map(N=>N.id===s&&A(N)?D(N):N))},[s,i]),S=(0,ae.useCallback)(A=>{l||(c(A),m(D=>D.type==="shape",D=>({...D,shape:A})))},[l,m]),R=(0,ae.useCallback)(A=>{l||(b(A),m(D=>D.type==="shape",D=>({...D,filled:A})))},[l,m]),B=(0,ae.useCallback)(A=>{l||(f(A),m(D=>D.type!=="note",D=>({...D,color:A})))},[l,m]),F=(0,ae.useCallback)(A=>{l||(w(A),m(D=>D.type==="arrow"||D.type==="freedraw"||D.type==="shape"||D.type==="ruler",D=>({...D,strokeWidth:A})))},[l,m]),G=(0,ae.useCallback)(A=>{l||(x(A),m(D=>D.type==="arrow"||D.type==="freedraw"||D.type==="shape"||D.type==="ruler",D=>({...D,dashed:A})))},[l,m]),$=(0,ae.useCallback)(A=>{if(l)return;T(A);let D=ue.find(P=>P.bg===A);m(P=>P.type==="note",P=>({...P,backgroundColor:A,textColor:D?.text??P.textColor}))},[l,m]),V=(0,ae.useCallback)(A=>{l||(E(A),m(D=>D.type==="text",D=>({...D,initialFontSize:A})))},[l,m]),C=(0,ae.useCallback)(A=>{l||(I(A),m(D=>D.type==="text",D=>({...D,fontWeight:A})))},[l,m]);return{activeShape:d,setActiveShape:S,shapeFilled:p,setShapeFilled:R,activeColor:g,setActiveColor:B,strokeWidth:u,setStrokeWidth:F,dashed:y,setDashed:G,noteColor:h,setNoteColor:$,fontSize:v,setFontSize:V,fontWeight:k,setFontWeight:C}}function co(e={}){let{items:t,initialTool:o="select",defaultColor:r,defaultStrokeWidth:n,defaultNoteColor:a,defaultFontSize:l,defaultShape:s}=e,{items:i,history:d,historyRef:c,callbacksRef:p,commitItems:b,notifyChangeComplete:g,undo:f,redo:u}=jo(e),[w,y]=(0,ee.useState)(o),[x,h]=(0,ee.useState)(!!(e.readOnly??!1)),T=(0,ee.useRef)(e.readOnly);(0,ee.useEffect)(()=>{e.readOnly!==void 0&&e.readOnly!==T.current&&(T.current=e.readOnly,h(!!e.readOnly))},[e.readOnly]);let[v,E]=(0,ee.useState)(null),[k,I]=(0,ee.useState)(!1),m=Fo({defaultColor:r,defaultStrokeWidth:n,defaultNoteColor:a,defaultFontSize:l,defaultShape:s,readOnly:x,selectedId:v,commitItems:b}),S=(0,ee.useCallback)(P=>{E(N=>{let _=typeof P=="function"?P(N):P;if(N!==_){I(!1),N!==null&&_===null&&g();let H=t??c.current.present;p.current.onItemSelect?.(H.find(K=>K.id===_)??null)}return _})},[t,g,c,p]),R=(0,ee.useCallback)(P=>{x&&P!=="select"||(y(P),p.current.onToolChange?.(P))},[x,p]),B=(0,ee.useCallback)(P=>{x||(b(N=>[...N,P]),S(P.id),p.current.onItemCreate?.(P))},[x,b,S,p]),F=(0,ee.useCallback)((P,N)=>{if(x){let H=Object.keys(N);if(H.length!==1||H[0]!=="minimized")return}let _;b(H=>H.map(K=>K.id===P?(_={...K,...N},_):K)),_&&p.current.onItemChange?.(_)},[x,b,p]),G=(0,ee.useCallback)(P=>{x||(b(N=>N.filter(_=>_.id!==P)),S(N=>N===P?null:N),p.current.onItemDelete?.(P),g())},[x,b,S,g,p]),$=(0,ee.useCallback)(()=>{!x&&v&&G(v)},[x,v,G]),V=(0,ee.useCallback)(()=>{x||(b(()=>[]),S(null),g())},[x,b,S,g]),C=(0,ee.useMemo)(()=>i.find(P=>P.id===v)??null,[i,v]),A=(0,ee.useCallback)(()=>JSON.stringify(i,null,2),[i]),D=(0,ee.useCallback)(P=>{if(x)return!1;try{let N=JSON.parse(P);return Array.isArray(N)?(b(()=>N),S(null),g(),!0):!1}catch{return!1}},[x,b,S,g]);return{items:i,activeTool:w,setActiveTool:R,readOnly:x,setReadOnly:h,...m,selectedId:v,setSelectedId:S,selectedItem:C,isEditingLabel:k,setEditingLabel:I,labelEditMode:k,setLabelEditMode:I,addItem:B,updateItem:F,removeItem:G,deleteSelected:$,clearAll:V,clear:V,deleteItem:G,setTool:R,selectItem:S,undo:(0,ee.useCallback)(()=>f(x),[f,x]),redo:(0,ee.useCallback)(()=>u(x),[u,x]),canUndo:!x&&d.past.length>0,canRedo:!x&&d.future.length>0,notifyChangeComplete:g,exportJSON:A,importJSON:D}}var dn=require("react");var zo=["select","freedraw","arrow","shape","ruler","note","text"],po={top:{top:"14px",left:"50%",transform:"translateX(-50%)"},bottom:{bottom:"24px",left:"50%",transform:"translateX(-50%)"},left:{top:"50%",left:"14px",transform:"translateY(-50%)"},right:{top:"50%",right:"14px",transform:"translateY(-50%)"},"top-center":{top:"14px",left:"50%",transform:"translateX(-50%)"},"bottom-center":{bottom:"24px",left:"50%",transform:"translateX(-50%)"},"left-center":{top:"50%",left:"14px",transform:"translateY(-50%)"},"right-center":{top:"50%",right:"14px",transform:"translateY(-50%)"}};function Go(e,t){return[{id:"arrow-linear",style:"linear",label:e?.arrowLinear??"Linear Arrow",shortcut:"A",icon:t?.arrowLinear??z.arrowLinear},{id:"arrow-curved",style:"curved",label:e?.arrowCurved??"Curved Arrow",shortcut:"C",icon:t?.arrowCurved??z.arrowCurved},{id:"arrow-bi",style:"bi",label:e?.arrowBi??"Double-Headed",shortcut:"B",icon:t?.arrowBi??z.arrowBi},{id:"arrow-elbow",style:"elbow",label:e?.arrowElbow??"Elbow / Step",shortcut:"E",icon:t?.arrowElbow??z.arrowElbow},{id:"arrow-s-curve",style:"s-curve",label:e?.arrowSCurve??"S-Curve Arrow",shortcut:"S",icon:t?.arrowSCurve??z.arrowSCurve}]}function _o(e,t){return[{kind:"square",label:e?.shapeSquare??"Square",icon:t?.shapeSquare??z.shapeSquare},{kind:"circle",label:e?.shapeCircle??"Circle",icon:t?.shapeCircle??z.shapeCircle},{kind:"star",label:e?.shapeStar??"Star",icon:t?.shapeStar??z.shapeStar},{kind:"actor",label:e?.shapeActor??"Actor",icon:t?.shapeActor??z.shapeActor},{kind:"triangle",label:e?.shapeTriangle??"Triangle",icon:t?.shapeTriangle??z.shapeTriangle},{kind:"diamond",label:e?.shapeDiamond??"Diamond",icon:t?.shapeDiamond??z.shapeDiamond},{kind:"hexagon",label:e?.shapeHexagon??"Hexagon",icon:t?.shapeHexagon??z.shapeHexagon},{kind:"marker",label:e?.shapeMarker??"Marker",icon:t?.shapeMarker??z.shapeMarker}]}function Uo(e,t,o,r,n,a){return{...n?{}:t&&o?{display:"grid",gridTemplateColumns:"20px 1fr auto",alignItems:"center",columnGap:"10px",padding:"8px 12px",textAlign:"left",width:"100%",height:"auto",borderRadius:"2px",border:e?"1px solid #4f4f4f":"1px solid #767676",boxSizing:"border-box",backgroundColor:e?"#e0e0e0":"#efefef",color:"#000000",fontWeight:"normal",fontSize:"12px",lineHeight:"16px",cursor:"pointer",boxShadow:e?"inset 1px 1px 2px rgba(0, 0, 0, 0.2)":"none",flexShrink:0,whiteSpace:"nowrap"}:{display:"inline-flex",alignItems:"center",justifyContent:"center",position:"relative",gap:o?"6px":"0px",padding:t?"0":o?"2px 7px":"3px 6px",width:t?"30px":"auto",height:t?"30px":"auto",minWidth:t?"30px":void 0,minHeight:t?"30px":void 0,borderRadius:"2px",border:e?"1px solid #4f4f4f":"1px solid #767676",boxSizing:"border-box",backgroundColor:e?"#e0e0e0":"#efefef",color:"#000000",fontWeight:"normal",fontSize:"12px",lineHeight:"16px",cursor:"pointer",boxShadow:e?"inset 1px 1px 2px rgba(0, 0, 0, 0.2)":"none",flexShrink:0,whiteSpace:"nowrap"},...a?.toolButton,...e?a?.toolButtonActive:void 0,...t&&!o?{padding:"0",width:a?.toolButton?.width??"30px",height:a?.toolButton?.height??"30px"}:void 0,...r&&!e?{opacity:.45,cursor:"not-allowed"}:void 0}}function Yo(e,t){return["rlc-tool-btn",t?.toolButton,e?t?.toolButtonActive:void 0].filter(Boolean).join(" ")}function Yt(e,t,o=!1){let r=t==="vertical",n=e.includes("right"),a=e.includes("left"),l=e.includes("bottom");return r?{...l?{bottom:0}:{top:0},...n?{right:"calc(100% + 8px)"}:{left:"calc(100% + 8px)"}}:{...n?{right:0}:a||!o?{left:0}:{left:"50%",transform:"translateX(-50%)"},...l?{bottom:"calc(100% + 8px)"}:{top:"calc(100% + 8px)"}}}function Ko(e,t,o){return o?{}:t?{display:"flex",flexDirection:e==="right"||e==="right-center"?"row-reverse":"row",alignItems:"flex-start",gap:"8px",fontFamily:"Inter, system-ui, -apple-system, sans-serif"}:{display:"flex",flexDirection:e==="bottom"||e==="bottom-center"?"column-reverse":"column",alignItems:"center",gap:"8px",fontFamily:"Inter, system-ui, -apple-system, sans-serif"}}function Xo(e,t,o,r,n,a,l,s){return e==="select"?{icon:l?.select??z.select,label:s?.select??"Select"}:e==="freedraw"?{icon:l?.freedraw??z.freedraw,label:s?.freedraw??"Free Draw"}:e==="ruler"?{icon:l?.ruler??z.ruler,label:s?.ruler??"Ruler"}:t?{icon:o,label:r}:e==="shape"?{icon:n,label:a}:e==="note"?{icon:l?.note??z.note,label:s?.note??"Note Card"}:e==="text"?{icon:l?.text??z.text,label:s?.text??"Normal Text"}:{icon:l?.shapesGroup??z.shapesGroup,label:"Tools"}}var $o=["arrow-linear","arrow-curved","arrow-bi","arrow-elbow","arrow-s-curve"];function Vo(e){return $o.includes(e)}function Je(e,t="top-center",o="horizontal"){return o==="vertical"?t==="right"||t==="right-center"?e?"rotate(-90deg)":"rotate(90deg)":e?"rotate(90deg)":"rotate(-90deg)":t==="bottom"||t==="bottom-center"?e?"rotate(0deg)":"rotate(180deg)":e?"rotate(180deg)":"rotate(0deg)"}function Kt(e="top-center",t="horizontal"){return t==="vertical"?e==="right"||e==="right-center"?"rotate(90deg)":"rotate(-90deg)":e==="bottom"||e==="bottom-center"?"rotate(180deg)":"rotate(0deg)"}function Xt(e="top-center",t="horizontal"){return t==="vertical"?e==="right"||e==="right-center"?"rotate(90deg)":"rotate(-90deg)":e==="bottom"||e==="bottom-center"?"rotate(180deg)":"rotate(0deg)"}var he=require("react/jsx-runtime");function Zo({position:e,orientation:t,isVertical:o,showToolLabels:r,unstyled:n,labels:a,icons:l,classNames:s,styles:i,onCollapse:d}){let c=Kt(e,t),p=l?.collapseToolbar??z.collapseToolbar;return(0,he.jsx)("button",{type:"button","aria-label":a?.collapseToolbar??"Collapse toolbar",title:a?.collapseToolbar??"Collapse toolbar","data-toolbar-collapse":"true",className:["rlc-toolbar-collapse-btn",s?.toolbarCollapseButton].filter(Boolean).join(" "),onClick:d,style:{...n?{}:o&&r?{display:"grid",gridTemplateColumns:"20px 1fr auto",alignItems:"center",columnGap:"10px",padding:"8px 12px",textAlign:"left",width:"100%",height:"auto",borderRadius:"2px",border:"1px solid #767676",boxSizing:"border-box",backgroundColor:"#efefef",color:"#000000",cursor:"pointer",boxShadow:"none",flexShrink:0,whiteSpace:"nowrap"}:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:o?"0":r?"2px 6px":"3px 6px",width:o?"30px":"auto",height:o?"30px":"auto",borderRadius:"2px",border:"1px solid #767676",boxSizing:"border-box",backgroundColor:"#efefef",color:"#000000",cursor:"pointer",boxShadow:"none",flexShrink:0},...i?.toolButton,...i?.toolbarCollapseButton},children:o&&r?(0,he.jsxs)(he.Fragment,{children:[(0,he.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px"},children:(0,he.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",transform:c,transition:"transform 0.15s ease"},children:p})}),(0,he.jsx)("span",{style:{whiteSpace:"nowrap"},children:a?.collapseToolbar??"Collapse"}),(0,he.jsx)("span",{})]}):(0,he.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",transform:c,transition:"transform 0.15s ease"},children:p})})}function qo({position:e,orientation:t,showToolLabels:o,unstyled:r,activeToolInfo:n,labels:a,icons:l,classNames:s,styles:i,onExpand:d}){return(0,he.jsxs)("button",{type:"button","aria-label":a?.expandToolbar??"Expand toolbar",title:a?.expandToolbar??"Expand toolbar","data-toolbar-expand":"true",className:["rlc-toolbar-expand-btn",s?.toolbarCollapseButton].filter(Boolean).join(" "),onClick:d,style:{...r?{}:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"4px",padding:"3px 7px",borderRadius:"2px",backgroundColor:"#efefef",border:"1px solid #767676",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.15)",color:"#000000",cursor:"pointer",fontSize:"12px",fontWeight:"normal",boxSizing:"border-box"},...i?.toolbarCollapseButton},children:[n.icon,o&&(0,he.jsx)("span",{children:n.label}),(0,he.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",opacity:.8,transform:Xt(e,t),transition:"transform 0.15s ease"},children:l?.expandToolbar??z.expandToolbar})]})}function uo(e,t,o,r,n){return{...r?{}:t&&o?{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 10px",flexGrow:1,flexShrink:0,flexBasis:0,width:"auto",height:"auto",minHeight:"28px",borderRadius:"2px",border:"1px solid #767676",boxSizing:"border-box",backgroundColor:"#efefef",color:"#000000",opacity:e?1:.45,cursor:e?"pointer":"not-allowed",boxShadow:"none",fontSize:"12px",fontWeight:"normal",whiteSpace:"nowrap"}:{padding:t?"0":o?"2px 6px":"3px 6px",width:t?"30px":"auto",height:t?"30px":"auto",borderRadius:"2px",border:"1px solid #767676",boxSizing:"border-box",backgroundColor:"#efefef",color:"#000000",opacity:e?1:.45,cursor:e?"pointer":"not-allowed",boxShadow:"none",fontSize:"12px",fontWeight:"normal",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"4px",flexShrink:0},...n?.actionButton,...t&&!o?{padding:"0",width:n?.actionButton?.width??"30px",height:n?.actionButton?.height??"30px"}:void 0,...e?void 0:n?.actionButtonDisabled}}function fo(e,t,o,r,n,a){return{...r?{}:t&&o?{display:"grid",gridTemplateColumns:"20px 1fr auto",alignItems:"center",columnGap:"10px",padding:"8px 12px",textAlign:"left",width:"100%",height:"auto",borderRadius:"2px",border:"1px solid #767676",boxSizing:"border-box",backgroundColor:"#efefef",color:e,cursor:"pointer",fontSize:"12px",fontWeight:"normal",whiteSpace:"nowrap",boxShadow:"none",flexShrink:0}:{padding:t?"0":o?"2px 6px":"3px 6px",width:t?"30px":"auto",height:t?"30px":"auto",borderRadius:"2px",border:"1px solid #767676",boxSizing:"border-box",backgroundColor:"#efefef",color:e,cursor:"pointer",fontSize:"12px",fontWeight:"normal",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"4px",boxShadow:"none",flexShrink:0},...a,...n?.actionButton,...t&&!o?{padding:"0",width:n?.actionButton?.width??"30px",height:n?.actionButton?.height??"30px"}:void 0}}var oe=require("react/jsx-runtime");function Jo({readOnly:e,showHistoryControls:t,showDeleteButton:o,showClearButton:r,showToolLabels:n=!0,selectedItem:a,itemsCount:l,canUndo:s,canRedo:i,undo:d,redo:c,deleteSelected:p,clearAll:b,orientation:g="horizontal",labels:f,icons:u,unstyled:w,classNames:y,styles:x}){let h=g==="vertical";if(!(t||!e&&o&&a||!e&&r&&l>0))return null;let v=(m,S)=>h&&n?(0,oe.jsxs)(oe.Fragment,{children:[(0,oe.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px"},children:m}),(0,oe.jsx)("span",{style:{whiteSpace:"nowrap"},children:S}),(0,oe.jsx)("span",{})]}):(0,oe.jsxs)(oe.Fragment,{children:[m,n&&(0,oe.jsx)("span",{children:S})]}),E=m=>["rlc-action-btn",m?void 0:"rlc-action-btn-disabled",y?.actionButton,m?void 0:y?.actionButtonDisabled].filter(Boolean).join(" "),k=(0,oe.jsx)("button",{type:"button",title:f?.undo??"Undo","aria-label":f?.undo??"Undo",disabled:!s,className:E(s),onClick:d,style:uo(s,h,n,!!w,x),children:u?.undo??z.undo},"undo"),I=(0,oe.jsx)("button",{type:"button",title:f?.redo??"Redo","aria-label":f?.redo??"Redo",disabled:!i,className:E(i),onClick:c,style:uo(i,h,n,!!w,x),children:u?.redo??z.redo},"redo");return(0,oe.jsxs)(oe.Fragment,{children:[(0,oe.jsx)("div",{className:["rlc-toolbar-divider",y?.toolbarDivider].filter(Boolean).join(" "),style:{...w?{}:h?{width:n?"100%":"18px",height:"1px",backgroundColor:"#767676",margin:n?"3px 0":"3px auto"}:{width:"1px",height:"18px",backgroundColor:"#767676",margin:"0 3px"},...x?.toolbarDivider}}),t&&(h?(0,oe.jsxs)("div",{style:{display:"flex",flexDirection:n?"row":"column",alignItems:"center",justifyContent:"center",gap:"4px",width:n?"100%":"auto"},children:[k,I]}):(0,oe.jsxs)(oe.Fragment,{children:[k,I]})),!e&&o&&a&&(0,oe.jsx)("button",{type:"button",title:f?.delete??"Delete selected item (Del)","aria-label":f?.delete??"Delete selected item",className:["rlc-action-btn","rlc-delete-btn",y?.actionButton,y?.deleteButton].filter(Boolean).join(" "),onClick:p,style:fo("#b91c1c",h,n,!!w,x,x?.deleteButton),children:v(u?.delete??z.delete,f?.delete??"Delete")}),!e&&r&&l>0&&(0,oe.jsx)("button",{type:"button",title:f?.clear??"Clear all annotations","aria-label":f?.clear??"Clear all annotations",className:["rlc-action-btn",y?.actionButton].filter(Boolean).join(" "),onClick:b,style:fo("#000000",h,n,!!w,x),children:v(u?.clear??z.clear,f?.clear??"Clear")})]})}var nn=je(require("react"),1);var $t=je(require("react"),1);var re=require("react/jsx-runtime");function Qo({isOpen:e,readOnly:t,isArrowToolActive:o,activeTool:r,arrowOptions:n,arrowGroupLabel:a,currentArrowIcon:l,showToolLabels:s,icons:i,unstyled:d,classNames:c,styles:p,position:b="top-center",orientation:g="horizontal",arrowGroupRef:f,getButtonClassName:u,getButtonStyle:w,onToggle:y,onSelectOption:x}){let[h,T]=$t.default.useState(null),v=g==="vertical",E=Yt(b,g),k=Je(e,b,g),I=i?.dropdownChevron??z.dropdownChevron;return(0,re.jsxs)("div",{ref:f,className:["rlc-arrow-group",c?.arrowGroupWrapper].filter(Boolean).join(" "),style:{position:"relative",display:v?"flex":"inline-flex",width:v?s?"100%":"30px":"auto",height:v?s?"auto":"30px":"auto",alignItems:"center",justifyContent:"center",boxSizing:"border-box",...p?.arrowGroupWrapper},children:[(0,re.jsx)("button",{type:"button",disabled:t,"aria-disabled":t||void 0,"aria-pressed":o,"aria-haspopup":"menu","aria-expanded":e,"data-tool":"arrow-group","data-active":o||void 0,title:`${a} \u2014 click to choose arrow type`,className:u(o),onClick:y,style:w(o),children:v&&s?(0,re.jsxs)(re.Fragment,{children:[(0,re.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px"},children:l}),(0,re.jsx)("span",{style:{whiteSpace:"nowrap"},children:a}),(0,re.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",opacity:.9,transform:k,transition:"transform 0.15s ease"},children:I})]}):(0,re.jsxs)(re.Fragment,{children:[(0,re.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:s?"6px":"0px",...v&&!s?{transform:"translate(-1px, -1px)"}:void 0},children:[l,s&&(0,re.jsx)("span",{children:a})]}),(0,re.jsx)("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",opacity:.85,...v&&!s?{position:"absolute",right:"2px",bottom:"2px",width:"8px",height:"8px",lineHeight:0,pointerEvents:"none"}:{marginLeft:s?"6px":"2px"},transform:v&&!s?e?"rotate(180deg)":"rotate(0deg)":k,transition:"transform 0.15s ease"},children:v&&!s&&$t.default.isValidElement(I)?$t.default.cloneElement(I,{width:"100%",height:"100%",style:{width:"100%",height:"100%",display:"block",...I.props?.style??{}}}):I})]})}),e&&(0,re.jsx)("div",{role:"menu","aria-label":"Arrow type options",className:["rlc-arrow-dropdown",c?.arrowDropdownMenu].filter(Boolean).join(" "),style:{position:"absolute",zIndex:1020,...E,...d?{}:{minWidth:"190px",display:"flex",flexDirection:"column",gap:"2px",padding:"4px",backgroundColor:"#f0f0f0",border:"1px solid #767676",borderRadius:"2px",boxShadow:"2px 2px 5px rgba(0, 0, 0, 0.25)",color:"inherit",boxSizing:"border-box"},...p?.arrowDropdownMenu},children:n.map(m=>{let S=r===m.id,R=h===m.id;return(0,re.jsxs)("button",{type:"button",role:"menuitemradio","aria-checked":S,"data-tool":m.id,"data-active":S||void 0,className:["rlc-arrow-dropdown-item",c?.arrowDropdownItem,S?c?.arrowDropdownItemActive:void 0].filter(Boolean).join(" "),onClick:()=>x(m.id),onPointerEnter:()=>T(m.id),onPointerLeave:()=>T(null),style:{...d?{}:{display:"grid",gridTemplateColumns:"20px 1fr auto",alignItems:"center",columnGap:"10px",width:"100%",padding:"6px 10px",borderRadius:"2px",border:S?"1px solid #4f4f4f":"1px solid #767676",boxSizing:"border-box",backgroundColor:S?"#e0e0e0":R?"#e8e8e8":"#efefef",color:"inherit",fontSize:"12px",fontWeight:"normal",cursor:"pointer",textAlign:"left",boxShadow:S?"inset 1px 1px 2px rgba(0, 0, 0, 0.2)":"none"},...p?.arrowDropdownItem,...S?p?.arrowDropdownItemActive:void 0},children:[(0,re.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px"},children:m.icon}),(0,re.jsx)("span",{style:{whiteSpace:"nowrap"},children:m.label}),(0,re.jsx)("span",{style:{fontSize:"11px",opacity:S?.9:.65,fontWeight:500},children:m.shortcut})]},m.id)})})]})}var ho=je(require("react"),1);var en=je(require("react"),1),Qe=require("react/jsx-runtime");function tn({shapeOptions:e,activeShape:t,isShapeToolActive:o,unstyled:r,classNames:n,styles:a,onSelectShape:l}){let[s,i]=en.default.useState(null);return(0,Qe.jsx)("div",{className:["rlc-shapes-modal-grid",n?.shapesModalGrid].filter(Boolean).join(" "),style:{...r?{}:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:"4px",width:"100%",boxSizing:"border-box"},...a?.shapesModalGrid},children:e.map(d=>{let c=o&&t===d.kind,p=s===d.kind;return(0,Qe.jsxs)("button",{type:"button","data-shape":d.kind,"data-active":c||void 0,className:["rlc-shapes-modal-item",n?.shapesModalItem,c?n?.shapesModalItemActive:void 0].filter(Boolean).join(" "),onClick:()=>l(d.kind),onPointerEnter:()=>i(d.kind),onPointerLeave:()=>i(null),style:{...r?{}:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",width:"100%",minWidth:0,padding:"6px 8px",borderRadius:"2px",border:c?"1px solid #4f4f4f":"1px solid #767676",boxSizing:"border-box",backgroundColor:c?"#e0e0e0":p?"#e8e8e8":"#efefef",color:"#000000",fontSize:"12px",fontWeight:c?600:"normal",cursor:"pointer",textAlign:"left",transition:"background-color 0.1s ease",boxShadow:c?"inset 1px 1px 2px rgba(0, 0, 0, 0.2)":"none"},...a?.shapesModalItem,...c?a?.shapesModalItemActive:void 0},children:[(0,Qe.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,width:"18px",height:"18px"},children:d.icon}),(0,Qe.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",textAlign:"left"},children:d.label})]},d.kind)})})}var ie=require("react/jsx-runtime");function on({isOpen:e,readOnly:t,isShapeToolActive:o,activeShape:r,shapeOptions:n,shapesGroupLabel:a,currentShapeIcon:l,showToolLabels:s,labels:i,icons:d,unstyled:c,classNames:p,styles:b,position:g="top-center",orientation:f="horizontal",shapesGroupRef:u,getButtonClassName:w,getButtonStyle:y,onToggle:x,onSelectShape:h}){let T=f==="vertical",v=Yt(g,f),E=Je(e,g,f),k=d?.dropdownChevron??z.dropdownChevron;return(0,ie.jsxs)("div",{ref:u,className:["rlc-shapes-group",p?.shapesGroupWrapper].filter(Boolean).join(" "),style:{position:"relative",display:T?"flex":"inline-flex",width:T?s?"100%":"30px":"auto",height:T?s?"auto":"30px":"auto",alignItems:"center",justifyContent:"center",boxSizing:"border-box",...b?.shapesGroupWrapper},children:[(0,ie.jsx)("button",{type:"button",disabled:t,"aria-disabled":t||void 0,"aria-pressed":o,"aria-haspopup":"dialog","aria-expanded":e,"data-tool":"shape-group","data-active":o||void 0,title:`${a} \u2014 open shapes modal`,className:w(o),onClick:x,style:y(o),children:T&&s?(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px"},children:l}),(0,ie.jsx)("span",{style:{whiteSpace:"nowrap"},children:a}),(0,ie.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",opacity:.9,transform:E,transition:"transform 0.15s ease"},children:k})]}):(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:s?"6px":"0px",...T&&!s?{transform:"translate(-1px, -1px)"}:void 0},children:[l,s&&(0,ie.jsx)("span",{children:a})]}),(0,ie.jsx)("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",opacity:.85,...T&&!s?{position:"absolute",right:"2px",bottom:"2px",width:"8px",height:"8px",lineHeight:0,pointerEvents:"none"}:{marginLeft:s?"6px":"2px"},transform:T&&!s?e?"rotate(180deg)":"rotate(0deg)":E,transition:"transform 0.15s ease"},children:T&&!s&&ho.default.isValidElement(k)?ho.default.cloneElement(k,{width:"100%",height:"100%",style:{width:"100%",height:"100%",display:"block",...k.props?.style??{}}}):k})]})}),e&&(0,ie.jsxs)("div",{role:"dialog","aria-label":i?.shapesModalTitle??"Select a Shape",className:["rlc-shapes-modal",p?.shapesModal].filter(Boolean).join(" "),onKeyDown:I=>{I.key==="Escape"&&(I.stopPropagation(),x())},style:{position:"absolute",zIndex:1020,...v,...c?{}:{width:"240px",maxWidth:"calc(100vw - 24px)",maxHeight:"calc(100vh - 80px)",overflowY:"auto",overflowX:"hidden",padding:"4px",backgroundColor:"#f0f0f0",border:"1px solid #767676",borderRadius:"2px",boxShadow:"2px 2px 5px rgba(0, 0, 0, 0.25)",color:"inherit",boxSizing:"border-box"},...b?.shapesModal},children:[i?.shapesModalTitle&&(0,ie.jsx)("div",{className:["rlc-shapes-modal-header",p?.shapesModalHeader].filter(Boolean).join(" "),style:{...c?{}:{padding:"2px 4px 4px",fontSize:"11px",fontWeight:600,letterSpacing:"0.04em",color:"#000000",textTransform:"uppercase",borderBottom:"1px solid #767676",marginBottom:"4px"},...b?.shapesModalHeader},children:i.shapesModalTitle}),(0,ie.jsx)(tn,{shapeOptions:n,activeShape:r,isShapeToolActive:o,unstyled:c,classNames:p,styles:b,onSelectShape:h})]})]})}var le=require("react/jsx-runtime");function rn(e){let{controller:t,readOnly:o,position:r,orientation:n,isVertical:a,showToolLabels:l,enabledTools:s,customTools:i,labels:d,icons:c,unstyled:p,classNames:b,styles:g,arrowOptions:f,shapeOptions:u,arrowGroupLabel:w,currentArrowIcon:y,shapesGroupLabel:x,currentShapeIcon:h,isArrowToolActive:T,isShapeToolActive:v,arrowDropdownOpen:E,shapesModalOpen:k,arrowGroupRef:I,shapesGroupRef:m,setArrowDropdownOpen:S,setShapesModalOpen:R,getButtonClassName:B,getButtonStyle:F}=e,{activeTool:G,setActiveTool:$,activeShape:V,setActiveShape:C}=t,A=(P,N)=>a&&l?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px"},children:P}),(0,le.jsx)("span",{style:{whiteSpace:"nowrap"},children:N}),(0,le.jsx)("span",{})]}):(0,le.jsxs)(le.Fragment,{children:[P,l&&(0,le.jsx)("span",{children:N})]}),D=(P,N,_,H,K=!1)=>{let Z=G===P;return(0,le.jsx)("button",{type:"button",disabled:!K&&o,"aria-disabled":!K&&o?!0:void 0,"aria-pressed":Z,"data-tool":P,"data-active":Z||void 0,title:`${N} (${_})`,className:B(Z),onClick:()=>{!K&&o||($(P),S(!1),R(!1))},style:F(Z),children:A(H,N)},P)};return(0,le.jsxs)(le.Fragment,{children:[s.map(P=>P==="select"?D("select",d?.select??"Select","V",c?.select??z.select,!0):P==="freedraw"?D("freedraw",d?.freedraw??"Free Draw","P",c?.freedraw??z.freedraw):P==="ruler"?D("ruler",d?.ruler??"Ruler","R",c?.ruler??z.ruler):P==="note"?D("note",d?.note??"Note Card","N",c?.note??z.note):P==="text"?D("text",d?.text??"Normal Text","T",c?.text??z.text):P==="arrow"?(0,le.jsx)(Qo,{isOpen:E,readOnly:o,isArrowToolActive:T,activeTool:G,arrowOptions:f,arrowGroupLabel:w,currentArrowIcon:y,showToolLabels:l,labels:d,icons:c,unstyled:p,classNames:b,styles:g,position:r,orientation:n,arrowGroupRef:I,getButtonClassName:B,getButtonStyle:F,onToggle:()=>{o||(R(!1),S(N=>!N))},onSelectOption:N=>{$(N),S(!1)}},"arrow"):P==="shape"?(0,le.jsx)(on,{isOpen:k,readOnly:o,isShapeToolActive:v,activeShape:V,shapeOptions:u,shapesGroupLabel:x,currentShapeIcon:h,showToolLabels:l,labels:d,icons:c,unstyled:p,classNames:b,styles:g,position:r,orientation:n,shapesGroupRef:m,getButtonClassName:B,getButtonStyle:F,onToggle:()=>{o||(S(!1),R(N=>!N))},onSelectShape:N=>{C(N),$("shape"),R(!1)}},"shape"):null),i?.map(P=>{if(P.render)return(0,le.jsx)(nn.default.Fragment,{children:P.render(t)},P.id);let N=!!P.isActive;return(0,le.jsx)("button",{type:"button",disabled:P.disabled,"aria-pressed":N,title:P.title??P.label,className:B(N),onClick:()=>P.onClick?.(t),style:F(N),children:A(P.icon,P.label??"")},P.id)})]})}var et=require("react/jsx-runtime");function an(e){let{controller:t,readOnly:o,position:r,orientation:n,isVertical:a,showToolLabels:l,collapsible:s,showCollapseButton:i,enabledTools:d,customTools:c,showHistoryControls:p,showDeleteButton:b,showClearButton:g,labels:f,icons:u,unstyled:w,classNames:y,styles:x,arrowOptions:h,shapeOptions:T,arrowGroupLabel:v,currentArrowIcon:E,shapesGroupLabel:k,currentShapeIcon:I,isArrowToolActive:m,isShapeToolActive:S,arrowDropdownOpen:R,shapesModalOpen:B,arrowGroupRef:F,shapesGroupRef:G,setArrowDropdownOpen:$,setShapesModalOpen:V,getButtonClassName:C,getButtonStyle:A,onCollapse:D}=e;return(0,et.jsxs)("div",{role:"toolbar","aria-label":"Map annotation tools",className:["rlc-toolbar-primary",y?.toolbarPrimary].filter(Boolean).join(" "),style:{...w?{}:{display:"flex",flexDirection:a?"column":"row",alignItems:a&&l?"stretch":"center",gap:"3px",padding:"3px",boxSizing:"border-box",minWidth:a?l?"auto":"38px":void 0,width:a?l?"auto":"38px":void 0,backgroundColor:"#f0f0f0",border:"1px solid #767676",borderRadius:"2px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.2)",color:"#000000"},...x?.toolbarPrimary},children:[(0,et.jsx)(rn,{controller:t,readOnly:o,position:r,orientation:n,isVertical:a,showToolLabels:l,enabledTools:d,customTools:c,labels:f,icons:u,unstyled:w,classNames:y,styles:x,arrowOptions:h,shapeOptions:T,arrowGroupLabel:v,currentArrowIcon:E,shapesGroupLabel:k,currentShapeIcon:I,isArrowToolActive:m,isShapeToolActive:S,arrowDropdownOpen:R,shapesModalOpen:B,arrowGroupRef:F,shapesGroupRef:G,setArrowDropdownOpen:$,setShapesModalOpen:V,getButtonClassName:C,getButtonStyle:A}),(0,et.jsx)(Jo,{readOnly:o,showHistoryControls:p,showDeleteButton:b,showClearButton:g,showToolLabels:l,selectedItem:t.selectedItem,itemsCount:t.items.length,canUndo:t.canUndo,canRedo:t.canRedo,undo:t.undo,redo:t.redo,deleteSelected:t.deleteSelected,clearAll:t.clearAll,orientation:n,labels:f,icons:u,unstyled:w,classNames:y,styles:x}),s&&i&&(0,et.jsx)(Zo,{position:r,orientation:n,isVertical:a,showToolLabels:l,unstyled:w,labels:f,icons:u,classNames:y,styles:x,onCollapse:D})]})}var tt=require("react");var Me=require("react/jsx-runtime");function Ct({label:e,value:t,options:o,onChange:r,control:n,unstyled:a,classNames:l,styles:s,icons:i}){let d=Array.from(new Set([...o,t])).sort((p,b)=>p-b),c=i?.dropdownChevron??z.dropdownChevron;return(0,Me.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[(0,Me.jsx)("span",{style:{fontSize:"12px",color:"inherit"},children:e}),(0,Me.jsxs)("div",{style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[(0,Me.jsx)("select",{"aria-label":e,"data-control":n,value:t,onChange:p=>r(Number(p.target.value)),className:["rlc-toolbar-select",l?.toolbarSelect].filter(Boolean).join(" "),style:{...a?{}:{padding:"1px 16px 1px 4px",borderRadius:"2px",border:"1px solid #767676",backgroundColor:"#efefef",color:"#000000",fontSize:"12px",cursor:"pointer",appearance:"none",WebkitAppearance:"none"},...s?.toolbarSelect},children:d.map(p=>(0,Me.jsxs)("option",{value:p,children:[p,"px"]},p))}),!a&&(0,Me.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",right:"3px",top:"50%",transform:"translateY(-50%)",pointerEvents:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",opacity:.7,color:"currentColor"},children:c})]})]})}var Q=require("react/jsx-runtime");function ln(e){let{isArrowContext:t,isFreeDrawContext:o,isShapeContext:r,isRulerContext:n,isTextContext:a,isNoteContext:l,selectedItem:s,selectedShape:i,selectedArrow:d,selectedText:c,activeColor:p,setActiveColor:b,strokeWidth:g,setStrokeWidth:f,strokeWidthOptions:u,dashed:w,setDashed:y,shapeFilled:x,setShapeFilled:h,noteColor:T,setNoteColor:v,fontSize:E,setFontSize:k,fontSizeOptions:I,fontWeight:m,setFontWeight:S,updateItem:R,notifyChangeComplete:B,isEditingLabel:F,setEditingLabel:G,strokeColors:$,orientation:V="horizontal",labels:C,icons:A,unstyled:D,classNames:P,styles:N}=e,_=V==="vertical",H=(0,tt.useRef)(null),K=(0,tt.useRef)(null),Z=(0,tt.useRef)(null),q=i?i.labelMode!==!1&&i.hasLabelMode!==!1:!1,de=d?d.labelMode!==!1&&d.hasLabelMode!==!1:!1;(0,tt.useEffect)(()=>{F&&(i&&q&&H.current?(H.current.focus(),H.current.select()):d&&de&&K.current&&(K.current.focus(),K.current.select()))},[F,i?.id,d?.id,q,de]);let ce=(W,J=!1)=>({...D?{}:{padding:"2px 6px",borderRadius:"2px",border:W?"1px solid #4f4f4f":"1px solid #767676",backgroundColor:W?"#e0e0e0":"#efefef",color:"#000000",boxShadow:W?"inset 1px 1px 2px rgba(0, 0, 0, 0.2)":"none",fontSize:"12px",fontWeight:J?700:void 0,cursor:"pointer"},...N?.actionButton,...W?N?.toolButtonActive:void 0}),j=W=>["rlc-action-btn",P?.actionButton,W?P?.toolButtonActive:void 0].filter(Boolean).join(" "),U=(W="105px")=>({...D?{}:{minWidth:"100px",width:_?"auto":W,flex:_?"1 1 auto":void 0,boxSizing:"border-box",padding:"2px 4px",borderRadius:"2px",border:"1px solid #767676",backgroundColor:"#ffffff",color:"#000000",fontSize:"12px"},...N?.toolbarInput}),L=(0,Q.jsx)("div",{className:["rlc-toolbar-divider",P?.toolbarDivider].filter(Boolean).join(" "),style:{...D?{}:_?{width:"100%",height:"1px",backgroundColor:"#767676"}:{width:"1px",height:"16px",backgroundColor:"#767676"},...N?.toolbarDivider}}),O=!!(s&&(s.type==="arrow"||s.type==="freedraw"||s.type==="shape"||s.type==="ruler")?s.dashed:w),Y=!!(i?i.filled:x),ne=c?c.fontWeight==="bold":(m??"bold")==="bold";return(0,Q.jsxs)("div",{className:["rlc-toolbar-secondary",P?.toolbarSecondary].filter(Boolean).join(" "),style:{...D?{}:{display:"flex",flexDirection:"row",flexWrap:_?"wrap":"nowrap",alignItems:"center",gap:_?"5px":"6px",padding:_?"6px 8px":"3px 6px",width:_?"230px":void 0,maxWidth:_?"230px":"min(92vw, 620px)",overflowX:_?"visible":"auto",scrollbarWidth:"none",boxSizing:"border-box",backgroundColor:"#f0f0f0",border:"1px solid #767676",borderRadius:"2px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.2)",color:"#000000",fontSize:"12px"},...N?.toolbarSecondary},children:[(t||o||r||n||a)&&(0,Q.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px",width:_?"100%":void 0},children:[(0,Q.jsx)("span",{style:{fontSize:"12px",color:"inherit"},children:C?.color??"Color"}),$.map(W=>{let J=(s&&s.type!=="note"?s.color:p)===W;return(0,Q.jsx)("button",{type:"button",title:`${C?.color??"Color"} ${W}`,"data-active":J||void 0,className:["rlc-swatch-btn",P?.swatchButton,J?P?.swatchButtonActive:void 0].filter(Boolean).join(" "),onClick:()=>b(W),style:{backgroundColor:W,...D?{}:{width:"16px",height:"16px",borderRadius:"999px",border:J?"2px solid #000000":"1px solid #767676",boxShadow:J?"0 0 0 1px #000000":"none",cursor:"pointer",padding:0},...N?.swatchButton,...J?N?.swatchButtonActive:void 0}},W)})]}),(t||o||r||n)&&(0,Q.jsxs)(Q.Fragment,{children:[L,(0,Q.jsx)(Ct,{label:C?.width??"Width",control:"stroke-width",value:s&&(s.type==="arrow"||s.type==="freedraw"||s.type==="shape"||s.type==="ruler")?s.strokeWidth:g,options:u??Mt,onChange:f,unstyled:D,classNames:P,styles:N,icons:A}),(0,Q.jsx)("button",{type:"button","data-active":O||void 0,className:j(O),onClick:()=>y(!O),style:ce(O),children:C?.dashed??"Dashed"})]}),r&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)("button",{type:"button","data-active":Y||void 0,className:j(Y),onClick:()=>h(!Y),style:ce(Y),children:C?.filled??"Fill"}),i&&q&&(0,Q.jsx)("input",{ref:H,type:"text","data-tual-shape-label-input":i.id,"data-testid":"shape-label-input","data-label-mode":"true","data-editing-label":F?"true":void 0,placeholder:C?.shapeLabelPlaceholder??"Shape label...",value:i.label??"",className:["rlc-toolbar-input",P?.toolbarInput].filter(Boolean).join(" "),onChange:W=>R(i.id,{label:W.target.value}),onFocus:()=>G?.(!0),onBlur:W=>{let J=W.relatedTarget;J?.tagName==="INPUT"||J?.tagName==="TEXTAREA"||J?.closest("[data-tual-toolbar], [data-tual-inline-shape-label]")||(G?.(!1),B?.(i))},onKeyDown:W=>{(W.key==="Enter"||W.key==="Escape")&&(W.preventDefault(),G?.(!1),W.currentTarget.blur(),B?.(i))},style:U()})]}),d&&de&&(0,Q.jsx)("input",{ref:K,type:"text","data-tual-arrow-label-input":d.id,"data-testid":"arrow-label-input","data-label-mode":"true","data-editing-label":F?"true":void 0,placeholder:C?.arrowLabelPlaceholder??"Arrow label...",value:d.label??"",className:["rlc-toolbar-input",P?.toolbarInput].filter(Boolean).join(" "),onChange:W=>R(d.id,{label:W.target.value}),onFocus:()=>G?.(!0),onBlur:()=>{G?.(!1),B?.(d)},onKeyDown:W=>{(W.key==="Enter"||W.key==="Escape")&&(W.preventDefault(),G?.(!1),W.currentTarget.blur(),B?.(d))},style:U()}),a&&(0,Q.jsxs)(Q.Fragment,{children:[L,(0,Q.jsx)(Ct,{label:C?.fontSize??"Size",control:"font-size",value:c?c.initialFontSize??E??16:E??16,options:I??Et,onChange:W=>k?.(W),unstyled:D,classNames:P,styles:N,icons:A}),(0,Q.jsx)("button",{type:"button","data-active":ne||void 0,title:C?.textBold??"Toggle bold","aria-pressed":ne,className:j(ne),onClick:()=>S?.(ne?"normal":"bold"),style:ce(ne,!0),children:A?.textBold??z.textBold??C?.textBold??"B"}),c&&(0,Q.jsx)("input",{ref:Z,type:"text","data-tual-text-input":c.id,"data-testid":"text-input","data-editing-label":F?"true":void 0,placeholder:C?.textPlaceholder??"Text...",value:c.text??"",className:["rlc-toolbar-input",P?.toolbarInput].filter(Boolean).join(" "),onChange:W=>R(c.id,{text:W.target.value}),onFocus:()=>G?.(!0),onBlur:W=>{let J=W.relatedTarget;J?.tagName==="INPUT"||J?.tagName==="TEXTAREA"||J?.closest("[data-tual-text], [data-tual-toolbar]")||(G?.(!1),B?.(c))},onKeyDown:W=>{(W.key==="Enter"||W.key==="Escape")&&(W.preventDefault(),G?.(!1),W.currentTarget.blur(),B?.(c))},style:U("120px")})]}),l&&(0,Q.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(0,Q.jsx)("span",{style:{opacity:.75,fontSize:"11px"},children:C?.noteTheme??"Theme"}),ue.map(W=>{let J=(s?.type==="note"?s.backgroundColor:T)===W.bg;return(0,Q.jsx)("button",{type:"button",title:W.name,"data-active":J||void 0,className:["rlc-swatch-btn",P?.swatchButton,J?P?.swatchButtonActive:void 0].filter(Boolean).join(" "),onClick:()=>v(W.bg),style:{backgroundColor:W.header,...D?{}:{width:"18px",height:"18px",borderRadius:"999px",border:J?"2px solid #111827":`1px solid ${W.border}`,boxShadow:J?"0 0 0 1px #111827":"none",cursor:"pointer",padding:0},...N?.swatchButton,...J?N?.swatchButtonActive:void 0}},W.name)})]})]})}var Ee=require("react");function sn(e,t){let{activeTool:o,selectedItem:r}=e,[n,a]=(0,Ee.useState)(!1),[l,s]=(0,Ee.useState)(!1),i=(0,Ee.useRef)(null),d=(0,Ee.useRef)(null);(0,Ee.useEffect)(()=>{if(!n&&!l)return;let h=T=>{n&&i.current&&!i.current.contains(T.target)&&a(!1),l&&d.current&&!d.current.contains(T.target)&&s(!1)};return window.addEventListener("pointerdown",h),()=>window.removeEventListener("pointerdown",h)},[n,l]);let c=Vo(o),p=o==="shape",b=c||r?.type==="arrow",g=o==="freedraw"||r?.type==="freedraw",f=p||r?.type==="shape",u=o==="ruler"||r?.type==="ruler",w=o==="note"||r?.type==="note",y=o==="text"||r?.type==="text";return{isArrowToolActive:c,isShapeToolActive:p,isArrowContext:b,isFreeDrawContext:g,isShapeContext:f,isRulerContext:u,isNoteContext:w,isTextContext:y,showSettingsBar:!t&&!n&&!l&&(b||g||f||u||y||w),arrowDropdownOpen:n,setArrowDropdownOpen:a,shapesModalOpen:l,setShapesModalOpen:s,arrowGroupRef:i,shapesGroupRef:d}}var Be=require("react/jsx-runtime");function Vt({controller:e,position:t="top-center",orientation:o,collapsible:r=!0,defaultCollapsed:n=!1,collapsed:a,onCollapsedChange:l,showCollapseButton:s=!0,readOnly:i,enabledTools:d=zo,customTools:c,showHistoryControls:p=!0,showDeleteButton:b=!0,showClearButton:g=!0,showToolLabels:f,labels:u,icons:w,unstyled:y=!1,classNames:x,styles:h,strokeColors:T=Jt,strokeWidthOptions:v,fontSizeOptions:E,className:k,style:I}){let m=!!(i??e.readOnly),R=o??(t==="left"||t==="right"||t==="left-center"||t==="right-center"?"vertical":"horizontal"),B=R==="vertical",F=f??!B,[G,$]=(0,dn.useState)(n),V=a!==void 0?a:G,C=me=>{a===void 0&&$(me),l?.(me)},{activeTool:A,activeShape:D,selectedItem:P}=e,{isArrowToolActive:N,isShapeToolActive:_,isArrowContext:H,isFreeDrawContext:K,isShapeContext:Z,isRulerContext:q,isNoteContext:de,isTextContext:ce,showSettingsBar:j,arrowDropdownOpen:U,setArrowDropdownOpen:L,shapesModalOpen:O,setShapesModalOpen:Y,arrowGroupRef:ne,shapesGroupRef:W}=sn(e,m),J=Go(u,w),Ce=_o(u,w),It=J.find(me=>me.id===A),mo=u?.arrowGroup??(It?It.label:"Arrows"),go=w?.arrowGroup??(It?It.icon:z.arrowLinear),Rt=Ce.find(me=>me.kind===D),bo=u?.shapesGroup??(_&&Rt?Rt.label:"Shapes"),yo=w?.shapesGroup??(_&&Rt?Rt.icon:z.shapesGroup),Cn=Xo(A,N,go,mo,yo,bo,w,u),Re=me=>me.stopPropagation();return V?(0,Be.jsx)("div",{"data-tual-toolbar":!0,"data-readonly":m||void 0,"data-position":t,"data-orientation":R,"data-collapsed":"true",className:["rlc-toolbar","rlc-toolbar-collapsed",m?"rlc-toolbar-readonly":void 0,x?.toolbar,x?.toolbarCollapsed,k].filter(Boolean).join(" "),onClick:Re,onDoubleClick:Re,onPointerDown:Re,onWheel:Re,style:{position:"absolute",zIndex:1e3,pointerEvents:"auto",userSelect:"none",...po[t],...h?.toolbar,...h?.toolbarCollapsed,...I},children:(0,Be.jsx)(qo,{position:t,orientation:R,showToolLabels:F,unstyled:y,activeToolInfo:Cn,labels:u,icons:w,classNames:x,styles:h,onExpand:()=>C(!1)})}):(0,Be.jsxs)("div",{"data-tual-toolbar":!0,"data-readonly":m||void 0,"data-position":t,"data-orientation":R,className:["rlc-toolbar",m?"rlc-toolbar-readonly":void 0,x?.toolbar,k].filter(Boolean).join(" "),onClick:Re,onDoubleClick:Re,onPointerDown:Re,onWheel:Re,style:{position:"absolute",zIndex:1e3,pointerEvents:"auto",userSelect:"none",...po[t],...Ko(t,B,y),...h?.toolbar,...I},children:[(0,Be.jsx)(an,{controller:e,readOnly:m,position:t,orientation:R,isVertical:B,showToolLabels:F,collapsible:r,showCollapseButton:s,enabledTools:d,customTools:c,showHistoryControls:p,showDeleteButton:b,showClearButton:g,labels:u,icons:w,unstyled:y,classNames:x,styles:h,arrowOptions:J,shapeOptions:Ce,arrowGroupLabel:mo,currentArrowIcon:go,shapesGroupLabel:bo,currentShapeIcon:yo,isArrowToolActive:N,isShapeToolActive:_,arrowDropdownOpen:U,shapesModalOpen:O,arrowGroupRef:ne,shapesGroupRef:W,setArrowDropdownOpen:L,setShapesModalOpen:Y,getButtonClassName:me=>Yo(me,x),getButtonStyle:me=>Uo(me,B,F,m,y,h),onCollapse:()=>C(!0)}),j&&(0,Be.jsx)(ln,{isArrowContext:H,isFreeDrawContext:K,isShapeContext:Z,isRulerContext:q,isTextContext:ce,isNoteContext:de,selectedItem:P,selectedShape:P?.type==="shape"?P:null,selectedArrow:P?.type==="arrow"?P:null,selectedText:P?.type==="text"?P:null,activeColor:e.activeColor,setActiveColor:e.setActiveColor,strokeWidth:e.strokeWidth,setStrokeWidth:e.setStrokeWidth,strokeWidthOptions:v,dashed:e.dashed,setDashed:e.setDashed,shapeFilled:e.shapeFilled,setShapeFilled:e.setShapeFilled,noteColor:e.noteColor,setNoteColor:e.setNoteColor,fontSize:e.fontSize,setFontSize:e.setFontSize,fontSizeOptions:E,fontWeight:e.fontWeight,setFontWeight:e.setFontWeight,updateItem:e.updateItem,notifyChangeComplete:e.notifyChangeComplete,isEditingLabel:e.isEditingLabel,setEditingLabel:e.setEditingLabel,strokeColors:T,orientation:R,labels:u,icons:w,unstyled:y,classNames:x,styles:h})]})}var wn=require("react-dom"),Tn=require("react-leaflet");var ve=require("react/jsx-runtime");function cn(e){let{map:t,canvasRef:o,viewport:r,isReadOnly:n,isDrawingTool:a,activeTool:l,hoverCursor:s,zIndex:i,className:d,style:c,classNames:p,styles:b,handleInteractionPointerDown:g,handleInteractionPointerMove:f,noteItems:u,textItems:w,selectedId:y,labels:x,icons:h,unstyled:T,clampOverlaysToViewport:v,autoMinimizeNotesZoom:E,autoMinimizeTextZoom:k,renderNote:I,renderText:m,setSelectedId:S,updateItem:R,removeItem:B,notifyChangeComplete:F,renderToolbar:G,showToolbar:$,controller:V,toolbarPosition:C,toolbarOrientation:A,collapsible:D,defaultCollapsed:P,collapsed:N,onCollapsedChange:_,showCollapseButton:H,enabledTools:K,customTools:Z,showHistoryControls:q,showDeleteButton:de,showClearButton:ce,showToolLabels:j,strokeColors:U,strokeWidthOptions:L,fontSizeOptions:O}=e;return(0,ve.jsxs)("div",{className:["rlc-overlay",n?"rlc-readonly":void 0,p?.overlay,d].filter(Boolean).join(" "),"data-tual-overlay":!0,"data-readonly":n||void 0,style:{position:"absolute",inset:0,zIndex:i,pointerEvents:"none",overflow:"hidden",...b?.overlay,...c},children:[(0,ve.jsx)("canvas",{ref:o,className:["rlc-canvas",p?.canvas].filter(Boolean).join(" "),style:{position:"absolute",inset:0,width:`${r.width}px`,height:`${r.height}px`,pointerEvents:"none",...b?.canvas}}),a&&(0,ve.jsx)("div",{"data-tual-drawing-surface":!0,className:["rlc-drawing-surface",p?.drawingSurface].filter(Boolean).join(" "),onPointerDown:g,onPointerMove:f,style:{position:"absolute",inset:0,pointerEvents:"auto",cursor:l==="text"?"text":"crosshair",...b?.drawingSurface}}),s&&!a&&(0,ve.jsx)("style",{children:`.leaflet-container { cursor: ${s} !important; }`}),(0,ve.jsxs)("div",{className:["rlc-items-container",p?.itemsContainer].filter(Boolean).join(" "),style:{position:"absolute",inset:0,pointerEvents:"none",...b?.itemsContainer},children:[u.map(Y=>(0,ve.jsx)(io,{item:Y,screenPos:te(t,Y.position),isSelected:!n&&Y.id===y,map:t,readOnly:n,labels:x,icons:h,unstyled:T,classNames:p,styles:b,clampToViewport:v,autoMinimizeZoomThreshold:E,renderNote:I,onSelect:S,onUpdate:R,onDelete:B,onComplete:F},Y.id)),w.map(Y=>(0,ve.jsx)(lo,{item:Y,screenPos:te(t,Y.position),isSelected:!n&&Y.id===y,isEditingLabel:!n&&Y.id===y&&!!V.isEditingLabel,map:t,readOnly:n,labels:x,icons:h,unstyled:T,classNames:p,styles:b,clampToViewport:v,autoMinimizeZoomThreshold:k,renderText:m,onSelect:S,onUpdate:R,onDelete:B,onComplete:F},Y.id)),!$&&V.isEditingLabel&&y&&(()=>{let Y=V.items.find(W=>W.id===y&&W.type==="shape");return!Y||!(Y.labelMode!==!1&&Y.hasLabelMode!==!1)?null:(0,ve.jsx)(ao,{shape:Y,map:t,labels:x,onUpdate:R,onClose:()=>{V.setEditingLabel?.(!1),F(Y)}})})()]}),G?G(V):$&&(0,ve.jsx)(Vt,{controller:V,position:C,orientation:A,collapsible:D,defaultCollapsed:P,collapsed:N,onCollapsedChange:_,showCollapseButton:H,readOnly:n,enabledTools:K,customTools:Z,showHistoryControls:q,showDeleteButton:de,showClearButton:ce,showToolLabels:j,labels:x,icons:h,unstyled:T,classNames:p,styles:b,strokeColors:U,strokeWidthOptions:L,fontSizeOptions:O})]})}var Pt=require("react");var Zt=require("react");function pn({map:e,viewport:t,canvasRef:o,arrowItems:r,shapeItems:n,freeDrawItems:a,rulerItems:l,selectedId:s,draftShape:i,draftArrow:d,draftRuler:c,draftFreeDrawRef:p,activeColor:b,strokeWidth:g,dashed:f,shapeFilled:u,annotationTheme:w,arrowTheme:y,isReadOnly:x}){let h=(0,Zt.useCallback)(()=>{Tt({map:e,canvas:o.current,width:t.width,height:t.height,arrowItems:r,shapeItems:n,freeDrawItems:a,rulerItems:l,selectedId:s,draftShape:i,draftArrow:d,draftRuler:c,draftFreeDraw:p.current,activeColor:b,strokeWidth:g,dashed:f,shapeFilled:u,annotationTheme:w,arrowTheme:y,isReadOnly:x})},[e,o,t.width,t.height,a,n,r,l,s,i,d,c,p,b,g,f,u,w,y,x]);return(0,Zt.useEffect)(()=>{h()},[h,t.tick]),h}var un=require("react");function fn({isReadOnly:e,selectedId:t,selectedItem:o,items:r,isEditingLabel:n,setEditingLabel:a,deleteSelected:l,setSelectedId:s,setActiveTool:i,setDraftArrow:d,setDraftShape:c,setDraftRuler:p,clearDraftFreeDraw:b,notifyChangeComplete:g}){(0,un.useEffect)(()=>{if(e)return;let f=u=>{let w=u.target;if(!(w&&(w.tagName==="INPUT"||w.tagName==="TEXTAREA"||w.isContentEditable))){if(u.key==="Escape")d(null),c(null),p?.(null),b(),s(null),i("select"),g?.();else if(u.key==="Delete"||u.key==="Backspace")t&&(u.preventDefault(),l());else if(u.key==="Enter"){let y=o??r?.find(x=>x.id===t);if(y&&y.type==="shape"){let x=y;if(x.labelMode!==!1&&x.hasLabelMode!==!1){u.preventDefault(),a?.(!0);let T=()=>{let v=document.querySelector(`[data-tual-shape-label-input="${x.id}"], [data-tual-shape-label-input], input[placeholder*="Shape label"]`);v&&(v.focus(),v.select())};T(),typeof requestAnimationFrame=="function"&&requestAnimationFrame(T),setTimeout(T,0)}}else if(y&&y.type==="text"){u.preventDefault(),a?.(!0);let x=()=>{let h=document.querySelector(`[data-tual-text="${y.id}"] textarea, [data-tual-text="${y.id}"] input, [data-tual-text] textarea`);h&&(h.focus(),"select"in h&&typeof h.select=="function"&&h.select())};x(),typeof requestAnimationFrame=="function"&&requestAnimationFrame(x),setTimeout(x,0)}else if(y&&y.type==="note"){u.preventDefault(),a?.(!0);let x=()=>{let h=document.querySelector(`[data-tual-note="${y.id}"] textarea, [data-tual-note="${y.id}"] input, [data-tual-note] textarea`);h&&h.focus()};x(),typeof requestAnimationFrame=="function"&&requestAnimationFrame(x),setTimeout(x,0)}else if(y&&y.type==="arrow"){let x=y;if(x.labelMode!==!1&&x.hasLabelMode!==!1){u.preventDefault(),a?.(!0);let T=()=>{let v=document.querySelector(`[data-tual-arrow-label-input="${x.id}"], [data-tual-arrow-label-input], input[placeholder*="Arrow label"]`);v&&(v.focus(),v.select())};T(),typeof requestAnimationFrame=="function"&&requestAnimationFrame(T),setTimeout(T,0)}}}else if(!u.metaKey&&!u.ctrlKey&&!u.altKey){let y=u.key.toLowerCase();y==="v"?i("select"):y==="p"?i("freedraw"):y==="r"?i("ruler"):y==="a"?i("arrow-linear"):y==="c"?i("arrow-curved"):y==="b"?i("arrow-bi"):y==="e"?i("arrow-elbow"):y==="s"?i("arrow-s-curve"):y==="n"?i("note"):y==="t"&&i("text")}}};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[e,t,o,r,a,l,s,i,d,c,p,b,g])}var qt=require("react");function hn({map:e,activeTool:t,isReadOnly:o,arrowItems:r,shapeItems:n,freeDrawItems:a,rulerItems:l,selectedId:s,setSelectedId:i,setEditingLabel:d,updateItem:c,notifyChangeComplete:p}){let[b,g]=(0,qt.useState)(null);return(0,qt.useEffect)(()=>{if(!e||t!=="select"||o){g(null);return}let f=e.getContainer(),u=h=>{let T=f.getBoundingClientRect();return{x:h.clientX-T.left,y:h.clientY-T.top}},w=h=>{if(h.target?.closest("[data-tual-toolbar], [data-tual-note], [data-tual-text]")){g(null);return}let v=u(h),E=r.find(m=>m.id===s);if(E&&Ge(v,ge(e,E),E)){g("crosshair");return}let k=n.find(m=>m.id===s);if(k&&Ye(v,pe(e,k))){g("nwse-resize");return}let I=l.find(m=>m.id===s);if(I&&Ke(v,be(e,I))){g("crosshair");return}for(let m=r.length-1;m>=0;m-=1){let S=r[m];if(_e(v,ge(e,S),S)){g("pointer");return}}for(let m=n.length-1;m>=0;m-=1)if(Ae(v,pe(e,n[m]))){g("pointer");return}for(let m=a.length-1;m>=0;m-=1){let S=a[m];if(Ue(v,De(e,S),S)){g("pointer");return}}for(let m=l.length-1;m>=0;m-=1){let S=l[m];if(Xe(v,be(e,S),S)){g("pointer");return}}g(null)},y=h=>{if(h.button!==0||h.target?.closest("[data-tual-toolbar], [data-tual-note], [data-tual-text], .leaflet-control"))return;let v=u(h),E=r.find(m=>m.id===s);if(E){let m=ge(e,E),S=Ge(v,m,E);if(S){h.stopPropagation(),h.preventDefault(),ht(e,E,m,S,u,c);return}}let k=n.find(m=>m.id===s);if(k){let m=pe(e,k),S=Ye(v,m);if(S){h.stopPropagation(),h.preventDefault(),mt(e,k,m,S,u,c);return}}let I=l.find(m=>m.id===s);if(I){let m=be(e,I),S=Ke(v,m);if(S){h.stopPropagation(),h.preventDefault(),xt(e,I,m,S,u,c);return}}for(let m=r.length-1;m>=0;m-=1){let S=r[m],R=ge(e,S);if(_e(v,R,S)){h.stopPropagation(),h.preventDefault(),i(S.id),gt(e,S,R,v,u,c);return}}for(let m=n.length-1;m>=0;m-=1){let S=n[m],R=pe(e,S);if(Ae(v,R)){h.stopPropagation(),h.preventDefault(),i(S.id),bt(e,S,R,v,u,c);return}}for(let m=a.length-1;m>=0;m-=1){let S=a[m],R=De(e,S);if(Ue(v,R,S)){h.stopPropagation(),h.preventDefault(),i(S.id),yt(e,S,R,v,u,c);return}}for(let m=l.length-1;m>=0;m-=1){let S=l[m],R=be(e,S);if(Xe(v,R,S)){h.stopPropagation(),h.preventDefault(),i(S.id),wt(e,S,R,v,u,c);return}}s&&(i(null),p?.())},x=h=>{if(h.target?.closest("[data-tual-toolbar], [data-tual-note], [data-tual-text], .leaflet-control"))return;let v=f.getBoundingClientRect(),E={x:h.clientX-v.left,y:h.clientY-v.top};for(let k=n.length-1;k>=0;k-=1){let I=n[k],m=pe(e,I);if(Ae(E,m)){if(h.stopPropagation(),h.preventDefault(),i(I.id),I.labelMode!==!1&&I.hasLabelMode!==!1){d?.(!0);let R=()=>{let B=document.querySelector(`[data-tual-shape-label-input="${I.id}"], [data-tual-shape-label-input], input[placeholder*="Shape label"]`);B&&(B.focus(),B.select())};R(),typeof requestAnimationFrame=="function"&&requestAnimationFrame(R),setTimeout(R,0)}return}}};return f.addEventListener("pointermove",w),f.addEventListener("pointerdown",y,{capture:!0}),f.addEventListener("dblclick",x,{capture:!0}),()=>{f.removeEventListener("pointermove",w),f.removeEventListener("pointerdown",y,{capture:!0}),f.removeEventListener("dblclick",x,{capture:!0})}},[e,t,r,n,a,s,i,d,c,o]),b}var We=require("react");function mn({map:e,activeTool:t,setActiveTool:o,activeShape:r,shapeFilled:n,activeColor:a,strokeWidth:l,dashed:s,noteColor:i,fontSize:d,fontWeight:c,labels:p,addItem:b,paintCanvas:g}){let[f,u]=(0,We.useState)(null),[w,y]=(0,We.useState)(null),[x,h]=(0,We.useState)(null),T=(0,We.useRef)(null),v=(0,We.useRef)(null),E=()=>{T.current=null,v.current!==null&&(window.cancelAnimationFrame(v.current),v.current=null)},k=S=>{if(!e)return{x:0,y:0};let R=e.getContainer().getBoundingClientRect();return{x:S.clientX-R.left,y:S.clientY-R.top}};return{draftArrow:f,setDraftArrow:u,draftShape:w,setDraftShape:y,draftRuler:x,setDraftRuler:h,draftFreeDrawRef:T,clearDraftFreeDraw:E,handleInteractionPointerDown:S=>{if(S.button!==0||!e)return;S.stopPropagation(),S.preventDefault();let R=e.getContainer(),B=k(S),F=X(e,B);if(t==="freedraw"){$e(e,R,B,F,a,l,s,T,v,g,b,o);return}if(t==="shape"){pt(e,R,B,F,r,a,n,l,s,y,b,o);return}if(t==="ruler"){ft(e,R,B,F,a,l,s,h,b,o);return}if(t==="note"){b(dt(F,i,p?.noteDefaultTitle)),S.shiftKey||o("select");return}if(t==="text"){let $=typeof e?.getZoom=="function"?e.getZoom():14;b(ct(F,a,d,c,$)),S.shiftKey||o("select");return}let G=Fe[t];if(G){if(f){let $=te(e,f.startGeo),V=S.shiftKey?se($,B):B;b(Ve(f.arrowStyle,f.startGeo,X(e,V),a,l,s)),u(null),o("select");return}ut(e,R,B,F,G,a,l,s,u,b,o)}},handleInteractionPointerMove:S=>{if(!f||!e)return;let R=k(S),B=te(e,f.startGeo),F=S.shiftKey?se(B,R):R;u(G=>G?{...G,currentGeo:X(e,F)}:null)}}}var gn=require("react");function bn(e){(0,gn.useEffect)(()=>{if(e)return vt(e)},[e])}var ot=require("react");function He(e,t){let o=(0,ot.useRef)([]);return(0,ot.useMemo)(()=>{let r=e.filter(n=>n.type===t);return o.current.length===r.length&&o.current.every((n,a)=>n===r[a])?o.current:(o.current=r,r)},[e,t])}function yn(e,t,o,r,n,a,l){(0,ot.useEffect)(()=>{if(!e||t)return;let s=i=>{if(i.button!==0)return;let d=i.target;e.getContainer().contains(d)||d?.closest?.("[data-tual-overlay], [data-tual-toolbar], [data-tual-note], [data-tual-text], .leaflet-control")||(o!=="select"&&r("select"),n&&a(null),l())};return window.addEventListener("pointerdown",s),()=>window.removeEventListener("pointerdown",s)},[e,t,o,r,n,a,l])}function xn(e){let{map:t,controller:o,readOnly:r,showToolbar:n,annotationTheme:a,arrowTheme:l,labels:s,...i}=e,d=!!(r??o?.readOnly??!1),c=co({...i,readOnly:d}),p=o??c,b=n??!d,g=(0,Pt.useRef)(i);g.current=i;let f=(0,Pt.useCallback)(Ce=>{p.notifyChangeComplete(Ce),o&&(g.current.onItemsChangeComplete?.(p.items,Ce),g.current.onChangeComplete?.(p.items,Ce),g.current.onEditEnd?.(p.items,Ce),g.current.onEditComplete?.(p.items,Ce),Ce&&g.current.onItemChangeComplete?.(Ce))},[p,o]),{items:u,activeTool:w,setActiveTool:y,activeShape:x,shapeFilled:h,selectedId:T,setSelectedId:v,activeColor:E,strokeWidth:k,dashed:I,noteColor:m,fontSize:S,fontWeight:R,addItem:B,updateItem:F,removeItem:G,deleteSelected:$}=p;yn(t,d,w,y,T,v,f);let V=so(t),C=(0,Pt.useRef)(null),A=He(u,"arrow"),D=He(u,"freedraw"),P=He(u,"shape"),N=He(u,"ruler"),_=He(u,"note"),H=He(u,"text"),{draftArrow:K,setDraftArrow:Z,draftShape:q,setDraftShape:de,draftRuler:ce,setDraftRuler:j,draftFreeDrawRef:U,clearDraftFreeDraw:L,handleInteractionPointerDown:O,handleInteractionPointerMove:Y}=mn({map:t,activeTool:w,setActiveTool:y,activeShape:x,shapeFilled:h,activeColor:E,strokeWidth:k,dashed:I,noteColor:m,fontSize:S,fontWeight:R,labels:s,addItem:B,paintCanvas:()=>ne()}),ne=pn({map:t,viewport:V,canvasRef:C,arrowItems:A,shapeItems:P,freeDrawItems:D,rulerItems:N,selectedId:T,draftShape:q,draftArrow:K,draftRuler:ce,draftFreeDrawRef:U,activeColor:E,strokeWidth:k,dashed:I,shapeFilled:h,annotationTheme:a??l,isReadOnly:d});fn({isReadOnly:d,selectedId:T,selectedItem:p.selectedItem,items:p.items,isEditingLabel:p.isEditingLabel,setEditingLabel:p.setEditingLabel,deleteSelected:$,setSelectedId:v,setActiveTool:y,setDraftArrow:Z,setDraftShape:de,setDraftRuler:j,clearDraftFreeDraw:L,notifyChangeComplete:f}),bn(t);let W=hn({map:t,activeTool:w,isReadOnly:d,arrowItems:A,shapeItems:P,freeDrawItems:D,rulerItems:N,selectedId:T,setSelectedId:v,setEditingLabel:p.setEditingLabel,updateItem:F,notifyChangeComplete:f});return{controller:p,isReadOnly:d,showToolbar:b,viewport:V,canvasRef:C,isDrawingTool:!d&&w!=="select",hoverCursor:W,arrowItems:A,shapeItems:P,freeDrawItems:D,noteItems:_,textItems:H,selectedId:T,setSelectedId:v,updateItem:F,removeItem:G,notifyChangeComplete:f,handleInteractionPointerDown:O,handleInteractionPointerMove:Y}}var Lt=require("react/jsx-runtime");function _n(e){let t=(0,Tn.useMap)();return(0,Lt.jsx)(vn,{...e,map:t})}function Sn(e){return e.map!==void 0?(0,Lt.jsx)(vn,{...e,map:e.map}):(0,Lt.jsx)(_n,{...e})}function vn(e){let{map:t,toolbarPosition:o="top-center",toolbarOrientation:r,orientation:n,collapsible:a,defaultCollapsed:l,collapsed:s,onCollapsedChange:i,showCollapseButton:d,enabledTools:c,customTools:p,showHistoryControls:b,showDeleteButton:g,showClearButton:f,showToolLabels:u,labels:w,icons:y,zIndex:x=650,unstyled:h=!1,classNames:T,styles:v,strokeColors:E,strokeWidthOptions:k,fontSizeOptions:I,renderToolbar:m,renderNote:S,renderText:R,clampOverlaysToViewport:B=!0,autoMinimizeNotesZoom:F,autoMinimizeTextZoom:G,className:$,style:V}=e,C=xn(e);return t?(0,wn.createPortal)((0,Lt.jsx)(cn,{map:t,canvasRef:C.canvasRef,viewport:C.viewport,isReadOnly:C.isReadOnly,isDrawingTool:C.isDrawingTool,activeTool:C.controller.activeTool,hoverCursor:C.hoverCursor,zIndex:x,className:$,style:V,classNames:T,styles:v,handleInteractionPointerDown:C.handleInteractionPointerDown,handleInteractionPointerMove:C.handleInteractionPointerMove,noteItems:C.noteItems,textItems:C.textItems,selectedId:C.selectedId,labels:w,icons:y,unstyled:h,clampOverlaysToViewport:B,autoMinimizeNotesZoom:F,autoMinimizeTextZoom:G,renderNote:S,renderText:R,setSelectedId:C.setSelectedId,updateItem:C.updateItem,removeItem:C.removeItem,notifyChangeComplete:C.notifyChangeComplete,renderToolbar:m,showToolbar:C.showToolbar,controller:C.controller,toolbarPosition:o,toolbarOrientation:r??n,collapsible:a,defaultCollapsed:l,collapsed:s,onCollapsedChange:i,showCollapseButton:d,enabledTools:c,customTools:p,showHistoryControls:b,showDeleteButton:g,showClearButton:f,showToolLabels:u,strokeColors:E,strokeWidthOptions:k,fontSizeOptions:I}),t.getContainer()):null}0&&(module.exports={DEFAULT_ANNOTATION_THEME,DEFAULT_FONT_SIZE,DEFAULT_FONT_SIZE_OPTIONS,DEFAULT_NOTE_BG,DEFAULT_NOTE_TEXT,DEFAULT_STROKE_COLOR,DEFAULT_STROKE_WIDTH,DEFAULT_STROKE_WIDTH_OPTIONS,FONT_SIZE_OPTIONS,InlineShapeLabelEditor,LeafletTual,NOTE_COLOR_THEMES,NoteOverlay,PixelSelect,STROKE_COLORS,STROKE_WIDTH_OPTIONS,TOOL_TO_ARROW_STYLE,TextOverlay,TualToolbar,VERSION,bindBlockMapDblClick,bindLeafletSync,buildArrowItem,buildRulerItem,calculateGeodesicDistance,calculateLineDistance,calculateZoomFontSize,clampNotePosition,clampTextPosition,computeDefaultControlGeoPoint,constrainAngleTo45Degrees,constrainToAspectRatio,createDraftNote,createDraftText,createId,createLeafletTual,createLeafletTualController,distanceToQuadraticBezier,distanceToSegment,drawArrowHead,drawTualHandle,drawTualLabelPill,formatRealWorldDistance,geoToScreen,getCollapseChevronRotation,getDropdownChevronRotation,getExpandChevronRotation,getMapDimensions,getQuadraticBezierPoint,getQuadraticEndAngle,hitTestArrow,hitTestArrowHandle,hitTestFreeDraw,hitTestRuler,hitTestRulerHandle,hitTestShape,hitTestShapeHandle,paintLeafletTual,projectArrow,projectFreeDraw,projectRuler,projectShape,renderArrowOnCanvas,renderFreeDrawOnCanvas,renderRulerOnCanvas,renderShapeOnCanvas,resolveNoteTheme,screenToGeo,startArrowBodyDrag,startArrowDrag,startArrowHandleDrag,startFreeDrawBodyDrag,startFreeDrawDrag,startRulerBodyDrag,startRulerDrag,startRulerHandleDrag,startShapeBodyDrag,startShapeDrag,startShapeHandleDrag,traceArrowPath,tracePolygonShape,truncateTualText,useLeafletSync,useLeafletTual});
4
+ //# sourceMappingURL=react.cjs.map