@cloro-dev/response-parser 0.5.3 → 0.6.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.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # @cloro-dev/response-parser
2
2
 
3
- A powerful TypeScript library for parsing AI model responses from ChatGPT, Gemini, Perplexity, Copilot, Grok, and Google AI Overview/Mode.
3
+ A powerful TypeScript library for parsing AI model responses from ChatGPT, Gemini, Perplexity, Grok, Google AI Overview/Mode, and Bing AI Mode.
4
4
 
5
5
  > **Framework-Agnostic**: This library returns HTML strings that can be rendered in any framework (React, Vue, Svelte, vanilla JS, etc.).
6
6
 
7
7
  ## Features
8
8
 
9
- - 🤖 **Multi-Provider Support**: ChatGPT, Gemini, Perplexity, Copilot, AI Overview, AI Mode, Grok
9
+ - 🤖 **Multi-Provider Support**: ChatGPT, Gemini, Perplexity, AI Overview, AI Mode, Bing AI Mode, Grok
10
10
  - 🔍 **Auto-Detection**: Automatically detects the AI provider from response structure
11
11
  - 🎨 **Built-in Styling**: Provider-specific styling
12
12
  - 🔧 **Framework-Agnostic**: Pure HTML output for any framework
@@ -147,9 +147,12 @@ type AIProvider =
147
147
  | 'COPILOT'
148
148
  | 'AIOVERVIEW'
149
149
  | 'AIMODE'
150
+ | 'BING_AIMODE'
150
151
  | 'GROK';
