} */
- __publicField(this, "entities", {});
- }
- /**
- * @param {import('../../../../schema/__generated__/schema.types.js').DetectedRequest} request
- */
- addRequest(request2) {
- let hostname;
- try {
- hostname = new URL(request2.url).hostname;
- } catch (e3) {
- hostname = request2.url;
- }
- let displayName;
- const urlHostname = hostname.replace(/^www\./, "");
- if (request2.entityName) {
- if (request2.entityName === request2.eTLDplus1) {
- displayName = request2.eTLDplus1;
- } else {
- displayName = removeTLD(request2.entityName);
- }
- } else {
- displayName = request2.eTLDplus1 || request2.url;
- }
- if (!this.entities[displayName]) {
- this.entities[displayName] = new AggregateCompanyData(request2.ownerName, displayName, request2.prevalence ?? 0);
- }
- this.entities[displayName].addUrl(urlHostname, request2.category);
- this.entitiesCount = Object.keys(this.entities).length;
- this.requestCount += 1;
- }
- /**
- * Returns a list of AggregateCompanyData sorted by the entity prevalence
- * @returns {AggregateCompanyData[]}
- */
- sortedByPrevalence() {
- return [...Object.values(this.entities)].sort((a3, b3) => b3.prevalence - a3.prevalence);
- }
- };
- var states = (
- /** @type {const} */
- {
- /* 01 */
- protectionsOn: "protectionsOn",
- /* 02 */
- protectionsOn_blocked: "protectionsOn_blocked",
- /* 03 */
- protectionsOn_blocked_allowedTrackers: "protectionsOn_blocked_allowedTrackers",
- /* 04 */
- protectionsOn_blocked_allowedNonTrackers: "protectionsOn_blocked_allowedNonTrackers",
- /* 05 */
- protectionsOn_blocked_allowedTrackers_allowedNonTrackers: "protectionsOn_blocked_allowedTrackers_allowedNonTrackers",
- /* 06 */
- protectionsOn_allowedTrackers: "protectionsOn_allowedTrackers",
- /* 07 */
- protectionsOn_allowedNonTrackers: "protectionsOn_allowedNonTrackers",
- /* 08 */
- protectionsOn_allowedTrackers_allowedNonTrackers: "protectionsOn_allowedTrackers_allowedNonTrackers",
- /* 09 */
- protectionsOn_allowedFirstParty: "protectionsOn_allowedFirstParty",
- /* 010 */
- protectionsOn_allowedFirstParty_allowedNonTrackers: "protectionsOn_allowedFirstParty_allowedNonTrackers",
- /* 011 */
- protectionsOff: "protectionsOff",
- /* 012 */
- protectionsOff_allowedTrackers: "protectionsOff_allowedTrackers",
- /* 013 */
- protectionsOff_allowedNonTrackers: "protectionsOff_allowedNonTrackers",
- /* 014 */
- protectionsOff_allowedTrackers_allowedNonTrackers: "protectionsOff_allowedTrackers_allowedNonTrackers"
- }
- );
- var RequestDetails = class {
- /**
- * @param {string[]} surrogates - any installed surrogates, just the domains
- */
- constructor(surrogates) {
- __publicField(this, "surrogates");
- __publicField(this, "all", new AggregatedCompanyResponseData());
- __publicField(this, "blocked", new AggregatedCompanyResponseData());
- __publicField(this, "allowed", {
- adClickAttribution: new AggregatedCompanyResponseData(),
- ownedByFirstParty: new AggregatedCompanyResponseData(),
- ruleException: new AggregatedCompanyResponseData(),
- protectionDisabled: new AggregatedCompanyResponseData(),
- otherThirdPartyRequest: new AggregatedCompanyResponseData()
- });
- this.surrogates = surrogates;
- }
- /**
- * Loop over every seen entity
- * @param {(entity: AggregateCompanyData) => void} fn
- */
- forEachEntity(fn) {
- for (const entity of Object.values(this.all.entities)) {
- fn(entity);
- }
- }
- /**
- * @returns {number}
- */
- blockedCount() {
- return this.blocked.entitiesCount;
- }
- /**
- * The number of entities observed that had 'special' requests.
- *
- * 'special' means that a request was classified as a tracker, but we didn't block it
- * for any given reason. Note: This list excludes 'non-special' requests such as 3rd party
- * requests not classified as trackers
- *
- * @returns {number}
- */
- allowedSpecialCount() {
- return this.allowed.adClickAttribution.entitiesCount + this.allowed.ownedByFirstParty.entitiesCount + this.allowed.ruleException.entitiesCount + this.allowed.protectionDisabled.entitiesCount;
- }
- /**
- * The number of entities observed that had 'non-special' requests.
- *
- * 'non-special' means a request that was observed, but it was *not* classified as a tracker
- *
- * @returns {number}
- */
- allowedNonSpecialCount() {
- return this.allowed.otherThirdPartyRequest.entitiesCount;
- }
- /**
- * The number of entities observed that were owned by the first party website
- */
- allowedFirstPartyCount() {
- return this.allowed.ownedByFirstParty.entitiesCount;
- }
- /**
- * When all the 'special' entities observed belong to the first party
- */
- allowedFirstPartyOnly() {
- return this.allowedFirstPartyCount() > 0 && this.allowedFirstPartyCount() === this.allowedSpecialCount();
- }
- /**
- * Create a list of company names, excluding any 'unknown' ones.
- * @returns {string[]}
- */
- blockedCompanyNames() {
- const output2 = [];
- for (const entity of Object.values(this.blocked.entities)) {
- if (entity.name === "unknown")
- continue;
- output2.push(entity);
- }
- return output2.sort((a3, b3) => b3.prevalence - a3.prevalence).map((entity) => entity.displayName);
- }
- /**
- * @param {boolean} protectionsEnabled
- * @param {(keyof states & string)[]} states
- */
- matches(protectionsEnabled, states2) {
- const curr = this.state(protectionsEnabled);
- return states2.includes(curr);
- }
- /**
- * From the available request data, determine the global 'state' of the Request Data
- * @param {boolean} protectionsEnabled
- * @return {keyof states & string}
- */
- state(protectionsEnabled) {
- if (!protectionsEnabled) {
- if (this.allowedSpecialCount() > 0 && this.allowedNonSpecialCount() > 0) {
- return states.protectionsOff_allowedTrackers_allowedNonTrackers;
- }
- if (this.allowedNonSpecialCount() > 0) {
- return states.protectionsOff_allowedNonTrackers;
- }
- if (this.allowedSpecialCount() > 0) {
- return states.protectionsOff_allowedTrackers;
- }
- return states.protectionsOff;
- } else {
- if (this.blockedCount() > 0) {
- if (this.allowedSpecialCount() > 0 && this.allowedNonSpecialCount() > 0) {
- return states.protectionsOn_blocked_allowedTrackers_allowedNonTrackers;
- }
- if (this.allowedSpecialCount() > 0) {
- return states.protectionsOn_blocked_allowedTrackers;
- }
- if (this.allowedNonSpecialCount() > 0) {
- return states.protectionsOn_blocked_allowedNonTrackers;
- }
- return states.protectionsOn_blocked;
- } else {
- if (this.allowedFirstPartyOnly()) {
- if (this.allowedNonSpecialCount() > 0) {
- return states.protectionsOn_allowedFirstParty_allowedNonTrackers;
- }
- return states.protectionsOn_allowedFirstParty;
- }
- if (this.allowedSpecialCount() > 0 && this.allowedNonSpecialCount() > 0) {
- return states.protectionsOn_allowedTrackers_allowedNonTrackers;
- }
- if (this.allowedSpecialCount() > 0) {
- return states.protectionsOn_allowedTrackers;
- }
- if (this.allowedNonSpecialCount() > 0) {
- return states.protectionsOn_allowedNonTrackers;
- }
- }
- return states.protectionsOn;
- }
- }
- };
- var AggregateCompanyData = class {
- /**
- * @param {string|undefined} name
- * @param {string} displayName
- * @param {number} prevalence
- */
- constructor(name, displayName, prevalence) {
- this.name = name;
- this.displayName = displayName;
- this.prevalence = prevalence;
- this.normalizedName = normalizeCompanyName(displayName);
- this.urls = {};
- }
- /**
- * @param {string} url
- * @param {string} [category]
- */
- addUrl(url, category) {
- this.urls[url] = new TrackerUrl(url, category);
- }
- };
- var TrackerUrl = class {
- /**
- * @param {string} url
- * @param {string} [category]
- */
- constructor(url, category) {
- this.url = url;
- this.category = category;
- }
- };
-
- // shared/js/ui/templates/shared/tracker-networks-text.js
- function trackerNetworksTitle(requestDetails, protectionsEnabled) {
- const state = requestDetails.state(protectionsEnabled);
- switch (state) {
- case states.protectionsOn_blocked:
- case states.protectionsOn_blocked_allowedTrackers:
- case states.protectionsOn_blocked_allowedNonTrackers:
- case states.protectionsOn_blocked_allowedTrackers_allowedNonTrackers: {
- return ns.site("trackerNetworksDesc.title");
- }
- case states.protectionsOn_allowedTrackers_allowedNonTrackers:
- case states.protectionsOn_allowedTrackers:
- case states.protectionsOn_allowedFirstParty:
- case states.protectionsOn_allowedFirstParty_allowedNonTrackers:
- case states.protectionsOff_allowedTrackers:
- case states.protectionsOff_allowedTrackers_allowedNonTrackers: {
- return ns.site("trackerNetworksNotBlocked.title");
- }
- case states.protectionsOn:
- case states.protectionsOff:
- case states.protectionsOn_allowedNonTrackers:
- case states.protectionsOff_allowedNonTrackers: {
- return ns.site("trackerNetworksNotFound.title");
- }
- default:
- return unreachable(state);
- }
- }
- function trackerNetworksIcon(requestDetails, protectionsEnabled, phishingDetected) {
- if (phishingDetected) {
- return "info";
- }
- const state = requestDetails.state(protectionsEnabled);
- switch (state) {
- case states.protectionsOn_blocked:
- case states.protectionsOn_blocked_allowedTrackers:
- case states.protectionsOn_blocked_allowedNonTrackers:
- case states.protectionsOn_blocked_allowedTrackers_allowedNonTrackers:
- case states.protectionsOn:
- case states.protectionsOff:
- case states.protectionsOn_allowedNonTrackers:
- case states.protectionsOff_allowedNonTrackers: {
- return "blocked";
- }
- case states.protectionsOn_allowedTrackers_allowedNonTrackers:
- case states.protectionsOn_allowedTrackers:
- case states.protectionsOn_allowedFirstParty:
- case states.protectionsOn_allowedFirstParty_allowedNonTrackers: {
- return "info";
- }
- case states.protectionsOff_allowedTrackers:
- case states.protectionsOff_allowedTrackers_allowedNonTrackers: {
- return "warning";
- }
- default:
- return unreachable(state);
- }
- }
- function trackerNetworkSummary(requestDetails, protectionsEnabled) {
- const state = requestDetails.state(protectionsEnabled);
- switch (state) {
- case states.protectionsOn:
- case states.protectionsOff:
- case states.protectionsOn_allowedNonTrackers:
- case states.protectionsOff_allowedNonTrackers: {
- return ns.site("trackerNetworksSummaryNoneFound.title");
- }
- case states.protectionsOn_allowedTrackers:
- case states.protectionsOn_allowedTrackers_allowedNonTrackers:
- case states.protectionsOn_allowedFirstParty:
- case states.protectionsOn_allowedFirstParty_allowedNonTrackers: {
- return ns.site("trackerNetworksSummaryNoneBlocked.title");
- }
- case states.protectionsOff_allowedTrackers:
- case states.protectionsOff_allowedTrackers_allowedNonTrackers:
- return ns.site("trackerNetworksSummaryProtectionsOff.title");
- default:
- return ns.site("trackerNetworksSummaryBlocked.title");
- }
- }
- function trackerNetworksHeroIcon(requestDetails, protectionsEnabled) {
- const state = requestDetails.state(protectionsEnabled);
- switch (state) {
- case states.protectionsOn:
- case states.protectionsOff:
- case states.protectionsOff_allowedNonTrackers:
- case states.protectionsOn_allowedNonTrackers: {
- return "major-networks-no-activity";
- }
- case states.protectionsOn_allowedTrackers:
- case states.protectionsOn_allowedTrackers_allowedNonTrackers:
- case states.protectionsOn_allowedFirstParty:
- case states.protectionsOn_allowedFirstParty_allowedNonTrackers: {
- return "major-networks-info";
- }
- case states.protectionsOff_allowedTrackers:
- case states.protectionsOff_allowedTrackers_allowedNonTrackers: {
- return "major-networks-warning";
- }
- case states.protectionsOn_blocked_allowedTrackers:
- case states.protectionsOn_blocked_allowedTrackers_allowedNonTrackers:
- case states.protectionsOn_blocked:
- case states.protectionsOn_blocked_allowedNonTrackers: {
- return "major-networks-blocked";
- }
- default:
- return unreachable(state);
- }
- }
- function unreachable(x2) {
- throw new Error("Didn't expect to get here with value" + x2);
- }
-
- // shared/js/ui/templates/shared/thirdparty-text.js
- function thirdpartyTitle(requestDetails, protectionsEnabled) {
- const state = requestDetails.state(protectionsEnabled);
- switch (state) {
- case states.protectionsOn:
- case states.protectionsOn_blocked:
- case states.protectionsOff: {
- return ns.site("thirdPartiesNoneFound.title");
- }
- case states.protectionsOn_allowedTrackers:
- case states.protectionsOn_allowedNonTrackers:
- case states.protectionsOn_blocked_allowedTrackers:
- case states.protectionsOn_blocked_allowedNonTrackers:
- case states.protectionsOn_allowedTrackers_allowedNonTrackers:
- case states.protectionsOn_blocked_allowedTrackers_allowedNonTrackers:
- case states.protectionsOff_allowedTrackers_allowedNonTrackers:
- case states.protectionsOff_allowedNonTrackers:
- case states.protectionsOff_allowedTrackers:
- case states.protectionsOn_allowedFirstParty:
- case states.protectionsOn_allowedFirstParty_allowedNonTrackers: {
- return ns.site("thirdPartiesLoaded.title");
- }
- default:
- return unreachable2(state);
- }
- }
- function thirdpartyIcon(requestDetails, protectionsEnabled, phishingDetected) {
- if (phishingDetected) {
- return "info";
- }
- const state = requestDetails.state(protectionsEnabled);
- switch (state) {
- case states.protectionsOn:
- case states.protectionsOn_blocked:
- case states.protectionsOff: {
- return "blocked";
- }
- case states.protectionsOn_allowedTrackers:
- case states.protectionsOn_allowedNonTrackers:
- case states.protectionsOn_blocked_allowedTrackers:
- case states.protectionsOn_blocked_allowedNonTrackers:
- case states.protectionsOn_allowedTrackers_allowedNonTrackers:
- case states.protectionsOn_blocked_allowedTrackers_allowedNonTrackers:
- case states.protectionsOff_allowedTrackers_allowedNonTrackers:
- case states.protectionsOff_allowedNonTrackers:
- case states.protectionsOff_allowedTrackers:
- case states.protectionsOn_allowedFirstParty:
- case states.protectionsOn_allowedFirstParty_allowedNonTrackers: {
- return "info";
- }
- default:
- return unreachable2(state);
- }
- }
- function thirdpartySummary(requestDetails, protectionsEnabled) {
- const state = requestDetails.state(protectionsEnabled);
- switch (state) {
- case states.protectionsOn_blocked_allowedTrackers:
- case states.protectionsOn_blocked_allowedNonTrackers:
- case states.protectionsOn_blocked_allowedTrackers_allowedNonTrackers:
- case states.protectionsOn_allowedTrackers_allowedNonTrackers:
- case states.protectionsOn_allowedTrackers:
- case states.protectionsOff_allowedTrackers:
- case states.protectionsOn_allowedNonTrackers:
- case states.protectionsOff_allowedTrackers_allowedNonTrackers:
- case states.protectionsOff_allowedNonTrackers:
- case states.protectionsOn_allowedFirstParty:
- case states.protectionsOn_allowedFirstParty_allowedNonTrackers: {
- return ns.site("thirdPartiesSummaryProtectionsOff.title");
- }
- case states.protectionsOn:
- case states.protectionsOff:
- case states.protectionsOn_blocked: {
- return ns.site("thirdPartiesSummaryNone.title");
- }
- default:
- return unreachable2(state);
- }
- }
- function thirdpartyHeroIcon(requestDetails, protectionsEnabled) {
- const state = requestDetails.state(protectionsEnabled);
- switch (state) {
- case states.protectionsOn:
- case states.protectionsOn_blocked:
- case states.protectionsOff: {
- return "major-networks-no-activity";
- }
- case states.protectionsOn_blocked_allowedTrackers:
- case states.protectionsOn_blocked_allowedTrackers_allowedNonTrackers:
- case states.protectionsOn_allowedTrackers:
- case states.protectionsOn_allowedNonTrackers:
- case states.protectionsOff_allowedNonTrackers:
- case states.protectionsOff_allowedTrackers:
- case states.protectionsOn_blocked_allowedNonTrackers:
- case states.protectionsOff_allowedTrackers_allowedNonTrackers:
- case states.protectionsOn_allowedTrackers_allowedNonTrackers:
- case states.protectionsOn_allowedFirstParty:
- case states.protectionsOn_allowedFirstParty_allowedNonTrackers: {
- return "major-networks-info";
- }
- default:
- return unreachable2(state);
- }
- }
- function unreachable2(x2) {
- throw new Error("Didn't expect to get here with value " + x2);
- }
-
- // shared/js/ui/templates/shared/hero.js
- var import_raw = __toESM(require_raw_browser());
- function heroTemplate(opts) {
- return import_nanohtml2.default`
-
- ${opts.icon} ${opts.summary ? import_nanohtml2.default`
${(0, import_raw.default)(opts.summary)}
` : null}
- ${opts.suffix === "about-link" ? aboutLink() : null} ${opts.children ? opts.children : null}
-
- `;
- }
- function heroFromTabTrackers(requestDetails, protectionsEnabled) {
- const summary = trackerNetworkSummary(requestDetails, protectionsEnabled);
- const icon = trackerNetworksHeroIcon(requestDetails, protectionsEnabled);
- const largeIcon = largeHeroIcon({
- status: icon
- });
- return heroTemplate({
- suffix: "about-link",
- icon: largeIcon,
- summary
- });
- }
- function heroFromTabNonTrackers(requestDetails, protectionsEnabled) {
- const summary = thirdpartySummary(requestDetails, protectionsEnabled);
- const icon = thirdpartyHeroIcon(requestDetails, protectionsEnabled);
- const largeIcon = largeHeroIcon({
- status: icon
- });
- return heroTemplate({
- suffix: "about-link",
- icon: largeIcon,
- summary
- });
- }
- function largeHeroIcon(props) {
- return import_nanohtml2.default``;
- }
-
- // shared/js/ui/templates/page-connection.js
- var import_nanohtml4 = __toESM(require_browser());
-
- // shared/js/ui/templates/shared/top-nav.js
- var import_nanohtml3 = __toESM(require_browser());
-
- // shared/js/ui/environment-check.js
- function isEnvironment(platform2) {
- return document.body.classList.contains(`environment--${platform2}`);
- }
- var isIOS = () => isEnvironment("ios");
- var isAndroid = () => isEnvironment("android");
- var isBrowser = () => isEnvironment("browser");
- var isWindows = () => isEnvironment("windows");
- var isMacos = () => isEnvironment("macos");
- function currentPlatform() {
- const matchingClass = [...document.body.classList].find((x2) => x2.startsWith("environment--"));
- if (matchingClass) {
- const platform2 = matchingClass.slice(13);
- if (isValidPlatform(platform2)) {
- return platform2;
- }
- }
- return null;
- }
- function isValidPlatform(name) {
- if (!name)
- throw new Error(`not a valid platform name ${name}`);
- const names = ["ios", "android", "macos", "browser", "windows"];
- if (names.includes(name)) {
- return true;
- }
- throw new Error("nope!");
- }
- var lastKnownPlatformName;
- function platformSwitch(mapping) {
- if (!lastKnownPlatformName)
- lastKnownPlatformName = currentPlatform();
- if (!lastKnownPlatformName)
- throw new Error("could not determine the current platform.");
- if (lastKnownPlatformName in mapping) {
- return mapping[lastKnownPlatformName]();
- }
- if ("default" in mapping) {
- return mapping.default();
- }
- throw new Error("did not expect to get here - use a default!");
- }
-
- // shared/js/ui/templates/page-connection.js
- function getKeyUsage(key) {
- const capabilities = {
- canEncrypt: i18n.t("connection:encrypt.title"),
- canDecrypt: i18n.t("connection:decrypt.title"),
- canSign: i18n.t("connection:sign.title"),
- canVerify: i18n.t("connection:verify.title"),
- canDerive: i18n.t("connection:derive.title"),
- canWrap: i18n.t("connection:wrap.title"),
- canUnwrap: i18n.t("connection:unwrap.title")
- };
- return Object.keys(capabilities).reduce((usage, capability) => {
- if (!key[capability])
- return usage;
- return [].concat(usage, capabilities[capability]);
- }, []);
- }
- function renderCertificateDetails(site2, tab) {
- if (site2.httpsState === "none" || site2.httpsState === "phishing" || !tab.certificate || tab.certificate.length === 0)
- return null;
- const certificate = tab.certificate[0];
- return import_nanohtml4.default`
-
- ${renderHeader(site2, tab)}
-
-
-
${i18n.t("connection:certificateDetail.title")}
-
- ${i18n.t("connection:commonName.title")}
- ${certificate.commonName}
-
- ${renderCertificateSummary(certificate)}
-
- ${renderPublicKeyDetails(certificate)}
-
-
- `;
- }
- function renderCertificateSummary(certificate) {
- if (!certificate.summary)
- return "";
- return import_nanohtml4.default`
- ${i18n.t("connection:summary.title")}
- ${certificate.summary}
-
`;
- }
- function renderPublicKeyDetails(certificate) {
- if (!certificate.publicKey)
- return "";
- return import_nanohtml4.default`
-
${i18n.t("connection:publicKey.title")}
- ${renderCertificateType(certificate.publicKey)} ${renderCertificateBitSize(certificate.publicKey)}
- ${renderCertificateEffectiveSize(certificate.publicKey)} ${renderCertificateKeyUsage(certificate.publicKey)}
- ${renderCertificateIsPermanent(certificate.publicKey)}
- `;
- }
- function renderCertificateType(publicKey) {
- if (!publicKey.type)
- return "";
- return import_nanohtml4.default`
- ${i18n.t("connection:algorithm.title")}
- ${publicKey.type}
-
`;
- }
- function renderCertificateBitSize(publicKey) {
- if (!publicKey.bitSize)
- return "";
- return import_nanohtml4.default`
- ${i18n.t("connection:keySize.title")}
- ${publicKey.bitSize} bits
-
`;
- }
- function renderCertificateIsPermanent(publicKey) {
- if (typeof publicKey.isPermanent !== "boolean")
- return "";
- return import_nanohtml4.default`
- ${i18n.t("connection:permanent.title")}
- ${publicKey.isPermanent ? "Yes" : "No"}
-
`;
- }
- function renderCertificateKeyUsage(publicKey) {
- const keyUsage = getKeyUsage(publicKey);
- if (keyUsage.length === 0)
- return "";
- return import_nanohtml4.default`
- ${i18n.t("connection:usage.title")}
- ${keyUsage.join(", ")}
-
`;
- }
- function renderCertificateEffectiveSize(publicKey) {
- if (!publicKey.effectiveSize)
- return "";
- return import_nanohtml4.default`
- ${i18n.t("connection:effectiveSize.title")}
- ${publicKey.effectiveSize} bits
-
`;
- }
- function renderHeader(site2, tab) {
- if (site2.httpsState === "none") {
- return import_nanohtml4.default``;
- }
- return import_nanohtml4.default``;
- }
- function renderConnectionDescription(site2, tab) {
- if (site2.httpsState === "phishing") {
- return i18n.t("connection:phishingWebsiteDesc.title", { domain: tab.domain });
- }
- if (site2.httpsState === "invalid") {
- return i18n.t("connection:invalidConnectionDesc.title", { domain: tab.domain });
- }
- if (site2.httpsState === "none") {
- return i18n.t("connection:insecureConnectionDesc.title");
- }
- if (site2.httpsState === "upgraded") {
- return i18n.t("connection:upgradedConnectionDesc.title");
- }
- return i18n.t("connection:secureConnectionDesc.title");
- }
-
- // shared/js/browser/browser-communication.js
- var browser_communication_exports = {};
- __export(browser_communication_exports, {
- backgroundMessage: () => backgroundMessage,
- doBurn: () => doBurn,
- fetch: () => fetch,
- getBackgroundTabData: () => getBackgroundTabData,
- getBurnOptions: () => getBurnOptions,
- getPrivacyDashboardData: () => getPrivacyDashboardData,
- getToggleReportOptions: () => getToggleReportOptions,
- openOptions: () => openOptions,
- refreshAlias: () => refreshAlias,
- rejectToggleReport: () => rejectToggleReport,
- search: () => search,
- seeWhatIsSent: () => seeWhatIsSent,
- sendToggleReport: () => sendToggleReport,
- setBurnDefaultOption: () => setBurnDefaultOption,
- setLists: () => setLists,
- setup: () => setup,
- submitBrokenSiteReport: () => submitBrokenSiteReport
- });
- init_schema_parsers();
-
- // shared/js/browser/common.js
- var getContentHeight = () => {
- const $openSubviewV2 = window.document.querySelector(
- "#popup-container.sliding-subview-v2--root [data-current]:last-of-type > *:first-child"
- );
- const $rootSubviewV2 = window.document.querySelector("#popup-container.sliding-subview-v2--root .page-inner");
- return ($openSubviewV2 || $rootSubviewV2)?.scrollHeight;
- };
- function setupMutationObserver(callback) {
- const bufferHeight = 200;
- let lastHeight;
- const mutationObserver = new MutationObserver(() => {
- const contentHeight = getContentHeight();
- if (!contentHeight)
- return;
- const height = Math.min(window.screen.height - bufferHeight, contentHeight);
- if (lastHeight === height)
- return;
- lastHeight = height;
- callback(height);
- });
- const config = { childList: true, attributes: true, subtree: true };
- mutationObserver.observe(window.document, config);
- return () => mutationObserver.disconnect();
- }
- function setupMutationObserverForExtensions(callback) {
- let lastHeight;
- const mutationObserver = new MutationObserver(() => {
- const contentHeight = getContentHeight();
- if (!contentHeight)
- return;
- if (lastHeight === contentHeight)
- return;
- lastHeight = contentHeight;
- callback(contentHeight);
- });
- const config = { childList: true, attributes: true, subtree: true };
- mutationObserver.observe(window.document, config);
- return () => mutationObserver.disconnect();
- }
- var DARK_THEME = "dark";
- var LIGHT_THEME = "light";
- var explicitlySetTheme = "";
- var detectedTheme = LIGHT_THEME;
- var oppositeTheme = {
- [LIGHT_THEME]: DARK_THEME,
- [DARK_THEME]: LIGHT_THEME
- };
- function swapThemeTo(theme) {
- document.body.classList.remove(`body--theme-${oppositeTheme[theme]}`);
- document.body.classList.add(`body--theme-${theme}`);
- }
- function updateTheme() {
- if (explicitlySetTheme) {
- swapThemeTo(explicitlySetTheme);
- } else {
- swapThemeTo(detectedTheme);
- }
- }
- function setupColorScheme() {
- const query = window.matchMedia("(prefers-color-scheme: dark)");
- if (query?.matches) {
- detectedTheme = DARK_THEME;
- }
- if (query.addEventListener) {
- query?.addEventListener("change", (event) => {
- detectedTheme = event.matches ? DARK_THEME : LIGHT_THEME;
- updateTheme();
- });
- } else if ("addListener" in query) {
- query.addListener((event) => {
- detectedTheme = event.matches ? DARK_THEME : LIGHT_THEME;
- updateTheme();
- });
- }
- updateTheme();
- return (theme = "") => {
- theme = theme.trim().toLowerCase();
- if (theme === LIGHT_THEME || theme === DARK_THEME) {
- explicitlySetTheme = theme;
- } else {
- explicitlySetTheme = "";
- }
- updateTheme();
- };
- }
- function assert(condition, message = "") {
- if (!condition) {
- if (!message) {
- throw new Error("invariant");
- }
- throw new Error(message);
- }
- }
- var Msg = class {
- toJSON() {
- return {
- ...this,
- kind: this.constructor.name
- };
- }
- };
- var SetListsMessage = class extends Msg {
- /**
- * @param {object} params
- * @param {Array<{ list: "allowlisted" | "denylisted", domain: string, value: boolean}>} params.lists
- * @param {import('../../../schema/__generated__/schema.types').EventOrigin} params.eventOrigin
- */
- constructor(params) {
- super();
- this.lists = params.lists;
- this.eventOrigin = params.eventOrigin;
- }
- };
- var SubmitBrokenSiteReportMessage = class extends Msg {
- /**
- * @param {object} params
- * @param {string} params.category
- * @param {string} params.description
- * @param {import('../../../schema/__generated__/schema.types').EventOrigin} params.eventOrigin
- */
- constructor(params) {
- super();
- this.category = params.category;
- this.description = params.description;
- this.eventOrigin = params.eventOrigin;
- }
- };
- var UpdatePermissionMessage = class extends Msg {
- /**
- * @param {object} params
- * @param {string} params.id
- * @param {string} params.value
- */
- constructor(params) {
- super();
- this.id = params.id;
- this.value = params.value;
- }
- };
- var CloseMessage = class extends Msg {
- /**
- * @param {object} params
- * @param {import('../../../schema/__generated__/schema.types').EventOrigin} params.eventOrigin
- */
- constructor(params) {
- super();
- this.eventOrigin = params.eventOrigin;
- }
- };
- var CheckBrokenSiteReportHandledMessage = class extends Msg {
- };
- var RefreshEmailAliasMessage = class extends Msg {
- };
- var OpenOptionsMessage = class extends Msg {
- };
- var ShowAlertForMissingDescription = class extends Msg {
- };
- var ShowNativeFeedback = class extends Msg {
- };
- var TelemetrySpanMsg = class extends Msg {
- /**
- * @param {object} params
- * @param {import('../../../schema/__generated__/schema.types').EventOrigin} params.eventOrigin
- * @param {import('../../../schema/__generated__/schema.types').TelemetrySpan['attributes']} params.attributes
- */
- constructor(params) {
- super();
- this.eventOrigin = params.eventOrigin;
- this.attributes = params.attributes;
- }
- };
- var SearchMessage = class extends Msg {
- /**
- * @param {object} params
- * @param {string} params.term
- */
- constructor(params) {
- super();
- this.term = params.term;
- }
- };
- var OpenSettingsMessages = class extends Msg {
- /**
- * @param {object} params
- * @param {'cpm'} params.target
- */
- constructor(params) {
- super();
- this.target = params.target;
- }
- };
- var BurnMessage = class extends Msg {
- /**
- * @param {import('../../../schema/__generated__/schema.types').FireOption} opts
- */
- constructor(opts) {
- super();
- Object.assign(this, opts);
- }
- };
- var FetchBurnOptions = class extends Msg {
- };
- var FetchToggleReportOptions = class extends Msg {
- };
- var SendToggleBreakageReport = class extends Msg {
- };
- var RejectToggleBreakageReport = class extends Msg {
- };
- var SeeWhatIsSent = class extends Msg {
- };
- var SetBurnDefaultOption = class extends Msg {
- /**
- * @param {import('../../../schema/__generated__/schema.types').FireOption['name']} name
- */
- constructor(name) {
- super();
- this.defaultOption = name;
- }
- };
-
- // shared/js/browser/browser-communication.js
- init_protections();
- var channel;
- var port;
- var devtoolsMessageResponseReceived = new EventTarget();
- function openPort() {
- port = chrome.runtime.connect({ name: "privacy-dashboard" });
- port.onDisconnect.addListener(() => {
- openPort();
- channel.didReconnect();
- });
- port.onMessage.addListener((message) => {
- const parsed = incomingExtensionMessageSchema.safeParse(message);
- if (!parsed.success) {
- console.warn("the incoming message could not be parsed with `incomingExtensionMessageSchema`", JSON.stringify(message));
- return;
- }
- switch (parsed.data.messageType) {
- case "response": {
- const { id, options } = parsed.data;
- devtoolsMessageResponseReceived.dispatchEvent(new CustomEvent(String(id), { detail: options }));
- break;
- }
- case "toggleReport": {
- window.location.search = "?screen=toggleReport&opener=dashboard";
- break;
- }
- case "closePopup": {
- window.close();
- break;
- }
- case "updateTabData": {
- channel.send("updateTabData");
- break;
- }
- case "didResetTrackersData": {
- channel.send("updateTabData");
- break;
- }
- default: {
- console.warn("unhandled message");
- }
- }
- });
- }
- function notify(messageType, options = {}) {
- port.postMessage({ messageType, options });
- }
- function request(messageType, options = {}) {
- return new Promise((resolve, reject) => {
- const outgoing = {
- messageType,
- options,
- id: Math.random()
- };
- const parsed = outgoingExtensionMessageSchema.safeParse(outgoing);
- if (!parsed.success) {
- return reject(new Error("invalid message " + JSON.stringify(outgoing)));
- }
- devtoolsMessageResponseReceived.addEventListener(
- String(outgoing.id),
- (evt) => {
- resolve(evt.detail);
- },
- { once: true }
- );
- port.postMessage(outgoing);
- });
- }
- function setup() {
- setupColorScheme();
- }
- async function fetch(message) {
- if (message instanceof CheckBrokenSiteReportHandledMessage) {
- return false;
- }
- if (message instanceof SubmitBrokenSiteReportMessage) {
- return submitBrokenSiteReport(message);
- }
- if (message instanceof SetListsMessage) {
- return setLists(message);
- }
- if (message instanceof SearchMessage) {
- return search(message);
- }
- if (message instanceof RefreshEmailAliasMessage) {
- return refreshAlias();
- }
- if (message instanceof OpenOptionsMessage) {
- return openOptions();
- }
- if (message instanceof BurnMessage) {
- return doBurn(message);
- }
- if (message instanceof FetchBurnOptions) {
- return getBurnOptions();
- }
- if (message instanceof SetBurnDefaultOption) {
- return setBurnDefaultOption(message);
- }
- if (message instanceof SendToggleBreakageReport) {
- return sendToggleReport();
- }
- if (message instanceof RejectToggleBreakageReport) {
- return rejectToggleReport();
- }
- if (message instanceof FetchToggleReportOptions) {
- return getToggleReportOptions();
- }
- if (message instanceof SeeWhatIsSent) {
- return seeWhatIsSent();
- }
- return Promise.reject(new Error("unhandled message: " + JSON.stringify(message)));
- }
- async function submitBrokenSiteReport(report2) {
- const parsedInput = breakageReportRequestSchema.parse(report2);
- notify("submitBrokenSiteReport", parsedInput);
- }
- async function setLists(options) {
- const parsedInput = setListOptionsSchema.parse(options);
- return notify("setLists", parsedInput);
- }
- async function refreshAlias() {
- const result = await request("refreshAlias");
- return refreshAliasResponseSchema.parse(result);
- }
- async function search(options) {
- return notify("search", options);
- }
- async function openOptions() {
- return notify("openOptions");
- }
- async function sendToggleReport() {
- return notify("sendToggleReport");
- }
- async function rejectToggleReport() {
- return notify("rejectToggleReport");
- }
- async function seeWhatIsSent() {
- return notify("seeWhatIsSent");
- }
- function getBurnOptions() {
- return request("getBurnOptions");
- }
- function getToggleReportOptions() {
- return request("getToggleReportOptions");
- }
- function setBurnDefaultOption(message) {
- return request("setBurnDefaultOption", message);
- }
- async function doBurn(message) {
- const browsingDataPermissions = {
- permissions: ["browsingData"]
- };
- const permissionRequestGranted = await new Promise((resolve) => chrome.permissions.request(browsingDataPermissions, resolve));
- if (!permissionRequestGranted) {
- throw new Error("Permission not granted");
- }
- return notify("doBurn", message);
- }
- async function getPrivacyDashboardData(tabId) {
- return request("getPrivacyDashboardData", { tabId });
- }
- function backgroundMessage(_channel) {
- channel = _channel;
- openPort();
- }
- async function getBackgroundTabData() {
- const tabIdParam = new URL(document.location.href).searchParams.get("tabId");
- const isNumeric = tabIdParam && !Number.isNaN(Number(tabIdParam));
- const tabId = isNumeric ? Number(tabIdParam) : null;
- const resp = await getPrivacyDashboardData(tabId);
- const parsedMessageData = getPrivacyDashboardDataSchema.safeParse(resp);
- if (parsedMessageData.success === true) {
- const { tab, emailProtectionUserData, requestData, fireButton } = parsedMessageData.data;
- const { upgradedHttps: upgradedHttps4, url, parentEntity: parentEntity4, specialDomainName, id, localeSettings } = tab;
- const protections5 = new Protections(
- tab.protections.unprotectedTemporary,
- tab.protections.enabledFeatures,
- tab.protections.allowlisted,
- tab.protections.denylisted
- );
- return {
- tab: {
- ...createTabData(url, upgradedHttps4, protections5, requestData),
- id,
- // if the extension sends this value, then use it as-is. Otherwise, the default of 'en' will take effect
- locale: localeSettings?.locale,
- search: {},
- emailProtection: {},
- ctaScreens: {},
- parentEntity: parentEntity4,
- specialDomainName
- },
- emailProtectionUserData,
- fireButton
- };
- } else {
- console.log("getPrivacyDashboardDataSchema failed", parsedMessageData.error);
- console.log("getPrivacyDashboardDataSchema failed: ", JSON.stringify(resp));
- }
- if (!window.__playwright) {
- console.log("\u{1F64F} getBackgroundTabData \u274C", parsedMessageData.error, resp);
- }
- const protections4 = {
- allowlisted: false,
- denylisted: false,
- enabledFeatures: ["contentBlocking"],
- unprotectedTemporary: false
- };
- return {
- tab: {
- ...createTabData("unknown", false, protections4, { requests: [] }),
- error: parsedMessageData.error.message,
- search: {},
- ctaScreens: {}
- }
- };
- }
-
- // shared/js/browser/ios-communication.js
- var ios_communication_exports = {};
- __export(ios_communication_exports, {
- backgroundMessage: () => backgroundMessage2,
- fetch: () => fetch3,
- getBackgroundTabData: () => getBackgroundTabData2,
- privacyDashboardShowAlertForMissingDescription: () => privacyDashboardShowAlertForMissingDescription,
- privacyDashboardShowNativeFeedback: () => privacyDashboardShowNativeFeedback,
- privacyDashboardShowReportBrokenSite: () => privacyDashboardShowReportBrokenSite,
- privacyDashboardTelemetrySpan: () => privacyDashboardTelemetrySpan,
- setup: () => setup3
- });
-
- // node_modules/tiny-invariant/dist/esm/tiny-invariant.js
- var isProduction = false;
- var prefix = "Invariant failed";
- function invariant(condition, message) {
- if (condition) {
- return;
- }
- if (isProduction) {
- throw new Error(prefix);
- }
- var provided = typeof message === "function" ? message() : message;
- var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
- throw new Error(value);
- }
-
- // shared/js/browser/macos-communication.js
- var macos_communication_exports = {};
- __export(macos_communication_exports, {
- backgroundMessage: () => backgroundMessage2,
- fetch: () => fetch2,
- firstRenderComplete: () => firstRenderComplete,
- getBackgroundTabData: () => getBackgroundTabData2,
- onChangeConsentManaged: () => onChangeConsentManaged,
- onChangeLocale: () => onChangeLocale,
- onChangePhishingStatus: () => onChangePhishingStatus,
- onChangeProtectionStatus: () => onChangeProtectionStatus,
- onChangeRequestData: () => onChangeRequestData,
- privacyDashboardClose: () => privacyDashboardClose,
- privacyDashboardGetToggleReportOptions: () => privacyDashboardGetToggleReportOptions,
- privacyDashboardOpenSettings: () => privacyDashboardOpenSettings,
- privacyDashboardOpenUrlInNewTab: () => privacyDashboardOpenUrlInNewTab,
- privacyDashboardRejectToggleReport: () => privacyDashboardRejectToggleReport,
- privacyDashboardSeeWhatIsSent: () => privacyDashboardSeeWhatIsSent,
- privacyDashboardSendToggleReport: () => privacyDashboardSendToggleReport,
- privacyDashboardSetPermission: () => privacyDashboardSetPermission,
- privacyDashboardSetProtection: () => privacyDashboardSetProtection,
- privacyDashboardSetSize: () => privacyDashboardSetSize,
- privacyDashboardSubmitBrokenSiteReport: () => privacyDashboardSubmitBrokenSiteReport,
- setup: () => setup2,
- setupShared: () => setupShared
- });
- init_schema_parsers();
-
- // node_modules/@material/ripple/util.js
- var supportsCssVariables_;
- function supportsCssVariables(windowObj, forceRefresh) {
- if (forceRefresh === void 0) {
- forceRefresh = false;
- }
- var CSS = windowObj.CSS;
- var supportsCssVars = supportsCssVariables_;
- if (typeof supportsCssVariables_ === "boolean" && !forceRefresh) {
- return supportsCssVariables_;
- }
- var supportsFunctionPresent = CSS && typeof CSS.supports === "function";
- if (!supportsFunctionPresent) {
- return false;
- }
- var explicitlySupportsCssVars = CSS.supports("--css-vars", "yes");
- var weAreFeatureDetectingSafari10plus = CSS.supports("(--css-vars: yes)") && CSS.supports("color", "#00000000");
- supportsCssVars = explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
- if (!forceRefresh) {
- supportsCssVariables_ = supportsCssVars;
- }
- return supportsCssVars;
- }
- function getNormalizedEventCoords(evt, pageOffset, clientRect) {
- if (!evt) {
- return { x: 0, y: 0 };
- }
- var x2 = pageOffset.x, y3 = pageOffset.y;
- var documentX = x2 + clientRect.left;
- var documentY = y3 + clientRect.top;
- var normalizedX;
- var normalizedY;
- if (evt.type === "touchstart") {
- var touchEvent = evt;
- normalizedX = touchEvent.changedTouches[0].pageX - documentX;
- normalizedY = touchEvent.changedTouches[0].pageY - documentY;
- } else {
- var mouseEvent = evt;
- normalizedX = mouseEvent.pageX - documentX;
- normalizedY = mouseEvent.pageY - documentY;
- }
- return { x: normalizedX, y: normalizedY };
- }
-
- // node_modules/@material/base/foundation.js
- var MDCFoundation = (
- /** @class */
- function() {
- function MDCFoundation2(adapter) {
- if (adapter === void 0) {
- adapter = {};
- }
- this.adapter = adapter;
- }
- Object.defineProperty(MDCFoundation2, "cssClasses", {
- get: function() {
- return {};
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCFoundation2, "strings", {
- get: function() {
- return {};
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCFoundation2, "numbers", {
- get: function() {
- return {};
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCFoundation2, "defaultAdapter", {
- get: function() {
- return {};
- },
- enumerable: false,
- configurable: true
- });
- MDCFoundation2.prototype.init = function() {
- };
- MDCFoundation2.prototype.destroy = function() {
- };
- return MDCFoundation2;
- }()
- );
-
- // node_modules/@material/base/component.js
- var MDCComponent = (
- /** @class */
- function() {
- function MDCComponent2(root, foundation) {
- var args = [];
- for (var _i = 2; _i < arguments.length; _i++) {
- args[_i - 2] = arguments[_i];
- }
- this.root = root;
- this.initialize.apply(this, __spreadArray([], __read(args)));
- this.foundation = foundation === void 0 ? this.getDefaultFoundation() : foundation;
- this.foundation.init();
- this.initialSyncWithDOM();
- }
- MDCComponent2.attachTo = function(root) {
- return new MDCComponent2(root, new MDCFoundation({}));
- };
- MDCComponent2.prototype.initialize = function() {
- var _args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- _args[_i] = arguments[_i];
- }
- };
- MDCComponent2.prototype.getDefaultFoundation = function() {
- throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class");
- };
- MDCComponent2.prototype.initialSyncWithDOM = function() {
- };
- MDCComponent2.prototype.destroy = function() {
- this.foundation.destroy();
- };
- MDCComponent2.prototype.listen = function(evtType, handler, options) {
- this.root.addEventListener(evtType, handler, options);
- };
- MDCComponent2.prototype.unlisten = function(evtType, handler, options) {
- this.root.removeEventListener(evtType, handler, options);
- };
- MDCComponent2.prototype.emit = function(evtType, evtData, shouldBubble) {
- if (shouldBubble === void 0) {
- shouldBubble = false;
- }
- var evt;
- if (typeof CustomEvent === "function") {
- evt = new CustomEvent(evtType, {
- bubbles: shouldBubble,
- detail: evtData
- });
- } else {
- evt = document.createEvent("CustomEvent");
- evt.initCustomEvent(evtType, shouldBubble, false, evtData);
- }
- this.root.dispatchEvent(evt);
- };
- return MDCComponent2;
- }()
- );
-
- // node_modules/@material/dom/events.js
- function applyPassive(globalObj) {
- if (globalObj === void 0) {
- globalObj = window;
- }
- return supportsPassiveOption(globalObj) ? { passive: true } : false;
- }
- function supportsPassiveOption(globalObj) {
- if (globalObj === void 0) {
- globalObj = window;
- }
- var passiveSupported = false;
- try {
- var options = {
- // This function will be called when the browser
- // attempts to access the passive property.
- get passive() {
- passiveSupported = true;
- return false;
- }
- };
- var handler = function() {
- };
- globalObj.document.addEventListener("test", handler, options);
- globalObj.document.removeEventListener("test", handler, options);
- } catch (err) {
- passiveSupported = false;
- }
- return passiveSupported;
- }
-
- // node_modules/@material/dom/ponyfill.js
- function matches(element, selector) {
- var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
- return nativeMatches.call(element, selector);
- }
-
- // node_modules/@material/ripple/constants.js
- var cssClasses = {
- // Ripple is a special case where the "root" component is really a "mixin" of sorts,
- // given that it's an 'upgrade' to an existing component. That being said it is the root
- // CSS class that all other CSS classes derive from.
- BG_FOCUSED: "mdc-ripple-upgraded--background-focused",
- FG_ACTIVATION: "mdc-ripple-upgraded--foreground-activation",
- FG_DEACTIVATION: "mdc-ripple-upgraded--foreground-deactivation",
- ROOT: "mdc-ripple-upgraded",
- UNBOUNDED: "mdc-ripple-upgraded--unbounded"
- };
- var strings = {
- VAR_FG_SCALE: "--mdc-ripple-fg-scale",
- VAR_FG_SIZE: "--mdc-ripple-fg-size",
- VAR_FG_TRANSLATE_END: "--mdc-ripple-fg-translate-end",
- VAR_FG_TRANSLATE_START: "--mdc-ripple-fg-translate-start",
- VAR_LEFT: "--mdc-ripple-left",
- VAR_TOP: "--mdc-ripple-top"
- };
- var numbers = {
- DEACTIVATION_TIMEOUT_MS: 225,
- FG_DEACTIVATION_MS: 150,
- INITIAL_ORIGIN_SCALE: 0.6,
- PADDING: 10,
- TAP_DELAY_MS: 300
- // Delay between touch and simulated mouse events on touch devices
- };
-
- // node_modules/@material/ripple/foundation.js
- var ACTIVATION_EVENT_TYPES = [
- "touchstart",
- "pointerdown",
- "mousedown",
- "keydown"
- ];
- var POINTER_DEACTIVATION_EVENT_TYPES = [
- "touchend",
- "pointerup",
- "mouseup",
- "contextmenu"
- ];
- var activatedTargets = [];
- var MDCRippleFoundation = (
- /** @class */
- function(_super) {
- __extends(MDCRippleFoundation2, _super);
- function MDCRippleFoundation2(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCRippleFoundation2.defaultAdapter), adapter)) || this;
- _this.activationAnimationHasEnded = false;
- _this.activationTimer = 0;
- _this.fgDeactivationRemovalTimer = 0;
- _this.fgScale = "0";
- _this.frame = { width: 0, height: 0 };
- _this.initialSize = 0;
- _this.layoutFrame = 0;
- _this.maxRadius = 0;
- _this.unboundedCoords = { left: 0, top: 0 };
- _this.activationState = _this.defaultActivationState();
- _this.activationTimerCallback = function() {
- _this.activationAnimationHasEnded = true;
- _this.runDeactivationUXLogicIfReady();
- };
- _this.activateHandler = function(e3) {
- _this.activateImpl(e3);
- };
- _this.deactivateHandler = function() {
- _this.deactivateImpl();
- };
- _this.focusHandler = function() {
- _this.handleFocus();
- };
- _this.blurHandler = function() {
- _this.handleBlur();
- };
- _this.resizeHandler = function() {
- _this.layout();
- };
- return _this;
- }
- Object.defineProperty(MDCRippleFoundation2, "cssClasses", {
- get: function() {
- return cssClasses;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCRippleFoundation2, "strings", {
- get: function() {
- return strings;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCRippleFoundation2, "numbers", {
- get: function() {
- return numbers;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCRippleFoundation2, "defaultAdapter", {
- get: function() {
- return {
- addClass: function() {
- return void 0;
- },
- browserSupportsCssVars: function() {
- return true;
- },
- computeBoundingRect: function() {
- return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
- },
- containsEventTarget: function() {
- return true;
- },
- deregisterDocumentInteractionHandler: function() {
- return void 0;
- },
- deregisterInteractionHandler: function() {
- return void 0;
- },
- deregisterResizeHandler: function() {
- return void 0;
- },
- getWindowPageOffset: function() {
- return { x: 0, y: 0 };
- },
- isSurfaceActive: function() {
- return true;
- },
- isSurfaceDisabled: function() {
- return true;
- },
- isUnbounded: function() {
- return true;
- },
- registerDocumentInteractionHandler: function() {
- return void 0;
- },
- registerInteractionHandler: function() {
- return void 0;
- },
- registerResizeHandler: function() {
- return void 0;
- },
- removeClass: function() {
- return void 0;
- },
- updateCssVariable: function() {
- return void 0;
- }
- };
- },
- enumerable: false,
- configurable: true
- });
- MDCRippleFoundation2.prototype.init = function() {
- var _this = this;
- var supportsPressRipple = this.supportsPressRipple();
- this.registerRootHandlers(supportsPressRipple);
- if (supportsPressRipple) {
- var _a2 = MDCRippleFoundation2.cssClasses, ROOT_1 = _a2.ROOT, UNBOUNDED_1 = _a2.UNBOUNDED;
- requestAnimationFrame(function() {
- _this.adapter.addClass(ROOT_1);
- if (_this.adapter.isUnbounded()) {
- _this.adapter.addClass(UNBOUNDED_1);
- _this.layoutInternal();
- }
- });
- }
- };
- MDCRippleFoundation2.prototype.destroy = function() {
- var _this = this;
- if (this.supportsPressRipple()) {
- if (this.activationTimer) {
- clearTimeout(this.activationTimer);
- this.activationTimer = 0;
- this.adapter.removeClass(MDCRippleFoundation2.cssClasses.FG_ACTIVATION);
- }
- if (this.fgDeactivationRemovalTimer) {
- clearTimeout(this.fgDeactivationRemovalTimer);
- this.fgDeactivationRemovalTimer = 0;
- this.adapter.removeClass(MDCRippleFoundation2.cssClasses.FG_DEACTIVATION);
- }
- var _a2 = MDCRippleFoundation2.cssClasses, ROOT_2 = _a2.ROOT, UNBOUNDED_2 = _a2.UNBOUNDED;
- requestAnimationFrame(function() {
- _this.adapter.removeClass(ROOT_2);
- _this.adapter.removeClass(UNBOUNDED_2);
- _this.removeCssVars();
- });
- }
- this.deregisterRootHandlers();
- this.deregisterDeactivationHandlers();
- };
- MDCRippleFoundation2.prototype.activate = function(evt) {
- this.activateImpl(evt);
- };
- MDCRippleFoundation2.prototype.deactivate = function() {
- this.deactivateImpl();
- };
- MDCRippleFoundation2.prototype.layout = function() {
- var _this = this;
- if (this.layoutFrame) {
- cancelAnimationFrame(this.layoutFrame);
- }
- this.layoutFrame = requestAnimationFrame(function() {
- _this.layoutInternal();
- _this.layoutFrame = 0;
- });
- };
- MDCRippleFoundation2.prototype.setUnbounded = function(unbounded) {
- var UNBOUNDED = MDCRippleFoundation2.cssClasses.UNBOUNDED;
- if (unbounded) {
- this.adapter.addClass(UNBOUNDED);
- } else {
- this.adapter.removeClass(UNBOUNDED);
- }
- };
- MDCRippleFoundation2.prototype.handleFocus = function() {
- var _this = this;
- requestAnimationFrame(function() {
- return _this.adapter.addClass(MDCRippleFoundation2.cssClasses.BG_FOCUSED);
- });
- };
- MDCRippleFoundation2.prototype.handleBlur = function() {
- var _this = this;
- requestAnimationFrame(function() {
- return _this.adapter.removeClass(MDCRippleFoundation2.cssClasses.BG_FOCUSED);
- });
- };
- MDCRippleFoundation2.prototype.supportsPressRipple = function() {
- return this.adapter.browserSupportsCssVars();
- };
- MDCRippleFoundation2.prototype.defaultActivationState = function() {
- return {
- activationEvent: void 0,
- hasDeactivationUXRun: false,
- isActivated: false,
- isProgrammatic: false,
- wasActivatedByPointer: false,
- wasElementMadeActive: false
- };
- };
- MDCRippleFoundation2.prototype.registerRootHandlers = function(supportsPressRipple) {
- var e_1, _a2;
- if (supportsPressRipple) {
- try {
- for (var ACTIVATION_EVENT_TYPES_1 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next(); !ACTIVATION_EVENT_TYPES_1_1.done; ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next()) {
- var evtType = ACTIVATION_EVENT_TYPES_1_1.value;
- this.adapter.registerInteractionHandler(evtType, this.activateHandler);
- }
- } catch (e_1_1) {
- e_1 = { error: e_1_1 };
- } finally {
- try {
- if (ACTIVATION_EVENT_TYPES_1_1 && !ACTIVATION_EVENT_TYPES_1_1.done && (_a2 = ACTIVATION_EVENT_TYPES_1.return))
- _a2.call(ACTIVATION_EVENT_TYPES_1);
- } finally {
- if (e_1)
- throw e_1.error;
- }
- }
- if (this.adapter.isUnbounded()) {
- this.adapter.registerResizeHandler(this.resizeHandler);
- }
- }
- this.adapter.registerInteractionHandler("focus", this.focusHandler);
- this.adapter.registerInteractionHandler("blur", this.blurHandler);
- };
- MDCRippleFoundation2.prototype.registerDeactivationHandlers = function(evt) {
- var e_2, _a2;
- if (evt.type === "keydown") {
- this.adapter.registerInteractionHandler("keyup", this.deactivateHandler);
- } else {
- try {
- for (var POINTER_DEACTIVATION_EVENT_TYPES_1 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next(); !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done; POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next()) {
- var evtType = POINTER_DEACTIVATION_EVENT_TYPES_1_1.value;
- this.adapter.registerDocumentInteractionHandler(evtType, this.deactivateHandler);
- }
- } catch (e_2_1) {
- e_2 = { error: e_2_1 };
- } finally {
- try {
- if (POINTER_DEACTIVATION_EVENT_TYPES_1_1 && !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done && (_a2 = POINTER_DEACTIVATION_EVENT_TYPES_1.return))
- _a2.call(POINTER_DEACTIVATION_EVENT_TYPES_1);
- } finally {
- if (e_2)
- throw e_2.error;
- }
- }
- }
- };
- MDCRippleFoundation2.prototype.deregisterRootHandlers = function() {
- var e_3, _a2;
- try {
- for (var ACTIVATION_EVENT_TYPES_2 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next(); !ACTIVATION_EVENT_TYPES_2_1.done; ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next()) {
- var evtType = ACTIVATION_EVENT_TYPES_2_1.value;
- this.adapter.deregisterInteractionHandler(evtType, this.activateHandler);
- }
- } catch (e_3_1) {
- e_3 = { error: e_3_1 };
- } finally {
- try {
- if (ACTIVATION_EVENT_TYPES_2_1 && !ACTIVATION_EVENT_TYPES_2_1.done && (_a2 = ACTIVATION_EVENT_TYPES_2.return))
- _a2.call(ACTIVATION_EVENT_TYPES_2);
- } finally {
- if (e_3)
- throw e_3.error;
- }
- }
- this.adapter.deregisterInteractionHandler("focus", this.focusHandler);
- this.adapter.deregisterInteractionHandler("blur", this.blurHandler);
- if (this.adapter.isUnbounded()) {
- this.adapter.deregisterResizeHandler(this.resizeHandler);
- }
- };
- MDCRippleFoundation2.prototype.deregisterDeactivationHandlers = function() {
- var e_4, _a2;
- this.adapter.deregisterInteractionHandler("keyup", this.deactivateHandler);
- try {
- for (var POINTER_DEACTIVATION_EVENT_TYPES_2 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next(); !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done; POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next()) {
- var evtType = POINTER_DEACTIVATION_EVENT_TYPES_2_1.value;
- this.adapter.deregisterDocumentInteractionHandler(evtType, this.deactivateHandler);
- }
- } catch (e_4_1) {
- e_4 = { error: e_4_1 };
- } finally {
- try {
- if (POINTER_DEACTIVATION_EVENT_TYPES_2_1 && !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done && (_a2 = POINTER_DEACTIVATION_EVENT_TYPES_2.return))
- _a2.call(POINTER_DEACTIVATION_EVENT_TYPES_2);
- } finally {
- if (e_4)
- throw e_4.error;
- }
- }
- };
- MDCRippleFoundation2.prototype.removeCssVars = function() {
- var _this = this;
- var rippleStrings = MDCRippleFoundation2.strings;
- var keys = Object.keys(rippleStrings);
- keys.forEach(function(key) {
- if (key.indexOf("VAR_") === 0) {
- _this.adapter.updateCssVariable(rippleStrings[key], null);
- }
- });
- };
- MDCRippleFoundation2.prototype.activateImpl = function(evt) {
- var _this = this;
- if (this.adapter.isSurfaceDisabled()) {
- return;
- }
- var activationState = this.activationState;
- if (activationState.isActivated) {
- return;
- }
- var previousActivationEvent = this.previousActivationEvent;
- var isSameInteraction = previousActivationEvent && evt !== void 0 && previousActivationEvent.type !== evt.type;
- if (isSameInteraction) {
- return;
- }
- activationState.isActivated = true;
- activationState.isProgrammatic = evt === void 0;
- activationState.activationEvent = evt;
- activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== void 0 && (evt.type === "mousedown" || evt.type === "touchstart" || evt.type === "pointerdown");
- var hasActivatedChild = evt !== void 0 && activatedTargets.length > 0 && activatedTargets.some(function(target) {
- return _this.adapter.containsEventTarget(target);
- });
- if (hasActivatedChild) {
- this.resetActivationState();
- return;
- }
- if (evt !== void 0) {
- activatedTargets.push(evt.target);
- this.registerDeactivationHandlers(evt);
- }
- activationState.wasElementMadeActive = this.checkElementMadeActive(evt);
- if (activationState.wasElementMadeActive) {
- this.animateActivation();
- }
- requestAnimationFrame(function() {
- activatedTargets = [];
- if (!activationState.wasElementMadeActive && evt !== void 0 && (evt.key === " " || evt.keyCode === 32)) {
- activationState.wasElementMadeActive = _this.checkElementMadeActive(evt);
- if (activationState.wasElementMadeActive) {
- _this.animateActivation();
- }
- }
- if (!activationState.wasElementMadeActive) {
- _this.activationState = _this.defaultActivationState();
- }
- });
- };
- MDCRippleFoundation2.prototype.checkElementMadeActive = function(evt) {
- return evt !== void 0 && evt.type === "keydown" ? this.adapter.isSurfaceActive() : true;
- };
- MDCRippleFoundation2.prototype.animateActivation = function() {
- var _this = this;
- var _a2 = MDCRippleFoundation2.strings, VAR_FG_TRANSLATE_START = _a2.VAR_FG_TRANSLATE_START, VAR_FG_TRANSLATE_END = _a2.VAR_FG_TRANSLATE_END;
- var _b = MDCRippleFoundation2.cssClasses, FG_DEACTIVATION = _b.FG_DEACTIVATION, FG_ACTIVATION = _b.FG_ACTIVATION;
- var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation2.numbers.DEACTIVATION_TIMEOUT_MS;
- this.layoutInternal();
- var translateStart = "";
- var translateEnd = "";
- if (!this.adapter.isUnbounded()) {
- var _c = this.getFgTranslationCoordinates(), startPoint = _c.startPoint, endPoint = _c.endPoint;
- translateStart = startPoint.x + "px, " + startPoint.y + "px";
- translateEnd = endPoint.x + "px, " + endPoint.y + "px";
- }
- this.adapter.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
- this.adapter.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
- clearTimeout(this.activationTimer);
- clearTimeout(this.fgDeactivationRemovalTimer);
- this.rmBoundedActivationClasses();
- this.adapter.removeClass(FG_DEACTIVATION);
- this.adapter.computeBoundingRect();
- this.adapter.addClass(FG_ACTIVATION);
- this.activationTimer = setTimeout(function() {
- _this.activationTimerCallback();
- }, DEACTIVATION_TIMEOUT_MS);
- };
- MDCRippleFoundation2.prototype.getFgTranslationCoordinates = function() {
- var _a2 = this.activationState, activationEvent = _a2.activationEvent, wasActivatedByPointer = _a2.wasActivatedByPointer;
- var startPoint;
- if (wasActivatedByPointer) {
- startPoint = getNormalizedEventCoords(activationEvent, this.adapter.getWindowPageOffset(), this.adapter.computeBoundingRect());
- } else {
- startPoint = {
- x: this.frame.width / 2,
- y: this.frame.height / 2
- };
- }
- startPoint = {
- x: startPoint.x - this.initialSize / 2,
- y: startPoint.y - this.initialSize / 2
- };
- var endPoint = {
- x: this.frame.width / 2 - this.initialSize / 2,
- y: this.frame.height / 2 - this.initialSize / 2
- };
- return { startPoint, endPoint };
- };
- MDCRippleFoundation2.prototype.runDeactivationUXLogicIfReady = function() {
- var _this = this;
- var FG_DEACTIVATION = MDCRippleFoundation2.cssClasses.FG_DEACTIVATION;
- var _a2 = this.activationState, hasDeactivationUXRun = _a2.hasDeactivationUXRun, isActivated = _a2.isActivated;
- var activationHasEnded = hasDeactivationUXRun || !isActivated;
- if (activationHasEnded && this.activationAnimationHasEnded) {
- this.rmBoundedActivationClasses();
- this.adapter.addClass(FG_DEACTIVATION);
- this.fgDeactivationRemovalTimer = setTimeout(function() {
- _this.adapter.removeClass(FG_DEACTIVATION);
- }, numbers.FG_DEACTIVATION_MS);
- }
- };
- MDCRippleFoundation2.prototype.rmBoundedActivationClasses = function() {
- var FG_ACTIVATION = MDCRippleFoundation2.cssClasses.FG_ACTIVATION;
- this.adapter.removeClass(FG_ACTIVATION);
- this.activationAnimationHasEnded = false;
- this.adapter.computeBoundingRect();
- };
- MDCRippleFoundation2.prototype.resetActivationState = function() {
- var _this = this;
- this.previousActivationEvent = this.activationState.activationEvent;
- this.activationState = this.defaultActivationState();
- setTimeout(function() {
- return _this.previousActivationEvent = void 0;
- }, MDCRippleFoundation2.numbers.TAP_DELAY_MS);
- };
- MDCRippleFoundation2.prototype.deactivateImpl = function() {
- var _this = this;
- var activationState = this.activationState;
- if (!activationState.isActivated) {
- return;
- }
- var state = __assign({}, activationState);
- if (activationState.isProgrammatic) {
- requestAnimationFrame(function() {
- _this.animateDeactivation(state);
- });
- this.resetActivationState();
- } else {
- this.deregisterDeactivationHandlers();
- requestAnimationFrame(function() {
- _this.activationState.hasDeactivationUXRun = true;
- _this.animateDeactivation(state);
- _this.resetActivationState();
- });
- }
- };
- MDCRippleFoundation2.prototype.animateDeactivation = function(_a2) {
- var wasActivatedByPointer = _a2.wasActivatedByPointer, wasElementMadeActive = _a2.wasElementMadeActive;
- if (wasActivatedByPointer || wasElementMadeActive) {
- this.runDeactivationUXLogicIfReady();
- }
- };
- MDCRippleFoundation2.prototype.layoutInternal = function() {
- var _this = this;
- this.frame = this.adapter.computeBoundingRect();
- var maxDim = Math.max(this.frame.height, this.frame.width);
- var getBoundedRadius = function() {
- var hypotenuse = Math.sqrt(Math.pow(_this.frame.width, 2) + Math.pow(_this.frame.height, 2));
- return hypotenuse + MDCRippleFoundation2.numbers.PADDING;
- };
- this.maxRadius = this.adapter.isUnbounded() ? maxDim : getBoundedRadius();
- var initialSize = Math.floor(maxDim * MDCRippleFoundation2.numbers.INITIAL_ORIGIN_SCALE);
- if (this.adapter.isUnbounded() && initialSize % 2 !== 0) {
- this.initialSize = initialSize - 1;
- } else {
- this.initialSize = initialSize;
- }
- this.fgScale = "" + this.maxRadius / this.initialSize;
- this.updateLayoutCssVars();
- };
- MDCRippleFoundation2.prototype.updateLayoutCssVars = function() {
- var _a2 = MDCRippleFoundation2.strings, VAR_FG_SIZE = _a2.VAR_FG_SIZE, VAR_LEFT = _a2.VAR_LEFT, VAR_TOP = _a2.VAR_TOP, VAR_FG_SCALE = _a2.VAR_FG_SCALE;
- this.adapter.updateCssVariable(VAR_FG_SIZE, this.initialSize + "px");
- this.adapter.updateCssVariable(VAR_FG_SCALE, this.fgScale);
- if (this.adapter.isUnbounded()) {
- this.unboundedCoords = {
- left: Math.round(this.frame.width / 2 - this.initialSize / 2),
- top: Math.round(this.frame.height / 2 - this.initialSize / 2)
- };
- this.adapter.updateCssVariable(VAR_LEFT, this.unboundedCoords.left + "px");
- this.adapter.updateCssVariable(VAR_TOP, this.unboundedCoords.top + "px");
- }
- };
- return MDCRippleFoundation2;
- }(MDCFoundation)
- );
-
- // node_modules/@material/ripple/component.js
- var MDCRipple = (
- /** @class */
- function(_super) {
- __extends(MDCRipple2, _super);
- function MDCRipple2() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.disabled = false;
- return _this;
- }
- MDCRipple2.attachTo = function(root, opts) {
- if (opts === void 0) {
- opts = {
- isUnbounded: void 0
- };
- }
- var ripple = new MDCRipple2(root);
- if (opts.isUnbounded !== void 0) {
- ripple.unbounded = opts.isUnbounded;
- }
- return ripple;
- };
- MDCRipple2.createAdapter = function(instance2) {
- return {
- addClass: function(className) {
- return instance2.root.classList.add(className);
- },
- browserSupportsCssVars: function() {
- return supportsCssVariables(window);
- },
- computeBoundingRect: function() {
- return instance2.root.getBoundingClientRect();
- },
- containsEventTarget: function(target) {
- return instance2.root.contains(target);
- },
- deregisterDocumentInteractionHandler: function(evtType, handler) {
- return document.documentElement.removeEventListener(evtType, handler, applyPassive());
- },
- deregisterInteractionHandler: function(evtType, handler) {
- return instance2.root.removeEventListener(evtType, handler, applyPassive());
- },
- deregisterResizeHandler: function(handler) {
- return window.removeEventListener("resize", handler);
- },
- getWindowPageOffset: function() {
- return { x: window.pageXOffset, y: window.pageYOffset };
- },
- isSurfaceActive: function() {
- return matches(instance2.root, ":active");
- },
- isSurfaceDisabled: function() {
- return Boolean(instance2.disabled);
- },
- isUnbounded: function() {
- return Boolean(instance2.unbounded);
- },
- registerDocumentInteractionHandler: function(evtType, handler) {
- return document.documentElement.addEventListener(evtType, handler, applyPassive());
- },
- registerInteractionHandler: function(evtType, handler) {
- return instance2.root.addEventListener(evtType, handler, applyPassive());
- },
- registerResizeHandler: function(handler) {
- return window.addEventListener("resize", handler);
- },
- removeClass: function(className) {
- return instance2.root.classList.remove(className);
- },
- updateCssVariable: function(varName, value) {
- return instance2.root.style.setProperty(varName, value);
- }
- };
- };
- Object.defineProperty(MDCRipple2.prototype, "unbounded", {
- get: function() {
- return Boolean(this.isUnbounded);
- },
- set: function(unbounded) {
- this.isUnbounded = Boolean(unbounded);
- this.setUnbounded();
- },
- enumerable: false,
- configurable: true
- });
- MDCRipple2.prototype.activate = function() {
- this.foundation.activate();
- };
- MDCRipple2.prototype.deactivate = function() {
- this.foundation.deactivate();
- };
- MDCRipple2.prototype.layout = function() {
- this.foundation.layout();
- };
- MDCRipple2.prototype.getDefaultFoundation = function() {
- return new MDCRippleFoundation(MDCRipple2.createAdapter(this));
- };
- MDCRipple2.prototype.initialSyncWithDOM = function() {
- var root = this.root;
- this.isUnbounded = "mdcRippleIsUnbounded" in root.dataset;
- };
- MDCRipple2.prototype.setUnbounded = function() {
- this.foundation.setUnbounded(Boolean(this.isUnbounded));
- };
- return MDCRipple2;
- }(MDCComponent)
- );
-
- // shared/js/ui/views/utils/utils.js
- var seen = /* @__PURE__ */ new WeakSet();
- var seenSwitch = /* @__PURE__ */ new WeakSet();
- function setupBlurOnLongPress() {
- let pressedTime = 0;
- const hasPointerEvents = "PointerEvent" in window || window.navigator && "msPointerEnabled" in window.navigator;
- const isTouch = "ontouchstart" in window || navigator.MaxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
- const mouseDown = hasPointerEvents ? "pointerdown" : isTouch ? "touchstart" : "mousedown";
- const mouseUp = hasPointerEvents ? "pointerup" : isTouch ? "touchend" : "mouseup";
- document.addEventListener(mouseDown, () => {
- pressedTime = 0;
- });
- document.addEventListener(mouseUp, (event) => {
- const now = Date.now();
- const delta = (now - pressedTime) / 1e3;
- const target = event.target;
- if (delta > 0.5 && target instanceof HTMLElement) {
- const trigger = target.closest("a,button");
- if (trigger instanceof HTMLElement) {
- if (seen.has(trigger) || seenSwitch.has(trigger)) {
- trigger?.blur();
- }
- }
- }
- });
- }
- function setupGlobalOpenerListener(cb) {
- document.addEventListener("click", (e3) => {
- const targetElem = e3.target;
- if (targetElem instanceof HTMLAnchorElement) {
- if (targetElem.target === "_blank" && targetElem.origin) {
- e3.preventDefault();
- cb(targetElem.href);
- }
- }
- });
- }
-
- // shared/js/browser/macos-communication.js
- var channel2 = null;
- var backgroundMessage2 = (backgroundModel) => {
- channel2 = backgroundModel;
- };
- var getBackgroundTabDataPromises = [];
- var trackerBlockingData;
- var permissionsData;
- var certificateData;
- var upgradedHttps;
- var protections;
- var isPendingUpdates;
- var parentEntity;
- var cookiePromptManagementStatus = {};
- var phishingStatus;
- var locale;
- var combineSources = () => ({
- tab: Object.assign(
- {},
- trackerBlockingData || {},
- { phishingStatus: phishingStatus ?? false },
- {
- isPendingUpdates,
- parentEntity,
- cookiePromptManagementStatus,
- platformLimitations: true,
- locale
- },
- permissionsData ? { permissions: permissionsData } : {},
- certificateData ? { certificate: certificateData } : {}
- )
- });
- var resolveInitialRender = function() {
- const isUpgradedHttpsSet = typeof upgradedHttps === "boolean";
- const isIsProtectedSet = typeof protections !== "undefined";
- const isTrackerBlockingDataSet = typeof trackerBlockingData === "object";
- const isLocaleSet = typeof locale === "string";
- const isPhishingSet = typeof phishingStatus === "boolean";
- if (!isLocaleSet || !isUpgradedHttpsSet || !isIsProtectedSet || !isTrackerBlockingDataSet || !isPhishingSet) {
- return;
- }
- getBackgroundTabDataPromises.forEach((resolve) => resolve(combineSources()));
- channel2?.send("updateTabData");
- };
- function onChangeRequestData(tabUrl, rawRequestData) {
- const requestData = requestDataSchema.safeParse(rawRequestData);
- if (!protections)
- throw new Error("protections status not set");
- if (!requestData.success) {
- console.error("could not parse incoming request data from `onChangeRequestData`");
- console.log(requestData.error);
- return;
- }
- trackerBlockingData = createTabData(tabUrl, upgradedHttps, protections, requestData.data);
- resolveInitialRender();
- }
- function onChangeProtectionStatus(protectionsStatus) {
- const parsed = protectionsStatusSchema.safeParse(protectionsStatus);
- if (!parsed.success) {
- console.error("could not parse incoming protection status from onChangeProtectionStatus");
- console.error(parsed.error);
- return;
- }
- protections = parsed.data;
- resolveInitialRender();
- }
- function onChangeLocale(payload) {
- const parsed = localeSettingsSchema.safeParse(payload);
- if (!parsed.success) {
- console.error("could not parse incoming data from onChangeLocale");
- console.error(parsed.error);
- return;
- }
- locale = parsed.data.locale;
- channel2?.send("updateTabData");
- }
- function onChangePhishingStatus(payload) {
- const parsed = phishingStatusSchema.safeParse(payload);
- if (!parsed.success) {
- console.error("could not parse incoming data from onChangePhishingStatus");
- console.error(parsed.error);
- return;
- }
- phishingStatus = parsed.data.phishingStatus;
- resolveInitialRender();
- }
- function onChangeConsentManaged(payload) {
- const parsed = cookiePromptManagementStatusSchema.safeParse(payload);
- if (!parsed.success) {
- console.error("could not parse incoming data from onChangeConsentManaged");
- console.error(parsed.error);
- return;
- }
- Object.assign(cookiePromptManagementStatus, parsed.data);
- channel2?.send("updateTabData");
- }
- function privacyDashboardSetProtection(params) {
- invariant(
- window.webkit?.messageHandlers?.privacyDashboardSetProtection,
- "webkit.messageHandlers.privacyDashboardSetProtection required"
- );
- window.webkit.messageHandlers.privacyDashboardSetProtection.postMessage(params);
- }
- function privacyDashboardSetPermission(params) {
- invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
- window.webkit.messageHandlers.privacyDashboardSetPermission.postMessage(params);
- }
- function privacyDashboardGetToggleReportOptions() {
- return new Promise((resolve) => {
- invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
- invariant(window.webkit.messageHandlers.privacyDashboardGetToggleReportOptions, "privacyDashboardGetToggleReportOptions required");
- window.webkit.messageHandlers.privacyDashboardGetToggleReportOptions.postMessage({});
- window.onGetToggleReportOptionsResponse = (data) => {
- resolve(data);
- Reflect.deleteProperty(window, "onGetToggleReportOptionsResponse");
- };
- });
- }
- function privacyDashboardSendToggleReport() {
- invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
- invariant(window.webkit.messageHandlers.privacyDashboardSendToggleReport, "privacyDashboardSendToggleReport required");
- return window.webkit.messageHandlers.privacyDashboardSendToggleReport.postMessage({});
- }
- function privacyDashboardRejectToggleReport() {
- invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
- invariant(window.webkit.messageHandlers.privacyDashboardRejectToggleReport, "privacyDashboardRejectToggleReport required");
- return window.webkit.messageHandlers.privacyDashboardRejectToggleReport.postMessage({});
- }
- function privacyDashboardSeeWhatIsSent() {
- invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
- invariant(window.webkit.messageHandlers.privacyDashboardSeeWhatIsSent, "privacyDashboardSeeWhatIsSent required");
- return window.webkit.messageHandlers.privacyDashboardSeeWhatIsSent.postMessage({});
- }
- function privacyDashboardClose(args) {
- invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
- window.webkit.messageHandlers.privacyDashboardClose.postMessage(args);
- }
- async function fetch2(message) {
- if (message instanceof CloseMessage) {
- privacyDashboardClose({ eventOrigin: message.eventOrigin });
- return;
- }
- if (message instanceof SubmitBrokenSiteReportMessage) {
- privacyDashboardSubmitBrokenSiteReport({
- category: message.category,
- description: message.description
- });
- return;
- }
- if (message instanceof SetListsMessage) {
- for (const listItem of message.lists) {
- const { list, value } = listItem;
- if (list !== "allowlisted") {
- if (!window.__playwright)
- console.warn("only `allowlisted` is currently supported on macos");
- continue;
- }
- const isProtected = value === false;
- privacyDashboardSetProtection({ eventOrigin: message.eventOrigin, isProtected });
- }
- return;
- }
- if (message instanceof OpenSettingsMessages) {
- privacyDashboardOpenSettings({
- target: message.target
- });
- return;
- }
- if (message instanceof UpdatePermissionMessage) {
- privacyDashboardSetPermission({
- permission: message.id,
- value: message.value
- });
- }
- if (message instanceof FetchToggleReportOptions) {
- const data = await privacyDashboardGetToggleReportOptions();
- const parsed = toggleReportScreenSchema.parse(data);
- return parsed;
- }
- if (message instanceof SendToggleBreakageReport) {
- return privacyDashboardSendToggleReport();
- }
- if (message instanceof RejectToggleBreakageReport) {
- return privacyDashboardRejectToggleReport();
- }
- if (message instanceof SeeWhatIsSent) {
- return privacyDashboardSeeWhatIsSent();
- }
- }
- var getBackgroundTabData2 = () => {
- return new Promise((resolve) => {
- if (trackerBlockingData) {
- resolve(combineSources());
- return;
- }
- getBackgroundTabDataPromises.push(resolve);
- });
- };
- function privacyDashboardOpenUrlInNewTab(args) {
- invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
- window.webkit.messageHandlers.privacyDashboardOpenUrlInNewTab.postMessage({
- url: args.url
- });
- }
- function privacyDashboardOpenSettings(args) {
- invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
- window.webkit.messageHandlers.privacyDashboardOpenSettings.postMessage({
- target: args.target
- });
- }
- function privacyDashboardSubmitBrokenSiteReport(report2) {
- invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
- window.webkit.messageHandlers.privacyDashboardSubmitBrokenSiteReport.postMessage({
- category: report2.category,
- description: report2.description
- });
- }
- function privacyDashboardSetSize(payload) {
- if (!isIOS()) {
- invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
- window.webkit.messageHandlers.privacyDashboardSetSize.postMessage(payload);
- }
- }
- function setupShared() {
- window.onChangeRequestData = onChangeRequestData;
- window.onChangeAllowedPermissions = function(data) {
- permissionsData = data;
- channel2?.send("updateTabData");
- };
- window.onChangeUpgradedHttps = function(data) {
- upgradedHttps = data;
- if (trackerBlockingData)
- trackerBlockingData.upgradedHttps = upgradedHttps;
- resolveInitialRender();
- };
- window.onChangePhishingStatus = onChangePhishingStatus;
- window.onChangeProtectionStatus = onChangeProtectionStatus;
- window.onChangeLocale = onChangeLocale;
- window.onChangeCertificateData = function(data) {
- certificateData = data.secCertificateViewModels;
- channel2?.send("updateTabData");
- };
- window.onIsPendingUpdates = function(data) {
- isPendingUpdates = data;
- channel2?.send("updateTabData");
- };
- window.onChangeParentEntity = function(data) {
- parentEntity = data;
- channel2?.send("updateTabData");
- };
- window.onChangeConsentManaged = onChangeConsentManaged;
- setupGlobalOpenerListener((href) => {
- privacyDashboardOpenUrlInNewTab({
- url: href
- });
- });
- }
- function setup2() {
- setupColorScheme();
- setupShared();
- setupMutationObserver((height) => {
- privacyDashboardSetSize({ height });
- });
- }
- function firstRenderComplete() {
- const height = getContentHeight();
- if (typeof height === "number") {
- privacyDashboardSetSize({ height });
- }
- }
-
- // shared/js/browser/ios-communication.js
- function setup3() {
- const setColorScheme = setupColorScheme();
- window.onChangeTheme = function(themeName) {
- setColorScheme(themeName);
- };
- window.history.replaceState({}, "", window.location.href);
- setupShared();
- }
- function privacyDashboardShowReportBrokenSite(args) {
- invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
- window.webkit.messageHandlers.privacyDashboardShowReportBrokenSite.postMessage(args);
- }
- function privacyDashboardShowAlertForMissingDescription(args) {
- invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
- window.webkit.messageHandlers.privacyDashboardShowAlertForMissingDescription.postMessage(args);
- }
- function privacyDashboardShowNativeFeedback(args) {
- invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
- window.webkit.messageHandlers.privacyDashboardShowNativeFeedback.postMessage(args);
- }
- function privacyDashboardTelemetrySpan(args) {
- invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required");
- window.webkit.messageHandlers.privacyDashboardTelemetrySpan.postMessage(args);
- }
- async function fetch3(message) {
- if (message instanceof CheckBrokenSiteReportHandledMessage) {
- privacyDashboardShowReportBrokenSite({});
- return false;
- }
- if (message instanceof ShowAlertForMissingDescription) {
- privacyDashboardShowAlertForMissingDescription({});
- return false;
- }
- if (message instanceof ShowNativeFeedback) {
- privacyDashboardShowNativeFeedback({});
- return false;
- }
- if (message instanceof TelemetrySpanMsg) {
- privacyDashboardTelemetrySpan(message);
- return false;
- }
- return fetch2(message);
- }
-
- // shared/js/browser/android-communication.js
- var android_communication_exports = {};
- __export(android_communication_exports, {
- PrivacyDashboardJavascriptInterface: () => PrivacyDashboardJavascriptInterface,
- backgroundMessage: () => backgroundMessage3,
- fetch: () => fetch4,
- getBackgroundTabData: () => getBackgroundTabData3,
- onChangeConsentManaged: () => onChangeConsentManaged2,
- onChangeFeatureSettings: () => onChangeFeatureSettings,
- onChangeLocale: () => onChangeLocale2,
- onChangeProtectionStatus: () => onChangeProtectionStatus2,
- onChangeRequestData: () => onChangeRequestData2,
- setup: () => setup4
- });
- init_schema_parsers();
- var channel3 = null;
- var backgroundMessage3 = (backgroundModel) => {
- channel3 = backgroundModel;
- };
- var getBackgroundTabDataPromises2 = [];
- var trackerBlockingData2;
- var permissionsData2;
- var certificateData2;
- var upgradedHttps2;
- var protections2;
- var isPendingUpdates2;
- var parentEntity2;
- var cookiePromptManagementStatus2 = {};
- var locale2;
- var featureSettings;
- var combineSources2 = () => ({
- tab: Object.assign(
- {},
- trackerBlockingData2 || {},
- {
- isPendingUpdates: isPendingUpdates2,
- parentEntity: parentEntity2,
- cookiePromptManagementStatus: cookiePromptManagementStatus2,
- locale: locale2
- },
- permissionsData2 ? { permissions: permissionsData2 } : {},
- certificateData2 ? { certificate: certificateData2 } : {}
- ),
- featureSettings
- });
- var resolveInitialRender2 = function() {
- const isUpgradedHttpsSet = typeof upgradedHttps2 === "boolean";
- const isIsProtectedSet = typeof protections2 !== "undefined";
- const isTrackerBlockingDataSet = typeof trackerBlockingData2 === "object";
- const isLocaleSet = typeof locale2 === "string";
- if (!isLocaleSet || !isUpgradedHttpsSet || !isIsProtectedSet || !isTrackerBlockingDataSet) {
- return;
- }
- getBackgroundTabDataPromises2.forEach((resolve) => resolve(combineSources2()));
- channel3?.send("updateTabData", { via: "resolveInitialRender" });
- };
- function onChangeRequestData2(tabUrl, rawRequestData) {
- const requestData = requestDataSchema.safeParse(rawRequestData);
- if (!protections2) {
- console.error("protections status not set");
- return;
- }
- if (!requestData.success) {
- console.error("could not parse incoming request data from `onChangeRequestData`");
- console.log(requestData.error);
- return;
- }
- trackerBlockingData2 = createTabData(tabUrl, upgradedHttps2, protections2, requestData.data);
- resolveInitialRender2();
- }
- function onChangeProtectionStatus2(protectionsStatus) {
- const parsed = protectionsStatusSchema.safeParse(protectionsStatus);
- if (!parsed.success) {
- console.error("could not parse incoming protection status from onChangeProtectionStatus");
- console.error(parsed.error);
- return;
- }
- protections2 = parsed.data;
- resolveInitialRender2();
- }
- function onChangeLocale2(payload) {
- const parsed = localeSettingsSchema.safeParse(payload);
- if (!parsed.success) {
- console.error("could not parse incoming protection status from onChangeLocale");
- console.error(parsed.error);
- return;
- }
- locale2 = parsed.data.locale;
- channel3?.send("updateTabData", { via: "onChangeLocale" });
- }
- function onChangeFeatureSettings(payload) {
- const parsed = remoteFeatureSettingsSchema.safeParse(payload);
- if (!parsed.success) {
- console.error("could not parse incoming protection status from onChangeFeatureSettings");
- console.error(parsed.error);
- return;
- }
- featureSettings = parsed.data;
- channel3?.send("updateTabData", { via: "onChangeFeatureSettings" });
- }
- function onChangeConsentManaged2(payload) {
- const parsed = cookiePromptManagementStatusSchema.safeParse(payload);
- if (!parsed.success) {
- console.error("could not parse incoming data from onChangeConsentManaged");
- console.error(parsed.error);
- return;
- }
- Object.assign(cookiePromptManagementStatus2, parsed.data);
- channel3?.send("updateTabData");
- }
- var PrivacyDashboardJavascriptInterface = class {
- /**
- * @param {import('../../../schema/__generated__/schema.types').SetProtectionParams} params
- *
- * Add the current domain to the 'allowlist'
- *
- * ```js
- * window.PrivacyDashboard.toggleAllowlist(JSON.stringify({
- * "isProtected": true,
- * "eventOrigin": { "screen": "primaryScreen" }
- * }))
- * ```
- *
- * Remove the current domain from the 'allowlist'
- *
- * ```js
- * window.PrivacyDashboard.toggleAllowlist(JSON.stringify({
- * "isProtected": false,
- * "eventOrigin": { "screen": "primaryScreen" }
- * }))
- * ```
- */
- toggleAllowlist(params) {
- window.PrivacyDashboard.toggleAllowlist(JSON.stringify(params));
- }
- /**
- * Shows the native breakage form, instead of using the one
- * embedded in the Privacy Dashboard
- * @example
- * ```
- * window.PrivacyDashboard.showBreakageForm()
- * ```
- */
- showBreakageForm() {
- window.PrivacyDashboard.showBreakageForm();
- }
- /**
- * @example
- * ```
- * window.PrivacyDashboard.close()
- * ```
- */
- close() {
- window.PrivacyDashboard.close();
- }
- /**
- * {@inheritDoc common.openInNewTab}
- * @type {import("./common.js").openInNewTab}
- *
- * ```js
- * const payload = JSON.stringify({
- * "url": "https://help.duckduckgo.com/duckduckgo-help-pages/privacy/web-tracking-protections/"
- * });
- * window.PrivacyDashboard.openInNewTab(payload)
- * ```
- */
- openInNewTab(payload) {
- window.PrivacyDashboard.openInNewTab(JSON.stringify(payload));
- }
- /**
- * {@inheritDoc common.openSettings}
- * @type {import("./common.js").openSettings}
- * @example
- * ```js
- * const payload = JSON.stringify({
- * "target": "cpm"
- * });
- * window.PrivacyDashboard.openSettings(payload)
- * ```
- */
- openSettings(payload) {
- window.PrivacyDashboard.openSettings(JSON.stringify(payload));
- }
- /**
- * {@inheritDoc common.submitBrokenSiteReport}
- * @type {import("./common.js").submitBrokenSiteReport}
- */
- submitBrokenSiteReport(payload) {
- invariant(typeof window.PrivacyDashboard?.submitBrokenSiteReport, "window.PrivacyDashboard.submitBrokenSiteReport required");
- window.PrivacyDashboard.submitBrokenSiteReport(JSON.stringify(payload));
- }
- };
- var privacyDashboardApi;
- async function fetchAndroid(message) {
- if (message instanceof SetListsMessage) {
- for (const listItem of message.lists) {
- const { list, value } = listItem;
- if (list !== "allowlisted") {
- if (!window.__playwright)
- console.warn("only `allowlisted` is currently supported on android");
- continue;
- }
- const isProtected = value === false;
- privacyDashboardApi.toggleAllowlist({ eventOrigin: message.eventOrigin, isProtected });
- }
- return;
- }
- if (message instanceof CloseMessage) {
- privacyDashboardApi.close();
- return;
- }
- if (message instanceof CheckBrokenSiteReportHandledMessage) {
- privacyDashboardApi.showBreakageForm();
- return true;
- }
- if (message instanceof SubmitBrokenSiteReportMessage) {
- privacyDashboardApi.submitBrokenSiteReport({
- category: message.category,
- description: message.description
- });
- return true;
- }
- if (message instanceof OpenSettingsMessages) {
- return privacyDashboardApi.openSettings({
- target: message.target
- });
- }
- console.warn("unhandled message", message);
- }
- var getBackgroundTabDataAndroid = () => {
- return new Promise((resolve) => {
- if (trackerBlockingData2) {
- resolve(combineSources2());
- return;
- }
- getBackgroundTabDataPromises2.push(resolve);
- });
- };
- function setup4(debug2) {
- const setColorScheme = setupColorScheme();
- window.onChangeTheme = function(themeName) {
- setColorScheme(themeName);
- };
- window.onChangeProtectionStatus = onChangeProtectionStatus2;
- window.onChangeLocale = onChangeLocale2;
- window.onChangeRequestData = onChangeRequestData2;
- window.onChangeConsentManaged = onChangeConsentManaged2;
- window.onChangeFeatureSettings = onChangeFeatureSettings;
- window.onChangeAllowedPermissions = function(data) {
- permissionsData2 = data;
- channel3?.send("updateTabData", { via: "onChangeAllowedPermissions" });
- };
- window.onChangeUpgradedHttps = function(data) {
- upgradedHttps2 = data;
- if (trackerBlockingData2)
- trackerBlockingData2.upgradedHttps = upgradedHttps2;
- resolveInitialRender2();
- };
- window.onChangeCertificateData = function(data) {
- certificateData2 = data.secCertificateViewModels;
- channel3?.send("updateTabData", { via: "onChangeCertificateData" });
- };
- window.onIsPendingUpdates = function(data) {
- isPendingUpdates2 = data;
- channel3?.send("updateTabData", { via: "onIsPendingUpdates" });
- };
- window.onChangeParentEntity = function(data) {
- parentEntity2 = data;
- channel3?.send("updateTabData", { via: "onChangeParentEntity" });
- };
- privacyDashboardApi = new PrivacyDashboardJavascriptInterface();
- setupBlurOnLongPress();
- setupGlobalOpenerListener((href) => {
- privacyDashboardApi.openInNewTab({
- url: href
- });
- });
- if (debug2)
- installAndroidCommunicationsProxy();
- }
- var getBackgroundTabData3 = new Proxy(getBackgroundTabDataAndroid, {
- apply(target, thisArg, argArray) {
- return Reflect.apply(target, thisArg, argArray);
- }
- });
- var fetch4 = new Proxy(fetchAndroid, {
- apply(target, thisArg, argArray) {
- return Reflect.apply(target, thisArg, argArray);
- }
- });
- function installAndroidCommunicationsProxy() {
- const handler = {
- get(target, propKey, receiver) {
- const origMethod = target[propKey];
- if (typeof origMethod === "function") {
- return function(...args) {
- if (args.length === 0) {
- console.log(`\u{1F916} called window.PrivacyDashboard.${propKey} without args`);
- } else {
- console.log(`\u{1F916} called window.PrivacyDashboard.${propKey} with`, ...args);
- }
- return Reflect.apply(origMethod, receiver, args);
- };
- } else {
- return origMethod;
- }
- }
- };
- window.PrivacyDashboard = new Proxy(window.PrivacyDashboard, handler);
- }
-
- // shared/js/browser/windows-communication.js
- var windows_communication_exports = {};
- __export(windows_communication_exports, {
- AddToAllowListCommand: () => AddToAllowListCommand,
- CloseCommand: () => CloseCommand,
- OpenInNewTab: () => OpenInNewTab,
- OpenSettings: () => OpenSettings,
- RemoveFromAllowListCommand: () => RemoveFromAllowListCommand,
- SetPermissionCommand: () => SetPermissionCommand,
- SetSize: () => SetSize,
- SubmitBrokenSiteReport: () => SubmitBrokenSiteReport,
- backgroundMessage: () => backgroundMessage4,
- fetch: () => fetch5,
- firstRenderComplete: () => firstRenderComplete2,
- getBackgroundTabData: () => getBackgroundTabData4,
- handleIncomingMessage: () => handleIncomingMessage,
- setup: () => setup5
- });
- init_lib();
- init_schema_parsers();
- var channel4 = null;
- var backgroundMessage4 = (backgroundModel) => {
- channel4 = backgroundModel;
- };
- var getBackgroundTabDataPromises3 = [];
- var trackerBlockingData3;
- var permissionsData3;
- var certificateData3;
- var upgradedHttps3;
- var protections3;
- var isPendingUpdates3;
- var parentEntity3;
- var locale3;
- var combineSources3 = () => ({
- tab: Object.assign(
- {},
- trackerBlockingData3 || {},
- {
- isPendingUpdates: isPendingUpdates3,
- parentEntity: parentEntity3,
- locale: locale3
- },
- permissionsData3 ? { permissions: permissionsData3 } : {},
- certificateData3 ? { certificate: certificateData3 } : {}
- )
- });
- var resolveInitialRender3 = function() {
- const isUpgradedHttpsSet = typeof upgradedHttps3 === "boolean";
- const isIsProtectedSet = typeof protections3 !== "undefined";
- const isTrackerBlockingDataSet = typeof trackerBlockingData3 === "object";
- if (!isUpgradedHttpsSet || !isIsProtectedSet || !isTrackerBlockingDataSet) {
- return;
- }
- getBackgroundTabDataPromises3.forEach((resolve) => resolve(combineSources3()));
- channel4?.send("updateTabData");
- };
- function handleViewModelUpdate(viewModel) {
- upgradedHttps3 = viewModel.upgradedHttps;
- parentEntity3 = viewModel.parentEntity || {};
- permissionsData3 = viewModel.permissions || [];
- certificateData3 = viewModel.certificates || [];
- protections3 = viewModel.protections;
- locale3 = viewModel.localeSettings?.locale;
- trackerBlockingData3 = createTabData(viewModel.tabUrl, upgradedHttps3, viewModel.protections, viewModel.rawRequestData);
- trackerBlockingData3.cookiePromptManagementStatus = viewModel.cookiePromptManagementStatus;
- trackerBlockingData3.isInvalidCert = viewModel.isInvalidCert;
- if (trackerBlockingData3)
- trackerBlockingData3.upgradedHttps = upgradedHttps3;
- resolveInitialRender3();
- }
- function windowsPostMessage(name, data) {
- assert(typeof window.chrome.webview?.postMessage === "function");
- window.chrome.webview.postMessage({
- Feature: "PrivacyDashboard",
- Name: name,
- Data: data
- });
- }
- async function fetch5(message) {
- if (message instanceof SubmitBrokenSiteReportMessage) {
- SubmitBrokenSiteReport({
- category: message.category,
- description: message.description
- });
- return;
- }
- if (message instanceof OpenSettingsMessages) {
- OpenSettings({
- target: message.target
- });
- return;
- }
- if (message instanceof SetListsMessage) {
- for (const listItem of message.lists) {
- const { list, value } = listItem;
- if (list !== "allowlisted") {
- if (!window.__playwright)
- console.warn("only `allowlisted` is currently supported on windows");
- continue;
- }
- const isProtected = value === false;
- const eventOrigin = message.eventOrigin;
- if (isProtected) {
- RemoveFromAllowListCommand(eventOrigin);
- } else {
- AddToAllowListCommand(eventOrigin);
- }
- }
- }
- if (message instanceof UpdatePermissionMessage) {
- SetPermissionCommand({
- permission: message.id,
- value: message.value
- });
- }
- if (message instanceof CloseMessage) {
- CloseCommand(message.eventOrigin);
- }
- }
- function SubmitBrokenSiteReport(report2) {
- windowsPostMessage("SubmitBrokenSiteReport", {
- category: report2.category,
- description: report2.description
- });
- }
- function OpenInNewTab(args) {
- windowsPostMessage("OpenInNewTab", {
- url: args.url
- });
- }
- function SetSize(payload) {
- windowsPostMessage("SetSize", payload);
- }
- function OpenSettings(args) {
- windowsPostMessage("OpenSettings", args);
- }
- function SetPermissionCommand(args) {
- windowsPostMessage("SetPermissionCommand", args);
- }
- function RemoveFromAllowListCommand(eventOrigin) {
- windowsPostMessage("RemoveFromAllowListCommand", { eventOrigin });
- }
- function AddToAllowListCommand(eventOrigin) {
- windowsPostMessage("AddToAllowListCommand", { eventOrigin });
- }
- function CloseCommand(eventOrigin) {
- windowsPostMessage("CloseCommand", { eventOrigin });
- }
- var getBackgroundTabData4 = () => {
- return new Promise((resolve) => {
- if (trackerBlockingData3) {
- resolve(combineSources3());
- return;
- }
- getBackgroundTabDataPromises3.push(resolve);
- });
- };
- var eventShape = z3.discriminatedUnion("Name", [windowsIncomingViewModelSchema, windowsIncomingVisibilitySchema]);
- function handleIncomingMessage(message) {
- const parsed = eventShape.safeParse(message);
- if (!parsed.success) {
- console.error("cannot handle incoming message from event data", message);
- console.error(parsed.error);
- return;
- }
- switch (parsed.data.Name) {
- case "VisibilityChanged": {
- if (parsed.data.Data.isVisible === false) {
- document.body.innerHTML = "";
- }
- break;
- }
- case "ViewModelUpdated": {
- handleViewModelUpdate(parsed.data.Data);
- }
- }
- }
- function setup5() {
- if (!window.chrome.webview) {
- console.error("window.chrome.webview not available");
- return;
- }
- setupColorScheme();
- assert(typeof window.chrome.webview?.addEventListener === "function", "window.chrome.webview.addEventListener is required");
- window.chrome.webview.addEventListener("message", (event) => {
- handleIncomingMessage(event.data);
- });
- setupMutationObserver((height) => {
- SetSize({ height });
- });
- setupGlobalOpenerListener((href) => {
- OpenInNewTab({
- url: href
- });
- });
- }
- function firstRenderComplete2() {
- const height = getContentHeight();
- if (typeof height === "number") {
- SetSize({ height });
- }
- }
-
- // shared/js/browser/communication.js
- var defaultComms;
- var platform = {
- name: "browser"
- };
- if (isIOS()) {
- defaultComms = ios_communication_exports;
- platform.name = "ios";
- } else if (isBrowser()) {
- defaultComms = browser_communication_exports;
- platform.name = "browser";
- } else if (isAndroid()) {
- defaultComms = android_communication_exports;
- platform.name = "android";
- } else if (isWindows()) {
- defaultComms = windows_communication_exports;
- platform.name = "windows";
- } else if (isMacos()) {
- defaultComms = macos_communication_exports;
- platform.name = "macos";
- }
- if (!defaultComms)
- throw new Error("unsupported environment");
- var debug = false;
- defaultComms.setup(debug);
- var communication_default = defaultComms;
-
- // shared/js/ui/platform-features.mjs
- function createPlatformFeatures(platform2) {
- const desktop = ["windows", "macos", "browser"];
- let includeToggleOnBreakageForm = true;
- let screen = "primaryScreen";
- const url = new URL(window.location.href);
- const acceptedScreenParam = [
- "breakageForm",
- "toggleReport",
- "choiceBreakageForm",
- "categoryTypeSelection",
- "categorySelection",
- "promptBreakageForm"
- ];
- if (url.searchParams.has("screen")) {
- const param = url.searchParams.get("screen");
- if (typeof param === "string" && acceptedScreenParam.includes(
- /** @type {string} */
- param
- )) {
- screen = /** @type {any} */
- param;
- }
- }
- if (screen === "promptBreakageForm") {
- includeToggleOnBreakageForm = false;
- }
- let opener = "menu";
- if (url.searchParams.get("opener") === "dashboard") {
- opener = "dashboard";
- }
- let breakageScreen = "breakageForm";
- if (url.searchParams.get("breakageScreen") === "categorySelection") {
- breakageScreen = "categorySelection";
- }
- if (url.searchParams.get("breakageScreen") === "categoryTypeSelection") {
- breakageScreen = "categoryTypeSelection";
- }
- let randomisedCategories = true;
- if (url.searchParams.get("randomisedCategories") === "false")
- randomisedCategories = false;
- let breakageFormCategorySelect = "default";
- if (platform2.name === "android" && typeof CSSLayerBlockRule === "function") {
- breakageFormCategorySelect = "material-web-dialog";
- }
- if (url.searchParams.get("breakageFormCategorySelect") === "material-web-dialog") {
- breakageFormCategorySelect = "material-web-dialog";
- }
- if (url.searchParams.get("breakageFormCategorySelect") === "default") {
- breakageFormCategorySelect = "default";
- }
- return new PlatformFeatures({
- spinnerFollowingProtectionsToggle: platform2.name !== "android" && platform2.name !== "windows",
- supportsHover: desktop.includes(platform2.name),
- initialScreen: screen,
- opener,
- supportsInvalidCertsImplicitly: platform2.name !== "browser" && platform2.name !== "windows",
- supportsPhishingWarning: platform2.name === "macos",
- includeToggleOnBreakageForm,
- breakageScreen,
- randomisedCategories,
- breakageFormCategorySelect
- });
- }
- var PlatformFeatures = class {
- /**
- * @param {object} params
- * @param {boolean} params.spinnerFollowingProtectionsToggle
- * @param {boolean} params.supportsHover
- * @param {InitialScreen} params.initialScreen
- * @param {'dashboard' | 'menu'} params.opener
- * @param {boolean} params.supportsInvalidCertsImplicitly
- * @param {boolean} params.includeToggleOnBreakageForm
- * @param {InitialScreen} params.breakageScreen
- * @param {boolean} params.supportsPhishingWarning
- * @param {boolean} params.randomisedCategories
- * @param {"default" | "material-web-dialog"} params.breakageFormCategorySelect
- */
- constructor(params) {
- this.spinnerFollowingProtectionsToggle = params.spinnerFollowingProtectionsToggle;
- this.supportsHover = params.supportsHover;
- this.supportsInvalidCertsImplicitly = params.supportsInvalidCertsImplicitly;
- this.initialScreen = params.initialScreen;
- this.opener = params.opener;
- this.includeToggleOnBreakageForm = params.includeToggleOnBreakageForm;
- this.supportsPhishingWarning = params.supportsPhishingWarning;
- this.breakageScreen = params.breakageScreen;
- this.randomisedCategories = params.randomisedCategories;
- this.breakageFormCategorySelect = params.breakageFormCategorySelect;
- }
- };
- var FeatureSettings = class _FeatureSettings {
- /**
- * @param {object} params
- * @param {import("../../../schema/__generated__/schema.types").PrimaryScreen} [params.primaryScreen]
- * @param {import("../../../schema/__generated__/schema.types").WebBreakageForm} [params.webBreakageForm]
- */
- constructor(params) {
- this.primaryScreen = params.primaryScreen || { layout: "default" };
- this.webBreakageForm = params.webBreakageForm || { state: "enabled" };
- }
- /**
- * @param {import("../../../schema/__generated__/schema.types").RemoteFeatureSettings|undefined} settings
- * @param {Platform} platform
- */
- static create(settings, platform2) {
- switch (platform2.name) {
- case "android": {
- return new _FeatureSettings({
- webBreakageForm: { state: "disabled" },
- ...settings
- });
- }
- default: {
- return new _FeatureSettings(settings || {});
- }
- }
- }
- };
-
- // v2/data-provider.js
- var DataChannel = class extends EventTarget {
- constructor() {
- super(...arguments);
- __publicField(this, "protectionsEnabled", false);
- /** @type {'secure' | 'upgraded' | 'none' | 'invalid' | 'phishing'} */
- __publicField(this, "httpsState", "none");
- __publicField(this, "isBroken", false);
- __publicField(this, "isAllowlisted", false);
- __publicField(this, "isDenylisted", false);
- __publicField(this, "displayBrokenUI", false);
- __publicField(this, "isaMajorTrackingNetwork", false);
- // always disabled by default
- __publicField(this, "disabled", true);
- __publicField(this, "features", createPlatformFeatures(platform));
- /** @type {FeatureSettings | null} */
- __publicField(this, "featureSettings", null);
- /** @type {any[] | null | undefined} */
- __publicField(this, "permissions", null);
- /** @type {import('../shared/js/browser/utils/request-details.mjs').TabData | null} */
- __publicField(this, "tab", null);
- /** @type {import('../schema/__generated__/schema.types').EmailProtectionUserData | null} */
- __publicField(this, "emailProtectionUserData", null);
- __publicField(this, "count", 0);
- __publicField(this, "connection", 1);
- __publicField(
- this,
- "_timeout",
- /** @type {any} */
- null
- );
- }
- /**
- * Sets a timeout to send a message
- *
- * @param {string} _messageName - The name of the message to send
- */
- send(_messageName) {
- clearTimeout(this._timeout);
- this._timeout = window.setTimeout(() => {
- communication_default.getBackgroundTabData().then((resp) => {
- this.accept(resp);
- }).catch((e3) => {
- console.log("\u274C [models/site.es6.js:handleBackgroundMsg()] --> ", e3);
- });
- }, 100);
- }
- /**
- * Allow producers to indicate when their connection was re-established
- */
- didReconnect() {
- this.connection += 1;
- this.broadcast();
- }
- /**
- * @param {import('../shared/js/browser/common.js').BackgroundTabData} data
- */
- accept({ tab, emailProtectionUserData, fireButton, featureSettings: featureSettings2 }) {
- if (tab) {
- if (tab.locale) {
- if (Object.keys(i18n.options.resources).includes(tab.locale)) {
- i18n.changeLanguage(tab.locale);
- } else {
- console.warn(`Unsupported locale ${tab.locale}`);
- }
- }
- this.tab = tab;
- this.domain = tab.domain;
- const MAJOR_TRACKER_THRESHOLD_PCT = 15;
- this.isaMajorTrackingNetwork = (tab.parentEntity?.prevalence || 0) >= MAJOR_TRACKER_THRESHOLD_PCT;
- } else {
- this.domain = "new tab";
- console.debug("Site model: no tab");
- }
- if (emailProtectionUserData) {
- this.emailProtectionUserData = emailProtectionUserData;
- }
- this.fireButton = fireButton;
- this.featureSettings = FeatureSettings.create(featureSettings2, platform);
- this.setSiteProperties();
- this.setHttpsMessage();
- if (this.tab) {
- this.permissions = this.tab.permissions;
- }
- this.broadcast();
- }
- initial() {
- communication_default.getBackgroundTabData().then((resp) => {
- this.accept(resp);
- }).catch((e3) => {
- console.log("\u274C [DataChannel .initial()] --> ", e3);
- });
- }
- setSiteProperties() {
- if (!this.tab) {
- this.domain = "new tab";
- } else {
- this.initAllowlisted(this.tab.protections.allowlisted, this.tab.protections.denylisted);
- if (this.tab.specialDomainName) {
- this.domain = this.tab.specialDomainName;
- } else {
- this.disabled = false;
- }
- }
- if (this.domain && this.domain === "-") {
- this.disabled = true;
- }
- }
- initAllowlisted(allowListValue, denyListValue) {
- this.isAllowlisted = allowListValue;
- this.isDenylisted = denyListValue;
- this.isBroken = Boolean(
- this.tab?.protections.unprotectedTemporary || !this.tab?.protections.enabledFeatures?.includes("contentBlocking")
- );
- this.displayBrokenUI = this.isBroken;
- if (denyListValue) {
- this.displayBrokenUI = false;
- this.protectionsEnabled = true;
- } else {
- this.displayBrokenUI = this.isBroken;
- this.protectionsEnabled = !(this.isAllowlisted || this.isBroken);
- }
- }
- setHttpsMessage() {
- if (!this.tab)
- return;
- const nextState = (() => {
- if (this.features.supportsPhishingWarning) {
- if (this.tab.phishingStatus) {
- return "phishing";
- }
- }
- if (this.tab.isInvalidCert === true) {
- return "invalid";
- }
- if (this.tab.upgradedHttps) {
- return "upgraded";
- }
- if (/^https/.exec(this.tab.url)) {
- if (this.features.supportsInvalidCertsImplicitly) {
- if (!this.tab.certificate || this.tab.certificate.length === 0) {
- return "invalid";
- }
- }
- return "secure";
- }
- return "none";
- })();
- this.httpsState = nextState;
- }
- broadcast() {
- this.count += 1;
- this.dispatchEvent(new CustomEvent("data", { detail: this.lastValue() }));
- }
- /**
- * @return {DataChannelPublicData}
- */
- lastValue() {
- if (!this.tab)
- throw new Error("unreachable, missing this.tab");
- if (!this.featureSettings)
- throw new Error("unreachable, missing this.featureSettings");
- return {
- fireButton: this.fireButton,
- protectionsEnabled: this.protectionsEnabled,
- httpsState: this.httpsState,
- isBroken: this.isBroken,
- isAllowlisted: this.isAllowlisted,
- isDenylisted: this.isDenylisted,
- displayBrokenUI: this.displayBrokenUI,
- isaMajorTrackingNetwork: this.isaMajorTrackingNetwork,
- disabled: this.disabled,
- features: this.features,
- featureSettings: this.featureSettings,
- permissions: this.permissions,
- tab: this.tab,
- count: this.count,
- emailProtectionUserData: this.emailProtectionUserData,
- connection: this.connection
- };
- }
- };
- var ToggleAllowList = class {
- /**
- * @param {DataChannelPublicData} data
- * @param {import('../schema/__generated__/schema.types.js').EventOrigin} eventOrigin
- * @return {import('../shared/js/browser/common.js').Msg}
- */
- intoMessage(data, eventOrigin) {
- const lists = [];
- if (data.tab && data.tab.domain) {
- if (data.isBroken) {
- lists.push({
- list: "denylisted",
- domain: data.tab.domain,
- value: !data.isDenylisted
- });
- } else {
- lists.push({
- list: "denylisted",
- domain: data.tab.domain,
- value: false
- });
- lists.push({
- list: "allowlisted",
- domain: data.tab.domain,
- value: !data.isAllowlisted
- });
- }
- }
- return new SetListsMessage({ lists, eventOrigin });
- }
- };
- var dc = new DataChannel();
- communication_default.backgroundMessage(dc);
- var ChannelContext = G({
- /** @type {DataChannel} */
- channel: (
- /** @type {any} */
- null
- )
- });
- function DataProvider({ children }) {
- const d3 = useInternalData();
- if (!d3 || d3.count === 0)
- return null;
- return /* @__PURE__ */ y(ChannelContext.Provider, { value: { channel: dc } }, children);
- }
- function useInternalData() {
- const [state, setState] = h2(null);
- p2(() => {
- dc.initial();
- const handler = (evt) => {
- setState(evt.detail);
- };
- dc.addEventListener("data", handler);
- return () => {
- dc.removeEventListener("data", handler);
- };
- }, []);
- return state;
- }
- function useConnectionCount() {
- const [count, setCount] = h2(() => dc.lastValue().connection);
- p2(() => {
- const controller = new AbortController();
- dc.addEventListener(
- "data",
- (evt) => {
- setCount(evt.detail.connection);
- },
- { signal: controller.signal }
- );
- window.addEventListener(
- useConnectionCount.PAUSE_EVENT,
- () => {
- controller.abort();
- },
- { signal: controller.signal }
- );
- return () => {
- controller.abort();
- };
- }, []);
- return { count };
- }
- useConnectionCount.PAUSE_EVENT = "ignore-reconnections";
- useConnectionCount.pause = () => {
- window.dispatchEvent(new Event(useConnectionCount.PAUSE_EVENT));
- };
- function useData() {
- const [state, setState] = h2(() => dc.lastValue());
- p2(() => {
- const handler = (evt) => {
- setState(evt.detail);
- };
- dc.addEventListener("data", handler);
- return () => {
- dc.removeEventListener("data", handler);
- };
- }, []);
- return state;
- }
- function useFeatures() {
- return dc.lastValue().features;
- }
- function useFeatureSettings() {
- return dc.lastValue().featureSettings;
- }
- function usePrimaryStatus() {
- const { disabled, tab } = dc.lastValue();
- if (tab?.error)
- return "error";
- if (tab?.ctaScreens && disabled)
- return "cta";
- return "ready";
- }
- function useFetcher() {
- return T2(async (msg) => {
- try {
- if (!window.__ddg_integration_test) {
- console.log("\u{1F4E4} [outgoing useFetcher]", msg);
- }
- return communication_default.fetch(msg);
- } catch (error2) {
- console.error("Error:", error2);
- throw error2;
- }
- }, []);
- }
- function useClose() {
- const fetcher = useFetcher();
- const nav = useNav();
- return T2(() => {
- const msg = new CloseMessage({ eventOrigin: { screen: nav.screen() } });
- fetcher(msg).catch(console.error);
- }, [nav]);
- }
- function useToggle() {
- const fetcher = useFetcher();
- const data = useData();
- const nav = useNav();
- return T2(() => {
- const msg = new ToggleAllowList().intoMessage(data, { screen: nav.screen() });
- fetcher(msg).catch(console.error);
- }, [data, nav]);
- }
- function useSendReport() {
- const fetcher = useFetcher();
- const nav = useNav();
- return T2(
- ({ category, description }) => {
- const msg = new SubmitBrokenSiteReportMessage({
- category: category || "",
- description: description || "",
- eventOrigin: { screen: nav.screen() }
- });
- fetcher(msg).catch(console.error);
- },
- [nav]
- );
- }
- function useShowAlert() {
- const fetcher = useFetcher();
- const nav = useNav();
- return T2(() => {
- const msg = new ShowAlertForMissingDescription();
- fetcher(msg).catch(console.error);
- }, [nav]);
- }
- function useShowNativeFeedback() {
- const fetcher = useFetcher();
- const nav = useNav();
- return T2(() => {
- const msg = new ShowNativeFeedback();
- fetcher(msg).catch(console.error);
- }, [nav]);
- }
- function useTelemetry() {
- const fetcher = useFetcher();
- const nav = useNav();
- return function(attrs) {
- const msg = new TelemetrySpanMsg({
- eventOrigin: { screen: nav.screen() },
- attributes: attrs
- });
- fetcher(msg).catch(console.error);
- };
- }
-
- // v2/dom-node.jsx
- function DomNode({ children }) {
- this.shouldComponentUpdate = () => false;
- return (
- /** @type {any} */
- Object.defineProperty(y(children.localName), "__e", { get: () => children, set: Object })
- );
- }
-
- // v2/components/top-nav.jsx
- function TopNav({ back, done, children }) {
- return /* @__PURE__ */ y("div", null, /* @__PURE__ */ y("div", { className: "top-nav" }, back, children, done), /* @__PURE__ */ y("div", { className: "top-nav__spacer" }));
- }
- function SecondaryTopNav({ children }) {
- const { pop } = useNav();
- const onClose = useClose();
- return platformSwitch({
- ios: () => {
- return /* @__PURE__ */ y(TopNav, { back: /* @__PURE__ */ y(Back, { onClick: pop }), done: /* @__PURE__ */ y(Done, { onClick: onClose }) }, children);
- },
- default: () => {
- return /* @__PURE__ */ y(TopNav, { back: /* @__PURE__ */ y(Back, { onClick: pop }), done: null }, children);
- }
- });
- }
- function SecondaryTopNavAlt({ children }) {
- const { pop } = useNav();
- const canPop = useCanPop();
- const onClose = useClose();
- return platformSwitch({
- ios: () => {
- return /* @__PURE__ */ y(TopNav, { back: canPop ? /* @__PURE__ */ y(Back, { onClick: pop }) : null, done: /* @__PURE__ */ y(Cancel, { onClick: onClose }) }, children);
- },
- default: () => {
- return /* @__PURE__ */ y(TopNav, { back: /* @__PURE__ */ y(Back, { onClick: pop }), done: null }, children);
- }
- });
- }
- function Back({ onClick }) {
- const textLabel = ns.site("navigationBack.title");
- return /* @__PURE__ */ y(
- "a",
- {
- href: "javascript:void(0)",
- onClick,
- className: "top-nav__back link-action link-action--dark",
- role: "button",
- "aria-label": textLabel
- },
- /* @__PURE__ */ y("span", { className: "icon icon__back-arrow", "data-icon-text": textLabel })
- );
- }
- function Done({ textLabel = ns.site("navigationComplete.title"), onClick }) {
- return /* @__PURE__ */ y("a", { href: "javascript:void(0)", onClick, className: "top-nav__done link-action link-action--dark", role: "button" }, textLabel);
- }
- function Close({ onClick }) {
- return /* @__PURE__ */ y(Done, { textLabel: ns.site("navigationClose.title"), onClick });
- }
- function Cancel({ onClick }) {
- return /* @__PURE__ */ y("a", { href: "javascript:void(0)", onClick, className: "top-nav__cancel link-action link-action--dark", role: "button" }, ns.site("navigationCancel.title"));
- }
- function Title({ children }) {
- return /* @__PURE__ */ y("span", { className: "top-nav__title" }, children);
- }
-
- // v2/screens/connection-screen.jsx
- var DomNode2 = (
- /** @type {any} */
- DomNode
- );
- function ConnectionScreen() {
- const data = useData();
- const summary = renderConnectionDescription(data, data.tab);
- const icon = largeHeroIcon({
- status: `connection-${data.httpsState}`
- });
- const hero = heroTemplate({
- icon,
- summary,
- suffix: "none"
- });
- const certDetails = data.tab.certificate ? renderCertificateDetails(data, data.tab) : null;
- const certDetailsElement = certDetails ? /* @__PURE__ */ y(DomNode2, { key: data.count }, certDetails) : null;
- return /* @__PURE__ */ y("div", { className: "site-info card page-inner", "data-page": "connection" }, /* @__PURE__ */ y(SecondaryTopNav, null), /* @__PURE__ */ y("div", { className: "padding-x-double" }, /* @__PURE__ */ y(DomNode2, { key: data.count }, hero), certDetailsElement));
- }
-
- // shared/js/ui/views/main-nav.js
- var import_nanohtml5 = __toESM(require_browser());
-
- // shared/data/constants.js
- var displayCategories = {
- Analytics: "site:analyticsCategory.title",
- Advertising: "site:advertisingCategory.title",
- "Social Network": "site:socialCategory.title",
- "Content Delivery": "site:contentDeliveryCategory.title",
- "Embedded Content": "site:embeddedContentCategory.title"
- };
- var httpsMessages = {
- secure: "site:connectionSecure.title",
- upgraded: "site:connectionSecure.title",
- none: "site:connectionNotSecure.title",
- invalid: "site:connectionNotSecureInvalidCertificate.title",
- phishing: "site:phishingWebsite.title"
- };
-
- // shared/js/ui/views/main-nav.js
- function template(model, nav) {
- const consentCb = model.tab.cookiePromptManagementStatus?.cosmetic ? nav.cookieHidden : nav.consentManaged;
- const consentRow = import_nanohtml5.default`${renderCookieConsentManaged(model, consentCb)}`;
- const networkTrackersLink = shouldRenderTrackerNetworksLink(model) ? import_nanohtml5.default`${renderTrackerNetworksNew(model, nav.trackers)}` : "";
- const renderConnectionAsText = model.httpsState === "phishing";
- const connectionRow = renderConnectionAsText ? import_nanohtml5.default`${renderConnectionText(model)}` : import_nanohtml5.default`${renderConnection(model, nav.connection)}`;
- return import_nanohtml5.default`
-
- ${connectionRow} ${networkTrackersLink}
- - ${renderThirdPartyNew(model, nav.nonTrackers)}
- ${model.tab?.cookiePromptManagementStatus?.consentManaged ? consentRow : null}
-
- `;
- }
- function renderCookieConsentManaged(model, cb) {
- if (!model.tab?.cookiePromptManagementStatus)
- return null;
- const { consentManaged, cosmetic, optoutFailed, configurable } = model.tab.cookiePromptManagementStatus;
- if (consentManaged && !optoutFailed) {
- const text = cosmetic ? i18n.t("site:cookiesHidden.title") : i18n.t("site:cookiesMinimized.title");
- if (configurable) {
- return import_nanohtml5.default`
-
-
- ${text}
-
-
- `;
- } else {
- return import_nanohtml5.default`
-
-
- ${text}
-
- `;
- }
- }
- return import_nanohtml5.default``;
- }
- function renderConnection(model, cb) {
- let icon = "icon-small--insecure";
- const text = i18n.t(httpsMessages[model.httpsState]);
- const isSecure = model.httpsState === "secure";
- const isUpgraded = model.httpsState === "upgraded" && /^https/.exec(model.tab.url);
- if (isSecure || isUpgraded) {
- icon = "icon-small--secure";
- }
- return import_nanohtml5.default`
-
- ${text}
-
- `;
- }
- function renderConnectionText(model) {
- let icon = "icon-small--insecure";
- const text = i18n.t(httpsMessages[model.httpsState]);
- const isSecure = model.httpsState === "secure";
- const isUpgraded = model.httpsState === "upgraded" && /^https/.exec(model.tab.url);
- if (isSecure || isUpgraded) {
- icon = "icon-small--secure";
- }
- return import_nanohtml5.default`
-
- ${text}
-
`;
- }
- function renderTrackerNetworksNew(model, cb) {
- const title = trackerNetworksTitle(model.tab.requestDetails, model.protectionsEnabled);
- const icon = trackerNetworksIcon(model.tab.requestDetails, model.protectionsEnabled, model.tab.phishingStatus);
- return import_nanohtml5.default`
-
- ${title}
-
- `;
- }
- function renderThirdPartyNew(model, cb) {
- const title = thirdpartyTitle(model.tab.requestDetails, model.protectionsEnabled);
- const icon = thirdpartyIcon(model.tab.requestDetails, model.protectionsEnabled, model.tab.phishingStatus);
- return import_nanohtml5.default`
-
- ${title}
-
- `;
- }
- function shouldRenderTrackerNetworksLink(model) {
- const state = model.tab.requestDetails.state(model.protectionsEnabled);
- switch (state) {
- case states.protectionsOn_allowedTrackers:
- case states.protectionsOn_allowedTrackers_allowedNonTrackers:
- case states.protectionsOn_allowedFirstParty:
- case states.protectionsOn_allowedFirstParty_allowedNonTrackers:
- return false;
- default:
- return true;
- }
- }
-
- // shared/js/ui/hooks/useRipple.js
- function useRipple(params) {
- const { ref } = params;
- y2(() => {
- const $el = ref.current;
- if (!$el)
- return;
- if (!isAndroid())
- return;
- $el.classList.add("material-design-ripple");
- const instance2 = MDCRipple.attachTo($el);
- instance2.listen("click", function(e3) {
- if (e3.target instanceof HTMLElement) {
- e3.target.closest?.("a")?.blur();
- }
- });
- return () => {
- instance2.destroy();
- };
- }, []);
- }
- function useRippleChildren(count) {
- const ref = _(null);
- p2(() => {
- const $el = ref.current;
- if (!$el)
- return console.warn("missing ref");
- if (!isAndroid())
- return;
- const links = $el.querySelectorAll("a");
- const cleanup = addRippleTo(links);
- return () => {
- cleanup();
- };
- }, [count]);
- return ref;
- }
- function addRippleTo(elements) {
- const instances = [];
- elements.forEach((element) => {
- const instance2 = MDCRipple.attachTo(element);
- element.classList.add("material-design-ripple");
- instance2.listen("click", function(e3) {
- if (e3.target instanceof HTMLElement) {
- e3.target.closest?.("a")?.blur();
- }
- });
- instances.push(instance2);
- });
- return () => {
- while (instances.length) {
- const last = instances.pop();
- last.destroy();
- }
- };
- }
-
- // v2/components/main-nav.jsx
- function MainNav() {
- const data = useData();
- const { push } = useNav();
- const ref = useRippleChildren(data.count);
- return /* @__PURE__ */ y("nav", { id: "main-nav", ref }, /* @__PURE__ */ y(DomNode, { key: data.count }, template(data, {
- connection: () => {
- push("connection");
- },
- trackers: () => {
- push("trackers");
- },
- nonTrackers: () => {
- push("nonTrackers");
- },
- consentManaged: () => {
- push("consentManaged");
- },
- cookieHidden: () => {
- push("cookieHidden");
- }
- })));
- }
-
- // shared/js/ui/templates/key-insights.js
- var import_nanohtml6 = __toESM(require_browser());
- var import_raw2 = __toESM(require_raw_browser());
-
- // shared/js/ui/templates/shared/utils.js
- var offset = "a".charCodeAt(0);
- var colorCount = 16;
- function getColorId(value) {
- const characters = value.toLowerCase().split("");
- const sum = characters.reduce((total, character) => total + character.charCodeAt(0) - offset, 0);
- return Math.abs(sum % colorCount + 1);
- }
-
- // shared/js/ui/templates/key-insights.js
- var keyInsightsState = (
- /** @type {const} */
- {
- /* 01 */
- insecure: "insecure",
- /* 02 */
- broken: "broken",
- /* 03 */
- userAllowListed: "userAllowListed",
- /* 04 */
- majorTrackingNetwork: "majorTrackingNetwork",
- /* 05 */
- noneBlocked_someSpecialAllowed: "noneBlocked_someSpecialAllowed",
- /* 06 */
- noneBlocked: "noneBlocked",
- /* 07 */
- emptyCompaniesList: "emptyCompaniesList",
- /* 08 */
- blocked: "blocked",
- /* 09 */
- invalid: "invalid",
- /* 10 */
- noneBlocked_firstPartyAllowed: "noneBlocked_firstPartyAllowed",
- /* 11 */
- phishing: "phishing"
- }
- );
- function renderKeyInsight(modelOverride) {
- const model = modelOverride;
- const title = (text) => import_nanohtml6.default`${text}
`;
- const description = (text) => import_nanohtml6.default`${text}
`;
- const state = (() => {
- if (model.httpsState === "phishing")
- return keyInsightsState.phishing;
- if (model.httpsState === "none")
- return keyInsightsState.insecure;
- if (model.httpsState === "invalid")
- return keyInsightsState.invalid;
- if (model.isBroken)
- return keyInsightsState.broken;
- if (!model.protectionsEnabled)
- return keyInsightsState.userAllowListed;
- if (model.isaMajorTrackingNetwork && model.tab.parentEntity)
- return keyInsightsState.majorTrackingNetwork;
- if (model.tab.requestDetails.blocked.requestCount === 0) {
- if (model.tab.requestDetails.allowedFirstPartyOnly()) {
- return keyInsightsState.noneBlocked_firstPartyAllowed;
- }
- if (model.tab.requestDetails.allowedSpecialCount() > 0) {
- return keyInsightsState.noneBlocked_someSpecialAllowed;
- }
- return keyInsightsState.noneBlocked;
- }
- const companyNames = model.tab.requestDetails.blockedCompanyNames();
- if (companyNames.length === 0)
- return keyInsightsState.emptyCompaniesList;
- return keyInsightsState.blocked;
- })();
- return {
- insecure: () => {
- return import_nanohtml6.default`
-
-
- ${title(model.tab.domain)} ${description((0, import_raw2.default)(i18n.t("site:connectionDescriptionUnencrypted.title")))}
-
- `;
- },
- invalid: () => {
- const text = i18n.t("site:connectionDescriptionInvalidCertificate.title", { domain: model.tab.domain });
- return import_nanohtml6.default`
-
-
- ${title(model.tab.domain)} ${description((0, import_raw2.default)(text))}
-
- `;
- },
- broken: () => {
- return import_nanohtml6.default`
-
-
- ${title(model.tab.domain)}
-
- `;
- },
- userAllowListed: () => {
- return import_nanohtml6.default`
-
-
- ${title(model.tab.domain)} ${description((0, import_raw2.default)(i18n.t("site:protectionsDisabled.title")))}
-
- `;
- },
- majorTrackingNetwork: () => {
- const company = model.tab.parentEntity;
- return import_nanohtml6.default`
-
-
- ${title(model.tab.domain)}
- ${description(
- (0, import_raw2.default)(
- i18n.t("site:majorTrackingNetworkDesc.title", {
- companyDisplayName: company?.displayName,
- companyPrevalence: Math.round(company?.prevalence ?? 0),
- blocked: model.tab.requestDetails.blocked.entitiesCount > 0
- })
- )
- )}
-
- `;
- },
- noneBlocked_someSpecialAllowed: () => {
- return import_nanohtml6.default`
-
-
- ${title(model.tab.domain)} ${description(i18n.t("site:trackerNetworksSummaryAllowedOnly.title"))}
-
- `;
- },
- noneBlocked_firstPartyAllowed: () => {
- return import_nanohtml6.default`
-
-
- ${title(model.tab.domain)}
- ${description((0, import_raw2.default)(i18n.t("site:trackerNetworksSummaryFirstPartyAllowedOnly.title", { domain: model.tab.domain })))}
-
- `;
- },
- noneBlocked: () => {
- return import_nanohtml6.default`
-
-
- ${title(model.tab.domain)} ${description((0, import_raw2.default)(i18n.t("site:trackerNetworksSummaryNone.title")))}
-
- `;
- },
- emptyCompaniesList: () => {
- return import_nanohtml6.default`
-
-
- ${title(model.tab.domain)}
- ${description((0, import_raw2.default)(i18n.t("site:trackersBlockedDesc.title", generateCompanyNamesList(model))))}
-
- `;
- },
- blocked: () => {
- return import_nanohtml6.default`
-
- ${renderCompanyIconsList(model)} ${title(model.tab.domain)}
- ${description((0, import_raw2.default)(i18n.t("site:trackersBlockedDesc.title", generateCompanyNamesList(model))))}
-
- `;
- },
- phishing: () => {
- const text = i18n.t("site:phishingWebsiteDesc.title", { domain: model.tab.domain });
- return import_nanohtml6.default`
-
-
- ${title(model.tab.domain)} ${description((0, import_raw2.default)(text))}
-
- `;
- }
- }[state]();
- }
- function generateCompanyNamesList(model) {
- const blockedCompanyNames = model.tab.requestDetails.blockedCompanyNames();
- return {
- companyCount: blockedCompanyNames.length,
- othersCount: blockedCompanyNames.length - 4,
- firstCompany: blockedCompanyNames[0],
- secondCompany: blockedCompanyNames[1],
- thirdCompany: blockedCompanyNames[2],
- fourthCompany: blockedCompanyNames[3]
- };
- }
- function renderCompanyIconsList(model) {
- const companyNames = model.tab.requestDetails.blockedCompanyNames();
- if (companyNames.length === 0)
- return "";
- const topCompanies = companyNames.slice(0, 4);
- const remainingCount = companyNames.length - topCompanies.length;
- const items = ["large", "medium", "medium", "small", "small"];
- const positions = {
- 1: [1],
- 2: [2, 1],
- 3: [2, 1, 3],
- 4: [3, 2, 4, 1],
- 5: [3, 2, 4, 1, 5]
- };
- const processed = topCompanies.map((name, index) => {
- const slug = normalizeCompanyName(name);
- return {
- kind: "icon",
- slug,
- colorId: getColorId(slug),
- letter: slug[0].toUpperCase(),
- size: items[index]
- };
- });
- if (remainingCount > 0) {
- processed.push({
- kind: "more",
- count: remainingCount,
- size: items[4]
- });
- }
- const positionMap = positions[processed.length];
- const list = processed.map((item, index) => {
- if (item.kind === "icon") {
- return import_nanohtml6.default`
-
-
-
- ${blockSvg()}
-
-
- `;
- }
- return import_nanohtml6.default`
-
-
- +${item.count}
-
-