@duckduckgo/autoconsent 4.0.0 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/.github/ISSUE_TEMPLATE/broken-site-issue.md +29 -0
  2. package/CHANGELOG.md +39 -0
  3. package/Jenkinsfile +2 -2
  4. package/api.md +10 -1
  5. package/dist/addon-firefox/background.bundle.js +312 -1
  6. package/dist/addon-firefox/content.bundle.js +1912 -1
  7. package/dist/addon-firefox/manifest.json +1 -1
  8. package/dist/addon-firefox/rules.json +174 -38
  9. package/dist/addon-mv3/background.bundle.js +312 -1
  10. package/dist/addon-mv3/content.bundle.js +1912 -1
  11. package/dist/addon-mv3/devtools/background.html +10 -0
  12. package/dist/addon-mv3/devtools/bulma.min.css +1 -0
  13. package/dist/addon-mv3/devtools/loader.js +2 -0
  14. package/dist/addon-mv3/devtools/panel.html +88 -0
  15. package/dist/addon-mv3/devtools/panel.js +148 -0
  16. package/dist/addon-mv3/devtools/panel.ts +145 -0
  17. package/dist/addon-mv3/manifest.json +5 -3
  18. package/dist/addon-mv3/popup.bundle.js +173 -1
  19. package/dist/addon-mv3/popup.html +14 -0
  20. package/dist/addon-mv3/rules.json +174 -38
  21. package/dist/autoconsent.cjs.js +1 -1
  22. package/dist/autoconsent.esm.js +1 -1
  23. package/dist/autoconsent.playwright.js +1 -1
  24. package/lib/cmps/airbnb.ts +4 -0
  25. package/lib/cmps/base.ts +8 -0
  26. package/lib/cmps/consentmanager.ts +4 -0
  27. package/lib/cmps/consentomatic.ts +1 -0
  28. package/lib/cmps/conversant.ts +4 -0
  29. package/lib/cmps/cookiebot.ts +4 -0
  30. package/lib/cmps/evidon.ts +4 -0
  31. package/lib/cmps/klaro.ts +4 -0
  32. package/lib/cmps/onetrust.ts +4 -0
  33. package/lib/cmps/sourcepoint-frame.ts +4 -0
  34. package/lib/cmps/tiktok.ts +4 -0
  35. package/lib/cmps/trustarc-frame.ts +4 -0
  36. package/lib/cmps/trustarc-top.ts +4 -0
  37. package/lib/cmps/uniconsent.ts +4 -0
  38. package/lib/eval-handler.ts +2 -6
  39. package/lib/messages.ts +44 -13
  40. package/lib/random.ts +6 -0
  41. package/lib/rules.ts +2 -1
  42. package/lib/types.ts +27 -0
  43. package/lib/web.ts +127 -82
  44. package/package.json +4 -3
  45. package/playwright/runner.ts +1 -0
  46. package/rollup.config.js +18 -5
  47. package/rules/autoconsent/ausopen.json +2 -2
  48. package/rules/autoconsent/baden-wuerttemberg-de.json +1 -0
  49. package/rules/autoconsent/cc-banner.json +1 -0
  50. package/rules/autoconsent/complianz-notice.json +1 -0
  51. package/rules/autoconsent/cookie-notice.json +2 -1
  52. package/rules/autoconsent/dsgvo.json +1 -0
  53. package/rules/autoconsent/eu-cookie-compliance.json +1 -1
  54. package/rules/autoconsent/eu-cookie-law.json +1 -0
  55. package/rules/autoconsent/ezoic.json +1 -0
  56. package/rules/autoconsent/generic-cosmetic.json +9 -0
  57. package/rules/autoconsent/indeed-com.json +9 -0
  58. package/rules/autoconsent/jquery-cookiebar.json +1 -0
  59. package/rules/autoconsent/marksandspencer.json +2 -2
  60. package/rules/autoconsent/notice-cookie.json +1 -0
  61. package/rules/autoconsent/osano.json +1 -0
  62. package/rules/autoconsent/pornhub.json +12 -0
  63. package/rules/autoconsent/testcmp-cosmetic.json +18 -0
  64. package/rules/autoconsent/uk-cookie-consent.json +1 -0
  65. package/rules/autoconsent/xnxx-com.json +9 -0
  66. package/rules/rules.json +174 -38
  67. package/tests/borlabs.spec.ts +1 -1
  68. package/tests/complianz-optin.spec.ts +4 -4
  69. package/tests/cookie-notice.spec.ts +3 -1
  70. package/tests/cookiebot.spec.ts +0 -4
  71. package/tests/cookieinformation.spec.ts +0 -1
  72. package/tests/dsgvo.spec.ts +4 -1
  73. package/tests/evidon.spec.ts +2 -4
  74. package/tests/ezoic.spec.ts +0 -1
  75. package/tests/fundingchoices.spec.ts +0 -1
  76. package/tests/generic-cosmetic.spec.ts +11 -0
  77. package/tests/indeed.spec.ts +7 -0
  78. package/tests/moove.spec.ts +0 -6
  79. package/tests/pornhub.spec.ts +7 -0
  80. package/tests/pubtech.spec.ts +0 -1
  81. package/tests/reddit.spec.ts +1 -1
  82. package/tests/sibbo.spec.ts +0 -1
  83. package/tests/sirdata.spec.ts +0 -1
  84. package/tests/testcmp-banner.spec.ts +5 -0
  85. package/tests/trustarc.spec.ts +0 -2
  86. package/tests/uniconsent.spec.ts +1 -1
  87. package/tests/usercentrics-api.spec.ts +1 -0
  88. package/tests/usercentrics-button.spec.ts +0 -1
  89. package/tests/xnxx.spec.ts +8 -0
  90. package/tsconfig.json +2 -1
  91. package/rules/autoconsent/motor-talk-de.json +0 -24
  92. package/tests/motor-talk.spec.ts +0 -7
@@ -169,7 +169,7 @@
169
169
  },
