Icard/angular-clarity-master(work.../node_modules/angularx-qrcode/esm2022/lib/angularx-qrcode.component.mjs

272 lines
37 KiB
JavaScript

import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewChild, } from "@angular/core";
import { toCanvas, toDataURL, toString, } from "qrcode";
import * as i0 from "@angular/core";
import * as i1 from "@angular/platform-browser";
class QRCodeComponent {
constructor(renderer, sanitizer) {
this.renderer = renderer;
this.sanitizer = sanitizer;
this.allowEmptyString = false;
this.colorDark = "#000000ff";
this.colorLight = "#ffffffff";
this.cssClass = "qrcode";
this.elementType = "canvas";
this.errorCorrectionLevel = "M";
this.margin = 4;
this.qrdata = "";
this.scale = 4;
this.width = 10;
this.qrCodeURL = new EventEmitter();
this.context = null;
}
async ngOnChanges() {
await this.createQRCode();
}
isValidQrCodeText(data) {
if (this.allowEmptyString === false) {
return !(typeof data === "undefined" ||
data === "" ||
data === "null" ||
data === null);
}
return !(typeof data === "undefined");
}
toDataURL(qrCodeConfig) {
return new Promise((resolve, reject) => {
toDataURL(this.qrdata, qrCodeConfig, (err, url) => {
if (err) {
reject(err);
}
else {
resolve(url);
}
});
});
}
toCanvas(canvas, qrCodeConfig) {
return new Promise((resolve, reject) => {
toCanvas(canvas, this.qrdata, qrCodeConfig, (error) => {
if (error) {
reject(error);
}
else {
resolve("success");
}
});
});
}
toSVG(qrCodeConfig) {
return new Promise((resolve, reject) => {
toString(this.qrdata, qrCodeConfig, (err, url) => {
if (err) {
reject(err);
}
else {
resolve(url);
}
});
});
}
renderElement(element) {
for (const node of this.qrcElement.nativeElement.childNodes) {
this.renderer.removeChild(this.qrcElement.nativeElement, node);
}
this.renderer.appendChild(this.qrcElement.nativeElement, element);
}
async createQRCode() {
if (this.version && this.version > 40) {
console.warn("[angularx-qrcode] max value for `version` is 40");
this.version = 40;
}
else if (this.version && this.version < 1) {
console.warn("[angularx-qrcode]`min value for `version` is 1");
this.version = 1;
}
else if (this.version !== undefined && isNaN(this.version)) {
console.warn("[angularx-qrcode] version should be a number, defaulting to auto.");
this.version = undefined;
}
try {
if (!this.isValidQrCodeText(this.qrdata)) {
throw new Error("[angularx-qrcode] Field `qrdata` is empty, set 'allowEmptyString=\"true\"' to overwrite this behaviour.");
}
if (this.isValidQrCodeText(this.qrdata) && this.qrdata === "") {
this.qrdata = " ";
}
const config = {
color: {
dark: this.colorDark,
light: this.colorLight,
},
errorCorrectionLevel: this.errorCorrectionLevel,
margin: this.margin,
scale: this.scale,
version: this.version,
width: this.width,
};
const centerImageSrc = this.imageSrc;
const centerImageHeight = this.imageHeight || 40;
const centerImageWidth = this.imageWidth || 40;
switch (this.elementType) {
case "canvas": {
const canvasElement = this.renderer.createElement("canvas");
this.context = canvasElement.getContext("2d");
this.toCanvas(canvasElement, config)
.then(() => {
if (this.ariaLabel) {
this.renderer.setAttribute(canvasElement, "aria-label", `${this.ariaLabel}`);
}
if (this.title) {
this.renderer.setAttribute(canvasElement, "title", `${this.title}`);
}
if (centerImageSrc && this.context) {
this.centerImage = new Image(centerImageWidth, centerImageHeight);
if (centerImageSrc !== this.centerImage.src) {
this.centerImage.src = centerImageSrc;
}
if (centerImageHeight !== this.centerImage.height) {
this.centerImage.height = centerImageHeight;
}
if (centerImageWidth !== this.centerImage.width) {
this.centerImage.width = centerImageWidth;
}
const centerImage = this.centerImage;
if (centerImage) {
centerImage.onload = () => {
this.context?.drawImage(centerImage, canvasElement.width / 2 - centerImageWidth / 2, canvasElement.height / 2 - centerImageHeight / 2, centerImageWidth, centerImageHeight);
};
}
}
this.renderElement(canvasElement);
this.emitQRCodeURL(canvasElement);
})
.catch((e) => {
console.error("[angularx-qrcode] canvas error:", e);
});
break;
}
case "svg": {
const svgParentElement = this.renderer.createElement("div");
this.toSVG(config)
.then((svgString) => {
this.renderer.setProperty(svgParentElement, "innerHTML", svgString);
const svgElement = svgParentElement.firstChild;
this.renderer.setAttribute(svgElement, "height", `${this.width}`);
this.renderer.setAttribute(svgElement, "width", `${this.width}`);
this.renderElement(svgElement);
this.emitQRCodeURL(svgElement);
})
.catch((e) => {
console.error("[angularx-qrcode] svg error:", e);
});
break;
}
case "url":
case "img":
default: {
const imgElement = this.renderer.createElement("img");
this.toDataURL(config)
.then((dataUrl) => {
if (this.alt) {
imgElement.setAttribute("alt", this.alt);
}
if (this.ariaLabel) {
imgElement.setAttribute("aria-label", this.ariaLabel);
}
imgElement.setAttribute("src", dataUrl);
if (this.title) {
imgElement.setAttribute("title", this.title);
}
this.renderElement(imgElement);
this.emitQRCodeURL(imgElement);
})
.catch((e) => {
console.error("[angularx-qrcode] img/url error:", e);
});
}
}
}
catch (e) {
console.error("[angularx-qrcode] Error generating QR Code:", e.message);
}
}
emitQRCodeURL(element) {
const className = element.constructor.name;
if (className === SVGSVGElement.name) {
const svgHTML = element.outerHTML;
const blob = new Blob([svgHTML], { type: "image/svg+xml" });
const urlSvg = URL.createObjectURL(blob);
const urlSanitized = this.sanitizer.bypassSecurityTrustUrl(urlSvg);
this.qrCodeURL.emit(urlSanitized);
return;
}
let urlImage = "";
if (className === HTMLCanvasElement.name) {
urlImage = element.toDataURL("image/png");
}
if (className === HTMLImageElement.name) {
urlImage = element.src;
}
fetch(urlImage)
.then((urlResponse) => urlResponse.blob())
.then((blob) => URL.createObjectURL(blob))
.then((url) => this.sanitizer.bypassSecurityTrustUrl(url))
.then((urlSanitized) => {
this.qrCodeURL.emit(urlSanitized);
})
.catch((error) => {
console.error("[angularx-qrcode] Error when fetching image/png URL: " + error);
});
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: QRCodeComponent, deps: [{ token: i0.Renderer2 }, { token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.6", type: QRCodeComponent, selector: "qrcode", inputs: { allowEmptyString: "allowEmptyString", colorDark: "colorDark", colorLight: "colorLight", cssClass: "cssClass", elementType: "elementType", errorCorrectionLevel: "errorCorrectionLevel", imageSrc: "imageSrc", imageHeight: "imageHeight", imageWidth: "imageWidth", margin: "margin", qrdata: "qrdata", scale: "scale", version: "version", width: "width", alt: "alt", ariaLabel: "ariaLabel", title: "title" }, outputs: { qrCodeURL: "qrCodeURL" }, viewQueries: [{ propertyName: "qrcElement", first: true, predicate: ["qrcElement"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: `<div #qrcElement [class]="cssClass"></div>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
export { QRCodeComponent };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: QRCodeComponent, decorators: [{
type: Component,
args: [{
selector: "qrcode",
changeDetection: ChangeDetectionStrategy.OnPush,
template: `<div #qrcElement [class]="cssClass"></div>`,
}]
}], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i1.DomSanitizer }]; }, propDecorators: { allowEmptyString: [{
type: Input
}], colorDark: [{
type: Input
}], colorLight: [{
type: Input
}], cssClass: [{
type: Input
}], elementType: [{
type: Input
}], errorCorrectionLevel: [{
type: Input
}], imageSrc: [{
type: Input
}], imageHeight: [{
type: Input
}], imageWidth: [{
type: Input
}], margin: [{
type: Input
}], qrdata: [{
type: Input
}], scale: [{
type: Input
}], version: [{
type: Input
}], width: [{
type: Input
}], alt: [{
type: Input
}], ariaLabel: [{
type: Input
}], title: [{
type: Input
}], qrCodeURL: [{
type: Output
}], qrcElement: [{
type: ViewChild,
args: ["qrcElement", { static: true }]
}] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5ndWxhcngtcXJjb2RlLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL2FuZ3VsYXJ4LXFyY29kZS9zcmMvbGliL2FuZ3VsYXJ4LXFyY29kZS5jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJt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0YSA9PT0gXCJudWxsXCIgfHxcbiAgICAgICAgZGF0YSA9PT0gbnVsbFxuICAgICAgKVxuICAgIH1cbiAgICByZXR1cm4gISh0eXBlb2YgZGF0YSA9PT0gXCJ1bmRlZmluZWRcIilcbiAgfVxuXG4gIHByaXZhdGUgdG9EYXRhVVJMKHFyQ29kZUNvbmZpZzogUVJDb2RlVG9EYXRhVVJMT3B0aW9ucyk6IFByb21pc2U8Rml4TWVMYXRlcj4ge1xuICAgIHJldHVybiBuZXcgUHJvbWlzZShcbiAgICAgIChcbiAgICAgICAgcmVzb2x2ZTogKGFyZzogRml4TWVMYXRlcikgPT4gRml4TWVMYXRlcixcbiAgICAgICAgcmVqZWN0OiAoYXJnOiBGaXhNZUxhdGVyKSA9PiBGaXhNZUxhdGVyXG4gICAgICApID0+IHtcbiAgICAgICAgdG9EYXRhVVJMKFxuICAgICAgICAgIHRoaXMucXJkYXRhLFxuICAgICAgICAgIHFyQ29kZUNvbmZpZyxcbiAgICAgICAgICAoZXJyOiBFcnJvciB8IG51bGwgfCB1bmRlZmluZWQsIHVybDogc3RyaW5nKSA9PiB7XG4gICAgICAgICAgICBpZiAoZXJyKSB7XG4gICAgICAgICAgICAgIHJlamVjdChlcnIpXG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICByZXNvbHZlKHVybClcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIClcbiAgICAgIH1cbiAgICApXG4gIH1cblxuICBwcml2YXRlIHRvQ2FudmFzKFxuICAgIGNhbnZhczogSFRNTENhbnZhc0VsZW1lbnQsXG4gICAgcXJDb2RlQ29uZmlnOiBRUkNvZGVSZW5kZXJlcnNPcHRpb25zXG4gICk6IFByb21pc2U8Rml4TWVMYXRlcj4ge1xuICAgIHJldHVybiBuZXcgUHJvbWlzZShcbiAgICAgIChcbiAgICAgICAgcmVzb2x2ZTogKGFyZzogRml4TWVMYXRlcikgPT4gRml4TWVMYXRlcixcbiAgICAgICAgcmVqZWN0OiAoYXJnOiBGaXhNZUxhdGVyKSA9PiBGaXhNZUxhdGVyXG4gICAgICApID0+IHtcbiAgICAgICAgdG9DYW52YXMoXG4gICAgICAgICAgY2FudmFzLFxuICAgICAgICAgIHRoaXMucXJkYXRhLFxuICAgICAgICAgIHFyQ29kZUNvbmZpZyxcbiAgICAgICAgICAoZXJyb3I6IEVycm9yIHwgbnVsbCB8IHVuZGVmaW5lZCkgPT4ge1xuICAgICAgICAgICAgaWYgKGVycm9yKSB7XG4gICAgICAgICAgICAgIHJlamVjdChlcnJvcilcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHJlc29sdmUoXCJzdWNjZXNzXCIpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICApXG4gICAgICB9XG4gICAgKVxuICB9XG5cbiAgcHJpdmF0ZSB0b1NWRyhxckNvZGVDb25maWc6IFFSQ29kZVRvU3RyaW5nT3B0aW9ucyk6IFByb21pc2U8Rml4TWVMYXRlcj4ge1xuICAgIHJldHVybiBuZXcgUHJvbWlzZShcbiAgICAgIChcbiAgICAgICAgcmVzb2x2ZTogKGFyZzogRml4TWVMYXRlcikgPT4gRml4TWVMYXRlcixcbiAgICAgICAgcmVqZWN0OiAoYXJnOiBGaXhNZUxhdGVyKSA9PiBGaXhNZUxhdGVyXG4gICAgICApID0+IHtcbiAgICAgICAgdG9TdHJpbmcoXG4gICAgICAgICAgdGhpcy5xcmRhdGEsXG4gICAgICAgICAgcXJDb2RlQ29uZmlnLFxuICAgICAgICAgIChlcnI6IEVycm9yIHwgbnVsbCB8IHVuZGVmaW5lZCwgdXJsOiBzdHJpbmcpID0+IHtcbiAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgcmVqZWN0KGVycilcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHJlc29sdmUodXJsKVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgKVxu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IHRoaXMuaW1hZ2VTcmNcbiAgICAgIGNvbnN0IGNlbnRlckltYWdlSGVpZ2h0ID0gdGhpcy5pbWFnZUhlaWdodCB8fCA0MFxuICAgICAgY29uc3QgY2VudGVySW1hZ2VXaWR0aCA9IHRoaXMuaW1hZ2VXaWR0aCB8fCA0MFxuXG4gICAgICBzd2l0Y2ggKHRoaXMuZWxlbWVudFR5cGUpIHtcbiAgICAgICAgY2FzZSBcImNhbnZhc1wiOiB7XG4gICAgICAgICAgY29uc3QgY2FudmFzRWxlbWVudDogSFRNTENhbnZhc0VsZW1lbnQgPVxuICAgICAgICAgICAgdGhpcy5yZW5kZXJlci5jcmVhdGVFbGVtZW50KFwiY2FudmFzXCIpXG4gICAgICAgICAgdGhpcy5jb250ZXh0ID0gY2FudmFzRWxlbWVudC5nZXRDb250ZXh0KFwiMmRcIilcbiAgICAgICAgICB0aGlzLnRvQ2FudmFzKGNhbnZhc0VsZW1lbnQsIGNvbmZpZylcbiAgICAgICAgICAgIC50aGVuKCgpID0+IHtcbiAgICAgICAgICAgICAgaWYgKHRoaXMuYXJpYUxhYmVsKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5yZW5kZXJlci5zZXRBdHRyaWJ1dGUoXG4gICAgICAgICAgICAgICAgICBjYW52YXNFbGVtZW50LFxuICAgICAgICAgICAgICAgICAgXCJhcmlhLWxhYmVsXCIsXG4gICAgICAgICAgICAgICAgICBgJHt0aGlzLmFyaWFMYWJlbH1gXG4gICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIGlmICh0aGlzLnRpdGxlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5yZW5kZXJlci5zZXRBdHRyaWJ1dGUoXG4gICAgICAgICAgICAgICAgICBjYW52YXNFbGVtZW50LFxuICAgICAgICAgICAgICAgICAgXCJ0aXRsZVwiLFxuICAgICAgICAgICAgICAgICAgYCR7dGhpcy50aXRsZX1gXG4gICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgaWYgKGNlbnRlckltYWdlU3JjICYmIHRoaXMuY29udGV4dCkge1xuICAgICAgICAgICAgICAgIHRoaXMuY2VudGVySW1hZ2UgPSBuZXcgSW1hZ2UoXG4gICAgICAgICAgICAgICAgICBjZW50ZXJJbWFnZVdpZHRoLFxuICAgICAgICAgICAgICAgICAgY2VudGVySW1hZ2VIZWlnaHRcbiAgICAgICAgICAgICAgICApXG5cbiAgICAgICAgICAgICAgICBpZiAoY2VudGVySW1hZ2VTcmMgIT09IHRoaXMuY2VudGVySW1hZ2Uuc3JjKSB7XG4gICAgICAgICAgICAgICAgICB0aGlzLmNlbnRlckltYWdlLnNyYyA9IGNlbnRlckltYWdlU3JjXG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKGNlbnRlckltYWdlSGVpZ2h0ICE9PSB0aGlzLmNlbnRlckltYWdlLmhlaWdodCkge1xuICAgICAgICAgICAgICAgICAgdGhpcy5jZW50ZXJJbWFnZS5oZWlnaHQgPSBjZW50ZXJJbWFnZUhlaWdodFxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmIChjZW50ZXJJbWFnZVdpZHRoICE9PSB0aGlzLmNlbnRlckltYWdlLndpZHRoKSB7XG4gICAgICAgICAgICAgICAgICB0aGlzLmNlbnRlckltYWdlLndpZHRoID0gY2VudGVySW1hZ2VXaWR0aFxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGNvbnN0IGNlbnRlckltYWdlID0gdGhpcy5jZW50ZXJJbWFnZVxuXG4gICAgICAgICAgICAgICAgaWYgKGNlbnRlckltYWdlKSB7XG4gICAgICAgICAgICAgICAgICBjZW50ZXJJbWFnZS5vbmxvYWQgPSAoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGV4dD8uZHJhd0ltYWdlKFxuICAgICAgICAgICAgICAgICAgICAgIGNlbnRlckltYWdlLFxuICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc0VsZW1lbnQud2lkdGggLyAyIC0gY2VudGVySW1hZ2VXaWR0aCAvIDIsXG4gICAgICAgICAgICAgICAgICAgICAgY2FudmFzRWxlbWVudC5oZWlnaHQgLyAyIC0gY2VudGVySW1hZ2VIZWlnaHQgLyAyLFxuICAgICAgICAgICAgICAgICAgICAgIGNlbnRlckltYWdlV2lkdGgsXG4gICAgICAgICAgICAgICAgICAgICAgY2VudGVySW1hZ2VIZWlnaHRcbiAgICAgICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgIHRoaXMucmVuZGVyRWxlbWVudChjYW52YXNFbGVtZW50KVxuICAgICAgICAgICAgICB0aGlzLmVtaXRRUkNvZGVVUkwoY2FudmFzRWxlbWVudCBhcyBIVE1MQ2FudmFzRWxlbWVudClcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAuY2F0Y2goKGUpID0+IHtcbiAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihcIlthbmd1bGFyeC1xcmNvZGVdIGNhbnZhcyBlcnJvcjpcIiwgZSlcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgYnJlYWtcbiAgICAgICAgfVxuICAgICAgICBjYXNlIFwic3ZnXCI6IHtcbiAgICAgICAgICBjb25zdCBzdmdQYXJlbnRFbGVtZW50OiBIVE1MRWxlbWVudCA9XG4gICAgICAgICAgICB0aGlzLnJlbmRlcmVyLmNyZWF0ZUVsZW1lbnQoXCJkaXZcIilcbiAgICAgICAgICB0aGlzLnRvU1ZHKGNvbmZpZylcbiAgICAgICAgICAgIC50aGVuKChzdmdTdHJpbmc6IHN0cmluZykgPT4ge1xuICAgICAgICAgICAgICB0aGlzLnJlbmRlcmVyLnNldFByb3BlcnR5KFxuICAgICAgICAgICAgICAgIHN2Z1BhcmVudEVsZW1lbnQsXG4gICAgICAgICAgICAgICAgXCJpbm5lckhUTUxcIixcbiAgICAgICAgICAgICAgICBzdmdTdHJpbmdcbiAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgICBjb25zdCBzdmdFbGVtZW50ID0gc3ZnUGFyZW50RWxlbWVudC5maXJzdENoaWxkIGFzIFNWR1NWR0VsZW1lbnRcbiAgICAgICAgICAgICAgdGhpcy5yZW5kZXJlci5zZXRBdHRyaWJ1dGUoc3ZnRWxlbWVudCwgXCJoZWlnaHRcIiwgYCR7dGhpcy53aWR0aH1gKVxuICAgICAgICAgICAgICB0aGlzLnJlbmRlcmVyLnNldEF0dHJpYnV0ZShzdmdFbGVtZW50LCBcIndpZHRoXCIsIGAke3RoaXMud2lkdGh9YClcbiAgICAgICAgICAgICAgdGhpcy5yZW5kZXJFbGVtZW50KHN2Z0VsZW1lbnQpXG4gICAgICAgICAgICAgIHRoaXMuZW1pdFFSQ29kZVVSTChzdmdFbGVtZW50KVxuICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIC5jYXRjaCgoZSkgPT4ge1xuICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKFwiW2FuZ3VsYXJ4LXFyY29kZV0gc3ZnIGVycm9yOlwiLCBlKVxuICAgICAgICAgICAgfSlcbiAgICAgICAgICBicmVha1xuICAgICAgICB9XG4gICAgICAgIGNhc2UgXCJ1cmxcIjpcbiAgICAgICAgY2FzZSBcImltZ1wiOlxuICAgICAgICBkZWZhdWx0OiB7XG4gICAgICAgICAgY29uc3QgaW1nRWxlbWVudDogSFRNTEltYWdlRWxlbWVudCA9XG4gICAgICAgICAgICB0aGlzLnJlbmRlcmVyLmNyZWF0ZUVsZW1lbnQoXCJpbWdcIilcbiAgICAgICAgICB0aGlzLnRvRGF0YVVSTChjb25maWcpXG4gICAgICAgICAgICAudGhlbigoZGF0YVVybDogc3RyaW5nKSA9PiB7XG4gICAgICAgICAgICAgIGlmICh0aGlzLmFsdCkge1xuICAgICAgICAgICAgICAgIGltZ0VsZW1lbnQuc2V0Q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