@coveops/abi 0.1.0

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 (90) hide show
  1. package/.env.example +24 -0
  2. package/README.md +34 -0
  3. package/coveo.deploy.json +30 -0
  4. package/deployment.esbuild.mjs +54 -0
  5. package/dist/abi/abi.css +1 -0
  6. package/dist/abi/abi.esm.js +1 -0
  7. package/dist/abi/index.esm.js +1 -0
  8. package/dist/abi/p-0ae1e588.js +2 -0
  9. package/dist/abi/p-38555fec.js +1 -0
  10. package/dist/abi/p-424e40eb.entry.js +1 -0
  11. package/dist/abi/p-4da5a336.js +18 -0
  12. package/dist/abi/p-941f664c.entry.js +1 -0
  13. package/dist/abi/p-e5564016.entry.js +50 -0
  14. package/dist/bundle/index.css +1 -0
  15. package/dist/bundle/index.html +61 -0
  16. package/dist/bundle/index.js +673 -0
  17. package/dist/cjs/abi.cjs.js +19 -0
  18. package/dist/cjs/atomic-7321a250.js +7 -0
  19. package/dist/cjs/faq-popup-component.cjs.entry.js +106 -0
  20. package/dist/cjs/index-39c8295a.js +1753 -0
  21. package/dist/cjs/index-bea59ea1.js +1093 -0
  22. package/dist/cjs/index.cjs.js +18 -0
  23. package/dist/cjs/loader.cjs.js +21 -0
  24. package/dist/cjs/results-manager.cjs.entry.js +40 -0
  25. package/dist/cjs/sample-component.cjs.entry.js +146 -0
  26. package/dist/collection/collection-manifest.json +19 -0
  27. package/dist/collection/components/faq-popup-component/faq-popup-component.css +15 -0
  28. package/dist/collection/components/faq-popup-component/faq-popup-component.js +78 -0
  29. package/dist/collection/components/results-manager/results-manager.js +45 -0
  30. package/dist/collection/components/sample-component/sample-component.css +10 -0
  31. package/dist/collection/components/sample-component/sample-component.js +102 -0
  32. package/dist/collection/index.js +15 -0
  33. package/dist/collection/utils/atomic.js +3 -0
  34. package/dist/components/index.d.ts +57 -0
  35. package/dist/components/index.js +2999 -0
  36. package/dist/esm/abi.js +17 -0
  37. package/dist/esm/atomic-0e957d02.js +5 -0
  38. package/dist/esm/faq-popup-component.entry.js +102 -0
  39. package/dist/esm/index-51334f26.js +1065 -0
  40. package/dist/esm/index-9483cecb.js +1749 -0
  41. package/dist/esm/index.js +16 -0
  42. package/dist/esm/loader.js +17 -0
  43. package/dist/esm/polyfills/core-js.js +11 -0
  44. package/dist/esm/polyfills/css-shim.js +1 -0
  45. package/dist/esm/polyfills/dom.js +79 -0
  46. package/dist/esm/polyfills/es5-html-element.js +1 -0
  47. package/dist/esm/polyfills/index.js +34 -0
  48. package/dist/esm/polyfills/system.js +6 -0
  49. package/dist/esm/results-manager.entry.js +36 -0
  50. package/dist/esm/sample-component.entry.js +142 -0
  51. package/dist/index.cjs.js +1 -0
  52. package/dist/index.js +1 -0
  53. package/dist/loader/cdn.js +3 -0
  54. package/dist/loader/index.cjs.js +3 -0
  55. package/dist/loader/index.d.ts +12 -0
  56. package/dist/loader/index.es2017.js +3 -0
  57. package/dist/loader/index.js +4 -0
  58. package/dist/loader/package.json +10 -0
  59. package/dist/types/components/faq-popup-component/faq-popup-component.d.ts +10 -0
  60. package/dist/types/components/results-manager/results-manager.d.ts +8 -0
  61. package/dist/types/components/sample-component/sample-component.d.ts +25 -0
  62. package/dist/types/components.d.ts +63 -0
  63. package/dist/types/html.d.ts +4 -0
  64. package/dist/types/index.d.ts +1 -0
  65. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  66. package/dist/types/utils/atomic.d.ts +1 -0
  67. package/package.json +31 -0
  68. package/src/components/faq-popup-component/faq-popup-component.css +15 -0
  69. package/src/components/faq-popup-component/faq-popup-component.tsx +102 -0
  70. package/src/components/results-manager/AppTemplate.html +44 -0
  71. package/src/components/results-manager/DocumentsTemplate.html +37 -0
  72. package/src/components/results-manager/ELearningTemplate.html +81 -0
  73. package/src/components/results-manager/FAQTemplate.html +73 -0
  74. package/src/components/results-manager/KATemplate.html +84 -0
  75. package/src/components/results-manager/MediaTemplate.html +40 -0
  76. package/src/components/results-manager/PeopleTemplate.html +74 -0
  77. package/src/components/results-manager/QuickLinksTemplate.html +51 -0
  78. package/src/components/results-manager/SitePagesTemplate.html +69 -0
  79. package/src/components/results-manager/results-manager.tsx +64 -0
  80. package/src/components/results-manager/template-1.html +67 -0
  81. package/src/components/sample-component/sample-component.css +10 -0
  82. package/src/components/sample-component/sample-component.tsx +157 -0
  83. package/src/components.d.ts +63 -0
  84. package/src/html.d.ts +4 -0
  85. package/src/index.ts +20 -0
  86. package/src/pages/index.html +137 -0
  87. package/src/style/index.css +12 -0
  88. package/src/utils/atomic.ts +3 -0
  89. package/stencil.config.ts +63 -0
  90. package/tsconfig.json +19 -0
