diff --git a/README.md b/README.md index 738d78d1..dfdae115 100644 --- a/README.md +++ b/README.md @@ -12,25 +12,6 @@ This module is already included in [`biigle/biigle`](https://github.com/biigle/b 2. Add `Biigle\Modules\Laserpoints\LaserpointsServiceProvider::class` to the `providers` array in `config/app.php`. 3. Run `php artisan vendor:publish --tag=public` to publish the public assets of this module. 4. Run `pip install -r vendor/biigle/laserpoints/requirements.txt` to install the Python requirements. -5. Configure a storage disk for the temporary laserpoints files `LASERPOINTS_DISK` variable to the name of this storage disk in the `.env` file. Example for a local disk: - ```php - 'laserpoints' => [ - 'driver' => 'local', - 'root' => storage_path('framework/cache/laserpoints'), - ], - ``` - -## References - -Reference publications that you should cite if you use the laser point detection for one of your studies. - -- **BIIGLE 2.0** - [Langenkämper, D., Zurowietz, M., Schoening, T., & Nattkemper, T. W. (2017). Biigle 2.0-browsing and annotating large marine image collections.](https://doi.org/10.3389/fmars.2017.00083) - Frontiers in Marine Science, 4, 83. doi: `10.3389/fmars.2017.00083` - -- **Laser Point Detection** - [Schoening, T., Kuhn, T., Bergmann, M., & Nattkemper, T. W. (2015). DELPHI—fast and adaptive computational laser point detection and visual footprint quantification for arbitrary underwater image collections.](https://doi.org/10.3389/fmars.2015.00020) - Frontiers in Marine Science, 2, 20. doi: `10.3389/fmars.2015.00020` ## Developing diff --git a/requirements.txt b/requirements.txt index 7606c0ed..e305e433 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -numpy==1.22.0 -scipy==1.10.0 -Pillow==10.3.0 +numpy==2.1.* +scipy==1.13.* +opencv-contrib-python-headless==4.11.0.* diff --git a/src/Console/Commands/Config.php b/src/Console/Commands/Config.php deleted file mode 100644 index f84f420c..00000000 --- a/src/Console/Commands/Config.php +++ /dev/null @@ -1,36 +0,0 @@ -call('vendor:publish', [ - '--provider' => ServiceProvider::class, - '--tag' => ['config'], - ]); - } -} diff --git a/src/Console/Commands/Publish.php b/src/Console/Commands/Publish.php deleted file mode 100644 index 0c8c5dc8..00000000 --- a/src/Console/Commands/Publish.php +++ /dev/null @@ -1,37 +0,0 @@ -call('vendor:publish', [ - '--provider' => ServiceProvider::class, - '--tag' => ['public'], - '--force' => true, - ]); - } -} diff --git a/src/Http/Controllers/Api/LaserpointsController.php b/src/Http/Controllers/Api/LaserpointsController.php index 0aa00a30..43e7d03f 100644 --- a/src/Http/Controllers/Api/LaserpointsController.php +++ b/src/Http/Controllers/Api/LaserpointsController.php @@ -4,96 +4,199 @@ use Biigle\Http\Controllers\Api\Controller; use Biigle\Label; -use Biigle\Modules\Laserpoints\Http\Requests\ComputeImage; -use Biigle\Modules\Laserpoints\Http\Requests\ComputeVolume; use Biigle\Modules\Laserpoints\Image; -use Biigle\Modules\Laserpoints\Jobs\ProcessImageDelphiJob; +use Biigle\Modules\Laserpoints\Jobs\ProcessImageAutomaticJob; use Biigle\Modules\Laserpoints\Jobs\ProcessImageManualJob; -use Biigle\Modules\Laserpoints\Jobs\ProcessVolumeDelphiJob; +use Biigle\Modules\Laserpoints\Jobs\ProcessVolumeAutomaticJob; +use Biigle\Modules\Laserpoints\Jobs\ProcessVolumeManualJob; use Biigle\Modules\Laserpoints\Volume; -use Biigle\Volume as BaseVolume; use Exception; +use Illuminate\Http\Request; use Illuminate\Validation\ValidationException; class LaserpointsController extends Controller { /** - * Compute distance between laser points for an image. + * Compute distance between laser points for an image with manual annotations. * - * @api {post} images/:id/laserpoints/area Compute image area + * @api {post} images/:id/laserpoints/manual Compute image area with manual annotations * @apiGroup Images - * @apiName ImagesComputeArea + * @apiName ImagesComputeAreaManual * @apiPermission projectEditor - * @apiDescription This feature is not available for very large images. * * @apiParam {Number} id The image ID. * @apiParam (Required arguments) {Number} label_id ID of the laser point label that was used. * @apiParam (Required arguments) {Number} distance The distance between two laser points in cm. + * @apiParam (Required arguments) {Number} num_laserpoints Number of laser points to search for. * - * @param ComputeImage $request + * @param Request $request + * @param int $id * * @return \Illuminate\Http\Response */ - public function computeImage(ComputeImage $request) + public function imageManual(Request $request, $id) { - $image = Image::convert($request->image); + $image = Image::with('volume')->findOrFail($id); + $this->authorize('edit-in', $image->volume); + // TODO manual is possible for tiled images? how does the script get the dimensions? do we need a python script for this at all? + if ($image->tiled) { + throw ValidationException::withMessages([ + 'id' => 'Laser point detection is not available for very large images.', + ]); + } + $request->validate([ + 'distance' => 'required|numeric|min:1', + 'label_id' => 'required|integer|exists:labels,id', + ]); + $label = Label::find($request->input('label_id')); try { - $manual = $image->readyForManualDetection($label); + $image->readyForManualDetection($label); } catch (Exception $e) { throw ValidationException::withMessages([ 'id' => 'Laser point detection can\'t be performed. '.$e->getMessage(), ]); } - if ($manual) { - ProcessImageManualJob::dispatch($image, $request->input('distance'), $label->id) - ->onQueue(config('laserpoints.process_manual_queue')); - } else { - try { - Volume::convert($image->volume)->readyForDelphiDetection($label); - } catch (Exception $e) { - throw ValidationException::withMessages([ - 'id' => 'Delphi laser point detection can\'t be performed. '.$e->getMessage(), - ]); - } - - ProcessImageDelphiJob::dispatch($image, $request->input('distance'), $label->id) - ->onQueue(config('laserpoints.process_delphi_queue')); + ProcessImageManualJob::dispatch($image, $label, $request->input('distance')) + ->onQueue(config('laserpoints.process_manual_queue')); + } + + /** + * Compute distance between laser points for an image with automatic detection. + * + * @api {post} images/:id/laserpoints/automatic Compute image area with automatic detection + * @apiGroup Images + * @apiName ImagesComputeAreaAutomatic + * @apiPermission projectEditor + * @apiDescription This feature is not available for very large images. + * + * @apiParam {Number} id The image ID. + * @apiParam (Required arguments) {Number} distance The distance between two laser points in cm. + * @apiParam (Required arguments) {Number} num_laserpoints Number of laser points to search for. + * @apiParam (Optional arguments) {String} channel_mode Channel mode to use (red/green/blue/gray). + * + * @param Request $request + * @param int $id + * + * @return \Illuminate\Http\Response + */ + public function imageAutomatic(Request $request, $id) + { + $image = Image::with('volume')->findOrFail($id); + $this->authorize('edit-in', $image->volume); + if ($image->tiled) { + throw ValidationException::withMessages([ + 'id' => 'Laser point detection is not available for very large images.', + ]); } + $request->validate([ + 'distance' => 'required|numeric|min:1', + 'num_laserpoints' => 'required|integer|min:1', + 'channel_mode' => 'required|in:red,green,blue,gray', + ]); + + ProcessImageAutomaticJob::dispatch($image, $request->input('distance'), $request->input('channel_mode'), $request->input('num_laserpoints')) + ->onQueue(config('laserpoints.process_automatic_queue')); } /** - * Compute distance between laser points for a volume. + * Compute distance between laser points for a volume with manual annotations. * - * @api {post} volumes/:id/laserpoints/area Compute image footprint for all images + * @api {post} volumes/:id/laserpoints/manual Compute image area with manual annotations * @apiGroup Volumes - * @apiName VolumesComputeImageArea + * @apiName VolumesComputeAreaManual * @apiPermission projectEditor - * @apiDescription This feature is not available for video volumes and volumes with very large images. * * @apiParam {Number} id The volume ID. * @apiParam (Required arguments) {Number} label_id ID of the laser point label that was used. * @apiParam (Required arguments) {Number} distance The distance between two laser points in cm. * - * @param ComputeVolume $request + * @param Request $request + * @param int $id + * * @return \Illuminate\Http\Response */ - public function computeVolume(ComputeVolume $request) + public function volumeManual(Request $request, $id) { - $volume = Volume::convert($request->volume); + // TODO use cache key to prevent users from submitting multiple jobs at the same + // time + $volume = Volume::findOrFail($id); + $this->authorize('edit-in', $volume); + if (!$volume->isImageVolume()) { + throw ValidationException::withMessages([ + 'id' => 'Laser point detection is only available for image volumes.', + ]); + } + // TODO manual is possible for tiled images? how does the script get the dimensions? do we need a python script for this at all? + if ($volume->hasTiledImages()) { + throw ValidationException::withMessages([ + 'id' => 'Laser point detection is not available for volumes with very large images.', + ]); + } + $request->validate([ + 'distance' => 'required|numeric|min:1', + 'label_id' => 'required|integer|exists:labels,id', + ]); + $label = Label::find($request->input('label_id')); try { - $volume->readyForDelphiDetection($label); + $volume->readyForManualDetection($label); } catch (Exception $e) { throw ValidationException::withMessages([ - 'id' => 'Delphi laser point detection can\'t be performed. '.$e->getMessage(), + 'id' => 'Laser point detection can\'t be performed. '.$e->getMessage(), + ]); + } + + ProcessVolumeManualJob::dispatch($volume, $label, $request->input('distance')) + ->onQueue(config('laserpoints.process_manual_queue')); + } + + /** + * Compute distance between laser points for a volume with automatic detection. + * + * @api {post} volumes/:id/laserpoints/automatic Compute image area with automatic detection + * @apiGroup Volumes + * @apiName VolumesComputeAreaAutomatic + * @apiPermission projectEditor + * @apiDescription This feature is not available for video volumes and volumes with very large images. + * + * @apiParam {Number} id The image ID. + * @apiParam (Required arguments) {Number} distance The distance between two laser points in cm. + * @apiParam (Required arguments) {Number} num_laserpoints Number of laser points to search for. + * + * @param Request $request + * @param int $id + * + * @return \Illuminate\Http\Response + */ + public function volumeAutomatic(Request $request, $id) + { + // TODO use cache key to track which image job should delete cache data + // and to prevent users from submitting multiple jobs at the same time + $volume = Volume::findOrFail($id); + $this->authorize('edit-in', $volume); + + if (!$volume->isImageVolume()) { + throw ValidationException::withMessages([ + 'id' => 'Laser point detection is only available for image volumes.', ]); } - ProcessVolumeDelphiJob::dispatch($volume, $request->input('distance'), $label->id) - ->onQueue(config('laserpoints.process_delphi_queue')); + if ($volume->hasTiledImages()) { + throw ValidationException::withMessages([ + 'id' => 'Laser point detection is not available for volumes with very large images.', + ]); + } + + $request->validate([ + 'distance' => 'required|numeric|min:1', + 'num_laserpoints' => 'required|integer|min:1', + ]); + + ProcessVolumeAutomaticJob::dispatch($volume, $request->input('distance'), $request->input('num_laserpoints')) + ->onQueue(config('laserpoints.process_automatic_queue')); } } diff --git a/src/Http/Requests/ComputeImage.php b/src/Http/Requests/ComputeImage.php deleted file mode 100644 index 457d3fff..00000000 --- a/src/Http/Requests/ComputeImage.php +++ /dev/null @@ -1,56 +0,0 @@ -image = Image::with('volume')->findOrFail($this->route('id')); - - return $this->user()->can('edit-in', $this->image->volume); - } - - /** - * Get the validation rules that apply to the request. - * - * @return array - */ - public function rules() - { - return [ - 'distance' => 'required|numeric|min:1', - 'label_id' => 'required|integer|exists:labels,id', - ]; - } - - /** - * Configure the validator instance. - * - * @param \Illuminate\Validation\Validator $validator - * @return void - */ - public function withValidator($validator) - { - $validator->after(function ($validator) { - if ($this->image->tiled === true) { - $validator->errors()->add('id', 'Laser point detection is not available for very large images.'); - } - }); - } -} diff --git a/src/Http/Requests/ComputeVolume.php b/src/Http/Requests/ComputeVolume.php deleted file mode 100644 index 2ee5aede..00000000 --- a/src/Http/Requests/ComputeVolume.php +++ /dev/null @@ -1,60 +0,0 @@ -volume = Volume::findOrFail($this->route('id')); - - return $this->user()->can('edit-in', $this->volume); - } - - /** - * Get the validation rules that apply to the request. - * - * @return array - */ - public function rules() - { - return [ - 'distance' => 'required|numeric|min:1', - 'label_id' => 'required|integer|exists:labels,id', - ]; - } - - /** - * Configure the validator instance. - * - * @param \Illuminate\Validation\Validator $validator - * @return void - */ - public function withValidator($validator) - { - $validator->after(function ($validator) { - if (!$this->volume->isImageVolume()) { - $validator->errors()->add('id', 'Laser point detection is only available for image volumes.'); - } - - if ($this->volume->hasTiledImages()) { - $validator->errors()->add('id', 'Laser point detection is not available for volumes with very large images.'); - } - }); - } -} diff --git a/src/Http/routes.php b/src/Http/routes.php index b0b91483..c528a8f3 100644 --- a/src/Http/routes.php +++ b/src/Http/routes.php @@ -5,12 +5,20 @@ 'prefix' => 'api/v1', 'middleware' => ['api', 'auth:web,api'], ], function ($router) { - $router->post('images/{id}/laserpoints/area', [ - 'uses' => 'LaserpointsController@computeImage', + $router->post('images/{id}/laserpoints/manual', [ + 'uses' => 'LaserpointsController@imageManual', ]); - $router->post('volumes/{id}/laserpoints/area', [ - 'uses' => 'LaserpointsController@computeVolume', + $router->post('images/{id}/laserpoints/automatic', [ + 'uses' => 'LaserpointsController@imageAutomatic', + ]); + + $router->post('volumes/{id}/laserpoints/manual', [ + 'uses' => 'LaserpointsController@volumeManual', + ]); + + $router->post('volumes/{id}/laserpoints/automatic', [ + 'uses' => 'LaserpointsController@volumeAutomatic', ]); $router->get('images/{id}/laserpoints', [ diff --git a/src/Image.php b/src/Image.php index 355dab0d..06b64a12 100644 --- a/src/Image.php +++ b/src/Image.php @@ -49,8 +49,16 @@ class Image extends BaseImage 'points', 'error', 'message', + 'channel_mode', ]; + /** + * Attributes that should be appended during serialization. + * + * @var array + */ + protected $appends = ['laserpoints']; + /** * Converts a regular Biigle image to a Laserpoints image. * @@ -60,6 +68,7 @@ class Image extends BaseImage */ public static function convert(BaseImage $image) { + // TODO: still needed? $instance = new static; $instance->setRawAttributes($image->attributes); $instance->exists = $image->exists; @@ -165,6 +174,16 @@ public function getMessageAttribute() return $this->accessLaserpointsArray('message'); } + /** + * Get the channel mode attribute from the laser point detection. + * + * @return ?string + */ + public function getChannelModeAttribute() + { + return $this->accessLaserpointsArray('channel_mode'); + } + /** * Determines if this image has a valid number of manually annotated laser points. * diff --git a/src/Jobs/Job.php b/src/Jobs/Job.php deleted file mode 100644 index 903e7d6e..00000000 --- a/src/Jobs/Job.php +++ /dev/null @@ -1,121 +0,0 @@ -distance = $distance; - $this->labelId = $labelId; - } - - /** - * Execute the job. - * - * @return void - */ - abstract public function handle(); - - /** - * Collects all images of a volume that contain laser point annotations. - * - * @param int $id Volume ID - * - * @return Collection Laser point coordinates indexed by image ID - */ - protected function getLaserpointsForVolume($id) - { - return ImageAnnotation::join('image_annotation_labels', 'image_annotation_labels.annotation_id', '=', 'image_annotations.id') - ->join('images', 'image_annotations.image_id', '=', 'images.id') - ->where('images.volume_id', $id) - ->where('image_annotation_labels.label_id', $this->labelId) - ->where('image_annotations.shape_id', Shape::pointId()) - ->select('image_annotations.points', 'image_annotations.image_id') - ->get() - ->groupBy('image_id') - ->pipe([$this, 'filterInvalidLaserPoints']) - ->map(function ($i) { - return $i->pluck('points')->toJson(); - }); - } - - /** - * Perform the gather step. - * - * @param Collection $points Points Collection returned from getLaserpointsForVolume. - * - * @return string Path to the gather file in the storage disk. - */ - protected function gather($points) - { - $images = Image::whereIn('id', $points->keys()) - ->with('volume') - ->select('filename', 'id', 'volume_id') - // Take only a maximum of 100 images for delphi_gather. - ->inRandomOrder() - ->limit(100) - ->get(); - - $gather = App::make(DelphiGather::class); - $callback = function ($image, $path) use ($gather, $points) { - return $gather->execute($path, $points->get($image->id)); - }; - - $outputPath = $gather->getOutputPath(); - - try { - foreach ($images as $image) { - FileCache::get($image, $callback); - } - - $gather->finish(); - - $storagePath = Storage::disk(config('laserpoints.disk')) - ->putFileAs('', new SplFileInfo($outputPath), File::basename($outputPath)); - } finally { - File::delete($outputPath); - } - - return $storagePath; - } -} diff --git a/src/Jobs/ProcessDelphiJob.php b/src/Jobs/ProcessDelphiJob.php deleted file mode 100644 index a178870e..00000000 --- a/src/Jobs/ProcessDelphiJob.php +++ /dev/null @@ -1,110 +0,0 @@ -image = Image::convert($image); - $this->gatherFile = $gatherFile; - $this->distance = $distance; - } - - /** - * Execute the job. - * - * @return void - */ - public function handle() - { - $tmpDir = config('laserpoints.tmp_dir'); - $localGatherPath = "{$tmpDir}/{$this->gatherFile}"; - $stream = Storage::disk(config('laserpoints.disk')) - ->readStream($this->gatherFile); - File::put($localGatherPath, $stream); - - $callback = function ($image, $path) use ($localGatherPath) { - $delphi = App::make(DelphiApply::class); - - return $delphi->execute($localGatherPath, $path, $this->distance); - }; - - try { - $output = FileCache::getOnce($this->image, $callback); - } catch (Exception $e) { - $output = [ - 'error' => true, - 'message' => $e->getMessage(), - ]; - } finally { - File::delete($localGatherPath); - } - - $output['distance'] = $this->distance; - - $this->image->laserpoints = $output; - $this->image->save(); - } -} diff --git a/src/Jobs/ProcessManualJob.php b/src/Jobs/ProcessImageAutomaticJob.php similarity index 53% rename from src/Jobs/ProcessManualJob.php rename to src/Jobs/ProcessImageAutomaticJob.php index 31d38be6..c82d9e19 100644 --- a/src/Jobs/ProcessManualJob.php +++ b/src/Jobs/ProcessImageAutomaticJob.php @@ -3,9 +3,10 @@ namespace Biigle\Modules\Laserpoints\Jobs; use App; -use Biigle\Jobs\Job as BaseJob; +use Biigle\Jobs\Job; +use Biigle\Shape; use Biigle\Modules\Laserpoints\Image; -use Biigle\Modules\Laserpoints\Support\Detect; +use Biigle\Modules\Laserpoints\Support\DetectAutomatic; use Exception; use FileCache; use Illuminate\Bus\Batchable; @@ -13,30 +14,11 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; -class ProcessManualJob extends BaseJob implements ShouldQueue +class ProcessImageAutomaticJob extends Job implements ShouldQueue { use Batchable, InteractsWithQueue, SerializesModels; - /** - * The image to process. - * - * @var Image - */ - protected $image; - - /** - * Laser point coordinates for the image. - * - * @var string - */ - protected $points; - - /** - * Distance between laser points im cm to use for computation. - * - * @var float - */ - protected $distance; + public $tries = 1; /** * Ignore this job if the image does not exist any more. @@ -48,17 +30,21 @@ class ProcessManualJob extends BaseJob implements ShouldQueue /** * Create a new job instance. * - * @param Image $image - * @param string $points - * @param float $distance + * @param Image $image The image to process. + * @param float $distance Distance between laser points im cm to use for computation. + * @param ?string $channelMode Channel mode override (red/green/blue/gray) + * @param int $numLaserpoints Number of laser points to search for. * * @return void */ - public function __construct($image, $points, $distance) + public function __construct( + public Image $image, + public float $distance, + public ?string $channelMode = null, + public int $numLaserpoints = 2, + ) { - $this->image = $image; - $this->points = $points; - $this->distance = $distance; + // } /** @@ -69,10 +55,10 @@ public function __construct($image, $points, $distance) public function handle() { try { - $output = FileCache::getOnce($this->image, function ($image, $path) { - $detect = App::make(Detect::class); + $output = FileCache::get($this->image, function ($image, $path) { + $detect = App::make(DetectAutomatic::class); - return $detect->execute($path, $this->distance, $this->points); + return $detect->execute($path, $this->distance, $this->channelMode, $this->numLaserpoints); }); } catch (Exception $e) { $output = [ @@ -82,6 +68,9 @@ public function handle() } $output['distance'] = $this->distance; + if ($this->channelMode) { + $output['channel_mode'] = $this->channelMode; + } $this->image->laserpoints = $output; $this->image->save(); diff --git a/src/Jobs/ProcessImageDelphiJob.php b/src/Jobs/ProcessImageDelphiJob.php deleted file mode 100644 index 17139e98..00000000 --- a/src/Jobs/ProcessImageDelphiJob.php +++ /dev/null @@ -1,56 +0,0 @@ -image = $image; - } - - /** - * Execute the job. - * - * @return void - */ - public function handle() - { - // The image may be deleted in the meantime. - if (!$this->image) { - return; - } - - $points = $this->getLaserpointsForVolume($this->image->volume_id); - $gatherFile = $this->gather($points); - $job = new ProcessDelphiJob($this->image, $this->distance, $gatherFile); - - Bus::batch([$job]) - ->onQueue(config('laserpoints.process_delphi_queue')) - ->finally(function () use ($gatherFile) { - Storage::disk(config('laserpoints.disk'))->delete($gatherFile); - }) - ->dispatch(); - } -} diff --git a/src/Jobs/ProcessImageManualJob.php b/src/Jobs/ProcessImageManualJob.php index 9cda3034..f06e5345 100644 --- a/src/Jobs/ProcessImageManualJob.php +++ b/src/Jobs/ProcessImageManualJob.php @@ -2,21 +2,24 @@ namespace Biigle\Modules\Laserpoints\Jobs; -use Biigle\Image; +use App; +use Biigle\Jobs\Job; +use Biigle\Label; +use Biigle\Modules\Laserpoints\Image; +use Biigle\Modules\Laserpoints\Support\DetectManual; use Biigle\Shape; -use DB; +use Exception; +use FileCache; +use Illuminate\Bus\Batchable; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; -class ProcessImageManualJob extends Job +class ProcessImageManualJob extends Job implements ShouldQueue { - use SerializesModels; + use Batchable, InteractsWithQueue, SerializesModels; - /** - * The image to compute the area for. - * - * @var Image - */ - protected $image; + public $tries = 1; /** * Ignore this job if the image does not exist any more. @@ -28,16 +31,19 @@ class ProcessImageManualJob extends Job /** * Create a new job instance. * - * @param Image $image - * @param float $distance - * @param int $labelId + * @param Image $image The image to process. + * @param Label $label The laser point label. + * @param float $distance Distance between laser points im cm to use for computation. * * @return void */ - public function __construct(Image $image, $distance, $labelId) + public function __construct( + public Image $image, + public Label $label, + public float $distance, + ) { - parent::__construct($distance, $labelId); - $this->image = $image; + // } /** @@ -47,28 +53,39 @@ public function __construct(Image $image, $distance, $labelId) */ public function handle() { - $points = $this->getLaserpointsForImage($this->image->id); - ProcessManualJob::dispatch($this->image, $points, $this->distance) - ->onQueue(config('laserpoints.process_manual_queue')); + try { + // TODO implement this without loading the image. dimensions are available in the image model. this can be enabled for tiled images too then. + $output = FileCache::get($this->image, function ($image, $path) { + $detect = App::make(DetectManual::class); + $points = $this->getLaserpoints(); + + return $detect->execute($path, $this->distance, $points); + }); + } catch (Exception $e) { + $output = [ + 'error' => true, + 'message' => $e->getMessage(), + ]; + } + + $output['distance'] = $this->distance; + + $this->image->laserpoints = $output; + $this->image->save(); } /** * Collects the laser point annotations of the given image. * - * @param int $id Image ID - * * @return string JSON encoded array of annotation coordinates */ - protected function getLaserpointsForImage($id) + protected function getLaserpoints() { - $points = DB::table('image_annotations') + return $this->image->annotations() ->join('image_annotation_labels', 'image_annotation_labels.annotation_id', '=', 'image_annotations.id') - ->where('image_annotations.image_id', $id) - ->where('image_annotation_labels.label_id', $this->labelId) + ->where('image_annotation_labels.label_id', $this->label->id) ->where('image_annotations.shape_id', Shape::pointId()) - ->select('image_annotations.points', 'image_annotations.image_id') - ->pluck('image_annotations.points'); - - return '['.$points->implode(',').']'; + ->pluck('image_annotations.points') + ->toJson(); } } diff --git a/src/Jobs/ProcessVolumeAutomaticJob.php b/src/Jobs/ProcessVolumeAutomaticJob.php new file mode 100644 index 00000000..c2e60aba --- /dev/null +++ b/src/Jobs/ProcessVolumeAutomaticJob.php @@ -0,0 +1,83 @@ +volume->images() + ->inRandomOrder() + ->take(100) + ->get() + ->all(); + $channelMode = FileCache::batch($colorSampleImages, function ($images, $paths) { + return $this->performColorDetection($images, $paths); + }); + + $this->volume->images() + ->eachById(function ($image) use ($channelMode) { + $image = Image::convert($image); + ProcessImageAutomaticJob::dispatch($image, $this->distance, $channelMode, $this->numLaserpoints) + ->onQueue(config('laserpoints.process_automatic_queue')); + }); + } + + /** + * Execute the color detection. + * + * @param array $images Cached image models + * @param array $paths Cached image file paths + * + * @return ?string + */ + protected function performColorDetection(array $images, array $paths) + { + $input = array_combine(array_map(fn ($image) => $image->id, $images), $paths); + $detect = App::make(DetectColor::class); + + return $detect->execute($input, $this->numLaserpoints); + } +} diff --git a/src/Jobs/ProcessVolumeDelphiJob.php b/src/Jobs/ProcessVolumeDelphiJob.php deleted file mode 100644 index 12c05b50..00000000 --- a/src/Jobs/ProcessVolumeDelphiJob.php +++ /dev/null @@ -1,81 +0,0 @@ -volume = $volume; - } - - /** - * Execute the job. - * - * @return void - */ - public function handle() - { - $points = $this->getLaserpointsForVolume($this->volume->id); - $images = Image::whereIn('id', $points->keys())->get(); - - $jobs = $images->map(function ($image) use ($points) { - return new ProcessManualJob($image, $points->get($image->id), $this->distance); - }); - - Bus::batch($jobs) - ->onQueue(config('laserpoints.process_manual_queue')) - ->dispatch(); - - $query = $this->volume->images()->whereNotIn('id', $points->keys()); - - if ($query->exists()) { - $images = $query->get(); - $gatherFile = $this->gather($points); - - $jobs = $images->map(function ($image) use ($gatherFile) { - return new ProcessDelphiJob($image, $this->distance, $gatherFile); - }); - - Bus::batch($jobs) - ->onQueue(config('laserpoints.process_delphi_queue')) - ->finally(function () use ($gatherFile) { - Storage::disk(config('laserpoints.disk'))->delete($gatherFile); - }) - ->dispatch(); - } - } -} diff --git a/src/Jobs/ProcessVolumeManualJob.php b/src/Jobs/ProcessVolumeManualJob.php new file mode 100644 index 00000000..ebafb222 --- /dev/null +++ b/src/Jobs/ProcessVolumeManualJob.php @@ -0,0 +1,64 @@ +volume->id) + ->join('image_annotations', 'images.id', '=', 'image_annotations.image_id') + ->join('image_annotation_labels', 'image_annotation_labels.annotation_id', '=', 'image_annotations.id') + ->where('image_annotation_labels.label_id', $this->label->id) + ->where('image_annotations.shape_id', Shape::pointId()) + ->select('images.id as images_id') + ->distinct() + ->eachById(function ($image) { + // Reassign the ID because the ambiguous column had to use an alias. + $image->id = $image->images_id; + ProcessImageManualJob::dispatch($image, $this->label, $this->distance) + ->onQueue(config('laserpoints.process_manual_queue')); + }, 1000, 'images.id', 'images_id'); + } +} diff --git a/src/LaserpointsServiceProvider.php b/src/LaserpointsServiceProvider.php index 42fb27fd..21a86671 100644 --- a/src/LaserpointsServiceProvider.php +++ b/src/LaserpointsServiceProvider.php @@ -58,29 +58,5 @@ public function boot(Modules $modules, Router $router) public function register() { $this->mergeConfigFrom(__DIR__.'/config/laserpoints.php', 'laserpoints'); - - $this->app->singleton('command.laserpoints.publish', function ($app) { - return new \Biigle\Modules\Laserpoints\Console\Commands\Publish(); - }); - $this->app->singleton('command.laserpoints.config', function ($app) { - return new \Biigle\Modules\Laserpoints\Console\Commands\Config(); - }); - - $this->commands([ - 'command.laserpoints.publish', - 'command.laserpoints.config', - ]); - } - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return [ - 'command.laserpoints.publish', - 'command.laserpoints.config', - ]; } } diff --git a/src/Support/DelphiApply.php b/src/Support/DelphiApply.php deleted file mode 100644 index 06e84dc9..00000000 --- a/src/Support/DelphiApply.php +++ /dev/null @@ -1,28 +0,0 @@ -&1"; - - return $this->exec($command); - } -} diff --git a/src/Support/DelphiGather.php b/src/Support/DelphiGather.php deleted file mode 100644 index 5768acb0..00000000 --- a/src/Support/DelphiGather.php +++ /dev/null @@ -1,89 +0,0 @@ -outputPath = "{$tmpDir}/{$tmpFile}"; - } - - /** - * Execute a new Delphi preprocessing. - * - * @param string $path Path to the image file - * @param string $points JSON encoded array of laser point coordinates for the image - * @throws Exception If the script crashed. - */ - public function execute($path, $points) - { - $script = config('laserpoints.delphi_gather_script'); - - return $this->python("{$script} '{$path}' '{$points}' '{$this->outputPath}'"); - } - - /** - * Finish the Delphi preprocessing after all images have been processed. - * - * @throws Exception If the script crashed. - */ - public function finish() - { - $script = config('laserpoints.delphi_gather_finish_script'); - - return $this->python("{$script} '{$this->outputPath}'"); - } - - /** - * Get the path to the temporary ouput file of the Delphi gather script. - * - * @return string - */ - public function getOutputPath() - { - return $this->outputPath; - } - - /** - * Execute a python script. - * - * @param string $command Script and arguments. - * @throws Exception If the script crashed. - */ - protected function python($command) - { - $code = 0; - $python = config('laserpoints.python'); - $lines = []; - $output = exec("{$python} {$command} 2>&1", $lines, $code); - - if ($output || $code !== 0) { - $message = "Fatal error with Delphi gather script (code {$code})."; - Log::error($message, [ - 'command' => $command, - 'output' => $lines, - ]); - File::delete($this->outputPath); - - throw new Exception($message); - } - } -} diff --git a/src/Support/DetectAutomatic.php b/src/Support/DetectAutomatic.php new file mode 100644 index 00000000..13b0e41a --- /dev/null +++ b/src/Support/DetectAutomatic.php @@ -0,0 +1,32 @@ +&1"; + + return $this->exec($command); + } +} diff --git a/src/Support/DetectColor.php b/src/Support/DetectColor.php new file mode 100644 index 00000000..a84ea427 --- /dev/null +++ b/src/Support/DetectColor.php @@ -0,0 +1,51 @@ +&1"; + + $this->exec($command, decode: false); + + $color = trim(File::get($workDir.'/'.$colorFile)); + } finally { + File::deleteDirectory($workDir); + } + + $color = strtolower($color); + if (!in_array($color, ['red', 'green', 'blue', 'gray'], true)) { + return null; + } + + return $color; + } +} diff --git a/src/Support/Detect.php b/src/Support/DetectManual.php similarity index 65% rename from src/Support/Detect.php rename to src/Support/DetectManual.php index 93801b56..14b76068 100644 --- a/src/Support/Detect.php +++ b/src/Support/DetectManual.php @@ -5,23 +5,23 @@ /** * Wrapper for the manual laser points detection script. */ -class Detect extends LaserpointsScript +class DetectManual extends LaserpointsScript { /** * Execute a new manual laser point detection. * - * @param string $imageUrl Absolute path to the image file to detect laserpoints on + * @param string $imagePath Absolute path to the image file to detect laserpoints on * @param float $distance Distance of the laser points in cm * @param string $points Coordinates of all manually annotated laser points on the image as JSON encoded string (like `'[[100,100],[200,200]]'`) * @throws Exception If the detection script crashed. * * @return array The JSON object returned by the detect script as array */ - public function execute($imageUrl, $distance, $points) + public function execute($imagePath, $distance, $points) { $python = config('laserpoints.python'); - $script = config('laserpoints.detect_script'); - $command = "{$python} {$script} '{$imageUrl}' '{$distance}' '{$points}' 2>&1"; + $script = config('laserpoints.manual_script'); + $command = "{$python} {$script} '{$imagePath}' '{$distance}' '{$points}' 2>&1"; return $this->exec($command); } diff --git a/src/Support/LaserpointsScript.php b/src/Support/LaserpointsScript.php index 8f425f7f..54235681 100644 --- a/src/Support/LaserpointsScript.php +++ b/src/Support/LaserpointsScript.php @@ -15,15 +15,18 @@ class LaserpointsScript * * @return array The JSON object returned by the detection script as array */ - public function exec($command) + public function exec($command, $decode = true) { $code = 0; $lines = []; - $output = json_decode(exec($command, $lines, $code), true); + $output = exec($command, $lines, $code); + if ($decode) { + $output = json_decode($output, true); + } // Common script errors are handled gracefully with JSON error output. If the // output is no valid JSON with an 'error' property the script crashed fatally. - if ($output === null || !array_key_exists('error', $output)) { + if ($code !== 0 || $decode && ($output === null || !array_key_exists('error', $output))) { $message = "Fatal error with laser point detection (code {$code})."; Log::error($message, [ 'command' => $command, diff --git a/src/Volume.php b/src/Volume.php index 5f12971a..cb54e83d 100644 --- a/src/Volume.php +++ b/src/Volume.php @@ -16,14 +16,6 @@ class Volume extends BaseVolume { use FiltersInvalidLaserPoints; - /** - * Minimum number of manually annotated images required for Delphi laser point - * detection. - * - * @var int - */ - const MIN_DELPHI_IMAGES = 4; - /** * Converts a regular Biigle volume to a Laserpoints volume. * @@ -41,13 +33,13 @@ public static function convert(BaseVolume $volume) } /** - * Determines if the images of this volume can be processed with Delphi. + * Determines if the images of this volume have a valid number of manually annotated laser points. * * @param Label $label The laser point label. * - * @throws Exception If the images of this volume can't be processed with Delphi + * @throws Exception If the images of this volume have an invalid count of manually annotated laser points */ - public function readyForDelphiDetection(Label $label) + public function readyForManualDetection(Label $label) { $points = ImageAnnotation::join('image_annotation_labels', 'image_annotation_labels.annotation_id', '=', 'image_annotations.id') ->join('images', 'image_annotations.image_id', '=', 'images.id') @@ -62,10 +54,6 @@ public function readyForDelphiDetection(Label $label) return $annotations->count(); }); - if ($points->count() < self::MIN_DELPHI_IMAGES) { - throw new Exception('Only '.$points->count().' images have manually annotated laser points. At least '.self::MIN_DELPHI_IMAGES.' are required.'); - } - $reference = $points->first(); if ($reference < Image::MIN_MANUAL_POINTS) { throw new Exception('There must be at least '.Image::MIN_MANUAL_POINTS.' manually annotated laser points per image ('.$reference.' found).'); diff --git a/src/config/laserpoints.php b/src/config/laserpoints.php index bc662f09..7e77d6b7 100644 --- a/src/config/laserpoints.php +++ b/src/config/laserpoints.php @@ -8,38 +8,23 @@ 'python' => '/usr/bin/python3', /* - | Path to the detect script. + | Path to the manual detection script. */ - 'detect_script' => __DIR__.'/../resources/scripts/detect.py', + 'manual_script' => __DIR__.'/../resources/scripts/manual.py', /* - | Path to the Delphi gather script. + | Path to the automatic detection script. */ - 'delphi_gather_script' => __DIR__.'/../resources/scripts/delphi_gather.py', - - /* - | Path to the Delphi gather finish script. - */ - 'delphi_gather_finish_script' => __DIR__.'/../resources/scripts/delphi_gather_finish.py', - - /* - | Path to the Delphi apply script. - */ - 'delphi_apply_script' => __DIR__.'/../resources/scripts/delphi_apply.py', + 'automatic_script' => __DIR__.'/../resources/scripts/automatic.py', /* | Directory for temporary files. */ 'tmp_dir' => sys_get_temp_dir(), - /* - | Storage disk to store Delphi gather files that are shared by queued jobs. - */ - 'disk' => env('LASERPOINTS_STORAGE_DISK', 'laserpoints'), - /* | Specifies which queue should be used for which job. */ - 'process_delphi_queue' => env('LASERPOINTS_PROCESS_DELPHI_QUEUE', 'default'), + 'process_automatic_queue' => env('LASERPOINTS_PROCESS_AUTOMATIC_QUEUE', env('LASERPOINTS_PROCESS_DELPHI_QUEUE', 'default')), 'process_manual_queue' => env('LASERPOINTS_PROCESS_MANUAL_QUEUE', 'default'), ]; diff --git a/src/public/assets/main-BKb7iDn1.js b/src/public/assets/main-BKb7iDn1.js new file mode 100644 index 00000000..b47cdc7b --- /dev/null +++ b/src/public/assets/main-BKb7iDn1.js @@ -0,0 +1,12 @@ +var Co=Object.defineProperty;var Ro=(n,t,e)=>t in n?Co(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var ls=(n,t,e)=>Ro(n,typeof t!="symbol"?t+"":t,e);import{openBlock as ae,createElementBlock as le,createElementVNode as H,createTextVNode as ct,toDisplayString as hr,withDirectives as Ie,vModelText as Sn,resolveComponent as vo,withModifiers as Mo,normalizeClass as hs,vShow as us,createStaticVNode as To,vModelSelect as bo,createCommentVNode as cs,createVNode as Ao}from"vue";const k={IDLE:0,LOADING:1,LOADED:2,ERROR:3};function X(){throw new Error("Unimplemented abstract method.")}let Lo=0;function it(n){return n.ol_uid||(n.ol_uid=String(++Lo))}function ri(n,t){return Array.isArray(n)?n:(t===void 0?t=[n,n]:(t[0]=n,t[1]=n),t)}class Ui{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=ri(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Ui({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return X()}getImage(t){return X()}getHitDetectionImage(){return X()}getPixelRatio(t){return 1}getImageState(){return X()}getImageSize(){return X()}getOrigin(){return X()}getSize(){return X()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=ri(t)}listenImageChange(t){X()}load(){X()}unlistenImageChange(t){X()}ready(){return Promise.resolve()}}const oi={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]},rt={name:"xyz",min:[0,0,0],channel:["X","Y","Z"],alias:["XYZ","ciexyz","cie1931"],whitepoint:{2:{A:[109.85,100,35.585],C:[98.074,100,118.232],D50:[96.422,100,82.521],D55:[95.682,100,92.149],D65:[95.045592705167,100,108.9057750759878],D75:[94.972,100,122.638],F2:[99.187,100,67.395],F7:[95.044,100,108.755],F11:[100.966,100,64.37],E:[100,100,100]},10:{A:[111.144,100,35.2],C:[97.285,100,116.145],D50:[96.72,100,81.427],D55:[95.799,100,90.926],D65:[94.811,100,107.304],D75:[94.416,100,120.641],F2:[103.28,100,69.026],F7:[95.792,100,107.687],F11:[103.866,100,65.627],E:[100,100,100]}}};rt.max=rt.whitepoint[2].D65;rt.rgb=function(n,t){t=t||rt.whitepoint[2].E;var e=n[0]/t[0],i=n[1]/t[1],s=n[2]/t[2],r,o,a;return r=e*3.240969941904521+i*-1.537383177570093+s*-.498610760293,o=e*-.96924363628087+i*1.87596750150772+s*.041555057407175,a=e*.055630079696993+i*-.20397695888897+s*1.056971514242878,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:r=r*12.92,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=o*12.92,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=a*12.92,r=Math.min(Math.max(0,r),1),o=Math.min(Math.max(0,o),1),a=Math.min(Math.max(0,a),1),[r*255,o*255,a*255]};oi.xyz=function(n,t){var e=n[0]/255,i=n[1]/255,s=n[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,s=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92;var r=e*.41239079926595+i*.35758433938387+s*.18048078840183,o=e*.21263900587151+i*.71516867876775+s*.072192315360733,a=e*.019330818715591+i*.11919477979462+s*.95053215224966;return t=t||rt.whitepoint[2].E,[r*t[0],o*t[1],a*t[2]]};var Fn={name:"luv",min:[0,-134,-140],max:[100,224,122],channel:["lightness","u","v"],alias:["LUV","cieluv","cie1976"],xyz:function(n,t,e){var i,s,r,o,a,l,u,h,c,d,f,g,_;if(r=n[0],o=n[1],a=n[2],r===0)return[0,0,0];var m=.0011070564598794539;return t=t||"D65",e=e||2,c=rt.whitepoint[e][t][0],d=rt.whitepoint[e][t][1],f=rt.whitepoint[e][t][2],g=4*c/(c+15*d+3*f),_=9*d/(c+15*d+3*f),i=o/(13*r)+g||0,s=a/(13*r)+_||0,u=r>8?d*Math.pow((r+16)/116,3):d*r*m,l=u*9*i/(4*s)||0,h=u*(12-3*i-20*s)/(4*s)||0,[l,u,h]}};rt.luv=function(n,t,e){var i,s,r,o,a,l,u,h,c,d,f,g,_,m=.008856451679035631,p=903.2962962962961;t=t||"D65",e=e||2,c=rt.whitepoint[e][t][0],d=rt.whitepoint[e][t][1],f=rt.whitepoint[e][t][2],g=4*c/(c+15*d+3*f),_=9*d/(c+15*d+3*f),l=n[0],u=n[1],h=n[2],i=4*l/(l+15*u+3*h)||0,s=9*u/(l+15*u+3*h)||0;var y=u/d;return r=y<=m?p*y:116*Math.pow(y,1/3)-16,o=13*r*(i-g),a=13*r*(s-_),[r,o,a]};var ur={name:"lchuv",channel:["lightness","chroma","hue"],alias:["LCHuv","cielchuv"],min:[0,0,0],max:[100,100,360],luv:function(n){var t=n[0],e=n[1],i=n[2],s,r,o;return o=i/360*2*Math.PI,s=e*Math.cos(o),r=e*Math.sin(o),[t,s,r]},xyz:function(n){return Fn.xyz(ur.luv(n))}};Fn.lchuv=function(n){var t=n[0],e=n[1],i=n[2],s=Math.sqrt(e*e+i*i),r=Math.atan2(i,e),o=r*360/2/Math.PI;return o<0&&(o+=360),[t,s,o]};rt.lchuv=function(n){return Fn.lchuv(rt.luv(n))};const ds={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};var fs={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function Fo(n){var h,c;var t,e=[],i=1,s;if(typeof n=="number")return{space:"rgb",values:[n>>>16,(n&65280)>>>8,n&255],alpha:1};if(typeof n=="number")return{space:"rgb",values:[n>>>16,(n&65280)>>>8,n&255],alpha:1};if(n=String(n).toLowerCase(),ds[n])e=ds[n].slice(),s="rgb";else if(n==="transparent")i=0,s="rgb",e=[0,0,0];else if(n[0]==="#"){var r=n.slice(1),o=r.length,a=o<=4;i=1,a?(e=[parseInt(r[0]+r[0],16),parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16)],o===4&&(i=parseInt(r[3]+r[3],16)/255)):(e=[parseInt(r[0]+r[1],16),parseInt(r[2]+r[3],16),parseInt(r[4]+r[5],16)],o===8&&(i=parseInt(r[6]+r[7],16)/255)),e[0]||(e[0]=0),e[1]||(e[1]=0),e[2]||(e[2]=0),s="rgb"}else if(t=/^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\s*\(([^\)]*)\)/.exec(n)){var l=t[1];s=l.replace(/a$/,"");var u=s==="cmyk"?4:s==="gray"?1:3;e=t[2].trim().split(/\s*[,\/]\s*|\s+/),s==="color"&&(s=e.shift()),e=e.map(function(d,f){if(d[d.length-1]==="%")return d=parseFloat(d)/100,f===3?d:s==="rgb"?d*255:s[0]==="h"||s[0]==="l"&&!f?d*100:s==="lab"?d*125:s==="lch"?f<2?d*150:d*360:s[0]==="o"&&!f?d:s==="oklab"?d*.4:s==="oklch"?f<2?d*.4:d*360:d;if(s[f]==="h"||f===2&&s[s.length-1]==="h"){if(fs[d]!==void 0)return fs[d];if(d.endsWith("deg"))return parseFloat(d);if(d.endsWith("turn"))return parseFloat(d)*360;if(d.endsWith("grad"))return parseFloat(d)*360/400;if(d.endsWith("rad"))return parseFloat(d)*180/Math.PI}return d==="none"?0:parseFloat(d)}),i=e.length>u?e.pop():1}else/[0-9](?:\s|\/|,)/.test(n)&&(e=n.match(/([0-9]+)/g).map(function(d){return parseFloat(d)}),s=((c=(h=n.match(/([a-z])/ig))==null?void 0:h.join(""))==null?void 0:c.toLowerCase())||"rgb");return{space:s,values:e,alpha:i}}var un={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(n){var t=n[0]/360,e=n[1]/100,i=n[2]/100,s,r,o,a,l,u=0;if(e===0)return l=i*255,[l,l,l];for(r=i<.5?i*(1+e):i+e-i*e,s=2*i-r,a=[0,0,0];u<3;)o=t+1/3*-(u-1),o<0?o++:o>1&&o--,l=6*o<1?s+(r-s)*6*o:2*o<1?r:3*o<2?s+(r-s)*(2/3-o)*6:s,a[u++]=l*255;return a}};oi.hsl=function(n){var t=n[0]/255,e=n[1]/255,i=n[2]/255,s=Math.min(t,e,i),r=Math.max(t,e,i),o=r-s,a,l,u;return r===s?a=0:t===r?a=(e-i)/o:e===r?a=2+(i-t)/o:i===r&&(a=4+(t-e)/o),a=Math.min(a*60,360),a<0&&(a+=360),u=(s+r)/2,r===s?l=0:u<=.5?l=o/(r+s):l=o/(2-r-s),[a,l*100,u*100]};function ko(n){Array.isArray(n)&&n.raw&&(n=String.raw(...arguments)),n instanceof Number&&(n=+n);var t,e=Fo(n);if(!e.space)return[];const i=e.space[0]==="h"?un.min:oi.min,s=e.space[0]==="h"?un.max:oi.max;return t=Array(3),t[0]=Math.min(Math.max(e.values[0],i[0]),s[0]),t[1]=Math.min(Math.max(e.values[1],i[1]),s[1]),t[2]=Math.min(Math.max(e.values[2],i[2]),s[2]),e.space[0]==="h"&&(t=un.rgb(t)),t.push(Math.min(Math.max(e.alpha,0),1)),t}function ot(n,t,e){return Math.min(Math.max(n,t),e)}function Oo(n,t,e,i,s,r){const o=s-e,a=r-i;if(o!==0||a!==0){const l=((n-e)*o+(t-i)*a)/(o*o+a*a);l>1?(e=s,i=r):l>0&&(e+=o*l,i+=a*l)}return Le(n,t,e,i)}function Le(n,t,e,i){const s=e-n,r=i-t;return s*s+r*r}function Do(n){return n*Math.PI/180}function gs(n,t){const e=n%t;return e*t<0?e+t:e}function St(n,t,e){return n+e*(t-n)}function Po(n,t){const e=Math.pow(10,t);return Math.round(n*e)/e}function No(n){return typeof n=="string"?n:On(n)}const Go=1024,$e={};let cn=0;function Wo(n){if(n.length===4)return n;const t=n.slice();return t[3]=1,t}function _s(n){const t=rt.lchuv(oi.xyz(n));return t[3]=n[3],t}function Bo(n){const t=rt.rgb(ur.xyz(n));return t[3]=n[3],t}function kn(n){if($e.hasOwnProperty(n))return $e[n];if(cn>=Go){let e=0;for(const i in $e)(e++&3)===0&&(delete $e[i],--cn)}const t=ko(n);if(t.length!==4)throw new Error('Failed to parse "'+n+'" as color');for(const e of t)if(isNaN(e))throw new Error('Failed to parse "'+n+'" as color');return cr(t),$e[n]=t,++cn,t}function ai(n){return Array.isArray(n)?n:kn(n)}function cr(n){return n[0]=ot(n[0]+.5|0,0,255),n[1]=ot(n[1]+.5|0,0,255),n[2]=ot(n[2]+.5|0,0,255),n[3]=ot(n[3],0,1),n}function On(n){let t=n[0];t!=(t|0)&&(t=t+.5|0);let e=n[1];e!=(e|0)&&(e=e+.5|0);let i=n[2];i!=(i|0)&&(i=i+.5|0);const s=n[3]===void 0?1:Math.round(n[3]*1e3)/1e3;return"rgba("+t+","+e+","+i+","+s+")"}function Xo(n){try{return kn(n),!0}catch{return!1}}const se=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"";se.includes("firefox");const zo=se.includes("safari")&&!se.includes("chrom");zo&&(se.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(se));se.includes("webkit")&&se.includes("edge");se.includes("macintosh");const dr=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Yo=typeof Image<"u"&&Image.prototype.decode;(function(){let n=!1;try{const t=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("_",null,t),window.removeEventListener("_",null,t)}catch{}return n})();function pt(n,t,e,i){let s;return e&&e.length?s=e.shift():dr?s=new OffscreenCanvas(n||300,t||300):s=document.createElement("canvas"),n&&(s.width=n),t&&(s.height=t),s.getContext("2d",i)}let dn;function Pi(){return dn||(dn=pt(1,1)),dn}function Vo(n){const t=n.canvas;t.width=1,t.height=1,n.clearRect(0,0,1,1)}class Zo{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}class pi{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}function Uo(n,t,e){let i,s;e=e||de;let r=0,o=n.length,a=!1;for(;r>1),s=+e(n[i],t),s<0?r=i+1:(o=i,a=!s);return a?r:~r}function de(n,t){return n>t?1:n0?s-1:s}return i-1}if(e>0){for(let s=1;s0:!1}removeEventListener(t,e){if(!this.listeners_)return;const i=this.listeners_[t];if(!i)return;const s=i.indexOf(e);s!==-1&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[s]=li,++this.pendingRemovals_[t]):(i.splice(s,1),i.length===0&&delete this.listeners_[t]))}}const vt={CHANGE:"change"};function Bt(n,t,e,i,s){if(i&&i!==n&&(e=e.bind(i)),s){const o=e;e=function(){n.removeEventListener(t,e),o.apply(this,arguments)}}const r={target:n,type:t,listener:e};return n.addEventListener(t,e),r}function ms(n,t,e,i){return Bt(n,t,e,i,!0)}function ie(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),Pn(n))}function $o(n,t){return new Promise((e,i)=>{function s(){o(),e(n)}function r(){o(),i(new Error("Image load error"))}function o(){n.removeEventListener("load",s),n.removeEventListener("error",r)}n.addEventListener("load",s),n.addEventListener("error",r)})}function Ho(n,t){return t&&(n.src=t),n.src&&Yo?new Promise((e,i)=>n.decode().then(()=>e(n)).catch(s=>n.complete&&n.width?e(n):i(s))):$o(n)}class Jo{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=32}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(const e in this.cache_){const i=this.cache_[e];(t++&3)===0&&!i.hasListener()&&(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e,i){const s=fn(t,e,i);return s in this.cache_?this.cache_[s]:null}getPattern(t,e,i){const s=fn(t,e,i);return s in this.patternCache_?this.patternCache_[s]:null}set(t,e,i,s,r){const o=fn(t,e,i),a=o in this.cache_;this.cache_[o]=s,r&&(s.getImageState()===k.IDLE&&s.load(),s.getImageState()===k.LOADING?s.ready().then(()=>{this.patternCache_[o]=Pi().createPattern(s.getImage(1),"repeat")}):this.patternCache_[o]=Pi().createPattern(s.getImage(1),"repeat")),a||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function fn(n,t,e){const i=e?ai(e):"null";return t+":"+n+":"+i}const te=new Jo;let He=null;class Ko extends _r{constructor(t,e,i,s,r){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i,this.canvas_={},this.color_=r,this.imageState_=s===void 0?k.IDLE:s,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===k.LOADED){He||(He=pt(1,1,void 0,{willReadFrequently:!0})),He.drawImage(this.image_,0,0);try{He.getImageData(0,0,1,1),this.tainted_=!1}catch{He=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(vt.CHANGE)}handleImageError_(){this.imageState_=k.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=k.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const t=this.size_[0],e=this.size_[1],i=pt(t,e);i.fillRect(0,0,t,e),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===k.IDLE){this.image_||this.initializeImage_(),this.imageState_=k.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&Ho(this.image_,this.src_).then(t=>{this.image_=t,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(t){if(!this.color_||this.canvas_[t]||this.imageState_!==k.LOADED)return;const e=this.image_,i=document.createElement("canvas");i.width=Math.ceil(e.width*t),i.height=Math.ceil(e.height*t);const s=i.getContext("2d");s.scale(t,t),s.drawImage(e,0,0),s.globalCompositeOperation="multiply",s.fillStyle=No(this.color_),s.fillRect(0,0,i.width/t,i.height/t),s.globalCompositeOperation="destination-in",s.drawImage(e,0,0),this.canvas_[t]=i}ready(){return this.ready_||(this.ready_=new Promise(t=>{this.imageState_===k.LOADED||this.imageState_===k.ERROR?t():this.addEventListener(vt.CHANGE,function e(){(this.imageState_===k.LOADED||this.imageState_===k.ERROR)&&(this.removeEventListener(vt.CHANGE,e),t())})})),this.ready_}}function Nn(n,t,e,i,s,r){let o=t===void 0?void 0:te.get(t,e,s);return o||(o=new Ko(n,n&&"src"in n?n.src||void 0:t,e,i,s),te.set(t,e,s,o,r)),r&&o&&!te.getPattern(t,e,s)&&te.set(t,e,s,o,r),o}function At(n){return n?Array.isArray(n)?On(n):typeof n=="object"&&"src"in n?Qo(n):n:null}function Qo(n){if(!n.offset||!n.size)return te.getPattern(n.src,"anonymous",n.color);const t=n.src+":"+n.offset,e=te.getPattern(t,void 0,n.color);if(e)return e;const i=te.get(n.src,"anonymous",null);if(i.getImageState()!==k.LOADED)return null;const s=pt(n.size[0],n.size[1]);return s.drawImage(i.getImage(1),n.offset[0],n.offset[1],n.size[0],n.size[1],0,0,n.size[0],n.size[1]),Nn(s.canvas,t,void 0,k.LOADED,n.color,!0),te.getPattern(t,void 0,n.color)}const mr={PROPERTYCHANGE:"propertychange"};class pr extends _r{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(vt.CHANGE)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,s=new Array(i);for(let r=0;rMath.max(s,Gi(n,r)),0);return e[t]=i,i}function sa(n,t){const e=[],i=[],s=[];let r=0,o=0,a=0,l=0;for(let u=0,h=t.length;u<=h;u+=2){const c=t[u];if(c===` +`||u===h){r=Math.max(r,o),s.push(o),o=0,a+=l,l=0;continue}const d=t[u+1]||n.font,f=Gi(d,c);e.push(f),o+=f;const g=na(d);i.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:e,heights:i,lineWidths:s}}function ra(n,t,e,i,s,r,o,a,l,u,h){n.save(),e!==1&&(n.globalAlpha===void 0?n.globalAlpha=c=>c.globalAlpha*=e:n.globalAlpha*=e),t&&n.transform.apply(n,t),i.contextInstructions?(n.translate(l,u),n.scale(h[0],h[1]),oa(i,n)):h[0]<0||h[1]<0?(n.translate(l,u),n.scale(h[0],h[1]),n.drawImage(i,s,r,o,a,0,0,o,a)):n.drawImage(i,s,r,o,a,l,u,o*h[0],a*h[1]),n.restore()}function oa(n,t){const e=n.contextInstructions;for(let i=0,s=e.length;ithis.imageState_=k.LOADED),this.render()}clone(){const t=this.getScale(),e=new ji({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){const t=this.size_,e=this.getDisplacement(),i=this.getScaleArray();return[t[0]/2-e[0]/i[0],t[1]/2+e[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){let e=this.canvases_[t];if(!e){const i=this.renderOptions_,s=pt(i.size*t,i.size*t);this.draw_(i,s,t),e=s.canvas,this.canvases_[t]=e}return e}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius_}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,i){if(e===0||this.points_===1/0||t!=="bevel"&&t!=="miter")return e;let s=this.radius_,r=this.radius2_===void 0?s:this.radius2_;if(sMath.round(e*Cs[i])/Cs[i]).join(", ")+")"}const J={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function Wn(n,t,e){return e?(e[0]=n[0]-t,e[1]=n[1]-t,e[2]=n[2]+t,e[3]=n[3]+t,e):[n[0]-t,n[1]-t,n[2]+t,n[3]+t]}function ma(n,t){return n.slice()}function Ir(n,t,e){let i,s;return ts&&(l=l|J.RIGHT),ar&&(l=l|J.ABOVE),l===J.UNKNOWN&&(l=J.INTERSECTING),l}function ge(){return[1/0,1/0,-1/0,-1/0]}function Ne(n,t,e,i,s){return s?(s[0]=n,s[1]=t,s[2]=e,s[3]=i,s):[n,t,e,i]}function Cr(n){return Ne(1/0,1/0,-1/0,-1/0,n)}function Rr(n,t){const e=n[0],i=n[1];return Ne(e,i,e,i,t)}function Bn(n,t,e,i,s){const r=Cr(s);return Mr(r,n,t,e,i)}function vr(n,t){return n[0]==t[0]&&n[2]==t[2]&&n[1]==t[1]&&n[3]==t[3]}function pa(n,t){t[0]n[2]&&(n[2]=t[0]),t[1]n[3]&&(n[3]=t[1])}function Mr(n,t,e,i,s){for(;e=t[0]&&n[1]<=t[3]&&n[3]>=t[1]}function Fr(n){return n[2]=o&&_<=l),!i&&r&J.RIGHT&&!(s&J.RIGHT)&&(m=f-(d-l)*g,i=m>=a&&m<=u),!i&&r&J.BELOW&&!(s&J.BELOW)&&(_=d-(f-a)/g,i=_>=o&&_<=l),!i&&r&J.LEFT&&!(s&J.LEFT)&&(m=f-(d-o)*g,i=m>=a&&m<=u)}return i}function kr(n,t){const e=t.getExtent(),i=Ge(n);if(t.canWrapX()&&(i[0]=e[2])){const s=dt(e),o=Math.floor((i[0]-e[0])/s)*s;n[0]-=o,n[2]-=o}return n}function Ca(n,t,e){if(t.canWrapX()){const i=t.getExtent();if(!isFinite(n[0])||!isFinite(n[2]))return[[i[0],n[1],i[2],n[3]]];kr(n,t);const s=dt(i);if(dt(n)>s)return[[i[0],n[1],i[2],n[3]]];if(n[0]i[2])return[[n[0],n[1],i[2],n[3]],[i[0],n[1],n[2]-s,n[3]]]}return[n]}const Or={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class Dr{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=t.extent!==void 0?t.extent:null,this.worldExtent_=t.worldExtent!==void 0?t.worldExtent:null,this.axisOrientation_=t.axisOrientation!==void 0?t.axisOrientation:"enu",this.global_=t.global!==void 0?t.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||Or[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!!(t&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!!(this.global_&&t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}}const yi=6378137,Me=Math.PI*yi,Ra=[-Me,-Me,Me,Me],va=[-180,-85,180,85],Li=yi*Math.log(Math.tan(Math.PI/2));class ye extends Dr{constructor(t){super({code:t,units:"m",extent:Ra,global:!0,worldExtent:va,getPointResolution:function(e,i){return e/Math.cosh(i[1]/yi)}})}}const Rs=[new ye("EPSG:3857"),new ye("EPSG:102100"),new ye("EPSG:102113"),new ye("EPSG:900913"),new ye("http://www.opengis.net/def/crs/EPSG/0/3857"),new ye("http://www.opengis.net/gml/srs/epsg.xml#3857")];function Ma(n,t,e){const i=n.length;e=e>1?e:2,t===void 0&&(e>2?t=n.slice():t=new Array(i));for(let s=0;sLi?r=Li:r<-Li&&(r=-Li),t[s+1]=r}return t}function Ta(n,t,e){const i=n.length;e=e>1?e:2,t===void 0&&(e>2?t=n.slice():t=new Array(i));for(let s=0;s=0;--i)if(n[i]!=t[i]){e=!1;break}return e}function Da(n,t){const e=Math.cos(t),i=Math.sin(t),s=n[0]*e-n[1]*i,r=n[1]*e+n[0]*i;return n[0]=s,n[1]=r,n}function Pa(n,t){if(t.canWrapX()){const e=dt(t.getExtent()),i=Na(n,t,e);i&&(n[0]-=i*e)}return n}function Na(n,t,e){const i=t.getExtent();let s=0;return t.canWrapX()&&(n[0]i[2])&&(e=e||dt(i),s=Math.floor((n[0]-i[0])/e)),s}function Ga(...n){console.warn(...n)}let bn=!0;function Wa(n){bn=!1}function Pr(n,t){if(t!==void 0){for(let e=0,i=n.length;e=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&(bn=!1,Ga("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n}function Nr(n,t){return n}function ti(n,t){return n}function Za(){Ts(Rs),Ts(Ms),Ya(Ms,Rs,Ma,Ta)}Za();function ne(n,t,e,i,s,r){r=r||[];let o=0;for(let a=t;a{if(!i)return this.getSimplifiedGeometry(e);const s=this.clone();return s.applyTransform(i),s.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return X()}closestPointXY(t,e,i,s){return X()}containsXY(t,e){const i=this.getClosestPoint([t,e]);return i[0]===t&&i[1]===e}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return X()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&Cr(e),this.extentRevision_=this.getRevision()}return Ia(this.extent_,t)}rotate(t,e){X()}scale(t,e,i){X()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return X()}getType(){return X()}applyTransform(t){X()}intersectsExtent(t){return X()}translate(t,e){X()}transform(t,e){const i=_e(t),s=i.getUnits()=="tile-pixels"?function(r,o,a){const l=i.getExtent(),u=i.getWorldExtent(),h=Zt(u)/Zt(l);return fe(Ls,u[0],u[3],h,-h,0,0,0),ne(r,0,r.length,a,Ls,o),bs(i,e)(r,o,a)}:bs(i,e);return this.applyTransform(s),this}}class zn extends qa{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return Bn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return X()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length{this.patternImage_=null}),e.getImageState()===k.IDLE&&e.load(),e.getImageState()===k.LOADING&&(this.patternImage_=e)}this.color_=t}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}class Vt{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=ks,t.geometry!==void 0&&this.setGeometry(t.geometry),this.fill_=t.fill!==void 0?t.fill:null,this.image_=t.image!==void 0?t.image:null,this.renderer_=t.renderer!==void 0?t.renderer:null,this.hitDetectionRenderer_=t.hitDetectionRenderer!==void 0?t.hitDetectionRenderer:null,this.stroke_=t.stroke!==void 0?t.stroke:null,this.text_=t.text!==void 0?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&typeof t=="object"&&(t=t.clone()),new Vt({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){typeof t=="function"?this.geometryFunction_=t:typeof t=="string"?this.geometryFunction_=function(e){return e.get(t)}:t?t!==void 0&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=ks,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function Qa(n){let t;if(typeof n=="function")t=n;else{let e;Array.isArray(n)?e=n:(nt(typeof n.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[n]),t=function(){return e}}return t}let _n=null;function Br(n,t){if(!_n){const e=new xi({color:"rgba(255,255,255,0.4)"}),i=new We({color:"#3399CC",width:1.25});_n=[new Vt({image:new Pe({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return _n}function ks(n){return n.getGeometry()}const B={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};class tl extends me{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);typeof t.properties=="object"&&(delete e.properties,Object.assign(e,t.properties)),e[B.OPACITY]=t.opacity!==void 0?t.opacity:1,nt(typeof e[B.OPACITY]=="number","Layer opacity must be a number"),e[B.VISIBLE]=t.visible!==void 0?t.visible:!0,e[B.Z_INDEX]=t.zIndex,e[B.MAX_RESOLUTION]=t.maxResolution!==void 0?t.maxResolution:1/0,e[B.MIN_RESOLUTION]=t.minResolution!==void 0?t.minResolution:0,e[B.MIN_ZOOM]=t.minZoom!==void 0?t.minZoom:-1/0,e[B.MAX_ZOOM]=t.maxZoom!==void 0?t.maxZoom:1/0,this.className_=e.className!==void 0?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){const e=this.state_||{layer:this,managed:t===void 0?!0:t},i=this.getZIndex();return e.opacity=ot(Math.round(this.getOpacity()*100)/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=i===void 0&&!e.managed?1/0:i,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return X()}getLayerStatesArray(t){return X()}getExtent(){return this.get(B.EXTENT)}getMaxResolution(){return this.get(B.MAX_RESOLUTION)}getMinResolution(){return this.get(B.MIN_RESOLUTION)}getMinZoom(){return this.get(B.MIN_ZOOM)}getMaxZoom(){return this.get(B.MAX_ZOOM)}getOpacity(){return this.get(B.OPACITY)}getSourceState(){return X()}getVisible(){return this.get(B.VISIBLE)}getZIndex(){return this.get(B.Z_INDEX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(B.EXTENT,t)}setMaxResolution(t){this.set(B.MAX_RESOLUTION,t)}setMinResolution(t){this.set(B.MIN_RESOLUTION,t)}setMaxZoom(t){this.set(B.MAX_ZOOM,t)}setMinZoom(t){this.set(B.MIN_ZOOM,t)}setOpacity(t){nt(typeof t=="number","Layer opacity must be a number"),this.set(B.OPACITY,t)}setVisible(t){this.set(B.VISIBLE,t)}setZIndex(t){this.set(B.Z_INDEX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}const ue={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose"},Et={ANIMATING:0,INTERACTING:1},Ct={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"},el=256;function Os(n,t,e){return(function(i,s,r,o,a){if(!i)return;if(!s&&!t)return i;const l=t?0:r[0]*s,u=t?0:r[1]*s,h=a?a[0]:0,c=a?a[1]:0;let d=n[0]+l/2+h,f=n[2]-l/2+h,g=n[1]+u/2+c,_=n[3]-u/2+c;d>f&&(d=(f+d)/2,f=d),g>_&&(g=(_+g)/2,_=g);let m=ot(i[0],d,f),p=ot(i[1],g,_);if(o&&e&&s){const y=30*s;m+=-y*Math.log(1+Math.max(0,d-i[0])/y)+y*Math.log(1+Math.max(0,i[0]-f)/y),p+=-y*Math.log(1+Math.max(0,g-i[1])/y)+y*Math.log(1+Math.max(0,i[1]-_)/y)}return[m,p]})}function il(n){return n}function Yn(n,t,e,i){const s=dt(t)/e[0],r=Zt(t)/e[1];return i?Math.min(n,Math.max(s,r)):Math.min(n,Math.min(s,r))}function Vn(n,t,e){let i=Math.min(n,t);const s=50;return i*=Math.log(1+s*Math.max(0,n/t-1))/s+1,e&&(i=Math.max(i,e),i/=Math.log(1+s*Math.max(0,e/n-1))/s+1),ot(i,e/2,t*2)}function nl(n,t,e,i){return t=t!==void 0?t:!0,(function(s,r,o,a){if(s!==void 0){const l=n[0],u=n[n.length-1],h=e?Yn(l,e,o,i):l;if(a)return t?Vn(s,h,u):ot(s,u,h);const c=Math.min(h,s),d=Math.floor(fr(n,c,r));return n[d]>h&&d1)c=e;else if(d>0){for(let f=0;fs&&(s=u),r=a,o=l}return s}function cl(n,t,e,i,s){for(let r=0,o=e.length;r0;){const c=u.pop(),d=u.pop();let f=0;const g=n[d],_=n[d+1],m=n[c],p=n[c+1];for(let y=d+i;yf&&(h=y,f=I)}f>s&&(l[(h-t)/i]=1,d+i0&&_>f)&&(g<0&&m0&&m>g)){u=c,h=d;continue}r[o++]=u,r[o++]=h,a=u,l=h,u=c,h=d}return r[o++]=u,r[o++]=h,o}function Yr(n,t,e,i,s,r,o,a){for(let l=0,u=e.length;lr&&(u-a)*(r-l)-(s-a)*(h-l)>0&&o++:h<=r&&(u-a)*(r-l)-(s-a)*(h-l)<0&&o--,a=u,l=h}return o!==0}function Zr(n,t,e,i,s,r){if(e.length===0||!ce(n,t,e[0],i,s,r))return!1;for(let o=1,a=e.length;op&&(u=(h+c)/2,Zr(n,t,e,i,u,g)&&(m=u,p=y)),h=c}return isNaN(m)&&(m=s[r]),o?(o.push(m,g,p),o):[m,g,p]}function pl(n,t,e,i,s){let r=[];for(let o=0,a=e.length;o=s[0]&&r[2]<=s[2]||r[1]>=s[1]&&r[3]<=s[3]?!0:yl(n,t,e,i,function(o,a){return Sa(s,o,a)}):!1}function xl(n,t,e,i,s){return!!(Ur(n,t,e,i,s)||ce(n,t,e,i,s[0],s[1])||ce(n,t,e,i,s[0],s[3])||ce(n,t,e,i,s[2],s[1])||ce(n,t,e,i,s[2],s[3]))}function wl(n,t,e,i,s){if(!xl(n,t,e[0],i,s))return!1;if(e.length===1)return!0;for(let r=1,o=e.length;r0}function Il(n,t,e,i,s){s=s!==void 0?s:!1;for(let r=0,o=e.length;r1&&typeof arguments[e-1]=="function"&&(i=arguments[e-1],--e);let s=0;for(;s0}getInteracting(){return this.hints_[Et.INTERACTING]>0}cancelAnimations(){this.setHint(Et.ANIMATING,-this.hints_[Et.ANIMATING]);let t;for(let e=0,i=this.animations_.length;e=0;--i){const s=this.animations_[i];let r=!0;for(let o=0,a=s.length;o0?u/l.duration:1;h>=1?(l.complete=!0,h=1):r=!1;const c=l.easing(h);if(l.sourceCenter){const d=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],_=l.targetCenter[1];this.nextCenter_=l.targetCenter;const m=d+c*(g-d),p=f+c*(_-f);this.targetCenter_=[m,p]}if(l.sourceResolution&&l.targetResolution){const d=c===1?l.targetResolution:l.sourceResolution+c*(l.targetResolution-l.sourceResolution);if(l.anchor){const f=this.getViewportSize_(this.getRotation()),g=this.constraints_.resolution(d,0,f,!0);this.targetCenter_=this.calculateCenterZoom(g,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=d,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){const d=c===1?gs(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+c*(l.targetRotation-l.sourceRotation);if(l.anchor){const f=this.constraints_.rotation(d,!0);this.targetCenter_=this.calculateCenterRotate(f,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=d}if(this.applyTargetState_(!0),e=!0,!l.complete)break}if(r){this.animations_[i]=null,this.setHint(Et.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=s[0].callback;o&&Fi(o,!0)}}this.animations_=this.animations_.filter(Boolean),e&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let i;const s=this.getCenterInternal();return s!==void 0&&(i=[s[0]-e[0],s[1]-e[1]],Da(i,t-this.getRotation()),Oa(i,e)),i}calculateCenterZoom(t,e){let i;const s=this.getCenterInternal(),r=this.getResolution();if(s!==void 0&&r!==void 0){const o=e[0]-t*(e[0]-s[0])/r,a=e[1]-t*(e[1]-s[1])/r;i=[o,a]}return i}getViewportSize_(t){const e=this.viewportSize_;if(t){const i=e[0],s=e[1];return[Math.abs(i*Math.cos(t))+Math.abs(s*Math.sin(t)),Math.abs(i*Math.sin(t))+Math.abs(s*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const t=this.getCenterInternal();return t&&As(t,this.getProjection())}getCenterInternal(){return this.get(Ct.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return t!==void 0?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){const e=this.calculateExtentInternal(t);return Nr(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();nt(e,"The view center is not defined");const i=this.getResolution();nt(i!==void 0,"The view resolution is not defined");const s=this.getRotation();return nt(s!==void 0,"The view rotation is not defined"),wa(e,i,s,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get(Ct.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(ti(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=dt(t)/e[0],s=Zt(t)/e[1];return Math.max(i,s)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,s=Math.log(e/i)/Math.log(t);return(function(r){return e/Math.pow(t,r*s)})}getRotation(){return this.get(Ct.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),i=this.getConstrainedResolution(this.maxResolution_),s=this.minResolution_,r=Math.log(i/s)/e;return(function(o){return Math.log(i/o)/e/r})}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const i=this.padding_;return i&&(e=[e[0]-i[1]-i[3],e[1]-i[0]-i[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),i=this.getRotation();let s=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();s=pn(s,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],e,i)}return{center:s.slice(0),projection:t!==void 0?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t;const e=this.getResolution();return e!==void 0&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e=this.minZoom_||0,i,s;if(this.resolutions_){const r=fr(this.resolutions_,t,1);e=r,i=this.resolutions_[r],r==this.resolutions_.length-1?s=2:s=i/this.resolutions_[r+1]}else i=this.maxResolution_,s=this.zoomFactor_;return e+Math.log(i/t)/Math.log(s)}getResolutionForZoom(t){if(this.resolutions_){if(this.resolutions_.length<=1)return 0;const e=ot(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,ot(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(nt(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){nt(!Fr(t),"Cannot fit empty extent provided as `geometry`");const s=ti(t,this.getProjection());i=Bs(s)}else if(t.getType()==="Circle"){const s=ti(t.getExtent(),this.getProjection());i=Bs(s),i.rotate(this.getRotation(),Ge(s))}else i=t;this.fitInternal(i,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),i=Math.cos(e),s=Math.sin(-e),r=t.getFlatCoordinates(),o=t.getStride();let a=1/0,l=1/0,u=-1/0,h=-1/0;for(let c=0,d=r.length;c{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return!this.renderer_||!this.rendered?null:this.renderer_.getData(t)}isVisible(t){let e;const i=this.getMapInternal();!t&&i&&(t=i.getView()),t instanceof Xs?e={viewState:t.getState(),extent:t.calculateExtent()}:e=t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let s;e.layerStatesArray?s=e.layerStatesArray.find(o=>o.layer===this):s=this.getLayerState();const r=this.getExtent();return bl(s,e.viewState)&&(!r||Rt(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];let e;const i=this.getSource();if(i&&(e=i.getAttributions()),!e)return[];const s=t instanceof Xs?t.getViewStateAndExtent():t;let r=e(s);return Array.isArray(r)||(r=[r]),r}render(t,e){const i=this.getRenderer();return i.prepareFrame(t)?(this.rendered=!0,i.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){const e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(B.MAP,t)}getMapInternal(){return this.get(B.MAP)}setMap(t){this.mapPrecomposeKey_&&(ie(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(ie(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=Bt(t,ue.PRECOMPOSE,function(e){const s=e.frameState.layerStatesArray,r=this.getLayerState(!1);nt(!s.some(function(o){return o.layer===r.layer}),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),s.push(r)},this),this.mapRenderKey_=Bt(this,vt.CHANGE,t.render,t),this.changed())}setSource(t){this.set(B.SOURCE,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}disposeInternal(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_),this.setSource(null),super.disposeInternal()}}function bl(n,t){if(!n.visible)return!1;const e=t.resolution;if(e=n.maxResolution)return!1;const i=t.zoom;return i>n.minZoom&&i<=n.maxZoom}function Al(n,t,e,i,s){jr(n,t,e||0,i||n.length-1,s||Ll)}function jr(n,t,e,i,s){for(;i>e;){if(i-e>600){var r=i-e+1,o=t-e+1,a=Math.log(r),l=.5*Math.exp(2*a/3),u=.5*Math.sqrt(a*l*(r-l)/r)*(o-r/2<0?-1:1),h=Math.max(e,Math.floor(t-o*l/r+u)),c=Math.min(i,Math.floor(t+(r-o)*l/r+u));jr(n,t,h,c,s)}var d=n[t],f=e,g=i;for(Je(n,e,t),s(n[i],d)>0&&Je(n,e,i);f0;)g--}s(n[e],d)===0?Je(n,e,g):(g++,Je(n,g,i)),g<=t&&(e=g+1),t<=g&&(i=g-1)}}function Je(n,t,e){var i=n[t];n[t]=n[e],n[e]=i}function Ll(n,t){return nt?1:0}let qr=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!Oi(t,e))return i;const s=this.toBBox,r=[];for(;e;){for(let o=0;o=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)}_split(t,e){const i=t[e],s=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,s);const o=this._chooseSplitIndex(i,r,s),a=Ce(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,xe(i,this.toBBox),xe(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=Ce([t,e]),this.data.height=t.height+1,this.data.leaf=!1,xe(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,r=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=ei(t,0,a,this.toBBox),u=ei(t,a,i,this.toBBox),h=Pl(l,u),c=yn(l)+yn(u);h=e;u--){const h=t.children[u];ii(a,t.leaf?r(h):h),l+=ki(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)ii(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():xe(t[e],this.toBBox)}};function Fl(n,t,e){if(!e)return t.indexOf(n);for(let i=0;i=n.minX&&t.maxY>=n.minY}function Ce(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function zs(n,t,e,i,s){const r=[t,e];for(;r.length;){if(e=r.pop(),t=r.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;Al(n,o,t,e,s),r.push(t,o,o,e)}}function Ys(n,t,e,i){return e!==void 0&&i!==void 0?[e/n,i/t]:e!==void 0?e/n:i!==void 0?i/t:1}class $i extends Ui{constructor(t){t=t||{};const e=t.opacity!==void 0?t.opacity:1,i=t.rotation!==void 0?t.rotation:0,s=t.scale!==void 0?t.scale:1,r=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:e,rotation:i,scale:s,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:r,declutterMode:t.declutterMode}),this.anchor_=t.anchor!==void 0?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=t.anchorOrigin!==void 0?t.anchorOrigin:"top-left",this.anchorXUnits_=t.anchorXUnits!==void 0?t.anchorXUnits:"fraction",this.anchorYUnits_=t.anchorYUnits!==void 0?t.anchorYUnits:"fraction",this.crossOrigin_=t.crossOrigin!==void 0?t.crossOrigin:null;const o=t.img!==void 0?t.img:null;let a=t.src;nt(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||it(o)),nt(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),nt(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(t.src!==void 0?l=k.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?k.LOADED:k.IDLE:l=k.LOADING:l=k.LOADED),this.color_=t.color!==void 0?ai(t.color):null,this.iconImage_=Nn(o,a,this.crossOrigin_,l,this.color_),this.offset_=t.offset!==void 0?t.offset:[0,0],this.offsetOrigin_=t.offsetOrigin!==void 0?t.offsetOrigin:"top-left",this.origin_=null,this.size_=t.size!==void 0?t.size:null,t.width!==void 0||t.height!==void 0){let u,h;if(t.size)[u,h]=t.size;else{const c=this.getImage(1);if(c.width&&c.height)u=c.width,h=c.height;else if(c instanceof HTMLImageElement){this.initialOptions_=t;const d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(Ys(f[0],f[1],t.width,t.height))};this.listenImageChange(d);return}}u!==void 0&&this.setScale(Ys(u,h,t.width,t.height))}}clone(){let t,e,i;return this.initialOptions_?(e=this.initialOptions_.width,i=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new $i({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:i,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;const s=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!s)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=s[0]),this.anchorYUnits_=="fraction"&&(t[1]*=s[1])}if(this.anchorOrigin_!="top-left"){if(!s)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+s[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+s[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),i=this.getScaleArray();return[t[0]-e[0]/i[0],t[1]+e[1]/i[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if(this.offsetOrigin_!="top-left"){const e=this.getSize(),i=this.iconImage_.getSize();if(!e||!i)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=i[0]-e[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=i[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();if(this.size_)return this.size_[0]*t[0];if(this.iconImage_.getImageState()==k.LOADED)return this.iconImage_.getSize()[0]*t[0]}getHeight(){const t=this.getScaleArray();if(this.size_)return this.size_[1]*t[1];if(this.iconImage_.getImageState()==k.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(vt.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(vt.CHANGE,t)}ready(){return this.iconImage_.ready()}}const Nl="#333";class qn{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.scale_=t.scale,this.scaleArray_=ri(t.scale!==void 0?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=t.fill!==void 0?t.fill:new xi({color:Nl}),this.maxAngle_=t.maxAngle!==void 0?t.maxAngle:Math.PI/4,this.placement_=t.placement!==void 0?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=t.stroke!==void 0?t.stroke:null,this.offsetX_=t.offsetX!==void 0?t.offsetX:0,this.offsetY_=t.offsetY!==void 0?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=t.padding===void 0?null:t.padding,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new qn({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=ri(t!==void 0?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}}let pe=0;const Xe=0,j=1<",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string"},zl={[x.Get]:L(([n,t])=>t!==void 0?Xl(t.value):st,F(1,2),Yl),[x.Var]:L(([n])=>n.type,F(1,1),Vl),[x.Id]:L(M|mt,Ke,Zl),[x.Concat]:L(mt,F(2,1/0),D(st)),[x.GeometryType]:L(mt,Ke,Ul),[x.Resolution]:L(M,Ke),[x.Zoom]:L(M,Ke),[x.Time]:L(M,Ke),[x.Any]:L(j,F(2,1/0),D(j)),[x.All]:L(j,F(2,1/0),D(j)),[x.Not]:L(j,F(1,1),D(j)),[x.Equal]:L(j,F(2,2),D(st),Ht),[x.NotEqual]:L(j,F(2,2),D(st),Ht),[x.GreaterThan]:L(j,F(2,2),D(st),Ht),[x.GreaterThanOrEqualTo]:L(j,F(2,2),D(st),Ht),[x.LessThan]:L(j,F(2,2),D(st),Ht),[x.LessThanOrEqualTo]:L(j,F(2,2),D(st),Ht),[x.Multiply]:L(n=>{let t=M|K;for(let e=0;e{let t=st;for(let e=1;e{let t=st;for(let e=2;e{let t=K|M;for(let e=3;e{let t=st;for(let e=1;en.length===2?Lt|si:n.length===3||n.length===4?Lt|K:Lt,F(1,1/0),D(M)),[x.Color]:L(K,F(1,4),D(M)),[x.Band]:L(M,F(1,3),D(M)),[x.Palette]:L(K,F(2,2),Kl),[x.ToString]:L(mt,F(1,1),D(j|M|mt|K))};function Yl(n,t){const e=W(n[1],t);if(!(e instanceof ee))throw new Error("Expected a literal argument for get operation");if(typeof e.value!="string")throw new Error("Expected a string argument for get operation");if(t.properties.add(e.value),n.length===3){const i=W(n[2],t);return[e,i]}return[e]}function Vl(n,t,e,i){const s=n[1];if(typeof s!="string")throw new Error("Expected a string argument for var operation");if(t.variables.add(s),!("variables"in t.style)||t.style.variables[s]===void 0)return[new ee(st,s)];const r=t.style.variables[s],o=W(r,t);if(o.value=s,i&&!Ft(i,o.type))throw new Error(`The variable ${s} has type ${at(o.type)} but the following type was expected: ${at(i)}`);return[o]}function Zl(n,t){t.featureId=!0}function Ul(n,t){t.geometryType=!0}function Ke(n,t){const e=n[0];if(n.length!==1)throw new Error(`Expected no arguments for ${e} operation`);return[]}function F(n,t){return function(e,i){const s=e[0],r=e.length-1;if(n===t){if(r!==n){const o=n===1?"":"s";throw new Error(`Expected ${n} argument${o} for ${s}, got ${r}`)}}else if(rt){const o=t===1/0?`${n} or more`:`${n} to ${t}`;throw new Error(`Expected ${o} arguments for ${s}, got ${r}`)}}}function D(n){return function(t,e){const i=t[0],s=t.length-1,r=new Array(s);for(let o=0;oi.featureId;case x.GeometryType:return i=>i.geometryType;case x.Concat:{const i=n.args.map(s=>Mt(s));return s=>"".concat(...i.map(r=>r(s).toString()))}case x.Resolution:return i=>i.resolution;case x.Any:case x.All:case x.Between:case x.In:case x.Not:return nh(n);case x.Equal:case x.NotEqual:case x.LessThan:case x.LessThanOrEqualTo:case x.GreaterThan:case x.GreaterThanOrEqualTo:return ih(n);case x.Multiply:case x.Divide:case x.Add:case x.Subtract:case x.Clamp:case x.Mod:case x.Pow:case x.Abs:case x.Floor:case x.Ceil:case x.Round:case x.Sin:case x.Cos:case x.Atan:case x.Sqrt:return sh(n);case x.Case:return rh(n);case x.Match:return oh(n);case x.Interpolate:return ah(n);case x.ToString:return lh(n);default:throw new Error(`Unsupported operator ${e}`)}}function th(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{for(let o=0;o{for(let o=0;os.properties[i];case x.Var:return s=>s.variables[i];default:throw new Error(`Unsupported accessor operator ${n.operator}`)}}function ih(n,t){const e=n.operator,i=Mt(n.args[0]),s=Mt(n.args[1]);switch(e){case x.Equal:return r=>i(r)===s(r);case x.NotEqual:return r=>i(r)!==s(r);case x.LessThan:return r=>i(r)i(r)<=s(r);case x.GreaterThan:return r=>i(r)>s(r);case x.GreaterThanOrEqualTo:return r=>i(r)>=s(r);default:throw new Error(`Unsupported comparison operator ${e}`)}}function nh(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{for(let o=0;o{for(let o=0;o{const o=s[0](r),a=s[1](r),l=s[2](r);return o>=a&&o<=l};case x.In:return r=>{const o=s[0](r);for(let a=1;a!s[0](r);default:throw new Error(`Unsupported logical operator ${e}`)}}function sh(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{let o=1;for(let a=0;as[0](r)/s[1](r);case x.Add:return r=>{let o=0;for(let a=0;as[0](r)-s[1](r);case x.Clamp:return r=>{const o=s[0](r),a=s[1](r);if(ol?l:o};case x.Mod:return r=>s[0](r)%s[1](r);case x.Pow:return r=>Math.pow(s[0](r),s[1](r));case x.Abs:return r=>Math.abs(s[0](r));case x.Floor:return r=>Math.floor(s[0](r));case x.Ceil:return r=>Math.ceil(s[0](r));case x.Round:return r=>Math.round(s[0](r));case x.Sin:return r=>Math.sin(s[0](r));case x.Cos:return r=>Math.cos(s[0](r));case x.Atan:return i===2?r=>Math.atan2(s[0](r),s[1](r)):r=>Math.atan(s[0](r));case x.Sqrt:return r=>Math.sqrt(s[0](r));default:throw new Error(`Unsupported numeric operator ${e}`)}}function rh(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s{for(let r=0;r{const r=i[0](s);for(let o=1;o{const r=i[0](s),o=i[1](s);let a,l;for(let u=2;u=o)return u===2?c:d?hh(r,o,a,l,h,c):ni(r,o,a,l,h,c);a=h,l=c}return l}}function lh(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{const o=s[0](r);return n.args[0].type===K?On(o):o.toString()};default:throw new Error(`Unsupported convert operator ${e}`)}}function ni(n,t,e,i,s,r){const o=s-e;if(o===0)return i;const a=t-e,l=n===1?a/o:(Math.pow(n,a)-1)/(Math.pow(n,o)-1);return i+l*(r-i)}function hh(n,t,e,i,s,r){if(s-e===0)return i;const a=_s(i),l=_s(r);let u=l[2]-a[2];u>180?u-=360:u<-180&&(u+=360);const h=[ni(n,t,e,a[0],s,l[0]),ni(n,t,e,a[1],s,l[1]),a[2]+ni(n,t,e,0,s,u),ni(n,t,e,i[3],s,r[3])];return cr(Bo(h))}function uh(n){return!0}function ch(n){const t=Hr(),e=dh(n,t),i=Kr();return function(s,r){if(i.properties=s.getPropertiesInternal(),i.resolution=r,t.featureId){const o=s.getId();o!==void 0?i.featureId=o:i.featureId=null}return t.geometryType&&(i.geometryType=Jr(s.getGeometry())),e(i)}}function Zs(n){const t=Hr(),e=n.length,i=new Array(e);for(let o=0;o4)throw new Error(`Expected a color with 3 or 4 values for ${t}`);return e}function io(n,t){const e=wi(n,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function Sh(n,t){return typeof n=="number"?n:io(n,t)}const $s={RENDER_ORDER:"renderOrder"};class Ch extends Tl{constructor(t){t=t||{};const e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=t.renderBuffer!==void 0?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=t.updateWhileAnimating!==void 0?t.updateWhileAnimating:!1,this.updateWhileInteracting_=t.updateWhileInteracting!==void 0?t.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get($s.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const i=this.getDeclutter();i in t.declutter||(t.declutter[i]=new qr(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set($s.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?Br:t;const e=Rh(t);this.styleFunction_=t===null?void 0:Qa(e),this.changed()}}function Rh(n){if(n===void 0)return Br;if(!n)return null;if(typeof n=="function"||n instanceof Vt)return n;if(!Array.isArray(n))return Zs([n]);if(n.length===0)return[];const t=n.length,e=n[0];if(e instanceof Vt){const s=new Array(t);for(let r=0;rl&&(this.instructions.push([T.CUSTOM,l,h,t,i,Te,r]),this.hitDetectionInstructions.push([T.CUSTOM,l,h,t,s||i,Te,r]));break;case"Point":u=t.getFlatCoordinates(),this.coordinates.push(u[0],u[1]),h=this.coordinates.length,this.instructions.push([T.CUSTOM,l,h,t,i,void 0,r]),this.hitDetectionInstructions.push([T.CUSTOM,l,h,t,s||i,void 0,r]);break}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[T.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[T.BEGIN_GEOMETRY,e,0,t,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;t.reverse();let e;const i=t.length;let s,r,o=-1;for(e=0;ethis.maxLineWidth&&(this.maxLineWidth=i.lineWidth,this.bufferedMaxExtent_=null)}else i.strokeStyle=void 0,i.lineCap=void 0,i.lineDash=null,i.lineDashOffset=void 0,i.lineJoin=void 0,i.lineWidth=void 0,i.miterLimit=void 0}createFill(t){const e=t.fillStyle,i=[T.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[T.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,this.applyPixelRatio(t.lineDash),t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const i=t.fillStyle;(typeof i!="string"||t.currentFillStyle!=i)&&(i!==void 0&&this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){const i=t.strokeStyle,s=t.lineCap,r=t.lineDash,o=t.lineDashOffset,a=t.lineJoin,l=t.lineWidth,u=t.miterLimit;(t.currentStrokeStyle!=i||t.currentLineCap!=s||r!=t.currentLineDash&&!Be(t.currentLineDash,r)||t.currentLineDashOffset!=o||t.currentLineJoin!=a||t.currentLineWidth!=l||t.currentMiterLimit!=u)&&(i!==void 0&&e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=s,t.currentLineDash=r,t.currentLineDashOffset=o,t.currentLineJoin=a,t.currentLineWidth=l,t.currentMiterLimit=u)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[T.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=ma(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;Wn(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class vh extends Ei{constructor(t,e,i,s){super(t,e,i,s),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(t,e,i){if(!this.image_||this.maxExtent&&!vn(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,i);const s=t.getFlatCoordinates(),r=t.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(s,r);this.instructions.push([T.DRAW_IMAGE,o,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([T.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}drawMultiPoint(t,e,i){if(!this.image_)return;this.beginGeometry(t,e,i);const s=t.getFlatCoordinates(),r=[];for(let l=0,u=s.length;l=n){const g=(n-a+f)/f,_=St(u,c,g),m=St(h,d,g);l.push(_,m),r.push(l),l=[_,m],a==n&&(o+=s),a=0}else if(a0&&r.push(l),r}function bh(n,t,e,i,s){let r=e,o=e,a=0,l=0,u=e,h,c,d,f,g,_,m,p,y,w;for(c=e;cn&&(l>a&&(a=l,r=u,o=c),l=0,u=c-s)),d=f,m=y,p=w),g=S,_=I}return l+=f,l>a?[u,c]:[r,o]}const Zi={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class Ah extends Ei{constructor(t,e,i,s){super(t,e,i,s),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[ut]={fillStyle:ut},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){const t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e,i){const s=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!s&&!r)return;const a=this.coordinates;let l=a.length;const u=t.getType();let h=null,c=t.getStride();if(o.placement==="line"&&(u=="LineString"||u=="MultiLineString"||u=="Polygon"||u=="MultiPolygon")){if(!Rt(this.maxExtent,t.getExtent()))return;let d;if(h=t.getFlatCoordinates(),u=="LineString")d=[h.length];else if(u=="MultiLineString")d=t.getEnds();else if(u=="Polygon")d=t.getEnds().slice(0,1);else if(u=="MultiPolygon"){const m=t.getEndss();d=[];for(let p=0,y=m.length;p{const I=a[(y+S)*2]===h[S*c]&&a[(y+S)*2+1]===h[S*c+1];return I||--y,I})}this.saveTextStates_(),(o.backgroundFill||o.backgroundStroke)&&(this.setFillStrokeStyle(o.backgroundFill,o.backgroundStroke),o.backgroundFill&&this.updateFillStyle(this.state,this.createFill),o.backgroundStroke&&(this.updateStrokeStyle(this.state,this.applyStroke),this.hitDetectionInstructions.push(this.createStroke(this.state)))),this.beginGeometry(t,e,i);let g=o.padding;if(g!=he&&(o.scale[0]<0||o.scale[1]<0)){let y=o.padding[0],w=o.padding[1],S=o.padding[2],I=o.padding[3];o.scale[0]<0&&(w=-w,I=-I),o.scale[1]<0&&(y=-y,S=-S),g=[y,w,S,I]}const _=this.pixelRatio;this.instructions.push([T.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,g==he?he:g.map(function(y){return y*_}),!!o.backgroundFill,!!o.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);const m=1/_,p=this.state.fillStyle;o.backgroundFill&&(this.state.fillStyle=ut,this.hitDetectionInstructions.push(this.createFill(this.state))),this.hitDetectionInstructions.push([T.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[m,m],NaN,this.declutterMode_,this.declutterImageWithText_,g,!!o.backgroundFill,!!o.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?ut:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),o.backgroundFill&&(this.state.fillStyle=p,this.hitDetectionInstructions.push(this.createFill(this.state))),this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,i=this.textFillState_,s=this.strokeKey_;t&&(s in this.strokeStates||(this.strokeStates[s]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:e.font,textAlign:e.textAlign||ci,justify:e.justify,textBaseline:e.textBaseline||Ni,scale:e.scale});const o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(t,e){const i=this.textStrokeState_,s=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,u=Zi[s.textBaseline],h=this.textOffsetY_*l,c=this.text_,d=i?i.lineWidth*Math.abs(s.scale[0])/2:0;this.instructions.push([T.DRAW_CHARS,t,e,u,s.overflow,a,s.maxAngle,l,h,r,d*l,c,o,1,this.declutterMode_]),this.hitDetectionInstructions.push([T.DRAW_CHARS,t,e,u,s.overflow,a&&ut,s.maxAngle,l,h,r,d*l,c,o,1/l,this.declutterMode_])}setTextStyle(t,e){let i,s,r;if(!t)this.text_="";else{const o=t.getFill();o?(s=this.textFillState_,s||(s={},this.textFillState_=s),s.fillStyle=At(o.getColor()||ut)):(s=null,this.textFillState_=s);const a=t.getStroke();if(!a)r=null,this.textStrokeState_=r;else{r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const g=a.getLineDash(),_=a.getLineDashOffset(),m=a.getWidth(),p=a.getMiterLimit();r.lineCap=a.getLineCap()||Oe,r.lineDash=g?g.slice():Xt,r.lineDashOffset=_===void 0?zt:_,r.lineJoin=a.getLineJoin()||De,r.lineWidth=m===void 0?di:m,r.miterLimit=p===void 0?hi:p,r.strokeStyle=At(a.getColor()||ui)}i=this.textState_;const l=t.getFont()||xr;ia(l);const u=t.getScaleArray();i.overflow=t.getOverflow(),i.font=l,i.maxAngle=t.getMaxAngle(),i.placement=t.getPlacement(),i.textAlign=t.getTextAlign(),i.repeat=t.getRepeat(),i.justify=t.getJustify(),i.textBaseline=t.getTextBaseline()||Ni,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||he,i.scale=u===void 0?[1,1]:u;const h=t.getOffsetX(),c=t.getOffsetY(),d=t.getRotateWithView(),f=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=h===void 0?0:h,this.textOffsetY_=c===void 0?0:c,this.textRotateWithView_=d===void 0?!1:d,this.textRotation_=f===void 0?0:f,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:it(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=s&&s.fillStyle?typeof s.fillStyle=="string"?s.fillStyle:"|"+it(s.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}const Lh={Circle:wn,Default:Ei,Image:vh,LineString:Mh,Polygon:wn,Text:Ah,Ellipse:wn};class Fh{constructor(t,e,i,s){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=s,this.resolution_=i,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const i=this.buildersByZIndex_[e];for(const s in i){const r=i[s].finish();t[e][s]=r}}return t}getBuilder(t,e){const i=t!==void 0?t.toString():"0";let s=this.buildersByZIndex_[i];s===void 0&&(s={},this.buildersByZIndex_[i]=s);let r=s[e];if(r===void 0){const o=Lh[e];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),s[e]=r}return r}}class kh extends pr{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t}getFeatures(t){return X()}getData(t){return null}prepareFrame(t){return X()}renderFrame(t,e){return X()}loadedTileCallback(t,e,i){t[e]||(t[e]={}),t[e][i.tileCoord.toString()]=i}createLoadedTileFinder(t,e,i){return((s,r)=>{const o=this.loadedTileCallback.bind(this,i,s);return t.forEachLoadedTile(e,s,r,o)})}forEachFeatureAtCoordinate(t,e,i,s,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;(e.getState()===k.LOADED||e.getState()===k.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=k.LOADED&&e!=k.ERROR&&t.addEventListener(vt.CHANGE,this.boundHandleImageChange_),e==k.IDLE&&(t.load(),e=t.getState()),e==k.LOADED}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}class Oh extends pi{constructor(t,e,i,s){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=s}}class so{constructor(){ls(this,"pushMethodArgs_",(...t)=>(this.instructions_[this.zIndex+this.offset_].push(t),this));this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Pi(),{get:(t,e)=>{if(typeof Pi()[e]=="function")return this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(e),this.pushMethodArgs_},set:(t,e,i)=>(this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(e,i),!0)})}pushFunction(t){this.instructions_[this.zIndex+this.offset_].push(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let i=0,s=e.length;iA[2]}else P=S>R;const O=Math.PI,z=[],N=b+i===t;t=b,m=0,p=C,d=n[t],f=n[t+1];let G;if(N){y(),G=Math.atan2(f-_,d-g),P&&(G+=G>0?-O:O);const A=(R+S)/2,$=(Z+I)/2;return z[0]=[A,$,(v-r)/2,G,s],z}s=s.replace(/\n/g," ");for(let A=0,$=s.length;A<$;){y();let Y=Math.atan2(f-_,d-g);if(P&&(Y+=Y>0?-O:O),G!==void 0){let E=Y-G;if(E+=E>O?-2*O:E<-O?2*O:0,Math.abs(E)>o)return null}G=Y;const gt=A;let V=0;for(;A<$;++A){const E=P?$-A-1:A,Qi=a*l(u,s[E],h);if(t+i0&&n.push(` +`,""),n.push(t,""),n}class Bh{constructor(t,e,i,s,r){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=s.instructions,this.coordinates=s.coordinates,this.coordinateCache_={},this.renderedTransform_=Yt(),this.hitDetectionInstructions=s.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=s.fillStates||{},this.strokeStates=s.strokeStates||{},this.textStates=s.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new so:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,i,s){const r=t+e+i+s;if(this.labels_[r])return this.labels_[r];const o=s?this.strokeStates[s]:null,a=i?this.fillStates[i]:null,l=this.textStates[e],u=this.pixelRatio,h=[l.scale[0]*u,l.scale[1]*u],c=Array.isArray(t),d=l.justify?Zi[l.justify]:En(Array.isArray(t)?t[0]:t,l.textAlign||ci),f=s&&o.lineWidth?o.lineWidth:0,g=c?t:t.split(` +`).reduce(Wh,[]),{width:_,height:m,widths:p,heights:y,lineWidths:w}=sa(l,g),S=_+f,I=[],b=(S+2)*h[0],C=(m+f)*h[1],v={width:b<0?Math.floor(b):Math.ceil(b),height:C<0?Math.floor(C):Math.ceil(C),contextInstructions:I};(h[0]!=1||h[1]!=1)&&I.push("scale",h),s&&(I.push("strokeStyle",o.strokeStyle),I.push("lineWidth",f),I.push("lineCap",o.lineCap),I.push("lineJoin",o.lineJoin),I.push("miterLimit",o.miterLimit),I.push("setLineDash",[o.lineDash]),I.push("lineDashOffset",o.lineDashOffset)),i&&I.push("fillStyle",a.fillStyle),I.push("textBaseline","middle"),I.push("textAlign","center");const R=.5-d;let Z=d*S+R*f;const P=[],O=[];let z=0,N=0,G=0,A=0,$;for(let Y=0,gt=g.length;Yt?t-u:r,S=o+h>e?e-h:o,I=g[3]+w*d[0]+g[1],b=g[0]+S*d[1]+g[2],C=p-g[3],v=y-g[0];(_||c!==0)&&(Jt[0]=C,Kt[0]=C,Jt[1]=v,Pt[1]=v,Pt[0]=C+I,Nt[0]=Pt[0],Nt[1]=v+b,Kt[1]=Nt[1]);let R;return c!==0?(R=fe(Yt(),i,s,1,1,c,-i,-s),_t(R,Jt),_t(R,Pt),_t(R,Nt),_t(R,Kt),Ne(Math.min(Jt[0],Pt[0],Nt[0],Kt[0]),Math.min(Jt[1],Pt[1],Nt[1],Kt[1]),Math.max(Jt[0],Pt[0],Nt[0],Kt[0]),Math.max(Jt[1],Pt[1],Nt[1],Kt[1]),Ee)):Ne(Math.min(C,C+I),Math.min(v,v+b),Math.max(C,C+I),Math.max(v,v+b),Ee),f&&(p=Math.round(p),y=Math.round(y)),{drawImageX:p,drawImageY:y,drawImageW:w,drawImageH:S,originX:u,originY:h,declutterBox:{minX:Ee[0],minY:Ee[1],maxX:Ee[2],maxY:Ee[3],value:m},canvasTransform:R,scale:d}}replayImageOrLabel_(t,e,i,s,r,o,a){const l=!!(o||a),u=s.declutterBox,h=a?a[2]*s.scale[0]/2:0;return u.minX-h<=e[0]&&u.maxX+h>=0&&u.minY-h<=e[1]&&u.maxY+h>=0&&(l&&this.replayTextBackground_(t,Jt,Pt,Nt,Kt,o,a),ra(t,s.canvasTransform,r,i,s.originX,s.originY,s.drawImageW,s.drawImageH,s.drawImageX,s.drawImageY,s.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const i=_t(this.renderedTransform_,[0,0]),s=512*this.pixelRatio;t.save(),t.translate(i[0]%s,i[1]%s),e!==1&&t.scale(e,e),t.rotate(this.viewRotation_)}t.fill(),e&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6])}drawLabelWithPointPlacement_(t,e,i,s){const r=this.textStates[e],o=this.createLabel(t,e,s,i),a=this.strokeStates[i],l=this.pixelRatio,u=En(Array.isArray(t)?t[0]:t,r.textAlign||ci),h=Zi[r.textBaseline||Ni],c=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*r.scale[0],f=u*d+2*(.5-u)*c,g=h*o.height/l+2*(.5-h)*c;return{label:o,anchorX:f,anchorY:g}}execute_(t,e,i,s,r,o,a,l){const u=this.zIndexContext_;let h;this.pixelCoordinates_&&Be(i,this.renderedTransform_)?h=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),h=ne(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),da(this.renderedTransform_,i));let c=0;const d=s.length;let f=0,g,_,m,p,y,w,S,I,b,C,v,R,Z,P=0,O=0,z=null,N=null;const G=this.coordinateCache_,A=this.viewRotation_,$=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,Y={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:A},gt=this.instructions!=s||this.overlaps?0:200;let V,q,Q,jt;for(;cgt&&(this.fill_(t),P=0),O>gt&&(t.stroke(),O=0),!P&&!O&&(t.beginPath(),y=NaN,w=NaN),++c;break;case T.CIRCLE:f=E[1];const tn=h[f],en=h[f+1],co=h[f+2],fo=h[f+3],Hn=co-tn,Jn=fo-en,Kn=Math.sqrt(Hn*Hn+Jn*Jn);t.moveTo(tn+Kn,en),t.arc(tn,en,Kn,0,2*Math.PI,!0),++c;break;case T.ELLIPSE:f=E[1],g=E[2];const ze=h[f],Ye=h[f+1],Ii=h[f+2],Si=h[f+3],Ci=h[f+4],Ri=h[f+5],vi=h[f+6],Mi=h[f+7];if(g-f===8){const tt=(Ci-ze)*.2761424,yt=(Ri-Ye)*.2761424,et=(vi-Ii)*.2761424,lt=(Mi-Si)*.2761424;t.moveTo(ze,Ye),t.bezierCurveTo(ze-et,Ye-lt,Ii-tt,Si-yt,Ii,Si),t.bezierCurveTo(Ii+tt,Si+yt,Ci-et,Ri-lt,Ci,Ri),t.bezierCurveTo(Ci+et,Ri+lt,vi+tt,Mi+yt,vi,Mi),t.bezierCurveTo(vi-tt,Mi-yt,ze+et,Ye+lt,ze,Ye)}++c;break;case T.CLOSE_PATH:t.closePath(),++c;break;case T.CUSTOM:f=E[1],g=E[2];const go=E[3],_o=E[4],Qn=E[5];Y.geometry=go,Y.feature=V,c in G||(G[c]=[]);const Ve=G[c];Qn?Qn(h,f,g,2,Ve):(Ve[0]=h[f],Ve[1]=h[f+1],Ve.length=2),u&&(u.zIndex=E[6]),_o(Ve,Y),++c;break;case T.DRAW_IMAGE:f=E[1],g=E[2],b=E[3],_=E[4],m=E[5];let nn=E[6];const mo=E[7],po=E[8],yo=E[9],ts=E[10];let sn=E[11];const xo=E[12];let Ti=E[13];p=E[14]||"declutter";const Ze=E[15];if(!b&&E.length>=20){C=E[19],v=E[20],R=E[21],Z=E[22];const tt=this.drawLabelWithPointPlacement_(C,v,R,Z);b=tt.label,E[3]=b;const yt=E[23];_=(tt.anchorX-yt)*this.pixelRatio,E[4]=_;const et=E[24];m=(tt.anchorY-et)*this.pixelRatio,E[5]=m,nn=b.height,E[6]=nn,Ti=b.width,E[13]=Ti}let rn;E.length>25&&(rn=E[25]);let on,bi,Ai;E.length>17?(on=E[16],bi=E[17],Ai=E[18]):(on=he,bi=!1,Ai=!1),ts&&$?sn+=A:!ts&&!$&&(sn-=A);let wo=0;for(;f!ro.includes(n));class zh{constructor(t,e,i,s,r,o,a){this.maxExtent_=t,this.overlaps_=s,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Yt(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}clip(t,e){const i=this.getClipCoords(e);t.beginPath(),t.moveTo(i[0],i[1]),t.lineTo(i[2],i[3]),t.lineTo(i[4],i[5]),t.lineTo(i[6],i[7]),t.clip()}createExecutors_(t,e){for(const i in t){let s=this.executorsByZIndex_[i];s===void 0&&(s={},this.executorsByZIndex_[i]=s);const r=t[i];for(const o in r){const a=r[o];s[o]=new Bh(this.resolution_,this.pixelRatio_,this.overlaps_,a,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const i=this.executorsByZIndex_[e];for(let s=0,r=t.length;s0){if(!o||C==="none"||f!=="Image"&&f!=="Text"||o.includes(I)){const P=(d[R]-3)/4,O=s-P%a,z=s-(P/a|0),N=r(I,b,O*O+z*z);if(N)return N}h.clearRect(0,0,a,a);break}}const _=Object.keys(this.executorsByZIndex_).map(Number);_.sort(de);let m,p,y,w,S;for(m=_.length-1;m>=0;--m){const I=_[m].toString();for(y=this.executorsByZIndex_[I],p=be.length-1;p>=0;--p)if(f=be[p],w=y[f],w!==void 0&&(S=w.executeHitDetection(h,l,i,g,c),S))return S}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const i=e[0],s=e[1],r=e[2],o=e[3],a=[i,s,i,o,r,o,r,s];return ne(a,0,8,2,t,a),a}isEmpty(){return ke(this.executorsByZIndex_)}execute(t,e,i,s,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(de),o=o||be;const u=be.length;let h,c,d,f,g;for(a&&l.reverse(),h=0,c=l.length;hp.execute(I,e,i,s,r,a)),S&&w.restore(),y){y.offset();const I=l[h]*u+d;this.deferredZIndexContexts_[I]||(this.deferredZIndexContexts_[I]=[]),this.deferredZIndexContexts_[I].push(y)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(de);for(let i=0,s=e.length;i{r.draw(this.renderedContext_),r.clear()}),t[e[i]].length=0}}const In={};function Yh(n){if(In[n]!==void 0)return In[n];const t=n*2+1,e=n*n,i=new Array(e+1);for(let r=0;r<=n;++r)for(let o=0;o<=n;++o){const a=r*r+o*o;if(a>e)break;let l=i[a];l||(l=[],i[a]=l),l.push(((n+r)*t+(n+o))*4+3),r>0&&l.push(((n-r)*t+(n+o))*4+3),o>0&&(l.push(((n+r)*t+(n-o))*4+3),r>0&&l.push(((n-r)*t+(n-o))*4+3))}const s=[];for(let r=0,o=i.length;rc*this.pixelRatio_),lineDashOffset:(o||zt)*this.pixelRatio_,lineJoin:a!==void 0?a:De,lineWidth:(l!==void 0?l:di)*this.pixelRatio_,miterLimit:u!==void 0?u:hi,strokeStyle:At(i||ui)}}}setImageStyle(t){let e;if(!t||!(e=t.getSize())){this.image_=null;return}const i=t.getPixelRatio(this.pixelRatio_),s=t.getAnchor(),r=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=s[0]*i,this.imageAnchorY_=s[1]*i,this.imageHeight_=e[1]*i,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();const o=t.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/i,o[1]*this.pixelRatio_/i],this.imageWidth_=e[0]*i}setTextStyle(t){if(!t)this.text_="";else{const e=t.getFill();if(!e)this.textFillState_=null;else{const f=e.getColor();this.textFillState_={fillStyle:At(f||ut)}}const i=t.getStroke();if(!i)this.textStrokeState_=null;else{const f=i.getColor(),g=i.getLineCap(),_=i.getLineDash(),m=i.getLineDashOffset(),p=i.getLineJoin(),y=i.getWidth(),w=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:Oe,lineDash:_||Xt,lineDashOffset:m||zt,lineJoin:p!==void 0?p:De,lineWidth:y!==void 0?y:di,miterLimit:w!==void 0?w:hi,strokeStyle:At(f||ui)}}const s=t.getFont(),r=t.getOffsetX(),o=t.getOffsetY(),a=t.getRotateWithView(),l=t.getRotation(),u=t.getScaleArray(),h=t.getText(),c=t.getTextAlign(),d=t.getTextBaseline();this.textState_={font:s!==void 0?s:xr,textAlign:c!==void 0?c:ci,textBaseline:d!==void 0?d:Ni},this.text_=h!==void 0?Array.isArray(h)?h.reduce((f,g,_)=>f+=_%2?" ":g,""):h:"",this.textOffsetX_=r!==void 0?this.pixelRatio_*r:0,this.textOffsetY_=o!==void 0?this.pixelRatio_*o:0,this.textRotateWithView_=a!==void 0?a:!1,this.textRotation_=l!==void 0?l:0,this.textScale_=[this.pixelRatio_*u[0],this.pixelRatio_*u[1]]}}}const bt=.5;function Zh(n,t,e,i,s,r,o,a,l){const u=s,h=n[0]*bt,c=n[1]*bt,d=pt(h,c);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new Vh(d,bt,s,null,o,a,null),_=e.length,m=Math.floor((256*256*256-1)/_),p={};for(let w=1;w<=_;++w){const S=e[w-1],I=S.getStyleFunction()||i;if(!I)continue;let b=I(S,r);if(!b)continue;Array.isArray(b)||(b=[b]);const v=(w*m).toString(16).padStart(7,"#00000");for(let R=0,Z=b.length;R0;return c&&Promise.all(l).then(()=>s(null)),Hh(n,t,e,i,r,o,a),c}function Hh(n,t,e,i,s,r,o){const a=e.getGeometryFunction()(t);if(!a)return;const l=a.simplifyTransformed(i,s);if(e.getRenderer())lo(n,l,e,t,o);else{const h=oo[l.getType()];h(n,l,e,t,o,r)}}function lo(n,t,e,i,s){if(t.getType()=="GeometryCollection"){const o=t.getGeometries();for(let a=0,l=o.length;a{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const i=this.frameState.size.slice(),s=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,u=this.getLayer(),h=[],c=i[0]*bt,d=i[1]*bt;h.push(this.getRenderTransform(s,r,o,bt,c,d,0).slice());const f=u.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!ve(g,l)){let _=l[0];const m=dt(g);let p=0,y;for(;_g[2];)++p,y=m*p,h.push(this.getRenderTransform(s,r,o,bt,c,d,y).slice()),_-=m}this.hitDetectionImageData_=Zh(i,h,this.renderedFeatures_,u.getStyleFunction(),l,r,o,tr(r,this.renderedPixelRatio_))}e(Uh(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,i,s,r){if(!this.replayGroup_)return;const o=e.viewState.resolution,a=e.viewState.rotation,l=this.getLayer(),u={},h=function(g,_,m){const p=it(g),y=u[p];if(y){if(y!==!0&&mc=g.forEachFeatureAtCoordinate(t,o,a,i,h,f&&e.declutter[f]?e.declutter[f].all().map(_=>_.value):null)),c}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),i=e.getSource();if(!i)return!1;const s=t.viewHints[Et.ANIMATING],r=t.viewHints[Et.INTERACTING],o=e.getUpdateWhileAnimating(),a=e.getUpdateWhileInteracting();if(this.ready&&!o&&s||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=t.extent,u=t.viewState,h=u.projection,c=u.resolution,d=t.pixelRatio,f=e.getRevision(),g=e.getRenderBuffer();let _=e.getRenderOrder();_===void 0&&(_=qh);const m=u.center.slice(),p=Wn(l,g*c),y=p.slice(),w=[p.slice()],S=h.getExtent();if(i.getWrapX()&&h.canWrapX()&&!ve(S,t.extent)){const N=dt(S),G=Math.max(dt(p)/2,N);p[0]=S[0]-G,p[2]=S[2]+G,Pa(m,h);const A=kr(w[0],h);A[0]S[0]&&A[2]>S[2]&&w.push([A[0]-N,A[1],A[2]-N,A[3]])}if(this.ready&&this.renderedResolution_==c&&this.renderedRevision_==f&&this.renderedRenderOrder_==_&&this.renderedFrameDeclutter_===!!t.declutter&&ve(this.wrappedRenderedExtent_,p))return Be(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=m,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const I=new Fh(ao(c,d),p,c,d);let b;for(let N=0,G=w.length;N{let A;const $=N.getStyleFunction()||e.getStyleFunction();if($&&(A=$(N,c)),A){const Y=this.renderFeature(N,C,A,I,b,this.getLayer().getDeclutter(),G);v=v&&!Y}},Z=Nr(p),P=i.getFeaturesInExtent(Z);_&&P.sort(_);for(let N=0,G=P.length;N0;)this.pop()}extend(t){for(let e=0,i=t.length;ethis.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new Di(Ae.ADD,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){this.unique_&&this.assertUnique_(t);const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let i=0,s=e.length;i=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new Di(Ae.REMOVE,e,t)),e}setAt(t,e){const i=this.getLength();if(t>=i){this.insertAt(t,e);return}if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const s=this.array_[t];this.array_[t]=e,this.dispatchEvent(new Di(Ae.REMOVE,s,t)),this.dispatchEvent(new Di(Ae.ADD,e,t))}updateLength_(){this.set(nr.LENGTH,this.array_.length)}assertUnique_(t,e){for(let i=0,s=this.array_.length;i1?o:2,r=r||new Array(o);for(let h=0;h{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const i=this.simplifiedGeometry_.getFlatCoordinates();let s;switch(this.type_){case"LineString":i.length=Zn(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),s=[i.length];break;case"MultiLineString":s=[],i.length=fl(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,s);break;case"Polygon":s=[],i.length=Yr(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,s);break}return s&&(this.simplifiedGeometry_=new It(this.type_,i,s,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}It.prototype.getFlatCoordinates=It.prototype.getOrientedFlatCoordinates;class lu extends me{constructor(t){super(),this.projection=_e(t.projection),this.attributions_=ar(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible!==void 0?t.attributionsCollapsible:!0,this.loading=!1,this.state_=t.state!==void 0?t.state:"ready",this.wrapX_=t.wrapX!==void 0?t.wrapX:!1,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;const e=this;this.viewPromise_=new Promise(function(i,s){e.viewResolver=i,e.viewRejector=s})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(t){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=ar(t),this.changed()}setState(t){this.state_=t,this.changed()}}function ar(n){return n?Array.isArray(n)?function(t){return n}:typeof n=="function"?n:function(t){return[n]}:null}const wt={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function hu(n,t){return[[-1/0,-1/0,1/0,1/0]]}let uu=!1;function cu(n,t,e,i,s,r,o){const a=new XMLHttpRequest;a.open("GET",typeof n=="function"?n(e,i,s):n,!0),t.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=uu,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){const u=t.getType();try{let h;u=="text"||u=="json"?h=a.responseText:u=="xml"?h=a.responseXML||a.responseText:u=="arraybuffer"&&(h=a.response),h?r(t.readFeatures(h,{extent:e,featureProjection:s}),t.readProjection(h)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function lr(n,t){return function(e,i,s,r,o){const a=this;cu(n,t,e,i,s,function(l,u){a.addFeatures(l),r!==void 0&&r(l)},o||li)}}class Qt extends pi{constructor(t,e,i){super(t),this.feature=e,this.features=i}}class du extends lu{constructor(t){t=t||{},super({attributions:t.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:t.wrapX!==void 0?t.wrapX:!0}),this.on,this.once,this.un,this.loader_=li,this.format_=t.format,this.overlaps_=t.overlaps===void 0?!0:t.overlaps,this.url_=t.url,t.loader!==void 0?this.loader_=t.loader:this.url_!==void 0&&(nt(this.format_,"`format` must be set when `url` is set"),this.loader_=lr(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:hu;const e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new sr:null,this.loadedExtentsRtree_=new sr,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,s;Array.isArray(t.features)?s=t.features:t.features&&(i=t.features,s=i.getArray()),!e&&i===void 0&&(i=new ou(s)),s!==void 0&&this.addFeaturesInternal(s),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=it(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);const i=t.getGeometry();if(i){const s=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(s,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new Qt(wt.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof It||(this.featureChangeKeys_[t]=[Bt(e,vt.CHANGE,this.handleFeatureChange_,this),Bt(e,mr.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,e){let i=!0;if(e.getId()!==void 0){const s=String(e.getId());if(!(s in this.idIndex_))this.idIndex_[s]=e;else if(e instanceof It){const r=this.idIndex_[s];r instanceof It?Array.isArray(r)?r.push(e):this.idIndex_[s]=[r,e]:i=!1}else i=!1}return i&&(nt(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],i=[],s=[];for(let r=0,o=t.length;r{e||(e=!0,this.addFeature(i.element),e=!1)}),t.addEventListener(Ae.REMOVE,i=>{e||(e=!0,this.removeFeature(i.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(const i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach(ie);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){const i=s=>{this.removeFeatureInternal(s)};this.featuresRtree_.forEach(i);for(const s in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[s])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new Qt(wt.CLEAR);this.dispatchEvent(e),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,e){const i=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(i,function(s){const r=s.getGeometry();if(r instanceof It||r.intersectsCoordinate(t))return e(s)})}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,function(i){const s=i.getGeometry();if(s instanceof It||s.intersectsExtent(t)){const r=e(i);if(r)return r}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),ke(this.nullGeometryFeatures_)||Dn(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,function(i){e.push(i)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const s=Ca(t,e);return[].concat(...s.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const i=t[0],s=t[1];let r=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return e=e||qo,this.featuresRtree_.forEachInExtent(l,function(u){if(e(u)){const h=u.getGeometry(),c=a;if(a=h instanceof It?0:h.closestPointXY(i,s,o,a),a{--this.loadingExtentsCount_,this.dispatchEvent(new Qt(wt.FEATURESLOADEND,void 0,h))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Qt(wt.FEATURESLOADERROR))}),s.insert(l,{extent:l.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){const e=this.loadedExtentsRtree_;let i;e.forEachInExtent(t,function(s){if(vr(s.extent,t))return i=s,!0}),i&&e.remove(i)}removeFeatures(t){const e=[];for(let i=0,s=t.length;i0&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=it(t);if(!(e in this.uidIndex_))return;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t);const i=this.featureChangeKeys_[e];i==null||i.forEach(ie),delete this.featureChangeKeys_[e];const s=t.getId();if(s!==void 0){const r=s.toString(),o=this.idIndex_[r];o===t?delete this.idIndex_[r]:Array.isArray(o)&&(o.splice(o.indexOf(t),1),o.length===1&&(this.idIndex_[r]=o[0]))}return delete this.uidIndex_[e],this.hasListener(wt.REMOVEFEATURE)&&this.dispatchEvent(new Qt(wt.REMOVEFEATURE,t)),t}removeFromIdIndex_(t){let e=!1;for(const i in this.idIndex_){const s=this.idIndex_[i];if(t instanceof It&&Array.isArray(s)&&s.includes(t))s.splice(s.indexOf(t),1);else if(this.idIndex_[i]===t){delete this.idIndex_[i],e=!0;break}}return e}setLoader(t){this.loader_=t}setUrl(t){nt(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(lr(t,this.format_))}}const ho=(n,t)=>{const e=n.__vccOpts||n;for(const[i,s]of t)e[i]=s;return e},fu={props:{settings:{type:Object,required:!0}},data(){return{opacityValue:"1",currentImageId:null,currentImage:null,cache:{}}},computed:{opacity(){return parseFloat(this.opacityValue)},shown(){return this.opacity>0}},methods:{maybeFetchLaserpoints(n){return this.shown&&!this.cache.hasOwnProperty(n)&&(this.cache[n]=Qe.get({image_id:n}).then(t=>t.data)),this.cache[n]},updateCurrentImage(n){const{id:t,image:e}=n;this.layer.getSource().clear(),this.currentImageId=t,this.currentImage=e},maybeDrawLaserpoints(n){if(n&&n.method!=="manual"&&n.points&&n.points.length>0){var t=this.currentImage.height;this.layer.getSource().addFeatures(n.points.map(function(e){return new Gn({geometry:new qi([e[0],t-e[1]])})}))}},extendMap(n){this.$nextTick(()=>n.addLayer(this.layer))}},watch:{opacity(n,t){n<1?this.settings.set("laserpointOpacity",n):this.settings.delete("laserpointOpacity"),t===0&&this.maybeFetchLaserpoints(this.currentImageId).then(this.maybeDrawLaserpoints),n===0&&this.layer.getSource().clear(),this.layer.setOpacity(n)},currentImageId(n){this.shown&&this.maybeFetchLaserpoints(n).then(this.maybeDrawLaserpoints)}},created(){this.layer=new ru({source:new du,style:[new Vt({image:new Pe({radius:6,stroke:new We({color:"white",width:4})})}),new Vt({image:new Pe({radius:6,stroke:new We({color:"#ff0000",width:2,lineDash:[1]})})})],zIndex:3,updateWhileAnimating:!0,updateWhileInteracting:!0}),this.settings.has("laserpointOpacity")&&(this.opacityValue=this.settings.get("laserpointOpacity")),gn.on("images.fetching",this.maybeFetchLaserpoints),gn.on("images.change",this.updateCurrentImage),gn.on("annotations.map.init",this.extendMap)}},gu={class:"sidebar-tab__section"},_u=["textContent"],mu={key:1};function pu(n,t,e,i,s,r){return ae(),le("div",gu,[H("h5",null,[t[1]||(t[1]=ct("Laser Points Opacity (",-1)),r.shown?(ae(),le("span",{key:0,textContent:hr(r.opacity)},null,8,_u)):(ae(),le("span",mu,"hidden")),t[2]||(t[2]=ct(")",-1))]),t[3]||(t[3]=ct()),Ie(H("input",{type:"range",min:"0",max:"1",step:"0.1","onUpdate:modelValue":t[0]||(t[0]=o=>s.opacityValue=o)},null,512),[[Sn,s.opacityValue]])])}const yu=ho(fu,[["render",pu]]);Es&&(Es.laserPoints=yu);const xu=Er("api/v1/volumes{/id}/images/filter/laserpoints");Array.isArray(Ss)&&Ss.push({id:"laserpoints",types:["image"],label:"detected laser points",help:"All images that (don't) contain detected laser points.",listComponent:{mixins:[la],data(){return{name:"detected laser points"}}},getSequence(n){return xu.query({id:n})}});const wu={mixins:[ua],components:{typeahead:ha},props:{volumeId:{type:Number,required:!0},imageId:{type:Number,default:null}},data(){return{distance:null,numLaserpoints:2,channelMode:"",processing:!1,error:!1,labels:[],label:null,manualMode:!1}},computed:{submitDisabled(){return this.manualMode?this.loading||this.processing||!this.distance||!this.label:this.imageId&&!this.manualMode?this.loading||this.processing||!this.distance||!this.channelMode:this.loading||this.processing||!this.distance},automaticButtonClass(){return this.manualMode?"":"active"},manualButtonClass(){return this.manualMode?"active":""}},methods:{selectAutomatic(){this.manualMode=!1},selectManual(){this.manualMode=!0},handleError(n){n.status===422&&n.body.errors&&n.body.errors.id?(this.error=n.body.errors.id.join(` +`),this.processing=!1):ws(n)},setProcessing(){this.processing=!0,this.error=!1},setLabels(n){this.labels=n.body},handleSelectLabel(n){this.label=n},loadLabels(){!this.loading&&this.labels.length===0&&(this.startLoading(),ca.queryAnnotationLabels({id:this.volumeId}).then(this.setLabels).then(this.finishLoading).catch(ws))},submit(){this.startLoading();let n;if(this.manualMode){const t={distance:this.distance,label_id:this.label.id};this.imageId?n=Qe.processImageManual({image_id:this.imageId},t):n=Qe.processVolumeManual({volume_id:this.volumeId},t)}else{const t={distance:this.distance,num_laserpoints:this.numLaserpoints};this.channelMode&&(t.channel_mode=this.channelMode),this.imageId?n=Qe.processImageAutomatic({image_id:this.imageId},t):n=Qe.processVolumeAutomatic({volume_id:this.volumeId},t)}n.then(this.setProcessing).catch(this.handleError).finally(this.finishLoading)}},mounted(){this.imageId&&window.biigle&&window.biigle.laserpoints&&window.biigle.laserpoints.channel_mode?this.channelMode=window.biigle.laserpoints.channel_mode:this.imageId&&(this.channelMode="gray")}},Eu={class:"btn-group btn-group-justified"},Iu={class:"btn-group"},Su={class:"btn-group"},Cu={class:"form-group"},Ru={class:"form-group"},vu={key:0,class:"form-group"},Mu={class:"form-group"},Tu={class:"form-group"},bu=["disabled"],Au={key:1,class:"alert alert-success"},Lu=["textContent"];function Fu(n,t,e,i,s,r){const o=vo("typeahead");return ae(),le("form",{class:"form-stacked",onSubmit:t[5]||(t[5]=Mo((...a)=>r.submit&&r.submit(...a),["prevent"]))},[H("div",Eu,[H("div",Iu,[H("button",{type:"button",class:hs(["btn btn-default",r.automaticButtonClass]),onClick:t[0]||(t[0]=(...a)=>r.selectAutomatic&&r.selectAutomatic(...a))},"Automatic",2)]),t[6]||(t[6]=ct()),H("div",Su,[H("button",{type:"button",class:hs(["btn btn-default",r.manualButtonClass]),onClick:t[1]||(t[1]=(...a)=>r.selectManual&&r.selectManual(...a))},"Manual",2)])]),t[16]||(t[16]=ct()),H("div",Cu,[t[7]||(t[7]=H("label",{for:"distance"},"Laser distance in cm",-1)),t[8]||(t[8]=ct()),Ie(H("input",{"onUpdate:modelValue":t[2]||(t[2]=a=>s.distance=a),id:"distance",type:"number",min:"1",step:"0.1",title:"Distance between two laser points in cm",class:"form-control",required:""},null,512),[[Sn,s.distance]])]),t[17]||(t[17]=ct()),Ie(H("div",Ru,[t[9]||(t[9]=H("label",{for:"num_laserpoints"},"Number of laser points",-1)),t[10]||(t[10]=ct()),Ie(H("input",{"onUpdate:modelValue":t[3]||(t[3]=a=>s.numLaserpoints=a),id:"num_laserpoints",type:"number",min:"1",step:"1",title:"Number of laser points to detect",class:"form-control",required:""},null,512),[[Sn,s.numLaserpoints,void 0,{number:!0}]])],512),[[us,!s.manualMode]]),t[18]||(t[18]=ct()),e.imageId&&!s.manualMode?(ae(),le("div",vu,[t[12]||(t[12]=H("label",{for:"channel_mode"},"Color channel",-1)),t[13]||(t[13]=ct()),Ie(H("select",{"onUpdate:modelValue":t[4]||(t[4]=a=>s.channelMode=a),id:"channel_mode",title:"Color channel to use for laser point detection.",class:"form-control",required:""},[...t[11]||(t[11]=[To(' ',9)])],512),[[bo,s.channelMode]])])):cs("",!0),t[19]||(t[19]=ct()),Ie(H("div",Mu,[t[14]||(t[14]=H("label",{for:"label"},"Laser point label",-1)),t[15]||(t[15]=ct()),Ao(o,{id:"label",title:"Laser point",placeholder:"Laser point label",class:"typeahead--block",items:s.labels,onSelect:r.handleSelectLabel,onFocus:r.loadLabels},null,8,["items","onSelect","onFocus"])],512),[[us,s.manualMode]]),t[20]||(t[20]=ct()),H("div",Tu,[H("button",{class:"btn btn-success btn-block",title:"Compute the area of each image in this volume.",disabled:r.submitDisabled||null},"Submit",8,bu)]),t[21]||(t[21]=ct()),s.processing?(ae(),le("div",Au,` + The laser point detection was submitted and will be available soon. + `)):s.error?(ae(),le("div",{key:2,class:"alert alert-danger",textContent:hr(s.error)},null,8,Lu)):cs("",!0)],32)}const uo=ho(wu,[["render",Fu],["__scopeId","data-v-84d8417e"]]);Is&&(Is.laserpointsForm=uo);const ku={components:{laserpointsForm:uo}};biigle.$mount("laserpoints-panel",ku); diff --git a/src/public/assets/main-BgU9hl6O.js b/src/public/assets/main-BgU9hl6O.js deleted file mode 100644 index e1d92b1a..00000000 --- a/src/public/assets/main-BgU9hl6O.js +++ /dev/null @@ -1,13 +0,0 @@ -var So=Object.defineProperty;var Co=(n,t,e)=>t in n?So(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var as=(n,t,e)=>Co(n,typeof t!="symbol"?t+"":t,e);import{createElementBlock as be,openBlock as Me,createElementVNode as Pt,createTextVNode as Qt,withDirectives as sr,toDisplayString as rr,vModelText as or,resolveComponent as Ro,withModifiers as vo,createCommentVNode as To,createVNode as bo}from"vue";const k={IDLE:0,LOADING:1,LOADED:2,ERROR:3};function B(){throw new Error("Unimplemented abstract method.")}let Mo=0;function et(n){return n.ol_uid||(n.ol_uid=String(++Mo))}function ni(n,t){return Array.isArray(n)?n:(t===void 0?t=[n,n]:(t[0]=n,t[1]=n),t)}class Zi{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=ni(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Zi({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return B()}getImage(t){return B()}getHitDetectionImage(){return B()}getPixelRatio(t){return 1}getImageState(){return B()}getImageSize(){return B()}getOrigin(){return B()}getSize(){return B()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=ni(t)}listenImageChange(t){B()}load(){B()}unlistenImageChange(t){B()}ready(){return Promise.resolve()}}const si={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]},st={name:"xyz",min:[0,0,0],channel:["X","Y","Z"],alias:["XYZ","ciexyz","cie1931"],whitepoint:{2:{A:[109.85,100,35.585],C:[98.074,100,118.232],D50:[96.422,100,82.521],D55:[95.682,100,92.149],D65:[95.045592705167,100,108.9057750759878],D75:[94.972,100,122.638],F2:[99.187,100,67.395],F7:[95.044,100,108.755],F11:[100.966,100,64.37],E:[100,100,100]},10:{A:[111.144,100,35.2],C:[97.285,100,116.145],D50:[96.72,100,81.427],D55:[95.799,100,90.926],D65:[94.811,100,107.304],D75:[94.416,100,120.641],F2:[103.28,100,69.026],F7:[95.792,100,107.687],F11:[103.866,100,65.627],E:[100,100,100]}}};st.max=st.whitepoint[2].D65;st.rgb=function(n,t){t=t||st.whitepoint[2].E;var e=n[0]/t[0],i=n[1]/t[1],s=n[2]/t[2],r,o,a;return r=e*3.240969941904521+i*-1.537383177570093+s*-.498610760293,o=e*-.96924363628087+i*1.87596750150772+s*.041555057407175,a=e*.055630079696993+i*-.20397695888897+s*1.056971514242878,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:r=r*12.92,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=o*12.92,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=a*12.92,r=Math.min(Math.max(0,r),1),o=Math.min(Math.max(0,o),1),a=Math.min(Math.max(0,a),1),[r*255,o*255,a*255]};si.xyz=function(n,t){var e=n[0]/255,i=n[1]/255,s=n[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,s=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92;var r=e*.41239079926595+i*.35758433938387+s*.18048078840183,o=e*.21263900587151+i*.71516867876775+s*.072192315360733,a=e*.019330818715591+i*.11919477979462+s*.95053215224966;return t=t||st.whitepoint[2].E,[r*t[0],o*t[1],a*t[2]]};var An={name:"luv",min:[0,-134,-140],max:[100,224,122],channel:["lightness","u","v"],alias:["LUV","cieluv","cie1976"],xyz:function(n,t,e){var i,s,r,o,a,l,c,h,u,f,d,g,_;if(r=n[0],o=n[1],a=n[2],r===0)return[0,0,0];var m=.0011070564598794539;return t=t||"D65",e=e||2,u=st.whitepoint[e][t][0],f=st.whitepoint[e][t][1],d=st.whitepoint[e][t][2],g=4*u/(u+15*f+3*d),_=9*f/(u+15*f+3*d),i=o/(13*r)+g||0,s=a/(13*r)+_||0,c=r>8?f*Math.pow((r+16)/116,3):f*r*m,l=c*9*i/(4*s)||0,h=c*(12-3*i-20*s)/(4*s)||0,[l,c,h]}};st.luv=function(n,t,e){var i,s,r,o,a,l,c,h,u,f,d,g,_,m=.008856451679035631,p=903.2962962962961;t=t||"D65",e=e||2,u=st.whitepoint[e][t][0],f=st.whitepoint[e][t][1],d=st.whitepoint[e][t][2],g=4*u/(u+15*f+3*d),_=9*f/(u+15*f+3*d),l=n[0],c=n[1],h=n[2],i=4*l/(l+15*c+3*h)||0,s=9*c/(l+15*c+3*h)||0;var y=c/f;return r=y<=m?p*y:116*Math.pow(y,1/3)-16,o=13*r*(i-g),a=13*r*(s-_),[r,o,a]};var ar={name:"lchuv",channel:["lightness","chroma","hue"],alias:["LCHuv","cielchuv"],min:[0,0,0],max:[100,100,360],luv:function(n){var t=n[0],e=n[1],i=n[2],s,r,o;return o=i/360*2*Math.PI,s=e*Math.cos(o),r=e*Math.sin(o),[t,s,r]},xyz:function(n){return An.xyz(ar.luv(n))}};An.lchuv=function(n){var t=n[0],e=n[1],i=n[2],s=Math.sqrt(e*e+i*i),r=Math.atan2(i,e),o=r*360/2/Math.PI;return o<0&&(o+=360),[t,s,o]};st.lchuv=function(n){return An.lchuv(st.luv(n))};const ls={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};var hs={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function Ao(n){var h,u;var t,e=[],i=1,s;if(typeof n=="number")return{space:"rgb",values:[n>>>16,(n&65280)>>>8,n&255],alpha:1};if(typeof n=="number")return{space:"rgb",values:[n>>>16,(n&65280)>>>8,n&255],alpha:1};if(n=String(n).toLowerCase(),ls[n])e=ls[n].slice(),s="rgb";else if(n==="transparent")i=0,s="rgb",e=[0,0,0];else if(n[0]==="#"){var r=n.slice(1),o=r.length,a=o<=4;i=1,a?(e=[parseInt(r[0]+r[0],16),parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16)],o===4&&(i=parseInt(r[3]+r[3],16)/255)):(e=[parseInt(r[0]+r[1],16),parseInt(r[2]+r[3],16),parseInt(r[4]+r[5],16)],o===8&&(i=parseInt(r[6]+r[7],16)/255)),e[0]||(e[0]=0),e[1]||(e[1]=0),e[2]||(e[2]=0),s="rgb"}else if(t=/^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\s*\(([^\)]*)\)/.exec(n)){var l=t[1];s=l.replace(/a$/,"");var c=s==="cmyk"?4:s==="gray"?1:3;e=t[2].trim().split(/\s*[,\/]\s*|\s+/),s==="color"&&(s=e.shift()),e=e.map(function(f,d){if(f[f.length-1]==="%")return f=parseFloat(f)/100,d===3?f:s==="rgb"?f*255:s[0]==="h"||s[0]==="l"&&!d?f*100:s==="lab"?f*125:s==="lch"?d<2?f*150:f*360:s[0]==="o"&&!d?f:s==="oklab"?f*.4:s==="oklch"?d<2?f*.4:f*360:f;if(s[d]==="h"||d===2&&s[s.length-1]==="h"){if(hs[f]!==void 0)return hs[f];if(f.endsWith("deg"))return parseFloat(f);if(f.endsWith("turn"))return parseFloat(f)*360;if(f.endsWith("grad"))return parseFloat(f)*360/400;if(f.endsWith("rad"))return parseFloat(f)*180/Math.PI}return f==="none"?0:parseFloat(f)}),i=e.length>c?e.pop():1}else/[0-9](?:\s|\/|,)/.test(n)&&(e=n.match(/([0-9]+)/g).map(function(f){return parseFloat(f)}),s=((u=(h=n.match(/([a-z])/ig))==null?void 0:h.join(""))==null?void 0:u.toLowerCase())||"rgb");return{space:s,values:e,alpha:i}}var hn={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(n){var t=n[0]/360,e=n[1]/100,i=n[2]/100,s,r,o,a,l,c=0;if(e===0)return l=i*255,[l,l,l];for(r=i<.5?i*(1+e):i+e-i*e,s=2*i-r,a=[0,0,0];c<3;)o=t+1/3*-(c-1),o<0?o++:o>1&&o--,l=6*o<1?s+(r-s)*6*o:2*o<1?r:3*o<2?s+(r-s)*(2/3-o)*6:s,a[c++]=l*255;return a}};si.hsl=function(n){var t=n[0]/255,e=n[1]/255,i=n[2]/255,s=Math.min(t,e,i),r=Math.max(t,e,i),o=r-s,a,l,c;return r===s?a=0:t===r?a=(e-i)/o:e===r?a=2+(i-t)/o:i===r&&(a=4+(t-e)/o),a=Math.min(a*60,360),a<0&&(a+=360),c=(s+r)/2,r===s?l=0:c<=.5?l=o/(r+s):l=o/(2-r-s),[a,l*100,c*100]};function Lo(n){Array.isArray(n)&&n.raw&&(n=String.raw(...arguments)),n instanceof Number&&(n=+n);var t,e=Ao(n);if(!e.space)return[];const i=e.space[0]==="h"?hn.min:si.min,s=e.space[0]==="h"?hn.max:si.max;return t=Array(3),t[0]=Math.min(Math.max(e.values[0],i[0]),s[0]),t[1]=Math.min(Math.max(e.values[1],i[1]),s[1]),t[2]=Math.min(Math.max(e.values[2],i[2]),s[2]),e.space[0]==="h"&&(t=hn.rgb(t)),t.push(Math.min(Math.max(e.alpha,0),1)),t}function rt(n,t,e){return Math.min(Math.max(n,t),e)}function Fo(n,t,e,i,s,r){const o=s-e,a=r-i;if(o!==0||a!==0){const l=((n-e)*o+(t-i)*a)/(o*o+a*a);l>1?(e=s,i=r):l>0&&(e+=o*l,i+=a*l)}return Ae(n,t,e,i)}function Ae(n,t,e,i){const s=e-n,r=i-t;return s*s+r*r}function ko(n){return n*Math.PI/180}function cs(n,t){const e=n%t;return e*t<0?e+t:e}function wt(n,t,e){return n+e*(t-n)}function Oo(n,t){const e=Math.pow(10,t);return Math.round(n*e)/e}function Do(n){return typeof n=="string"?n:Fn(n)}const Po=1024,qe={};let cn=0;function No(n){if(n.length===4)return n;const t=n.slice();return t[3]=1,t}function us(n){const t=st.lchuv(si.xyz(n));return t[3]=n[3],t}function Go(n){const t=st.rgb(ar.xyz(n));return t[3]=n[3],t}function Ln(n){if(qe.hasOwnProperty(n))return qe[n];if(cn>=Po){let e=0;for(const i in qe)(e++&3)===0&&(delete qe[i],--cn)}const t=Lo(n);if(t.length!==4)throw new Error('Failed to parse "'+n+'" as color');for(const e of t)if(isNaN(e))throw new Error('Failed to parse "'+n+'" as color');return lr(t),qe[n]=t,++cn,t}function ri(n){return Array.isArray(n)?n:Ln(n)}function lr(n){return n[0]=rt(n[0]+.5|0,0,255),n[1]=rt(n[1]+.5|0,0,255),n[2]=rt(n[2]+.5|0,0,255),n[3]=rt(n[3],0,1),n}function Fn(n){let t=n[0];t!=(t|0)&&(t=t+.5|0);let e=n[1];e!=(e|0)&&(e=e+.5|0);let i=n[2];i!=(i|0)&&(i=i+.5|0);const s=n[3]===void 0?1:Math.round(n[3]*1e3)/1e3;return"rgba("+t+","+e+","+i+","+s+")"}function Wo(n){try{return Ln(n),!0}catch{return!1}}const se=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"";se.includes("firefox");const Xo=se.includes("safari")&&!se.includes("chrom");Xo&&(se.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(se));se.includes("webkit")&&se.includes("edge");se.includes("macintosh");const hr=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Bo=typeof Image<"u"&&Image.prototype.decode;(function(){let n=!1;try{const t=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("_",null,t),window.removeEventListener("_",null,t)}catch{}return n})();function _t(n,t,e,i){let s;return e&&e.length?s=e.shift():hr?s=new OffscreenCanvas(n||300,t||300):s=document.createElement("canvas"),n&&(s.width=n),t&&(s.height=t),s.getContext("2d",i)}let un;function Oi(){return un||(un=_t(1,1)),un}function zo(n){const t=n.canvas;t.width=1,t.height=1,n.clearRect(0,0,1,1)}class Yo{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}class _i{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}function Vo(n,t,e){let i,s;e=e||ce;let r=0,o=n.length,a=!1;for(;r>1),s=+e(n[i],t),s<0?r=i+1:(o=i,a=!s);return a?r:~r}function ce(n,t){return n>t?1:n0?s-1:s}return i-1}if(e>0){for(let s=1;s0:!1}removeEventListener(t,e){if(!this.listeners_)return;const i=this.listeners_[t];if(!i)return;const s=i.indexOf(e);s!==-1&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[s]=oi,++this.pendingRemovals_[t]):(i.splice(s,1),i.length===0&&delete this.listeners_[t]))}}const Ct={CHANGE:"change"};function Wt(n,t,e,i,s){if(i&&i!==n&&(e=e.bind(i)),s){const o=e;e=function(){n.removeEventListener(t,e),o.apply(this,arguments)}}const r={target:n,type:t,listener:e};return n.addEventListener(t,e),r}function fs(n,t,e,i){return Wt(n,t,e,i,!0)}function ie(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),On(n))}function jo(n,t){return new Promise((e,i)=>{function s(){o(),e(n)}function r(){o(),i(new Error("Image load error"))}function o(){n.removeEventListener("load",s),n.removeEventListener("error",r)}n.addEventListener("load",s),n.addEventListener("error",r)})}function qo(n,t){return t&&(n.src=t),n.src&&Bo?new Promise((e,i)=>n.decode().then(()=>e(n)).catch(s=>n.complete&&n.width?e(n):i(s))):jo(n)}class $o{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=32}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(const e in this.cache_){const i=this.cache_[e];(t++&3)===0&&!i.hasListener()&&(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e,i){const s=fn(t,e,i);return s in this.cache_?this.cache_[s]:null}getPattern(t,e,i){const s=fn(t,e,i);return s in this.patternCache_?this.patternCache_[s]:null}set(t,e,i,s,r){const o=fn(t,e,i),a=o in this.cache_;this.cache_[o]=s,r&&(s.getImageState()===k.IDLE&&s.load(),s.getImageState()===k.LOADING?s.ready().then(()=>{this.patternCache_[o]=Oi().createPattern(s.getImage(1),"repeat")}):this.patternCache_[o]=Oi().createPattern(s.getImage(1),"repeat")),a||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function fn(n,t,e){const i=e?ri(e):"null";return t+":"+n+":"+i}const te=new $o;let $e=null;class Ho extends fr{constructor(t,e,i,s,r){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i,this.canvas_={},this.color_=r,this.imageState_=s===void 0?k.IDLE:s,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===k.LOADED){$e||($e=_t(1,1,void 0,{willReadFrequently:!0})),$e.drawImage(this.image_,0,0);try{$e.getImageData(0,0,1,1),this.tainted_=!1}catch{$e=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(Ct.CHANGE)}handleImageError_(){this.imageState_=k.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=k.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const t=this.size_[0],e=this.size_[1],i=_t(t,e);i.fillRect(0,0,t,e),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===k.IDLE){this.image_||this.initializeImage_(),this.imageState_=k.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&qo(this.image_,this.src_).then(t=>{this.image_=t,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(t){if(!this.color_||this.canvas_[t]||this.imageState_!==k.LOADED)return;const e=this.image_,i=document.createElement("canvas");i.width=Math.ceil(e.width*t),i.height=Math.ceil(e.height*t);const s=i.getContext("2d");s.scale(t,t),s.drawImage(e,0,0),s.globalCompositeOperation="multiply",s.fillStyle=Do(this.color_),s.fillRect(0,0,i.width/t,i.height/t),s.globalCompositeOperation="destination-in",s.drawImage(e,0,0),this.canvas_[t]=i}ready(){return this.ready_||(this.ready_=new Promise(t=>{this.imageState_===k.LOADED||this.imageState_===k.ERROR?t():this.addEventListener(Ct.CHANGE,function e(){(this.imageState_===k.LOADED||this.imageState_===k.ERROR)&&(this.removeEventListener(Ct.CHANGE,e),t())})})),this.ready_}}function Dn(n,t,e,i,s,r){let o=t===void 0?void 0:te.get(t,e,s);return o||(o=new Ho(n,n&&"src"in n?n.src||void 0:t,e,i,s),te.set(t,e,s,o,r)),r&&o&&!te.getPattern(t,e,s)&&te.set(t,e,s,o,r),o}function bt(n){return n?Array.isArray(n)?Fn(n):typeof n=="object"&&"src"in n?Jo(n):n:null}function Jo(n){if(!n.offset||!n.size)return te.getPattern(n.src,"anonymous",n.color);const t=n.src+":"+n.offset,e=te.getPattern(t,void 0,n.color);if(e)return e;const i=te.get(n.src,"anonymous",null);if(i.getImageState()!==k.LOADED)return null;const s=_t(n.size[0],n.size[1]);return s.drawImage(i.getImage(1),n.offset[0],n.offset[1],n.size[0],n.size[1],0,0,n.size[0],n.size[1]),Dn(s.canvas,t,void 0,k.LOADED,n.color,!0),te.getPattern(t,void 0,n.color)}const dr={PROPERTYCHANGE:"propertychange"};class gr extends fr{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(Ct.CHANGE)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,s=new Array(i);for(let r=0;rMath.max(s,Pi(n,r)),0);return e[t]=i,i}function ia(n,t){const e=[],i=[],s=[];let r=0,o=0,a=0,l=0;for(let c=0,h=t.length;c<=h;c+=2){const u=t[c];if(u===` -`||c===h){r=Math.max(r,o),s.push(o),o=0,a+=l,l=0;continue}const f=t[c+1]||n.font,d=Pi(f,u);e.push(d),o+=d;const g=ea(f);i.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:e,heights:i,lineWidths:s}}function na(n,t,e,i,s,r,o,a,l,c,h){n.save(),e!==1&&(n.globalAlpha===void 0?n.globalAlpha=u=>u.globalAlpha*=e:n.globalAlpha*=e),t&&n.transform.apply(n,t),i.contextInstructions?(n.translate(l,c),n.scale(h[0],h[1]),sa(i,n)):h[0]<0||h[1]<0?(n.translate(l,c),n.scale(h[0],h[1]),n.drawImage(i,s,r,o,a,0,0,o,a)):n.drawImage(i,s,r,o,a,l,c,o*h[0],a*h[1]),n.restore()}function sa(n,t){const e=n.contextInstructions;for(let i=0,s=e.length;ithis.imageState_=k.LOADED),this.render()}clone(){const t=this.getScale(),e=new Ui({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){const t=this.size_,e=this.getDisplacement(),i=this.getScaleArray();return[t[0]/2-e[0]/i[0],t[1]/2+e[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){let e=this.canvases_[t];if(!e){const i=this.renderOptions_,s=_t(i.size*t,i.size*t);this.draw_(i,s,t),e=s.canvas,this.canvases_[t]=e}return e}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius_}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,i){if(e===0||this.points_===1/0||t!=="bevel"&&t!=="miter")return e;let s=this.radius_,r=this.radius2_===void 0?s:this.radius2_;if(sMath.round(e*xs[i])/xs[i]).join(", ")+")"}const H={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function Gn(n,t,e){return e?(e[0]=n[0]-t,e[1]=n[1]-t,e[2]=n[2]+t,e[3]=n[3]+t,e):[n[0]-t,n[1]-t,n[2]+t,n[3]+t]}function ua(n,t){return n.slice()}function Ir(n,t,e){let i,s;return ts&&(l=l|H.RIGHT),ar&&(l=l|H.ABOVE),l===H.UNKNOWN&&(l=H.INTERSECTING),l}function fe(){return[1/0,1/0,-1/0,-1/0]}function Pe(n,t,e,i,s){return s?(s[0]=n,s[1]=t,s[2]=e,s[3]=i,s):[n,t,e,i]}function Cr(n){return Pe(1/0,1/0,-1/0,-1/0,n)}function Rr(n,t){const e=n[0],i=n[1];return Pe(e,i,e,i,t)}function Wn(n,t,e,i,s){const r=Cr(s);return Tr(r,n,t,e,i)}function vr(n,t){return n[0]==t[0]&&n[2]==t[2]&&n[1]==t[1]&&n[3]==t[3]}function fa(n,t){t[0]n[2]&&(n[2]=t[0]),t[1]n[3]&&(n[3]=t[1])}function Tr(n,t,e,i,s){for(;e=t[0]&&n[1]<=t[3]&&n[3]>=t[1]}function Fr(n){return n[2]=o&&_<=l),!i&&r&H.RIGHT&&!(s&H.RIGHT)&&(m=d-(f-l)*g,i=m>=a&&m<=c),!i&&r&H.BELOW&&!(s&H.BELOW)&&(_=f-(d-a)/g,i=_>=o&&_<=l),!i&&r&H.LEFT&&!(s&H.LEFT)&&(m=d-(f-o)*g,i=m>=a&&m<=c)}return i}function kr(n,t){const e=t.getExtent(),i=Ne(n);if(t.canWrapX()&&(i[0]=e[2])){const s=ct(e),o=Math.floor((i[0]-e[0])/s)*s;n[0]-=o,n[2]-=o}return n}function xa(n,t,e){if(t.canWrapX()){const i=t.getExtent();if(!isFinite(n[0])||!isFinite(n[2]))return[[i[0],n[1],i[2],n[3]]];kr(n,t);const s=ct(i);if(ct(n)>s)return[[i[0],n[1],i[2],n[3]]];if(n[0]i[2])return[[n[0],n[1],i[2],n[3]],[i[0],n[1],n[2]-s,n[3]]]}return[n]}const Or={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class Dr{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=t.extent!==void 0?t.extent:null,this.worldExtent_=t.worldExtent!==void 0?t.worldExtent:null,this.axisOrientation_=t.axisOrientation!==void 0?t.axisOrientation:"enu",this.global_=t.global!==void 0?t.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||Or[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!!(t&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!!(this.global_&&t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}}const mi=6378137,Ce=Math.PI*mi,Ea=[-Ce,-Ce,Ce,Ce],wa=[-180,-85,180,85],Mi=mi*Math.log(Math.tan(Math.PI/2));class me extends Dr{constructor(t){super({code:t,units:"m",extent:Ea,global:!0,worldExtent:wa,getPointResolution:function(e,i){return e/Math.cosh(i[1]/mi)}})}}const Es=[new me("EPSG:3857"),new me("EPSG:102100"),new me("EPSG:102113"),new me("EPSG:900913"),new me("http://www.opengis.net/def/crs/EPSG/0/3857"),new me("http://www.opengis.net/gml/srs/epsg.xml#3857")];function Ia(n,t,e){const i=n.length;e=e>1?e:2,t===void 0&&(e>2?t=n.slice():t=new Array(i));for(let s=0;sMi?r=Mi:r<-Mi&&(r=-Mi),t[s+1]=r}return t}function Sa(n,t,e){const i=n.length;e=e>1?e:2,t===void 0&&(e>2?t=n.slice():t=new Array(i));for(let s=0;s=0;--i)if(n[i]!=t[i]){e=!1;break}return e}function Aa(n,t){const e=Math.cos(t),i=Math.sin(t),s=n[0]*e-n[1]*i,r=n[1]*e+n[0]*i;return n[0]=s,n[1]=r,n}function La(n,t){if(t.canWrapX()){const e=ct(t.getExtent()),i=Fa(n,t,e);i&&(n[0]-=i*e)}return n}function Fa(n,t,e){const i=t.getExtent();let s=0;return t.canWrapX()&&(n[0]i[2])&&(e=e||ct(i),s=Math.floor((n[0]-i[0])/e)),s}function ka(...n){console.warn(...n)}let Tn=!0;function Oa(n){Tn=!1}function Pr(n,t){if(t!==void 0){for(let e=0,i=n.length;e=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&(Tn=!1,ka("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n}function Nr(n,t){return n}function Ke(n,t){return n}function Xa(){Ss(Es),Ss(Is),Ga(Is,Es,Ia,Sa)}Xa();function ne(n,t,e,i,s,r){r=r||[];let o=0;for(let a=t;a{if(!i)return this.getSimplifiedGeometry(e);const s=this.clone();return s.applyTransform(i),s.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return B()}closestPointXY(t,e,i,s){return B()}containsXY(t,e){const i=this.getClosestPoint([t,e]);return i[0]===t&&i[1]===e}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return B()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&Cr(e),this.extentRevision_=this.getRevision()}return pa(this.extent_,t)}rotate(t,e){B()}scale(t,e,i){B()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return B()}getType(){return B()}applyTransform(t){B()}intersectsExtent(t){return B()}translate(t,e){B()}transform(t,e){const i=de(t),s=i.getUnits()=="tile-pixels"?function(r,o,a){const l=i.getExtent(),c=i.getWorldExtent(),h=Vt(c)/Vt(l);return ue(vs,c[0],c[3],h,-h,0,0,0),ne(r,0,r.length,a,vs,o),Cs(i,e)(r,o,a)}:Cs(i,e);return this.applyTransform(s),this}}class Bn extends Ya{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return Wn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return B()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length{this.patternImage_=null}),e.getImageState()===k.IDLE&&e.load(),e.getImageState()===k.LOADING&&(this.patternImage_=e)}this.color_=t}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}class Yt{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=bs,t.geometry!==void 0&&this.setGeometry(t.geometry),this.fill_=t.fill!==void 0?t.fill:null,this.image_=t.image!==void 0?t.image:null,this.renderer_=t.renderer!==void 0?t.renderer:null,this.hitDetectionRenderer_=t.hitDetectionRenderer!==void 0?t.hitDetectionRenderer:null,this.stroke_=t.stroke!==void 0?t.stroke:null,this.text_=t.text!==void 0?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&typeof t=="object"&&(t=t.clone()),new Yt({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){typeof t=="function"?this.geometryFunction_=t:typeof t=="string"?this.geometryFunction_=function(e){return e.get(t)}:t?t!==void 0&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=bs,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function qa(n){let t;if(typeof n=="function")t=n;else{let e;Array.isArray(n)?e=n:(it(typeof n.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[n]),t=function(){return e}}return t}let gn=null;function Xr(n,t){if(!gn){const e=new pi({color:"rgba(255,255,255,0.4)"}),i=new Ge({color:"#3399CC",width:1.25});gn=[new Yt({image:new De({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return gn}function bs(n){return n.getGeometry()}const X={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};class $a extends ge{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);typeof t.properties=="object"&&(delete e.properties,Object.assign(e,t.properties)),e[X.OPACITY]=t.opacity!==void 0?t.opacity:1,it(typeof e[X.OPACITY]=="number","Layer opacity must be a number"),e[X.VISIBLE]=t.visible!==void 0?t.visible:!0,e[X.Z_INDEX]=t.zIndex,e[X.MAX_RESOLUTION]=t.maxResolution!==void 0?t.maxResolution:1/0,e[X.MIN_RESOLUTION]=t.minResolution!==void 0?t.minResolution:0,e[X.MIN_ZOOM]=t.minZoom!==void 0?t.minZoom:-1/0,e[X.MAX_ZOOM]=t.maxZoom!==void 0?t.maxZoom:1/0,this.className_=e.className!==void 0?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){const e=this.state_||{layer:this,managed:t===void 0?!0:t},i=this.getZIndex();return e.opacity=rt(Math.round(this.getOpacity()*100)/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=i===void 0&&!e.managed?1/0:i,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return B()}getLayerStatesArray(t){return B()}getExtent(){return this.get(X.EXTENT)}getMaxResolution(){return this.get(X.MAX_RESOLUTION)}getMinResolution(){return this.get(X.MIN_RESOLUTION)}getMinZoom(){return this.get(X.MIN_ZOOM)}getMaxZoom(){return this.get(X.MAX_ZOOM)}getOpacity(){return this.get(X.OPACITY)}getSourceState(){return B()}getVisible(){return this.get(X.VISIBLE)}getZIndex(){return this.get(X.Z_INDEX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(X.EXTENT,t)}setMaxResolution(t){this.set(X.MAX_RESOLUTION,t)}setMinResolution(t){this.set(X.MIN_RESOLUTION,t)}setMaxZoom(t){this.set(X.MAX_ZOOM,t)}setMinZoom(t){this.set(X.MIN_ZOOM,t)}setOpacity(t){it(typeof t=="number","Layer opacity must be a number"),this.set(X.OPACITY,t)}setVisible(t){this.set(X.VISIBLE,t)}setZIndex(t){this.set(X.Z_INDEX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}const le={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose"},xt={ANIMATING:0,INTERACTING:1},It={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"},Ha=256;function Ms(n,t,e){return function(i,s,r,o,a){if(!i)return;if(!s&&!t)return i;const l=t?0:r[0]*s,c=t?0:r[1]*s,h=a?a[0]:0,u=a?a[1]:0;let f=n[0]+l/2+h,d=n[2]-l/2+h,g=n[1]+c/2+u,_=n[3]-c/2+u;f>d&&(f=(d+f)/2,d=f),g>_&&(g=(_+g)/2,_=g);let m=rt(i[0],f,d),p=rt(i[1],g,_);if(o&&e&&s){const y=30*s;m+=-y*Math.log(1+Math.max(0,f-i[0])/y)+y*Math.log(1+Math.max(0,i[0]-d)/y),p+=-y*Math.log(1+Math.max(0,g-i[1])/y)+y*Math.log(1+Math.max(0,i[1]-_)/y)}return[m,p]}}function Ja(n){return n}function zn(n,t,e,i){const s=ct(t)/e[0],r=Vt(t)/e[1];return i?Math.min(n,Math.max(s,r)):Math.min(n,Math.min(s,r))}function Yn(n,t,e){let i=Math.min(n,t);const s=50;return i*=Math.log(1+s*Math.max(0,n/t-1))/s+1,e&&(i=Math.max(i,e),i/=Math.log(1+s*Math.max(0,e/n-1))/s+1),rt(i,e/2,t*2)}function Ka(n,t,e,i){return t=t!==void 0?t:!0,function(s,r,o,a){if(s!==void 0){const l=n[0],c=n[n.length-1],h=e?zn(l,e,o,i):l;if(a)return t?Yn(s,h,c):rt(s,c,h);const u=Math.min(h,s),f=Math.floor(cr(n,u,r));return n[f]>h&&f1)u=e;else if(f>0){for(let d=0;ds&&(s=c),r=a,o=l}return s}function ol(n,t,e,i,s){for(let r=0,o=e.length;r0;){const u=c.pop(),f=c.pop();let d=0;const g=n[f],_=n[f+1],m=n[u],p=n[u+1];for(let y=f+i;yd&&(h=y,d=I)}d>s&&(l[(h-t)/i]=1,f+i0&&_>d)&&(g<0&&m0&&m>g)){c=u,h=f;continue}r[o++]=c,r[o++]=h,a=c,l=h,c=u,h=f}return r[o++]=c,r[o++]=h,o}function Yr(n,t,e,i,s,r,o,a){for(let l=0,c=e.length;lr&&(c-a)*(r-l)-(s-a)*(h-l)>0&&o++:h<=r&&(c-a)*(r-l)-(s-a)*(h-l)<0&&o--,a=c,l=h}return o!==0}function Zr(n,t,e,i,s,r){if(e.length===0||!he(n,t,e[0],i,s,r))return!1;for(let o=1,a=e.length;op&&(c=(h+u)/2,Zr(n,t,e,i,c,g)&&(m=c,p=y)),h=u}return isNaN(m)&&(m=s[r]),o?(o.push(m,g,p),o):[m,g,p]}function fl(n,t,e,i,s){let r=[];for(let o=0,a=e.length;o=s[0]&&r[2]<=s[2]||r[1]>=s[1]&&r[3]<=s[3]?!0:dl(n,t,e,i,function(o,a){return ya(s,o,a)}):!1}function gl(n,t,e,i,s){return!!(Ur(n,t,e,i,s)||he(n,t,e,i,s[0],s[1])||he(n,t,e,i,s[0],s[3])||he(n,t,e,i,s[2],s[1])||he(n,t,e,i,s[2],s[3]))}function _l(n,t,e,i,s){if(!gl(n,t,e[0],i,s))return!1;if(e.length===1)return!0;for(let r=1,o=e.length;r0}function pl(n,t,e,i,s){s=s!==void 0?s:!1;for(let r=0,o=e.length;r1&&typeof arguments[e-1]=="function"&&(i=arguments[e-1],--e);let s=0;for(;s0}getInteracting(){return this.hints_[xt.INTERACTING]>0}cancelAnimations(){this.setHint(xt.ANIMATING,-this.hints_[xt.ANIMATING]);let t;for(let e=0,i=this.animations_.length;e=0;--i){const s=this.animations_[i];let r=!0;for(let o=0,a=s.length;o0?c/l.duration:1;h>=1?(l.complete=!0,h=1):r=!1;const u=l.easing(h);if(l.sourceCenter){const f=l.sourceCenter[0],d=l.sourceCenter[1],g=l.targetCenter[0],_=l.targetCenter[1];this.nextCenter_=l.targetCenter;const m=f+u*(g-f),p=d+u*(_-d);this.targetCenter_=[m,p]}if(l.sourceResolution&&l.targetResolution){const f=u===1?l.targetResolution:l.sourceResolution+u*(l.targetResolution-l.sourceResolution);if(l.anchor){const d=this.getViewportSize_(this.getRotation()),g=this.constraints_.resolution(f,0,d,!0);this.targetCenter_=this.calculateCenterZoom(g,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=f,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){const f=u===1?cs(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+u*(l.targetRotation-l.sourceRotation);if(l.anchor){const d=this.constraints_.rotation(f,!0);this.targetCenter_=this.calculateCenterRotate(d,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=f}if(this.applyTargetState_(!0),e=!0,!l.complete)break}if(r){this.animations_[i]=null,this.setHint(xt.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=s[0].callback;o&&Ai(o,!0)}}this.animations_=this.animations_.filter(Boolean),e&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let i;const s=this.getCenterInternal();return s!==void 0&&(i=[s[0]-e[0],s[1]-e[1]],Aa(i,t-this.getRotation()),Ma(i,e)),i}calculateCenterZoom(t,e){let i;const s=this.getCenterInternal(),r=this.getResolution();if(s!==void 0&&r!==void 0){const o=e[0]-t*(e[0]-s[0])/r,a=e[1]-t*(e[1]-s[1])/r;i=[o,a]}return i}getViewportSize_(t){const e=this.viewportSize_;if(t){const i=e[0],s=e[1];return[Math.abs(i*Math.cos(t))+Math.abs(s*Math.sin(t)),Math.abs(i*Math.sin(t))+Math.abs(s*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const t=this.getCenterInternal();return t&&Rs(t,this.getProjection())}getCenterInternal(){return this.get(It.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return t!==void 0?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){const e=this.calculateExtentInternal(t);return Nr(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();it(e,"The view center is not defined");const i=this.getResolution();it(i!==void 0,"The view resolution is not defined");const s=this.getRotation();return it(s!==void 0,"The view rotation is not defined"),_a(e,i,s,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get(It.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(Ke(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=ct(t)/e[0],s=Vt(t)/e[1];return Math.max(i,s)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,s=Math.log(e/i)/Math.log(t);return function(r){return e/Math.pow(t,r*s)}}getRotation(){return this.get(It.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),i=this.getConstrainedResolution(this.maxResolution_),s=this.minResolution_,r=Math.log(i/s)/e;return function(o){return Math.log(i/o)/e/r}}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const i=this.padding_;return i&&(e=[e[0]-i[1]-i[3],e[1]-i[0]-i[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),i=this.getRotation();let s=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();s=mn(s,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],e,i)}return{center:s.slice(0),projection:t!==void 0?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t;const e=this.getResolution();return e!==void 0&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e=this.minZoom_||0,i,s;if(this.resolutions_){const r=cr(this.resolutions_,t,1);e=r,i=this.resolutions_[r],r==this.resolutions_.length-1?s=2:s=i/this.resolutions_[r+1]}else i=this.maxResolution_,s=this.zoomFactor_;return e+Math.log(i/t)/Math.log(s)}getResolutionForZoom(t){if(this.resolutions_){if(this.resolutions_.length<=1)return 0;const e=rt(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,rt(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(it(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){it(!Fr(t),"Cannot fit empty extent provided as `geometry`");const s=Ke(t,this.getProjection());i=Ds(s)}else if(t.getType()==="Circle"){const s=Ke(t.getExtent(),this.getProjection());i=Ds(s),i.rotate(this.getRotation(),Ne(s))}else i=t;this.fitInternal(i,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),i=Math.cos(e),s=Math.sin(-e),r=t.getFlatCoordinates(),o=t.getStride();let a=1/0,l=1/0,c=-1/0,h=-1/0;for(let u=0,f=r.length;u{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return!this.renderer_||!this.rendered?null:this.renderer_.getData(t)}isVisible(t){let e;const i=this.getMapInternal();!t&&i&&(t=i.getView()),t instanceof Ps?e={viewState:t.getState(),extent:t.calculateExtent()}:e=t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let s;e.layerStatesArray?s=e.layerStatesArray.find(o=>o.layer===this):s=this.getLayerState();const r=this.getExtent();return Cl(s,e.viewState)&&(!r||St(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];let e;const i=this.getSource();if(i&&(e=i.getAttributions()),!e)return[];const s=t instanceof Ps?t.getViewStateAndExtent():t;let r=e(s);return Array.isArray(r)||(r=[r]),r}render(t,e){const i=this.getRenderer();return i.prepareFrame(t)?(this.rendered=!0,i.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){const e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(X.MAP,t)}getMapInternal(){return this.get(X.MAP)}setMap(t){this.mapPrecomposeKey_&&(ie(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(ie(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=Wt(t,le.PRECOMPOSE,function(e){const s=e.frameState.layerStatesArray,r=this.getLayerState(!1);it(!s.some(function(o){return o.layer===r.layer}),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),s.push(r)},this),this.mapRenderKey_=Wt(this,Ct.CHANGE,t.render,t),this.changed())}setSource(t){this.set(X.SOURCE,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}disposeInternal(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_),this.setSource(null),super.disposeInternal()}}function Cl(n,t){if(!n.visible)return!1;const e=t.resolution;if(e=n.maxResolution)return!1;const i=t.zoom;return i>n.minZoom&&i<=n.maxZoom}function Rl(n,t,e,i,s){jr(n,t,e||0,i||n.length-1,s||vl)}function jr(n,t,e,i,s){for(;i>e;){if(i-e>600){var r=i-e+1,o=t-e+1,a=Math.log(r),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(r-l)/r)*(o-r/2<0?-1:1),h=Math.max(e,Math.floor(t-o*l/r+c)),u=Math.min(i,Math.floor(t+(r-o)*l/r+c));jr(n,t,h,u,s)}var f=n[t],d=e,g=i;for(He(n,e,t),s(n[i],f)>0&&He(n,e,i);d0;)g--}s(n[e],f)===0?He(n,e,g):(g++,He(n,g,i)),g<=t&&(e=g+1),t<=g&&(i=g-1)}}function He(n,t,e){var i=n[t];n[t]=n[e],n[e]=i}function vl(n,t){return nt?1:0}let qr=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!Fi(t,e))return i;const s=this.toBBox,r=[];for(;e;){for(let o=0;o=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)}_split(t,e){const i=t[e],s=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,s);const o=this._chooseSplitIndex(i,r,s),a=we(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,pe(i,this.toBBox),pe(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=we([t,e]),this.data.height=t.height+1,this.data.leaf=!1,pe(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,r=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=Qe(t,0,a,this.toBBox),c=Qe(t,a,i,this.toBBox),h=Ll(l,c),u=pn(l)+pn(c);h=e;c--){const h=t.children[c];ti(a,t.leaf?r(h):h),l+=Li(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)ti(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():pe(t[e],this.toBBox)}};function Tl(n,t,e){if(!e)return t.indexOf(n);for(let i=0;i=n.minX&&t.maxY>=n.minY}function we(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Ns(n,t,e,i,s){const r=[t,e];for(;r.length;){if(e=r.pop(),t=r.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;Rl(n,o,t,e,s),r.push(t,o,o,e)}}function Gs(n,t,e,i){return e!==void 0&&i!==void 0?[e/n,i/t]:e!==void 0?e/n:i!==void 0?i/t:1}class qi extends Zi{constructor(t){t=t||{};const e=t.opacity!==void 0?t.opacity:1,i=t.rotation!==void 0?t.rotation:0,s=t.scale!==void 0?t.scale:1,r=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:e,rotation:i,scale:s,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:r,declutterMode:t.declutterMode}),this.anchor_=t.anchor!==void 0?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=t.anchorOrigin!==void 0?t.anchorOrigin:"top-left",this.anchorXUnits_=t.anchorXUnits!==void 0?t.anchorXUnits:"fraction",this.anchorYUnits_=t.anchorYUnits!==void 0?t.anchorYUnits:"fraction",this.crossOrigin_=t.crossOrigin!==void 0?t.crossOrigin:null;const o=t.img!==void 0?t.img:null;let a=t.src;it(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||et(o)),it(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),it(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(t.src!==void 0?l=k.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?k.LOADED:k.IDLE:l=k.LOADING:l=k.LOADED),this.color_=t.color!==void 0?ri(t.color):null,this.iconImage_=Dn(o,a,this.crossOrigin_,l,this.color_),this.offset_=t.offset!==void 0?t.offset:[0,0],this.offsetOrigin_=t.offsetOrigin!==void 0?t.offsetOrigin:"top-left",this.origin_=null,this.size_=t.size!==void 0?t.size:null,t.width!==void 0||t.height!==void 0){let c,h;if(t.size)[c,h]=t.size;else{const u=this.getImage(1);if(u.width&&u.height)c=u.width,h=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=t;const f=()=>{if(this.unlistenImageChange(f),!this.initialOptions_)return;const d=this.iconImage_.getSize();this.setScale(Gs(d[0],d[1],t.width,t.height))};this.listenImageChange(f);return}}c!==void 0&&this.setScale(Gs(c,h,t.width,t.height))}}clone(){let t,e,i;return this.initialOptions_?(e=this.initialOptions_.width,i=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new qi({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:i,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;const s=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!s)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=s[0]),this.anchorYUnits_=="fraction"&&(t[1]*=s[1])}if(this.anchorOrigin_!="top-left"){if(!s)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+s[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+s[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),i=this.getScaleArray();return[t[0]-e[0]/i[0],t[1]+e[1]/i[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if(this.offsetOrigin_!="top-left"){const e=this.getSize(),i=this.iconImage_.getSize();if(!e||!i)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=i[0]-e[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=i[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();if(this.size_)return this.size_[0]*t[0];if(this.iconImage_.getImageState()==k.LOADED)return this.iconImage_.getSize()[0]*t[0]}getHeight(){const t=this.getScaleArray();if(this.size_)return this.size_[1]*t[1];if(this.iconImage_.getImageState()==k.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(Ct.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(Ct.CHANGE,t)}ready(){return this.iconImage_.ready()}}const Fl="#333";class jn{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.scale_=t.scale,this.scaleArray_=ni(t.scale!==void 0?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=t.fill!==void 0?t.fill:new pi({color:Fl}),this.maxAngle_=t.maxAngle!==void 0?t.maxAngle:Math.PI/4,this.placement_=t.placement!==void 0?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=t.stroke!==void 0?t.stroke:null,this.offsetX_=t.offsetX!==void 0?t.offsetX:0,this.offsetY_=t.offsetY!==void 0?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=t.padding===void 0?null:t.padding,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new jn({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=ni(t!==void 0?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}}let _e=0;const Xe=0,j=1<<_e++,T=1<<_e++,gt=1<<_e++,J=1<<_e++,Mt=1<<_e++,ii=1<<_e++,nt=Math.pow(2,_e)-1,$r={[j]:"boolean",[T]:"number",[gt]:"string",[J]:"color",[Mt]:"number[]",[ii]:"size"},kl=Object.keys($r).map(Number).sort(ce);function ot(n){const t=[];for(const e of kl)Ol(n,e)&&t.push($r[e]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function Ol(n,t){return(n&t)===t}function At(n,t){return!!(n&t)}function $i(n,t){return n===t}class ee{constructor(t,e){this.type=t,this.value=e}}class Dl{constructor(t,e,...i){this.type=t,this.operator=e,this.args=i}}function Hr(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,style:{}}}function Pl(n){switch(n){case"string":return gt;case"color":return J;case"number":return T;case"boolean":return j;case"number[]":return Mt;default:throw new Error(`Unrecognized type hint: ${n}`)}}function W(n,t,e){switch(typeof n){case"boolean":return new ee(j,n);case"number":return new ee(e===ii?ii:T,n);case"string":{let s=gt;return Wo(n)&&(s|=J),$i(s&e,Xe)||(s&=e),new ee(s,n)}}if(!Array.isArray(n))throw new Error("Expression must be an array or a primitive value");if(n.length===0)throw new Error("Empty expression");if(typeof n[0]=="string")return ql(n,t,e);for(const s of n)if(typeof s!="number")throw new Error("Expected an array of numbers");let i=Mt;return n.length===2?i|=ii:(n.length===3||n.length===4)&&(i|=J),e&&(i&=e),new ee(i,n)}const x={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string"},Nl={[x.Get]:L(([n,t])=>t!==void 0?Pl(t.value):nt,F(1,2),Gl),[x.Var]:L(([n])=>n.type,F(1,1),Wl),[x.Id]:L(T|gt,Je,Xl),[x.Concat]:L(gt,F(2,1/0),D(nt)),[x.GeometryType]:L(gt,Je,Bl),[x.Resolution]:L(T,Je),[x.Zoom]:L(T,Je),[x.Time]:L(T,Je),[x.Any]:L(j,F(2,1/0),D(j)),[x.All]:L(j,F(2,1/0),D(j)),[x.Not]:L(j,F(1,1),D(j)),[x.Equal]:L(j,F(2,2),D(nt),$t),[x.NotEqual]:L(j,F(2,2),D(nt),$t),[x.GreaterThan]:L(j,F(2,2),D(nt),$t),[x.GreaterThanOrEqualTo]:L(j,F(2,2),D(nt),$t),[x.LessThan]:L(j,F(2,2),D(nt),$t),[x.LessThanOrEqualTo]:L(j,F(2,2),D(nt),$t),[x.Multiply]:L(n=>{let t=T|J;for(let e=0;e{let t=nt;for(let e=1;e{let t=nt;for(let e=2;e{let t=J|T;for(let e=3;e{let t=nt;for(let e=1;en.length===2?Mt|ii:n.length===3||n.length===4?Mt|J:Mt,F(1,1/0),D(T)),[x.Color]:L(J,F(1,4),D(T)),[x.Band]:L(T,F(1,3),D(T)),[x.Palette]:L(J,F(2,2),jl),[x.ToString]:L(gt,F(1,1),D(j|T|gt|J))};function Gl(n,t){const e=W(n[1],t);if(!(e instanceof ee))throw new Error("Expected a literal argument for get operation");if(typeof e.value!="string")throw new Error("Expected a string argument for get operation");if(t.properties.add(e.value),n.length===3){const i=W(n[2],t);return[e,i]}return[e]}function Wl(n,t,e,i){const s=n[1];if(typeof s!="string")throw new Error("Expected a string argument for var operation");if(t.variables.add(s),!("variables"in t.style)||t.style.variables[s]===void 0)return[new ee(nt,s)];const r=t.style.variables[s],o=W(r,t);if(o.value=s,i&&!At(i,o.type))throw new Error(`The variable ${s} has type ${ot(o.type)} but the following type was expected: ${ot(i)}`);return[o]}function Xl(n,t){t.featureId=!0}function Bl(n,t){t.geometryType=!0}function Je(n,t){const e=n[0];if(n.length!==1)throw new Error(`Expected no arguments for ${e} operation`);return[]}function F(n,t){return function(e,i){const s=e[0],r=e.length-1;if(n===t){if(r!==n){const o=n===1?"":"s";throw new Error(`Expected ${n} argument${o} for ${s}, got ${r}`)}}else if(rt){const o=t===1/0?`${n} or more`:`${n} to ${t}`;throw new Error(`Expected ${o} arguments for ${s}, got ${r}`)}}}function D(n){return function(t,e){const i=t[0],s=t.length-1,r=new Array(s);for(let o=0;oi.featureId;case x.GeometryType:return i=>i.geometryType;case x.Concat:{const i=n.args.map(s=>Rt(s));return s=>"".concat(...i.map(r=>r(s).toString()))}case x.Resolution:return i=>i.resolution;case x.Any:case x.All:case x.Between:case x.In:case x.Not:return Kl(n);case x.Equal:case x.NotEqual:case x.LessThan:case x.LessThanOrEqualTo:case x.GreaterThan:case x.GreaterThanOrEqualTo:return Jl(n);case x.Multiply:case x.Divide:case x.Add:case x.Subtract:case x.Clamp:case x.Mod:case x.Pow:case x.Abs:case x.Floor:case x.Ceil:case x.Round:case x.Sin:case x.Cos:case x.Atan:case x.Sqrt:return Ql(n);case x.Case:return th(n);case x.Match:return eh(n);case x.Interpolate:return ih(n);case x.ToString:return nh(n);default:throw new Error(`Unsupported operator ${e}`)}}function $l(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{for(let o=0;o{for(let o=0;os.properties[i];case x.Var:return s=>s.variables[i];default:throw new Error(`Unsupported accessor operator ${n.operator}`)}}function Jl(n,t){const e=n.operator,i=Rt(n.args[0]),s=Rt(n.args[1]);switch(e){case x.Equal:return r=>i(r)===s(r);case x.NotEqual:return r=>i(r)!==s(r);case x.LessThan:return r=>i(r)i(r)<=s(r);case x.GreaterThan:return r=>i(r)>s(r);case x.GreaterThanOrEqualTo:return r=>i(r)>=s(r);default:throw new Error(`Unsupported comparison operator ${e}`)}}function Kl(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{for(let o=0;o{for(let o=0;o{const o=s[0](r),a=s[1](r),l=s[2](r);return o>=a&&o<=l};case x.In:return r=>{const o=s[0](r);for(let a=1;a!s[0](r);default:throw new Error(`Unsupported logical operator ${e}`)}}function Ql(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{let o=1;for(let a=0;as[0](r)/s[1](r);case x.Add:return r=>{let o=0;for(let a=0;as[0](r)-s[1](r);case x.Clamp:return r=>{const o=s[0](r),a=s[1](r);if(ol?l:o};case x.Mod:return r=>s[0](r)%s[1](r);case x.Pow:return r=>Math.pow(s[0](r),s[1](r));case x.Abs:return r=>Math.abs(s[0](r));case x.Floor:return r=>Math.floor(s[0](r));case x.Ceil:return r=>Math.ceil(s[0](r));case x.Round:return r=>Math.round(s[0](r));case x.Sin:return r=>Math.sin(s[0](r));case x.Cos:return r=>Math.cos(s[0](r));case x.Atan:return i===2?r=>Math.atan2(s[0](r),s[1](r)):r=>Math.atan(s[0](r));case x.Sqrt:return r=>Math.sqrt(s[0](r));default:throw new Error(`Unsupported numeric operator ${e}`)}}function th(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s{for(let r=0;r{const r=i[0](s);for(let o=1;o{const r=i[0](s),o=i[1](s);let a,l;for(let c=2;c=o)return c===2?u:f?sh(r,o,a,l,h,u):ei(r,o,a,l,h,u);a=h,l=u}return l}}function nh(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{const o=s[0](r);return n.args[0].type===J?Fn(o):o.toString()};default:throw new Error(`Unsupported convert operator ${e}`)}}function ei(n,t,e,i,s,r){const o=s-e;if(o===0)return i;const a=t-e,l=n===1?a/o:(Math.pow(n,a)-1)/(Math.pow(n,o)-1);return i+l*(r-i)}function sh(n,t,e,i,s,r){if(s-e===0)return i;const a=us(i),l=us(r);let c=l[2]-a[2];c>180?c-=360:c<-180&&(c+=360);const h=[ei(n,t,e,a[0],s,l[0]),ei(n,t,e,a[1],s,l[1]),a[2]+ei(n,t,e,0,s,c),ei(n,t,e,i[3],s,r[3])];return lr(Go(h))}function rh(n){return!0}function oh(n){const t=Hr(),e=ah(n,t),i=Kr();return function(s,r){if(i.properties=s.getPropertiesInternal(),i.resolution=r,t.featureId){const o=s.getId();o!==void 0?i.featureId=o:i.featureId=null}return t.geometryType&&(i.geometryType=Jr(s.getGeometry())),e(i)}}function Xs(n){const t=Hr(),e=n.length,i=new Array(e);for(let o=0;o4)throw new Error(`Expected a color with 3 or 4 values for ${t}`);return e}function io(n,t){const e=yi(n,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function yh(n,t){return typeof n=="number"?n:io(n,t)}const Vs={RENDER_ORDER:"renderOrder"};class xh extends Sl{constructor(t){t=t||{};const e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=t.renderBuffer!==void 0?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=t.updateWhileAnimating!==void 0?t.updateWhileAnimating:!1,this.updateWhileInteracting_=t.updateWhileInteracting!==void 0?t.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Vs.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const i=this.getDeclutter();i in t.declutter||(t.declutter[i]=new qr(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(Vs.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?Xr:t;const e=Eh(t);this.styleFunction_=t===null?void 0:qa(e),this.changed()}}function Eh(n){if(n===void 0)return Xr;if(!n)return null;if(typeof n=="function"||n instanceof Yt)return n;if(!Array.isArray(n))return Xs([n]);if(n.length===0)return[];const t=n.length,e=n[0];if(e instanceof Yt){const s=new Array(t);for(let r=0;rl&&(this.instructions.push([b.CUSTOM,l,h,t,i,Re,r]),this.hitDetectionInstructions.push([b.CUSTOM,l,h,t,s||i,Re,r]));break;case"Point":c=t.getFlatCoordinates(),this.coordinates.push(c[0],c[1]),h=this.coordinates.length,this.instructions.push([b.CUSTOM,l,h,t,i,void 0,r]),this.hitDetectionInstructions.push([b.CUSTOM,l,h,t,s||i,void 0,r]);break}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[b.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[b.BEGIN_GEOMETRY,e,0,t,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;t.reverse();let e;const i=t.length;let s,r,o=-1;for(e=0;ethis.maxLineWidth&&(this.maxLineWidth=i.lineWidth,this.bufferedMaxExtent_=null)}else i.strokeStyle=void 0,i.lineCap=void 0,i.lineDash=null,i.lineDashOffset=void 0,i.lineJoin=void 0,i.lineWidth=void 0,i.miterLimit=void 0}createFill(t){const e=t.fillStyle,i=[b.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[b.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,this.applyPixelRatio(t.lineDash),t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const i=t.fillStyle;(typeof i!="string"||t.currentFillStyle!=i)&&(i!==void 0&&this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){const i=t.strokeStyle,s=t.lineCap,r=t.lineDash,o=t.lineDashOffset,a=t.lineJoin,l=t.lineWidth,c=t.miterLimit;(t.currentStrokeStyle!=i||t.currentLineCap!=s||r!=t.currentLineDash&&!We(t.currentLineDash,r)||t.currentLineDashOffset!=o||t.currentLineJoin!=a||t.currentLineWidth!=l||t.currentMiterLimit!=c)&&(i!==void 0&&e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=s,t.currentLineDash=r,t.currentLineDashOffset=o,t.currentLineJoin=a,t.currentLineWidth=l,t.currentMiterLimit=c)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[b.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=ua(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;Gn(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class wh extends xi{constructor(t,e,i,s){super(t,e,i,s),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(t,e,i){if(!this.image_||this.maxExtent&&!Cn(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,i);const s=t.getFlatCoordinates(),r=t.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(s,r);this.instructions.push([b.DRAW_IMAGE,o,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([b.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}drawMultiPoint(t,e,i){if(!this.image_)return;this.beginGeometry(t,e,i);const s=t.getFlatCoordinates(),r=[];for(let l=0,c=s.length;l=n){const g=(n-a+d)/d,_=wt(c,u,g),m=wt(h,f,g);l.push(_,m),r.push(l),l=[_,m],a==n&&(o+=s),a=0}else if(a0&&r.push(l),r}function Ch(n,t,e,i,s){let r=e,o=e,a=0,l=0,c=e,h,u,f,d,g,_,m,p,y,E;for(u=e;un&&(l>a&&(a=l,r=c,o=u),l=0,c=u-s)),f=d,m=y,p=E),g=S,_=I}return l+=d,l>a?[c,u]:[r,o]}const Vi={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class Rh extends xi{constructor(t,e,i,s){super(t,e,i,s),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[ht]={fillStyle:ht},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){const t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e,i){const s=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!s&&!r)return;const a=this.coordinates;let l=a.length;const c=t.getType();let h=null,u=t.getStride();if(o.placement==="line"&&(c=="LineString"||c=="MultiLineString"||c=="Polygon"||c=="MultiPolygon")){if(!St(this.maxExtent,t.getExtent()))return;let f;if(h=t.getFlatCoordinates(),c=="LineString")f=[h.length];else if(c=="MultiLineString")f=t.getEnds();else if(c=="Polygon")f=t.getEnds().slice(0,1);else if(c=="MultiPolygon"){const m=t.getEndss();f=[];for(let p=0,y=m.length;p{const I=a[(y+S)*2]===h[S*u]&&a[(y+S)*2+1]===h[S*u+1];return I||--y,I})}this.saveTextStates_(),(o.backgroundFill||o.backgroundStroke)&&(this.setFillStrokeStyle(o.backgroundFill,o.backgroundStroke),o.backgroundFill&&this.updateFillStyle(this.state,this.createFill),o.backgroundStroke&&(this.updateStrokeStyle(this.state,this.applyStroke),this.hitDetectionInstructions.push(this.createStroke(this.state)))),this.beginGeometry(t,e,i);let g=o.padding;if(g!=ae&&(o.scale[0]<0||o.scale[1]<0)){let y=o.padding[0],E=o.padding[1],S=o.padding[2],I=o.padding[3];o.scale[0]<0&&(E=-E,I=-I),o.scale[1]<0&&(y=-y,S=-S),g=[y,E,S,I]}const _=this.pixelRatio;this.instructions.push([b.DRAW_IMAGE,l,d,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,g==ae?ae:g.map(function(y){return y*_}),!!o.backgroundFill,!!o.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,f]);const m=1/_,p=this.state.fillStyle;o.backgroundFill&&(this.state.fillStyle=ht,this.hitDetectionInstructions.push(this.createFill(this.state))),this.hitDetectionInstructions.push([b.DRAW_IMAGE,l,d,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[m,m],NaN,this.declutterMode_,this.declutterImageWithText_,g,!!o.backgroundFill,!!o.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?ht:this.fillKey_,this.textOffsetX_,this.textOffsetY_,f]),o.backgroundFill&&(this.state.fillStyle=p,this.hitDetectionInstructions.push(this.createFill(this.state))),this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,i=this.textFillState_,s=this.strokeKey_;t&&(s in this.strokeStates||(this.strokeStates[s]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:e.font,textAlign:e.textAlign||hi,justify:e.justify,textBaseline:e.textBaseline||Di,scale:e.scale});const o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(t,e){const i=this.textStrokeState_,s=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,c=Vi[s.textBaseline],h=this.textOffsetY_*l,u=this.text_,f=i?i.lineWidth*Math.abs(s.scale[0])/2:0;this.instructions.push([b.DRAW_CHARS,t,e,c,s.overflow,a,s.maxAngle,l,h,r,f*l,u,o,1,this.declutterMode_]),this.hitDetectionInstructions.push([b.DRAW_CHARS,t,e,c,s.overflow,a&&ht,s.maxAngle,l,h,r,f*l,u,o,1/l,this.declutterMode_])}setTextStyle(t,e){let i,s,r;if(!t)this.text_="";else{const o=t.getFill();o?(s=this.textFillState_,s||(s={},this.textFillState_=s),s.fillStyle=bt(o.getColor()||ht)):(s=null,this.textFillState_=s);const a=t.getStroke();if(!a)r=null,this.textStrokeState_=r;else{r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const g=a.getLineDash(),_=a.getLineDashOffset(),m=a.getWidth(),p=a.getMiterLimit();r.lineCap=a.getLineCap()||ke,r.lineDash=g?g.slice():Xt,r.lineDashOffset=_===void 0?Bt:_,r.lineJoin=a.getLineJoin()||Oe,r.lineWidth=m===void 0?ci:m,r.miterLimit=p===void 0?ai:p,r.strokeStyle=bt(a.getColor()||li)}i=this.textState_;const l=t.getFont()||mr;ta(l);const c=t.getScaleArray();i.overflow=t.getOverflow(),i.font=l,i.maxAngle=t.getMaxAngle(),i.placement=t.getPlacement(),i.textAlign=t.getTextAlign(),i.repeat=t.getRepeat(),i.justify=t.getJustify(),i.textBaseline=t.getTextBaseline()||Di,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||ae,i.scale=c===void 0?[1,1]:c;const h=t.getOffsetX(),u=t.getOffsetY(),f=t.getRotateWithView(),d=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=h===void 0?0:h,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=f===void 0?!1:f,this.textRotation_=d===void 0?0:d,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:et(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=s&&s.fillStyle?typeof s.fillStyle=="string"?s.fillStyle:"|"+et(s.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}const vh={Circle:xn,Default:xi,Image:wh,LineString:Ih,Polygon:xn,Text:Rh,Ellipse:xn};class Th{constructor(t,e,i,s){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=s,this.resolution_=i,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const i=this.buildersByZIndex_[e];for(const s in i){const r=i[s].finish();t[e][s]=r}}return t}getBuilder(t,e){const i=t!==void 0?t.toString():"0";let s=this.buildersByZIndex_[i];s===void 0&&(s={},this.buildersByZIndex_[i]=s);let r=s[e];if(r===void 0){const o=vh[e];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),s[e]=r}return r}}class bh extends gr{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t}getFeatures(t){return B()}getData(t){return null}prepareFrame(t){return B()}renderFrame(t,e){return B()}loadedTileCallback(t,e,i){t[e]||(t[e]={}),t[e][i.tileCoord.toString()]=i}createLoadedTileFinder(t,e,i){return(s,r)=>{const o=this.loadedTileCallback.bind(this,i,s);return t.forEachLoadedTile(e,s,r,o)}}forEachFeatureAtCoordinate(t,e,i,s,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;(e.getState()===k.LOADED||e.getState()===k.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=k.LOADED&&e!=k.ERROR&&t.addEventListener(Ct.CHANGE,this.boundHandleImageChange_),e==k.IDLE&&(t.load(),e=t.getState()),e==k.LOADED}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}class Mh extends _i{constructor(t,e,i,s){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=s}}class so{constructor(){as(this,"pushMethodArgs_",(...t)=>(this.instructions_[this.zIndex+this.offset_].push(t),this));this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Oi(),{get:(t,e)=>{if(typeof Oi()[e]=="function")return this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(e),this.pushMethodArgs_},set:(t,e,i)=>(this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(e,i),!0)})}pushFunction(t){this.instructions_[this.zIndex+this.offset_].push(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let i=0,s=e.length;iA[2]}else P=S>R;const O=Math.PI,z=[],N=M+i===t;t=M,m=0,p=C,f=n[t],d=n[t+1];let G;if(N){y(),G=Math.atan2(d-_,f-g),P&&(G+=G>0?-O:O);const A=(R+S)/2,$=(Z+I)/2;return z[0]=[A,$,(v-r)/2,G,s],z}s=s.replace(/\n/g," ");for(let A=0,$=s.length;A<$;){y();let Y=Math.atan2(d-_,f-g);if(P&&(Y+=Y>0?-O:O),G!==void 0){let w=Y-G;if(w+=w>O?-2*O:w<-O?2*O:0,Math.abs(w)>o)return null}G=Y;const ft=A;let V=0;for(;A<$;++A){const w=P?$-A-1:A,Ki=a*l(c,s[w],h);if(t+i0&&n.push(` -`,""),n.push(t,""),n}class Dh{constructor(t,e,i,s,r){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=s.instructions,this.coordinates=s.coordinates,this.coordinateCache_={},this.renderedTransform_=zt(),this.hitDetectionInstructions=s.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=s.fillStates||{},this.strokeStates=s.strokeStates||{},this.textStates=s.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new so:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,i,s){const r=t+e+i+s;if(this.labels_[r])return this.labels_[r];const o=s?this.strokeStates[s]:null,a=i?this.fillStates[i]:null,l=this.textStates[e],c=this.pixelRatio,h=[l.scale[0]*c,l.scale[1]*c],u=Array.isArray(t),f=l.justify?Vi[l.justify]:En(Array.isArray(t)?t[0]:t,l.textAlign||hi),d=s&&o.lineWidth?o.lineWidth:0,g=u?t:t.split(` -`).reduce(Oh,[]),{width:_,height:m,widths:p,heights:y,lineWidths:E}=ia(l,g),S=_+d,I=[],M=(S+2)*h[0],C=(m+d)*h[1],v={width:M<0?Math.floor(M):Math.ceil(M),height:C<0?Math.floor(C):Math.ceil(C),contextInstructions:I};(h[0]!=1||h[1]!=1)&&I.push("scale",h),s&&(I.push("strokeStyle",o.strokeStyle),I.push("lineWidth",d),I.push("lineCap",o.lineCap),I.push("lineJoin",o.lineJoin),I.push("miterLimit",o.miterLimit),I.push("setLineDash",[o.lineDash]),I.push("lineDashOffset",o.lineDashOffset)),i&&I.push("fillStyle",a.fillStyle),I.push("textBaseline","middle"),I.push("textAlign","center");const R=.5-f;let Z=f*S+R*d;const P=[],O=[];let z=0,N=0,G=0,A=0,$;for(let Y=0,ft=g.length;Yt?t-c:r,S=o+h>e?e-h:o,I=g[3]+E*f[0]+g[1],M=g[0]+S*f[1]+g[2],C=p-g[3],v=y-g[0];(_||u!==0)&&(Ht[0]=C,Jt[0]=C,Ht[1]=v,Ot[1]=v,Ot[0]=C+I,Dt[0]=Ot[0],Dt[1]=v+M,Jt[1]=Dt[1]);let R;return u!==0?(R=ue(zt(),i,s,1,1,u,-i,-s),dt(R,Ht),dt(R,Ot),dt(R,Dt),dt(R,Jt),Pe(Math.min(Ht[0],Ot[0],Dt[0],Jt[0]),Math.min(Ht[1],Ot[1],Dt[1],Jt[1]),Math.max(Ht[0],Ot[0],Dt[0],Jt[0]),Math.max(Ht[1],Ot[1],Dt[1],Jt[1]),xe)):Pe(Math.min(C,C+I),Math.min(v,v+M),Math.max(C,C+I),Math.max(v,v+M),xe),d&&(p=Math.round(p),y=Math.round(y)),{drawImageX:p,drawImageY:y,drawImageW:E,drawImageH:S,originX:c,originY:h,declutterBox:{minX:xe[0],minY:xe[1],maxX:xe[2],maxY:xe[3],value:m},canvasTransform:R,scale:f}}replayImageOrLabel_(t,e,i,s,r,o,a){const l=!!(o||a),c=s.declutterBox,h=a?a[2]*s.scale[0]/2:0;return c.minX-h<=e[0]&&c.maxX+h>=0&&c.minY-h<=e[1]&&c.maxY+h>=0&&(l&&this.replayTextBackground_(t,Ht,Ot,Dt,Jt,o,a),na(t,s.canvasTransform,r,i,s.originX,s.originY,s.drawImageW,s.drawImageH,s.drawImageX,s.drawImageY,s.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const i=dt(this.renderedTransform_,[0,0]),s=512*this.pixelRatio;t.save(),t.translate(i[0]%s,i[1]%s),e!==1&&t.scale(e,e),t.rotate(this.viewRotation_)}t.fill(),e&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6])}drawLabelWithPointPlacement_(t,e,i,s){const r=this.textStates[e],o=this.createLabel(t,e,s,i),a=this.strokeStates[i],l=this.pixelRatio,c=En(Array.isArray(t)?t[0]:t,r.textAlign||hi),h=Vi[r.textBaseline||Di],u=a&&a.lineWidth?a.lineWidth:0,f=o.width/l-2*r.scale[0],d=c*f+2*(.5-c)*u,g=h*o.height/l+2*(.5-h)*u;return{label:o,anchorX:d,anchorY:g}}execute_(t,e,i,s,r,o,a,l){const c=this.zIndexContext_;let h;this.pixelCoordinates_&&We(i,this.renderedTransform_)?h=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),h=ne(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),aa(this.renderedTransform_,i));let u=0;const f=s.length;let d=0,g,_,m,p,y,E,S,I,M,C,v,R,Z,P=0,O=0,z=null,N=null;const G=this.coordinateCache_,A=this.viewRotation_,$=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,Y={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:A},ft=this.instructions!=s||this.overlaps?0:200;let V,q,K,Ut;for(;uft&&(this.fill_(t),P=0),O>ft&&(t.stroke(),O=0),!P&&!O&&(t.beginPath(),y=NaN,E=NaN),++u;break;case b.CIRCLE:d=w[1];const Qi=h[d],tn=h[d+1],co=h[d+2],uo=h[d+3],$n=co-Qi,Hn=uo-tn,Jn=Math.sqrt($n*$n+Hn*Hn);t.moveTo(Qi+Jn,tn),t.arc(Qi,tn,Jn,0,2*Math.PI,!0),++u;break;case b.ELLIPSE:d=w[1],g=w[2];const Be=h[d],ze=h[d+1],Ei=h[d+2],wi=h[d+3],Ii=h[d+4],Si=h[d+5],Ci=h[d+6],Ri=h[d+7];if(g-d===8){const Q=(Ii-Be)*.2761424,mt=(Si-ze)*.2761424,tt=(Ci-Ei)*.2761424,at=(Ri-wi)*.2761424;t.moveTo(Be,ze),t.bezierCurveTo(Be-tt,ze-at,Ei-Q,wi-mt,Ei,wi),t.bezierCurveTo(Ei+Q,wi+mt,Ii-tt,Si-at,Ii,Si),t.bezierCurveTo(Ii+tt,Si+at,Ci+Q,Ri+mt,Ci,Ri),t.bezierCurveTo(Ci-Q,Ri-mt,Be+tt,ze+at,Be,ze)}++u;break;case b.CLOSE_PATH:t.closePath(),++u;break;case b.CUSTOM:d=w[1],g=w[2];const fo=w[3],go=w[4],Kn=w[5];Y.geometry=fo,Y.feature=V,u in G||(G[u]=[]);const Ye=G[u];Kn?Kn(h,d,g,2,Ye):(Ye[0]=h[d],Ye[1]=h[d+1],Ye.length=2),c&&(c.zIndex=w[6]),go(Ye,Y),++u;break;case b.DRAW_IMAGE:d=w[1],g=w[2],M=w[3],_=w[4],m=w[5];let en=w[6];const _o=w[7],mo=w[8],po=w[9],Qn=w[10];let nn=w[11];const yo=w[12];let vi=w[13];p=w[14]||"declutter";const Ve=w[15];if(!M&&w.length>=20){C=w[19],v=w[20],R=w[21],Z=w[22];const Q=this.drawLabelWithPointPlacement_(C,v,R,Z);M=Q.label,w[3]=M;const mt=w[23];_=(Q.anchorX-mt)*this.pixelRatio,w[4]=_;const tt=w[24];m=(Q.anchorY-tt)*this.pixelRatio,w[5]=m,en=M.height,w[6]=en,vi=M.width,w[13]=vi}let sn;w.length>25&&(sn=w[25]);let rn,Ti,bi;w.length>17?(rn=w[16],Ti=w[17],bi=w[18]):(rn=ae,Ti=!1,bi=!1),Qn&&$?nn+=A:!Qn&&!$&&(nn-=A);let xo=0;for(;d!ro.includes(n));class Nh{constructor(t,e,i,s,r,o,a){this.maxExtent_=t,this.overlaps_=s,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=zt(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}clip(t,e){const i=this.getClipCoords(e);t.beginPath(),t.moveTo(i[0],i[1]),t.lineTo(i[2],i[3]),t.lineTo(i[4],i[5]),t.lineTo(i[6],i[7]),t.clip()}createExecutors_(t,e){for(const i in t){let s=this.executorsByZIndex_[i];s===void 0&&(s={},this.executorsByZIndex_[i]=s);const r=t[i];for(const o in r){const a=r[o];s[o]=new Dh(this.resolution_,this.pixelRatio_,this.overlaps_,a,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const i=this.executorsByZIndex_[e];for(let s=0,r=t.length;s0){if(!o||C==="none"||d!=="Image"&&d!=="Text"||o.includes(I)){const P=(f[R]-3)/4,O=s-P%a,z=s-(P/a|0),N=r(I,M,O*O+z*z);if(N)return N}h.clearRect(0,0,a,a);break}}const _=Object.keys(this.executorsByZIndex_).map(Number);_.sort(ce);let m,p,y,E,S;for(m=_.length-1;m>=0;--m){const I=_[m].toString();for(y=this.executorsByZIndex_[I],p=ve.length-1;p>=0;--p)if(d=ve[p],E=y[d],E!==void 0&&(S=E.executeHitDetection(h,l,i,g,u),S))return S}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const i=e[0],s=e[1],r=e[2],o=e[3],a=[i,s,i,o,r,o,r,s];return ne(a,0,8,2,t,a),a}isEmpty(){return Fe(this.executorsByZIndex_)}execute(t,e,i,s,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(ce),o=o||ve;const c=ve.length;let h,u,f,d,g;for(a&&l.reverse(),h=0,u=l.length;hp.execute(I,e,i,s,r,a)),S&&E.restore(),y){y.offset();const I=l[h]*c+f;this.deferredZIndexContexts_[I]||(this.deferredZIndexContexts_[I]=[]),this.deferredZIndexContexts_[I].push(y)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(ce);for(let i=0,s=e.length;i{r.draw(this.renderedContext_),r.clear()}),t[e[i]].length=0}}const wn={};function Gh(n){if(wn[n]!==void 0)return wn[n];const t=n*2+1,e=n*n,i=new Array(e+1);for(let r=0;r<=n;++r)for(let o=0;o<=n;++o){const a=r*r+o*o;if(a>e)break;let l=i[a];l||(l=[],i[a]=l),l.push(((n+r)*t+(n+o))*4+3),r>0&&l.push(((n-r)*t+(n+o))*4+3),o>0&&(l.push(((n+r)*t+(n-o))*4+3),r>0&&l.push(((n-r)*t+(n-o))*4+3))}const s=[];for(let r=0,o=i.length;ru*this.pixelRatio_),lineDashOffset:(o||Bt)*this.pixelRatio_,lineJoin:a!==void 0?a:Oe,lineWidth:(l!==void 0?l:ci)*this.pixelRatio_,miterLimit:c!==void 0?c:ai,strokeStyle:bt(i||li)}}}setImageStyle(t){let e;if(!t||!(e=t.getSize())){this.image_=null;return}const i=t.getPixelRatio(this.pixelRatio_),s=t.getAnchor(),r=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=s[0]*i,this.imageAnchorY_=s[1]*i,this.imageHeight_=e[1]*i,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();const o=t.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/i,o[1]*this.pixelRatio_/i],this.imageWidth_=e[0]*i}setTextStyle(t){if(!t)this.text_="";else{const e=t.getFill();if(!e)this.textFillState_=null;else{const d=e.getColor();this.textFillState_={fillStyle:bt(d||ht)}}const i=t.getStroke();if(!i)this.textStrokeState_=null;else{const d=i.getColor(),g=i.getLineCap(),_=i.getLineDash(),m=i.getLineDashOffset(),p=i.getLineJoin(),y=i.getWidth(),E=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:ke,lineDash:_||Xt,lineDashOffset:m||Bt,lineJoin:p!==void 0?p:Oe,lineWidth:y!==void 0?y:ci,miterLimit:E!==void 0?E:ai,strokeStyle:bt(d||li)}}const s=t.getFont(),r=t.getOffsetX(),o=t.getOffsetY(),a=t.getRotateWithView(),l=t.getRotation(),c=t.getScaleArray(),h=t.getText(),u=t.getTextAlign(),f=t.getTextBaseline();this.textState_={font:s!==void 0?s:mr,textAlign:u!==void 0?u:hi,textBaseline:f!==void 0?f:Di},this.text_=h!==void 0?Array.isArray(h)?h.reduce((d,g,_)=>d+=_%2?" ":g,""):h:"",this.textOffsetX_=r!==void 0?this.pixelRatio_*r:0,this.textOffsetY_=o!==void 0?this.pixelRatio_*o:0,this.textRotateWithView_=a!==void 0?a:!1,this.textRotation_=l!==void 0?l:0,this.textScale_=[this.pixelRatio_*c[0],this.pixelRatio_*c[1]]}}}const Tt=.5;function Xh(n,t,e,i,s,r,o,a,l){const c=s,h=n[0]*Tt,u=n[1]*Tt,f=_t(h,u);f.imageSmoothingEnabled=!1;const d=f.canvas,g=new Wh(f,Tt,s,null,o,a,null),_=e.length,m=Math.floor((256*256*256-1)/_),p={};for(let E=1;E<=_;++E){const S=e[E-1],I=S.getStyleFunction()||i;if(!I)continue;let M=I(S,r);if(!M)continue;Array.isArray(M)||(M=[M]);const v=(E*m).toString(16).padStart(7,"#00000");for(let R=0,Z=M.length;R0;return u&&Promise.all(l).then(()=>s(null)),Zh(n,t,e,i,r,o,a),u}function Zh(n,t,e,i,s,r,o){const a=e.getGeometryFunction()(t);if(!a)return;const l=a.simplifyTransformed(i,s);if(e.getRenderer())lo(n,l,e,t,o);else{const h=oo[l.getType()];h(n,l,e,t,o,r)}}function lo(n,t,e,i,s){if(t.getType()=="GeometryCollection"){const o=t.getGeometries();for(let a=0,l=o.length;a{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const i=this.frameState.size.slice(),s=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,c=this.getLayer(),h=[],u=i[0]*Tt,f=i[1]*Tt;h.push(this.getRenderTransform(s,r,o,Tt,u,f,0).slice());const d=c.getSource(),g=a.getExtent();if(d.getWrapX()&&a.canWrapX()&&!Se(g,l)){let _=l[0];const m=ct(g);let p=0,y;for(;_g[2];)++p,y=m*p,h.push(this.getRenderTransform(s,r,o,Tt,u,f,y).slice()),_-=m}this.hitDetectionImageData_=Xh(i,h,this.renderedFeatures_,c.getStyleFunction(),l,r,o,$s(r,this.renderedPixelRatio_))}e(Bh(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,i,s,r){if(!this.replayGroup_)return;const o=e.viewState.resolution,a=e.viewState.rotation,l=this.getLayer(),c={},h=function(g,_,m){const p=et(g),y=c[p];if(y){if(y!==!0&&mu=g.forEachFeatureAtCoordinate(t,o,a,i,h,d&&e.declutter[d]?e.declutter[d].all().map(_=>_.value):null)),u}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),i=e.getSource();if(!i)return!1;const s=t.viewHints[xt.ANIMATING],r=t.viewHints[xt.INTERACTING],o=e.getUpdateWhileAnimating(),a=e.getUpdateWhileInteracting();if(this.ready&&!o&&s||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=t.extent,c=t.viewState,h=c.projection,u=c.resolution,f=t.pixelRatio,d=e.getRevision(),g=e.getRenderBuffer();let _=e.getRenderOrder();_===void 0&&(_=Yh);const m=c.center.slice(),p=Gn(l,g*u),y=p.slice(),E=[p.slice()],S=h.getExtent();if(i.getWrapX()&&h.canWrapX()&&!Se(S,t.extent)){const N=ct(S),G=Math.max(ct(p)/2,N);p[0]=S[0]-G,p[2]=S[2]+G,La(m,h);const A=kr(E[0],h);A[0]S[0]&&A[2]>S[2]&&E.push([A[0]-N,A[1],A[2]-N,A[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==d&&this.renderedRenderOrder_==_&&this.renderedFrameDeclutter_===!!t.declutter&&Se(this.wrappedRenderedExtent_,p))return We(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=m,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const I=new Th(ao(u,f),p,u,f);let M;for(let N=0,G=E.length;N{let A;const $=N.getStyleFunction()||e.getStyleFunction();if($&&(A=$(N,u)),A){const Y=this.renderFeature(N,C,A,I,M,this.getLayer().getDeclutter(),G);v=v&&!Y}},Z=Nr(p),P=i.getFeaturesInExtent(Z);_&&P.sort(_);for(let N=0,G=P.length;N0;)this.pop()}extend(t){for(let e=0,i=t.length;ethis.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new ki(Te.ADD,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){this.unique_&&this.assertUnique_(t);const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let i=0,s=e.length;i=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new ki(Te.REMOVE,e,t)),e}setAt(t,e){const i=this.getLength();if(t>=i){this.insertAt(t,e);return}if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const s=this.array_[t];this.array_[t]=e,this.dispatchEvent(new ki(Te.REMOVE,s,t)),this.dispatchEvent(new ki(Te.ADD,e,t))}updateLength_(){this.set(Ks.LENGTH,this.array_.length)}assertUnique_(t,e){for(let i=0,s=this.array_.length;i1?o:2,r=r||new Array(o);for(let h=0;h{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const i=this.simplifiedGeometry_.getFlatCoordinates();let s;switch(this.type_){case"LineString":i.length=Vn(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),s=[i.length];break;case"MultiLineString":s=[],i.length=ll(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,s);break;case"Polygon":s=[],i.length=Yr(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,s);break}return s&&(this.simplifiedGeometry_=new Et(this.type_,i,s,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}Et.prototype.getFlatCoordinates=Et.prototype.getOrientedFlatCoordinates;class nc extends ge{constructor(t){super(),this.projection=de(t.projection),this.attributions_=ir(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible!==void 0?t.attributionsCollapsible:!0,this.loading=!1,this.state_=t.state!==void 0?t.state:"ready",this.wrapX_=t.wrapX!==void 0?t.wrapX:!1,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;const e=this;this.viewPromise_=new Promise(function(i,s){e.viewResolver=i,e.viewRejector=s})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(t){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=ir(t),this.changed()}setState(t){this.state_=t,this.changed()}}function ir(n){return n?Array.isArray(n)?function(t){return n}:typeof n=="function"?n:function(t){return[n]}:null}const yt={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function sc(n,t){return[[-1/0,-1/0,1/0,1/0]]}let rc=!1;function oc(n,t,e,i,s,r,o){const a=new XMLHttpRequest;a.open("GET",typeof n=="function"?n(e,i,s):n,!0),t.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=rc,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){const c=t.getType();try{let h;c=="text"||c=="json"?h=a.responseText:c=="xml"?h=a.responseXML||a.responseText:c=="arraybuffer"&&(h=a.response),h?r(t.readFeatures(h,{extent:e,featureProjection:s}),t.readProjection(h)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function nr(n,t){return function(e,i,s,r,o){const a=this;oc(n,t,e,i,s,function(l,c){a.addFeatures(l),r!==void 0&&r(l)},o||oi)}}class Kt extends _i{constructor(t,e,i){super(t),this.feature=e,this.features=i}}class ac extends nc{constructor(t){t=t||{},super({attributions:t.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:t.wrapX!==void 0?t.wrapX:!0}),this.on,this.once,this.un,this.loader_=oi,this.format_=t.format,this.overlaps_=t.overlaps===void 0?!0:t.overlaps,this.url_=t.url,t.loader!==void 0?this.loader_=t.loader:this.url_!==void 0&&(it(this.format_,"`format` must be set when `url` is set"),this.loader_=nr(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:sc;const e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new Qs:null,this.loadedExtentsRtree_=new Qs,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,s;Array.isArray(t.features)?s=t.features:t.features&&(i=t.features,s=i.getArray()),!e&&i===void 0&&(i=new ec(s)),s!==void 0&&this.addFeaturesInternal(s),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=et(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);const i=t.getGeometry();if(i){const s=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(s,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new Kt(yt.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof Et||(this.featureChangeKeys_[t]=[Wt(e,Ct.CHANGE,this.handleFeatureChange_,this),Wt(e,dr.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,e){let i=!0;if(e.getId()!==void 0){const s=String(e.getId());if(!(s in this.idIndex_))this.idIndex_[s]=e;else if(e instanceof Et){const r=this.idIndex_[s];r instanceof Et?Array.isArray(r)?r.push(e):this.idIndex_[s]=[r,e]:i=!1}else i=!1}return i&&(it(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],i=[],s=[];for(let r=0,o=t.length;r{e||(e=!0,this.addFeature(i.element),e=!1)}),t.addEventListener(Te.REMOVE,i=>{e||(e=!0,this.removeFeature(i.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(const i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach(ie);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){const i=s=>{this.removeFeatureInternal(s)};this.featuresRtree_.forEach(i);for(const s in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[s])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new Kt(yt.CLEAR);this.dispatchEvent(e),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,e){const i=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(i,function(s){const r=s.getGeometry();if(r instanceof Et||r.intersectsCoordinate(t))return e(s)})}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,function(i){const s=i.getGeometry();if(s instanceof Et||s.intersectsExtent(t)){const r=e(i);if(r)return r}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),Fe(this.nullGeometryFeatures_)||kn(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,function(i){e.push(i)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const s=xa(t,e);return[].concat(...s.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const i=t[0],s=t[1];let r=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return e=e||Uo,this.featuresRtree_.forEachInExtent(l,function(c){if(e(c)){const h=c.getGeometry(),u=a;if(a=h instanceof Et?0:h.closestPointXY(i,s,o,a),a{--this.loadingExtentsCount_,this.dispatchEvent(new Kt(yt.FEATURESLOADEND,void 0,h))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Kt(yt.FEATURESLOADERROR))}),s.insert(l,{extent:l.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){const e=this.loadedExtentsRtree_;let i;e.forEachInExtent(t,function(s){if(vr(s.extent,t))return i=s,!0}),i&&e.remove(i)}removeFeatures(t){const e=[];for(let i=0,s=t.length;i0&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=et(t);if(!(e in this.uidIndex_))return;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t);const i=this.featureChangeKeys_[e];i==null||i.forEach(ie),delete this.featureChangeKeys_[e];const s=t.getId();if(s!==void 0){const r=s.toString(),o=this.idIndex_[r];o===t?delete this.idIndex_[r]:Array.isArray(o)&&(o.splice(o.indexOf(t),1),o.length===1&&(this.idIndex_[r]=o[0]))}return delete this.uidIndex_[e],this.hasListener(yt.REMOVEFEATURE)&&this.dispatchEvent(new Kt(yt.REMOVEFEATURE,t)),t}removeFromIdIndex_(t){let e=!1;for(const i in this.idIndex_){const s=this.idIndex_[i];if(t instanceof Et&&Array.isArray(s)&&s.includes(t))s.splice(s.indexOf(t),1);else if(this.idIndex_[i]===t){delete this.idIndex_[i],e=!0;break}}return e}setLoader(t){this.loader_=t}setUrl(t){it(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(nr(t,this.format_))}}const ho=(n,t)=>{const e=n.__vccOpts||n;for(const[i,s]of t)e[i]=s;return e},lc={props:{settings:{type:Object,required:!0}},data(){return{opacityValue:"1",currentImageId:null,currentImage:null,cache:{}}},computed:{opacity(){return parseFloat(this.opacityValue)},shown(){return this.opacity>0}},methods:{maybeFetchLaserpoints(n){return this.shown&&!this.cache.hasOwnProperty(n)&&(this.cache[n]=Nn.get({image_id:n}).then(t=>t.data)),this.cache[n]},updateCurrentImage(n){const{id:t,image:e}=n;this.layer.getSource().clear(),this.currentImageId=t,this.currentImage=e},maybeDrawLaserpoints(n){if(n&&n.method!=="manual"&&n.points&&n.points.length>0){var t=this.currentImage.height;this.layer.getSource().addFeatures(n.points.map(function(e){return new Pn({geometry:new ji([e[0],t-e[1]])})}))}},extendMap(n){this.$nextTick(()=>n.addLayer(this.layer))}},watch:{opacity(n,t){n<1?this.settings.set("laserpointOpacity",n):this.settings.delete("laserpointOpacity"),t===0&&this.maybeFetchLaserpoints(this.currentImageId).then(this.maybeDrawLaserpoints),n===0&&this.layer.getSource().clear(),this.layer.setOpacity(n)},currentImageId(n){this.shown&&this.maybeFetchLaserpoints(n).then(this.maybeDrawLaserpoints)}},created(){this.layer=new tc({source:new ac,style:[new Yt({image:new De({radius:6,stroke:new Ge({color:"white",width:4})})}),new Yt({image:new De({radius:6,stroke:new Ge({color:"#ff0000",width:2,lineDash:[1]})})})],zIndex:3,updateWhileAnimating:!0,updateWhileInteracting:!0}),this.settings.has("laserpointOpacity")&&(this.opacityValue=this.settings.get("laserpointOpacity")),dn.on("images.fetching",this.maybeFetchLaserpoints),dn.on("images.change",this.updateCurrentImage),dn.on("annotations.map.init",this.extendMap)}},hc={class:"sidebar-tab__section"},cc=["textContent"],uc={key:1};function fc(n,t,e,i,s,r){return Me(),be("div",hc,[Pt("h5",null,[t[1]||(t[1]=Qt("Laser Points Opacity (")),r.shown?(Me(),be("span",{key:0,textContent:rr(r.opacity)},null,8,cc)):(Me(),be("span",uc,"hidden")),t[2]||(t[2]=Qt(")"))]),t[3]||(t[3]=Qt()),sr(Pt("input",{type:"range",min:"0",max:"1",step:"0.1","onUpdate:modelValue":t[0]||(t[0]=o=>s.opacityValue=o)},null,512),[[or,s.opacityValue]])])}const dc=ho(lc,[["render",fc]]);ms&&(ms.laserPoints=dc);const gc=Er("api/v1/volumes{/id}/images/filter/laserpoints");Array.isArray(ys)&&ys.push({id:"laserpoints",types:["image"],label:"detected laser points",help:"All images that (don't) contain detected laser points.",listComponent:{mixins:[oa],data(){return{name:"detected laser points"}}},getSequence(n){return gc.query({id:n})}});const _c={mixins:[xr],components:{typeahead:yr},data(){return{volumeId:null,distance:1,processing:!1,error:!1,labels:[],label:null}},computed:{submitDisabled(){return this.loading||this.processing||!this.distance||!this.label}},methods:{handleError(n){n.status===422&&n.body.errors&&n.body.errors.id?(this.error=n.body.errors.id.join(` -`),this.processing=!1):Ni(n)},setProcessing(){this.processing=!0,this.error=!1},setLabels(n){this.labels=n.body},handleSelectLabel(n){this.label=n},loadLabels(){!this.loading&&this.labels.length===0&&(this.startLoading(),wr.queryAnnotationLabels({id:this.volumeId}).then(this.setLabels).then(this.finishLoading).catch(Ni))},submit(){this.startLoading(),Nn.processVolume({volume_id:this.volumeId},{distance:this.distance,label_id:this.label.id}).then(this.setProcessing).catch(this.handleError).finally(this.finishLoading)}},created(){this.volumeId=biigle.$require("volumes.volumeId")}},mc={class:"form-group"},pc={class:"form-group"},yc={class:"form-group"},xc=["disabled"],Ec={key:0,class:"alert alert-success"},wc=["textContent"];function Ic(n,t,e,i,s,r){const o=Ro("typeahead");return Me(),be("form",{class:"form-stacked",onSubmit:t[1]||(t[1]=vo((...a)=>r.submit&&r.submit(...a),["prevent"]))},[Pt("div",mc,[t[2]||(t[2]=Pt("label",{for:"label"},"Laser point label",-1)),t[3]||(t[3]=Qt()),bo(o,{id:"label",title:"Laser point",placeholder:"Laser point label",class:"typeahead--block",items:s.labels,onSelect:r.handleSelectLabel,onFocus:r.loadLabels},null,8,["items","onSelect","onFocus"])]),t[6]||(t[6]=Qt()),Pt("div",pc,[t[4]||(t[4]=Pt("label",{for:"distance"},"Laser distance in cm",-1)),t[5]||(t[5]=Qt()),sr(Pt("input",{"onUpdate:modelValue":t[0]||(t[0]=a=>s.distance=a),id:"distance",type:"number",min:"1",step:"0.1",title:"Distance between two laser points in cm",class:"form-control",required:""},null,512),[[or,s.distance]])]),t[7]||(t[7]=Qt()),Pt("div",yc,[Pt("button",{class:"btn btn-success btn-block",title:"Compute the area of each image in this volume.",disabled:r.submitDisabled||null},"Submit",8,xc)]),t[8]||(t[8]=Qt()),s.processing?(Me(),be("div",Ec,` - The laser point detection was submitted and will be available soon. - `)):s.error?(Me(),be("div",{key:1,class:"alert alert-danger",textContent:rr(s.error)},null,8,wc)):To("",!0)],32)}const Sc=ho(_c,[["render",Ic]]);ps&&(ps.laserpointsForm=Sc);const Cc={mixins:[xr],components:{typeahead:yr},data(){return{image:null,distance:null,processing:!1,error:!1,labels:[],label:null}},computed:{submitDisabled(){return this.loading||this.processing||!this.distance||!this.label},volumeId(){return this.image.volume_id}},methods:{handleError(n){n.status===422&&n.body.errors&&n.body.errors.id?(this.error=n.body.errors.id.join(` -`),this.processing=!1):Ni(n)},setProcessing(){this.processing=!0,this.error=!1},setLabels(n){this.labels=n.body},handleSelectLabel(n){this.label=n},loadLabels(){!this.loading&&this.labels.length===0&&(this.startLoading(),wr.queryAnnotationLabels({id:this.volumeId}).then(this.setLabels).then(this.finishLoading).catch(Ni))},submit(){this.loading||(this.startLoading(),Nn.processImage({image_id:this.image.id},{distance:this.distance,label_id:this.label.id}).then(this.setProcessing).catch(this.handleError).finally(this.finishLoading))}},created(){this.image=biigle.$require("laserpoints.image"),this.distance=biigle.$require("laserpoints.distance")}};biigle.$mount("laserpoints-panel",Cc); diff --git a/src/public/assets/main-CHHIg8Df.css b/src/public/assets/main-CHHIg8Df.css new file mode 100644 index 00000000..47c078b4 --- /dev/null +++ b/src/public/assets/main-CHHIg8Df.css @@ -0,0 +1 @@ +.btn-group-justified[data-v-84d8417e]{margin-bottom:15px} diff --git a/src/public/manifest.json b/src/public/manifest.json index 7be316b1..6b0bd1ca 100644 --- a/src/public/manifest.json +++ b/src/public/manifest.json @@ -1,8 +1,11 @@ { "src/resources/assets/js/main.js": { - "file": "assets/main-BgU9hl6O.js", + "file": "assets/main-BKb7iDn1.js", "name": "main", "src": "src/resources/assets/js/main.js", - "isEntry": true + "isEntry": true, + "css": [ + "assets/main-CHHIg8Df.css" + ] } } \ No newline at end of file diff --git a/src/resources/assets/js/api/laserpoints.js b/src/resources/assets/js/api/laserpoints.js index 6a4566ca..93e9f031 100644 --- a/src/resources/assets/js/api/laserpoints.js +++ b/src/resources/assets/js/api/laserpoints.js @@ -6,21 +6,29 @@ import { Resource } from '../import.js'; * var resource = biigle.$require('api.laserpoints'); * * Perform the laser point detection on all images of a volume: - * resource.processVolume({volume_id: 1}, {distance: 50}).then(...); + * resource.processVolumeAutomatic({volume_id: 1}, {distance: 50}).then(...); * * Perform the laser point detection on a single image: - * resource.processImage({image_id: 1}, {distance: 50}).then(...); + * resource.processImageAutomatic({image_id: 1}, {distance: 50}).then(...); * * Get the laser point information for an image * resource.get({image_id: 1}).then(...); */ export default Resource('api/v1/images{/image_id}/laserpoints', {}, { - processVolume: { + processVolumeAutomatic: { method: 'POST', - url: 'api/v1/volumes{/volume_id}/laserpoints/area', + url: 'api/v1/volumes{/volume_id}/laserpoints/automatic', }, - processImage: { + processImageAutomatic: { method: 'POST', - url: 'api/v1/images{/image_id}/laserpoints/area', + url: 'api/v1/images{/image_id}/laserpoints/automatic', + }, + processVolumeManual: { + method: 'POST', + url: 'api/v1/volumes{/volume_id}/laserpoints/manual', + }, + processImageManual: { + method: 'POST', + url: 'api/v1/images{/image_id}/laserpoints/manual', }, }); diff --git a/src/resources/assets/js/components/laserpointsForm.vue b/src/resources/assets/js/components/laserpointsForm.vue index 58950db9..ef22c88f 100644 --- a/src/resources/assets/js/components/laserpointsForm.vue +++ b/src/resources/assets/js/components/laserpointsForm.vue @@ -1,13 +1,45 @@