@peak-ai/canvas 1.4.20-rc.10 → 1.4.20-rc.12

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.
@@ -1 +1 @@
1
- {"version":3,"file":"filter-placeholder.js","names":["filterPlaceholders","obj","filtered","_extends","Object","keys","forEach","key","value","name"],"sources":["../../src/helpers/filter-placeholder.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function filterPlaceholders(obj: any) {\n if (!obj || typeof obj !== 'object') {\n return obj;\n }\n\n const filtered = { ...obj };\n\n Object.keys(filtered).forEach((key) => {\n const value = filtered[key];\n\n if (value && typeof value === 'object' && value.name === '__peak_placeholder') {\n delete filtered[key];\n }\n });\n\n return filtered;\n}\n"],"mappings":"qDAAA;AACA,MAAO,SAAS,CAAAA,kBAAkBA,CAACC,GAAQ,CAAE,CAC3C,GAAI,CAACA,GAAG,EAAI,MAAO,CAAAA,GAAG,GAAK,QAAQ,CAAE,CACnC,MAAO,CAAAA,GACT,CAEA,GAAM,CAAAC,QAAQ,CAAAC,QAAA,IAAQF,GAAG,CAAE,CAE3BG,MAAM,CAACC,IAAI,CAACH,QAAQ,CAAC,CAACI,OAAO,CAAC,SAACC,GAAG,CAAK,CACrC,GAAM,CAAAC,KAAK,CAAGN,QAAQ,CAACK,GAAG,CAAC,CAE3B,GAAIC,KAAK,EAAI,MAAO,CAAAA,KAAK,GAAK,QAAQ,EAAIA,KAAK,CAACC,IAAI,GAAK,oBAAoB,CAAE,CAC7E,MAAO,CAAAP,QAAQ,CAACK,GAAG,CACrB,CACF,CAAC,CAAC,CAEF,MAAO,CAAAL,QACT","ignoreList":[]}
1
+ {"version":3,"file":"filter-placeholder.js","names":["filterPlaceholders","obj","filtered","_extends","Object","keys","forEach","key","value","name"],"sources":["../../src/helpers/filter-placeholder.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function filterPlaceholders(obj: any) {\n if (!obj || typeof obj !== 'object') {\n return obj;\n }\n\n const filtered = { ...obj };\n\n Object.keys(filtered).forEach((key) => {\n const value = filtered[key];\n \n if (value && typeof value === 'object' && value.name === '__peak_placeholder') {\n delete filtered[key];\n }\n });\n\n return filtered;\n}\n"],"mappings":"qDAAA;AACA,MAAO,SAAS,CAAAA,kBAAkBA,CAACC,GAAQ,CAAE,CAC3C,GAAI,CAACA,GAAG,EAAI,MAAO,CAAAA,GAAG,GAAK,QAAQ,CAAE,CACnC,MAAO,CAAAA,GACT,CAEA,GAAM,CAAAC,QAAQ,CAAAC,QAAA,IAAQF,GAAG,CAAE,CAE3BG,MAAM,CAACC,IAAI,CAACH,QAAQ,CAAC,CAACI,OAAO,CAAC,SAACC,GAAG,CAAK,CACrC,GAAM,CAAAC,KAAK,CAAGN,QAAQ,CAACK,GAAG,CAAC,CAE3B,GAAIC,KAAK,EAAI,MAAO,CAAAA,KAAK,GAAK,QAAQ,EAAIA,KAAK,CAACC,IAAI,GAAK,oBAAoB,CAAE,CAC7E,MAAO,CAAAP,QAAQ,CAACK,GAAG,CACrB,CACF,CAAC,CAAC,CAEF,MAAO,CAAAL,QACT","ignoreList":[]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@peak-ai/canvas",
3
3
  "author": "squad-builder-experience",
4
4
  "license": "UNLICENSED",
5
- "version": "1.4.20-rc.10",
5
+ "version": "1.4.20-rc.12",
6
6
  "description": "",
7
7
  "dependencies": {
8
8
  "@emotion/react": "^11.11.4",
@@ -1,2 +1,2 @@
1
- import React,{useEffect}from"react";import{X}from"lucide-react";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function CustomModal(_ref){var isOpen=_ref.isOpen,onClose=_ref.onClose,title=_ref.title,children=_ref.children,_ref$className=_ref.className,className=_ref$className===void 0?"":_ref$className,titleIcon=_ref.titleIcon;useEffect(function(){function handleEscapeKey(event){if(event.key==="Escape"&&isOpen){onClose()}}if(isOpen){var _iframe$contentWindow;document.addEventListener("keydown",handleEscapeKey);var iframe=document.querySelector(".gjs-frame");var iframeDocument=(iframe==null?void 0:iframe.contentDocument)||(iframe==null||(_iframe$contentWindow=iframe.contentWindow)==null?void 0:_iframe$contentWindow.document);if(iframeDocument){var _iframeDocument$docum;(_iframeDocument$docum=iframeDocument.documentElement)==null||_iframeDocument$docum.style.setProperty("overflow","hidden","important")}return function(){document.removeEventListener("keydown",handleEscapeKey);if(iframeDocument){var _iframeDocument$docum2;(_iframeDocument$docum2=iframeDocument.documentElement)==null||_iframeDocument$docum2.style.removeProperty("overflow")}}}return function(){document.removeEventListener("keydown",handleEscapeKey)}},[isOpen,onClose]);function handleBackdropClick(event){if(event.target===event.currentTarget){onClose()}}if(!isOpen){return null}return/*#__PURE__*/_jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4 bg-black bg-opacity-30 "+className,onClick:handleBackdropClick,children:[/*#__PURE__*/_jsxs("div",{className:"relative w-full max-w-2xl max-h-[90vh] min-h-[45vh] bg-white rounded-lg shadow-xl overflow-hidden animate-modal-fade-in",onClick:function onClick(e){return e.stopPropagation()},children:[/*#__PURE__*/_jsxs("div",{className:"p-6 border-b border-gray-200 bg-gray-50 relative flex items-center justify-between",children:[/*#__PURE__*/_jsxs("h2",{className:"flex items-center text-lg font-semibold text-gray-900",children:[titleIcon&&/*#__PURE__*/_jsx("span",{className:"mr-2",children:titleIcon}),title]}),/*#__PURE__*/_jsx("button",{onClick:onClose,className:"transition-colors duration-200 hover:bg-gray-100 rounded p-1 flex items-center justify-center",type:"button","aria-label":"Close modal",style:{width:"24px",height:"24px"},children:/*#__PURE__*/_jsx(X,{size:12,className:"text-gray-600",style:{opacity:1,transform:"rotate(0deg)"}})})]}),/*#__PURE__*/_jsx("div",{className:"overflow-y-auto max-h-[calc(90vh-160px)]",children:children})]}),/*#__PURE__*/_jsx("style",{children:"\n .animate-modal-fade-in {\n animation: modalFadeIn 0.2s ease-out;\n }\n \n @keyframes modalFadeIn {\n from {\n opacity: 0;\n transform: scale(0.95) translateY(-10px);\n }\n to {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n }\n "})]})}export default CustomModal;
1
+ import React,{useEffect}from"react";import{X}from"lucide-react";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function CustomModal(_ref){var isOpen=_ref.isOpen,onClose=_ref.onClose,title=_ref.title,children=_ref.children,_ref$className=_ref.className,className=_ref$className===void 0?"":_ref$className,titleIcon=_ref.titleIcon;useEffect(function(){function handleEscapeKey(event){if(event.key==="Escape"&&isOpen){onClose()}}if(isOpen){document.addEventListener("keydown",handleEscapeKey);document.body.style.overflow="hidden"}return function(){document.removeEventListener("keydown",handleEscapeKey);document.body.style.overflow="unset"}},[isOpen,onClose]);function handleBackdropClick(event){if(event.target===event.currentTarget){onClose()}}if(!isOpen){return null}return/*#__PURE__*/_jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4 bg-black bg-opacity-30 "+className,onClick:handleBackdropClick,children:[/*#__PURE__*/_jsxs("div",{className:"relative w-full max-w-2xl max-h-[90vh] min-h-[45vh] bg-white rounded-lg shadow-xl overflow-hidden animate-modal-fade-in",onClick:function onClick(e){return e.stopPropagation()},children:[/*#__PURE__*/_jsxs("div",{className:"p-6 border-b border-gray-200 bg-gray-50 relative flex items-center justify-between",children:[/*#__PURE__*/_jsxs("h2",{className:"flex items-center text-lg font-semibold text-gray-900",children:[titleIcon&&/*#__PURE__*/_jsx("span",{className:"mr-2",children:titleIcon}),title]}),/*#__PURE__*/_jsx("button",{onClick:onClose,className:"transition-colors duration-200 hover:bg-gray-100 rounded p-1 flex items-center justify-center",type:"button","aria-label":"Close modal",style:{width:"24px",height:"24px"},children:/*#__PURE__*/_jsx(X,{size:12,className:"text-gray-600",style:{opacity:1,transform:"rotate(0deg)"}})})]}),/*#__PURE__*/_jsx("div",{className:"overflow-y-auto max-h-[calc(90vh-160px)]",children:children})]}),/*#__PURE__*/_jsx("style",{children:"\n .animate-modal-fade-in {\n animation: modalFadeIn 0.2s ease-out;\n }\n \n @keyframes modalFadeIn {\n from {\n opacity: 0;\n transform: scale(0.95) translateY(-10px);\n }\n to {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n }\n "})]})}export default CustomModal;
2
2
  //# sourceMappingURL=custom-modal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"custom-modal.js","names":["React","useEffect","X","jsx","_jsx","jsxs","_jsxs","CustomModal","_ref","isOpen","onClose","title","children","_ref$className","className","titleIcon","handleEscapeKey","event","key","_iframe$contentWindow","document","addEventListener","iframe","querySelector","iframeDocument","contentDocument","contentWindow","_iframeDocument$docum","documentElement","style","setProperty","removeEventListener","_iframeDocument$docum2","removeProperty","handleBackdropClick","target","currentTarget","onClick","e","stopPropagation","type","width","height","size","opacity","transform"],"sources":["../../../src/plugins/helpers/custom-modal.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { X } from 'lucide-react';\n\ntype CustomModalProps = {\n isOpen: boolean;\n onClose: () => void;\n title: string;\n children: React.ReactNode;\n className?: string;\n titleIcon?: React.ReactNode;\n}\n\nexport function CustomModal({\n isOpen,\n onClose,\n title,\n children,\n className = '',\n titleIcon\n}: CustomModalProps) {\n\n useEffect(() => {\n function handleEscapeKey(event: KeyboardEvent) {\n if (event.key === 'Escape' && isOpen) {\n onClose();\n }\n }\n\n if (isOpen) {\n document.addEventListener('keydown', handleEscapeKey);\n const iframe = document.querySelector('.gjs-frame') as HTMLIFrameElement;\n const iframeDocument = iframe?.contentDocument || iframe?.contentWindow?.document;\n \n if (iframeDocument) {\n iframeDocument.documentElement?.style.setProperty('overflow', 'hidden', 'important');\n }\n\n return () => {\n document.removeEventListener('keydown', handleEscapeKey);\n \n if (iframeDocument) {\n iframeDocument.documentElement?.style.removeProperty('overflow');\n }\n };\n }\n\n return () => {\n document.removeEventListener('keydown', handleEscapeKey);\n };\n }, [isOpen, onClose]);\n\n function handleBackdropClick(event: React.MouseEvent<HTMLDivElement>) {\n if (event.target === event.currentTarget) {\n onClose();\n }\n }\n\n if (!isOpen) {\n return null;\n }\n\n return (\n <div\n className={`fixed inset-0 z-[9999] flex items-center justify-center p-4 bg-black bg-opacity-30 ${className}`}\n onClick={handleBackdropClick}\n >\n <div\n className=\"relative w-full max-w-2xl max-h-[90vh] min-h-[45vh] bg-white rounded-lg shadow-xl overflow-hidden animate-modal-fade-in\"\n onClick={(e) => e.stopPropagation()}\n >\n <div className=\"p-6 border-b border-gray-200 bg-gray-50 relative flex items-center justify-between\">\n <h2 className=\"flex items-center text-lg font-semibold text-gray-900\">\n {titleIcon && <span className=\"mr-2\">{titleIcon}</span>}\n {title}\n </h2>\n\n <button\n onClick={onClose}\n className=\"transition-colors duration-200 hover:bg-gray-100 rounded p-1 flex items-center justify-center\"\n type=\"button\"\n aria-label=\"Close modal\"\n style={{\n width: '24px',\n height: '24px'\n }}\n >\n <X \n size={12}\n className=\"text-gray-600\"\n style={{ \n opacity: 1,\n transform: 'rotate(0deg)'\n }}\n />\n </button>\n </div>\n\n <div className=\"overflow-y-auto max-h-[calc(90vh-160px)]\">\n {children}\n </div>\n </div>\n\n <style>{`\n .animate-modal-fade-in {\n animation: modalFadeIn 0.2s ease-out;\n }\n \n @keyframes modalFadeIn {\n from {\n opacity: 0;\n transform: scale(0.95) translateY(-10px);\n }\n to {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n }\n `}</style>\n </div>\n );\n}\n\nexport default CustomModal;\n"],"mappings":"AAAA,MAAO,CAAAA,KAAK,EAAIC,SAAS,KAAQ,OAAO,CACxC,OAASC,CAAC,KAAQ,cAAc,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAWjC,MAAO,SAAS,CAAAC,WAAWA,CAAAC,IAAA,CAON,IANnB,CAAAC,MAAM,CAAAD,IAAA,CAANC,MAAM,CACNC,OAAO,CAAAF,IAAA,CAAPE,OAAO,CACPC,KAAK,CAAAH,IAAA,CAALG,KAAK,CACLC,QAAQ,CAAAJ,IAAA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al","_ref","isOpen","onClose","title","children","_ref$className","className","titleIcon","handleEscapeKey","event","key","document","addEventListener","body","style","overflow","removeEventListener","handleBackdropClick","target","currentTarget","onClick","e","stopPropagation","type","width","height","size","opacity","transform"],"sources":["../../../src/plugins/helpers/custom-modal.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { X } from 'lucide-react';\n\ntype CustomModalProps = {\n isOpen: boolean;\n onClose: () => void;\n title: string;\n children: React.ReactNode;\n className?: string;\n titleIcon?: React.ReactNode;\n}\n\nexport function CustomModal({\n isOpen,\n onClose,\n title,\n children,\n className = '',\n titleIcon\n}: CustomModalProps) {\n\n useEffect(() => {\n function handleEscapeKey(event: KeyboardEvent) {\n if (event.key === 'Escape' && isOpen) {\n onClose();\n }\n }\n\n if (isOpen) {\n document.addEventListener('keydown', handleEscapeKey);\n document.body.style.overflow = 'hidden';\n }\n\n return () => {\n document.removeEventListener('keydown', handleEscapeKey);\n document.body.style.overflow = 'unset';\n };\n }, [isOpen, onClose]);\n\n function handleBackdropClick(event: React.MouseEvent<HTMLDivElement>) {\n if (event.target === event.currentTarget) {\n onClose();\n }\n }\n\n if (!isOpen) {\n return null;\n }\n\n return (\n <div\n className={`fixed inset-0 z-[9999] flex items-center justify-center p-4 bg-black bg-opacity-30 ${className}`}\n onClick={handleBackdropClick}\n >\n <div\n className=\"relative w-full max-w-2xl max-h-[90vh] min-h-[45vh] bg-white rounded-lg shadow-xl overflow-hidden animate-modal-fade-in\"\n onClick={(e) => e.stopPropagation()}\n >\n <div className=\"p-6 border-b border-gray-200 bg-gray-50 relative flex items-center justify-between\">\n <h2 className=\"flex items-center text-lg font-semibold text-gray-900\">\n {titleIcon && <span className=\"mr-2\">{titleIcon}</span>}\n {title}\n </h2>\n\n <button\n onClick={onClose}\n className=\"transition-colors duration-200 hover:bg-gray-100 rounded p-1 flex items-center justify-center\"\n type=\"button\"\n aria-label=\"Close modal\"\n style={{\n width: '24px',\n height: '24px'\n }}\n >\n <X \n size={12}\n className=\"text-gray-600\"\n style={{ \n opacity: 1,\n transform: 'rotate(0deg)'\n }}\n />\n </button>\n </div>\n\n <div className=\"overflow-y-auto max-h-[calc(90vh-160px)]\">\n {children}\n </div>\n </div>\n\n <style>{`\n .animate-modal-fade-in {\n animation: modalFadeIn 0.2s ease-out;\n }\n \n @keyframes modalFadeIn {\n from {\n opacity: 0;\n transform: scale(0.95) translateY(-10px);\n }\n to {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n }\n `}</style>\n </div>\n );\n}\n\nexport default CustomModal;\n"],"mappings":"AAAA,MAAO,CAAAA,KAAK,EAAIC,SAAS,KAAQ,OAAO,CACxC,OAASC,CAAC,KAAQ,cAAc,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAWjC,MAAO,SAAS,CAAAC,WAAWA,CAAAC,IAAA,CAON,IANnB,CAAAC,MAAM,CAAAD,IAAA,CAANC,MAAM,CACNC,OAAO,CAAAF,IAAA,CAAPE,OAAO,CACPC,KAAK,CAAAH,IAAA,CAALG,KAAK,CACLC,QAAQ,CAAAJ,IAAA,CAARI,QAAQ,CAAAC,cAAA,CAAAL,IAAA,CACRM,SAAS,CAATA,SAAS,CAAAD,cAAA,UAAG,EAAE,CAAAA,cAAA,CACdE,SAAS,CAAAP,IAAA,CAATO,SAAS,CAGTd,SAAS,CAAC,UAAM,CACd,QAAS,CAAAe,eAAeA,CAACC,KAAoB,CAAE,CAC7C,GAAIA,KAAK,CAACC,GAAG,GAAK,QAAQ,EAAIT,MAAM,CAAE,CACpCC,OAAO,CAAC,CACV,CACF,CAEA,GAAID,MAAM,CAAE,CACVU,QAAQ,CAACC,gBAAgB,CAAC,SAAS,CAAEJ,eAAe,CAAC,CACrDG,QAAQ,CAACE,IAAI,CAACC,KAAK,CAACC,QAAQ,CAAG,QACjC,CAEA,MAAO,WAAM,CACXJ,QAAQ,CAACK,mBAAmB,CAAC,SAAS,CAAER,eAAe,CAAC,CACxDG,QAAQ,CA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AAC,cAENR,IAAA,UAAAQ,QAAA,sXAeS,CAAC,EACP,CAET,CAEA,cAAe,CAAAL,WAAW","ignoreList":[]}
@@ -1,7 +1,6 @@
1
1
  import { QueryCacheEntry, InteractionType, InteractionState } from './query-cache-utils';
2
2
  declare class QueryCacheManager {
3
3
  private cache;
4
- private totalEntries;
5
4
  private maxCacheSize;
6
5
  private maxCacheAge;
7
6
  constructor(maxCacheSize?: number, maxCacheAge?: number);
@@ -11,9 +10,7 @@ declare class QueryCacheManager {
11
10
  invalidateAll(): void;
12
11
  isCached(componentId: string, interactionType: InteractionType, state: InteractionState): boolean;
13
12
  private cleanupCache;
14
- private getTotalCacheSize;
15
13
  getStats(): {
16
- componentCount: number;
17
14
  maxAge: number;
18
15
  maxSize: number;
19
16
  size: number;
@@ -1,4 +1,3 @@
1
- import _extends from"@babel/runtime/helpers/extends";function _createForOfIteratorHelperLoose(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var o=0;return function(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}import{createInteractionKey}from"./query-cache-utils";var QueryCacheManager=/*#__PURE__*/function(){// 5 minutes
2
- function QueryCacheManager(maxCacheSize,maxCacheAge){if(maxCacheSize===void 0){maxCacheSize=100}if(maxCacheAge===void 0){maxCacheAge=5*60*1000}this.cache=new Map;this.totalEntries=0;this.maxCacheSize=100;this.maxCacheAge=5*60*1000;this.maxCacheSize=maxCacheSize;this.maxCacheAge=maxCacheAge}var _proto=QueryCacheManager.prototype;_proto.getCachedQuery=function getCachedQuery(componentId,interactionType,state){var componentCache=this.cache.get(componentId);if(!componentCache){return null}var key=createInteractionKey(interactionType,state);var entry=componentCache.get(key);if(!entry){return null}var now=Date.now();if(now-entry.timestamp>this.maxCacheAge){componentCache["delete"](key);this.totalEntries-=1;if(componentCache.size===0){this.cache["delete"](componentId)}return null}return entry};_proto.setCachedQuery=function setCachedQuery(componentId,interactionType,state,entry){var componentCache=this.cache.get(componentId);if(!componentCache){componentCache=new Map;this.cache.set(componentId,componentCache)}var key=createInteractionKey(interactionType,state);var isNewEntry=!componentCache.has(key);componentCache.set(key,_extends({},entry,{timestamp:Date.now()}));if(isNewEntry){this.totalEntries+=1}if(this.totalEntries>this.maxCacheSize){this.cleanupCache()}};_proto.invalidateComponent=function invalidateComponent(componentId){var componentCache=this.cache.get(componentId);if(componentCache){this.totalEntries-=componentCache.size;this.cache["delete"](componentId)}};_proto.invalidateAll=function invalidateAll(){this.cache.clear();this.totalEntries=0};_proto.isCached=function isCached(componentId,interactionType,state){return this.getCachedQuery(componentId,interactionType,state)!==null};_proto.cleanupCache=function cleanupCache(){var now=Date.now();var allEntries=[];for(var _iterator=_createForOfIteratorHelperLoose(this.cache.entries()),_step;!(_step=_iterator()).done;){var _step$value=_step.value,_componentId=_step$value[0],_componentCache=_step$value[1];for(var _iterator3=_createForOfIteratorHelperLoose(_componentCache.entries()),_step3;!(_step3=_iterator3()).done;){var _step3$value=_step3.value,_key=_step3$value[0],entry=_step3$value[1];if(now-entry.timestamp>this.maxCacheAge){_componentCache["delete"](_key);this.totalEntries-=1}else{allEntries.push({componentId:_componentId,key:_key,timestamp:entry.timestamp})}}if(_componentCache.size===0){this.cache["delete"](_componentId)}}if(allEntries.length>this.maxCacheSize){allEntries.sort(function(a,b){return a.timestamp-b.timestamp});var entriesToRemove=allEntries.slice(0,allEntries.length-this.maxCacheSize);for(var _iterator2=_createForOfIteratorHelperLoose(entriesToRemove),_step2;!(_step2=_iterator2()).done;){var _step2$value=_step2.value,componentId=_step2$value.componentId,key=_step2$value.key;var componentCache=this.cache.get(componentId);if(componentCache){componentCache["delete"](key);this.totalEntries-=1;// Remove empty component caches
3
- if(componentCache.size===0){this.cache["delete"](componentId)}}}}};_proto.getTotalCacheSize=function getTotalCacheSize(){return this.totalEntries};_proto.getStats=function getStats(){return{componentCount:this.cache.size,maxAge:this.maxCacheAge,maxSize:this.maxCacheSize,size:this.getTotalCacheSize()}};return QueryCacheManager}();var globalCacheInstance=null;export function getGlobalQueryCache(){if(!globalCacheInstance){globalCacheInstance=new QueryCacheManager}return globalCacheInstance}export function resetGlobalQueryCache(){globalCacheInstance=null}export function configureGlobalQueryCache(maxCacheSize,maxCacheAge){if(maxCacheSize===void 0){maxCacheSize=100}if(maxCacheAge===void 0){maxCacheAge=5*60*1000}globalCacheInstance=new QueryCacheManager(maxCacheSize,maxCacheAge)}
1
+ import _extends from"@babel/runtime/helpers/extends";function _createForOfIteratorHelperLoose(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var o=0;return function(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}import{createCacheKey,getInvalidationPattern}from"./query-cache-utils";var QueryCacheManager=/*#__PURE__*/function(){// 5 minutes
2
+ function QueryCacheManager(maxCacheSize,maxCacheAge){if(maxCacheSize===void 0){maxCacheSize=100}if(maxCacheAge===void 0){maxCacheAge=5*60*1000}this.cache=new Map;this.maxCacheSize=100;this.maxCacheAge=5*60*1000;this.maxCacheSize=maxCacheSize;this.maxCacheAge=maxCacheAge}var _proto=QueryCacheManager.prototype;_proto.getCachedQuery=function getCachedQuery(componentId,interactionType,state){var key=createCacheKey(componentId,interactionType,state);var entry=this.cache.get(key);if(!entry){return null}var now=Date.now();if(now-entry.timestamp>this.maxCacheAge){this.cache["delete"](key);return null}return entry};_proto.setCachedQuery=function setCachedQuery(componentId,interactionType,state,entry){var key=createCacheKey(componentId,interactionType,state);this.cache.set(key,_extends({},entry,{timestamp:Date.now()}));if(this.cache.size>this.maxCacheSize){this.cleanupCache()}};_proto.invalidateComponent=function invalidateComponent(componentId){var pattern=getInvalidationPattern(componentId);for(var _iterator=_createForOfIteratorHelperLoose(this.cache.keys()),_step;!(_step=_iterator()).done;){var key=_step.value;if(pattern.test(key)){this.cache["delete"](key)}}};_proto.invalidateAll=function invalidateAll(){this.cache.clear()};_proto.isCached=function isCached(componentId,interactionType,state){return this.getCachedQuery(componentId,interactionType,state)!==null};_proto.cleanupCache=function cleanupCache(){var now=Date.now();for(var _iterator2=_createForOfIteratorHelperLoose(this.cache.entries()),_step2;!(_step2=_iterator2()).done;){var _step2$value=_step2.value,_key=_step2$value[0],entry=_step2$value[1];if(now-entry.timestamp>this.maxCacheAge){this.cache["delete"](_key)}}if(this.cache.size>this.maxCacheSize){var entries=Array.from(this.cache.entries());entries.sort(function(a,b){return a[1].timestamp-b[1].timestamp});var entriesToRemove=entries.slice(0,this.cache.size-this.maxCacheSize);for(var _iterator3=_createForOfIteratorHelperLoose(entriesToRemove),_step3;!(_step3=_iterator3()).done;){var _step3$value=_step3.value,key=_step3$value[0];this.cache["delete"](key)}}};_proto.getStats=function getStats(){return{maxAge:this.maxCacheAge,maxSize:this.maxCacheSize,size:this.cache.size}};return QueryCacheManager}();var globalCacheInstance=null;export function getGlobalQueryCache(){if(!globalCacheInstance){globalCacheInstance=new QueryCacheManager}return globalCacheInstance}export function resetGlobalQueryCache(){globalCacheInstance=null}export function configureGlobalQueryCache(maxCacheSize,maxCacheAge){if(maxCacheSize===void 0){maxCacheSize=100}if(maxCacheAge===void 0){maxCacheAge=5*60*1000}globalCacheInstance=new QueryCacheManager(maxCacheSize,maxCacheAge)}
4
3
  //# sourceMappingURL=query-cache-singleton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-cache-singleton.js","names":["createInteractionKey","QueryCacheManager","maxCacheSize","maxCacheAge","cache","Map","totalEntries","_proto","prototype","getCachedQuery","componentId","interactionType","state","componentCache","get","key","entry","now","Date","timestamp","size","setCachedQuery","set","isNewEntry","has","_extends","cleanupCache","invalidateComponent","invalidateAll","clear","isCached","allEntries","_iterator","_createForOfIteratorHelperLoose","entries","_step","done","_step$value","value","_iterator3","_step3","_step3$value","push","length","sort","a","b","entriesToRemove","slice","_iterator2","_step2","_step2$value","getTotalCacheSize","getStats","componentCount","maxAge","maxSize","globalCacheInstance","getGlobalQueryCache","resetGlobalQueryCache","configureGlobalQueryCache"],"sources":["../../../src/plugins/helpers/query-cache-singleton.ts"],"sourcesContent":["import {\n QueryCacheEntry,\n InteractionType,\n InteractionState,\n createInteractionKey\n} from './query-cache-utils';\n\nclass QueryCacheManager {\n private cache: Map<string, Map<string, QueryCacheEntry>> = new Map();\n private totalEntries = 0;\n private maxCacheSize = 100;\n private maxCacheAge: number = 5 * 60 * 1000; // 5 minutes\n\n constructor(maxCacheSize = 100, maxCacheAge = 5 * 60 * 1000) {\n this.maxCacheSize = maxCacheSize;\n this.maxCacheAge = maxCacheAge;\n }\n\n getCachedQuery(\n componentId: string,\n interactionType: InteractionType,\n state: InteractionState\n ): QueryCacheEntry | null {\n const componentCache = this.cache.get(componentId);\n \n if (!componentCache) {\n return null;\n }\n \n const key = createInteractionKey(interactionType, state);\n const entry = componentCache.get(key);\n \n if (!entry) {\n return null;\n }\n \n const now = Date.now();\n\n if (now - entry.timestamp > this.maxCacheAge) {\n componentCache.delete(key);\n this.totalEntries -= 1;\n \n if (componentCache.size === 0) {\n this.cache.delete(componentId);\n }\n\n return null;\n }\n \n return entry;\n }\n\n setCachedQuery(\n componentId: string,\n interactionType: InteractionType,\n state: InteractionState,\n entry: QueryCacheEntry\n ): void {\n let componentCache = this.cache.get(componentId);\n \n if (!componentCache) {\n componentCache = new Map();\n this.cache.set(componentId, componentCache);\n }\n \n const key = createInteractionKey(interactionType, state);\n const isNewEntry = !componentCache.has(key);\n\n componentCache.set(key, {\n ...entry,\n timestamp: Date.now(),\n });\n \n if (isNewEntry) {\n this.totalEntries += 1;\n }\n\n if (this.totalEntries > this.maxCacheSize) {\n this.cleanupCache();\n }\n }\n\n invalidateComponent(componentId: string): void {\n const componentCache = this.cache.get(componentId);\n\n if (componentCache) {\n this.totalEntries -= componentCache.size;\n this.cache.delete(componentId);\n }\n }\n\n invalidateAll(): void {\n this.cache.clear();\n this.totalEntries = 0;\n }\n\n isCached(\n componentId: string,\n interactionType: InteractionType,\n state: InteractionState\n ): boolean {\n return this.getCachedQuery(componentId, interactionType, state) !== null;\n }\n\n private cleanupCache(): void {\n const now = Date.now();\n const allEntries: Array<{ componentId: string; key: string; timestamp: number }> = [];\n \n for (const [componentId, componentCache] of this.cache.entries()) {\n for (const [key, entry] of componentCache.entries()) {\n if (now - entry.timestamp > this.maxCacheAge) {\n componentCache.delete(key);\n this.totalEntries -= 1;\n } else {\n allEntries.push({ componentId, key, timestamp: entry.timestamp });\n }\n }\n \n if (componentCache.size === 0) {\n this.cache.delete(componentId);\n }\n }\n \n if (allEntries.length > this.maxCacheSize) {\n allEntries.sort((a, b) => a.timestamp - b.timestamp);\n \n const entriesToRemove = allEntries.slice(0, allEntries.length - this.maxCacheSize);\n \n for (const { componentId, key } of entriesToRemove) {\n const componentCache = this.cache.get(componentId);\n\n if (componentCache) {\n componentCache.delete(key);\n this.totalEntries -= 1;\n \n // Remove empty component caches\n if (componentCache.size === 0) {\n this.cache.delete(componentId);\n }\n }\n }\n }\n }\n \n private getTotalCacheSize(): number {\n return this.totalEntries;\n }\n\n getStats(): { componentCount: number; maxAge: number; maxSize: number; size: number } {\n return {\n componentCount: this.cache.size,\n maxAge: this.maxCacheAge,\n maxSize: this.maxCacheSize,\n size: this.getTotalCacheSize(),\n };\n }\n}\n\nlet globalCacheInstance: QueryCacheManager | null = null;\n\nexport function getGlobalQueryCache(): QueryCacheManager {\n if (!globalCacheInstance) {\n globalCacheInstance = new QueryCacheManager();\n }\n\n return globalCacheInstance;\n}\n\nexport function resetGlobalQueryCache(): void {\n globalCacheInstance = null;\n}\n\nexport function configureGlobalQueryCache(maxCacheSize = 100, maxCacheAge = 5 * 60 * 1000): void {\n globalCacheInstance = new QueryCacheManager(maxCacheSize, maxCacheAge);\n}\n\n"],"mappings":"89BAAA,OAIEA,oBAAoB,KACf,qBAAqB,CAAC,GAEvB,CAAAC,iBAAiB,yBAIwB;AAE7C,SAAAA,kBAAYC,YAAY,CAAQC,WAAW,CAAkB,IAAjDD,YAAY,WAAZA,YAAY,CAAG,GAAG,IAAEC,WAAW,WAAXA,WAAW,CAAG,CAAC,CAAG,EAAE,CAAG,IAAI,MALnDC,KAAK,CAA8C,GAAI,CAAAC,GAAK,MAC5DC,YAAY,CAAG,CAAC,MAChBJ,YAAY,CAAG,GAAG,MAClBC,WAAW,CAAW,CAAC,CAAG,EAAE,CAAG,IAAI,CAGzC,IAAI,CAACD,YAAY,CAAGA,YAAY,CAChC,IAAI,CAACC,WAAW,CAAGA,WACrB,CAAC,IAAAI,MAAA,CAAAN,iBAAA,CAAAO,SA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G,EAAE,CAAG,IAAI,CACvFsD,mBAAmB,CAAG,GAAI,CAAAxD,iBAAiB,CAACC,YAAY,CAAEC,WAAW,CACvE","ignoreList":[]}
1
+ {"version":3,"file":"query-cache-singleton.js","names":["createCacheKey","getInvalidationPattern","QueryCacheManager","maxCacheSize","maxCacheAge","cache","Map","_proto","prototype","getCachedQuery","componentId","interactionType","state","key","entry","get","now","Date","timestamp","setCachedQuery","set","_extends","size","cleanupCache","invalidateComponent","pattern","_iterator","_createForOfIteratorHelperLoose","keys","_step","done","value","test","invalidateAll","clear","isCached","_iterator2","entries","_step2","_step2$value","Array","from","sort","a","b","entriesToRemove","slice","_iterator3","_step3","_step3$value","getStats","maxAge","maxSize","globalCacheInstance","getGlobalQueryCache","resetGlobalQueryCache","configureGlobalQueryCache"],"sources":["../../../src/plugins/helpers/query-cache-singleton.ts"],"sourcesContent":["import {\n QueryCacheEntry,\n InteractionType,\n InteractionState,\n createCacheKey,\n getInvalidationPattern\n} from './query-cache-utils';\n\nclass QueryCacheManager {\n private cache: Map<string, QueryCacheEntry> = new Map();\n private maxCacheSize = 100;\n private maxCacheAge: number = 5 * 60 * 1000; // 5 minutes\n\n constructor(maxCacheSize = 100, maxCacheAge = 5 * 60 * 1000) {\n this.maxCacheSize = maxCacheSize;\n this.maxCacheAge = maxCacheAge;\n }\n\n getCachedQuery(\n componentId: string,\n interactionType: InteractionType,\n state: InteractionState\n ): QueryCacheEntry | null {\n const key = createCacheKey(componentId, interactionType, state);\n const entry = this.cache.get(key);\n \n if (!entry) {\n return null;\n }\n \n const now = Date.now();\n\n if (now - entry.timestamp > this.maxCacheAge) {\n this.cache.delete(key);\n\n return null;\n }\n \n return entry;\n }\n\n setCachedQuery(\n componentId: string,\n interactionType: InteractionType,\n state: InteractionState,\n entry: QueryCacheEntry\n ): void {\n const key = createCacheKey(componentId, interactionType, state);\n this.cache.set(key, {\n ...entry,\n timestamp: Date.now(),\n });\n \n if (this.cache.size > this.maxCacheSize) {\n this.cleanupCache();\n }\n }\n\n invalidateComponent(componentId: string): void {\n const pattern = getInvalidationPattern(componentId);\n \n for (const key of this.cache.keys()) {\n if (pattern.test(key)) {\n this.cache.delete(key);\n }\n }\n }\n\n invalidateAll(): void {\n this.cache.clear();\n }\n\n isCached(\n componentId: string,\n interactionType: InteractionType,\n state: InteractionState\n ): boolean {\n return this.getCachedQuery(componentId, interactionType, state) !== null;\n }\n\n private cleanupCache(): void {\n const now = Date.now();\n \n for (const [key, entry] of this.cache.entries()) {\n if (now - entry.timestamp > this.maxCacheAge) {\n this.cache.delete(key);\n }\n }\n \n if (this.cache.size > this.maxCacheSize) {\n const entries = Array.from(this.cache.entries());\n entries.sort((a, b) => a[1].timestamp - b[1].timestamp);\n \n const entriesToRemove = entries.slice(0, this.cache.size - this.maxCacheSize);\n\n for (const [key] of entriesToRemove) {\n this.cache.delete(key);\n }\n }\n }\n\n getStats(): { maxAge: number; maxSize: number; size: number } {\n return {\n maxAge: this.maxCacheAge,\n maxSize: this.maxCacheSize,\n size: this.cache.size,\n };\n }\n}\n\nlet globalCacheInstance: QueryCacheManager | null = null;\n\nexport function getGlobalQueryCache(): QueryCacheManager {\n if (!globalCacheInstance) {\n globalCacheInstance = new QueryCacheManager();\n }\n\n return globalCacheInstance;\n}\n\nexport function resetGlobalQueryCache(): void {\n globalCacheInstance = null;\n}\n\nexport function configureGlobalQueryCache(maxCacheSize = 100, maxCacheAge = 5 * 60 * 1000): void {\n globalCacheInstance = new QueryCacheManager(maxCacheSize, maxCacheAge);\n}\n\n"],"mappings":"89BAAA,OAIEA,cAAc,CACdC,sBAAsB,KACjB,qBAAqB,CAAC,GAEvB,CAAAC,iBAAiB,yBAGwB;AAE7C,SAAAA,kBAAYC,YAAY,CAAQC,WAAW,CAAkB,IAAjDD,YAAY,WAAZA,YAAY,CAAG,GAAG,IAAEC,WAAW,WAAXA,WAAW,CAAG,CAAC,CAAG,EAAE,CAAG,IAAI,MAJnDC,KAAK,CAAiC,GAAI,CAAAC,GAAK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O,SAAS,CAAAG,yBAAyBA,CAACrD,YAAY,CAAQC,WAAW,CAAwB,IAAvDD,YAAY,WAAZA,YAAY,CAAG,GAAG,IAAEC,WAAW,WAAXA,WAAW,CAAG,CAAC,CAAG,EAAE,CAAG,IAAI,CACvFiD,mBAAmB,CAAG,GAAI,CAAAnD,iBAAiB,CAACC,YAAY,CAAEC,WAAW,CACvE","ignoreList":[]}
@@ -43,6 +43,6 @@ export type CacheKey = {
43
43
  state: InteractionState;
44
44
  };
45
45
  export declare function createCacheKey(componentId: string, interactionType: InteractionType, interactionState: InteractionState): string;
46
- export declare function createInteractionKey(interactionType: InteractionType, interactionState: InteractionState): string;
47
46
  export declare function extractInteractionState(componentProps: Record<string, unknown>): InteractionState;
48
47
  export declare function areStatesEqual(state1: InteractionState, state2: InteractionState): boolean;
48
+ export declare function getInvalidationPattern(componentId: string): RegExp;
@@ -1,6 +1,3 @@
1
- function _createForOfIteratorHelperLoose(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var o=0;return function(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}export function createCacheKey(componentId,interactionType,interactionState){var sortedState=sortObjectKeys(interactionState);try{var stateString=JSON.stringify(sortedState);return componentId+"::"+interactionType+"::"+stateString}catch(error){// eslint-disable-next-line no-console
2
- console.warn("Failed to serialize interaction state:",error);return componentId+"::"+interactionType+"::"+Date.now()+"::"+Math.random()}}export function createInteractionKey(interactionType,interactionState){var sortedState=sortObjectKeys(interactionState);try{var stateString=JSON.stringify(sortedState);return interactionType+"::"+stateString}catch(error){// eslint-disable-next-line no-console
3
- console.warn("Failed to serialize interaction state:",error);return interactionType+"::"+Date.now()+"::"+Math.random()}}function sortObjectKeys(obj){if(obj===null||obj===undefined){return obj}if(Array.isArray(obj)){return obj.map(function(item){return sortObjectKeys(item)})}if(typeof obj==="object"){var sorted={};var keys=Object.keys(obj).sort();for(var _iterator=_createForOfIteratorHelperLoose(keys),_step;!(_step=_iterator()).done;){var _key=_step.value;sorted[_key]=sortObjectKeys(obj[_key])}return sorted}return obj}export function extractInteractionState(componentProps){var state={};if("pagination"in componentProps&&typeof componentProps.pagination==="object"&&componentProps.pagination){var pagination=componentProps.pagination;if("pageNumber"in pagination&&typeof pagination.pageNumber==="number"){state.pageNumber=pagination.pageNumber}if("pageSize"in pagination&&typeof pagination.pageSize==="number"){state.pageSize=pagination.pageSize}}if("sortColumn"in componentProps){state.sortColumn=componentProps.sortColumn}if("sortDirection"in componentProps){state.sortDirection=componentProps.sortDirection}if("filters"in componentProps&&typeof componentProps.filters==="object"){state.filters=componentProps.filters}if("value"in componentProps){state.filterValue=componentProps.value}if("searchQuery"in componentProps&&typeof componentProps.searchQuery==="string"){state.searchQuery=componentProps.searchQuery}if("searchValue"in componentProps&&typeof componentProps.searchValue==="string"){state.searchValue=componentProps.searchValue}if("data"in componentProps){var data=componentProps.data;if(Array.isArray(data)&&data.length>0){state.dataLength=data.length;var firstRow=data[0];var lastRow=data[data.length-1];if(firstRow&&typeof firstRow==="object"){try{state.dataFingerprint=JSON.stringify({firstId:firstRow.id||Object.values(firstRow)[0],lastId:lastRow&&typeof lastRow==="object"?lastRow.id||Object.values(lastRow)[0]:null,length:data.length})}catch(error){// eslint-disable-next-line no-console
4
- console.warn("Failed to serialize data fingerprint:",error);state.dataFingerprint="fallback_"+data.length+"_"+Date.now()}}}else if(data&&typeof data==="object"&&data.name==="__peak_placeholder"){state.dataFingerprint="__peak_placeholder"}else{state.dataFingerprint="empty"}}if("bodyContent"in componentProps){state.bodyContent=componentProps.bodyContent}if("headerContent"in componentProps){state.headerContent=componentProps.headerContent}if("footerContent"in componentProps){state.footerContent=componentProps.footerContent}if("chartData"in componentProps){var chartData=componentProps.chartData;if(Array.isArray(chartData)){state.chartDataLength=chartData.length;try{state.chartDataFingerprint=JSON.stringify(chartData)}catch(error){// eslint-disable-next-line no-console
5
- console.warn("Failed to serialize chart data fingerprint:",error);state.chartDataFingerprint="fallback_"+chartData.length+"_"+Date.now()}}}if("summaryText"in componentProps){state.summaryText=componentProps.summaryText}if("error"in componentProps){state.error=componentProps.error}if("isMissing"in componentProps){state.isMissing=componentProps.isMissing}return state}export function areStatesEqual(state1,state2){return createCacheKey("test","semanticLayerQuery",state1)===createCacheKey("test","semanticLayerQuery",state2)}
1
+ function _createForOfIteratorHelperLoose(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var o=0;return function(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}export function createCacheKey(componentId,interactionType,interactionState){var sortedState=sortObjectKeys(interactionState);var stateString=JSON.stringify(sortedState);return componentId+"::"+interactionType+"::"+stateString}function sortObjectKeys(obj){if(obj===null||obj===undefined){return obj}if(Array.isArray(obj)){return obj.map(function(item){return sortObjectKeys(item)})}if(typeof obj==="object"){var sorted={};var keys=Object.keys(obj).sort();for(var _iterator=_createForOfIteratorHelperLoose(keys),_step;!(_step=_iterator()).done;){var _key=_step.value;sorted[_key]=sortObjectKeys(obj[_key])}return sorted}return obj}export function extractInteractionState(componentProps){var state={};if("pagination"in componentProps&&typeof componentProps.pagination==="object"&&componentProps.pagination){var pagination=componentProps.pagination;if("pageNumber"in pagination&&typeof pagination.pageNumber==="number"){state.pageNumber=pagination.pageNumber}if("pageSize"in pagination&&typeof pagination.pageSize==="number"){state.pageSize=pagination.pageSize}}if("sortColumn"in componentProps){state.sortColumn=componentProps.sortColumn}if("sortDirection"in componentProps){state.sortDirection=componentProps.sortDirection}if("filters"in componentProps&&typeof componentProps.filters==="object"){state.filters=componentProps.filters}if("value"in componentProps){state.filterValue=componentProps.value}if("searchQuery"in componentProps&&typeof componentProps.searchQuery==="string"){state.searchQuery=componentProps.searchQuery}if("searchValue"in componentProps&&typeof componentProps.searchValue==="string"){state.searchValue=componentProps.searchValue}if("data"in componentProps){var data=componentProps.data;if(Array.isArray(data)&&data.length>0){state.dataLength=data.length;var firstRow=data[0];var lastRow=data[data.length-1];if(firstRow&&typeof firstRow==="object"){state.dataFingerprint=JSON.stringify({firstId:firstRow.id||Object.values(firstRow)[0],lastId:lastRow&&typeof lastRow==="object"?lastRow.id||Object.values(lastRow)[0]:null,length:data.length})}}else if(data&&typeof data==="object"&&data.name==="__peak_placeholder"){state.dataFingerprint="__peak_placeholder"}else{state.dataFingerprint="empty"}}if("bodyContent"in componentProps){state.bodyContent=componentProps.bodyContent}if("headerContent"in componentProps){state.headerContent=componentProps.headerContent}if("footerContent"in componentProps){state.footerContent=componentProps.footerContent}if("chartData"in componentProps){var chartData=componentProps.chartData;if(Array.isArray(chartData)){state.chartDataLength=chartData.length;state.chartDataFingerprint=JSON.stringify(chartData)}}if("summaryText"in componentProps){state.summaryText=componentProps.summaryText}if("error"in componentProps){state.error=componentProps.error}if("isMissing"in componentProps){state.isMissing=componentProps.isMissing}return state}export function areStatesEqual(state1,state2){return createCacheKey("test","semanticLayerQuery",state1)===createCacheKey("test","semanticLayerQuery",state2)}export function getInvalidationPattern(componentId){var escapedId=componentId.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");// eslint-disable-next-line security/detect-non-literal-regexp
2
+ return new RegExp("^"+escapedId+"::")}
6
3
  //# sourceMappingURL=query-cache-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-cache-utils.js","names":["createCacheKey","componentId","interactionType","interactionState","sortedState","sortObjectKeys","stateString","JSON","stringify","error","console","warn","Date","now","Math","random","createInteractionKey","obj","undefined","Array","isArray","map","item","sorted","keys","Object","sort","_iterator","_createForOfIteratorHelperLoose","_step","done","key","value","extractInteractionState","componentProps","state","pagination","pageNumber","pageSize","sortColumn","sortDirection","filters","filterValue","searchQuery","searchValue","data","length","dataLength","firstRow","lastRow","dataFingerprint","firstId","id","values","lastId","name","bodyContent","headerContent","footerContent","chartData","chartDataLength","chartDataFingerprint","summaryText","isMissing","areStatesEqual","state1","state2"],"sources":["../../../src/plugins/helpers/query-cache-utils.ts"],"sourcesContent":["\nexport type InteractionType = 'semanticLayerQuery' | 'tableButton';\n\nexport type InteractionState = {\n [key: string]: unknown;\n bodyContent?: unknown;\n chartData?: unknown;\n chartDataFingerprint?: string;\n chartDataLength?: number;\n dataFingerprint?: string;\n dataLength?: number;\n error?: unknown;\n filterValue?: unknown;\n filters?: Record<string, unknown>;\n footerContent?: unknown;\n headerContent?: unknown;\n isMissing?: unknown;\n pageNumber?: number;\n pageSize?: number;\n searchQuery?: string;\n searchValue?: string;\n sortColumn?: string | null;\n sortDirection?: 'asc' | 'desc' | null;\n summaryText?: unknown;\n};\n\nexport type QueryCacheEntry = {\n queryHeadings: string[];\n sqlQuery: string | string[];\n tableButtonExplanations: Array<{\n action: string;\n buttonClassName?: string;\n buttonStyle?: Record<string, unknown>;\n explanation: string;\n formFields?: Record<string, unknown>;\n jsonBody?: unknown;\n operationDescription?: string;\n operationSummary?: string;\n requestUrl?: string;\n }>;\n timestamp: number;\n};\n\nexport type CacheKey = {\n componentId: string;\n interactionType: InteractionType;\n state: InteractionState;\n};\n\nexport function createCacheKey(\n componentId: string,\n interactionType: InteractionType,\n interactionState: InteractionState\n): string {\n const sortedState = sortObjectKeys(interactionState);\n \n try {\n const stateString = JSON.stringify(sortedState);\n \n return `${componentId}::${interactionType}::${stateString}`;\n } catch (error) {\n // eslint-disable-next-line no-console\n console.warn('Failed to serialize interaction state:', error);\n \n return `${componentId}::${interactionType}::${Date.now()}::${Math.random()}`;\n }\n}\n\nexport function createInteractionKey(\n interactionType: InteractionType,\n interactionState: InteractionState\n): string {\n const sortedState = sortObjectKeys(interactionState);\n \n try {\n const stateString = JSON.stringify(sortedState);\n \n return `${interactionType}::${stateString}`;\n } catch (error) {\n // eslint-disable-next-line no-console\n console.warn('Failed to serialize interaction state:', error);\n \n return `${interactionType}::${Date.now()}::${Math.random()}`;\n }\n}\n\nfunction sortObjectKeys(obj: unknown): unknown {\n if (obj === null || obj === undefined) {\n return obj;\n }\n \n if (Array.isArray(obj)) {\n return obj.map(item => sortObjectKeys(item));\n }\n \n if (typeof obj === 'object') {\n const sorted: Record<string, unknown> = {};\n const keys = Object.keys(obj as Record<string, unknown>).sort();\n \n for (const key of keys) {\n sorted[key] = sortObjectKeys((obj as Record<string, unknown>)[key]);\n }\n \n return sorted;\n }\n \n return obj;\n}\n\nexport function extractInteractionState(componentProps: Record<string, unknown>): InteractionState {\n const state: InteractionState = {};\n \n if ('pagination' in componentProps && typeof componentProps.pagination === 'object' && componentProps.pagination) {\n const pagination = componentProps.pagination as Record<string, unknown>;\n\n if ('pageNumber' in pagination && typeof pagination.pageNumber === 'number') {\n state.pageNumber = pagination.pageNumber;\n }\n\n if ('pageSize' in pagination && typeof pagination.pageSize === 'number') {\n state.pageSize = pagination.pageSize;\n }\n }\n \n if ('sortColumn' in componentProps) {\n state.sortColumn = componentProps.sortColumn as string | null;\n }\n \n if ('sortDirection' in componentProps) {\n state.sortDirection = componentProps.sortDirection as 'asc' | 'desc' | null;\n }\n \n if ('filters' in componentProps && typeof componentProps.filters === 'object') {\n state.filters = componentProps.filters as Record<string, unknown>;\n }\n \n if ('value' in componentProps) {\n state.filterValue = componentProps.value as unknown;\n }\n \n if ('searchQuery' in componentProps && typeof componentProps.searchQuery === 'string') {\n state.searchQuery = componentProps.searchQuery;\n }\n \n if ('searchValue' in componentProps && typeof componentProps.searchValue === 'string') {\n state.searchValue = componentProps.searchValue;\n }\n\n if ('data' in componentProps) {\n const data = componentProps.data;\n \n if (Array.isArray(data) && data.length > 0) {\n state.dataLength = data.length;\n const firstRow = data[0];\n const lastRow = data[data.length - 1];\n \n if (firstRow && typeof firstRow === 'object') {\n try {\n state.dataFingerprint = JSON.stringify({\n firstId: (firstRow as Record<string, unknown>).id || Object.values(firstRow)[0],\n lastId: lastRow && typeof lastRow === 'object' \n ? ((lastRow as Record<string, unknown>).id || Object.values(lastRow)[0])\n : null,\n length: data.length\n });\n } catch (error) {\n // eslint-disable-next-line no-console\n console.warn('Failed to serialize data fingerprint:', error);\n state.dataFingerprint = `fallback_${data.length}_${Date.now()}`;\n }\n }\n } else if (data && typeof data === 'object' && (data as Record<string, unknown>).name === '__peak_placeholder') {\n state.dataFingerprint = '__peak_placeholder';\n } else {\n state.dataFingerprint = 'empty';\n }\n }\n \n if ('bodyContent' in componentProps) {\n state.bodyContent = componentProps.bodyContent as unknown;\n }\n \n if ('headerContent' in componentProps) {\n state.headerContent = componentProps.headerContent as unknown;\n }\n \n if ('footerContent' in componentProps) {\n state.footerContent = componentProps.footerContent as unknown;\n }\n \n if ('chartData' in componentProps) {\n const chartData = componentProps.chartData;\n\n if (Array.isArray(chartData)) {\n state.chartDataLength = chartData.length;\n\n try {\n state.chartDataFingerprint = JSON.stringify(chartData);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.warn('Failed to serialize chart data fingerprint:', error);\n state.chartDataFingerprint = `fallback_${chartData.length}_${Date.now()}`;\n }\n }\n }\n \n if ('summaryText' in componentProps) {\n state.summaryText = componentProps.summaryText as unknown;\n }\n \n if ('error' in componentProps) {\n state.error = componentProps.error as unknown;\n }\n \n if ('isMissing' in componentProps) {\n state.isMissing = componentProps.isMissing as unknown;\n }\n \n return state;\n}\n\nexport function areStatesEqual(state1: InteractionState, state2: InteractionState): boolean {\n return createCacheKey('test', 'semanticLayerQuery', state1) === \n createCacheKey('test', 'semanticLayerQuery', state2);\n}\n\n"],"mappings":"y6BAiDA,MAAO,SAAS,CAAAA,cAAcA,CAC5BC,WAAmB,CACnBC,eAAgC,CAChCC,gBAAkC,CAC1B,CACR,GAAM,CAAAC,WAAW,CAAGC,cAAc,CAACF,gBAAgB,CAAC,CAEpD,GAAI,CACF,GAAM,CAAAG,WAAW,CAAGC,IAAI,CAACC,SAAS,CAACJ,WAAW,CAAC,CAE/C,MAAU,CAAAH,WAAW,MAAKC,eAAe,MAAKI,WAChD,CAAE,MAAOG,KAAK,CAAE,CACd;AACAC,OAAO,CAACC,IAAI,CAAC,wCAAwC,CAAEF,KAAK,CAAC,CAE7D,MAAU,CAAAR,WAAW,MAAKC,eAAe,MAAKU,IAAI,CAACC,GAAG,CAAC,CAAC,MAAKC,IAAI,CAACC,MAAM,CAAC,CAC3E,CACF,CAEA,MAAO,SAAS,CAAAC,oBAAoBA,CAClCd,eAAgC,CAChCC,gBAAkC,CAC1B,CACR,GAAM,CAAAC,WAAW,CAAGC,cAAc,CAACF,gBAAgB,CAAC,CAEpD,GAAI,CACF,GAAM,CAAAG,WAAW,CAAGC,IAAI,CAACC,SAAS,CAACJ,WAAW,CAAC,CAE/C,MAAU,CAA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Aa,CAAGvB,cAAc,CAACuB,aACvC,CAEA,GAAI,eAAe,EAAI,CAAAvB,cAAc,CAAE,CACrCC,KAAK,CAACuB,aAAa,CAAGxB,cAAc,CAACwB,aACvC,CAEA,GAAI,WAAW,EAAI,CAAAxB,cAAc,CAAE,CACjC,GAAM,CAAAyB,SAAS,CAAGzB,cAAc,CAACyB,SAAS,CAE1C,GAAIxC,KAAK,CAACC,OAAO,CAACuC,SAAS,CAAC,CAAE,CAC5BxB,KAAK,CAACyB,eAAe,CAAGD,SAAS,CAACb,MAAM,CAExC,GAAI,CACFX,KAAK,CAAC0B,oBAAoB,CAAGtD,IAAI,CAACC,SAAS,CAACmD,SAAS,CACvD,CAAE,MAAOlD,KAAK,CAAE,CACd;AACAC,OAAO,CAACC,IAAI,CAAC,6CAA6C,CAAEF,KAAK,CAAC,CAClE0B,KAAK,CAAC0B,oBAAoB,aAAeF,SAAS,CAACb,MAAM,KAAIlC,IAAI,CAACC,GAAG,CAAC,CACxE,CACF,CACF,CAEA,GAAI,aAAa,EAAI,CAAAqB,cAAc,CAAE,CACnCC,KAAK,CAAC2B,WAAW,CAAG5B,cAAc,CAAC4B,WACrC,CAEA,GAAI,OAAO,EAAI,CAAA5B,cAAc,CAAE,CAC7BC,KAAK,CAAC1B,KAAK,CAAGyB,cAAc,CAACzB,KAC/B,CAEA,GAAI,WAAW,EAAI,CAAAyB,cAAc,CAAE,CACjCC,KAAK,CAAC4B,SAAS,CAAG7B,cAAc,CAAC6B,SACnC,CAEA,MAAO,CAAA5B,KACT,CAEA,MAAO,SAAS,CAAA6B,cAAcA,CAACC,MAAwB,CAAEC,MAAwB,CAAW,CAC1F,MAAO,CAAAlE,cAAc,CAAC,MAAM,CAAE,oBAAoB,CAAEiE,MAAM,CAAC,GACpDjE,cAAc,CAAC,MAAM,CAAE,oBAAoB,CAAEkE,MAAM,CAC5D","ignoreList":[]}
1
+ {"version":3,"file":"query-cache-utils.js","names":["createCacheKey","componentId","interactionType","interactionState","sortedState","sortObjectKeys","stateString","JSON","stringify","obj","undefined","Array","isArray","map","item","sorted","keys","Object","sort","_iterator","_createForOfIteratorHelperLoose","_step","done","key","value","extractInteractionState","componentProps","state","pagination","pageNumber","pageSize","sortColumn","sortDirection","filters","filterValue","searchQuery","searchValue","data","length","dataLength","firstRow","lastRow","dataFingerprint","firstId","id","values","lastId","name","bodyContent","headerContent","footerContent","chartData","chartDataLength","chartDataFingerprint","summaryText","error","isMissing","areStatesEqual","state1","state2","getInvalidationPattern","escapedId","replace","RegExp"],"sources":["../../../src/plugins/helpers/query-cache-utils.ts"],"sourcesContent":["\nexport type InteractionType = 'semanticLayerQuery' | 'tableButton';\n\nexport type InteractionState = {\n [key: string]: unknown;\n bodyContent?: unknown;\n chartData?: unknown;\n chartDataFingerprint?: string;\n chartDataLength?: number;\n dataFingerprint?: string;\n dataLength?: number;\n error?: unknown;\n filterValue?: unknown;\n filters?: Record<string, unknown>;\n footerContent?: unknown;\n headerContent?: unknown;\n isMissing?: unknown;\n pageNumber?: number;\n pageSize?: number;\n searchQuery?: string;\n searchValue?: string;\n sortColumn?: string | null;\n sortDirection?: 'asc' | 'desc' | null;\n summaryText?: unknown;\n};\n\nexport type QueryCacheEntry = {\n queryHeadings: string[];\n sqlQuery: string | string[];\n tableButtonExplanations: Array<{\n action: string;\n buttonClassName?: string;\n buttonStyle?: Record<string, unknown>;\n explanation: string;\n formFields?: Record<string, unknown>;\n jsonBody?: unknown;\n operationDescription?: string;\n operationSummary?: string;\n requestUrl?: string;\n }>;\n timestamp: number;\n};\n\nexport type CacheKey = {\n componentId: string;\n interactionType: InteractionType;\n state: InteractionState;\n};\n\nexport function createCacheKey(\n componentId: string,\n interactionType: InteractionType,\n interactionState: InteractionState\n): string {\n const sortedState = sortObjectKeys(interactionState);\n \n const stateString = JSON.stringify(sortedState);\n \n return `${componentId}::${interactionType}::${stateString}`;\n}\n\nfunction sortObjectKeys(obj: unknown): unknown {\n if (obj === null || obj === undefined) {\n return obj;\n }\n \n if (Array.isArray(obj)) {\n return obj.map(item => sortObjectKeys(item));\n }\n \n if (typeof obj === 'object') {\n const sorted: Record<string, unknown> = {};\n const keys = Object.keys(obj as Record<string, unknown>).sort();\n \n for (const key of keys) {\n sorted[key] = sortObjectKeys((obj as Record<string, unknown>)[key]);\n }\n \n return sorted;\n }\n \n return obj;\n}\n\nexport function extractInteractionState(componentProps: Record<string, unknown>): InteractionState {\n const state: InteractionState = {};\n \n if ('pagination' in componentProps && typeof componentProps.pagination === 'object' && componentProps.pagination) {\n const pagination = componentProps.pagination as Record<string, unknown>;\n\n if ('pageNumber' in pagination && typeof pagination.pageNumber === 'number') {\n state.pageNumber = pagination.pageNumber;\n }\n\n if ('pageSize' in pagination && typeof pagination.pageSize === 'number') {\n state.pageSize = pagination.pageSize;\n }\n }\n \n if ('sortColumn' in componentProps) {\n state.sortColumn = componentProps.sortColumn as string | null;\n }\n \n if ('sortDirection' in componentProps) {\n state.sortDirection = componentProps.sortDirection as 'asc' | 'desc' | null;\n }\n \n if ('filters' in componentProps && typeof componentProps.filters === 'object') {\n state.filters = componentProps.filters as Record<string, unknown>;\n }\n \n if ('value' in componentProps) {\n state.filterValue = componentProps.value as unknown;\n }\n \n if ('searchQuery' in componentProps && typeof componentProps.searchQuery === 'string') {\n state.searchQuery = componentProps.searchQuery;\n }\n \n if ('searchValue' in componentProps && typeof componentProps.searchValue === 'string') {\n state.searchValue = componentProps.searchValue;\n }\n\n if ('data' in componentProps) {\n const data = componentProps.data;\n \n if (Array.isArray(data) && data.length > 0) {\n state.dataLength = data.length;\n const firstRow = data[0];\n const lastRow = data[data.length - 1];\n \n if (firstRow && typeof firstRow === 'object') {\n state.dataFingerprint = JSON.stringify({\n firstId: (firstRow as Record<string, unknown>).id || Object.values(firstRow)[0],\n lastId: lastRow && typeof lastRow === 'object' \n ? ((lastRow as Record<string, unknown>).id || Object.values(lastRow)[0])\n : null,\n length: data.length\n });\n }\n } else if (data && typeof data === 'object' && (data as Record<string, unknown>).name === '__peak_placeholder') {\n state.dataFingerprint = '__peak_placeholder';\n } else {\n state.dataFingerprint = 'empty';\n }\n }\n \n if ('bodyContent' in componentProps) {\n state.bodyContent = componentProps.bodyContent as unknown;\n }\n \n if ('headerContent' in componentProps) {\n state.headerContent = componentProps.headerContent as unknown;\n }\n \n if ('footerContent' in componentProps) {\n state.footerContent = componentProps.footerContent as unknown;\n }\n \n if ('chartData' in componentProps) {\n const chartData = componentProps.chartData;\n\n if (Array.isArray(chartData)) {\n state.chartDataLength = chartData.length;\n state.chartDataFingerprint = JSON.stringify(chartData);\n }\n }\n \n if ('summaryText' in componentProps) {\n state.summaryText = componentProps.summaryText as unknown;\n }\n \n if ('error' in componentProps) {\n state.error = componentProps.error as unknown;\n }\n \n if ('isMissing' in componentProps) {\n state.isMissing = componentProps.isMissing as unknown;\n }\n \n return state;\n}\n\nexport function areStatesEqual(state1: InteractionState, state2: InteractionState): boolean {\n return createCacheKey('test', 'semanticLayerQuery', state1) === \n createCacheKey('test', 'semanticLayerQuery', state2);\n}\n\nexport function getInvalidationPattern(componentId: string): RegExp {\n const escapedId = componentId.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n // eslint-disable-next-line security/detect-non-literal-regexp\n return new RegExp(`^${escapedId}::`);\n}\n\n"],"mappings":"y6BAiDA,MAAO,SAAS,CAAAA,cAAcA,CAC5BC,WAAmB,CACnBC,eAAgC,CAChCC,gBAAkC,CAC1B,CACR,GAAM,CAAAC,WAAW,CAAGC,cAAc,CAACF,gBAAgB,CAAC,CAEpD,GAAM,CAAAG,WAAW,CAAGC,IAAI,CAACC,SAAS,CAACJ,WAAW,CAAC,CAE/C,MAAU,CAAAH,WAAW,MAAKC,eAAe,MAAKI,WAChD,CAEA,QAAS,CAAAD,cAAcA,CAACI,GAAY,CAAW,CAC7C,GAAIA,GAAG,GAAK,IAAI,EAAIA,GAAG,GAAKC,SAAS,CAAE,CACrC,MAAO,CAAAD,GACT,CAEA,GAAIE,KAAK,CAACC,OA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AK,CAAC4B,KAAK,CAAG7B,cAAc,CAAC6B,KAC/B,CAEA,GAAI,WAAW,EAAI,CAAA7B,cAAc,CAAE,CACjCC,KAAK,CAAC6B,SAAS,CAAG9B,cAAc,CAAC8B,SACnC,CAEA,MAAO,CAAA7B,KACT,CAEA,MAAO,SAAS,CAAA8B,cAAcA,CAACC,MAAwB,CAAEC,MAAwB,CAAW,CAC1F,MAAO,CAAA3D,cAAc,CAAC,MAAM,CAAE,oBAAoB,CAAE0D,MAAM,CAAC,GACpD1D,cAAc,CAAC,MAAM,CAAE,oBAAoB,CAAE2D,MAAM,CAC5D,CAEA,MAAO,SAAS,CAAAC,sBAAsBA,CAAC3D,WAAmB,CAAU,CAClE,GAAM,CAAA4D,SAAS,CAAG5D,WAAW,CAAC6D,OAAO,CAAC,qBAAqB,CAAE,MAAM,CAAC,CAEpE;AACA,MAAO,IAAI,CAAAC,MAAM,KAAKF,SAAS,KAAI,CACrC","ignoreList":[]}
@@ -3,8 +3,13 @@ import*as domutil from"recharts/lib/util/DOMUtils";import{TooltipButton}from"../
3
3
  // REMEMBER TO UDPATE THIS WHEN recharts IS UPGRADED
4
4
  // @ts-ignore
5
5
  import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";domutil.getOffset=function(el){var html=el.ownerDocument.documentElement;var box={top:0,left:0};if(typeof el.getBoundingClientRect!=="undefined"){box=el.getBoundingClientRect()}var iframe=document.querySelector(".gjs-frame");var iframeWindow=iframe==null?void 0:iframe.contentWindow;return{top:box.top+iframeWindow.pageYOffset-html.clientTop,left:box.left+iframeWindow.pageXOffset-html.clientLeft}};var baseColors=[[theme.colors.Blue_100,theme.colors.Blue_30],[theme.colors.Purpley_100,theme.colors.Purpley_30],[theme.colors.Light_Bluish_Green,"#06601b"],[theme.colors.Wild_Strawberry,"#4d001c"]];var iconMap={TrendingUp:/*#__PURE__*/_jsx(TrendingUp,{}),TrendingDown:/*#__PURE__*/_jsx(TrendingDown,{}),ShoppingCart:/*#__PURE__*/_jsx(ShoppingCart,{}),Equalizer:/*#__PURE__*/_jsx(ChartBarBig,{}),Style:/*#__PURE__*/_jsx(Tag,{}),Place:/*#__PURE__*/_jsx(MapPin,{})};function getIconFromString(iconString){if(!iconString){return null}if(iconMap[iconString]){return iconMap[iconString]}var lowerIconString=iconString.toLowerCase();var matchingKey=Object.keys(iconMap).find(function(key){return key.toLowerCase()===lowerIconString});if(matchingKey){return iconMap[matchingKey]}return null}function getNColors(n){var colors=[];var safeBaseColors=Array.isArray(baseColors)?baseColors:[];for(var _iterator=_createForOfIteratorHelperLoose(safeBaseColors),_step;!(_step=_iterator()).done;){var baseColor=_step.value;// eslint-disable-next-line import/no-named-as-default-member
6
- colors.push(chroma.scale(baseColor).mode("lab").colors(n))}function getOneColor(existing){var color=null;do{var base=colors[Math.floor(Math.random()*colors.length)];var selectedColorIndex=Math.floor(Math.random()*base.length);color=base[selectedColorIndex]}while(existing.includes(color));return color}var selectedColors=[];for(var i=0;i<n;i++){selectedColors.push(getOneColor(selectedColors))}return selectedColors}/* TODO: Loader remains */export function renderActionCard(props){var gjsModel=props.gjsModel,rest=_objectWithoutPropertiesLoose(props,_excluded);var _useState=useState(_extends({},filterPlaceholders(gjsModel.get("componentProps")),filterPlaceholders(props))),allData=_useState[0],setAllData=_useState[1];var _allData$headerConten=allData.headerContent,headerContent=_allData$headerConten===void 0?"Default action card title":_allData$headerConten,icon=allData.icon,_allData$bodyContent=allData.bodyContent,bodyContent=_allData$bodyContent===void 0?"Default body content. Click to edit.":_allData$bodyContent;var _useState2=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState2[0],setAttributes=_useState2[1];useEffect(function(){gjsModel.on("change:componentProps",function(){setAllData(function(prevData){return _extends({},prevData,filterPlaceholders(gjsModel.get("componentProps")))})})},[]);useEffect(function(){gjsModel.on("change:attributes",function(){setAttributes(_extends({},gjsModel.get("attributes")))})},[]);var defaultClasses="text-black p-4 rounded-lg shadow border flex flex-col h-full";return/*#__PURE__*/_jsx(Card,_extends({className:defaultClasses+" relative",style:{backgroundColor:"#f9f9fe"},isEditable:false,contentEditable:false},rest,{children:/*#__PURE__*/_jsx(CardContent,{className:"p-0",isEditable:false,contentEditable:false,children:/*#__PURE__*/_jsx("div",{className:"px-4 py-3",children:/*#__PURE__*/_jsxs("div",{className:"flex items-start flex-col",children:[/*#__PURE__*/_jsxs("div",{className:"flex items-center justify-between w-full",children:[/*#__PURE__*/_jsx("div",{className:"text-xl font-semibold",children:headerContent}),/*#__PURE__*/_jsx("div",{className:"text-5xl ml-2 flex items-center","aria-hidden":"true",children:getIconFromString(icon)})]}),/*#__PURE__*/_jsx("div",{className:"w-full mt-1",children:attributes.error||allData.error||attributes.isMissing||allData.isMissing||!bodyContent?/*#__PURE__*/_jsxs("span",{className:"flex flex-row items-center px-3 py-2",children:[/*#__PURE__*/_jsx(CircleAlert,{className:"w-3 h-3 text-gray-400 mr-1"}),/*#__PURE__*/_jsx("p",{className:"text-sm text-gray-500 max-w-md text-center",children:"No data available for given filters"})]}):/*#__PURE__*/_jsx("div",{className:"text-base leading-relaxed",children:bodyContent})})]})})})}))}export function renderCard(props){var _attributes$error,_attributes$isMissing;var _props$isEditable=props.isEditable,isEditable=_props$isEditable===void 0?false:_props$isEditable,gjsModel=props.gjsModel,_props$performInterac=props.performInteraction,performInteraction=_props$performInterac===void 0?function(){return Promise.resolve({})}:_props$performInterac,rest=_objectWithoutPropertiesLoose(props,_excluded2);var _useState3=useState(_extends({},filterPlaceholders(gjsModel.get("componentProps")),filterPlaceholders(props))),allData=_useState3[0],setAllData=_useState3[1];var headerContent=allData.headerContent,headerDescription=allData.headerDescription,bodyContent=allData.bodyContent,footerContent=allData.footerContent,footerClass=allData.footerClass,footerIcon=allData.footerIcon,contentMetadata=allData.contentMetadata,contentMetadataClass=allData.contentMetadataClass,dataClassName=allData.className,dataError=allData.error,dataIsMissing=allData.isMissing;function toSafeText(value){if(value===null){return""}return typeof value==="string"?value:JSON.stringify(value)}var safeHeaderContent=toSafeText(headerContent);var safeHeaderDescription=toSafeText(headerDescription);var safeBodyContent=toSafeText(bodyContent);var safeFooterContent=toSafeText(footerContent);var safeContentMetadata=toSafeText(contentMetadata);var _useState4=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState4[0],setAttributes=_useState4[1];useEffect(function(){gjsModel.on("change:componentProps",function(){setAllData(function(prevData){return _extends({},prevData,filterPlaceholders(gjsModel.get("componentProps")))})})},[]);useEffect(function(){gjsModel.on("change:attributes",function(){setAttributes(_extends({},gjsModel.get("attributes")))})},[]);var defaultClasses="bg-white text-black p-4 rounded-lg border flex flex-col h-full shadow-none";var defaultFooterClasses=safeFooterContent?"text-sm bg-pink-50 text-pink-900 shadow-sm":"text-sm";var defaultContentMetadataClasses="text-xs";var mergedCardClassName=dataClassName?cn(defaultClasses,dataClassName):defaultClasses;var mergedFooterClassName=footerClass?cn(defaultFooterClasses,footerClass):defaultFooterClasses;var mergedContentMetadataClassName=contentMetadataClass?cn(defaultContentMetadataClasses,contentMetadataClass):defaultContentMetadataClasses;var hasError=Boolean((_attributes$error=attributes==null?void 0:attributes.error)!=null?_attributes$error:dataError);var hasMissing=Boolean((_attributes$isMissing=attributes==null?void 0:attributes.isMissing)!=null?_attributes$isMissing:dataIsMissing);var isLoading=Boolean(((attributes==null?void 0:attributes.interactionApiInProgress)||(attributes==null?void 0:attributes.loading))&&!hasError&&!hasMissing);var footerIconText=typeof footerIcon==="string"?footerIcon:footerIcon&&typeof footerIcon==="object"&&"icon"in footerIcon?String(footerIcon.icon):"";function getCardContent(){if(isLoading){return/*#__PURE__*/_jsx(CardContent,{children:/*#__PURE__*/_jsx(CardLoader,{})})}var showEmpty=hasError||hasMissing||!safeBodyContent;return/*#__PURE__*/_jsxs(React.Fragment,{children:[/*#__PURE__*/_jsx(CardHeader,{children:/*#__PURE__*/_jsx("div",{className:"flex items-start justify-between",children:/*#__PURE__*/_jsxs("div",{className:"flex-1",children:[/*#__PURE__*/_jsx(CardTitle,{"data-slot":"headerContent",contentEditable:isEditable,className:"text-lg",children:safeHeaderContent}),/*#__PURE__*/_jsx(CardDescription,{"data-slot":"headerDescription",contentEditable:isEditable,className:"text-sm",children:safeHeaderDescription})]})})}),showEmpty?/*#__PURE__*/_jsxs("span",{className:"flex flex-row items-center px-3 py-2",children:[/*#__PURE__*/_jsx(CircleAlert,{className:"w-3 h-3 text-gray-400 mr-1"}),/*#__PURE__*/_jsx("p",{className:"text-sm text-gray-500 max-w-md text-center",children:"No data available for given filters"})]}):/*#__PURE__*/_jsxs(CardContent,{"data-slot":"bodyContent",contentEditable:false,className:"flex-grow",children:[/*#__PURE__*/_jsx("div",{className:"text-3xl font-semibold truncate",children:safeBodyContent}),safeContentMetadata&&/*#__PURE__*/_jsx("div",{className:mergedContentMetadataClassName,style:{color:"#2A44D4"},children:safeContentMetadata})]}),/*#__PURE__*/_jsxs(CardFooter,{"data-slot":"footerContent",contentEditable:isEditable,className:cn(mergedFooterClassName),children:[(footerIconText||"").trim()&&/*#__PURE__*/_jsx("span",{className:"mr-2","aria-hidden":"true",children:footerIconText}),safeFooterContent||""]})]})}return/*#__PURE__*/_jsxs(Card,_extends({},rest,{className:mergedCardClassName+" relative",children:[getCardContent(),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:performInteraction,position:"top-right",isVisible:isEditable,componentProps:allData})]}))}function renderChartComponent(chartType,data,config){var safeData=Array.isArray(data)?data:[];if(safeData.length===0){return renderNoDataFallback()}switch(chartType){case"pie":return/*#__PURE__*/_jsxs(PieChart,{children:[safeData.length>=20&&/*#__PURE__*/_jsx(ChartTooltip,{cursor:false,content:/*#__PURE__*/_jsx(ChartTooltipContent,{hideLabel:true})}),/*#__PURE__*/_jsx(Pie,{data:safeData,dataKey:config.dataKey,nameKey:config.nameKey,innerRadius:60,strokeWidth:10,label:safeData.length<20?function(_ref){var name=_ref.name,percent=_ref.percent;return name+": "+(percent*100).toFixed(0)+"%"}:undefined,labelLine:false})]});case"bar":{config.dataKeys=config.dataKeys||[];var barDataKeys=Array.isArray(config.dataKeys)?config.dataKeys:[];return/*#__PURE__*/_jsxs(BarChart,_extends({data:safeData},config.chartUi,{children:[/*#__PURE__*/_jsx(CartesianGrid,{vertical:false}),/*#__PURE__*/_jsx(XAxis,{dataKey:config.xAxis}),/*#__PURE__*/_jsx(YAxis,{}),/*#__PURE__*/_jsx(Legend,{align:"left",wrapperStyle:{marginLeft:20}}),barDataKeys.map(function(_ref2){var key=_ref2.key,name=_ref2.name,color=_ref2.color;return/*#__PURE__*/_jsx(Bar,{dataKey:key,fill:color!=null?color:"#4caf50",name:name,radius:2},key)}),/*#__PURE__*/_jsx(ChartTooltip,{cursor:false,content:/*#__PURE__*/_jsx(ChartTooltipContent,{indicator:"dashed"})})]}))}case"line":{config.dataKeys=config.dataKeys||[];var safeDataKeysLine=Array.isArray(config.dataKeys)?config.dataKeys:[];return/*#__PURE__*/_jsxs(LineChart,_extends({data:safeData},config.chartUi,{children:[/*#__PURE__*/_jsx(CartesianGrid,{vertical:false}),/*#__PURE__*/_jsx(XAxis,{dataKey:config.xAxis}),/*#__PURE__*/_jsx(YAxis,{}),/*#__PURE__*/_jsx(ChartTooltip,{cursor:false,content:/*#__PURE__*/_jsx(ChartTooltipContent,{indicator:"dashed"})}),safeDataKeysLine.map(function(_ref3){var key=_ref3.key,name=_ref3.name,color=_ref3.color;return/*#__PURE__*/_jsx(Line,{type:"monotone",dataKey:key,stroke:color!=null?color:"#4caf50",name:name},key)}),/*#__PURE__*/_jsx(Legend,{align:"left"})]}))}default:return/*#__PURE__*/_jsxs(PieChart,{children:[safeData.length>=20&&/*#__PURE__*/_jsx(ChartTooltip,{cursor:false,content:/*#__PURE__*/_jsx(ChartTooltipContent,{hideLabel:true})}),/*#__PURE__*/_jsx(Pie,{data:safeData,dataKey:config.dataKey,nameKey:config.nameKey,innerRadius:60,strokeWidth:10,label:safeData.length<20?function(_ref4){var name=_ref4.name,percent=_ref4.percent;return name+": "+(percent*100).toFixed(0)+"%"}:undefined,labelLine:false})]})}}export function renderChart(props){var _props$isEditable2=props.isEditable,isEditable=_props$isEditable2===void 0?false:_props$isEditable2,gjsModel=props.gjsModel,_props$performInterac2=props.performInteraction,performInteraction=_props$performInterac2===void 0?function(){return Promise.resolve({})}:_props$performInterac2,rest=_objectWithoutPropertiesLoose(props,_excluded3);var _useState5=useState(_extends({},filterPlaceholders(gjsModel.get("componentProps")),filterPlaceholders(props))),allData=_useState5[0],setAllData=_useState5[1];var _useState6=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState6[0],setAttributes=_useState6[1];var containerRef=useRef(null);var _useState7=useState(0),containerWidth=_useState7[0],setContainerWidth=_useState7[1];useEffect(function(){var handlePropsChange=function handlePropsChange(){var newProps=filterPlaceholders(gjsModel.get("componentProps"));setAllData(function(prevData){return _extends({},prevData,newProps)})};gjsModel.on("change:componentProps",handlePropsChange);return function(){gjsModel.off("change:componentProps",handlePropsChange)}},[gjsModel]);useEffect(function(){var handleAttributesChange=function handleAttributesChange(){var newAttributes=gjsModel.get("attributes");setAttributes(_extends({},newAttributes))};gjsModel.on("change:attributes",handleAttributesChange);return function(){gjsModel.off("change:attributes",handleAttributesChange)}},[gjsModel]);useEffect(function(){var updateContainerWidth=function updateContainerWidth(){if(containerRef.current){setContainerWidth(containerRef.current.offsetWidth)}};updateContainerWidth();window.addEventListener("resize",updateContainerWidth);return function(){return window.removeEventListener("resize",updateContainerWidth)}},[]);var _allData$config=allData.config,config=_allData$config===void 0?{}:_allData$config,_allData$chartType=allData.chartType,chartType=_allData$chartType===void 0?"pie":_allData$chartType,_allData$chartData=allData.chartData,chartData=_allData$chartData===void 0?[]:_allData$chartData,className=allData.className,_allData$title=allData.title,title=_allData$title===void 0?"Title":_allData$title,_allData$subTitle=allData.subTitle,subTitle=_allData$subTitle===void 0?"Subtitle":_allData$subTitle;var defaultClasses="aspect-auto h-[250px] w-full";var mergedClasses=className?cn(defaultClasses,className):defaultClasses;if(chartType==="pie"){var safeChartData=Array.isArray(chartData)?chartData:[];var colors=getNColors(safeChartData.length);for(var i=0;i<safeChartData.length;i++){var data=safeChartData[i];if(!data.fill){data.fill=colors[i]}}}else if(!config.color){var safeBaseColors=Array.isArray(baseColors)?baseColors:[];if(safeBaseColors.length>0){config.color=safeBaseColors[Math.floor(Math.random()*safeBaseColors.length)]}}var width=undefined;var totalDataPoints=0;// Helper function to get responsive config
6
+ colors.push(chroma.scale(baseColor).mode("lab").colors(n))}function getOneColor(existing){var color=null;do{var base=colors[Math.floor(Math.random()*colors.length)];var selectedColorIndex=Math.floor(Math.random()*base.length);color=base[selectedColorIndex]}while(existing.includes(color));return color}var selectedColors=[];for(var i=0;i<n;i++){selectedColors.push(getOneColor(selectedColors))}return selectedColors}/* TODO: Loader remains */export function renderActionCard(props){var gjsModel=props.gjsModel,rest=_objectWithoutPropertiesLoose(props,_excluded);// Only filter props once - it already contains componentProps merged with other props
7
+ var _useState=useState(filterPlaceholders(props)),allData=_useState[0],setAllData=_useState[1];var _allData$headerConten=allData.headerContent,headerContent=_allData$headerConten===void 0?"Default action card title":_allData$headerConten,icon=allData.icon,_allData$bodyContent=allData.bodyContent,bodyContent=_allData$bodyContent===void 0?"Default body content. Click to edit.":_allData$bodyContent;var _useState2=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState2[0],setAttributes=_useState2[1];useEffect(function(){var handlePropsChange=function handlePropsChange(){var newComponentProps=gjsModel.get("componentProps");var filteredProps=filterPlaceholders(newComponentProps);setAllData(function(prevData){return _extends({},prevData,filteredProps)})};gjsModel.on("change:componentProps",handlePropsChange);return function(){gjsModel.off("change:componentProps",handlePropsChange)}},[gjsModel]);useEffect(function(){gjsModel.on("change:attributes",function(){setAttributes(_extends({},gjsModel.get("attributes")))})},[]);var defaultClasses="text-black p-4 rounded-lg shadow border flex flex-col h-full";return/*#__PURE__*/_jsx(Card,_extends({className:defaultClasses+" relative",style:{backgroundColor:"#f9f9fe"},isEditable:false,contentEditable:false},rest,{children:/*#__PURE__*/_jsx(CardContent,{className:"p-0",isEditable:false,contentEditable:false,children:/*#__PURE__*/_jsx("div",{className:"px-4 py-3",children:/*#__PURE__*/_jsxs("div",{className:"flex items-start flex-col",children:[/*#__PURE__*/_jsxs("div",{className:"flex items-center justify-between w-full",children:[/*#__PURE__*/_jsx("div",{className:"text-xl font-semibold",children:headerContent}),/*#__PURE__*/_jsx("div",{className:"text-5xl ml-2 flex items-center","aria-hidden":"true",children:getIconFromString(icon)})]}),/*#__PURE__*/_jsx("div",{className:"w-full mt-1",children:attributes.error||allData.error||attributes.isMissing||allData.isMissing||!bodyContent?/*#__PURE__*/_jsxs("span",{className:"flex flex-row items-center px-3 py-2",children:[/*#__PURE__*/_jsx(CircleAlert,{className:"w-3 h-3 text-gray-400 mr-1"}),/*#__PURE__*/_jsx("p",{className:"text-sm text-gray-500 max-w-md text-center",children:"No data available for given filters"})]}):/*#__PURE__*/_jsx("div",{className:"text-base leading-relaxed",children:bodyContent})})]})})})}))}export function renderCard(props){var _attributes$error,_attributes$isMissing;var _props$isEditable=props.isEditable,isEditable=_props$isEditable===void 0?false:_props$isEditable,gjsModel=props.gjsModel,_props$performInterac=props.performInteraction,performInteraction=_props$performInterac===void 0?function(){return Promise.resolve({})}:_props$performInterac,rest=_objectWithoutPropertiesLoose(props,_excluded2);// Only filter props once - it already contains componentProps merged with other props
8
+ var _useState3=useState(filterPlaceholders(props)),allData=_useState3[0],setAllData=_useState3[1];var headerContent=allData.headerContent,headerDescription=allData.headerDescription,bodyContent=allData.bodyContent,footerContent=allData.footerContent,footerClass=allData.footerClass,footerIcon=allData.footerIcon,contentMetadata=allData.contentMetadata,contentMetadataClass=allData.contentMetadataClass,dataClassName=allData.className,dataError=allData.error,dataIsMissing=allData.isMissing;function toSafeText(value){if(value===null){return""}return typeof value==="string"?value:JSON.stringify(value)}var safeHeaderContent=toSafeText(headerContent);var safeHeaderDescription=toSafeText(headerDescription);var safeBodyContent=toSafeText(bodyContent);var safeFooterContent=toSafeText(footerContent);var safeContentMetadata=toSafeText(contentMetadata);var _useState4=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState4[0],setAttributes=_useState4[1];useEffect(function(){var handlePropsChange=function handlePropsChange(){var newComponentProps=gjsModel.get("componentProps");var filteredProps=filterPlaceholders(newComponentProps);setAllData(function(prevData){return _extends({},prevData,filteredProps)})};gjsModel.on("change:componentProps",handlePropsChange);return function(){gjsModel.off("change:componentProps",handlePropsChange)}},[gjsModel]);useEffect(function(){gjsModel.on("change:attributes",function(){setAttributes(_extends({},gjsModel.get("attributes")))})},[]);var defaultClasses="bg-white text-black p-4 rounded-lg border flex flex-col h-full shadow-none";var defaultFooterClasses=safeFooterContent?"text-sm bg-pink-50 text-pink-900 shadow-sm":"text-sm";var defaultContentMetadataClasses="text-xs";var mergedCardClassName=dataClassName?cn(defaultClasses,dataClassName):defaultClasses;var mergedFooterClassName=footerClass?cn(defaultFooterClasses,footerClass):defaultFooterClasses;var mergedContentMetadataClassName=contentMetadataClass?cn(defaultContentMetadataClasses,contentMetadataClass):defaultContentMetadataClasses;var hasError=Boolean((_attributes$error=attributes==null?void 0:attributes.error)!=null?_attributes$error:dataError);var hasMissing=Boolean((_attributes$isMissing=attributes==null?void 0:attributes.isMissing)!=null?_attributes$isMissing:dataIsMissing);var isLoading=Boolean(((attributes==null?void 0:attributes.interactionApiInProgress)||(attributes==null?void 0:attributes.loading))&&!hasError&&!hasMissing);var footerIconText=typeof footerIcon==="string"?footerIcon:footerIcon&&typeof footerIcon==="object"&&"icon"in footerIcon?String(footerIcon.icon):"";function getCardContent(){if(isLoading){return/*#__PURE__*/_jsx(CardContent,{children:/*#__PURE__*/_jsx(CardLoader,{})})}var showEmpty=hasError||hasMissing||!safeBodyContent;return/*#__PURE__*/_jsxs(React.Fragment,{children:[/*#__PURE__*/_jsx(CardHeader,{children:/*#__PURE__*/_jsx("div",{className:"flex items-start justify-between",children:/*#__PURE__*/_jsxs("div",{className:"flex-1",children:[/*#__PURE__*/_jsx(CardTitle,{"data-slot":"headerContent",contentEditable:isEditable,className:"text-lg",children:safeHeaderContent}),/*#__PURE__*/_jsx(CardDescription,{"data-slot":"headerDescription",contentEditable:isEditable,className:"text-sm",children:safeHeaderDescription})]})})}),showEmpty?/*#__PURE__*/_jsxs("span",{className:"flex flex-row items-center px-3 py-2",children:[/*#__PURE__*/_jsx(CircleAlert,{className:"w-3 h-3 text-gray-400 mr-1"}),/*#__PURE__*/_jsx("p",{className:"text-sm text-gray-500 max-w-md text-center",children:"No data available for given filters"})]}):/*#__PURE__*/_jsxs(CardContent,{"data-slot":"bodyContent",contentEditable:false,className:"flex-grow",children:[/*#__PURE__*/_jsx("div",{className:"text-3xl font-semibold truncate",children:safeBodyContent}),safeContentMetadata&&/*#__PURE__*/_jsx("div",{className:mergedContentMetadataClassName,style:{color:"#2A44D4"},children:safeContentMetadata})]}),/*#__PURE__*/_jsxs(CardFooter,{"data-slot":"footerContent",contentEditable:isEditable,className:cn(mergedFooterClassName),children:[(footerIconText||"").trim()&&/*#__PURE__*/_jsx("span",{className:"mr-2","aria-hidden":"true",children:footerIconText}),safeFooterContent||""]})]})}return/*#__PURE__*/_jsxs(Card,_extends({},rest,{className:mergedCardClassName+" relative",children:[getCardContent(),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:performInteraction,position:"top-right",isVisible:isEditable,componentProps:allData})]}))}function renderChartComponent(chartType,data,config){var safeData=Array.isArray(data)?data:[];if(safeData.length===0){return renderNoDataFallback()}switch(chartType){case"pie":return/*#__PURE__*/_jsxs(PieChart,{children:[safeData.length>=20&&/*#__PURE__*/_jsx(ChartTooltip,{cursor:false,content:/*#__PURE__*/_jsx(ChartTooltipContent,{hideLabel:true})}),/*#__PURE__*/_jsx(Pie,{data:safeData,dataKey:config.dataKey,nameKey:config.nameKey,innerRadius:60,strokeWidth:10,label:safeData.length<20?function(_ref){var name=_ref.name,percent=_ref.percent;return name+": "+(percent*100).toFixed(0)+"%"}:undefined,labelLine:false})]});case"bar":{config.dataKeys=config.dataKeys||[];var barDataKeys=Array.isArray(config.dataKeys)?config.dataKeys:[];return/*#__PURE__*/_jsxs(BarChart,_extends({data:safeData},config.chartUi,{children:[/*#__PURE__*/_jsx(CartesianGrid,{vertical:false}),/*#__PURE__*/_jsx(XAxis,{dataKey:config.xAxis}),/*#__PURE__*/_jsx(YAxis,{}),/*#__PURE__*/_jsx(Legend,{align:"left",wrapperStyle:{marginLeft:20}}),barDataKeys.map(function(_ref2){var key=_ref2.key,name=_ref2.name,color=_ref2.color;return/*#__PURE__*/_jsx(Bar,{dataKey:key,fill:color!=null?color:"#4caf50",name:name,radius:2},key)}),/*#__PURE__*/_jsx(ChartTooltip,{cursor:false,content:/*#__PURE__*/_jsx(ChartTooltipContent,{indicator:"dashed"})})]}))}case"line":{config.dataKeys=config.dataKeys||[];var safeDataKeysLine=Array.isArray(config.dataKeys)?config.dataKeys:[];return/*#__PURE__*/_jsxs(LineChart,_extends({data:safeData},config.chartUi,{children:[/*#__PURE__*/_jsx(CartesianGrid,{vertical:false}),/*#__PURE__*/_jsx(XAxis,{dataKey:config.xAxis}),/*#__PURE__*/_jsx(YAxis,{}),/*#__PURE__*/_jsx(ChartTooltip,{cursor:false,content:/*#__PURE__*/_jsx(ChartTooltipContent,{indicator:"dashed"})}),safeDataKeysLine.map(function(_ref3){var key=_ref3.key,name=_ref3.name,color=_ref3.color;return/*#__PURE__*/_jsx(Line,{type:"monotone",dataKey:key,stroke:color!=null?color:"#4caf50",name:name},key)}),/*#__PURE__*/_jsx(Legend,{align:"left"})]}))}default:return/*#__PURE__*/_jsxs(PieChart,{children:[safeData.length>=20&&/*#__PURE__*/_jsx(ChartTooltip,{cursor:false,content:/*#__PURE__*/_jsx(ChartTooltipContent,{hideLabel:true})}),/*#__PURE__*/_jsx(Pie,{data:safeData,dataKey:config.dataKey,nameKey:config.nameKey,innerRadius:60,strokeWidth:10,label:safeData.length<20?function(_ref4){var name=_ref4.name,percent=_ref4.percent;return name+": "+(percent*100).toFixed(0)+"%"}:undefined,labelLine:false})]})}}export function renderChart(props){var _props$isEditable2=props.isEditable,isEditable=_props$isEditable2===void 0?false:_props$isEditable2,gjsModel=props.gjsModel,_props$performInterac2=props.performInteraction,performInteraction=_props$performInterac2===void 0?function(){return Promise.resolve({})}:_props$performInterac2,rest=_objectWithoutPropertiesLoose(props,_excluded3);// Only filter props once - it already contains componentProps merged with other props
9
+ var _useState5=useState(filterPlaceholders(props)),allData=_useState5[0],setAllData=_useState5[1];var _useState6=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState6[0],setAttributes=_useState6[1];var containerRef=useRef(null);var _useState7=useState(0),containerWidth=_useState7[0],setContainerWidth=_useState7[1];useEffect(function(){var handlePropsChange=function handlePropsChange(){var newComponentProps=gjsModel.get("componentProps");var filteredProps=filterPlaceholders(newComponentProps);setAllData(function(prevData){return _extends({},prevData,filteredProps)})};gjsModel.on("change:componentProps",handlePropsChange);return function(){gjsModel.off("change:componentProps",handlePropsChange)}},[gjsModel]);useEffect(function(){var handleAttributesChange=function handleAttributesChange(){var newAttributes=gjsModel.get("attributes");setAttributes(_extends({},newAttributes))};gjsModel.on("change:attributes",handleAttributesChange);return function(){gjsModel.off("change:attributes",handleAttributesChange)}},[gjsModel]);useEffect(function(){var updateContainerWidth=function updateContainerWidth(){if(containerRef.current){setContainerWidth(containerRef.current.offsetWidth)}};updateContainerWidth();window.addEventListener("resize",updateContainerWidth);return function(){return window.removeEventListener("resize",updateContainerWidth)}},[]);var _allData$config=allData.config,config=_allData$config===void 0?{}:_allData$config,_allData$chartType=allData.chartType,chartType=_allData$chartType===void 0?"pie":_allData$chartType,_allData$chartData=allData.chartData,chartData=_allData$chartData===void 0?[]:_allData$chartData,className=allData.className,_allData$title=allData.title,title=_allData$title===void 0?"Title":_allData$title,_allData$subTitle=allData.subTitle,subTitle=_allData$subTitle===void 0?"Subtitle":_allData$subTitle;var defaultClasses="aspect-auto h-[250px] w-full";var mergedClasses=className?cn(defaultClasses,className):defaultClasses;if(chartType==="pie"){var safeChartData=Array.isArray(chartData)?chartData:[];var colors=getNColors(safeChartData.length);for(var i=0;i<safeChartData.length;i++){var data=safeChartData[i];if(!data.fill){data.fill=colors[i]}}}else if(!config.color){var safeBaseColors=Array.isArray(baseColors)?baseColors:[];if(safeBaseColors.length>0){config.color=safeBaseColors[Math.floor(Math.random()*safeBaseColors.length)]}}var width=undefined;var totalDataPoints=0;// Helper function to get responsive config
7
10
  var getResponsiveConfig=function getResponsiveConfig(){if(chartType==="bar"&&totalDataPoints>15&&containerWidth>0&&width&&width<=containerWidth){// If chart fits in container, use responsive behavior
8
- return _extends({},config,{chartUi:{}})}return config};if(chartType==="bar"){config.dataKeys=config.dataKeys||[];var _safeChartData=Array.isArray(chartData)?chartData:[];var safeDataKeys=Array.isArray(config.dataKeys)?config.dataKeys:[];totalDataPoints=_safeChartData.length*Math.max(1,safeDataKeys.length);if(totalDataPoints>15){width=totalDataPoints*20+safeDataKeys.length*8*_safeChartData.length+_safeChartData.length*15;config.chartUi={barCategoryGap:"10%",width:width}}else{config.chartUi={}}}else if(chartType==="line"){config.dataKeys=config.dataKeys||[];var _safeChartData2=Array.isArray(chartData)?chartData:[];totalDataPoints=_safeChartData2.length;if(totalDataPoints>15){width=Math.max(800,totalDataPoints*20);config.chartUi={width:width}}else{config.chartUi={}}}var hasError=attributes.error||allData.error;var hasMissing=attributes.isMissing||allData.isMissing;var isLoading=(attributes.interactionApiInProgress||attributes.loading)&&!hasError&&!hasMissing;var chartUi=isLoading?/*#__PURE__*/_jsx(ChartLoader,{}):hasError||hasMissing||!chartData?renderNoDataFallback():/*#__PURE__*/_jsx(React.Fragment,{children:(chartType==="bar"||chartType==="line")&&totalDataPoints>15&&width&&(containerWidth===0||width>containerWidth)?/*#__PURE__*/_jsx("div",{className:"w-full h-[250px]",children:/*#__PURE__*/_jsxs(ScrollArea,{className:"w-full h-full",children:[/*#__PURE__*/_jsx("div",{style:{minWidth:width+"px",width:"max-content",height:"250px"},children:/*#__PURE__*/_jsx(ResponsiveContainer,{width:width,height:250,children:/*#__PURE__*/_jsx(ChartContainer,_extends({},rest,{config:config,className:mergedClasses,children:renderChartComponent(chartType,chartData,config)}))})}),/*#__PURE__*/_jsx(ScrollBar,{orientation:"horizontal"})]})}):/*#__PURE__*/_jsx(ResponsiveContainer,{width:"100%",height:250,children:/*#__PURE__*/_jsx(ChartContainer,_extends({},rest,{config:getResponsiveConfig(),className:mergedClasses,children:renderChartComponent(chartType,chartData,getResponsiveConfig())}))})});return/*#__PURE__*/_jsxs(Card,{className:"shadow border mt-2 mb-2 relative",children:[/*#__PURE__*/_jsx(CardHeader,{children:/*#__PURE__*/_jsx("div",{className:"flex items-start justify-between",children:/*#__PURE__*/_jsxs("div",{className:"flex-1",children:[/*#__PURE__*/_jsx(CardTitle,{"data-slot":"title",contentEditable:isEditable,className:"text-2xl",children:title}),/*#__PURE__*/_jsx(CardDescription,{"data-slot":"subTitle",contentEditable:isEditable,className:"text-sm",children:subTitle})]})})}),/*#__PURE__*/_jsx(CardContent,{ref:containerRef,"data-slot":"bodyContent",contentEditable:false,className:"px-6",children:chartUi}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:performInteraction,position:"top-right",isVisible:isEditable,componentProps:allData})]})}export function renderTable(props){var _props$isEditable3=props.isEditable,isEditable=_props$isEditable3===void 0?false:_props$isEditable3,gjsModel=props.gjsModel,_props$performInterac3=props.performInteraction,performInteraction=_props$performInterac3===void 0?function(){}:_props$performInterac3,rest=_objectWithoutPropertiesLoose(props,_excluded4);var _useState8=useState(_extends({},filterPlaceholders(gjsModel.get("componentProps")),filterPlaceholders(props))),allData=_useState8[0],setAllData=_useState8[1];var cardRef=useRef(null);var _useState9=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState9[0],setAttributes=_useState9[1];var rawData=allData.data,_allData$headerMapper=allData.headerMapper,rawHeaderMapper=_allData$headerMapper===void 0?{}:_allData$headerMapper,className=allData.className,_allData$title2=allData.title,title=_allData$title2===void 0?"Title":_allData$title2,_allData$subTitle2=allData.subTitle,subTitle=_allData$subTitle2===void 0?"Subtitle":_allData$subTitle2,_allData$actions=allData.actions,actions=_allData$actions===void 0?[]:_allData$actions,pagination=allData.pagination;var data=Array.isArray(rawData)?rawData:[];var headerMapper=function(){var cleaned=_extends({},rawHeaderMapper);if("id"in cleaned){delete cleaned.id}if(data.length>0){var dataKeys=Object.keys(data[0]||{});return Object.fromEntries(Object.entries(cleaned).filter(function(_ref5){var key=_ref5[0];return dataKeys.includes(key)}))}return cleaned}();var sortConfig=function(_gjsModel$get,_ref7){var _ref6=(_gjsModel$get=gjsModel.get("componentProps"))!=null?_gjsModel$get:{},sortColumn=_ref6.sortColumn,sortDirection=_ref6.sortDirection;return sortColumn&&sortDirection?(_ref7={},_ref7[sortColumn]=sortDirection,_ref7):{}}();var _useState10=useState(0),viewportWidth=_useState10[0],setViewportWidth=_useState10[1];var _useState11=useState(250),scrollAreaHeight=_useState11[0],setScrollAreaHeight=_useState11[1];var calculateTableHeight=function calculateTableHeight(tableWidth,rowCount){if(viewportWidth>0){var _gjsModel$collection;var widthRatio=tableWidth/viewportWidth;var baseTableHeight=250;var targetScrollAreaHeight=baseTableHeight;if(widthRatio>=0.8){var headerHeight=48;var rowHeight=40;var calculatedHeight=headerHeight+rowCount*rowHeight;targetScrollAreaHeight=Math.min(calculatedHeight,baseTableHeight)}var tableId=gjsModel.get("id");var editor=gjsModel.em||((_gjsModel$collection=gjsModel.collection)==null?void 0:_gjsModel$collection.em);var canvasDocument=editor.Canvas.getDocument()||document;var tableElement=canvasDocument.querySelector("[data-table-id=\""+tableId+"\"]");if(tableElement){var headerElement=tableElement.querySelector("[data-slot=\"card-header\"]");if(headerElement&&headerElement.offsetHeight>0){var actualHeaderHeight=headerElement.offsetHeight;var standardHeaderHeight=58;var heightDifference=actualHeaderHeight-standardHeaderHeight;if(heightDifference>0){targetScrollAreaHeight=targetScrollAreaHeight-heightDifference}}}setScrollAreaHeight(targetScrollAreaHeight)}};useEffect(function(){var updateViewportWidth=function updateViewportWidth(){var iframe=document.querySelector(".gjs-frame");var iframeWindow=iframe==null?void 0:iframe.contentWindow;var iframeDocument=iframeWindow==null?void 0:iframeWindow.document;if(iframeDocument){var dashboardRoot=iframeDocument.getElementById("dashboard-root");var effectiveViewportWidth=(dashboardRoot==null?void 0:dashboardRoot.clientWidth)||iframeDocument.documentElement.clientWidth;setViewportWidth(effectiveViewportWidth)}};updateViewportWidth();window.addEventListener("resize",updateViewportWidth);var iframe=document.querySelector(".gjs-frame");var iframeWindow=iframe==null?void 0:iframe.contentWindow;if(iframeWindow){iframeWindow.addEventListener("resize",updateViewportWidth)}return function(){window.removeEventListener("resize",updateViewportWidth);if(iframeWindow){iframeWindow.removeEventListener("resize",updateViewportWidth)}}},[]);useEffect(function(){var updateTableWidthAndApplyCSS=function updateTableWidthAndApplyCSS(){var _gjsModel$collection2;var tableId=gjsModel.get("id");var editor=gjsModel.em||((_gjsModel$collection2=gjsModel.collection)==null?void 0:_gjsModel$collection2.em);var canvasDocument=editor.Canvas.getDocument()||document;var tableElement=canvasDocument.querySelector("[data-table-id=\""+tableId+"\"]");if(!tableElement&&window.parent!==window){tableElement=window.parent.document.querySelector("[data-table-id=\""+tableId+"\"]")}if(!tableElement){return}var tableActualWidth=tableElement.getBoundingClientRect().width;if(tableActualWidth>0){calculateTableHeight(tableActualWidth,Array.isArray(data)?data.length:0)}};var timeoutId=setTimeout(updateTableWidthAndApplyCSS,150);window.addEventListener("resize",updateTableWidthAndApplyCSS);return function(){clearTimeout(timeoutId);window.removeEventListener("resize",updateTableWidthAndApplyCSS)}},[allData,gjsModel,viewportWidth,data,calculateTableHeight]);useEffect(function(){gjsModel.on("change:componentProps",function(){setAllData(function(prevData){return _extends({},prevData,filterPlaceholders(gjsModel.get("componentProps")))})})},[]);useEffect(function(){gjsModel.on("change:attributes",function(){setAttributes(_extends({},gjsModel.get("attributes")))})},[]);var parsedData=function(){if(typeof data==="object"&&data!==null&&!Array.isArray(data)&&data.name==="__peak_placeholder"){return[]}if(!Array.isArray(data)){return[]}return data.map(function(datum){var newData=_extends({},datum);delete newData.id;return newData})}();function onRowAction(_x,_x2){return _onRowAction.apply(this,arguments)}function _onRowAction(){_onRowAction=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(rowIndex,actionId){var id;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:id=gjsModel.get("id");_context.next=3;return performInteraction({id:actionId,interactionType:"tableButton",payload:{row:data[rowIndex],tableId:id},affectedComponents:[]});case 3:case"end":return _context.stop()}},_callee)}));return _onRowAction.apply(this,arguments)}function onPageChange(_x3,_x4){return _onPageChange.apply(this,arguments)}function _onPageChange(){_onPageChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(pageNumber,pageSize){var _gjsModel$get2;var id,_ref8,sortColumn,sortDirection;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:id=gjsModel.get("id");_ref8=(_gjsModel$get2=gjsModel.get("componentProps"))!=null?_gjsModel$get2:{},sortColumn=_ref8.sortColumn,sortDirection=_ref8.sortDirection;_context2.next=4;return performInteraction({id:id,interactionType:"pagination",payload:_extends({pageNumber:pageNumber,pageSize:pageSize},sortColumn&&sortDirection&&{sortColumn:sortColumn,sortDirection:sortDirection}),affectedComponents:getAffectedComponentsWithLoader([id],true)});case 4:case"end":return _context2.stop()}},_callee2)}));return _onPageChange.apply(this,arguments)}function handleSort(_x5,_x6){return _handleSort.apply(this,arguments)}function _handleSort(){_handleSort=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(column,direction){var currentProps,id;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:currentProps=gjsModel.get("componentProps");id=gjsModel.get("id");gjsModel.set("componentProps",_extends({},currentProps,{sortColumn:direction?column:null,sortDirection:direction}));_context3.next=5;return performInteraction({id:id,interactionType:"tableSort",payload:{sortColumn:direction?column:null,sortDirection:direction,tableId:id},affectedComponents:getAffectedComponentsWithLoader([id],true)});case 5:case"end":return _context3.stop()}},_callee3)}));return _handleSort.apply(this,arguments)}return/*#__PURE__*/_jsxs(Card,{ref:cardRef,className:"shadow border relative flex flex-col h-fit overflow-hidden","data-component-type":"table","data-table-id":gjsModel.get("id"),children:[/*#__PURE__*/_jsx(CardHeader,{children:/*#__PURE__*/_jsx("div",{className:"flex items-start justify-between",children:/*#__PURE__*/_jsxs("div",{className:"flex-1",children:[/*#__PURE__*/_jsx(CardTitle,{"data-slot":"title",contentEditable:isEditable,className:"text-2xl",children:title}),/*#__PURE__*/_jsx(CardDescription,{"data-slot":"subTitle",contentEditable:isEditable,className:"text-sm",children:subTitle})]})})}),/*#__PURE__*/_jsx(CardContent,{"data-slot":"bodyContent",contentEditable:false,className:"flex-1 flex flex-col overflow-hidden",children:attributes.error||allData.error||attributes.isMissing||allData.isMissing?renderNoDataFallback():/*#__PURE__*/_jsx(DataTable,{data:parsedData,headerMapper:headerMapper,className:className,isEditable:isEditable,actions:actions,pagination:pagination,isLoading:attributes.interactionApiInProgress,onRowAction:onRowAction,onPageChange:onPageChange,onSort:handleSort,sortConfig:sortConfig,otherProps:rest,height:scrollAreaHeight})}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:performInteraction,position:"top-right",tableActions:actions,firstRowData:Array.isArray(data)&&data.length>0?data[0]:{},isVisible:isEditable,componentProps:allData})]})}export function renderTab(props){var tabsWidth=157;var safeTabs=Array.isArray(props.tabs)?props.tabs:[];var showFallback=safeTabs.length===0;if(safeTabs.length>4){tabsWidth=157}var defaultValue=props.defaultValue||(safeTabs.length>0?safeTabs[0]:undefined);return/*#__PURE__*/_jsxs(Tabs,{defaultValue:defaultValue,children:[/*#__PURE__*/_jsx("div",{className:"text-center mb-4",children:/*#__PURE__*/_jsx(TabsList,{className:"bg-[#F9F9FE] border border-[#D4D5DE] p-1 rounded-lg h-auto",children:safeTabs.length>0?safeTabs.map(function(tab){return/*#__PURE__*/_jsx(TabsTrigger,{value:tab,className:"\n w-["+tabsWidth+"px] h-[38px] gap-1 px-3 py-[11px]\n font-medium text-sm leading-4\n border-0 bg-[#F9F9FE] text-[#687387] rounded-none\n data-[state=active]:border data-[state=active]:border-solid data-[state=active]:border-[#2A44D4] data-[state=active]:bg-[#EAECFB] data-[state=active]:text-[#263DBF] data-[state=active]:shadow-none data-[state=active]:rounded-md\n transition-all duration-200\n ",style:{fontFamily:"Helvetica Neue",fontWeight:500,fontSize:"14px",lineHeight:"16px",letterSpacing:"0%"},children:tab},tab)}):/*#__PURE__*/_jsx(TabsTrigger,{value:"no-data",className:"\n w-["+tabsWidth+"px] h-[38px] gap-1 px-3 py-[11px]\n font-medium text-sm leading-4\n border-0 bg-[#F9F9FE] text-[#687387] rounded-none\n data-[state=active]:border data-[state=active]:border-solid data-[state=active]:border-[#2A44D4] data-[state=active]:bg-[#EAECFB] data-[state=active]:text-[#263DBF] data-[state=active]:shadow-none data-[state=active]:rounded-md\n transition-all duration-200\n ",style:{fontFamily:"Helvetica Neue",fontWeight:500,fontSize:"14px",lineHeight:"16px",letterSpacing:"0%"},disabled:true,children:"No tabs"})})}),showFallback?/*#__PURE__*/_jsx(TabsContent,{value:defaultValue||"no-data",className:"tabs-content","data-fallback":"true",children:renderNoDataFallback()}):safeTabs.map(function(tab){return/*#__PURE__*/_jsx(TabsContent,{value:tab,className:"tabs-content"},tab)})]})}export function renderMarkdown(props){var _props$isEditable4=props.isEditable,isEditable=_props$isEditable4===void 0?false:_props$isEditable4,gjsModel=props.gjsModel,rest=_objectWithoutPropertiesLoose(props,_excluded5);var _useState12=useState(_extends({},filterPlaceholders(gjsModel.get("componentProps")),filterPlaceholders(props))),allData=_useState12[0],setAllData=_useState12[1];var _useState13=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState13[0],setAttributes=_useState13[1];useEffect(function(){gjsModel.on("change:componentProps",function(){setAllData(function(prevData){return _extends({},prevData,filterPlaceholders(gjsModel.get("componentProps")))})})},[]);useEffect(function(){gjsModel.on("change:attributes",function(){setAttributes(_extends({},gjsModel.get("attributes")))})},[]);var _useState14=useState(false),isEditing=_useState14[0],setIsEditing=_useState14[1];var editRef=useRef(null);var startEditing=function startEditing(){setIsEditing(true);setTimeout(function(){setupEditor()},0)};var setupEditor=function setupEditor(){if(!editRef.current){return}var editor=editRef.current;editor.innerHTML="";editor.textContent=allData.summaryText;editor.focus()};// Save changes and exit editing mode
11
+ return _extends({},config,{chartUi:{}})}return config};if(chartType==="bar"){config.dataKeys=config.dataKeys||[];var _safeChartData=Array.isArray(chartData)?chartData:[];var safeDataKeys=Array.isArray(config.dataKeys)?config.dataKeys:[];totalDataPoints=_safeChartData.length*Math.max(1,safeDataKeys.length);if(totalDataPoints>15){width=totalDataPoints*20+safeDataKeys.length*8*_safeChartData.length+_safeChartData.length*15;config.chartUi={barCategoryGap:"10%",width:width}}else{config.chartUi={}}}else if(chartType==="line"){config.dataKeys=config.dataKeys||[];var _safeChartData2=Array.isArray(chartData)?chartData:[];totalDataPoints=_safeChartData2.length;if(totalDataPoints>15){width=Math.max(800,totalDataPoints*20);config.chartUi={width:width}}else{config.chartUi={}}}var hasError=attributes.error||allData.error;var hasMissing=attributes.isMissing||allData.isMissing;var isLoading=(attributes.interactionApiInProgress||attributes.loading)&&!hasError&&!hasMissing;var chartUi=isLoading?/*#__PURE__*/_jsx(ChartLoader,{}):hasError||hasMissing||!chartData?renderNoDataFallback():/*#__PURE__*/_jsx(React.Fragment,{children:(chartType==="bar"||chartType==="line")&&totalDataPoints>15&&width&&(containerWidth===0||width>containerWidth)?/*#__PURE__*/_jsx("div",{className:"w-full h-[250px]",children:/*#__PURE__*/_jsxs(ScrollArea,{className:"w-full h-full",children:[/*#__PURE__*/_jsx("div",{style:{minWidth:width+"px",width:"max-content",height:"250px"},children:/*#__PURE__*/_jsx(ResponsiveContainer,{width:width,height:250,children:/*#__PURE__*/_jsx(ChartContainer,_extends({},rest,{config:config,className:mergedClasses,children:renderChartComponent(chartType,chartData,config)}))})}),/*#__PURE__*/_jsx(ScrollBar,{orientation:"horizontal"})]})}):/*#__PURE__*/_jsx(ResponsiveContainer,{width:"100%",height:250,children:/*#__PURE__*/_jsx(ChartContainer,_extends({},rest,{config:getResponsiveConfig(),className:mergedClasses,children:renderChartComponent(chartType,chartData,getResponsiveConfig())}))})});return/*#__PURE__*/_jsxs(Card,{className:"shadow border mt-2 mb-2 relative",children:[/*#__PURE__*/_jsx(CardHeader,{children:/*#__PURE__*/_jsx("div",{className:"flex items-start justify-between",children:/*#__PURE__*/_jsxs("div",{className:"flex-1",children:[/*#__PURE__*/_jsx(CardTitle,{"data-slot":"title",contentEditable:isEditable,className:"text-2xl",children:title}),/*#__PURE__*/_jsx(CardDescription,{"data-slot":"subTitle",contentEditable:isEditable,className:"text-sm",children:subTitle})]})})}),/*#__PURE__*/_jsx(CardContent,{ref:containerRef,"data-slot":"bodyContent",contentEditable:false,className:"px-6",children:chartUi}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:performInteraction,position:"top-right",isVisible:isEditable,componentProps:allData})]})}export function renderTable(props){var _props$isEditable3=props.isEditable,isEditable=_props$isEditable3===void 0?false:_props$isEditable3,gjsModel=props.gjsModel,_props$performInterac3=props.performInteraction,performInteraction=_props$performInterac3===void 0?function(){}:_props$performInterac3,rest=_objectWithoutPropertiesLoose(props,_excluded4);// Only filter props once - it already contains componentProps merged with other props
12
+ var _useState8=useState(filterPlaceholders(props)),allData=_useState8[0],setAllData=_useState8[1];var cardRef=useRef(null);var _useState9=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState9[0],setAttributes=_useState9[1];var rawData=allData.data,_allData$headerMapper=allData.headerMapper,rawHeaderMapper=_allData$headerMapper===void 0?{}:_allData$headerMapper,className=allData.className,_allData$title2=allData.title,title=_allData$title2===void 0?"Title":_allData$title2,_allData$subTitle2=allData.subTitle,subTitle=_allData$subTitle2===void 0?"Subtitle":_allData$subTitle2,_allData$actions=allData.actions,actions=_allData$actions===void 0?[]:_allData$actions,pagination=allData.pagination;var data=Array.isArray(rawData)?rawData:[];var headerMapper=function(){var cleaned=_extends({},rawHeaderMapper);if("id"in cleaned){delete cleaned.id}if(data.length>0){var dataKeys=Object.keys(data[0]||{});return Object.fromEntries(Object.entries(cleaned).filter(function(_ref5){var key=_ref5[0];return dataKeys.includes(key)}))}return cleaned}();var sortConfig=function(_gjsModel$get,_ref7){var _ref6=(_gjsModel$get=gjsModel.get("componentProps"))!=null?_gjsModel$get:{},sortColumn=_ref6.sortColumn,sortDirection=_ref6.sortDirection;return sortColumn&&sortDirection?(_ref7={},_ref7[sortColumn]=sortDirection,_ref7):{}}();var _useState10=useState(0),viewportWidth=_useState10[0],setViewportWidth=_useState10[1];var _useState11=useState(250),scrollAreaHeight=_useState11[0],setScrollAreaHeight=_useState11[1];var calculateTableHeight=function calculateTableHeight(tableWidth,rowCount){if(viewportWidth>0){var _gjsModel$collection;var widthRatio=tableWidth/viewportWidth;var baseTableHeight=250;var targetScrollAreaHeight=baseTableHeight;if(widthRatio>=0.8){var headerHeight=48;var rowHeight=40;var calculatedHeight=headerHeight+rowCount*rowHeight;targetScrollAreaHeight=Math.min(calculatedHeight,baseTableHeight)}var tableId=gjsModel.get("id");var editor=gjsModel.em||((_gjsModel$collection=gjsModel.collection)==null?void 0:_gjsModel$collection.em);var canvasDocument=editor.Canvas.getDocument()||document;var tableElement=canvasDocument.querySelector("[data-table-id=\""+tableId+"\"]");if(tableElement){var headerElement=tableElement.querySelector("[data-slot=\"card-header\"]");if(headerElement&&headerElement.offsetHeight>0){var actualHeaderHeight=headerElement.offsetHeight;var standardHeaderHeight=58;var heightDifference=actualHeaderHeight-standardHeaderHeight;if(heightDifference>0){targetScrollAreaHeight=targetScrollAreaHeight-heightDifference}}}setScrollAreaHeight(targetScrollAreaHeight)}};useEffect(function(){var updateViewportWidth=function updateViewportWidth(){var iframe=document.querySelector(".gjs-frame");var iframeWindow=iframe==null?void 0:iframe.contentWindow;var iframeDocument=iframeWindow==null?void 0:iframeWindow.document;if(iframeDocument){var dashboardRoot=iframeDocument.getElementById("dashboard-root");var effectiveViewportWidth=(dashboardRoot==null?void 0:dashboardRoot.clientWidth)||iframeDocument.documentElement.clientWidth;setViewportWidth(effectiveViewportWidth)}};updateViewportWidth();window.addEventListener("resize",updateViewportWidth);var iframe=document.querySelector(".gjs-frame");var iframeWindow=iframe==null?void 0:iframe.contentWindow;if(iframeWindow){iframeWindow.addEventListener("resize",updateViewportWidth)}return function(){window.removeEventListener("resize",updateViewportWidth);if(iframeWindow){iframeWindow.removeEventListener("resize",updateViewportWidth)}}},[]);useEffect(function(){var updateTableWidthAndApplyCSS=function updateTableWidthAndApplyCSS(){var _gjsModel$collection2;var tableId=gjsModel.get("id");var editor=gjsModel.em||((_gjsModel$collection2=gjsModel.collection)==null?void 0:_gjsModel$collection2.em);var canvasDocument=editor.Canvas.getDocument()||document;var tableElement=canvasDocument.querySelector("[data-table-id=\""+tableId+"\"]");if(!tableElement&&window.parent!==window){tableElement=window.parent.document.querySelector("[data-table-id=\""+tableId+"\"]")}if(!tableElement){return}var tableActualWidth=tableElement.getBoundingClientRect().width;if(tableActualWidth>0){calculateTableHeight(tableActualWidth,Array.isArray(data)?data.length:0)}};var timeoutId=setTimeout(updateTableWidthAndApplyCSS,150);window.addEventListener("resize",updateTableWidthAndApplyCSS);return function(){clearTimeout(timeoutId);window.removeEventListener("resize",updateTableWidthAndApplyCSS)}},[allData,gjsModel,viewportWidth,data,calculateTableHeight]);useEffect(function(){var handlePropsChange=function handlePropsChange(){var newComponentProps=gjsModel.get("componentProps");var filteredProps=filterPlaceholders(newComponentProps);setAllData(function(prevData){return _extends({},prevData,filteredProps)})};gjsModel.on("change:componentProps",handlePropsChange);return function(){gjsModel.off("change:componentProps",handlePropsChange)}},[gjsModel]);useEffect(function(){var handleAttributesChange=function handleAttributesChange(){setAttributes(_extends({},gjsModel.get("attributes")))};gjsModel.on("change:attributes",handleAttributesChange);return function(){gjsModel.off("change:attributes",handleAttributesChange)}},[gjsModel]);var parsedData=function(){if(typeof data==="object"&&data!==null&&!Array.isArray(data)&&data.name==="__peak_placeholder"){return[]}if(!Array.isArray(data)){return[]}return data.map(function(datum){var newData=_extends({},datum);delete newData.id;return newData})}();function onRowAction(_x,_x2){return _onRowAction.apply(this,arguments)}function _onRowAction(){_onRowAction=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(rowIndex,actionId){var id;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:id=gjsModel.get("id");_context.next=3;return performInteraction({id:actionId,interactionType:"tableButton",payload:{row:data[rowIndex],tableId:id},affectedComponents:[]});case 3:case"end":return _context.stop()}},_callee)}));return _onRowAction.apply(this,arguments)}function onPageChange(_x3,_x4){return _onPageChange.apply(this,arguments)}function _onPageChange(){_onPageChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(pageNumber,pageSize){var _gjsModel$get2;var id,_ref8,sortColumn,sortDirection;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:id=gjsModel.get("id");_ref8=(_gjsModel$get2=gjsModel.get("componentProps"))!=null?_gjsModel$get2:{},sortColumn=_ref8.sortColumn,sortDirection=_ref8.sortDirection;_context2.next=4;return performInteraction({id:id,interactionType:"pagination",payload:_extends({pageNumber:pageNumber,pageSize:pageSize},sortColumn&&sortDirection&&{sortColumn:sortColumn,sortDirection:sortDirection}),affectedComponents:getAffectedComponentsWithLoader([id],true)});case 4:case"end":return _context2.stop()}},_callee2)}));return _onPageChange.apply(this,arguments)}function handleSort(_x5,_x6){return _handleSort.apply(this,arguments)}function _handleSort(){_handleSort=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(column,direction){var currentProps,id;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:currentProps=gjsModel.get("componentProps");id=gjsModel.get("id");gjsModel.set("componentProps",_extends({},currentProps,{sortColumn:direction?column:null,sortDirection:direction}));_context3.next=5;return performInteraction({id:id,interactionType:"tableSort",payload:{sortColumn:direction?column:null,sortDirection:direction,tableId:id},affectedComponents:getAffectedComponentsWithLoader([id],true)});case 5:case"end":return _context3.stop()}},_callee3)}));return _handleSort.apply(this,arguments)}return/*#__PURE__*/_jsxs(Card,{ref:cardRef,className:"shadow border relative flex flex-col h-fit overflow-hidden","data-component-type":"table","data-table-id":gjsModel.get("id"),children:[/*#__PURE__*/_jsx(CardHeader,{children:/*#__PURE__*/_jsx("div",{className:"flex items-start justify-between",children:/*#__PURE__*/_jsxs("div",{className:"flex-1",children:[/*#__PURE__*/_jsx(CardTitle,{"data-slot":"title",contentEditable:isEditable,className:"text-2xl",children:title}),/*#__PURE__*/_jsx(CardDescription,{"data-slot":"subTitle",contentEditable:isEditable,className:"text-sm",children:subTitle})]})})}),/*#__PURE__*/_jsx(CardContent,{"data-slot":"bodyContent",contentEditable:false,className:"flex-1 flex flex-col overflow-hidden",children:attributes.error||allData.error||attributes.isMissing||allData.isMissing?renderNoDataFallback():/*#__PURE__*/_jsx(DataTable,{data:parsedData,headerMapper:headerMapper,className:className,isEditable:isEditable,actions:actions,pagination:pagination,isLoading:attributes.interactionApiInProgress,onRowAction:onRowAction,onPageChange:onPageChange,onSort:handleSort,sortConfig:sortConfig,otherProps:rest,height:scrollAreaHeight})}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:performInteraction,position:"top-right",tableActions:actions,firstRowData:Array.isArray(data)&&data.length>0?data[0]:{},isVisible:isEditable,componentProps:allData})]})}export function renderTab(props){var tabsWidth=157;var safeTabs=Array.isArray(props.tabs)?props.tabs:[];var showFallback=safeTabs.length===0;if(safeTabs.length>4){tabsWidth=157}var defaultValue=props.defaultValue||(safeTabs.length>0?safeTabs[0]:undefined);return/*#__PURE__*/_jsxs(Tabs,{defaultValue:defaultValue,children:[/*#__PURE__*/_jsx("div",{className:"text-center mb-4",children:/*#__PURE__*/_jsx(TabsList,{className:"bg-[#F9F9FE] border border-[#D4D5DE] p-1 rounded-lg h-auto",children:safeTabs.length>0?safeTabs.map(function(tab){return/*#__PURE__*/_jsx(TabsTrigger,{value:tab,className:"\n w-["+tabsWidth+"px] h-[38px] gap-1 px-3 py-[11px]\n font-medium text-sm leading-4\n border-0 bg-[#F9F9FE] text-[#687387] rounded-none\n data-[state=active]:border data-[state=active]:border-solid data-[state=active]:border-[#2A44D4] data-[state=active]:bg-[#EAECFB] data-[state=active]:text-[#263DBF] data-[state=active]:shadow-none data-[state=active]:rounded-md\n transition-all duration-200\n ",style:{fontFamily:"Helvetica Neue",fontWeight:500,fontSize:"14px",lineHeight:"16px",letterSpacing:"0%"},children:tab},tab)}):/*#__PURE__*/_jsx(TabsTrigger,{value:"no-data",className:"\n w-["+tabsWidth+"px] h-[38px] gap-1 px-3 py-[11px]\n font-medium text-sm leading-4\n border-0 bg-[#F9F9FE] text-[#687387] rounded-none\n data-[state=active]:border data-[state=active]:border-solid data-[state=active]:border-[#2A44D4] data-[state=active]:bg-[#EAECFB] data-[state=active]:text-[#263DBF] data-[state=active]:shadow-none data-[state=active]:rounded-md\n transition-all duration-200\n ",style:{fontFamily:"Helvetica Neue",fontWeight:500,fontSize:"14px",lineHeight:"16px",letterSpacing:"0%"},disabled:true,children:"No tabs"})})}),showFallback?/*#__PURE__*/_jsx(TabsContent,{value:defaultValue||"no-data",className:"tabs-content","data-fallback":"true",children:renderNoDataFallback()}):safeTabs.map(function(tab){return/*#__PURE__*/_jsx(TabsContent,{value:tab,className:"tabs-content"},tab)})]})}export function renderMarkdown(props){var _props$isEditable4=props.isEditable,isEditable=_props$isEditable4===void 0?false:_props$isEditable4,gjsModel=props.gjsModel,rest=_objectWithoutPropertiesLoose(props,_excluded5);// Only filter props once - it already contains componentProps merged with other props
13
+ var _useState12=useState(filterPlaceholders(props)),allData=_useState12[0],setAllData=_useState12[1];var _useState13=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState13[0],setAttributes=_useState13[1];useEffect(function(){var handlePropsChange=function handlePropsChange(){var newComponentProps=gjsModel.get("componentProps");var filteredProps=filterPlaceholders(newComponentProps);setAllData(function(prevData){return _extends({},prevData,filteredProps)})};gjsModel.on("change:componentProps",handlePropsChange);return function(){gjsModel.off("change:componentProps",handlePropsChange)}},[gjsModel]);useEffect(function(){var handleAttributesChange=function handleAttributesChange(){setAttributes(_extends({},gjsModel.get("attributes")))};gjsModel.on("change:attributes",handleAttributesChange);return function(){gjsModel.off("change:attributes",handleAttributesChange)}},[gjsModel]);var _useState14=useState(false),isEditing=_useState14[0],setIsEditing=_useState14[1];var editRef=useRef(null);var startEditing=function startEditing(){setIsEditing(true);setTimeout(function(){setupEditor()},0)};var setupEditor=function setupEditor(){if(!editRef.current){return}var editor=editRef.current;editor.innerHTML="";editor.textContent=allData.summaryText;editor.focus()};// Save changes and exit editing mode
9
14
  var saveChanges=function saveChanges(){if(!editRef.current){return}var content=editRef.current.innerText||"";setAllData(function(prev){return _extends({},prev,{summaryText:content})});setIsEditing(false);editRef.current.innerHTML=""};var markdownStyles={ul:{props:{className:"list-disc"}},h1:{props:{className:"text-4xl font-bold leading-[4rem]"}},h2:{props:{className:"text-3xl font-bold leading-[3rem]"}},h3:{props:{className:"text-2xl font-bold leading-[2rem]"}},h4:{props:{className:"text-xl font-bold leading-[2.5rem]"}},h5:{props:{className:"text-lg font-bold leading-[2.5rem]"}},h6:{props:{className:"text-base font-bold leading-[2rem]"}}};var hasError=attributes.error||allData.error;var hasMissing=attributes.isMissing||allData.isMissing;var isLoading=attributes.loading&&!hasError&&!hasMissing;if(isLoading){return/*#__PURE__*/_jsx(MarkdownLoader,{})}if(hasError||hasMissing){return/*#__PURE__*/_jsxs("div",_extends({className:"px-[1em] relative"},rest,{children:[/*#__PURE__*/_jsx("h3",{className:"text-xl font-semibold text-left",children:"Insights"}),/*#__PURE__*/_jsxs("div",{className:"w-full py-8 flex flex-col items-center justify-center px-6 text-center",style:{minHeight:"180px"},children:[/*#__PURE__*/_jsx(CircleAlert,{className:"w-12 h-12 text-gray-400 mb-2"}),/*#__PURE__*/_jsx("h3",{className:"text-lg font-medium text-gray-900",children:"No data available"}),/*#__PURE__*/_jsx("p",{className:"mt-2 text-sm text-gray-500 max-w-md",children:"Check your filters or try a different time range."})]}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:props.performInteraction,position:"top-right",isVisible:isEditable,componentProps:allData})]}))}if(!allData.isEditable){return/*#__PURE__*/_jsxs("div",_extends({className:"px-[1em] relative"},rest,{children:[/*#__PURE__*/_jsx("h3",{className:"text-xl font-semibold text-left",children:"Insights"}),/*#__PURE__*/_jsx("div",{"data-slot":"summaryText",children:/*#__PURE__*/_jsx(Markdown,{options:{overrides:markdownStyles},children:allData.summaryText})}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:props.performInteraction,position:"top-right",isVisible:isEditable,componentProps:allData})]}))}return/*#__PURE__*/_jsxs("div",_extends({className:"p-[1em] relative"},rest,{children:[/*#__PURE__*/_jsx("h3",{className:"text-xl font-semibold text-left",children:"Insights"}),isEditing?/*#__PURE__*/_jsx("div",{ref:editRef,contentEditable:true,onBlur:saveChanges,"data-slot":"summaryText",className:"p-2 min-h-[100px] whitespace-pre-wrap",suppressContentEditableWarning:true,style:{whiteSpace:"pre-wrap",wordWrap:"break-word"}}):/*#__PURE__*/_jsx("div",{onClick:startEditing,"data-slot":"summaryText",style:{whiteSpace:"pre-wrap",wordWrap:"break-word"},children:/*#__PURE__*/_jsx(Markdown,{options:{overrides:markdownStyles},children:allData.summaryText})}),/*#__PURE__*/_jsx(StyledInfoButton,{componentId:gjsModel.get("id"),performInteraction:props.performInteraction,position:"top-right",isVisible:isEditable,componentProps:allData})]}))}export function renderButton(props){var _props$isEditable5=props.isEditable,isEditable=_props$isEditable5===void 0?false:_props$isEditable5,gjsModel=props.gjsModel,_props$performInterac4=props.performInteraction,performInteraction=_props$performInterac4===void 0?function(){}:_props$performInterac4;var _useState15=useState(_extends({},props)),allData=_useState15[0],setAllData=_useState15[1];var _useState16=useState(_extends({},gjsModel.get("attributes"))),attributes=_useState16[0],setAttributes=_useState16[1];useEffect(function(){gjsModel.on("change:componentProps",function(){setAllData(_extends({},gjsModel.get("componentProps")))})},[]);useEffect(function(){gjsModel.on("change:attributes",function(){setAttributes(_extends({},gjsModel.get("attributes")))})},[]);var text=allData.text,className=allData.className,payload=allData.payload,_allData$variant=allData.variant,variant=_allData$variant===void 0?"default":_allData$variant,_allData$size=allData.size,size=_allData$size===void 0?"sm":_allData$size,affectedComponents=allData.affectedComponents,tooltipContent=allData.tooltipContent;function interact(){var id=gjsModel.get("id");performInteraction({id:id,interactionType:"button",affectedComponents:getAffectedComponentsWithLoader([id].concat(affectedComponents),true),payload:payload})}return/*#__PURE__*/_jsx(TooltipButton,{className:className,isEditable:isEditable,interact:interact,attributes:attributes,variant:variant,size:size,text:text,tooltipContent:tooltipContent})}var renderActionCardWithWrapper=function renderActionCardWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"ActionCard"}),children:renderActionCard(props)})};var renderButtonWithWrapper=function renderButtonWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Button"}),children:renderButton(props)})};var renderCardWithWrapper=function renderCardWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Card"}),children:renderCard(props)})};var renderChartWithWrapper=function renderChartWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Chart"}),children:renderChart(props)})};var renderFilterWithWrapper=function renderFilterWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Filter"}),children:renderFilter(props)})};var renderMarkdownWithWrapper=function renderMarkdownWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Markdown"}),children:renderMarkdown(props)})};var renderSearchWithWrapper=function renderSearchWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Search"}),children:renderSearch(props)})};var renderTableWithWrapper=function renderTableWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Table"}),children:renderTable(props)})};var renderTabWithWrapper=function renderTabWithWrapper(props){return/*#__PURE__*/_jsx(ComponentWrapper,{componentProps:_extends({},props,{componentType:"Tabs"}),children:renderTab(props)})};export function getRenderers(){return{ActionCard:renderActionCardWithWrapper,Button:renderButtonWithWrapper,Card:renderCardWithWrapper,Chart:renderChartWithWrapper,Filter:renderFilterWithWrapper,Markdown:renderMarkdownWithWrapper,Search:renderSearchWithWrapper,Table:renderTableWithWrapper,Tabs:renderTabWithWrapper}}
10
15
  //# sourceMappingURL=render-components.js.map