151
152
  ```
152
153
 
154
+ `COPILOT` is deprecated: cloro discontinues its Copilot endpoint. Use `BING_AIMODE` for Bing's AI answers.
155
+
153
156
  ## Supported Providers
154
157
 
155
158
  | Provider | Status | Features |
@@ -157,9 +160,10 @@ type AIProvider =
157
160
  | ChatGPT | ✅ | Sidebar, header, footer removal, auto cookie banner hiding |
158
161
  | Gemini | ✅ | Sidebar, header, footer, sources removal |
159
162
  | Perplexity | ✅ | Sidebar, header, footer, sources removal, auto cookie banner hiding |
160
- | Copilot | ✅ | Sidebar, header, footer, sources removal, auto cookie banner hiding |
163
+ | Copilot | ⚠️ Deprecated | Sidebar, header, footer, sources removal, auto cookie banner hiding |
161
164
  | AI Overview | ✅ | Header, footer removal, WIZ data extraction |
162
165
  | AI Mode | ✅ | Sidebar, header, footer removal, auto cookie banner hiding |
166
+ | Bing AI Mode | ✅ | Renders the whole answer (from the answer frame's `srcdoc`); header (reasoning panel) and sources removal |
163
167
  | Grok | ✅ | Sources removal, auto cookie banner hiding |
164
168
 
165
169
  ## Common Use Cases
@@ -1 +1 @@
1
- {"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../src/core/detector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEvD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAoFvC;IAEF;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,GAAG,gBAAgB,GAAG,IAAI;IA4CrD;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,GAAG,GAAG,gBAAgB,EAAE;IA2BzD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO;CAI9D"}
1
+ {"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../src/core/detector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEvD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAiGvC;IAEF;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,GAAG,gBAAgB,GAAG,IAAI;IA6CrD;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,GAAG,GAAG,gBAAgB,EAAE;IA2BzD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO;CAI9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/core/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAwB,MAAM,SAAS,CAAC;AAUzF,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAmC;;IAYpD;;OAEG;IACH,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,cAAc,GAAG,IAAI;IA4BnE;;OAEG;IACH,iBAAiB,CACf,QAAQ,EAAE,GAAG,EACb,QAAQ,EAAE,UAAU,EACpB,OAAO,CAAC,EAAE,YAAY,GACrB,cAAc,GAAG,IAAI;IAcxB;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,GAAG,GAAG,UAAU,GAAG,IAAI;IAKhD;;OAEG;IACH,kBAAkB,CAAC,QAAQ,EAAE,GAAG,GAAG,KAAK,CAAC;QAAE,QAAQ,EAAE,UAAU,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAItF;;OAEG;IACH,OAAO,CAAC,YAAY;IAwBpB;;OAEG;IACH,qBAAqB,IAAI,UAAU,EAAE;IAIrC;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI;CAG5D;AAGD,eAAO,MAAM,MAAM,kBAAyB,CAAC;AAG7C,eAAO,MAAM,eAAe,GAAI,UAAU,GAAG,EAAE,UAAU,YAAY,0BACpC,CAAC;AAElC,eAAO,MAAM,cAAc,GAAI,UAAU,GAAG,sBACX,CAAC"}
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/core/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAwB,MAAM,SAAS,CAAC;AAWzF,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAmC;;IAapD;;OAEG;IACH,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,cAAc,GAAG,IAAI;IA4BnE;;OAEG;IACH,iBAAiB,CACf,QAAQ,EAAE,GAAG,EACb,QAAQ,EAAE,UAAU,EACpB,OAAO,CAAC,EAAE,YAAY,GACrB,cAAc,GAAG,IAAI;IAcxB;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,GAAG,GAAG,UAAU,GAAG,IAAI;IAKhD;;OAEG;IACH,kBAAkB,CAAC,QAAQ,EAAE,GAAG,GAAG,KAAK,CAAC;QAAE,QAAQ,EAAE,UAAU,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAItF;;OAEG;IACH,OAAO,CAAC,YAAY;IAwBpB;;OAEG;IACH,qBAAqB,IAAI,UAAU,EAAE;IAIrC;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI;CAG5D;AAGD,eAAO,MAAM,MAAM,kBAAyB,CAAC;AAG7C,eAAO,MAAM,eAAe,GAAI,UAAU,GAAG,EAAE,UAAU,YAAY,0BACpC,CAAC;AAElC,eAAO,MAAM,cAAc,GAAI,UAAU,GAAG,sBACX,CAAC"}
@@ -1,4 +1,6 @@
1
- export type AIProvider = 'CHATGPT' | 'GEMINI' | 'PERPLEXITY' | 'COPILOT' | 'AIOVERVIEW' | 'AIMODE' | 'GROK';
1
+ export type AIProvider = 'CHATGPT' | 'GEMINI' | 'PERPLEXITY'
2
+ /** @deprecated cloro discontinues its Copilot endpoint. Use `BING_AIMODE` for Bing's AI answers. */
3
+ | 'COPILOT' | 'AIOVERVIEW' | 'AIMODE' | 'BING_AIMODE' | 'GROK';
2
4
  export interface ParsedResponse {
3
5
  provider: AIProvider;
4
6
  html: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,MAAM,CAAC;AAEX,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,UAAU,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,UAAU,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,GAAG,GAAG,iBAAiB,CAgCrE"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,QAAQ,GACR,YAAY;AACd,oGAAoG;GAClG,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,aAAa,GACb,MAAM,CAAC;AAEX,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,UAAU,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,UAAU,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,GAAG,GAAG,iBAAiB,CAgCrE"}
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";function e(e){let t="",r="",o=e;return e.result&&(o=e.result),"string"==typeof o?o.trim().startsWith("<")&&o.includes(">")?t=o:r=o:"object"==typeof o&&null!==o&&(o.html?t=o.html:o.content?o.content.trim().startsWith("<")?t=o.content:r=o.content:o.text&&(r=o.text)),{html:t,text:r}}class t{static detect(e){const t={CHATGPT:0,GEMINI:0,PERPLEXITY:0,COPILOT:0,AIOVERVIEW:0,AIMODE:0,GROK:0};for(const[r,o]of Object.entries(this.PROVIDER_PATTERNS))for(const n of o)try{n(e)&&t[r]++}catch(e){}let r=0,o=null;for(const[e,n]of Object.entries(t))n>r&&(r=n,o=e);return 0===r?null:{provider:o,confidence:r/Object.values(t).reduce((e,t)=>Math.max(e,t),1)}}static getAllProviders(e){const t=[];for(const[r,o]of Object.entries(this.PROVIDER_PATTERNS)){let n=0;for(const t of o)try{t(e)&&n++}catch(e){}n>0&&t.push({provider:r,confidence:n/o.length})}return t.sort((e,t)=>t.confidence-e.confidence)}static validate(e,t){const r=this.detect(e);return(null==r?void 0:r.provider)===t&&r.confidence>.5}}t.PROVIDER_PATTERNS={CHATGPT:[e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("bg-token-bg-primary")||r.includes("text-token-text-secondary")},e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("chatgpt.com")||r.includes("openai.com")}],GEMINI:[e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("bard-sidenav")||r.includes("mat-sidenav")},e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("<chat-app")||r.includes("gem-sys-color")}],PERPLEXITY:[e=>{var t;return((null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"").includes("perplexity.ai")},e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("prose")&&!r.includes("grok.com")&&!r.includes("chatgpt.com")}],COPILOT:[e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("copilot.microsoft.com")||r.includes('data-testid="sidebar-container"')}],AIOVERVIEW:[e=>{var t,r,o;return!!(null===(r=null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.aioverview)||void 0===r?void 0:r.text)||!!(null===(o=null==e?void 0:e.aioverview)||void 0===o?void 0:o.text)},e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes('id="gsr"')&&!r.includes("aim-mars")&&!r.includes("ho072b")}],AIMODE:[e=>{var t;return((null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"").includes("aim-mars")},e=>{var t;return((null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"").includes("ho072b")}],GROK:[e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("grok.com")||r.includes("x.ai")},e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("cdn.grok.com")||r.includes("vaul-drawer")}]};class r{extractContentCommon(t,r=!1){var o;const n=e(t);if(r){let e=[];const r=t.result||t;return"object"==typeof r&&null!==r&&((null===(o=r.aioverview)||void 0===o?void 0:o.sources)?e=r.aioverview.sources:r.sources&&(e=r.sources)),{...n,sources:e}}return n}injectStyles(e,t){let r=e;(null==t?void 0:t.baseUrl)&&!e.includes("<base ")&&(r=r.includes("<head>")?r.replace("<head>",`<head><base href="${t.baseUrl}">`):r.replace(/(<html[^>]*>)/i,`$1<head><base href="${t.baseUrl}"></head>`));const o=(null==t?void 0:t.customCSS)||"";return o&&r.includes("<head>")?r=r.replace("<head>",`<head><style>${o}</style>`):o&&(r=r.replace(/(<html[^>]*>)/i,`$1<head><style>${o}</style></head>`)),r}sanitizeHtml(e){let t=e.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gim,"");return t=t.replace(/<noscript[\s\S]*?<\/noscript>/gi,""),t}isFullDocument(e){return/^\s*(<html|<!DOCTYPE)/i.test(e)}removeLinks(e){return e.replace(/<a\b[^>]*>([\s\S]*?)<\/a>/gim,"$1")}wrapFragment(e){return`<!DOCTYPE html>\n<html>\n<head>\n <meta charset="utf-8">\n <meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'none'; style-src 'unsafe-inline';">\n <style>\n body {\n margin: 0;\n padding: 16px;\n font-family: system-ui, -apple-system, sans-serif;\n white-space: pre-wrap;\n word-wrap: break-word;\n }\n img { max-width: 100%; height: auto; }\n body {\n pointer-events: none;\n user-select: none;\n }\n </style>\n</head>\n<body>\n ${e}\n</body>\n</html>`}}class o extends r{constructor(){super(...arguments),this.name="CHATGPT",this.baseUrl="https://chatgpt.com"}extractContent(e){return this.extractContentCommon(e)}removeLinks(e){return e.replace(/<a\b([^>]*)>/gi,(e,t)=>{const r=t.replace(/\s+href\s*=\s*["'][^"']*["']/gi,"").replace(/\s+alt\s*=\s*["'][^"']*["']/gi,"").replace(/\s+rel\s*=\s*["'][^"']*["']/gi,"").replace(/\s+target\s*=\s*["'][^"']*["']/gi,"").trim();return`<span${r?" "+r:""}>`}).replace(/<\/a>/gi,"</span>")}removeHeader(e){let t=e;return t=t.replace(/<header[^>]*id="page-header"[^>]*>.*?<\/header>/gis,""),t}removeSidebar(e){return e.replace(/<nav[^>]*>.*?<\/nav>/gis,"")}removeFooter(e){return e}removeCookieBanner(e){return e.replace(/<div[^>]*role="dialog"[^>]*>[\s\S]*?openai\.com\/policies\/cookie-policy[\s\S]*?<\/div><\/div><\/div><\/div><\/div><\/div>/gi,"")}removeSources(e){return e}parse(e,t){var r;const{html:o,text:n}=this.extractContent(e);if(!o)throw new Error("No HTML content found in ChatGPT response");let i=o;const s=null!==(r=null==t?void 0:t.removeFooter)&&void 0!==r&&r;i=this.sanitizeHtml(i),i=this.removeCookieBanner(i),(null==t?void 0:t.removeHeader)&&(i=this.removeHeader(i)),(null==t?void 0:t.removeSidebar)&&(i=this.removeSidebar(i)),s&&(i=this.removeFooter(i)),(null==t?void 0:t.removeSources)&&(i=this.removeSources(i)),(null==t?void 0:t.removeLinks)&&(i=this.removeLinks(i));let l="";return(null==t?void 0:t.removeSidebar)&&(l+="\n #stage-slideover-sidebar { display: none !important; }\n [data-sidebar-item] { display: none !important; }\n [data-skip-to-content] { display: none !important; }\n .h-svh { height: auto !important; }\n "),s&&(l+='\n #thread-bottom-container { display: none !important; }\n form[data-type="unified-composer"] { display: none !important; }\n #thread { min-height: auto !important; }\n '),(null==t?void 0:t.removeSources)&&(l+='\n /* Side flyout, the modal sheet that replaces it on narrow pages, and\n the sources dialog of the mobile page */\n [data-testid="stage-thread-flyout"],\n [data-sheet-travel-state],\n #assistant-sources-dialog {\n display: none !important;\n }\n '),i=this.injectStyles(i,{baseUrl:this.baseUrl,customCSS:l}),{provider:this.name,html:i,text:n,metadata:{isFullDocument:this.isFullDocument(i),cookieBannerRemoved:!0,headerRemoved:(null==t?void 0:t.removeHeader)||!1,sidebarRemoved:(null==t?void 0:t.removeSidebar)||!1,footerRemoved:s,sourcesRemoved:(null==t?void 0:t.removeSources)||!1,linksRemoved:(null==t?void 0:t.removeLinks)||!1}}}}class n extends r{constructor(){super(...arguments),this.name="GEMINI",this.baseUrl="https://gemini.google.com"}extractContent(e){return this.extractContentCommon(e,!0)}removeHeader(e){let t=e;return t=t.replace(/<div[^>]*class="[^"]*boqOnegoogleliteOgbOneGoogleBar[^"]*"[^>]*>.*?<\/div><\/div><\/div><\/div>/gis,""),t=t.replace(/<top-bar-actions[^>]*>.*?<\/top-bar-actions>/gis,""),t=t.replace(/<div[^>]*class="[^"]*desktop-ogb-buffer[^"]*"[^>]*><\/div>/gis,""),t}removeFooter(e){return e.replace(/<input-container[^>]*>.*?<\/input-container>/gis,"")}removeSidebar(e){return e.replace(/<bard-sidenav[^>]*>.*?<\/bard-sidenav>/gis,"")}removeSources(e){let t=e;return t=t.replace(/<context-sidebar[^>]*>[\s\S]*?<\/context-sidebar>/gi,""),t=t.replace(/<sources-sidebar-button[^>]*>[\s\S]*?<\/sources-sidebar-button>/gi,""),t}parse(e,t){var r,o;const{html:n,text:i,sources:s}=this.extractContent(e);if(!n)throw new Error("No HTML content found in Gemini response");let l=n;const a=null!==(r=null==t?void 0:t.removeHeader)&&void 0!==r&&r,d=null!==(o=null==t?void 0:t.removeFooter)&&void 0!==o&&o;l=this.sanitizeHtml(l),a&&(l=this.removeHeader(l)),d&&(l=this.removeFooter(l)),(null==t?void 0:t.removeSidebar)&&(l=this.removeSidebar(l)),(null==t?void 0:t.removeSources)&&(l=this.removeSources(l)),(null==t?void 0:t.removeLinks)&&(l=this.removeLinks(l));let v="\n sign-in-nudge { display: none !important; }\n ";return a&&(v+="\n .side-nav-menu-button { display: none !important; }\n "),l=this.injectStyles(l,{baseUrl:this.baseUrl,customCSS:v}),{provider:this.name,html:l,text:i,sources:s,metadata:{isFullDocument:this.isFullDocument(l),headerRemoved:a,footerRemoved:d,sidebarRemoved:(null==t?void 0:t.removeSidebar)||!1,sourcesRemoved:(null==t?void 0:t.removeSources)||!1,linksRemoved:(null==t?void 0:t.removeLinks)||!1}}}}class i extends r{constructor(){super(...arguments),this.name="PERPLEXITY",this.baseUrl="https://www.perplexity.ai"}extractContent(e){return this.extractContentCommon(e)}removeHeader(e){return e.replace(/<div[^>]*class="[^"]*@container\/header[^"]*"[^>]*>.*?<div[^>]*class="[^"]*absolute bottom-0 inset-x-0 border-b[^"]*"[^>]*><\/div>/gis,"")}removeFooter(e){return e}removeSidebar(e){let t=e;return t=t.replace(/<div[^>]*class="[^"]*w-sideBarWidth[^"]*"[^>]*>[\s\S]*?<\/nav>[\s\S]*?<\/div>/gi,""),t}removeSources(e){return e}parse(e,t){var r,o;const{html:n,text:i}=this.extractContent(e);if(!n)throw new Error("No HTML content found in Perplexity response");let s=n;const l=null!==(r=null==t?void 0:t.removeHeader)&&void 0!==r&&r,a=null!==(o=null==t?void 0:t.removeFooter)&&void 0!==o&&o;s=this.sanitizeHtml(s),s=s.replace(/style="transition: none; overflow: hidden; height: 48px;"/gi,""),s=s.replace(/padding-right:\s*\d+px/gi,"padding-right: 0px"),l&&(s=this.removeHeader(s)),(null==t?void 0:t.removeSidebar)&&(s=this.removeSidebar(s)),a&&(s=this.removeFooter(s)),(null==t?void 0:t.removeSources)&&(s=this.removeSources(s)),(null==t?void 0:t.removeLinks)&&(s=this.removeLinks(s));let d='\n #cookie-consent,\n [role="dialog"]:has(#cookie-consent),\n div[role="dialog"][class*="fixed"][class*="bottom-2"] {\n display: none !important;\n }\n /* Login prompts: the full-page modal and the corner card. The #root\n prefix keeps the rule above the removeSidebar layout overrides. */\n [data-type="portal"]:has([data-testid="login-modal"]),\n #root div[class*="fixed"]:has([data-testid="login-modal"]),\n div[class*="fixed"]:has([data-testid="login-modal"]) {\n display: none !important;\n }\n [data-radix-focus-guard] {\n display: none !important;\n }\n ';return(null==t?void 0:t.removeSidebar)&&(d+='\n [class*="w-sideBarWidth"] { display: none !important; }\n #root, #root > div, #root > div > div {\n display: block !important;\n height: auto !important;\n max-height: none !important;\n width: 100% !important;\n padding: 0 !important;\n }\n main {\n display: block !important;\n height: auto !important;\n max-height: none !important;\n overflow: visible !important;\n }\n main > div {\n height: auto !important;\n overflow: visible !important;\n }\n [class*="scrollable-container"] {\n height: auto !important;\n overflow: visible !important;\n }\n [class*="max-w-threadContentWidth"] {\n max-width: 100% !important;\n }\n '),(null==t?void 0:t.removeSources)&&(d+='\n div[class*="fixed"][class*="inset-y-0"][class*="right-0"],\n [data-radix-popper-content-wrapper] {\n display: none !important;\n }\n '),a&&(d+='\n [class*="bottom-safeAreaInsetBottom"] {\n display: none !important;\n }\n '),s=this.injectStyles(s,{baseUrl:this.baseUrl,customCSS:d}),{provider:this.name,html:s,text:i,metadata:{isFullDocument:this.isFullDocument(s),linksRemoved:(null==t?void 0:t.removeLinks)||!1,headerRemoved:l,footerRemoved:a,sidebarRemoved:(null==t?void 0:t.removeSidebar)||!1,cookieBannerRemoved:!0,sourcesRemoved:(null==t?void 0:t.removeSources)||!1}}}}class s extends r{constructor(){super(...arguments),this.name="COPILOT",this.baseUrl="https://copilot.microsoft.com"}extractContent(e){return this.extractContentCommon(e)}removeHeader(e){let t=e;return t=t.replace(/<div[^>]*class="[^"]*absolute flex end-6 origin-top-right flex-col items-end[^"]*"[^>]*data-testid="settings-wrapper"[^>]*>.*?<\/div><\/div>/gis,""),t}removeFooter(e){let t=e;return t=t.replace(/<div[^>]*class="[^"]*absolute bottom-0 w-full[^"]*"[^>]*>.*?<\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/div>/gis,""),t=t.replace(/<div[^>]*class="[^"]*mt-\[var\(--composer-container-height\)\][^"]*"[^>]*><\/div>/gis,""),t=t.replace(/<div[^>]*class="[^"]*pointer-events-none absolute flex justify-center z-20 inset-x-0 bottom-\[calc\(var\(--composer-container-height\)\+1rem\)\][^"]*"[^>]*>.*?<button[^>]*data-testid="scroll-to-bottom-button"[^>]*>.*?<\/button><\/div>/gis,""),t}removeCookieBanner(e){let t=e;return t=t.replace(/<div[^>]*id="cookie-banner"[^>]*>.*?<\/div>.*?<\/div>.*?<\/div>.*?<\/div>/gis,""),t=t.replace(/<div[^>]*class="[^"]*max-w-cookie-banner[^"]*"[^>]*>.*?<\/div>.*?<\/div>.*?<\/div>.*?<\/div>/gis,""),t}removeSources(e){return e.replace(/<div[^>]*class="[^"]*relative h-full overflow-hidden will-change-auto[^"]*"[^>]*style="[^"]*width:\s*\d+px[^"]*"[^>]*>[\s\S]*?(?=<div[^>]*class="[^"]*pointer-events-none (?:fixed|absolute)[^"]*")/gi,"")}removeSidebar(e){return e}parse(e,t){var r,o;const{html:n,text:i}=this.extractContent(e);if(!n)throw new Error("No HTML content found in Copilot response");let s=n;const l=null!==(r=null==t?void 0:t.removeHeader)&&void 0!==r&&r,a=null!==(o=null==t?void 0:t.removeFooter)&&void 0!==o&&o;s=this.sanitizeHtml(s),s=this.removeCookieBanner(s),l&&(s=this.removeHeader(s)),a&&(s=this.removeFooter(s)),(null==t?void 0:t.removeSidebar)&&(s=this.removeSidebar(s)),(null==t?void 0:t.removeSources)&&(s=this.removeSources(s)),(null==t?void 0:t.removeLinks)&&(s=this.removeLinks(s));let d="";return l&&(d+='\n [data-testid="sticky-header"],\n [data-testid="backstage-chats"],\n div:has(> div > [data-testid="date-divider"]) {\n display: none !important;\n }\n '),(null==t?void 0:t.removeSidebar)&&(d+="\n div:has(> #sidebar-container) { display: none !important; }\n "),s=this.injectStyles(s,{baseUrl:this.baseUrl,customCSS:d}),{provider:this.name,html:s,text:i,metadata:{isFullDocument:this.isFullDocument(s),cookieBannerRemoved:!0,headerRemoved:l,footerRemoved:a,sidebarRemoved:(null==t?void 0:t.removeSidebar)||!1,sourcesRemoved:(null==t?void 0:t.removeSources)||!1,linksRemoved:(null==t?void 0:t.removeLinks)||!1}}}}class l extends r{constructor(){super(...arguments),this.name="AIOVERVIEW",this.baseUrl="https://www.google.com"}extractContent(e){return this.extractContentCommon(e,!0)}removeHeader(e){return e}removeFooter(e){return e}removeSidebar(e){return e}parse(e,t){var r,o;const{html:n,sources:i}=this.extractContent(e);if(!n)throw new Error("No HTML content found in AI Overview response");let s=n;const l=null===(r=null==t?void 0:t.removeHeader)||void 0===r||r,a=null===(o=null==t?void 0:t.removeFooter)||void 0===o||o;s=this.sanitizeHtml(s),l&&(s=this.removeHeader(s)),a&&(s=this.removeFooter(s)),(null==t?void 0:t.removeSidebar)&&(s=this.removeSidebar(s)),(null==t?void 0:t.removeLinks)&&(s=this.removeLinks(s));let d="";return l&&(d+='\n /* Header hiding */\n header, #header, #searchform, .sfbg, #appbar,\n div[role="navigation"], #leftnav, #sidetogether,\n [role="banner"], .Fgvgjc, #hdtb, .hdtb-msb,\n .DZ13He, .wYq63b, .eT9Cje, .bNg8Rb, .S6VXfe, .Lu57id {\n display: none !important;\n }\n '),(null==t?void 0:t.removeSidebar)&&(d+="\n /* Sidebar hiding */\n #leftnav, #sidetogether {\n display: none !important;\n }\n "),a&&(d+='\n /* Footer hiding */\n footer, #footer, #sfooter, .fbar,\n .pdp-nav, [aria-label="Main menu"], .gb_Td, .gb_L {\n display: none !important;\n }\n '),s=this.injectStyles(s,{baseUrl:this.baseUrl,customCSS:d}),{provider:this.name,html:s,sources:i,metadata:{isFullDocument:this.isFullDocument(s),headerRemoved:l,footerRemoved:a,sidebarRemoved:(null==t?void 0:t.removeSidebar)||!1,linksRemoved:(null==t?void 0:t.removeLinks)||!1}}}}class a extends r{constructor(){super(...arguments),this.name="AIMODE",this.baseUrl="https://www.google.com"}extractContent(e){return this.extractContentCommon(e)}removeHeader(e){let t=e;return t=t.replace(/<div[^>]*jsname="oEQ3x"[^>]*class="[^"]*DZ13He[^"]*"[^>]*>.*?<hr class="e9c7U">.*?<\/div><\/div><\/div><\/div><\/div>/gis,""),t}removeFooter(e){let t=e;return t=t.replace(/<div[^>]*data-xid="aim-mars-input-plate"[^>]*>[\s\S]*?<\/div><\/div><\/div><\/div><\/div>/gis,""),t=t.replace(/<div[^>]*jscontroller="P5gZDb"[^>]*>[\s\S]*?<\/div><\/div><\/div>/gis,""),t=t.replace(/<div[^>]*class="[^"]*t0ITR hh3ttd[^"]*"[^>]*>[\s\S]*?<\/div><\/div>/gis,""),t=t.replace(/<div[^>]*class="[^"]*y4VEUd vve6Ce[^"]*"[^>]*>[\s\S]*?<\/div><\/div>/gis,""),t}removeSidebar(e){let t=e;return t=t.replace(/<div[^>]*aria-label="AI Mode history"[^>]*class="[^"]*ho072b[^"]*"[^>]*>[\s\S]*?(?=<!--TgQPHd)/gi,""),t=t.replace(/<div[^>]*class="[^"]*ho072b[^"]*"[^>]*aria-label="AI Mode history"[^>]*>[\s\S]*?(?=<!--TgQPHd)/gi,""),t=t.replace(/<div[^>]*class="[^"]*OEwhSe[^"]*"[^>]*>[\s\S]*?<\/div><\/div>/gis,""),t=t.replace(/<button[^>]*aria-label="AI Mode history"[^>]*>[\s\S]*?<\/button>/gis,""),t}parse(e,t){var r,o;const{html:n,text:i}=this.extractContent(e);if(!n)throw new Error("No HTML content found in AI Mode response");let s=n;const l=null===(r=null==t?void 0:t.removeHeader)||void 0===r||r,a=null===(o=null==t?void 0:t.removeFooter)||void 0===o||o;s=this.sanitizeHtml(s),l&&(s=this.removeHeader(s)),a&&(s=this.removeFooter(s)),(null==t?void 0:t.removeSidebar)&&(s=this.removeSidebar(s)),(null==t?void 0:t.removeLinks)&&(s=this.removeLinks(s));let d="";return d+="\n .KxvlWc, #CXQnmb {\n display: none !important;\n }\n ",l&&(d+='\n /* Header hiding */\n header, #header, #searchform, .sfbg, #appbar,\n div[role="navigation"], #leftnav, #sidetogether,\n [role="banner"], .Fgvgjc, #hdtb, .hdtb-msb,\n .DZ13He, .wYq63b, .eT9Cje, .bNg8Rb, .S6VXfe, .Lu57id,\n .YHsVn, .UTNPFf {\n display: none !important;\n }\n '),a&&(d+='\n /* Footer hiding */\n footer, #footer, .fbar,\n .pdp-nav, [aria-label="Main menu"], .gb_Td, .gb_L {\n display: none !important;\n }\n /* Hide the "Ask anything" input bar */\n [data-xid="aim-mars-input-plate"],\n .UAbVe, .y4VEUd, .t0ITR.hh3ttd {\n display: none !important;\n }\n '),(null==t?void 0:t.removeSidebar)&&(d+="\n /* Hide AI Mode history panel */\n .ho072b, .OEwhSe, .qEn1od {\n display: none !important;\n }\n "),s=this.injectStyles(s,{baseUrl:this.baseUrl,customCSS:d}),{provider:this.name,html:s,text:i,metadata:{isFullDocument:this.isFullDocument(s),headerRemoved:l,footerRemoved:a,sidebarRemoved:(null==t?void 0:t.removeSidebar)||!1,linksRemoved:(null==t?void 0:t.removeLinks)||!1}}}}class d extends r{constructor(){super(...arguments),this.name="GROK",this.baseUrl="https://grok.com"}extractContent(e){return this.extractContentCommon(e)}removeHeader(e){return e}removeFooter(e){return e}parse(e,t){const{html:r,text:o}=this.extractContent(e);if(!r)throw new Error("No HTML content found in Grok response");let n=r;n=this.sanitizeHtml(n);let i="";return i+='\n [data-cookie-banner],\n [data-cookie-banner="true"] {\n display: none !important;\n }\n ',i+='\n [data-sonner-toaster],\n [data-sonner-toast],\n [class*="sonner-toast"] {\n display: none !important;\n }\n ',(null==t?void 0:t.removeSources)&&(n=n.replace(/<div[^>]*class="[^"]*h-dvh[^"]*flex-shrink-0[^"]*max-w-[^"]*"[^>]*>[\s\S]*?<\/aside>[\s\S]*?(?=<section)/gi,""),i+='\n div[data-state] > div.flex.flex-row.gap-1.items-center.rounded-full.cursor-pointer {\n display: none !important;\n }\n [vaul-drawer][vaul-drawer-direction="right"],\n [vaul-overlay] {\n display: none !important;\n }\n '),(null==t?void 0:t.removeHeader)&&(i+='\n /* Header hiding - hide elements with Grok\'s header class pattern */\n div[class*="h-16"][class*="top-0"][class*="z-10"],\n div[class*="absolute"][class*="inset-x-0"][class*="top-0"] {\n display: none !important;\n }\n '),(null==t?void 0:t.removeFooter)&&(i+='\n /* Footer hiding - hide Grok\'s footer/input area */\n div[class*="absolute"][class*="inset-x-0"][class*="bottom-0"][class*="max-w-breakout"],\n div[class*="absolute"][class*="bottom-0"][class*="w-full"] {\n display: none !important;\n }\n '),(null==t?void 0:t.removeLinks)&&(n=this.removeLinks(n)),n=this.injectStyles(n,{baseUrl:this.baseUrl,customCSS:i}),{provider:this.name,html:n,text:o,metadata:{isFullDocument:this.isFullDocument(n),linksRemoved:(null==t?void 0:t.removeLinks)||!1,headerRemoved:(null==t?void 0:t.removeHeader)||!1,footerRemoved:(null==t?void 0:t.removeFooter)||!1,cookieBannerRemoved:!0,sourcesRemoved:(null==t?void 0:t.removeSources)||!1}}}}class v{constructor(){this.providers=new Map,this.providers.set("CHATGPT",new o),this.providers.set("GEMINI",new n),this.providers.set("PERPLEXITY",new i),this.providers.set("COPILOT",new s),this.providers.set("AIOVERVIEW",new l),this.providers.set("AIMODE",new a),this.providers.set("GROK",new d)}parse(e,r){const o=t.detect(e);if(!o)return this.parseGeneric(e);const n=this.providers.get(o.provider);if(!n)return null;try{const t=n.parse(e,r);return{...t,metadata:{...t.metadata,detectionConfidence:o.confidence}}}catch(e){return console.error(`Failed to parse response with ${o.provider}:`,e),null}}parseWithProvider(e,t,r){const o=this.providers.get(t);if(!o)throw new Error(`Unknown provider: ${t}`);try{return o.parse(e,r)}catch(e){return console.error(`Failed to parse response with ${t}:`,e),null}}detectProvider(e){const r=t.detect(e);return(null==r?void 0:r.provider)||null}detectAllProviders(e){return t.getAllProviders(e)}parseGeneric(t){const{html:r,text:o}=e(t);if(!r&&!o)return null;let n=r;return n&&(n=n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gim,""),n=n.replace(/<noscript[\s\S]*?<\/noscript>/gi,"")),{provider:"CHATGPT",html:n||"",text:o||"",metadata:{isGeneric:!0}}}getSupportedProviders(){return Array.from(this.providers.keys())}registerProvider(e,t){this.providers.set(e,t)}}const c=new v;exports.AIModeProvider=a,exports.AIOverviewProvider=l,exports.AIResponseParser=v,exports.BaseProvider=r,exports.ChatGPTProvider=o,exports.CopilotProvider=s,exports.GeminiProvider=n,exports.GrokProvider=d,exports.PerplexityProvider=i,exports.ProviderDetector=t,exports.detectProvider=e=>c.detectProvider(e),exports.parseAiResponse=(e,t)=>c.parse(e,t),exports.parser=c;
1
+ "use strict";function e(e){let t="",r="",o=e;return e.result&&(o=e.result),"string"==typeof o?o.trim().startsWith("<")&&o.includes(">")?t=o:r=o:"object"==typeof o&&null!==o&&(o.html?t=o.html:o.content?o.content.trim().startsWith("<")?t=o.content:r=o.content:o.text&&(r=o.text)),{html:t,text:r}}class t{static detect(e){const t={CHATGPT:0,GEMINI:0,PERPLEXITY:0,COPILOT:0,AIOVERVIEW:0,AIMODE:0,BING_AIMODE:0,GROK:0};for(const[r,o]of Object.entries(this.PROVIDER_PATTERNS))for(const n of o)try{n(e)&&t[r]++}catch(e){}let r=0,o=null;for(const[e,n]of Object.entries(t))n>r&&(r=n,o=e);return 0===r?null:{provider:o,confidence:r/Object.values(t).reduce((e,t)=>Math.max(e,t),1)}}static getAllProviders(e){const t=[];for(const[r,o]of Object.entries(this.PROVIDER_PATTERNS)){let n=0;for(const t of o)try{t(e)&&n++}catch(e){}n>0&&t.push({provider:r,confidence:n/o.length})}return t.sort((e,t)=>t.confidence-e.confidence)}static validate(e,t){const r=this.detect(e);return(null==r?void 0:r.provider)===t&&r.confidence>.5}}t.PROVIDER_PATTERNS={CHATGPT:[e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("bg-token-bg-primary")||r.includes("text-token-text-secondary")},e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("chatgpt.com")||r.includes("openai.com")}],GEMINI:[e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("bard-sidenav")||r.includes("mat-sidenav")},e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("<chat-app")||r.includes("gem-sys-color")}],PERPLEXITY:[e=>{var t;return((null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"").includes("perplexity.ai")},e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("prose")&&!r.includes("grok.com")&&!r.includes("chatgpt.com")}],COPILOT:[e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("copilot.microsoft.com")||r.includes('data-testid="sidebar-container"')}],AIOVERVIEW:[e=>{var t,r,o;return!!(null===(r=null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.aioverview)||void 0===r?void 0:r.text)||!!(null===(o=null==e?void 0:e.aioverview)||void 0===o?void 0:o.text)},e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes('id="gsr"')&&!r.includes("aim-mars")&&!r.includes("ho072b")}],AIMODE:[e=>{var t;return((null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"").includes("aim-mars")},e=>{var t;return((null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"").includes("ho072b")}],BING_AIMODE:[e=>{var t;return((null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"").includes("b_cs_canvas")},e=>{var t;return((null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"").includes("gs_temp_content")}],GROK:[e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("grok.com")||r.includes("x.ai")},e=>{var t;const r=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t.html)||(null==e?void 0:e.html)||"";return r.includes("cdn.grok.com")||r.includes("vaul-drawer")}]};class r{extractContentCommon(t,r=!1){var o;const n=e(t);if(r){let e=[];const r=t.result||t;return"object"==typeof r&&null!==r&&((null===(o=r.aioverview)||void 0===o?void 0:o.sources)?e=r.aioverview.sources:r.sources&&(e=r.sources)),{...n,sources:e}}return n}injectStyles(e,t){let r=e;(null==t?void 0:t.baseUrl)&&!e.includes("<base ")&&(r=r.includes("<head>")?r.replace("<head>",`<head><base href="${t.baseUrl}">`):r.replace(/(<html[^>]*>)/i,`$1<head><base href="${t.baseUrl}"></head>`));const o=(null==t?void 0:t.customCSS)||"";return o&&r.includes("<head>")?r=r.replace("<head>",`<head><style>${o}</style>`):o&&(r=r.replace(/(<html[^>]*>)/i,`$1<head><style>${o}</style></head>`)),r}sanitizeHtml(e){let t=e.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gim,"");return t=t.replace(/<noscript[\s\S]*?<\/noscript>/gi,""),t}isFullDocument(e){return/^\s*(<html|<!DOCTYPE)/i.test(e)}removeLinks(e){return e.replace(/<a\b[^>]*>([\s\S]*?)<\/a>/gim,"$1")}wrapFragment(e){return`<!DOCTYPE html>\n<html>\n<head>\n <meta charset="utf-8">\n <meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'none'; style-src 'unsafe-inline';">\n <style>\n body {\n margin: 0;\n padding: 16px;\n font-family: system-ui, -apple-system, sans-serif;\n white-space: pre-wrap;\n word-wrap: break-word;\n }\n img { max-width: 100%; height: auto; }\n body {\n pointer-events: none;\n user-select: none;\n }\n </style>\n</head>\n<body>\n ${e}\n</body>\n</html>`}}class o extends r{constructor(){super(...arguments),this.name="CHATGPT",this.baseUrl="https://chatgpt.com"}extractContent(e){return this.extractContentCommon(e)}removeLinks(e){return e.replace(/<a\b([^>]*)>/gi,(e,t)=>{const r=t.replace(/\s+href\s*=\s*["'][^"']*["']/gi,"").replace(/\s+alt\s*=\s*["'][^"']*["']/gi,"").replace(/\s+rel\s*=\s*["'][^"']*["']/gi,"").replace(/\s+target\s*=\s*["'][^"']*["']/gi,"").trim();return`<span${r?" "+r:""}>`}).replace(/<\/a>/gi,"</span>")}removeHeader(e){let t=e;return t=t.replace(/<header[^>]*id="page-header"[^>]*>.*?<\/header>/gis,""),t}removeSidebar(e){return e.replace(/<nav[^>]*>.*?<\/nav>/gis,"")}removeFooter(e){return e}removeCookieBanner(e){return e.replace(/<div[^>]*role="dialog"[^>]*>[\s\S]*?openai\.com\/policies\/cookie-policy[\s\S]*?<\/div><\/div><\/div><\/div><\/div><\/div>/gi,"")}removeSources(e){return e}parse(e,t){var r;const{html:o,text:n}=this.extractContent(e);if(!o)throw new Error("No HTML content found in ChatGPT response");let i=o;const s=null!==(r=null==t?void 0:t.removeFooter)&&void 0!==r&&r;i=this.sanitizeHtml(i),i=this.removeCookieBanner(i),(null==t?void 0:t.removeHeader)&&(i=this.removeHeader(i)),(null==t?void 0:t.removeSidebar)&&(i=this.removeSidebar(i)),s&&(i=this.removeFooter(i)),(null==t?void 0:t.removeSources)&&(i=this.removeSources(i)),(null==t?void 0:t.removeLinks)&&(i=this.removeLinks(i));let l="";return(null==t?void 0:t.removeSidebar)&&(l+="\n #stage-slideover-sidebar { display: none !important; }\n [data-sidebar-item] { display: none !important; }\n [data-skip-to-content] { display: none !important; }\n .h-svh { height: auto !important; }\n "),s&&(l+='\n #thread-bottom-container { display: none !important; }\n form[data-type="unified-composer"] { display: none !important; }\n #thread { min-height: auto !important; }\n '),(null==t?void 0:t.removeSources)&&(l+='\n /* Side flyout, the modal sheet that replaces it on narrow pages, and\n the sources dialog of the mobile page */\n [data-testid="stage-thread-flyout"],\n [data-sheet-travel-state],\n #assistant-sources-dialog {\n display: none !important;\n }\n '),i=this.injectStyles(i,{baseUrl:this.baseUrl,customCSS:l}),{provider:this.name,html:i,text:n,metadata:{isFullDocument:this.isFullDocument(i),cookieBannerRemoved:!0,headerRemoved:(null==t?void 0:t.removeHeader)||!1,sidebarRemoved:(null==t?void 0:t.removeSidebar)||!1,footerRemoved:s,sourcesRemoved:(null==t?void 0:t.removeSources)||!1,linksRemoved:(null==t?void 0:t.removeLinks)||!1}}}}class n extends r{constructor(){super(...arguments),this.name="GEMINI",this.baseUrl="https://gemini.google.com"}extractContent(e){return this.extractContentCommon(e,!0)}removeHeader(e){let t=e;return t=t.replace(/<div[^>]*class="[^"]*boqOnegoogleliteOgbOneGoogleBar[^"]*"[^>]*>.*?<\/div><\/div><\/div><\/div>/gis,""),t=t.replace(/<top-bar-actions[^>]*>.*?<\/top-bar-actions>/gis,""),t=t.replace(/<div[^>]*class="[^"]*desktop-ogb-buffer[^"]*"[^>]*><\/div>/gis,""),t}removeFooter(e){return e.replace(/<input-container[^>]*>.*?<\/input-container>/gis,"")}removeSidebar(e){return e.replace(/<bard-sidenav[^>]*>.*?<\/bard-sidenav>/gis,"")}removeSources(e){let t=e;return t=t.replace(/<context-sidebar[^>]*>[\s\S]*?<\/context-sidebar>/gi,""),t=t.replace(/<sources-sidebar-button[^>]*>[\s\S]*?<\/sources-sidebar-button>/gi,""),t}parse(e,t){var r,o;const{html:n,text:i,sources:s}=this.extractContent(e);if(!n)throw new Error("No HTML content found in Gemini response");let l=n;const a=null!==(r=null==t?void 0:t.removeHeader)&&void 0!==r&&r,d=null!==(o=null==t?void 0:t.removeFooter)&&void 0!==o&&o;l=this.sanitizeHtml(l),a&&(l=this.removeHeader(l)),d&&(l=this.removeFooter(l)),(null==t?void 0:t.removeSidebar)&&(l=this.removeSidebar(l)),(null==t?void 0:t.removeSources)&&(l=this.removeSources(l)),(null==t?void 0:t.removeLinks)&&(l=this.removeLinks(l));let v="\n sign-in-nudge { display: none !important; }\n ";return a&&(v+="\n .side-nav-menu-button { display: none !important; }\n "),l=this.injectStyles(l,{baseUrl:this.baseUrl,customCSS:v}),{provider:this.name,html:l,text:i,sources:s,metadata:{isFullDocument:this.isFullDocument(l),headerRemoved:a,footerRemoved:d,sidebarRemoved:(null==t?void 0:t.removeSidebar)||!1,sourcesRemoved:(null==t?void 0:t.removeSources)||!1,linksRemoved:(null==t?void 0:t.removeLinks)||!1}}}}class i extends r{constructor(){super(...arguments),this.name="PERPLEXITY",this.baseUrl="https://www.perplexity.ai"}extractContent(e){return this.extractContentCommon(e)}removeHeader(e){return e.replace(/<div[^>]*class="[^"]*@container\/header[^"]*"[^>]*>.*?<div[^>]*class="[^"]*absolute bottom-0 inset-x-0 border-b[^"]*"[^>]*><\/div>/gis,"")}removeFooter(e){return e}removeSidebar(e){let t=e;return t=t.replace(/<div[^>]*class="[^"]*w-sideBarWidth[^"]*"[^>]*>[\s\S]*?<\/nav>[\s\S]*?<\/div>/gi,""),t}removeSources(e){return e}parse(e,t){var r,o;const{html:n,text:i}=this.extractContent(e);if(!n)throw new Error("No HTML content found in Perplexity response");let s=n;const l=null!==(r=null==t?void 0:t.removeHeader)&&void 0!==r&&r,a=null!==(o=null==t?void 0:t.removeFooter)&&void 0!==o&&o;s=this.sanitizeHtml(s),s=s.replace(/style="transition: none; overflow: hidden; height: 48px;"/gi,""),s=s.replace(/padding-right:\s*\d+px/gi,"padding-right: 0px"),l&&(s=this.removeHeader(s)),(null==t?void 0:t.removeSidebar)&&(s=this.removeSidebar(s)),a&&(s=this.removeFooter(s)),(null==t?void 0:t.removeSources)&&(s=this.removeSources(s)),(null==t?void 0:t.removeLinks)&&(s=this.removeLinks(s));let d='\n #cookie-consent,\n [role="dialog"]:has(#cookie-consent),\n div[role="dialog"][class*="fixed"][class*="bottom-2"] {\n display: none !important;\n }\n /* Login prompts: the full-page modal and the corner card. The #root\n prefix keeps the rule above the removeSidebar layout overrides. */\n [data-type="portal"]:has([data-testid="login-modal"]),\n #root div[class*="fixed"]:has([data-testid="login-modal"]),\n div[class*="fixed"]:has([data-testid="login-modal"]) {\n display: none !important;\n }\n [data-radix-focus-guard] {\n display: none !important;\n }\n ';return(null==t?void 0:t.removeSidebar)&&(d+='\n [class*="w-sideBarWidth"] { display: none !important; }\n #root, #root > div, #root > div > div {\n display: block !important;\n height: auto !important;\n max-height: none !important;\n width: 100% !important;\n padding: 0 !important;\n }\n main {\n display: block !important;\n height: auto !important;\n max-height: none !important;\n overflow: visible !important;\n }\n main > div {\n height: auto !important;\n overflow: visible !important;\n }\n [class*="scrollable-container"] {\n height: auto !important;\n overflow: visible !important;\n }\n [class*="max-w-threadContentWidth"] {\n max-width: 100% !important;\n }\n '),(null==t?void 0:t.removeSources)&&(d+='\n div[class*="fixed"][class*="inset-y-0"][class*="right-0"],\n [data-radix-popper-content-wrapper] {\n display: none !important;\n }\n '),a&&(d+='\n [class*="bottom-safeAreaInsetBottom"] {\n display: none !important;\n }\n '),s=this.injectStyles(s,{baseUrl:this.baseUrl,customCSS:d}),{provider:this.name,html:s,text:i,metadata:{isFullDocument:this.isFullDocument(s),linksRemoved:(null==t?void 0:t.removeLinks)||!1,headerRemoved:l,footerRemoved:a,sidebarRemoved:(null==t?void 0:t.removeSidebar)||!1,cookieBannerRemoved:!0,sourcesRemoved:(null==t?void 0:t.removeSources)||!1}}}}class s extends r{constructor(){super(...arguments),this.name="COPILOT",this.baseUrl="https://copilot.microsoft.com"}extractContent(e){return this.extractContentCommon(e)}removeHeader(e){let t=e;return t=t.replace(/<div[^>]*class="[^"]*absolute flex end-6 origin-top-right flex-col items-end[^"]*"[^>]*data-testid="settings-wrapper"[^>]*>.*?<\/div><\/div>/gis,""),t}removeFooter(e){let t=e;return t=t.replace(/<div[^>]*class="[^"]*absolute bottom-0 w-full[^"]*"[^>]*>.*?<\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/div>/gis,""),t=t.replace(/<div[^>]*class="[^"]*mt-\[var\(--composer-container-height\)\][^"]*"[^>]*><\/div>/gis,""),t=t.replace(/<div[^>]*class="[^"]*pointer-events-none absolute flex justify-center z-20 inset-x-0 bottom-\[calc\(var\(--composer-container-height\)\+1rem\)\][^"]*"[^>]*>.*?<button[^>]*data-testid="scroll-to-bottom-button"[^>]*>.*?<\/button><\/div>/gis,""),t}removeCookieBanner(e){let t=e;return t=t.replace(/<div[^>]*id="cookie-banner"[^>]*>.*?<\/div>.*?<\/div>.*?<\/div>.*?<\/div>/gis,""),t=t.replace(/<div[^>]*class="[^"]*max-w-cookie-banner[^"]*"[^>]*>.*?<\/div>.*?<\/div>.*?<\/div>.*?<\/div>/gis,""),t}removeSources(e){return e.replace(/<div[^>]*class="[^"]*relative h-full overflow-hidden will-change-auto[^"]*"[^>]*style="[^"]*width:\s*\d+px[^"]*"[^>]*>[\s\S]*?(?=<div[^>]*class="[^"]*pointer-events-none (?:fixed|absolute)[^"]*")/gi,"")}removeSidebar(e){return e}parse(e,t){var r,o;const{html:n,text:i}=this.extractContent(e);if(!n)throw new Error("No HTML content found in Copilot response");let s=n;const l=null!==(r=null==t?void 0:t.removeHeader)&&void 0!==r&&r,a=null!==(o=null==t?void 0:t.removeFooter)&&void 0!==o&&o;s=this.sanitizeHtml(s),s=this.removeCookieBanner(s),l&&(s=this.removeHeader(s)),a&&(s=this.removeFooter(s)),(null==t?void 0:t.removeSidebar)&&(s=this.removeSidebar(s)),(null==t?void 0:t.removeSources)&&(s=this.removeSources(s)),(null==t?void 0:t.removeLinks)&&(s=this.removeLinks(s));let d="";return l&&(d+='\n [data-testid="sticky-header"],\n [data-testid="backstage-chats"],\n div:has(> div > [data-testid="date-divider"]) {\n display: none !important;\n }\n '),(null==t?void 0:t.removeSidebar)&&(d+="\n div:has(> #sidebar-container) { display: none !important; }\n "),s=this.injectStyles(s,{baseUrl:this.baseUrl,customCSS:d}),{provider:this.name,html:s,text:i,metadata:{isFullDocument:this.isFullDocument(s),cookieBannerRemoved:!0,headerRemoved:l,footerRemoved:a,sidebarRemoved:(null==t?void 0:t.removeSidebar)||!1,sourcesRemoved:(null==t?void 0:t.removeSources)||!1,linksRemoved:(null==t?void 0:t.removeLinks)||!1}}}}class l extends r{constructor(){super(...arguments),this.name="AIOVERVIEW",this.baseUrl="https://www.google.com"}extractContent(e){return this.extractContentCommon(e,!0)}removeHeader(e){return e}removeFooter(e){return e}removeSidebar(e){return e}parse(e,t){var r,o;const{html:n,sources:i}=this.extractContent(e);if(!n)throw new Error("No HTML content found in AI Overview response");let s=n;const l=null===(r=null==t?void 0:t.removeHeader)||void 0===r||r,a=null===(o=null==t?void 0:t.removeFooter)||void 0===o||o;s=this.sanitizeHtml(s),l&&(s=this.removeHeader(s)),a&&(s=this.removeFooter(s)),(null==t?void 0:t.removeSidebar)&&(s=this.removeSidebar(s)),(null==t?void 0:t.removeLinks)&&(s=this.removeLinks(s));let d="";return l&&(d+='\n /* Header hiding */\n header, #header, #searchform, .sfbg, #appbar,\n div[role="navigation"], #leftnav, #sidetogether,\n [role="banner"], .Fgvgjc, #hdtb, .hdtb-msb,\n .DZ13He, .wYq63b, .eT9Cje, .bNg8Rb, .S6VXfe, .Lu57id {\n display: none !important;\n }\n '),(null==t?void 0:t.removeSidebar)&&(d+="\n /* Sidebar hiding */\n #leftnav, #sidetogether {\n display: none !important;\n }\n "),a&&(d+='\n /* Footer hiding */\n footer, #footer, #sfooter, .fbar,\n .pdp-nav, [aria-label="Main menu"], .gb_Td, .gb_L {\n display: none !important;\n }\n '),s=this.injectStyles(s,{baseUrl:this.baseUrl,customCSS:d}),{provider:this.name,html:s,sources:i,metadata:{isFullDocument:this.isFullDocument(s),headerRemoved:l,footerRemoved:a,sidebarRemoved:(null==t?void 0:t.removeSidebar)||!1,linksRemoved:(null==t?void 0:t.removeLinks)||!1}}}}class a extends r{constructor(){super(...arguments),this.name="AIMODE",this.baseUrl="https://www.google.com"}extractContent(e){return this.extractContentCommon(e)}removeHeader(e){let t=e;return t=t.replace(/<div[^>]*jsname="oEQ3x"[^>]*class="[^"]*DZ13He[^"]*"[^>]*>.*?<hr class="e9c7U">.*?<\/div><\/div><\/div><\/div><\/div>/gis,""),t}removeFooter(e){let t=e;return t=t.replace(/<div[^>]*data-xid="aim-mars-input-plate"[^>]*>[\s\S]*?<\/div><\/div><\/div><\/div><\/div>/gis,""),t=t.replace(/<div[^>]*jscontroller="P5gZDb"[^>]*>[\s\S]*?<\/div><\/div><\/div>/gis,""),t=t.replace(/<div[^>]*class="[^"]*t0ITR hh3ttd[^"]*"[^>]*>[\s\S]*?<\/div><\/div>/gis,""),t=t.replace(/<div[^>]*class="[^"]*y4VEUd vve6Ce[^"]*"[^>]*>[\s\S]*?<\/div><\/div>/gis,""),t}removeSidebar(e){let t=e;return t=t.replace(/<div[^>]*aria-label="AI Mode history"[^>]*class="[^"]*ho072b[^"]*"[^>]*>[\s\S]*?(?=<!--TgQPHd)/gi,""),t=t.replace(/<div[^>]*class="[^"]*ho072b[^"]*"[^>]*aria-label="AI Mode history"[^>]*>[\s\S]*?(?=<!--TgQPHd)/gi,""),t=t.replace(/<div[^>]*class="[^"]*OEwhSe[^"]*"[^>]*>[\s\S]*?<\/div><\/div>/gis,""),t=t.replace(/<button[^>]*aria-label="AI Mode history"[^>]*>[\s\S]*?<\/button>/gis,""),t}parse(e,t){var r,o;const{html:n,text:i}=this.extractContent(e);if(!n)throw new Error("No HTML content found in AI Mode response");let s=n;const l=null===(r=null==t?void 0:t.removeHeader)||void 0===r||r,a=null===(o=null==t?void 0:t.removeFooter)||void 0===o||o;s=this.sanitizeHtml(s),l&&(s=this.removeHeader(s)),a&&(s=this.removeFooter(s)),(null==t?void 0:t.removeSidebar)&&(s=this.removeSidebar(s)),(null==t?void 0:t.removeLinks)&&(s=this.removeLinks(s));let d="";return d+="\n .KxvlWc, #CXQnmb {\n display: none !important;\n }\n ",l&&(d+='\n /* Header hiding */\n header, #header, #searchform, .sfbg, #appbar,\n div[role="navigation"], #leftnav, #sidetogether,\n [role="banner"], .Fgvgjc, #hdtb, .hdtb-msb,\n .DZ13He, .wYq63b, .eT9Cje, .bNg8Rb, .S6VXfe, .Lu57id,\n .YHsVn, .UTNPFf {\n display: none !important;\n }\n '),a&&(d+='\n /* Footer hiding */\n footer, #footer, .fbar,\n .pdp-nav, [aria-label="Main menu"], .gb_Td, .gb_L {\n display: none !important;\n }\n /* Hide the "Ask anything" input bar */\n [data-xid="aim-mars-input-plate"],\n .UAbVe, .y4VEUd, .t0ITR.hh3ttd {\n display: none !important;\n }\n '),(null==t?void 0:t.removeSidebar)&&(d+="\n /* Hide AI Mode history panel */\n .ho072b, .OEwhSe, .qEn1od {\n display: none !important;\n }\n "),s=this.injectStyles(s,{baseUrl:this.baseUrl,customCSS:d}),{provider:this.name,html:s,text:i,metadata:{isFullDocument:this.isFullDocument(s),headerRemoved:l,footerRemoved:a,sidebarRemoved:(null==t?void 0:t.removeSidebar)||!1,linksRemoved:(null==t?void 0:t.removeLinks)||!1}}}}class d extends r{constructor(){super(...arguments),this.name="BING_AIMODE",this.baseUrl="https://www.bing.com"}extractContent(e){return this.extractContentCommon(e)}answerDocument(e){const t=/<iframe\b[^>]*\ssrcdoc="([^"]*)"/i.exec(e);return t?t[1].replace(/&quot;/g,'"').replace(/&#0*39;/g,"'").replace(/&#x0*27;/gi,"'").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"):e}userQuery(e){const t=/<div\b[^>]*class="ca_userquery_text"[^>]*>([^<]*)<\/div>/i.exec(e);return t?t[1].trim():null}addQuery(e,t){if(!t)return e;const r=`<div class="cloro_bing_query">${t}</div>`;return/<body\b[^>]*>/i.test(e)?e.replace(/(<body\b[^>]*>)/i,`$1${r}`):r+e}parse(e,t){var r,o;const{html:n,text:i}=this.extractContent(e);if(!n)throw new Error("No HTML content found in Bing AI Mode response");const s=null!==(r=null==t?void 0:t.removeHeader)&&void 0!==r&&r,l=null!==(o=null==t?void 0:t.removeSources)&&void 0!==o&&o,a=this.userQuery(n);let d=this.addQuery(this.sanitizeHtml(this.answerDocument(n)),a);(null==t?void 0:t.removeLinks)&&(d=this.removeLinks(d));let v='\n html { overflow: auto !important; height: auto !important; }\n body { max-width: 880px; margin: 0 auto !important; padding: 24px 24px 48px !important; box-sizing: border-box; }\n .cloro_bing_query { width: fit-content; max-width: 80%; margin: 0 0 16px; padding: 10px 16px; border-radius: 16px; background: #e8f1fd; color: #111; font: 16px/1.5 "Segoe UI", -apple-system, system-ui, sans-serif; }\n .b_ts_source_fav:has(img[src^="blob:"]) { display: none !important; }\n #b_ts_exp_content { display: block !important; height: auto !important; max-height: none !important; overflow: visible !important; opacity: 1 !important; }\n .b_ts_exp_header { display: none !important; }\n ';return s&&(v+="\n .b_ts_container { display: none !important; }\n "),l&&(v+="\n .gs_cit_cont, .gs_cit_stry_preview { display: none !important; }\n "),d=this.injectStyles(d,{baseUrl:this.baseUrl,customCSS:v}),{provider:this.name,html:d,text:i,metadata:{isFullDocument:this.isFullDocument(d),headerRemoved:s,footerRemoved:!0,sidebarRemoved:!0,sourcesRemoved:l,linksRemoved:(null==t?void 0:t.removeLinks)||!1}}}}class v extends r{constructor(){super(...arguments),this.name="GROK",this.baseUrl="https://grok.com"}extractContent(e){return this.extractContentCommon(e)}removeHeader(e){return e}removeFooter(e){return e}parse(e,t){const{html:r,text:o}=this.extractContent(e);if(!r)throw new Error("No HTML content found in Grok response");let n=r;n=this.sanitizeHtml(n);let i="";return i+='\n [data-cookie-banner],\n [data-cookie-banner="true"] {\n display: none !important;\n }\n ',i+='\n [data-sonner-toaster],\n [data-sonner-toast],\n [class*="sonner-toast"] {\n display: none !important;\n }\n ',(null==t?void 0:t.removeSources)&&(n=n.replace(/<div[^>]*class="[^"]*h-dvh[^"]*flex-shrink-0[^"]*max-w-[^"]*"[^>]*>[\s\S]*?<\/aside>[\s\S]*?(?=<section)/gi,""),i+='\n div[data-state] > div.flex.flex-row.gap-1.items-center.rounded-full.cursor-pointer {\n display: none !important;\n }\n [vaul-drawer][vaul-drawer-direction="right"],\n [vaul-overlay] {\n display: none !important;\n }\n '),(null==t?void 0:t.removeHeader)&&(i+='\n /* Header hiding - hide elements with Grok\'s header class pattern */\n div[class*="h-16"][class*="top-0"][class*="z-10"],\n div[class*="absolute"][class*="inset-x-0"][class*="top-0"] {\n display: none !important;\n }\n '),(null==t?void 0:t.removeFooter)&&(i+='\n /* Footer hiding - hide Grok\'s footer/input area */\n div[class*="absolute"][class*="inset-x-0"][class*="bottom-0"][class*="max-w-breakout"],\n div[class*="absolute"][class*="bottom-0"][class*="w-full"] {\n display: none !important;\n }\n '),(null==t?void 0:t.removeLinks)&&(n=this.removeLinks(n)),n=this.injectStyles(n,{baseUrl:this.baseUrl,customCSS:i}),{provider:this.name,html:n,text:o,metadata:{isFullDocument:this.isFullDocument(n),linksRemoved:(null==t?void 0:t.removeLinks)||!1,headerRemoved:(null==t?void 0:t.removeHeader)||!1,footerRemoved:(null==t?void 0:t.removeFooter)||!1,cookieBannerRemoved:!0,sourcesRemoved:(null==t?void 0:t.removeSources)||!1}}}}class c{constructor(){this.providers=new Map,this.providers.set("CHATGPT",new o),this.providers.set("GEMINI",new n),this.providers.set("PERPLEXITY",new i),this.providers.set("COPILOT",new s),this.providers.set("AIOVERVIEW",new l),this.providers.set("AIMODE",new a),this.providers.set("BING_AIMODE",new d),this.providers.set("GROK",new v)}parse(e,r){const o=t.detect(e);if(!o)return this.parseGeneric(e);const n=this.providers.get(o.provider);if(!n)return null;try{const t=n.parse(e,r);return{...t,metadata:{...t.metadata,detectionConfidence:o.confidence}}}catch(e){return console.error(`Failed to parse response with ${o.provider}:`,e),null}}parseWithProvider(e,t,r){const o=this.providers.get(t);if(!o)throw new Error(`Unknown provider: ${t}`);try{return o.parse(e,r)}catch(e){return console.error(`Failed to parse response with ${t}:`,e),null}}detectProvider(e){const r=t.detect(e);return(null==r?void 0:r.provider)||null}detectAllProviders(e){return t.getAllProviders(e)}parseGeneric(t){const{html:r,text:o}=e(t);if(!r&&!o)return null;let n=r;return n&&(n=n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gim,""),n=n.replace(/<noscript[\s\S]*?<\/noscript>/gi,"")),{provider:"CHATGPT",html:n||"",text:o||"",metadata:{isGeneric:!0}}}getSupportedProviders(){return Array.from(this.providers.keys())}registerProvider(e,t){this.providers.set(e,t)}}const u=new c;exports.AIModeProvider=a,exports.AIOverviewProvider=l,exports.AIResponseParser=c,exports.BaseProvider=r,exports.BingAiModeProvider=d,exports.ChatGPTProvider=o,exports.CopilotProvider=s,exports.GeminiProvider=n,exports.GrokProvider=v,exports.PerplexityProvider=i,exports.ProviderDetector=t,exports.detectProvider=e=>u.detectProvider(e),exports.parseAiResponse=(e,t)=>u.parse(e,t),exports.parser=u;
2
2
  //# sourceMappingURL=index.cjs.map