{ "version": 3, "sources": ["../../../../../src/lib/tools/SelectTool/children/PointingResizeHandle.ts"], "sourcesContent": ["import {\n\tStateNode,\n\tTLCursorType,\n\tTLEventHandlers,\n\tTLPointerEventInfo,\n\tTLSelectionHandle,\n} from '@tldraw/editor'\n\nexport const CursorTypeMap: Record = {\n\tbottom: 'ns-resize',\n\ttop: 'ns-resize',\n\tleft: 'ew-resize',\n\tright: 'ew-resize',\n\tbottom_left: 'nesw-resize',\n\tbottom_right: 'nwse-resize',\n\ttop_left: 'nwse-resize',\n\ttop_right: 'nesw-resize',\n\tbottom_left_rotate: 'swne-rotate',\n\tbottom_right_rotate: 'senw-rotate',\n\ttop_left_rotate: 'nwse-rotate',\n\ttop_right_rotate: 'nesw-rotate',\n\tmobile_rotate: 'grabbing',\n}\n\ntype PointingResizeHandleInfo = Extract & {\n\tonInteractionEnd?: string\n}\n\nexport class PointingResizeHandle extends StateNode {\n\tstatic override id = 'pointing_resize_handle'\n\n\tprivate info = {} as PointingResizeHandleInfo\n\n\tprivate updateCursor() {\n\t\tconst selected = this.editor.selectedShapes\n\t\tconst cursorType = CursorTypeMap[this.info.handle!]\n\t\tthis.editor.updateInstanceState({\n\t\t\tcursor: { type: cursorType, rotation: selected.length === 1 ? selected[0].rotation : 0 },\n\t\t})\n\t}\n\n\toverride onEnter = (info: PointingResizeHandleInfo) => {\n\t\tthis.info = info\n\t\tthis.updateCursor()\n\t}\n\n\toverride onPointerMove: TLEventHandlers['onPointerMove'] = () => {\n\t\tconst isDragging = this.editor.inputs.isDragging\n\n\t\tif (isDragging) {\n\t\t\tthis.parent.transition('resizing', this.info)\n\t\t}\n\t}\n\n\toverride onPointerUp: TLEventHandlers['onPointerUp'] = () => {\n\t\tthis.complete()\n\t}\n\n\t// override onPinchStart: TLEventHandlers['onPinchStart'] = (info) => {\n\t// \tthis.parent.transition('pinching', info)\n\t// }\n\n\toverride onCancel: TLEventHandlers['onCancel'] = () => {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete: TLEventHandlers['onComplete'] = () => {\n\t\tthis.cancel()\n\t}\n\n\toverride onInterrupt = () => {\n\t\tthis.cancel()\n\t}\n\n\tprivate complete() {\n\t\tif (this.info.onInteractionEnd) {\n\t\t\tthis.editor.setCurrentTool(this.info.onInteractionEnd, {})\n\t\t} else {\n\t\t\tthis.parent.transition('idle', {})\n\t\t}\n\t}\n\n\tprivate cancel() {\n\t\tif (this.info.onInteractionEnd) {\n\t\t\tthis.editor.setCurrentTool(this.info.onInteractionEnd, {})\n\t\t} else {\n\t\t\tthis.parent.transition('idle', {})\n\t\t}\n\t}\n}\n"], "mappings": "AAAA;AAAA,EACC;AAAA,OAKM;AAEA,MAAM,gBAAyD;AAAA,EACrE,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,cAAc;AAAA,EACd,UAAU;AAAA,EACV,WAAW;AAAA,EACX,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,eAAe;AAChB;AAMO,MAAM,6BAA6B,UAAU;AAAA,EACnD,OAAgB,KAAK;AAAA,EAEb,OAAO,CAAC;AAAA,EAER,eAAe;AACtB,UAAM,WAAW,KAAK,OAAO;AAC7B,UAAM,aAAa,cAAc,KAAK,KAAK,MAAO;AAClD,SAAK,OAAO,oBAAoB;AAAA,MAC/B,QAAQ,EAAE,MAAM,YAAY,UAAU,SAAS,WAAW,IAAI,SAAS,CAAC,EAAE,WAAW,EAAE;AAAA,IACxF,CAAC;AAAA,EACF;AAAA,EAES,UAAU,CAAC,SAAmC;AACtD,SAAK,OAAO;AACZ,SAAK,aAAa;AAAA,EACnB;AAAA,EAES,gBAAkD,MAAM;AAChE,UAAM,aAAa,KAAK,OAAO,OAAO;AAEtC,QAAI,YAAY;AACf,WAAK,OAAO,WAAW,YAAY,KAAK,IAAI;AAAA,IAC7C;AAAA,EACD;AAAA,EAES,cAA8C,MA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