guess-the-year-web-component 3.0.0 → 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,23 +6,18 @@ 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
- const SPLASH_DELAY = 3000;
20
+ const SPLASH_DELAY = 1000;
26
21
  const MIN_YEAR = 1950;
27
22
  const MAX_YEAR = 2024;
28
23
  const MAX_QUESTIONS = 10;
@@ -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();
@@ -213,10 +172,6 @@ let GuessTheYear = class GuessTheYear extends LitElement {
213
172
  return html `
214
173
  <div id="splash-screen-container" class="splashscreen">
215
174
  <div class="splash-logo">
216
- <img
217
- src="./assets/logo.png"
218
- alt="logo"
219
- />
220
175
  <h2>${this.i18n.translate("game-name")}</h2>
221
176
  <p>${this.i18n.translate("Loading...")}</p>
222
177
  </div>
@@ -241,9 +196,8 @@ let GuessTheYear = class GuessTheYear extends LitElement {
241
196
  // allows to select the number of questions,
242
197
  // select the year range
243
198
  // and to start the game
244
- // TODO: add real content
245
199
  renderGameIntro() {
246
- console.info("renderGameIntro");
200
+ console.debug("renderGameIntro");
247
201
  // pre-render number of question options
248
202
  // and mark selected when they match
249
203
  const selectQuestionOptions = [];
@@ -310,7 +264,7 @@ let GuessTheYear = class GuessTheYear extends LitElement {
310
264
  renderGameStage() {
311
265
  console.debug("renderGameStage");
312
266
  return html `
313
- ${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() + ''))}
314
268
  <div class="guess-the-year-game-stage">
315
269
  <div class="game-score">${this._renderGameScore()}</div>
316
270
 
