@featurevisor/sdk 1.32.0 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/coverage/clover.xml +126 -124
- package/coverage/coverage-final.json +1 -1
- package/coverage/lcov-report/bucket.ts.html +1 -1
- package/coverage/lcov-report/conditions.ts.html +1 -1
- package/coverage/lcov-report/datafileReader.ts.html +1 -1
- package/coverage/lcov-report/emitter.ts.html +1 -1
- package/coverage/lcov-report/evaluate.ts.html +29 -8
- package/coverage/lcov-report/feature.ts.html +1 -1
- package/coverage/lcov-report/index.html +15 -15
- package/coverage/lcov-report/instance.ts.html +1 -1
- package/coverage/lcov-report/logger.ts.html +1 -1
- package/coverage/lcov-report/segments.ts.html +1 -1
- package/coverage/lcov.info +228 -225
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.gz +0 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/evaluate.ts +7 -0
package/coverage/lcov.info
CHANGED
|
@@ -363,14 +363,14 @@ TN:
|
|
|
363
363
|
SF:src/evaluate.ts
|
|
364
364
|
FN:35,(anonymous_0)
|
|
365
365
|
FN:103,evaluate
|
|
366
|
-
FN:
|
|
367
|
-
FN:
|
|
368
|
-
FN:
|
|
369
|
-
FN:
|
|
370
|
-
FN:
|
|
371
|
-
FN:
|
|
372
|
-
FN:
|
|
373
|
-
FN:
|
|
366
|
+
FN:357,(anonymous_2)
|
|
367
|
+
FN:396,(anonymous_3)
|
|
368
|
+
FN:504,(anonymous_4)
|
|
369
|
+
FN:579,(anonymous_5)
|
|
370
|
+
FN:600,(anonymous_6)
|
|
371
|
+
FN:656,(anonymous_7)
|
|
372
|
+
FN:659,(anonymous_8)
|
|
373
|
+
FN:663,(anonymous_9)
|
|
374
374
|
FNF:10
|
|
375
375
|
FNH:10
|
|
376
376
|
FNDA:1,(anonymous_0)
|
|
@@ -462,133 +462,135 @@ DA:300,24
|
|
|
462
462
|
DA:301,1
|
|
463
463
|
DA:307,1
|
|
464
464
|
DA:309,1
|
|
465
|
-
DA:
|
|
466
|
-
DA:
|
|
467
|
-
DA:
|
|
465
|
+
DA:312,23
|
|
466
|
+
DA:313,0
|
|
467
|
+
DA:321,109
|
|
468
468
|
DA:322,1
|
|
469
|
-
DA:
|
|
470
|
-
DA:
|
|
469
|
+
DA:327,1
|
|
470
|
+
DA:329,1
|
|
471
471
|
DA:332,108
|
|
472
|
-
DA:
|
|
473
|
-
DA:
|
|
474
|
-
DA:
|
|
475
|
-
DA:
|
|
476
|
-
DA:
|
|
477
|
-
DA:
|
|
478
|
-
DA:
|
|
479
|
-
DA:
|
|
480
|
-
DA:
|
|
481
|
-
DA:
|
|
482
|
-
DA:368,
|
|
483
|
-
DA:
|
|
484
|
-
DA:
|
|
485
|
-
DA:
|
|
486
|
-
DA:
|
|
487
|
-
DA:
|
|
488
|
-
DA:
|
|
489
|
-
DA:
|
|
490
|
-
DA:396,2
|
|
491
|
-
DA:397,2
|
|
472
|
+
DA:337,108
|
|
473
|
+
DA:339,108
|
|
474
|
+
DA:341,14
|
|
475
|
+
DA:342,9
|
|
476
|
+
DA:350,9
|
|
477
|
+
DA:352,9
|
|
478
|
+
DA:356,5
|
|
479
|
+
DA:357,1
|
|
480
|
+
DA:359,1
|
|
481
|
+
DA:360,1
|
|
482
|
+
DA:368,1
|
|
483
|
+
DA:370,1
|
|
484
|
+
DA:375,4
|
|
485
|
+
DA:376,1
|
|
486
|
+
DA:386,1
|
|
487
|
+
DA:388,1
|
|
488
|
+
DA:395,97
|
|
489
|
+
DA:396,4
|
|
492
490
|
DA:400,4
|
|
493
|
-
DA:
|
|
494
|
-
DA:
|
|
495
|
-
DA:
|
|
496
|
-
DA:
|
|
497
|
-
DA:420,
|
|
498
|
-
DA:
|
|
499
|
-
DA:
|
|
500
|
-
DA:
|
|
501
|
-
DA:
|
|
502
|
-
DA:
|
|
503
|
-
DA:
|
|
504
|
-
DA:
|
|
491
|
+
DA:401,2
|
|
492
|
+
DA:403,2
|
|
493
|
+
DA:404,2
|
|
494
|
+
DA:407,4
|
|
495
|
+
DA:420,4
|
|
496
|
+
DA:422,4
|
|
497
|
+
DA:423,1
|
|
498
|
+
DA:426,3
|
|
499
|
+
DA:427,2
|
|
500
|
+
DA:443,2
|
|
501
|
+
DA:444,0
|
|
502
|
+
DA:445,2
|
|
503
|
+
DA:446,2
|
|
505
504
|
DA:449,2
|
|
505
|
+
DA:452,1
|
|
506
|
+
DA:455,4
|
|
506
507
|
DA:456,2
|
|
507
|
-
DA:
|
|
508
|
-
DA:465,
|
|
509
|
-
DA:
|
|
510
|
-
DA:
|
|
511
|
-
DA:
|
|
512
|
-
DA:
|
|
513
|
-
DA:
|
|
514
|
-
DA:
|
|
515
|
-
DA:
|
|
516
|
-
DA:
|
|
517
|
-
DA:
|
|
518
|
-
DA:
|
|
519
|
-
DA:
|
|
520
|
-
DA:
|
|
521
|
-
DA:
|
|
522
|
-
DA:
|
|
523
|
-
DA:
|
|
524
|
-
DA:
|
|
525
|
-
DA:530,1
|
|
526
|
-
DA:534,49
|
|
508
|
+
DA:463,2
|
|
509
|
+
DA:465,2
|
|
510
|
+
DA:472,95
|
|
511
|
+
DA:484,95
|
|
512
|
+
DA:485,39
|
|
513
|
+
DA:493,39
|
|
514
|
+
DA:494,39
|
|
515
|
+
DA:496,56
|
|
516
|
+
DA:499,95
|
|
517
|
+
DA:501,90
|
|
518
|
+
DA:503,51
|
|
519
|
+
DA:504,2
|
|
520
|
+
DA:505,2
|
|
521
|
+
DA:509,2
|
|
522
|
+
DA:510,1
|
|
523
|
+
DA:521,1
|
|
524
|
+
DA:523,1
|
|
525
|
+
DA:527,1
|
|
527
526
|
DA:535,1
|
|
528
|
-
DA:
|
|
529
|
-
DA:
|
|
530
|
-
DA:
|
|
531
|
-
DA:552,
|
|
532
|
-
DA:
|
|
533
|
-
DA:
|
|
534
|
-
DA:
|
|
535
|
-
DA:
|
|
536
|
-
DA:
|
|
537
|
-
DA:
|
|
538
|
-
DA:
|
|
539
|
-
DA:
|
|
540
|
-
DA:
|
|
541
|
-
DA:
|
|
542
|
-
DA:
|
|
543
|
-
DA:
|
|
544
|
-
DA:
|
|
545
|
-
DA:
|
|
546
|
-
DA:
|
|
547
|
-
DA:
|
|
548
|
-
DA:
|
|
549
|
-
DA:
|
|
550
|
-
DA:
|
|
551
|
-
DA:
|
|
552
|
-
DA:
|
|
553
|
-
DA:
|
|
554
|
-
DA:
|
|
555
|
-
DA:
|
|
556
|
-
DA:
|
|
557
|
-
DA:
|
|
558
|
-
DA:
|
|
559
|
-
DA:
|
|
560
|
-
DA:
|
|
561
|
-
DA:
|
|
562
|
-
DA:
|
|
563
|
-
DA:
|
|
564
|
-
DA:
|
|
565
|
-
DA:
|
|
566
|
-
DA:
|
|
567
|
-
DA:
|
|
568
|
-
DA:
|
|
569
|
-
DA:
|
|
570
|
-
DA:
|
|
571
|
-
DA:
|
|
572
|
-
DA:
|
|
573
|
-
DA:697,
|
|
574
|
-
DA:
|
|
575
|
-
DA:
|
|
576
|
-
DA:
|
|
577
|
-
DA:
|
|
527
|
+
DA:537,1
|
|
528
|
+
DA:541,49
|
|
529
|
+
DA:542,1
|
|
530
|
+
DA:552,1
|
|
531
|
+
DA:554,1
|
|
532
|
+
DA:558,48
|
|
533
|
+
DA:559,48
|
|
534
|
+
DA:569,48
|
|
535
|
+
DA:571,48
|
|
536
|
+
DA:576,39
|
|
537
|
+
DA:578,17
|
|
538
|
+
DA:579,1
|
|
539
|
+
DA:581,1
|
|
540
|
+
DA:582,1
|
|
541
|
+
DA:592,1
|
|
542
|
+
DA:594,1
|
|
543
|
+
DA:599,16
|
|
544
|
+
DA:600,23
|
|
545
|
+
DA:602,16
|
|
546
|
+
DA:603,16
|
|
547
|
+
DA:613,16
|
|
548
|
+
DA:615,16
|
|
549
|
+
DA:622,27
|
|
550
|
+
DA:624,22
|
|
551
|
+
DA:629,2
|
|
552
|
+
DA:641,2
|
|
553
|
+
DA:643,2
|
|
554
|
+
DA:649,20
|
|
555
|
+
DA:650,3
|
|
556
|
+
DA:651,17
|
|
557
|
+
DA:652,16
|
|
558
|
+
DA:655,20
|
|
559
|
+
DA:656,38
|
|
560
|
+
DA:658,19
|
|
561
|
+
DA:659,34
|
|
562
|
+
DA:661,19
|
|
563
|
+
DA:662,7
|
|
564
|
+
DA:663,7
|
|
565
|
+
DA:664,12
|
|
566
|
+
DA:665,5
|
|
567
|
+
DA:672,7
|
|
568
|
+
DA:673,7
|
|
569
|
+
DA:681,0
|
|
570
|
+
DA:684,7
|
|
571
|
+
DA:685,4
|
|
572
|
+
DA:697,4
|
|
573
|
+
DA:699,4
|
|
574
|
+
DA:703,3
|
|
575
|
+
DA:704,3
|
|
576
|
+
DA:716,3
|
|
577
|
+
DA:718,3
|
|
578
|
+
DA:728,18
|
|
578
579
|
DA:729,0
|
|
579
|
-
DA:
|
|
580
|
-
DA:
|
|
581
|
-
DA:
|
|
582
|
-
DA:
|
|
583
|
-
DA:
|
|
584
|
-
DA:
|
|
585
|
-
DA:
|
|
586
|
-
DA:
|
|
587
|
-
DA:
|
|
588
|
-
DA:
|
|
589
|
-
DA:
|
|
590
|
-
|
|
591
|
-
|
|
580
|
+
DA:736,0
|
|
581
|
+
DA:738,0
|
|
582
|
+
DA:741,18
|
|
583
|
+
DA:742,13
|
|
584
|
+
DA:752,13
|
|
585
|
+
DA:754,13
|
|
586
|
+
DA:757,5
|
|
587
|
+
DA:765,5
|
|
588
|
+
DA:767,5
|
|
589
|
+
DA:769,0
|
|
590
|
+
DA:775,0
|
|
591
|
+
DA:777,0
|
|
592
|
+
LF:206
|
|
593
|
+
LH:197
|
|
592
594
|
BRDA:35,0,0,1
|
|
593
595
|
BRDA:35,0,1,1
|
|
594
596
|
BRDA:122,1,0,130
|
|
@@ -631,103 +633,104 @@ BRDA:295,27,0,23
|
|
|
631
633
|
BRDA:295,28,0,24
|
|
632
634
|
BRDA:295,28,1,24
|
|
633
635
|
BRDA:300,29,0,1
|
|
634
|
-
BRDA:
|
|
635
|
-
BRDA:
|
|
636
|
-
BRDA:
|
|
637
|
-
BRDA:
|
|
638
|
-
BRDA:
|
|
639
|
-
BRDA:
|
|
640
|
-
BRDA:332,33,
|
|
641
|
-
BRDA:
|
|
642
|
-
BRDA:
|
|
643
|
-
BRDA:
|
|
644
|
-
BRDA:
|
|
645
|
-
BRDA:
|
|
646
|
-
BRDA:
|
|
647
|
-
BRDA:
|
|
648
|
-
BRDA:
|
|
649
|
-
BRDA:
|
|
650
|
-
BRDA:
|
|
651
|
-
BRDA:
|
|
652
|
-
BRDA:
|
|
653
|
-
BRDA:
|
|
654
|
-
BRDA:
|
|
655
|
-
BRDA:
|
|
656
|
-
BRDA:
|
|
657
|
-
BRDA:
|
|
658
|
-
BRDA:
|
|
659
|
-
BRDA:
|
|
660
|
-
BRDA:
|
|
661
|
-
BRDA:
|
|
662
|
-
BRDA:
|
|
663
|
-
BRDA:
|
|
664
|
-
BRDA:
|
|
665
|
-
BRDA:
|
|
666
|
-
BRDA:
|
|
667
|
-
BRDA:
|
|
668
|
-
BRDA:
|
|
669
|
-
BRDA:
|
|
670
|
-
BRDA:
|
|
671
|
-
BRDA:
|
|
672
|
-
BRDA:
|
|
673
|
-
BRDA:
|
|
674
|
-
BRDA:
|
|
675
|
-
BRDA:
|
|
676
|
-
BRDA:
|
|
677
|
-
BRDA:
|
|
678
|
-
BRDA:
|
|
679
|
-
BRDA:
|
|
680
|
-
BRDA:
|
|
681
|
-
BRDA:
|
|
682
|
-
BRDA:
|
|
683
|
-
BRDA:
|
|
684
|
-
BRDA:
|
|
685
|
-
BRDA:
|
|
686
|
-
BRDA:
|
|
687
|
-
BRDA:
|
|
688
|
-
BRDA:
|
|
689
|
-
BRDA:
|
|
690
|
-
BRDA:
|
|
691
|
-
BRDA:
|
|
692
|
-
BRDA:
|
|
693
|
-
BRDA:
|
|
694
|
-
BRDA:
|
|
695
|
-
BRDA:
|
|
696
|
-
BRDA:
|
|
697
|
-
BRDA:
|
|
698
|
-
BRDA:
|
|
699
|
-
BRDA:
|
|
700
|
-
BRDA:
|
|
701
|
-
BRDA:
|
|
702
|
-
BRDA:
|
|
703
|
-
BRDA:
|
|
704
|
-
BRDA:
|
|
705
|
-
BRDA:
|
|
706
|
-
BRDA:
|
|
707
|
-
BRDA:
|
|
708
|
-
BRDA:
|
|
709
|
-
BRDA:
|
|
710
|
-
BRDA:
|
|
711
|
-
BRDA:
|
|
712
|
-
BRDA:
|
|
713
|
-
BRDA:
|
|
714
|
-
BRDA:
|
|
715
|
-
BRDA:
|
|
716
|
-
BRDA:
|
|
717
|
-
BRDA:
|
|
718
|
-
BRDA:
|
|
719
|
-
BRDA:
|
|
720
|
-
BRDA:
|
|
721
|
-
BRDA:
|
|
722
|
-
BRDA:
|
|
723
|
-
BRDA:
|
|
724
|
-
BRDA:
|
|
725
|
-
BRDA:
|
|
726
|
-
BRDA:
|
|
727
|
-
BRDA:
|
|
728
|
-
BRDA:
|
|
729
|
-
BRDA:
|
|
730
|
-
|
|
636
|
+
BRDA:312,30,0,0
|
|
637
|
+
BRDA:321,31,0,1
|
|
638
|
+
BRDA:321,32,0,109
|
|
639
|
+
BRDA:321,32,1,19
|
|
640
|
+
BRDA:321,32,2,18
|
|
641
|
+
BRDA:332,33,0,1
|
|
642
|
+
BRDA:332,33,1,107
|
|
643
|
+
BRDA:339,34,0,14
|
|
644
|
+
BRDA:341,35,0,9
|
|
645
|
+
BRDA:341,36,0,14
|
|
646
|
+
BRDA:341,36,1,9
|
|
647
|
+
BRDA:356,37,0,1
|
|
648
|
+
BRDA:356,38,0,5
|
|
649
|
+
BRDA:356,38,1,1
|
|
650
|
+
BRDA:356,38,2,1
|
|
651
|
+
BRDA:359,39,0,1
|
|
652
|
+
BRDA:375,40,0,1
|
|
653
|
+
BRDA:375,41,0,4
|
|
654
|
+
BRDA:375,41,1,4
|
|
655
|
+
BRDA:375,41,2,1
|
|
656
|
+
BRDA:395,42,0,4
|
|
657
|
+
BRDA:395,43,0,97
|
|
658
|
+
BRDA:395,43,1,58
|
|
659
|
+
BRDA:395,43,2,4
|
|
660
|
+
BRDA:400,44,0,2
|
|
661
|
+
BRDA:400,44,1,2
|
|
662
|
+
BRDA:422,45,0,1
|
|
663
|
+
BRDA:426,46,0,2
|
|
664
|
+
BRDA:443,47,0,0
|
|
665
|
+
BRDA:443,47,1,2
|
|
666
|
+
BRDA:445,48,0,2
|
|
667
|
+
BRDA:455,49,0,2
|
|
668
|
+
BRDA:484,50,0,39
|
|
669
|
+
BRDA:484,50,1,56
|
|
670
|
+
BRDA:499,51,0,90
|
|
671
|
+
BRDA:501,52,0,51
|
|
672
|
+
BRDA:503,53,0,2
|
|
673
|
+
BRDA:503,54,0,51
|
|
674
|
+
BRDA:503,54,1,2
|
|
675
|
+
BRDA:505,55,0,2
|
|
676
|
+
BRDA:505,55,1,2
|
|
677
|
+
BRDA:509,56,0,1
|
|
678
|
+
BRDA:518,57,0,1
|
|
679
|
+
BRDA:518,57,1,0
|
|
680
|
+
BRDA:541,58,0,1
|
|
681
|
+
BRDA:558,59,0,48
|
|
682
|
+
BRDA:576,60,0,17
|
|
683
|
+
BRDA:576,61,0,39
|
|
684
|
+
BRDA:576,61,1,17
|
|
685
|
+
BRDA:578,62,0,1
|
|
686
|
+
BRDA:581,63,0,1
|
|
687
|
+
BRDA:599,64,0,16
|
|
688
|
+
BRDA:599,65,0,16
|
|
689
|
+
BRDA:599,65,1,16
|
|
690
|
+
BRDA:602,66,0,16
|
|
691
|
+
BRDA:622,67,0,22
|
|
692
|
+
BRDA:622,68,0,27
|
|
693
|
+
BRDA:622,68,1,22
|
|
694
|
+
BRDA:624,69,0,2
|
|
695
|
+
BRDA:625,70,0,22
|
|
696
|
+
BRDA:625,70,1,22
|
|
697
|
+
BRDA:625,70,2,3
|
|
698
|
+
BRDA:649,71,0,3
|
|
699
|
+
BRDA:649,71,1,17
|
|
700
|
+
BRDA:649,72,0,20
|
|
701
|
+
BRDA:649,72,1,3
|
|
702
|
+
BRDA:651,73,0,16
|
|
703
|
+
BRDA:651,74,0,17
|
|
704
|
+
BRDA:651,74,1,16
|
|
705
|
+
BRDA:655,75,0,19
|
|
706
|
+
BRDA:655,76,0,20
|
|
707
|
+
BRDA:655,76,1,19
|
|
708
|
+
BRDA:658,77,0,19
|
|
709
|
+
BRDA:658,78,0,19
|
|
710
|
+
BRDA:658,78,1,19
|
|
711
|
+
BRDA:661,79,0,7
|
|
712
|
+
BRDA:662,80,0,7
|
|
713
|
+
BRDA:664,81,0,5
|
|
714
|
+
BRDA:666,82,0,0
|
|
715
|
+
BRDA:666,82,1,5
|
|
716
|
+
BRDA:672,83,0,7
|
|
717
|
+
BRDA:684,84,0,4
|
|
718
|
+
BRDA:690,85,0,0
|
|
719
|
+
BRDA:690,85,1,4
|
|
720
|
+
BRDA:690,86,0,4
|
|
721
|
+
BRDA:690,86,1,4
|
|
722
|
+
BRDA:703,87,0,3
|
|
723
|
+
BRDA:709,88,0,0
|
|
724
|
+
BRDA:709,88,1,3
|
|
725
|
+
BRDA:709,89,0,3
|
|
726
|
+
BRDA:709,89,1,3
|
|
727
|
+
BRDA:728,90,0,0
|
|
728
|
+
BRDA:741,91,0,13
|
|
729
|
+
BRDA:741,92,0,18
|
|
730
|
+
BRDA:741,92,1,13
|
|
731
|
+
BRDA:770,93,0,0
|
|
732
|
+
BRDA:770,93,1,0
|
|
733
|
+
BRF:139
|
|
731
734
|
BRH:128
|
|
732
735
|
end_of_record
|
|
733
736
|
TN:
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FeaturevisorSDK=t():e.FeaturevisorSDK=t()}(this,(()=>(()=>{var e={393:(e,t,r)=>{"use strict";r.r(t),r.d(t,{compare:()=>n,compareVersions:()=>i,satisfies:()=>o,validate:()=>a});const i=(e,t)=>{const r=u(e),i=u(t),a=r.pop(),n=i.pop(),o=d(r,i);return 0!==o?o:a&&n?d(a.split("."),n.split(".")):a||n?a?-1:1:0},a=e=>"string"==typeof e&&/^[v\d]/.test(e)&&s.test(e),n=(e,t,r)=>{g(r);const a=i(e,t);return v[r].includes(a)},o=(e,t)=>{if(t.includes("||"))return t.split("||").some((t=>o(e,t)));if(t.includes(" "))return t.trim().replace(/\s{2,}/g," ").split(" ").every((t=>o(e,t)));const r=t.match(/^([<>=~^]+)/),i=r?r[1]:"=";if("^"!==i&&"~"!==i)return n(e,t,i);const[a,s,f,,c]=u(e),[l,v,y,,g]=u(t),h=[a,s,f],b=[l,null!=v?v:"x",null!=y?y:"x"];if(g){if(!c)return!1;if(0!==d(h,b))return!1;if(-1===d(c.split("."),g.split(".")))return!1}const p=b.findIndex((e=>"0"!==e))+1,k="~"===i?2:p>1?p:1;return 0===d(h.slice(0,k),b.slice(0,k))&&-1!==d(h.slice(k),b.slice(k))},s=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,u=e=>{if("string"!=typeof e)throw new TypeError("Invalid argument expected string");const t=e.match(s);if(!t)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},f=e=>"*"===e||"x"===e||"X"===e,c=e=>{const t=parseInt(e,10);return isNaN(t)?e:t},l=(e,t)=>{if(f(e)||f(t))return 0;const[r,i]=((e,t)=>typeof e!=typeof t?[String(e),String(t)]:[e,t])(c(e),c(t));return r>i?1:r<i?-1:0},d=(e,t)=>{for(let r=0;r<Math.max(e.length,t.length);r++){const i=l(e[r]||"0",t[r]||"0");if(0!==i)return i}return 0},v={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1]},y=Object.keys(v),g=e=>{if("string"!=typeof e)throw new TypeError("Invalid operator type, expected string but got "+typeof e);if(-1===y.indexOf(e))throw new Error(`Invalid operator, expected one of ${y.join("|")}`)}},784:e=>{!function(){const t=e=>(new TextEncoder).encode(e);function r(e,r){let i,a,n,o,s,u,f,c;for("string"==typeof e&&(e=t(e)),i=3&e.length,a=e.length-i,n=r,s=3432918353,u=461845907,c=0;c<a;)f=255&e[c]|(255&e[++c])<<8|(255&e[++c])<<16|(255&e[++c])<<24,++c,f=(65535&f)*s+(((f>>>16)*s&65535)<<16)&4294967295,f=f<<15|f>>>17,f=(65535&f)*u+(((f>>>16)*u&65535)<<16)&4294967295,n^=f,n=n<<13|n>>>19,o=5*(65535&n)+((5*(n>>>16)&65535)<<16)&4294967295,n=27492+(65535&o)+((58964+(o>>>16)&65535)<<16);switch(f=0,i){case 3:f^=(255&e[c+2])<<16;case 2:f^=(255&e[c+1])<<8;case 1:f^=255&e[c],f=(65535&f)*s+(((f>>>16)*s&65535)<<16)&4294967295,f=f<<15|f>>>17,f=(65535&f)*u+(((f>>>16)*u&65535)<<16)&4294967295,n^=f}return n^=e.length,n^=n>>>16,n=2246822507*(65535&n)+((2246822507*(n>>>16)&65535)<<16)&4294967295,n^=n>>>13,n=3266489909*(65535&n)+((3266489909*(n>>>16)&65535)<<16)&4294967295,n^=n>>>16,n>>>0}const i=r;i.v2=function(e,r){"string"==typeof e&&(e=t(e));let i,a=e.length,n=r^a,o=0;for(;a>=4;)i=255&e[o]|(255&e[++o])<<8|(255&e[++o])<<16|(255&e[++o])<<24,i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16),i^=i>>>24,i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^i,a-=4,++o;switch(a){case 3:n^=(255&e[o+2])<<16;case 2:n^=(255&e[o+1])<<8;case 1:n^=255&e[o],n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)}return n^=n>>>13,n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16),n^=n>>>15,n>>>0},i.v3=r,e.exports=i}()},906:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_BUCKETED_NUMBER=void 0,t.getBucketedNumber=o,t.getBucketKey=s,t.getBucket=function(e){var t=e.feature,r=e.context,i=e.logger,a=e.bucketKeySeparator,n=e.configureBucketKey,u=e.configureBucketValue,f=s({feature:t,context:r,logger:i,bucketKeySeparator:a,configureBucketKey:n}),c=o(f);return u?{bucketKey:f,bucketValue:u(t,r,c)}:{bucketKey:f,bucketValue:c}};var i=r(784),a=1,n=Math.pow(2,32);function o(e){var r=i.v3(e,a)/n;return Math.floor(r*t.MAX_BUCKETED_NUMBER)}function s(e){var t,r,i=e.feature,a=e.context,n=e.logger,o=e.bucketKeySeparator,s=void 0===o?".":o,u=e.configureBucketKey,f=i.key;if("string"==typeof i.bucketBy)t="plain",r=[i.bucketBy];else if(Array.isArray(i.bucketBy))t="and",r=i.bucketBy;else{if("object"!=typeof i.bucketBy||!Array.isArray(i.bucketBy.or))throw n.error("invalid bucketBy",{featureKey:f,bucketBy:i.bucketBy}),new Error("invalid bucketBy");t="or",r=i.bucketBy.or}var c=[];r.forEach((function(e){var r=a[e];void 0!==r&&("plain"===t||"and"===t||0===c.length)&&c.push(r)})),c.push(f);var l=c.join(s);return u?u(i,a,l):l}t.MAX_BUCKETED_NUMBER=1e5},186:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.conditionIsMatched=a,t.allConditionsAreMatched=function e(t,r,i){if("attribute"in t)try{return a(t,r)}catch(e){return i.warn(e.message,{error:e,details:{condition:t,context:r}}),!1}return"and"in t&&Array.isArray(t.and)?t.and.every((function(t){return e(t,r,i)})):"or"in t&&Array.isArray(t.or)?t.or.some((function(t){return e(t,r,i)})):"not"in t&&Array.isArray(t.not)?t.not.every((function(){return!1===e({and:t.not},r,i)})):!!Array.isArray(t)&&t.every((function(t){return e(t,r,i)}))};var i=r(393);function a(e,t){var r=e.attribute,a=e.operator,n=e.value;if("equals"===a)return t[r]===n;if("notEquals"===a)return t[r]!==n;if("before"===a||"after"===a){var o=(u=t[r])instanceof Date?u:new Date(u),s=n instanceof Date?n:new Date(n);return"before"===a?o<s:o>s}if(!Array.isArray(n)||-1===["string","number"].indexOf(typeof t[r])&&null!==t[r]){if("string"==typeof t[r]&&"string"==typeof n){if(u=t[r],"contains"===a)return-1!==u.indexOf(n);if("notContains"===a)return-1===u.indexOf(n);if("startsWith"===a)return u.startsWith(n);if("endsWith"===a)return u.endsWith(n);if("semverEquals"===a)return 0===(0,i.compareVersions)(u,n);if("semverNotEquals"===a)return 0!==(0,i.compareVersions)(u,n);if("semverGreaterThan"===a)return 1===(0,i.compareVersions)(u,n);if("semverGreaterThanOrEquals"===a)return(0,i.compareVersions)(u,n)>=0;if("semverLessThan"===a)return-1===(0,i.compareVersions)(u,n);if("semverLessThanOrEquals"===a)return(0,i.compareVersions)(u,n)<=0}else if("number"==typeof t[r]&&"number"==typeof n){if(u=t[r],"greaterThan"===a)return u>n;if("greaterThanOrEquals"===a)return u>=n;if("lessThan"===a)return u<n;if("lessThanOrEquals"===a)return u<=n}}else{var u=t[r];if("in"===a)return-1!==n.indexOf(u);if("notIn"===a)return-1===n.indexOf(u)}return!1}},649:(e,t)=>{"use strict";function r(e,t){if("string"==typeof e[t]&&"*"!==e[t])try{e[t]=JSON.parse(e[t])}catch(e){console.error("Error parsing JSON",e)}return e}Object.defineProperty(t,"__esModule",{value:!0}),t.DatafileReader=void 0,t.parseJsonConditionsIfStringified=r;var i=function(){function e(e){var t=this;if(this.schemaVersion=e.schemaVersion,this.revision=e.revision,"2"===this.schemaVersion){var r=e;this.attributes=r.attributes,this.segments=r.segments,this.features=r.features}else{var i=e;this.attributes={},i.attributes.forEach((function(e){t.attributes[e.key]=e})),this.segments={},i.segments.forEach((function(e){t.segments[e.key]=e})),this.features={},i.features.forEach((function(e){Array.isArray(e.variablesSchema)&&(e.variablesSchema=e.variablesSchema.reduce((function(e,t){return e[t.key]=t,e}),{})),t.features[e.key]=e}))}}return e.prototype.getRevision=function(){return this.revision},e.prototype.getSchemaVersion=function(){return this.schemaVersion},e.prototype.getAllAttributes=function(){var e=this,t=[];return Object.keys(this.attributes).forEach((function(r){t.push(e.attributes[r])})),t},e.prototype.getAttribute=function(e){return this.attributes[e]},e.prototype.getSegment=function(e){var t=this.segments[e];if(t)return r(t,"conditions")},e.prototype.getFeature=function(e){return this.features[e]},e}();t.DatafileReader=i},40:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=void 0;var r=function(){function e(){this._listeners={}}return e.prototype.addListener=function(e,t){void 0===this._listeners[e]&&(this._listeners[e]=[]),this._listeners[e].push(t)},e.prototype.removeListener=function(e,t){if(void 0!==this._listeners[e]){var r=this._listeners[e].indexOf(t);-1!==r&&this._listeners[e].splice(r,1)}},e.prototype.removeAllListeners=function(e){var t=this;e?this._listeners[e]=[]:Object.keys(this._listeners).forEach((function(e){t._listeners[e]=[]}))},e.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];void 0!==this._listeners[e]&&this._listeners[e].forEach((function(e){e.apply(void 0,t)}))},e}();t.Emitter=r},335:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EvaluationReason=void 0,t.evaluate=function e(t){var r,u=t.type,f=t.featureKey,c=t.variableKey,l=t.context,d=t.logger,v=t.datafileReader,y=t.statuses,g=t.stickyFeatures,h=t.initialFeatures,b=t.interceptContext,p=t.bucketKeySeparator,k=t.configureBucketKey,m=t.configureBucketValue;try{var K="string"==typeof f?f:f.key;if("flag"!==u&&!1===e({type:"flag",featureKey:K,context:l,logger:d,datafileReader:v,statuses:y,stickyFeatures:g,initialFeatures:h,bucketKeySeparator:p,configureBucketKey:k,configureBucketValue:m}).enabled)return r={featureKey:K,reason:i.DISABLED},d.debug("feature is disabled",r),r;if(g&&g[K]){if("flag"===u&&void 0!==g[K].enabled)return r={featureKey:K,reason:i.STICKY,sticky:g[K],enabled:g[K].enabled},d.debug("using sticky enabled",r),r;if("variation"===u&&void 0!==(A=g[K].variation))return r={featureKey:K,reason:i.STICKY,variationValue:A},d.debug("using sticky variation",r),r;if(c&&(O=g[K].variables)){var V=O[c];if(void 0!==V)return r={featureKey:K,reason:i.STICKY,variableKey:c,variableValue:V},d.debug("using sticky variable",r),r}}if(y&&!y.ready&&h&&h[K]){if("flag"===u&&void 0!==h[K].enabled)return r={featureKey:K,reason:i.INITIAL,initial:h[K],enabled:h[K].enabled},d.debug("using initial enabled",r),r;if("variation"===u&&void 0!==h[K].variation){var A=h[K].variation;return r={featureKey:K,reason:i.INITIAL,variationValue:A},d.debug("using initial variation",r),r}var O;if(c&&(O=h[K].variables)&&void 0!==O[c])return r={featureKey:K,reason:i.INITIAL,variableKey:c,variableValue:O[c]},d.debug("using initial variable",r),r}var E="string"==typeof f?v.getFeature(f):f;if(!E)return r={featureKey:K,reason:i.NOT_FOUND},d.warn("feature not found",r),r;"flag"===u&&E.deprecated&&d.warn("feature is deprecated",{featureKey:E.key});var S=void 0;if(c&&(E.variablesSchema&&E.variablesSchema[c]&&(S=E.variablesSchema[c]),!S))return r={featureKey:K,reason:i.NOT_FOUND,variableKey:c},d.warn("variable schema not found",r),r;if("variation"===u&&(!E.variations||0===E.variations.length))return r={featureKey:K,reason:i.NO_VARIATIONS},d.warn("no variations",r),r;var x=b?b(l):l,I=(0,n.findForceFromFeature)(E,l,v,d),R=I.force,_=I.forceIndex;if(R){if("flag"===u&&void 0!==R.enabled)return r={featureKey:E.key,reason:i.FORCED,forceIndex:_,force:R,enabled:R.enabled},d.debug("forced enabled found",r),r;if("variation"===u&&R.variation&&E.variations&&(C=E.variations.find((function(e){return e.value===R.variation}))))return r={featureKey:E.key,reason:i.FORCED,forceIndex:_,force:R,variation:C},d.debug("forced variation found",r),r;if(c&&R.variables&&void 0!==R.variables[c])return r={featureKey:E.key,reason:i.FORCED,forceIndex:_,force:R,variableKey:c,variableSchema:S,variableValue:R.variables[c]},d.debug("forced variable",r),r}if("flag"===u&&E.required&&E.required.length>0){var F=E.required.every((function(t){var r,i;if("string"==typeof t?r=t:(r=t.key,i=t.variation),!e({type:"flag",featureKey:r,context:x,logger:d,datafileReader:v,statuses:y,stickyFeatures:g,initialFeatures:h,bucketKeySeparator:p,configureBucketKey:k,configureBucketValue:m}).enabled)return!1;if(void 0!==i){var a=e({type:"variation",featureKey:r,context:x,logger:d,datafileReader:v,statuses:y,stickyFeatures:g,initialFeatures:h,bucketKeySeparator:p,configureBucketKey:k,configureBucketValue:m}),n=void 0;return a.variationValue?n=a.variationValue:a.variation&&(n=a.variation.value),n===i}return!0}));if(!F)return r={featureKey:E.key,reason:i.REQUIRED,required:E.required,enabled:F},d.debug("required features not enabled",r),r}var B,L,T=(0,a.getBucket)({feature:E,context:x,logger:d,bucketKeySeparator:p,configureBucketKey:k,configureBucketValue:m}),D=T.bucketKey,w=T.bucketValue;if("flag"!==u){var M=(0,n.getMatchedTrafficAndAllocation)(E.traffic,x,w,v,d);B=M.matchedTraffic,L=M.matchedAllocation}else B=(0,n.getMatchedTraffic)(E.traffic,x,v,d);if(B){if("flag"===u){if(E.ranges&&E.ranges.length>0)return E.ranges.find((function(e){return w>=e[0]&&w<e[1]}))?(r={featureKey:E.key,reason:i.ALLOCATED,bucketKey:D,bucketValue:w,ruleKey:B.key,traffic:B,enabled:void 0===B.enabled||B.enabled},d.debug("matched",r),r):(r={featureKey:E.key,reason:i.OUT_OF_RANGE,bucketKey:D,bucketValue:w,enabled:!1},d.debug("not matched",r),r);if(void 0!==B.enabled)return r={featureKey:E.key,reason:i.OVERRIDE,bucketKey:D,bucketValue:w,ruleKey:B.key,traffic:B,enabled:B.enabled},d.debug("override from rule",r),r;if(w<=B.percentage)return r={featureKey:E.key,reason:i.RULE,bucketKey:D,bucketValue:w,ruleKey:B.key,traffic:B,enabled:!0},d.debug("matched traffic",r),r}if("variation"===u&&E.variations){if(B.variation&&(C=E.variations.find((function(e){return e.value===B.variation}))))return r={featureKey:E.key,reason:i.RULE,bucketKey:D,bucketValue:w,ruleKey:B.key,traffic:B,variation:C},d.debug("override from rule",r),r;if(L&&L.variation&&(C=E.variations.find((function(e){return e.value===L.variation}))))return r={featureKey:E.key,reason:i.ALLOCATED,bucketKey:D,bucketValue:w,ruleKey:B.key,traffic:B,variation:C},d.debug("allocated variation",r),r}}if("variable"===u&&c){if(B&&B.variables&&void 0!==B.variables[c])return r={featureKey:E.key,reason:i.RULE,bucketKey:D,bucketValue:w,ruleKey:B.key,traffic:B,variableKey:c,variableSchema:S,variableValue:B.variables[c]},d.debug("override from rule",r),r;var j,C;if(R&&R.variation?j=R.variation:L&&L.variation&&(j=L.variation),j&&Array.isArray(E.variations)&&(C=E.variations.find((function(e){return e.value===j})))&&C.variables){var N=C.variables.find((function(e){return e.key===c}));if(N){if(N.overrides){var U=N.overrides.find((function(e){return e.conditions?(0,o.allConditionsAreMatched)("string"==typeof e.conditions?JSON.parse(e.conditions):e.conditions,x,d):!!e.segments&&(0,s.allGroupSegmentsAreMatched)((0,n.parseFromStringifiedSegments)(e.segments),x,v,d)}));if(U)return r={featureKey:E.key,reason:i.OVERRIDE,bucketKey:D,bucketValue:w,ruleKey:null==B?void 0:B.key,traffic:B,variableKey:c,variableSchema:S,variableValue:U.value},d.debug("variable override",r),r}if(void 0!==N.value)return r={featureKey:E.key,reason:i.ALLOCATED,bucketKey:D,bucketValue:w,ruleKey:null==B?void 0:B.key,traffic:B,variableKey:c,variableSchema:S,variableValue:N.value},d.debug("allocated variable",r),r}}}return"variation"===u?(r={featureKey:E.key,reason:i.NO_MATCH,bucketKey:D,bucketValue:w},d.debug("no matched variation",r),r):"variable"===u&&S?(r={featureKey:E.key,reason:i.DEFAULTED,bucketKey:D,bucketValue:w,variableKey:c,variableSchema:S,variableValue:S.defaultValue},d.debug("using default value",r),r):(r={featureKey:E.key,reason:i.NO_MATCH,bucketKey:D,bucketValue:w,enabled:!1},d.debug("nothing matched",r),r)}catch(e){return r={featureKey:"string"==typeof f?f:f.key,reason:i.ERROR,error:e},d.error("error",r),r}};var i,a=r(906),n=r(512),o=r(186),s=r(826);!function(e){e.NOT_FOUND="not_found",e.NO_VARIATIONS="no_variations",e.NO_MATCH="no_match",e.DISABLED="disabled",e.REQUIRED="required",e.OUT_OF_RANGE="out_of_range",e.FORCED="forced",e.INITIAL="initial",e.STICKY="sticky",e.RULE="rule",e.ALLOCATED="allocated",e.DEFAULTED="defaulted",e.OVERRIDE="override",e.ERROR="error"}(i||(t.EvaluationReason=i={}))},512:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMatchedAllocation=n,t.parseFromStringifiedSegments=o,t.getMatchedTraffic=function(e,t,r,a){var n=e.find((function(e){return!!(0,i.allGroupSegmentsAreMatched)(o(e.segments),t,r,a)}));if(n&&n.percentage>0)return n},t.getMatchedTrafficAndAllocation=function(e,t,r,a,s){var u=e.find((function(e){return(0,i.allGroupSegmentsAreMatched)(o(e.segments),t,a,s)}));return u?{matchedTraffic:u,matchedAllocation:n(u,r)}:{matchedTraffic:void 0,matchedAllocation:void 0}},t.findForceFromFeature=function(e,t,r,n){var o={force:void 0,forceIndex:void 0};if(!e.force)return o;for(var s=0;s<e.force.length;s++){var u=e.force[s];if(u.conditions&&(0,a.allConditionsAreMatched)(u.conditions,t,n)){o.force=u,o.forceIndex=s;break}if(u.segments&&(0,i.allGroupSegmentsAreMatched)(u.segments,t,r,n)){o.force=u,o.forceIndex=s;break}}return o};var i=r(826),a=r(186);function n(e,t){for(var r=0,i=e.allocation;r<i.length;r++){var a=i[r],n=a.range,o=n[0],s=n[1];if(a.range&&o<=t&&s>=t)return a}}function o(e){return"string"==typeof e&&(e.startsWith("{")||e.startsWith("["))?JSON.parse(e):e}},166:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,a)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),a=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),a(r(906),t),a(r(247),t),a(r(584),t),a(r(186),t),a(r(40),t),a(r(335),t)},247:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FeaturevisorInstance=void 0,t.getValueByType=f,t.createInstance=function(e){return new c(e)};var i=r(584),a=r(649),n=r(40),o=r(335),s={schemaVersion:"1",revision:"unknown",attributes:[],segments:[],features:[]};function u(e,t){return t?t(e):fetch(e).then((function(e){return e.json()}))}function f(e,t){try{if(void 0===e)return;switch(t){case"string":return"string"==typeof e?e:void 0;case"integer":return parseInt(e,10);case"double":return parseFloat(e);case"boolean":return!0===e;case"array":return Array.isArray(e)?e:void 0;case"object":return"object"==typeof e?e:void 0;default:return e}}catch(e){return}}var c=function(){function e(e){var t=this;this.bucketKeySeparator=e.bucketKeySeparator||".",this.configureBucketKey=e.configureBucketKey,this.configureBucketValue=e.configureBucketValue,this.datafileUrl=e.datafileUrl,this.handleDatafileFetch=e.handleDatafileFetch,this.initialFeatures=e.initialFeatures,this.interceptContext=e.interceptContext,this.logger=e.logger||(0,i.createLogger)(),this.refreshInterval=e.refreshInterval,this.stickyFeatures=e.stickyFeatures,this.emitter=new n.Emitter,this.statuses={ready:!1,refreshInProgress:!1},e.onReady&&this.emitter.addListener("ready",e.onReady),e.onRefresh&&this.emitter.addListener("refresh",e.onRefresh),e.onUpdate&&this.emitter.addListener("update",e.onUpdate),e.onActivation&&this.emitter.addListener("activation",e.onActivation);var r=this.emitter.addListener.bind(this.emitter);this.on=r,this.addListener=r;var a=this.emitter.removeListener.bind(this.emitter);if(this.off=a,this.removeListener=a,this.removeAllListeners=this.emitter.removeAllListeners.bind(this.emitter),e.datafileUrl)this.setDatafile(e.datafile||s),u(e.datafileUrl,e.handleDatafileFetch).then((function(e){t.setDatafile(e),t.statuses.ready=!0,t.emitter.emit("ready"),t.refreshInterval&&t.startRefreshing()})).catch((function(e){t.logger.error("failed to fetch datafile",{error:e})}));else{if(!e.datafile)throw new Error("Featurevisor SDK instance cannot be created without both `datafile` and `datafileUrl` options");this.setDatafile(e.datafile),this.statuses.ready=!0,setTimeout((function(){t.emitter.emit("ready")}),0)}}return e.prototype.setLogLevels=function(e){this.logger.setLevels(e)},e.prototype.onReady=function(){var e=this;return new Promise((function(t){if(e.statuses.ready)return t(e);var r=function(){e.emitter.removeListener("ready",r),t(e)};e.emitter.addListener("ready",r)}))},e.prototype.setDatafile=function(e){try{this.datafileReader=new a.DatafileReader("string"==typeof e?JSON.parse(e):e)}catch(e){this.logger.error("could not parse datafile",{error:e})}},e.prototype.setStickyFeatures=function(e){this.stickyFeatures=e},e.prototype.getRevision=function(){return this.datafileReader.getRevision()},e.prototype.getFeature=function(e){return"string"==typeof e?this.datafileReader.getFeature(e):e},e.prototype.isReady=function(){return this.statuses.ready},e.prototype.refresh=function(){var e=this;return this.logger.debug("refreshing datafile"),this.statuses.refreshInProgress?this.logger.warn("refresh in progress, skipping"):this.datafileUrl?(this.statuses.refreshInProgress=!0,void u(this.datafileUrl,this.handleDatafileFetch).then((function(t){var r=e.getRevision()!==t.revision;e.setDatafile(t),e.logger.info("refreshed datafile"),e.emitter.emit("refresh"),r&&e.emitter.emit("update"),e.statuses.refreshInProgress=!1})).catch((function(t){e.logger.error("failed to refresh datafile",{error:t}),e.statuses.refreshInProgress=!1}))):this.logger.error("cannot refresh since `datafileUrl` is not provided")},e.prototype.startRefreshing=function(){var e=this;return this.datafileUrl?this.intervalId?this.logger.warn("refreshing has already started"):this.refreshInterval?void(this.intervalId=setInterval((function(){e.refresh()}),1e3*this.refreshInterval)):this.logger.warn("no `refreshInterval` option provided"):this.logger.error("cannot start refreshing since `datafileUrl` is not provided")},e.prototype.stopRefreshing=function(){if(!this.intervalId)return this.logger.warn("refreshing has not started yet");clearInterval(this.intervalId)},e.prototype.evaluateFlag=function(e,t){return void 0===t&&(t={}),(0,o.evaluate)({type:"flag",featureKey:e,context:t,logger:this.logger,datafileReader:this.datafileReader,statuses:this.statuses,interceptContext:this.interceptContext,stickyFeatures:this.stickyFeatures,initialFeatures:this.initialFeatures,bucketKeySeparator:this.bucketKeySeparator,configureBucketKey:this.configureBucketKey,configureBucketValue:this.configureBucketValue})},e.prototype.isEnabled=function(e,t){void 0===t&&(t={});try{return!0===this.evaluateFlag(e,t).enabled}catch(t){return this.logger.error("isEnabled",{featureKey:e,error:t}),!1}},e.prototype.evaluateVariation=function(e,t){return void 0===t&&(t={}),(0,o.evaluate)({type:"variation",featureKey:e,context:t,logger:this.logger,datafileReader:this.datafileReader,statuses:this.statuses,interceptContext:this.interceptContext,stickyFeatures:this.stickyFeatures,initialFeatures:this.initialFeatures,bucketKeySeparator:this.bucketKeySeparator,configureBucketKey:this.configureBucketKey,configureBucketValue:this.configureBucketValue})},e.prototype.getVariation=function(e,t){void 0===t&&(t={});try{var r=this.evaluateVariation(e,t);return void 0!==r.variationValue?r.variationValue:r.variation?r.variation.value:void 0}catch(t){return void this.logger.error("getVariation",{featureKey:e,error:t})}},e.prototype.activate=function(e,t){void 0===t&&(t={});try{var r=this.evaluateVariation(e,t),i=r.variation?r.variation.value:r.variationValue;if(void 0===i)return;var a=this.interceptContext?this.interceptContext(t):t,n={};return this.datafileReader.getAllAttributes().filter((function(e){return!0===e.capture})).forEach((function(e){void 0!==a[e.key]&&(n[e.key]=t[e.key])})),this.emitter.emit("activation",e,i,a,n,r),i}catch(t){return void this.logger.error("activate",{featureKey:e,error:t})}},e.prototype.evaluateVariable=function(e,t,r){return void 0===r&&(r={}),(0,o.evaluate)({type:"variable",featureKey:e,variableKey:t,context:r,logger:this.logger,datafileReader:this.datafileReader,statuses:this.statuses,interceptContext:this.interceptContext,stickyFeatures:this.stickyFeatures,initialFeatures:this.initialFeatures,bucketKeySeparator:this.bucketKeySeparator,configureBucketKey:this.configureBucketKey,configureBucketValue:this.configureBucketValue})},e.prototype.getVariable=function(e,t,r){void 0===r&&(r={});try{var i=this.evaluateVariable(e,t,r);return void 0!==i.variableValue?i.variableSchema&&"json"===i.variableSchema.type&&"string"==typeof i.variableValue?JSON.parse(i.variableValue):i.variableValue:void 0}catch(r){return void this.logger.error("getVariable",{featureKey:e,variableKey:t,error:r})}},e.prototype.getVariableBoolean=function(e,t,r){return void 0===r&&(r={}),f(this.getVariable(e,t,r),"boolean")},e.prototype.getVariableString=function(e,t,r){return void 0===r&&(r={}),f(this.getVariable(e,t,r),"string")},e.prototype.getVariableInteger=function(e,t,r){return void 0===r&&(r={}),f(this.getVariable(e,t,r),"integer")},e.prototype.getVariableDouble=function(e,t,r){return void 0===r&&(r={}),f(this.getVariable(e,t,r),"double")},e.prototype.getVariableArray=function(e,t,r){return void 0===r&&(r={}),f(this.getVariable(e,t,r),"array")},e.prototype.getVariableObject=function(e,t,r){return void 0===r&&(r={}),f(this.getVariable(e,t,r),"object")},e.prototype.getVariableJSON=function(e,t,r){return void 0===r&&(r={}),f(this.getVariable(e,t,r),"json")},e}();t.FeaturevisorInstance=c},584:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=t.defaultLogHandler=t.defaultLogLevels=t.loggerPrefix=void 0,t.createLogger=function(e){void 0===e&&(e={});var i=e.levels||t.defaultLogLevels,a=e.handler||t.defaultLogHandler;return new r({levels:i,handler:a})},t.loggerPrefix="[Featurevisor]",t.defaultLogLevels=["warn","error"],t.defaultLogHandler=function(e,r,i){switch(void 0===i&&(i={}),e){case"debug":console.log(t.loggerPrefix,r,i);break;case"info":console.info(t.loggerPrefix,r,i);break;case"warn":console.warn(t.loggerPrefix,r,i);break;case"error":console.error(t.loggerPrefix,r,i)}};var r=function(){function e(e){this.levels=e.levels,this.handle=e.handler}return e.prototype.setLevels=function(e){this.levels=e},e.prototype.log=function(e,t,r){-1!==this.levels.indexOf(e)&&this.handle(e,t,r)},e.prototype.debug=function(e,t){this.log("debug",e,t)},e.prototype.info=function(e,t){this.log("info",e,t)},e.prototype.warn=function(e,t){this.log("warn",e,t)},e.prototype.error=function(e,t){this.log("error",e,t)},e}();t.Logger=r},826:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.segmentIsMatched=a,t.allGroupSegmentsAreMatched=function e(t,r,i,n){if("*"===t)return!0;if("string"==typeof t){var o=i.getSegment(t);return!!o&&a(o,r,n)}if("object"==typeof t){if("and"in t&&Array.isArray(t.and))return t.and.every((function(t){return e(t,r,i,n)}));if("or"in t&&Array.isArray(t.or))return t.or.some((function(t){return e(t,r,i,n)}));if("not"in t&&Array.isArray(t.not))return t.not.every((function(t){return!1===e(t,r,i,n)}))}return!!Array.isArray(t)&&t.every((function(t){return e(t,r,i,n)}))};var i=r(186);function a(e,t,r){return(0,i.allConditionsAreMatched)(e.conditions,t,r)}}},t={};function r(i){var a=t[i];if(void 0!==a)return a.exports;var n=t[i]={exports:{}};return e[i].call(n.exports,n,n.exports,r),n.exports}return r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(166)})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FeaturevisorSDK=t():e.FeaturevisorSDK=t()}(this,(()=>(()=>{var e={393:(e,t,r)=>{"use strict";r.r(t),r.d(t,{compare:()=>n,compareVersions:()=>i,satisfies:()=>o,validate:()=>a});const i=(e,t)=>{const r=u(e),i=u(t),a=r.pop(),n=i.pop(),o=d(r,i);return 0!==o?o:a&&n?d(a.split("."),n.split(".")):a||n?a?-1:1:0},a=e=>"string"==typeof e&&/^[v\d]/.test(e)&&s.test(e),n=(e,t,r)=>{g(r);const a=i(e,t);return v[r].includes(a)},o=(e,t)=>{if(t.includes("||"))return t.split("||").some((t=>o(e,t)));if(t.includes(" "))return t.trim().replace(/\s{2,}/g," ").split(" ").every((t=>o(e,t)));const r=t.match(/^([<>=~^]+)/),i=r?r[1]:"=";if("^"!==i&&"~"!==i)return n(e,t,i);const[a,s,f,,c]=u(e),[l,v,y,,g]=u(t),h=[a,s,f],b=[l,null!=v?v:"x",null!=y?y:"x"];if(g){if(!c)return!1;if(0!==d(h,b))return!1;if(-1===d(c.split("."),g.split(".")))return!1}const p=b.findIndex((e=>"0"!==e))+1,k="~"===i?2:p>1?p:1;return 0===d(h.slice(0,k),b.slice(0,k))&&-1!==d(h.slice(k),b.slice(k))},s=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,u=e=>{if("string"!=typeof e)throw new TypeError("Invalid argument expected string");const t=e.match(s);if(!t)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},f=e=>"*"===e||"x"===e||"X"===e,c=e=>{const t=parseInt(e,10);return isNaN(t)?e:t},l=(e,t)=>{if(f(e)||f(t))return 0;const[r,i]=((e,t)=>typeof e!=typeof t?[String(e),String(t)]:[e,t])(c(e),c(t));return r>i?1:r<i?-1:0},d=(e,t)=>{for(let r=0;r<Math.max(e.length,t.length);r++){const i=l(e[r]||"0",t[r]||"0");if(0!==i)return i}return 0},v={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1]},y=Object.keys(v),g=e=>{if("string"!=typeof e)throw new TypeError("Invalid operator type, expected string but got "+typeof e);if(-1===y.indexOf(e))throw new Error(`Invalid operator, expected one of ${y.join("|")}`)}},784:e=>{!function(){const t=e=>(new TextEncoder).encode(e);function r(e,r){let i,a,n,o,s,u,f,c;for("string"==typeof e&&(e=t(e)),i=3&e.length,a=e.length-i,n=r,s=3432918353,u=461845907,c=0;c<a;)f=255&e[c]|(255&e[++c])<<8|(255&e[++c])<<16|(255&e[++c])<<24,++c,f=(65535&f)*s+(((f>>>16)*s&65535)<<16)&4294967295,f=f<<15|f>>>17,f=(65535&f)*u+(((f>>>16)*u&65535)<<16)&4294967295,n^=f,n=n<<13|n>>>19,o=5*(65535&n)+((5*(n>>>16)&65535)<<16)&4294967295,n=27492+(65535&o)+((58964+(o>>>16)&65535)<<16);switch(f=0,i){case 3:f^=(255&e[c+2])<<16;case 2:f^=(255&e[c+1])<<8;case 1:f^=255&e[c],f=(65535&f)*s+(((f>>>16)*s&65535)<<16)&4294967295,f=f<<15|f>>>17,f=(65535&f)*u+(((f>>>16)*u&65535)<<16)&4294967295,n^=f}return n^=e.length,n^=n>>>16,n=2246822507*(65535&n)+((2246822507*(n>>>16)&65535)<<16)&4294967295,n^=n>>>13,n=3266489909*(65535&n)+((3266489909*(n>>>16)&65535)<<16)&4294967295,n^=n>>>16,n>>>0}const i=r;i.v2=function(e,r){"string"==typeof e&&(e=t(e));let i,a=e.length,n=r^a,o=0;for(;a>=4;)i=255&e[o]|(255&e[++o])<<8|(255&e[++o])<<16|(255&e[++o])<<24,i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16),i^=i>>>24,i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^i,a-=4,++o;switch(a){case 3:n^=(255&e[o+2])<<16;case 2:n^=(255&e[o+1])<<8;case 1:n^=255&e[o],n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)}return n^=n>>>13,n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16),n^=n>>>15,n>>>0},i.v3=r,e.exports=i}()},906:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_BUCKETED_NUMBER=void 0,t.getBucketedNumber=o,t.getBucketKey=s,t.getBucket=function(e){var t=e.feature,r=e.context,i=e.logger,a=e.bucketKeySeparator,n=e.configureBucketKey,u=e.configureBucketValue,f=s({feature:t,context:r,logger:i,bucketKeySeparator:a,configureBucketKey:n}),c=o(f);return u?{bucketKey:f,bucketValue:u(t,r,c)}:{bucketKey:f,bucketValue:c}};var i=r(784),a=1,n=Math.pow(2,32);function o(e){var r=i.v3(e,a)/n;return Math.floor(r*t.MAX_BUCKETED_NUMBER)}function s(e){var t,r,i=e.feature,a=e.context,n=e.logger,o=e.bucketKeySeparator,s=void 0===o?".":o,u=e.configureBucketKey,f=i.key;if("string"==typeof i.bucketBy)t="plain",r=[i.bucketBy];else if(Array.isArray(i.bucketBy))t="and",r=i.bucketBy;else{if("object"!=typeof i.bucketBy||!Array.isArray(i.bucketBy.or))throw n.error("invalid bucketBy",{featureKey:f,bucketBy:i.bucketBy}),new Error("invalid bucketBy");t="or",r=i.bucketBy.or}var c=[];r.forEach((function(e){var r=a[e];void 0!==r&&("plain"===t||"and"===t||0===c.length)&&c.push(r)})),c.push(f);var l=c.join(s);return u?u(i,a,l):l}t.MAX_BUCKETED_NUMBER=1e5},186:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.conditionIsMatched=a,t.allConditionsAreMatched=function e(t,r,i){if("attribute"in t)try{return a(t,r)}catch(e){return i.warn(e.message,{error:e,details:{condition:t,context:r}}),!1}return"and"in t&&Array.isArray(t.and)?t.and.every((function(t){return e(t,r,i)})):"or"in t&&Array.isArray(t.or)?t.or.some((function(t){return e(t,r,i)})):"not"in t&&Array.isArray(t.not)?t.not.every((function(){return!1===e({and:t.not},r,i)})):!!Array.isArray(t)&&t.every((function(t){return e(t,r,i)}))};var i=r(393);function a(e,t){var r=e.attribute,a=e.operator,n=e.value;if("equals"===a)return t[r]===n;if("notEquals"===a)return t[r]!==n;if("before"===a||"after"===a){var o=(u=t[r])instanceof Date?u:new Date(u),s=n instanceof Date?n:new Date(n);return"before"===a?o<s:o>s}if(!Array.isArray(n)||-1===["string","number"].indexOf(typeof t[r])&&null!==t[r]){if("string"==typeof t[r]&&"string"==typeof n){if(u=t[r],"contains"===a)return-1!==u.indexOf(n);if("notContains"===a)return-1===u.indexOf(n);if("startsWith"===a)return u.startsWith(n);if("endsWith"===a)return u.endsWith(n);if("semverEquals"===a)return 0===(0,i.compareVersions)(u,n);if("semverNotEquals"===a)return 0!==(0,i.compareVersions)(u,n);if("semverGreaterThan"===a)return 1===(0,i.compareVersions)(u,n);if("semverGreaterThanOrEquals"===a)return(0,i.compareVersions)(u,n)>=0;if("semverLessThan"===a)return-1===(0,i.compareVersions)(u,n);if("semverLessThanOrEquals"===a)return(0,i.compareVersions)(u,n)<=0}else if("number"==typeof t[r]&&"number"==typeof n){if(u=t[r],"greaterThan"===a)return u>n;if("greaterThanOrEquals"===a)return u>=n;if("lessThan"===a)return u<n;if("lessThanOrEquals"===a)return u<=n}}else{var u=t[r];if("in"===a)return-1!==n.indexOf(u);if("notIn"===a)return-1===n.indexOf(u)}return!1}},649:(e,t)=>{"use strict";function r(e,t){if("string"==typeof e[t]&&"*"!==e[t])try{e[t]=JSON.parse(e[t])}catch(e){console.error("Error parsing JSON",e)}return e}Object.defineProperty(t,"__esModule",{value:!0}),t.DatafileReader=void 0,t.parseJsonConditionsIfStringified=r;var i=function(){function e(e){var t=this;if(this.schemaVersion=e.schemaVersion,this.revision=e.revision,"2"===this.schemaVersion){var r=e;this.attributes=r.attributes,this.segments=r.segments,this.features=r.features}else{var i=e;this.attributes={},i.attributes.forEach((function(e){t.attributes[e.key]=e})),this.segments={},i.segments.forEach((function(e){t.segments[e.key]=e})),this.features={},i.features.forEach((function(e){Array.isArray(e.variablesSchema)&&(e.variablesSchema=e.variablesSchema.reduce((function(e,t){return e[t.key]=t,e}),{})),t.features[e.key]=e}))}}return e.prototype.getRevision=function(){return this.revision},e.prototype.getSchemaVersion=function(){return this.schemaVersion},e.prototype.getAllAttributes=function(){var e=this,t=[];return Object.keys(this.attributes).forEach((function(r){t.push(e.attributes[r])})),t},e.prototype.getAttribute=function(e){return this.attributes[e]},e.prototype.getSegment=function(e){var t=this.segments[e];if(t)return r(t,"conditions")},e.prototype.getFeature=function(e){return this.features[e]},e}();t.DatafileReader=i},40:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=void 0;var r=function(){function e(){this._listeners={}}return e.prototype.addListener=function(e,t){void 0===this._listeners[e]&&(this._listeners[e]=[]),this._listeners[e].push(t)},e.prototype.removeListener=function(e,t){if(void 0!==this._listeners[e]){var r=this._listeners[e].indexOf(t);-1!==r&&this._listeners[e].splice(r,1)}},e.prototype.removeAllListeners=function(e){var t=this;e?this._listeners[e]=[]:Object.keys(this._listeners).forEach((function(e){t._listeners[e]=[]}))},e.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];void 0!==this._listeners[e]&&this._listeners[e].forEach((function(e){e.apply(void 0,t)}))},e}();t.Emitter=r},335:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EvaluationReason=void 0,t.evaluate=function e(t){var r,u=t.type,f=t.featureKey,c=t.variableKey,l=t.context,d=t.logger,v=t.datafileReader,y=t.statuses,g=t.stickyFeatures,h=t.initialFeatures,b=t.interceptContext,p=t.bucketKeySeparator,k=t.configureBucketKey,m=t.configureBucketValue;try{var K="string"==typeof f?f:f.key;if("flag"!==u&&!1===e({type:"flag",featureKey:K,context:l,logger:d,datafileReader:v,statuses:y,stickyFeatures:g,initialFeatures:h,bucketKeySeparator:p,configureBucketKey:k,configureBucketValue:m}).enabled)return r={featureKey:K,reason:i.DISABLED},d.debug("feature is disabled",r),r;if(g&&g[K]){if("flag"===u&&void 0!==g[K].enabled)return r={featureKey:K,reason:i.STICKY,sticky:g[K],enabled:g[K].enabled},d.debug("using sticky enabled",r),r;if("variation"===u&&void 0!==(A=g[K].variation))return r={featureKey:K,reason:i.STICKY,variationValue:A},d.debug("using sticky variation",r),r;if(c&&(O=g[K].variables)){var V=O[c];if(void 0!==V)return r={featureKey:K,reason:i.STICKY,variableKey:c,variableValue:V},d.debug("using sticky variable",r),r}}if(y&&!y.ready&&h&&h[K]){if("flag"===u&&void 0!==h[K].enabled)return r={featureKey:K,reason:i.INITIAL,initial:h[K],enabled:h[K].enabled},d.debug("using initial enabled",r),r;if("variation"===u&&void 0!==h[K].variation){var A=h[K].variation;return r={featureKey:K,reason:i.INITIAL,variationValue:A},d.debug("using initial variation",r),r}var O;if(c&&(O=h[K].variables)&&void 0!==O[c])return r={featureKey:K,reason:i.INITIAL,variableKey:c,variableValue:O[c]},d.debug("using initial variable",r),r}var E="string"==typeof f?v.getFeature(f):f;if(!E)return r={featureKey:K,reason:i.NOT_FOUND},d.warn("feature not found",r),r;"flag"===u&&E.deprecated&&d.warn("feature is deprecated",{featureKey:E.key});var S=void 0;if(c){if(E.variablesSchema&&E.variablesSchema[c]&&(S=E.variablesSchema[c]),!S)return r={featureKey:K,reason:i.NOT_FOUND,variableKey:c},d.warn("variable schema not found",r),r;S.deprecated&&d.warn("variable is deprecated",{featureKey:E.key,variableKey:c})}if("variation"===u&&(!E.variations||0===E.variations.length))return r={featureKey:K,reason:i.NO_VARIATIONS},d.warn("no variations",r),r;var x=b?b(l):l,I=(0,n.findForceFromFeature)(E,l,v,d),R=I.force,_=I.forceIndex;if(R){if("flag"===u&&void 0!==R.enabled)return r={featureKey:E.key,reason:i.FORCED,forceIndex:_,force:R,enabled:R.enabled},d.debug("forced enabled found",r),r;if("variation"===u&&R.variation&&E.variations&&(C=E.variations.find((function(e){return e.value===R.variation}))))return r={featureKey:E.key,reason:i.FORCED,forceIndex:_,force:R,variation:C},d.debug("forced variation found",r),r;if(c&&R.variables&&void 0!==R.variables[c])return r={featureKey:E.key,reason:i.FORCED,forceIndex:_,force:R,variableKey:c,variableSchema:S,variableValue:R.variables[c]},d.debug("forced variable",r),r}if("flag"===u&&E.required&&E.required.length>0){var F=E.required.every((function(t){var r,i;if("string"==typeof t?r=t:(r=t.key,i=t.variation),!e({type:"flag",featureKey:r,context:x,logger:d,datafileReader:v,statuses:y,stickyFeatures:g,initialFeatures:h,bucketKeySeparator:p,configureBucketKey:k,configureBucketValue:m}).enabled)return!1;if(void 0!==i){var a=e({type:"variation",featureKey:r,context:x,logger:d,datafileReader:v,statuses:y,stickyFeatures:g,initialFeatures:h,bucketKeySeparator:p,configureBucketKey:k,configureBucketValue:m}),n=void 0;return a.variationValue?n=a.variationValue:a.variation&&(n=a.variation.value),n===i}return!0}));if(!F)return r={featureKey:E.key,reason:i.REQUIRED,required:E.required,enabled:F},d.debug("required features not enabled",r),r}var B,L,T=(0,a.getBucket)({feature:E,context:x,logger:d,bucketKeySeparator:p,configureBucketKey:k,configureBucketValue:m}),D=T.bucketKey,w=T.bucketValue;if("flag"!==u){var M=(0,n.getMatchedTrafficAndAllocation)(E.traffic,x,w,v,d);B=M.matchedTraffic,L=M.matchedAllocation}else B=(0,n.getMatchedTraffic)(E.traffic,x,v,d);if(B){if("flag"===u){if(E.ranges&&E.ranges.length>0)return E.ranges.find((function(e){return w>=e[0]&&w<e[1]}))?(r={featureKey:E.key,reason:i.ALLOCATED,bucketKey:D,bucketValue:w,ruleKey:B.key,traffic:B,enabled:void 0===B.enabled||B.enabled},d.debug("matched",r),r):(r={featureKey:E.key,reason:i.OUT_OF_RANGE,bucketKey:D,bucketValue:w,enabled:!1},d.debug("not matched",r),r);if(void 0!==B.enabled)return r={featureKey:E.key,reason:i.OVERRIDE,bucketKey:D,bucketValue:w,ruleKey:B.key,traffic:B,enabled:B.enabled},d.debug("override from rule",r),r;if(w<=B.percentage)return r={featureKey:E.key,reason:i.RULE,bucketKey:D,bucketValue:w,ruleKey:B.key,traffic:B,enabled:!0},d.debug("matched traffic",r),r}if("variation"===u&&E.variations){if(B.variation&&(C=E.variations.find((function(e){return e.value===B.variation}))))return r={featureKey:E.key,reason:i.RULE,bucketKey:D,bucketValue:w,ruleKey:B.key,traffic:B,variation:C},d.debug("override from rule",r),r;if(L&&L.variation&&(C=E.variations.find((function(e){return e.value===L.variation}))))return r={featureKey:E.key,reason:i.ALLOCATED,bucketKey:D,bucketValue:w,ruleKey:B.key,traffic:B,variation:C},d.debug("allocated variation",r),r}}if("variable"===u&&c){if(B&&B.variables&&void 0!==B.variables[c])return r={featureKey:E.key,reason:i.RULE,bucketKey:D,bucketValue:w,ruleKey:B.key,traffic:B,variableKey:c,variableSchema:S,variableValue:B.variables[c]},d.debug("override from rule",r),r;var j,C;if(R&&R.variation?j=R.variation:L&&L.variation&&(j=L.variation),j&&Array.isArray(E.variations)&&(C=E.variations.find((function(e){return e.value===j})))&&C.variables){var N=C.variables.find((function(e){return e.key===c}));if(N){if(N.overrides){var U=N.overrides.find((function(e){return e.conditions?(0,o.allConditionsAreMatched)("string"==typeof e.conditions?JSON.parse(e.conditions):e.conditions,x,d):!!e.segments&&(0,s.allGroupSegmentsAreMatched)((0,n.parseFromStringifiedSegments)(e.segments),x,v,d)}));if(U)return r={featureKey:E.key,reason:i.OVERRIDE,bucketKey:D,bucketValue:w,ruleKey:null==B?void 0:B.key,traffic:B,variableKey:c,variableSchema:S,variableValue:U.value},d.debug("variable override",r),r}if(void 0!==N.value)return r={featureKey:E.key,reason:i.ALLOCATED,bucketKey:D,bucketValue:w,ruleKey:null==B?void 0:B.key,traffic:B,variableKey:c,variableSchema:S,variableValue:N.value},d.debug("allocated variable",r),r}}}return"variation"===u?(r={featureKey:E.key,reason:i.NO_MATCH,bucketKey:D,bucketValue:w},d.debug("no matched variation",r),r):"variable"===u&&S?(r={featureKey:E.key,reason:i.DEFAULTED,bucketKey:D,bucketValue:w,variableKey:c,variableSchema:S,variableValue:S.defaultValue},d.debug("using default value",r),r):(r={featureKey:E.key,reason:i.NO_MATCH,bucketKey:D,bucketValue:w,enabled:!1},d.debug("nothing matched",r),r)}catch(e){return r={featureKey:"string"==typeof f?f:f.key,reason:i.ERROR,error:e},d.error("error",r),r}};var i,a=r(906),n=r(512),o=r(186),s=r(826);!function(e){e.NOT_FOUND="not_found",e.NO_VARIATIONS="no_variations",e.NO_MATCH="no_match",e.DISABLED="disabled",e.REQUIRED="required",e.OUT_OF_RANGE="out_of_range",e.FORCED="forced",e.INITIAL="initial",e.STICKY="sticky",e.RULE="rule",e.ALLOCATED="allocated",e.DEFAULTED="defaulted",e.OVERRIDE="override",e.ERROR="error"}(i||(t.EvaluationReason=i={}))},512:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMatchedAllocation=n,t.parseFromStringifiedSegments=o,t.getMatchedTraffic=function(e,t,r,a){var n=e.find((function(e){return!!(0,i.allGroupSegmentsAreMatched)(o(e.segments),t,r,a)}));if(n&&n.percentage>0)return n},t.getMatchedTrafficAndAllocation=function(e,t,r,a,s){var u=e.find((function(e){return(0,i.allGroupSegmentsAreMatched)(o(e.segments),t,a,s)}));return u?{matchedTraffic:u,matchedAllocation:n(u,r)}:{matchedTraffic:void 0,matchedAllocation:void 0}},t.findForceFromFeature=function(e,t,r,n){var o={force:void 0,forceIndex:void 0};if(!e.force)return o;for(var s=0;s<e.force.length;s++){var u=e.force[s];if(u.conditions&&(0,a.allConditionsAreMatched)(u.conditions,t,n)){o.force=u,o.forceIndex=s;break}if(u.segments&&(0,i.allGroupSegmentsAreMatched)(u.segments,t,r,n)){o.force=u,o.forceIndex=s;break}}return o};var i=r(826),a=r(186);function n(e,t){for(var r=0,i=e.allocation;r<i.length;r++){var a=i[r],n=a.range,o=n[0],s=n[1];if(a.range&&o<=t&&s>=t)return a}}function o(e){return"string"==typeof e&&(e.startsWith("{")||e.startsWith("["))?JSON.parse(e):e}},166:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,a)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),a=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),a(r(906),t),a(r(247),t),a(r(584),t),a(r(186),t),a(r(40),t),a(r(335),t)},247:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FeaturevisorInstance=void 0,t.getValueByType=f,t.createInstance=function(e){return new c(e)};var i=r(584),a=r(649),n=r(40),o=r(335),s={schemaVersion:"1",revision:"unknown",attributes:[],segments:[],features:[]};function u(e,t){return t?t(e):fetch(e).then((function(e){return e.json()}))}function f(e,t){try{if(void 0===e)return;switch(t){case"string":return"string"==typeof e?e:void 0;case"integer":return parseInt(e,10);case"double":return parseFloat(e);case"boolean":return!0===e;case"array":return Array.isArray(e)?e:void 0;case"object":return"object"==typeof e?e:void 0;default:return e}}catch(e){return}}var c=function(){function e(e){var t=this;this.bucketKeySeparator=e.bucketKeySeparator||".",this.configureBucketKey=e.configureBucketKey,this.configureBucketValue=e.configureBucketValue,this.datafileUrl=e.datafileUrl,this.handleDatafileFetch=e.handleDatafileFetch,this.initialFeatures=e.initialFeatures,this.interceptContext=e.interceptContext,this.logger=e.logger||(0,i.createLogger)(),this.refreshInterval=e.refreshInterval,this.stickyFeatures=e.stickyFeatures,this.emitter=new n.Emitter,this.statuses={ready:!1,refreshInProgress:!1},e.onReady&&this.emitter.addListener("ready",e.onReady),e.onRefresh&&this.emitter.addListener("refresh",e.onRefresh),e.onUpdate&&this.emitter.addListener("update",e.onUpdate),e.onActivation&&this.emitter.addListener("activation",e.onActivation);var r=this.emitter.addListener.bind(this.emitter);this.on=r,this.addListener=r;var a=this.emitter.removeListener.bind(this.emitter);if(this.off=a,this.removeListener=a,this.removeAllListeners=this.emitter.removeAllListeners.bind(this.emitter),e.datafileUrl)this.setDatafile(e.datafile||s),u(e.datafileUrl,e.handleDatafileFetch).then((function(e){t.setDatafile(e),t.statuses.ready=!0,t.emitter.emit("ready"),t.refreshInterval&&t.startRefreshing()})).catch((function(e){t.logger.error("failed to fetch datafile",{error:e})}));else{if(!e.datafile)throw new Error("Featurevisor SDK instance cannot be created without both `datafile` and `datafileUrl` options");this.setDatafile(e.datafile),this.statuses.ready=!0,setTimeout((function(){t.emitter.emit("ready")}),0)}}return e.prototype.setLogLevels=function(e){this.logger.setLevels(e)},e.prototype.onReady=function(){var e=this;return new Promise((function(t){if(e.statuses.ready)return t(e);var r=function(){e.emitter.removeListener("ready",r),t(e)};e.emitter.addListener("ready",r)}))},e.prototype.setDatafile=function(e){try{this.datafileReader=new a.DatafileReader("string"==typeof e?JSON.parse(e):e)}catch(e){this.logger.error("could not parse datafile",{error:e})}},e.prototype.setStickyFeatures=function(e){this.stickyFeatures=e},e.prototype.getRevision=function(){return this.datafileReader.getRevision()},e.prototype.getFeature=function(e){return"string"==typeof e?this.datafileReader.getFeature(e):e},e.prototype.isReady=function(){return this.statuses.ready},e.prototype.refresh=function(){var e=this;return this.logger.debug("refreshing datafile"),this.statuses.refreshInProgress?this.logger.warn("refresh in progress, skipping"):this.datafileUrl?(this.statuses.refreshInProgress=!0,void u(this.datafileUrl,this.handleDatafileFetch).then((function(t){var r=e.getRevision()!==t.revision;e.setDatafile(t),e.logger.info("refreshed datafile"),e.emitter.emit("refresh"),r&&e.emitter.emit("update"),e.statuses.refreshInProgress=!1})).catch((function(t){e.logger.error("failed to refresh datafile",{error:t}),e.statuses.refreshInProgress=!1}))):this.logger.error("cannot refresh since `datafileUrl` is not provided")},e.prototype.startRefreshing=function(){var e=this;return this.datafileUrl?this.intervalId?this.logger.warn("refreshing has already started"):this.refreshInterval?void(this.intervalId=setInterval((function(){e.refresh()}),1e3*this.refreshInterval)):this.logger.warn("no `refreshInterval` option provided"):this.logger.error("cannot start refreshing since `datafileUrl` is not provided")},e.prototype.stopRefreshing=function(){if(!this.intervalId)return this.logger.warn("refreshing has not started yet");clearInterval(this.intervalId)},e.prototype.evaluateFlag=function(e,t){return void 0===t&&(t={}),(0,o.evaluate)({type:"flag",featureKey:e,context:t,logger:this.logger,datafileReader:this.datafileReader,statuses:this.statuses,interceptContext:this.interceptContext,stickyFeatures:this.stickyFeatures,initialFeatures:this.initialFeatures,bucketKeySeparator:this.bucketKeySeparator,configureBucketKey:this.configureBucketKey,configureBucketValue:this.configureBucketValue})},e.prototype.isEnabled=function(e,t){void 0===t&&(t={});try{return!0===this.evaluateFlag(e,t).enabled}catch(t){return this.logger.error("isEnabled",{featureKey:e,error:t}),!1}},e.prototype.evaluateVariation=function(e,t){return void 0===t&&(t={}),(0,o.evaluate)({type:"variation",featureKey:e,context:t,logger:this.logger,datafileReader:this.datafileReader,statuses:this.statuses,interceptContext:this.interceptContext,stickyFeatures:this.stickyFeatures,initialFeatures:this.initialFeatures,bucketKeySeparator:this.bucketKeySeparator,configureBucketKey:this.configureBucketKey,configureBucketValue:this.configureBucketValue})},e.prototype.getVariation=function(e,t){void 0===t&&(t={});try{var r=this.evaluateVariation(e,t);return void 0!==r.variationValue?r.variationValue:r.variation?r.variation.value:void 0}catch(t){return void this.logger.error("getVariation",{featureKey:e,error:t})}},e.prototype.activate=function(e,t){void 0===t&&(t={});try{var r=this.evaluateVariation(e,t),i=r.variation?r.variation.value:r.variationValue;if(void 0===i)return;var a=this.interceptContext?this.interceptContext(t):t,n={};return this.datafileReader.getAllAttributes().filter((function(e){return!0===e.capture})).forEach((function(e){void 0!==a[e.key]&&(n[e.key]=t[e.key])})),this.emitter.emit("activation",e,i,a,n,r),i}catch(t){return void this.logger.error("activate",{featureKey:e,error:t})}},e.prototype.evaluateVariable=function(e,t,r){return void 0===r&&(r={}),(0,o.evaluate)({type:"variable",featureKey:e,variableKey:t,context:r,logger:this.logger,datafileReader:this.datafileReader,statuses:this.statuses,interceptContext:this.interceptContext,stickyFeatures:this.stickyFeatures,initialFeatures:this.initialFeatures,bucketKeySeparator:this.bucketKeySeparator,configureBucketKey:this.configureBucketKey,configureBucketValue:this.configureBucketValue})},e.prototype.getVariable=function(e,t,r){void 0===r&&(r={});try{var i=this.evaluateVariable(e,t,r);return void 0!==i.variableValue?i.variableSchema&&"json"===i.variableSchema.type&&"string"==typeof i.variableValue?JSON.parse(i.variableValue):i.variableValue:void 0}catch(r){return void this.logger.error("getVariable",{featureKey:e,variableKey:t,error:r})}},e.prototype.getVariableBoolean=function(e,t,r){return void 0===r&&(r={}),f(this.getVariable(e,t,r),"boolean")},e.prototype.getVariableString=function(e,t,r){return void 0===r&&(r={}),f(this.getVariable(e,t,r),"string")},e.prototype.getVariableInteger=function(e,t,r){return void 0===r&&(r={}),f(this.getVariable(e,t,r),"integer")},e.prototype.getVariableDouble=function(e,t,r){return void 0===r&&(r={}),f(this.getVariable(e,t,r),"double")},e.prototype.getVariableArray=function(e,t,r){return void 0===r&&(r={}),f(this.getVariable(e,t,r),"array")},e.prototype.getVariableObject=function(e,t,r){return void 0===r&&(r={}),f(this.getVariable(e,t,r),"object")},e.prototype.getVariableJSON=function(e,t,r){return void 0===r&&(r={}),f(this.getVariable(e,t,r),"json")},e}();t.FeaturevisorInstance=c},584:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=t.defaultLogHandler=t.defaultLogLevels=t.loggerPrefix=void 0,t.createLogger=function(e){void 0===e&&(e={});var i=e.levels||t.defaultLogLevels,a=e.handler||t.defaultLogHandler;return new r({levels:i,handler:a})},t.loggerPrefix="[Featurevisor]",t.defaultLogLevels=["warn","error"],t.defaultLogHandler=function(e,r,i){switch(void 0===i&&(i={}),e){case"debug":console.log(t.loggerPrefix,r,i);break;case"info":console.info(t.loggerPrefix,r,i);break;case"warn":console.warn(t.loggerPrefix,r,i);break;case"error":console.error(t.loggerPrefix,r,i)}};var r=function(){function e(e){this.levels=e.levels,this.handle=e.handler}return e.prototype.setLevels=function(e){this.levels=e},e.prototype.log=function(e,t,r){-1!==this.levels.indexOf(e)&&this.handle(e,t,r)},e.prototype.debug=function(e,t){this.log("debug",e,t)},e.prototype.info=function(e,t){this.log("info",e,t)},e.prototype.warn=function(e,t){this.log("warn",e,t)},e.prototype.error=function(e,t){this.log("error",e,t)},e}();t.Logger=r},826:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.segmentIsMatched=a,t.allGroupSegmentsAreMatched=function e(t,r,i,n){if("*"===t)return!0;if("string"==typeof t){var o=i.getSegment(t);return!!o&&a(o,r,n)}if("object"==typeof t){if("and"in t&&Array.isArray(t.and))return t.and.every((function(t){return e(t,r,i,n)}));if("or"in t&&Array.isArray(t.or))return t.or.some((function(t){return e(t,r,i,n)}));if("not"in t&&Array.isArray(t.not))return t.not.every((function(t){return!1===e(t,r,i,n)}))}return!!Array.isArray(t)&&t.every((function(t){return e(t,r,i,n)}))};var i=r(186);function a(e,t,r){return(0,i.allConditionsAreMatched)(e.conditions,t,r)}}},t={};function r(i){var a=t[i];if(void 0!==a)return a.exports;var n=t[i]={exports:{}};return e[i].call(n.exports,n,n.exports,r),n.exports}return r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(166)})()));
|
|
2
2
|
//# sourceMappingURL=index.js.map
|