guess-the-year-web-component 3.0.1 → 3.0.2

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.
@@ -2,8 +2,6 @@ import { LitElement, PropertyValues, TemplateResult } from "lit";
2
2
  import { Dayjs } from "dayjs";
3
3
  import { Incident } from "./lib/Incident";
4
4
  export declare class GuessTheYear extends LitElement {
5
- private _startTime;
6
- private _endTime;
7
5
  private sources;
8
6
  private _loading;
9
7
  private _score0;
@@ -18,16 +16,9 @@ export declare class GuessTheYear extends LitElement {
18
16
  impact: string;
19
17
  from: Dayjs;
20
18
  to: Dayjs;
21
- limit: string;
22
- shuffle: boolean;
23
- showDuration: boolean;
24
- showFeedback: boolean;
25
19
  noImageSrc: string;
26
20
  suppressImages: boolean;
27
- autoFocus: boolean;
28
- hintIntervalSecs: number;
29
21
  maxHints: number;
30
- maxTries: number;
31
22
  numberOfQuestions: number;
32
23
  private _numberOfQuestionsSeen;
33
24
  private _incident;
@@ -38,15 +29,11 @@ export declare class GuessTheYear extends LitElement {
38
29
  private _hintsIndex;
39
30
  private _hints;
40
31
  private _solution;
41
- private _displaySolution;
42
- private _answeredCorrectly;
43
- private _tries;
44
32
  _renderState: string;
45
33
  private _score;
46
34
  totalScore: number;
47
35
  private _answer;
48
36
  private _apiService;
49
- private _intervalsPassed;
50
37
  private i18n;
51
38
  static styles: import("lit").CSSResult;
52
39
  constructor();
@@ -67,6 +54,7 @@ export declare class GuessTheYear extends LitElement {
67
54
  private _setToDate;
68
55
  private renderGameStage;
69
56
  private _renderIncident;
57
+ private _shouldDisplayAnImage;
70
58
  private _renderIncidentImage;
71
59
  private _renderAnswers;
72
60
  private _renderGameScore;
@@ -81,22 +69,7 @@ export declare class GuessTheYear extends LitElement {
81
69
  private setupNewGame;
82
70
  private _resetStage;
83
71
  _loadQuestion(): Promise<void>;
84
- renderRefreshButton(): TemplateResult;
85
- renderStopGameButton(): TemplateResult;
86
- renderFeedbackPossibility(): TemplateResult;
87
- renderSubmitPossibility(): TemplateResult;
88
- renderTries(): TemplateResult;
89
- renderTheSolution(): TemplateResult;
90
- renderTheDuration(): TemplateResult;
91
- renderTiles(incident: Incident | undefined): "" | TemplateResult<1>;
92
- private _tileShouldDisplayAnImage;
93
- renderTile(incident: Incident): TemplateResult;
94
- renderTileContent(incident: Incident): TemplateResult;
95
72
  private _generateHintText;
96
- renderHintTile(hint: Incident | undefined): TemplateResult;
97
- renderTileTitle(incident: Incident): TemplateResult;
98
- renderTileImage(incident: Incident): TemplateResult;
99
- renderTileTextContent(incident: Incident): TemplateResult;
100
73
  renderSources(): TemplateResult;
101
74
  _handleImageLoadError: (evt: Event, incident: Incident) => false | undefined;
102
75
  }
@@ -1 +1 @@
1
- {"version":3,"file":"guess-the-year.d.ts","sourceRoot":"","sources":["../src/guess-the-year.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAK5E,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAI9B,OAAO,EAAE,QAAQ,EAAc,MAAM,gBAAgB,CAAC;AAsBtD,qBACa,YAAa,SAAQ,UAAU;IAC1C,OAAO,CAAC,UAAU,CAAoB;IACtC,OAAO,CAAC,QAAQ,CAAoB;IAEpC,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO,CAAC,OAAO,CAA0B;IAEzC,IAAI,OAAO,IAIQ,OAAO,CAFzB;IAED,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAEzB;IAGD,UAAU,EAAE,MAAM,CAA2B;IAG7C,kBAAkB,EAAE,OAAO,CAAS;IAGpC,IAAI,EAAE,MAAM,CAAM;IAGlB,OAAO,EAAE,MAAM,CAAM;IAGrB,QAAQ,EAAE,MAAM,CAAM;IAGtB,OAAO,EAAE,MAAM,CAAM;IAGrB,MAAM,EAAE,MAAM,CAAM;IAuBpB,IAAI,EA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IAWjC,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,aAAa;IAkBrB,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,WAAW;IAab,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IA8EpC,OAAO,CAAC,iBAAiB;IAsDzB,aAAa,IAAI,cAAc;IAa/B,qBAAqB,QAAS,KAAK,YAAY,QAAQ,uBAiCrD;CACH;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,YAAY,CAAC;KAChC;CACF"}
@@ -6,22 +6,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { LitElement, css, html } from "lit";
8
8
  import { customElement, property, state } from "lit/decorators.js";
9
- import { unsafeHTML } from "lit/directives/unsafe-html.js";
10
- // import { Task } from '@lit/task';
11
9
  import dayjs from "dayjs";
12
10
  import { Dayjs } from "dayjs";
13
11
  const { setTimeout } = window;
14
- import { Categories } from "./lib/Incident";
15
- import { NoImageImg, RefreshIconSVG, SolutionIconSVG } from "./lib/Icon";
12
+ import { Categories, Category } from "./lib/Incident";
13
+ import { NoImageImg } from "./lib/Icon";
16
14
  import { ApiService, ContentFeedback } from "./lib/ApiService";
17
15
  import { Util } from "./lib/Util";
18
16
  import { i18nFactory } from "./lib/i18n/i18n";
19
17
  import { GameState } from "./lib/enums";
20
18
  import stylesheet from "./scss/main.scss";
21
19
  import { QuestionScoreController } from "./lib/controller/scorecontroller";
22
- // const GREEN = "#07d207";
23
- // const RED = "#ec3737";
24
- // const BLACK = "#000";
25
20
  const SPLASH_DELAY = 1000;
26
21
  const MIN_YEAR = 1950;
27
22
  const MAX_YEAR = 2024;
@@ -34,12 +29,8 @@ let GuessTheYear = class GuessTheYear extends LitElement {
34
29
  set loading(value) {
35
30
  this._loading = value;
36
31
  }
37
- // private _game_engine: Engine;
38
32
  constructor() {
39
33
  super();
40
- this._startTime = new Date();
41
- this._endTime = new Date();
42
- // private _uuid = Math.random();
43
34
  this.sources = [];
44
35
  this._loading = false;
45
36
  this.teeeApiUrl = "https://api.tee-e.com";
@@ -51,16 +42,9 @@ let GuessTheYear = class GuessTheYear extends LitElement {
51
42
  this.impact = "";
52
43
  this.from = dayjs(`${MIN_YEAR}-01-01`, "YYYY-MM-DD");
53
44
  this.to = dayjs(); // defaults to today
54
- this.limit = "";
55
- this.shuffle = false;
56
- this.showDuration = false;
57
- this.showFeedback = false;
58
45
  this.noImageSrc = "";
59
46
  this.suppressImages = false;
60
- this.autoFocus = false;
61
- this.hintIntervalSecs = 7;
62
47
  this.maxHints = 3;
63
- this.maxTries = -1;
64
48
  this.numberOfQuestions = 10;
65
49
  this._numberOfQuestionsSeen = 0;
66
50
  this._incident = undefined;
@@ -71,40 +55,17 @@ let GuessTheYear = class GuessTheYear extends LitElement {
71
55
  this._hintsIndex = 0;
72
56
  this._hints = [];
73
57
  this._solution = undefined;
74
- this._displaySolution = false;
75
- this._answeredCorrectly = false;
76
- this._tries = 0;
77
58
  this._renderState = GameState.INIT;
78
59
  this._score = 30;
79
60
  this.totalScore = 0;
80
61
  // _answer is stored as string because it will be entered character for character
81
62
  this._answer = undefined;
82
63
  this._apiService = new ApiService(this.teeeApiUrl);
83
- this._intervalsPassed = 0;
84
64
  this.i18n = i18nFactory("nl");
85
- // private _incidentsTask: Task = new Task(this, {
86
- // task: async ([]) => {
87
- // console.debug('incidentsTask');
88
- // if (!this.loading) {
89
- // this.loading = true;
90
- // await this.setupNewGame();
91
- // this.loading = false;
92
- // }
93
- // },
94
- // args: () => [
95
- // this.country,
96
- // this.category,
97
- // this.emotion,
98
- // this.impact,
99
- // this.date,
100
- // this.from,
101
- // this.to,
102
- // ],
103
- // });
104
65
  this._handleImageLoadError = (evt, incident) => {
105
66
  // grab the image element that triggered the error
106
67
  const targetImage = evt.target;
107
- console.info(`Error loading image: ${targetImage.src}`);
68
+ console.debug(`Error loading image: ${targetImage.src}`);
108
69
  // find out which no image source needs to be used
109
70
  const noImageSrc = this.noImageSrc || NoImageImg;
110
71
  // don't try to set the image source if it
@@ -126,7 +87,6 @@ let GuessTheYear = class GuessTheYear extends LitElement {
126
87
  return false;
127
88
  };
128
89
  this._score0 = new QuestionScoreController(this, 30, 1000);
129
- // this._engine = new GameController(this);
130
90
  }
131
91
  connectedCallback() {
132
92
  console.debug("connectedCallback");
@@ -137,7 +97,6 @@ let GuessTheYear = class GuessTheYear extends LitElement {
137
97
  disconnectedCallback() {
138
98
  console.debug("disconnectedCallback");
139
99
  super.disconnectedCallback();
140
- // clearInterval(this._intervalHandler);
141
100
  this._renderState = GameState.INIT;
142
101
  this._score0.stop();
143
102
  this._score0.reset();
@@ -237,9 +196,8 @@ let GuessTheYear = class GuessTheYear extends LitElement {
237
196
  // allows to select the number of questions,
238
197
  // select the year range
239
198
  // and to start the game
240
- // TODO: add real content
241
199
  renderGameIntro() {
242
- console.info("renderGameIntro");
200
+ console.debug("renderGameIntro");
243
201
  // pre-render number of question options
244
202
  // and mark selected when they match
245
203
  const selectQuestionOptions = [];
@@ -306,7 +264,7 @@ let GuessTheYear = class GuessTheYear extends LitElement {
306
264
  renderGameStage() {
307
265
  console.debug("renderGameStage");
308
266
  return html `
309
- ${this._renderHeader(this.i18n.translate("game-call-to-action"))}
267
+ ${this._renderHeader(this.i18n.translate("game-call-to-action").replace(/__FROM__/, this.from.year() + '').replace(/__TO__/, this.to.year() + ''))}
310
268
  <div class="guess-the-year-game-stage">
311
269
  <div class="game-score">${this._renderGameScore()}</div>
312
270
 
@@ -340,12 +298,22 @@ let GuessTheYear = class GuessTheYear extends LitElement {
340
298
  </div>
341
299
  `;
342
300
  }
301
+ _shouldDisplayAnImage(incident) {
302
+ const hasImage = !!(incident && incident.image && incident.image[0]);
303
+ const displayImages = !this.suppressImages;
304
+ return hasImage && displayImages;
305
+ }
343
306
  // renders the optional image with the item
344
307
  _renderIncidentImage(incident) {
345
- if (incident && incident.image) {
308
+ if (incident && this._shouldDisplayAnImage(incident)) {
346
309
  return html `
347
310
  <div class="incident--image">
348
- <img src="${incident.image}" />
311
+ <img
312
+ @error=${(evt) => {
313
+ this._handleImageLoadError(evt, incident);
314
+ }}
315
+ src="${incident.image[0]}"
316
+ />
349
317
  </div>
350
318
  `;
351
319
  }
@@ -394,7 +362,7 @@ let GuessTheYear = class GuessTheYear extends LitElement {
394
362
  // check if the answer is correct
395
363
  if (answer) {
396
364
  // this._apiService.postIncidentAnswer(this._incident?.id, answer);
397
- console.info(answer, this._solution, this._score, answer == this._solution);
365
+ console.debug(answer, this._solution, this._score, answer == this._solution);
398
366
  this._answer = answer;
399
367
  }
400
368
  }
@@ -414,7 +382,7 @@ let GuessTheYear = class GuessTheYear extends LitElement {
414
382
  return html `
415
383
  <div class="game-controls--hint">
416
384
  <button @click="${this._handleHintClicked}">
417
- ${this.i18n.translate("show-hint")} (${this.maxHints - this._hintsIndex})
385
+ ${this.i18n.translate("show-hint")} (${this._hints.length - this._hintsIndex})
418
386
  </button>
419
387
  </div>
420
388
  `;
@@ -424,7 +392,7 @@ let GuessTheYear = class GuessTheYear extends LitElement {
424
392
  // subtracts the cost of the hint from
425
393
  // the question score
426
394
  _handleHintClicked() {
427
- console.info("handleHintClicked", [this._hintsIndex, this._hints.length]);
395
+ console.debug("handleHintClicked", [this._hintsIndex, this._hints.length]);
428
396
  if (this._hintsIndex < this._hints.length) {
429
397
  const hintText = this._generateHintText(this._hints[this._hintsIndex]);
430
398
  if (hintText) {
@@ -525,8 +493,8 @@ let GuessTheYear = class GuessTheYear extends LitElement {
525
493
  // private _incidentsStack = [];
526
494
  // private _totalScore: number = 0;
527
495
  setupNewGame() {
528
- console.log("new game!");
529
- console.info({
496
+ console.debug("new game!");
497
+ console.debug({
530
498
  "number of questions": this.numberOfQuestions,
531
499
  from: this.from.toISOString(),
532
500
  to: this.to.toISOString(),
@@ -553,11 +521,8 @@ let GuessTheYear = class GuessTheYear extends LitElement {
553
521
  var _a;
554
522
  this._resetStage();
555
523
  const response = await this._apiService.fetchOneIncident(this.country, this.category, this.emotion, this.impact, this.date, this.from.format("YYYY-MM-DD"), this.to.format("YYYY-MM-DD"), "40", "quiz_year");
556
- this._startTime = new Date();
557
- this._endTime = new Date();
558
524
  this._incident = response.incident;
559
525
  this.sources = response.sources;
560
- this._tries = this.maxTries;
561
526
  this._solution = Number((((_a = response.incident) === null || _a === void 0 ? void 0 : _a.yearplusmonth) || "").substring(0, 4));
562
527
  const answers = [this._solution];
563
528
  const from = this.from.year();
@@ -573,8 +538,8 @@ let GuessTheYear = class GuessTheYear extends LitElement {
573
538
  answers.sort();
574
539
  this._answers = answers;
575
540
  for (let i = 0; i < this.maxHints; i++) {
576
- console.info("loading hint", i);
577
- const response = await this._apiService.fetchOneIncident(this.country, Util.shuffleArray(Categories).shift(), undefined, undefined, "", `${this._solution}-01-01`, `${this._solution}-12-31`, undefined, undefined);
541
+ console.debug("loading hint", i);
542
+ const response = await this._apiService.fetchOneIncident(this.country, Util.shuffleArray([...Categories]).shift(), undefined, undefined, "", `${this._solution}-01-01`, `${this._solution}-12-31`, undefined, undefined);
578
543
  if (response.incident) {
579
544
  this._hints.push(response.incident);
580
545
  }
@@ -592,115 +557,14 @@ let GuessTheYear = class GuessTheYear extends LitElement {
592
557
  // increment question counter
593
558
  this._numberOfQuestionsSeen += 1;
594
559
  }
595
- renderRefreshButton() {
596
- return html `<div class="refresh" id="refresh" @click="${this.setupNewGame}">
597
- <span>${unsafeHTML(RefreshIconSVG)}</span>
598
- </div>`;
599
- }
600
- renderStopGameButton() {
601
- return html `<div
602
- class="stop-game"
603
- id="stop-game"
604
- @click="${() => {
605
- this._displaySolution = true;
606
- }}"
607
- >
608
- <span>${unsafeHTML(SolutionIconSVG)}</span>
609
- </div>`;
610
- }
611
- renderFeedbackPossibility() {
612
- if (this.showFeedback) {
613
- return html `<div class="feedback-possibility">
614
- <input
615
- type="text"
616
- id="feedback"
617
- size="15"
618
- placeholder="${this.i18n.translate("your-feedback")}"
619
- />
620
- </div>`;
621
- }
622
- else {
623
- return html ``;
624
- }
625
- }
626
- renderSubmitPossibility() {
627
- return html `<div class="submit-possibility">
628
- <input
629
- type="text"
630
- id="answer"
631
- size="15"
632
- ?disabled=${this._displaySolution}
633
- placeholder="${this.i18n.translate("your-answer")}"
634
- />
635
- ${this.renderTries()}
636
- </div>`;
637
- }
638
- renderTries() {
639
- const i18nKey = this._tries > 1 ? "tries-left" : "try-left";
640
- if (this._tries >= 0 && !this._displaySolution) {
641
- return html `<span class="tries"
642
- >${this.i18n
643
- .translate(i18nKey)
644
- .replace("__TRIES__", "" + this._tries)}</span
645
- >`;
646
- }
647
- return html ``;
648
- }
649
- renderTheSolution() {
650
- if (this._displaySolution) {
651
- return html `<div class="solution">${this._solution}</div>
652
- ${this.renderTheDuration()} `;
653
- }
654
- return html ``;
655
- }
656
- renderTheDuration() {
657
- const duration = Math.round(new Date(this._endTime.getTime() - this._startTime.getTime()).getTime() /
658
- 1000);
659
- const i18nKey = duration === 1 ? "in-x-seconds" : "in-one-second";
660
- if (this.showDuration && this._answeredCorrectly) {
661
- return html `<div class="timer">
662
- ${this.i18n.translate(i18nKey).replace("__SECONDS__", "" + duration)}
663
- </div>`;
664
- }
665
- return html ``;
666
- }
667
- renderTiles(incident) {
668
- console.debug("renderTiles");
669
- if (!incident) {
670
- return "";
671
- }
672
- return html `${this.renderTile(incident)}`;
673
- }
674
- _tileShouldDisplayAnImage(incident) {
675
- const hasImage = !!incident.image;
676
- const displayImages = !this.suppressImages;
677
- return hasImage && displayImages;
678
- }
679
- renderTile(incident) {
680
- console.debug("renderTile");
681
- const tileContent = this.renderTileContent(incident);
682
- if (this._tileShouldDisplayAnImage(incident)) {
683
- return html `<div class="guess-the-year-tile with-image">
684
- ${tileContent}
685
- </div>`;
686
- }
687
- return html `<div class="guess-the-year-tile">${tileContent}</div>`;
688
- }
689
- renderTileContent(incident) {
690
- console.debug("renderTileContent");
691
- return html `<div class="guess-the-year-tile-content">
692
- ${this.renderTileTitle(incident)} ${this.renderTileImage(incident)}
693
- ${this.renderTileTextContent(incident)}
694
- </div>`;
695
- }
696
560
  _generateHintText(hintIncident) {
697
561
  let hint = "";
698
562
  const hintTemplates = this.i18n.HintTemplates[hintIncident.category];
699
563
  switch (hintIncident.category) {
700
- case "newsItem":
564
+ case Category.newsItem:
701
565
  hint = (hintTemplates[Math.round(Math.random() * hintTemplates.length)] || "").replace(/__TITLE__/, hintIncident.title);
702
566
  break;
703
- case "radioSong":
567
+ case Category.radioSong:
704
568
  // The title property of radioSongs always follow this pattern: track - artist
705
569
  const track = hintIncident.title.replace(/(.*?)\s+\-.*/, "$1");
706
570
  const artist = hintIncident.title.replace(/.*\-(.*)/, "$1");
@@ -709,64 +573,29 @@ let GuessTheYear = class GuessTheYear extends LitElement {
709
573
  .replace(/__ARTIST__/, artist)
710
574
  .replace(/__TRACK__/, track);
711
575
  break;
712
- case "cinemaMovie":
576
+ case Category.cinemaMovie:
713
577
  hint = (hintTemplates[Math.round(Math.random() * hintTemplates.length)] ||
714
578
  hintTemplates[0]).replace(/__TITLE__/, hintIncident.title);
715
579
  break;
716
- case "tech":
580
+ case Category.tech:
717
581
  hint = (hintTemplates[Math.round(Math.random() * hintTemplates.length)] ||
718
582
  hintTemplates[0]).replace(/__TITLE__/, hintIncident.title);
719
583
  break;
720
- case "newsPresenter":
584
+ case Category.newsPresenter:
721
585
  hint = (hintTemplates[Math.round(Math.random() * hintTemplates.length)] ||
722
- hintTemplates[0]).replace(/__TITLE__/, hintIncident.title);
586
+ hintTemplates[0]).replace(/__TITLE__/, hintIncident.title || hintIncident.text);
723
587
  break;
724
- case "sports":
588
+ case Category.sports:
725
589
  hint = (hintTemplates[Math.round(Math.random() * hintTemplates.length)] ||
726
- hintTemplates[0]).replace(/__TITLE__/, hintIncident.title);
590
+ hintTemplates[0]).replace(/__TITLE__/, hintIncident.title || hintIncident.text);
591
+ break;
592
+ case Category.showbizz:
593
+ hint = (hintTemplates[Math.round(Math.random() * hintTemplates.length)] ||
594
+ hintTemplates[0]).replace(/__TITLE__/, hintIncident.title || hintIncident.text);
727
595
  break;
728
596
  }
729
597
  return hint;
730
598
  }
731
- renderHintTile(hint) {
732
- if (hint) {
733
- console.debug("renderHint");
734
- return html `<div class="guess-the-year-hint-tile">
735
- <h1 class="title">
736
- Hint ${this._intervalsPassed} <br />
737
- ${this._generateHintText(hint)}
738
- </h1>
739
- ${this.renderTileTextContent(hint)}
740
- </div>`;
741
- }
742
- return html ``;
743
- }
744
- renderTileTitle(incident) {
745
- console.debug("renderTileTitle");
746
- if (incident.title) {
747
- return html `<h1 class="guess-the-year-tile-title">${incident.title}</h1>`;
748
- }
749
- return html ``;
750
- }
751
- renderTileImage(incident) {
752
- console.debug("renderTileImage");
753
- if (this._tileShouldDisplayAnImage(incident)) {
754
- return html `<img
755
- @error=${(evt) => {
756
- this._handleImageLoadError(evt, incident);
757
- }}
758
- src=${incident.image}
759
- />`;
760
- }
761
- return html ``;
762
- }
763
- renderTileTextContent(incident) {
764
- console.debug("renderTileTextContent");
765
- if (incident.text) {
766
- return html `<p class="hint-text">${incident.text}</p>`;
767
- }
768
- return html ``;
769
- }
770
599
  renderSources() {
771
600
  console.debug("renderSources");
772
601
  if (!this.sources.length) {
@@ -809,7 +638,7 @@ __decorate([
809
638
  type: Dayjs,
810
639
  converter: {
811
640
  fromAttribute: (value) => {
812
- console.info(["from", "from", value]);
641
+ console.debug(["from", "from", value]);
813
642
  if (!value) {
814
643
  return dayjs();
815
644
  }
@@ -819,7 +648,7 @@ __decorate([
819
648
  return dayjs(`${value}-01-01`, "YYYY-MM-DD");
820
649
  },
821
650
  toAttribute: (value) => {
822
- console.info(["from", "to", value]);
651
+ console.debug(["from", "to", value]);
823
652
  return value.format("YYYY-MM-DD");
824
653
  },
825
654
  },
@@ -830,7 +659,7 @@ __decorate([
830
659
  type: Dayjs,
831
660
  converter: {
832
661
  fromAttribute: (value) => {
833
- console.info(["to", "from", value]);
662
+ console.debug(["to", "from", value]);
834
663
  if (!value) {
835
664
  return dayjs();
836
665
  }
@@ -840,42 +669,21 @@ __decorate([
840
669
  return dayjs(`${value}-12-31`, "YYYY-MM-DD");
841
670
  },
842
671
  toAttribute: (value) => {
843
- console.info(["to", "to", value]);
672
+ console.debug(["to", "to", value]);
844
673
  return value.format("YYYY-MM-DD");
845
674
  },
846
675
  },
847
676
  })
848
677
  ], GuessTheYear.prototype, "to", void 0);
849
- __decorate([
850
- property({ type: String })
851
- ], GuessTheYear.prototype, "limit", void 0);
852
- __decorate([
853
- property({ type: Boolean })
854
- ], GuessTheYear.prototype, "shuffle", void 0);
855
- __decorate([
856
- property({ type: Boolean, attribute: "show-duration" })
857
- ], GuessTheYear.prototype, "showDuration", void 0);
858
- __decorate([
859
- property({ type: Boolean, attribute: "show-feedback" })
860
- ], GuessTheYear.prototype, "showFeedback", void 0);
861
678
  __decorate([
862
679
  property({ type: String, attribute: "no-image-src" })
863
680
  ], GuessTheYear.prototype, "noImageSrc", void 0);
864
681
  __decorate([
865
682
  property({ type: Boolean, attribute: "suppress-images" })
866
683
  ], GuessTheYear.prototype, "suppressImages", void 0);
867
- __decorate([
868
- property({ type: Boolean, attribute: "auto-focus" })
869
- ], GuessTheYear.prototype, "autoFocus", void 0);
870
- __decorate([
871
- property({ type: Number, attribute: "hint-interval-length" })
872
- ], GuessTheYear.prototype, "hintIntervalSecs", void 0);
873
684
  __decorate([
874
685
  property({ type: Number, attribute: "max-hints" })
875
686
  ], GuessTheYear.prototype, "maxHints", void 0);
876
- __decorate([
877
- property({ type: Number, attribute: "max-tries" })
878
- ], GuessTheYear.prototype, "maxTries", void 0);
879
687
  __decorate([
880
688
  property({ type: Number, attribute: "number-of-questions", reflect: true })
881
689
  ], GuessTheYear.prototype, "numberOfQuestions", void 0);
@@ -888,15 +696,6 @@ __decorate([
888
696
  __decorate([
889
697
  state()
890
698
  ], GuessTheYear.prototype, "_solution", void 0);
891
- __decorate([
892
- state()
893
- ], GuessTheYear.prototype, "_displaySolution", void 0);
894
- __decorate([
895
- state()
896
- ], GuessTheYear.prototype, "_answeredCorrectly", void 0);
897
- __decorate([
898
- state()
899
- ], GuessTheYear.prototype, "_tries", void 0);
900
699
  __decorate([
901
700
  state()
902
701
  ], GuessTheYear.prototype, "_renderState", void 0);