@@ -344,12 +298,22 @@ let GuessTheYear = class GuessTheYear extends LitElement {
344
298
  </div>
345
299
  `;
346
300
  }
301
+ _shouldDisplayAnImage(incident) {
302
+ const hasImage = !!(incident && incident.image && incident.image[0]);
303
+ const displayImages = !this.suppressImages;
304
+ return hasImage && displayImages;
305
+ }
347
306
  // renders the optional image with the item
348
307
  _renderIncidentImage(incident) {
349
- if (incident && incident.image) {
308
+ if (incident && this._shouldDisplayAnImage(incident)) {
350
309
  return html `
351
310
  <div class="incident--image">
352
- <img src="${incident.image}" />
311
+ <img
312
+ @error=${(evt) => {
313
+ this._handleImageLoadError(evt, incident);
314
+ }}
315
+ src="${incident.image[0]}"
316
+ />
353
317
  </div>
354
318
  `;
355
319
  }
@@ -398,7 +362,7 @@ let GuessTheYear = class GuessTheYear extends LitElement {
398
362
  // check if the answer is correct
399
363
  if (answer) {
400
364
  // this._apiService.postIncidentAnswer(this._incident?.id, answer);
401
- console.info(answer, this._solution, this._score, answer == this._solution);
365
+ console.debug(answer, this._solution, this._score, answer == this._solution);
402
366
  this._answer = answer;
403
367
  }
404
368
  }
@@ -418,7 +382,7 @@ let GuessTheYear = class GuessTheYear extends LitElement {
418
382
  return html `
419
383
  <div class="game-controls--hint">
420
384
  <button @click="${this._handleHintClicked}">
421
- ${this.i18n.translate("show-hint")} (${this.maxHints - this._hintsIndex})
385
+ ${this.i18n.translate("show-hint")} (${this._hints.length - this._hintsIndex})
422
386
  </button>
423
387
  </div>
424
388
  `;
@@ -428,7 +392,7 @@ let GuessTheYear = class GuessTheYear extends LitElement {
428
392
  // subtracts the cost of the hint from
429
393
  // the question score
430
394
  _handleHintClicked() {
431
- console.info("handleHintClicked", [this._hintsIndex, this._hints.length]);
395
+ console.debug("handleHintClicked", [this._hintsIndex, this._hints.length]);
432
396
  if (this._hintsIndex < this._hints.length) {
433
397
  const hintText = this._generateHintText(this._hints[this._hintsIndex]);
434
398
  if (hintText) {
@@ -529,8 +493,8 @@ let GuessTheYear = class GuessTheYear extends LitElement {
529
493
  // private _incidentsStack = [];
530
494
  // private _totalScore: number = 0;
531
495
  setupNewGame() {
532
- console.log("new game!");
533
- console.info({
496
+ console.debug("new game!");
497
+ console.debug({
534
498
  "number of questions": this.numberOfQuestions,
535
499
  from: this.from.toISOString(),
536
500
  to: this.to.toISOString(),
@@ -557,11 +521,8 @@ let GuessTheYear = class GuessTheYear extends LitElement {
557
521
  var _a;
558
522
  this._resetStage();
559
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");
560
- this._startTime = new Date();
561
- this._endTime = new Date();
562
524
  this._incident = response.incident;
563
525
  this.sources = response.sources;
564
- this._tries = this.maxTries;
565
526
  this._solution = Number((((_a = response.incident) === null || _a === void 0 ? void 0 : _a.yearplusmonth) || "").substring(0, 4));
566
527
  const answers = [this._solution];
567
528
  const from = this.from.year();
@@ -577,8 +538,8 @@ let GuessTheYear = class GuessTheYear extends LitElement {
577
538
  answers.sort();
578
539
  this._answers = answers;
579
540
  for (let i = 0; i < this.maxHints; i++) {
580
- console.info("loading hint", i);
581
- 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);
582
543
  if (response.incident) {
583
544
  this._hints.push(response.incident);
584
545
  }
@@ -596,115 +557,14 @@ let GuessTheYear = class GuessTheYear extends LitElement {
596
557
  // increment question counter
597
558
  this._numberOfQuestionsSeen += 1;
598
559
  }
599
- renderRefreshButton() {
600
- return html `<div class="refresh" id="refresh" @click="${this.setupNewGame}">
601
- <span>${unsafeHTML(RefreshIconSVG)}</span>
602
- </div>`;
603
- }
604
- renderStopGameButton() {
605
- return html `<div
606
- class="stop-game"
607
- id="stop-game"
608
- @click="${() => {
609
- this._displaySolution = true;
610
- }}"
611
- >
612
- <span>${unsafeHTML(SolutionIconSVG)}</span>
613
- </div>`;
614
- }
615
- renderFeedbackPossibility() {
616
- if (this.showFeedback) {
617
- return html `<div class="feedback-possibility">
618
- <input
619
- type="text"
620
- id="feedback"
621
- size="15"
622
- placeholder="${this.i18n.translate("your-feedback")}"
623
- />
624
- </div>`;
625
- }
626
- else {
627
- return html ``;
628
- }
629
- }
630
- renderSubmitPossibility() {
631
- return html `<div class="submit-possibility">
632
- <input
633
- type="text"
634
- id="answer"
635
- size="15"
636
- ?disabled=${this._displaySolution}
637
- placeholder="${this.i18n.translate("your-answer")}"
638
- />
639
- ${this.renderTries()}
640
- </div>`;
641
- }
642
- renderTries() {
643
- const i18nKey = this._tries > 1 ? "tries-left" : "try-left";
644
- if (this._tries >= 0 && !this._displaySolution) {
645
- return html `<span class="tries"
646
- >${this.i18n
647
- .translate(i18nKey)
648
- .replace("__TRIES__", "" + this._tries)}</span
649
- >`;
650
- }
651
- return html ``;
652
- }
653
- renderTheSolution() {
654
- if (this._displaySolution) {
655
- return html `<div class="solution">${this._solution}</div>
656
- ${this.renderTheDuration()} `;
657
- }
658
- return html ``;
659
- }
660
- renderTheDuration() {
661
- const duration = Math.round(new Date(this._endTime.getTime() - this._startTime.getTime()).getTime() /
662
- 1000);
663
- const i18nKey = duration === 1 ? "in-x-seconds" : "in-one-second";
664
- if (this.showDuration && this._answeredCorrectly) {
665
- return html `<div class="timer">
666
- ${this.i18n.translate(i18nKey).replace("__SECONDS__", "" + duration)}
667
- </div>`;
668
- }
669
- return html ``;
670
- }
671
- renderTiles(incident) {
672
- console.debug("renderTiles");
673
- if (!incident) {
674
- return "";
675
- }
676
- return html `${this.renderTile(incident)}`;
677
- }
678
- _tileShouldDisplayAnImage(incident) {
679
- const hasImage = !!incident.image;
680
- const displayImages = !this.suppressImages;
681
- return hasImage && displayImages;
682
- }
683
- renderTile(incident) {
684
- console.debug("renderTile");
685
- const tileContent = this.renderTileContent(incident);
686
- if (this._tileShouldDisplayAnImage(incident)) {
687
- return html `<div class="guess-the-year-tile with-image">
688
- ${tileContent}
689
- </div>`;
690
- }
691
- return html `<div class="guess-the-year-tile">${tileContent}</div>`;
692
- }
693
- renderTileContent(incident) {
694
- console.debug("renderTileContent");
695
- return html `<div class="guess-the-year-tile-content">
696
- ${this.renderTileTitle(incident)} ${this.renderTileImage(incident)}
697
- ${this.renderTileTextContent(incident)}
698
- </div>`;
699
- }
700
560
  _generateHintText(hintIncident) {
701
561
  let hint = "";
702
562
  const hintTemplates = this.i18n.HintTemplates[hintIncident.category];
703
563
  switch (hintIncident.category) {
704
- case "newsItem":
564
+ case Category.newsItem:
705
565
  hint = (hintTemplates[Math.round(Math.random() * hintTemplates.length)] || "").replace(/__TITLE__/, hintIncident.title);
706
566
  break;
707
- case "radioSong":
567
+ case Category.radioSong:
708
568
  // The title property of radioSongs always follow this pattern: track - artist
709
569
  const track = hintIncident.title.replace(/(.*?)\s+\-.*/, "$1");
710
570
  const artist = hintIncident.title.replace(/.*\-(.*)/, "$1");
@@ -713,64 +573,29 @@ let GuessTheYear = class GuessTheYear extends LitElement {
713
573
  .replace(/__ARTIST__/, artist)
714
574
  .replace(/__TRACK__/, track);
715
575
  break;
716
- case "cinemaMovie":
576
+ case Category.cinemaMovie:
717
577
  hint = (hintTemplates[Math.round(Math.random() * hintTemplates.length)] ||
718
578
  hintTemplates[0]).replace(/__TITLE__/, hintIncident.title);
719
579
  break;
720
- case "tech":
580
+ case Category.tech:
721
581
  hint = (hintTemplates[Math.round(Math.random() * hintTemplates.length)] ||
722
582
  hintTemplates[0]).replace(/__TITLE__/, hintIncident.title);
723
583
  break;
724
- case "newsPresenter":
584
+ case Category.newsPresenter:
725
585
  hint = (hintTemplates[Math.round(Math.random() * hintTemplates.length)] ||
726
- hintTemplates[0]).replace(/__TITLE__/, hintIncident.title);
586
+ hintTemplates[0]).replace(/__TITLE__/, hintIncident.title || hintIncident.text);
727
587
  break;
728
- case "sports":
588
+ case Category.sports:
729
589
  hint = (hintTemplates[Math.round(Math.random() * hintTemplates.length)] ||
730
- 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);
731
595
  break;
732
596
  }
733
597
  return hint;
734
598
  }
735
- renderHintTile(hint) {
736
- if (hint) {
737
- console.debug("renderHint");
738
- return html `<div class="guess-the-year-hint-tile">
739
- <h1 class="title">
740
- Hint ${this._intervalsPassed} <br />
741
- ${this._generateHintText(hint)}
742
- </h1>
743
- ${this.renderTileTextContent(hint)}
744
- </div>`;
745
- }
746
- return html ``;
747
- }
748
- renderTileTitle(incident) {
749
- console.debug("renderTileTitle");
750
- if (incident.title) {
751
- return html `<h1 class="guess-the-year-tile-title">${incident.title}</h1>`;
752
- }
753
- return html ``;
754
- }
755
- renderTileImage(incident) {
756
- console.debug("renderTileImage");
757
- if (this._tileShouldDisplayAnImage(incident)) {
758
- return html `<img
759
- @error=${(evt) => {
760
- this._handleImageLoadError(evt, incident);
761
- }}
762
- src=${incident.image}
763
- />`;
764
- }
765
- return html ``;
766
- }
767
- renderTileTextContent(incident) {
768
- console.debug("renderTileTextContent");
769
- if (incident.text) {
770
- return html `<p class="hint-text">${incident.text}</p>`;
771
- }
772
- return html ``;
773
- }
774
599
  renderSources() {
775
600
  console.debug("renderSources");
776
601
  if (!this.sources.length) {
@@ -813,7 +638,7 @@ __decorate([
813
638
  type: Dayjs,
814
639
  converter: {
815
640
  fromAttribute: (value) => {
816
- console.info(["from", "from", value]);
641
+ console.debug(["from", "from", value]);
817
642
  if (!value) {
818
643
  return dayjs();
819
644
  }
@@ -823,7 +648,7 @@ __decorate([
823
648
  return dayjs(`${value}-01-01`, "YYYY-MM-DD");
824
649
  },
825
650
  toAttribute: (value) => {
826
- console.info(["from", "to", value]);
651
+ console.debug(["from", "to", value]);
827
652
  return value.format("YYYY-MM-DD");
828
653
  },
829
654
  },
@@ -834,7 +659,7 @@ __decorate([
834
659
  type: Dayjs,
835
660
  converter: {
836
661
  fromAttribute: (value) => {
837
- console.info(["to", "from", value]);
662
+ console.debug(["to", "from", value]);
838
663
  if (!value) {
839
664
  return dayjs();
840
665
  }
@@ -844,42 +669,21 @@ __decorate([
844
669
  return dayjs(`${value}-12-31`, "YYYY-MM-DD");
845
670
  },
846
671
  toAttribute: (value) => {
847
- console.info(["to", "to", value]);
672
+ console.debug(["to", "to", value]);
848
673
  return value.format("YYYY-MM-DD");
849
674
  },
850
675
  },
851
676
  })
852
677
  ], GuessTheYear.prototype, "to", void 0);
853
- __decorate([
854
- property({ type: String })
855
- ], GuessTheYear.prototype, "limit", void 0);
856
- __decorate([
857
- property({ type: Boolean })
858
- ], GuessTheYear.prototype, "shuffle", void 0);
859
- __decorate([
860
- property({ type: Boolean, attribute: "show-duration" })
861
- ], GuessTheYear.prototype, "showDuration", void 0);
862
- __decorate([
863
- property({ type: Boolean, attribute: "show-feedback" })
864
- ], GuessTheYear.prototype, "showFeedback", void 0);
865
678
  __decorate([
866
679
  property({ type: String, attribute: "no-image-src" })
867
680
  ], GuessTheYear.prototype, "noImageSrc", void 0);
868
681
  __decorate([
869
682
  property({ type: Boolean, attribute: "suppress-images" })
870
683
  ], GuessTheYear.prototype, "suppressImages", void 0);
871
- __decorate([
872
- property({ type: Boolean, attribute: "auto-focus" })
873
- ], GuessTheYear.prototype, "autoFocus", void 0);
874
- __decorate([
875
- property({ type: Number, attribute: "hint-interval-length" })
876
- ], GuessTheYear.prototype, "hintIntervalSecs", void 0);
877
684
  __decorate([
878
685
  property({ type: Number, attribute: "max-hints" })
879
686
  ], GuessTheYear.prototype, "maxHints", void 0);
880
- __decorate([
881
- property({ type: Number, attribute: "max-tries" })
882
- ], GuessTheYear.prototype, "maxTries", void 0);
883
687
  __decorate([
884
688
  property({ type: Number, attribute: "number-of-questions", reflect: true })
885
689
  ], GuessTheYear.prototype, "numberOfQuestions", void 0);
@@ -892,15 +696,6 @@ __decorate([
892
696
  __decorate([
893
697
  state()
894
698
  ], GuessTheYear.prototype, "_solution", void 0);
895
- __decorate([
896
- state()
897
- ], GuessTheYear.prototype, "_displaySolution", void 0);
898
- __decorate([
899
- state()
900
- ], GuessTheYear.prototype, "_answeredCorrectly", void 0);
901
- __decorate([
902
- state()
903
- ], GuessTheYear.prototype, "_tries", void 0);
904
699
  __decorate([
905
700
  state()
906
701
  ], GuessTheYear.prototype, "_renderState", void 0);