Try importing it from ../components/modal/lottery-form-modal
instead.
When you start your import with discourse
, it will look for the file and directory in the Discourse codebase, not your own project.
For example, your line:
imports this from app/assets/javascripts/discourse/app/lib/plugin-api.gjs
in the Discourse codebase.
As an example on how you could do this, see @abroun_beholder’s GitHub - Beholder-Vision/discourse-insert-model-3d: A Discourse theme component for adding 3D models to topics.