ai12z 0.0.1-alpha.8

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 (83) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/ai12z-chat_3.cjs.entry.js +395 -0
  3. package/dist/cjs/ai12z-chat_3.cjs.entry.js.map +1 -0
  4. package/dist/cjs/ai12z-spinner.cjs.entry.js +22 -0
  5. package/dist/cjs/ai12z-spinner.cjs.entry.js.map +1 -0
  6. package/dist/cjs/index-6be98462.js +1967 -0
  7. package/dist/cjs/index-6be98462.js.map +1 -0
  8. package/dist/cjs/index.cjs.js +4 -0
  9. package/dist/cjs/index.cjs.js.map +1 -0
  10. package/dist/cjs/library.cjs.js +25 -0
  11. package/dist/cjs/library.cjs.js.map +1 -0
  12. package/dist/cjs/loader.cjs.js +15 -0
  13. package/dist/cjs/loader.cjs.js.map +1 -0
  14. package/dist/collection/collection-manifest.json +15 -0
  15. package/dist/collection/components/ai12z-cta/ai12z-cta.css +1 -0
  16. package/dist/collection/components/ai12z-cta/ai12z-cta.js +340 -0
  17. package/dist/collection/components/ai12z-cta/ai12z-cta.js.map +1 -0
  18. package/dist/collection/components/ai12z-cta/components/Chat.js +112 -0
  19. package/dist/collection/components/ai12z-cta/components/Chat.js.map +1 -0
  20. package/dist/collection/components/ai12z-cta/components/Form.js +32 -0
  21. package/dist/collection/components/ai12z-cta/components/Form.js.map +1 -0
  22. package/dist/collection/components/ai12z-cta/components/SearchResult.js +8 -0
  23. package/dist/collection/components/ai12z-cta/components/SearchResult.js.map +1 -0
  24. package/dist/collection/components/ai12z-cta/components/ai12z-chat.css +1 -0
  25. package/dist/collection/components/input/Input.js +130 -0
  26. package/dist/collection/components/input/Input.js.map +1 -0
  27. package/dist/collection/components/input/input.css +1 -0
  28. package/dist/collection/components/spinner/Spinner.js +44 -0
  29. package/dist/collection/components/spinner/Spinner.js.map +1 -0
  30. package/dist/collection/components/spinner/spinner.css +1 -0
  31. package/dist/collection/index.js +2 -0
  32. package/dist/collection/index.js.map +1 -0
  33. package/dist/collection/utils/utils.js +86 -0
  34. package/dist/collection/utils/utils.js.map +1 -0
  35. package/dist/collection/utils/utils.spec.js +16 -0
  36. package/dist/collection/utils/utils.spec.js.map +1 -0
  37. package/dist/esm/ai12z-chat_3.entry.js +389 -0
  38. package/dist/esm/ai12z-chat_3.entry.js.map +1 -0
  39. package/dist/esm/ai12z-spinner.entry.js +18 -0
  40. package/dist/esm/ai12z-spinner.entry.js.map +1 -0
  41. package/dist/esm/index-4dc12b55.js +1938 -0
  42. package/dist/esm/index-4dc12b55.js.map +1 -0
  43. package/dist/esm/index.js +3 -0
  44. package/dist/esm/index.js.map +1 -0
  45. package/dist/esm/library.js +20 -0
  46. package/dist/esm/library.js.map +1 -0
  47. package/dist/esm/loader.js +11 -0
  48. package/dist/esm/loader.js.map +1 -0
  49. package/dist/esm/polyfills/core-js.js +11 -0
  50. package/dist/esm/polyfills/dom.js +79 -0
  51. package/dist/esm/polyfills/es5-html-element.js +1 -0
  52. package/dist/esm/polyfills/index.js +34 -0
  53. package/dist/esm/polyfills/system.js +6 -0
  54. package/dist/index.cjs.js +1 -0
  55. package/dist/index.js +1 -0
  56. package/dist/library/index.esm.js +2 -0
  57. package/dist/library/index.esm.js.map +1 -0
  58. package/dist/library/library.esm.js +2 -0
  59. package/dist/library/library.esm.js.map +1 -0
  60. package/dist/library/p-65468fcf.entry.js +2 -0
  61. package/dist/library/p-65468fcf.entry.js.map +1 -0
  62. package/dist/library/p-b31186dc.js +3 -0
  63. package/dist/library/p-b31186dc.js.map +1 -0
  64. package/dist/library/p-f08d8e98.entry.js +2 -0
  65. package/dist/library/p-f08d8e98.entry.js.map +1 -0
  66. package/dist/types/components/ai12z-cta/ai12z-cta.d.ts +32 -0
  67. package/dist/types/components/ai12z-cta/components/Chat.d.ts +14 -0
  68. package/dist/types/components/ai12z-cta/components/Form.d.ts +1 -0
  69. package/dist/types/components/ai12z-cta/components/SearchResult.d.ts +1 -0
  70. package/dist/types/components/input/Input.d.ts +16 -0
  71. package/dist/types/components/spinner/Spinner.d.ts +4 -0
  72. package/dist/types/components.d.ts +130 -0
  73. package/dist/types/index.d.ts +1 -0
  74. package/dist/types/stencil-public-runtime.d.ts +1681 -0
  75. package/dist/types/utils/utils.d.ts +5 -0
  76. package/loader/cdn.js +3 -0
  77. package/loader/index.cjs.js +3 -0
  78. package/loader/index.d.ts +21 -0
  79. package/loader/index.es2017.js +3 -0
  80. package/loader/index.js +4 -0
  81. package/loader/package.json +11 -0
  82. package/package.json +42 -0
  83. package/readme.md +30 -0
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+
3
+
4
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"file":"index.cjs.js","mappings":";;","names":[],"sources":[],"sourcesContent":[],"version":3}
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-6be98462.js');
6
+
7
+ /*
8
+ Stencil Client Patch Browser v4.10.0 | MIT Licensed | https://stenciljs.com
9
+ */
10
+ const patchBrowser = () => {
11
+ const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('library.cjs.js', document.baseURI).href));
12
+ const opts = {};
13
+ if (importMeta !== '') {
14
+ opts.resourcesUrl = new URL('.', importMeta).href;
15
+ }
16
+ return index.promiseResolve(opts);
17
+ };
18
+
19
+ patchBrowser().then(options => {
20
+ return index.bootstrapLazy([["ai12z-spinner.cjs",[[1,"ai12z-spinner",{"class":[1]}]]],["ai12z-chat_3.cjs",[[1,"ai12z-cta",{"heading":[513],"placeholder":[513],"dataKey":[513,"data-key"],"dataMode":[513,"data-mode"],"buttonText":[513,"button-text"],"showModal":[32],"formData":[32],"searchResults":[32],"error":[32],"conversationId":[32],"chatHistory":[32],"isChat":[32],"openModal":[64],"closeModal":[64]},[[8,"keydown","handleKeyDown"]],{"buttonText":["watchButtonText"],"placeholder":["watchPlaceHolder"]}],[1,"ai12z-chat",{"chats":[8],"scrollBottom":[32]}],[1,"ai12z-input-form",{"isChat":[4,"is-chat"],"placeholder":[1],"buttonText":[1,"button-text"],"searchInput":[32],"submitted":[32]}]]]], options);
21
+ });
22
+
23
+ exports.setNonce = index.setNonce;
24
+
25
+ //# sourceMappingURL=library.cjs.js.map
@@ -0,0 +1 @@
1
+ {"file":"library.cjs.js","mappings":";;;;;;AAAA;AACA;AACA;AAGA,MAAM,YAAY,GAAG,MAAM;AAa3B,IAAI,MAAM,UAAU,GAAG,yMAAe,CAAC;AACvC,IAAI,MAAM,IAAI,GAAiE,EAAE,CAAC;AAClF,IAAI,IAAI,UAAU,KAAK,EAAE,EAAE;AAC3B,QAAQ,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC;AAC1D,KAAK;AACL,IAAI,OAAOA,oBAAc,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;;ACpBD,YAAY,EAAE,CAAC,IAAI,CAAC,OAAO,IAAI;AAE/B,EAAE,OAAOC,mBAAa,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC,CAAC;;;;","names":["promiseResolve","bootstrapLazy"],"sources":["../../node_modules/@stencil/core/internal/client/patch-browser.js","@lazy-browser-entrypoint?app-data=conditional"],"sourcesContent":["/*\n Stencil Client Patch Browser v4.10.0 | MIT Licensed | https://stenciljs.com\n */\nimport { BUILD, NAMESPACE } from '@stencil/core/internal/app-data';\nimport { consoleDevInfo, doc, promiseResolve, H } from '@stencil/core';\nconst patchBrowser = () => {\n // NOTE!! This fn cannot use async/await!\n if (BUILD.isDev && !BUILD.isTesting) {\n consoleDevInfo('Running in development mode.');\n }\n if (BUILD.cloneNodeFix) {\n // opted-in to polyfill cloneNode() for slot polyfilled components\n patchCloneNodeFix(H.prototype);\n }\n const scriptElm = BUILD.scriptDataOpts\n ? Array.from(doc.querySelectorAll('script')).find((s) => new RegExp(`\\/${NAMESPACE}(\\\\.esm)?\\\\.js($|\\\\?|#)`).test(s.src) ||\n s.getAttribute('data-stencil-namespace') === NAMESPACE)\n : null;\n const importMeta = import.meta.url;\n const opts = BUILD.scriptDataOpts ? (scriptElm || {})['data-opts'] || {} : {};\n if (importMeta !== '') {\n opts.resourcesUrl = new URL('.', importMeta).href;\n }\n return promiseResolve(opts);\n};\nconst patchCloneNodeFix = (HTMLElementPrototype) => {\n const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;\n HTMLElementPrototype.cloneNode = function (deep) {\n if (this.nodeName === 'TEMPLATE') {\n return nativeCloneNodeFn.call(this, deep);\n }\n const clonedNode = nativeCloneNodeFn.call(this, false);\n const srcChildNodes = this.childNodes;\n if (deep) {\n for (let i = 0; i < srcChildNodes.length; i++) {\n // Node.ATTRIBUTE_NODE === 2, and checking because IE11\n if (srcChildNodes[i].nodeType !== 2) {\n clonedNode.appendChild(srcChildNodes[i].cloneNode(true));\n }\n }\n }\n return clonedNode;\n };\n};\nexport { patchBrowser };\n","export { setNonce } from '@stencil/core';\nimport { bootstrapLazy } from '@stencil/core';\nimport { patchBrowser } from '@stencil/core/internal/client/patch-browser';\nimport { globalScripts } from '@stencil/core/internal/app-globals';\npatchBrowser().then(options => {\n globalScripts();\n return bootstrapLazy([/*!__STENCIL_LAZY_DATA__*/], options);\n});\n"],"version":3}
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-6be98462.js');
6
+
7
+ const defineCustomElements = (win, options) => {
8
+ if (typeof window === 'undefined') return undefined;
9
+ return index.bootstrapLazy([["ai12z-spinner.cjs",[[1,"ai12z-spinner",{"class":[1]}]]],["ai12z-chat_3.cjs",[[1,"ai12z-cta",{"heading":[513],"placeholder":[513],"dataKey":[513,"data-key"],"dataMode":[513,"data-mode"],"buttonText":[513,"button-text"],"showModal":[32],"formData":[32],"searchResults":[32],"error":[32],"conversationId":[32],"chatHistory":[32],"isChat":[32],"openModal":[64],"closeModal":[64]},[[8,"keydown","handleKeyDown"]],{"buttonText":["watchButtonText"],"placeholder":["watchPlaceHolder"]}],[1,"ai12z-chat",{"chats":[8],"scrollBottom":[32]}],[1,"ai12z-input-form",{"isChat":[4,"is-chat"],"placeholder":[1],"buttonText":[1,"button-text"],"searchInput":[32],"submitted":[32]}]]]], options);
10
+ };
11
+
12
+ exports.setNonce = index.setNonce;
13
+ exports.defineCustomElements = defineCustomElements;
14
+
15
+ //# sourceMappingURL=loader.cjs.js.map
@@ -0,0 +1 @@
1
+ {"file":"loader.cjs.js","mappings":";;;;;;AAGY,MAAC,oBAAoB,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK;AACtD,EAAE,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,OAAO,SAAS,CAAC;AAEtD,EAAE,OAAOA,mBAAa,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;AAC9D;;;;;","names":["bootstrapLazy"],"sources":["@lazy-external-entrypoint?app-data=conditional"],"sourcesContent":["export { setNonce } from '@stencil/core';\nimport { bootstrapLazy } from '@stencil/core';\nimport { globalScripts } from '@stencil/core/internal/app-globals';\nexport const defineCustomElements = (win, options) => {\n if (typeof window === 'undefined') return undefined;\n globalScripts();\n return bootstrapLazy([/*!__STENCIL_LAZY_DATA__*/], options);\n};\n"],"version":3}
@@ -0,0 +1,15 @@
1
+ {
2
+ "entries": [
3
+ "components/ai12z-cta/ai12z-cta.js",
4
+ "components/ai12z-cta/components/Chat.js",
5
+ "components/input/Input.js",
6
+ "components/spinner/Spinner.js"
7
+ ],
8
+ "compiler": {
9
+ "name": "@stencil/core",
10
+ "version": "4.10.0",
11
+ "typescriptVersion": "5.3.3"
12
+ },
13
+ "collections": [],
14
+ "bundles": []
15
+ }
@@ -0,0 +1 @@
1
+ /*! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com*/*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,fieldset,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.fixed{position:fixed}.flex{display:flex}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-filter{backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}:host{--bg-smoke-light:rgba(0,0,0,.5)}.bg-smoke-light{--tw-backdrop-blur:blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);background-color:#0003;cursor:auto;display:flex;flex-direction:column;height:100vh;left:0;position:fixed;top:0;transition:opacity .3s ease-in-out;width:100vw;z-index:200}.modal-content{opacity:0;transform:scale(.9);transition:transform .3s ease-in-out,opacity .3s ease-in-out}:host(.show-modal) .bg-smoke-light{opacity:1}:host(.show-modal) .modal-content{opacity:1;transform:scale(1)}.model-wrapper{--tw-backdrop-blur:blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);background-color:#0003;cursor:auto;display:flex;flex-direction:column;height:100vh;left:0;padding:1rem;position:fixed;top:0;width:100vw;z-index:200}.static{position:static}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.right-0{right:0}.top-0{top:0}.m-auto{margin:auto}.mb-2{margin-bottom:.5rem}.mt-12{margin-top:3rem}.hidden{display:none}.h-12{height:3rem}.h-6{height:1.5rem}.w-6{width:1.5rem}.w-72{width:18rem}.w-full{width:100%}.max-w-xl{max-width:36rem}.flex-auto{flex:1 1 auto}.flex-none{flex:none}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}.animate-ping{animation:ping 1s cubic-bezier(0,0,.2,1) infinite}@keyframes spin{to{transform:rotate(1turn)}}.animate-spin{animation:spin 1s linear infinite}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.space-x-3>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.75rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.75rem*var(--tw-space-x-reverse))}.overflow-auto{overflow:auto}.rounded-lg{border-radius:.5rem}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.p-10{padding:2.5rem}.p-4{padding:1rem}.p-8{padding:2rem}.px-4{padding-left:1rem;padding-right:1rem}.text-left{text-align:left}.text-center{text-align:center}.font-sans{font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.text-2xl{font-size:1.5rem;line-height:2rem}.font-semibold{font-weight:600}.text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}.text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity))}.text-slate-300{--tw-text-opacity:1;color:rgb(203 213 225/var(--tw-text-opacity))}.text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity))}.text-slate-500{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity))}.text-slate-700{--tw-text-opacity:1;color:rgb(51 65 85/var(--tw-text-opacity))}.no-underline{text-decoration-line:none}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.ring-1{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.ring-slate-900\/10{--tw-ring-color:rgba(15,23,42,.1)}.hover\:text-gray-800:hover{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.hover\:ring-slate-300:hover{--tw-ring-opacity:1;--tw-ring-color:rgb(203 213 225/var(--tw-ring-opacity))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\:ring-sky-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(14 165 233/var(--tw-ring-opacity))}@media (min-width:640px){.sm\:flex{display:flex}}@media (prefers-color-scheme:dark){.dark\:text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity))}.dark\:text-slate-500{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity))}}.inset-x-0{left:0;right:0}.-top-px{top:-1px}.bottom-0{bottom:0}.mx-auto{margin-left:auto;margin-right:auto}.mt-1{margin-top:.25rem}.h-5{height:1.25rem}.w-5{width:1.25rem}.min-w-0{min-width:0}.max-w-4xl{max-width:56rem}.shrink-0{flex-shrink:0}.justify-between{justify-content:space-between}.gap-x-4{column-gap:1rem}.gap-x-6{column-gap:1.5rem}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.divide-gray-100>:not([hidden])~:not([hidden]){--tw-divide-opacity:1;border-color:rgb(243 244 246/var(--tw-divide-opacity))}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.py-5{padding-bottom:1.25rem;padding-top:1.25rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity))}.hover\:bg-gray-50:hover{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity))}.hover\:underline:hover{text-decoration-line:underline}@media (min-width:640px){.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width:1024px){.lg\:px-8{padding-left:2rem;padding-right:2rem}}
@@ -0,0 +1,340 @@
1
+ import { h, Host } from "@stencil/core";
2
+ import { search, askAI, sendFeedback } from "../../utils/utils";
3
+ // import InputForm from "./components/Form"
4
+ import SearchResult from "./components/SearchResult";
5
+ export class MyModal {
6
+ constructor() {
7
+ this.dirty = false;
8
+ this.isSubmitted = false;
9
+ this.pButtonText = "Ask AI";
10
+ this.handleSubmit = async (event, value, type) => {
11
+ this.dirty = true;
12
+ this.isSubmitted = true;
13
+ event === null || event === void 0 ? void 0 : event.preventDefault();
14
+ this.formData = Object.assign(Object.assign({}, this.formData), { search: value });
15
+ if (!this.formData.search && this.formData.search.length < 3)
16
+ return;
17
+ try {
18
+ let response = null;
19
+ if (type === "ask-ai" || this.isChat) {
20
+ this.isChat = true;
21
+ this.chatHistory.push({
22
+ message: this.formData.search,
23
+ status: "success",
24
+ type: "user",
25
+ });
26
+ this.chatHistory.push({
27
+ message: `<div class="animate-ping">...</div>`,
28
+ type: "ai",
29
+ status: "pending",
30
+ });
31
+ response = await askAI(this.dataKey, this.dataMode, this.formData.search, this.conversationId);
32
+ this.conversationId = response.conversation_Id;
33
+ this.chatHistory.pop();
34
+ const lastMessage = { message: response.answer, type: "ai", status: "success", insightId: response.insight_id };
35
+ this.chatHistory = [...this.chatHistory, lastMessage];
36
+ // this.chatHistory.push({
37
+ // message: response.answer,
38
+ // type: "ai",
39
+ // status: "success",
40
+ // })
41
+ }
42
+ else {
43
+ response = await search(this.dataKey, this.dataMode, this.formData.search);
44
+ this.displaySearchResults(response);
45
+ }
46
+ }
47
+ catch (error) {
48
+ console.error(error);
49
+ this.error = error;
50
+ }
51
+ finally {
52
+ this.isSubmitted = false;
53
+ }
54
+ };
55
+ this.displaySearchResults = results => {
56
+ this.searchResults = results.docs;
57
+ this.isSubmitted = false;
58
+ };
59
+ this.showModal = false;
60
+ this.formData = { search: "" };
61
+ this.searchResults = [];
62
+ this.error = null;
63
+ this.conversationId = null;
64
+ this.chatHistory = [
65
+ // {
66
+ // message: "Hi, I am AI12z, your AI assistant. How can I help you?",
67
+ // type: "user",
68
+ // status: "pending",
69
+ // },
70
+ // {
71
+ // message: `<div class="animate-ping">...</div>`,
72
+ // type: "ai",
73
+ // status: "pending",
74
+ // },
75
+ ];
76
+ this.isChat = false;
77
+ this.heading = undefined;
78
+ this.placeholder = undefined;
79
+ this.dataKey = undefined;
80
+ this.dataMode = undefined;
81
+ this.buttonText = "Ask AI";
82
+ }
83
+ watchButtonText(newValue, oldValue) {
84
+ if (newValue === oldValue) {
85
+ return;
86
+ }
87
+ this.pButtonText = newValue;
88
+ }
89
+ watchPlaceHolder(newValue, oldValue) {
90
+ if (newValue === oldValue) {
91
+ return;
92
+ }
93
+ this.pPlaceholder = newValue;
94
+ }
95
+ async openModal() {
96
+ this.showModal = true;
97
+ this.dirty = false;
98
+ requestAnimationFrame(() => {
99
+ const searchInput = this.el.shadowRoot.querySelector("ai12z-input-form").shadowRoot.querySelector("input");
100
+ searchInput.focus();
101
+ this.el.shadowRoot.querySelector(".modal-wrapper").classList.add("show-modal");
102
+ });
103
+ }
104
+ async closeModal() {
105
+ this.el.shadowRoot.querySelector(".modal-wrapper").classList.remove("show-modal");
106
+ setTimeout(() => (this.showModal = false), 300); // Assuming 300ms is your transition duration
107
+ }
108
+ handleKeyDown(ev) {
109
+ if (ev.metaKey && ev.key === "k") {
110
+ this.openModal();
111
+ }
112
+ if (ev.key === "Escape") {
113
+ this.closeModal();
114
+ }
115
+ }
116
+ handleOutsideClick(ev) {
117
+ const outsideContent = ev.target.classList.contains("modal-wrapper");
118
+ if (outsideContent) {
119
+ this.closeModal();
120
+ }
121
+ }
122
+ // componentWillLoad() {
123
+ // console.log("this.buttonText", this.buttonText)
124
+ // }
125
+ // componentDidLoad() {
126
+ // console.log("Component has been rendered")
127
+ // }
128
+ // componentWillUpdate() {
129
+ // console.log("Component will update and re-render")
130
+ // }
131
+ defaultTemplate() {
132
+ return (h("button", { type: "button", class: "hidden sm:flex items-center w-72 text-left space-x-3 px-4 h-12 bg-white ring-1 ring-slate-900/10 hover:ring-slate-300 focus:outline-none focus:ring-2 focus:ring-sky-500 shadow-sm rounded-lg text-slate-400" }, h("svg", { width: "24", height: "24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "flex-none text-slate-300 dark:text-slate-400", "aria-hidden": "true" }, h("path", { d: "m19 19-3.5-3.5" }), h("circle", { cx: "11", cy: "11", r: "6" })), h("span", { class: "flex-auto" }, "Quick search..."), h("kbd", { class: "font-sans font-semibold dark:text-slate-500" }, h("abbr", { title: "Command", class: "no-underline text-slate-300 dark:text-slate-500" }, "\u2318"), "K")));
133
+ }
134
+ displayMessage() {
135
+ var _a;
136
+ let message = null;
137
+ if (this.error) {
138
+ message = h("p", { class: "text-red-500" }, "Errored please try again!");
139
+ }
140
+ else {
141
+ if (this.isSubmitted) {
142
+ message = (h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor", class: "animate-spin w-6 h-6" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99" })));
143
+ }
144
+ else {
145
+ if (this.dirty) {
146
+ message = "No results found";
147
+ }
148
+ message = "Enter text to get started";
149
+ }
150
+ }
151
+ if (((_a = this.searchResults) === null || _a === void 0 ? void 0 : _a.length) > 0) {
152
+ return null;
153
+ }
154
+ else {
155
+ return h("p", { class: "text-center p-10 text-slate-500 flex justify-center" }, message);
156
+ }
157
+ }
158
+ render() {
159
+ const slot = this.el.shadowRoot.host;
160
+ const slotHasContent = slot && slot.children.length > 0;
161
+ return (h(Host, null, h("div", { onClick: () => this.openModal() }, !slotHasContent && this.defaultTemplate(), slotHasContent && h("slot", null)), h("div", { class: { "modal-wrapper": true, "hidden": !this.showModal, "fixed": true, "inset-0": true, "overflow-auto": true, "bg-smoke-light": true, "flex": true }, onClick: ev => this.handleOutsideClick(ev) }, h("div", { class: "model-content relative p-8 bg-white w-full max-w-xl m-auto flex-col rounded-lg shadow-m z-250 mt-12" }, h("span", { class: "absolute top-0 right-0 p-4" }, h("button", { onClick: () => this.closeModal(), class: "text-black hover:text-gray-800" }, "\u00D7")), h("h1", { class: "text-slate-700 text-2xl mb-2" }, this.heading), h("ai12z-input-form", { onAction: async (event) => {
162
+ const { value, type } = event.detail;
163
+ await this.handleSubmit(event, value, type);
164
+ }, isChat: this.isChat, placeholder: this.pPlaceholder, buttonText: this.pButtonText }), this.displayMessage(), !this.isChat && h(SearchResult, { results: this.searchResults }), this.isChat && (h("ai12z-chat", { chats: this.chatHistory, onFeedback: async (event) => {
165
+ const { feedback, insightId } = event.detail;
166
+ sendFeedback(this.dataKey, this.dataMode, insightId, feedback);
167
+ } }))))));
168
+ }
169
+ static get is() { return "ai12z-cta"; }
170
+ static get encapsulation() { return "shadow"; }
171
+ static get originalStyleUrls() {
172
+ return {
173
+ "$": ["./ai12z-cta.css"]
174
+ };
175
+ }
176
+ static get styleUrls() {
177
+ return {
178
+ "$": ["ai12z-cta.css"]
179
+ };
180
+ }
181
+ static get properties() {
182
+ return {
183
+ "heading": {
184
+ "type": "string",
185
+ "mutable": false,
186
+ "complexType": {
187
+ "original": "string",
188
+ "resolved": "string",
189
+ "references": {}
190
+ },
191
+ "required": false,
192
+ "optional": false,
193
+ "docs": {
194
+ "tags": [],
195
+ "text": ""
196
+ },
197
+ "attribute": "heading",
198
+ "reflect": true
199
+ },
200
+ "placeholder": {
201
+ "type": "string",
202
+ "mutable": false,
203
+ "complexType": {
204
+ "original": "string",
205
+ "resolved": "string",
206
+ "references": {}
207
+ },
208
+ "required": false,
209
+ "optional": false,
210
+ "docs": {
211
+ "tags": [],
212
+ "text": ""
213
+ },
214
+ "attribute": "placeholder",
215
+ "reflect": true
216
+ },
217
+ "dataKey": {
218
+ "type": "string",
219
+ "mutable": false,
220
+ "complexType": {
221
+ "original": "string",
222
+ "resolved": "string",
223
+ "references": {}
224
+ },
225
+ "required": false,
226
+ "optional": false,
227
+ "docs": {
228
+ "tags": [],
229
+ "text": ""
230
+ },
231
+ "attribute": "data-key",
232
+ "reflect": true
233
+ },
234
+ "dataMode": {
235
+ "type": "string",
236
+ "mutable": false,
237
+ "complexType": {
238
+ "original": "string",
239
+ "resolved": "string",
240
+ "references": {}
241
+ },
242
+ "required": false,
243
+ "optional": false,
244
+ "docs": {
245
+ "tags": [],
246
+ "text": ""
247
+ },
248
+ "attribute": "data-mode",
249
+ "reflect": true
250
+ },
251
+ "buttonText": {
252
+ "type": "string",
253
+ "mutable": false,
254
+ "complexType": {
255
+ "original": "string",
256
+ "resolved": "string",
257
+ "references": {}
258
+ },
259
+ "required": false,
260
+ "optional": false,
261
+ "docs": {
262
+ "tags": [],
263
+ "text": ""
264
+ },
265
+ "attribute": "button-text",
266
+ "reflect": true,
267
+ "defaultValue": "\"Ask AI\""
268
+ }
269
+ };
270
+ }
271
+ static get states() {
272
+ return {
273
+ "showModal": {},
274
+ "formData": {},
275
+ "searchResults": {},
276
+ "error": {},
277
+ "conversationId": {},
278
+ "chatHistory": {},
279
+ "isChat": {}
280
+ };
281
+ }
282
+ static get methods() {
283
+ return {
284
+ "openModal": {
285
+ "complexType": {
286
+ "signature": "() => Promise<void>",
287
+ "parameters": [],
288
+ "references": {
289
+ "Promise": {
290
+ "location": "global",
291
+ "id": "global::Promise"
292
+ }
293
+ },
294
+ "return": "Promise<void>"
295
+ },
296
+ "docs": {
297
+ "text": "",
298
+ "tags": []
299
+ }
300
+ },
301
+ "closeModal": {
302
+ "complexType": {
303
+ "signature": "() => Promise<void>",
304
+ "parameters": [],
305
+ "references": {
306
+ "Promise": {
307
+ "location": "global",
308
+ "id": "global::Promise"
309
+ }
310
+ },
311
+ "return": "Promise<void>"
312
+ },
313
+ "docs": {
314
+ "text": "",
315
+ "tags": []
316
+ }
317
+ }
318
+ };
319
+ }
320
+ static get elementRef() { return "el"; }
321
+ static get watchers() {
322
+ return [{
323
+ "propName": "buttonText",
324
+ "methodName": "watchButtonText"
325
+ }, {
326
+ "propName": "placeholder",
327
+ "methodName": "watchPlaceHolder"
328
+ }];
329
+ }
330
+ static get listeners() {
331
+ return [{
332
+ "name": "keydown",
333
+ "method": "handleKeyDown",
334
+ "target": "window",
335
+ "capture": false,
336
+ "passive": false
337
+ }];
338
+ }
339
+ }
340
+ //# sourceMappingURL=ai12z-cta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai12z-cta.js","sourceRoot":"","sources":["../../../src/components/ai12z-cta/ai12z-cta.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC/F,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC/D,4CAA4C;AAC5C,O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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Method, State, Listen, Element, Prop, Host, Watch } from \"@stencil/core\"\nimport { search, askAI, sendFeedback } from \"../../utils/utils\"\n// import InputForm from \"./components/Form\"\nimport SearchResult from \"./components/SearchResult\"\n@Component({\n tag: \"ai12z-cta\",\n styleUrl: \"./ai12z-cta.css\",\n shadow: true,\n})\nexport class MyModal {\n private dirty: boolean = false\n private isSubmitted = false\n private pButtonText: string = \"Ask AI\"\n private pPlaceholder: string\n\n @Element() el!: HTMLElement\n @State() showModal: boolean = false\n @State() formData = { search: \"\" }\n @State() searchResults = []\n @State() error = null\n @State() conversationId = null\n @State() chatHistory = [\n // {\n // message: \"Hi, I am AI12z, your AI assistant. How can I help you?\",\n // type: \"user\",\n // status: \"pending\",\n // },\n // {\n // message: `<div class=\"animate-ping\">...</div>`,\n // type: \"ai\",\n // status: \"pending\",\n // },\n ]\n @State() isChat = false\n\n @Prop({ reflect: true }) heading: string\n @Prop({ reflect: true }) placeholder: string\n @Prop({ reflect: true }) dataKey: string\n @Prop({ reflect: true }) dataMode: string\n @Prop({ reflect: true }) buttonText: string = \"Ask AI\"\n\n @Watch(\"buttonText\")\n watchButtonText(newValue: string, oldValue: string) {\n if (newValue === oldValue) {\n return\n }\n this.pButtonText = newValue\n }\n\n @Watch(\"placeholder\")\n watchPlaceHolder(newValue: string, oldValue: string) {\n if (newValue === oldValue) {\n return\n }\n this.pPlaceholder = newValue\n }\n\n @Method()\n async openModal() {\n this.showModal = true\n this.dirty = false\n\n requestAnimationFrame(() => {\n const searchInput = this.el.shadowRoot.querySelector(\"ai12z-input-form\").shadowRoot.querySelector(\"input\")\n searchInput.focus()\n this.el.shadowRoot.querySelector(\".modal-wrapper\").classList.add(\"show-modal\")\n })\n }\n\n @Method()\n async closeModal() {\n this.el.shadowRoot.querySelector(\".modal-wrapper\").classList.remove(\"show-modal\")\n setTimeout(() => (this.showModal = false), 300) // Assuming 300ms is your transition duration\n }\n\n @Listen(\"keydown\", { target: \"window\" })\n handleKeyDown(ev: KeyboardEvent) {\n if (ev.metaKey && ev.key === \"k\") {\n this.openModal()\n }\n if (ev.key === \"Escape\") {\n this.closeModal()\n }\n }\n\n handleOutsideClick(ev: MouseEvent) {\n const outsideContent = (ev.target as any).classList.contains(\"modal-wrapper\")\n if (outsideContent) {\n this.closeModal()\n }\n }\n\n handleSubmit = async (event, value, type) => {\n this.dirty = true\n this.isSubmitted = true\n event?.preventDefault()\n this.formData = { ...this.formData, search: value }\n\n if (!this.formData.search && this.formData.search.length < 3) return\n try {\n let response = null\n if (type === \"ask-ai\" || this.isChat) {\n this.isChat = true\n this.chatHistory.push({\n message: this.formData.search,\n status: \"success\",\n type: \"user\",\n })\n this.chatHistory.push({\n message: `<div class=\"animate-ping\">...</div>`,\n type: \"ai\",\n status: \"pending\",\n })\n response = await askAI(this.dataKey, this.dataMode, this.formData.search, this.conversationId)\n this.conversationId = response.conversation_Id\n this.chatHistory.pop()\n const lastMessage = { message: response.answer, type: \"ai\", status: \"success\", insightId: response.insight_id }\n this.chatHistory = [...this.chatHistory, lastMessage]\n\n // this.chatHistory.push({\n // message: response.answer,\n // type: \"ai\",\n // status: \"success\",\n // })\n } else {\n response = await search(this.dataKey, this.dataMode, this.formData.search)\n this.displaySearchResults(response)\n }\n } catch (error) {\n console.error(error)\n this.error = error\n } finally {\n this.isSubmitted = false\n }\n }\n\n displaySearchResults = results => {\n this.searchResults = results.docs\n this.isSubmitted = false\n }\n\n // componentWillLoad() {\n // console.log(\"this.buttonText\", this.buttonText)\n // }\n\n // componentDidLoad() {\n // console.log(\"Component has been rendered\")\n // }\n\n // componentWillUpdate() {\n // console.log(\"Component will update and re-render\")\n // }\n\n defaultTemplate() {\n return (\n <button\n type=\"button\"\n class=\"hidden sm:flex items-center w-72 text-left space-x-3 px-4 h-12 bg-white ring-1 ring-slate-900/10 hover:ring-slate-300 focus:outline-none focus:ring-2 focus:ring-sky-500 shadow-sm rounded-lg text-slate-400\"\n >\n <svg\n width=\"24\"\n height=\"24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"flex-none text-slate-300 dark:text-slate-400\"\n aria-hidden=\"true\"\n >\n <path d=\"m19 19-3.5-3.5\"></path>\n <circle cx=\"11\" cy=\"11\" r=\"6\"></circle>\n </svg>\n <span class=\"flex-auto\">Quick search...</span>\n <kbd class=\"font-sans font-semibold dark:text-slate-500\">\n <abbr title=\"Command\" class=\"no-underline text-slate-300 dark:text-slate-500\">\n ⌘\n </abbr>\n K\n </kbd>\n </button>\n )\n }\n\n displayMessage() {\n let message = null\n if (this.error) {\n message = <p class=\"text-red-500\">Errored please try again!</p>\n } else {\n if (this.isSubmitted) {\n message = (\n <svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\" class=\"animate-spin w-6 h-6\">\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99\"\n />\n </svg>\n )\n } else {\n if (this.dirty) {\n message = \"No results found\"\n }\n message = \"Enter text to get started\"\n }\n }\n if (this.searchResults?.length > 0) {\n return null\n } else {\n return <p class=\"text-center p-10 text-slate-500 flex justify-center\">{message}</p>\n }\n }\n\n render() {\n const slot = this.el.shadowRoot.host\n const slotHasContent = slot && slot.children.length > 0\n\n return (\n <Host>\n <div onClick={() => this.openModal()}>\n {!slotHasContent && this.defaultTemplate()}\n {slotHasContent && <slot />}\n </div>\n\n <div\n class={{ \"modal-wrapper\": true, \"hidden\": !this.showModal, \"fixed\": true, \"inset-0\": true, \"overflow-auto\": true, \"bg-smoke-light\": true, \"flex\": true }}\n onClick={ev => this.handleOutsideClick(ev)}\n >\n <div class=\"model-content relative p-8 bg-white w-full max-w-xl m-auto flex-col rounded-lg shadow-m z-250 mt-12\">\n <span class=\"absolute top-0 right-0 p-4\">\n <button onClick={() => this.closeModal()} class=\"text-black hover:text-gray-800\">\n &times;\n </button>\n </span>\n <h1 class=\"text-slate-700 text-2xl mb-2\">{this.heading}</h1>\n <ai12z-input-form\n onAction={async event => {\n const { value, type } = event.detail\n await this.handleSubmit(event, value, type)\n }}\n isChat={this.isChat}\n placeholder={this.pPlaceholder}\n buttonText={this.pButtonText}\n />\n {/* <InputForm isChat={this.isChat} placeholder={this.pPlaceholder} formData={this.formData} buttonText={this.pButtonText} onsubmit={this.handleSubmit} /> */}\n {this.displayMessage()}\n {!this.isChat && <SearchResult results={this.searchResults} />}\n {this.isChat && (\n <ai12z-chat\n chats={this.chatHistory}\n onFeedback={async event => {\n const { feedback, insightId } = event.detail\n sendFeedback(this.dataKey, this.dataMode, insightId, feedback)\n }}\n />\n )}\n </div>\n </div>\n </Host>\n )\n }\n}\n"]}
@@ -0,0 +1,112 @@
1
+ import { h } from "@stencil/core";
2
+ export class MyChat {
3
+ constructor() {
4
+ this.scrollToBottom = () => {
5
+ this.scrollBottom = this.element.shadowRoot.querySelector(".scroll-bottom");
6
+ this.scrollBottom.scrollIntoView({ behavior: "smooth" });
7
+ };
8
+ this.disableFeedback = (id) => {
9
+ const thumbsUp = this.element.shadowRoot.querySelector(`#thumbsUp_${id}`);
10
+ const thumbsDown = this.element.shadowRoot.querySelector(`#thumbsDown_${id}`);
11
+ thumbsUp.classList.add("cursor-not-allowed");
12
+ thumbsUp.setAttribute("disabled", "true");
13
+ thumbsDown.classList.add("cursor-not-allowed");
14
+ thumbsDown.setAttribute("disabled", "true");
15
+ };
16
+ this.thumbsUp = (id) => {
17
+ const thumbsUp = this.element.shadowRoot.querySelector(`#thumbsUp_${id}`);
18
+ thumbsUp.classList.add("text-gray-700");
19
+ this.disableFeedback(id);
20
+ this.feedback.emit({ insightId: id, feedback: 1 });
21
+ };
22
+ this.thumbsDown = (id) => {
23
+ const thumbsDown = this.element.shadowRoot.querySelector(`#thumbsDown_${id}`);
24
+ thumbsDown.classList.add("text-gray-700");
25
+ this.disableFeedback(id);
26
+ this.feedback.emit({ insightId: id, feedback: -1 });
27
+ };
28
+ this.chats = undefined;
29
+ this.scrollBottom = undefined;
30
+ }
31
+ componentDidLoad() {
32
+ this.scrollToBottom();
33
+ }
34
+ componentDidUpdate() {
35
+ this.scrollToBottom();
36
+ }
37
+ render() {
38
+ var _a;
39
+ return (h("ul", { class: "flex flex-col max-h-[600px] overflow-y-auto mt-5" }, (_a = this.chats) === null || _a === void 0 ? void 0 :
40
+ _a.map(chat => {
41
+ return (h("li", { class: {
42
+ "p-4": true,
43
+ "flex": true,
44
+ "justify-start": chat.type === "user",
45
+ "justify-end": chat.type !== "user",
46
+ "pe-10": chat.type === "user",
47
+ "ps-20": chat.type !== "user",
48
+ "text-md": true,
49
+ "text-slate-900": true,
50
+ "relative": true,
51
+ } }, chat.type === "user" && (h("div", { class: "flex items-end pr-2" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor", class: "w-8 h-8" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" })))), h("div", { class: "border p-5 bg-slate-100 leading-7 rounded-lg", innerHTML: chat.message }), chat.type !== "user" && (h("div", { class: "absolute top-0 right-0 w-16 h-16" }, h("button", { id: `thumbsUp_${chat.insightId}`, onClick: () => this.thumbsUp(chat.insightId), class: "text-gray-500" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor", class: "w-6 h-6" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M6.633 10.25c.806 0 1.533-.446 2.031-1.08a9.041 9.041 0 0 1 2.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 0 0 .322-1.672V2.75a.75.75 0 0 1 .75-.75 2.25 2.25 0 0 1 2.25 2.25c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282m0 0h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 0 1-2.649 7.521c-.388.482-.987.729-1.605.729H13.48c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 0 0-1.423-.23H5.904m10.598-9.75H14.25M5.904 18.5c.083.205.173.405.27.602.197.4-.078.898-.523.898h-.908c-.889 0-1.713-.518-1.972-1.368a12 12 0 0 1-.521-3.507c0-1.553.295-3.036.831-4.398C3.387 9.953 4.167 9.5 5 9.5h1.053c.472 0 .745.556.5.96a8.958 8.958 0 0 0-1.302 4.665c0 1.194.232 2.333.654 3.375Z" }))), h("button", { id: `thumbsDown_${chat.insightId}`, onClick: () => this.thumbsDown(chat.insightId), class: "text-gray-500" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor", class: "w-6 h-6" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M7.498 15.25H4.372c-1.026 0-1.945-.694-2.054-1.715a12.137 12.137 0 0 1-.068-1.285c0-2.848.992-5.464 2.649-7.521C5.287 4.247 5.886 4 6.504 4h4.016a4.5 4.5 0 0 1 1.423.23l3.114 1.04a4.5 4.5 0 0 0 1.423.23h1.294M7.498 15.25c.618 0 .991.724.725 1.282A7.471 7.471 0 0 0 7.5 19.75 2.25 2.25 0 0 0 9.75 22a.75.75 0 0 0 .75-.75v-.633c0-.573.11-1.14.322-1.672.304-.76.93-1.33 1.653-1.715a9.04 9.04 0 0 0 2.86-2.4c.498-.634 1.226-1.08 2.032-1.08h.384m-10.253 1.5H9.7m8.075-9.75c.01.05.027.1.05.148.593 1.2.925 2.55.925 3.977 0 1.487-.36 2.89-.999 4.125m.023-8.25c-.076-.365.183-.75.575-.75h.908c.889 0 1.713.518 1.972 1.368.339 1.11.521 2.287.521 3.507 0 1.553-.295 3.036-.831 4.398-.306.774-1.086 1.227-1.918 1.227h-1.053c-.472 0-.745-.556-.5-.96a8.95 8.95 0 0 0 .303-.54" })))))));
52
+ }), h("div", { class: "scroll-bottom" })));
53
+ }
54
+ static get is() { return "ai12z-chat"; }
55
+ static get encapsulation() { return "shadow"; }
56
+ static get originalStyleUrls() {
57
+ return {
58
+ "$": ["ai12z-chat.css"]
59
+ };
60
+ }
61
+ static get styleUrls() {
62
+ return {
63
+ "$": ["ai12z-chat.css"]
64
+ };
65
+ }
66
+ static get properties() {
67
+ return {
68
+ "chats": {
69
+ "type": "any",
70
+ "mutable": false,
71
+ "complexType": {
72
+ "original": "any",
73
+ "resolved": "any",
74
+ "references": {}
75
+ },
76
+ "required": false,
77
+ "optional": false,
78
+ "docs": {
79
+ "tags": [],
80
+ "text": ""
81
+ },
82
+ "attribute": "chats",
83
+ "reflect": false
84
+ }
85
+ };
86
+ }
87
+ static get states() {
88
+ return {
89
+ "scrollBottom": {}
90
+ };
91
+ }
92
+ static get events() {
93
+ return [{
94
+ "method": "feedback",
95
+ "name": "feedback",
96
+ "bubbles": true,
97
+ "cancelable": true,
98
+ "composed": true,
99
+ "docs": {
100
+ "tags": [],
101
+ "text": ""
102
+ },
103
+ "complexType": {
104
+ "original": "any",
105
+ "resolved": "any",
106
+ "references": {}
107
+ }
108
+ }];
109
+ }
110
+ static get elementRef() { return "element"; }
111
+ }
112
+ //# sourceMappingURL=Chat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Chat.js","sourceRoot":"","sources":["../../../../src/components/ai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;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, Element, State, Event, EventEmitter } from \"@stencil/core\"\n\n@Component({\n tag: \"ai12z-chat\",\n styleUrl: \"ai12z-chat.css\",\n shadow: true,\n})\nexport class MyChat {\n @Element() private element: HTMLElement\n @Prop() chats: any\n @State() scrollBottom: any\n\n @Event() feedback: EventEmitter\n\n componentDidLoad() {\n this.scrollToBottom()\n }\n\n componentDidUpdate() {\n this.scrollToBottom()\n }\n\n scrollToBottom = () => {\n this.scrollBottom = this.element.shadowRoot.querySelector(\".scroll-bottom\")\n this.scrollBottom.scrollIntoView({ behavior: \"smooth\" })\n }\n disableFeedback = (id: string): void => {\n const thumbsUp = this.element.shadowRoot.querySelector(`#thumbsUp_${id}`)\n const thumbsDown = this.element.shadowRoot.querySelector(`#thumbsDown_${id}`)\n thumbsUp.classList.add(\"cursor-not-allowed\")\n thumbsUp.setAttribute(\"disabled\", \"true\")\n thumbsDown.classList.add(\"cursor-not-allowed\")\n thumbsDown.setAttribute(\"disabled\", \"true\")\n }\n\n thumbsUp = (id: string): void => {\n const thumbsUp = this.element.shadowRoot.querySelector(`#thumbsUp_${id}`)\n thumbsUp.classList.add(\"text-gray-700\")\n this.disableFeedback(id)\n this.feedback.emit({ insightId: id, feedback: 1 })\n }\n\n thumbsDown = (id: string): void => {\n const thumbsDown = this.element.shadowRoot.querySelector(`#thumbsDown_${id}`)\n thumbsDown.classList.add(\"text-gray-700\")\n this.disableFeedback(id)\n this.feedback.emit({ insightId: id, feedback: -1 })\n }\n\n render() {\n return (\n <ul class=\"flex flex-col max-h-[600px] overflow-y-auto mt-5\">\n {this.chats?.map(chat => {\n return (\n <li\n class={{\n \"p-4\": true,\n \"flex\": true,\n \"justify-start\": chat.type === \"user\",\n \"justify-end\": chat.type !== \"user\",\n \"pe-10\": chat.type === \"user\",\n \"ps-20\": chat.type !== \"user\",\n \"text-md\": true,\n \"text-slate-900\": true,\n \"relative\": true,\n }}\n >\n {chat.type === \"user\" && (\n <div class=\"flex items-end pr-2\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\" class=\"w-8 h-8\">\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z\"\n />\n </svg>\n </div>\n )}\n <div class=\"border p-5 bg-slate-100 leading-7 rounded-lg\" innerHTML={chat.message}></div>\n {chat.type !== \"user\" && (\n <div class=\"absolute top-0 right-0 w-16 h-16\">\n <button id={`thumbsUp_${chat.insightId}`} onClick={() => this.thumbsUp(chat.insightId)} class={\"text-gray-500\"}>\n <svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\" class=\"w-6 h-6\">\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M6.633 10.25c.806 0 1.533-.446 2.031-1.08a9.041 9.041 0 0 1 2.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 0 0 .322-1.672V2.75a.75.75 0 0 1 .75-.75 2.25 2.25 0 0 1 2.25 2.25c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282m0 0h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 0 1-2.649 7.521c-.388.482-.987.729-1.605.729H13.48c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 0 0-1.423-.23H5.904m10.598-9.75H14.25M5.904 18.5c.083.205.173.405.27.602.197.4-.078.898-.523.898h-.908c-.889 0-1.713-.518-1.972-1.368a12 12 0 0 1-.521-3.507c0-1.553.295-3.036.831-4.398C3.387 9.953 4.167 9.5 5 9.5h1.053c.472 0 .745.556.5.96a8.958 8.958 0 0 0-1.302 4.665c0 1.194.232 2.333.654 3.375Z\"\n />\n </svg>\n </button>\n\n <button id={`thumbsDown_${chat.insightId}`} onClick={() => this.thumbsDown(chat.insightId)} class={\"text-gray-500\"}>\n <svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\" class=\"w-6 h-6\">\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M7.498 15.25H4.372c-1.026 0-1.945-.694-2.054-1.715a12.137 12.137 0 0 1-.068-1.285c0-2.848.992-5.464 2.649-7.521C5.287 4.247 5.886 4 6.504 4h4.016a4.5 4.5 0 0 1 1.423.23l3.114 1.04a4.5 4.5 0 0 0 1.423.23h1.294M7.498 15.25c.618 0 .991.724.725 1.282A7.471 7.471 0 0 0 7.5 19.75 2.25 2.25 0 0 0 9.75 22a.75.75 0 0 0 .75-.75v-.633c0-.573.11-1.14.322-1.672.304-.76.93-1.33 1.653-1.715a9.04 9.04 0 0 0 2.86-2.4c.498-.634 1.226-1.08 2.032-1.08h.384m-10.253 1.5H9.7m8.075-9.75c.01.05.027.1.05.148.593 1.2.925 2.55.925 3.977 0 1.487-.36 2.89-.999 4.125m.023-8.25c-.076-.365.183-.75.575-.75h.908c.889 0 1.713.518 1.972 1.368.339 1.11.521 2.287.521 3.507 0 1.553-.295 3.036-.831 4.398-.306.774-1.086 1.227-1.918 1.227h-1.053c-.472 0-.745-.556-.5-.96a8.95 8.95 0 0 0 .303-.54\"\n />\n </svg>\n </button>\n </div>\n )}\n </li>\n )\n })}\n <div class=\"scroll-bottom\" />\n </ul>\n )\n }\n}\n"]}