package/.env.example ADDED
@@ -0,0 +1,24 @@
1
+ # The Plaform URL to use.
2
+ # See https://docs.coveo.com/en/2976/coveo-solutions/deployment-regions-and-strategies
3
+ PLATFORM_URL=https://platform.cloud.coveo.com
4
+
5
+ # The unique identifier of the organization in which to generate a search token.
6
+ # Example: ORGANIZATION_ID=mycoveoorganizationg8tp8wu3.
7
+ # See https://docs.coveo.com/en/148/manage-an-organization/retrieve-the-organization-id
8
+ ORGANIZATION_ID=<YOUR_ORGANIZATION_ID>
9
+
10
+ # An API key granting the impersonate privilege in your organization.
11
+ # The API key should have the impersonate privilege.
12
+ # See https://docs.coveo.com/en/1718/manage-an-organization/manage-api-keys#add-an-api-key
13
+ API_KEY=<YOUR_API_KEY>
14
+
15
+ # The name of the security identity to impersonate.
16
+ # Example: USER_EMAIL="alicesmith@example.com"
17
+ # See https://docs.coveo.com/en/56/#name-string-required.
18
+ USER_EMAIL=<YOUR_USER_EMAIL>
19
+
20
+ # The endpoint to the server returning Coveo search tokens.
21
+ # Example: TOKEN_ENDPOINT=https://acme.com/token
22
+ # If not specified, the application will fetch the search token
23
+ # from the local server within this project
24
+ # TOKEN_ENDPOINT=<YOUR_ENDPOINT>
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Atomic
2
+
3
+ This project was generated with [@coveo/create-atomic](https://npmjs.com/package/@coveo/create-atomic).
4
+
5
+ ## Setup environment
6
+
7
+ The root folder should contain a `.env` file. Replace all placeholder variables (`<...>`) by the proper information for your organization. Consult the example configuration file named `.env.example` as needed. For more involved configurations, you can modify the request parameters used in the `lambda/functions/token/token.ts` file.
8
+
9
+ ### CDN
10
+
11
+ By default, the project installs the latest major Atomic version, v2, to allow types and more advanced customizations. [Coveo Headless](https://www.npmjs.com/package/@coveo/headless) is also installed with Atomic and accessible at `@coveo/headless`.
12
+
13
+ When running, the app will use the bundled Atomic, but using the CDN is a viable option, just make sure you're using the same minor version of Atomic as the one bundled. It could cause issues with your custom components if the minor version differs.
14
+ E.g., if you have @coveo/atomic@2.0.0 installed, use the following CDN link at path [https://static.cloud.coveo.com/atomic/v2.0/](https://static.cloud.coveo.com/atomic/v2.0/atomic.esm.js).
15
+
16
+ ## Available Scripts
17
+
18
+ In the project directory, you can run:
19
+
20
+ ### `npm start`
21
+
22
+ Runs the app in the development mode.
23
+
24
+ ### `npm run build`
25
+
26
+ Builds the [Stencil](https://stenciljs.com/docs/cli) project for production.
27
+
28
+ ### `npm run deploy`
29
+
30
+ Builds the app for production and manually deploys the search page using the [Coveo CLI deploy command](https://docs.coveo.com/en/cli/#coveo-uideploy).
31
+
32
+ ## Learn More
33
+
34
+ To learn more about Atomic, check out the [Atomic documentation](https://docs.coveo.com/en/atomic/latest/).
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "abi",
3
+ "dir": "dist/bundle",
4
+ "htmlEntryFile": {
5
+ "path": "index.html"
6
+ },
7
+ "javascriptEntryFiles": [
8
+ {
9
+ "path": "index.js",
10
+ "isModule": true
11
+ }
12
+ ],
13
+ "javascriptUrls": [
14
+ {
15
+ "path": "https://static.cloud.coveo.com/atomic/v2/atomic.esm.js",
16
+ "isModule": true
17
+ }
18
+ ],
19
+ "cssEntryFiles": [
20
+ {
21
+ "path": "index.css"
22
+ }
23
+ ],
24
+ "cssUrls": [
25
+ {
26
+ "path": "https://static.cloud.coveo.com/atomic/v2/themes/coveo.css"
27
+ }
28
+ ],
29
+ "schemaVersion": "1.0.0"
30
+ }
@@ -0,0 +1,54 @@
1
+ import { build } from "esbuild";
2
+ import { join } from "node:path";
3
+ import {
4
+ appendFileSync,
5
+ readFileSync,
6
+ writeFileSync,
7
+ mkdirSync,
8
+ } from "node:fs";
9
+
10
+ function jsBundle() {
11
+ const entry = join("dist/components/index.js");
12
+ const contents = readFileSync(entry, "utf-8");
13
+ const toAppend = "\ndefineCustomElements();";
14
+ if (!contents.includes(toAppend)) {
15
+ appendFileSync(entry, toAppend);
16
+ }
17
+
18
+ return build({
19
+ entryPoints: ["dist/components/index.js"],
20
+ bundle: true,
21
+ minify: true,
22
+ outfile: "dist/bundle/index.js",
23
+ format: "esm",
24
+ });
25
+ }
26
+
27
+ function cssBundle() {
28
+ return build({
29
+ entryPoints: ["src/style/index.css"],
30
+ outfile: "dist/bundle/index.css",
31
+ bundle: true,
32
+ minify: true,
33
+ });
34
+ }
35
+
36
+ function html() {
37
+ const entry = join("src/pages/index.html");
38
+ const outputFile = join("dist/bundle/index.html");
39
+ const htmlContents = readFileSync(entry, "utf-8");
40
+ const hostedPageContents =
41
+ /<atomic-hosted-page>((.|\n)*)<\/atomic-hosted-page>/gm
42
+ .exec(htmlContents)[1]
43
+ .trim();
44
+
45
+ writeFileSync(outputFile, hostedPageContents, "utf-8");
46
+ }
47
+
48
+ async function main() {
49
+ mkdirSync("dist/bundle", { recursive: true });
50
+
51
+ await Promise.all([jsBundle(), cssBundle(), html()]);
52
+ }
53
+
54
+ main();
@@ -0,0 +1 @@
1
+ body{margin:0}atomic-modal#faq-modal::part(header-wrapper){display:grid;width:100%;padding-right:0px !important}
@@ -0,0 +1 @@
1
+ import{p as e,b as p}from"./p-0ae1e588.js";(()=>{const p=import.meta.url,t={};return""!==p&&(t.resourcesUrl=new URL(".",p).href),e(t)})().then((e=>p([["p-424e40eb",[[1,"faq-popup-component",{result:[32]}]]],["p-941f664c",[[0,"results-manager"]]],["p-e5564016",[[1,"sample-component",{pagerState:[32],statusState:[32]}]]]],e)));
@@ -0,0 +1 @@
1
+ import{w as a}from"./p-38555fec.js";!async function(){await a();const c=document.querySelector("atomic-search-interface");await c.initialize({accessToken:"x8a8b3b17-d11c-4dab-8e69-a693c8cd6058",organizationId:"anheuserbuschinbevprod",platformUrl:"https://platform.cloud.coveo.com"}),c.executeFirstSearch()}();
@@ -0,0 +1,2 @@
1
+ let e,t,n=!1;const l="undefined"!=typeof window?window:{},s=l.document||{head:{}},o={t:0,l:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,n,l)=>e.addEventListener(t,n,l),rel:(e,t,n,l)=>e.removeEventListener(t,n,l),ce:(e,t)=>new CustomEvent(e,t)},c=e=>Promise.resolve(e),r=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync}catch(e){}return!1})(),i=new WeakMap,a=e=>"sc-"+e.o,u={},f=e=>"object"==(e=typeof e)||"function"===e,$=(e,t,...n)=>{let l=null,s=!1,o=!1;const c=[],r=t=>{for(let n=0;n<t.length;n++)l=t[n],Array.isArray(l)?r(l):null!=l&&"boolean"!=typeof l&&((s="function"!=typeof e&&!f(l))&&(l+=""),s&&o?c[c.length-1].i+=l:c.push(s?d(null,l):l),o=s)};if(r(n),t){const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter((t=>e[t])).join(" "))}const i=d(e,null);return i.u=t,c.length>0&&(i.$=c),i},d=(e,t)=>({t:0,m:e,i:t,p:null,$:null,u:null}),y={},m=(e,t,n,s,c,r)=>{if(n!==s){let i=z(e,t),a=t.toLowerCase();if("class"===t){const t=e.classList,l=h(n),o=h(s);t.remove(...l.filter((e=>e&&!o.includes(e)))),t.add(...o.filter((e=>e&&!l.includes(e))))}else if(i||"o"!==t[0]||"n"!==t[1]){const l=f(s);if((i||l&&null!==s)&&!c)try{if(e.tagName.includes("-"))e[t]=s;else{const l=null==s?"":s;"list"===t?i=!1:null!=n&&e[t]==l||(e[t]=l)}}catch(e){}null==s||!1===s?!1===s&&""!==e.getAttribute(t)||e.removeAttribute(t):(!i||4&r||c)&&!l&&e.setAttribute(t,s=!0===s?"":s)}else t="-"===t[2]?t.slice(3):z(l,a)?a.slice(2):a[2]+t.slice(3),n&&o.rel(e,t,n,!1),s&&o.ael(e,t,s,!1)}},p=/\s/,h=e=>e?e.split(p):[],b=(e,t,n,l)=>{const s=11===t.p.nodeType&&t.p.host?t.p.host:t.p,o=e&&e.u||u,c=t.u||u;for(l in o)l in c||m(s,l,o[l],void 0,n,t.t);for(l in c)m(s,l,o[l],c[l],n,t.t)},w=(t,n,l)=>{const o=n.$[l];let c,r,i=0;if(null!==o.i)c=o.p=s.createTextNode(o.i);else if(c=o.p=s.createElement(o.m),b(null,o,!1),null!=e&&c["s-si"]!==e&&c.classList.add(c["s-si"]=e),o.$)for(i=0;i<o.$.length;++i)r=w(t,o,i),r&&c.appendChild(r);return c},S=(e,n,l,s,o,c)=>{let r,i=e;for(i.shadowRoot&&i.tagName===t&&(i=i.shadowRoot);o<=c;++o)s[o]&&(r=w(null,l,o),r&&(s[o].p=r,i.insertBefore(r,n)))},g=(e,t,n,l)=>{for(;t<=n;++t)(l=e[t])&&l.p.remove()},j=(e,t)=>e.m===t.m,k=(e,t)=>{const n=t.p=e.p,l=e.$,s=t.$,o=t.i;null===o?(b(e,t,!1),null!==l&&null!==s?((e,t,n,l)=>{let s,o=0,c=0,r=t.length-1,i=t[0],a=t[r],u=l.length-1,f=l[0],$=l[u];for(;o<=r&&c<=u;)null==i?i=t[++o]:null==a?a=t[--r]:null==f?f=l[++c]:null==$?$=l[--u]:j(i,f)?(k(i,f),i=t[++o],f=l[++c]):j(a,$)?(k(a,$),a=t[--r],$=l[--u]):j(i,$)?(k(i,$),e.insertBefore(i.p,a.p.nextSibling),i=t[++o],$=l[--u]):j(a,f)?(k(a,f),e.insertBefore(a.p,i.p),a=t[--r],f=l[++c]):(s=w(t&&t[c],n,c),f=l[++c],s&&i.p.parentNode.insertBefore(s,i.p));o>r?S(e,null==l[u+1]?null:l[u+1].p,n,l,c,u):c>u&&g(t,o,r)})(n,l,t,s):null!==s?(null!==e.i&&(n.textContent=""),S(n,null,t,s,0,s.length-1)):null!==l&&g(l,0,l.length-1)):e.i!==o&&(n.data=o)},C=e=>F(e).h,v=(e,t)=>{t&&!e.S&&t["s-p"]&&t["s-p"].push(new Promise((t=>e.S=t)))},M=(e,t)=>{if(e.t|=16,!(4&e.t))return v(e,e.g),ee((()=>O(e,t)));e.t|=512},O=(e,t)=>{const n=e.j;let l;return t&&(l=T(n,"componentWillLoad")),W(l,(()=>P(e,n,t)))},P=async(e,t,n)=>{const l=e.h,o=l["s-rc"];n&&(e=>{const t=e.k,n=e.h,l=t.t,o=((e,t)=>{let n=a(t);const l=I.get(n);if(e=11===e.nodeType?e:s,l)if("string"==typeof l){let t,o=i.get(e=e.head||e);o||i.set(e,o=new Set),o.has(n)||(t=s.createElement("style"),t.innerHTML=l,e.insertBefore(t,e.querySelector("link")),o&&o.add(n))}else e.adoptedStyleSheets.includes(l)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,l]);return n})(n.shadowRoot?n.shadowRoot:n.getRootNode(),t);10&l&&(n["s-sc"]=o,n.classList.add(o+"-h"))})(e);x(e,t),o&&(o.map((e=>e())),l["s-rc"]=void 0);{const t=l["s-p"],n=()=>E(e);0===t.length?n():(Promise.all(t).then(n),e.t|=4,t.length=0)}},x=(n,l)=>{try{l=l.render(),n.t&=-17,n.t|=2,((n,l)=>{const s=n.h,o=n.C||d(null,null),c=(e=>e&&e.m===y)(l)?l:$(null,null,l);t=s.tagName,c.m=null,c.t|=4,n.C=c,c.p=o.p=s.shadowRoot||s,e=s["s-sc"],k(o,c)})(n,l)}catch(e){B(e,n.h)}return null},E=e=>{const t=e.h,n=e.g;64&e.t||(e.t|=64,A(t),e.v(t),n||N()),e.S&&(e.S(),e.S=void 0),512&e.t&&Z((()=>M(e,!1))),e.t&=-517},L=e=>{{const t=F(e),n=t.h.isConnected;return n&&2==(18&t.t)&&M(t,!1),n}},N=()=>{A(s.documentElement),Z((()=>(e=>{const t=o.ce("appload",{detail:{namespace:"abi"}});return e.dispatchEvent(t),t})(l)))},T=(e,t,n)=>{if(e&&e[t])try{return e[t](n)}catch(e){B(e)}},W=(e,t)=>e&&e.then?e.then(t):t(),A=e=>e.classList.add("hydrated"),H=(e,t,n)=>{if(t.M){const l=Object.entries(t.M),s=e.prototype;l.map((([e,[t]])=>{(31&t||2&n&&32&t)&&Object.defineProperty(s,e,{get(){return((e,t)=>F(this).O.get(t))(0,e)},set(t){((e,t,n)=>{const l=F(e),s=l.O.get(t),o=l.t,c=l.j;n=(e=>(null==e||f(e),e))(n),8&o&&void 0!==s||n===s||Number.isNaN(s)&&Number.isNaN(n)||(l.O.set(t,n),c&&2==(18&o)&&M(l,!1))})(this,e,t)},configurable:!0,enumerable:!0})}))}return e},R=e=>{T(e,"connectedCallback")},U=(e,t={})=>{const n=[],c=t.exclude||[],i=l.customElements,u=s.head,f=u.querySelector("meta[charset]"),$=s.createElement("style"),d=[];let y,m=!0;Object.assign(o,t),o.l=new URL(t.resourcesUrl||"./",s.baseURI).href,e.map((e=>{e[1].map((t=>{const l={t:t[0],o:t[1],M:t[2],P:t[3]};l.M=t[2];const s=l.o,u=class extends HTMLElement{constructor(e){super(e),_(e=this,l),1&l.t&&e.attachShadow({mode:"open"})}connectedCallback(){y&&(clearTimeout(y),y=null),m?d.push(this):o.jmp((()=>(e=>{if(0==(1&o.t)){const t=F(e),n=t.k,l=()=>{};if(1&t.t)R(t.j);else{t.t|=1;{let n=e;for(;n=n.parentNode||n.host;)if(n["s-p"]){v(t,t.g=n);break}}(async(e,t,n,l,s)=>{if(0==(32&t.t)){{if(t.t|=32,(s=G(n)).then){const e=()=>{};s=await s,e()}s.isProxied||(H(s,n,2),s.isProxied=!0);const e=()=>{};t.t|=8;try{new s(t)}catch(e){B(e)}t.t&=-9,e(),R(t.j)}if(s.style){let e=s.style;const t=a(n);if(!I.has(t)){const l=()=>{};((e,t,n)=>{let l=I.get(e);r&&n?(l=l||new CSSStyleSheet,"string"==typeof l?l=t:l.replaceSync(t)):l=t,I.set(e,l)})(t,e,!!(1&n.t)),l()}}}const o=t.g,c=()=>M(t,!0);o&&o["s-rc"]?o["s-rc"].push(c):c()})(0,t,n)}l()}})(this)))}disconnectedCallback(){o.jmp((()=>(()=>{0==(1&o.t)&&T(F(this).j,"disconnectedCallback")})()))}componentOnReady(){return F(this).L}};l.N=e[0],c.includes(s)||i.get(s)||(n.push(s),i.define(s,H(u,l,1)))}))})),$.innerHTML=n+"{visibility:hidden}.hydrated{visibility:inherit}",$.setAttribute("data-styles",""),u.insertBefore($,f?f.nextSibling:u.firstChild),m=!1,d.length?d.map((e=>e.connectedCallback())):o.jmp((()=>y=setTimeout(N,30)))},q=new WeakMap,F=e=>q.get(e),V=(e,t)=>q.set(t.j=e,t),_=(e,t)=>{const n={t:0,h:e,k:t,O:new Map};return n.L=new Promise((e=>n.v=e)),e["s-p"]=[],e["s-rc"]=[],q.set(e,n)},z=(e,t)=>t in e,B=(e,t)=>(0,console.error)(e,t),D=new Map,G=e=>{const t=e.o.replace(/-/g,"_"),n=e.N,l=D.get(n);return l?l[t]:import(`./${n}.entry.js`).then((e=>(D.set(n,e),e[t])),B)
2
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/},I=new Map,J=[],K=[],Q=(e,t)=>l=>{e.push(l),n||(n=!0,t&&4&o.t?Z(Y):o.raf(Y))},X=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){B(e)}e.length=0},Y=()=>{X(J),X(K),(n=J.length>0)&&o.raf(Y)},Z=e=>c().then(e),ee=Q(K,!0);export{y as H,U as b,L as f,C as g,$ as h,c as p,V as r}
@@ -0,0 +1 @@
1
+ function e(){return customElements.whenDefined("atomic-search-interface")}export{e as w}
@@ -0,0 +1 @@
1
+ import{r as t,h as s,g as i,H as o}from"./p-0ae1e588.js";import{b as e,c as n,i as a}from"./p-4da5a336.js";class c extends Error{constructor(t){super(`The "${t}" element must be the child of an "atomic-result" element.`)}}const l=class{constructor(s){t(this,s),this.closeFAQModal=()=>{this.modalElement.setAttribute("is-open","false"),this.modalElement.querySelector("#btn-done").removeEventListener("click",this.closeFAQModal)}}async connectedCallback(){var t,s;try{this.bindings=await a(this.host),this.result=await(s=this.host,new Promise(((t,i)=>{const o=e("atomic/resolveResult",(s=>t(s)));s.dispatchEvent(o),n(s,"atomic-result")||i(new c(s.nodeName.toLowerCase()))}))),this.modalElement=null===(t=this.bindings)||void 0===t?void 0:t.interfaceElement.querySelector("#faq-modal"),console.log("this.result",this.result,this.modalElement,this.bindings)}catch(t){console.error(t),this.host.remove()}}openFAQModal(){var t,s,i,o;this.modalElement.source=this.host,this.modalElement.querySelector("[slot=header]").children[0].innerHTML="Question: "+((null===(t=this.result)||void 0===t?void 0:t.title)||"");const e=this.modalElement.querySelector("[slot=body]");e.innerHTML="";const n=document.createElement("div");n.style.display="flex",n.style.gap="16px";const a=document.createElement("div");a.innerText="Answer:",n.appendChild(a);const c=(null===(s=this.result)||void 0===s?void 0:s.raw.answer)||"",l=document.createElement("div");l.innerHTML=c,n.appendChild(l),e.appendChild(n);const h=document.createElement("div");h.innerHTML="Category: "+((null===(i=this.result)||void 0===i?void 0:i.raw.category)||""),e.appendChild(h);const r=document.createElement("div"),d=(null===(o=this.result)||void 0===o?void 0:o.raw.newmoreinfo)||"";r.innerHTML=`Link: <a href="${d}" target="_blank">${d}</a>`,e.appendChild(r),this.modalElement.querySelector("#faq-modal-close").addEventListener("click",this.closeFAQModal),this.modalElement.setAttribute("is-open","true")}render(){if(this.result)return s(o,{className:"clickable-host",onClick:()=>this.openFAQModal()},this.result.title)}get host(){return i(this)}};l.style="b{color:var(--atomic-primary)}";export{l as faq_popup_component}