{
  "version": 3,
  "sources": ["../../../../src/lib/ui/hooks/menu-hooks.ts"],
  "sourcesContent": ["import { useEditor, useValue } from '@tldraw/editor'\nimport {\n\tcanApplySelectionAction,\n\tgetUnlockedSelectedShapes,\n\thasShapesOnPage,\n} from '../context/action-predicates'\n\n// The @public hooks here are SDK API: keep them even when nothing in tldraw calls them.\n\nfunction countWithinBounds(len: number, min?: number, max?: number) {\n\tif (min === undefined && max === undefined) return len\n\treturn (min === undefined || len >= min) && (max === undefined || len <= max)\n}\n\n/**\n * Returns true if the number of LOCKED OR UNLOCKED selected shapes is at least min or at most max.\n */\nexport function useAnySelectedShapesCount(min?: number, max?: number) {\n\tconst editor = useEditor()\n\treturn useValue(\n\t\t'selectedShapes',\n\t\t() => countWithinBounds(editor.getSelectedShapes().length, min, max),\n\t\t[editor, min, max]\n\t)\n}\n\n/**\n * Returns true if the number of UNLOCKED selected shapes is at least min or at most max.\n * @public\n */\nexport function useUnlockedSelectedShapesCount(min?: number, max?: number) {\n\tconst editor = useEditor()\n\treturn useValue(\n\t\t'selectedShapes',\n\t\t() => countWithinBounds(getUnlockedSelectedShapes(editor).length, min, max),\n\t\t[editor, min, max]\n\t)\n}\n\n/** @public */\nexport function useCanRedo() {\n\tconst editor = useEditor()\n\treturn useValue('useCanRedo', () => editor.getCanRedo(), [editor])\n}\n\n/** @public */\nexport function useCanUndo() {\n\tconst editor = useEditor()\n\treturn useValue('useCanUndo', () => editor.getCanUndo(), [editor])\n}\n\n/** Returns true if the current page has at least one shape. */\nexport function useHasShapesOnPage() {\n\tconst editor = useEditor()\n\treturn useValue('hasShapesOnPage', () => hasShapesOnPage(editor), [editor])\n}\n\n/**\n * Returns true if the user is in the select tool and has at least one shape selected.\n * @public\n */\nexport function useCanApplySelectionAction() {\n\tconst editor = useEditor()\n\treturn useValue('canApplySelectionAction', () => canApplySelectionAction(editor), [editor])\n}\n"],
  "mappings": "AAAA,SAAS,WAAW,gBAAgB;AACpC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAIP,SAAS,kBAAkB,KAAa,KAAc,KAAc;AACnE,MAAI,QAAQ,UAAa,QAAQ,OAAW,QAAO;AACnD,UAAQ,QAAQ,UAAa,OAAO,SAAS,QAAQ,UAAa,OAAO;AAC1E;AAKO,SAAS,0BAA0B,KAAc,KAAc;AACrE,QAAM,SAAS,UAAU;AACzB,SAAO;AAAA,IACN;AAAA,IACA,MAAM,kBAAkB,OAAO,kBAAkB,EAAE,QAAQ,KAAK,GAAG;AAAA,IACnE,CAAC,QAAQ,KAAK,GAAG;AAAA,EAClB;AACD;AAMO,SAAS,+BAA+B,KAAc,KAAc;AAC1E,QAAM,SAAS,UAAU;AACzB,SAAO;AAAA,IACN;AAAA,IACA,MAAM,kBAAkB,0BAA0B,MAAM,EAAE,QAAQ,KAAK,GAAG;AAAA,IAC1E,CAAC,QAAQ,KAAK,GAAG;AAAA,EAClB;AACD;AAGO,SAAS,aAAa;AAC5B,QAAM,SAAS,UAAU;AACzB,SAAO,SAAS,cAAc,MAAM,OAAO,WAAW,GAAG,CAAC,MAAM,CAAC;AAClE;AAGO,SAAS,aAAa;AAC5B,QAAM,SAAS,UAAU;AACzB,SAAO,SAAS,cAAc,MAAM,OAAO,WAAW,GAAG,CAAC,MAAM,CAAC;AAClE;AAGO,SAAS,qBAAqB;AACpC,QAAM,SAAS,UAAU;AACzB,SAAO,SAAS,mBAAmB,MAAM,gBAAgB,MAAM,GAAG,CAAC,MAAM,CAAC;AAC3E;AAMO,SAAS,6BAA6B;AAC5C,QAAM,SAAS,UAAU;AACzB,SAAO,SAAS,2BAA2B,MAAM,wBAAwB,MAAM,GAAG,CAAC,MAAM,CAAC;AAC3F;",
  "names": []
}