170
170
  {
171
171
  "name": "ausopen.com",
172
- "isHidingRule": true,
172
+ "cosmetic": true,
173
173
  "detectCmp": [
174
174
  {
175
175
  "exists": ".gdpr-popup__message"
@@ -189,9 +189,7 @@
189
189
  ],
190
190
  "optIn": [
191
191
  {
192
- "click": [
193
- ".gdpr-popup__message button"
194
- ]
192
+ "click": ".gdpr-popup__message button"
195
193
  }
196
194
  ]
197
195
  },
@@ -277,6 +275,7 @@
277
275
  "prehideSelectors": [
278
276
  ".cookie-alert.t-dark"
279
277
  ],
278
+ "cosmetic": true,
280
279
  "detectCmp": [
281
280
  {
282
281
  "exists": ".cookie-alert.t-dark"
@@ -419,6 +418,7 @@
419
418
  },
420
419
  {
421
420
  "name": "cc_banner",
421
+ "cosmetic": true,
422
422
  "prehideSelectors": [
423
423
  ".cc_banner-wrapper"
424
424
  ],
@@ -570,6 +570,7 @@
570
570
  "prehideSelectors": [
571
571
  ".cc-type-info[aria-describedby=\"cookieconsent:desc\"]"
572
572
  ],
573
+ "cosmetic": true,
573
574
  "detectCmp": [
574
575
  {
575
576
  "exists": ".cc-type-info[aria-describedby=\"cookieconsent:desc\"]"
@@ -693,6 +694,7 @@
693
694
  "prehideSelectors": [
694
695
  "#cookie-notice"
695
696
  ],
697
+ "cosmetic": true,
696
698
  "detectCmp": [
697
699
  {
698
700
  "visible": "#cookie-notice .cookie-notice-container"
@@ -705,9 +707,7 @@
705
707
  ],
706
708
  "optIn": [
707
709
  {
708
- "click": [
709
- "#cn-accept-cookie"
710
- ]
710
+ "click": "#cn-accept-cookie"
711
711
  }
712
712
  ],
713
713
  "optOut": [
@@ -957,6 +957,7 @@
957
957
  "prehideSelectors": [
958
958
  ".sp-dsgvo"
959
959
  ],
960
+ "cosmetic": true,
960
961
  "detectCmp": [
961
962
  {
962
963
  "exists": ".sp-dsgvo.sp-dsgvo-popup-overlay"
@@ -1070,7 +1071,7 @@
1070
1071
  ],
1071
1072
  "detectPopup": [
1072
1073
  {
1073
- "visible": ".eu-cookie-compliance-banner-info"
1074
+ "exists": ".eu-cookie-compliance-popup-open"
1074
1075
  }
1075
1076
  ],
1076
1077
  "optIn": [
@@ -1101,6 +1102,7 @@
1101
1102
  "prehideSelectors": [
1102
1103
  ".pea_cook_wrapper,.pea_cook_more_info_popover"
1103
1104
  ],
1105
+ "cosmetic": true,
1104
1106
  "detectCmp": [
1105
1107
  {
1106
1108
  "exists": ".pea_cook_wrapper"
@@ -1158,6 +1160,9 @@
1158
1160
  }
1159
1161
  ],
1160
1162
  "optOut": [
1163
+ {
1164
+ "wait": 500
1165
+ },
1161
1166
  {
1162
1167
  "click": "#ez-manage-settings"
1163
1168
  },
@@ -1250,6 +1255,31 @@
1250
1255
  }
1251
1256
  ]
1252
1257
  },
1258
+ {
1259
+ "name": "generic-cosmetic",
1260
+ "cosmetic": true,
1261
+ "prehideSelectors": [
1262
+ "#js-cookie-banner,.js-cookie-banner,.cookie-banner,#cookie-banner"
1263
+ ],
1264
+ "detectCmp": [
1265
+ {
1266
+ "exists": "#js-cookie-banner,.js-cookie-banner,.cookie-banner,#cookie-banner"
1267
+ }
1268
+ ],
1269
+ "detectPopup": [
1270
+ {
1271
+ "visible": "#js-cookie-banner,.js-cookie-banner,.cookie-banner,#cookie-banner"
1272
+ }
1273
+ ],
1274
+ "optIn": [],
1275
+ "optOut": [
1276
+ {
1277
+ "hide": [
1278
+ "#js-cookie-banner,.js-cookie-banner,.cookie-banner,#cookie-banner"
1279
+ ]
1280
+ }
1281
+ ]
1282
+ },
1253
1283
  {
1254
1284
  "name": "google-consent-standalone",
1255
1285
  "prehideSelectors": [],
@@ -1409,6 +1439,35 @@
1409
1439
  }
1410
1440
  ]
1411
1441
  },
1442
+ {
1443
+ "name": "indeed.com",
1444
+ "cosmetic": true,
1445
+ "prehideSelectors": [
1446
+ "#CookiePrivacyNotice"
1447
+ ],
1448
+ "detectCmp": [
1449
+ {
1450
+ "exists": "#CookiePrivacyNotice"
1451
+ }
1452
+ ],
1453
+ "detectPopup": [
1454
+ {
1455
+ "visible": "#CookiePrivacyNotice"
1456
+ }
1457
+ ],
1458
+ "optIn": [
1459
+ {
1460
+ "click": "#CookiePrivacyNotice button[data-gnav-element-name=CookiePrivacyNoticeOk]"
1461
+ }
1462
+ ],
1463
+ "optOut": [
1464
+ {
1465
+ "hide": [
1466
+ "#CookiePrivacyNotice"
1467
+ ]
1468
+ }
1469
+ ]
1470
+ },
1412
1471
  {
1413
1472
  "name": "ionos.de",
1414
1473
  "prehideSelectors": [
@@ -1519,6 +1578,7 @@
1519
1578
  "prehideSelectors": [
1520
1579
  ".cookie-bar"
1521
1580
  ],
1581
+ "cosmetic": true,
1522
1582
  "detectCmp": [
1523
1583
  {
1524
1584
  "exists": ".cookie-bar .cookie-bar__message,.cookie-bar .cookie-bar__buttons"
@@ -1598,7 +1658,7 @@
1598
1658
  },
1599
1659
  {
1600
1660
  "name": "marksandspencer.com",
1601
- "isHidingRule": true,
1661
+ "cosmetic": true,
1602
1662
  "detectCmp": [
1603
1663
  {
1604
1664
  "exists": ".navigation-cookiebbanner"
@@ -1618,9 +1678,7 @@
1618
1678
  ],
1619
1679
  "optIn": [
1620
1680
  {
1621
- "click": [
1622
- ".navigation-cookiebbanner__submit"
1623
- ]
1681
+ "click": ".navigation-cookiebbanner__submit"
1624
1682
  }
1625
1683
  ]
1626
1684
  },
@@ -1857,32 +1915,6 @@
1857
1915
  }
1858
1916
  ]
1859
1917
  },
1860
- {
1861
- "name": "motor-talk.de",
1862
- "prehideSelectors": [
1863
- ".mt-cc-bnnr__wrapper"
1864
- ],
1865
- "detectCmp": [
1866
- {
1867
- "exists": ".mt-cc-bnnr"
1868
- }
1869
- ],
1870
- "detectPopup": [
1871
- {
1872
- "visible": ".mt-cc-bnnr__wrapper"
1873
- }
1874
- ],
1875
- "optIn": [
1876
- {
1877
- "click": ".mt-cc-bnnr__button-main"
1878
- }
1879
- ],
1880
- "optOut": [
1881
- {
1882
- "click": ".mt-cc-bnnr__decline-link"
1883
- }
1884
- ]
1885
- },
1886
1918
  {
1887
1919
  "name": "national-lottery.co.uk",
1888
1920
  "detectCmp": [
@@ -1973,6 +2005,7 @@
1973
2005
  "prehideSelectors": [
1974
2006
  ".button--notice"
1975
2007
  ],
2008
+ "cosmetic": true,
1976
2009
  "detectCmp": [
1977
2010
  {
1978
2011
  "exists": ".notice--cookie"
@@ -2027,6 +2060,7 @@
2027
2060
  "prehideSelectors": [
2028
2061
  ".osano-cm-window"
2029
2062
  ],
2063
+ "cosmetic": true,
2030
2064
  "detectCmp": [
2031
2065
  {
2032
2066
  "exists": ".osano-cm-window"
@@ -2114,6 +2148,38 @@
2114
2148
  }
2115
2149
  ]
2116
2150
  },
2151
+ {
2152
+ "name": "pornhub.com",
2153
+ "runContext": {
2154
+ "urlPattern": "^https://(www\\.)?pornhub\\.com/"
2155
+ },
2156
+ "cosmetic": true,
2157
+ "prehideSelectors": [
2158
+ ".cookiesBanner"
2159
+ ],
2160
+ "detectCmp": [
2161
+ {
2162
+ "exists": ".cookiesBanner"
2163
+ }
2164
+ ],
2165
+ "detectPopup": [
2166
+ {
2167
+ "visible": ".cookiesBanner"
2168
+ }
2169
+ ],
2170
+ "optIn": [
2171
+ {
2172
+ "click": ".cookiesBanner .okButton"
2173
+ }
2174
+ ],
2175
+ "optOut": [
2176
+ {
2177
+ "hide": [
2178
+ ".cookiesBanner"
2179
+ ]
2180
+ }
2181
+ ]
2182
+ },
2117
2183
  {
2118
2184
  "name": "PrimeBox CookieBar",
2119
2185
  "prehideSelectors": [
@@ -2621,6 +2687,46 @@
2621
2687
  }
2622
2688
  ]
2623
2689
  },
2690
+ {
2691
+ "name": "Test page cosmetic CMP",
2692
+ "cosmetic": true,
2693
+ "prehideSelectors": [
2694
+ "#privacy-test-page-cmp-test-prehide"
2695
+ ],
2696
+ "detectCmp": [
2697
+ {
2698
+ "exists": "#privacy-test-page-cmp-test-banner"
2699
+ }
2700
+ ],
2701
+ "detectPopup": [
2702
+ {
2703
+ "visible": "#privacy-test-page-cmp-test-banner"
2704
+ }
2705
+ ],
2706
+ "optIn": [
2707
+ {
2708
+ "waitFor": "#accept-all"
2709
+ },
2710
+ {
2711
+ "click": "#accept-all"
2712
+ }
2713
+ ],
2714
+ "optOut": [
2715
+ {
2716
+ "hide": [
2717
+ "#privacy-test-page-cmp-test-banner"
2718
+ ]
2719
+ }
2720
+ ],
2721
+ "test": [
2722
+ {
2723
+ "wait": 500
2724
+ },
2725
+ {
2726
+ "eval": "window.results.results[0] === 'banner_hidden'"
2727
+ }
2728
+ ]
2729
+ },
2624
2730
  {
2625
2731
  "name": "Test page CMP",
2626
2732
  "prehideSelectors": [
@@ -2749,6 +2855,7 @@
2749
2855
  "prehideSelectors": [
2750
2856
  "#catapult-cookie-bar"
2751
2857
  ],
2858
+ "cosmetic": true,
2752
2859
  "detectCmp": [
2753
2860
  {
2754
2861
  "exists": "#catapult-cookie-bar"
@@ -3025,6 +3132,35 @@
3025
3132
  }
3026
3133
  ]
3027
3134
  },
3135
+ {
3136
+ "name": "xnxx-com",
3137
+ "cosmetic": true,
3138
+ "prehideSelectors": [
3139
+ "#cookies-use-alert"
3140
+ ],
3141
+ "detectCmp": [
3142
+ {
3143
+ "exists": "#cookies-use-alert"
3144
+ }
3145
+ ],
3146
+ "detectPopup": [
3147
+ {
3148
+ "visible": "#cookies-use-alert"
3149
+ }
3150
+ ],
3151
+ "optIn": [
3152
+ {
3153
+ "click": "#cookies-use-alert .close"
3154
+ }
3155
+ ],
3156
+ "optOut": [
3157
+ {
3158
+ "hide": [
3159
+ "#cookies-use-alert"
3160
+ ]
3161
+ }
3162
+ ]
3163
+ },
3028
3164
  {
3029
3165
  "name": "youtube-desktop",
3030
3166
  "prehideSelectors": [
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t{constructor(t,e=1e3){this.id=t,this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e})),this.timer=window.setTimeout((()=>{this.reject(new Error("timeout"))}),e)}}const e={pending:new Map,sendContentMessage:null};function n(t="autoconsent-css-rules"){const e=`style#${t}`,n=document.querySelector(e);if(n&&n instanceof HTMLStyleElement)return n;{const e=document.head||document.getElementsByTagName("head")[0]||document.documentElement,n=document.createElement("style");return n.id=t,e.appendChild(n),n}}function o(t,e,n="display"){const o="opacity"===n?"opacity: 0":"display: none",i=`${e.join(",")} { ${o} !important; z-index: -1 !important; pointer-events: none !important; } `;return t instanceof HTMLStyleElement&&(t.innerText+=i,e.length>0)}async function i(t,e,n){const o=await t();return!o&&e>0?new Promise((o=>{setTimeout((async()=>{o(i(t,e-1,n))}),n)})):Promise.resolve(o)}function s(t){if(!t)return!1;if(null!==t.offsetParent)return!0;{const e=window.getComputedStyle(t);if("fixed"===e.position&&"none"!==e.display)return!0}return!1}function r(n){return function(n){let o;o=crypto&&void 0!==crypto.randomUUID?crypto.randomUUID():Math.random().toString(),e.sendContentMessage({type:"eval",id:o,code:n});const i=new t(o);return e.pending.set(i.id,i),i.promise}(n).catch((t=>!1))}function c(t,e=!1){let n=[];return n="string"==typeof t?Array.from(document.querySelectorAll(t)):t,n.length>0&&(e?n.forEach((t=>t.click())):n[0].click()),n.length>0}function a(t){return null!==document.querySelector(t)}function u(t,e){const n=document.querySelectorAll(t),o=new Array(n.length);return n.forEach(((t,e)=>{o[e]=s(t)})),"none"===e?o.every((t=>!t)):0!==o.length&&("any"===e?o.some((t=>t)):o.every((t=>t)))}function l(t,e=1e4){return i((()=>null!==document.querySelector(t)),Math.ceil(e/200),200)}async function p(t,e=1e4,n=!1){return await l(t,e),c(t,n)}function d(t){return new Promise((e=>{setTimeout((()=>{e(!0)}),t)}))}function h(){const t=n("autoconsent-prehide");return t&&t.remove(),!!t}const m={main:!0,frame:!1,urlPattern:""};class f{constructor(t){this.runContext=m,this.name=t}get hasSelfTest(){throw new Error("Not Implemented")}get isIntermediate(){throw new Error("Not Implemented")}checkRunContext(){const t={...m,...this.runContext},e=window.top===window;return!(e&&!t.main)&&(!(!e&&!t.frame)&&!(t.urlPattern&&!window.location.href.match(t.urlPattern)))}detectCmp(){throw new Error("Not Implemented")}async detectPopup(){return!1}optOut(){throw new Error("Not Implemented")}optIn(){throw new Error("Not Implemented")}openCmp(){throw new Error("Not Implemented")}async test(){return Promise.resolve(!0)}}async function y(t){const e=[];if(t.exists&&e.push(a(t.exists)),t.visible&&e.push(u(t.visible,t.check)),t.eval){const n=r(t.eval);e.push(n)}var s,h;if(t.waitFor&&e.push(l(t.waitFor,t.timeout)),t.waitForVisible&&e.push(function(t,e=1e4,n="any"){return i((()=>u(t,n)),Math.ceil(e/200),200)}(t.waitForVisible,t.timeout,t.check)),t.click&&e.push(c(t.click,t.all)),t.waitForThenClick&&e.push(p(t.waitForThenClick,t.timeout,t.all)),t.wait&&e.push(d(t.wait)),t.hide&&e.push((s=t.hide,h=t.method,o(n(),s,h))),t.if){if(!t.if.exists&&!t.if.visible)return console.error("invalid conditional rule",t.if),!1;await y(t.if)?e.push(w(t.then)):t.else&&e.push(w(t.else))}if(0===e.length)return!1;return(await Promise.all(e)).reduce(((t,e)=>t&&e),!0)}async function w(t){for(const e of t){if(!await y(e)&&!e.optional)return!1}return!0}class g extends f{constructor(t){super(t.name),this.config=t,this.runContext=t.runContext||m}get hasSelfTest(){return!!this.config.test}get isIntermediate(){return!!this.config.intermediate}get prehideSelectors(){return this.config.prehideSelectors}async detectCmp(){return!!this.config.detectCmp&&async function(t){const e=t.map((t=>y(t)));return(await Promise.all(e)).every((t=>!!t))}(this.config.detectCmp)}async detectPopup(){return!!this.config.detectPopup&&w(this.config.detectPopup)}async optOut(){return!!this.config.optOut&&w(this.config.optOut)}async optIn(){return!!this.config.optIn&&w(this.config.optIn)}async openCmp(){return!!this.config.openCmp&&w(this.config.openCmp)}async test(){return this.hasSelfTest?w(this.config.test):super.test()}}function b(t){return new g(t)}const C=[new class extends f{constructor(){super("TrustArc-top"),this.prehideSelectors=[".trustarc-banner-container",".truste_popframe,.truste_overlay,.truste_box_overlay,#truste-consent-track"],this.runContext={main:!0,frame:!1},this._shortcutButton=null,this._optInDone=!1}get hasSelfTest(){return!1}get isIntermediate(){return!this._optInDone&&!this._shortcutButton}async detectCmp(){const t=a("#truste-show-consent,#truste-consent-track");return t&&(this._shortcutButton=document.querySelector("#truste-consent-required")),t}async detectPopup(){return u("#truste-consent-content,#trustarc-banner-overlay,#truste-consent-track","all")}openFrame(){c("#truste-show-consent")}async optOut(){return this._shortcutButton?(this._shortcutButton.click(),!0):(o(n(),[".truste_popframe",".truste_overlay",".truste_box_overlay","#truste-consent-track"]),c("#truste-show-consent"),setTimeout((()=>{n().remove()}),1e4),!0)}async optIn(){return this._optInDone=!0,c("#truste-consent-button")}async openCmp(){return!0}async test(){return!0}},new class extends f{constructor(){super("TrustArc-frame"),this.runContext={main:!1,frame:!0,urlPattern:"^https://consent-pref\\.trustarc\\.com/\\?"}}get hasSelfTest(){return!1}get isIntermediate(){return!1}async detectCmp(){return!0}async detectPopup(){return u("#defaultpreferencemanager","any")&&u(".mainContent","any")}async navigateToSettings(){return await i((async()=>a(".shp")||u(".advance","any")||a(".switch span:first-child")),10,500),a(".shp")&&c(".shp"),await l(".prefPanel",5e3),u(".advance","any")&&c(".advance"),await i((()=>u(".switch span:first-child","any")),5,1e3)}async optOut(){return await i((()=>"complete"===document.readyState),20,100),await l(".mainContent[aria-hidden=false]",5e3),!!c(".rejectAll")||(a(".prefPanel")&&await l('.prefPanel[style="visibility: visible;"]',3e3),c("#catDetails0")?(c(".submit"),!0):(c(".required")||(await this.navigateToSettings(),c(".switch span:nth-child(1):not(.active)",!0),c(".submit"),l("#gwt-debug-close_id",3e5).then((()=>{c("#gwt-debug-close_id")}))),!0))}async optIn(){return c(".call")||(await this.navigateToSettings(),c(".switch span:nth-child(2)",!0),c(".submit"),l("#gwt-debug-close_id",3e5).then((()=>{c("#gwt-debug-close_id")}))),!0}},new class extends f{constructor(){super("Cybotcookiebot"),this.prehideSelectors=["#CybotCookiebotDialog,#dtcookie-container,#cookiebanner,#cb-cookieoverlay"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}async detectCmp(){return a("#CybotCookiebotDialogBodyLevelButtonPreferences")}async detectPopup(){return a("#CybotCookiebotDialog,#dtcookie-container,#cookiebanner,#cb-cookiebanner")}async optOut(){return c(".cookie-alert-extended-detail-link")?(await l(".cookie-alert-configuration",2e3),c(".cookie-alert-configuration-input:checked",!0),c(".cookie-alert-extended-button-secondary"),!0):a("#dtcookie-container")?c(".h-dtcookie-decline"):(c(".cookiebot__button--settings")||c("#CybotCookiebotDialogBodyButtonDecline")||(c(".cookiebanner__link--details"),c('.CybotCookiebotDialogBodyLevelButton:checked:enabled,input[id*="CybotCookiebotDialogBodyLevelButton"]:checked:enabled',!0),c("#CybotCookiebotDialogBodyButtonDecline"),c("input[id^=CybotCookiebotDialogBodyLevelButton]:checked",!0),a("#CybotCookiebotDialogBodyButtonAcceptSelected")?c("#CybotCookiebotDialogBodyButtonAcceptSelected"):c("#CybotCookiebotDialogBodyLevelButtonAccept,#CybotCookiebotDialogBodyButtonAccept,#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowallSelection",!0),await r("window.CookieConsent.hasResponse !== true")&&(await r("window.Cookiebot.dialog.submitConsent()"),await d(500)),a("#cb-confirmedSettings")&&await r("endCookieProcess()")),!0)}async optIn(){return a("#dtcookie-container")?c(".h-dtcookie-accept"):(c(".CybotCookiebotDialogBodyLevelButton:not(:checked):enabled",!0),c("#CybotCookiebotDialogBodyLevelButtonAccept"),c("#CybotCookiebotDialogBodyButtonAccept"),!0)}async test(){return r("window.CookieConsent.declined === true")}},new class extends f{constructor(){super("Sourcepoint-frame"),this.prehideSelectors=["div[id^='sp_message_container_'],.message-overlay","#sp_privacy_manager_container"],this.ccpaNotice=!1,this.ccpaPopup=!1,this.runContext={main:!1,frame:!0}}get hasSelfTest(){return!1}get isIntermediate(){return!1}async detectCmp(){const t=new URL(location.href);return t.searchParams.has("message_id")&&"ccpa-notice.sp-prod.net"===t.hostname?(this.ccpaNotice=!0,!0):"ccpa-pm.sp-prod.net"===t.hostname?(this.ccpaPopup=!0,!0):("/index.html"===t.pathname||"/privacy-manager/index.html"===t.pathname)&&(t.searchParams.has("message_id")||t.searchParams.has("requestUUID")||t.searchParams.has("consentUUID"))}async detectPopup(){return!!this.ccpaNotice||(this.ccpaPopup?await l(".priv-save-btn",2e3):(await l(".sp_choice_type_11,.sp_choice_type_12,.sp_choice_type_13,.sp_choice_type_ACCEPT_ALL",2e3),!a(".sp_choice_type_9")))}async optIn(){return await l(".sp_choice_type_11,.sp_choice_type_ACCEPT_ALL",2e3),!!c(".sp_choice_type_11")||!!c(".sp_choice_type_ACCEPT_ALL")}isManagerOpen(){return"/privacy-manager/index.html"===location.pathname}async optOut(){if(this.ccpaPopup){const t=document.querySelectorAll(".priv-purpose-container .sp-switch-arrow-block a.neutral.on .right");for(const e of t)c([e]);const e=document.querySelectorAll(".priv-purpose-container .sp-switch-arrow-block a.switch-bg.on");for(const t of e)c([t]);return c(".priv-save-btn")}if(!this.isManagerOpen()){if(!await l(".sp_choice_type_12,.sp_choice_type_13"))return!1;if(!a(".sp_choice_type_12"))return c(".sp_choice_type_13");c(".sp_choice_type_12"),await i((()=>this.isManagerOpen()),200,100)}await l(".type-modal",2e4);try{const t=".sp_choice_type_REJECT_ALL",e=".reject-toggle",n=await Promise.race([l(t,2e3).then((t=>t?0:-1)),l(e,2e3).then((t=>t?1:-1)),l(".pm-features",2e3).then((t=>t?2:-1))]);if(0===n)return await d(1e3),c(t);1===n?c(e):2===n&&(await l(".pm-features",1e4),c(".checked > span",!0),c(".chevron"))}catch(t){}return c(".sp_choice_type_SAVE_AND_EXIT")}},new class extends f{constructor(){super("consentmanager.net"),this.prehideSelectors=["#cmpbox,#cmpbox2"],this.apiAvailable=!1}get hasSelfTest(){return this.apiAvailable}get isIntermediate(){return!1}async detectCmp(){return this.apiAvailable=await r('window.__cmp && typeof __cmp("getCMPData") === "object"'),!!this.apiAvailable||a("#cmpbox")}async detectPopup(){return this.apiAvailable?(await d(500),await r("!__cmp('consentStatus').userChoiceExists")):u("#cmpbox .cmpmore","any")}async optOut(){return await d(500),this.apiAvailable?await r("__cmp('setConsent', 0)"):!!c(".cmpboxbtnno")||(a(".cmpwelcomeprpsbtn")?(c(".cmpwelcomeprpsbtn > a[aria-checked=true]",!0),c(".cmpboxbtnsave"),!0):(c(".cmpboxbtncustom"),await l(".cmptblbox",2e3),c(".cmptdchoice > a[aria-checked=true]",!0),c(".cmpboxbtnyescustomchoices"),!0))}async optIn(){return this.apiAvailable?await r("__cmp('setConsent', 1)"):c(".cmpboxbtnyes")}async test(){if(this.apiAvailable)return await r("__cmp('consentStatus').userChoiceExists")}},new class extends f{constructor(){super("Evidon")}get hasSelfTest(){return!1}get isIntermediate(){return!1}async detectCmp(){return a("#_evidon_banner")}async detectPopup(){return u("#_evidon_banner","any")}async optOut(){return c("#_evidon-decline-button")||(o(n(),["#evidon-prefdiag-overlay","#evidon-prefdiag-background"]),c("#_evidon-option-button"),await l("#evidon-prefdiag-overlay",5e3),c("#evidon-prefdiag-decline")),!0}async optIn(){return c("#_evidon-accept-button")}},new class extends f{constructor(){super("Onetrust"),this.prehideSelectors=["#onetrust-banner-sdk,#onetrust-consent-sdk,.onetrust-pc-dark-filter,.js-consent-banner"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}async detectCmp(){return a("#onetrust-banner-sdk")}async detectPopup(){return u("#onetrust-banner-sdk","all")}async optOut(){return a("#onetrust-pc-btn-handler")?c("#onetrust-pc-btn-handler"):c(".ot-sdk-show-settings,button.js-cookie-settings"),await l("#onetrust-consent-sdk",2e3),await d(1e3),c("#onetrust-consent-sdk input.category-switch-handler:checked,.js-editor-toggle-state:checked",!0),await d(1e3),await l(".save-preference-btn-handler,.js-consent-save",2e3),c(".save-preference-btn-handler,.js-consent-save"),await i((()=>u("#onetrust-banner-sdk","none")),10,500),!0}async optIn(){return c("#onetrust-accept-btn-handler,.js-accept-cookies")}async test(){return await r("window.OnetrustActiveGroups.split(',').filter(s => s.length > 0).length <= 1")}},new class extends f{constructor(){super("Klaro"),this.prehideSelectors=[".klaro"],this.settingsOpen=!1}get hasSelfTest(){return!0}get isIntermediate(){return!1}async detectCmp(){return a(".klaro > .cookie-modal")?(this.settingsOpen=!0,!0):a(".klaro > .cookie-notice")}async detectPopup(){return u(".klaro > .cookie-notice,.klaro > .cookie-modal","any")}async optOut(){return!!c(".klaro .cn-decline")||(this.settingsOpen||(c(".klaro .cn-learn-more"),await l(".klaro > .cookie-modal",2e3),this.settingsOpen=!0),!!c(".klaro .cn-decline")||(c(".cm-purpose:not(.cm-toggle-all) > input:not(.half-checked)",!0),c(".cm-btn-accept")))}async optIn(){return!!c(".klaro .cm-btn-accept-all")||(this.settingsOpen?(c(".cm-purpose:not(.cm-toggle-all) > input.half-checked",!0),c(".cm-btn-accept")):c(".klaro .cookie-notice .cm-btn-success"))}async test(){return await r("klaro.getManager().config.services.every(c => c.required || !klaro.getManager().consents[c.name])")}},new class extends f{constructor(){super("Uniconsent")}get prehideSelectors(){return[".unic",".modal:has(.unic)"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}async detectCmp(){return a(".unic .unic-box,.unic .unic-bar")}async detectPopup(){return u(".unic .unic-box,.unic .unic-bar","any")}async optOut(){if(await l(".unic button",1e3),document.querySelectorAll(".unic button").forEach((t=>{const e=t.textContent;(e.includes("Manage Options")||e.includes("Optionen verwalten"))&&t.click()})),await l(".unic input[type=checkbox]",1e3)){await l(".unic button",1e3),document.querySelectorAll(".unic input[type=checkbox]").forEach((t=>{t.checked&&t.click()}));for(const t of document.querySelectorAll(".unic button")){const e=t.textContent;for(const n of["Confirm Choices","Save Choices","Auswahl speichern"])if(e.includes(n))return t.click(),await d(500),!0}}return!1}async optIn(){return p(".unic #unic-agree")}async test(){await d(1e3);return!a(".unic .unic-box,.unic .unic-bar")}},new class extends f{constructor(){super("Conversant"),this.prehideSelectors=[".cmp-root"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}async detectCmp(){return a(".cmp-root .cmp-receptacle")}async detectPopup(){return u(".cmp-root .cmp-receptacle","any")}async optOut(){if(!await p(".cmp-main-button:not(.cmp-main-button--primary)"))return!1;if(!await l(".cmp-view-tab-tabs"))return!1;await p(".cmp-view-tab-tabs > :first-child"),await p(".cmp-view-tab-tabs > .cmp-view-tab--active:first-child");for(const t of Array.from(document.querySelectorAll(".cmp-accordion-item"))){t.querySelector(".cmp-accordion-item-title").click(),await i((()=>!!t.querySelector(".cmp-accordion-item-content.cmp-active")),10,50);const e=t.querySelector(".cmp-accordion-item-content.cmp-active");e.querySelectorAll(".cmp-toggle-actions .cmp-toggle-deny:not(.cmp-toggle-deny--active)").forEach((t=>t.click())),e.querySelectorAll(".cmp-toggle-actions .cmp-toggle-checkbox:not(.cmp-toggle-checkbox--active)").forEach((t=>t.click()))}return await c(".cmp-main-button:not(.cmp-main-button--primary)"),!0}async optIn(){return p(".cmp-main-button.cmp-main-button--primary")}async test(){return document.cookie.includes("cmp-data=0")}},new class extends f{constructor(){super("tiktok.com"),this.runContext={urlPattern:"tiktok"}}get hasSelfTest(){return!0}get isIntermediate(){return!1}getShadowRoot(){const t=document.querySelector("tiktok-cookie-banner");return t?t.shadowRoot:null}async detectCmp(){return a("tiktok-cookie-banner")}async detectPopup(){return s(this.getShadowRoot().querySelector(".tiktok-cookie-banner"))}async optOut(){const t=this.getShadowRoot().querySelector(".button-wrapper button:first-child");return!!t&&(t.click(),!0)}async optIn(){const t=this.getShadowRoot().querySelector(".button-wrapper button:last-child");return!!t&&(t.click(),!0)}async test(){const t=document.cookie.match(/cookie-consent=([^;]+)/);if(!t)return!1;const e=JSON.parse(decodeURIComponent(t[1]));return Object.values(e).every((t=>"boolean"!=typeof t||!1===t))}},new class extends f{constructor(){super("airbnb"),this.runContext={urlPattern:"^https://(www\\.)?airbnb\\.[^/]+/"},this.prehideSelectors=["div[data-testid=main-cookies-banner-container]",'div:has(> div:first-child):has(> div:last-child):has(> section [data-testid="strictly-necessary-cookies"])']}get hasSelfTest(){return!0}get isIntermediate(){return!1}async detectCmp(){return a("div[data-testid=main-cookies-banner-container]")}async detectPopup(){return u("div[data-testid=main-cookies-banner-container","any")}async optOut(){let t;for(await p("div[data-testid=main-cookies-banner-container] button._snbhip0");t=document.querySelector("[data-testid=modal-container] button[aria-checked=true]:not([disabled])");)t.click();return p("button[data-testid=save-btn]")}async optIn(){return p("div[data-testid=main-cookies-banner-container] button._148dgdpk")}async test(){return await i((()=>!!document.cookie.match("OptanonAlertBoxClosed")),20,200)}}];class k{static setBase(t){k.base=t}static findElement(t,e=null,n=!1){let o=null;return o=null!=e?Array.from(e.querySelectorAll(t.selector)):null!=k.base?Array.from(k.base.querySelectorAll(t.selector)):Array.from(document.querySelectorAll(t.selector)),null!=t.textFilter&&(o=o.filter((e=>{const n=e.textContent.toLowerCase();if(Array.isArray(t.textFilter)){let e=!1;for(const o of t.textFilter)if(-1!==n.indexOf(o.toLowerCase())){e=!0;break}return e}if(null!=t.textFilter)return-1!==n.indexOf(t.textFilter.toLowerCase())}))),null!=t.styleFilters&&(o=o.filter((e=>{const n=window.getComputedStyle(e);let o=!0;for(const e of t.styleFilters){const t=n[e.option];o=e.negated?o&&t!==e.value:o&&t===e.value}return o}))),null!=t.displayFilter&&(o=o.filter((e=>t.displayFilter?0!==e.offsetHeight:0===e.offsetHeight))),null!=t.iframeFilter&&(o=o.filter((()=>t.iframeFilter?window.location!==window.parent.location:window.location===window.parent.location))),null!=t.childFilter&&(o=o.filter((e=>{const n=k.base;k.setBase(e);const o=k.find(t.childFilter);return k.setBase(n),null!=o.target}))),n?o:(o.length>1&&console.warn("Multiple possible targets: ",o,t,e),o[0])}static find(t,e=!1){const n=[];if(null!=t.parent){const o=k.findElement(t.parent,null,e);if(null!=o){if(o instanceof Array)return o.forEach((o=>{const i=k.findElement(t.target,o,e);i instanceof Array?i.forEach((t=>{n.push({parent:o,target:t})})):n.push({parent:o,target:i})})),n;{const i=k.findElement(t.target,o,e);i instanceof Array?i.forEach((t=>{n.push({parent:o,target:t})})):n.push({parent:o,target:i})}}}else{const o=k.findElement(t.target,null,e);o instanceof Array?o.forEach((t=>{n.push({parent:null,target:t})})):n.push({parent:null,target:o})}return 0===n.length&&n.push({parent:null,target:null}),e?n:(1!==n.length&&console.warn("Multiple results found, even though multiple false",n),n[0])}}function v(t){const e=k.find(t);return"css"===t.type?!!e.target:"checkbox"===t.type?!!e.target&&e.target.checked:void 0}async function _(t,e){switch(t.type){case"click":return async function(t){const e=k.find(t);null!=e.target&&e.target.click();return S(0)}(t);case"list":return async function(t,e){for(const n of t.actions)await _(n,e)}(t,e);case"consent":return async function(t,e){for(const n of t.consents){const t=-1!==e.indexOf(n.type);if(n.matcher&&n.toggleAction){v(n.matcher)!==t&&await _(n.toggleAction)}else t?await _(n.trueAction):await _(n.falseAction)}}(t,e);case"ifcss":return async function(t,e){k.find(t).target?t.falseAction&&await _(t.falseAction,e):t.trueAction&&await _(t.trueAction,e)}(t,e);case"waitcss":return async function(t){await new Promise((e=>{let n=t.retries||10;const o=t.waitTime||250,i=()=>{const s=k.find(t);(t.negated&&s.target||!t.negated&&!s.target)&&n>0?(n-=1,setTimeout(i,o)):e()};i()}))}(t);case"foreach":return async function(t,e){const n=k.find(t,!0),o=k.base;for(const o of n)o.target&&(k.setBase(o.target),await _(t.action,e));k.setBase(o)}(t,e);case"hide":return async function(t){const e=k.find(t);e.target&&e.target.classList.add("Autoconsent-Hidden")}(t);case"slide":return async function(t){const e=k.find(t),n=k.find(t.dragTarget);if(e.target){const t=e.target.getBoundingClientRect(),o=n.target.getBoundingClientRect();let i=o.top-t.top,s=o.left-t.left;"y"===this.config.axis.toLowerCase()&&(s=0),"x"===this.config.axis.toLowerCase()&&(i=0);const r=window.screenX+t.left+t.width/2,c=window.screenY+t.top+t.height/2,a=t.left+t.width/2,u=t.top+t.height/2,l=document.createEvent("MouseEvents");l.initMouseEvent("mousedown",!0,!0,window,0,r,c,a,u,!1,!1,!1,!1,0,e.target);const p=document.createEvent("MouseEvents");p.initMouseEvent("mousemove",!0,!0,window,0,r+s,c+i,a+s,u+i,!1,!1,!1,!1,0,e.target);const d=document.createEvent("MouseEvents");d.initMouseEvent("mouseup",!0,!0,window,0,r+s,c+i,a+s,u+i,!1,!1,!1,!1,0,e.target),e.target.dispatchEvent(l),await this.waitTimeout(10),e.target.dispatchEvent(p),await this.waitTimeout(10),e.target.dispatchEvent(d)}}(t);case"close":return async function(){window.close()}();case"wait":return async function(t){await S(t.waitTime)}(t);case"eval":return async function(t){return console.log("eval!",t.code),new Promise((e=>{try{t.async?(window.eval(t.code),setTimeout((()=>{e(window.eval("window.__consentCheckResult"))}),t.timeout||250)):e(window.eval(t.code))}catch(n){console.warn("eval error",n,t.code),e(!1)}}))}(t);default:throw"Unknown action type: "+t.type}}k.base=null;function S(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))}class x{constructor(t,e){this.name=t,this.config=e,this.methods=new Map,this.runContext=m,e.methods.forEach((t=>{t.action&&this.methods.set(t.name,t.action)})),this.hasSelfTest=!1}get isIntermediate(){return!1}checkRunContext(){return!0}async detectCmp(){return this.config.detectors.map((t=>v(t.presentMatcher))).some((t=>!!t))}async detectPopup(){return this.config.detectors.map((t=>v(t.showingMatcher))).some((t=>!!t))}async executeAction(t,e){return!this.methods.has(t)||_(this.methods.get(t),e)}async optOut(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),await this.executeAction("HIDE_CMP"),await this.executeAction("DO_CONSENT",[]),await this.executeAction("SAVE_CONSENT"),!0}async optIn(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),await this.executeAction("HIDE_CMP"),await this.executeAction("DO_CONSENT",["D","A","B","E","F","X"]),await this.executeAction("SAVE_CONSENT"),!0}async openCmp(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),!0}async test(){return!0}}exports.createAutoCMP=b,exports.default=class{constructor(t,n=null,o=null){if(this.rules=[],this.foundCmp=null,e.sendContentMessage=t,this.sendContentMessage=t,this.rules=[...C],n)this.initialize(n,o);else{o&&this.parseRules(o);t({type:"init",url:window.location.href})}}initialize(t,e){if(this.config=t,t.enabled){if(e&&this.parseRules(e),t.disabledCmps?.length>0&&this.disableCMPs(t.disabledCmps),t.enablePrehide)if(document.documentElement)this.prehideElements();else{const t=()=>{window.removeEventListener("DOMContentLoaded",t),this.prehideElements()};window.addEventListener("DOMContentLoaded",t)}if("loading"===document.readyState){const t=()=>{window.removeEventListener("DOMContentLoaded",t),this.start()};window.addEventListener("DOMContentLoaded",t)}else this.start()}}parseRules(t){Object.keys(t.consentomatic).forEach((e=>{this.addConsentomaticCMP(e,t.consentomatic[e])})),t.autoconsent.forEach((t=>{this.addCMP(t)}))}addCMP(t){this.rules.push(b(t))}disableCMPs(t){this.rules=this.rules.filter((e=>!t.includes(e.name)))}addConsentomaticCMP(t,e){this.rules.push(new x(`com_${t}`,e))}start(){window.requestIdleCallback?window.requestIdleCallback((()=>this._start()),{timeout:500}):this._start()}async _start(){const t=await this.findCmp(this.config.detectRetries);if(t.length>0){const e=[];for(const n of t)this.sendContentMessage({type:"cmpDetected",url:location.href,cmp:n.name}),e.push(this.waitForPopup(n).then((t=>t?(this.foundCmp||(this.foundCmp=n),this.sendContentMessage({type:"popupFound",cmp:n.name,url:location.href}),!0):Promise.reject(`${n.name} popup not found`))));let n=!1;for(const t of e)try{await t,n=!0;break}catch(t){continue}return n?"optOut"===this.config.autoAction?await this.doOptOut():"optIn"!==this.config.autoAction||await this.doOptIn():(this.config.enablePrehide&&h(),!1)}return this.config.enablePrehide&&h(),!1}async findCmp(t){const e=[];for(const t of this.rules)try{if(!t.checkRunContext())continue;await t.detectCmp()&&e.push(t)}catch(t){}if(e.length>1){const t={msg:"Found multiple CMPs, check the detection rules.",cmps:e.map((t=>t.name))};this.sendContentMessage({type:"autoconsentError",details:t})}return 0===e.length&&t>0?new Promise((e=>{setTimeout((async()=>{const n=this.findCmp(t-1);e(n)}),500)})):e}async doOptOut(){let t;return t=!!this.foundCmp&&await this.foundCmp.optOut(),this.config.enablePrehide&&h(),this.sendContentMessage({type:"optOutResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,scheduleSelfTest:this.foundCmp&&this.foundCmp.hasSelfTest,url:location.href}),t&&!this.foundCmp.isIntermediate&&this.sendContentMessage({type:"autoconsentDone",cmp:this.foundCmp.name,url:location.href}),t}async doOptIn(){let t;return t=!!this.foundCmp&&await this.foundCmp.optIn(),this.config.enablePrehide&&h(),this.sendContentMessage({type:"optInResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,scheduleSelfTest:!1,url:location.href}),t&&!this.foundCmp.isIntermediate&&this.sendContentMessage({type:"autoconsentDone",cmp:this.foundCmp.name,url:location.href}),t}async doSelfTest(){let t;return t=!!this.foundCmp&&await this.foundCmp.test(),this.sendContentMessage({type:"selfTestResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,url:location.href}),t}async waitForPopup(t,e=5,n=500){const o=await t.detectPopup();return!o&&e>0?new Promise((o=>setTimeout((()=>o(this.waitForPopup(t,e-1,n))),n))):o}prehideElements(){return function(t){return o(n("autoconsent-prehide"),t,"opacity")}(this.rules.reduce(((t,e)=>e.prehideSelectors?[...t,...e.prehideSelectors]:t),["#didomi-popup,.didomi-popup-container,.didomi-popup-notice,.didomi-consent-popup-preferences,#didomi-notice,.didomi-popup-backdrop,.didomi-screen-medium"]))}async receiveMessageCallback(t){switch(t.type){case"initResp":this.initialize(t.config,t.rules);break;case"optIn":await this.doOptIn();break;case"optOut":await this.doOptOut();break;case"selfTest":await this.doSelfTest();break;case"evalResp":!function(t,n){const o=e.pending.get(t);o?(e.pending.delete(t),o.timer&&window.clearTimeout(o.timer),o.resolve(n)):console.warn("no eval #",t)}(t.id,t.result)}}},exports.rules=C;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});function t(){return crypto&&void 0!==crypto.randomUUID?crypto.randomUUID():Math.random().toString()}class e{constructor(t,e=1e3){this.id=t,this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e})),this.timer=window.setTimeout((()=>{this.reject(new Error("timeout"))}),e)}}const n={pending:new Map,sendContentMessage:null};function o(t="autoconsent-css-rules"){const e=`style#${t}`,n=document.querySelector(e);if(n&&n instanceof HTMLStyleElement)return n;{const e=document.head||document.getElementsByTagName("head")[0]||document.documentElement,n=document.createElement("style");return n.id=t,e.appendChild(n),n}}function i(t,e,n="display"){const o="opacity"===n?"opacity: 0":"display: none",i=`${e.join(",")} { ${o} !important; z-index: -1 !important; pointer-events: none !important; } `;return t instanceof HTMLStyleElement&&(t.innerText+=i,e.length>0)}async function s(t,e,n){const o=await t();return!o&&e>0?new Promise((o=>{setTimeout((async()=>{o(s(t,e-1,n))}),n)})):Promise.resolve(o)}function r(t){if(!t)return!1;if(null!==t.offsetParent)return!0;{const e=window.getComputedStyle(t);if("fixed"===e.position&&"none"!==e.display)return!0}return!1}function c(o){return function(o){const i=t();n.sendContentMessage({type:"eval",id:i,code:o});const s=new e(i);return n.pending.set(s.id,s),s.promise}(o).catch((t=>!1))}function a(t,e=!1){let n=[];return n="string"==typeof t?Array.from(document.querySelectorAll(t)):t,n.length>0&&(e?n.forEach((t=>t.click())):n[0].click()),n.length>0}function u(t){return null!==document.querySelector(t)}function l(t,e){const n=document.querySelectorAll(t),o=new Array(n.length);return n.forEach(((t,e)=>{o[e]=r(t)})),"none"===e?o.every((t=>!t)):0!==o.length&&("any"===e?o.some((t=>t)):o.every((t=>t)))}function p(t,e=1e4){return s((()=>null!==document.querySelector(t)),Math.ceil(e/200),200)}async function d(t,e=1e4,n=!1){return await p(t,e),a(t,n)}function h(t){return new Promise((e=>{setTimeout((()=>{e(!0)}),t)}))}const m={main:!0,frame:!1,urlPattern:""};class f{constructor(t){this.runContext=m,this.name=t}get hasSelfTest(){throw new Error("Not Implemented")}get isIntermediate(){throw new Error("Not Implemented")}get isCosmetic(){throw new Error("Not Implemented")}checkRunContext(){const t={...m,...this.runContext},e=window.top===window;return!(e&&!t.main)&&(!(!e&&!t.frame)&&!(t.urlPattern&&!window.location.href.match(t.urlPattern)))}detectCmp(){throw new Error("Not Implemented")}async detectPopup(){return!1}optOut(){throw new Error("Not Implemented")}optIn(){throw new Error("Not Implemented")}openCmp(){throw new Error("Not Implemented")}async test(){return Promise.resolve(!0)}}async function y(t){const e=[];if(t.exists&&e.push(u(t.exists)),t.visible&&e.push(l(t.visible,t.check)),t.eval){const n=c(t.eval);e.push(n)}var n,r;if(t.waitFor&&e.push(p(t.waitFor,t.timeout)),t.waitForVisible&&e.push(function(t,e=1e4,n="any"){return s((()=>l(t,n)),Math.ceil(e/200),200)}(t.waitForVisible,t.timeout,t.check)),t.click&&e.push(a(t.click,t.all)),t.waitForThenClick&&e.push(d(t.waitForThenClick,t.timeout,t.all)),t.wait&&e.push(h(t.wait)),t.hide&&e.push((n=t.hide,r=t.method,i(o(),n,r))),t.if){if(!t.if.exists&&!t.if.visible)return console.error("invalid conditional rule",t.if),!1;await y(t.if)?e.push(w(t.then)):t.else&&e.push(w(t.else))}if(0===e.length)return!1;return(await Promise.all(e)).reduce(((t,e)=>t&&e),!0)}async function w(t){for(const e of t){if(!await y(e)&&!e.optional)return!1}return!0}class g extends f{constructor(t){super(t.name),this.config=t,this.runContext=t.runContext||m}get hasSelfTest(){return!!this.config.test}get isIntermediate(){return!!this.config.intermediate}get isCosmetic(){return!!this.config.cosmetic}get prehideSelectors(){return this.config.prehideSelectors}async detectCmp(){return!!this.config.detectCmp&&async function(t){const e=t.map((t=>y(t)));return(await Promise.all(e)).every((t=>!!t))}(this.config.detectCmp)}async detectPopup(){return!!this.config.detectPopup&&w(this.config.detectPopup)}async optOut(){return!!this.config.optOut&&w(this.config.optOut)}async optIn(){return!!this.config.optIn&&w(this.config.optIn)}async openCmp(){return!!this.config.openCmp&&w(this.config.openCmp)}async test(){return this.hasSelfTest?w(this.config.test):super.test()}}function C(t){return new g(t)}const b=[new class extends f{constructor(){super("TrustArc-top"),this.prehideSelectors=[".trustarc-banner-container",".truste_popframe,.truste_overlay,.truste_box_overlay,#truste-consent-track"],this.runContext={main:!0,frame:!1},this._shortcutButton=null,this._optInDone=!1}get hasSelfTest(){return!1}get isIntermediate(){return!this._optInDone&&!this._shortcutButton}get isCosmetic(){return!1}async detectCmp(){const t=u("#truste-show-consent,#truste-consent-track");return t&&(this._shortcutButton=document.querySelector("#truste-consent-required")),t}async detectPopup(){return l("#truste-consent-content,#trustarc-banner-overlay,#truste-consent-track","all")}openFrame(){a("#truste-show-consent")}async optOut(){return this._shortcutButton?(this._shortcutButton.click(),!0):(i(o(),[".truste_popframe",".truste_overlay",".truste_box_overlay","#truste-consent-track"]),a("#truste-show-consent"),setTimeout((()=>{o().remove()}),1e4),!0)}async optIn(){return this._optInDone=!0,a("#truste-consent-button")}async openCmp(){return!0}async test(){return!0}},new class extends f{constructor(){super("TrustArc-frame"),this.runContext={main:!1,frame:!0,urlPattern:"^https://consent-pref\\.trustarc\\.com/\\?"}}get hasSelfTest(){return!1}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return!0}async detectPopup(){return l("#defaultpreferencemanager","any")&&l(".mainContent","any")}async navigateToSettings(){return await s((async()=>u(".shp")||l(".advance","any")||u(".switch span:first-child")),10,500),u(".shp")&&a(".shp"),await p(".prefPanel",5e3),l(".advance","any")&&a(".advance"),await s((()=>l(".switch span:first-child","any")),5,1e3)}async optOut(){return await s((()=>"complete"===document.readyState),20,100),await p(".mainContent[aria-hidden=false]",5e3),!!a(".rejectAll")||(u(".prefPanel")&&await p('.prefPanel[style="visibility: visible;"]',3e3),a("#catDetails0")?(a(".submit"),!0):(a(".required")||(await this.navigateToSettings(),a(".switch span:nth-child(1):not(.active)",!0),a(".submit"),p("#gwt-debug-close_id",3e5).then((()=>{a("#gwt-debug-close_id")}))),!0))}async optIn(){return a(".call")||(await this.navigateToSettings(),a(".switch span:nth-child(2)",!0),a(".submit"),p("#gwt-debug-close_id",3e5).then((()=>{a("#gwt-debug-close_id")}))),!0}},new class extends f{constructor(){super("Cybotcookiebot"),this.prehideSelectors=["#CybotCookiebotDialog,#dtcookie-container,#cookiebanner,#cb-cookieoverlay"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("#CybotCookiebotDialogBodyLevelButtonPreferences")}async detectPopup(){return u("#CybotCookiebotDialog,#dtcookie-container,#cookiebanner,#cb-cookiebanner")}async optOut(){return a(".cookie-alert-extended-detail-link")?(await p(".cookie-alert-configuration",2e3),a(".cookie-alert-configuration-input:checked",!0),a(".cookie-alert-extended-button-secondary"),!0):u("#dtcookie-container")?a(".h-dtcookie-decline"):(a(".cookiebot__button--settings")||a("#CybotCookiebotDialogBodyButtonDecline")||(a(".cookiebanner__link--details"),a('.CybotCookiebotDialogBodyLevelButton:checked:enabled,input[id*="CybotCookiebotDialogBodyLevelButton"]:checked:enabled',!0),a("#CybotCookiebotDialogBodyButtonDecline"),a("input[id^=CybotCookiebotDialogBodyLevelButton]:checked",!0),u("#CybotCookiebotDialogBodyButtonAcceptSelected")?a("#CybotCookiebotDialogBodyButtonAcceptSelected"):a("#CybotCookiebotDialogBodyLevelButtonAccept,#CybotCookiebotDialogBodyButtonAccept,#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowallSelection",!0),await c("window.CookieConsent.hasResponse !== true")&&(await c("window.Cookiebot.dialog.submitConsent()"),await h(500)),u("#cb-confirmedSettings")&&await c("endCookieProcess()")),!0)}async optIn(){return u("#dtcookie-container")?a(".h-dtcookie-accept"):(a(".CybotCookiebotDialogBodyLevelButton:not(:checked):enabled",!0),a("#CybotCookiebotDialogBodyLevelButtonAccept"),a("#CybotCookiebotDialogBodyButtonAccept"),!0)}async test(){return c("window.CookieConsent.declined === true")}},new class extends f{constructor(){super("Sourcepoint-frame"),this.prehideSelectors=["div[id^='sp_message_container_'],.message-overlay","#sp_privacy_manager_container"],this.ccpaNotice=!1,this.ccpaPopup=!1,this.runContext={main:!1,frame:!0}}get hasSelfTest(){return!1}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){const t=new URL(location.href);return t.searchParams.has("message_id")&&"ccpa-notice.sp-prod.net"===t.hostname?(this.ccpaNotice=!0,!0):"ccpa-pm.sp-prod.net"===t.hostname?(this.ccpaPopup=!0,!0):("/index.html"===t.pathname||"/privacy-manager/index.html"===t.pathname)&&(t.searchParams.has("message_id")||t.searchParams.has("requestUUID")||t.searchParams.has("consentUUID"))}async detectPopup(){return!!this.ccpaNotice||(this.ccpaPopup?await p(".priv-save-btn",2e3):(await p(".sp_choice_type_11,.sp_choice_type_12,.sp_choice_type_13,.sp_choice_type_ACCEPT_ALL",2e3),!u(".sp_choice_type_9")))}async optIn(){return await p(".sp_choice_type_11,.sp_choice_type_ACCEPT_ALL",2e3),!!a(".sp_choice_type_11")||!!a(".sp_choice_type_ACCEPT_ALL")}isManagerOpen(){return"/privacy-manager/index.html"===location.pathname}async optOut(){if(this.ccpaPopup){const t=document.querySelectorAll(".priv-purpose-container .sp-switch-arrow-block a.neutral.on .right");for(const e of t)a([e]);const e=document.querySelectorAll(".priv-purpose-container .sp-switch-arrow-block a.switch-bg.on");for(const t of e)a([t]);return a(".priv-save-btn")}if(!this.isManagerOpen()){if(!await p(".sp_choice_type_12,.sp_choice_type_13"))return!1;if(!u(".sp_choice_type_12"))return a(".sp_choice_type_13");a(".sp_choice_type_12"),await s((()=>this.isManagerOpen()),200,100)}await p(".type-modal",2e4);try{const t=".sp_choice_type_REJECT_ALL",e=".reject-toggle",n=await Promise.race([p(t,2e3).then((t=>t?0:-1)),p(e,2e3).then((t=>t?1:-1)),p(".pm-features",2e3).then((t=>t?2:-1))]);if(0===n)return await h(1e3),a(t);1===n?a(e):2===n&&(await p(".pm-features",1e4),a(".checked > span",!0),a(".chevron"))}catch(t){}return a(".sp_choice_type_SAVE_AND_EXIT")}},new class extends f{constructor(){super("consentmanager.net"),this.prehideSelectors=["#cmpbox,#cmpbox2"],this.apiAvailable=!1}get hasSelfTest(){return this.apiAvailable}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return this.apiAvailable=await c('window.__cmp && typeof __cmp("getCMPData") === "object"'),!!this.apiAvailable||u("#cmpbox")}async detectPopup(){return this.apiAvailable?(await h(500),await c("!__cmp('consentStatus').userChoiceExists")):l("#cmpbox .cmpmore","any")}async optOut(){return await h(500),this.apiAvailable?await c("__cmp('setConsent', 0)"):!!a(".cmpboxbtnno")||(u(".cmpwelcomeprpsbtn")?(a(".cmpwelcomeprpsbtn > a[aria-checked=true]",!0),a(".cmpboxbtnsave"),!0):(a(".cmpboxbtncustom"),await p(".cmptblbox",2e3),a(".cmptdchoice > a[aria-checked=true]",!0),a(".cmpboxbtnyescustomchoices"),!0))}async optIn(){return this.apiAvailable?await c("__cmp('setConsent', 1)"):a(".cmpboxbtnyes")}async test(){if(this.apiAvailable)return await c("__cmp('consentStatus').userChoiceExists")}},new class extends f{constructor(){super("Evidon")}get hasSelfTest(){return!1}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("#_evidon_banner")}async detectPopup(){return l("#_evidon_banner","any")}async optOut(){return a("#_evidon-decline-button")||(i(o(),["#evidon-prefdiag-overlay","#evidon-prefdiag-background"]),a("#_evidon-option-button"),await p("#evidon-prefdiag-overlay",5e3),a("#evidon-prefdiag-decline")),!0}async optIn(){return a("#_evidon-accept-button")}},new class extends f{constructor(){super("Onetrust"),this.prehideSelectors=["#onetrust-banner-sdk,#onetrust-consent-sdk,.onetrust-pc-dark-filter,.js-consent-banner"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("#onetrust-banner-sdk")}async detectPopup(){return l("#onetrust-banner-sdk","all")}async optOut(){return u("#onetrust-pc-btn-handler")?a("#onetrust-pc-btn-handler"):a(".ot-sdk-show-settings,button.js-cookie-settings"),await p("#onetrust-consent-sdk",2e3),await h(1e3),a("#onetrust-consent-sdk input.category-switch-handler:checked,.js-editor-toggle-state:checked",!0),await h(1e3),await p(".save-preference-btn-handler,.js-consent-save",2e3),a(".save-preference-btn-handler,.js-consent-save"),await s((()=>l("#onetrust-banner-sdk","none")),10,500),!0}async optIn(){return a("#onetrust-accept-btn-handler,.js-accept-cookies")}async test(){return await c("window.OnetrustActiveGroups.split(',').filter(s => s.length > 0).length <= 1")}},new class extends f{constructor(){super("Klaro"),this.prehideSelectors=[".klaro"],this.settingsOpen=!1}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u(".klaro > .cookie-modal")?(this.settingsOpen=!0,!0):u(".klaro > .cookie-notice")}async detectPopup(){return l(".klaro > .cookie-notice,.klaro > .cookie-modal","any")}async optOut(){return!!a(".klaro .cn-decline")||(this.settingsOpen||(a(".klaro .cn-learn-more"),await p(".klaro > .cookie-modal",2e3),this.settingsOpen=!0),!!a(".klaro .cn-decline")||(a(".cm-purpose:not(.cm-toggle-all) > input:not(.half-checked)",!0),a(".cm-btn-accept")))}async optIn(){return!!a(".klaro .cm-btn-accept-all")||(this.settingsOpen?(a(".cm-purpose:not(.cm-toggle-all) > input.half-checked",!0),a(".cm-btn-accept")):a(".klaro .cookie-notice .cm-btn-success"))}async test(){return await c("klaro.getManager().config.services.every(c => c.required || !klaro.getManager().consents[c.name])")}},new class extends f{constructor(){super("Uniconsent")}get prehideSelectors(){return[".unic",".modal:has(.unic)"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u(".unic .unic-box,.unic .unic-bar")}async detectPopup(){return l(".unic .unic-box,.unic .unic-bar","any")}async optOut(){if(await p(".unic button",1e3),document.querySelectorAll(".unic button").forEach((t=>{const e=t.textContent;(e.includes("Manage Options")||e.includes("Optionen verwalten"))&&t.click()})),await p(".unic input[type=checkbox]",1e3)){await p(".unic button",1e3),document.querySelectorAll(".unic input[type=checkbox]").forEach((t=>{t.checked&&t.click()}));for(const t of document.querySelectorAll(".unic button")){const e=t.textContent;for(const n of["Confirm Choices","Save Choices","Auswahl speichern"])if(e.includes(n))return t.click(),await h(500),!0}}return!1}async optIn(){return d(".unic #unic-agree")}async test(){await h(1e3);return!u(".unic .unic-box,.unic .unic-bar")}},new class extends f{constructor(){super("Conversant"),this.prehideSelectors=[".cmp-root"]}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u(".cmp-root .cmp-receptacle")}async detectPopup(){return l(".cmp-root .cmp-receptacle","any")}async optOut(){if(!await d(".cmp-main-button:not(.cmp-main-button--primary)"))return!1;if(!await p(".cmp-view-tab-tabs"))return!1;await d(".cmp-view-tab-tabs > :first-child"),await d(".cmp-view-tab-tabs > .cmp-view-tab--active:first-child");for(const t of Array.from(document.querySelectorAll(".cmp-accordion-item"))){t.querySelector(".cmp-accordion-item-title").click(),await s((()=>!!t.querySelector(".cmp-accordion-item-content.cmp-active")),10,50);const e=t.querySelector(".cmp-accordion-item-content.cmp-active");e.querySelectorAll(".cmp-toggle-actions .cmp-toggle-deny:not(.cmp-toggle-deny--active)").forEach((t=>t.click())),e.querySelectorAll(".cmp-toggle-actions .cmp-toggle-checkbox:not(.cmp-toggle-checkbox--active)").forEach((t=>t.click()))}return await a(".cmp-main-button:not(.cmp-main-button--primary)"),!0}async optIn(){return d(".cmp-main-button.cmp-main-button--primary")}async test(){return document.cookie.includes("cmp-data=0")}},new class extends f{constructor(){super("tiktok.com"),this.runContext={urlPattern:"tiktok"}}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}getShadowRoot(){const t=document.querySelector("tiktok-cookie-banner");return t?t.shadowRoot:null}async detectCmp(){return u("tiktok-cookie-banner")}async detectPopup(){return r(this.getShadowRoot().querySelector(".tiktok-cookie-banner"))}async optOut(){const t=this.getShadowRoot().querySelector(".button-wrapper button:first-child");return!!t&&(t.click(),!0)}async optIn(){const t=this.getShadowRoot().querySelector(".button-wrapper button:last-child");return!!t&&(t.click(),!0)}async test(){const t=document.cookie.match(/cookie-consent=([^;]+)/);if(!t)return!1;const e=JSON.parse(decodeURIComponent(t[1]));return Object.values(e).every((t=>"boolean"!=typeof t||!1===t))}},new class extends f{constructor(){super("airbnb"),this.runContext={urlPattern:"^https://(www\\.)?airbnb\\.[^/]+/"},this.prehideSelectors=["div[data-testid=main-cookies-banner-container]",'div:has(> div:first-child):has(> div:last-child):has(> section [data-testid="strictly-necessary-cookies"])']}get hasSelfTest(){return!0}get isIntermediate(){return!1}get isCosmetic(){return!1}async detectCmp(){return u("div[data-testid=main-cookies-banner-container]")}async detectPopup(){return l("div[data-testid=main-cookies-banner-container","any")}async optOut(){let t;for(await d("div[data-testid=main-cookies-banner-container] button._snbhip0");t=document.querySelector("[data-testid=modal-container] button[aria-checked=true]:not([disabled])");)t.click();return d("button[data-testid=save-btn]")}async optIn(){return d("div[data-testid=main-cookies-banner-container] button._148dgdpk")}async test(){return await s((()=>!!document.cookie.match("OptanonAlertBoxClosed")),20,200)}}];class k{static setBase(t){k.base=t}static findElement(t,e=null,n=!1){let o=null;return o=null!=e?Array.from(e.querySelectorAll(t.selector)):null!=k.base?Array.from(k.base.querySelectorAll(t.selector)):Array.from(document.querySelectorAll(t.selector)),null!=t.textFilter&&(o=o.filter((e=>{const n=e.textContent.toLowerCase();if(Array.isArray(t.textFilter)){let e=!1;for(const o of t.textFilter)if(-1!==n.indexOf(o.toLowerCase())){e=!0;break}return e}if(null!=t.textFilter)return-1!==n.indexOf(t.textFilter.toLowerCase())}))),null!=t.styleFilters&&(o=o.filter((e=>{const n=window.getComputedStyle(e);let o=!0;for(const e of t.styleFilters){const t=n[e.option];o=e.negated?o&&t!==e.value:o&&t===e.value}return o}))),null!=t.displayFilter&&(o=o.filter((e=>t.displayFilter?0!==e.offsetHeight:0===e.offsetHeight))),null!=t.iframeFilter&&(o=o.filter((()=>t.iframeFilter?window.location!==window.parent.location:window.location===window.parent.location))),null!=t.childFilter&&(o=o.filter((e=>{const n=k.base;k.setBase(e);const o=k.find(t.childFilter);return k.setBase(n),null!=o.target}))),n?o:(o.length>1&&console.warn("Multiple possible targets: ",o,t,e),o[0])}static find(t,e=!1){const n=[];if(null!=t.parent){const o=k.findElement(t.parent,null,e);if(null!=o){if(o instanceof Array)return o.forEach((o=>{const i=k.findElement(t.target,o,e);i instanceof Array?i.forEach((t=>{n.push({parent:o,target:t})})):n.push({parent:o,target:i})})),n;{const i=k.findElement(t.target,o,e);i instanceof Array?i.forEach((t=>{n.push({parent:o,target:t})})):n.push({parent:o,target:i})}}}else{const o=k.findElement(t.target,null,e);o instanceof Array?o.forEach((t=>{n.push({parent:null,target:t})})):n.push({parent:null,target:o})}return 0===n.length&&n.push({parent:null,target:null}),e?n:(1!==n.length&&console.warn("Multiple results found, even though multiple false",n),n[0])}}function v(t){const e=k.find(t);return"css"===t.type?!!e.target:"checkbox"===t.type?!!e.target&&e.target.checked:void 0}async function _(t,e){switch(t.type){case"click":return async function(t){const e=k.find(t);null!=e.target&&e.target.click();return S(0)}(t);case"list":return async function(t,e){for(const n of t.actions)await _(n,e)}(t,e);case"consent":return async function(t,e){for(const n of t.consents){const t=-1!==e.indexOf(n.type);if(n.matcher&&n.toggleAction){v(n.matcher)!==t&&await _(n.toggleAction)}else t?await _(n.trueAction):await _(n.falseAction)}}(t,e);case"ifcss":return async function(t,e){k.find(t).target?t.falseAction&&await _(t.falseAction,e):t.trueAction&&await _(t.trueAction,e)}(t,e);case"waitcss":return async function(t){await new Promise((e=>{let n=t.retries||10;const o=t.waitTime||250,i=()=>{const s=k.find(t);(t.negated&&s.target||!t.negated&&!s.target)&&n>0?(n-=1,setTimeout(i,o)):e()};i()}))}(t);case"foreach":return async function(t,e){const n=k.find(t,!0),o=k.base;for(const o of n)o.target&&(k.setBase(o.target),await _(t.action,e));k.setBase(o)}(t,e);case"hide":return async function(t){const e=k.find(t);e.target&&e.target.classList.add("Autoconsent-Hidden")}(t);case"slide":return async function(t){const e=k.find(t),n=k.find(t.dragTarget);if(e.target){const t=e.target.getBoundingClientRect(),o=n.target.getBoundingClientRect();let i=o.top-t.top,s=o.left-t.left;"y"===this.config.axis.toLowerCase()&&(s=0),"x"===this.config.axis.toLowerCase()&&(i=0);const r=window.screenX+t.left+t.width/2,c=window.screenY+t.top+t.height/2,a=t.left+t.width/2,u=t.top+t.height/2,l=document.createEvent("MouseEvents");l.initMouseEvent("mousedown",!0,!0,window,0,r,c,a,u,!1,!1,!1,!1,0,e.target);const p=document.createEvent("MouseEvents");p.initMouseEvent("mousemove",!0,!0,window,0,r+s,c+i,a+s,u+i,!1,!1,!1,!1,0,e.target);const d=document.createEvent("MouseEvents");d.initMouseEvent("mouseup",!0,!0,window,0,r+s,c+i,a+s,u+i,!1,!1,!1,!1,0,e.target),e.target.dispatchEvent(l),await this.waitTimeout(10),e.target.dispatchEvent(p),await this.waitTimeout(10),e.target.dispatchEvent(d)}}(t);case"close":return async function(){window.close()}();case"wait":return async function(t){await S(t.waitTime)}(t);case"eval":return async function(t){return console.log("eval!",t.code),new Promise((e=>{try{t.async?(window.eval(t.code),setTimeout((()=>{e(window.eval("window.__consentCheckResult"))}),t.timeout||250)):e(window.eval(t.code))}catch(n){console.warn("eval error",n,t.code),e(!1)}}))}(t);default:throw"Unknown action type: "+t.type}}k.base=null;function S(t){return new Promise((e=>{setTimeout((()=>{e()}),t)}))}class P{constructor(t,e){this.name=t,this.config=e,this.methods=new Map,this.runContext=m,this.isCosmetic=!1,e.methods.forEach((t=>{t.action&&this.methods.set(t.name,t.action)})),this.hasSelfTest=!1}get isIntermediate(){return!1}checkRunContext(){return!0}async detectCmp(){return this.config.detectors.map((t=>v(t.presentMatcher))).some((t=>!!t))}async detectPopup(){return this.config.detectors.map((t=>v(t.showingMatcher))).some((t=>!!t))}async executeAction(t,e){return!this.methods.has(t)||_(this.methods.get(t),e)}async optOut(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),await this.executeAction("HIDE_CMP"),await this.executeAction("DO_CONSENT",[]),await this.executeAction("SAVE_CONSENT"),!0}async optIn(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),await this.executeAction("HIDE_CMP"),await this.executeAction("DO_CONSENT",["D","A","B","E","F","X"]),await this.executeAction("SAVE_CONSENT"),!0}async openCmp(){return await this.executeAction("HIDE_CMP"),await this.executeAction("OPEN_OPTIONS"),!0}async test(){return!0}}exports.createAutoCMP=C,exports.default=class{constructor(e,o=null,i=null){if(this.id=t(),this.rules=[],this.foundCmp=null,this.state={lifecycle:"loading",prehideOn:!1,findCmpAttempts:0,detectedCmps:[],detectedPopups:[],selfTest:null},n.sendContentMessage=e,this.sendContentMessage=e,this.rules=[...b],this.updateState({lifecycle:"loading"}),o)this.initialize(o,i);else{i&&this.parseRules(i);e({type:"init",url:window.location.href}),this.updateState({lifecycle:"waitingForInitResponse"})}}initialize(t,e){if(this.config=t,t.enabled){if(e&&this.parseRules(e),this.rules=function(t,e){return t.filter((t=>(!e.disabledCmps||!e.disabledCmps.includes(t.name))&&(e.enableCosmeticRules||!t.isCosmetic)))}(this.rules,t),t.enablePrehide)if(document.documentElement)this.prehideElements();else{const t=()=>{window.removeEventListener("DOMContentLoaded",t),this.prehideElements()};window.addEventListener("DOMContentLoaded",t)}if("loading"===document.readyState){const t=()=>{window.removeEventListener("DOMContentLoaded",t),this.start()};window.addEventListener("DOMContentLoaded",t)}else this.start();this.updateState({lifecycle:"initialized"})}}parseRules(t){Object.keys(t.consentomatic).forEach((e=>{this.addConsentomaticCMP(e,t.consentomatic[e])})),t.autoconsent.forEach((t=>{this.addCMP(t)}))}addCMP(t){this.rules.push(C(t))}addConsentomaticCMP(t,e){this.rules.push(new P(`com_${t}`,e))}start(){window.requestIdleCallback?window.requestIdleCallback((()=>this._start()),{timeout:500}):this._start()}async _start(){this.updateState({lifecycle:"started"});const t=await this.findCmp(this.config.detectRetries);if(this.updateState({detectedCmps:t.map((t=>t.name))}),0===t.length)return this.config.enablePrehide&&this.undoPrehide(),this.updateState({lifecycle:"nothingDetected"}),!1;this.updateState({lifecycle:"cmpDetected"});let e=await this.detectPopups(t.filter((t=>!t.isCosmetic)));if(0===e.length&&(e=await this.detectPopups(t.filter((t=>t.isCosmetic)))),0===e.length)return this.config.enablePrehide&&this.undoPrehide(),!1;if(this.updateState({lifecycle:"openPopupDetected"}),e.length>1){const t={msg:"Found multiple CMPs, check the detection rules.",cmps:e.map((t=>t.name))};this.sendContentMessage({type:"autoconsentError",details:t})}return this.foundCmp=e[0],"optOut"===this.config.autoAction?await this.doOptOut():"optIn"!==this.config.autoAction||await this.doOptIn()}async findCmp(t){this.updateState({findCmpAttempts:this.state.findCmpAttempts+1});const e=[];for(const t of this.rules)try{if(!t.checkRunContext())continue;await t.detectCmp()&&(this.sendContentMessage({type:"cmpDetected",url:location.href,cmp:t.name}),e.push(t))}catch(t){}return 0===e.length&&t>0?new Promise((e=>{setTimeout((async()=>{const n=this.findCmp(t-1);e(n)}),500)})):e}async detectPopups(t){const e=[],n=t.map((t=>this.waitForPopup(t).then((n=>{n&&(this.updateState({detectedPopups:this.state.detectedPopups.concat([t.name])}),this.sendContentMessage({type:"popupFound",cmp:t.name,url:location.href}),e.push(t))})).catch((()=>null))));return await Promise.all(n),e}async doOptOut(){let t;return this.updateState({lifecycle:"runningOptOut"}),t=!!this.foundCmp&&await this.foundCmp.optOut(),this.config.enablePrehide&&this.undoPrehide(),this.sendContentMessage({type:"optOutResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,scheduleSelfTest:this.foundCmp&&this.foundCmp.hasSelfTest,url:location.href}),t&&!this.foundCmp.isIntermediate?(this.sendContentMessage({type:"autoconsentDone",cmp:this.foundCmp.name,isCosmetic:this.foundCmp.isCosmetic,url:location.href}),this.updateState({lifecycle:"done"})):this.updateState({lifecycle:t?"optOutSucceeded":"optOutFailed"}),t}async doOptIn(){let t;return this.updateState({lifecycle:"runningOptIn"}),t=!!this.foundCmp&&await this.foundCmp.optIn(),this.config.enablePrehide&&this.undoPrehide(),this.sendContentMessage({type:"optInResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,scheduleSelfTest:!1,url:location.href}),t&&!this.foundCmp.isIntermediate?(this.sendContentMessage({type:"autoconsentDone",cmp:this.foundCmp.name,isCosmetic:this.foundCmp.isCosmetic,url:location.href}),this.updateState({lifecycle:"done"})):this.updateState({lifecycle:t?"optInSucceeded":"optInFailed"}),t}async doSelfTest(){let t;return t=!!this.foundCmp&&await this.foundCmp.test(),this.sendContentMessage({type:"selfTestResult",cmp:this.foundCmp?this.foundCmp.name:"none",result:t,url:location.href}),this.updateState({selfTest:t}),t}async waitForPopup(t,e=5,n=500){const o=await t.detectPopup();return!o&&e>0?new Promise((o=>setTimeout((()=>o(this.waitForPopup(t,e-1,n))),n))):o}prehideElements(){const t=this.rules.reduce(((t,e)=>e.prehideSelectors?[...t,...e.prehideSelectors]:t),["#didomi-popup,.didomi-popup-container,.didomi-popup-notice,.didomi-consent-popup-preferences,#didomi-notice,.didomi-popup-backdrop,.didomi-screen-medium"]);return this.updateState({prehideOn:!0}),function(t){return i(o("autoconsent-prehide"),t,"opacity")}(t)}undoPrehide(){return this.updateState({prehideOn:!1}),function(){const t=o("autoconsent-prehide");return t&&t.remove(),!!t}()}updateState(t){Object.assign(this.state,t),this.sendContentMessage({type:"report",instanceId:this.id,url:window.location.href,mainFrame:window.top===window.self,state:this.state})}async receiveMessageCallback(t){switch(t.type){case"initResp":this.initialize(t.config,t.rules);break;case"optIn":await this.doOptIn();break;case"optOut":await this.doOptOut();break;case"selfTest":await this.doSelfTest();break;case"evalResp":!function(t,e){const o=n.pending.get(t);o?(n.pending.delete(t),o.timer&&window.clearTimeout(o.timer),o.resolve(e)):console.warn("no eval #",t)}(t.id,t.result)}}},exports.rules=b;