@epam/statgpt-conversation-view 0.7.0-dev.3 → 0.7.0-dev.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,13 +1,13 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),f=require("react"),Ie=require("@epam/ai-dial-shared"),j=require("@epam/statgpt-ui-components"),He=require("@tabler/icons-react"),W=require("classnames"),we=require("@epam/statgpt-dial-toolkit"),ne=require("@epam/statgpt-shared-toolkit"),hd=require("@epam/statgpt-conversation-list"),yl=require("react-markdown"),Sl=require("remark-gfm"),D=require("@epam/statgpt-sdmx-toolkit"),md=require("react-window"),pd=require("react-virtualized-auto-sizer"),Qe=require("@floating-ui/react"),Wa=require("ag-grid-community"),Rr=require("lodash"),Dl=require("echarts-for-react"),Pr=require("ag-grid-react"),gd=require("tailwind-merge"),$a=require("date-fns"),vd=require("@monaco-editor/react");function Cd(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Ne=Cd(f),Tl=f.createContext(void 0),wd=({children:e})=>{const[t,n]=f.useState(!1);return o.jsx(Tl.Provider,{value:{isOpenedAdvancedView:t,setIsOpenedAdvancedView:n},children:e})},qe=()=>{const e=f.useContext(Tl);if(e===void 0)throw new Error("useAdvancedView must be used within a AdvancedViewProvider");return e},Ml=f.createContext(void 0),bd=({children:e})=>{const[t,n]=f.useState(!1);return o.jsx(Ml.Provider,{value:{isStreaming:t,setIsStreaming:n},children:e})},Al=()=>{const e=f.useContext(Ml);if(e===void 0)throw new Error("useChatMessages must be used within a ChatMessagesProvider");return e},El=f.createContext(null);function xd({value:e,children:t}){const n=f.useMemo(()=>e,[e]);return o.jsx(El.Provider,{value:n,children:t})}function Lr(){const e=f.useContext(El);if(!e)throw new Error("useConversationViewMessages must be used within ConversationViewMessagesProvider");return e}const Nl=f.createContext(void 0),yd=({children:e})=>{const[t,n]=f.useState(""),[s,r]=f.useState(""),[a,i]=f.useState(),[c,l]=f.useState();return o.jsx(Nl.Provider,{value:{onboardingFileName:t,onboardingFilePath:s,isShowOnboarding:a,onboardingFileSchema:c,setOnboardingFileName:n,setOnboardingFilePath:r,setIsShowOnboarding:i,setOnboardingFileSchema:l},children:e})},Ze=()=>{const e=f.useContext(Nl);if(e===void 0)throw new Error("useOnboarding must be used within a OnboardingProvider");return e};var cn=(e=>(e.CHOICE="choice",e.COMPLETION="completion",e))(cn||{}),vn=(e=>(e.COMPLETE="complete",e))(vn||{}),jl=(e=>(e.COMPLETED="completed",e))(jl||{}),un=(e=>(e.PREVIOUS="previous",e.NEXT="next",e))(un||{});const kl=({inProcess:e,disabled:t,containerClasses:n,inputClasses:s,placeholder:r,sendMessageIcon:a,isLastFailed:i,retryIcon:c,onSendMessage:l,onStopStreaming:d,onRetryFailed:u})=>{const[h,m]=f.useState(""),p=f.useCallback(w=>{m(w)},[m]),g=w=>{e||t||(m(""),l(w))},x=w=>{t||w.key===j.KeyboardKey.Enter&&!w.shiftKey&&(i?u?.():g(h.trim()))},v=()=>t?null:i?o.jsx(j.IconButton,{buttonClassName:"input-for-ask-button",onClick:()=>u?.(),icon:c||o.jsx(He.IconRefresh,{})}):e?o.jsx(j.IconButton,{buttonClassName:"input-for-ask-button",onClick:()=>d?.(),icon:o.jsx(He.IconPlayerStopFilled,{})}):h?o.jsx(j.IconButton,{buttonClassName:"input-for-ask-button",onClick:()=>g(h),icon:a}):null;return o.jsx(j.InputWithIcon,{inputId:"ask-input",containerClasses:n,placeholder:r,onChange:p,onKeyDown:x,disabled:t,cssClass:W(s,"input-for-ask"),value:h,iconAfterInput:v()})},Ka=160,Sd=':;,=/{}%&\\"',Dd=new RegExp(`[${Sd}]|(\r
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),f=require("react"),Pe=require("@epam/ai-dial-shared"),j=require("@epam/statgpt-ui-components"),qe=require("@tabler/icons-react"),$=require("classnames"),ve=require("@epam/statgpt-dial-toolkit"),ne=require("@epam/statgpt-shared-toolkit"),hd=require("@epam/statgpt-conversation-list"),yl=require("react-markdown"),Sl=require("remark-gfm"),D=require("@epam/statgpt-sdmx-toolkit"),md=require("react-window"),pd=require("react-virtualized-auto-sizer"),et=require("@floating-ui/react"),Wa=require("ag-grid-community"),Rr=require("lodash"),Dl=require("echarts-for-react"),Pr=require("ag-grid-react"),gd=require("tailwind-merge"),$a=require("date-fns"),vd=require("@monaco-editor/react");function Cd(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Ee=Cd(f),Tl=f.createContext(void 0),wd=({children:e})=>{const[t,n]=f.useState(!1);return o.jsx(Tl.Provider,{value:{isOpenedAdvancedView:t,setIsOpenedAdvancedView:n},children:e})},$e=()=>{const e=f.useContext(Tl);if(e===void 0)throw new Error("useAdvancedView must be used within a AdvancedViewProvider");return e},Ml=f.createContext(void 0),bd=({children:e})=>{const[t,n]=f.useState(!1);return o.jsx(Ml.Provider,{value:{isStreaming:t,setIsStreaming:n},children:e})},Al=()=>{const e=f.useContext(Ml);if(e===void 0)throw new Error("useChatMessages must be used within a ChatMessagesProvider");return e},El=f.createContext(null);function xd({value:e,children:t}){const n=f.useMemo(()=>e,[e]);return o.jsx(El.Provider,{value:n,children:t})}function Lr(){const e=f.useContext(El);if(!e)throw new Error("useConversationViewMessages must be used within ConversationViewMessagesProvider");return e}const Nl=f.createContext(void 0),yd=({children:e})=>{const[t,n]=f.useState(""),[s,r]=f.useState(""),[a,i]=f.useState(),[c,l]=f.useState();return o.jsx(Nl.Provider,{value:{onboardingFileName:t,onboardingFilePath:s,isShowOnboarding:a,onboardingFileSchema:c,setOnboardingFileName:n,setOnboardingFilePath:r,setIsShowOnboarding:i,setOnboardingFileSchema:l},children:e})},Xe=()=>{const e=f.useContext(Nl);if(e===void 0)throw new Error("useOnboarding must be used within a OnboardingProvider");return e};var cn=(e=>(e.CHOICE="choice",e.COMPLETION="completion",e))(cn||{}),vn=(e=>(e.COMPLETE="complete",e))(vn||{}),jl=(e=>(e.COMPLETED="completed",e))(jl||{}),un=(e=>(e.PREVIOUS="previous",e.NEXT="next",e))(un||{});const kl=({inProcess:e,disabled:t,containerClasses:n,inputClasses:s,placeholder:r,sendMessageIcon:a,isLastFailed:i,retryIcon:c,onSendMessage:l,onStopStreaming:d,onRetryFailed:u})=>{const[h,m]=f.useState(""),p=f.useCallback(w=>{m(w)},[m]),g=w=>{e||t||(m(""),l(w))},x=w=>{t||w.key===j.KeyboardKey.Enter&&!w.shiftKey&&(i?u?.():g(h.trim()))},v=()=>t?null:i?o.jsx(j.IconButton,{buttonClassName:"input-for-ask-button",onClick:()=>u?.(),icon:c||o.jsx(qe.IconRefresh,{})}):e?o.jsx(j.IconButton,{buttonClassName:"input-for-ask-button",onClick:()=>d?.(),icon:o.jsx(qe.IconPlayerStopFilled,{})}):h?o.jsx(j.IconButton,{buttonClassName:"input-for-ask-button",onClick:()=>g(h),icon:a}):null;return o.jsx(j.InputWithIcon,{inputId:"ask-input",containerClasses:n,placeholder:r,onChange:p,onKeyDown:x,disabled:t,cssClass:$(s,"input-for-ask"),value:h,iconAfterInput:v()})},Ka=160,Sd=':;,=/{}%&\\"',Dd=new RegExp(`[${Sd}]|(\r
2
2
  |
3
3
  |\r| )|[\0-]`,"gm"),Td=(e,t,n,s)=>({name:Md(s||`${n} ${new Date().toLocaleDateString()}`),folderId:`${e}/${t}`,prompt:s}),Md=e=>{const t=e?.replace(/\r\n|\r/gm,`
4
4
  `).split(`
5
- `).map(s=>s.replace(Dd," ").trim()).filter(Boolean)[0]??"";return(t.length>Ka?t.substring(0,Ka):t).trim()},Ad=(e,t,n,s,r,a)=>{const i=`${e}/${t}`;return{name:n,folderId:i,prompt:r,id:we.generateConversationId({folderId:i,name:n}),messages:[{role:Ie.Role.Assistant,content:s}],custom_fields:{configuration:{choice:a}}}},_l=f.createContext(null);function Cn({children:e,styles:t}){return o.jsx(_l.Provider,{value:t??{},children:e})}function Me(){const e=f.useContext(_l);if(!e)throw new Error("useConversationViewStyles must be used within ConversationViewStylesProvider");return e}var Ed=Object.defineProperty,dn=Object.getOwnPropertySymbols,Il=Object.prototype.hasOwnProperty,Rl=Object.prototype.propertyIsEnumerable,Ja=(e,t,n)=>t in e?Ed(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Dr=(e,t)=>{for(var n in t||(t={}))Il.call(t,n)&&Ja(e,n,t[n]);if(dn)for(var n of dn(t))Rl.call(t,n)&&Ja(e,n,t[n]);return e},Tr=(e,t)=>{var n={};for(var s in e)Il.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&dn)for(var s of dn(e))t.indexOf(s)<0&&Rl.call(e,s)&&(n[s]=e[s]);return n};var yt;(e=>{const t=class Te{constructor(l,d,u,h){if(this.version=l,this.errorCorrectionLevel=d,this.modules=[],this.isFunction=[],l<Te.MIN_VERSION||l>Te.MAX_VERSION)throw new RangeError("Version value out of range");if(h<-1||h>7)throw new RangeError("Mask value out of range");this.size=l*4+17;let m=[];for(let g=0;g<this.size;g++)m.push(!1);for(let g=0;g<this.size;g++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const p=this.addEccAndInterleave(u);if(this.drawCodewords(p),h==-1){let g=1e9;for(let x=0;x<8;x++){this.applyMask(x),this.drawFormatBits(x);const v=this.getPenaltyScore();v<g&&(h=x,g=v),this.applyMask(x)}}r(0<=h&&h<=7),this.mask=h,this.applyMask(h),this.drawFormatBits(h),this.isFunction=[]}static encodeText(l,d){const u=e.QrSegment.makeSegments(l);return Te.encodeSegments(u,d)}static encodeBinary(l,d){const u=e.QrSegment.makeBytes(l);return Te.encodeSegments([u],d)}static encodeSegments(l,d,u=1,h=40,m=-1,p=!0){if(!(Te.MIN_VERSION<=u&&u<=h&&h<=Te.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let g,x;for(g=u;;g++){const b=Te.getNumDataCodewords(g,d)*8,y=i.getTotalBits(l,g);if(y<=b){x=y;break}if(g>=h)throw new RangeError("Data too long")}for(const b of[Te.Ecc.MEDIUM,Te.Ecc.QUARTILE,Te.Ecc.HIGH])p&&x<=Te.getNumDataCodewords(g,b)*8&&(d=b);let v=[];for(const b of l){n(b.mode.modeBits,4,v),n(b.numChars,b.mode.numCharCountBits(g),v);for(const y of b.getData())v.push(y)}r(v.length==x);const w=Te.getNumDataCodewords(g,d)*8;r(v.length<=w),n(0,Math.min(4,w-v.length),v),n(0,(8-v.length%8)%8,v),r(v.length%8==0);for(let b=236;v.length<w;b^=253)n(b,8,v);let C=[];for(;C.length*8<v.length;)C.push(0);return v.forEach((b,y)=>C[y>>>3]|=b<<7-(y&7)),new Te(g,d,C,m)}getModule(l,d){return 0<=l&&l<this.size&&0<=d&&d<this.size&&this.modules[d][l]}getModules(){return this.modules}drawFunctionPatterns(){for(let u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const l=this.getAlignmentPatternPositions(),d=l.length;for(let u=0;u<d;u++)for(let h=0;h<d;h++)u==0&&h==0||u==0&&h==d-1||u==d-1&&h==0||this.drawAlignmentPattern(l[u],l[h]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(l){const d=this.errorCorrectionLevel.formatBits<<3|l;let u=d;for(let m=0;m<10;m++)u=u<<1^(u>>>9)*1335;const h=(d<<10|u)^21522;r(h>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,s(h,m));this.setFunctionModule(8,7,s(h,6)),this.setFunctionModule(8,8,s(h,7)),this.setFunctionModule(7,8,s(h,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,s(h,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,s(h,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,s(h,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let l=this.version;for(let u=0;u<12;u++)l=l<<1^(l>>>11)*7973;const d=this.version<<12|l;r(d>>>18==0);for(let u=0;u<18;u++){const h=s(d,u),m=this.size-11+u%3,p=Math.floor(u/3);this.setFunctionModule(m,p,h),this.setFunctionModule(p,m,h)}}drawFinderPattern(l,d){for(let u=-4;u<=4;u++)for(let h=-4;h<=4;h++){const m=Math.max(Math.abs(h),Math.abs(u)),p=l+h,g=d+u;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,m!=2&&m!=4)}}drawAlignmentPattern(l,d){for(let u=-2;u<=2;u++)for(let h=-2;h<=2;h++)this.setFunctionModule(l+h,d+u,Math.max(Math.abs(h),Math.abs(u))!=1)}setFunctionModule(l,d,u){this.modules[d][l]=u,this.isFunction[d][l]=!0}addEccAndInterleave(l){const d=this.version,u=this.errorCorrectionLevel;if(l.length!=Te.getNumDataCodewords(d,u))throw new RangeError("Invalid argument");const h=Te.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][d],m=Te.ECC_CODEWORDS_PER_BLOCK[u.ordinal][d],p=Math.floor(Te.getNumRawDataModules(d)/8),g=h-p%h,x=Math.floor(p/h);let v=[];const w=Te.reedSolomonComputeDivisor(m);for(let b=0,y=0;b<h;b++){let N=l.slice(y,y+x-m+(b<g?0:1));y+=N.length;const M=Te.reedSolomonComputeRemainder(N,w);b<g&&N.push(0),v.push(N.concat(M))}let C=[];for(let b=0;b<v[0].length;b++)v.forEach((y,N)=>{(b!=x-m||N>=g)&&C.push(y[b])});return r(C.length==p),C}drawCodewords(l){if(l.length!=Math.floor(Te.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let d=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let h=0;h<this.size;h++)for(let m=0;m<2;m++){const p=u-m,x=(u+1&2)==0?this.size-1-h:h;!this.isFunction[x][p]&&d<l.length*8&&(this.modules[x][p]=s(l[d>>>3],7-(d&7)),d++)}}r(d==l.length*8)}applyMask(l){if(l<0||l>7)throw new RangeError("Mask value out of range");for(let d=0;d<this.size;d++)for(let u=0;u<this.size;u++){let h;switch(l){case 0:h=(u+d)%2==0;break;case 1:h=d%2==0;break;case 2:h=u%3==0;break;case 3:h=(u+d)%3==0;break;case 4:h=(Math.floor(u/3)+Math.floor(d/2))%2==0;break;case 5:h=u*d%2+u*d%3==0;break;case 6:h=(u*d%2+u*d%3)%2==0;break;case 7:h=((u+d)%2+u*d%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[d][u]&&h&&(this.modules[d][u]=!this.modules[d][u])}}getPenaltyScore(){let l=0;for(let m=0;m<this.size;m++){let p=!1,g=0,x=[0,0,0,0,0,0,0];for(let v=0;v<this.size;v++)this.modules[m][v]==p?(g++,g==5?l+=Te.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,x),p||(l+=this.finderPenaltyCountPatterns(x)*Te.PENALTY_N3),p=this.modules[m][v],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,x)*Te.PENALTY_N3}for(let m=0;m<this.size;m++){let p=!1,g=0,x=[0,0,0,0,0,0,0];for(let v=0;v<this.size;v++)this.modules[v][m]==p?(g++,g==5?l+=Te.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,x),p||(l+=this.finderPenaltyCountPatterns(x)*Te.PENALTY_N3),p=this.modules[v][m],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,x)*Te.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let p=0;p<this.size-1;p++){const g=this.modules[m][p];g==this.modules[m][p+1]&&g==this.modules[m+1][p]&&g==this.modules[m+1][p+1]&&(l+=Te.PENALTY_N2)}let d=0;for(const m of this.modules)d=m.reduce((p,g)=>p+(g?1:0),d);const u=this.size*this.size,h=Math.ceil(Math.abs(d*20-u*10)/u)-1;return r(0<=h&&h<=9),l+=h*Te.PENALTY_N4,r(0<=l&&l<=2568888),l}getAlignmentPatternPositions(){if(this.version==1)return[];{const l=Math.floor(this.version/7)+2,d=this.version==32?26:Math.ceil((this.version*4+4)/(l*2-2))*2;let u=[6];for(let h=this.size-7;u.length<l;h-=d)u.splice(1,0,h);return u}}static getNumRawDataModules(l){if(l<Te.MIN_VERSION||l>Te.MAX_VERSION)throw new RangeError("Version number out of range");let d=(16*l+128)*l+64;if(l>=2){const u=Math.floor(l/7)+2;d-=(25*u-10)*u-55,l>=7&&(d-=36)}return r(208<=d&&d<=29648),d}static getNumDataCodewords(l,d){return Math.floor(Te.getNumRawDataModules(l)/8)-Te.ECC_CODEWORDS_PER_BLOCK[d.ordinal][l]*Te.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][l]}static reedSolomonComputeDivisor(l){if(l<1||l>255)throw new RangeError("Degree out of range");let d=[];for(let h=0;h<l-1;h++)d.push(0);d.push(1);let u=1;for(let h=0;h<l;h++){for(let m=0;m<d.length;m++)d[m]=Te.reedSolomonMultiply(d[m],u),m+1<d.length&&(d[m]^=d[m+1]);u=Te.reedSolomonMultiply(u,2)}return d}static reedSolomonComputeRemainder(l,d){let u=d.map(h=>0);for(const h of l){const m=h^u.shift();u.push(0),d.forEach((p,g)=>u[g]^=Te.reedSolomonMultiply(p,m))}return u}static reedSolomonMultiply(l,d){if(l>>>8||d>>>8)throw new RangeError("Byte out of range");let u=0;for(let h=7;h>=0;h--)u=u<<1^(u>>>7)*285,u^=(d>>>h&1)*l;return r(u>>>8==0),u}finderPenaltyCountPatterns(l){const d=l[1];r(d<=this.size*3);const u=d>0&&l[2]==d&&l[3]==d*3&&l[4]==d&&l[5]==d;return(u&&l[0]>=d*4&&l[6]>=d?1:0)+(u&&l[6]>=d*4&&l[0]>=d?1:0)}finderPenaltyTerminateAndCount(l,d,u){return l&&(this.finderPenaltyAddHistory(d,u),d=0),d+=this.size,this.finderPenaltyAddHistory(d,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(l,d){d[0]==0&&(l+=this.size),d.pop(),d.unshift(l)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(c,l,d){if(l<0||l>31||c>>>l)throw new RangeError("Value out of range");for(let u=l-1;u>=0;u--)d.push(c>>>u&1)}function s(c,l){return(c>>>l&1)!=0}function r(c){if(!c)throw new Error("Assertion error")}const a=class Oe{constructor(l,d,u){if(this.mode=l,this.numChars=d,this.bitData=u,d<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(l){let d=[];for(const u of l)n(u,8,d);return new Oe(Oe.Mode.BYTE,l.length,d)}static makeNumeric(l){if(!Oe.isNumeric(l))throw new RangeError("String contains non-numeric characters");let d=[];for(let u=0;u<l.length;){const h=Math.min(l.length-u,3);n(parseInt(l.substring(u,u+h),10),h*3+1,d),u+=h}return new Oe(Oe.Mode.NUMERIC,l.length,d)}static makeAlphanumeric(l){if(!Oe.isAlphanumeric(l))throw new RangeError("String contains unencodable characters in alphanumeric mode");let d=[],u;for(u=0;u+2<=l.length;u+=2){let h=Oe.ALPHANUMERIC_CHARSET.indexOf(l.charAt(u))*45;h+=Oe.ALPHANUMERIC_CHARSET.indexOf(l.charAt(u+1)),n(h,11,d)}return u<l.length&&n(Oe.ALPHANUMERIC_CHARSET.indexOf(l.charAt(u)),6,d),new Oe(Oe.Mode.ALPHANUMERIC,l.length,d)}static makeSegments(l){return l==""?[]:Oe.isNumeric(l)?[Oe.makeNumeric(l)]:Oe.isAlphanumeric(l)?[Oe.makeAlphanumeric(l)]:[Oe.makeBytes(Oe.toUtf8ByteArray(l))]}static makeEci(l){let d=[];if(l<0)throw new RangeError("ECI assignment value out of range");if(l<128)n(l,8,d);else if(l<16384)n(2,2,d),n(l,14,d);else if(l<1e6)n(6,3,d),n(l,21,d);else throw new RangeError("ECI assignment value out of range");return new Oe(Oe.Mode.ECI,0,d)}static isNumeric(l){return Oe.NUMERIC_REGEX.test(l)}static isAlphanumeric(l){return Oe.ALPHANUMERIC_REGEX.test(l)}getData(){return this.bitData.slice()}static getTotalBits(l,d){let u=0;for(const h of l){const m=h.mode.numCharCountBits(d);if(h.numChars>=1<<m)return 1/0;u+=4+m+h.bitData.length}return u}static toUtf8ByteArray(l){l=encodeURI(l);let d=[];for(let u=0;u<l.length;u++)l.charAt(u)!="%"?d.push(l.charCodeAt(u)):(d.push(parseInt(l.substring(u+1,u+3),16)),u+=2);return d}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let i=a;e.QrSegment=a})(yt||(yt={}));(e=>{(t=>{const n=class{constructor(r,a){this.ordinal=r,this.formatBits=a}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),t.Ecc=n})(e.QrCode||(e.QrCode={}))})(yt||(yt={}));(e=>{(t=>{const n=class{constructor(r,a){this.modeBits=r,this.numBitsCharCount=a}numCharCountBits(r){return this.numBitsCharCount[Math.floor((r+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),t.Mode=n})(e.QrSegment||(e.QrSegment={}))})(yt||(yt={}));var Tt=yt;var Nd={L:Tt.QrCode.Ecc.LOW,M:Tt.QrCode.Ecc.MEDIUM,Q:Tt.QrCode.Ecc.QUARTILE,H:Tt.QrCode.Ecc.HIGH},Pl=128,Ll="L",Ol="#FFFFFF",Fl="#000000",Vl=!1,Hl=1,jd=4,kd=0,_d=.1;function Ul(e,t=0){const n=[];return e.forEach(function(s,r){let a=null;s.forEach(function(i,c){if(!i&&a!==null){n.push(`M${a+t} ${r+t}h${c-a}v1H${a+t}z`),a=null;return}if(c===s.length-1){if(!i)return;a===null?n.push(`M${c+t},${r+t} h1v1H${c+t}z`):n.push(`M${a+t},${r+t} h${c+1-a}v1H${a+t}z`);return}i&&a===null&&(a=c)})}),n.join("")}function Gl(e,t){return e.slice().map((n,s)=>s<t.y||s>=t.y+t.h?n:n.map((r,a)=>a<t.x||a>=t.x+t.w?r:!1))}function Id(e,t,n,s){if(s==null)return null;const r=e.length+n*2,a=Math.floor(t*_d),i=r/t,c=(s.width||a)*i,l=(s.height||a)*i,d=s.x==null?e.length/2-c/2:s.x*i,u=s.y==null?e.length/2-l/2:s.y*i,h=s.opacity==null?1:s.opacity;let m=null;if(s.excavate){let g=Math.floor(d),x=Math.floor(u),v=Math.ceil(c+d-g),w=Math.ceil(l+u-x);m={x:g,y:x,w:v,h:w}}const p=s.crossOrigin;return{x:d,y:u,h:l,w:c,excavation:m,opacity:h,crossOrigin:p}}function Rd(e,t){return t!=null?Math.max(Math.floor(t),0):e?jd:kd}function Bl({value:e,level:t,minVersion:n,includeMargin:s,marginSize:r,imageSettings:a,size:i,boostLevel:c}){let l=f.useMemo(()=>{const g=(Array.isArray(e)?e:[e]).reduce((x,v)=>(x.push(...Tt.QrSegment.makeSegments(v)),x),[]);return Tt.QrCode.encodeSegments(g,Nd[t],n,void 0,void 0,c)},[e,t,n,c]);const{cells:d,margin:u,numCells:h,calculatedImageSettings:m}=f.useMemo(()=>{let p=l.getModules();const g=Rd(s,r),x=p.length+g*2,v=Id(p,i,g,a);return{cells:p,margin:g,numCells:x,calculatedImageSettings:v}},[l,i,a,s,r]);return{qrcode:l,margin:u,cells:d,numCells:h,calculatedImageSettings:m}}var Pd=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Ld=f.forwardRef(function(t,n){const s=t,{value:r,size:a=Pl,level:i=Ll,bgColor:c=Ol,fgColor:l=Fl,includeMargin:d=Vl,minVersion:u=Hl,boostLevel:h,marginSize:m,imageSettings:p}=s,x=Tr(s,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:v}=x,w=Tr(x,["style"]),C=p?.src,b=f.useRef(null),y=f.useRef(null),N=f.useCallback(L=>{b.current=L,typeof n=="function"?n(L):n&&(n.current=L)},[n]),[M,A]=f.useState(!1),{margin:S,cells:_,numCells:E,calculatedImageSettings:T}=Bl({value:r,level:i,minVersion:u,boostLevel:h,includeMargin:d,marginSize:m,imageSettings:p,size:a});f.useEffect(()=>{if(b.current!=null){const L=b.current,H=L.getContext("2d");if(!H)return;let G=_;const Y=y.current,O=T!=null&&Y!==null&&Y.complete&&Y.naturalHeight!==0&&Y.naturalWidth!==0;O&&T.excavation!=null&&(G=Gl(_,T.excavation));const $=window.devicePixelRatio||1;L.height=L.width=a*$;const K=a/E*$;H.scale(K,K),H.fillStyle=c,H.fillRect(0,0,E,E),H.fillStyle=l,Pd?H.fill(new Path2D(Ul(G,S))):_.forEach(function(Z,se){Z.forEach(function(ge,he){ge&&H.fillRect(he+S,se+S,1,1)})}),T&&(H.globalAlpha=T.opacity),O&&H.drawImage(Y,T.x+S,T.y+S,T.w,T.h)}}),f.useEffect(()=>{A(!1)},[C]);const k=Dr({height:a,width:a},v);let I=null;return C!=null&&(I=f.createElement("img",{src:C,key:C,style:{display:"none"},onLoad:()=>{A(!0)},ref:y,crossOrigin:T?.crossOrigin})),f.createElement(f.Fragment,null,f.createElement("canvas",Dr({style:k,height:a,width:a,ref:N,role:"img"},w)),I)});Ld.displayName="QRCodeCanvas";var ql=f.forwardRef(function(t,n){const s=t,{value:r,size:a=Pl,level:i=Ll,bgColor:c=Ol,fgColor:l=Fl,includeMargin:d=Vl,minVersion:u=Hl,boostLevel:h,title:m,marginSize:p,imageSettings:g}=s,x=Tr(s,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:v,cells:w,numCells:C,calculatedImageSettings:b}=Bl({value:r,level:i,minVersion:u,boostLevel:h,includeMargin:d,marginSize:p,imageSettings:g,size:a});let y=w,N=null;g!=null&&b!=null&&(b.excavation!=null&&(y=Gl(w,b.excavation)),N=f.createElement("image",{href:g.src,height:b.h,width:b.w,x:b.x+v,y:b.y+v,preserveAspectRatio:"none",opacity:b.opacity,crossOrigin:b.crossOrigin}));const M=Ul(y,v);return f.createElement("svg",Dr({height:a,width:a,viewBox:`0 0 ${C} ${C}`,ref:n,role:"img"},x),!!m&&f.createElement("title",null,m),f.createElement("path",{fill:c,d:`M0,0 h${C}v${C}H0z`,shapeRendering:"crispEdges"}),f.createElement("path",{fill:l,d:M,shapeRendering:"crispEdges"}),N)});ql.displayName="QRCodeSVG";const Od=(e,t)=>({invitationType:we.InvitationType.LINK,resources:[{url:`conversations/${encodeURI(e)}`},...t]}),Fd=e=>{const t=e?.invitationLink?.split("/").at(-1)||"";return`/${ne.SHARE_CONVERSATION_ROUTE}/${t}`},Vd=(e,t)=>t?.find(n=>{const s=e?.id?.split("/")?.pop(),r=n?.url?.split("/")?.pop()||"";return r===s||decodeURI(r)===s}),Hd=e=>e?.messages?.filter(n=>!!n?.custom_content?.attachments)?.flatMap(n=>n?.custom_content?.attachments?.map(s=>({url:s?.url||""}))||[])?.filter(n=>!!n?.url)||[],Ud=({conversation:e,locale:t,onCloseModal:n,modalDividers:s,getConversation:r,generateConversationLink:a,chatExpiration:i,chatExpirationDays:c,close:l,chatWarning:d,shareLink:u,shareCopyLink:h,shareCopiedLink:m,shareDescription:p,shareRemoveAccessToUsers:g,chatName:x,getSharedConversations:v,revokeSharedConversations:w,baseUrl:C,id:b,clientSharedPage:y,clientSharedProp:N,shareAlertMessage:M})=>{const[A,S]=f.useState(null),[_,E]=f.useState(),[T,k]=f.useState(!1),[I,L]=f.useState(!1),[H,G]=f.useState(),Y=f.useRef(null),O=f.useRef(null),$=f.useMemo(()=>e?.id?decodeURI(e.id):b?.[0]&&b?.[1]&&t?decodeURI(`${b[0]}/${t}/${b[1]}`):null,[e?.id,b,t]),K=f.useMemo(()=>{if(!A)return"";const F=C||window.location.origin;if(C&&C!==window.location.origin&&y&&N){const J=A.split(`/${ne.SHARE_CONVERSATION_ROUTE}/`)?.[1];return`${F}/${y}?${N}=${J}`}return`${F}/${t}${A}`},[C,A,t,y,N]),Z=f.useCallback(async F=>{const J=await v?.(we.getSharedConversationsRequest(we.ShareTarget.OTHERS));if(J)return Vd({id:F},J.resources)},[v]);f.useEffect(()=>{if(!$||Y.current===$)return;Y.current=$,k(!1),O.current?.abort();const F=new AbortController;return O.current=F,(async()=>{try{const ue=await r?.($),de=Od($,Hd(ue)),me=await a?.(de),re=await Z($);if(F.signal.aborted||!me)return;S(Fd(me)),E(re),k(!0)}catch(ue){if(F.signal.aborted)return;k(!1),console.error("Error sharing conversation",ue)}})(),()=>{F.abort(),Y.current=null}},[$,a,r,Z]);const se=f.useCallback(()=>{O.current?.abort(),Y.current=null,n(),S(null),k(!1),L(!1)},[n]),ge=f.useCallback(()=>{L(!0),navigator.clipboard.writeText(K||"")},[K]),he=async()=>{try{if(G(!0),_&&await w?.({resources:[_]}),$){const F=await Z($);O.current?.signal.aborted||E(F)}}catch(F){console.error("Error revoking shared conversation",F)}finally{O.current?.signal.aborted||G(!1)}},xe=f.useCallback(()=>o.jsx(j.Button,{buttonClassName:I?"text-button-secondary":"text-button-primary",iconBefore:I?o.jsx(He.IconCheck,{width:20,height:20}):o.jsx(He.IconCopy,{width:20,height:20}),title:I?m??"Copied":h??"Copy link",disabled:I,onClick:ge}),[I,ge,m,h]);return o.jsxs(j.Popup,{heading:u??"Share link",portalId:"share",size:j.PopUpSize.SM,dividers:s,onClose:se,closeButtonTitle:l??"Close",children:[T?o.jsxs("div",{className:"share flex flex-col gap-y-4 overflow-auto px-6 pb-6 sm:p-0",children:[M?o.jsx(j.InlineAlert,{type:j.InlineAlertType.Note,icon:o.jsx(He.IconInfoCircle,{width:16,height:16}),children:M}):null,e?.name?o.jsxs("div",{className:"share-info flex w-full",children:[o.jsx("p",{className:"share-info-title body-1 mr-1 text-neutrals-800",children:x??"Chat name:"}),o.jsx("h3",{className:"min-w-0 flex-1 truncate",title:e?.name,children:e?.name})]}):null,o.jsxs("div",{className:"share-info flex",children:[o.jsx("p",{className:"share-info-title body-1 mr-1 text-neutrals-800",children:i??"Link expiration date:"}),o.jsxs("h3",{children:["3 ",c??"days"]})]}),o.jsx(ql,{className:"min-h-[200px] self-center rounded border border-neutrals-600 p-2",value:K,size:200}),o.jsx("p",{className:"body-2 text-neutrals-1000",children:p??"Your name, special instructions, and any messages you add after sharing remain confidential."}),o.jsx(j.InputWithIcon,{containerClasses:"share-input-container",cssClass:"share-input",readonly:!0,placeholder:K,value:K,inputId:"conversationLink",iconAfterInput:xe()})]}):o.jsx("div",{className:"flex items-center justify-center p-6",children:o.jsx(j.Loader,{})}),T?e&&_?o.jsx("div",{className:"remove-access",children:o.jsx(j.Button,{title:g??"Remove access to all users",buttonClassName:"remove-access-button py-3 px-4",isSmallButton:!0,disabled:H,onClick:he})}):o.jsx("p",{className:"body-2 share-footer text-neutrals-800",children:d??"This chat has not been shared with anyone yet."}):o.jsx("div",{})]})},zl=({shareButtonClass:e,shareIcon:t,...n})=>{const[s,r]=f.useState(j.PopUpState.Closed),a=()=>{r(j.PopUpState.Opened)},i=f.useCallback(()=>{r(j.PopUpState.Closed)},[]);return o.jsxs(o.Fragment,{children:[o.jsx(j.Button,{buttonClassName:e||"text-button-secondary",title:n?.share||"Share",iconBefore:t,onClick:a}),s===j.PopUpState.Opened&&o.jsx(Ud,{onCloseModal:i,...n})]})},Wl=({conversation:e,locale:t,isOpenedAdvancedView:n,isShowShareButton:s,shareConversationProps:r,rightSlot:a})=>o.jsx(o.Fragment,{children:o.jsxs("header",{className:W("bg-white border-b px-6 py-2 border-gray-200 flex justify-between items-center sm:hidden","conversation-view-header"),children:[o.jsx("span",{className:W("flex-1 min-w-0 truncate h4","conversation-view-header-text"),title:e?.name,children:e?.name}),o.jsxs("div",{className:"ml-3 flex items-center gap-4",children:[!n&&s&&o.jsx("div",{className:"flex gap-x-2",children:o.jsx(zl,{conversation:e,locale:t,...r})}),a]})]})}),$l=({content:e,textColorClass:t})=>{const{isOpenedAdvancedView:n}=qe();return o.jsx("div",{className:W("prose max-w-none break-words",n?"body-2":"body-1",t),children:o.jsx(yl,{remarkPlugins:[Sl],components:{strong:s=>o.jsx("strong",{className:t,...s}),a:({href:s,children:r,...a})=>o.jsx("a",{href:s,target:"_blank",rel:"noreferrer",...a,children:r})},children:e})})},Kl=({choiceButtons:e,disabled:t,onClick:n})=>{const s=W("flex w-full min-h-[72px] flex-col items-start justify-center rounded border px-4 py-2 text-left","border-hues-200 hover:bg-hues-100","disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent");return e.map(r=>o.jsx("div",{className:"mt-4",children:o.jsxs("button",{type:"button",className:s,disabled:t,onClick:()=>n(r[Ie.DialSchemaProperties.DialWidgetOptions]?.populateText,r?.const),"aria-label":"button",children:[o.jsx("h3",{className:"mb-1",children:r.title}),r.const!==vn.COMPLETE&&o.jsx("p",{className:"body-1 text-neutrals-800",children:r[Ie.DialSchemaProperties.DialWidgetOptions]?.populateText})]})},r.title))},Gd=({messageContent:e,choiceButtons:t,disabled:n,onClick:s,handleOnboardingSkip:r})=>{const{titles:a}=Me();return o.jsxs("div",{className:"onboarding flex size-full flex-1 flex-col overflow-auto",children:[o.jsx(Wl,{conversation:{name:a?.onboardingTitle??"Introducing the AI assistant"}}),o.jsxs("div",{className:"onboarding-content flex flex-col",children:[o.jsx($l,{content:e}),o.jsx("div",{className:"mt-4",children:o.jsx(Kl,{choiceButtons:t,disabled:n,onClick:s})}),o.jsxs("div",{className:"mt-8 flex",children:[o.jsx(j.Button,{title:a?.skipOnboardingNow,buttonClassName:"text-button-secondary mr-4",disabled:n,onClick:()=>r?.(),isSmallButton:!0}),o.jsx(j.Button,{title:a?.refuseOnboarding,buttonClassName:"text-button-tertiary",disabled:n,onClick:()=>r?.(!0),isSmallButton:!0})]})]})]})},Jl=({openNewConversation:e})=>{const{titles:t}=Me();return o.jsxs("div",{className:"body-3 bg-accent-300 p-2 text-center",children:[o.jsx("span",{className:"mr-2 text-neutrals-900",children:t?.onboardingFooter}),o.jsxs("span",{onClick:e,className:"inline-flex cursor-pointer align-top",children:[o.jsx(He.IconPlus,{width:15,height:15}),o.jsx("p",{className:"ml-1",children:t?.onboardingFooterLink})]})]})},Yl=({firstLine:e,secondLine:t})=>{const n=e!=null&&e.trim()!=="",s=t!=null&&t.trim()!=="";return o.jsxs("div",{className:W("text-center body-3",s?"p-0":n?"p-1":"p-3"),children:[n&&o.jsx("div",{className:"text-neutrals-800",children:e}),s&&o.jsx("div",{className:"text-neutrals-800",children:t})]})},Bd=({suggestionsList:e,welcomeText:t,welcomeDescription:n,welcomeInputPlaceholder:s,titleIcon:r,actions:a,titles:i,inputMessageStyles:c,suggestionsContainerClass:l,isBottomInputPosition:d,prompt:u,onboardingMessageSchema:h,handleConversationClick:m,setConversations:p,locale:g,setSharedConversations:x})=>{const[v,w]=f.useState(null),[C,b]=f.useState(!0),[y,N]=f.useState(!1),{onboardingFileSchema:M,onboardingFileName:A,onboardingFilePath:S,isShowOnboarding:_,setIsShowOnboarding:E,setOnboardingFileSchema:T}=Ze(),{isAgentAvailable:k}=j.useAgentAvailability(),{statusMessages:I}=Lr();f.useEffect(()=>{(async()=>{try{const O=await a.getBucket();w(O.bucket)}catch(O){console.error(O instanceof Error?O.message:"Request error")}finally{b(!1)}})()},[a]);const L=f.useCallback(async(Y,O)=>{if(!v){console.error("No bucket");return}N(!0);try{const $=_?Ad(v,g,i?.onboardingTitle??"Introducing the AI assistant",h?.properties?.choice?.description??"",Y,O):Td(v,g,i.newChat??"New chat",Y),K=await a.createConversation($,g,_),Z=await a.getConversations(g),se=await a.getSharedConversations(we.getSharedConversationsRequest(we.ShareTarget.ME));if(h&&M){const ge={...M,isStarted:!0};await a.putOnboardingFile?.(A,S,ge),T?.(ge)}p(ne.cleanConversationNames(Z)),x(ne.cleanConversationNames(hd.transformSharedConversations(se,g))),m(K.folderId,K.id)}catch($){console.error($ instanceof Error?$.message:"Creation conversation failed"),N(!1)}},[a,v,m,_,g,A,S,M,h,p,T,x,i.newChat,i?.onboardingTitle]),H=f.useCallback(async Y=>{if(E(!1),Y&&M){const O={...M,isSkipped:!0};await a.putOnboardingFile?.(A,S,O),T?.(O)}},[a,A,S,M,E,T]);f.useEffect(()=>{u&&v&&L(u)},[v,u]);const G=()=>{const Y=!v;return k?o.jsxs(o.Fragment,{children:[o.jsx(kl,{containerClasses:W(c.inputContainerClass,d&&"order-3 mt-auto"),inputClasses:"mr-2",disabled:Y,placeholder:s||i?.askAnything||"Ask anything...",sendMessageIcon:c.sendMessageIcon,onSendMessage:L}),o.jsx("div",{className:W("no-scrollbar overflow-x-auto",l),children:o.jsx("div",{className:W("flex flex-wrap justify-center gap-2","tags-container"),children:e.map(O=>o.jsx(j.Tag,{title:O.title,text:O[Ie.DialSchemaProperties.DialWidgetOptions]?.populateText,disabled:Y,onClick:L},O.title))})})]}):o.jsx(j.InlineAlert,{type:j.InlineAlertType.Error,children:I.assistantUnavailable})};return o.jsx(Cn,{styles:{titles:i},children:o.jsxs("div",{className:"flex size-full flex-col",children:[y||u&&C?o.jsx(j.Loader,{}):_?o.jsx(Gd,{messageContent:h?.properties?.choice?.description||"",choiceButtons:h?.properties?.choice?.oneOf||[],disabled:!v,handleOnboardingSkip:H,onClick:L}):o.jsxs("div",{className:"flex h-full flex-col items-center justify-center sm:px-4",children:[o.jsxs("div",{className:W("flex items-center max-w-full sm-min:px-4",d?"mt-auto mb-8":n?"mb-0":"mb-6"),children:[r,o.jsx("h1",{className:"sm:h2 text-hues-800 text-center",children:t??i?.welcomeTitle??"How can I help you?"})]}),n&&o.jsx("p",{className:"body-1 text-neutrals-900 mb-6 mt-3 max-w-[784px] text-center",children:n}),G()]}),_&&o.jsx(Jl,{openNewConversation:()=>E(!1)}),!_&&o.jsx(Yl,{firstLine:i.footerFirstLine,secondLine:i.footerSecondLine})]})})};var en=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Or(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Vn,Ya;function qd(){if(Ya)return Vn;Ya=1;function e(){this.__data__=[],this.size=0}return Vn=e,Vn}var Hn,Za;function Zl(){if(Za)return Hn;Za=1;function e(t,n){return t===n||t!==t&&n!==n}return Hn=e,Hn}var Un,Xa;function wn(){if(Xa)return Un;Xa=1;var e=Zl();function t(n,s){for(var r=n.length;r--;)if(e(n[r][0],s))return r;return-1}return Un=t,Un}var Gn,Qa;function zd(){if(Qa)return Gn;Qa=1;var e=wn(),t=Array.prototype,n=t.splice;function s(r){var a=this.__data__,i=e(a,r);if(i<0)return!1;var c=a.length-1;return i==c?a.pop():n.call(a,i,1),--this.size,!0}return Gn=s,Gn}var Bn,ei;function Wd(){if(ei)return Bn;ei=1;var e=wn();function t(n){var s=this.__data__,r=e(s,n);return r<0?void 0:s[r][1]}return Bn=t,Bn}var qn,ti;function $d(){if(ti)return qn;ti=1;var e=wn();function t(n){return e(this.__data__,n)>-1}return qn=t,qn}var zn,ni;function Kd(){if(ni)return zn;ni=1;var e=wn();function t(n,s){var r=this.__data__,a=e(r,n);return a<0?(++this.size,r.push([n,s])):r[a][1]=s,this}return zn=t,zn}var Wn,si;function bn(){if(si)return Wn;si=1;var e=qd(),t=zd(),n=Wd(),s=$d(),r=Kd();function a(i){var c=-1,l=i==null?0:i.length;for(this.clear();++c<l;){var d=i[c];this.set(d[0],d[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=r,Wn=a,Wn}var $n,ri;function Jd(){if(ri)return $n;ri=1;var e=bn();function t(){this.__data__=new e,this.size=0}return $n=t,$n}var Kn,ai;function Yd(){if(ai)return Kn;ai=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return Kn=e,Kn}var Jn,ii;function Zd(){if(ii)return Jn;ii=1;function e(t){return this.__data__.get(t)}return Jn=e,Jn}var Yn,oi;function Xd(){if(oi)return Yn;oi=1;function e(t){return this.__data__.has(t)}return Yn=e,Yn}var Zn,li;function Xl(){if(li)return Zn;li=1;var e=typeof en=="object"&&en&&en.Object===Object&&en;return Zn=e,Zn}var Xn,ci;function ht(){if(ci)return Xn;ci=1;var e=Xl(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Xn=n,Xn}var Qn,ui;function Fr(){if(ui)return Qn;ui=1;var e=ht(),t=e.Symbol;return Qn=t,Qn}var es,di;function Qd(){if(di)return es;di=1;var e=Fr(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,r=e?e.toStringTag:void 0;function a(i){var c=n.call(i,r),l=i[r];try{i[r]=void 0;var d=!0}catch{}var u=s.call(i);return d&&(c?i[r]=l:delete i[r]),u}return es=a,es}var ts,fi;function ef(){if(fi)return ts;fi=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return ts=n,ts}var ns,hi;function xn(){if(hi)return ns;hi=1;var e=Fr(),t=Qd(),n=ef(),s="[object Null]",r="[object Undefined]",a=e?e.toStringTag:void 0;function i(c){return c==null?c===void 0?r:s:a&&a in Object(c)?t(c):n(c)}return ns=i,ns}var ss,mi;function Ql(){if(mi)return ss;mi=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return ss=e,ss}var rs,pi;function ec(){if(pi)return rs;pi=1;var e=xn(),t=Ql(),n="[object AsyncFunction]",s="[object Function]",r="[object GeneratorFunction]",a="[object Proxy]";function i(c){if(!t(c))return!1;var l=e(c);return l==s||l==r||l==n||l==a}return rs=i,rs}var as,gi;function tf(){if(gi)return as;gi=1;var e=ht(),t=e["__core-js_shared__"];return as=t,as}var is,vi;function nf(){if(vi)return is;vi=1;var e=tf(),t=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function n(s){return!!t&&t in s}return is=n,is}var os,Ci;function tc(){if(Ci)return os;Ci=1;var e=Function.prototype,t=e.toString;function n(s){if(s!=null){try{return t.call(s)}catch{}try{return s+""}catch{}}return""}return os=n,os}var ls,wi;function sf(){if(wi)return ls;wi=1;var e=ec(),t=nf(),n=Ql(),s=tc(),r=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,i=Function.prototype,c=Object.prototype,l=i.toString,d=c.hasOwnProperty,u=RegExp("^"+l.call(d).replace(r,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function h(m){if(!n(m)||t(m))return!1;var p=e(m)?u:a;return p.test(s(m))}return ls=h,ls}var cs,bi;function rf(){if(bi)return cs;bi=1;function e(t,n){return t?.[n]}return cs=e,cs}var us,xi;function Mt(){if(xi)return us;xi=1;var e=sf(),t=rf();function n(s,r){var a=t(s,r);return e(a)?a:void 0}return us=n,us}var ds,yi;function Vr(){if(yi)return ds;yi=1;var e=Mt(),t=ht(),n=e(t,"Map");return ds=n,ds}var fs,Si;function yn(){if(Si)return fs;Si=1;var e=Mt(),t=e(Object,"create");return fs=t,fs}var hs,Di;function af(){if(Di)return hs;Di=1;var e=yn();function t(){this.__data__=e?e(null):{},this.size=0}return hs=t,hs}var ms,Ti;function of(){if(Ti)return ms;Ti=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return ms=e,ms}var ps,Mi;function lf(){if(Mi)return ps;Mi=1;var e=yn(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function r(a){var i=this.__data__;if(e){var c=i[a];return c===t?void 0:c}return s.call(i,a)?i[a]:void 0}return ps=r,ps}var gs,Ai;function cf(){if(Ai)return gs;Ai=1;var e=yn(),t=Object.prototype,n=t.hasOwnProperty;function s(r){var a=this.__data__;return e?a[r]!==void 0:n.call(a,r)}return gs=s,gs}var vs,Ei;function uf(){if(Ei)return vs;Ei=1;var e=yn(),t="__lodash_hash_undefined__";function n(s,r){var a=this.__data__;return this.size+=this.has(s)?0:1,a[s]=e&&r===void 0?t:r,this}return vs=n,vs}var Cs,Ni;function df(){if(Ni)return Cs;Ni=1;var e=af(),t=of(),n=lf(),s=cf(),r=uf();function a(i){var c=-1,l=i==null?0:i.length;for(this.clear();++c<l;){var d=i[c];this.set(d[0],d[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=r,Cs=a,Cs}var ws,ji;function ff(){if(ji)return ws;ji=1;var e=df(),t=bn(),n=Vr();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return ws=s,ws}var bs,ki;function hf(){if(ki)return bs;ki=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return bs=e,bs}var xs,_i;function Sn(){if(_i)return xs;_i=1;var e=hf();function t(n,s){var r=n.__data__;return e(s)?r[typeof s=="string"?"string":"hash"]:r.map}return xs=t,xs}var ys,Ii;function mf(){if(Ii)return ys;Ii=1;var e=Sn();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return ys=t,ys}var Ss,Ri;function pf(){if(Ri)return Ss;Ri=1;var e=Sn();function t(n){return e(this,n).get(n)}return Ss=t,Ss}var Ds,Pi;function gf(){if(Pi)return Ds;Pi=1;var e=Sn();function t(n){return e(this,n).has(n)}return Ds=t,Ds}var Ts,Li;function vf(){if(Li)return Ts;Li=1;var e=Sn();function t(n,s){var r=e(this,n),a=r.size;return r.set(n,s),this.size+=r.size==a?0:1,this}return Ts=t,Ts}var Ms,Oi;function nc(){if(Oi)return Ms;Oi=1;var e=ff(),t=mf(),n=pf(),s=gf(),r=vf();function a(i){var c=-1,l=i==null?0:i.length;for(this.clear();++c<l;){var d=i[c];this.set(d[0],d[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=r,Ms=a,Ms}var As,Fi;function Cf(){if(Fi)return As;Fi=1;var e=bn(),t=Vr(),n=nc(),s=200;function r(a,i){var c=this.__data__;if(c instanceof e){var l=c.__data__;if(!t||l.length<s-1)return l.push([a,i]),this.size=++c.size,this;c=this.__data__=new n(l)}return c.set(a,i),this.size=c.size,this}return As=r,As}var Es,Vi;function wf(){if(Vi)return Es;Vi=1;var e=bn(),t=Jd(),n=Yd(),s=Zd(),r=Xd(),a=Cf();function i(c){var l=this.__data__=new e(c);this.size=l.size}return i.prototype.clear=t,i.prototype.delete=n,i.prototype.get=s,i.prototype.has=r,i.prototype.set=a,Es=i,Es}var Ns,Hi;function bf(){if(Hi)return Ns;Hi=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Ns=t,Ns}var js,Ui;function xf(){if(Ui)return js;Ui=1;function e(t){return this.__data__.has(t)}return js=e,js}var ks,Gi;function yf(){if(Gi)return ks;Gi=1;var e=nc(),t=bf(),n=xf();function s(r){var a=-1,i=r==null?0:r.length;for(this.__data__=new e;++a<i;)this.add(r[a])}return s.prototype.add=s.prototype.push=t,s.prototype.has=n,ks=s,ks}var _s,Bi;function Sf(){if(Bi)return _s;Bi=1;function e(t,n){for(var s=-1,r=t==null?0:t.length;++s<r;)if(n(t[s],s,t))return!0;return!1}return _s=e,_s}var Is,qi;function Df(){if(qi)return Is;qi=1;function e(t,n){return t.has(n)}return Is=e,Is}var Rs,zi;function sc(){if(zi)return Rs;zi=1;var e=yf(),t=Sf(),n=Df(),s=1,r=2;function a(i,c,l,d,u,h){var m=l&s,p=i.length,g=c.length;if(p!=g&&!(m&&g>p))return!1;var x=h.get(i),v=h.get(c);if(x&&v)return x==c&&v==i;var w=-1,C=!0,b=l&r?new e:void 0;for(h.set(i,c),h.set(c,i);++w<p;){var y=i[w],N=c[w];if(d)var M=m?d(N,y,w,c,i,h):d(y,N,w,i,c,h);if(M!==void 0){if(M)continue;C=!1;break}if(b){if(!t(c,function(A,S){if(!n(b,S)&&(y===A||u(y,A,l,d,h)))return b.push(S)})){C=!1;break}}else if(!(y===N||u(y,N,l,d,h))){C=!1;break}}return h.delete(i),h.delete(c),C}return Rs=a,Rs}var Ps,Wi;function Tf(){if(Wi)return Ps;Wi=1;var e=ht(),t=e.Uint8Array;return Ps=t,Ps}var Ls,$i;function Mf(){if($i)return Ls;$i=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(r,a){s[++n]=[a,r]}),s}return Ls=e,Ls}var Os,Ki;function Af(){if(Ki)return Os;Ki=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(r){s[++n]=r}),s}return Os=e,Os}var Fs,Ji;function Ef(){if(Ji)return Fs;Ji=1;var e=Fr(),t=Tf(),n=Zl(),s=sc(),r=Mf(),a=Af(),i=1,c=2,l="[object Boolean]",d="[object Date]",u="[object Error]",h="[object Map]",m="[object Number]",p="[object RegExp]",g="[object Set]",x="[object String]",v="[object Symbol]",w="[object ArrayBuffer]",C="[object DataView]",b=e?e.prototype:void 0,y=b?b.valueOf:void 0;function N(M,A,S,_,E,T,k){switch(S){case C:if(M.byteLength!=A.byteLength||M.byteOffset!=A.byteOffset)return!1;M=M.buffer,A=A.buffer;case w:return!(M.byteLength!=A.byteLength||!T(new t(M),new t(A)));case l:case d:case m:return n(+M,+A);case u:return M.name==A.name&&M.message==A.message;case p:case x:return M==A+"";case h:var I=r;case g:var L=_&i;if(I||(I=a),M.size!=A.size&&!L)return!1;var H=k.get(M);if(H)return H==A;_|=c,k.set(M,A);var G=s(I(M),I(A),_,E,T,k);return k.delete(M),G;case v:if(y)return y.call(M)==y.call(A)}return!1}return Fs=N,Fs}var Vs,Yi;function Nf(){if(Yi)return Vs;Yi=1;function e(t,n){for(var s=-1,r=n.length,a=t.length;++s<r;)t[a+s]=n[s];return t}return Vs=e,Vs}var Hs,Zi;function Hr(){if(Zi)return Hs;Zi=1;var e=Array.isArray;return Hs=e,Hs}var Us,Xi;function jf(){if(Xi)return Us;Xi=1;var e=Nf(),t=Hr();function n(s,r,a){var i=r(s);return t(s)?i:e(i,a(s))}return Us=n,Us}var Gs,Qi;function kf(){if(Qi)return Gs;Qi=1;function e(t,n){for(var s=-1,r=t==null?0:t.length,a=0,i=[];++s<r;){var c=t[s];n(c,s,t)&&(i[a++]=c)}return i}return Gs=e,Gs}var Bs,eo;function _f(){if(eo)return Bs;eo=1;function e(){return[]}return Bs=e,Bs}var qs,to;function If(){if(to)return qs;to=1;var e=kf(),t=_f(),n=Object.prototype,s=n.propertyIsEnumerable,r=Object.getOwnPropertySymbols,a=r?function(i){return i==null?[]:(i=Object(i),e(r(i),function(c){return s.call(i,c)}))}:t;return qs=a,qs}var zs,no;function Rf(){if(no)return zs;no=1;function e(t,n){for(var s=-1,r=Array(t);++s<t;)r[s]=n(s);return r}return zs=e,zs}var Ws,so;function Dn(){if(so)return Ws;so=1;function e(t){return t!=null&&typeof t=="object"}return Ws=e,Ws}var $s,ro;function Pf(){if(ro)return $s;ro=1;var e=xn(),t=Dn(),n="[object Arguments]";function s(r){return t(r)&&e(r)==n}return $s=s,$s}var Ks,ao;function Lf(){if(ao)return Ks;ao=1;var e=Pf(),t=Dn(),n=Object.prototype,s=n.hasOwnProperty,r=n.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(i){return t(i)&&s.call(i,"callee")&&!r.call(i,"callee")};return Ks=a,Ks}var Lt={exports:{}},Js,io;function Of(){if(io)return Js;io=1;function e(){return!1}return Js=e,Js}Lt.exports;var oo;function rc(){return oo||(oo=1,(function(e,t){var n=ht(),s=Of(),r=t&&!t.nodeType&&t,a=r&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===r,c=i?n.Buffer:void 0,l=c?c.isBuffer:void 0,d=l||s;e.exports=d})(Lt,Lt.exports)),Lt.exports}var Ys,lo;function Ff(){if(lo)return Ys;lo=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(s,r){var a=typeof s;return r=r??e,!!r&&(a=="number"||a!="symbol"&&t.test(s))&&s>-1&&s%1==0&&s<r}return Ys=n,Ys}var Zs,co;function ac(){if(co)return Zs;co=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Zs=t,Zs}var Xs,uo;function Vf(){if(uo)return Xs;uo=1;var e=xn(),t=ac(),n=Dn(),s="[object Arguments]",r="[object Array]",a="[object Boolean]",i="[object Date]",c="[object Error]",l="[object Function]",d="[object Map]",u="[object Number]",h="[object Object]",m="[object RegExp]",p="[object Set]",g="[object String]",x="[object WeakMap]",v="[object ArrayBuffer]",w="[object DataView]",C="[object Float32Array]",b="[object Float64Array]",y="[object Int8Array]",N="[object Int16Array]",M="[object Int32Array]",A="[object Uint8Array]",S="[object Uint8ClampedArray]",_="[object Uint16Array]",E="[object Uint32Array]",T={};T[C]=T[b]=T[y]=T[N]=T[M]=T[A]=T[S]=T[_]=T[E]=!0,T[s]=T[r]=T[v]=T[a]=T[w]=T[i]=T[c]=T[l]=T[d]=T[u]=T[h]=T[m]=T[p]=T[g]=T[x]=!1;function k(I){return n(I)&&t(I.length)&&!!T[e(I)]}return Xs=k,Xs}var Qs,fo;function Hf(){if(fo)return Qs;fo=1;function e(t){return function(n){return t(n)}}return Qs=e,Qs}var Ot={exports:{}};Ot.exports;var ho;function Uf(){return ho||(ho=1,(function(e,t){var n=Xl(),s=t&&!t.nodeType&&t,r=s&&!0&&e&&!e.nodeType&&e,a=r&&r.exports===s,i=a&&n.process,c=(function(){try{var l=r&&r.require&&r.require("util").types;return l||i&&i.binding&&i.binding("util")}catch{}})();e.exports=c})(Ot,Ot.exports)),Ot.exports}var er,mo;function ic(){if(mo)return er;mo=1;var e=Vf(),t=Hf(),n=Uf(),s=n&&n.isTypedArray,r=s?t(s):e;return er=r,er}var tr,po;function Gf(){if(po)return tr;po=1;var e=Rf(),t=Lf(),n=Hr(),s=rc(),r=Ff(),a=ic(),i=Object.prototype,c=i.hasOwnProperty;function l(d,u){var h=n(d),m=!h&&t(d),p=!h&&!m&&s(d),g=!h&&!m&&!p&&a(d),x=h||m||p||g,v=x?e(d.length,String):[],w=v.length;for(var C in d)(u||c.call(d,C))&&!(x&&(C=="length"||p&&(C=="offset"||C=="parent")||g&&(C=="buffer"||C=="byteLength"||C=="byteOffset")||r(C,w)))&&v.push(C);return v}return tr=l,tr}var nr,go;function Bf(){if(go)return nr;go=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,r=typeof s=="function"&&s.prototype||e;return n===r}return nr=t,nr}var sr,vo;function qf(){if(vo)return sr;vo=1;function e(t,n){return function(s){return t(n(s))}}return sr=e,sr}var rr,Co;function zf(){if(Co)return rr;Co=1;var e=qf(),t=e(Object.keys,Object);return rr=t,rr}var ar,wo;function Wf(){if(wo)return ar;wo=1;var e=Bf(),t=zf(),n=Object.prototype,s=n.hasOwnProperty;function r(a){if(!e(a))return t(a);var i=[];for(var c in Object(a))s.call(a,c)&&c!="constructor"&&i.push(c);return i}return ar=r,ar}var ir,bo;function $f(){if(bo)return ir;bo=1;var e=ec(),t=ac();function n(s){return s!=null&&t(s.length)&&!e(s)}return ir=n,ir}var or,xo;function Kf(){if(xo)return or;xo=1;var e=Gf(),t=Wf(),n=$f();function s(r){return n(r)?e(r):t(r)}return or=s,or}var lr,yo;function Jf(){if(yo)return lr;yo=1;var e=jf(),t=If(),n=Kf();function s(r){return e(r,n,t)}return lr=s,lr}var cr,So;function Yf(){if(So)return cr;So=1;var e=Jf(),t=1,n=Object.prototype,s=n.hasOwnProperty;function r(a,i,c,l,d,u){var h=c&t,m=e(a),p=m.length,g=e(i),x=g.length;if(p!=x&&!h)return!1;for(var v=p;v--;){var w=m[v];if(!(h?w in i:s.call(i,w)))return!1}var C=u.get(a),b=u.get(i);if(C&&b)return C==i&&b==a;var y=!0;u.set(a,i),u.set(i,a);for(var N=h;++v<p;){w=m[v];var M=a[w],A=i[w];if(l)var S=h?l(A,M,w,i,a,u):l(M,A,w,a,i,u);if(!(S===void 0?M===A||d(M,A,c,l,u):S)){y=!1;break}N||(N=w=="constructor")}if(y&&!N){var _=a.constructor,E=i.constructor;_!=E&&"constructor"in a&&"constructor"in i&&!(typeof _=="function"&&_ instanceof _&&typeof E=="function"&&E instanceof E)&&(y=!1)}return u.delete(a),u.delete(i),y}return cr=r,cr}var ur,Do;function Zf(){if(Do)return ur;Do=1;var e=Mt(),t=ht(),n=e(t,"DataView");return ur=n,ur}var dr,To;function Xf(){if(To)return dr;To=1;var e=Mt(),t=ht(),n=e(t,"Promise");return dr=n,dr}var fr,Mo;function Qf(){if(Mo)return fr;Mo=1;var e=Mt(),t=ht(),n=e(t,"Set");return fr=n,fr}var hr,Ao;function eh(){if(Ao)return hr;Ao=1;var e=Mt(),t=ht(),n=e(t,"WeakMap");return hr=n,hr}var mr,Eo;function th(){if(Eo)return mr;Eo=1;var e=Zf(),t=Vr(),n=Xf(),s=Qf(),r=eh(),a=xn(),i=tc(),c="[object Map]",l="[object Object]",d="[object Promise]",u="[object Set]",h="[object WeakMap]",m="[object DataView]",p=i(e),g=i(t),x=i(n),v=i(s),w=i(r),C=a;return(e&&C(new e(new ArrayBuffer(1)))!=m||t&&C(new t)!=c||n&&C(n.resolve())!=d||s&&C(new s)!=u||r&&C(new r)!=h)&&(C=function(b){var y=a(b),N=y==l?b.constructor:void 0,M=N?i(N):"";if(M)switch(M){case p:return m;case g:return c;case x:return d;case v:return u;case w:return h}return y}),mr=C,mr}var pr,No;function nh(){if(No)return pr;No=1;var e=wf(),t=sc(),n=Ef(),s=Yf(),r=th(),a=Hr(),i=rc(),c=ic(),l=1,d="[object Arguments]",u="[object Array]",h="[object Object]",m=Object.prototype,p=m.hasOwnProperty;function g(x,v,w,C,b,y){var N=a(x),M=a(v),A=N?u:r(x),S=M?u:r(v);A=A==d?h:A,S=S==d?h:S;var _=A==h,E=S==h,T=A==S;if(T&&i(x)){if(!i(v))return!1;N=!0,_=!1}if(T&&!_)return y||(y=new e),N||c(x)?t(x,v,w,C,b,y):n(x,v,A,w,C,b,y);if(!(w&l)){var k=_&&p.call(x,"__wrapped__"),I=E&&p.call(v,"__wrapped__");if(k||I){var L=k?x.value():x,H=I?v.value():v;return y||(y=new e),b(L,H,w,C,y)}}return T?(y||(y=new e),s(x,v,w,C,b,y)):!1}return pr=g,pr}var gr,jo;function sh(){if(jo)return gr;jo=1;var e=nh(),t=Dn();function n(s,r,a,i,c){return s===r?!0:s==null||r==null||!t(s)&&!t(r)?s!==s&&r!==r:e(s,r,a,i,n,c)}return gr=n,gr}var vr,ko;function rh(){if(ko)return vr;ko=1;var e=sh();function t(n,s){return e(n,s)}return vr=t,vr}var ah=rh();const Mr=Or(ah),oc=e=>Ne.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ne.createElement("path",{d:"M8.00016 1.33325C4.3135 1.33325 1.3335 4.31325 1.3335 7.99992C1.3335 11.6866 4.3135 14.6666 8.00016 14.6666C11.6868 14.6666 14.6668 11.6866 14.6668 7.99992C14.6668 4.31325 11.6868 1.33325 8.00016 1.33325ZM8.00016 13.3333C5.06016 13.3333 2.66683 10.9399 2.66683 7.99992C2.66683 5.05992 5.06016 2.66659 8.00016 2.66659C10.9402 2.66659 13.3335 5.05992 13.3335 7.99992C13.3335 10.9399 10.9402 13.3333 8.00016 13.3333ZM10.3935 4.66659L8.00016 7.05992L5.60683 4.66659L4.66683 5.60659L7.06016 7.99992L4.66683 10.3933L5.60683 11.3333L8.00016 8.93992L10.3935 11.3333L11.3335 10.3933L8.94016 7.99992L11.3335 5.60659L10.3935 4.66659Z",fill:"currentColor"})),ih=({dataQueries:e,disabledDatasetUrns:t,isSelected:n,onSelect:s,onClearAll:r})=>{const{titles:a}=Me(),i=e.length-t.size,c=t.size>0;return o.jsxs("div",{className:W("flex justify-between items-center px-2 h-10 shrink-0 hover:bg-hues-100 rounded","filters-facet-item cursor-pointer",n&&"bg-hues-100"),onClick:s,children:[o.jsx("h3",{className:"w-full min-w-0 flex-1 truncate",title:a?.dataset??"Dataset",children:o.jsx("span",{className:"truncate",children:a?.dataset??"Dataset"})}),o.jsxs("div",{className:"ml-2 flex items-center gap-2 text-neutrals-800",children:[o.jsx("span",{className:"filters-facet-item-counter px-2 text-center",children:`${i}/${e.length}`}),c&&o.jsx("div",{className:"filters-facet-item-settings flex items-center gap-2",children:o.jsx(j.IconButton,{buttonClassName:"text-button-tertiary w-4 h-4 border-0 p-0 filters-facet-item-icon",icon:o.jsx(oc,{width:16,height:16}),title:a?.reset??"Reset",onClick:l=>{l.stopPropagation(),r()}})})]})]})},Ur=e=>Ne.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ne.createElement("path",{d:"M11.3301 6.25L8.00008 9.75L4.67008 6.25L11.3301 6.25Z",fill:"currentColor"})),oh=e=>Ne.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ne.createElement("path",{d:"M12.8232 7C12.926 7 13.012 7.07201 13.0244 7.16797L13.1807 8.22754C13.4315 8.32754 13.6621 8.46012 13.876 8.62012L14.9004 8.21973C14.9208 8.21186 14.9453 8.20803 14.9697 8.20801C15.0436 8.20801 15.1133 8.24392 15.1504 8.30762L15.9736 9.69238C16.0227 9.7803 16.0018 9.88834 15.9238 9.94824L15.0566 10.6084C15.0731 10.7363 15.085 10.8642 15.085 11C15.085 11.1358 15.0731 11.2637 15.0566 11.3916L15.9238 12.0518C16.0018 12.1117 16.0227 12.2197 15.9736 12.3076L15.1504 13.6924C15.1133 13.7561 15.0434 13.792 14.9736 13.792C14.9492 13.7919 14.9248 13.7881 14.9004 13.7803L13.876 13.3799C13.6621 13.5359 13.4315 13.6725 13.1807 13.7725L13.0244 14.832C13.012 14.928 12.926 15 12.8232 15H11.1787C11.0759 15 10.9889 14.928 10.9766 14.832L10.8203 13.7725C10.5696 13.6725 10.3397 13.5398 10.126 13.3799L9.10156 13.7803C9.08115 13.7882 9.05667 13.792 9.03223 13.792C8.95826 13.792 8.88761 13.7563 8.85059 13.6924L8.02832 12.3076C7.97924 12.2197 8.0001 12.1117 8.07812 12.0518L8.94531 11.3916C8.92889 11.2637 8.91699 11.1319 8.91699 11C8.91699 10.8681 8.92889 10.7363 8.94531 10.6084L8.07812 9.94824C8.0001 9.88832 7.97515 9.78032 8.02832 9.69238L8.85059 8.30762C8.88754 8.24383 8.95763 8.20816 9.02734 8.20801C9.05192 8.20801 9.07699 8.21179 9.10156 8.21973L10.126 8.62012C10.3397 8.46418 10.5696 8.32752 10.8203 8.22754L10.9766 7.16797C10.9889 7.07197 11.0759 7 11.1787 7H12.8232ZM11.7129 7.7998L11.6309 8.33984L11.5654 8.79199L11.1289 8.96387C10.9604 9.03184 10.792 9.12795 10.6152 9.25586L10.2451 9.52832L9.81738 9.36035L9.29492 9.15625L9.00684 9.63965L9.45117 9.97559L9.81738 10.2559L9.75977 10.708C9.74743 10.828 9.73926 10.92 9.73926 11C9.73926 11.08 9.74743 11.1719 9.75977 11.2959L9.81738 11.748L9.45117 12.0283L9.00684 12.3643L9.29492 12.8477L9.81738 12.6436L10.2529 12.4717L10.627 12.752C10.7913 12.8719 10.9561 12.9642 11.1328 13.0361L11.5693 13.208L11.6348 13.6602L11.7129 14.2002H12.2891L12.3711 13.6602L12.4365 13.208L12.873 13.0361C13.0415 12.9681 13.21 12.8721 13.3867 12.7441L13.7568 12.4717L14.1846 12.6396L14.707 12.8438L14.9941 12.3604L14.5508 12.0244L14.1846 11.7441L14.2422 11.292C14.2545 11.172 14.2627 11.084 14.2627 11C14.2627 10.916 14.2586 10.832 14.2422 10.708L14.1846 10.2559L14.5508 9.97559L14.9902 9.63574L14.7021 9.15234L14.1807 9.35645L13.7441 9.52832L13.3701 9.24805C13.2057 9.12808 13.0411 9.03586 12.8643 8.96387L12.4287 8.79199L12.3623 8.33984L12.2842 7.7998H11.7129ZM3.33301 12.6338H2V11.3008H3.33301V12.6338ZM7.00977 11.3008C7.03732 11.7651 7.12864 12.2121 7.27441 12.6338H4.66699V11.3008H7.00977ZM12.001 9.40039C12.9097 9.40043 13.6455 10.116 13.6455 11C13.6455 11.884 12.9097 12.5996 12.001 12.5996C11.0922 12.5996 10.3564 11.884 10.3564 11C10.3564 10.116 11.0922 9.40039 12.001 9.40039ZM12.001 10.2002C11.5486 10.2002 11.1787 10.56 11.1787 11C11.1787 11.44 11.5486 11.7998 12.001 11.7998C12.4533 11.7998 12.8232 11.44 12.8232 11C12.8232 10.56 12.4533 10.2002 12.001 10.2002ZM3.33301 8.63379H2V7.30078H3.33301V8.63379ZM8.63574 7.30078C8.21765 7.68124 7.86483 8.13197 7.59473 8.63379H4.66699V7.30078H8.63574ZM3.33301 4.7334H2V3.40039H3.33301V4.7334ZM14 4.7334H4.66699V3.40039H14V4.7334Z",fill:"currentColor"}));var Ft={exports:{}},lh=Ft.exports,_o;function ch(){return _o||(_o=1,(function(e,t){(function(n,s){s(t)})(lh,(function(n){var s=function(){return s=Object.assign||function(ct){for(var Qt,On=1,fd=arguments.length;On<fd;On++){Qt=arguments[On];for(var Fn in Qt)Object.prototype.hasOwnProperty.call(Qt,Fn)&&(ct[Fn]=Qt[Fn])}return ct},s.apply(this,arguments)},r=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},a={weekdays:{shorthand:["أحد","اثنين","ثلاثاء","أربعاء","خميس","جمعة","سبت"],longhand:["الأحد","الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة","السبت"]},months:{shorthand:["1","2","3","4","5","6","7","8","9","10","11","12"],longhand:["يناير","فبراير","مارس","أبريل","مايو","يونيو","يوليو","أغسطس","سبتمبر","أكتوبر","نوفمبر","ديسمبر"]},firstDayOfWeek:6,rangeSeparator:" إلى ",weekAbbreviation:"Wk",scrollTitle:"قم بالتمرير للزيادة",toggleTitle:"اضغط للتبديل",amPM:["ص","م"],yearAriaLabel:"سنة",monthAriaLabel:"شهر",hourAriaLabel:"ساعة",minuteAriaLabel:"دقيقة",time_24hr:!1};r.l10ns.ar=a,r.l10ns;var i=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},c={weekdays:{shorthand:["So","Mo","Di","Mi","Do","Fr","Sa"],longhand:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"]},months:{shorthand:["Jän","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],longhand:["Jänner","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"]},firstDayOfWeek:1,weekAbbreviation:"KW",rangeSeparator:" bis ",scrollTitle:"Zum Ändern scrollen",toggleTitle:"Zum Umschalten klicken",time_24hr:!0};i.l10ns.at=c,i.l10ns;var l=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},d={weekdays:{shorthand:["B.","B.e.","Ç.a.","Ç.","C.a.","C.","Ş."],longhand:["Bazar","Bazar ertəsi","Çərşənbə axşamı","Çərşənbə","Cümə axşamı","Cümə","Şənbə"]},months:{shorthand:["Yan","Fev","Mar","Apr","May","İyn","İyl","Avq","Sen","Okt","Noy","Dek"],longhand:["Yanvar","Fevral","Mart","Aprel","May","İyun","İyul","Avqust","Sentyabr","Oktyabr","Noyabr","Dekabr"]},firstDayOfWeek:1,ordinal:function(){return"."},rangeSeparator:" - ",weekAbbreviation:"Hf",scrollTitle:"Artırmaq üçün sürüşdürün",toggleTitle:"Aç / Bağla",amPM:["GƏ","GS"],time_24hr:!0};l.l10ns.az=d,l.l10ns;var u=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},h={weekdays:{shorthand:["Нд","Пн","Аў","Ср","Чц","Пт","Сб"],longhand:["Нядзеля","Панядзелак","Аўторак","Серада","Чацвер","Пятніца","Субота"]},months:{shorthand:["Сту","Лют","Сак","Кра","Тра","Чэр","Ліп","Жні","Вер","Кас","Ліс","Сне"],longhand:["Студзень","Люты","Сакавік","Красавік","Травень","Чэрвень","Ліпень","Жнівень","Верасень","Кастрычнік","Лістапад","Снежань"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Тыд.",scrollTitle:"Пракруціце для павелічэння",toggleTitle:"Націсніце для пераключэння",amPM:["ДП","ПП"],yearAriaLabel:"Год",time_24hr:!0};u.l10ns.be=h,u.l10ns;var m=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},p={firstDayOfWeek:1,weekdays:{shorthand:["Ned","Pon","Uto","Sri","Čet","Pet","Sub"],longhand:["Nedjelja","Ponedjeljak","Utorak","Srijeda","Četvrtak","Petak","Subota"]},months:{shorthand:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Avg","Sep","Okt","Nov","Dec"],longhand:["Januar","Februar","Mart","April","Maj","Juni","Juli","Avgust","Septembar","Oktobar","Novembar","Decembar"]},time_24hr:!0};m.l10ns.bs=p,m.l10ns;var g=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},x={weekdays:{shorthand:["Нд","Пн","Вт","Ср","Чт","Пт","Сб"],longhand:["Неделя","Понеделник","Вторник","Сряда","Четвъртък","Петък","Събота"]},months:{shorthand:["Яну","Фев","Март","Апр","Май","Юни","Юли","Авг","Сеп","Окт","Ное","Дек"],longhand:["Януари","Февруари","Март","Април","Май","Юни","Юли","Август","Септември","Октомври","Ноември","Декември"]},time_24hr:!0,firstDayOfWeek:1};g.l10ns.bg=x,g.l10ns;var v=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},w={weekdays:{shorthand:["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],longhand:["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"]},months:{shorthand:["জানু","ফেব্রু","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],longhand:["জানুয়ারী","ফেব্রুয়ারী","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"]}};v.l10ns.bn=w,v.l10ns;var C=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},b={weekdays:{shorthand:["Dg","Dl","Dt","Dc","Dj","Dv","Ds"],longhand:["Diumenge","Dilluns","Dimarts","Dimecres","Dijous","Divendres","Dissabte"]},months:{shorthand:["Gen","Febr","Març","Abr","Maig","Juny","Jul","Ag","Set","Oct","Nov","Des"],longhand:["Gener","Febrer","Març","Abril","Maig","Juny","Juliol","Agost","Setembre","Octubre","Novembre","Desembre"]},ordinal:function(je){var ct=je%100;if(ct>3&&ct<21)return"è";switch(ct%10){case 1:return"r";case 2:return"n";case 3:return"r";case 4:return"t";default:return"è"}},firstDayOfWeek:1,rangeSeparator:" a ",time_24hr:!0};C.l10ns.cat=C.l10ns.ca=b,C.l10ns;var y=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},N={weekdays:{shorthand:["یەکشەممە","دووشەممە","سێشەممە","چوارشەممە","پێنجشەممە","هەینی","شەممە"],longhand:["یەکشەممە","دووشەممە","سێشەممە","چوارشەممە","پێنجشەممە","هەینی","شەممە"]},months:{shorthand:["ڕێبەندان","ڕەشەمە","نەورۆز","گوڵان","جۆزەردان","پووشپەڕ","گەلاوێژ","خەرمانان","ڕەزبەر","گەڵاڕێزان","سەرماوەز","بەفرانبار"],longhand:["ڕێبەندان","ڕەشەمە","نەورۆز","گوڵان","جۆزەردان","پووشپەڕ","گەلاوێژ","خەرمانان","ڕەزبەر","گەڵاڕێزان","سەرماوەز","بەفرانبار"]},firstDayOfWeek:6,ordinal:function(){return""}};y.l10ns.ckb=N,y.l10ns;var M=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},A={weekdays:{shorthand:["Ne","Po","Út","St","Čt","Pá","So"],longhand:["Neděle","Pondělí","Úterý","Středa","Čtvrtek","Pátek","Sobota"]},months:{shorthand:["Led","Ún","Bře","Dub","Kvě","Čer","Čvc","Srp","Zář","Říj","Lis","Pro"],longhand:["Leden","Únor","Březen","Duben","Květen","Červen","Červenec","Srpen","Září","Říjen","Listopad","Prosinec"]},firstDayOfWeek:1,ordinal:function(){return"."},rangeSeparator:" do ",weekAbbreviation:"Týd.",scrollTitle:"Rolujte pro změnu",toggleTitle:"Přepnout dopoledne/odpoledne",amPM:["dop.","odp."],yearAriaLabel:"Rok",time_24hr:!0};M.l10ns.cs=A,M.l10ns;var S=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},_={weekdays:{shorthand:["Sul","Llun","Maw","Mer","Iau","Gwe","Sad"],longhand:["Dydd Sul","Dydd Llun","Dydd Mawrth","Dydd Mercher","Dydd Iau","Dydd Gwener","Dydd Sadwrn"]},months:{shorthand:["Ion","Chwef","Maw","Ebr","Mai","Meh","Gorff","Awst","Medi","Hyd","Tach","Rhag"],longhand:["Ionawr","Chwefror","Mawrth","Ebrill","Mai","Mehefin","Gorffennaf","Awst","Medi","Hydref","Tachwedd","Rhagfyr"]},firstDayOfWeek:1,ordinal:function(je){return je===1?"af":je===2?"ail":je===3||je===4?"ydd":je===5||je===6?"ed":je>=7&&je<=10||je==12||je==15||je==18||je==20?"fed":je==11||je==13||je==14||je==16||je==17||je==19?"eg":je>=21&&je<=39?"ain":""},time_24hr:!0};S.l10ns.cy=_,S.l10ns;var E=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},T={weekdays:{shorthand:["søn","man","tir","ons","tors","fre","lør"],longhand:["søndag","mandag","tirsdag","onsdag","torsdag","fredag","lørdag"]},months:{shorthand:["jan","feb","mar","apr","maj","jun","jul","aug","sep","okt","nov","dec"],longhand:["januar","februar","marts","april","maj","juni","juli","august","september","oktober","november","december"]},ordinal:function(){return"."},firstDayOfWeek:1,rangeSeparator:" til ",weekAbbreviation:"uge",time_24hr:!0};E.l10ns.da=T,E.l10ns;var k=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},I={weekdays:{shorthand:["So","Mo","Di","Mi","Do","Fr","Sa"],longhand:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"]},months:{shorthand:["Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],longhand:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"]},firstDayOfWeek:1,weekAbbreviation:"KW",rangeSeparator:" bis ",scrollTitle:"Zum Ändern scrollen",toggleTitle:"Zum Umschalten klicken",time_24hr:!0};k.l10ns.de=I,k.l10ns;var L={weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0,ordinal:function(je){var ct=je%100;if(ct>3&&ct<21)return"th";switch(ct%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},rangeSeparator:" to ",weekAbbreviation:"Wk",scrollTitle:"Scroll to increment",toggleTitle:"Click to toggle",amPM:["AM","PM"],yearAriaLabel:"Year",monthAriaLabel:"Month",hourAriaLabel:"Hour",minuteAriaLabel:"Minute",time_24hr:!1},H=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},G={firstDayOfWeek:1,rangeSeparator:" ĝis ",weekAbbreviation:"Sem",scrollTitle:"Rulumu por pligrandigi la valoron",toggleTitle:"Klaku por ŝalti",weekdays:{shorthand:["Dim","Lun","Mar","Mer","Ĵaŭ","Ven","Sab"],longhand:["dimanĉo","lundo","mardo","merkredo","ĵaŭdo","vendredo","sabato"]},months:{shorthand:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aŭg","Sep","Okt","Nov","Dec"],longhand:["januaro","februaro","marto","aprilo","majo","junio","julio","aŭgusto","septembro","oktobro","novembro","decembro"]},ordinal:function(){return"-a"},time_24hr:!0};H.l10ns.eo=G,H.l10ns;var Y=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},O={weekdays:{shorthand:["Dom","Lun","Mar","Mié","Jue","Vie","Sáb"],longhand:["Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado"]},months:{shorthand:["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],longhand:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]},ordinal:function(){return"º"},firstDayOfWeek:1,rangeSeparator:" a ",time_24hr:!0};Y.l10ns.es=O,Y.l10ns;var $=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},K={weekdays:{shorthand:["P","E","T","K","N","R","L"],longhand:["Pühapäev","Esmaspäev","Teisipäev","Kolmapäev","Neljapäev","Reede","Laupäev"]},months:{shorthand:["Jaan","Veebr","Märts","Apr","Mai","Juuni","Juuli","Aug","Sept","Okt","Nov","Dets"],longhand:["Jaanuar","Veebruar","Märts","Aprill","Mai","Juuni","Juuli","August","September","Oktoober","November","Detsember"]},firstDayOfWeek:1,ordinal:function(){return"."},weekAbbreviation:"Näd",rangeSeparator:" kuni ",scrollTitle:"Keri, et suurendada",toggleTitle:"Klõpsa, et vahetada",time_24hr:!0};$.l10ns.et=K,$.l10ns;var Z=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},se={weekdays:{shorthand:["یک","دو","سه","چهار","پنج","جمعه","شنبه"],longhand:["یک‌شنبه","دوشنبه","سه‌شنبه","چهارشنبه","پنچ‌شنبه","جمعه","شنبه"]},months:{shorthand:["ژانویه","فوریه","مارس","آوریل","مه","ژوئن","ژوئیه","اوت","سپتامبر","اکتبر","نوامبر","دسامبر"],longhand:["ژانویه","فوریه","مارس","آوریل","مه","ژوئن","ژوئیه","اوت","سپتامبر","اکتبر","نوامبر","دسامبر"]},firstDayOfWeek:6,ordinal:function(){return""}};Z.l10ns.fa=se,Z.l10ns;var ge=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},he={firstDayOfWeek:1,weekdays:{shorthand:["su","ma","ti","ke","to","pe","la"],longhand:["sunnuntai","maanantai","tiistai","keskiviikko","torstai","perjantai","lauantai"]},months:{shorthand:["tammi","helmi","maalis","huhti","touko","kesä","heinä","elo","syys","loka","marras","joulu"],longhand:["tammikuu","helmikuu","maaliskuu","huhtikuu","toukokuu","kesäkuu","heinäkuu","elokuu","syyskuu","lokakuu","marraskuu","joulukuu"]},ordinal:function(){return"."},time_24hr:!0};ge.l10ns.fi=he,ge.l10ns;var xe=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},F={weekdays:{shorthand:["Sun","Mán","Týs","Mik","Hós","Frí","Ley"],longhand:["Sunnudagur","Mánadagur","Týsdagur","Mikudagur","Hósdagur","Fríggjadagur","Leygardagur"]},months:{shorthand:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Des"],longhand:["Januar","Februar","Mars","Apríl","Mai","Juni","Juli","August","Septembur","Oktobur","Novembur","Desembur"]},ordinal:function(){return"."},firstDayOfWeek:1,rangeSeparator:" til ",weekAbbreviation:"vika",scrollTitle:"Rulla fyri at broyta",toggleTitle:"Trýst fyri at skifta",yearAriaLabel:"Ár",time_24hr:!0};xe.l10ns.fo=F,xe.l10ns;var J=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ue={firstDayOfWeek:1,weekdays:{shorthand:["dim","lun","mar","mer","jeu","ven","sam"],longhand:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"]},months:{shorthand:["janv","févr","mars","avr","mai","juin","juil","août","sept","oct","nov","déc"],longhand:["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"]},ordinal:function(je){return je>1?"":"er"},rangeSeparator:" au ",weekAbbreviation:"Sem",scrollTitle:"Défiler pour augmenter la valeur",toggleTitle:"Cliquer pour basculer",time_24hr:!0};J.l10ns.fr=ue,J.l10ns;var de=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},me={weekdays:{shorthand:["Κυ","Δε","Τρ","Τε","Πέ","Πα","Σά"],longhand:["Κυριακή","Δευτέρα","Τρίτη","Τετάρτη","Πέμπτη","Παρασκευή","Σάββατο"]},months:{shorthand:["Ιαν","Φεβ","Μάρ","Απρ","Μάι","Ιούν","Ιούλ","Αύγ","Σεπ","Οκτ","Νοέ","Δεκ"],longhand:["Ιανουάριος","Φεβρουάριος","Μάρτιος","Απρίλιος","Μάιος","Ιούνιος","Ιούλιος","Αύγουστος","Σεπτέμβριος","Οκτώβριος","Νοέμβριος","Δεκέμβριος"]},firstDayOfWeek:1,ordinal:function(){return""},weekAbbreviation:"Εβδ",rangeSeparator:" έως ",scrollTitle:"Μετακυλήστε για προσαύξηση",toggleTitle:"Κάντε κλικ για αλλαγή",amPM:["ΠΜ","ΜΜ"],yearAriaLabel:"χρόνος",monthAriaLabel:"μήνας",hourAriaLabel:"ώρα",minuteAriaLabel:"λεπτό"};de.l10ns.gr=me,de.l10ns;var re=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Q={weekdays:{shorthand:["א","ב","ג","ד","ה","ו","ש"],longhand:["ראשון","שני","שלישי","רביעי","חמישי","שישי","שבת"]},months:{shorthand:["ינו׳","פבר׳","מרץ","אפר׳","מאי","יוני","יולי","אוג׳","ספט׳","אוק׳","נוב׳","דצמ׳"],longhand:["ינואר","פברואר","מרץ","אפריל","מאי","יוני","יולי","אוגוסט","ספטמבר","אוקטובר","נובמבר","דצמבר"]},rangeSeparator:" אל ",time_24hr:!0};re.l10ns.he=Q,re.l10ns;var U=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},q={weekdays:{shorthand:["रवि","सोम","मंगल","बुध","गुरु","शुक्र","शनि"],longhand:["रविवार","सोमवार","मंगलवार","बुधवार","गुरुवार","शुक्रवार","शनिवार"]},months:{shorthand:["जन","फर","मार्च","अप्रेल","मई","जून","जूलाई","अग","सित","अक्ट","नव","दि"],longhand:["जनवरी ","फरवरी","मार्च","अप्रेल","मई","जून","जूलाई","अगस्त ","सितम्बर","अक्टूबर","नवम्बर","दिसम्बर"]}};U.l10ns.hi=q,U.l10ns;var fe=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ae={firstDayOfWeek:1,weekdays:{shorthand:["Ned","Pon","Uto","Sri","Čet","Pet","Sub"],longhand:["Nedjelja","Ponedjeljak","Utorak","Srijeda","Četvrtak","Petak","Subota"]},months:{shorthand:["Sij","Velj","Ožu","Tra","Svi","Lip","Srp","Kol","Ruj","Lis","Stu","Pro"],longhand:["Siječanj","Veljača","Ožujak","Travanj","Svibanj","Lipanj","Srpanj","Kolovoz","Rujan","Listopad","Studeni","Prosinac"]},time_24hr:!0};fe.l10ns.hr=ae,fe.l10ns;var oe=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},pe={firstDayOfWeek:1,weekdays:{shorthand:["V","H","K","Sz","Cs","P","Szo"],longhand:["Vasárnap","Hétfő","Kedd","Szerda","Csütörtök","Péntek","Szombat"]},months:{shorthand:["Jan","Feb","Már","Ápr","Máj","Jún","Júl","Aug","Szep","Okt","Nov","Dec"],longhand:["Január","Február","Március","Április","Május","Június","Július","Augusztus","Szeptember","Október","November","December"]},ordinal:function(){return"."},weekAbbreviation:"Hét",scrollTitle:"Görgessen",toggleTitle:"Kattintson a váltáshoz",rangeSeparator:" - ",time_24hr:!0};oe.l10ns.hu=pe,oe.l10ns;var Se=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ce={weekdays:{shorthand:["Կիր","Երկ","Երք","Չրք","Հնգ","Ուրբ","Շբթ"],longhand:["Կիրակի","Եկուշաբթի","Երեքշաբթի","Չորեքշաբթի","Հինգշաբթի","Ուրբաթ","Շաբաթ"]},months:{shorthand:["Հնվ","Փտր","Մար","Ապր","Մայ","Հնս","Հլս","Օգս","Սեպ","Հոկ","Նմբ","Դեկ"],longhand:["Հունվար","Փետրվար","Մարտ","Ապրիլ","Մայիս","Հունիս","Հուլիս","Օգոստոս","Սեպտեմբեր","Հոկտեմբեր","Նոյեմբեր","Դեկտեմբեր"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"ՇԲՏ",scrollTitle:"Ոլորեք՝ մեծացնելու համար",toggleTitle:"Սեղմեք՝ փոխելու համար",amPM:["ՄԿ","ԿՀ"],yearAriaLabel:"Տարի",monthAriaLabel:"Ամիս",hourAriaLabel:"Ժամ",minuteAriaLabel:"Րոպե",time_24hr:!0};Se.l10ns.hy=Ce,Se.l10ns;var ye=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ce={weekdays:{shorthand:["Min","Sen","Sel","Rab","Kam","Jum","Sab"],longhand:["Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu"]},months:{shorthand:["Jan","Feb","Mar","Apr","Mei","Jun","Jul","Agu","Sep","Okt","Nov","Des"],longhand:["Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"]},firstDayOfWeek:1,ordinal:function(){return""},time_24hr:!0,rangeSeparator:" - "};ye.l10ns.id=ce,ye.l10ns;var Ee=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Pe={weekdays:{shorthand:["Sun","Mán","Þri","Mið","Fim","Fös","Lau"],longhand:["Sunnudagur","Mánudagur","Þriðjudagur","Miðvikudagur","Fimmtudagur","Föstudagur","Laugardagur"]},months:{shorthand:["Jan","Feb","Mar","Apr","Maí","Jún","Júl","Ágú","Sep","Okt","Nóv","Des"],longhand:["Janúar","Febrúar","Mars","Apríl","Maí","Júní","Júlí","Ágúst","September","Október","Nóvember","Desember"]},ordinal:function(){return"."},firstDayOfWeek:1,rangeSeparator:" til ",weekAbbreviation:"vika",yearAriaLabel:"Ár",time_24hr:!0};Ee.l10ns.is=Pe,Ee.l10ns;var ze=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ge={weekdays:{shorthand:["Dom","Lun","Mar","Mer","Gio","Ven","Sab"],longhand:["Domenica","Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"]},months:{shorthand:["Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Ott","Nov","Dic"],longhand:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"]},firstDayOfWeek:1,ordinal:function(){return"°"},rangeSeparator:" al ",weekAbbreviation:"Se",scrollTitle:"Scrolla per aumentare",toggleTitle:"Clicca per cambiare",time_24hr:!0};ze.l10ns.it=Ge,ze.l10ns;var Ve=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Xe={weekdays:{shorthand:["日","月","火","水","木","金","土"],longhand:["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"]},months:{shorthand:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],longhand:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"]},time_24hr:!0,rangeSeparator:" から ",monthAriaLabel:"月",amPM:["午前","午後"],yearAriaLabel:"年",hourAriaLabel:"時間",minuteAriaLabel:"分"};Ve.l10ns.ja=Xe,Ve.l10ns;var $e=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Be={weekdays:{shorthand:["კვ","ორ","სა","ოთ","ხუ","პა","შა"],longhand:["კვირა","ორშაბათი","სამშაბათი","ოთხშაბათი","ხუთშაბათი","პარასკევი","შაბათი"]},months:{shorthand:["იან","თებ","მარ","აპრ","მაი","ივნ","ივლ","აგვ","სექ","ოქტ","ნოე","დეკ"],longhand:["იანვარი","თებერვალი","მარტი","აპრილი","მაისი","ივნისი","ივლისი","აგვისტო","სექტემბერი","ოქტომბერი","ნოემბერი","დეკემბერი"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"კვ.",scrollTitle:"დასქროლეთ გასადიდებლად",toggleTitle:"დააკლიკეთ გადართვისთვის",amPM:["AM","PM"],yearAriaLabel:"წელი",time_24hr:!0};$e.l10ns.ka=Be,$e.l10ns;var ot=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},X={weekdays:{shorthand:["일","월","화","수","목","금","토"],longhand:["일요일","월요일","화요일","수요일","목요일","금요일","토요일"]},months:{shorthand:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"],longhand:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"]},ordinal:function(){return"일"},rangeSeparator:" ~ ",amPM:["오전","오후"]};ot.l10ns.ko=X,ot.l10ns;var ve=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ie={weekdays:{shorthand:["អាទិត្យ","ចន្ទ","អង្គារ","ពុធ","ព្រហស.","សុក្រ","សៅរ៍"],longhand:["អាទិត្យ","ចន្ទ","អង្គារ","ពុធ","ព្រហស្បតិ៍","សុក្រ","សៅរ៍"]},months:{shorthand:["មករា","កុម្ភះ","មីនា","មេសា","ឧសភា","មិថុនា","កក្កដា","សីហា","កញ្ញា","តុលា","វិច្ឆិកា","ធ្នូ"],longhand:["មករា","កុម្ភះ","មីនា","មេសា","ឧសភា","មិថុនា","កក្កដា","សីហា","កញ្ញា","តុលា","វិច្ឆិកា","ធ្នូ"]},ordinal:function(){return""},firstDayOfWeek:1,rangeSeparator:" ដល់ ",weekAbbreviation:"សប្តាហ៍",scrollTitle:"រំកិលដើម្បីបង្កើន",toggleTitle:"ចុចដើម្បីផ្លាស់ប្ដូរ",yearAriaLabel:"ឆ្នាំ",time_24hr:!0};ve.l10ns.km=ie,ve.l10ns;var le=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Le={weekdays:{shorthand:["Жс","Дс","Сc","Ср","Бс","Жм","Сб"],longhand:["Жексенбi","Дүйсенбi","Сейсенбi","Сәрсенбi","Бейсенбi","Жұма","Сенбi"]},months:{shorthand:["Қаң","Ақп","Нау","Сәу","Мам","Мау","Шiл","Там","Қыр","Қаз","Қар","Жел"],longhand:["Қаңтар","Ақпан","Наурыз","Сәуiр","Мамыр","Маусым","Шiлде","Тамыз","Қыркүйек","Қазан","Қараша","Желтоқсан"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Апта",scrollTitle:"Үлкейту үшін айналдырыңыз",toggleTitle:"Ауыстыру үшін басыңыз",amPM:["ТД","ТК"],yearAriaLabel:"Жыл"};le.l10ns.kz=Le,le.l10ns;var V=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},B={weekdays:{shorthand:["S","Pr","A","T","K","Pn","Š"],longhand:["Sekmadienis","Pirmadienis","Antradienis","Trečiadienis","Ketvirtadienis","Penktadienis","Šeštadienis"]},months:{shorthand:["Sau","Vas","Kov","Bal","Geg","Bir","Lie","Rgp","Rgs","Spl","Lap","Grd"],longhand:["Sausis","Vasaris","Kovas","Balandis","Gegužė","Birželis","Liepa","Rugpjūtis","Rugsėjis","Spalis","Lapkritis","Gruodis"]},firstDayOfWeek:1,ordinal:function(){return"-a"},rangeSeparator:" iki ",weekAbbreviation:"Sav",scrollTitle:"Keisti laiką pelės rateliu",toggleTitle:"Perjungti laiko formatą",time_24hr:!0};V.l10ns.lt=B,V.l10ns;var ee=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},R={firstDayOfWeek:1,weekdays:{shorthand:["Sv","Pr","Ot","Tr","Ce","Pk","Se"],longhand:["Svētdiena","Pirmdiena","Otrdiena","Trešdiena","Ceturtdiena","Piektdiena","Sestdiena"]},months:{shorthand:["Jan","Feb","Mar","Apr","Mai","Jūn","Jūl","Aug","Sep","Okt","Nov","Dec"],longhand:["Janvāris","Februāris","Marts","Aprīlis","Maijs","Jūnijs","Jūlijs","Augusts","Septembris","Oktobris","Novembris","Decembris"]},rangeSeparator:" līdz ",time_24hr:!0};ee.l10ns.lv=R,ee.l10ns;var P=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},z={weekdays:{shorthand:["Не","По","Вт","Ср","Че","Пе","Са"],longhand:["Недела","Понеделник","Вторник","Среда","Четврток","Петок","Сабота"]},months:{shorthand:["Јан","Фев","Мар","Апр","Мај","Јун","Јул","Авг","Сеп","Окт","Ное","Дек"],longhand:["Јануари","Февруари","Март","Април","Мај","Јуни","Јули","Август","Септември","Октомври","Ноември","Декември"]},firstDayOfWeek:1,weekAbbreviation:"Нед.",rangeSeparator:" до ",time_24hr:!0};P.l10ns.mk=z,P.l10ns;var te=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},_e={firstDayOfWeek:1,weekdays:{shorthand:["Да","Мя","Лх","Пү","Ба","Бя","Ня"],longhand:["Даваа","Мягмар","Лхагва","Пүрэв","Баасан","Бямба","Ням"]},months:{shorthand:["1-р сар","2-р сар","3-р сар","4-р сар","5-р сар","6-р сар","7-р сар","8-р сар","9-р сар","10-р сар","11-р сар","12-р сар"],longhand:["Нэгдүгээр сар","Хоёрдугаар сар","Гуравдугаар сар","Дөрөвдүгээр сар","Тавдугаар сар","Зургаадугаар сар","Долдугаар сар","Наймдугаар сар","Есдүгээр сар","Аравдугаар сар","Арваннэгдүгээр сар","Арванхоёрдугаар сар"]},rangeSeparator:"-с ",time_24hr:!0};te.l10ns.mn=_e,te.l10ns;var be=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},De={weekdays:{shorthand:["Aha","Isn","Sel","Rab","Kha","Jum","Sab"],longhand:["Ahad","Isnin","Selasa","Rabu","Khamis","Jumaat","Sabtu"]},months:{shorthand:["Jan","Feb","Mac","Apr","Mei","Jun","Jul","Ogo","Sep","Okt","Nov","Dis"],longhand:["Januari","Februari","Mac","April","Mei","Jun","Julai","Ogos","September","Oktober","November","Disember"]},firstDayOfWeek:1,ordinal:function(){return""}};be.l10ns;var Ye=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ke={weekdays:{shorthand:["နွေ","လာ","ဂါ","ဟူး","ကြာ","သော","နေ"],longhand:["တနင်္ဂနွေ","တနင်္လာ","အင်္ဂါ","ဗုဒ္ဓဟူး","ကြာသပတေး","သောကြာ","စနေ"]},months:{shorthand:["ဇန်","ဖေ","မတ်","ပြီ","မေ","ဇွန်","လိုင်","သြ","စက်","အောက်","နို","ဒီ"],longhand:["ဇန်နဝါရီ","ဖေဖော်ဝါရီ","မတ်","ဧပြီ","မေ","ဇွန်","ဇူလိုင်","သြဂုတ်","စက်တင်ဘာ","အောက်တိုဘာ","နိုဝင်ဘာ","ဒီဇင်ဘာ"]},firstDayOfWeek:1,ordinal:function(){return""},time_24hr:!0};Ye.l10ns.my=Ke,Ye.l10ns;var rt=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},at={weekdays:{shorthand:["zo","ma","di","wo","do","vr","za"],longhand:["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"]},months:{shorthand:["jan","feb","mrt","apr","mei","jun","jul","aug","sept","okt","nov","dec"],longhand:["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"]},firstDayOfWeek:1,weekAbbreviation:"wk",rangeSeparator:" t/m ",scrollTitle:"Scroll voor volgende / vorige",toggleTitle:"Klik om te wisselen",time_24hr:!0,ordinal:function(je){return je===1||je===8||je>=20?"ste":"de"}};rt.l10ns.nl=at,rt.l10ns;var bt=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},lt={weekdays:{shorthand:["Sø.","Må.","Ty.","On.","To.","Fr.","La."],longhand:["Søndag","Måndag","Tysdag","Onsdag","Torsdag","Fredag","Laurdag"]},months:{shorthand:["Jan","Feb","Mars","Apr","Mai","Juni","Juli","Aug","Sep","Okt","Nov","Des"],longhand:["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"]},firstDayOfWeek:1,rangeSeparator:" til ",weekAbbreviation:"Veke",scrollTitle:"Scroll for å endre",toggleTitle:"Klikk for å veksle",time_24hr:!0,ordinal:function(){return"."}};bt.l10ns.nn=lt,bt.l10ns;var Xt=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},oa={weekdays:{shorthand:["Søn","Man","Tir","Ons","Tor","Fre","Lør"],longhand:["Søndag","Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag"]},months:{shorthand:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Des"],longhand:["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"]},firstDayOfWeek:1,rangeSeparator:" til ",weekAbbreviation:"Uke",scrollTitle:"Scroll for å endre",toggleTitle:"Klikk for å veksle",time_24hr:!0,ordinal:function(){return"."}};Xt.l10ns.no=oa,Xt.l10ns;var la=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ca={weekdays:{shorthand:["ਐਤ","ਸੋਮ","ਮੰਗਲ","ਬੁੱਧ","ਵੀਰ","ਸ਼ੁੱਕਰ","ਸ਼ਨਿੱਚਰ"],longhand:["ਐਤਵਾਰ","ਸੋਮਵਾਰ","ਮੰਗਲਵਾਰ","ਬੁੱਧਵਾਰ","ਵੀਰਵਾਰ","ਸ਼ੁੱਕਰਵਾਰ","ਸ਼ਨਿੱਚਰਵਾਰ"]},months:{shorthand:["ਜਨ","ਫ਼ਰ","ਮਾਰ","ਅਪ੍ਰੈ","ਮਈ","ਜੂਨ","ਜੁਲਾ","ਅਗ","ਸਤੰ","ਅਕ","ਨਵੰ","ਦਸੰ"],longhand:["ਜਨਵਰੀ","ਫ਼ਰਵਰੀ","ਮਾਰਚ","ਅਪ੍ਰੈਲ","ਮਈ","ਜੂਨ","ਜੁਲਾਈ","ਅਗਸਤ","ਸਤੰਬਰ","ਅਕਤੂਬਰ","ਨਵੰਬਰ","ਦਸੰਬਰ"]},time_24hr:!0};la.l10ns.pa=ca,la.l10ns;var ua=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},da={weekdays:{shorthand:["Nd","Pn","Wt","Śr","Cz","Pt","So"],longhand:["Niedziela","Poniedziałek","Wtorek","Środa","Czwartek","Piątek","Sobota"]},months:{shorthand:["Sty","Lut","Mar","Kwi","Maj","Cze","Lip","Sie","Wrz","Paź","Lis","Gru"],longhand:["Styczeń","Luty","Marzec","Kwiecień","Maj","Czerwiec","Lipiec","Sierpień","Wrzesień","Październik","Listopad","Grudzień"]},rangeSeparator:" do ",weekAbbreviation:"tydz.",scrollTitle:"Przewiń, aby zwiększyć",toggleTitle:"Kliknij, aby przełączyć",firstDayOfWeek:1,time_24hr:!0,ordinal:function(){return"."}};ua.l10ns.pl=da,ua.l10ns;var fa=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ha={weekdays:{shorthand:["Dom","Seg","Ter","Qua","Qui","Sex","Sáb"],longhand:["Domingo","Segunda-feira","Terça-feira","Quarta-feira","Quinta-feira","Sexta-feira","Sábado"]},months:{shorthand:["Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"],longhand:["Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"]},rangeSeparator:" até ",time_24hr:!0};fa.l10ns.pt=ha,fa.l10ns;var ma=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},pa={weekdays:{shorthand:["Dum","Lun","Mar","Mie","Joi","Vin","Sâm"],longhand:["Duminică","Luni","Marți","Miercuri","Joi","Vineri","Sâmbătă"]},months:{shorthand:["Ian","Feb","Mar","Apr","Mai","Iun","Iul","Aug","Sep","Oct","Noi","Dec"],longhand:["Ianuarie","Februarie","Martie","Aprilie","Mai","Iunie","Iulie","August","Septembrie","Octombrie","Noiembrie","Decembrie"]},firstDayOfWeek:1,time_24hr:!0,ordinal:function(){return""}};ma.l10ns.ro=pa,ma.l10ns;var ga=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},va={weekdays:{shorthand:["Вс","Пн","Вт","Ср","Чт","Пт","Сб"],longhand:["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"]},months:{shorthand:["Янв","Фев","Март","Апр","Май","Июнь","Июль","Авг","Сен","Окт","Ноя","Дек"],longhand:["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Нед.",scrollTitle:"Прокрутите для увеличения",toggleTitle:"Нажмите для переключения",amPM:["ДП","ПП"],yearAriaLabel:"Год",time_24hr:!0};ga.l10ns.ru=va,ga.l10ns;var Ca=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},wa={weekdays:{shorthand:["ඉ","ස","අ","බ","බ්‍ර","සි","සෙ"],longhand:["ඉරිදා","සඳුදා","අඟහරුවාදා","බදාදා","බ්‍රහස්පතින්දා","සිකුරාදා","සෙනසුරාදා"]},months:{shorthand:["ජන","පෙබ","මාර්","අප්‍රේ","මැයි","ජුනි","ජූලි","අගෝ","සැප්","ඔක්","නොවැ","දෙසැ"],longhand:["ජනවාරි","පෙබරවාරි","මාර්තු","අප්‍රේල්","මැයි","ජුනි","ජූලි","අගෝස්තු","සැප්තැම්බර්","ඔක්තෝබර්","නොවැම්බර්","දෙසැම්බර්"]},time_24hr:!0};Ca.l10ns.si=wa,Ca.l10ns;var ba=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},xa={weekdays:{shorthand:["Ned","Pon","Ut","Str","Štv","Pia","Sob"],longhand:["Nedeľa","Pondelok","Utorok","Streda","Štvrtok","Piatok","Sobota"]},months:{shorthand:["Jan","Feb","Mar","Apr","Máj","Jún","Júl","Aug","Sep","Okt","Nov","Dec"],longhand:["Január","Február","Marec","Apríl","Máj","Jún","Júl","August","September","Október","November","December"]},firstDayOfWeek:1,rangeSeparator:" do ",time_24hr:!0,ordinal:function(){return"."}};ba.l10ns.sk=xa,ba.l10ns;var ya=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Sa={weekdays:{shorthand:["Ned","Pon","Tor","Sre","Čet","Pet","Sob"],longhand:["Nedelja","Ponedeljek","Torek","Sreda","Četrtek","Petek","Sobota"]},months:{shorthand:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Avg","Sep","Okt","Nov","Dec"],longhand:["Januar","Februar","Marec","April","Maj","Junij","Julij","Avgust","September","Oktober","November","December"]},firstDayOfWeek:1,rangeSeparator:" do ",time_24hr:!0,ordinal:function(){return"."}};ya.l10ns.sl=Sa,ya.l10ns;var Da=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ta={weekdays:{shorthand:["Di","Hë","Ma","Më","En","Pr","Sh"],longhand:["E Diel","E Hënë","E Martë","E Mërkurë","E Enjte","E Premte","E Shtunë"]},months:{shorthand:["Jan","Shk","Mar","Pri","Maj","Qer","Kor","Gus","Sht","Tet","Nën","Dhj"],longhand:["Janar","Shkurt","Mars","Prill","Maj","Qershor","Korrik","Gusht","Shtator","Tetor","Nëntor","Dhjetor"]},firstDayOfWeek:1,rangeSeparator:" deri ",weekAbbreviation:"Java",yearAriaLabel:"Viti",monthAriaLabel:"Muaji",hourAriaLabel:"Ora",minuteAriaLabel:"Minuta",time_24hr:!0};Da.l10ns.sq=Ta,Da.l10ns;var Ma=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Aa={weekdays:{shorthand:["Ned","Pon","Uto","Sre","Čet","Pet","Sub"],longhand:["Nedelja","Ponedeljak","Utorak","Sreda","Četvrtak","Petak","Subota"]},months:{shorthand:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Avg","Sep","Okt","Nov","Dec"],longhand:["Januar","Februar","Mart","April","Maj","Jun","Jul","Avgust","Septembar","Oktobar","Novembar","Decembar"]},firstDayOfWeek:1,weekAbbreviation:"Ned.",rangeSeparator:" do ",time_24hr:!0};Ma.l10ns.sr=Aa,Ma.l10ns;var Ea=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Na={firstDayOfWeek:1,weekAbbreviation:"v",weekdays:{shorthand:["sön","mån","tis","ons","tor","fre","lör"],longhand:["söndag","måndag","tisdag","onsdag","torsdag","fredag","lördag"]},months:{shorthand:["jan","feb","mar","apr","maj","jun","jul","aug","sep","okt","nov","dec"],longhand:["januari","februari","mars","april","maj","juni","juli","augusti","september","oktober","november","december"]},rangeSeparator:" till ",time_24hr:!0,ordinal:function(){return"."}};Ea.l10ns.sv=Na,Ea.l10ns;var ja=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ka={weekdays:{shorthand:["อา","จ","อ","พ","พฤ","ศ","ส"],longhand:["อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัสบดี","ศุกร์","เสาร์"]},months:{shorthand:["ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค."],longhand:["มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม"]},firstDayOfWeek:1,rangeSeparator:" ถึง ",scrollTitle:"เลื่อนเพื่อเพิ่มหรือลด",toggleTitle:"คลิกเพื่อเปลี่ยน",time_24hr:!0,ordinal:function(){return""}};ja.l10ns.th=ka,ja.l10ns;var _a=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ia={weekdays:{shorthand:["Paz","Pzt","Sal","Çar","Per","Cum","Cmt"],longhand:["Pazar","Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi"]},months:{shorthand:["Oca","Şub","Mar","Nis","May","Haz","Tem","Ağu","Eyl","Eki","Kas","Ara"],longhand:["Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık"]},firstDayOfWeek:1,ordinal:function(){return"."},rangeSeparator:" - ",weekAbbreviation:"Hf",scrollTitle:"Artırmak için kaydırın",toggleTitle:"Aç/Kapa",amPM:["ÖÖ","ÖS"],time_24hr:!0};_a.l10ns.tr=Ia,_a.l10ns;var Ra=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Pa={firstDayOfWeek:1,weekdays:{shorthand:["Нд","Пн","Вт","Ср","Чт","Пт","Сб"],longhand:["Неділя","Понеділок","Вівторок","Середа","Четвер","П'ятниця","Субота"]},months:{shorthand:["Січ","Лют","Бер","Кві","Тра","Чер","Лип","Сер","Вер","Жов","Лис","Гру"],longhand:["Січень","Лютий","Березень","Квітень","Травень","Червень","Липень","Серпень","Вересень","Жовтень","Листопад","Грудень"]},time_24hr:!0};Ra.l10ns.uk=Pa,Ra.l10ns;var La=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Oa={weekdays:{shorthand:["Якш","Душ","Сеш","Чор","Пай","Жум","Шан"],longhand:["Якшанба","Душанба","Сешанба","Чоршанба","Пайшанба","Жума","Шанба"]},months:{shorthand:["Янв","Фев","Мар","Апр","Май","Июн","Июл","Авг","Сен","Окт","Ноя","Дек"],longhand:["Январ","Феврал","Март","Апрел","Май","Июн","Июл","Август","Сентябр","Октябр","Ноябр","Декабр"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Ҳафта",scrollTitle:"Катталаштириш учун айлантиринг",toggleTitle:"Ўтиш учун босинг",amPM:["AM","PM"],yearAriaLabel:"Йил",time_24hr:!0};La.l10ns.uz=Oa,La.l10ns;var Fa=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Va={weekdays:{shorthand:["Ya","Du","Se","Cho","Pa","Ju","Sha"],longhand:["Yakshanba","Dushanba","Seshanba","Chorshanba","Payshanba","Juma","Shanba"]},months:{shorthand:["Yan","Fev","Mar","Apr","May","Iyun","Iyul","Avg","Sen","Okt","Noy","Dek"],longhand:["Yanvar","Fevral","Mart","Aprel","May","Iyun","Iyul","Avgust","Sentabr","Oktabr","Noyabr","Dekabr"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Hafta",scrollTitle:"Kattalashtirish uchun aylantiring",toggleTitle:"O‘tish uchun bosing",amPM:["AM","PM"],yearAriaLabel:"Yil",time_24hr:!0};Fa.l10ns.uz_latn=Va,Fa.l10ns;var Ha=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ua={weekdays:{shorthand:["CN","T2","T3","T4","T5","T6","T7"],longhand:["Chủ nhật","Thứ hai","Thứ ba","Thứ tư","Thứ năm","Thứ sáu","Thứ bảy"]},months:{shorthand:["Th1","Th2","Th3","Th4","Th5","Th6","Th7","Th8","Th9","Th10","Th11","Th12"],longhand:["Tháng một","Tháng hai","Tháng ba","Tháng tư","Tháng năm","Tháng sáu","Tháng bảy","Tháng tám","Tháng chín","Tháng mười","Tháng mười một","Tháng mười hai"]},firstDayOfWeek:1,rangeSeparator:" đến "};Ha.l10ns.vn=Ua,Ha.l10ns;var Ga=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ba={weekdays:{shorthand:["周日","周一","周二","周三","周四","周五","周六"],longhand:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},months:{shorthand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],longhand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},rangeSeparator:" 至 ",weekAbbreviation:"周",scrollTitle:"滚动切换",toggleTitle:"点击切换 12/24 小时时制"};Ga.l10ns.zh=Ba,Ga.l10ns;var qa=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},za={weekdays:{shorthand:["週日","週一","週二","週三","週四","週五","週六"],longhand:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},months:{shorthand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],longhand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},rangeSeparator:" 至 ",weekAbbreviation:"週",scrollTitle:"滾動切換",toggleTitle:"點擊切換 12/24 小時時制"};qa.l10ns.zh_tw=za,qa.l10ns;var dd={ar:a,at:c,az:d,be:h,bg:x,bn:w,bs:p,ca:b,ckb:N,cat:b,cs:A,cy:_,da:T,de:I,default:s({},L),en:L,eo:G,es:O,et:K,fa:se,fi:he,fo:F,fr:ue,gr:me,he:Q,hi:q,hr:ae,hu:pe,hy:Ce,id:ce,is:Pe,it:Ge,ja:Xe,ka:Be,ko:X,km:ie,kz:Le,lt:B,lv:R,mk:z,mn:_e,ms:De,my:Ke,nl:at,nn:lt,no:oa,pa:ca,pl:da,pt:ha,ro:pa,ru:va,si:wa,sk:xa,sl:Sa,sq:Ta,sr:Aa,sv:Na,th:ka,tr:Ia,uk:Pa,vn:Ua,zh:Ba,zh_tw:za,uz:Oa,uz_latn:Va};n.default=dd,Object.defineProperty(n,"__esModule",{value:!0})}))})(Ft,Ft.exports)),Ft.exports}var uh=ch();const dh=Or(uh);var nn={exports:{}},fh=nn.exports,Io;function hh(){return Io||(Io=1,(function(e,t){(function(n,s){e.exports=s()})(fh,(function(){var n=function(){return n=Object.assign||function(d){for(var u,h=1,m=arguments.length;h<m;h++){u=arguments[h];for(var p in u)Object.prototype.hasOwnProperty.call(u,p)&&(d[p]=u[p])}return d},n.apply(this,arguments)},s=function(l,d,u){return u.months[d?"shorthand":"longhand"][l]};function r(l){for(;l.firstChild;)l.removeChild(l.firstChild)}function a(l){try{if(typeof l.composedPath=="function"){var d=l.composedPath();return d[0]}return l.target}catch{return l.target}}var i={shorthand:!1,dateFormat:"F Y",altFormat:"F Y",theme:"light"};function c(l){var d=n(n({},i),l);return function(u){u.config.dateFormat=d.dateFormat,u.config.altFormat=d.altFormat;var h={monthsContainer:null};function m(){if(u.rContainer){r(u.rContainer);for(var E=0;E<u.monthElements.length;E++){var T=u.monthElements[E];T.parentNode&&T.parentNode.removeChild(T)}}}function p(){u.rContainer&&(h.monthsContainer=u._createElement("div","flatpickr-monthSelect-months"),h.monthsContainer.tabIndex=-1,g(),u.rContainer.appendChild(h.monthsContainer),u.calendarContainer.classList.add("flatpickr-monthSelect-theme-"+d.theme))}function g(){if(h.monthsContainer){r(h.monthsContainer);for(var E=document.createDocumentFragment(),T=0;T<12;T++){var k=u.createDay("flatpickr-monthSelect-month",new Date(u.currentYear,T),0,T);k.dateObj.getMonth()===new Date().getMonth()&&k.dateObj.getFullYear()===new Date().getFullYear()&&k.classList.add("today"),k.textContent=s(T,d.shorthand,u.l10n),k.addEventListener("click",C),E.appendChild(k)}h.monthsContainer.appendChild(E),u.config.minDate&&u.currentYear===u.config.minDate.getFullYear()?u.prevMonthNav.classList.add("flatpickr-disabled"):u.prevMonthNav.classList.remove("flatpickr-disabled"),u.config.maxDate&&u.currentYear===u.config.maxDate.getFullYear()?u.nextMonthNav.classList.add("flatpickr-disabled"):u.nextMonthNav.classList.remove("flatpickr-disabled")}}function x(){u._bind(u.prevMonthNav,"click",function(E){E.preventDefault(),E.stopPropagation(),u.changeYear(u.currentYear-1),w(),g()}),u._bind(u.nextMonthNav,"click",function(E){E.preventDefault(),E.stopPropagation(),u.changeYear(u.currentYear+1),w(),g()}),u._bind(h.monthsContainer,"mouseover",function(E){u.config.mode==="range"&&u.onMouseOver(a(E),"flatpickr-monthSelect-month")})}function v(){if(u.rContainer&&u.selectedDates.length){for(var E=u.rContainer.querySelectorAll(".flatpickr-monthSelect-month.selected"),T=0;T<E.length;T++)E[T].classList.remove("selected");var k=u.selectedDates[0].getMonth(),I=u.rContainer.querySelector(".flatpickr-monthSelect-month:nth-child("+(k+1)+")");I&&I.classList.add("selected")}}function w(){var E=u.selectedDates[0];if(E&&(E=new Date(E),E.setFullYear(u.currentYear),u.config.minDate&&E<u.config.minDate&&(E=u.config.minDate),u.config.maxDate&&E>u.config.maxDate&&(E=u.config.maxDate),u.currentYear=E.getFullYear()),u.currentYearElement.value=String(u.currentYear),u.rContainer){var T=u.rContainer.querySelectorAll(".flatpickr-monthSelect-month");T.forEach(function(k){k.dateObj.setFullYear(u.currentYear),u.config.minDate&&k.dateObj<u.config.minDate||u.config.maxDate&&k.dateObj>u.config.maxDate?k.classList.add("flatpickr-disabled"):k.classList.remove("flatpickr-disabled")})}v()}function C(E){E.preventDefault(),E.stopPropagation();var T=a(E);if(T instanceof Element&&!T.classList.contains("flatpickr-disabled")&&!T.classList.contains("notAllowed")&&(b(T.dateObj),u.config.closeOnSelect)){var k=u.config.mode==="single",I=u.config.mode==="range"&&u.selectedDates.length===2;(k||I)&&u.close()}}function b(E){var T=new Date(u.currentYear,E.getMonth(),E.getDate()),k=[];switch(u.config.mode){case"single":k=[T];break;case"multiple":k.push(T);break;case"range":u.selectedDates.length===2?k=[T]:(k=u.selectedDates.concat([T]),k.sort(function(I,L){return I.getTime()-L.getTime()}));break}u.setDate(k,!0),v()}var y={37:-1,39:1,40:3,38:-3};function N(E,T,k,I){var L=y[I.keyCode]!==void 0;if(!(!L&&I.keyCode!==13)&&!(!u.rContainer||!h.monthsContainer)){var H=u.rContainer.querySelector(".flatpickr-monthSelect-month.selected"),G=Array.prototype.indexOf.call(h.monthsContainer.children,document.activeElement);if(G===-1){var Y=H||h.monthsContainer.firstElementChild;Y.focus(),G=Y.$i}L?h.monthsContainer.children[(12+G+y[I.keyCode])%12].focus():I.keyCode===13&&h.monthsContainer.contains(document.activeElement)&&b(document.activeElement.dateObj)}}function M(){var E;((E=u.config)===null||E===void 0?void 0:E.mode)==="range"&&u.selectedDates.length===1&&u.clear(!1),u.selectedDates.length||g()}function A(){d._stubbedCurrentMonth=u._initialDate.getMonth(),u._initialDate.setMonth(d._stubbedCurrentMonth),u.currentMonth=d._stubbedCurrentMonth}function S(){d._stubbedCurrentMonth&&(u._initialDate.setMonth(d._stubbedCurrentMonth),u.currentMonth=d._stubbedCurrentMonth,delete d._stubbedCurrentMonth)}function _(){if(h.monthsContainer!==null)for(var E=h.monthsContainer.querySelectorAll(".flatpickr-monthSelect-month"),T=0;T<E.length;T++)E[T].removeEventListener("click",C)}return{onParseConfig:function(){u.config.enableTime=!1},onValueUpdate:v,onKeyDown:N,onReady:[A,m,p,x,v,function(){u.config.onClose.push(M),u.loadedPlugins.push("monthSelect")}],onDestroy:[S,_,function(){u.config.onClose=u.config.onClose.filter(function(E){return E!==M})}]}}}return c}))})(nn)),nn.exports}var mh=hh();const ph=Or(mh),Ro=(e,t,n,s,r=!1,a)=>{const i={...dh[s]},c=ph;r&&(i.firstDayOfWeek=1);const l=new Date(e);l.setHours(0,0,0,0);const d=new Date(t);d.setHours(23,59,59,999);const u={minDate:n===ne.CalendarResolution.MONTH?new Date(e.getFullYear(),e.getMonth()):l,maxDate:n===ne.CalendarResolution.MONTH?new Date(t.getFullYear(),t.getMonth()):d,locale:i};return n===ne.CalendarResolution.MONTH?{...u,dateFormat:"M Y",plugins:[new c({shorthand:!0,dateFormat:"M Y"})]}:{...u,monthSelectorType:"static",dateFormat:a||"d.m.Y"}},Po=e=>{e?.setMinutes(e.getMinutes()-e.getTimezoneOffset())},gh={year:"numeric",month:"short",day:"numeric"},fn=(e,t)=>e?.toLocaleDateString(t,gh)||"",vh=(e,t)=>{const{startPeriod:n,endPeriod:s}=e;if(!t.startPeriod&&!t.endPeriod&&n&&s)return{startPeriod:new Date(n?.getTime()),endPeriod:new Date(s?.getTime())};const r=n?new Date(Math.max(n.getTime(),t.startPeriod.getTime())):t.startPeriod,a=s?new Date(Math.min(s.getTime(),t.endPeriod.getTime())):t.endPeriod;return{startPeriod:r,endPeriod:a}},Ch=(e,t)=>{const{endPeriod:n}=e,s=n?.getFullYear()||new Date().getFullYear(),r=s+ +t,a=new Date(+t<0?s:r,n?.getMonth()||0,n?.getDate()||1),i=new Date(+t<0?r:s,0,1);return{startPeriod:new Date(Math.max(i.getTime(),e?.startPeriod?.getTime()||0)),endPeriod:a}},wh=e=>({quarterly:e?.quarterly||"Q",monthly:e?.monthly||"M"}),lc=(e,t)=>{const n=wh(t);return D.isQuarterly(e)&&n?.quarterly?e?.replace(/Q/g,n?.quarterly):D.isMonthly(e)&&n?.monthly?e?.replace(/M/g,n?.monthly):e},bh=(e,t)=>{const n={...e};return(!e.startPeriod&&t?.startPeriod||t?.startPeriod&&e?.startPeriod&&t.startPeriod<e?.startPeriod)&&(n.startPeriod=t?.startPeriod||null),(!e.endPeriod&&t?.endPeriod||t?.endPeriod&&e?.endPeriod&&t.endPeriod>e?.endPeriod)&&(n.endPeriod=t?.endPeriod||null),n},Lo=e=>{if(!e?.length)return null;let t=null,n=null;for(const s of e){const r=s.filters?.find(l=>l.componentCode===D.TIME_PERIOD);if(!r)continue;const a=r.values.filter(Boolean),i=a[0]?ne.getTimePeriod(a[0]):null,c=a[1]?ne.getTimePeriod(a[1]):null;!i||!c||((!t||i<t)&&(t=i),(!n||c>n)&&(n=c))}return t&&n?{startPeriod:t,endPeriod:n}:null};var tt=(e=>(e.FLAT_LIST="FLAT_LIST",e.HIERARCHY="HIERARCHY",e))(tt||{});const cc=(e,t,n,s,r)=>e?.map(a=>{const i=D.findCodelistByDimension(t?.codelists,t?.conceptSchemes,a)?.codes,c=D.getAvailableCodes(a,n,i,s),l=i?.some(d=>d?.parent);return{id:a?.id,title:D.getDimensionTitle(t?.conceptSchemes,a,s),dimensionValues:c,isTimeDimension:a?.type===D.DimensionType.TIME_DIMENSION,isHierarchical:l,displayMode:l?tt.HIERARCHY:tt.FLAT_LIST,datasetUrn:r,filterType:"dataset"}})||[],sn=e=>e?.filterType==="shared",We=e=>{if(e?.id)return sn(e)?`shared:${e.id}`:e?.datasetUrn?`${e.datasetUrn}:${e.id}`:e.id},Re=(e,t)=>We(e)===We(t),hn=(e,t)=>e?.map(n=>t&&Re(n,t)?{...t,isSelectedFilter:!0}:{...n,isSelectedFilter:!1}),uc=(e,t,n)=>e?e.map(s=>Re(s,t)?{...s,displayMode:n}:s):[],dc=e=>e?.filter(t=>!!t?.isSelectedValue)||[],Tn=e=>e?.map(t=>({...t,dimensionValues:dc(t?.dimensionValues)})).filter(t=>t.dimensionValues?.length||t.timeRange?.startPeriod||t.timeRange?.endPeriod),Gr=e=>e?.reduce((t,n)=>(n?.dimensionValues?.length??0)+t,0)||0,fc=e=>({...e,dimensionValues:e?.dimensionValues?.map(t=>({...t,isSelectedValue:!1})),timeRange:void 0}),hc=(e,t)=>e?.map(n=>Re(n,t)?fc(n):n),mc=e=>e?.map(t=>fc(t)),pc=(e,t,n)=>e.map(s=>{const r=t?.filters?.find(i=>i.componentCode===s.id);let a=[];if(r)if(s.isTimeDimension){const i=r.values.filter(h=>!!h),c=D.getAnnotationPeriod(n?.[0]?.annotations),l=i[0]?ne.getTimePeriod(i[0]):null,d=i[1]?ne.getTimePeriod(i[1]):null;let u=c;return l&&d&&(u=c?vh({startPeriod:l,endPeriod:d},c):{startPeriod:l,endPeriod:d}),{...s,timeRange:u}}else a=s?.dimensionValues?.map(c=>r?.values?.includes(c.id)?{...c,isSelectedValue:!0}:c);else a=s.dimensionValues;return{...s,dimensionValues:a}}),mn=e=>e?.map(t=>({...t,isDisabled:!0})),xh=e=>new Map(e?.map(t=>[t.id,{...t,children:[]}])),yh=e=>{if(!e)return[];const t=xh(e),n=[];return e.forEach(s=>{if(s&&s.parent){const r=t.get(s.parent),a=t.get(s.id);r&&r.children&&a&&(r.children=[...r.children,a])}else{const r=t.get(s.id);r&&n.push(r)}}),n},Sh=(e,t=!1)=>t?`${e*j.TREE_NODE_PADDING-j.TREE_NODE_ARROW_SIZE}px`:`${e*j.TREE_NODE_PADDING}px`,gc=e=>e?.children?.reduce((t,n)=>[...t,n,...gc(n)],[])||[],Dh=(e,t)=>e?e.filter(n=>!n.disabled).map(n=>({...n,isSelectedValue:t})):[],vc=e=>!!e?.children?.some(t=>t?.isSelectedValue||vc(t)),Th=e=>{const t=gc(e);if(!e.children?.length)return[{...e,isSelectedValue:!e.isSelectedValue}];const n=(c,l)=>[{...e,isSelectedValue:c},...Dh(t,l)];if(!e.isSelectableValue)return e.isSelectedValue?n(!1,!1):n(!0,!0);const s=t.filter(c=>!c.disabled),r=s.some(c=>c.isSelectedValue),a=s.length>0&&s.every(c=>c.isSelectedValue),i=!!e.isSelectedValue;return!i&&!r?n(!0,!0):i&&a?n(!1,!0):!i&&r?n(!0,!1):i&&!r?n(!1,!1):n(!0,!0)},Mh=(e,t)=>e.filter(n=>n.isSelectableValue&&!t.has(n.id)).map(n=>({id:n.id,name:n.name,isSelectedValue:n.isSelectedValue})),Ah=({isHierarchical:e,availableHierarchies:t,titles:n})=>[{key:"",title:n?.flatList??"Flat list"},...e?[{key:tt.HIERARCHY,title:n?.hierarchy??"Hierarchy by parent"}]:[],...(t??[]).map(s=>({key:s.id,title:`${s.name??s.id} (${s.version})`}))],Eh=({calendarResolution:e,timeRange:t,timeRangeOptions:n,calendarStartFromMonday:s=!0,locale:r=ne.Locale.EN,radioIcon:a,initialConstraints:i,onValueChange:c,calendarIcon:l,dateFormat:d,defaultTimeOption:u,dataQueries:h})=>{const{titles:m}=Me(),p=bh(D.getAnnotationPeriod(i?.[0]?.annotations),t),x=!!!(p?.startPeriod||p?.endPeriod)&&!t?Lo(h):null,v=x??p,[w,C]=f.useState(t??x),b=!t||t?.startPeriod?.getTime()===v?.startPeriod?.getTime()&&t?.endPeriod?.getTime()===v?.endPeriod?.getTime()?0:ne.CUSTOM_PERIOD,[y,N]=f.useState(u??b),M=f.useMemo(()=>{const{startPeriod:T,endPeriod:k}=v,I=T?.getFullYear(),L=k?.getFullYear(),H=new Date().getFullYear();return n.filter(G=>G.value===ne.CUSTOM_PERIOD||G.value===0||+G.value>=0&&L-H>=+G.value||+G.value<0&&I-H<+G.value)},[v,n]);f.useEffect(()=>{c(w,y)},[w]),f.useEffect(()=>{if(t!==null)return;const T=D.getAnnotationPeriod(i?.[0]?.annotations);T?.startPeriod||T?.endPeriod||C(Lo(h))},[t]);const A=T=>{T&&(Po(T),C(k=>k?{...k,startPeriod:T||null}:{endPeriod:null,startPeriod:T||null}))},S=T=>{T&&(Po(T),C(k=>k?{...k,endPeriod:T||null}:{startPeriod:null,endPeriod:T||null}))};if(v==null)return null;const _=Ro(v.startPeriod,w?.endPeriod||v.endPeriod,e,r,s,d),E=Ro(w?.startPeriod||v.startPeriod,v.endPeriod,e,r,s,d);return o.jsxs("div",{className:"mt-3 flex h-full min-w-0 flex-1 flex-col overflow-auto py-2 pr-3",children:[o.jsx("div",{className:"w-full",children:M.map(T=>o.jsx(j.Radio,{id:T.value.toString(),checked:y===T.value,label:T.title,onChange:()=>{const{value:k}=T;N(k),k!==ne.CUSTOM_PERIOD&&C(k===0?v:Ch(v,k))},radioIcon:a},T.value.toString()))}),o.jsx("div",{className:"w-full",children:y===ne.CUSTOM_PERIOD&&o.jsxs("div",{className:"filters-time-period caption mt-3 flex gap-4 text-neutral-700",children:[o.jsx(j.Calendar,{onChange:A,options:_,value:w?.startPeriod||v?.startPeriod,label:m?.from||"From",id:"time-options-start",icon:l}),o.jsx(j.Calendar,{onChange:S,options:E,value:w?.endPeriod||v?.endPeriod,label:m?.to||"To",id:"time-options-end",icon:l,isEndDate:!0})]})})]})},Nh={isMetadataInSidePanel:!1,isCrossDatasetModeOn:!1,isTableSettingsFeatureEnabled:!1},Cc=f.createContext(Nh);function jh({children:e,isMetadataInSidePanel:t=!1,isCrossDatasetModeOn:n=!1,isTableSettingsFeatureEnabled:s=!1}){const r=f.useMemo(()=>({isMetadataInSidePanel:t,isCrossDatasetModeOn:n,isTableSettingsFeatureEnabled:s}),[t,n,s]);return o.jsx(Cc.Provider,{value:r,children:e})}function Ue(){return f.useContext(Cc)}const kh=2,wc=({value:e,onChange:t,searchIconSize:n})=>{const{titles:s}=Me(),{isCrossDatasetModeOn:r}=Ue(),[a,i]=f.useState(!1),c=e.trim().toLowerCase(),l=r&&a&&c.length<kh;return o.jsxs(o.Fragment,{children:[o.jsx(j.InputWithIcon,{inputId:"filters-search-input",containerClasses:"gap-2 items-center filters-search-input",cssClass:"filters-search-input-text",placeholder:s?.searchPlaceholder??"Search",value:e,onChange:t,onFocus:()=>i(!0),onBlur:()=>i(!1),iconBeforeInput:o.jsx(He.IconSearch,{width:n,height:n,className:"text-primary"})}),r&&o.jsx("span",{className:W("caption text-neutrals-800 mt-1",{invisible:!l}),children:s?.searchMinCharsCaption??"Enter at least 2 characters to start searching"})]})},_h=e=>Ne.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ne.createElement("path",{d:"M6.25 4.66668L9.75 8.00001L6.25 11.3333L6.25 4.66668Z",fill:"currentColor"})),bc=({node:e,level:t=1,checkboxIcon:n,selectFilterValue:s,selectHierarchicalNodes:r,expandHierarchicalValue:a})=>{const i=!!e?.children?.length,c=i&&!e.isSelectedValue&&vc(e),l="cursor-pointer text-neutrals-1000 w-6 h-6 shrink-0",d=f.useId(),u=(h,m)=>{if(e?.children?.length){const p=e.children.some(g=>!g.disabled);r?.(p?Th(e):[{...e,isSelectedValue:m}])}else s?.(e.id,m)};return o.jsxs("div",{className:"flex flex-col",children:[o.jsxs("div",{className:"flex items-center",style:{paddingLeft:Sh(t,i)},children:[i&&(e?.isExpanded?o.jsx(_h,{className:l,onClick:()=>a?.(e)}):o.jsx(Ur,{className:l,onClick:()=>a?.(e)})),o.jsx(j.Checkbox,{id:d,label:e?.name,checked:!!e.isSelectedValue,indeterminate:c,checkboxIcon:n,disabled:e?.disabled,onChange:u})]}),i&&e?.isExpanded&&o.jsx(o.Fragment,{children:e?.children?.map(h=>o.jsx(bc,{node:h,level:t+1,checkboxIcon:n,selectFilterValue:s,selectHierarchicalNodes:r,expandHierarchicalValue:a},h?.id))})]},e?.id)},Ih=({treeNodes:e,checkboxIcon:t,selectFilterValue:n,selectHierarchicalNodes:s,expandHierarchicalValue:r})=>o.jsx(o.Fragment,{children:e?.map(a=>o.jsx(bc,{node:a,checkboxIcon:t,selectFilterValue:n,selectHierarchicalNodes:s,expandHierarchicalValue:r},a?.id))}),Oo=({style:e,filterValue:t,checkboxIcon:n,selectFilterValue:s})=>o.jsx("div",{style:e,children:o.jsx(j.Checkbox,{id:t.id,label:t.name,checked:!!t.isSelectedValue,checkboxIcon:n,onChange:s})}),rn=(e,t,n,s,r=ne.Locale.EN)=>{const a=t?.map(i=>{const c=D.findCodelistByDimension(n?.codelists,n?.conceptSchemes,i),l=D.getAvailableCodesFromConstrains(c?.codes,i.id,s,r);return{...i,dimensionValues:l}});return e?.map(i=>{const c=a?.find(m=>m.id===i.id),d=(c?.dimensionValues||[]).map(m=>{const p=i.dimensionValues?.find(g=>g?.id===m?.id)?.isSelectedValue;return{...m,isSelectedValue:p}}),u=new Set(d.map(m=>m.id)),h=c?(i.dimensionValues??[]).filter(m=>!!m.isSelectedValue&&!u.has(m.id)):[];return{...i,isDisabled:!1,dimensionValues:[...d,...h]}})||[]},Ar=(e,t,n)=>{let s=[];return Mn(e,t,n).filter(r=>r.timeRange||r.dimensionValues?.some(a=>a.isSelectedValue)).forEach(r=>{const{id:a,dimensionValues:i}=r;r.isTimeDimension?s=[...s,...Rh(r.timeRange,a)]:s.push({componentCode:a,operator:D.SeriesFilterOperator.EQUALS,value:i?.filter(c=>c.isSelectedValue)?.map(c=>c.id).join(D.GET_v3_FILTER_AND)||""})}),s},Rh=(e,t)=>e==null||e.startPeriod==null||e.endPeriod==null?[]:[{componentCode:t,operator:D.SeriesFilterOperator.GREATER_OR_EQUAL,value:Fo(new Date(e.startPeriod))},{componentCode:t,operator:D.SeriesFilterOperator.LESS_OR_EQUAL,value:Fo(new Date(e.endPeriod),1)}],Ph=1e3*60*60*24,Fo=(e,t=0)=>{e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMinutes(e.getMinutes()-e.getTimezoneOffset());let n=e.getTime();return n+=t?Ph-1:0,e=new Date(n),n.toString()},Ht=e=>[...e].map(t=>({...t,value:t.value.split(",").sort().join(",")})).sort((t,n)=>t.componentCode.localeCompare(n.componentCode)),Vt=new Map,an=new Map;function xc(e,t){return`${e.name??""}::${t}`}function st(...e){return JSON.stringify(e)}async function it(e,t,n){const s=xc(e,t);if(Vt.has(s))return Vt.get(s);const r=an.get(s);if(r)return r;const a=n().then(i=>(Vt.set(s,i),i)).finally(()=>{an.delete(s)});return an.set(s,a),a}function Er(e,t){return Vt.has(xc(e,t))}function Vo(){Vt.clear(),an.clear()}const Lh=e=>e.map(t=>({componentCode:t.id||"",operator:ne.QueryFilterType.IN,values:t.dimensionValues?.map(n=>n.id)||[]})),yc=(e,t)=>{const n=t?.timeDimensions?.[0],s=D.getTimeRangeFromAttachment(e,n)||null;return s?D.getQueryTimePeriodFilters(s,n?.id):null},Sc=(e,t,n)=>{const s=Tn(Mn(e,n)),r=s.find(a=>a?.isTimeDimension&&a?.timeRange);return{filterKey:D.getTimeSeriesFilterKey(t||[],Lh(s)),timeFilter:D.getQueryTimePeriodFilters(r?.timeRange,r?.id)}},Oh=e=>{if(!e)return"";const t=String(e.getDate()).padStart(2,"0"),n=String(e.getMonth()+1).padStart(2,"0"),s=e.getFullYear();return`${n}-${t}-${s}`},Fh=e=>{if(!e)return"";const t=String(e.getDate()).padStart(2,"0"),n=String(e.getMonth()+1).padStart(2,"0");return`${e.getFullYear()}-${n}-${t}`},Dc=(e,t,n=Oh)=>Mn(e,t)?.filter(s=>s.timeRange||s.isExcluded||s.dimensionValues?.some(r=>r.isSelectedValue)).map(s=>s?.isTimeDimension?{componentCode:s?.id,operator:ne.QueryFilterType.BETWEEN,values:[n(s?.timeRange?.startPeriod||void 0)||"",n(s?.timeRange?.endPeriod||void 0)||""]}:s.isExcluded?{componentCode:s?.id,operator:ne.QueryFilterType.EXCLUDED,values:[]}:{componentCode:s?.id,operator:ne.QueryFilterType.IN,values:s?.dimensionValues?.filter(r=>r.isSelectedValue)?.map(r=>r.id)||[]}),Vh=(e,t)=>{const n=Mn(e,t).flatMap(r=>r.id?[r.id]:[]),s=e.flatMap(r=>{if(r.filterType!=="shared")return[];const a=r.sourceFilterIdsByDataset?.[t];return a?[a]:[]});return new Set([...n,...s])},Hh=(e,t)=>{const n=new Set(t.map(s=>s.componentCode));return Array.from(e).filter(s=>!n.has(s)).map(s=>({componentCode:s,operator:ne.QueryFilterType.IN,values:[D.GET_v3_FILTER_ALL]}))},Tc=(e,t)=>{const n=Uh(t,e.urn),s=Vh(t,e.urn),r=Hh(s,n),a=(e.filters??[]).filter(i=>!s.has(i.componentCode));return{...e,filters:[...a,...n,...r]}},Mc=(e,t)=>Dc(e,t),Uh=(e,t)=>Dc(e,t,Fh),Ac="COUNTRY",Ec="FREQUENCY",Dt="TIME_PERIOD",Gh=new Set([Ac,Ec,Dt]),on=e=>e?.trim()?.toLocaleUpperCase(),Ho=()=>(e,t)=>{const n=e?.name?.trim()?.toLocaleLowerCase();return n?Bh(n):qh(t||"",e.id)},Bh=e=>`name:${e}`,qh=(e,t)=>`dataset:${e}:id:${t}`,Nc=(e,t)=>e?t?.[e]:void 0,Uo=(e,t)=>{if(!(e?.filterType!=="dataset"||!e.id))return Nc(e.datasetUrn,t)?.[e.id]},jc=(e,t,n)=>Object.entries(Nc(e,n)||{}).find(([,s])=>t(s))?.[0],kc=(e,t,n)=>jc(e,s=>s.subtype===t,n),zh=(e,t)=>jc(e,n=>n.dimensionType==="TIME_PERIOD",t),At=[{id:Ac,subtype:"REGION",getMergedValueKey:Ho()},{id:Ec,subtype:"FREQUENCY",getMergedValueKey:Ho()},{id:Dt,getMergedValueKey:e=>e.id}],Wh=new Map(At.map(e=>[e.id,e])),Br=e=>e?Wh.get(on(e)||""):void 0,$h=(e,t,n)=>{if(e.filterType==="shared")return t.id===on(e.id);if(t.id===Dt)return e.isTimeDimension||Uo(e,n)?.dimensionType==="TIME_PERIOD"||t.id===on(e.id);const s=Uo(e,n);return t.subtype&&s?.subtype===t.subtype?!0:t.id===on(e.id)},pn=(e,t)=>e?At.find(n=>$h(e,n,t)):void 0,Kh=(e,t,n)=>{if(!t)return;const s=e?n?.[e]?.[t]:void 0;return s?.dimensionType==="TIME_PERIOD"?Dt:At.find(a=>!!a.subtype&&a.subtype===s?.subtype)?.id??Br(t)?.id},Jh=e=>!!Br(e),Yh=e=>e?.filterType==="shared"&&Jh(e?.id),_c=(e,t)=>!e||Array.isArray(e.get(t)),Ic=(e,t)=>!e?.dataMessagesMap||e.dataMessagesMap.has(t),Zh=(e,t)=>{const n=new Map;return e.forEach(s=>{s.dimensionValues?.forEach(r=>{const a=t.getMergedValueKey(r,s.datasetUrn),i={datasetUrn:s.datasetUrn,id:r.id,name:r.name,parent:r.parent},c=n.get(a);if(c){c.isSelectedValue=c.isSelectedValue||r.isSelectedValue,c.sourceValues=[...c.sourceValues||[],i];return}n.set(a,{id:a,name:r.name,isSelectedValue:r.isSelectedValue,parent:r.parent,sourceValues:[i]})})}),Array.from(n.values())},Rc=(e,t)=>{const n=new Map,s=[];return e.forEach(a=>{const i=pn(a,t);if(i&&a?.datasetUrn){const c=n.get(i.id)||[];n.set(i.id,[...c,a]);return}s.push(a)}),[...At.flatMap(a=>{const i=n.get(a.id);if(!i?.length)return[];const c={...i[0],id:a.id,datasetUrn:void 0,filterType:"shared",sourceDatasetUrns:Array.from(new Set(i.map(l=>l.datasetUrn).filter(l=>!!l))),sourceFilterIdsByDataset:Object.fromEntries(i.flatMap(l=>l.datasetUrn&&l.id?[[l.datasetUrn,l.id]]:[])),dimensionValues:Zh(i,a)};return c.isTimeDimension&&(c.timeRange=nm(i)),c}),...s]},qr=(e,t,n)=>{const s=e.sourceFilterIdsByDataset?.[t];if(s)return s;if(e.id===Dt)return zh(t,n);const r=Br(e.id);return r?.subtype?kc(t,r.subtype,n):void 0},Pc=(e,t,n,s)=>({...e,id:qr(e,t,s)||e.id,datasetUrn:t,filterType:"dataset",...n?{dimensionValues:n}:{}}),Xh=(e,t)=>(e.sourceDatasetUrns||[]).map(n=>Pc(e,n,void 0,t)),Qh=(e,t)=>({id:t.id,name:t.name,parent:t.parent,isSelectedValue:e.isSelectedValue}),em=(e,t)=>{const n=new Map;return e.dimensionValues?.forEach(s=>{s.sourceValues?.forEach(r=>{const a=r.datasetUrn||"",i=n.get(a),c=Qh(s,r);if(i){i.dimensionValues=[...i.dimensionValues||[],c];return}n.set(a,Pc(e,a,[c],t))})}),n},tm=(e,t=!1,n)=>{if(!Yh(e))return[e];if(e.isTimeDimension)return Xh(e,n);const s=em(e,n);return Array.from(s.values())},nm=e=>{const t=e.map(s=>s.timeRange?.startPeriod).filter(s=>!!s),n=e.map(s=>s.timeRange?.endPeriod).filter(s=>!!s);if(!(!t.length||!n.length))return{startPeriod:new Date(Math.min(...t.map(s=>s.getTime()))),endPeriod:new Date(Math.max(...n.map(s=>s.getTime())))}},Lc=(e,t,n,s)=>t&&t<n?{startPeriod:new Date(n),endPeriod:new Date(n)}:e&&e>s?{startPeriod:new Date(s),endPeriod:new Date(s)}:{startPeriod:e?new Date(Math.max(e.getTime(),n.getTime())):new Date(n),endPeriod:t?new Date(Math.min(t.getTime(),s.getTime())):new Date(s)},sm=(e,t)=>{if(!e.isTimeDimension||!e.timeRange)return e;const{startPeriod:n,endPeriod:s}=D.getAnnotationPeriod(t?.[0]?.annotations);return!n||!s?e:{...e,timeRange:Lc(e.timeRange.startPeriod,e.timeRange.endPeriod,n,s)}},rm=(e,t)=>e?.dimensionsMap?new Map(Array.from(e.dimensionsMap.entries()).map(([n,s])=>[n,cc(s,e?.structuresMap?.get(n),e?.structureDimensionsMap?.get(n),t,n)])):new Map,am=(e,t,n=!0)=>new Map(Array.from(e?.dimensionsMap?.entries()||[]).map(([s,r])=>{const a=_c(e?.constraintsMap,s),i=Ic(e,s),c=r?.map(l=>{if(!a||n&&!i)return{...l,dimensionValues:[]};const d=D.findCodelistByDimension(e?.structuresMap?.get(s)?.codelists,e?.structuresMap?.get(s)?.conceptSchemes,l),u=D.getAvailableCodesFromConstrains(d?.codes,l.id,e?.constraintsMap?.get(s),t);return{...l,dimensionValues:u}})||[];return[s,c]})),im=e=>e.map(t=>({...t,isDisabled:!1,dimensionValues:t.dimensionValues?.filter(n=>n.isSelectedValue)||[]})),Oc=(e,t,n=!0)=>{const s=rm(e,t),r=am(e,t,n);return new Map(Array.from(s?.entries()||[]).map(([a,i])=>{const c=r?.get(a),l=i.map(d=>({...d,dimensionValues:c?.find(u=>u.id===d.id)?.dimensionValues||[]}));return[a,l]}))},Fc=(e,t,n,s)=>{const r=(a,i)=>t?.some(c=>c.urn!==a.urn&&c.filters?.some(l=>l.operator===ne.QueryFilterType.BETWEEN||!l.values?.length?!1:pn({id:l.componentCode,datasetUrn:c.urn,filterType:"dataset"},s)?.id===i.id))??!1;return Rc(t?.flatMap(a=>{const i=a?.urn,c=e?.get(i)||[],l=n?.get(i)||[];return pc(c,a,l).map(u=>{if(u.isTimeDimension||u.filterType!=="dataset")return u;const h=pn(u,s);return!h||h.id===Dt||a.filters?.some(g=>g.componentCode===u.id&&g.operator!==ne.QueryFilterType.BETWEEN)||!r(a,h)||u.dimensionValues?.some(g=>g.isSelectedValue)?u:{...u,dimensionValues:u.dimensionValues?.map(g=>({...g,isSelectedValue:!0}))}})})||[],s)},xt=(e,t,n=!1,s,r=new Set)=>{const a=e?.flatMap(i=>tm(i,n,s))?.reduce((i,c)=>{const l=c?.datasetUrn||"",d=sm(c,t?.get(l));return i.has(l)||i.set(l,[]),i?.get(l)?.push(d),i},new Map);if(r.size>0)for(const i of r)a.delete(i);return a},Vc=(e,t,n,s,r)=>{const a=e.filter(c=>c.filterType==="shared"&&!c.isTimeDimension&&(c.dimensionValues?.some(l=>l.isSelectedValue)??!1));if(!a.length)return new Set(t);const i=(c,l)=>{const d=qr(l,c,s);if(!d)return!1;if(r)return!(r.get(c)??[]).find(p=>p.id===d);const u=n?.find(h=>h.urn===c);return u?!u.filters?.some(h=>h.componentCode===d&&h.operator!==ne.QueryFilterType.BETWEEN):!1};return new Set(t.filter(c=>a.every(l=>l.dimensionValues?.some(d=>d.isSelectedValue&&d.sourceValues?.some(u=>u.datasetUrn===c))||i(c,l))))},Go=(e,t)=>t?(e||[]).filter(n=>t.has(n.urn)):e||[],jt=(e,t)=>t?new Map([...e].filter(([n])=>t.has(n))):e,Hc=(e,t)=>{const n=new Map;if(e?.forEach(s=>{s.filters?.forEach(r=>{if(r.operator===ne.QueryFilterType.BETWEEN||!r.values?.length)return;const a=pn({id:r.componentCode,datasetUrn:s.urn,filterType:"dataset"},t);if(!a||a.id===Dt)return;const i=n.get(a.id)??new Set;i.add(s.urn),n.set(a.id,i)})}),!!n.size)return e?.filter(s=>Array.from(n.values()).every(r=>r.has(s.urn))).map(s=>s.urn)??[]},om=(e,t)=>t?Array.from(new Set(e?.flatMap(n=>n.cubeRegions?.filter(s=>s.isIncluded).flatMap(s=>s.memberSelection?.filter(r=>r.componentId===t).flatMap(r=>r.selectionValues.map(a=>a.memberValue))??[])??[])??[])):[],lm=(e,t,n)=>{if(e.length<2||!t)return e;const s=e.flatMap(i=>At.flatMap(c=>{if(!c.subtype)return[];const l=kc(i.urn,c.subtype,n);return l?[{configId:c.id,dataQuery:i,dimensionId:l,filter:i.filters?.find(d=>d.componentCode===l&&d.operator!==ne.QueryFilterType.BETWEEN),availableValues:om(t.get(i.urn),l)}]:[]})),r=new Map;s.forEach(i=>{r.set(i.configId,[...r.get(i.configId)??[],i])});const a=new Map;return r.forEach(i=>{const c=i.filter(u=>u.filter?.values?.length),l=i.filter(u=>!u.filter);if(!c.length||!l.length)return;const d=new Set(l.flatMap(u=>u.availableValues));d.size&&c.forEach(u=>{const h=u.filter;if(!h?.values?.length)return;const m=new Set(u.availableValues),p=Array.from(new Set([...h.values,...Array.from(d).filter(g=>m.has(g))]));p.length>h.values.length&&a.set(h,p)})}),a.size?e.map(i=>{let c=!1;const l=i.filters?.map(d=>{const u=a.get(d);return u?(c=!0,{...d,values:u}):d});return c?{...i,filters:l}:i}):e},Uc=e=>JSON.stringify(e?.map(t=>({urn:t.urn,filters:t.filters??[]}))??[]),kt=(e,t,n=ne.Locale.EN,s)=>{const r=[];return Array.from(e?.entries())?.forEach(([a,i])=>{const c=t?.dimensionsMap?.get(a),l=t?.structuresMap?.get(a),d=_c(t?.constraintsMap,a),u=Ic(t,a);if(!d||!u){r.push(...im(i));return}const h=t?.constraintsMap?.get(a);r.push(...rn(i,c,l,h,n))}),Rc(r,s)},Mn=(e,t,n)=>t?xt(e,void 0,!1,n).get(t)||[]:e.filter(s=>s.filterType!=="shared"),Gc=(e,t)=>{if(e?.filterType==="shared")return;const n=e?.datasetUrn?t?.get(e.datasetUrn)?.dataflows?.[0]:void 0;return n?D.generateShortUrn(n?.name,"",n?.agencyID):void 0},cm=(e,t)=>e?.length?!!t?.dimensionsMap&&!!t?.structuresMap&&!!t?.structureDimensionsMap&&!!t?.constraintsMap:!1,Bc=(e,t,n)=>Ht(Ar(t,e,n).filter(s=>s.componentCode!==D.TIME_PERIOD)),Bo=(e,t,n,s,r)=>e?.map(a=>{const i=a?.urn??"",c=r??t?.get(i)??[],l=Bc(i,c,s);return n?it(n.getConstraints,st(i,l),()=>n.getConstraints(i,l)).then(d=>({urn:i,data:d})):Promise.resolve({urn:i,data:{}})})||[],qo=(e,t,n,s,r)=>!n?.getConstraints||!e?.length?!1:e.some(a=>{const i=a?.urn??"",c=r??t?.get(i)??[],l=Bc(i,c,s);return!Er(n.getConstraints,st(i,l))}),um=(e,t,n)=>{if(e.length<2)return!1;const s=new Map;for(const r of e){const a=t.dimensionsMap?.get(r.urn);if(a)for(const i of a){const c=i.id;if(!c)continue;const l=n?.[r.urn]?.[c],d=l?.subtype;if(!d||l?.dimensionType==="TIME_PERIOD")continue;const u=At.find(p=>p.subtype===d);if(!u)continue;const h=s.get(u.id)??{datasetsWithExplicitValues:new Set,datasetsWithMissingFilter:new Set},m=r.filters?.find(p=>p.componentCode===c&&p.operator!==ne.QueryFilterType.BETWEEN);m?m.values?.length&&h.datasetsWithExplicitValues.add(r.urn):h.datasetsWithMissingFilter.add(r.urn),s.set(u.id,h)}}return[...s.values()].some(r=>[...r.datasetsWithMissingFilter].some(a=>[...r.datasetsWithExplicitValues].some(i=>i!==a)))},dm=e=>new Map(e?.flatMap(({urn:t,data:n})=>{const s=n?.data?.dataConstraints;return Array.isArray(s)?[[t,s]]:[]})),zo=e=>dm(e.flatMap(t=>t.status==="fulfilled"?[t.value]:[])),Wo=(e,t)=>{const n=new Map(e);return t.forEach((s,r)=>{n.set(r,s)}),n},qc=(e,t,n,s)=>{if(e&&t?.filterType==="shared"&&t?.isTimeDimension){const a=Array.from(s?.values()||[]).flatMap(l=>l||[]).map(l=>D.getAnnotationPeriod(l?.annotations)).filter(l=>l.startPeriod!==null&&l.endPeriod!==null);if(!a.length)return[];const i=new Date(Math.min(...a.map(l=>l.startPeriod.getTime()))),c=new Date(Math.max(...a.map(l=>l.endPeriod.getTime())));return[{id:t.id||D.TIME_PERIOD,annotations:[{id:D.TIME_PERIOD_START_ANNOTATION_KEY,title:i.toISOString()},{id:D.TIME_PERIOD_END_ANNOTATION_KEY,title:c.toISOString()}]}]}return e?s?.get(t?.datasetUrn??"")??[]:n??[]},zc=(e,t,n)=>new Map(t?.map(s=>{const r=s?.urn;return[r,Sc(e.get(r)||[],n?.get(r))]})),$o=(e,t,n,s,r)=>{const a=um(e,t,r);if(!n||!e.length||!a)return;const i={...t,constraintsMap:n},c=Oc(i,s,!1),l=Fc(c,e,n,r),d=xt(l,n,!1,r),u=Vc(l,e.map(m=>m.urn),e,r,d),h=e.filter(m=>u.has(m.urn));return{compatibleUrns:u,filterParamsMap:zc(d,h,t.dimensionsMap)}},Wc=(e,t)=>new Map(e?.map(n=>{const s=n?.urn;return[s,Mc(t?.get(s)||[])]})),fm=(e,t,n)=>{const s=(e.sourceDatasetUrns??[]).filter(c=>!t.has(c));if(s.length===0)return[];if(!n||!e.timeRange)return[{...e,sourceDatasetUrns:s}];const r=s.map(c=>D.getAnnotationPeriod(n.get(c)?.[0]?.annotations)).filter(c=>!!c?.startPeriod&&!!c?.endPeriod);if(r.length===0)return[{...e,sourceDatasetUrns:s}];const a=new Date(Math.min(...r.map(c=>c.startPeriod.getTime()))),i=new Date(Math.max(...r.map(c=>c.endPeriod.getTime())));return[{...e,sourceDatasetUrns:s,timeRange:Lc(e.timeRange.startPeriod,e.timeRange.endPeriod,a,i)}]},hm=(e,t,n)=>t.size===0?e:e.flatMap(s=>{if(s.filterType!=="shared")return[s];if(s.isTimeDimension)return fm(s,t,n);const r=(s.dimensionValues??[]).filter(a=>a.sourceValues?.some(i=>!t.has(i.datasetUrn??"")));return r.length===0?[]:[{...s,dimensionValues:r}]}),zr=e=>Ne.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ne.createElement("path",{d:"M8 14C6.32222 14 4.90278 13.7417 3.74167 13.225C2.58056 12.7083 2 12.0778 2 11.3333V4.66667C2 3.93333 2.58611 3.30556 3.75833 2.78333C4.93056 2.26111 6.34444 2 8 2C9.65556 2 11.0694 2.26111 12.2417 2.78333C13.4139 3.30556 14 3.93333 14 4.66667V11.3333C14 12.0778 13.4194 12.7083 12.2583 13.225C11.0972 13.7417 9.67778 14 8 14ZM8 6.01667C8.98889 6.01667 9.98333 5.875 10.9833 5.59167C11.9833 5.30833 12.5444 5.00556 12.6667 4.68333C12.5444 4.36111 11.9861 4.05556 10.9917 3.76667C9.99722 3.47778 9 3.33333 8 3.33333C6.98889 3.33333 5.99722 3.475 5.025 3.75833C4.05278 4.04167 3.48889 4.35 3.33333 4.68333C3.48889 5.01667 4.05278 5.32222 5.025 5.6C5.99722 5.87778 6.98889 6.01667 8 6.01667ZM8 9.33333C8.46667 9.33333 8.91667 9.31111 9.35 9.26667C9.78333 9.22222 10.1972 9.15833 10.5917 9.075C10.9861 8.99167 11.3583 8.88889 11.7083 8.76667C12.0583 8.64444 12.3778 8.50556 12.6667 8.35V6.35C12.3778 6.50556 12.0583 6.64444 11.7083 6.76667C11.3583 6.88889 10.9861 6.99167 10.5917 7.075C10.1972 7.15833 9.78333 7.22222 9.35 7.26667C8.91667 7.31111 8.46667 7.33333 8 7.33333C7.53333 7.33333 7.07778 7.31111 6.63333 7.26667C6.18889 7.22222 5.76944 7.15833 5.375 7.075C4.98056 6.99167 4.61111 6.88889 4.26667 6.76667C3.92222 6.64444 3.61111 6.50556 3.33333 6.35V8.35C3.61111 8.50556 3.92222 8.64444 4.26667 8.76667C4.61111 8.88889 4.98056 8.99167 5.375 9.075C5.76944 9.15833 6.18889 9.22222 6.63333 9.26667C7.07778 9.31111 7.53333 9.33333 8 9.33333ZM8 12.6667C8.51111 12.6667 9.03056 12.6278 9.55833 12.55C10.0861 12.4722 10.5722 12.3694 11.0167 12.2417C11.4611 12.1139 11.8333 11.9694 12.1333 11.8083C12.4333 11.6472 12.6111 11.4833 12.6667 11.3167V9.68333C12.3778 9.83889 12.0583 9.97778 11.7083 10.1C11.3583 10.2222 10.9861 10.325 10.5917 10.4083C10.1972 10.4917 9.78333 10.5556 9.35 10.6C8.91667 10.6444 8.46667 10.6667 8 10.6667C7.53333 10.6667 7.07778 10.6444 6.63333 10.6C6.18889 10.5556 5.76944 10.4917 5.375 10.4083C4.98056 10.325 4.61111 10.2222 4.26667 10.1C3.92222 9.97778 3.61111 9.83889 3.33333 9.68333V11.3333C3.38889 11.5 3.56389 11.6611 3.85833 11.8167C4.15278 11.9722 4.52222 12.1139 4.96667 12.2417C5.41111 12.3694 5.9 12.4722 6.43333 12.55C6.96667 12.6278 7.48889 12.6667 8 12.6667Z",fill:"currentColor"})),mm=e=>Ne.createElement("svg",{viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ne.createElement("path",{d:"M6.66663 6.175L10.4833 10L6.66663 13.825L7.84163 15L12.8416 10L7.84163 5L6.66663 6.175Z",fill:"currentColor"})),pm=md.FixedSizeList,Ko=24,Jo=232,Cr=({selectedFilter:e,filterValues:t,checkboxIcon:n,isHierarchicalView:s,isVirtualized:r=!0,isScrollable:a=!0,isDisableValues:i,isValuesLoading:c,structuresMap:l,hierarchyTreeNodes:d,isHierarchyLoading:u,selectFilterValue:h,selectHierarchicalNodes:m,expandHierarchicalValue:p})=>{const g=j.useIsMobile(),{isCrossDatasetModeOn:x}=Ue(),v=c||u;if(!t&&!v)return null;const w=t??[],C=e?Gc(e,l):void 0,b=l?.size===1,y=x&&e?.filterType!=="shared"&&!!e?.title&&(b||!!C),N=w.length*Ko,M=N>Jo?Jo:N;return o.jsxs("div",{className:W("relative",i&&"pointer-events-none opacity-[0.7]",a?"flex h-full min-h-0 flex-col":"flex flex-col"),children:[y&&o.jsxs("div",{className:"mb-2 flex items-center gap-x-1",children:[!b&&o.jsxs(o.Fragment,{children:[o.jsx(zr,{className:"size-4 shrink-0 text-neutrals-700"}),o.jsx("span",{className:"h4 text-neutrals-800",children:C}),o.jsx(mm,{className:"size-4 shrink-0 text-neutrals-1000"})]}),o.jsx("span",{className:"h4 text-neutrals-1000",children:e?.title})]}),v&&o.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 min-h-12",children:o.jsx(j.Loader,{})}),o.jsx("div",{className:W(a?"min-h-0 flex-1 overflow-auto":"overflow-visible",v&&"pointer-events-none opacity-[0.7]"),style:a&&g&&!v?{height:`${M}px`}:void 0,children:d?.length||s?o.jsx(Ih,{treeNodes:d??yh(w),checkboxIcon:n,selectFilterValue:h,selectHierarchicalNodes:m,expandHierarchicalValue:p}):r?o.jsx(pd,{children:({width:A,height:S})=>o.jsx(pm,{itemCount:w.length,itemSize:Ko,width:A,height:S,children:({index:_,style:E})=>o.jsx(Oo,{style:E,filterValue:w[_],checkboxIcon:n,selectFilterValue:h})})}):o.jsx("div",{className:"flex flex-col gap-y-1",children:w.map(A=>o.jsx(Oo,{filterValue:A,checkboxIcon:n,selectFilterValue:h},A.id))})})]})};function gm(e,t){const n=(e??"").split(".").map(Number),s=(t??"").split(".").map(Number),r=Math.max(n.length,s.length);for(let a=0;a<r;a++){const i=(n[a]??0)-(s[a]??0);if(i!==0)return i}return 0}function vm(e){const t=new Map;for(const n of e){const s=`${n.agencyID??""}:${n.id}`,r=t.get(s);(!r||gm(n.version??"",r.version??"")>0)&&t.set(s,n)}return Array.from(t.values())}function Yo(e){return D.generateShortUrn(e.id,e.version??"",e.agencyID??"")}function Zo(e,t,n,s,r){const a=D.getHierarchyCodes(e,t),i=D.getHierarchyAvailableCodes(a,n,s),c=D.getCodeListsData(t),l=Cm(e,c,i.map(d=>d.id),r);return Kc(l)}function $c(e,t,n,s,r){return s?.map(a=>{const{childId:i,agency:c,id:l,version:d}=D.getChildParsedUrn(a.code),u=D.generateShortUrn(l,d,c),h=Object.keys(e??{}).find(b=>D.urnMatchesIgnoreVersion(b,u))??u,p=e?.[h]?.find(b=>b.id===i),g=p?.name||p?.description||i,x=n?D.urnMatchesIgnoreVersion(u,n):!0,v=!x&&(a.hierarchicalCodes?.length??0)>0,w=$c(e,t,n,a.hierarchicalCodes,a.code),C=w.length===0;return v&&C||x&&C&&t&&!t.includes(i??"")?null:{id:a.code,name:g,children:w,isExpanded:!0,disabled:!x&&w.every(b=>b.disabled),isSelectableValue:x,parent:r,metadata:{...a,hierarchicalCodes:void 0}}}).filter(a=>a!==null)??[]}function Cm(e,t,n,s){return!n||n.length===0?[]:$c(t,n,s,e?.hierarchicalCodes,void 0)}function Kc(e){return e.map(t=>{const{childId:n}=D.getChildParsedUrn(t.id??"");return{id:n??t.id??"",name:t.name,isExpanded:t.isExpanded,isSelectedValue:!1,disabled:t.disabled,isSelectableValue:t.isSelectableValue,children:Kc(t.children)}})}function Jc(e,t){return e?.filterType!=="shared"?t:e.dimensionValues?.find(n=>n.id===t||n.sourceValues?.some(s=>s.id===t))?.id}function wm(e){return e?.filterType!=="shared"?new Set(e?.dimensionValues?.filter(t=>t.isSelectedValue).map(t=>t.id)??[]):new Set(e.dimensionValues?.flatMap(t=>t.isSelectedValue?t.sourceValues?.map(n=>n.id)??[]:[])??[])}function bm(e,t){if(!e?.length||t?.filterType!=="shared")return e??[];const n=new Map;return e.forEach(s=>{const r=Jc(t,s.id);r&&n.set(r,{...s,id:r})}),Array.from(n.values())}function xm(e,t){return Jc(t,e)}function Yc(e,t){return e.map(n=>{const s=n.children?.length?Yc(n.children,t):n.children;let r;if(t.has(n.id))r=!0;else if(s?.length&&!n.isSelectableValue){const a=s.filter(i=>!i.disabled);r=a.length>0&&a.every(i=>!!i.isSelectedValue)}else r=!1;return{...n,isSelectedValue:r,children:s}})}function Zc(e,t){return e.map(n=>n.id===t?{...n,isExpanded:!n.isExpanded}:n.children?.length?{...n,children:Zc(n.children,t)}:n)}function Xc(e,t){const n=t.toLowerCase();return e.reduce((s,r)=>{const a=r.name?.toLowerCase().includes(n),i=Xc(r.children??[],t);return(a||i.length>0)&&s.push({...r,isExpanded:!0,children:a?r.children:i}),s},[])}const Qc=f.createContext(null);function ym({children:e,value:t}){return o.jsx(Qc.Provider,{value:t,children:e})}function eu(){const e=f.useContext(Qc);if(!e)throw new Error("useFiltersModal must be used within FiltersModalProvider");return e}const Sm=2,tu=({filtersList:e,selectedFilter:t,initialConstraints:n,structuresMap:s,selectedTimeOption:r,hierarchyState:a})=>{const{titles:i}=Me(),{locale:c,isDisableValues:l,isValuesLoading:d,timeRangeOptions:u,filterValuesProps:h,dataQueries:m,selectFilterValue:p,selectHierarchicalNodes:g,expandHierarchicalValue:x,onTimePeriodChange:v}=eu(),[w,C]=f.useState(""),{isCrossDatasetModeOn:b}=Ue(),y=t?.displayMode===tt.HIERARCHY,N=We(t),M=t?.filterType==="shared",A=w?.trim().toLowerCase(),S=b?A.length>=Sm:!!A,_=S&&b&&!M,E=f.useCallback(O=>{if(!O?.dimensionValues)return{filterValues:[],matchedCount:0};const $=O.dimensionValues.filter(K=>K?.name?.toLowerCase()?.includes(A));return{filterValues:O.displayMode===tt.HIERARCHY?D.getFilteredItemsWithParents(O.dimensionValues,$):$,matchedCount:$.length}},[A]),T=f.useMemo(()=>S?E(t).filterValues:t?.dimensionValues,[S,E,t]),k=f.useMemo(()=>_?(e||[]).reduce((O,$)=>{if(Re($,t)||$.filterType==="shared")return O;const{filterValues:K,matchedCount:Z}=E($);return Z?[...O,{filter:$,filterValues:K,matchedCount:Z,isHierarchicalView:$.displayMode===tt.HIERARCHY}]:O},[]):[],[_,e,t,E]),I=f.useMemo(()=>{const O=a?.treeNodes;if(!O?.length)return O;const $=wm(t),K=$.size?Yc(O,$):O;return S?Xc(K,A):K},[a?.treeNodes,t,S,A]),L=I?!I.length:!T?.length,H=!!d||!!a?.isLoading,G=f.useMemo(()=>k.reduce((O,$)=>O+$.matchedCount,0),[k]);f.useEffect(()=>{C("")},[N]);const Y=f.useCallback(O=>{C(O)},[C]);return o.jsx(o.Fragment,{children:t?.isTimeDimension&&n?o.jsx(Eh,{initialConstraints:n,calendarResolution:ne.CalendarResolution.DAY,timeRange:t?.timeRange||null,timeRangeOptions:u||[],calendarStartFromMonday:!0,locale:c,radioIcon:h?.radioIcon,onValueChange:v,calendarIcon:h?.calendarIcon,dateFormat:h?.dateFormat,defaultTimeOption:r,dataQueries:m}):o.jsxs("div",{className:W("flex flex-col py-2 h-full flex-1 min-w-0 sm:border-0","filter-values-container"),children:[o.jsx(wc,{value:w,onChange:Y,searchIconSize:h?.searchIconSize}),o.jsx("div",{className:"body-2 mt-3 flex min-h-0 flex-1 flex-col overflow-auto",children:_?o.jsxs(o.Fragment,{children:[t&&o.jsxs("div",{className:"shrink-0 pb-4",children:[o.jsx(Cr,{selectedFilter:t,filterValues:T,checkboxIcon:h?.checkboxIcon,isHierarchicalView:y,isVirtualized:!1,isScrollable:!1,isDisableValues:l,isValuesLoading:d,structuresMap:s,hierarchyTreeNodes:I,isHierarchyLoading:a?.isLoading,selectFilterValue:p,selectHierarchicalNodes:g,expandHierarchicalValue:x}),!H&&L&&o.jsx("span",{className:"body-2 text-neutrals-700",children:i?.noResultsInSection?.(t.title??"")??`No results found in ${t.title??""}`})]}),o.jsxs("div",{className:"pb-3",children:[o.jsxs("span",{className:"h2 text-neutrals-1000",children:[i?.otherResults??"Other results",":"," ",G]}),!d&&G===0&&o.jsx("p",{className:"body-2 mt-1 text-neutrals-700",children:i?.noResultsInOtherDimensions??"No results found in other dimensions"})]}),k.map(({filter:O,filterValues:$,isHierarchicalView:K})=>o.jsx("div",{className:"shrink-0 pb-4 last:pb-0",children:o.jsx(Cr,{selectedFilter:O,filterValues:$,checkboxIcon:h?.checkboxIcon,isHierarchicalView:K,isVirtualized:!1,isScrollable:!1,isDisableValues:l,isValuesLoading:d,structuresMap:s,selectFilterValue:(Z,se)=>p(Z,se,O),selectHierarchicalNodes:Z=>g(Z,O),expandHierarchicalValue:Z=>x(Z,O)})},We(O)))]}):o.jsx(Cr,{selectedFilter:t,filterValues:T,checkboxIcon:h?.checkboxIcon,isHierarchicalView:y,isDisableValues:l,isValuesLoading:d,structuresMap:s,hierarchyTreeNodes:I,isHierarchyLoading:a?.isLoading,selectFilterValue:p,selectHierarchicalNodes:g,expandHierarchicalValue:x})})]})})},Dm=({filtersList:e,filter:t,onSelectFilter:n,onSelectDisplayMode:s,onDeleteFilter:r,initialConstraints:a,hideFacetCounterByDefault:i,hierarchyState:c})=>{const{titles:l}=Me(),{locale:d,onSelectHierarchy:u}=eu(),h=j.useIsMobile(),[m,p]=f.useState(0),[g,x]=f.useState(!1),v=t?.isTimeDimension&&t?.timeRange,w=f.useMemo(()=>t?.timeRange?.startPeriod&&t?.timeRange?.endPeriod?`${fn(t?.timeRange?.startPeriod,d)} -
6
- ${fn(t?.timeRange?.endPeriod,d)}`:"",[d,t?.timeRange]);f.useEffect(()=>{p(dc(t?.dimensionValues)?.length)},[t?.dimensionValues]);const C=i?m>0:!0,b=f.useMemo(()=>Ah({isHierarchical:t?.isHierarchical,availableHierarchies:c?.availableHierarchies,titles:l}),[t?.isHierarchical,c?.availableHierarchies,l]),y=c?.isLoading||!t?.isHierarchical&&!c?.availableHierarchies?.length;f.useEffect(()=>{t.isSelectedFilter||x(!1)},[t.isSelectedFilter]);const N=()=>{h&&x(A=>!A),n(t)},M=A=>{if(A==="")u?.(t,null),s?.(t,tt.FLAT_LIST);else if(A===tt.HIERARCHY)u?.(t,null),s?.(t,tt.HIERARCHY);else{const S=c?.availableHierarchies?.find(_=>_.id===A)??null;u?.(t,S)}};return o.jsxs("div",{className:"flex flex-col",children:[o.jsxs("div",{className:W("flex justify-between items-center px-2 h-10 hover:bg-hues-100 sm:h-14 sm:hover:bg-white rounded","filters-facet-item cursor-pointer",t?.isSelectedFilter&&!h&&"bg-hues-100",t?.isDisabled&&"cursor-default pointer-events-none opacity-[0.7]"),onClick:N,children:[o.jsxs("h3",{className:"w-full min-w-0 flex-1 truncate sm:flex sm:items-center",title:t?.title,children:[o.jsx("span",{className:"truncate",children:t?.title}),h&&o.jsx(Ur,{className:W("chevron-icon w-6 h-6 shrink-0",g&&"rotate-180")})]}),o.jsxs("div",{className:"ml-2 flex items-center gap-2 text-neutrals-800",children:[v&&o.jsx("span",{className:"filters-facet-item-counter border-none",children:w}),!v&&C&&o.jsx("span",{className:W("px-2 text-center","filters-facet-item-counter"),children:m?`${m}/${t?.dimensionValues?.length||0}`:l?.all||"All"}),v?null:o.jsxs("div",{className:"filters-facet-item-settings flex items-center gap-2",children:[o.jsx(j.Dropdown,{triggerButton:o.jsx(j.IconButton,{buttonClassName:W("text-button-tertiary w-4 h-4 border-0 p-0","filters-facet-item-icon"),icon:o.jsx(oh,{width:16,height:16}),title:l?.displayOrder||"Display Order",disabled:y}),disabled:y,options:b,selectedOption:c?.selectedHierarchy?.id??(t?.displayMode===tt.HIERARCHY?tt.HIERARCHY:""),onOptionSelect:M}),m>0&&o.jsx(j.IconButton,{buttonClassName:W("text-button-tertiary w-4 h-4 border-0 p-0","filters-facet-item-icon"),icon:o.jsx(oc,{width:16,height:16}),title:l?.reset||"Reset",onClick:A=>{A.stopPropagation(),r?.(t)}})]})]})]}),g&&o.jsx(tu,{filtersList:e,selectedFilter:t,initialConstraints:a,hierarchyState:c})]})},Tm=new Set,Mm=({filtersList:e,hideFacetCounterByDefault:t,onSelectFilter:n,onDeleteFilter:s,onSelectDisplayMode:r,initialConstraints:a,initialConstraintsMap:i,datasetIcon:c,structuresMap:l,hierarchyStateMap:d,dataQueries:u,disabledDatasetUrns:h=Tm,isDatasetFacetSelected:m=!1,onSelectDatasetFacet:p,onClearAllDatasets:g})=>{const{isCrossDatasetModeOn:x}=Ue(),v=new Set(e.filter(w=>w.filterType==="dataset").map(w=>w.datasetUrn||"")).size;return o.jsxs("div",{className:W("overflow-y-auto advanced-view-filters-list w-[338px] pr-3 h-full sm:w-full"),children:[u&&u.length>0&&o.jsx(ih,{dataQueries:u,disabledDatasetUrns:h,isSelected:m,onSelect:p,onClearAll:g}),e.filter(w=>!(w.filterType==="dataset"&&w.datasetUrn&&h.has(w.datasetUrn))).map((w,C,b)=>{const y=b[C-1],M=w.filterType==="dataset"&&v>1&&w.datasetUrn!==y?.datasetUrn?Gc(w,l):void 0;return o.jsxs("div",{className:"min-w-0 shrink-0",children:[M&&o.jsxs("h4",{className:"filters-facet-dataset-name !flex",children:[o.jsx("span",{className:"filters-facet-dataset-icon",children:c}),o.jsx("span",{className:"min-w-0 truncate",title:M,children:M})]}),o.jsx(Dm,{filtersList:b,filter:w,onSelectFilter:n,onSelectDisplayMode:r,onDeleteFilter:s,hideFacetCounterByDefault:t,initialConstraints:qc(x,w,a,i),hierarchyState:d?.get(We(w)??"")})]},We(w))})]})},Am=({dataQueries:e,disabledDatasetUrns:t,onToggleDataset:n,searchIconSize:s})=>{const[r,a]=f.useState(""),i=r.trim().toLowerCase(),c=e.filter(d=>i.length<2||(d.title??d.urn).toLowerCase().includes(i)),l=e.length-t.size;return o.jsxs("div",{className:"filter-values-container flex h-full min-w-0 flex-1 flex-col py-2 sm:border-0",children:[o.jsx(wc,{value:r,onChange:a,searchIconSize:s}),o.jsx("div",{className:"body-2 mt-3 flex min-h-0 flex-1 flex-col overflow-auto",children:c.map(d=>{const u=!t.has(d.urn),h=u&&l===1;return o.jsx("div",{className:W("py-1",h&&"pointer-events-none"),children:o.jsx(j.Checkbox,{id:d.urn,label:d.title??d.urn,checked:u,disabled:h,disabledScope:"icon",onChange:(m,p)=>n(d.urn,!!p)})},d.urn)})})]})},nu=({filtersList:e,selectedFilter:t,modalProps:n,locale:s,isDisableValues:r,isValuesLoading:a,timeSeriesCount:i,timeRangeOptions:c,initialConstraints:l,initialConstraintsMap:d,datasetIcon:u,structuresMap:h,setSelectedFilter:m,onSelectDisplayMode:p,onDeleteFilter:g,onClearAllFilters:x,updateSelectedFilterValues:v,onTimePeriodChange:w,selectedTimeOption:C,hierarchyStateMap:b,onSelectHierarchy:y,onExpandHierarchyNode:N,dataQueries:M,disabledDatasetUrns:A,onToggleDataset:S,onClearAllDatasets:_})=>{const{titles:E}=Me(),T=b?.get(We(t)),k=j.useIsMobile(),{isCrossDatasetModeOn:I}=Ue(),[L,H]=f.useState(!1),G=f.useMemo(()=>hm(e.filter(F=>!(F.filterType==="dataset"&&F.datasetUrn&&A.has(F.datasetUrn))),A,d),[e,A,d]),Y=f.useMemo(()=>t?G.find(F=>Re(F,t)):void 0,[t,G]),O=Gr(Tn(e))+A.size,$=f.useCallback(()=>{H(!0),m(void 0)},[m]),K=f.useCallback(F=>{H(!1);const J=e?.find(ue=>Re(ue,F));if(!J){m(void 0);return}m({...J,isSelectedFilter:!0})},[e,m]),Z=F=>F?e?.find(J=>Re(J,F)):void 0,se=(F,J,ue)=>{const de=!ue||Re(ue,t),me=Z(ue??t)??ue??t;if(!me)return;const re=sn(me)?xm(F,me):F;if(!re)return;const Q={...me,dimensionValues:me?.dimensionValues?.map(U=>U?.id===re?{...U,isSelectedValue:J}:U)};de&&m(Q),v&&v(Q)},ge=(F,J)=>{const ue=!J||Re(J,t),de=Z(J??t)??J??t;if(!de)return;const me=sn(de)?bm(F,de):F??[],re=new Set(de?.dimensionValues?.map(q=>q.id)),Q=sn(de)?[]:Mh(me,re),U={...de,dimensionValues:[...de?.dimensionValues?.map(q=>{const fe=me.find(ae=>ae?.id===q?.id);return fe?{...q,isSelectedValue:fe.isSelectedValue}:q})??[],...Q]};ue&&m(U),v&&v(U)},he=(F,J)=>{const ue=!J||Re(J,t),de=Z(J??t)??J??t;if(!de||!F?.id)return;const me=We(de);if((me?b?.get(me):void 0)?.treeNodes?.length){N?.(me,F.id);return}const Q={...de,dimensionValues:de?.dimensionValues?.map(U=>U?.id===F?.id?{...U,isExpanded:!F?.isExpanded}:U)};ue&&m(Q),v&&v(Q)},xe=(F,J)=>{if(!t)return;const ue={...t,timeRange:F||void 0};w?.(J),m(ue),v&&v(ue)};return o.jsx(ym,{value:{locale:s,isDisableValues:r,isValuesLoading:a,timeRangeOptions:c,filterValuesProps:n?.filterValuesProps,dataQueries:M,onSelectHierarchy:y,selectFilterValue:se,selectHierarchicalNodes:ge,expandHierarchicalValue:he,onTimePeriodChange:xe},children:o.jsxs("div",{className:W("flex flex-row gap-5 flex-1 min-h-0 sm:p-0","filters-settings"),children:[o.jsxs("div",{className:W("h-full sm:w-full",n?.isShowTimeSeriesCount&&"flex flex-col justify-between"),children:[I&&o.jsxs("div",{className:"mb-4 flex items-center justify-between gap-x-4",children:[o.jsxs("span",{className:"body-3 text-neutrals-900",children:[E?.appliedFilters??"Applied filters",":"," ",O]}),o.jsx(j.Button,{buttonClassName:"text-button-tertiary p-0",title:E?.clearAll??"Clear All",onClick:x,isSmallButton:k})]}),o.jsx(Mm,{filtersList:G,hideFacetCounterByDefault:n?.isHideFacetCounterByDefault,onSelectFilter:K,onSelectDisplayMode:p,onDeleteFilter:g,initialConstraints:l,initialConstraintsMap:d,datasetIcon:u,structuresMap:h,hierarchyStateMap:b,dataQueries:M,disabledDatasetUrns:A,isDatasetFacetSelected:L,onSelectDatasetFacet:$,onClearAllDatasets:_}),n?.isShowTimeSeriesCount&&i?o.jsxs("h4",{className:"my-4 text-neutrals-800",children:[E?.timeSeries??"Timeseries",": ",i]}):null]}),!k&&(L?o.jsx(Am,{dataQueries:M??[],disabledDatasetUrns:A,onToggleDataset:S,searchIconSize:n?.filterValuesProps?.searchIconSize}):o.jsx(tu,{filtersList:G,selectedFilter:Y,structuresMap:h,initialConstraints:qc(I,t,l,d),selectedTimeOption:C,hierarchyState:T}))]})})},Em=e=>{const t=e.filterType==="dataset"?[e.datasetUrn]:e.sourceDatasetUrns;return Array.from(new Set((t||[]).filter(n=>!!n)))},Nm=(e,t)=>{if(!t)return!1;const n=e.dataStructureComponents?.dimensionList;return[...n?.dimensions||[],...n?.timeDimensions||[]].some(r=>r.id===t)},Nr=e=>{if(!e.length||e.some(n=>!n))return;const t=Array.from(new Set(e));return t.length===1?t[0]:void 0},jm=(e,t)=>{const n=t?.dataStructures||[];if(!n.length)return[];const s=n.filter(r=>Nm(r,e));return s.length?s:n.length===1?n:[]},km=e=>e.urn??D.generateShortUrn(e.id,e.version,e.agencyID),su=(e,t)=>Nr(jm(e,t).map(km)),_m=(e,t,n,s)=>{if(!e||!t)return;const r=n?.get(t)?.find(l=>l.id===e);if(!r)return;const a=D.getKeyFromUrn(r.localRepresentation?.enumeration);if(a)return a;const i=s?.get(t),c=D.findCodelistByDimension(i?.codelists,i?.conceptSchemes,r);return c?D.getKeyFromUrn(c.urn)??D.generateShortUrn(c.id,c.version,c.agencyID):void 0},Im=(e,t,n)=>{const s=Em(e);return{codelistUrn:Nr(s.map(r=>_m(e.id,r,t,n))),sourceArtefactUrn:Nr(s.map(r=>su(e.id,n?.get(r))))}},Rm=({timeseriesLength:e=0,limitMessages:t})=>{const n=!e||j.SERIES_LIMIT>e;return o.jsx("div",{className:"body-3 flex items-center gap-x-[4px] text-neutrals-800 sm:justify-center sm:text-center",children:n?o.jsx("span",{children:t?.seriesCount?.(e)}):o.jsxs(o.Fragment,{children:[o.jsx("span",{children:t?.warningIcon}),o.jsx("span",{children:t?.counterLimit?.(e,j.SERIES_LIMIT)})]})})},ru=({modalProps:e,onApply:t,onClearAllFilters:n,onClose:s,applyDisabled:r,timeseriesLength:a,limitMessages:i})=>{const{titles:c}=Me(),l=j.useIsMobile(),d=e?.footerActionsPosition==="right",u=e?.isShowCancelButton,h=e?.isShowClearAllButton??!0,m=u?d?"justify-end":"justify-start":d?"flex-row items-center justify-between sm:flex-col-reverse sm:gap-y-4":"gap-x-8 flex-row-reverse items-center justify-between sm:flex-col sm:gap-y-4",p=u?d?"items-center gap-x-8":"justify-between":d?"flex-row justify-end items-center sm:flex-col-reverse sm:gap-y-4":"gap-x-8 flex-row-reverse justify-end items-center sm:flex-col-reverse sm:gap-y-4";return o.jsxs("div",{className:W("flex py-4 px-6 modal-footer-wrapper",m),children:[!u&&o.jsx(Rm,{timeseriesLength:a,limitMessages:i}),o.jsxs("div",{className:W("flex",p),children:[h&&o.jsx(j.Button,{iconBefore:l?e?.resetIcon:void 0,buttonClassName:"text-button-tertiary p-0",title:e?.isShowClearIcon?c?.clearAllFilters??"Clear All Filters":c?.clearAll??"Clear All",onClick:()=>n(),isSmallButton:l}),o.jsxs("div",{className:"flex items-center gap-x-3",children:[e?.isShowCancelButton?o.jsx(j.Button,{buttonClassName:"text-button-tertiary sm:h8",title:c?.cancel??"Cancel",onClick:s,isSmallButton:l}):null,o.jsx(j.Button,{buttonClassName:"advanced-view-filters-modal-apply-button",title:c?.apply??"Apply",onClick:t,isSmallButton:l,disabled:r})]})]})]})},Pm=e=>Ne.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Ne.createElement("path",{d:"M3.33333 13.3327V8.66602H2V7.33268H6V8.66602H4.66667V13.3327H3.33333ZM3.33333 5.99935V2.66602H4.66667V5.99935H3.33333ZM6 5.99935V4.66602H7.33333V2.66602H8.66667V4.66602H10V5.99935H6ZM7.33333 13.3327V7.33268H8.66667V13.3327H7.33333ZM11.3333 13.3327V11.3327H10V9.99935H14V11.3327H12.6667V13.3327H11.3333ZM11.3333 8.66602V2.66602H12.6667V8.66602H11.3333Z",fill:"currentColor"}));var Fe=(e=>(e.DATA_GRID="dataGrid",e.METADATA_PER_SERIES="metadataPerSeries",e.CHARTS="charts",e.CHARTS_NAVIGATION="chartsNavigation",e.OPEN_ADVANCED_VIEW="openAdvancedView",e.FILTERS="filters",e.CHART_PER_SERIES="chartPerSeries",e.METADATA_PER_DATASET="metadataPerDataset",e.EXIT_ADVANCED_VIEW="exitAdvancedView",e))(Fe||{});const Wr=["charts","chartsNavigation"],Xo=["dataGrid","metadataPerSeries",...Wr,"openAdvancedView"],au=["filters","chartPerSeries","metadataPerDataset","exitAdvancedView"],mt=(e,t)=>{const n=t?.[`${e}Title`],s=t?.[`${e}Description`];return{title:typeof n=="string"?n:"",description:typeof s=="string"?s:""}},jr=(e,t)=>e.find(n=>!t.infoElements?.[n])||"",Lm=(e,t)=>{if(!e||!t)return"";if(Xo.includes(t)){const s=jr(Xo,e);if(s)return s}const n=jr(au,e);return n||""},iu=(e,t)=>{const n=jr(e,t);return{...t,infoElements:{...t?.infoElements,[t.lastDisplayedElement]:!1,...n?{[n]:!0}:{}},lastDisplayedElement:n}},ou=e=>iu(au,e),Om=e=>iu(Wr,e),Fm=e=>(!e?.infoElements?.charts||!e?.infoElements?.chartsNavigation)&&!Wr.includes(e.lastDisplayedElement),ut=5,Vm=({targetPosition:e,overlayClasses:t,onClose:n})=>o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"overlay overlay-top",style:{height:e.top,top:0-ut,bottom:e.top+ut}}),o.jsx("div",{className:"overlay overlay-bottom",style:{top:e.bottom+ut,bottom:0}}),o.jsx("div",{className:"overlay overlay-left",style:{top:e.top-ut,height:e.height+ut*2,width:e.left,left:0-ut,right:e.left-ut*2}}),o.jsx("div",{className:"overlay overlay-right",style:{top:e.top-ut,left:e.right+ut,height:e.height+ut*2,right:0}}),o.jsx("div",{className:W("outline-block z-10",t),onClick:n,style:{top:e.top,left:e.left,height:e.height,width:e.width}})]}),pt=({reference:e,title:t,description:n,onReferenceClick:s,shouldCloseTooltip:r,shouldMoveToNextStep:a,supressReferenceClick:i})=>{const[c,l]=f.useState(!0),[d,u]=f.useState(!1),h=f.useRef(null),{isShowOnboarding:m,onboardingFileSchema:p,setOnboardingFileSchema:g}=Ze(),{refs:x,floatingStyles:v,context:w,placement:C}=Qe.useFloating({open:c,onOpenChange:l,placement:"right-start",elements:{reference:e?.current},middleware:[Qe.offset({mainAxis:12,crossAxis:-4}),Qe.flip(),Qe.shift(),Qe.arrow({element:h})],whileElementsMounted:Qe.autoUpdate}),b=Qe.useClick(w),{getFloatingProps:y}=Qe.useInteractions([b]),N=f.useCallback(()=>{if(m){const _=Lm(p,p?.lastDisplayedElement);g?.({...p,infoElements:{...p?.infoElements,..._?{[_]:!0}:{}},lastDisplayedElement:_})}l?.(!1)},[m,p,g]);f.useEffect(()=>{x.setReference(e?.current??null)},[e,x]);const M=()=>N(),A=e?.current?.getBoundingClientRect();f.useEffect(()=>{r&&!d&&(N(),u(!0))},[r,N,d]);const S=()=>{s?(s?.(),a?N():l(!1)):i||(N(),e?.current?.click())};return o.jsx(o.Fragment,{children:c&&o.jsxs(Qe.FloatingPortal,{children:[A&&o.jsx(Vm,{overlayClasses:i?"cursor-default":"cursor-pointer",targetPosition:A,onClose:S}),o.jsxs("div",{ref:x.setFloating,style:v,...y(),className:"tooltip z-tooltip max-w-[350px]",children:[o.jsxs("div",{className:"tooltip-header",children:[o.jsx("h3",{children:t}),o.jsx(j.CloseButton,{btnClassNames:"w-4 h-4",onClick:M})]}),o.jsx("div",{className:"tooltip-description",children:o.jsx("p",{children:n})}),o.jsx("div",{ref:h,className:W("tooltip-arrow absolute w-3 h-3 rotate-45",C?.includes("right")?"left-[-4px]":"right-[-6px]",C?.includes("end")?"bottom-2 tooltip-arrow-white":"top-3")})]})]})})},lu=({buttonProps:e,selectedFiltersCount:t=0,isLoading:n,setModalState:s,isModalClosed:r,warningIcon:a,filterIconClassName:i,timeSeriesCount:c})=>{const{titles:l}=Me(),d=f.useRef(null),[u,h]=f.useState(""),[m,p]=f.useState(""),[g,x]=f.useState(!1),{onboardingFileSchema:v,isShowOnboarding:w}=Ze(),C=j.SERIES_LIMIT<(c??0),b=f.useMemo(()=>e?.isShowBadge?e?.title:`${e?.title}: ${t}`,[e?.isShowBadge,e?.title,t]);return f.useEffect(()=>{if(w){const{title:y,description:N}=mt(Fe.FILTERS,l);h(y),p(N)}},[l,w]),f.useEffect(()=>{w&&x(v?.lastDisplayedElement===Fe.FILTERS)},[v?.lastDisplayedElement,w]),o.jsx("div",{className:"filter-button-container relative",ref:d,children:n?o.jsx(j.Loader,{}):o.jsxs(o.Fragment,{children:[o.jsx(j.Button,{iconBefore:o.jsx(Pm,{className:W("size-4",i)}),iconAfter:C?a:void 0,title:b,buttonClassName:"text-button-secondary filter-button",isSmallButton:!0,onClick:()=>s(j.PopUpState.Opened)}),e?.isShowBadge&&o.jsx("div",{className:"filter-count-badge",children:o.jsx("h5",{children:t})}),g&&o.jsx(pt,{reference:d,title:u,description:m,onReferenceClick:()=>s(j.PopUpState.Opened),shouldCloseTooltip:r})]})})},cu=f.createContext(null);function Hm({children:e}){const[t,n]=f.useState(j.PopUpState.Closed),[s,r]=f.useState(!1),a=f.useMemo(()=>({modalState:t,setModalState:n,isModalClosed:s,setIsModalClosed:r}),[t,s]);return o.jsx(cu.Provider,{value:a,children:e})}function uu(){const e=f.useContext(cu);if(!e)throw new Error("useFiltersModalState must be used within FiltersModalStateProvider");return e}const Qo=e=>{const t=[];return e.custom_content?.attachments&&t.push(...e.custom_content.attachments),t};function $r(e){return e.type===we.AttachmentType.MARKDOWN&&e.title!=null&&e.title?.startsWith("URL Query")}function du(e){return e.type===we.AttachmentType.JSON&&e.title!=null&&e.title?.startsWith("Query (JSON)")}function fu(e){return e.type===we.AttachmentType.MARKDOWN&&!$r(e)}function Um(e){return e.type===we.AttachmentType.CSV}function Kr(e){return e.type===we.AttachmentType.TABLE}function ft(e){return e.type===we.AttachmentType.CUSTOM_DATA_GRID}function ln(e){return e.type===we.AttachmentType.CUSTOM_CHART}function Gm(e){return e.type===we.AttachmentType.PLOTLY}function Jr(e){return e.type===we.AttachmentType.CUSTOM_CODE_SAMPLE}function vt(e){return e.type===we.AttachmentType.CROSS_DATASET_GRID}function Bm(e){return Kr(e)||ft(e)||vt(e)}const qm=(e,t)=>e?.filter((n,s)=>n?.custom_content?.attachments&&s<t)?.at(-1),hu=e=>e?.reduce((t,n,s)=>n?.custom_content?.attachments?.some(r=>du(r))?s:t,-1),zm=e=>e?.reduce((t,n)=>n?.role===Ie.Role.Assistant?n:t,{}),Wm=(e,t,n,s,r)=>({role:Ie.Role.System,content:"",custom_content:{attachments:n?.map(a=>{const i=e&&t?.urn===a?.urn?e:a?.filters;return{type:we.AttachmentType.JSON,title:a?.title,data:JSON.stringify({urn:a?.urn,metadata:a?.metadata,filters:r?r?.get(a?.urn):i,disabled:!!a?.disabled})}})||[],form_schema:s?.custom_content?.form_schema}}),mu=(e,t,n,s,r)=>{if(!e)return[];const a=e.at(-1),i=a?.role===Ie.Role.System,c=i?a?.custom_content?.attachments?.find(u=>u.type==="text/markdown"&&u.data?.includes("```python")):void 0,l=i?e.slice(0,-1):e,d=Wm(s,r,t,zm(l),n);return c&&d.custom_content&&(d.custom_content={...d.custom_content,attachments:[...d.custom_content.attachments??[],c]}),[...l,d]},$m=(e,t,n,s)=>e?.map(r=>({...r,filters:n&&s?.urn===r?.urn?n:r?.filters}))||[],gt={availableHierarchies:[],selectedHierarchy:null,mainHierarchy:null,codelists:[],treeNodes:[],isLoading:!1},pu=({getCodelistUrnForFilter:e,getConstraintsForFilter:t,getSourceArtefactUrn:n,getAvailableHierarchies:s,getHierarchy:r})=>{const[a,i]=f.useState(new Map),c=f.useCallback((m,p)=>{const g=We(m);if(!g)return;const x=e(m),v=p??t(m);i(w=>{const C=w.get(g);if(!C?.mainHierarchy)return w;const b=Zo(C.mainHierarchy,C.codelists,m.id??"",v,x),y=new Map(w);return y.set(g,{...C,treeNodes:b}),y})},[e,t]),l=f.useCallback(async m=>{if(!s)return;const p=e(m);if(!p)return;const g=We(m);if(g){i(x=>{const v=new Map(x),w=x.get(g)??gt;return v.set(g,{...w,isLoading:!0}),v});try{const x=await s(p,n?.(m)),v=vm(x?.data?.hierarchies??[]);i(w=>{const C=new Map(w),b=w.get(g)??gt;return C.set(g,{...b,availableHierarchies:v,isLoading:!1}),C})}catch{i(x=>{const v=new Map(x),w=x.get(g)??gt;return v.set(g,{...w,isLoading:!1}),v})}}},[s,e,n]),d=f.useCallback(async(m,p)=>{if(!r)return;const g=We(m);if(!g)return;const x=e(m);i(v=>{const w=new Map(v),C=v.get(g)??gt;return w.set(g,{...C,isLoading:!0}),w});try{const v=Yo(p),w=await r(v,x),C=w?.data?.hierarchies?.find(N=>Yo(N)===v);if(!C){i(N=>{const M=new Map(N),A=N.get(g)??gt;return M.set(g,{...A,selectedHierarchy:p,mainHierarchy:null,treeNodes:[],isLoading:!1}),M});return}const b=D.resolveCodelistsFromResponse(w?.data),y=Zo(C,b,m.id??"",t(m),x);i(N=>{const M=new Map(N),A=N.get(g)??gt;return M.set(g,{...A,selectedHierarchy:p,mainHierarchy:C,codelists:b,treeNodes:y,isLoading:!1}),M})}catch{i(v=>{const w=new Map(v),C=v.get(g)??gt;return w.set(g,{...C,isLoading:!1}),w})}},[r,e,t]),u=f.useCallback((m,p)=>{if(!m)return;const g=We(m);if(g){if(!p){i(x=>{const v=new Map(x),w=x.get(g)??gt;return v.set(g,{...w,selectedHierarchy:null,mainHierarchy:null,treeNodes:[]}),v});return}d(m,p)}},[d]),h=f.useCallback((m,p)=>{i(g=>{const x=g.get(m);if(!x?.treeNodes)return g;const v=new Map(g);return v.set(m,{...x,treeNodes:Zc(x.treeNodes,p)}),v})},[]);return{hierarchyStateMap:a,rebuildHierarchyTree:c,loadAvailableHierarchies:l,onSelectHierarchy:u,onExpandHierarchyNode:h}},Km=(e,t,n,s,r)=>{const a=new Set;if(!t||e.isTimeDimension)return a;const i=e.dimensionValues?.filter(u=>u.isSelectedValue)??[];if(!i.length)return a;const c=D.findCodelistByDimension(n?.codelists,n?.conceptSchemes,t);if(!c?.codes?.length)return a;const l=new Set(c.codes.map(u=>u.id)),d=new Set(D.getAvailableCodesFromConstrains(c.codes,t.id,s,r).map(u=>u.id));return i.forEach(u=>{l.has(u.id)&&!d.has(u.id)&&a.add(u.id)}),a},gu=(e,t,n,s,r,a)=>{let i=!1;const c=e.map(l=>{if(l.isTimeDimension||r&&l.id===r)return l;const d=t?.find(h=>h.id===l.id),u=Km(l,d,n,s,a);return u.size?(i=!0,{...l,dimensionValues:l.dimensionValues?.map(h=>u.has(h.id)?{...h,isSelectedValue:!1}:h)}):l});return{filters:i?c:e,changed:i}},Jm=(e,t,n,s,r,a)=>gu(e,t,n,s,r?.id,a),Ym=(e,t,n,s,r)=>{let a=!1;const i=new Map;return e.forEach((c,l)=>{const d=n?.filterType==="shared"?qr(n,l,r):n?.datasetUrn===l?n.id:void 0,u=gu(c,t?.dimensionsMap?.get(l),t?.structuresMap?.get(l),t?.constraintsMap?.get(l),d,s);a=a||u.changed,i.set(l,u.filters)}),{filtersMap:a?i:e,changed:a}},Zm=new Set,Xm=({actions:e,dimensions:t,structureDimensions:n,structures:s,buttonProps:r,modalProps:a,attachmentsDataQuery:i,dataQueries:c,initialConstraints:l,onFiltersChange:d,locale:u,timeRangeOptions:h,conversationKey:m,conversation:p,setConversation:g,updateConversation:x,updateDataQueries:v,limitMessages:w,filterIconClassName:C})=>{const{titles:b}=Me(),{modalState:y,setModalState:N,isModalClosed:M,setIsModalClosed:A}=uu(),[S,_]=f.useState([]),[E,T]=f.useState([]),[k,I]=f.useState(),[L,H]=f.useState([]),[G,Y]=f.useState(void 0),O=f.useRef(l||[]),[$,K]=f.useState([]),[Z,se]=f.useState(),[ge,he]=f.useState(),[xe,F]=f.useState(!1),J=f.useRef(0),ue=f.useRef(!1),de=f.useCallback(()=>{J.current+=1,J.current===1&&F(!0)},[]),me=f.useCallback(()=>{J.current=Math.max(J.current-1,0),J.current===0&&F(!1)},[]),re=f.useCallback(X=>{const ve=t?.find(Le=>Le.id===X.id);if(!ve)return;const ie=D.getKeyFromUrn(ve.localRepresentation?.enumeration);if(ie)return ie;const le=D.findCodelistByDimension(s?.codelists,s?.conceptSchemes,ve);return le?D.getKeyFromUrn(le.urn)??D.generateShortUrn(le.id,le.version,le.agencyID):void 0},[t,s?.codelists,s?.conceptSchemes]),{hierarchyStateMap:Q,rebuildHierarchyTree:U,loadAvailableHierarchies:q,onSelectHierarchy:fe,onExpandHierarchyNode:ae}=pu({getCodelistUrnForFilter:re,getConstraintsForFilter:()=>O.current,getSourceArtefactUrn:X=>su(X.id,s),getAvailableHierarchies:e?.getAvailableHierarchies,getHierarchy:e?.getHierarchy}),oe=X=>{const ve=X?S.map(ie=>Re(ie,X)?X:ie):S;he(!0),_(mn(ve)),se?.(!0),pe(X?.isTimeDimension?hn(ve,X):ve,_,se,X)};f.useEffect(()=>{y===j.PopUpState.Closed&&K(O.current)},[y]);const pe=f.useCallback((X,ve,ie,le)=>{const Le=i?.urn??"",V=Ht(Ar(X).filter(P=>P.componentCode!==D.TIME_PERIOD)),B=st(Le,V),ee=!!e?.getConstraints&&!Er(e.getConstraints,B);ee&&de(),(e?it(e.getConstraints,B,()=>e.getConstraints(Le,V)):Promise.resolve(void 0)).then(P=>{const z=P?.data?.dataConstraints||[];if(le){const{filters:_e,changed:be}=Jm(X,t,s,z,le,u);if(be){O.current=z,ie?.(!0),he(!0),pe(_e,ve,ie,le);return}}const te=rn(X,t,s,z,u);if(O.current=z,ie?.(!1),ve(te),le){const _e=te.find(be=>Re(be,le));I(be=>be&&_e&&Re(be,le)?{..._e,isSelectedFilter:!0}:be),U(le,z)}}).catch(()=>{const P=rn(X,t,s,[],u);if(O.current=[],ie?.(!1),ve(P),le){const z=P.find(te=>Re(te,le));I(te=>te&&z&&Re(te,le)?{...z,isSelectedFilter:!0}:te)}}).finally(()=>{he(!1),ee&&me()})},[e,i?.urn,t,me,u,U,de,s]);f.useEffect(()=>{const X=cc(t,s,n,u),ve=t?.map(le=>{const Le=D.findCodelistByDimension(s?.codelists,s?.conceptSchemes,le),V=D.getAvailableCodesFromConstrains(Le?.codes,le.id,O.current,u);return{...le,dimensionValues:V}}),ie=X.map(le=>{const Le=ve?.find(V=>V.id===le.id)?.dimensionValues||[];return{...le,dimensionValues:Le}});if(!ue.current){if(!s)return;const le=pc(ie,i,O.current);se?.(!0),pe(le,T,se),ue.current=!0}},[t,n,s,i,u,l,pe]),f.useEffect(()=>{E?.length&&H(Tn(E))},[E]),f.useEffect(()=>{_(X=>hn(X,k))},[k]),f.useEffect(()=>{if(y===j.PopUpState.Opened){const X=E.find(ve=>!ve.isTimeDimension);I(X?{...X,isSelectedFilter:!0}:void 0),_(E)}y===j.PopUpState.Closed&&I(void 0)},[E,y]),f.useEffect(()=>{if(!k||k.isTimeDimension)return;const X=We(k);if(!X)return;Q.get(X)||q(k)},[k,Q,q]),f.useEffect(()=>{y===j.PopUpState.Opened&&E.forEach(X=>{if(X.isTimeDimension)return;const ve=We(X);ve&&!Q.has(ve)&&q(X)})},[y,E,Q,q]);const Se=f.useCallback(async X=>{const ve=Mc(X),ie=p?{...p,messages:mu(p?.messages,c,void 0,ve,i)}:null;g?.(ie),v?.($m(c,void 0,ve,i)),await x(decodeURI(m),{name:ie?.name,messages:ie?.messages||[]})},[i,p,m,c,g,x,v]),Ce=f.useCallback((X,ve)=>{_(ie=>uc(ie,X,ve)),Re(k,X)&&I(ie=>ie&&{...ie,displayMode:ve})},[k]),ye=f.useCallback(X=>Sc(X,t),[t]),ce=f.useMemo(()=>Mr(ye(S),ye(E)),[S,E,ye]),Ee=f.useCallback((X,ve)=>{const ie=rn(ve,t,s,X,u);O.current=X,I(le=>ie?.find(Le=>Re(Le,le))||le),_(ie),he(!1)},[t,u,s]),Pe=f.useCallback(X=>{he(!0),_(mn(X));const ve=i?.urn??"",ie=Ht(Ar(X).filter(B=>B.componentCode!==D.TIME_PERIOD)),le=st(ve,ie),Le=!!e?.getConstraints&&!Er(e.getConstraints,le);Le&&de(),(e?it(e.getConstraints,le,()=>e.getConstraints(ve,ie)):Promise.resolve(void 0)).then(B=>{Ee(B?.data?.dataConstraints||[],X)}).catch(()=>{Ee([],X)}).finally(()=>{Le&&me()})},[e,i?.urn,me,de,Ee]),ze=f.useCallback(X=>{const ve=hc(S,X);Pe(ve)},[Pe,S]),Ge=f.useCallback(()=>{O.current=$,N(j.PopUpState.Closed),A(!0)},[$,N,A]),Ve=f.useCallback(()=>{const X=mc(S);Pe(X)},[Pe,S]),Xe=f.useCallback(()=>{const X=ye(S);d?.(X,O.current,S),T(S),N(j.PopUpState.Closed),A(!0),f.startTransition(()=>{Se(S)})},[ye,S,d,Se,O,N,A]),$e=X=>{Y(X)},Be=Number(D.getTimeSeriesCount(O?.current?.[0]?.annotations)),ot=Z||ge||ce;return o.jsxs("div",{className:"filters-container",children:[o.jsx(lu,{buttonProps:r,selectedFiltersCount:Gr(L),isLoading:Z,setModalState:N,isModalClosed:M,warningIcon:w?.warningIcon,filterIconClassName:C,timeSeriesCount:Be}),o.jsx(o.Fragment,{children:y===j.PopUpState.Opened&&o.jsxs(j.Popup,{heading:b?.settings||"Settings",portalId:"filters",size:j.PopUpSize.LG,containerClassName:"advanced-view-filters-modal h-[80%]",dividers:a?.isShowDividers,onClose:Ge,closeButtonTitle:b?.close||"Close",children:[o.jsx(nu,{locale:u,timeRangeOptions:h,filtersList:S,selectedFilter:k,isDisableValues:ge,isValuesLoading:xe,modalProps:a,initialConstraints:l,timeSeriesCount:`${Be}`,setSelectedFilter:I,onSelectDisplayMode:Ce,onDeleteFilter:ze,onClearAllFilters:Ve,updateSelectedFilterValues:oe,onTimePeriodChange:$e,selectedTimeOption:G,hierarchyStateMap:Q,onSelectHierarchy:fe,onExpandHierarchyNode:ae,dataQueries:i?[i]:void 0,disabledDatasetUrns:Zm,onToggleDataset:()=>{},onClearAllDatasets:()=>{}}),o.jsx(ru,{onApply:Xe,onClose:Ge,onClearAllFilters:Ve,modalProps:a,applyDisabled:ot,timeseriesLength:Be,limitMessages:w})]})})]})},wr=({setToTitle:e,datasetName:t,datasetIcon:n,isShowDatasetDetails:s,queryFilterDetails:r})=>o.jsx("div",{children:r?.map(a=>o.jsxs("div",{className:"body-1 mb-2 flex flex-wrap items-center gap-1",children:[o.jsxs("span",{children:[a?.title,o.jsx("span",{children:e??" set to "}),o.jsx("span",{className:"font-bold",children:a?.valuesTitles?.join(", ")})]}),t&&s&&o.jsxs("span",{className:"attachment-dataset-name caption !mb-0 inline-flex items-center",children:[o.jsx("span",{className:"attachment-dataset-icon mr-1",children:n}),t]})]},a?.title))}),Qm=({titles:e,attachmentInfoList:t,datasetIcon:n,dataQueries:s})=>{const{isCrossDatasetModeOn:r}=Ue(),{sharedFilterDetails:a,perDatasetInfoList:i}=f.useMemo(()=>{if(!r)return{sharedFilterDetails:[],perDatasetInfoList:[]};const d=new Map,u=[];return t?.forEach(h=>{const m=[];h.queryFiltersDetails?.forEach(p=>{if(Gh.has(p.id)){const g=d.get(p.id);g?d.set(p.id,{...g,valuesTitles:Array.from(new Set([...g.valuesTitles||[],...p.valuesTitles||[]]))}):d.set(p.id,{...p})}else p.valuesTitles?.length&&m.push(p)}),m.length&&u.push({...h,queryFiltersDetails:m})}),{sharedFilterDetails:Array.from(d.values()),perDatasetInfoList:u}},[r,t]),c=s?.some(d=>d.disabled)??!1,l=t?.map(d=>d.datasetName).filter(Boolean)??[];return o.jsxs("div",{className:"attachment-details flex flex-col",children:[o.jsx("p",{className:W("body-1",(t&&t.length<=1||r&&a.length>0)&&"mb-2"),children:e?.queryUpdatedManuallyTitle??"Query has been updated manually."}),c&&l.length>0&&o.jsxs("div",{className:"body-1 mb-2 flex flex-wrap items-center gap-1",children:[o.jsxs("span",{children:[e?.datasetLabel??"Dataset",e?.setToTitle??" set to "]}),l.map(d=>o.jsxs("span",{className:"attachment-dataset-name caption !mb-0 inline-flex items-center",children:[o.jsx("span",{className:"attachment-dataset-icon mr-1",children:n}),d]},d))]}),r?o.jsxs(o.Fragment,{children:[a.length>0&&o.jsx(wr,{setToTitle:e?.setToTitle,queryFilterDetails:a}),i.map(d=>o.jsx(wr,{setToTitle:e?.setToTitle,datasetName:d.datasetName,datasetIcon:n,isShowDatasetDetails:!0,queryFilterDetails:d.queryFiltersDetails},d.datasetName))]}):t?.map(d=>!!d?.queryFiltersDetails?.length&&o.jsx(wr,{setToTitle:e?.setToTitle,datasetName:d?.datasetName,datasetIcon:n,isShowDatasetDetails:t?.length>1,queryFilterDetails:d?.queryFiltersDetails},d?.datasetName))]})},ep=({icon:e,title:t})=>o.jsx("div",{className:W("px-3 py-4 rounded border mt-3","attachment-collapsed"),children:o.jsxs("p",{className:W("flex body-3 items-center"),children:[e,o.jsxs("span",{className:"ml-2",children:[" ",t]})]})}),tp=e=>Ne.createElement("svg",{width:44,height:24,viewBox:"0 0 44 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ne.createElement("rect",{width:44,height:24,rx:12,fill:"currentColor"}),Ne.createElement("circle",{cx:32,cy:12,r:10,fill:"white"})),np=e=>Ne.createElement("svg",{width:44,height:24,viewBox:"0 0 44 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ne.createElement("rect",{width:44,height:24,rx:12,fill:"currentColor"}),Ne.createElement("circle",{cx:12,cy:12,r:10,fill:"white"})),el=[{value:D.SdmxDataFormat.JSON,title:"SDMX-JSON"},{value:D.SdmxDataFormat.XML,title:"SDMX-ML (XML)"},{value:D.SdmxDataFormat.CSV,title:"SDMX-CSV"}],sp=e=>[{value:D.FileColumnsAttribute.ID,title:e?.idOptions||"ID",description:e?.idOptionsDescription},{value:D.FileColumnsAttribute.NAME,title:e?.nameOptions||"Name",description:e?.nameOptionsDescription},{value:D.FileColumnsAttribute.ID_NAME,title:e?.idAndNameOptions||"Combined ID and Name",description:e?.idAndNameOptionsDescription}],tl=({title:e,items:t,selectedValue:n,setSelectedValue:s,infoMessage:r,collapsible:a=!0})=>{const i=o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex flex-col gap-y-1",children:t.map(c=>o.jsx("div",{className:"flex flex-col",children:o.jsx(j.Radio,{id:c.value,checked:n.value===c.value,label:c.title,description:c.description,onChange:()=>{s(c)},radioIcon:o.jsx(He.IconCircleFilled,{className:"size-3"})},c.value)},c.value))}),r]});return a?o.jsx(j.CollapsibleBlock,{title:e,value:n.title,children:i}):o.jsxs("div",{className:"flex flex-col",children:[o.jsx("div",{className:"flex items-center py-4",children:o.jsx("span",{children:e})}),o.jsx("div",{className:"pb-4",children:i})]})},rp=({title:e,items:t,selectedUrns:n,onToggle:s,collapsible:r=!0,rowsLabel:a="rows"})=>{const i=o.jsx("div",{className:"flex flex-col",children:t.map(c=>o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("div",{className:"min-w-0 flex-1",children:o.jsx(j.Checkbox,{id:c.urn,label:c.name,checked:n.has(c.urn),onChange:s})}),o.jsxs("span",{className:"download-row-count",children:[c.rowCount," ",a]})]},c.urn))});return r?o.jsx(j.CollapsibleBlock,{title:e,children:i}):o.jsxs("div",{className:"flex flex-col",children:[o.jsx("div",{className:"flex items-center py-4",children:o.jsx("span",{children:e})}),o.jsx("div",{className:"pb-4",children:i})]})},ap=e=>{const t=e.metadata?.keyDimensionIdsInDsdOrder,n=e.metadata?.timePeriodDimension;if(!t?.length)return null;const s=t.map(a=>{const i=e.filters?.find(c=>c.componentCode===a);return i?.values?.length?i.values.join(D.GET_v3_FILTER_OR):"*"}).join("."),r=n?D.getTimeQueryFilter(e,{id:n}):null;return{filterKey:s,timeFilter:r}},ip=(e,t,n,s)=>{if(t&&e===D.DownloadType.DATA_IN_TABLE){const i=ap(t);if(i)return i}if(s?.filterKey&&e===D.DownloadType.DATA_IN_TABLE)return s;let r=null,a=null;return t&&n&&e===D.DownloadType.DATA_IN_TABLE&&(r=D.getTimeSeriesFilterKey(n,t.filters??[]),a=D.getTimeQueryFilter(t,D.getTimeDimension(n))),{filterKey:r,timeFilter:a}},op=({dataQuery:e,datasetName:t,onCloseModal:n,type:s=D.DownloadType.FULL_DATASET,locale:r=ne.Locale.EN,dimensions:a,filters:i,urn:c,titles:l,collapsible:d=!0,downloadDatasets:u,rowCount:h,isDownloadInProgress:m=!1,onDownloadStart:p,limitMessages:g,showLimitMessage:x,externalLink:v})=>{const w=sp(l),[C,b]=f.useState(el[0]),[y,N]=f.useState(w[0]),[M,A]=f.useState(!0),[S,_]=f.useState(()=>new Set(u?.map(H=>H.urn)??[])),E=f.useRef(!1);f.useEffect(()=>{_(new Set(u?.map(H=>H.urn)??[]))},[u]);const T=f.useCallback(H=>{_(G=>{const Y=new Set(G);return Y.has(H)?Y.delete(H):Y.add(H),Y})},[]),k=u!==void 0&&(u.length===0||S.size===0),I=f.useCallback(()=>{if(E.current)return;const H=C.value,G=(K,Z,se,ge)=>({dataQuery:K,urn:Z,name:se,rowCount:ge,fileName:`${se}.${H}`,filters:ip(s,K,a,i)}),O={items:u&&u.length>0?u.filter(K=>S.has(K.urn)).map(K=>G(K.dataQuery,K.urn,K.name,K.rowCount)):[G(e,e?.urn||c||"",t||e?.urn||c||"",h??0)],dataFormat:H,dataFormatTitle:C.title,attribute:y.value,language:r,isMetadata:M};if(!p(O)){E.current=!1;return}E.current=!0,n()},[C.value,C.title,y.value,u,S,e,c,t,h,s,a,i,r,M,p,n]),L=o.jsxs("div",{className:W("download-metadata flex cursor-pointer gap-4",{"download-metadata-active":M}),children:[M?o.jsx(tp,{width:44,height:24,className:"text-primary",onClick:()=>A(!M)}):o.jsx(np,{width:44,height:24,className:"text-neutrals-500",onClick:()=>A(!M)}),o.jsx("div",{children:l?.includeMetadata||"Include Metadata"})]});return o.jsxs(j.Popup,{heading:o.jsx("p",{className:"download-heading h2",children:l?.download||"Download"}),portalId:"filters",size:j.PopUpSize.LG,containerClassName:"download-popup h-[80%]",dividers:!1,onClose:n,closeButtonTitle:l?.close||"Close",children:[!u&&x&&o.jsx("div",{className:"download-info flex flex-col gap-1 px-6 pt-5",children:o.jsx(j.RequestLimitMessage,{limitMessages:g,isDownload:!0,query:v})}),o.jsxs("div",{className:"download-settings flex flex-col overflow-auto p-6",children:[o.jsx(tl,{title:l?.dataFormat||"Data Format",selectedValue:C,setSelectedValue:b,items:el,collapsible:d,infoMessage:o.jsx(j.DownloadFormatMessage,{limitMessages:g,query:v})}),C.value===D.SdmxDataFormat.CSV&&o.jsx(tl,{title:l?.attributes||"Attributes",selectedValue:y,setSelectedValue:N,items:w,collapsible:d}),u&&o.jsxs(o.Fragment,{children:[o.jsx(rp,{title:l?.datasetsToDownload||"Datasets to download",items:u,selectedUrns:S,onToggle:T,collapsible:d,rowsLabel:l?.rows||"rows"}),S.size>1&&o.jsxs(j.InlineAlert,{type:j.InlineAlertType.Note,children:[o.jsx("span",{className:"font-bold",children:l?.filesWillBeDownloaded?.(S.size)??`${S.size} files will be downloaded`})," ",l?.oneFilePerDataset??"- one file per selected dataset."]})]}),d?o.jsx(j.CollapsibleBlock,{title:l?.metadata||"Metadata",value:M?l?.all||"Included":l?.none||"Not included",children:L}):o.jsxs("div",{className:"flex flex-col",children:[o.jsx("div",{className:"flex items-center py-4",children:o.jsx("span",{children:l?.metadata||"Metadata"})}),o.jsx("div",{className:"pb-4",children:L})]})]}),o.jsxs("div",{className:"download-button mt-auto flex items-center gap-x-3 p-6",children:[l?.cancel&&o.jsx(j.Button,{buttonClassName:"text-button-tertiary",title:l.cancel,onClick:n}),o.jsx(j.Button,{buttonClassName:"text-button-primary",title:l?.download||"Download",disabled:k||m,onClick:I})]})]})},lp=({id:e,title:t,version:n,agency:s,isActive:r,isSingleTab:a,onSelectDataset:i})=>o.jsx("div",{className:W("dataset-tab truncate last:mr-4",r?"dataset-tab-active":"border-b-transparent",a?"dataset-tab-single cursor-default":"cursor-pointer"),title:t,onClick:()=>{a||i(D.generateShortUrn(e,n,s))},children:o.jsx("h3",{className:"dataset-tab-title truncate",title:t,children:t})}),cp=({datasets:e,locale:t,initialSelectedDatasetUrn:n,selectDataset:s})=>{const{isOpenedAdvancedView:r}=qe(),[a,i]=f.useState();f.useEffect(()=>{if(!n&&!a&&e?.[0]){const l=D.generateShortUrn(e[0].id,e[0].version,e[0].agencyID);i(l),s?.(l)}else n&&n!==a&&(i(n),s?.(n))},[e,s,n,a]);const c=f.useCallback(l=>{i(l),s?.(l)},[s]);return o.jsx("div",{className:W("dataset-tabs flex w-full items-center justify-between",r&&"hide-advance-button"),children:o.jsx("div",{className:"flex w-full items-center gap-4 overflow-y-auto sm:w-[calc(100%-30px)]",children:e?.map(l=>o.jsx(lp,{id:l?.id,title:D.getLocalizedName(l,t||ne.Locale.EN),version:l?.version,agency:l?.agencyID,isActive:e?.length>1&&a===D.generateShortUrn(l?.id,l?.version,l?.agencyID),isSingleTab:e?.length===1,onSelectDataset:c},l?.id))})})},up=3,dp=({datasets:e,locale:t})=>{const{isOpenedAdvancedView:n}=qe(),s=f.useMemo(()=>(e||[]).map(c=>({urn:D.generateShortUrn(c?.id,c?.version,c?.agencyID),title:D.getLocalizedName(c,t||ne.Locale.EN)})),[e,t]),r=f.useMemo(()=>s.slice(0,up),[s]),a=Math.max(s.length-r.length,0),i=s.filter(c=>!r.some(l=>l.urn===c.urn)).map(c=>c.title).join(`
7
- `);return o.jsx("div",{className:W("cross-dataset-tabs flex w-full items-center justify-between",n&&"hide-advance-button"),children:o.jsxs("div",{className:"cross-dataset-tabs-list sm:w-[calc(100%-30px)]",children:[r.map((c,l)=>o.jsxs("span",{className:"cross-dataset-tabs-item-wrapper",children:[o.jsx("span",{className:"cross-dataset-tabs-item",title:c.title,children:c.title}),l<r.length-1&&o.jsx("span",{className:"cross-dataset-tabs-separator","aria-hidden":"true"})]},c.urn)),a>0&&o.jsxs("span",{className:"cross-dataset-tabs-counter",title:i,children:["+",a]})]})})},vu=({datasets:e,locale:t,initialSelectedDatasetUrn:n,selectDataset:s})=>{const{isCrossDatasetModeOn:r}=Ue();return r?o.jsx(dp,{datasets:e,locale:t}):o.jsx(cp,{datasets:e,locale:t,initialSelectedDatasetUrn:n,selectDataset:s})},nl=(e,t)=>{const n=t?.get(e?.urn),s=n?.conceptSchemes||[],r=n?.codelists||[],a=D.getDimensions(n),i=[...a?.dimensions||[],...a?.timeDimensions||[]];return{structures:n,conceptSchemes:s,codelists:r,dimensions:i}},fp=(e,t,n,s,r)=>{const a=t?.filter(c=>!c.disabled)??[],i=new Map;return a?.forEach(c=>{const{conceptSchemes:l,codelists:d,dimensions:u}=nl(c,n);br((c?.filters??[]).filter(h=>h.operator!==ne.QueryFilterType.EXCLUDED),c?.urn,u,l,d,s,r).forEach(h=>{if(h.valuesTitles?.length){const m=i.get(h.id)??[];i.set(h.id,Array.from(new Set([...m,...h.valuesTitles])))}})}),a?.map(c=>{const l=e?.find(x=>x?.urn===c?.urn),{structures:d,conceptSchemes:u,codelists:h,dimensions:m}=nl(c,n),g=hp(br(l?.filters||[],c?.urn,m,u,h,s,r),br(c?.filters??[],c?.urn,m,u,h,s,r)).map(x=>{if(x.valuesTitles?.length)return x;const v=i.get(x.id);return v?.length?{...x,valuesTitles:v}:null}).filter(x=>x!==null);return{datasetName:D.getLocalizedName(d?.dataflows?.[0],s),queryFiltersDetails:g}})},hp=(e,t)=>{const n=new Map(e?.map(s=>[s?.id,s]));return t?.filter(s=>!Rr.isEqual(n?.get(s?.id)?.valuesTitles?.sort(),s?.valuesTitles?.sort()))||[]},br=(e,t,n,s,r,a,i)=>e?.map(c=>{const l=n.find(h=>h?.id===c?.componentCode),d=D.getConcept(l?.conceptIdentity||"",s),u=D.findCodelistByDimension(r,s,l);return{id:Kh(t,c?.componentCode,i)??c?.componentCode,title:D.getLocalizedName(d,a),valuesTitles:c?.operator===ne.QueryFilterType.BETWEEN?[`${fn(ne.getTimePeriod(c?.values?.[0]),a)} - ${fn(ne.getTimePeriod(c?.values?.[1]),a)}`]:c?.values?.map(h=>D.getLocalizedName(u?.codes?.find(m=>m?.id===h),a)||h)}}),mp=(e,t,n)=>{let s="",r="";if(e?.timeFilter){const i=decodeURIComponent(e.timeFilter||"")?.split(":");s=i[1]||"",r=i[3]||""}else if(t){const i=t?.filters?.find(c=>c.componentCode===D.TIME_PERIOD);s=i?.values?.[0]||"",r=i?.values?.[1]||""}return`&filter=${e?.filterKey||D.getTimeSeriesFilterKey(n||[],t?.filters||[])}&startPeriod=${s}&endPeriod=${r}`},kr=(e,t,n,s)=>{const r=n?.metadata?.datasetUrl;if(!r)return"";const a=e?mp(t,n,s):"";return r+a},Cu=e=>Ne.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Ne.createElement("path",{d:"M2.33325 12.3267L6.33325 8.32001L8.99992 10.9867L14.6666 4.61334L13.7266 3.67334L8.99992 8.98667L6.33325 6.32001L1.33325 11.3267L2.33325 12.3267Z",fill:"currentColor"})),pp=e=>Ne.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Ne.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.50644 4.00043L1.97857 7.52207L1.5 7.99979L1.97857 8.47751L5.50644 11.9991L6.46019 11.0437L3.41088 7.99979L6.46019 4.95587L5.50644 4.00043ZM10.4918 4.00043L14.0197 7.52207L14.4983 7.99979L14.0197 8.47751L10.4918 11.9991L9.53809 11.0437L12.5874 7.99979L9.53809 4.95587L10.4918 4.00043Z",fill:"currentColor"})),gp=e=>Ne.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Ne.createElement("path",{d:"M2.3999 4V12H13.5999V4H2.3999ZM5.7359 10.8H3.5999V5.2H5.7359V10.8ZM9.0639 10.8H6.9359V5.2H9.0719V10.8H9.0639ZM12.3999 10.8H10.2639V5.2H12.3999V10.8Z",fill:"currentColor"})),vp=e=>Ne.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Ne.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.18519 10.4815H7.18116C7.31033 10.9089 7.50501 11.3078 7.7535 11.6667H2.18519C1.53333 11.6667 1 11.1333 1 10.4815V2.18519C1 1.53333 1.53333 1 2.18519 1H10.4815C11.1333 1 11.6667 1.53333 11.6667 2.18519V5.02017C11.5296 5.00683 11.3906 5 11.25 5C10.9876 5 10.7307 5.02378 10.4815 5.06931V2.18519H2.18519V10.4815ZM7.69316 6.92288C7.99945 6.45568 8.39531 6.05248 8.85633 5.73769H3.37044V6.92288H7.69316ZM7 9.25C7 8.8544 7.05405 8.47143 7.15517 8.10807H3.37044V9.29326H7.00022L7 9.25ZM3.37044 4.5525H9.29636V3.36731H3.37044V4.5525ZM11.6624 10.9695C12.5981 10.8087 13.2264 9.91979 13.0656 8.98403C12.9049 8.04827 12.016 7.42002 11.0802 7.58078C10.1444 7.74155 9.51618 8.63046 9.67695 9.56621C9.83771 10.502 10.7266 11.1302 11.6624 10.9695ZM11.8656 12.1521C11.9243 12.142 11.9824 12.1303 12.0396 12.1168L14.5611 15.5477L15.5281 14.8371L13.1449 11.5944C13.9785 10.9558 14.4384 9.88763 14.2483 8.78085C13.9753 7.19192 12.4659 6.12513 10.877 6.39811C9.28808 6.67109 8.22129 8.18047 8.49428 9.7694C8.76726 11.3583 10.2766 12.4251 11.8656 12.1521Z",fill:"currentColor"})),Cp=({attachment:e,index:t,selectedAttachmentIndex:n,onSelectedAttachmentChange:s,showTabIcon:r,dataGridTitle:a})=>{const{titles:i}=Me(),c=f.useRef(null),[l,d]=f.useState(""),[u,h]=f.useState(""),[m,p]=f.useState(!1),{onboardingFileSchema:g,isShowOnboarding:x}=Ze(),v=f.useCallback((C,b="")=>r?Gm(C)||ln(C)?o.jsx(Cu,{className:b}):ft(C)||vt(C)?o.jsx(gp,{className:b}):$r(C)?o.jsx(vp,{className:b}):fu(C)||Jr(C)?o.jsx(pp,{className:b}):null:null,[r]),w=f.useCallback(C=>ft(C)?a||"Data Grid":C.title,[a]);return f.useEffect(()=>{if(x&&ln(e)){const{title:C,description:b}=mt(Fe.CHARTS,i);d(C),h(b)}},[e,i,x]),f.useEffect(()=>{if(ln(e)&&x){const C=g?.lastDisplayedElement===Fe.CHARTS;p(C),C&&c?.current?.scrollIntoView({block:"end",behavior:"smooth"})}},[g?.lastDisplayedElement,e,x]),o.jsxs("div",{ref:c,className:W("cursor-pointer min-w-30","flex items-center gap-1","attachment-tab",n===t?"attachment-tab-active text-primary":""),onClick:()=>s(t),children:[v(e,"w-4 h-4"),o.jsx("h4",{className:"max-w-[130px] truncate",title:w(e),children:w(e)}),m&&o.jsx(pt,{reference:c,title:l,description:u})]},e.index||t)},wp=({attachments:e,...t})=>o.jsx("div",{className:"attachments-tabs flex w-fit flex-wrap items-center",children:e.map((n,s)=>o.jsx(Cp,{attachment:n,index:s,...t},s))}),bp=({attachments:e,selectedAttachmentIndex:t,selectedAttachment:n,attachmentsStyles:s,externalLink:r,isExternalLinkIncludeFilters:a,limitMessages:i,onSelectedAttachmentChange:c,onDownloadClick:l,showAdvancedView:d,onOpenAdvancedView:u,isTableSettingsOpen:h,onTableSettingsOpen:m})=>{const{isTableSettingsFeatureEnabled:p}=Ue(),{isOpenedAdvancedView:g}=qe(),{titles:x}=Me(),{onboardingFileSchema:v,isShowOnboarding:w}=Ze(),C=f.useRef(null),[b,y]=f.useState(""),[N,M]=f.useState(""),[A,S]=f.useState(!1);f.useEffect(()=>{if(w){const{title:L,description:H}=mt(Fe.OPEN_ADVANCED_VIEW,x);y(L),M(H)}},[x,w]),f.useEffect(()=>{if(w){const L=v?.lastDisplayedElement===Fe.OPEN_ADVANCED_VIEW;S(L),L&&C?.current?.scrollIntoView({block:"center",behavior:"smooth"})}},[v?.lastDisplayedElement,w]);const _=p&&!d&&!!m&&!!(n&&(ft(n)||vt(n))),E=!!n&&(ft(n)||vt(n)),T=!!d&&!g,k=g&&s?.hideDownloadIconInAdvancedView?void 0:s?.downloadIcon,I=!g&&s?.hideDownloadTextInConversationView?"":s?.downloadTitle??"";return o.jsxs("div",{className:"flex w-full min-w-0 items-center justify-between",children:[o.jsx(wp,{dataGridTitle:s?.dataGridTitle,attachments:e,selectedAttachmentIndex:t,showTabIcon:s?.showTabIcon,onSelectedAttachmentChange:c}),o.jsxs("div",{className:"attachments-buttons flex w-fit flex-wrap items-center justify-end gap-x-3",children:[n&&ft(n)&&a&&o.jsx("a",{href:r,target:"_blank",rel:"noreferrer",children:o.jsx(j.Button,{title:i?.dataExplorer||"Data explorer",buttonClassName:"text-button-tertiary small-icon-button [&>svg]:h-[16px] [&>svg]:w-[16px] whitespace-nowrap",iconBefore:i?.dataExplorerIcon})}),E&&o.jsx(j.Button,{title:I,buttonClassName:"text-button-tertiary small-icon-button !p-0 !h-6",textClassName:W("ml-1",s?.downloadButtonTextClassName),onClick:l,iconBefore:k}),E&&T&&o.jsx("span",{className:"advanced-view-button-divider","aria-hidden":"true"}),T&&o.jsx("div",{ref:C,children:o.jsx(j.Button,{title:s?.advancedViewTitle,buttonClassName:"advanced-view-button",textClassName:"ml-1 h4 md:hidden",iconBefore:s?.openAdvancedViewIcon,onClick:u})}),_&&o.jsx(j.Button,{disabled:h,buttonClassName:"text-button-tertiary !p-0 !h-6",textClassName:"ml-1 h4",iconBefore:s?.tableSettingsIcon??o.jsx(He.IconSettings,{className:"size-4"}),title:s?.tableSettings||"Table settings",onClick:m}),n&&Jr(n)&&o.jsx(j.CopyButton,{title:s?.copyTitle,copiedTitle:s?.copiedTitle,tooltip:s?.copiedTooltip,hoverTooltip:s?.copyHoverTooltip,icon:s?.copyIcon,copiedIcon:s?.copiedIcon,onClick:()=>navigator.clipboard.writeText(n.data??"")})]}),A&&o.jsx(pt,{reference:C,title:b,description:N,onReferenceClick:u,shouldCloseTooltip:g})]})},xp=({downloadTitles:e,attachment:t,actions:n,className:s=""})=>{const r=t.url,[a,i]=f.useState(null);async function c(l){if(l==null)return;const d=await n.getFile(l);i(d)}return o.jsxs("div",{className:`rounded-lg border bg-white p-3 transition-colors ${s}`,children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"min-w-0 flex-1",children:o.jsx("div",{className:"flex items-center gap-2",children:o.jsx("span",{className:"body-2 truncate text-neutrals-800",title:t.title,children:t.title})})}),r&&o.jsx("div",{className:"shrink-0",children:o.jsx(j.Button,{title:e??"Download",onClick:()=>c(t.url),buttonClassName:"text-button-tertiary"})})]}),a&&o.jsx("div",{className:"mt-3",children:o.jsx("pre",{className:"overflow-x-auto rounded-md bg-white p-3",children:o.jsx("code",{children:JSON.stringify(a,null,2)})})})]})},wu="json";function yp(e){return Dp(e)?Sp(e?.slice(wu.length)):e}function Sp(e){let t="";if(e)try{t=JSON.stringify(JSON.parse(e),null,2)}catch{t=e.toString()}return t}function Dp(e){return e?.startsWith(wu)||!1}const Tp=({attachment:e,className:t=""})=>{const n=yp(e.data);return n?o.jsxs("div",{className:`attachment-json rounded-lg border bg-white ${t}`,children:[o.jsx("div",{className:"flex items-center justify-between rounded-t-lg border-b border-neutrals-200 bg-neutrals-100 px-3 py-2",children:o.jsx("div",{className:"flex items-center gap-2",children:o.jsx("h3",{className:"text-neutrals-900",children:e.title})})}),o.jsx("div",{className:"p-3",children:o.jsx("pre",{className:"max-h-96 overflow-auto whitespace-pre-wrap break-words text-neutrals-800",children:o.jsx("code",{children:n})})})]}):null},Mp=e=>{try{const t=new URL(e);return["http:","https:","data:"].includes(t.protocol)}catch{return!1}},Ap=e=>Mp(e)?e:"",Ep=e=>Ne.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ne.createElement("path",{d:"M11.3333 4.66667H8.66659V6.00001H11.3333C12.4333 6.00001 13.3333 6.9 13.3333 8C13.3333 9.1 12.4333 10 11.3333 10H8.66659V11.3333H11.3333C13.1733 11.3333 14.6666 9.84 14.6666 8C14.6666 6.16 13.1733 4.66667 11.3333 4.66667ZM7.33325 10H4.66659C3.56659 10 2.66659 9.1 2.66659 8C2.66659 6.9 3.56659 6.00001 4.66659 6.00001H7.33325V4.66667H4.66659C2.82659 4.66667 1.33325 6.16 1.33325 8C1.33325 9.84 2.82659 11.3333 4.66659 11.3333H7.33325V10ZM5.33325 7.33334H10.6666V8.66667H5.33325V7.33334Z",fill:"currentColor"})),Np=({attachment:e,openLinkTitle:t,className:n=""})=>{const s=Ap(e.data||"");if(!s)return null;const r=a=>{window.open(a,"_blank")?.focus()};return o.jsx("div",{className:`max-w-[500px] rounded-lg border bg-white py-3 pl-4 pr-3 ${n}`,children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("span",{className:"mt-1 shrink-0 text-hues-800",role:"img","aria-label":"Link",children:o.jsx(Ep,{width:16,height:16})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"mb-1",children:o.jsx(j.Link,{url:s,title:e.title})}),o.jsx("div",{className:"truncate break-all text-neutrals-600",children:s})]}),o.jsx("div",{className:"shrink-0",children:o.jsx(j.Button,{title:t??"Open link",onClick:()=>r(s),buttonClassName:"text-button-tertiary"})})]})})},bu=({dimensionsInfo:e})=>o.jsx("div",{className:"sidebar flex min-h-0 w-[176px] flex-col gap-3 overflow-auto",children:e.map(t=>o.jsxs("div",{className:"flex flex-col",children:[o.jsx("h5",{className:"text-neutrals-800",children:t.title}),o.jsx("h5",{className:"font-bold",children:t.value})]},t.title))}),jp=({chart:e,isOpen:t,onClose:n,datasetTitle:s})=>{const{titles:r}=Me(),[a,i]=f.useState(j.PopUpState.Closed);f.useEffect(()=>{i(t?j.PopUpState.Opened:j.PopUpState.Closed)},[t]);const c=f.useCallback(()=>{i(j.PopUpState.Closed),n?.()},[n]);return o.jsx(o.Fragment,{children:a===j.PopUpState.Opened&&o.jsxs(j.Popup,{heading:o.jsx("h1",{className:"single-chart-popup-heading",children:r?.chart??"Chart"}),containerClassName:"single-chart-popup h-[80%]",portalId:"single-chart",size:j.PopUpSize.LG,dividers:!1,onClose:c,closeButtonTitle:r?.close??"Close",children:[o.jsxs("div",{className:"single-chart-popup-content flex h-full min-h-0 flex-1 flex-row gap-4",children:[o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[s&&o.jsxs("div",{className:"mb-2 flex items-center gap-1",children:[o.jsx(zr,{className:"size-4 shrink-0 text-neutrals-1000"}),o.jsx("h4",{className:"text-neutrals-1000",children:s})]}),o.jsx(Dl,{option:e.config,className:"size-full",style:{width:"100%",height:"100%"}})]}),o.jsx(bu,{dimensionsInfo:e.dimensions})]}),o.jsx("div",{})]})})},Yr=e=>{const{titles:t}=Me(),[n,s]=f.useState(!1),[r,a]=f.useState(),i=f.useRef(null),[c,l]=f.useState(""),[d,u]=f.useState(""),[h,m]=f.useState(!1),{onboardingFileSchema:p,isShowOnboarding:g}=Ze(),{isCrossDatasetModeOn:x}=Ue(),[v,w]=f.useState(!1),C=f.useMemo(()=>kp(e.value),[e.value]),b=f.useCallback(()=>{a(N=>N??C),s(!0)},[C]),y=f.useCallback(()=>{s(!1),w(!0)},[]);return f.useEffect(()=>{if(g){const{title:N,description:M}=mt(Fe.CHART_PER_SERIES,t);l(N),u(M)}},[t,g]),f.useEffect(()=>{g&&m(p?.lastDisplayedElement===Fe.CHART_PER_SERIES&&e.node.rowIndex===0)},[p?.lastDisplayedElement,e.node.rowIndex,g]),f.useEffect(()=>{a(void 0)},[e.value]),C&&!C.isPlottable?null:o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:i,children:o.jsx(j.IconButton,{title:t?.chart??"Chart",buttonClassName:"!text-neutrals-1000 !border-none !p-1",icon:o.jsx(Cu,{className:"size-5"}),onClick:b})}),h&&o.jsx(pt,{reference:i,title:c,description:d,onReferenceClick:b,shouldCloseTooltip:v}),n&&r&&o.jsx(jp,{chart:r,isOpen:n,onClose:y,datasetTitle:x?e.data?.datasetTitle??void 0:void 0})]})};function kp(e){return typeof e=="function"?e():e}const qt=32,An=32,_p=16,Ct="padding-0",Et=200,St={flex:1,minWidth:Et},Ip=qt,En="observationValueCell",Nn="metadataCell",xu="chartCell",yu="mergedDimensionCell",Su="datasetDetailCell",Ut="Chart_column",Rp=(e,t,n,s,r,a)=>({headerName:"",suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:!0,width:32,maxWidth:32,cellClass:Ct,cellRenderer:Nn,cellRendererParams:{attributesData:t,dataSetData:e,locale:n,metadataSettings:s,titles:r,action:a}});function Du(e,t,n,s=Ip,r,a){return{headerName:"",field:Ut,colId:Ut,suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:"right",width:s,maxWidth:s,minWidth:s,cellClass:Ct,suppressColumnsToolPanel:!0,cellRenderer:Yr,cellRendererParams:{attributesData:t,dataSetData:e,locale:n,titles:r,action:a}}}function Pp(e,t,n,s){return{headerName:"",suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:!0,width:32,maxWidth:32,cellClass:Ct,cellRenderer:Nn,cellRendererParams:{structuresMap:e,attributesDataMap:t,locale:n,titles:s}}}const _r=["index","value"],Lp=e=>({columns:Vp(e),data:Op(e)}),Op=e=>{const t=e.metadata.time_column,n={};for(const s of e.data.data){const{value:r,...a}=s,i=Fp(s,t);n[i]={...n[i]||{},...a,[s[t]]:r}}return Object.values(n)},Fp=(e,t)=>Object.keys(e).filter(n=>!_r.includes(n)&&n!==t).map(n=>e[n]).join("."),Vp=e=>{const{metadata:t,data:n}=e,s=t.time_column,r=t.pinned_columns||[],a=n.schema.fields,i=[],c=n.data.map(m=>m[s]),d=Array.from(new Set(c)).filter(m=>m!=null).map(m=>({field:m,colId:m,headerName:m,cellClass:"text-right",width:Et})),u=r.map(m=>a.find(p=>p.name===m)).filter(m=>m!=null),h=a.filter(m=>!r.includes(m.name)).filter(m=>m!=null);if(u.length>0)for(const m of[...u])m.name===s||_r.includes(m.name)||i.push({colId:m.name,field:m.name,headerName:m.name,pinned:"left",...St,tooltipValueGetter:p=>p.value});for(const m of[...h])m.name===s||_r.includes(m.name)||i.push({colId:m.name,field:m.name,headerName:m.name,pinned:!1,...St,tooltipValueGetter:p=>p.value});return i.push(...d),i},Zr=e=>e*An+qt+_p,Hp=({attachment:e,actions:t,className:n="",showLimitMessage:s})=>{const[r,a]=f.useState(!1),[i,c]=f.useState([]),[l,d]=f.useState(),[u,h]=f.useState(400);f.useEffect(()=>{e.url!=null&&(a(!0),t.getFile(e.url).then(p=>{if(p==null){c([]),d([]),a(!1);return}const{columns:g,data:x}=Lp(p);c(x),d(g),a(!1)}))},[e.url,t]),f.useEffect(()=>{i?(h(Zr(i.length)),s?.(i.length>=j.SERIES_LIMIT)):s?.(!1)},[i,s]);const m=f.useMemo(()=>o.jsx(Pr.AgGridReact,{headerHeight:qt,rowHeight:An,rowData:i,columnDefs:l,enableCellTextSelection:!0,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",autoSizeStrategy:{type:l&&l?.length>5?"fitCellContents":"fitGridWidth"}}),[i,l]);return r?o.jsx(j.Loader,{}):o.jsx("div",{className:`w-full ${n}`,children:o.jsx("div",{className:"ag-theme-quartz max-h-[400px] min-h-[80px] w-full",style:{height:u},children:m})})},Tu=e=>Ne.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ne.createElement("path",{d:"M7.4665 6.39967H8.53317V5.33301H7.4665V6.39967ZM7.4665 10.6663H8.53317V7.46634H7.4665V10.6663ZM7.9945 13.333C5.0505 13.333 2.6665 10.9437 2.6665 7.99967C2.6665 5.05567 5.0505 2.66634 7.9945 2.66634C10.9438 2.66634 13.3332 5.05567 13.3332 7.99967C13.3332 10.9437 10.9438 13.333 7.9945 13.333ZM7.99984 3.73301C5.6425 3.73301 3.73317 5.64234 3.73317 7.99967C3.73317 10.357 5.6425 12.2663 7.99984 12.2663C10.3572 12.2663 12.2665 10.357 12.2665 7.99967C12.2665 5.64234 10.3572 3.73301 7.99984 3.73301Z",fill:"currentColor"})),Up=({title:e,value:t})=>{const n=f.useCallback(()=>Array.isArray(t)?t.join(", "):t,[t]);return o.jsxs("div",{className:"body-3 flex gap-x-3",children:[o.jsxs("p",{title:e,className:"text-neutrals-800",children:[e,":"]}),o.jsx("p",{title:n(),className:"truncate pr-3 font-semibold",children:n()})]})};function Mu(e){const t=f.useRef(null),[n,s]=f.useState(!1),[r,a]=f.useState(!1),i=f.useCallback(()=>{const l=t.current;l&&a(l.scrollHeight>l.offsetHeight)},[]);f.useEffect(()=>{if(n)return;i();const l=t.current;if(!l||typeof ResizeObserver>"u")return;const d=new ResizeObserver(()=>i());return d.observe(l),()=>d.disconnect()},[n,e,i]);const c=f.useCallback(()=>s(l=>!l),[]);return{valueRef:t,isExpanded:n,canToggle:r,toggle:c}}const Au=({isExpanded:e,onToggle:t,title:n})=>o.jsx(j.IconButton,{title:n,buttonClassName:W("border-none p-0 w-6 h-6 shrink-0",e&&"rotate-[180deg]"),isBaseIconStyles:!1,icon:o.jsx(Ur,{width:24,height:24}),onClick:t}),Gp=({title:e,value:t,attachedKeysTitles:n,isDimensionGroup:s,locale:r})=>{const a=f.useMemo(()=>Array.isArray(t)?t?.map(u=>typeof u=="object"?u?.[r]:u)?.join(", "):t,[r,t]),{valueRef:i,isExpanded:c,canToggle:l,toggle:d}=Mu(a);return o.jsxs("div",{className:"metadata-item",children:[!s&&n?.map(u=>o.jsx("div",{title:u,className:"metadata-item-key mb-1 pr-3 text-neutrals-800",children:u},u)),o.jsxs("div",{className:W("flex items-center",l&&"justify-between"),children:[o.jsx("h2",{title:e,className:"metadata-item-title",children:e}),l&&o.jsx(Au,{isExpanded:c,onToggle:d})]}),o.jsx("p",{title:a,className:W("metadata-item-value pr-3",!c&&"line-clamp-4"),ref:i,children:a})]})},Bp=({metadata:e,metadataDescription:t=[],locale:n})=>{const{titles:s}=Me();return o.jsxs("div",{className:"metadata-content h-full overflow-hidden",children:[t?.length>0&&o.jsx("div",{className:"metadata-description",children:t?.map(r=>o.jsx(Up,{title:r?.title,value:r?.value},r?.title))}),o.jsx("div",{className:"metadata-list h-full overflow-y-auto",children:e&&e?.length>0?e?.map(r=>o.jsx(Gp,{title:r?.title,value:r?.value,locale:n,attachedKeysTitles:r?.attachedKeysTitles,isDimensionGroup:r?.isDimensionGroup},r?.id||r?.title)):o.jsx("div",{className:"metadata-empty flex h-full items-center justify-center text-neutrals-700",children:s?.noMetadata||"No metadata"})})]})},Xr=({metadata:e,metadataDescription:t=[],isOpenMetadata:n,onCloseMetadata:s,locale:r})=>{const{titles:a}=Me(),[i,c]=f.useState(j.PopUpState.Closed);f.useEffect(()=>{c(n?j.PopUpState.Opened:j.PopUpState.Closed)},[n]);const l=f.useCallback(()=>{c(j.PopUpState.Closed),s?.()},[s]);return o.jsx(o.Fragment,{children:i===j.PopUpState.Opened&&o.jsxs(j.Popup,{heading:o.jsx("h1",{className:"metadata-heading",children:a?.metadata||"Metadata"}),containerClassName:"metadata h-[80%]",portalId:"metadata",size:j.PopUpSize.LG,dividers:!1,onClose:l,closeButtonTitle:a?.close||"Close",children:[o.jsx(Bp,{locale:r,metadata:e,metadataDescription:t}),o.jsx("div",{})]})})},dt={dataset:"dataset",agency:"agency",lastUpdated:"lastUpdated"},qp=({dataset:e,agency:t,lastUpdated:n,externalLink:s,formatValue:r})=>o.jsxs("div",{className:"mb-6 flex flex-col gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(He.IconDatabase,{className:"size-4 text-neutrals-700"}),o.jsx("p",{className:"h4 break-words text-neutrals-1000",children:r(e?.value)}),s&&o.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:o.jsx(He.IconExternalLink,{className:"size-4 shrink-0 cursor-pointer text-primary"})})]}),t&&o.jsxs("div",{className:"body-3 flex gap-1",children:[o.jsxs("span",{className:"text-neutrals-800",children:[t?.title,":"]}),o.jsx("span",{className:"break-words text-neutrals-1000",children:r(t?.value)})]}),n&&o.jsxs("div",{className:"body-3 flex gap-1",children:[o.jsxs("span",{className:"text-neutrals-800",children:[n?.title,":"]}),o.jsx("span",{className:"break-words text-neutrals-1000",children:r(n?.value)})]})]}),zp=({title:e,value:t,attachedKeysTitles:n,isDimensionGroup:s})=>{const{valueRef:r,isExpanded:a,canToggle:i,toggle:c}=Mu(t);return o.jsxs("div",{className:"flex flex-col gap-1",children:[!s&&n?.map((l,d)=>o.jsx("div",{title:l,className:"body-3 text-neutrals-800",children:l},`${l}-${d}`)),o.jsxs("div",{className:"flex items-center justify-between gap-2 pr-2",children:[o.jsx("p",{title:e,className:"body-3 text-neutrals-800",children:e}),i&&o.jsx(Au,{isExpanded:a,onToggle:c})]}),o.jsx("p",{ref:r,title:t,className:W("body-2 break-words text-neutrals-1000",!a&&"line-clamp-4"),children:t})]})},Wp=new Set(Object.values(dt)),$p=", ",zt=({metadata:e,metadataDescription:t=[],datasetInfo:n,externalLink:s,locale:r})=>{const{titles:a}=Me(),i=f.useCallback(p=>Array.isArray(p)?p.map(g=>typeof g=="object"?g?.[r]??"":g).join($p):typeof p=="object"&&p!==null?p?.[r]??"":p??"",[r]),{dataset:c,agency:l,lastUpdated:d,hasStructuredDatasetInfo:u}=f.useMemo(()=>{const p=t.find(b=>b?.id===dt.dataset),g=t.find(b=>b?.id===dt.agency),x=t.find(b=>b?.id===dt.lastUpdated),v=n?.dataset||p,w=n?.agency||g,C=n?.lastUpdated||x;return{dataset:v,agency:w,lastUpdated:C,hasStructuredDatasetInfo:!!v}},[n,t]),h=f.useMemo(()=>u?t.filter(p=>!p?.id||!Wp.has(p.id)):t,[u,t]),m=u||h.length>0||!!e?.length;return o.jsx("div",{className:"flex h-full flex-col overflow-hidden px-5 pb-4",children:m?o.jsxs(o.Fragment,{children:[u&&c&&o.jsx(qp,{dataset:c,agency:l,lastUpdated:d,externalLink:s,formatValue:i}),h.length>0&&o.jsx("div",{className:"mb-4 flex flex-col gap-2",children:h.map((p,g)=>o.jsxs("div",{className:"body-3 flex gap-2",children:[o.jsxs("span",{className:"shrink-0 text-neutrals-800",children:[p?.title||p?.id,":"]}),o.jsx("span",{className:"min-w-0 truncate font-semibold text-neutrals-1000",children:i(p?.value)})]},`${p?.id||p?.title}-${g}`))}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:o.jsx("div",{className:"flex flex-col gap-4",children:e?.map(p=>o.jsx(zp,{title:p?.title||p?.id,value:i(p?.value),attachedKeysTitles:p?.attachedKeysTitles,isDimensionGroup:p?.isDimensionGroup},p?.id||p?.title))})})]}):o.jsx("div",{className:"body-3 flex h-full items-center justify-center text-neutrals-700",children:a?.noMetadata||"No metadata"})})};function jn(e,t){const{externalLink:n,externalLinksMap:s}=e??{};return t!=null&&s!=null?s.get(t):n}const Kp=e=>e?.data[e?.colDef?.field||0]?.obsAttributes,Jp=e=>e?.data?.attributes,Eu=(e,t)=>Object.entries(e?.data).filter(([n])=>t?.get(n)).map(([n,s])=>({name:n,value:String(s)})),sl=(e,t,n)=>{const s=typeof e=="object"?e?.[t]:e;return n?D.getLocalizedName(n?.codes?.find(r=>r?.id===e),t)||"":s},Gt=(e,t,n)=>e?.map(s=>{const r=s?.name||"",a=t?.get(r),i=a?.codes?.length?a:void 0,c=Array.isArray(s?.value)?s?.value.map(l=>sl(l,n,i)):sl(s?.value,n,i);return{id:D.getLocalizedName(i,n)||s?.name,title:D.getLocalizedName(i||a,n),value:c||s?.value}})||[],Wt=(e,t,n)=>({title:n?.dataset||"Dataset",value:D.getLocalizedName(e,t)}),Yp=(e,t,n,s)=>[{...Wt(e,n,s),id:dt.dataset},{id:dt.agency,title:s?.agency??"Agency",value:e?.agencyID},{id:dt.lastUpdated,title:s?.lastUpdated??"Last updated",value:t}],$t=(e,t,n,s)=>({dataset:e?{...Wt(e,n,s),id:dt.dataset}:void 0,agency:e?{id:dt.agency,title:s?.agency??"Agency",value:e?.agencyID}:void 0,lastUpdated:e?{id:dt.lastUpdated,title:s?.lastUpdated??"Last updated",value:t}:void 0}),Nu=(e,t,n)=>({title:D.getDimensionTitle(e?.conceptSchemes,D.getDimensions(e)?.timeDimensions?.[0],t),value:n?.colId||""}),ju=(e,t)=>({title:t?.observation||"Observation",value:e}),ku=(e,t,n,s,r,a)=>{const i={title:s?.timeSeries||"Time Series",value:a?.originalData?.name};return n?[Nu(e,t,r),i,ju(n,s)]:[i]},_u=e=>{const t=e?.dataSets?.[0]?.attributes||[],n=e?.structures?.[0]?.attributes?.dataSet||[];return t?.length?n.reduce((s,r,a)=>{const i=t[a];if(i==null)return s;if(r?.values?.length>0){const c=r.values[i];s.push(c?{...r,values:[c]}:{...r})}else Array.isArray(i)?s.push({...r,values:[{values:i}]}):s.push({...r,values:[{value:i}]});return s},[]):n},rl=(e,t)=>{if(e==null)return;if(typeof e!="object")return String(e);const n=e,s=n[t];if(typeof s=="string")return s;const r=Object.values(n).find(a=>typeof a=="string");return typeof r=="string"?r:void 0},Iu=(e,t,n)=>e?.map(s=>{const r=s?.id,a=s?.values?.[0]?.value,i=(typeof a=="object"?rl(a,n):a)||s?.values?.[0]?.id,c=s?.values?.[0]?.ids||s?.values?.[0]?.values,l=t?.get(r),d=l?.codes?.length?l:void 0,u=D.getLocalizedName(d?.codes?.find(m=>m?.id===i),n)||D.getLocalizedName(s?.values?.[0],n)||i,h=c&&c.map(m=>{const p=typeof m=="object"?rl(m,n):String(m);return D.getLocalizedName(d?.codes?.find(g=>g?.id===p),n)||p}).filter(m=>m!=null);return{id:r,title:D.getLocalizedName(l,n)||r,value:h?.length?h:u}}).filter(({value:s})=>!!s)||[],Zp=(e,t)=>{const n=e?.dataSets?.[0],r=e?.structures?.[0]?.attributes?.dimensionGroup||[],a=n?.dimensionGroupAttributes;return new Map(r.map(i=>{const c=i?.relationship?.dimensions,{codedSeriesKey:l,decodedSeriesKey:d}=Xp(e,t,c);return[i.id,{values:a?.[l]||[],decodedSeriesKey:d,codedSeriesKey:l}]}))},Xp=(e,t,n)=>{const s=e?.structures?.[0],r=[...s?.dimensions.series||[],...s?.dimensions.observation||[]],a=new Array(r?.length)?.fill(""),i=new Array(r?.length)?.fill("");return n&&n?.forEach(c=>{const l=r?.findIndex(h=>h?.id===c)||0,d=t[l],u=r[l]?.values?.findIndex(h=>h?.id===d||h?.value===d)||0;a[l]=u>=0?u:d,i[l]=d}),{codedSeriesKey:a?.join(":"),decodedSeriesKey:i?.join(":")}},Qp=(e,t)=>{if(t==null)return;const n=e?.values?.[t],s=typeof t=="object"&&!Array.isArray(t),r=Array.isArray(t);return n||(s||r?{values:t}:{value:t?.toString()})},eg=e=>{const t=e?.value||e?.id,n=e?.values||e?.ids;return t!=null?[t]:n||[null]},Ru=(e,t,n)=>t==null?t:n?.get(e||"")?.codes?.find(r=>r?.id===t)?.name||t,tg=(e,t,n,s=ne.Locale.EN)=>{const r=n?.dataStructureComponents?.dimensionList,a=[...r?.dimensions||[],...r?.timeDimensions||[]],i=[];return(e?.split(":")||[])?.forEach((l,d)=>{if(l!==""){const u=a?.[d]?.id||"",h=D.getLocalizedName(t?.get(u),s),m=Ru(u,l,t);i.push(`${h}: ${m}`)}}),i},ng=(e,t,n,s,r=ne.Locale.EN)=>{if(!e||!t||!s)return[];const a=e?.structures?.[0]?.attributes?.dimensionGroup||[],i=Zp(e,s);return a?.map((c,l)=>{const d=i?.get(c?.id),u=n?.get(c?.id),h=eg(Qp(c,d?.values?.[l]));return{id:c?.id,title:D.getLocalizedName(u,r),value:Array.isArray(h)?h?.map(m=>Ru(c?.id,m,n)||""):h,attachedKeysTitles:tg(d?.decodedSeriesKey,n,t),isDimensionGroup:!0}})?.filter(({value:c})=>c?.some(l=>!!l))||[]},sg=gd.extendTailwindMerge({extend:{classGroups:{typography:["h1","h2","h3","h4","h5","body-1","body-2","body-3","caption"]}}});function nt(...e){return sg(W(...e))}function rg({title:e,headerExtension:t,headerClassName:n,onClose:s,bodyClassName:r,panelClassName:a,children:i}){return o.jsxs("div",{className:nt("h-full w-[362px] bg-white border-l border-neutrals-500 flex flex-col overflow-hidden",a),children:[o.jsxs("div",{className:nt("flex justify-between px-5 py-6",n),children:[o.jsx("div",{className:"h2 text-neutrals-1000",children:e}),o.jsxs("div",{className:"flex items-center gap-2",children:[t,t&&o.jsx("div",{className:"h-3 w-px bg-neutrals-600"}),o.jsx("button",{type:"button",onClick:s,children:o.jsx(He.IconX,{className:"size-5 text-neutrals-1000"})})]})]}),o.jsx("div",{className:nt("flex-1 min-h-0 overflow-hidden",r),children:i})]})}const Pu=f.createContext(null);function ag({children:e}){const[t,n]=f.useState(null),s=f.useCallback(c=>{n(c)},[]),r=f.useCallback(()=>{n(null)},[]),a=f.useCallback(c=>c?t?.id===c:t!==null,[t]),i=f.useMemo(()=>({panel:t,openPanel:s,closePanel:r,isPanelOpen:a}),[t,s,r,a]);return o.jsx(Pu.Provider,{value:i,children:e})}function Lu(){return f.useContext(Pu)}function wt(){const e=Lu();if(!e)return null;const{openPanel:t,closePanel:n,isPanelOpen:s}=e;return{openPanel:t,closePanel:n,isPanelOpen:s}}function Ou({scope:e}){const t=Lu();if(!t)return null;const{panel:n,closePanel:s}=t;if(!n)return null;const r=n.scope??"any";return r!=="any"&&r!==e?null:o.jsx(rg,{title:n.title,headerExtension:n.headerExtension,headerClassName:n.headerClassName,onClose:s,bodyClassName:n.bodyClassName,panelClassName:n.panelClassName,children:n.content})}function xr(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function _t(e){return(t,n)=>{const s=n?.context?String(n.context):"standalone";let r;if(s==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,c=n?.width?String(n.width):i;r=e.formattingValues[c]||e.formattingValues[i]}else{const i=e.defaultWidth,c=n?.width?String(n.width):e.defaultWidth;r=e.values[c]||e.values[i]}const a=e.argumentCallback?e.argumentCallback(t):t;return r[a]}}function It(e){return(t,n={})=>{const s=n.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],a=t.match(r);if(!a)return null;const i=a[0],c=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(c)?og(c,h=>h.test(i)):ig(c,h=>h.test(i));let d;d=e.valueCallback?e.valueCallback(l):l,d=n.valueCallback?n.valueCallback(d):d;const u=t.slice(i.length);return{value:d,rest:u}}}function ig(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function og(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function lg(e){return(t,n={})=>{const s=t.match(e.matchPattern);if(!s)return null;const r=s[0],a=t.match(e.parsePattern);if(!a)return null;let i=e.valueCallback?e.valueCallback(a[0]):a[0];i=n.valueCallback?n.valueCallback(i):i;const c=t.slice(r.length);return{value:i,rest:c}}}const al=Symbol.for("constructDateFrom");function Fu(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&al in e?e[al](t):e instanceof Date?new e.constructor(t):new Date(t)}function cg(e,...t){const n=Fu.bind(null,e||t.find(s=>typeof s=="object"));return t.map(n)}let ug={};function dg(){return ug}function Qr(e,t){return Fu(t||e,e)}function il(e,t){const n=dg(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=Qr(e,t?.in),a=r.getDay(),i=(a<s?7:0)+a-s;return r.setDate(r.getDate()-i),r.setHours(0,0,0,0),r}function Vu(e,t,n){const[s,r]=cg(n?.in,e,t);return+il(s,n)==+il(r,n)}function Rt(e,t){if(e.one!==void 0&&t===1)return e.one;const n=t%10,s=t%100;return n===1&&s!==11?e.singularNominative.replace("{{count}}",String(t)):n>=2&&n<=4&&(s<10||s>20)?e.singularGenitive.replace("{{count}}",String(t)):e.pluralGenitive.replace("{{count}}",String(t))}function Je(e){return(t,n)=>n&&n.addSuffix?n.comparison&&n.comparison>0?e.future?Rt(e.future,t):"за "+Rt(e.regular,t):e.past?Rt(e.past,t):Rt(e.regular,t)+" тому":Rt(e.regular,t)}const fg=(e,t)=>t&&t.addSuffix?t.comparison&&t.comparison>0?"за півхвилини":"півхвилини тому":"півхвилини",hg={lessThanXSeconds:Je({regular:{one:"менше секунди",singularNominative:"менше {{count}} секунди",singularGenitive:"менше {{count}} секунд",pluralGenitive:"менше {{count}} секунд"},future:{one:"менше, ніж за секунду",singularNominative:"менше, ніж за {{count}} секунду",singularGenitive:"менше, ніж за {{count}} секунди",pluralGenitive:"менше, ніж за {{count}} секунд"}}),xSeconds:Je({regular:{singularNominative:"{{count}} секунда",singularGenitive:"{{count}} секунди",pluralGenitive:"{{count}} секунд"},past:{singularNominative:"{{count}} секунду тому",singularGenitive:"{{count}} секунди тому",pluralGenitive:"{{count}} секунд тому"},future:{singularNominative:"за {{count}} секунду",singularGenitive:"за {{count}} секунди",pluralGenitive:"за {{count}} секунд"}}),halfAMinute:fg,lessThanXMinutes:Je({regular:{one:"менше хвилини",singularNominative:"менше {{count}} хвилини",singularGenitive:"менше {{count}} хвилин",pluralGenitive:"менше {{count}} хвилин"},future:{one:"менше, ніж за хвилину",singularNominative:"менше, ніж за {{count}} хвилину",singularGenitive:"менше, ніж за {{count}} хвилини",pluralGenitive:"менше, ніж за {{count}} хвилин"}}),xMinutes:Je({regular:{singularNominative:"{{count}} хвилина",singularGenitive:"{{count}} хвилини",pluralGenitive:"{{count}} хвилин"},past:{singularNominative:"{{count}} хвилину тому",singularGenitive:"{{count}} хвилини тому",pluralGenitive:"{{count}} хвилин тому"},future:{singularNominative:"за {{count}} хвилину",singularGenitive:"за {{count}} хвилини",pluralGenitive:"за {{count}} хвилин"}}),aboutXHours:Je({regular:{singularNominative:"близько {{count}} години",singularGenitive:"близько {{count}} годин",pluralGenitive:"близько {{count}} годин"},future:{singularNominative:"приблизно за {{count}} годину",singularGenitive:"приблизно за {{count}} години",pluralGenitive:"приблизно за {{count}} годин"}}),xHours:Je({regular:{singularNominative:"{{count}} годину",singularGenitive:"{{count}} години",pluralGenitive:"{{count}} годин"}}),xDays:Je({regular:{singularNominative:"{{count}} день",singularGenitive:"{{count}} днi",pluralGenitive:"{{count}} днів"}}),aboutXWeeks:Je({regular:{singularNominative:"близько {{count}} тижня",singularGenitive:"близько {{count}} тижнів",pluralGenitive:"близько {{count}} тижнів"},future:{singularNominative:"приблизно за {{count}} тиждень",singularGenitive:"приблизно за {{count}} тижні",pluralGenitive:"приблизно за {{count}} тижнів"}}),xWeeks:Je({regular:{singularNominative:"{{count}} тиждень",singularGenitive:"{{count}} тижні",pluralGenitive:"{{count}} тижнів"}}),aboutXMonths:Je({regular:{singularNominative:"близько {{count}} місяця",singularGenitive:"близько {{count}} місяців",pluralGenitive:"близько {{count}} місяців"},future:{singularNominative:"приблизно за {{count}} місяць",singularGenitive:"приблизно за {{count}} місяці",pluralGenitive:"приблизно за {{count}} місяців"}}),xMonths:Je({regular:{singularNominative:"{{count}} місяць",singularGenitive:"{{count}} місяці",pluralGenitive:"{{count}} місяців"}}),aboutXYears:Je({regular:{singularNominative:"близько {{count}} року",singularGenitive:"близько {{count}} років",pluralGenitive:"близько {{count}} років"},future:{singularNominative:"приблизно за {{count}} рік",singularGenitive:"приблизно за {{count}} роки",pluralGenitive:"приблизно за {{count}} років"}}),xYears:Je({regular:{singularNominative:"{{count}} рік",singularGenitive:"{{count}} роки",pluralGenitive:"{{count}} років"}}),overXYears:Je({regular:{singularNominative:"більше {{count}} року",singularGenitive:"більше {{count}} років",pluralGenitive:"більше {{count}} років"},future:{singularNominative:"більше, ніж за {{count}} рік",singularGenitive:"більше, ніж за {{count}} роки",pluralGenitive:"більше, ніж за {{count}} років"}}),almostXYears:Je({regular:{singularNominative:"майже {{count}} рік",singularGenitive:"майже {{count}} роки",pluralGenitive:"майже {{count}} років"},future:{singularNominative:"майже за {{count}} рік",singularGenitive:"майже за {{count}} роки",pluralGenitive:"майже за {{count}} років"}})},mg=(e,t,n)=>(n=n||{},hg[e](t,n)),pg={full:"EEEE, do MMMM y 'р.'",long:"do MMMM y 'р.'",medium:"d MMM y 'р.'",short:"dd.MM.y"},gg={full:"H:mm:ss zzzz",long:"H:mm:ss z",medium:"H:mm:ss",short:"H:mm"},vg={full:"{{date}} 'о' {{time}}",long:"{{date}} 'о' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Cg={date:xr({formats:pg,defaultWidth:"full"}),time:xr({formats:gg,defaultWidth:"full"}),dateTime:xr({formats:vg,defaultWidth:"full"})},ea=["неділю","понеділок","вівторок","середу","четвер","п’ятницю","суботу"];function wg(e){const t=ea[e];switch(e){case 0:case 3:case 5:case 6:return"'у минулу "+t+" о' p";case 1:case 2:case 4:return"'у минулий "+t+" о' p"}}function Hu(e){return"'у "+ea[e]+" о' p"}function bg(e){const t=ea[e];switch(e){case 0:case 3:case 5:case 6:return"'у наступну "+t+" о' p";case 1:case 2:case 4:return"'у наступний "+t+" о' p"}}const xg=(e,t,n)=>{const s=Qr(e),r=s.getDay();return Vu(s,t,n)?Hu(r):wg(r)},yg=(e,t,n)=>{const s=Qr(e),r=s.getDay();return Vu(s,t,n)?Hu(r):bg(r)},Sg={lastWeek:xg,yesterday:"'вчора о' p",today:"'сьогодні о' p",tomorrow:"'завтра о' p",nextWeek:yg,other:"P"},Dg=(e,t,n,s)=>{const r=Sg[e];return typeof r=="function"?r(t,n,s):r},Tg={narrow:["до н.е.","н.е."],abbreviated:["до н. е.","н. е."],wide:["до нашої ери","нашої ери"]},Mg={narrow:["1","2","3","4"],abbreviated:["1-й кв.","2-й кв.","3-й кв.","4-й кв."],wide:["1-й квартал","2-й квартал","3-й квартал","4-й квартал"]},Ag={narrow:["С","Л","Б","К","Т","Ч","Л","С","В","Ж","Л","Г"],abbreviated:["січ.","лют.","берез.","квіт.","трав.","черв.","лип.","серп.","верес.","жовт.","листоп.","груд."],wide:["січень","лютий","березень","квітень","травень","червень","липень","серпень","вересень","жовтень","листопад","грудень"]},Eg={narrow:["С","Л","Б","К","Т","Ч","Л","С","В","Ж","Л","Г"],abbreviated:["січ.","лют.","берез.","квіт.","трав.","черв.","лип.","серп.","верес.","жовт.","листоп.","груд."],wide:["січня","лютого","березня","квітня","травня","червня","липня","серпня","вересня","жовтня","листопада","грудня"]},Ng={narrow:["Н","П","В","С","Ч","П","С"],short:["нд","пн","вт","ср","чт","пт","сб"],abbreviated:["нед","пон","вів","сер","чтв","птн","суб"],wide:["неділя","понеділок","вівторок","середа","четвер","п’ятниця","субота"]},jg={narrow:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранок",afternoon:"день",evening:"веч.",night:"ніч"},abbreviated:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранок",afternoon:"день",evening:"веч.",night:"ніч"},wide:{am:"ДП",pm:"ПП",midnight:"північ",noon:"полудень",morning:"ранок",afternoon:"день",evening:"вечір",night:"ніч"}},kg={narrow:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранку",afternoon:"дня",evening:"веч.",night:"ночі"},abbreviated:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранку",afternoon:"дня",evening:"веч.",night:"ночі"},wide:{am:"ДП",pm:"ПП",midnight:"північ",noon:"полудень",morning:"ранку",afternoon:"дня",evening:"веч.",night:"ночі"}},_g=(e,t)=>{const n=String(t?.unit),s=Number(e);let r;return n==="date"?s===3||s===23?r="-є":r="-е":n==="minute"||n==="second"||n==="hour"?r="-а":r="-й",s+r},Ig={ordinalNumber:_g,era:_t({values:Tg,defaultWidth:"wide"}),quarter:_t({values:Mg,defaultWidth:"wide",argumentCallback:e=>e-1}),month:_t({values:Ag,defaultWidth:"wide",formattingValues:Eg,defaultFormattingWidth:"wide"}),day:_t({values:Ng,defaultWidth:"wide"}),dayPeriod:_t({values:jg,defaultWidth:"any",formattingValues:kg,defaultFormattingWidth:"wide"})},Rg=/^(\d+)(-?(е|й|є|а|я))?/i,Pg=/\d+/i,Lg={narrow:/^((до )?н\.?\s?е\.?)/i,abbreviated:/^((до )?н\.?\s?е\.?)/i,wide:/^(до нашої ери|нашої ери|наша ера)/i},Og={any:[/^д/i,/^н/i]},Fg={narrow:/^[1234]/i,abbreviated:/^[1234](-?[иі]?й?)? кв.?/i,wide:/^[1234](-?[иі]?й?)? квартал/i},Vg={any:[/1/i,/2/i,/3/i,/4/i]},Hg={narrow:/^[слбктчвжг]/i,abbreviated:/^(січ|лют|бер(ез)?|квіт|трав|черв|лип|серп|вер(ес)?|жовт|лис(топ)?|груд)\.?/i,wide:/^(січень|січня|лютий|лютого|березень|березня|квітень|квітня|травень|травня|червня|червень|липень|липня|серпень|серпня|вересень|вересня|жовтень|жовтня|листопад[а]?|грудень|грудня)/i},Ug={narrow:[/^с/i,/^л/i,/^б/i,/^к/i,/^т/i,/^ч/i,/^л/i,/^с/i,/^в/i,/^ж/i,/^л/i,/^г/i],any:[/^сі/i,/^лю/i,/^б/i,/^к/i,/^т/i,/^ч/i,/^лип/i,/^се/i,/^в/i,/^ж/i,/^лис/i,/^г/i]},Gg={narrow:/^[нпвсч]/i,short:/^(нд|пн|вт|ср|чт|пт|сб)\.?/i,abbreviated:/^(нед|пон|вів|сер|че?тв|птн?|суб)\.?/i,wide:/^(неділ[яі]|понеділ[ок][ка]|вівтор[ок][ка]|серед[аи]|четвер(га)?|п\W*?ятниц[яі]|субот[аи])/i},Bg={narrow:[/^н/i,/^п/i,/^в/i,/^с/i,/^ч/i,/^п/i,/^с/i],any:[/^н/i,/^п[он]/i,/^в/i,/^с[ер]/i,/^ч/i,/^п\W*?[ят]/i,/^с[уб]/i]},qg={narrow:/^([дп]п|півн\.?|пол\.?|ранок|ранку|день|дня|веч\.?|ніч|ночі)/i,abbreviated:/^([дп]п|півн\.?|пол\.?|ранок|ранку|день|дня|веч\.?|ніч|ночі)/i,wide:/^([дп]п|північ|полудень|ранок|ранку|день|дня|вечір|вечора|ніч|ночі)/i},zg={any:{am:/^дп/i,pm:/^пп/i,midnight:/^півн/i,noon:/^пол/i,morning:/^р/i,afternoon:/^д[ен]/i,evening:/^в/i,night:/^н/i}},Wg={ordinalNumber:lg({matchPattern:Rg,parsePattern:Pg,valueCallback:e=>parseInt(e,10)}),era:It({matchPatterns:Lg,defaultMatchWidth:"wide",parsePatterns:Og,defaultParseWidth:"any"}),quarter:It({matchPatterns:Fg,defaultMatchWidth:"wide",parsePatterns:Vg,defaultParseWidth:"any",valueCallback:e=>e+1}),month:It({matchPatterns:Hg,defaultMatchWidth:"wide",parsePatterns:Ug,defaultParseWidth:"any"}),day:It({matchPatterns:Gg,defaultMatchWidth:"wide",parsePatterns:Bg,defaultParseWidth:"any"}),dayPeriod:It({matchPatterns:qg,defaultMatchWidth:"wide",parsePatterns:zg,defaultParseWidth:"any"})},$g={code:"uk",formatDistance:mg,formatLong:Cg,formatRelative:Dg,localize:Ig,match:Wg,options:{weekStartsOn:1,firstWeekContainsDate:1}},Kg=e=>e===ne.Locale.UK?"dd MMM, yyyy":" MMM dd, yyyy hh:mm aa",Kt=(e,t)=>{const n=Kg(t);return e!=null&&e!==""&&n&&$a.isValid(new Date(e))?$a.format(new Date(e),n,t===ne.Locale.UK?{locale:$g}:void 0):""},Uu=e=>{const{titles:t}=Me(),n="grid-metadata-side-panel",[s,r]=f.useState(!1),a=f.useRef(null),[i,c]=f.useState(""),[l,d]=f.useState(""),[u,h]=f.useState(!1),{onboardingFileSchema:m,isShowOnboarding:p}=Ze(),{isOpenedAdvancedView:g}=qe(),x=wt(),{isMetadataInSidePanel:v}=Ue(),[w,C]=f.useState(!1),b=e?.data?.dataset?.urn,y=jn(e?.context,b),N=f.useMemo(()=>e.structuresMap?b!=null?e.structuresMap.get(b):void 0:e.dataSetData,[e.structuresMap,b,e.dataSetData]),M=f.useMemo(()=>e.attributesDataMap?b!=null?e.attributesDataMap.get(b):void 0:e.attributesData,[e.attributesDataMap,b,e.attributesData]),A=f.useMemo(()=>D.getStructureComponentsMap(N),[N]),S=f.useMemo(()=>[Wt(N?.dataflows?.[0],e?.locale,t),...Gt(Eu(e,A),A,e?.locale),...Gt(Jp(e),A,e?.locale),...ng(M,N?.dataStructures?.[0],A,e?.data?.originalData?.parsedTimeSeriesValue,e?.locale)],[e,N,M,A,t]),_=f.useMemo(()=>ku(N,e?.locale,e?.valueFormatted||e?.value,t,e?.colDef,e?.data),[e,N,t]),E=f.useMemo(()=>{const I=N?.dataflows?.[0],L=Kt(D.getLastUpdatedTime(I),e?.locale);return $t(I,L,e?.locale,t)},[N,e?.locale,t]),T=f.useCallback(()=>{if(v&&x){x.openPanel({id:n,scope:g?"advanced":"conversation",title:t?.timeseriesMetadataPanel||"Timeseries Metadata",bodyClassName:"overflow-hidden",content:o.jsx(zt,{locale:e?.locale,metadata:S,datasetInfo:E,externalLink:y,metadataDescription:e?.metadataSettings?.isMetadataDescription?_:[]})}),C(!0);return}r(!0)},[v,g,S,_,E,y,e?.locale,e?.metadataSettings?.isMetadataDescription,t,x]),k=f.useCallback(()=>{r(!1),C(!0)},[]);return f.useEffect(()=>{if(p){const{title:I,description:L}=mt(Fe.METADATA_PER_SERIES,t);c(I),d(L)}},[t,p]),f.useEffect(()=>{if(p){const I=m?.lastDisplayedElement===Fe.METADATA_PER_SERIES&&e.node.rowIndex===0;h(I),I&&setTimeout(()=>{a?.current?.scrollIntoView({block:"end",behavior:"smooth"})})}},[m?.lastDisplayedElement,e.node.rowIndex,p]),o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:a,children:o.jsx(j.IconButton,{title:t?.metadata||"View details",buttonClassName:"!text-neutrals-1000 !border-none !p-1",icon:o.jsx(Tu,{className:"size-5"}),onClick:T})}),u&&o.jsx(pt,{reference:a,title:i,description:l,onReferenceClick:T,shouldCloseTooltip:w}),s&&o.jsx(Xr,{locale:e?.locale,metadata:S,metadataDescription:e?.metadataSettings?.isMetadataDescription?_:[],isOpenMetadata:s,onCloseMetadata:k})]})},Jg=(e,t)=>{const n=Yg(e),s=D.getStructureComponentsMap(n),r=e?.valueFormatted||e?.value,a=Gt(t,s,e?.locale),i=[Wt(n?.dataflows?.[0],e?.locale,e?.titles),...Gt(Eu(e,s),s,e?.locale),...e?.metadataSettings?.isMetadataDescription?[]:[Nu(n,e?.locale,e?.colDef),ju(r,e?.titles)],...a],c=e?.metadataSettings?.isMetadataDescription?ku(n,e?.locale,r,e?.titles,e?.colDef,e?.data):[],l=n?.dataflows?.[0],d=Kt(D.getLastUpdatedTime(l),e?.locale),u=$t(l,d,e?.locale,e?.titles);return{metadata:i,metadataDescription:c,sidePanelDatasetInfo:u}},Yg=e=>{if(e.structuresMap){const t=e?.data?.dataset?.urn;return t!=null?e.structuresMap.get(t):void 0}return e.dataSetData},Zg="observation-metadata-side-panel",Xg=({params:e,obsAttributes:t})=>{const{titles:n}=Me(),[s,r]=f.useState(null),{isOpenedAdvancedView:a}=qe(),i=wt(),{isMetadataInSidePanel:c}=Ue(),l=e?.data?.dataset?.urn,d=jn(e?.context,l),u=f.useCallback(()=>{const m=Jg(e,t);if(c&&i){i.openPanel({id:Zg,scope:a?"advanced":"conversation",title:n?.metadata||"Metadata",bodyClassName:"overflow-hidden",content:o.jsx(zt,{locale:e?.locale,metadata:m.metadata,datasetInfo:m.sidePanelDatasetInfo,externalLink:d,metadataDescription:m.metadataDescription})});return}r(m)},[c,a,d,t,e,i,n]),h=f.useCallback(()=>{r(null)},[]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"relative size-full p-2 text-end",children:[e?.valueFormatted||e?.value,o.jsx("div",{className:"metadata-indicator",title:n?.metadata||"View details",onClick:u})]}),s&&o.jsx(Xr,{locale:e?.locale,metadata:s.metadata,metadataDescription:s.metadataDescription,isOpenMetadata:!0,onCloseMetadata:h})]})},Gu=e=>{const t=Kp(e);return t?.length?o.jsx(Xg,{params:e,obsAttributes:t}):o.jsx("div",{className:"relative size-full p-2 text-end",children:e?.valueFormatted||e?.value})},Bu=({ref:e,fixHeight:t,gridHeight:n,children:s})=>o.jsx("div",{ref:e,className:W("ag-theme-quartz w-full min-h-[80px]",t?"max-h-[400px]":"max-h-full"),style:{height:n},children:s}),Qg=({attachment:e,isDataLoading:t,isChartColumnVisible:n,fixHeight:s,externalLink:r,showLimitMessage:a,onApiReady:i})=>{const{titles:c}=Me(),[l,d]=f.useState(!1),[u,h]=f.useState([]),[m,p]=f.useState(),[g,x]=f.useState(400),v=f.useRef(null),[w,C]=f.useState(""),[b,y]=f.useState(""),[N,M]=f.useState(!1),{isShowOnboarding:A,onboardingFileSchema:S,setOnboardingFileSchema:_}=Ze();f.useEffect(()=>{if(e.grid_data==null)d(!0);else{const L=e.grid_data.columns.map(H=>H.colId===Ut?{...H,hide:!n}:H);h(e.grid_data.data),p(L),d(!1)}},[e.grid_data,n]),f.useEffect(()=>{u?(x(Zr(u.length)),a?.(u.length>=j.SERIES_LIMIT)):a?.(!1)},[u,a]),f.useEffect(()=>{if(A){const{title:L,description:H}=mt(Fe.DATA_GRID,c);C(L),y(H)}},[c,A]),f.useEffect(()=>{S&&!S?.infoElements?.dataGrid&&_?.({...S,infoElements:{...S?.infoElements,dataGrid:!0},lastDisplayedElement:Fe.DATA_GRID})},[S,_]),f.useEffect(()=>{if(A){const L=S?.lastDisplayedElement===Fe.DATA_GRID;M(L),!l&&!t&&L&&setTimeout(()=>{v?.current?.scrollIntoView({block:"end",behavior:"smooth"})})}},[S?.lastDisplayedElement,A,t,l]);const E=f.useCallback(L=>{i?.(L.api)},[i]),T=f.useMemo(()=>({externalLink:r}),[r]),k=f.useMemo(()=>({[Nn]:Uu,[En]:Gu,[xu]:Yr}),[]),I=f.useMemo(()=>o.jsx(Pr.AgGridReact,{onGridReady:E,headerHeight:qt,rowHeight:An,rowData:u,enableCellTextSelection:!0,columnDefs:m,context:T,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",components:k,valueCache:!0}),[u,m,E,T,k]);return l||t?o.jsx(j.Loader,{}):o.jsxs("div",{className:"size-full",children:[o.jsx(Bu,{ref:v,fixHeight:s,gridHeight:g,children:I}),N&&o.jsx(pt,{reference:v,title:w,description:b,supressReferenceClick:!0})]})};function Bt(e){if(typeof window>"u")return e(),()=>{};let t;const n=window.requestAnimationFrame(()=>{t=window.setTimeout(e,0)});return()=>{window.cancelAnimationFrame(n),t!=null&&window.clearTimeout(t)}}const e1=200,t1=8,n1=2,s1=({currentIndex:e,totalCount:t,icons:n,onPrev:s,onNext:r})=>{const{titles:a}=Me(),i=f.useRef(null),[c,l]=f.useState(""),[d,u]=f.useState(""),[h,m]=f.useState(!1),{onboardingFileSchema:p,isShowOnboarding:g}=Ze();f.useEffect(()=>{if(g){const{title:C,description:b}=mt(Fe.CHARTS_NAVIGATION,a);l(C),u(b)}},[a,g]),f.useEffect(()=>{if(g){const C=p?.lastDisplayedElement===Fe.CHARTS_NAVIGATION;m(C),C&&i?.current?.scrollIntoView({block:"center",behavior:"smooth"})}},[p?.lastDisplayedElement,g]);const x=t>0?e/t*100:0,v=t>0?Math.min(t1*t,e1):0,w=t>0?Math.max(v/t,n1):0;return o.jsxs("div",{className:"flex w-full flex-row items-center justify-center gap-2",children:[o.jsx("div",{className:W("h-[20px] w-[20px] cursor-pointer",e===0?"text-neutrals-700":"text-primary"),onClick:s,children:n?.[un.PREVIOUS]}),o.jsxs("div",{className:"flex flex-col items-center gap-1 pt-[20px]",children:[o.jsx("div",{className:"relative h-[4px] rounded-full bg-neutral-300",style:{width:`${v}px`},children:o.jsx("div",{className:"absolute h-full rounded-full bg-primary",style:{left:`${x}%`,width:`${w}px`}})}),o.jsxs("h5",{className:"text-neutrals-800",children:[e+1,"/",t]})]}),o.jsx("div",{className:W("h-[20px] w-[20px] cursor-pointer",e+1===t?"text-neutrals-700":"text-primary"),onClick:r,ref:i,children:n?.[un.NEXT]}),h&&o.jsx(pt,{reference:i,title:c,description:d})]})},r1=({limitAmount:e,openAdvancedView:t,prefixIcon:n,contentClassName:s})=>{const{titles:r}=Me(),[a,i]=f.useState(!1),{refs:c,floatingStyles:l,context:d}=Qe.useFloating({open:a,onOpenChange:i,placement:"top-start"}),u=Qe.useHover(d,{handleClose:Qe.safePolygon({blockPointerEvents:!0})}),{getReferenceProps:h,getFloatingProps:m}=Qe.useInteractions([u]);return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex w-fit",ref:c.setReference,...h(),children:o.jsxs("div",{className:nt("mt-1 flex w-fit items-center gap-1 bg-hues-100 px-4 py-2",s),children:[n,o.jsx("h5",{className:"font-bold",children:r?.limits||"Limited to"}),o.jsxs("h5",{children:[e," ",r?.timeseriesLimit||"Timeseries"]})]})}),a&&o.jsx("div",{className:"floating",ref:c.setFloating,style:l,...m(),children:o.jsxs("div",{className:"z-10 mb-2 flex w-[300px] flex-col gap-2 rounded bg-white p-4 shadow",children:[o.jsxs("div",{children:[o.jsxs("h5",{className:"text-neutrals-900",children:[o.jsx("span",{className:"pr-0.5",children:r?.limitLinkInfoP1_1||"The number of timeseries displayed in a single chart i"}),o.jsxs("span",{className:"pr-0.5 font-bold",children:[r?.limitLinkInfoP1_2||"limited to"," ",e]}),r?.limitLinkInfoP1_3||"for better clarity and performance."]}),o.jsxs("h5",{className:"text-neutrals-900",children:[o.jsx("span",{className:"pr-0.5",children:r?.limitLinkInfoP2_1||"To visualize specific timeseries"}),o.jsx("span",{className:"pr-0.5 font-bold",children:r?.limitLinkInfoP2_2||"filter"}),o.jsx("span",{className:"pr-0.5",children:r?.limitLinkInfoP2_3||"your request, or"}),o.jsx("span",{className:"pr-0.5 font-bold",children:r?.limitLinkInfoP2_4||"refine"}),r?.limitLinkInfoP2_5||"it in the chat."]})]}),t&&o.jsx("h4",{className:"cursor-pointer text-primary",onClick:t,children:r?.limitLinkInfoLink||"Open Advanced View"})]})})]})};function a1(e,t,n){const s=(e.getZr()?.painter).getRenderedCanvas()?.getContext("2d");if(!s)return 0;const r=n.textStyle?.fontSize??12,a=n.textStyle?.fontFamily??"sans-serif";s.font=`${r}px ${a}`;const i=s.measureText(t).width,c=n.itemWidth??25,l=n.itemGap??10;return i+c+l}const i1=({option:e,style:t})=>{const n=f.useRef(null),[s,r]=f.useState(e);f.useEffect(()=>{r(Rr.cloneDeep(e))},[e]);const a=f.useCallback(()=>{const i=n.current?.getEchartsInstance?.();if(!i)return;const l=i.getDom().clientWidth,d=e.legend||{},u=d.itemHeight??14,h=d.textStyle?.fontSize??12,m=i.getModel()?.getComponent("legend")?.getData()||[];let p=0;m.forEach(w=>{const C=w.option.name||"";p+=a1(i,C,d)});const x=Math.max(1,Math.ceil(p/l))*(+u+ +h+6),v=20;r(w=>({...w,grid:{...w.grid||{},bottom:x+v}}))},[e.legend]);return f.useEffect(()=>{a();const i=()=>{a()};return window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i)}},[e,a]),o.jsx(Dl,{notMerge:!0,lazyUpdate:!1,ref:n,option:s,style:t})},o1=({attachment:e,icons:t,isDataLoading:n,openAdvancedView:s,fixHeight:r=!0,limitationInfoPrefixIcon:a,limitationInfoContentClassName:i})=>{const{titles:c}=Me(),[l,d]=f.useState(!0),[u,h]=f.useState(),[m,p]=f.useState([]),[g,x]=f.useState(0),[v,w]=f.useState(void 0),[C,b]=f.useState(),{onboardingFileSchema:y,isShowOnboarding:N,setOnboardingFileSchema:M}=Ze(),A=f.useRef(null),{charting_data:S,getChartingData:_}=e;f.useEffect(()=>{if(x(0),S){h(S),d(!1);return}if(!_){h(void 0),d(!0);return}return d(!0),Bt(()=>{try{h(_())}catch(k){console.error("Error building chart data",k),h({units:[]})}finally{d(!1)}})},[S,_]),f.useEffect(()=>{const k=u?.groups??[],I=u?.units??[];p(k.length>0?k.flatMap(L=>L.units.map(H=>({unit:H,groupTitle:L.title}))):I.map(L=>({unit:L})))},[u]),f.useEffect(()=>{const k=m.length>g,I=k?m[g]:m[0];w(!l&&I!=null?I.unit:void 0),b(I?.groupTitle),k||x(0)},[l,m,g]),f.useEffect(()=>{y&&N&&!l&&(Fm(y)&&(M?.(Om(y)),A?.current?.scrollIntoView({block:"center",behavior:"smooth"})),y.lastDisplayedElement===Fe.CHART_PER_SERIES&&M?.(ou(y)))},[l,M,y,N]);const E=f.useCallback(()=>{x(k=>Math.min(k+1,m.length-1))},[m.length]),T=f.useCallback(()=>{x(k=>Math.max(k-1,0))},[]);return l||n?o.jsx(j.Loader,{}):o.jsx("div",{className:"chart-attachment size-full",ref:A,children:u&&o.jsx("div",{className:"flex size-full flex-col gap-4",children:m.length==0||v==null?o.jsx("h4",{className:"ml-1",children:c?.chartInfo||"No data"}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("h3",{className:"chart-attachment-title",children:[c?.chart||"Chart"," ",g+1,"/",m.length]}),o.jsx("span",{className:"h4 chart-attachment-info text-neutrals-700",children:c?.chartInfo||"Chart Information"})]}),o.jsxs("div",{className:W("chart-area overflow-hidden flex flex-row gap-4 h-full ",r&&"max-h-[400px] min-h-[400px]",!r&&"min-h-[300px]"),children:[o.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[C&&o.jsxs("div",{className:"mb-1 flex items-center gap-1",children:[o.jsx(zr,{className:"size-4 shrink-0 text-neutrals-1000"}),o.jsx("h4",{className:"text-neutrals-1000",children:C})]}),o.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[o.jsx(i1,{option:v.config,style:{width:"100%",height:"100%",minHeight:0}}),v.limitedByRowsAmountTo&&o.jsx(r1,{limitAmount:v.limitedByRowsAmountTo,openAdvancedView:s,prefixIcon:a,contentClassName:i}),m.length>1&&o.jsx(s1,{icons:t,currentIndex:g,totalCount:m.length,onNext:E,onPrev:T})]})]}),o.jsx(bu,{dimensionsInfo:v.dimensions})]})]})})})},l1=({attachment:e,className:t})=>{const{data:n,language:s}=e,r=(a,i)=>{a.addCommand(i.KeyCode.F1,()=>{})};return o.jsx("div",{className:nt(["h-full w-full [&_.cursors-layer]:hidden",t]),children:o.jsx(vd.Editor,{value:n,language:s,theme:"vs-light",onMount:r,options:{readOnly:!0,contextmenu:!1,scrollBeyondLastLine:!1,minimap:{enabled:!1},wordWrap:"on",automaticLayout:!0,tabSize:2}})})},c1="Dataset",ol="dataset_name",u1="Agency",ll="agency",d1="Country dimensions",Jt="country_aggregated",f1="Indicator dimensions",Yt="indicator_aggregated",h1="Frequency",kn="frequency_aggregated",qu=".";function cl(e){return{columnState:e.getColumnState(),columnGroupState:e.getColumnGroupState()??[]}}function m1(e,t){t&&(e.applyColumnState({state:t.columnState,applyOrder:!0}),e.setColumnGroupState(t.columnGroupState))}const ul=["columnVisible","columnMoved","displayedColumnsChanged","newColumnsLoaded","gridColumnsChanged","columnPinned"];function zu(e,t){f.useEffect(()=>{if(e){for(const n of ul)e.addEventListener(n,t);return()=>{for(const n of ul)e.removeEventListener(n,t)}}},[e,t])}function p1({currentUrn:e}){const[t,n]=f.useState(),[s,r]=f.useState(null),a=f.useRef(new Map),i=f.useRef(new Map),c=f.useCallback(h=>{if(n(h),a.current.has(e))s==null&&r(a.current.get(e)??null);else{const p=cl(h);a.current.set(e,p),r(p)}const m=i.current.get(e);m&&(h.applyColumnState({state:m.columnState,applyOrder:!0}),m.columnGroupState!=null&&h.setColumnGroupState(m.columnGroupState))},[e]);f.useEffect(()=>{r(a.current.get(e)??null)},[e]);const l=f.useCallback(()=>{t&&i.current.set(e,cl(t))},[e,t]),d=f.useCallback(()=>{i.current.delete(e)},[e]),u=f.useCallback(()=>{a.current.delete(e),r(null)},[e]);return zu(t,l),{gridApi:t,onGridApiReady:c,initialColumnsState:s,clearUserColumnState:d,clearInitialColumnState:u}}var et=(e=>(e.Compact="compact",e.Extended="extended",e))(et||{});const ta=f.createContext(null);function g1({currentUrn:e,structuresMap:t,locale:n,dataQueries:s,gridViewMode:r=et.Compact,onGridViewModeChange:a,texts:i,resetIcon:c,children:l}){const{gridApi:d,onGridApiReady:u,initialColumnsState:h,clearUserColumnState:m,clearInitialColumnState:p}=p1({currentUrn:e}),g=f.useCallback(M=>a?.(M),[a]),[x,v]=f.useState(new Map),w=f.useCallback((M,A,S)=>{v(_=>{const E=new Map(_),T=new Map(E.get(M)??[]),k=T.get(A)??{order:[],hidden:new Set};return T.set(A,S(k)),E.set(M,T),E}),d?.refreshCells({columns:[A]})},[d]),C=f.useCallback((M,A,S)=>{w(M,A,_=>({..._,order:S}))},[w]),b=f.useCallback(()=>{v(new Map)},[]),y=f.useCallback((M,A,S,_)=>{w(M,A,E=>{const T=new Set(E.hidden);return _?T.add(S):T.delete(S),{...E,hidden:T}})},[w]),N=f.useMemo(()=>({gridApi:d,onGridApiReady:u,initialColumnsState:h,structuresMap:t,locale:n,dataQueries:s,dimensionCustomization:x,setDimensionKeyOrder:C,setDimensionKeyHidden:y,resetDimensionCustomization:b,clearUserColumnState:m,clearInitialColumnState:p,gridViewMode:r,setGridViewMode:g,texts:i,resetIcon:c}),[d,h,u,t,n,s,x,C,y,b,m,p,r,g,i,c]);return o.jsx(ta.Provider,{value:N,children:l})}function na(){const e=f.useContext(ta);if(!e)throw new Error("useTableSettingsContext must be used within TableSettingsProvider");return e}const v1=()=>f.useContext(ta);function _n(e,t,n){const s=D.getConcept(e.conceptIdentity,t),r=e?.localRepresentation?.enumeration,a=s?.coreRepresentation?.enumeration,i=r||a,c=D.getArtifactByUrnWithWildCard(i,n);return{concept:s,codeList:c||void 0}}function Wu(e,t,n){const s=e.findIndex(r=>r.id===t);return n.originalData.parsedTimeSeriesValue[s]}function sa(e,t,n,s,r){const a=Wu(e,t,s),i=n?.codes?.find(c=>c.id===a);return D.getLocalizedName(i,r)}function C1(e,t,n,s,r=et.Compact){const a=r===et.Extended?S1(e,t,n):[b1(e,t,n,s)];return[w1(e,t,n,s),...a,x1(e,t,n,s),...y1(e,t,n)]}function w1(e,t,n,s){const r=a=>{const{structures:i,urn:c,data:l}=Zt(a,e),d=t.get(c)?.region;return l==null||c==null||i==null||d==null?"":Nt(i,d,l,n)};return In(s?.countryDimensions||d1,Jt,r,e,t,n,s)}function b1(e,t,n,s){const r=a=>{const{structures:i,urn:c,data:l}=Zt(a,e),d=t.get(c)?.indicators;return l==null||c==null||i==null||d==null||d.length===0?"":d.map(h=>Nt(i,h,l,n)||"").join(qu)};return In(s?.indicatorDimensions||f1,Yt,r,e,t,n,s)}function x1(e,t,n,s){const r=a=>{const{structures:i,urn:c,data:l}=Zt(a,e),d=t.get(c)?.frequency;return l==null||c==null||i==null||d==null?"":Nt(i,d,l,n)};return In(s?.frequency||h1,kn,r,e,t,n,s)}function y1(e,t,n){const s=new Set;return t.forEach(r=>{r?.other?.forEach(a=>{s.add(a)})}),Array.from(s).map(r=>D1(r,e,t,n))}function S1(e,t,n){const s=new Set;return t.forEach(r=>{r?.indicators?.forEach(a=>{s.add(a)})}),Array.from(s).map(r=>{const a=i=>{const{structures:c,urn:l,data:d}=Zt(i,e),u=t.get(l)?.indicators??[];return d==null||l==null||c==null||!u.includes(r)?"":Nt(c,r,d,n)};return{headerName:$u(r,e,n),field:r,colId:r,valueGetter:a,...St,cellClass:Ct,tooltipValueGetter:i=>i.value}})}function D1(e,t,n,s){const r=a=>{const{structures:i,urn:c,data:l}=Zt(a,t),d=n.get(c)?.other??[];return l==null||c==null||i==null||!d.includes(e)?"":Nt(i,e,l,s)};return{...In($u(e,t,s),e,r,t,n,s),hide:!0}}function $u(e,t,n){for(const s of t.values()){if(!s)continue;const a=(D.getDimensions(s)?.dimensions||[]).find(i=>i.id===e);if(a)return D.getDimensionTitle(s.conceptSchemes,a,n)??e}return e}function In(e,t,n,s,r,a,i){return{headerName:e,field:t,colId:t,valueGetter:n,...St,cellClass:Ct,cellRenderer:yu,tooltipValueGetter:c=>c.value,cellRendererParams:{structuresMap:s,datasetDimensionsSchemesMap:r,locale:a,titles:i,colId:t}}}function Zt(e,t){const{data:n}=e,s=n?.dataset?.urn,r=s==null?void 0:t.get(s);return{data:n,urn:s,structures:r}}function Nt(e,t,n,s){const r=e.conceptSchemes||[],a=e.codelists||[],i=D.getDimensions(e)?.dimensions||[],c=i.find(d=>d.id===t);if(c==null)return;const{codeList:l}=_n(c,r,a);return sa(i,t,l,n,s)}const gn="::";function T1(e,t){return`${e}${gn}${t}`}function yr(e){return e.includes(gn)}function Pt(e){const t=e.indexOf(gn);return{urn:e.slice(0,t),dimensionKey:e.slice(t+gn.length)}}const M1=new Set([Yt]);function Ku(e,t){let n=e;return t?.order.length&&(n=[...t.order.filter(s=>e.includes(s)),...e.filter(s=>!t.order.includes(s))]),t?.hidden.size&&(n=n.filter(s=>!t.hidden.has(s))),n}function A1(e,t,n){const s=n(t);return s?e===Yt?s.indicators:e===Jt?s.region?[s.region]:[]:e===kn?s.frequency?[s.frequency]:[]:[]:[]}function E1(e,t,n){const s=e.getDimensionConfig(t,n);if(s?.alias)return s.alias;const r=e.structuresMap.get(t),i=(r?D.getDimensions(r)?.dimensions??[]:[]).find(c=>c.id===n);return D.getDimensionTitle(r?.conceptSchemes??[],i,e.locale)??n}function N1(e){const t=e.enrichedColIds??M1;return n=>{if(!t.has(n.id))return n;const s=[];for(const{urn:r}of e.dataQueries){const a=A1(n.id,r,e.getDimensionsScheme);if(!a.length)continue;const i=e.dimensionCustomization?.get(r)?.get(n.id),c=i?.order.length?Ku(a,{order:i.order,hidden:new Set}):a,l=c.length>1,d=c.map(m=>({id:T1(r,m),type:"item",label:E1(e,r,m),isChecked:!i?.hidden.has(m),draggable:l,checkable:l})),u=e.structuresMap.get(r),h=D.getLocalizedName(u?.dataflows?.[0],e.locale)??r;s.push({id:r,type:"group",label:h,items:d})}return s.length?s.length===1?{...n,items:s[0].items}:{...n,items:s}:n}}function dl(e,t){return e===Yt?t.indicators??[]:e===Jt?t.region?[t.region]:[]:e===kn?t.frequency?[t.frequency]:[]:t.other?.includes(e)?[e]:[]}function j1(e,t){return e===Yt?t?.indicatorMetadataPanel||"Indicator dimension details":e===Jt?t?.countryMetadataPanel||"Country dimension details":t?.metadata||"Metadata"}const k1="merged-dimension-metadata-side-panel",_1=e=>{const{titles:t}=Me(),{isOpenedAdvancedView:n}=qe(),s=wt(),{isMetadataInSidePanel:r}=Ue(),a=v1(),i=e?.data?.dataset?.urn,c=jn(e?.context,i),l=i!=null?e.structuresMap.get(i):void 0,d=i!=null?e.datasetDimensionsSchemesMap.get(i):void 0,u=a?.dimensionCustomization,h=f.useMemo(()=>{if(!l||!d||i==null)return e.valueFormatted??e.value;const v=u?.get(i)?.get(e.colId);return Ku(dl(e.colId,d),v).map(b=>Nt(l,b,e.data,e.locale)).filter(Boolean).join(qu)},[u,l,d,i,e.valueFormatted,e.value,e.colId,e.data,e.locale]),m=f.useMemo(()=>{if(!l||!d)return[];const v=dl(e.colId,d),w=D.getStructureComponentsMap(l),C=v.filter(b=>e.data[b]!=null).map(b=>({name:b,value:String(e.data[b])}));return Gt(C,w,e.locale)},[l,d,e.colId,e.data,e.locale]),p=f.useMemo(()=>{const v=l?.dataflows?.[0];if(!v)return;const w=Kt(D.getLastUpdatedTime(v),e.locale);return $t(v,w,e.locale,t)},[l,e.locale,t]),g=r&&!!s&&!!e.value&&![kn,Jt].includes(e.colId),x=f.useCallback(()=>{s&&s.openPanel({id:k1,scope:n?"advanced":"conversation",title:j1(e.colId,t),bodyClassName:"overflow-hidden",content:o.jsx(zt,{locale:e.locale,metadata:m,datasetInfo:p,externalLink:c})})},[s,n,e.colId,t,e.locale,m,p,c]);return o.jsxs("div",{className:"relative size-full p-2",children:[h,g&&o.jsx("div",{className:"metadata-indicator",title:t?.metadata||"View details",onClick:x})]})},I1="dataset-detail-metadata-side-panel",R1=e=>{const{titles:t}=Me(),{isOpenedAdvancedView:n}=qe(),s=wt(),{isMetadataInSidePanel:r}=Ue(),a=e?.data?.dataset?.urn,i=jn(e?.context,a),c=a!=null?e.structuresMap.get(a):void 0,l=a!=null?e.attributesDataMap?.get(a):void 0,d=f.useMemo(()=>{const p=c?.dataflows?.[0];if(!p)return;const g=Kt(D.getLastUpdatedTime(p),e.locale);return $t(p,g,e.locale,t)},[c,e.locale,t]),u=f.useMemo(()=>Iu(_u(l),D.getStructureComponentsMap(c),e.locale),[l,c,e.locale]),h=r&&!!s&&!!e.value,m=f.useCallback(()=>{s&&s.openPanel({id:I1,scope:n?"advanced":"conversation",title:t?.datasetMetadataPanel||"Dataset Metadata",bodyClassName:"overflow-hidden",content:o.jsx(zt,{locale:e.locale,metadata:u,datasetInfo:d,externalLink:i})})},[s,n,u,d,i,t,e.locale]);return o.jsxs("div",{className:"relative size-full p-2",children:[e.valueFormatted??e.value,h&&o.jsx("div",{className:"metadata-indicator",title:t?.metadata||"View details",onClick:m})]})},P1=({attachment:e,isDataLoading:t,isChartColumnVisible:n,fixHeight:s,externalLink:r,externalLinksMap:a,showLimitMessage:i,onApiReady:c})=>{const[l,d]=f.useState(!1),[u,h]=f.useState([]),[m,p]=f.useState(),[g,x]=f.useState(400),v=f.useRef(null),w=f.useRef([]);f.useEffect(()=>{if(e.gridContent==null)d(!0);else{const M=e.gridContent.columns.map(A=>A.colId===Ut?{...A,hide:!n}:A);h(e.gridContent.data),p(M),d(!1)}},[e.gridContent,n]),f.useEffect(()=>{u?(x(Zr(u.length)),i?.(u.length>=j.SERIES_LIMIT)):i?.(!1)},[u,i]),f.useEffect(()=>{if(!m||!v.current)return;const M=m.map(E=>E.colId??E.field??"").filter(Boolean),A=w.current,S=new Set(A),_=M.length!==A.length||M.some(E=>!S.has(E));w.current=M,_&&v.current.resetColumnState()},[m]);const C=f.useCallback(M=>{v.current=M.api,c?.(M.api)},[c]),b=f.useMemo(()=>({externalLink:r,externalLinksMap:a}),[r,a]),y=f.useMemo(()=>({[Nn]:Uu,[En]:Gu,[yu]:_1,[xu]:Yr,[Su]:R1}),[]),N=f.useMemo(()=>o.jsx(Pr.AgGridReact,{headerHeight:qt,rowHeight:An,rowData:u,enableCellTextSelection:!0,columnDefs:m,context:b,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",components:y,valueCache:!0,onGridReady:C}),[u,m,b,y,C]);return l||t?o.jsx(j.Loader,{}):o.jsx("div",{className:"size-full",children:o.jsx(Bu,{fixHeight:s,gridHeight:g,children:N})})},L1=({selectedAttachment:e,actions:t,attachmentsStyles:n,isDataLoading:s,externalLink:r,externalLinksMap:a,isOpenedAdvancedView:i,onOpenAdvancedView:c,showLimitMessage:l,onGridApiReady:d})=>o.jsxs("div",{className:"flex min-h-0 w-full flex-1 justify-center",children:[Um(e)&&o.jsx(xp,{actions:t,downloadTitles:n?.downloadTitle,attachment:e}),Kr(e)&&o.jsx(Hp,{actions:t,attachment:e,showLimitMessage:l}),ft(e)&&o.jsx(Qg,{attachment:e,isDataLoading:s,isChartColumnVisible:i,fixHeight:!i,showLimitMessage:l,onApiReady:d,externalLink:r}),vt(e)&&o.jsx(P1,{attachment:e,isDataLoading:s,isChartColumnVisible:i,fixHeight:!i,showLimitMessage:l,onApiReady:d,externalLink:r,externalLinksMap:a}),ln(e)&&o.jsx(o1,{isDataLoading:s,attachment:e,icons:n?.chartingIcons,openAdvancedView:i?void 0:c,fixHeight:!i,limitationInfoPrefixIcon:n?.limitationInfoIcon,limitationInfoContentClassName:n?.limitationInfoContentClassName}),$r(e)&&o.jsx(Np,{attachment:e,openLinkTitle:n?.openLinkTitle}),fu(e)&&o.jsx(Tp,{attachment:e}),Jr(e)&&o.jsx(l1,{attachment:e,className:n?.codeAttachmentContainerClassName})]}),O1=({isOpen:e,alertDetails:t,attachmentsStyles:n,onClose:s})=>{if(!e)return null;const r=t?.progress&&t.progress.total>0?`${Math.min(100,Math.max(0,t.progress.current/t.progress.total*100))}%`:"0%";return o.jsx(j.Alert,{alertDetails:t,infoIcon:n?.infoDownloadIcon,successIcon:n?.successDownloadIcon,errorIcon:n?.errorDownloadIcon,onClose:s,closeButtonTitle:n?.closeTitle||"Close",children:o.jsxs(o.Fragment,{children:[t?.text&&o.jsx("div",{className:"alert-text whitespace-pre-line break-words",title:t.text,children:t.text}),t?.progress&&o.jsx("div",{className:"alert-progress",children:o.jsx("div",{className:"alert-progress-value",style:{width:r}})}),t?.action&&o.jsxs("button",{type:"button",className:"alert-action",disabled:t.action.disabled,onClick:t.action.onClick,title:t.action.title,children:[t.action.icon&&o.jsx("span",{className:"alert-action-icon",children:t.action.icon}),o.jsx("span",{className:"alert-action-text",children:t.action.text})]})]})})},F1=({attachmentsStyles:e,onCancel:t,onRetry:n})=>{const s=f.useCallback(p=>e?.downloadTitles?.downloadStartedText?.(p.dataFormatTitle)??`Preparing ${p.dataFormatTitle} file.`,[e?.downloadTitles]),r=f.useCallback((p,g)=>e?.downloadTitles?.downloadInProgressTitle?.(p,g)??`Downloading file ${p} of ${g}`,[e?.downloadTitles]),a=f.useCallback((p,g)=>e?.downloadTitles?.downloadInProgressText?.(p,g)??`${p} · ${g}`,[e?.downloadTitles]),i=f.useCallback(p=>p.items.length>1?e?.downloadTitles?.downloadSuccessMultipleTitle?.(p.items.length)??`${p.items.length} files downloaded`:e?.downloadTitles?.downloadSuccessTitle?.(p.dataFormatTitle)??`${p.dataFormatTitle} file downloaded`,[e?.downloadTitles]),c=f.useCallback(p=>{if(p.items.length>1)return e?.downloadTitles?.downloadSuccessMultipleText?.(p.items.length)??`${p.items.length} files successfully downloaded`;const[g]=p.items;return e?.downloadTitles?.downloadSuccessText?.(g.fileName,g.rowCount)??`${g.fileName} · ${g.rowCount} rows`},[e?.downloadTitles]),l=f.useCallback(p=>{if(p.items.length>1)return e?.downloadTitles?.downloadFailedMultipleText?.(p.items.length)??`${p.items.length} datasets could not be exported`;const[g]=p.items;return e?.downloadTitles?.downloadFailedText?.(g.name)??`${g.name} could not be exported`},[e?.downloadTitles]),d=f.useCallback(p=>({type:j.AlertType.INFO,title:e?.downloadTitles?.downloadStartedTitle??"Download started",text:s(p),action:{text:e?.downloadTitles?.downloadCancelActionText??e?.downloadTitles?.cancel??"Cancel",icon:e?.downloadInProgressActionIcon,onClick:t}}),[e?.downloadInProgressActionIcon,e?.downloadTitles,s,t]),u=f.useCallback((p,g,x,v)=>({type:j.AlertType.IN_PROGRESS,title:r(g,p.items.length),text:a(v,p.dataFormatTitle),progress:{current:x,total:p.items.length},action:{text:e?.downloadTitles?.downloadCancelActionText??e?.downloadTitles?.cancel??"Cancel",icon:e?.downloadInProgressActionIcon,onClick:t}}),[e?.downloadInProgressActionIcon,e?.downloadTitles,a,r,t]),h=f.useCallback(p=>({type:j.AlertType.SUCCESS,title:i(p),text:c(p)}),[c,i]),m=f.useCallback(p=>({type:j.AlertType.ERROR,title:e?.downloadTitles?.downloadFailedTitle??"Download failed",text:l(p),action:{text:e?.downloadTitles?.downloadRetryActionText??"Retry download",icon:e?.downloadErrorActionIcon,onClick:n}}),[e?.downloadErrorActionIcon,e?.downloadTitles,l,n]);return{getStartedAlertDetails:d,getInProgressAlertDetails:u,getSuccessAlertDetails:h,getErrorAlertDetails:m}},V1=300,H1=({attachmentsStyles:e,downloadDataSet:t})=>{const[n,s]=f.useState(),[r,a]=f.useState(!1),[i,c]=f.useState(),l=f.useRef(null),d=f.useRef(null),u=f.useRef(null),h=f.useRef(!1),m=f.useRef(!1),p=f.useCallback(S=>{c(S),s(!0)},[]),g=f.useCallback(()=>{s(!1)},[]),x=f.useCallback(()=>{m.current=!0,l.current?.abort(),g()},[g]),v=f.useCallback(()=>{const S=d.current;!S||!u.current||u.current(S)},[]),w=f.useCallback(S=>(S instanceof DOMException||S instanceof Error)&&S.name==="AbortError",[]),{getStartedAlertDetails:C,getInProgressAlertDetails:b,getSuccessAlertDetails:y,getErrorAlertDetails:N}=F1({attachmentsStyles:e,onCancel:x,onRetry:v}),M=f.useCallback(async S=>{if(!h.current){h.current=!0,a(!0),m.current=!1,d.current=null;try{const _=[],E=S.items.length>1;E||p(C(S));for(const[T,k]of S.items.entries()){if(m.current)return;E&&p(b(S,T+1,T,k.name));const I=new AbortController;l.current=I;try{await t(k.urn,S.dataFormat,S.language,S.attribute,k.filters,k.fileName,S.isMetadata,I.signal)}catch(L){if(w(L)&&m.current)return;_.push(k),console.error("Failed to download dataset",L)}finally{l.current===I&&(l.current=null)}T<S.items.length-1&&await new Promise(L=>window.setTimeout(L,V1))}if(m.current)return;if(_.length>0){const T={...S,items:_};d.current=T,p(N(T));return}p(y(S))}finally{l.current=null,h.current=!1,a(!1)}}},[t,N,b,C,y,w,p]);return f.useEffect(()=>{u.current=M},[M]),f.useEffect(()=>()=>{m.current=!0,l.current?.abort()},[]),{startDownload:f.useCallback(S=>h.current?!1:(M(S),!0),[M]),isDownloadRunning:r,downloadAlertProps:{isOpen:n,alertDetails:i,attachmentsStyles:e,onClose:g}}};Wa.ModuleRegistry.registerModules([Wa.AllCommunityModule]);const Ju=({attachments:e,actions:t,isSystemAttachments:n,isShowAttachments:s,showAdvancedView:r,currentDataQuery:a,dataQueries:i,attachmentInfoList:c,datasets:l,initialSelectedDatasetUrn:d,isDataLoading:u,isDataSetAttachments:h,locale:m,dimensions:p,filters:g,selectDataset:x,onAdvancedViewOpen:v,isTableSettingsOpen:w,onTableSettingsOpen:C,onTableSettingsClose:b,onGridApiReady:y})=>{const{titles:N,messageStyles:M,attachmentsStyles:A,limitMessages:S,attachmentsConfig:_}=Me(),{isCrossDatasetModeOn:E}=Ue(),[T,k]=f.useState(0),[I,L]=f.useState(null),{isOpenedAdvancedView:H,setIsOpenedAdvancedView:G}=qe(),[Y,O]=f.useState(j.PopUpState.Closed),[$,K]=f.useState(!1),[Z,se]=f.useState(!1),ge=D.DownloadType.DATA_IN_TABLE,he=f.useMemo(()=>{if(!E||!i?.some(oe=>oe.disabled))return l;const ae=new Set(i.filter(oe=>!oe.disabled).map(oe=>oe.urn));return l?.filter(oe=>{const pe=D.generateShortUrn(oe?.id,oe?.version,oe?.agencyID);return ae.has(pe)})},[l,i,E]),xe=ae=>{k(ae)},F=f.useCallback(()=>{v?.(),G(!0),t.updateCurrentDataQuery(a||i?.[0]),t.updateDataQueries(i),t.updateDatasets(l)},[t,a,i,l,G,v]);f.useEffect(()=>{L(e[T]||null)},[e,T]),f.useEffect(()=>{K(h&&(l==null||l?.length==0))},[l,h]),f.useEffect(()=>{w&&I&&!ft(I)&&!vt(I)&&b?.()},[w,I,b]);const J=f.useCallback(()=>{O(j.PopUpState.Closed)},[O]),ue=_?.isExternaLinkIncludeFilters,de=kr(ue,g,a||i?.[0],p),me=f.useMemo(()=>i?.length?new Map(i.map(oe=>[oe.urn,kr(ue,void 0,oe)])):void 0,[i,ue]),re=f.useMemo(()=>{if(!I||!vt(I))return;const oe=I.gridContent?.data??[],pe=new Map,Se=new Map;for(const Ce of oe){const{dataset:ye,datasetTitle:ce}=Ce,Ee=ye?.urn;Ee&&(pe.set(Ee,(pe.get(Ee)??0)+1),!Se.has(Ee)&&ce&&Se.set(Ee,ce))}return Array.from(pe.entries()).map(([Ce,ye])=>({urn:Ce,name:Se.get(Ce)??Ce,rowCount:ye,dataQuery:i?.find(ce=>ce.urn===Ce)}))},[I,i]),Q=f.useMemo(()=>{if(I){if(ft(I))return I.grid_data?.data?.length;if(vt(I))return I.gridContent?.data?.length}},[I]),{startDownload:U,isDownloadRunning:q,downloadAlertProps:fe}=H1({attachmentsStyles:A,downloadDataSet:t.downloadDataSet});return!e||e.length===0?null:o.jsx(o.Fragment,{children:H&&!s?o.jsx(ep,{icon:M?.advanceViewIcon,title:M?.openAdvanceViewTitle??"Opened in Advanced view"}):o.jsxs("div",{className:W("space-y-3 max-w-full max-h-full h-full",!H&&!n?"pt-5":"pt-0","flex flex-col pb-1"),children:[!H&&$?o.jsx(j.Loader,{}):o.jsxs(o.Fragment,{children:[n&&!H&&o.jsx(Qm,{titles:{queryUpdatedManuallyTitle:N?.queryUpdatedManually,setToTitle:N?.setTo,datasetLabel:N?.dataset},datasetIcon:A?.datasetIcon,attachmentInfoList:c,dataQueries:i}),!H&&he?.length!=null&&he?.length>0&&o.jsx(vu,{datasets:he,initialSelectedDatasetUrn:d,locale:m,selectDataset:x}),Z&&o.jsx(j.RequestLimitMessage,{limitMessages:S,showAdvancedViewButton:!!I&&Bm(I)&&r,onAdvancedViewClick:F,query:de}),o.jsx("div",{className:W(!H&&l?.length&&"attachments-bordered","attachments-wrapper h-full min-h-0"),children:o.jsxs("div",{className:"flex h-full max-w-full flex-col items-center gap-4",children:[o.jsx(bp,{attachments:e,selectedAttachmentIndex:T,selectedAttachment:I,attachmentsStyles:A,externalLink:de,isExternalLinkIncludeFilters:ue,limitMessages:S,onSelectedAttachmentChange:xe,onDownloadClick:()=>O(j.PopUpState.Opened),showAdvancedView:r,onOpenAdvancedView:F,isTableSettingsOpen:w,onTableSettingsOpen:C}),I!=null&&o.jsx(L1,{selectedAttachment:I,actions:t,attachmentsStyles:A,isDataLoading:u,isOpenedAdvancedView:H,onOpenAdvancedView:F,showLimitMessage:se,onGridApiReady:y,externalLink:de,externalLinksMap:me})]})})]}),o.jsxs(o.Fragment,{children:[Y===j.PopUpState.Opened&&o.jsx(op,{onCloseModal:J,onDownloadStart:U,isDownloadInProgress:q,dataQuery:a,datasetName:I?.title||"",locale:m,type:ge,dimensions:p,filters:g,urn:a?.urn,titles:A?.downloadTitles,rowCount:Q,collapsible:A?.downloadCollapsible,downloadDatasets:re,limitMessages:S,showLimitMessage:Z,externalLink:de}),o.jsx(O1,{...fe})]})]})})},U1=({label:e,colDef:t})=>!!e.trim()&&!t.suppressColumnsToolPanel;function G1(e){return e.colId??e.field??null}function B1(e){return String(e.headerName??e.field??e.colId??"").trim()}function q1(e){return new Map(e.getColumnState().map(t=>[t.colId,t]))}function z1(e,t){const n=e.getColumnDefs()??[],s=q1(e),r=[];for(const c of n){const l=G1(c);if(!l)continue;const d=B1(c);if(!t({colId:l,label:d,colDef:c}))continue;const u=s.get(l);r.push({id:l,type:"item",label:d,isChecked:!(u?.hide??!1),draggable:!0,checkable:!0})}const a=e.getColumnState().map(c=>c.colId),i=new Map(a.map((c,l)=>[c,l]));return r.sort((c,l)=>{const d=i.get(c.id)??Number.MAX_SAFE_INTEGER,u=i.get(l.id)??Number.MAX_SAFE_INTEGER;return d-u})}function W1(e,t,n){const s=[...t];return e.map(r=>n.has(r)?s.shift()??r:r)}function Sr(e,t){let n=e,s;for(const r of t){if(s=n.find(a=>a.id===r),!s)return;n=s.type==="group"?s.items:s.items??[]}return s?.type==="item"?s:void 0}function $1(e){if(!e.items?.length)return e;if(e.items.every(n=>n.type==="item")){const n=e.items,s=n.filter(a=>a.isChecked!==!1);if(s.length!==1)return e;const[r]=s;return{...e,items:n.map(a=>a===r?{...a,checkable:!1,draggable:!1}:{...a,draggable:!1})}}const t=e.items.map(n=>{if(n.type!=="group")return n;const r=n.items.filter(i=>i.type==="item").filter(i=>i.isChecked!==!1);if(r.length!==1)return n;const[a]=r;return{...n,items:n.items.map(i=>i.type!=="item"?i:i===a?{...i,checkable:!1,draggable:!1}:{...i,draggable:!1})}});return t.every((n,s)=>n===e.items[s])?e:{...e,items:t}}function Ir(e,t){const n=[];for(const s of e){if(s.type==="group"){n.push(...Ir(s.items,t));continue}if(t?.(s)){n.push(s.id);continue}if(s.items?.length){n.push(...Ir(s.items,t));continue}n.push(s.id)}return n}function K1({api:e,searchQuery:t,includeColumn:n=U1,enrichItem:s,onSubItemOrderChange:r,onSubItemVisibilityChange:a}){const[i,c]=f.useState(0),[l,d]=f.useState(new Set),u=f.useCallback(()=>{c(b=>b+1)},[]);zu(e,u);const h=f.useMemo(()=>!e||!e.getColumnState()?[]:z1(e,n),[e,n,i]),m=f.useMemo(()=>(s?h.map(y=>y.type==="item"?s(y):y):h).map(y=>y.type==="item"&&y.items?.length?{...y,isExpanded:l.has(y.id)}:y),[h,s,l]),p=f.useMemo(()=>new Set(h.map(b=>b.id)),[h]),g=f.useMemo(()=>j.filterDraggableListNodes(m,t),[m,t]),x=f.useCallback(b=>{if(!e)return;if(yr(b.itemId)&&a){const{urn:N,dimensionKey:M}=Pt(b.itemId),A=b.path[0];a(N,A,M,!b.nextChecked);return}const y=Sr(m,b.path);!y||!p.has(y.id)||(e.applyColumnState({state:[{colId:y.id,hide:!b.nextChecked}]}),u())},[e,m,p,u,a]),v=f.useCallback(b=>{if(!e)return;if(yr(b.itemId)&&a){const{urn:A,dimensionKey:S}=Pt(b.itemId),_=b.path[0],E=Sr(m,b.path);E?.type==="item"&&a(A,_,S,E.isChecked??!0);return}const y=Sr(m,b.path);if(!y||!p.has(y.id))return;const M=!(e.getColumnState().find(A=>A.colId===y.id)?.hide??!1);e.applyColumnState({state:[{colId:y.id,hide:M}]}),u()},[e,m,p,u,a]),w=f.useCallback(b=>{const y=b.path[b.path.length-1];d(N=>{const M=new Set(N);return b.nextExpanded?M.add(y):M.delete(y),M})},[]),C=f.useCallback(b=>{if(!e)return;const y=e.getColumnState().map(S=>S.colId),N=new Set(h.map(S=>S.id)),M=Ir(b,S=>p.has(S.id)),A=W1(y,M,N);if(e.applyColumnState({state:A.map(S=>({colId:S})),applyOrder:!0}),u(),r){for(const S of b)if(!(S.type!=="item"||!p.has(S.id)||!S.items))if(S.items.some(_=>_.type==="group"))for(const _ of S.items){if(_.type!=="group")continue;const E=_.items.filter(I=>I.type==="item");if(E.length<=1)continue;const T=_.id,k=E.map(I=>Pt(I.id).dimensionKey);r(T,S.id,k)}else{const _=S.items.filter(k=>k.type==="item");if(_.length<=1||!yr(_[0].id))continue;const{urn:E}=Pt(_[0].id),T=_.map(k=>Pt(k.id).dimensionKey);r(E,S.id,T)}}},[e,h,p,u,r]);return{items:m,visibleItems:g,handleToggleChecked:x,handleToggleExpanded:w,handleItemClick:v,handleItemsChange:C}}function J1({api:e,includeColumn:t,enrichItem:n,renderLabel:s,onSubItemOrderChange:r,onSubItemVisibilityChange:a,searchPlaceholder:i}){const[c,l]=f.useState(""),d=f.useCallback(C=>{l(C)},[l]),u=f.useCallback(()=>l(""),[l]),h=f.useMemo(()=>o.jsx("button",{type:"button",onClick:u,children:o.jsx(He.IconX,{className:"size-4 text-neutrals-1000"})}),[u]),m=f.useCallback(C=>{const b=n?n(C):C;return $1(b)},[n]),{visibleItems:p,handleItemsChange:g,handleToggleChecked:x,handleToggleExpanded:v,handleItemClick:w}=K1({api:e,includeColumn:t,searchQuery:c,enrichItem:m,onSubItemOrderChange:r,onSubItemVisibilityChange:a});return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 px-5",children:[o.jsx(j.InputWithIcon,{inputId:"columns-search-input",containerClasses:"items-center filters-search-input gap-1 !p-2",cssClass:"filters-search-input-text",placeholder:i||"Search",iconBeforeInput:o.jsx(He.IconSearch,{className:"size-4 text-neutrals-1000"}),iconAfterInput:c?h:void 0,value:c,onChange:d}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:o.jsx(j.DraggableList,{items:p,onItemsChange:g,onToggleChecked:x,onToggleExpanded:v,onItemClick:w,renderLabel:s})})]})}const Y1={},Z1={map:Y1,getDimensionsMetadata:()=>{},getDimensionMetadata:()=>{},getRegionDimension:()=>{},getFrequencyDimension:()=>{},getIndicatorDimensions:()=>[],getDimensionsScheme:()=>{}},ra=f.createContext(Z1);function X1({map:e,children:t}){const n=f.useMemo(()=>{const s={},r={},a={},i=Object.keys(e);for(const c of i){s[c]={},r[c]={};const l=Object.keys(e[c]);for(const d of l){const u=e[c][d];u.subtype&&(s[c][u.subtype]=d),r[c][u.dimensionType]||(r[c][u.dimensionType]=[]),r[c][u.dimensionType].push(d)}a[c]={timePeriod:r[c]?.TIME_PERIOD?.[0]??void 0,frequency:s[c]?.FREQUENCY??void 0,region:s[c]?.REGION??void 0,indicators:r[c]?.INDICATOR??[],other:(r[c]?.NON_INDICATOR??[]).filter(d=>{const u=e[c][d];return u.subtype!=="FREQUENCY"&&u.subtype!=="REGION"})}}return{map:e,getDimensionsMetadata:c=>e[c],getDimensionMetadata:(c,l)=>e[c]?.[l],getRegionDimension:c=>s[c]?.REGION,getFrequencyDimension:c=>s[c]?.FREQUENCY,getIndicatorDimensions:c=>r[c]?.INDICATOR??[],getDimensionsScheme:c=>a[c]}},[e]);return o.jsx(ra.Provider,{value:n,children:t})}function Rn(){return f.useContext(ra)}function Pn(){return f.useContext(ra)}function Q1(){const{dataQueries:e,structuresMap:t,locale:n,gridViewMode:s}=na(),r=Pn(),a=f.useMemo(()=>{const i=new Map;if(!r||!e?.length)return i;for(const{urn:c}of e){const l=r.getDimensionsScheme(c),d=!!l?.other.length,u=s===et.Extended&&!!l?.indicators?.length;if(!d&&!u)continue;const h=n?D.getLocalizedName(t?.get(c)?.dataflows?.[0],n)??c:c,m=[...l?.other??[],...u?l?.indicators??[]:[]];for(const p of m){const g=i.get(p);g?g.push(h):i.set(p,[h])}}return i},[r,e,t,n,s]);return f.useMemo(()=>{if(!a.size)return;function i(c){const l=a.get(c.id);return l?.length?o.jsxs("span",{className:"flex w-full items-center gap-2 overflow-hidden",children:[o.jsx("span",{className:"min-w-0 flex-1 truncate",title:c.label,children:c.label}),o.jsx("span",{className:"h5 min-w-0 flex-1 truncate text-right text-neutrals-700",title:l.join(", "),children:l.join(", ")})]}):c.label}return i},[a])}var ke=(e=>(e.Header="header",e.Cell="cell",e))(ke||{}),Ae=(e=>(e.Focus="focus",e.Default="default",e))(Ae||{});const ev="grid gap-1",tv={gridTemplateColumns:"44px 23px 23px",gridTemplateRows:"repeat(4, 14px)"},nv={gridTemplateColumns:"repeat(4, 21.5px)",gridTemplateRows:"repeat(4, 14px)"},sv={[ke.Header]:{[Ae.Focus]:"content-center rounded-sm border border-accent-300 bg-accent-300 text-center text-[8px] font-semibold",[Ae.Default]:"rounded-sm bg-semantic-warning border border-accent-300"},[ke.Cell]:{[Ae.Focus]:"content-center rounded-sm border border-accent-300 bg-hues-100 pl-1 text-left text-[8px] font-semibold",[Ae.Default]:"rounded-sm bg-neutrals-100 border border-accent-300"}},Yu=({rows:e,style:t})=>o.jsx("div",{className:ev,style:t,children:e.map((n,s)=>o.jsx(f.Fragment,{children:n.map((r,a)=>o.jsx("span",{className:nt([sv[r.role][r.emphasis],!r.label&&"text-transparent"]),children:r.label||" "},`${s}-${a}`))},s))}),rv=[[{role:ke.Header,emphasis:Ae.Focus,label:"D1.D2.D3"},{role:ke.Header,emphasis:Ae.Default},{role:ke.Header,emphasis:Ae.Default}],[{role:ke.Cell,emphasis:Ae.Focus,label:"C1.A"},{role:ke.Cell,emphasis:Ae.Default},{role:ke.Cell,emphasis:Ae.Default}],[{role:ke.Cell,emphasis:Ae.Focus,label:"C1.B"},{role:ke.Cell,emphasis:Ae.Default},{role:ke.Cell,emphasis:Ae.Default}],[{role:ke.Cell,emphasis:Ae.Focus,label:"C2.X"},{role:ke.Cell,emphasis:Ae.Default},{role:ke.Cell,emphasis:Ae.Default}]],av=()=>o.jsx(Yu,{rows:rv,style:tv}),iv=[[{role:ke.Header,emphasis:Ae.Focus,label:"D1"},{role:ke.Header,emphasis:Ae.Focus,label:"D2"},{role:ke.Header,emphasis:Ae.Focus,label:"D3"},{role:ke.Header,emphasis:Ae.Default}],[{role:ke.Cell,emphasis:Ae.Focus,label:"C1"},{role:ke.Cell,emphasis:Ae.Focus,label:"A"},{role:ke.Cell,emphasis:Ae.Focus},{role:ke.Cell,emphasis:Ae.Default}],[{role:ke.Cell,emphasis:Ae.Focus,label:"C1"},{role:ke.Cell,emphasis:Ae.Focus,label:"B"},{role:ke.Cell,emphasis:Ae.Focus},{role:ke.Cell,emphasis:Ae.Default}],[{role:ke.Cell,emphasis:Ae.Focus,label:"C2"},{role:ke.Cell,emphasis:Ae.Focus},{role:ke.Cell,emphasis:Ae.Focus,label:"X"},{role:ke.Cell,emphasis:Ae.Default}]],ov=()=>o.jsx(Yu,{rows:iv,style:nv}),fl=({title:e,description:t,visual:n,mode:s,activeMode:r,onClick:a})=>o.jsxs("button",{type:"button",className:nt(["flex items-center gap-3 rounded border p-1",s===r&&"border-primary"]),onClick:()=>a(s),children:[o.jsx("div",{className:"rounded-[5px] bg-neutrals-100 px-2 py-1",children:n}),o.jsxs("div",{className:"flex flex-col gap-1 text-left",children:[o.jsx("span",{className:"h4 text-neutrals-1000",children:e}),o.jsx("span",{className:"caption text-neutrals-800",children:t})]})]}),lv=({gridViewMode:e,onModeChange:t,compactViewTitle:n,compactViewDescription:s,extendedViewTitle:r,extendedViewDescription:a})=>o.jsxs("div",{className:"mx-5 my-3 flex flex-col gap-2",children:[o.jsx(fl,{title:n||"Compact view",description:s??o.jsxs(o.Fragment,{children:["Related dimensions ",o.jsx("strong",{children:"combined into a single column."})]}),visual:o.jsx(av,{}),mode:et.Compact,activeMode:e,onClick:t}),o.jsx(fl,{title:r||"Extended view",description:a??o.jsxs(o.Fragment,{children:["Each dimension displayed in ",o.jsx("strong",{children:"separate column."})]}),visual:o.jsx(ov,{}),mode:et.Extended,activeMode:e,onClick:t})]}),hl="table-settings-side-panel",cv=()=>{const{gridApi:e,initialColumnsState:t,structuresMap:n,locale:s,dataQueries:r,dimensionCustomization:a,setDimensionKeyOrder:i,setDimensionKeyHidden:c,resetDimensionCustomization:l,clearUserColumnState:d,clearInitialColumnState:u,gridViewMode:h,setGridViewMode:m,texts:p,resetIcon:g}=na(),x=Pn(),v=Q1(),w=f.useCallback(y=>{d(),u(),l(),m(y)},[d,u,l,m]),C=f.useCallback(()=>{e&&(d(),t?m1(e,t):e.resetColumnState(),l())},[d,e,t,l]),b=f.useMemo(()=>{if(!(h!==et.Compact||!x||!n||!s||!r?.length))return N1({dataQueries:r,structuresMap:n,getDimensionsScheme:x.getDimensionsScheme,getDimensionConfig:(y,N)=>x.map[y]?.[N],locale:s,dimensionCustomization:a})},[h,x,n,s,r,a]);return e?o.jsxs("div",{className:"flex h-full flex-col",children:[o.jsx(lv,{gridViewMode:h,onModeChange:w,compactViewTitle:p?.compactViewTitle,compactViewDescription:p?.compactViewDescription,extendedViewTitle:p?.extendedViewTitle,extendedViewDescription:p?.extendedViewDescription}),o.jsx("hr",{className:"border-neutrals-500"}),o.jsxs("div",{className:"mx-5 mb-4 mt-5 flex items-center justify-between",children:[o.jsx("h3",{className:"text-neutrals-1000",children:p?.columnsDisplayTitle||"Columns display"}),o.jsx("button",{type:"button",className:"text-neutrals-800",onClick:C,children:g??o.jsx(He.IconRotate,{className:"size-4 rotate-180"})})]}),o.jsx(J1,{api:e,enrichItem:b,renderLabel:v,onSubItemOrderChange:i,onSubItemVisibilityChange:c,searchPlaceholder:p?.columnsSearchPlaceholder})]}):null},uv=e=>{const{attachmentsStyles:t}=Me(),{onGridApiReady:n}=na(),s=wt(),r=f.useCallback(()=>{s&&s.openPanel({id:hl,scope:"advanced",title:t?.tableSettings||"Table settings",headerClassName:"border-b border-neutrals-500",content:o.jsx(cv,{})})},[s,t?.tableSettings]);return o.jsx(Ju,{...e,isTableSettingsOpen:s?.isPanelOpen(hl)??!1,onTableSettingsOpen:s?r:void 0,onTableSettingsClose:s?.closePanel,onGridApiReady:n})},dv=({actions:e,structureDataMaps:t,buttonProps:n,modalProps:s,dataQueries:r,onMultipleDataFiltersChange:a,locale:i,timeRangeOptions:c,datasetIcon:l,conversationKey:d,conversation:u,setConversation:h,updateConversation:m,updateDataQueries:p,limitMessages:g,filterIconClassName:x})=>{const{titles:v}=Me(),w=Pn(),{modalState:C,setModalState:b,isModalClosed:y,setIsModalClosed:N}=uu(),[M,A]=f.useState([]),[S,_]=f.useState([]),[E,T]=f.useState(),[k,I]=f.useState([]),[L,H]=f.useState(void 0),G=f.useRef(t?.constraintsMap),[Y,O]=f.useState(),[$,K]=f.useState(),[Z,se]=f.useState(),[ge,he]=f.useState(!1),xe=f.useRef(0),[F,J]=f.useState(new Set),[ue,de]=f.useState(new Set),me=f.useRef(u);f.useEffect(()=>{me.current=u},[u]);const re=f.useCallback(()=>{xe.current+=1,xe.current===1&&he(!0)},[]),Q=f.useCallback(()=>{xe.current=Math.max(xe.current-1,0),xe.current===0&&he(!1)},[]),U=f.useMemo(()=>cm(r,t),[r,t]),q=f.useCallback(R=>Im(R,t?.dimensionsMap,t?.structuresMap),[t?.dimensionsMap,t?.structuresMap]),fe=f.useCallback(R=>q(R).codelistUrn,[q]),ae=f.useCallback(R=>{const P=R.filterType==="dataset"?R.datasetUrn:R.sourceDatasetUrns?.[0];return P?G.current?.get(P):void 0},[]),oe=f.useCallback(R=>q(R).sourceArtefactUrn,[q]),{hierarchyStateMap:pe,rebuildHierarchyTree:Se,loadAvailableHierarchies:Ce,onSelectHierarchy:ye,onExpandHierarchyNode:ce}=pu({getCodelistUrnForFilter:fe,getConstraintsForFilter:ae,getSourceArtefactUrn:oe,getAvailableHierarchies:e?.getAvailableHierarchies,getHierarchy:e?.getHierarchy}),Ee=R=>{const P=R?M.map(z=>Re(z,R)?R:z):M;se(!0),A(mn(P)),K?.(!0),Pe(R?.isTimeDimension?hn(P,R):P,A,K,R)};f.useEffect(()=>{C===j.PopUpState.Closed&&O(G.current)},[C]);const Pe=f.useCallback((R,P,z,te)=>{const _e=xt(R,G.current,!1,w.map),be=qo(r,_e,e,w.map,R);be&&re();const De=Bo(r,_e,e,w.map,R);Promise.allSettled(De).then(Ye=>{const Ke=Wo(G.current||t?.constraintsMap,zo(Ye)),rt={...t,constraintsMap:Ke};if(te){const{filtersMap:bt,changed:lt}=Ym(_e,rt,te,i,w.map);if(lt){G.current=Ke,z?.(!0),se(!0);const Xt=kt(bt,rt,i,w.map);Pe(Xt,P,z,te);return}}const at=kt(_e,rt,i,w.map);if(G.current=Ke,z?.(!1),P(at),te){const bt=at.find(lt=>Re(lt,te));T(lt=>lt&&bt&&Re(lt,te)?{...bt,isSelectedFilter:!0}:lt),Se(te,ae(te))}}).catch(()=>{const Ye=G.current||t?.constraintsMap||new Map,Ke=kt(_e,{...t,constraintsMap:Ye},i,w.map);if(G.current=Ye,z?.(!1),P(Ke),te){const rt=Ke.find(at=>Re(at,te));T(at=>at&&rt&&Re(at,te)?{...rt,isSelectedFilter:!0}:at)}}).finally(()=>{se(!1),be&&Q()})},[e,r,w.map,Q,ae,i,Se,re,t]);f.useEffect(()=>{if(!U){K(!0);return}const R=Oc(t,i),P=r?.map(te=>{if(!te.disabled)return te;const _e=(R.get(te.urn)??[]).filter(be=>be.filterType==="dataset"&&be.id&&!be.isTimeDimension).map(be=>({componentCode:be.id,operator:ne.QueryFilterType.IN,values:[]}));return{...te,filters:_e}}),z=Fc(R,P,t?.constraintsMap,w.map);K?.(!0),Pe(z,_,K)},[r,w.map,Pe,U,i,t]),f.useEffect(()=>{S?.length&&I(Tn(S))},[S]),f.useEffect(()=>{A(R=>hn(R,E))},[E]),f.useEffect(()=>{if(C===j.PopUpState.Opened){H(void 0);const R=S.find(z=>!z.isTimeDimension);T(R?{...R,isSelectedFilter:!0}:void 0),A(S);const P=new Set(r?.filter(z=>z.disabled).map(z=>z.urn));J(P),de(P)}C===j.PopUpState.Closed&&T(void 0)},[S,r,C]),f.useEffect(()=>{if(!E||E.isTimeDimension)return;const R=We(E);if(!R)return;pe.get(R)||Ce(E)},[E,pe,Ce]),f.useEffect(()=>{C===j.PopUpState.Opened&&S.forEach(R=>{if(R.isTimeDimension)return;const P=We(R);P&&!pe.has(P)&&Ce(R)})},[C,S,pe,Ce]);const ze=f.useCallback(async R=>{const P=me.current,z=r?.map(De=>({...De,disabled:F.has(De.urn)})),te=z?.filter(De=>!De.disabled),_e=Wc(te,R),be=P?{...P,messages:mu(P.messages,z,_e)}:null;h?.(be),p?.(z?.map(De=>({...De,filters:De.disabled?De.filters??[]:_e.get(De.urn)??[]}))??[]),await m(decodeURI(d),{name:be?.name,messages:be?.messages||[]})},[d,r,F,h,m,p]),Ge=f.useCallback((R,P)=>{A(z=>uc(z,R,P)),Re(E,R)&&T(z=>z&&{...z,displayMode:P})},[E]),Ve=f.useCallback(R=>zc(R,r,t?.dimensionsMap),[r,t?.dimensionsMap]),Xe=f.useMemo(()=>{const R=xt(S,G.current,!1,w.map),P=xt(M,G.current,!1,w.map),z=Mr(Ve(R),Ve(P)),te=Mr([...ue].sort(),[...F].sort());return z&&te},[S,M,ue,F,Ve,w.map]),$e=f.useCallback((R,P)=>{const z=kt(R,P,i,w.map);G.current=P?.constraintsMap,T(te=>z?.find(_e=>Re(_e,te))||te),A(z),se(!1)},[w.map,i]),Be=f.useCallback((R,P)=>{se(!0),A(mn(R));const z=xt(R,G.current,!1,w.map),te=G.current||t?.constraintsMap||new Map,_e=qo(P,z,e,w.map,R);_e&&re();const be=Bo(P,z,e,w.map,R);Promise.allSettled(be).then(De=>{const Ye=Wo(te,zo(De));$e(z,{...t,constraintsMap:Ye})}).catch(()=>{$e(z,{...t,constraintsMap:te})}).finally(()=>{_e&&Q()})},[e,w.map,Q,re,t,$e]),ot=f.useCallback(R=>{const P=r?.find(te=>te?.urn===R?.datasetUrn),z=hc(M,R);Be(z,R?.datasetUrn?P?[P]:[]:r)},[Be,M,r]),X=f.useCallback(()=>{J(new Set)},[]),ve=f.useCallback((R,P)=>{J(z=>{const te=new Set(z);return P?te.delete(R):te.add(R),te})},[]),ie=f.useCallback(()=>{G.current=Y,b(j.PopUpState.Closed),N(!0)},[Y,b,N]),le=f.useCallback(()=>{const R=mc(M);Be(R,r),J(new Set)},[Be,M,r]),Le=f.useCallback(()=>{const R=r?.map(De=>({...De,disabled:F.has(De.urn)})),P=xt(M,G.current,!1,w.map,F),z=kt(P,{...t,constraintsMap:G.current},i,w.map),te=Ve(P),_e=Vc(z,r?.map(De=>De.urn)??[],r,w.map,P),be=(r?.map(De=>De.urn)??[]).filter(De=>!_e.has(De));for(const De of be){const Ye=P.get(De);Ye&&P.set(De,Ye.map(Ke=>!Ke.isTimeDimension&&Ke.dimensionValues?.length&&!Ke.dimensionValues.some(rt=>rt.isSelectedValue)?{...Ke,isExcluded:!0}:Ke))}a?.(te,G.current,R?.filter(De=>_e.has(De.urn)||De.disabled),P,z),_(z),b(j.PopUpState.Closed),N(!0),f.startTransition(()=>{ze(P)})},[Ve,M,t,i,w.map,a,r,F,ze,b,N]),V=R=>{H(R)},B=f.useMemo(()=>r?.map(R=>{const P=t?.structuresMap?.get(R.urn)?.dataflows?.[0],z=D.getLocalizedName(P,i??""),te=z?D.generateShortUrn(z,"",P?.agencyID):void 0;return te?{...R,title:te}:R}),[r,t?.structuresMap,i]),ee=$||Z||Xe;return o.jsxs("div",{className:"filters-container",children:[o.jsx(lu,{buttonProps:n,selectedFiltersCount:Gr(k),isLoading:$,setModalState:b,isModalClosed:y,warningIcon:g?.warningIcon,filterIconClassName:x}),o.jsx(o.Fragment,{children:C===j.PopUpState.Opened&&o.jsxs(j.Popup,{heading:v?.settings||"Settings",portalId:"filters",size:j.PopUpSize.LG,containerClassName:"advanced-view-filters-modal h-[80%]",dividers:s?.isShowDividers,onClose:ie,closeButtonTitle:v?.close||"Close",children:[o.jsx(nu,{locale:i,timeRangeOptions:c,filtersList:M,selectedFilter:E,isDisableValues:Z,isValuesLoading:ge,modalProps:s,initialConstraintsMap:t?.constraintsMap,datasetIcon:l,structuresMap:t?.structuresMap,setSelectedFilter:T,onSelectDisplayMode:Ge,onDeleteFilter:ot,onClearAllFilters:le,updateSelectedFilterValues:Ee,onTimePeriodChange:V,selectedTimeOption:L,hierarchyStateMap:pe,onSelectHierarchy:ye,onExpandHierarchyNode:ce,dataQueries:B,disabledDatasetUrns:F,onToggleDataset:ve,onClearAllDatasets:X}),o.jsx(ru,{onApply:Le,onClose:ie,onClearAllFilters:le,modalProps:s,applyDisabled:ee,limitMessages:g})]})})]})},fv=({filtersProps:e,actions:t,attachments:n,attachmentsDataQuery:s,dataQueries:r,dimensions:a,locale:i,isDataLoading:c,setIsFiltering:l,filters:d,onFiltersChange:u})=>{const{titles:h,limitMessages:m}=Me(),p={getConstraints:t.getConstraints,getAvailableHierarchies:e.actions?.getAvailableHierarchies,getHierarchy:e.actions?.getHierarchy},{isCrossDatasetModeOn:g}=Ue();return f.useEffect(()=>{c||l?.(!1)},[c,l]),o.jsx("div",{className:"h-full min-h-0 rounded bg-white",children:o.jsxs("div",{className:"flex h-full flex-col gap-4 overflow-x-hidden",children:[o.jsxs("div",{className:"data-details-header flex items-center justify-between",children:[o.jsx("h2",{children:h?.content??"Content"}),g?o.jsx(dv,{attachmentsDataQuery:s,dataQueries:r,updateDataQueries:t?.updateDataQueries,locale:i,actions:p,dimensions:a,...e,onFiltersChange:u,limitMessages:m}):o.jsx(Xm,{attachmentsDataQuery:s,dataQueries:r,updateDataQueries:t?.updateDataQueries,locale:i,actions:p,dimensions:a,...e,onFiltersChange:u,limitMessages:m})]}),o.jsx("div",{className:"advanced-view-attachments-container min-h-0 flex-1",children:o.jsx(uv,{attachments:n,currentDataQuery:s,dataQueries:r,dimensions:a,actions:t,isShowAttachments:!0,isDataSetAttachments:!0,isDataLoading:c,locale:i,filters:d})})]})})},hv=({isShowAgency:e,isShowDatasetBadge:t,dataset:n,data:s,structures:r,metadataSettings:a,locale:i,getDatasetUpdatedTime:c,externalLink:l,datasetIcon:d,externalLinkIcon:u,metadataButtonClassName:h,metadataIconClassName:m,infoSegmentContainerClassName:p,infoSegmentHeaderClassName:g,nameAndMetadataContainerClassName:x})=>{const{titles:v}=Me(),w="dataset-metadata-side-panel",[C,b]=f.useState(""),[y,N]=f.useState(!1),M=f.useRef(null),[A,S]=f.useState(""),[_,E]=f.useState(""),[T,k]=f.useState(!1),{onboardingFileSchema:I,isShowOnboarding:L}=Ze(),{isOpenedAdvancedView:H}=qe(),G=wt(),{isMetadataInSidePanel:Y}=Ue(),[O,$]=f.useState(!1),K=f.useMemo(()=>a?.isMetadataDescription?Yp(n,C,i,v):[],[n,C,i,a?.isMetadataDescription,v]),Z=f.useMemo(()=>[...a?.isMetadataDescription?[]:[Wt(n,i,v)],...Iu(_u(s),D.getStructureComponentsMap(r),i)],[s,n,i,a?.isMetadataDescription,r,v]),se=f.useMemo(()=>$t(n,C,i,v),[n,C,i,v]),ge=f.useCallback(()=>{if(Y&&G){G.openPanel({id:w,scope:H?"advanced":"conversation",title:"Dataset Metadata",bodyClassName:"overflow-hidden",content:o.jsx(zt,{locale:i,metadata:Z,metadataDescription:K,datasetInfo:se,externalLink:l})}),$(!0);return}N(!0)},[K,Z,se,l,Y,H,i,G]),he=f.useCallback(()=>{N(!1),$(!0)},[]);f.useEffect(()=>{const J=c&&c(Z)||Kt(D.getLastUpdatedTime(n),i);b(J)},[n,i,Z,c]),f.useEffect(()=>{if(L){const{title:F,description:J}=mt(Fe.METADATA_PER_DATASET,v);S(F),E(J)}},[v,L]),f.useEffect(()=>{L&&k(I?.lastDisplayedElement===Fe.METADATA_PER_DATASET)},[I?.lastDisplayedElement,L]);const xe=(F,J)=>o.jsxs("div",{className:nt("flex gap-1 text-neutrals-1000",p),children:[o.jsxs("span",{className:nt("text-neutral-800",g),children:[F,":"]}),o.jsx("span",{children:J})]});return o.jsxs("div",{className:"dataset-info flex flex-col gap-3 bg-white",children:[t&&o.jsxs("div",{className:"bg-accent-500 body-2 flex w-fit items-center gap-1 rounded-[20px] px-2 py-1",children:[d,v?.dataset??"Dataset"]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsxs("div",{role:"heading","aria-level":4,className:nt("flex gap-1 items-center h4",x),children:[o.jsx("div",{ref:M,children:o.jsx(j.IconButton,{title:v?.metadata??"View details",buttonClassName:nt("!text-neutrals-1000 !border-none !w-4 !h-4 !p-0 shrink-0",h),icon:o.jsx(Tu,{className:nt("size-4",m)}),onClick:ge})}),o.jsx("span",{children:D.getLocalizedName(n,i)})]}),l&&o.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",children:u||o.jsx(He.IconExternalLink,{className:"size-4 shrink-0 cursor-pointer text-primary"})})]}),o.jsxs("div",{className:"body-3 flex items-center gap-2",children:[e&&o.jsxs(o.Fragment,{children:[xe(v?.agency??"Agency",n?.agencyID??""),o.jsx("div",{"aria-hidden":"true",className:"h-[14px] border-l border-l-neutral-500"})]}),xe(v?.lastUpdated??"Last updated",C)]})]}),T&&o.jsx(pt,{reference:M,title:A,description:_,onReferenceClick:ge,shouldCloseTooltip:O}),y&&o.jsx(Xr,{locale:i,metadata:Z,metadataDescription:K,isOpenMetadata:y,onCloseMetadata:he})]})},mv=({locale:e,isShowShare:t,shareConversationProps:n,conversation:s})=>{const{titles:r}=Me(),{setIsOpenedAdvancedView:a}=qe(),i=f.useRef(null),[c,l]=f.useState(""),[d,u]=f.useState(""),[h,m]=f.useState(!1),{onboardingFileSchema:p,isShowOnboarding:g}=Ze();return f.useEffect(()=>{if(g){const{title:x,description:v}=mt(Fe.EXIT_ADVANCED_VIEW,r);l(x),u(v)}},[r,g]),f.useEffect(()=>{g&&m(p?.lastDisplayedElement===Fe.EXIT_ADVANCED_VIEW)},[p?.lastDisplayedElement,g]),o.jsxs("header",{className:W("bg-white px-6 py-4 flex justify-between items-center sm:px-0","advanced-view-header"),children:[o.jsxs("div",{className:W("flex gap-3 items-center",!t&&"justify-between w-full","advanced-view-header-title"),children:[o.jsx("div",{ref:i,className:W(!t&&"order-2","flex"),children:o.jsx(j.CloseButton,{btnClassNames:"button-close",onClick:()=>a(!1),title:r?.close||"Close"})}),h&&o.jsx(pt,{reference:i,title:c,description:d,onReferenceClick:()=>a(!1),shouldMoveToNextStep:!0}),o.jsx("h2",{children:r?.advanceViewTitle??"Advanced view"})]}),t&&o.jsx(zl,{locale:e,conversation:s,...n})]})};function pv(e,t,n,s,r,a,i,c,l){const d=gv(e,n),u=l?.startPeriod&&l.endPeriod?D.getAdditionalColumns(c,l):[],h=vv(e,t,n,s,r,a,u);return[Rp(e,t?.data,n,r,a,i),...d,...h,Du(e,t?.data,n,void 0,a,i)]}function gv(e,t){const n=e.conceptSchemes||[],s=e.codelists||[],r=D.getDimensions(e)?.dimensions||[];return r.map(a=>{const{codeList:i,concept:c}=_n(a,n,s),l=d=>{const{data:u,colDef:h}=d,m=h.field;return sa(r,m,i,u,t)};return{headerName:D.getLocalizedName(c,t),field:a.id,colId:a.id,valueGetter:l,...St,tooltipValueGetter:d=>d.value}})}function vv(e,t,n,s,r,a,i){const c=bv(i,D.getTimePeriods(t));return wv(c,(d,u)=>Cv(d,u||d,s,a),e,n,r,a)}const Cv=(e,t,n=ne.defaultFormatNumbers,s)=>({headerName:lc(t,s),colId:e,field:e,type:"numericColumn",suppressColumnsToolPanel:!0,sortable:!1,width:Et,cellClass:["justify-end","cell-with-meta"],valueFormatter:r=>ne.formatNumberBySign(r.value,n)}),wv=(e,t,n,s,r,a)=>{const i=[];return e.sort((l,d)=>D.sortPeriods(l,d)).forEach(l=>{i.push({headerName:l.toString(),field:l.toString(),...t(l.toString()),valueGetter:d=>d.data[d.column.getColId()]?.value?.[0]?.value||null,cellClass:Ct,cellRenderer:En,width:Et,cellRendererParams:{dataSetData:n,locale:s,metadataSettings:r,titles:a}})}),i},bv=(e=[],t=[])=>{if(!e.length)return t;if(!t.length)return e;const n=t.some(d=>D.isYearly(d)),s=t.some(d=>D.isSemiAnnually(d)),r=t.some(d=>D.isQuarterly(d)),a=t.some(d=>D.isMonthly(d)),i=t.some(d=>D.isWeekly(d)),c=t.some(d=>D.isDaily(d)),l=e.filter(d=>D.isYearly(d)?n:D.isSemiAnnually(d)?s:D.isQuarterly(d)?r:D.isMonthly(d)?a:D.isWeekly(d)?i:D.isDaily(d)?c:!0);return Array.from(new Set([...l,...t]))};function xv(e,t,n){const s=t.map(a=>a.id).filter(a=>a!=null),r=n.map(a=>a.id).filter(a=>a!=null);return yv(e,s,r,s)}const yv=(e,t,n,s)=>{const r={};for(const a of e){const i=Tv(a,t),c=Sv(i,s);let l=r[c];if(l==null){l={},r[c]=l;for(const u of s)l[u]=i[u]}const d=gl(a.attributes);if(vl(l,c,d,a),!a.values.length){ml(l,i,n);continue}for(const u of a.values){const h=gl(u.obsAttributes);vl(l,c,d,a),ml(l,i,n,u.dimensionAtObservation,Mv(a,u),h)}}return Object.values(r)},Sv=(e,t)=>t.map(n=>e[n]).join("_"),Dv=(e,t,n)=>t.map(s=>s==="TIME_PERIOD"?n:e[s]).join("_"),ml=(e,t,n,s,r,a)=>{const i=Dv(t,n,s);e[i]={value:r,obsAttributes:a}},Tv=(e,t)=>{const n={},s=e.name.split(".");for(let r=0;r<t.length;r+=1)n[t[r]]=s[r];return n},Mv=(e,t)=>{const n=pl(e.attributes);if(n)return[n];const s=pl(t.obsAttributes);return s?[s]:t.values},pl=(e=[])=>e.find(({name:t})=>t==="OBS_VALUE"),gl=(e=[])=>e.filter(({value:t})=>t),vl=(e,t,n,s)=>{e.attributes??=n,e.id=t,e.originalData=s},Av="#EEEEEE",Ev="#777777";function Nv(e,t,n){const s={animation:!1,tooltip:{trigger:"axis",appendToBody:!0,formatter:r=>{let a=r[0].axisValueLabel+"<br/>";return r.forEach(i=>{i.value!==null&&i.value!==void 0&&(a+=i.marker+" "+i.seriesName+": "+i.value+"<br/>")}),a}},legend:{bottom:0},grid:{left:"3%",right:"3%",bottom:"40px",containLabel:!0},xAxis:{...Cl(n?.ticksColor,n?.labelsColor),type:"category",boundaryGap:!1,data:e},yAxis:{...Cl(n?.ticksColor,n?.labelsColor),type:"value"},series:t};return n?.colors!=null&&(s.color=n.colors),s}function Cl(e=Av,t=Ev){return{splitLine:{show:!0,showMaxLine:!1,lineStyle:{color:[e]}},axisTick:{show:!1},axisLabel:{color:t},axisLine:{lineStyle:{color:e}}}}function Zu(e,t,n,s){return t.map(a=>{const i=D.getDimensions(n)?.dimensions||[],c=i?.find(d=>d.id===a);if(c==null)return e[a]||"";const{codeList:l}=_n(c,n.conceptSchemes||[],n.codelists||[]);return sa(i,a,l,e,s)}).join(" - ")}function jv(e,t){const n=[...t?.metadata?.indicatorDimensions||[]].filter(a=>a!=null),r=D.getDimensions(e)?.dimensions?.filter(a=>a.id!=null&&!n.includes(a.id)&&t?.metadata?.countryDimension!==a.id).map(a=>a.id).filter(a=>a!=null)||[];return[...n,...r]}function kv(e,t,n){const s={};return e.forEach(r=>{const a=_v(r,t,n);s[a]||(s[a]={rows:[]}),s[a].rows.push(r)}),Object.keys(s).map(r=>s[r])}function _v(e,t,n){const s=n.dataStructures?.[0]?.dataStructureComponents?.dimensionList?.dimensions||[];return t.map(a=>s?.find(c=>c.id===a)==null?e[a]||"":Wu(s,a,e)).join(" - ")}function Iv(e,t){const n={};return e.forEach(s=>n[s]=Rv(s,t)),{nonUniqDimensions:e.filter(s=>!n[s])}}function Rv(e,t){const n=t.map(r=>Pv(e,r));return new Set(n).size===1}function Pv(e,t){return t[e]}const Lv="line",tn=10,Ov=2;function Fv(e){return typeof e=="number"?Number.isFinite(e):typeof e=="string"&&e.trim()!==""?Number.isFinite(Number(e)):!1}function Xu(e){const t=(e.groups??[]).flatMap(n=>n.units);return[...e.units,...t].some(n=>n.isPlottable)}function Qu(e,t,n,s,r){const a=aa(t,e,n,s,r,{includeChartData:!1}),c=D.getTimePeriods(t).sort((h,m)=>D.sortPeriods(h,m)),l=jv(e,n),{nonUniqDimensions:d}=Iv(l,a);return{units:kv(a,d,e).map(h=>ed(h,e,n,c,s,r))}}function Vv(e,t,n,s,r){let a;return()=>(a??=Qu(e,t,n,s,r),a)}function Hv(e,t,n,s,r,a){return ed({rows:[e]},n,s,t,r,a)}function ed(e,t,n,s,r,a){const i=zv(e.rows,t,n,r),c=i?.find(u=>D.FREQUENCY_DIMENSION_ID.includes(u?.id))?.id,l=Gv(s,e?.rows?.[0],c),d=Bv(e.rows.length>tn?e.rows.slice(0,tn):e.rows,t,n,r,l);return{rows:e.rows,limitedByRowsAmountTo:e.rows.length>tn?tn:void 0,dimensions:i,config:Nv(l,d,a),isPlottable:Uv(d)}}function Uv(e){return e.some(t=>t.data.filter(Fv).length>=Ov)}function Gv(e,t,n){if(n){const s=t?.[n];if(s===D.Periods.MONTHLY)return e?.filter(r=>D.isMonthly(r));if(s===D.Periods.QUARTERLY)return e?.filter(r=>D.isQuarterly(r));if(s===D.Periods.ANNUAL)return e?.filter(r=>D.isYearly(r))}return e}function Bv(e,t,n,s,r){return e.map(a=>({name:n?.metadata?.countryDimension==null?"":Zu(a,[n?.metadata?.countryDimension],t,s),type:Lv,data:r.map(i=>qv(i,a))}))}function qv(e,t){return t[e]?.value?.[0]?.value||null}function zv(e,t,n,s){const r=n?.metadata?.countryDimension;return(D.getDimensions(t)?.dimensions||[]).map(a=>{if(!(a.id==null||a.id===r))return{id:a.id,title:Wv(a,t,s),value:Zu(e[0],[a.id],t,s)}}).filter(a=>a!=null)}function Wv(e,t,n){const s=t.conceptSchemes||[],r=t.codelists||[],{concept:a}=_n(e,s,r);return D.getLocalizedName(a,n)||e.id}function aa(e,t,n,s,r,a={}){const i=e==null?[]:D.getParsedResponse(e),c=D.getDimensions(t)?.dimensions||[],l=D.getDimensions(t)?.timeDimensions||[],d=xv(i,c,l);return a.includeChartData===!1?d:$v(d,e,t,n,s,r)}function $v(e,t,n,s,r,a){const c=D.getTimePeriods(t).sort((l,d)=>D.sortPeriods(l,d));return e.map(l=>({...l,[Ut]:()=>Hv(l,c,n,s,r,a)}))}function Kv(e,t,n,s,r,a,i,c,l,d,u){return{columns:pv(e,t,s,r,a,c,l,d,u),data:aa(t,e,n,s,i)}}function Jv(e,t,n,s,r,a,i,c,l,d,u){const h=e.dataflows?.[0]?.names?.[s],m=Kv(e,t,n,s,r,a,i,c,l,d,u);return{title:h||c?.dataGrid||"Data Grid",grid_data:m}}function Yv(e){const t=e.replace(/\r\n/g,`
5
+ `).map(s=>s.replace(Dd," ").trim()).filter(Boolean)[0]??"";return(t.length>Ka?t.substring(0,Ka):t).trim()},Ad=(e,t,n,s,r,a)=>{const i=`${e}/${t}`;return{name:n,folderId:i,prompt:r,id:ve.generateConversationId({folderId:i,name:n}),messages:[{role:Pe.Role.Assistant,content:s}],custom_fields:{configuration:{choice:a}}}},_l=f.createContext(null);function Cn({children:e,styles:t}){return o.jsx(_l.Provider,{value:t??{},children:e})}function De(){const e=f.useContext(_l);if(!e)throw new Error("useConversationViewStyles must be used within ConversationViewStylesProvider");return e}var Ed=Object.defineProperty,dn=Object.getOwnPropertySymbols,Il=Object.prototype.hasOwnProperty,Rl=Object.prototype.propertyIsEnumerable,Ja=(e,t,n)=>t in e?Ed(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Dr=(e,t)=>{for(var n in t||(t={}))Il.call(t,n)&&Ja(e,n,t[n]);if(dn)for(var n of dn(t))Rl.call(t,n)&&Ja(e,n,t[n]);return e},Tr=(e,t)=>{var n={};for(var s in e)Il.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&dn)for(var s of dn(e))t.indexOf(s)<0&&Rl.call(e,s)&&(n[s]=e[s]);return n};var yt;(e=>{const t=class ye{constructor(l,d,u,h){if(this.version=l,this.errorCorrectionLevel=d,this.modules=[],this.isFunction=[],l<ye.MIN_VERSION||l>ye.MAX_VERSION)throw new RangeError("Version value out of range");if(h<-1||h>7)throw new RangeError("Mask value out of range");this.size=l*4+17;let m=[];for(let g=0;g<this.size;g++)m.push(!1);for(let g=0;g<this.size;g++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const p=this.addEccAndInterleave(u);if(this.drawCodewords(p),h==-1){let g=1e9;for(let x=0;x<8;x++){this.applyMask(x),this.drawFormatBits(x);const v=this.getPenaltyScore();v<g&&(h=x,g=v),this.applyMask(x)}}r(0<=h&&h<=7),this.mask=h,this.applyMask(h),this.drawFormatBits(h),this.isFunction=[]}static encodeText(l,d){const u=e.QrSegment.makeSegments(l);return ye.encodeSegments(u,d)}static encodeBinary(l,d){const u=e.QrSegment.makeBytes(l);return ye.encodeSegments([u],d)}static encodeSegments(l,d,u=1,h=40,m=-1,p=!0){if(!(ye.MIN_VERSION<=u&&u<=h&&h<=ye.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let g,x;for(g=u;;g++){const b=ye.getNumDataCodewords(g,d)*8,y=i.getTotalBits(l,g);if(y<=b){x=y;break}if(g>=h)throw new RangeError("Data too long")}for(const b of[ye.Ecc.MEDIUM,ye.Ecc.QUARTILE,ye.Ecc.HIGH])p&&x<=ye.getNumDataCodewords(g,b)*8&&(d=b);let v=[];for(const b of l){n(b.mode.modeBits,4,v),n(b.numChars,b.mode.numCharCountBits(g),v);for(const y of b.getData())v.push(y)}r(v.length==x);const w=ye.getNumDataCodewords(g,d)*8;r(v.length<=w),n(0,Math.min(4,w-v.length),v),n(0,(8-v.length%8)%8,v),r(v.length%8==0);for(let b=236;v.length<w;b^=253)n(b,8,v);let C=[];for(;C.length*8<v.length;)C.push(0);return v.forEach((b,y)=>C[y>>>3]|=b<<7-(y&7)),new ye(g,d,C,m)}getModule(l,d){return 0<=l&&l<this.size&&0<=d&&d<this.size&&this.modules[d][l]}getModules(){return this.modules}drawFunctionPatterns(){for(let u=0;u<this.size;u++)this.setFunctionModule(6,u,u%2==0),this.setFunctionModule(u,6,u%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const l=this.getAlignmentPatternPositions(),d=l.length;for(let u=0;u<d;u++)for(let h=0;h<d;h++)u==0&&h==0||u==0&&h==d-1||u==d-1&&h==0||this.drawAlignmentPattern(l[u],l[h]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(l){const d=this.errorCorrectionLevel.formatBits<<3|l;let u=d;for(let m=0;m<10;m++)u=u<<1^(u>>>9)*1335;const h=(d<<10|u)^21522;r(h>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,s(h,m));this.setFunctionModule(8,7,s(h,6)),this.setFunctionModule(8,8,s(h,7)),this.setFunctionModule(7,8,s(h,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,s(h,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,s(h,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,s(h,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let l=this.version;for(let u=0;u<12;u++)l=l<<1^(l>>>11)*7973;const d=this.version<<12|l;r(d>>>18==0);for(let u=0;u<18;u++){const h=s(d,u),m=this.size-11+u%3,p=Math.floor(u/3);this.setFunctionModule(m,p,h),this.setFunctionModule(p,m,h)}}drawFinderPattern(l,d){for(let u=-4;u<=4;u++)for(let h=-4;h<=4;h++){const m=Math.max(Math.abs(h),Math.abs(u)),p=l+h,g=d+u;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,m!=2&&m!=4)}}drawAlignmentPattern(l,d){for(let u=-2;u<=2;u++)for(let h=-2;h<=2;h++)this.setFunctionModule(l+h,d+u,Math.max(Math.abs(h),Math.abs(u))!=1)}setFunctionModule(l,d,u){this.modules[d][l]=u,this.isFunction[d][l]=!0}addEccAndInterleave(l){const d=this.version,u=this.errorCorrectionLevel;if(l.length!=ye.getNumDataCodewords(d,u))throw new RangeError("Invalid argument");const h=ye.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][d],m=ye.ECC_CODEWORDS_PER_BLOCK[u.ordinal][d],p=Math.floor(ye.getNumRawDataModules(d)/8),g=h-p%h,x=Math.floor(p/h);let v=[];const w=ye.reedSolomonComputeDivisor(m);for(let b=0,y=0;b<h;b++){let N=l.slice(y,y+x-m+(b<g?0:1));y+=N.length;const E=ye.reedSolomonComputeRemainder(N,w);b<g&&N.push(0),v.push(N.concat(E))}let C=[];for(let b=0;b<v[0].length;b++)v.forEach((y,N)=>{(b!=x-m||N>=g)&&C.push(y[b])});return r(C.length==p),C}drawCodewords(l){if(l.length!=Math.floor(ye.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let d=0;for(let u=this.size-1;u>=1;u-=2){u==6&&(u=5);for(let h=0;h<this.size;h++)for(let m=0;m<2;m++){const p=u-m,x=(u+1&2)==0?this.size-1-h:h;!this.isFunction[x][p]&&d<l.length*8&&(this.modules[x][p]=s(l[d>>>3],7-(d&7)),d++)}}r(d==l.length*8)}applyMask(l){if(l<0||l>7)throw new RangeError("Mask value out of range");for(let d=0;d<this.size;d++)for(let u=0;u<this.size;u++){let h;switch(l){case 0:h=(u+d)%2==0;break;case 1:h=d%2==0;break;case 2:h=u%3==0;break;case 3:h=(u+d)%3==0;break;case 4:h=(Math.floor(u/3)+Math.floor(d/2))%2==0;break;case 5:h=u*d%2+u*d%3==0;break;case 6:h=(u*d%2+u*d%3)%2==0;break;case 7:h=((u+d)%2+u*d%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[d][u]&&h&&(this.modules[d][u]=!this.modules[d][u])}}getPenaltyScore(){let l=0;for(let m=0;m<this.size;m++){let p=!1,g=0,x=[0,0,0,0,0,0,0];for(let v=0;v<this.size;v++)this.modules[m][v]==p?(g++,g==5?l+=ye.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,x),p||(l+=this.finderPenaltyCountPatterns(x)*ye.PENALTY_N3),p=this.modules[m][v],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,x)*ye.PENALTY_N3}for(let m=0;m<this.size;m++){let p=!1,g=0,x=[0,0,0,0,0,0,0];for(let v=0;v<this.size;v++)this.modules[v][m]==p?(g++,g==5?l+=ye.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,x),p||(l+=this.finderPenaltyCountPatterns(x)*ye.PENALTY_N3),p=this.modules[v][m],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,x)*ye.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let p=0;p<this.size-1;p++){const g=this.modules[m][p];g==this.modules[m][p+1]&&g==this.modules[m+1][p]&&g==this.modules[m+1][p+1]&&(l+=ye.PENALTY_N2)}let d=0;for(const m of this.modules)d=m.reduce((p,g)=>p+(g?1:0),d);const u=this.size*this.size,h=Math.ceil(Math.abs(d*20-u*10)/u)-1;return r(0<=h&&h<=9),l+=h*ye.PENALTY_N4,r(0<=l&&l<=2568888),l}getAlignmentPatternPositions(){if(this.version==1)return[];{const l=Math.floor(this.version/7)+2,d=this.version==32?26:Math.ceil((this.version*4+4)/(l*2-2))*2;let u=[6];for(let h=this.size-7;u.length<l;h-=d)u.splice(1,0,h);return u}}static getNumRawDataModules(l){if(l<ye.MIN_VERSION||l>ye.MAX_VERSION)throw new RangeError("Version number out of range");let d=(16*l+128)*l+64;if(l>=2){const u=Math.floor(l/7)+2;d-=(25*u-10)*u-55,l>=7&&(d-=36)}return r(208<=d&&d<=29648),d}static getNumDataCodewords(l,d){return Math.floor(ye.getNumRawDataModules(l)/8)-ye.ECC_CODEWORDS_PER_BLOCK[d.ordinal][l]*ye.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][l]}static reedSolomonComputeDivisor(l){if(l<1||l>255)throw new RangeError("Degree out of range");let d=[];for(let h=0;h<l-1;h++)d.push(0);d.push(1);let u=1;for(let h=0;h<l;h++){for(let m=0;m<d.length;m++)d[m]=ye.reedSolomonMultiply(d[m],u),m+1<d.length&&(d[m]^=d[m+1]);u=ye.reedSolomonMultiply(u,2)}return d}static reedSolomonComputeRemainder(l,d){let u=d.map(h=>0);for(const h of l){const m=h^u.shift();u.push(0),d.forEach((p,g)=>u[g]^=ye.reedSolomonMultiply(p,m))}return u}static reedSolomonMultiply(l,d){if(l>>>8||d>>>8)throw new RangeError("Byte out of range");let u=0;for(let h=7;h>=0;h--)u=u<<1^(u>>>7)*285,u^=(d>>>h&1)*l;return r(u>>>8==0),u}finderPenaltyCountPatterns(l){const d=l[1];r(d<=this.size*3);const u=d>0&&l[2]==d&&l[3]==d*3&&l[4]==d&&l[5]==d;return(u&&l[0]>=d*4&&l[6]>=d?1:0)+(u&&l[6]>=d*4&&l[0]>=d?1:0)}finderPenaltyTerminateAndCount(l,d,u){return l&&(this.finderPenaltyAddHistory(d,u),d=0),d+=this.size,this.finderPenaltyAddHistory(d,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(l,d){d[0]==0&&(l+=this.size),d.pop(),d.unshift(l)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(c,l,d){if(l<0||l>31||c>>>l)throw new RangeError("Value out of range");for(let u=l-1;u>=0;u--)d.push(c>>>u&1)}function s(c,l){return(c>>>l&1)!=0}function r(c){if(!c)throw new Error("Assertion error")}const a=class Ue{constructor(l,d,u){if(this.mode=l,this.numChars=d,this.bitData=u,d<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(l){let d=[];for(const u of l)n(u,8,d);return new Ue(Ue.Mode.BYTE,l.length,d)}static makeNumeric(l){if(!Ue.isNumeric(l))throw new RangeError("String contains non-numeric characters");let d=[];for(let u=0;u<l.length;){const h=Math.min(l.length-u,3);n(parseInt(l.substring(u,u+h),10),h*3+1,d),u+=h}return new Ue(Ue.Mode.NUMERIC,l.length,d)}static makeAlphanumeric(l){if(!Ue.isAlphanumeric(l))throw new RangeError("String contains unencodable characters in alphanumeric mode");let d=[],u;for(u=0;u+2<=l.length;u+=2){let h=Ue.ALPHANUMERIC_CHARSET.indexOf(l.charAt(u))*45;h+=Ue.ALPHANUMERIC_CHARSET.indexOf(l.charAt(u+1)),n(h,11,d)}return u<l.length&&n(Ue.ALPHANUMERIC_CHARSET.indexOf(l.charAt(u)),6,d),new Ue(Ue.Mode.ALPHANUMERIC,l.length,d)}static makeSegments(l){return l==""?[]:Ue.isNumeric(l)?[Ue.makeNumeric(l)]:Ue.isAlphanumeric(l)?[Ue.makeAlphanumeric(l)]:[Ue.makeBytes(Ue.toUtf8ByteArray(l))]}static makeEci(l){let d=[];if(l<0)throw new RangeError("ECI assignment value out of range");if(l<128)n(l,8,d);else if(l<16384)n(2,2,d),n(l,14,d);else if(l<1e6)n(6,3,d),n(l,21,d);else throw new RangeError("ECI assignment value out of range");return new Ue(Ue.Mode.ECI,0,d)}static isNumeric(l){return Ue.NUMERIC_REGEX.test(l)}static isAlphanumeric(l){return Ue.ALPHANUMERIC_REGEX.test(l)}getData(){return this.bitData.slice()}static getTotalBits(l,d){let u=0;for(const h of l){const m=h.mode.numCharCountBits(d);if(h.numChars>=1<<m)return 1/0;u+=4+m+h.bitData.length}return u}static toUtf8ByteArray(l){l=encodeURI(l);let d=[];for(let u=0;u<l.length;u++)l.charAt(u)!="%"?d.push(l.charCodeAt(u)):(d.push(parseInt(l.substring(u+1,u+3),16)),u+=2);return d}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let i=a;e.QrSegment=a})(yt||(yt={}));(e=>{(t=>{const n=class{constructor(r,a){this.ordinal=r,this.formatBits=a}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),t.Ecc=n})(e.QrCode||(e.QrCode={}))})(yt||(yt={}));(e=>{(t=>{const n=class{constructor(r,a){this.modeBits=r,this.numBitsCharCount=a}numCharCountBits(r){return this.numBitsCharCount[Math.floor((r+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),t.Mode=n})(e.QrSegment||(e.QrSegment={}))})(yt||(yt={}));var Tt=yt;var Nd={L:Tt.QrCode.Ecc.LOW,M:Tt.QrCode.Ecc.MEDIUM,Q:Tt.QrCode.Ecc.QUARTILE,H:Tt.QrCode.Ecc.HIGH},Pl=128,Ll="L",Ol="#FFFFFF",Fl="#000000",Vl=!1,Hl=1,jd=4,kd=0,_d=.1;function Ul(e,t=0){const n=[];return e.forEach(function(s,r){let a=null;s.forEach(function(i,c){if(!i&&a!==null){n.push(`M${a+t} ${r+t}h${c-a}v1H${a+t}z`),a=null;return}if(c===s.length-1){if(!i)return;a===null?n.push(`M${c+t},${r+t} h1v1H${c+t}z`):n.push(`M${a+t},${r+t} h${c+1-a}v1H${a+t}z`);return}i&&a===null&&(a=c)})}),n.join("")}function Gl(e,t){return e.slice().map((n,s)=>s<t.y||s>=t.y+t.h?n:n.map((r,a)=>a<t.x||a>=t.x+t.w?r:!1))}function Id(e,t,n,s){if(s==null)return null;const r=e.length+n*2,a=Math.floor(t*_d),i=r/t,c=(s.width||a)*i,l=(s.height||a)*i,d=s.x==null?e.length/2-c/2:s.x*i,u=s.y==null?e.length/2-l/2:s.y*i,h=s.opacity==null?1:s.opacity;let m=null;if(s.excavate){let g=Math.floor(d),x=Math.floor(u),v=Math.ceil(c+d-g),w=Math.ceil(l+u-x);m={x:g,y:x,w:v,h:w}}const p=s.crossOrigin;return{x:d,y:u,h:l,w:c,excavation:m,opacity:h,crossOrigin:p}}function Rd(e,t){return t!=null?Math.max(Math.floor(t),0):e?jd:kd}function Bl({value:e,level:t,minVersion:n,includeMargin:s,marginSize:r,imageSettings:a,size:i,boostLevel:c}){let l=f.useMemo(()=>{const g=(Array.isArray(e)?e:[e]).reduce((x,v)=>(x.push(...Tt.QrSegment.makeSegments(v)),x),[]);return Tt.QrCode.encodeSegments(g,Nd[t],n,void 0,void 0,c)},[e,t,n,c]);const{cells:d,margin:u,numCells:h,calculatedImageSettings:m}=f.useMemo(()=>{let p=l.getModules();const g=Rd(s,r),x=p.length+g*2,v=Id(p,i,g,a);return{cells:p,margin:g,numCells:x,calculatedImageSettings:v}},[l,i,a,s,r]);return{qrcode:l,margin:u,cells:d,numCells:h,calculatedImageSettings:m}}var Pd=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Ld=f.forwardRef(function(t,n){const s=t,{value:r,size:a=Pl,level:i=Ll,bgColor:c=Ol,fgColor:l=Fl,includeMargin:d=Vl,minVersion:u=Hl,boostLevel:h,marginSize:m,imageSettings:p}=s,x=Tr(s,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:v}=x,w=Tr(x,["style"]),C=p?.src,b=f.useRef(null),y=f.useRef(null),N=f.useCallback(L=>{b.current=L,typeof n=="function"?n(L):n&&(n.current=L)},[n]),[E,T]=f.useState(!1),{margin:S,cells:_,numCells:A,calculatedImageSettings:M}=Bl({value:r,level:i,minVersion:u,boostLevel:h,includeMargin:d,marginSize:m,imageSettings:p,size:a});f.useEffect(()=>{if(b.current!=null){const L=b.current,z=L.getContext("2d");if(!z)return;let U=_;const Z=y.current,O=M!=null&&Z!==null&&Z.complete&&Z.naturalHeight!==0&&Z.naturalWidth!==0;O&&M.excavation!=null&&(U=Gl(_,M.excavation));const K=window.devicePixelRatio||1;L.height=L.width=a*K;const J=a/A*K;z.scale(J,J),z.fillStyle=c,z.fillRect(0,0,A,A),z.fillStyle=l,Pd?z.fill(new Path2D(Ul(U,S))):_.forEach(function(X,Q){X.forEach(function(pe,we){pe&&z.fillRect(we+S,Q+S,1,1)})}),M&&(z.globalAlpha=M.opacity),O&&z.drawImage(Z,M.x+S,M.y+S,M.w,M.h)}}),f.useEffect(()=>{T(!1)},[C]);const k=Dr({height:a,width:a},v);let R=null;return C!=null&&(R=f.createElement("img",{src:C,key:C,style:{display:"none"},onLoad:()=>{T(!0)},ref:y,crossOrigin:M?.crossOrigin})),f.createElement(f.Fragment,null,f.createElement("canvas",Dr({style:k,height:a,width:a,ref:N,role:"img"},w)),R)});Ld.displayName="QRCodeCanvas";var zl=f.forwardRef(function(t,n){const s=t,{value:r,size:a=Pl,level:i=Ll,bgColor:c=Ol,fgColor:l=Fl,includeMargin:d=Vl,minVersion:u=Hl,boostLevel:h,title:m,marginSize:p,imageSettings:g}=s,x=Tr(s,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:v,cells:w,numCells:C,calculatedImageSettings:b}=Bl({value:r,level:i,minVersion:u,boostLevel:h,includeMargin:d,marginSize:p,imageSettings:g,size:a});let y=w,N=null;g!=null&&b!=null&&(b.excavation!=null&&(y=Gl(w,b.excavation)),N=f.createElement("image",{href:g.src,height:b.h,width:b.w,x:b.x+v,y:b.y+v,preserveAspectRatio:"none",opacity:b.opacity,crossOrigin:b.crossOrigin}));const E=Ul(y,v);return f.createElement("svg",Dr({height:a,width:a,viewBox:`0 0 ${C} ${C}`,ref:n,role:"img"},x),!!m&&f.createElement("title",null,m),f.createElement("path",{fill:c,d:`M0,0 h${C}v${C}H0z`,shapeRendering:"crispEdges"}),f.createElement("path",{fill:l,d:E,shapeRendering:"crispEdges"}),N)});zl.displayName="QRCodeSVG";const Od=(e,t)=>({invitationType:ve.InvitationType.LINK,resources:[{url:`conversations/${encodeURI(e)}`},...t]}),Fd=e=>{const t=e?.invitationLink?.split("/").at(-1)||"";return`/${ne.SHARE_CONVERSATION_ROUTE}/${t}`},Vd=(e,t)=>t?.find(n=>{const s=e?.id?.split("/")?.pop(),r=n?.url?.split("/")?.pop()||"";return r===s||decodeURI(r)===s}),Hd=e=>e?.messages?.filter(n=>!!n?.custom_content?.attachments)?.flatMap(n=>n?.custom_content?.attachments?.map(s=>({url:s?.url||""}))||[])?.filter(n=>!!n?.url)||[],Ud=({conversation:e,locale:t,onCloseModal:n,modalDividers:s,getConversation:r,generateConversationLink:a,chatExpiration:i,chatExpirationDays:c,close:l,chatWarning:d,shareLink:u,shareCopyLink:h,shareCopiedLink:m,shareDescription:p,shareRemoveAccessToUsers:g,chatName:x,getSharedConversations:v,revokeSharedConversations:w,baseUrl:C,id:b,clientSharedPage:y,clientSharedProp:N,shareAlertMessage:E})=>{const[T,S]=f.useState(null),[_,A]=f.useState(),[M,k]=f.useState(!1),[R,L]=f.useState(!1),[z,U]=f.useState(),Z=f.useRef(null),O=f.useRef(null),K=f.useMemo(()=>e?.id?decodeURI(e.id):b?.[0]&&b?.[1]&&t?decodeURI(`${b[0]}/${t}/${b[1]}`):null,[e?.id,b,t]),J=f.useMemo(()=>{if(!T)return"";const V=C||window.location.origin;if(C&&C!==window.location.origin&&y&&N){const W=T.split(`/${ne.SHARE_CONVERSATION_ROUTE}/`)?.[1];return`${V}/${y}?${N}=${W}`}return`${V}/${t}${T}`},[C,T,t,y,N]),X=f.useCallback(async V=>{const W=await v?.(ve.getSharedConversationsRequest(ve.ShareTarget.OTHERS));if(W)return Vd({id:V},W.resources)},[v]);f.useEffect(()=>{if(!K||Z.current===K)return;Z.current=K,k(!1),O.current?.abort();const V=new AbortController;return O.current=V,(async()=>{try{const ce=await r?.(K),fe=Od(K,Hd(ce)),de=await a?.(fe),Ne=await X(K);if(V.signal.aborted||!de)return;S(Fd(de)),A(Ne),k(!0)}catch(ce){if(V.signal.aborted)return;k(!1),console.error("Error sharing conversation",ce)}})(),()=>{V.abort(),Z.current=null}},[K,a,r,X]);const Q=f.useCallback(()=>{O.current?.abort(),Z.current=null,n(),S(null),k(!1),L(!1)},[n]),pe=f.useCallback(()=>{L(!0),navigator.clipboard.writeText(J||"")},[J]),we=async()=>{try{if(U(!0),_&&await w?.({resources:[_]}),K){const V=await X(K);O.current?.signal.aborted||A(V)}}catch(V){console.error("Error revoking shared conversation",V)}finally{O.current?.signal.aborted||U(!1)}},se=f.useCallback(()=>o.jsx(j.Button,{buttonClassName:R?"text-button-secondary":"text-button-primary",iconBefore:R?o.jsx(qe.IconCheck,{width:20,height:20}):o.jsx(qe.IconCopy,{width:20,height:20}),title:R?m??"Copied":h??"Copy link",disabled:R,onClick:pe}),[R,pe,m,h]);return o.jsxs(j.Popup,{heading:u??"Share link",portalId:"share",size:j.PopUpSize.SM,dividers:s,onClose:Q,closeButtonTitle:l??"Close",children:[M?o.jsxs("div",{className:"share flex flex-col gap-y-4 overflow-auto px-6 pb-6 sm:p-0",children:[E?o.jsx(j.InlineAlert,{type:j.InlineAlertType.Note,icon:o.jsx(qe.IconInfoCircle,{width:16,height:16}),children:E}):null,e?.name?o.jsxs("div",{className:"share-info flex w-full",children:[o.jsx("p",{className:"share-info-title body-1 mr-1 text-neutrals-800",children:x??"Chat name:"}),o.jsx("h3",{className:"min-w-0 flex-1 truncate",title:e?.name,children:e?.name})]}):null,o.jsxs("div",{className:"share-info flex",children:[o.jsx("p",{className:"share-info-title body-1 mr-1 text-neutrals-800",children:i??"Link expiration date:"}),o.jsxs("h3",{children:["3 ",c??"days"]})]}),o.jsx(zl,{className:"min-h-[200px] self-center rounded border border-neutrals-600 p-2",value:J,size:200}),o.jsx("p",{className:"body-2 text-neutrals-1000",children:p??"Your name, special instructions, and any messages you add after sharing remain confidential."}),o.jsx(j.InputWithIcon,{containerClasses:"share-input-container",cssClass:"share-input",readonly:!0,placeholder:J,value:J,inputId:"conversationLink",iconAfterInput:se()})]}):o.jsx("div",{className:"flex items-center justify-center p-6",children:o.jsx(j.Loader,{})}),M?e&&_?o.jsx("div",{className:"remove-access",children:o.jsx(j.Button,{title:g??"Remove access to all users",buttonClassName:"remove-access-button py-3 px-4",isSmallButton:!0,disabled:z,onClick:we})}):o.jsx("p",{className:"body-2 share-footer text-neutrals-800",children:d??"This chat has not been shared with anyone yet."}):o.jsx("div",{})]})},ql=({shareButtonClass:e,shareIcon:t,...n})=>{const[s,r]=f.useState(j.PopUpState.Closed),a=()=>{r(j.PopUpState.Opened)},i=f.useCallback(()=>{r(j.PopUpState.Closed)},[]);return o.jsxs(o.Fragment,{children:[o.jsx(j.Button,{buttonClassName:e||"text-button-secondary",title:n?.share||"Share",iconBefore:t,onClick:a}),s===j.PopUpState.Opened&&o.jsx(Ud,{onCloseModal:i,...n})]})},Wl=({conversation:e,locale:t,isOpenedAdvancedView:n,isShowShareButton:s,shareConversationProps:r,rightSlot:a})=>o.jsx(o.Fragment,{children:o.jsxs("header",{className:$("bg-white border-b px-6 py-2 border-gray-200 flex justify-between items-center sm:hidden","conversation-view-header"),children:[o.jsx("span",{className:$("flex-1 min-w-0 truncate h4","conversation-view-header-text"),title:e?.name,children:e?.name}),o.jsxs("div",{className:"ml-3 flex items-center gap-4",children:[!n&&s&&o.jsx("div",{className:"flex gap-x-2",children:o.jsx(ql,{conversation:e,locale:t,...r})}),a]})]})}),$l=({content:e,textColorClass:t})=>{const{isOpenedAdvancedView:n}=$e();return o.jsx("div",{className:$("prose max-w-none break-words",n?"body-2":"body-1",t),children:o.jsx(yl,{remarkPlugins:[Sl],components:{strong:s=>o.jsx("strong",{className:t,...s}),a:({href:s,children:r,...a})=>o.jsx("a",{href:s,target:"_blank",rel:"noreferrer",...a,children:r})},children:e})})},Kl=({choiceButtons:e,disabled:t,onClick:n})=>{const s=$("flex w-full min-h-[72px] flex-col items-start justify-center rounded border px-4 py-2 text-left","border-hues-200 hover:bg-hues-100","disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent");return e.map(r=>o.jsx("div",{className:"mt-4",children:o.jsxs("button",{type:"button",className:s,disabled:t,onClick:()=>n(r[Pe.DialSchemaProperties.DialWidgetOptions]?.populateText,r?.const),"aria-label":"button",children:[o.jsx("h3",{className:"mb-1",children:r.title}),r.const!==vn.COMPLETE&&o.jsx("p",{className:"body-1 text-neutrals-800",children:r[Pe.DialSchemaProperties.DialWidgetOptions]?.populateText})]})},r.title))},Gd=({messageContent:e,choiceButtons:t,disabled:n,onClick:s,handleOnboardingSkip:r})=>{const{titles:a}=De();return o.jsxs("div",{className:"onboarding flex size-full flex-1 flex-col overflow-auto",children:[o.jsx(Wl,{conversation:{name:a?.onboardingTitle??"Introducing the AI assistant"}}),o.jsxs("div",{className:"onboarding-content flex flex-col",children:[o.jsx($l,{content:e}),o.jsx("div",{className:"mt-4",children:o.jsx(Kl,{choiceButtons:t,disabled:n,onClick:s})}),o.jsxs("div",{className:"mt-8 flex",children:[o.jsx(j.Button,{title:a?.skipOnboardingNow,buttonClassName:"text-button-secondary mr-4",disabled:n,onClick:()=>r?.(),isSmallButton:!0}),o.jsx(j.Button,{title:a?.refuseOnboarding,buttonClassName:"text-button-tertiary",disabled:n,onClick:()=>r?.(!0),isSmallButton:!0})]})]})]})},Jl=({openNewConversation:e})=>{const{titles:t}=De();return o.jsxs("div",{className:"body-3 bg-accent-300 p-2 text-center",children:[o.jsx("span",{className:"mr-2 text-neutrals-900",children:t?.onboardingFooter}),o.jsxs("span",{onClick:e,className:"inline-flex cursor-pointer align-top",children:[o.jsx(qe.IconPlus,{width:15,height:15}),o.jsx("p",{className:"ml-1",children:t?.onboardingFooterLink})]})]})},Yl=({firstLine:e,secondLine:t})=>{const n=e!=null&&e.trim()!=="",s=t!=null&&t.trim()!=="";return o.jsxs("div",{className:$("text-center body-3",s?"p-0":n?"p-1":"p-3"),children:[n&&o.jsx("div",{className:"text-neutrals-800",children:e}),s&&o.jsx("div",{className:"text-neutrals-800",children:t})]})},Bd=({suggestionsList:e,welcomeText:t,welcomeDescription:n,welcomeInputPlaceholder:s,titleIcon:r,actions:a,titles:i,inputMessageStyles:c,suggestionsContainerClass:l,isBottomInputPosition:d,prompt:u,onboardingMessageSchema:h,handleConversationClick:m,setConversations:p,locale:g,setSharedConversations:x})=>{const[v,w]=f.useState(null),[C,b]=f.useState(!0),[y,N]=f.useState(!1),{onboardingFileSchema:E,onboardingFileName:T,onboardingFilePath:S,isShowOnboarding:_,setIsShowOnboarding:A,setOnboardingFileSchema:M}=Xe(),{isAgentAvailable:k}=j.useAgentAvailability(),{statusMessages:R}=Lr();f.useEffect(()=>{(async()=>{try{const O=await a.getBucket();w(O.bucket)}catch(O){console.error(O instanceof Error?O.message:"Request error")}finally{b(!1)}})()},[a]);const L=f.useCallback(async(Z,O)=>{if(!v){console.error("No bucket");return}N(!0);try{const K=_?Ad(v,g,i?.onboardingTitle??"Introducing the AI assistant",h?.properties?.choice?.description??"",Z,O):Td(v,g,i.newChat??"New chat",Z),J=await a.createConversation(K,g,_),X=await a.getConversations(g),Q=await a.getSharedConversations(ve.getSharedConversationsRequest(ve.ShareTarget.ME));if(h&&E){const pe={...E,isStarted:!0};await a.putOnboardingFile?.(T,S,pe),M?.(pe)}p(ne.cleanConversationNames(X)),x(ne.cleanConversationNames(hd.transformSharedConversations(Q,g))),m(J.folderId,J.id)}catch(K){console.error(K instanceof Error?K.message:"Creation conversation failed"),N(!1)}},[a,v,m,_,g,T,S,E,h,p,M,x,i.newChat,i?.onboardingTitle]),z=f.useCallback(async Z=>{if(A(!1),Z&&E){const O={...E,isSkipped:!0};await a.putOnboardingFile?.(T,S,O),M?.(O)}},[a,T,S,E,A,M]);f.useEffect(()=>{u&&v&&L(u)},[v,u]);const U=()=>{const Z=!v;return k?o.jsxs(o.Fragment,{children:[o.jsx(kl,{containerClasses:$(c.inputContainerClass,d&&"order-3 mt-auto"),inputClasses:"mr-2",disabled:Z,placeholder:s||i?.askAnything||"Ask anything...",sendMessageIcon:c.sendMessageIcon,onSendMessage:L}),o.jsx("div",{className:$("no-scrollbar overflow-x-auto",l),children:o.jsx("div",{className:$("flex flex-wrap justify-center gap-2","tags-container"),children:e.map(O=>o.jsx(j.Tag,{title:O.title,text:O[Pe.DialSchemaProperties.DialWidgetOptions]?.populateText,disabled:Z,onClick:L},O.title))})})]}):o.jsx(j.InlineAlert,{type:j.InlineAlertType.Error,children:R.assistantUnavailable})};return o.jsx(Cn,{styles:{titles:i},children:o.jsxs("div",{className:"flex size-full flex-col",children:[y||u&&C?o.jsx(j.Loader,{}):_?o.jsx(Gd,{messageContent:h?.properties?.choice?.description||"",choiceButtons:h?.properties?.choice?.oneOf||[],disabled:!v,handleOnboardingSkip:z,onClick:L}):o.jsxs("div",{className:"flex h-full flex-col items-center justify-center sm:px-4",children:[o.jsxs("div",{className:$("flex items-center max-w-full sm-min:px-4",d?"mt-auto mb-8":n?"mb-0":"mb-6"),children:[r,o.jsx("h1",{className:"sm:h2 text-hues-800 text-center",children:t??i?.welcomeTitle??"How can I help you?"})]}),n&&o.jsx("p",{className:"body-1 text-neutrals-900 mb-6 mt-3 max-w-[784px] text-center",children:n}),U()]}),_&&o.jsx(Jl,{openNewConversation:()=>A(!1)}),!_&&o.jsx(Yl,{firstLine:i.footerFirstLine,secondLine:i.footerSecondLine})]})})};var en=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Or(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Vn,Ya;function zd(){if(Ya)return Vn;Ya=1;function e(){this.__data__=[],this.size=0}return Vn=e,Vn}var Hn,Za;function Zl(){if(Za)return Hn;Za=1;function e(t,n){return t===n||t!==t&&n!==n}return Hn=e,Hn}var Un,Xa;function wn(){if(Xa)return Un;Xa=1;var e=Zl();function t(n,s){for(var r=n.length;r--;)if(e(n[r][0],s))return r;return-1}return Un=t,Un}var Gn,Qa;function qd(){if(Qa)return Gn;Qa=1;var e=wn(),t=Array.prototype,n=t.splice;function s(r){var a=this.__data__,i=e(a,r);if(i<0)return!1;var c=a.length-1;return i==c?a.pop():n.call(a,i,1),--this.size,!0}return Gn=s,Gn}var Bn,ei;function Wd(){if(ei)return Bn;ei=1;var e=wn();function t(n){var s=this.__data__,r=e(s,n);return r<0?void 0:s[r][1]}return Bn=t,Bn}var zn,ti;function $d(){if(ti)return zn;ti=1;var e=wn();function t(n){return e(this.__data__,n)>-1}return zn=t,zn}var qn,ni;function Kd(){if(ni)return qn;ni=1;var e=wn();function t(n,s){var r=this.__data__,a=e(r,n);return a<0?(++this.size,r.push([n,s])):r[a][1]=s,this}return qn=t,qn}var Wn,si;function bn(){if(si)return Wn;si=1;var e=zd(),t=qd(),n=Wd(),s=$d(),r=Kd();function a(i){var c=-1,l=i==null?0:i.length;for(this.clear();++c<l;){var d=i[c];this.set(d[0],d[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=r,Wn=a,Wn}var $n,ri;function Jd(){if(ri)return $n;ri=1;var e=bn();function t(){this.__data__=new e,this.size=0}return $n=t,$n}var Kn,ai;function Yd(){if(ai)return Kn;ai=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return Kn=e,Kn}var Jn,ii;function Zd(){if(ii)return Jn;ii=1;function e(t){return this.__data__.get(t)}return Jn=e,Jn}var Yn,oi;function Xd(){if(oi)return Yn;oi=1;function e(t){return this.__data__.has(t)}return Yn=e,Yn}var Zn,li;function Xl(){if(li)return Zn;li=1;var e=typeof en=="object"&&en&&en.Object===Object&&en;return Zn=e,Zn}var Xn,ci;function ht(){if(ci)return Xn;ci=1;var e=Xl(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Xn=n,Xn}var Qn,ui;function Fr(){if(ui)return Qn;ui=1;var e=ht(),t=e.Symbol;return Qn=t,Qn}var es,di;function Qd(){if(di)return es;di=1;var e=Fr(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,r=e?e.toStringTag:void 0;function a(i){var c=n.call(i,r),l=i[r];try{i[r]=void 0;var d=!0}catch{}var u=s.call(i);return d&&(c?i[r]=l:delete i[r]),u}return es=a,es}var ts,fi;function ef(){if(fi)return ts;fi=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return ts=n,ts}var ns,hi;function xn(){if(hi)return ns;hi=1;var e=Fr(),t=Qd(),n=ef(),s="[object Null]",r="[object Undefined]",a=e?e.toStringTag:void 0;function i(c){return c==null?c===void 0?r:s:a&&a in Object(c)?t(c):n(c)}return ns=i,ns}var ss,mi;function Ql(){if(mi)return ss;mi=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return ss=e,ss}var rs,pi;function ec(){if(pi)return rs;pi=1;var e=xn(),t=Ql(),n="[object AsyncFunction]",s="[object Function]",r="[object GeneratorFunction]",a="[object Proxy]";function i(c){if(!t(c))return!1;var l=e(c);return l==s||l==r||l==n||l==a}return rs=i,rs}var as,gi;function tf(){if(gi)return as;gi=1;var e=ht(),t=e["__core-js_shared__"];return as=t,as}var is,vi;function nf(){if(vi)return is;vi=1;var e=tf(),t=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function n(s){return!!t&&t in s}return is=n,is}var os,Ci;function tc(){if(Ci)return os;Ci=1;var e=Function.prototype,t=e.toString;function n(s){if(s!=null){try{return t.call(s)}catch{}try{return s+""}catch{}}return""}return os=n,os}var ls,wi;function sf(){if(wi)return ls;wi=1;var e=ec(),t=nf(),n=Ql(),s=tc(),r=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,i=Function.prototype,c=Object.prototype,l=i.toString,d=c.hasOwnProperty,u=RegExp("^"+l.call(d).replace(r,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function h(m){if(!n(m)||t(m))return!1;var p=e(m)?u:a;return p.test(s(m))}return ls=h,ls}var cs,bi;function rf(){if(bi)return cs;bi=1;function e(t,n){return t?.[n]}return cs=e,cs}var us,xi;function Mt(){if(xi)return us;xi=1;var e=sf(),t=rf();function n(s,r){var a=t(s,r);return e(a)?a:void 0}return us=n,us}var ds,yi;function Vr(){if(yi)return ds;yi=1;var e=Mt(),t=ht(),n=e(t,"Map");return ds=n,ds}var fs,Si;function yn(){if(Si)return fs;Si=1;var e=Mt(),t=e(Object,"create");return fs=t,fs}var hs,Di;function af(){if(Di)return hs;Di=1;var e=yn();function t(){this.__data__=e?e(null):{},this.size=0}return hs=t,hs}var ms,Ti;function of(){if(Ti)return ms;Ti=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return ms=e,ms}var ps,Mi;function lf(){if(Mi)return ps;Mi=1;var e=yn(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function r(a){var i=this.__data__;if(e){var c=i[a];return c===t?void 0:c}return s.call(i,a)?i[a]:void 0}return ps=r,ps}var gs,Ai;function cf(){if(Ai)return gs;Ai=1;var e=yn(),t=Object.prototype,n=t.hasOwnProperty;function s(r){var a=this.__data__;return e?a[r]!==void 0:n.call(a,r)}return gs=s,gs}var vs,Ei;function uf(){if(Ei)return vs;Ei=1;var e=yn(),t="__lodash_hash_undefined__";function n(s,r){var a=this.__data__;return this.size+=this.has(s)?0:1,a[s]=e&&r===void 0?t:r,this}return vs=n,vs}var Cs,Ni;function df(){if(Ni)return Cs;Ni=1;var e=af(),t=of(),n=lf(),s=cf(),r=uf();function a(i){var c=-1,l=i==null?0:i.length;for(this.clear();++c<l;){var d=i[c];this.set(d[0],d[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=r,Cs=a,Cs}var ws,ji;function ff(){if(ji)return ws;ji=1;var e=df(),t=bn(),n=Vr();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return ws=s,ws}var bs,ki;function hf(){if(ki)return bs;ki=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return bs=e,bs}var xs,_i;function Sn(){if(_i)return xs;_i=1;var e=hf();function t(n,s){var r=n.__data__;return e(s)?r[typeof s=="string"?"string":"hash"]:r.map}return xs=t,xs}var ys,Ii;function mf(){if(Ii)return ys;Ii=1;var e=Sn();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return ys=t,ys}var Ss,Ri;function pf(){if(Ri)return Ss;Ri=1;var e=Sn();function t(n){return e(this,n).get(n)}return Ss=t,Ss}var Ds,Pi;function gf(){if(Pi)return Ds;Pi=1;var e=Sn();function t(n){return e(this,n).has(n)}return Ds=t,Ds}var Ts,Li;function vf(){if(Li)return Ts;Li=1;var e=Sn();function t(n,s){var r=e(this,n),a=r.size;return r.set(n,s),this.size+=r.size==a?0:1,this}return Ts=t,Ts}var Ms,Oi;function nc(){if(Oi)return Ms;Oi=1;var e=ff(),t=mf(),n=pf(),s=gf(),r=vf();function a(i){var c=-1,l=i==null?0:i.length;for(this.clear();++c<l;){var d=i[c];this.set(d[0],d[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=s,a.prototype.set=r,Ms=a,Ms}var As,Fi;function Cf(){if(Fi)return As;Fi=1;var e=bn(),t=Vr(),n=nc(),s=200;function r(a,i){var c=this.__data__;if(c instanceof e){var l=c.__data__;if(!t||l.length<s-1)return l.push([a,i]),this.size=++c.size,this;c=this.__data__=new n(l)}return c.set(a,i),this.size=c.size,this}return As=r,As}var Es,Vi;function wf(){if(Vi)return Es;Vi=1;var e=bn(),t=Jd(),n=Yd(),s=Zd(),r=Xd(),a=Cf();function i(c){var l=this.__data__=new e(c);this.size=l.size}return i.prototype.clear=t,i.prototype.delete=n,i.prototype.get=s,i.prototype.has=r,i.prototype.set=a,Es=i,Es}var Ns,Hi;function bf(){if(Hi)return Ns;Hi=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Ns=t,Ns}var js,Ui;function xf(){if(Ui)return js;Ui=1;function e(t){return this.__data__.has(t)}return js=e,js}var ks,Gi;function yf(){if(Gi)return ks;Gi=1;var e=nc(),t=bf(),n=xf();function s(r){var a=-1,i=r==null?0:r.length;for(this.__data__=new e;++a<i;)this.add(r[a])}return s.prototype.add=s.prototype.push=t,s.prototype.has=n,ks=s,ks}var _s,Bi;function Sf(){if(Bi)return _s;Bi=1;function e(t,n){for(var s=-1,r=t==null?0:t.length;++s<r;)if(n(t[s],s,t))return!0;return!1}return _s=e,_s}var Is,zi;function Df(){if(zi)return Is;zi=1;function e(t,n){return t.has(n)}return Is=e,Is}var Rs,qi;function sc(){if(qi)return Rs;qi=1;var e=yf(),t=Sf(),n=Df(),s=1,r=2;function a(i,c,l,d,u,h){var m=l&s,p=i.length,g=c.length;if(p!=g&&!(m&&g>p))return!1;var x=h.get(i),v=h.get(c);if(x&&v)return x==c&&v==i;var w=-1,C=!0,b=l&r?new e:void 0;for(h.set(i,c),h.set(c,i);++w<p;){var y=i[w],N=c[w];if(d)var E=m?d(N,y,w,c,i,h):d(y,N,w,i,c,h);if(E!==void 0){if(E)continue;C=!1;break}if(b){if(!t(c,function(T,S){if(!n(b,S)&&(y===T||u(y,T,l,d,h)))return b.push(S)})){C=!1;break}}else if(!(y===N||u(y,N,l,d,h))){C=!1;break}}return h.delete(i),h.delete(c),C}return Rs=a,Rs}var Ps,Wi;function Tf(){if(Wi)return Ps;Wi=1;var e=ht(),t=e.Uint8Array;return Ps=t,Ps}var Ls,$i;function Mf(){if($i)return Ls;$i=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(r,a){s[++n]=[a,r]}),s}return Ls=e,Ls}var Os,Ki;function Af(){if(Ki)return Os;Ki=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(r){s[++n]=r}),s}return Os=e,Os}var Fs,Ji;function Ef(){if(Ji)return Fs;Ji=1;var e=Fr(),t=Tf(),n=Zl(),s=sc(),r=Mf(),a=Af(),i=1,c=2,l="[object Boolean]",d="[object Date]",u="[object Error]",h="[object Map]",m="[object Number]",p="[object RegExp]",g="[object Set]",x="[object String]",v="[object Symbol]",w="[object ArrayBuffer]",C="[object DataView]",b=e?e.prototype:void 0,y=b?b.valueOf:void 0;function N(E,T,S,_,A,M,k){switch(S){case C:if(E.byteLength!=T.byteLength||E.byteOffset!=T.byteOffset)return!1;E=E.buffer,T=T.buffer;case w:return!(E.byteLength!=T.byteLength||!M(new t(E),new t(T)));case l:case d:case m:return n(+E,+T);case u:return E.name==T.name&&E.message==T.message;case p:case x:return E==T+"";case h:var R=r;case g:var L=_&i;if(R||(R=a),E.size!=T.size&&!L)return!1;var z=k.get(E);if(z)return z==T;_|=c,k.set(E,T);var U=s(R(E),R(T),_,A,M,k);return k.delete(E),U;case v:if(y)return y.call(E)==y.call(T)}return!1}return Fs=N,Fs}var Vs,Yi;function Nf(){if(Yi)return Vs;Yi=1;function e(t,n){for(var s=-1,r=n.length,a=t.length;++s<r;)t[a+s]=n[s];return t}return Vs=e,Vs}var Hs,Zi;function Hr(){if(Zi)return Hs;Zi=1;var e=Array.isArray;return Hs=e,Hs}var Us,Xi;function jf(){if(Xi)return Us;Xi=1;var e=Nf(),t=Hr();function n(s,r,a){var i=r(s);return t(s)?i:e(i,a(s))}return Us=n,Us}var Gs,Qi;function kf(){if(Qi)return Gs;Qi=1;function e(t,n){for(var s=-1,r=t==null?0:t.length,a=0,i=[];++s<r;){var c=t[s];n(c,s,t)&&(i[a++]=c)}return i}return Gs=e,Gs}var Bs,eo;function _f(){if(eo)return Bs;eo=1;function e(){return[]}return Bs=e,Bs}var zs,to;function If(){if(to)return zs;to=1;var e=kf(),t=_f(),n=Object.prototype,s=n.propertyIsEnumerable,r=Object.getOwnPropertySymbols,a=r?function(i){return i==null?[]:(i=Object(i),e(r(i),function(c){return s.call(i,c)}))}:t;return zs=a,zs}var qs,no;function Rf(){if(no)return qs;no=1;function e(t,n){for(var s=-1,r=Array(t);++s<t;)r[s]=n(s);return r}return qs=e,qs}var Ws,so;function Dn(){if(so)return Ws;so=1;function e(t){return t!=null&&typeof t=="object"}return Ws=e,Ws}var $s,ro;function Pf(){if(ro)return $s;ro=1;var e=xn(),t=Dn(),n="[object Arguments]";function s(r){return t(r)&&e(r)==n}return $s=s,$s}var Ks,ao;function Lf(){if(ao)return Ks;ao=1;var e=Pf(),t=Dn(),n=Object.prototype,s=n.hasOwnProperty,r=n.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(i){return t(i)&&s.call(i,"callee")&&!r.call(i,"callee")};return Ks=a,Ks}var Lt={exports:{}},Js,io;function Of(){if(io)return Js;io=1;function e(){return!1}return Js=e,Js}Lt.exports;var oo;function rc(){return oo||(oo=1,(function(e,t){var n=ht(),s=Of(),r=t&&!t.nodeType&&t,a=r&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===r,c=i?n.Buffer:void 0,l=c?c.isBuffer:void 0,d=l||s;e.exports=d})(Lt,Lt.exports)),Lt.exports}var Ys,lo;function Ff(){if(lo)return Ys;lo=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(s,r){var a=typeof s;return r=r??e,!!r&&(a=="number"||a!="symbol"&&t.test(s))&&s>-1&&s%1==0&&s<r}return Ys=n,Ys}var Zs,co;function ac(){if(co)return Zs;co=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Zs=t,Zs}var Xs,uo;function Vf(){if(uo)return Xs;uo=1;var e=xn(),t=ac(),n=Dn(),s="[object Arguments]",r="[object Array]",a="[object Boolean]",i="[object Date]",c="[object Error]",l="[object Function]",d="[object Map]",u="[object Number]",h="[object Object]",m="[object RegExp]",p="[object Set]",g="[object String]",x="[object WeakMap]",v="[object ArrayBuffer]",w="[object DataView]",C="[object Float32Array]",b="[object Float64Array]",y="[object Int8Array]",N="[object Int16Array]",E="[object Int32Array]",T="[object Uint8Array]",S="[object Uint8ClampedArray]",_="[object Uint16Array]",A="[object Uint32Array]",M={};M[C]=M[b]=M[y]=M[N]=M[E]=M[T]=M[S]=M[_]=M[A]=!0,M[s]=M[r]=M[v]=M[a]=M[w]=M[i]=M[c]=M[l]=M[d]=M[u]=M[h]=M[m]=M[p]=M[g]=M[x]=!1;function k(R){return n(R)&&t(R.length)&&!!M[e(R)]}return Xs=k,Xs}var Qs,fo;function Hf(){if(fo)return Qs;fo=1;function e(t){return function(n){return t(n)}}return Qs=e,Qs}var Ot={exports:{}};Ot.exports;var ho;function Uf(){return ho||(ho=1,(function(e,t){var n=Xl(),s=t&&!t.nodeType&&t,r=s&&!0&&e&&!e.nodeType&&e,a=r&&r.exports===s,i=a&&n.process,c=(function(){try{var l=r&&r.require&&r.require("util").types;return l||i&&i.binding&&i.binding("util")}catch{}})();e.exports=c})(Ot,Ot.exports)),Ot.exports}var er,mo;function ic(){if(mo)return er;mo=1;var e=Vf(),t=Hf(),n=Uf(),s=n&&n.isTypedArray,r=s?t(s):e;return er=r,er}var tr,po;function Gf(){if(po)return tr;po=1;var e=Rf(),t=Lf(),n=Hr(),s=rc(),r=Ff(),a=ic(),i=Object.prototype,c=i.hasOwnProperty;function l(d,u){var h=n(d),m=!h&&t(d),p=!h&&!m&&s(d),g=!h&&!m&&!p&&a(d),x=h||m||p||g,v=x?e(d.length,String):[],w=v.length;for(var C in d)(u||c.call(d,C))&&!(x&&(C=="length"||p&&(C=="offset"||C=="parent")||g&&(C=="buffer"||C=="byteLength"||C=="byteOffset")||r(C,w)))&&v.push(C);return v}return tr=l,tr}var nr,go;function Bf(){if(go)return nr;go=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,r=typeof s=="function"&&s.prototype||e;return n===r}return nr=t,nr}var sr,vo;function zf(){if(vo)return sr;vo=1;function e(t,n){return function(s){return t(n(s))}}return sr=e,sr}var rr,Co;function qf(){if(Co)return rr;Co=1;var e=zf(),t=e(Object.keys,Object);return rr=t,rr}var ar,wo;function Wf(){if(wo)return ar;wo=1;var e=Bf(),t=qf(),n=Object.prototype,s=n.hasOwnProperty;function r(a){if(!e(a))return t(a);var i=[];for(var c in Object(a))s.call(a,c)&&c!="constructor"&&i.push(c);return i}return ar=r,ar}var ir,bo;function $f(){if(bo)return ir;bo=1;var e=ec(),t=ac();function n(s){return s!=null&&t(s.length)&&!e(s)}return ir=n,ir}var or,xo;function Kf(){if(xo)return or;xo=1;var e=Gf(),t=Wf(),n=$f();function s(r){return n(r)?e(r):t(r)}return or=s,or}var lr,yo;function Jf(){if(yo)return lr;yo=1;var e=jf(),t=If(),n=Kf();function s(r){return e(r,n,t)}return lr=s,lr}var cr,So;function Yf(){if(So)return cr;So=1;var e=Jf(),t=1,n=Object.prototype,s=n.hasOwnProperty;function r(a,i,c,l,d,u){var h=c&t,m=e(a),p=m.length,g=e(i),x=g.length;if(p!=x&&!h)return!1;for(var v=p;v--;){var w=m[v];if(!(h?w in i:s.call(i,w)))return!1}var C=u.get(a),b=u.get(i);if(C&&b)return C==i&&b==a;var y=!0;u.set(a,i),u.set(i,a);for(var N=h;++v<p;){w=m[v];var E=a[w],T=i[w];if(l)var S=h?l(T,E,w,i,a,u):l(E,T,w,a,i,u);if(!(S===void 0?E===T||d(E,T,c,l,u):S)){y=!1;break}N||(N=w=="constructor")}if(y&&!N){var _=a.constructor,A=i.constructor;_!=A&&"constructor"in a&&"constructor"in i&&!(typeof _=="function"&&_ instanceof _&&typeof A=="function"&&A instanceof A)&&(y=!1)}return u.delete(a),u.delete(i),y}return cr=r,cr}var ur,Do;function Zf(){if(Do)return ur;Do=1;var e=Mt(),t=ht(),n=e(t,"DataView");return ur=n,ur}var dr,To;function Xf(){if(To)return dr;To=1;var e=Mt(),t=ht(),n=e(t,"Promise");return dr=n,dr}var fr,Mo;function Qf(){if(Mo)return fr;Mo=1;var e=Mt(),t=ht(),n=e(t,"Set");return fr=n,fr}var hr,Ao;function eh(){if(Ao)return hr;Ao=1;var e=Mt(),t=ht(),n=e(t,"WeakMap");return hr=n,hr}var mr,Eo;function th(){if(Eo)return mr;Eo=1;var e=Zf(),t=Vr(),n=Xf(),s=Qf(),r=eh(),a=xn(),i=tc(),c="[object Map]",l="[object Object]",d="[object Promise]",u="[object Set]",h="[object WeakMap]",m="[object DataView]",p=i(e),g=i(t),x=i(n),v=i(s),w=i(r),C=a;return(e&&C(new e(new ArrayBuffer(1)))!=m||t&&C(new t)!=c||n&&C(n.resolve())!=d||s&&C(new s)!=u||r&&C(new r)!=h)&&(C=function(b){var y=a(b),N=y==l?b.constructor:void 0,E=N?i(N):"";if(E)switch(E){case p:return m;case g:return c;case x:return d;case v:return u;case w:return h}return y}),mr=C,mr}var pr,No;function nh(){if(No)return pr;No=1;var e=wf(),t=sc(),n=Ef(),s=Yf(),r=th(),a=Hr(),i=rc(),c=ic(),l=1,d="[object Arguments]",u="[object Array]",h="[object Object]",m=Object.prototype,p=m.hasOwnProperty;function g(x,v,w,C,b,y){var N=a(x),E=a(v),T=N?u:r(x),S=E?u:r(v);T=T==d?h:T,S=S==d?h:S;var _=T==h,A=S==h,M=T==S;if(M&&i(x)){if(!i(v))return!1;N=!0,_=!1}if(M&&!_)return y||(y=new e),N||c(x)?t(x,v,w,C,b,y):n(x,v,T,w,C,b,y);if(!(w&l)){var k=_&&p.call(x,"__wrapped__"),R=A&&p.call(v,"__wrapped__");if(k||R){var L=k?x.value():x,z=R?v.value():v;return y||(y=new e),b(L,z,w,C,y)}}return M?(y||(y=new e),s(x,v,w,C,b,y)):!1}return pr=g,pr}var gr,jo;function sh(){if(jo)return gr;jo=1;var e=nh(),t=Dn();function n(s,r,a,i,c){return s===r?!0:s==null||r==null||!t(s)&&!t(r)?s!==s&&r!==r:e(s,r,a,i,n,c)}return gr=n,gr}var vr,ko;function rh(){if(ko)return vr;ko=1;var e=sh();function t(n,s){return e(n,s)}return vr=t,vr}var ah=rh();const Mr=Or(ah),oc=e=>Ee.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ee.createElement("path",{d:"M8.00016 1.33325C4.3135 1.33325 1.3335 4.31325 1.3335 7.99992C1.3335 11.6866 4.3135 14.6666 8.00016 14.6666C11.6868 14.6666 14.6668 11.6866 14.6668 7.99992C14.6668 4.31325 11.6868 1.33325 8.00016 1.33325ZM8.00016 13.3333C5.06016 13.3333 2.66683 10.9399 2.66683 7.99992C2.66683 5.05992 5.06016 2.66659 8.00016 2.66659C10.9402 2.66659 13.3335 5.05992 13.3335 7.99992C13.3335 10.9399 10.9402 13.3333 8.00016 13.3333ZM10.3935 4.66659L8.00016 7.05992L5.60683 4.66659L4.66683 5.60659L7.06016 7.99992L4.66683 10.3933L5.60683 11.3333L8.00016 8.93992L10.3935 11.3333L11.3335 10.3933L8.94016 7.99992L11.3335 5.60659L10.3935 4.66659Z",fill:"currentColor"})),ih=({dataQueries:e,disabledDatasetUrns:t,isSelected:n,onSelect:s,onClearAll:r})=>{const{titles:a}=De(),i=e.length-t.size,c=t.size>0;return o.jsxs("div",{className:$("flex justify-between items-center px-2 h-10 shrink-0 hover:bg-hues-100 rounded","filters-facet-item cursor-pointer",n&&"bg-hues-100"),onClick:s,children:[o.jsx("h3",{className:"w-full min-w-0 flex-1 truncate",title:a?.dataset??"Dataset",children:o.jsx("span",{className:"truncate",children:a?.dataset??"Dataset"})}),o.jsxs("div",{className:"ml-2 flex items-center gap-2 text-neutrals-800",children:[o.jsx("span",{className:"filters-facet-item-counter px-2 text-center",children:`${i}/${e.length}`}),c&&o.jsx("div",{className:"filters-facet-item-settings flex items-center gap-2",children:o.jsx(j.IconButton,{buttonClassName:"text-button-tertiary w-4 h-4 border-0 p-0 filters-facet-item-icon",icon:o.jsx(oc,{width:16,height:16}),title:a?.reset??"Reset",onClick:l=>{l.stopPropagation(),r()}})})]})]})},Ur=e=>Ee.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ee.createElement("path",{d:"M11.3301 6.25L8.00008 9.75L4.67008 6.25L11.3301 6.25Z",fill:"currentColor"})),oh=e=>Ee.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ee.createElement("path",{d:"M12.8232 7C12.926 7 13.012 7.07201 13.0244 7.16797L13.1807 8.22754C13.4315 8.32754 13.6621 8.46012 13.876 8.62012L14.9004 8.21973C14.9208 8.21186 14.9453 8.20803 14.9697 8.20801C15.0436 8.20801 15.1133 8.24392 15.1504 8.30762L15.9736 9.69238C16.0227 9.7803 16.0018 9.88834 15.9238 9.94824L15.0566 10.6084C15.0731 10.7363 15.085 10.8642 15.085 11C15.085 11.1358 15.0731 11.2637 15.0566 11.3916L15.9238 12.0518C16.0018 12.1117 16.0227 12.2197 15.9736 12.3076L15.1504 13.6924C15.1133 13.7561 15.0434 13.792 14.9736 13.792C14.9492 13.7919 14.9248 13.7881 14.9004 13.7803L13.876 13.3799C13.6621 13.5359 13.4315 13.6725 13.1807 13.7725L13.0244 14.832C13.012 14.928 12.926 15 12.8232 15H11.1787C11.0759 15 10.9889 14.928 10.9766 14.832L10.8203 13.7725C10.5696 13.6725 10.3397 13.5398 10.126 13.3799L9.10156 13.7803C9.08115 13.7882 9.05667 13.792 9.03223 13.792C8.95826 13.792 8.88761 13.7563 8.85059 13.6924L8.02832 12.3076C7.97924 12.2197 8.0001 12.1117 8.07812 12.0518L8.94531 11.3916C8.92889 11.2637 8.91699 11.1319 8.91699 11C8.91699 10.8681 8.92889 10.7363 8.94531 10.6084L8.07812 9.94824C8.0001 9.88832 7.97515 9.78032 8.02832 9.69238L8.85059 8.30762C8.88754 8.24383 8.95763 8.20816 9.02734 8.20801C9.05192 8.20801 9.07699 8.21179 9.10156 8.21973L10.126 8.62012C10.3397 8.46418 10.5696 8.32752 10.8203 8.22754L10.9766 7.16797C10.9889 7.07197 11.0759 7 11.1787 7H12.8232ZM11.7129 7.7998L11.6309 8.33984L11.5654 8.79199L11.1289 8.96387C10.9604 9.03184 10.792 9.12795 10.6152 9.25586L10.2451 9.52832L9.81738 9.36035L9.29492 9.15625L9.00684 9.63965L9.45117 9.97559L9.81738 10.2559L9.75977 10.708C9.74743 10.828 9.73926 10.92 9.73926 11C9.73926 11.08 9.74743 11.1719 9.75977 11.2959L9.81738 11.748L9.45117 12.0283L9.00684 12.3643L9.29492 12.8477L9.81738 12.6436L10.2529 12.4717L10.627 12.752C10.7913 12.8719 10.9561 12.9642 11.1328 13.0361L11.5693 13.208L11.6348 13.6602L11.7129 14.2002H12.2891L12.3711 13.6602L12.4365 13.208L12.873 13.0361C13.0415 12.9681 13.21 12.8721 13.3867 12.7441L13.7568 12.4717L14.1846 12.6396L14.707 12.8438L14.9941 12.3604L14.5508 12.0244L14.1846 11.7441L14.2422 11.292C14.2545 11.172 14.2627 11.084 14.2627 11C14.2627 10.916 14.2586 10.832 14.2422 10.708L14.1846 10.2559L14.5508 9.97559L14.9902 9.63574L14.7021 9.15234L14.1807 9.35645L13.7441 9.52832L13.3701 9.24805C13.2057 9.12808 13.0411 9.03586 12.8643 8.96387L12.4287 8.79199L12.3623 8.33984L12.2842 7.7998H11.7129ZM3.33301 12.6338H2V11.3008H3.33301V12.6338ZM7.00977 11.3008C7.03732 11.7651 7.12864 12.2121 7.27441 12.6338H4.66699V11.3008H7.00977ZM12.001 9.40039C12.9097 9.40043 13.6455 10.116 13.6455 11C13.6455 11.884 12.9097 12.5996 12.001 12.5996C11.0922 12.5996 10.3564 11.884 10.3564 11C10.3564 10.116 11.0922 9.40039 12.001 9.40039ZM12.001 10.2002C11.5486 10.2002 11.1787 10.56 11.1787 11C11.1787 11.44 11.5486 11.7998 12.001 11.7998C12.4533 11.7998 12.8232 11.44 12.8232 11C12.8232 10.56 12.4533 10.2002 12.001 10.2002ZM3.33301 8.63379H2V7.30078H3.33301V8.63379ZM8.63574 7.30078C8.21765 7.68124 7.86483 8.13197 7.59473 8.63379H4.66699V7.30078H8.63574ZM3.33301 4.7334H2V3.40039H3.33301V4.7334ZM14 4.7334H4.66699V3.40039H14V4.7334Z",fill:"currentColor"}));var Ft={exports:{}},lh=Ft.exports,_o;function ch(){return _o||(_o=1,(function(e,t){(function(n,s){s(t)})(lh,(function(n){var s=function(){return s=Object.assign||function(ct){for(var Qt,On=1,fd=arguments.length;On<fd;On++){Qt=arguments[On];for(var Fn in Qt)Object.prototype.hasOwnProperty.call(Qt,Fn)&&(ct[Fn]=Qt[Fn])}return ct},s.apply(this,arguments)},r=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},a={weekdays:{shorthand:["أحد","اثنين","ثلاثاء","أربعاء","خميس","جمعة","سبت"],longhand:["الأحد","الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة","السبت"]},months:{shorthand:["1","2","3","4","5","6","7","8","9","10","11","12"],longhand:["يناير","فبراير","مارس","أبريل","مايو","يونيو","يوليو","أغسطس","سبتمبر","أكتوبر","نوفمبر","ديسمبر"]},firstDayOfWeek:6,rangeSeparator:" إلى ",weekAbbreviation:"Wk",scrollTitle:"قم بالتمرير للزيادة",toggleTitle:"اضغط للتبديل",amPM:["ص","م"],yearAriaLabel:"سنة",monthAriaLabel:"شهر",hourAriaLabel:"ساعة",minuteAriaLabel:"دقيقة",time_24hr:!1};r.l10ns.ar=a,r.l10ns;var i=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},c={weekdays:{shorthand:["So","Mo","Di","Mi","Do","Fr","Sa"],longhand:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"]},months:{shorthand:["Jän","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],longhand:["Jänner","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"]},firstDayOfWeek:1,weekAbbreviation:"KW",rangeSeparator:" bis ",scrollTitle:"Zum Ändern scrollen",toggleTitle:"Zum Umschalten klicken",time_24hr:!0};i.l10ns.at=c,i.l10ns;var l=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},d={weekdays:{shorthand:["B.","B.e.","Ç.a.","Ç.","C.a.","C.","Ş."],longhand:["Bazar","Bazar ertəsi","Çərşənbə axşamı","Çərşənbə","Cümə axşamı","Cümə","Şənbə"]},months:{shorthand:["Yan","Fev","Mar","Apr","May","İyn","İyl","Avq","Sen","Okt","Noy","Dek"],longhand:["Yanvar","Fevral","Mart","Aprel","May","İyun","İyul","Avqust","Sentyabr","Oktyabr","Noyabr","Dekabr"]},firstDayOfWeek:1,ordinal:function(){return"."},rangeSeparator:" - ",weekAbbreviation:"Hf",scrollTitle:"Artırmaq üçün sürüşdürün",toggleTitle:"Aç / Bağla",amPM:["GƏ","GS"],time_24hr:!0};l.l10ns.az=d,l.l10ns;var u=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},h={weekdays:{shorthand:["Нд","Пн","Аў","Ср","Чц","Пт","Сб"],longhand:["Нядзеля","Панядзелак","Аўторак","Серада","Чацвер","Пятніца","Субота"]},months:{shorthand:["Сту","Лют","Сак","Кра","Тра","Чэр","Ліп","Жні","Вер","Кас","Ліс","Сне"],longhand:["Студзень","Люты","Сакавік","Красавік","Травень","Чэрвень","Ліпень","Жнівень","Верасень","Кастрычнік","Лістапад","Снежань"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Тыд.",scrollTitle:"Пракруціце для павелічэння",toggleTitle:"Націсніце для пераключэння",amPM:["ДП","ПП"],yearAriaLabel:"Год",time_24hr:!0};u.l10ns.be=h,u.l10ns;var m=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},p={firstDayOfWeek:1,weekdays:{shorthand:["Ned","Pon","Uto","Sri","Čet","Pet","Sub"],longhand:["Nedjelja","Ponedjeljak","Utorak","Srijeda","Četvrtak","Petak","Subota"]},months:{shorthand:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Avg","Sep","Okt","Nov","Dec"],longhand:["Januar","Februar","Mart","April","Maj","Juni","Juli","Avgust","Septembar","Oktobar","Novembar","Decembar"]},time_24hr:!0};m.l10ns.bs=p,m.l10ns;var g=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},x={weekdays:{shorthand:["Нд","Пн","Вт","Ср","Чт","Пт","Сб"],longhand:["Неделя","Понеделник","Вторник","Сряда","Четвъртък","Петък","Събота"]},months:{shorthand:["Яну","Фев","Март","Апр","Май","Юни","Юли","Авг","Сеп","Окт","Ное","Дек"],longhand:["Януари","Февруари","Март","Април","Май","Юни","Юли","Август","Септември","Октомври","Ноември","Декември"]},time_24hr:!0,firstDayOfWeek:1};g.l10ns.bg=x,g.l10ns;var v=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},w={weekdays:{shorthand:["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],longhand:["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"]},months:{shorthand:["জানু","ফেব্রু","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],longhand:["জানুয়ারী","ফেব্রুয়ারী","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"]}};v.l10ns.bn=w,v.l10ns;var C=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},b={weekdays:{shorthand:["Dg","Dl","Dt","Dc","Dj","Dv","Ds"],longhand:["Diumenge","Dilluns","Dimarts","Dimecres","Dijous","Divendres","Dissabte"]},months:{shorthand:["Gen","Febr","Març","Abr","Maig","Juny","Jul","Ag","Set","Oct","Nov","Des"],longhand:["Gener","Febrer","Març","Abril","Maig","Juny","Juliol","Agost","Setembre","Octubre","Novembre","Desembre"]},ordinal:function(_e){var ct=_e%100;if(ct>3&&ct<21)return"è";switch(ct%10){case 1:return"r";case 2:return"n";case 3:return"r";case 4:return"t";default:return"è"}},firstDayOfWeek:1,rangeSeparator:" a ",time_24hr:!0};C.l10ns.cat=C.l10ns.ca=b,C.l10ns;var y=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},N={weekdays:{shorthand:["یەکشەممە","دووشەممە","سێشەممە","چوارشەممە","پێنجشەممە","هەینی","شەممە"],longhand:["یەکشەممە","دووشەممە","سێشەممە","چوارشەممە","پێنجشەممە","هەینی","شەممە"]},months:{shorthand:["ڕێبەندان","ڕەشەمە","نەورۆز","گوڵان","جۆزەردان","پووشپەڕ","گەلاوێژ","خەرمانان","ڕەزبەر","گەڵاڕێزان","سەرماوەز","بەفرانبار"],longhand:["ڕێبەندان","ڕەشەمە","نەورۆز","گوڵان","جۆزەردان","پووشپەڕ","گەلاوێژ","خەرمانان","ڕەزبەر","گەڵاڕێزان","سەرماوەز","بەفرانبار"]},firstDayOfWeek:6,ordinal:function(){return""}};y.l10ns.ckb=N,y.l10ns;var E=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},T={weekdays:{shorthand:["Ne","Po","Út","St","Čt","Pá","So"],longhand:["Neděle","Pondělí","Úterý","Středa","Čtvrtek","Pátek","Sobota"]},months:{shorthand:["Led","Ún","Bře","Dub","Kvě","Čer","Čvc","Srp","Zář","Říj","Lis","Pro"],longhand:["Leden","Únor","Březen","Duben","Květen","Červen","Červenec","Srpen","Září","Říjen","Listopad","Prosinec"]},firstDayOfWeek:1,ordinal:function(){return"."},rangeSeparator:" do ",weekAbbreviation:"Týd.",scrollTitle:"Rolujte pro změnu",toggleTitle:"Přepnout dopoledne/odpoledne",amPM:["dop.","odp."],yearAriaLabel:"Rok",time_24hr:!0};E.l10ns.cs=T,E.l10ns;var S=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},_={weekdays:{shorthand:["Sul","Llun","Maw","Mer","Iau","Gwe","Sad"],longhand:["Dydd Sul","Dydd Llun","Dydd Mawrth","Dydd Mercher","Dydd Iau","Dydd Gwener","Dydd Sadwrn"]},months:{shorthand:["Ion","Chwef","Maw","Ebr","Mai","Meh","Gorff","Awst","Medi","Hyd","Tach","Rhag"],longhand:["Ionawr","Chwefror","Mawrth","Ebrill","Mai","Mehefin","Gorffennaf","Awst","Medi","Hydref","Tachwedd","Rhagfyr"]},firstDayOfWeek:1,ordinal:function(_e){return _e===1?"af":_e===2?"ail":_e===3||_e===4?"ydd":_e===5||_e===6?"ed":_e>=7&&_e<=10||_e==12||_e==15||_e==18||_e==20?"fed":_e==11||_e==13||_e==14||_e==16||_e==17||_e==19?"eg":_e>=21&&_e<=39?"ain":""},time_24hr:!0};S.l10ns.cy=_,S.l10ns;var A=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},M={weekdays:{shorthand:["søn","man","tir","ons","tors","fre","lør"],longhand:["søndag","mandag","tirsdag","onsdag","torsdag","fredag","lørdag"]},months:{shorthand:["jan","feb","mar","apr","maj","jun","jul","aug","sep","okt","nov","dec"],longhand:["januar","februar","marts","april","maj","juni","juli","august","september","oktober","november","december"]},ordinal:function(){return"."},firstDayOfWeek:1,rangeSeparator:" til ",weekAbbreviation:"uge",time_24hr:!0};A.l10ns.da=M,A.l10ns;var k=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},R={weekdays:{shorthand:["So","Mo","Di","Mi","Do","Fr","Sa"],longhand:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"]},months:{shorthand:["Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],longhand:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"]},firstDayOfWeek:1,weekAbbreviation:"KW",rangeSeparator:" bis ",scrollTitle:"Zum Ändern scrollen",toggleTitle:"Zum Umschalten klicken",time_24hr:!0};k.l10ns.de=R,k.l10ns;var L={weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0,ordinal:function(_e){var ct=_e%100;if(ct>3&&ct<21)return"th";switch(ct%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},rangeSeparator:" to ",weekAbbreviation:"Wk",scrollTitle:"Scroll to increment",toggleTitle:"Click to toggle",amPM:["AM","PM"],yearAriaLabel:"Year",monthAriaLabel:"Month",hourAriaLabel:"Hour",minuteAriaLabel:"Minute",time_24hr:!1},z=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},U={firstDayOfWeek:1,rangeSeparator:" ĝis ",weekAbbreviation:"Sem",scrollTitle:"Rulumu por pligrandigi la valoron",toggleTitle:"Klaku por ŝalti",weekdays:{shorthand:["Dim","Lun","Mar","Mer","Ĵaŭ","Ven","Sab"],longhand:["dimanĉo","lundo","mardo","merkredo","ĵaŭdo","vendredo","sabato"]},months:{shorthand:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aŭg","Sep","Okt","Nov","Dec"],longhand:["januaro","februaro","marto","aprilo","majo","junio","julio","aŭgusto","septembro","oktobro","novembro","decembro"]},ordinal:function(){return"-a"},time_24hr:!0};z.l10ns.eo=U,z.l10ns;var Z=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},O={weekdays:{shorthand:["Dom","Lun","Mar","Mié","Jue","Vie","Sáb"],longhand:["Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado"]},months:{shorthand:["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],longhand:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]},ordinal:function(){return"º"},firstDayOfWeek:1,rangeSeparator:" a ",time_24hr:!0};Z.l10ns.es=O,Z.l10ns;var K=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},J={weekdays:{shorthand:["P","E","T","K","N","R","L"],longhand:["Pühapäev","Esmaspäev","Teisipäev","Kolmapäev","Neljapäev","Reede","Laupäev"]},months:{shorthand:["Jaan","Veebr","Märts","Apr","Mai","Juuni","Juuli","Aug","Sept","Okt","Nov","Dets"],longhand:["Jaanuar","Veebruar","Märts","Aprill","Mai","Juuni","Juuli","August","September","Oktoober","November","Detsember"]},firstDayOfWeek:1,ordinal:function(){return"."},weekAbbreviation:"Näd",rangeSeparator:" kuni ",scrollTitle:"Keri, et suurendada",toggleTitle:"Klõpsa, et vahetada",time_24hr:!0};K.l10ns.et=J,K.l10ns;var X=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Q={weekdays:{shorthand:["یک","دو","سه","چهار","پنج","جمعه","شنبه"],longhand:["یک‌شنبه","دوشنبه","سه‌شنبه","چهارشنبه","پنچ‌شنبه","جمعه","شنبه"]},months:{shorthand:["ژانویه","فوریه","مارس","آوریل","مه","ژوئن","ژوئیه","اوت","سپتامبر","اکتبر","نوامبر","دسامبر"],longhand:["ژانویه","فوریه","مارس","آوریل","مه","ژوئن","ژوئیه","اوت","سپتامبر","اکتبر","نوامبر","دسامبر"]},firstDayOfWeek:6,ordinal:function(){return""}};X.l10ns.fa=Q,X.l10ns;var pe=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},we={firstDayOfWeek:1,weekdays:{shorthand:["su","ma","ti","ke","to","pe","la"],longhand:["sunnuntai","maanantai","tiistai","keskiviikko","torstai","perjantai","lauantai"]},months:{shorthand:["tammi","helmi","maalis","huhti","touko","kesä","heinä","elo","syys","loka","marras","joulu"],longhand:["tammikuu","helmikuu","maaliskuu","huhtikuu","toukokuu","kesäkuu","heinäkuu","elokuu","syyskuu","lokakuu","marraskuu","joulukuu"]},ordinal:function(){return"."},time_24hr:!0};pe.l10ns.fi=we,pe.l10ns;var se=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},V={weekdays:{shorthand:["Sun","Mán","Týs","Mik","Hós","Frí","Ley"],longhand:["Sunnudagur","Mánadagur","Týsdagur","Mikudagur","Hósdagur","Fríggjadagur","Leygardagur"]},months:{shorthand:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Des"],longhand:["Januar","Februar","Mars","Apríl","Mai","Juni","Juli","August","Septembur","Oktobur","Novembur","Desembur"]},ordinal:function(){return"."},firstDayOfWeek:1,rangeSeparator:" til ",weekAbbreviation:"vika",scrollTitle:"Rulla fyri at broyta",toggleTitle:"Trýst fyri at skifta",yearAriaLabel:"Ár",time_24hr:!0};se.l10ns.fo=V,se.l10ns;var W=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ce={firstDayOfWeek:1,weekdays:{shorthand:["dim","lun","mar","mer","jeu","ven","sam"],longhand:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"]},months:{shorthand:["janv","févr","mars","avr","mai","juin","juil","août","sept","oct","nov","déc"],longhand:["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"]},ordinal:function(_e){return _e>1?"":"er"},rangeSeparator:" au ",weekAbbreviation:"Sem",scrollTitle:"Défiler pour augmenter la valeur",toggleTitle:"Cliquer pour basculer",time_24hr:!0};W.l10ns.fr=ce,W.l10ns;var fe=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},de={weekdays:{shorthand:["Κυ","Δε","Τρ","Τε","Πέ","Πα","Σά"],longhand:["Κυριακή","Δευτέρα","Τρίτη","Τετάρτη","Πέμπτη","Παρασκευή","Σάββατο"]},months:{shorthand:["Ιαν","Φεβ","Μάρ","Απρ","Μάι","Ιούν","Ιούλ","Αύγ","Σεπ","Οκτ","Νοέ","Δεκ"],longhand:["Ιανουάριος","Φεβρουάριος","Μάρτιος","Απρίλιος","Μάιος","Ιούνιος","Ιούλιος","Αύγουστος","Σεπτέμβριος","Οκτώβριος","Νοέμβριος","Δεκέμβριος"]},firstDayOfWeek:1,ordinal:function(){return""},weekAbbreviation:"Εβδ",rangeSeparator:" έως ",scrollTitle:"Μετακυλήστε για προσαύξηση",toggleTitle:"Κάντε κλικ για αλλαγή",amPM:["ΠΜ","ΜΜ"],yearAriaLabel:"χρόνος",monthAriaLabel:"μήνας",hourAriaLabel:"ώρα",minuteAriaLabel:"λεπτό"};fe.l10ns.gr=de,fe.l10ns;var Ne=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Te={weekdays:{shorthand:["א","ב","ג","ד","ה","ו","ש"],longhand:["ראשון","שני","שלישי","רביעי","חמישי","שישי","שבת"]},months:{shorthand:["ינו׳","פבר׳","מרץ","אפר׳","מאי","יוני","יולי","אוג׳","ספט׳","אוק׳","נוב׳","דצמ׳"],longhand:["ינואר","פברואר","מרץ","אפריל","מאי","יוני","יולי","אוגוסט","ספטמבר","אוקטובר","נובמבר","דצמבר"]},rangeSeparator:" אל ",time_24hr:!0};Ne.l10ns.he=Te,Ne.l10ns;var F=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},G={weekdays:{shorthand:["रवि","सोम","मंगल","बुध","गुरु","शुक्र","शनि"],longhand:["रविवार","सोमवार","मंगलवार","बुधवार","गुरुवार","शुक्रवार","शनिवार"]},months:{shorthand:["जन","फर","मार्च","अप्रेल","मई","जून","जूलाई","अग","सित","अक्ट","नव","दि"],longhand:["जनवरी ","फरवरी","मार्च","अप्रेल","मई","जून","जूलाई","अगस्त ","सितम्बर","अक्टूबर","नवम्बर","दिसम्बर"]}};F.l10ns.hi=G,F.l10ns;var oe=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},re={firstDayOfWeek:1,weekdays:{shorthand:["Ned","Pon","Uto","Sri","Čet","Pet","Sub"],longhand:["Nedjelja","Ponedjeljak","Utorak","Srijeda","Četvrtak","Petak","Subota"]},months:{shorthand:["Sij","Velj","Ožu","Tra","Svi","Lip","Srp","Kol","Ruj","Lis","Stu","Pro"],longhand:["Siječanj","Veljača","Ožujak","Travanj","Svibanj","Lipanj","Srpanj","Kolovoz","Rujan","Listopad","Studeni","Prosinac"]},time_24hr:!0};oe.l10ns.hr=re,oe.l10ns;var ae=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ue={firstDayOfWeek:1,weekdays:{shorthand:["V","H","K","Sz","Cs","P","Szo"],longhand:["Vasárnap","Hétfő","Kedd","Szerda","Csütörtök","Péntek","Szombat"]},months:{shorthand:["Jan","Feb","Már","Ápr","Máj","Jún","Júl","Aug","Szep","Okt","Nov","Dec"],longhand:["Január","Február","Március","Április","Május","Június","Július","Augusztus","Szeptember","Október","November","December"]},ordinal:function(){return"."},weekAbbreviation:"Hét",scrollTitle:"Görgessen",toggleTitle:"Kattintson a váltáshoz",rangeSeparator:" - ",time_24hr:!0};ae.l10ns.hu=ue,ae.l10ns;var he=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},je={weekdays:{shorthand:["Կիր","Երկ","Երք","Չրք","Հնգ","Ուրբ","Շբթ"],longhand:["Կիրակի","Եկուշաբթի","Երեքշաբթի","Չորեքշաբթի","Հինգշաբթի","Ուրբաթ","Շաբաթ"]},months:{shorthand:["Հնվ","Փտր","Մար","Ապր","Մայ","Հնս","Հլս","Օգս","Սեպ","Հոկ","Նմբ","Դեկ"],longhand:["Հունվար","Փետրվար","Մարտ","Ապրիլ","Մայիս","Հունիս","Հուլիս","Օգոստոս","Սեպտեմբեր","Հոկտեմբեր","Նոյեմբեր","Դեկտեմբեր"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"ՇԲՏ",scrollTitle:"Ոլորեք՝ մեծացնելու համար",toggleTitle:"Սեղմեք՝ փոխելու համար",amPM:["ՄԿ","ԿՀ"],yearAriaLabel:"Տարի",monthAriaLabel:"Ամիս",hourAriaLabel:"Ժամ",minuteAriaLabel:"Րոպե",time_24hr:!0};he.l10ns.hy=je,he.l10ns;var Se=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ge={weekdays:{shorthand:["Min","Sen","Sel","Rab","Kam","Jum","Sab"],longhand:["Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu"]},months:{shorthand:["Jan","Feb","Mar","Apr","Mei","Jun","Jul","Agu","Sep","Okt","Nov","Des"],longhand:["Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"]},firstDayOfWeek:1,ordinal:function(){return""},time_24hr:!0,rangeSeparator:" - "};Se.l10ns.id=ge,Se.l10ns;var be=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Me={weekdays:{shorthand:["Sun","Mán","Þri","Mið","Fim","Fös","Lau"],longhand:["Sunnudagur","Mánudagur","Þriðjudagur","Miðvikudagur","Fimmtudagur","Föstudagur","Laugardagur"]},months:{shorthand:["Jan","Feb","Mar","Apr","Maí","Jún","Júl","Ágú","Sep","Okt","Nóv","Des"],longhand:["Janúar","Febrúar","Mars","Apríl","Maí","Júní","Júlí","Ágúst","September","Október","Nóvember","Desember"]},ordinal:function(){return"."},firstDayOfWeek:1,rangeSeparator:" til ",weekAbbreviation:"vika",yearAriaLabel:"Ár",time_24hr:!0};be.l10ns.is=Me,be.l10ns;var Le=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Be={weekdays:{shorthand:["Dom","Lun","Mar","Mer","Gio","Ven","Sab"],longhand:["Domenica","Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"]},months:{shorthand:["Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Ott","Nov","Dic"],longhand:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"]},firstDayOfWeek:1,ordinal:function(){return"°"},rangeSeparator:" al ",weekAbbreviation:"Se",scrollTitle:"Scrolla per aumentare",toggleTitle:"Clicca per cambiare",time_24hr:!0};Le.l10ns.it=Be,Le.l10ns;var ze=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ke={weekdays:{shorthand:["日","月","火","水","木","金","土"],longhand:["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"]},months:{shorthand:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],longhand:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"]},time_24hr:!0,rangeSeparator:" から ",monthAriaLabel:"月",amPM:["午前","午後"],yearAriaLabel:"年",hourAriaLabel:"時間",minuteAriaLabel:"分"};ze.l10ns.ja=ke,ze.l10ns;var Oe=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ve={weekdays:{shorthand:["კვ","ორ","სა","ოთ","ხუ","პა","შა"],longhand:["კვირა","ორშაბათი","სამშაბათი","ოთხშაბათი","ხუთშაბათი","პარასკევი","შაბათი"]},months:{shorthand:["იან","თებ","მარ","აპრ","მაი","ივნ","ივლ","აგვ","სექ","ოქტ","ნოე","დეკ"],longhand:["იანვარი","თებერვალი","მარტი","აპრილი","მაისი","ივნისი","ივლისი","აგვისტო","სექტემბერი","ოქტომბერი","ნოემბერი","დეკემბერი"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"კვ.",scrollTitle:"დასქროლეთ გასადიდებლად",toggleTitle:"დააკლიკეთ გადართვისთვის",amPM:["AM","PM"],yearAriaLabel:"წელი",time_24hr:!0};Oe.l10ns.ka=Ve,Oe.l10ns;var Qe=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Y={weekdays:{shorthand:["일","월","화","수","목","금","토"],longhand:["일요일","월요일","화요일","수요일","목요일","금요일","토요일"]},months:{shorthand:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"],longhand:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"]},ordinal:function(){return"일"},rangeSeparator:" ~ ",amPM:["오전","오후"]};Qe.l10ns.ko=Y,Qe.l10ns;var me=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ie={weekdays:{shorthand:["អាទិត្យ","ចន្ទ","អង្គារ","ពុធ","ព្រហស.","សុក្រ","សៅរ៍"],longhand:["អាទិត្យ","ចន្ទ","អង្គារ","ពុធ","ព្រហស្បតិ៍","សុក្រ","សៅរ៍"]},months:{shorthand:["មករា","កុម្ភះ","មីនា","មេសា","ឧសភា","មិថុនា","កក្កដា","សីហា","កញ្ញា","តុលា","វិច្ឆិកា","ធ្នូ"],longhand:["មករា","កុម្ភះ","មីនា","មេសា","ឧសភា","មិថុនា","កក្កដា","សីហា","កញ្ញា","តុលា","វិច្ឆិកា","ធ្នូ"]},ordinal:function(){return""},firstDayOfWeek:1,rangeSeparator:" ដល់ ",weekAbbreviation:"សប្តាហ៍",scrollTitle:"រំកិលដើម្បីបង្កើន",toggleTitle:"ចុចដើម្បីផ្លាស់ប្ដូរ",yearAriaLabel:"ឆ្នាំ",time_24hr:!0};me.l10ns.km=ie,me.l10ns;var le=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},He={weekdays:{shorthand:["Жс","Дс","Сc","Ср","Бс","Жм","Сб"],longhand:["Жексенбi","Дүйсенбi","Сейсенбi","Сәрсенбi","Бейсенбi","Жұма","Сенбi"]},months:{shorthand:["Қаң","Ақп","Нау","Сәу","Мам","Мау","Шiл","Там","Қыр","Қаз","Қар","Жел"],longhand:["Қаңтар","Ақпан","Наурыз","Сәуiр","Мамыр","Маусым","Шiлде","Тамыз","Қыркүйек","Қазан","Қараша","Желтоқсан"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Апта",scrollTitle:"Үлкейту үшін айналдырыңыз",toggleTitle:"Ауыстыру үшін басыңыз",amPM:["ТД","ТК"],yearAriaLabel:"Жыл"};le.l10ns.kz=He,le.l10ns;var H=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},B={weekdays:{shorthand:["S","Pr","A","T","K","Pn","Š"],longhand:["Sekmadienis","Pirmadienis","Antradienis","Trečiadienis","Ketvirtadienis","Penktadienis","Šeštadienis"]},months:{shorthand:["Sau","Vas","Kov","Bal","Geg","Bir","Lie","Rgp","Rgs","Spl","Lap","Grd"],longhand:["Sausis","Vasaris","Kovas","Balandis","Gegužė","Birželis","Liepa","Rugpjūtis","Rugsėjis","Spalis","Lapkritis","Gruodis"]},firstDayOfWeek:1,ordinal:function(){return"-a"},rangeSeparator:" iki ",weekAbbreviation:"Sav",scrollTitle:"Keisti laiką pelės rateliu",toggleTitle:"Perjungti laiko formatą",time_24hr:!0};H.l10ns.lt=B,H.l10ns;var ee=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},I={firstDayOfWeek:1,weekdays:{shorthand:["Sv","Pr","Ot","Tr","Ce","Pk","Se"],longhand:["Svētdiena","Pirmdiena","Otrdiena","Trešdiena","Ceturtdiena","Piektdiena","Sestdiena"]},months:{shorthand:["Jan","Feb","Mar","Apr","Mai","Jūn","Jūl","Aug","Sep","Okt","Nov","Dec"],longhand:["Janvāris","Februāris","Marts","Aprīlis","Maijs","Jūnijs","Jūlijs","Augusts","Septembris","Oktobris","Novembris","Decembris"]},rangeSeparator:" līdz ",time_24hr:!0};ee.l10ns.lv=I,ee.l10ns;var P=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},q={weekdays:{shorthand:["Не","По","Вт","Ср","Че","Пе","Са"],longhand:["Недела","Понеделник","Вторник","Среда","Четврток","Петок","Сабота"]},months:{shorthand:["Јан","Фев","Мар","Апр","Мај","Јун","Јул","Авг","Сеп","Окт","Ное","Дек"],longhand:["Јануари","Февруари","Март","Април","Мај","Јуни","Јули","Август","Септември","Октомври","Ноември","Декември"]},firstDayOfWeek:1,weekAbbreviation:"Нед.",rangeSeparator:" до ",time_24hr:!0};P.l10ns.mk=q,P.l10ns;var te=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Re={firstDayOfWeek:1,weekdays:{shorthand:["Да","Мя","Лх","Пү","Ба","Бя","Ня"],longhand:["Даваа","Мягмар","Лхагва","Пүрэв","Баасан","Бямба","Ням"]},months:{shorthand:["1-р сар","2-р сар","3-р сар","4-р сар","5-р сар","6-р сар","7-р сар","8-р сар","9-р сар","10-р сар","11-р сар","12-р сар"],longhand:["Нэгдүгээр сар","Хоёрдугаар сар","Гуравдугаар сар","Дөрөвдүгээр сар","Тавдугаар сар","Зургаадугаар сар","Долдугаар сар","Наймдугаар сар","Есдүгээр сар","Аравдугаар сар","Арваннэгдүгээр сар","Арванхоёрдугаар сар"]},rangeSeparator:"-с ",time_24hr:!0};te.l10ns.mn=Re,te.l10ns;var Ce=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},xe={weekdays:{shorthand:["Aha","Isn","Sel","Rab","Kha","Jum","Sab"],longhand:["Ahad","Isnin","Selasa","Rabu","Khamis","Jumaat","Sabtu"]},months:{shorthand:["Jan","Feb","Mac","Apr","Mei","Jun","Jul","Ogo","Sep","Okt","Nov","Dis"],longhand:["Januari","Februari","Mac","April","Mei","Jun","Julai","Ogos","September","Oktober","November","Disember"]},firstDayOfWeek:1,ordinal:function(){return""}};Ce.l10ns;var Ze=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Je={weekdays:{shorthand:["နွေ","လာ","ဂါ","ဟူး","ကြာ","သော","နေ"],longhand:["တနင်္ဂနွေ","တနင်္လာ","အင်္ဂါ","ဗုဒ္ဓဟူး","ကြာသပတေး","သောကြာ","စနေ"]},months:{shorthand:["ဇန်","ဖေ","မတ်","ပြီ","မေ","ဇွန်","လိုင်","သြ","စက်","အောက်","နို","ဒီ"],longhand:["ဇန်နဝါရီ","ဖေဖော်ဝါရီ","မတ်","ဧပြီ","မေ","ဇွန်","ဇူလိုင်","သြဂုတ်","စက်တင်ဘာ","အောက်တိုဘာ","နိုဝင်ဘာ","ဒီဇင်ဘာ"]},firstDayOfWeek:1,ordinal:function(){return""},time_24hr:!0};Ze.l10ns.my=Je,Ze.l10ns;var at=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},it={weekdays:{shorthand:["zo","ma","di","wo","do","vr","za"],longhand:["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"]},months:{shorthand:["jan","feb","mrt","apr","mei","jun","jul","aug","sept","okt","nov","dec"],longhand:["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"]},firstDayOfWeek:1,weekAbbreviation:"wk",rangeSeparator:" t/m ",scrollTitle:"Scroll voor volgende / vorige",toggleTitle:"Klik om te wisselen",time_24hr:!0,ordinal:function(_e){return _e===1||_e===8||_e>=20?"ste":"de"}};at.l10ns.nl=it,at.l10ns;var bt=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},lt={weekdays:{shorthand:["Sø.","Må.","Ty.","On.","To.","Fr.","La."],longhand:["Søndag","Måndag","Tysdag","Onsdag","Torsdag","Fredag","Laurdag"]},months:{shorthand:["Jan","Feb","Mars","Apr","Mai","Juni","Juli","Aug","Sep","Okt","Nov","Des"],longhand:["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"]},firstDayOfWeek:1,rangeSeparator:" til ",weekAbbreviation:"Veke",scrollTitle:"Scroll for å endre",toggleTitle:"Klikk for å veksle",time_24hr:!0,ordinal:function(){return"."}};bt.l10ns.nn=lt,bt.l10ns;var Xt=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},oa={weekdays:{shorthand:["Søn","Man","Tir","Ons","Tor","Fre","Lør"],longhand:["Søndag","Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag"]},months:{shorthand:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Des"],longhand:["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"]},firstDayOfWeek:1,rangeSeparator:" til ",weekAbbreviation:"Uke",scrollTitle:"Scroll for å endre",toggleTitle:"Klikk for å veksle",time_24hr:!0,ordinal:function(){return"."}};Xt.l10ns.no=oa,Xt.l10ns;var la=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ca={weekdays:{shorthand:["ਐਤ","ਸੋਮ","ਮੰਗਲ","ਬੁੱਧ","ਵੀਰ","ਸ਼ੁੱਕਰ","ਸ਼ਨਿੱਚਰ"],longhand:["ਐਤਵਾਰ","ਸੋਮਵਾਰ","ਮੰਗਲਵਾਰ","ਬੁੱਧਵਾਰ","ਵੀਰਵਾਰ","ਸ਼ੁੱਕਰਵਾਰ","ਸ਼ਨਿੱਚਰਵਾਰ"]},months:{shorthand:["ਜਨ","ਫ਼ਰ","ਮਾਰ","ਅਪ੍ਰੈ","ਮਈ","ਜੂਨ","ਜੁਲਾ","ਅਗ","ਸਤੰ","ਅਕ","ਨਵੰ","ਦਸੰ"],longhand:["ਜਨਵਰੀ","ਫ਼ਰਵਰੀ","ਮਾਰਚ","ਅਪ੍ਰੈਲ","ਮਈ","ਜੂਨ","ਜੁਲਾਈ","ਅਗਸਤ","ਸਤੰਬਰ","ਅਕਤੂਬਰ","ਨਵੰਬਰ","ਦਸੰਬਰ"]},time_24hr:!0};la.l10ns.pa=ca,la.l10ns;var ua=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},da={weekdays:{shorthand:["Nd","Pn","Wt","Śr","Cz","Pt","So"],longhand:["Niedziela","Poniedziałek","Wtorek","Środa","Czwartek","Piątek","Sobota"]},months:{shorthand:["Sty","Lut","Mar","Kwi","Maj","Cze","Lip","Sie","Wrz","Paź","Lis","Gru"],longhand:["Styczeń","Luty","Marzec","Kwiecień","Maj","Czerwiec","Lipiec","Sierpień","Wrzesień","Październik","Listopad","Grudzień"]},rangeSeparator:" do ",weekAbbreviation:"tydz.",scrollTitle:"Przewiń, aby zwiększyć",toggleTitle:"Kliknij, aby przełączyć",firstDayOfWeek:1,time_24hr:!0,ordinal:function(){return"."}};ua.l10ns.pl=da,ua.l10ns;var fa=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ha={weekdays:{shorthand:["Dom","Seg","Ter","Qua","Qui","Sex","Sáb"],longhand:["Domingo","Segunda-feira","Terça-feira","Quarta-feira","Quinta-feira","Sexta-feira","Sábado"]},months:{shorthand:["Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"],longhand:["Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"]},rangeSeparator:" até ",time_24hr:!0};fa.l10ns.pt=ha,fa.l10ns;var ma=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},pa={weekdays:{shorthand:["Dum","Lun","Mar","Mie","Joi","Vin","Sâm"],longhand:["Duminică","Luni","Marți","Miercuri","Joi","Vineri","Sâmbătă"]},months:{shorthand:["Ian","Feb","Mar","Apr","Mai","Iun","Iul","Aug","Sep","Oct","Noi","Dec"],longhand:["Ianuarie","Februarie","Martie","Aprilie","Mai","Iunie","Iulie","August","Septembrie","Octombrie","Noiembrie","Decembrie"]},firstDayOfWeek:1,time_24hr:!0,ordinal:function(){return""}};ma.l10ns.ro=pa,ma.l10ns;var ga=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},va={weekdays:{shorthand:["Вс","Пн","Вт","Ср","Чт","Пт","Сб"],longhand:["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"]},months:{shorthand:["Янв","Фев","Март","Апр","Май","Июнь","Июль","Авг","Сен","Окт","Ноя","Дек"],longhand:["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Нед.",scrollTitle:"Прокрутите для увеличения",toggleTitle:"Нажмите для переключения",amPM:["ДП","ПП"],yearAriaLabel:"Год",time_24hr:!0};ga.l10ns.ru=va,ga.l10ns;var Ca=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},wa={weekdays:{shorthand:["ඉ","ස","අ","බ","බ්‍ර","සි","සෙ"],longhand:["ඉරිදා","සඳුදා","අඟහරුවාදා","බදාදා","බ්‍රහස්පතින්දා","සිකුරාදා","සෙනසුරාදා"]},months:{shorthand:["ජන","පෙබ","මාර්","අප්‍රේ","මැයි","ජුනි","ජූලි","අගෝ","සැප්","ඔක්","නොවැ","දෙසැ"],longhand:["ජනවාරි","පෙබරවාරි","මාර්තු","අප්‍රේල්","මැයි","ජුනි","ජූලි","අගෝස්තු","සැප්තැම්බර්","ඔක්තෝබර්","නොවැම්බර්","දෙසැම්බර්"]},time_24hr:!0};Ca.l10ns.si=wa,Ca.l10ns;var ba=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},xa={weekdays:{shorthand:["Ned","Pon","Ut","Str","Štv","Pia","Sob"],longhand:["Nedeľa","Pondelok","Utorok","Streda","Štvrtok","Piatok","Sobota"]},months:{shorthand:["Jan","Feb","Mar","Apr","Máj","Jún","Júl","Aug","Sep","Okt","Nov","Dec"],longhand:["Január","Február","Marec","Apríl","Máj","Jún","Júl","August","September","Október","November","December"]},firstDayOfWeek:1,rangeSeparator:" do ",time_24hr:!0,ordinal:function(){return"."}};ba.l10ns.sk=xa,ba.l10ns;var ya=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Sa={weekdays:{shorthand:["Ned","Pon","Tor","Sre","Čet","Pet","Sob"],longhand:["Nedelja","Ponedeljek","Torek","Sreda","Četrtek","Petek","Sobota"]},months:{shorthand:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Avg","Sep","Okt","Nov","Dec"],longhand:["Januar","Februar","Marec","April","Maj","Junij","Julij","Avgust","September","Oktober","November","December"]},firstDayOfWeek:1,rangeSeparator:" do ",time_24hr:!0,ordinal:function(){return"."}};ya.l10ns.sl=Sa,ya.l10ns;var Da=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ta={weekdays:{shorthand:["Di","Hë","Ma","Më","En","Pr","Sh"],longhand:["E Diel","E Hënë","E Martë","E Mërkurë","E Enjte","E Premte","E Shtunë"]},months:{shorthand:["Jan","Shk","Mar","Pri","Maj","Qer","Kor","Gus","Sht","Tet","Nën","Dhj"],longhand:["Janar","Shkurt","Mars","Prill","Maj","Qershor","Korrik","Gusht","Shtator","Tetor","Nëntor","Dhjetor"]},firstDayOfWeek:1,rangeSeparator:" deri ",weekAbbreviation:"Java",yearAriaLabel:"Viti",monthAriaLabel:"Muaji",hourAriaLabel:"Ora",minuteAriaLabel:"Minuta",time_24hr:!0};Da.l10ns.sq=Ta,Da.l10ns;var Ma=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Aa={weekdays:{shorthand:["Ned","Pon","Uto","Sre","Čet","Pet","Sub"],longhand:["Nedelja","Ponedeljak","Utorak","Sreda","Četvrtak","Petak","Subota"]},months:{shorthand:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Avg","Sep","Okt","Nov","Dec"],longhand:["Januar","Februar","Mart","April","Maj","Jun","Jul","Avgust","Septembar","Oktobar","Novembar","Decembar"]},firstDayOfWeek:1,weekAbbreviation:"Ned.",rangeSeparator:" do ",time_24hr:!0};Ma.l10ns.sr=Aa,Ma.l10ns;var Ea=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Na={firstDayOfWeek:1,weekAbbreviation:"v",weekdays:{shorthand:["sön","mån","tis","ons","tor","fre","lör"],longhand:["söndag","måndag","tisdag","onsdag","torsdag","fredag","lördag"]},months:{shorthand:["jan","feb","mar","apr","maj","jun","jul","aug","sep","okt","nov","dec"],longhand:["januari","februari","mars","april","maj","juni","juli","augusti","september","oktober","november","december"]},rangeSeparator:" till ",time_24hr:!0,ordinal:function(){return"."}};Ea.l10ns.sv=Na,Ea.l10ns;var ja=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ka={weekdays:{shorthand:["อา","จ","อ","พ","พฤ","ศ","ส"],longhand:["อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัสบดี","ศุกร์","เสาร์"]},months:{shorthand:["ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค."],longhand:["มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม"]},firstDayOfWeek:1,rangeSeparator:" ถึง ",scrollTitle:"เลื่อนเพื่อเพิ่มหรือลด",toggleTitle:"คลิกเพื่อเปลี่ยน",time_24hr:!0,ordinal:function(){return""}};ja.l10ns.th=ka,ja.l10ns;var _a=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ia={weekdays:{shorthand:["Paz","Pzt","Sal","Çar","Per","Cum","Cmt"],longhand:["Pazar","Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi"]},months:{shorthand:["Oca","Şub","Mar","Nis","May","Haz","Tem","Ağu","Eyl","Eki","Kas","Ara"],longhand:["Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık"]},firstDayOfWeek:1,ordinal:function(){return"."},rangeSeparator:" - ",weekAbbreviation:"Hf",scrollTitle:"Artırmak için kaydırın",toggleTitle:"Aç/Kapa",amPM:["ÖÖ","ÖS"],time_24hr:!0};_a.l10ns.tr=Ia,_a.l10ns;var Ra=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Pa={firstDayOfWeek:1,weekdays:{shorthand:["Нд","Пн","Вт","Ср","Чт","Пт","Сб"],longhand:["Неділя","Понеділок","Вівторок","Середа","Четвер","П'ятниця","Субота"]},months:{shorthand:["Січ","Лют","Бер","Кві","Тра","Чер","Лип","Сер","Вер","Жов","Лис","Гру"],longhand:["Січень","Лютий","Березень","Квітень","Травень","Червень","Липень","Серпень","Вересень","Жовтень","Листопад","Грудень"]},time_24hr:!0};Ra.l10ns.uk=Pa,Ra.l10ns;var La=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Oa={weekdays:{shorthand:["Якш","Душ","Сеш","Чор","Пай","Жум","Шан"],longhand:["Якшанба","Душанба","Сешанба","Чоршанба","Пайшанба","Жума","Шанба"]},months:{shorthand:["Янв","Фев","Мар","Апр","Май","Июн","Июл","Авг","Сен","Окт","Ноя","Дек"],longhand:["Январ","Феврал","Март","Апрел","Май","Июн","Июл","Август","Сентябр","Октябр","Ноябр","Декабр"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Ҳафта",scrollTitle:"Катталаштириш учун айлантиринг",toggleTitle:"Ўтиш учун босинг",amPM:["AM","PM"],yearAriaLabel:"Йил",time_24hr:!0};La.l10ns.uz=Oa,La.l10ns;var Fa=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Va={weekdays:{shorthand:["Ya","Du","Se","Cho","Pa","Ju","Sha"],longhand:["Yakshanba","Dushanba","Seshanba","Chorshanba","Payshanba","Juma","Shanba"]},months:{shorthand:["Yan","Fev","Mar","Apr","May","Iyun","Iyul","Avg","Sen","Okt","Noy","Dek"],longhand:["Yanvar","Fevral","Mart","Aprel","May","Iyun","Iyul","Avgust","Sentabr","Oktabr","Noyabr","Dekabr"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Hafta",scrollTitle:"Kattalashtirish uchun aylantiring",toggleTitle:"O‘tish uchun bosing",amPM:["AM","PM"],yearAriaLabel:"Yil",time_24hr:!0};Fa.l10ns.uz_latn=Va,Fa.l10ns;var Ha=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ua={weekdays:{shorthand:["CN","T2","T3","T4","T5","T6","T7"],longhand:["Chủ nhật","Thứ hai","Thứ ba","Thứ tư","Thứ năm","Thứ sáu","Thứ bảy"]},months:{shorthand:["Th1","Th2","Th3","Th4","Th5","Th6","Th7","Th8","Th9","Th10","Th11","Th12"],longhand:["Tháng một","Tháng hai","Tháng ba","Tháng tư","Tháng năm","Tháng sáu","Tháng bảy","Tháng tám","Tháng chín","Tháng mười","Tháng mười một","Tháng mười hai"]},firstDayOfWeek:1,rangeSeparator:" đến "};Ha.l10ns.vn=Ua,Ha.l10ns;var Ga=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ba={weekdays:{shorthand:["周日","周一","周二","周三","周四","周五","周六"],longhand:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},months:{shorthand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],longhand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},rangeSeparator:" 至 ",weekAbbreviation:"周",scrollTitle:"滚动切换",toggleTitle:"点击切换 12/24 小时时制"};Ga.l10ns.zh=Ba,Ga.l10ns;var za=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},qa={weekdays:{shorthand:["週日","週一","週二","週三","週四","週五","週六"],longhand:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},months:{shorthand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],longhand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},rangeSeparator:" 至 ",weekAbbreviation:"週",scrollTitle:"滾動切換",toggleTitle:"點擊切換 12/24 小時時制"};za.l10ns.zh_tw=qa,za.l10ns;var dd={ar:a,at:c,az:d,be:h,bg:x,bn:w,bs:p,ca:b,ckb:N,cat:b,cs:T,cy:_,da:M,de:R,default:s({},L),en:L,eo:U,es:O,et:J,fa:Q,fi:we,fo:V,fr:ce,gr:de,he:Te,hi:G,hr:re,hu:ue,hy:je,id:ge,is:Me,it:Be,ja:ke,ka:Ve,ko:Y,km:ie,kz:He,lt:B,lv:I,mk:q,mn:Re,ms:xe,my:Je,nl:it,nn:lt,no:oa,pa:ca,pl:da,pt:ha,ro:pa,ru:va,si:wa,sk:xa,sl:Sa,sq:Ta,sr:Aa,sv:Na,th:ka,tr:Ia,uk:Pa,vn:Ua,zh:Ba,zh_tw:qa,uz:Oa,uz_latn:Va};n.default=dd,Object.defineProperty(n,"__esModule",{value:!0})}))})(Ft,Ft.exports)),Ft.exports}var uh=ch();const dh=Or(uh);var nn={exports:{}},fh=nn.exports,Io;function hh(){return Io||(Io=1,(function(e,t){(function(n,s){e.exports=s()})(fh,(function(){var n=function(){return n=Object.assign||function(d){for(var u,h=1,m=arguments.length;h<m;h++){u=arguments[h];for(var p in u)Object.prototype.hasOwnProperty.call(u,p)&&(d[p]=u[p])}return d},n.apply(this,arguments)},s=function(l,d,u){return u.months[d?"shorthand":"longhand"][l]};function r(l){for(;l.firstChild;)l.removeChild(l.firstChild)}function a(l){try{if(typeof l.composedPath=="function"){var d=l.composedPath();return d[0]}return l.target}catch{return l.target}}var i={shorthand:!1,dateFormat:"F Y",altFormat:"F Y",theme:"light"};function c(l){var d=n(n({},i),l);return function(u){u.config.dateFormat=d.dateFormat,u.config.altFormat=d.altFormat;var h={monthsContainer:null};function m(){if(u.rContainer){r(u.rContainer);for(var A=0;A<u.monthElements.length;A++){var M=u.monthElements[A];M.parentNode&&M.parentNode.removeChild(M)}}}function p(){u.rContainer&&(h.monthsContainer=u._createElement("div","flatpickr-monthSelect-months"),h.monthsContainer.tabIndex=-1,g(),u.rContainer.appendChild(h.monthsContainer),u.calendarContainer.classList.add("flatpickr-monthSelect-theme-"+d.theme))}function g(){if(h.monthsContainer){r(h.monthsContainer);for(var A=document.createDocumentFragment(),M=0;M<12;M++){var k=u.createDay("flatpickr-monthSelect-month",new Date(u.currentYear,M),0,M);k.dateObj.getMonth()===new Date().getMonth()&&k.dateObj.getFullYear()===new Date().getFullYear()&&k.classList.add("today"),k.textContent=s(M,d.shorthand,u.l10n),k.addEventListener("click",C),A.appendChild(k)}h.monthsContainer.appendChild(A),u.config.minDate&&u.currentYear===u.config.minDate.getFullYear()?u.prevMonthNav.classList.add("flatpickr-disabled"):u.prevMonthNav.classList.remove("flatpickr-disabled"),u.config.maxDate&&u.currentYear===u.config.maxDate.getFullYear()?u.nextMonthNav.classList.add("flatpickr-disabled"):u.nextMonthNav.classList.remove("flatpickr-disabled")}}function x(){u._bind(u.prevMonthNav,"click",function(A){A.preventDefault(),A.stopPropagation(),u.changeYear(u.currentYear-1),w(),g()}),u._bind(u.nextMonthNav,"click",function(A){A.preventDefault(),A.stopPropagation(),u.changeYear(u.currentYear+1),w(),g()}),u._bind(h.monthsContainer,"mouseover",function(A){u.config.mode==="range"&&u.onMouseOver(a(A),"flatpickr-monthSelect-month")})}function v(){if(u.rContainer&&u.selectedDates.length){for(var A=u.rContainer.querySelectorAll(".flatpickr-monthSelect-month.selected"),M=0;M<A.length;M++)A[M].classList.remove("selected");var k=u.selectedDates[0].getMonth(),R=u.rContainer.querySelector(".flatpickr-monthSelect-month:nth-child("+(k+1)+")");R&&R.classList.add("selected")}}function w(){var A=u.selectedDates[0];if(A&&(A=new Date(A),A.setFullYear(u.currentYear),u.config.minDate&&A<u.config.minDate&&(A=u.config.minDate),u.config.maxDate&&A>u.config.maxDate&&(A=u.config.maxDate),u.currentYear=A.getFullYear()),u.currentYearElement.value=String(u.currentYear),u.rContainer){var M=u.rContainer.querySelectorAll(".flatpickr-monthSelect-month");M.forEach(function(k){k.dateObj.setFullYear(u.currentYear),u.config.minDate&&k.dateObj<u.config.minDate||u.config.maxDate&&k.dateObj>u.config.maxDate?k.classList.add("flatpickr-disabled"):k.classList.remove("flatpickr-disabled")})}v()}function C(A){A.preventDefault(),A.stopPropagation();var M=a(A);if(M instanceof Element&&!M.classList.contains("flatpickr-disabled")&&!M.classList.contains("notAllowed")&&(b(M.dateObj),u.config.closeOnSelect)){var k=u.config.mode==="single",R=u.config.mode==="range"&&u.selectedDates.length===2;(k||R)&&u.close()}}function b(A){var M=new Date(u.currentYear,A.getMonth(),A.getDate()),k=[];switch(u.config.mode){case"single":k=[M];break;case"multiple":k.push(M);break;case"range":u.selectedDates.length===2?k=[M]:(k=u.selectedDates.concat([M]),k.sort(function(R,L){return R.getTime()-L.getTime()}));break}u.setDate(k,!0),v()}var y={37:-1,39:1,40:3,38:-3};function N(A,M,k,R){var L=y[R.keyCode]!==void 0;if(!(!L&&R.keyCode!==13)&&!(!u.rContainer||!h.monthsContainer)){var z=u.rContainer.querySelector(".flatpickr-monthSelect-month.selected"),U=Array.prototype.indexOf.call(h.monthsContainer.children,document.activeElement);if(U===-1){var Z=z||h.monthsContainer.firstElementChild;Z.focus(),U=Z.$i}L?h.monthsContainer.children[(12+U+y[R.keyCode])%12].focus():R.keyCode===13&&h.monthsContainer.contains(document.activeElement)&&b(document.activeElement.dateObj)}}function E(){var A;((A=u.config)===null||A===void 0?void 0:A.mode)==="range"&&u.selectedDates.length===1&&u.clear(!1),u.selectedDates.length||g()}function T(){d._stubbedCurrentMonth=u._initialDate.getMonth(),u._initialDate.setMonth(d._stubbedCurrentMonth),u.currentMonth=d._stubbedCurrentMonth}function S(){d._stubbedCurrentMonth&&(u._initialDate.setMonth(d._stubbedCurrentMonth),u.currentMonth=d._stubbedCurrentMonth,delete d._stubbedCurrentMonth)}function _(){if(h.monthsContainer!==null)for(var A=h.monthsContainer.querySelectorAll(".flatpickr-monthSelect-month"),M=0;M<A.length;M++)A[M].removeEventListener("click",C)}return{onParseConfig:function(){u.config.enableTime=!1},onValueUpdate:v,onKeyDown:N,onReady:[T,m,p,x,v,function(){u.config.onClose.push(E),u.loadedPlugins.push("monthSelect")}],onDestroy:[S,_,function(){u.config.onClose=u.config.onClose.filter(function(A){return A!==E})}]}}}return c}))})(nn)),nn.exports}var mh=hh();const ph=Or(mh),Ro=(e,t,n,s,r=!1,a)=>{const i={...dh[s]},c=ph;r&&(i.firstDayOfWeek=1);const l=new Date(e);l.setHours(0,0,0,0);const d=new Date(t);d.setHours(23,59,59,999);const u={minDate:n===ne.CalendarResolution.MONTH?new Date(e.getFullYear(),e.getMonth()):l,maxDate:n===ne.CalendarResolution.MONTH?new Date(t.getFullYear(),t.getMonth()):d,locale:i};return n===ne.CalendarResolution.MONTH?{...u,dateFormat:"M Y",plugins:[new c({shorthand:!0,dateFormat:"M Y"})]}:{...u,monthSelectorType:"static",dateFormat:a||"d.m.Y"}},Po=e=>{e?.setMinutes(e.getMinutes()-e.getTimezoneOffset())},gh={year:"numeric",month:"short",day:"numeric"},fn=(e,t)=>e?.toLocaleDateString(t,gh)||"",vh=(e,t)=>{const{startPeriod:n,endPeriod:s}=e;if(!t.startPeriod&&!t.endPeriod&&n&&s)return{startPeriod:new Date(n?.getTime()),endPeriod:new Date(s?.getTime())};const r=n?new Date(Math.max(n.getTime(),t.startPeriod.getTime())):t.startPeriod,a=s?new Date(Math.min(s.getTime(),t.endPeriod.getTime())):t.endPeriod;return{startPeriod:r,endPeriod:a}},Ch=(e,t)=>{const{endPeriod:n}=e,s=n?.getFullYear()||new Date().getFullYear(),r=s+ +t,a=new Date(+t<0?s:r,n?.getMonth()||0,n?.getDate()||1),i=new Date(+t<0?r:s,0,1);return{startPeriod:new Date(Math.max(i.getTime(),e?.startPeriod?.getTime()||0)),endPeriod:a}},wh=e=>({quarterly:e?.quarterly||"Q",monthly:e?.monthly||"M"}),lc=(e,t)=>{const n=wh(t);return D.isQuarterly(e)&&n?.quarterly?e?.replace(/Q/g,n?.quarterly):D.isMonthly(e)&&n?.monthly?e?.replace(/M/g,n?.monthly):e},bh=(e,t)=>{const n={...e};return(!e.startPeriod&&t?.startPeriod||t?.startPeriod&&e?.startPeriod&&t.startPeriod<e?.startPeriod)&&(n.startPeriod=t?.startPeriod||null),(!e.endPeriod&&t?.endPeriod||t?.endPeriod&&e?.endPeriod&&t.endPeriod>e?.endPeriod)&&(n.endPeriod=t?.endPeriod||null),n},Lo=e=>{if(!e?.length)return null;let t=null,n=null;for(const s of e){const r=s.filters?.find(l=>l.componentCode===D.TIME_PERIOD);if(!r)continue;const a=r.values.filter(Boolean),i=a[0]?ne.getTimePeriod(a[0]):null,c=a[1]?ne.getTimePeriod(a[1]):null;!i||!c||((!t||i<t)&&(t=i),(!n||c>n)&&(n=c))}return t&&n?{startPeriod:t,endPeriod:n}:null};var nt=(e=>(e.FLAT_LIST="FLAT_LIST",e.HIERARCHY="HIERARCHY",e))(nt||{});const cc=(e,t,n,s,r)=>e?.map(a=>{const i=D.findCodelistByDimension(t?.codelists,t?.conceptSchemes,a)?.codes,c=D.getAvailableCodes(a,n,i,s),l=i?.some(d=>d?.parent);return{id:a?.id,title:D.getDimensionTitle(t?.conceptSchemes,a,s),dimensionValues:c,isTimeDimension:a?.type===D.DimensionType.TIME_DIMENSION,isHierarchical:l,displayMode:l?nt.HIERARCHY:nt.FLAT_LIST,datasetUrn:r,filterType:"dataset"}})||[],sn=e=>e?.filterType==="shared",Ke=e=>{if(e?.id)return sn(e)?`shared:${e.id}`:e?.datasetUrn?`${e.datasetUrn}:${e.id}`:e.id},Fe=(e,t)=>Ke(e)===Ke(t),hn=(e,t)=>e?.map(n=>t&&Fe(n,t)?{...t,isSelectedFilter:!0}:{...n,isSelectedFilter:!1}),uc=(e,t,n)=>e?e.map(s=>Fe(s,t)?{...s,displayMode:n}:s):[],dc=e=>e?.filter(t=>!!t?.isSelectedValue)||[],Tn=e=>e?.map(t=>({...t,dimensionValues:dc(t?.dimensionValues)})).filter(t=>t.dimensionValues?.length||t.timeRange?.startPeriod||t.timeRange?.endPeriod),Gr=e=>e?.reduce((t,n)=>(n?.dimensionValues?.length??0)+t,0)||0,fc=e=>({...e,dimensionValues:e?.dimensionValues?.map(t=>({...t,isSelectedValue:!1})),timeRange:void 0}),hc=(e,t)=>e?.map(n=>Fe(n,t)?fc(n):n),mc=e=>e?.map(t=>fc(t)),pc=(e,t,n)=>e.map(s=>{const r=t?.filters?.find(i=>i.componentCode===s.id);let a=[];if(r)if(s.isTimeDimension){const i=r.values.filter(h=>!!h),c=D.getAnnotationPeriod(n?.[0]?.annotations),l=i[0]?ne.getTimePeriod(i[0]):null,d=i[1]?ne.getTimePeriod(i[1]):null;let u=c;return l&&d&&(u=c?vh({startPeriod:l,endPeriod:d},c):{startPeriod:l,endPeriod:d}),{...s,timeRange:u}}else a=s?.dimensionValues?.map(c=>r?.values?.includes(c.id)?{...c,isSelectedValue:!0}:c);else a=s.dimensionValues;return{...s,dimensionValues:a}}),mn=e=>e?.map(t=>({...t,isDisabled:!0})),xh=e=>new Map(e?.map(t=>[t.id,{...t,children:[]}])),yh=e=>{if(!e)return[];const t=xh(e),n=[];return e.forEach(s=>{if(s&&s.parent){const r=t.get(s.parent),a=t.get(s.id);r&&r.children&&a&&(r.children=[...r.children,a])}else{const r=t.get(s.id);r&&n.push(r)}}),n},Sh=(e,t=!1)=>t?`${e*j.TREE_NODE_PADDING-j.TREE_NODE_ARROW_SIZE}px`:`${e*j.TREE_NODE_PADDING}px`,gc=e=>e?.children?.reduce((t,n)=>[...t,n,...gc(n)],[])||[],Dh=(e,t)=>e?e.filter(n=>!n.disabled).map(n=>({...n,isSelectedValue:t})):[],vc=e=>!!e?.children?.some(t=>t?.isSelectedValue||vc(t)),Th=e=>{const t=gc(e);if(!e.children?.length)return[{...e,isSelectedValue:!e.isSelectedValue}];const n=(c,l)=>[{...e,isSelectedValue:c},...Dh(t,l)];if(!e.isSelectableValue)return e.isSelectedValue?n(!1,!1):n(!0,!0);const s=t.filter(c=>!c.disabled),r=s.some(c=>c.isSelectedValue),a=s.length>0&&s.every(c=>c.isSelectedValue),i=!!e.isSelectedValue;return!i&&!r?n(!0,!0):i&&a?n(!1,!0):!i&&r?n(!0,!1):i&&!r?n(!1,!1):n(!0,!0)},Mh=(e,t)=>e.filter(n=>n.isSelectableValue&&!t.has(n.id)).map(n=>({id:n.id,name:n.name,isSelectedValue:n.isSelectedValue})),Ah=({isHierarchical:e,availableHierarchies:t,titles:n})=>[{key:"",title:n?.flatList??"Flat list"},...e?[{key:nt.HIERARCHY,title:n?.hierarchy??"Hierarchy by parent"}]:[],...(t??[]).map(s=>({key:s.id,title:`${s.name??s.id} (${s.version})`}))],Eh=({calendarResolution:e,timeRange:t,timeRangeOptions:n,calendarStartFromMonday:s=!0,locale:r=ne.Locale.EN,radioIcon:a,initialConstraints:i,onValueChange:c,calendarIcon:l,dateFormat:d,defaultTimeOption:u,dataQueries:h})=>{const{titles:m}=De(),p=bh(D.getAnnotationPeriod(i?.[0]?.annotations),t),x=!!!(p?.startPeriod||p?.endPeriod)&&!t?Lo(h):null,v=x??p,[w,C]=f.useState(t??x),b=!t||t?.startPeriod?.getTime()===v?.startPeriod?.getTime()&&t?.endPeriod?.getTime()===v?.endPeriod?.getTime()?0:ne.CUSTOM_PERIOD,[y,N]=f.useState(u??b),E=f.useMemo(()=>{const{startPeriod:M,endPeriod:k}=v,R=M?.getFullYear(),L=k?.getFullYear(),z=new Date().getFullYear();return n.filter(U=>U.value===ne.CUSTOM_PERIOD||U.value===0||+U.value>=0&&L-z>=+U.value||+U.value<0&&R-z<+U.value)},[v,n]);f.useEffect(()=>{c(w,y)},[w]),f.useEffect(()=>{if(t!==null)return;const M=D.getAnnotationPeriod(i?.[0]?.annotations);M?.startPeriod||M?.endPeriod||C(Lo(h))},[t]);const T=M=>{M&&(Po(M),C(k=>k?{...k,startPeriod:M||null}:{endPeriod:null,startPeriod:M||null}))},S=M=>{M&&(Po(M),C(k=>k?{...k,endPeriod:M||null}:{startPeriod:null,endPeriod:M||null}))};if(v==null)return null;const _=Ro(v.startPeriod,w?.endPeriod||v.endPeriod,e,r,s,d),A=Ro(w?.startPeriod||v.startPeriod,v.endPeriod,e,r,s,d);return o.jsxs("div",{className:"mt-3 flex h-full min-w-0 flex-1 flex-col overflow-auto py-2 pr-3",children:[o.jsx("div",{className:"w-full",children:E.map(M=>o.jsx(j.Radio,{id:M.value.toString(),checked:y===M.value,label:M.title,onChange:()=>{const{value:k}=M;N(k),k!==ne.CUSTOM_PERIOD&&C(k===0?v:Ch(v,k))},radioIcon:a},M.value.toString()))}),o.jsx("div",{className:"w-full",children:y===ne.CUSTOM_PERIOD&&o.jsxs("div",{className:"filters-time-period caption mt-3 flex gap-4 text-neutral-700",children:[o.jsx(j.Calendar,{onChange:T,options:_,value:w?.startPeriod||v?.startPeriod,label:m?.from||"From",id:"time-options-start",icon:l}),o.jsx(j.Calendar,{onChange:S,options:A,value:w?.endPeriod||v?.endPeriod,label:m?.to||"To",id:"time-options-end",icon:l,isEndDate:!0})]})})]})},Nh={isMetadataInSidePanel:!1,isCrossDatasetModeOn:!1,isTableSettingsFeatureEnabled:!1},Cc=f.createContext(Nh);function jh({children:e,isMetadataInSidePanel:t=!1,isCrossDatasetModeOn:n=!1,isTableSettingsFeatureEnabled:s=!1}){const r=f.useMemo(()=>({isMetadataInSidePanel:t,isCrossDatasetModeOn:n,isTableSettingsFeatureEnabled:s}),[t,n,s]);return o.jsx(Cc.Provider,{value:r,children:e})}function We(){return f.useContext(Cc)}const kh=2,wc=({value:e,onChange:t,searchIconSize:n})=>{const{titles:s}=De(),{isCrossDatasetModeOn:r}=We(),[a,i]=f.useState(!1),c=e.trim().toLowerCase(),l=r&&a&&c.length<kh;return o.jsxs(o.Fragment,{children:[o.jsx(j.InputWithIcon,{inputId:"filters-search-input",containerClasses:"gap-2 items-center filters-search-input",cssClass:"filters-search-input-text",placeholder:s?.searchPlaceholder??"Search",value:e,onChange:t,onFocus:()=>i(!0),onBlur:()=>i(!1),iconBeforeInput:o.jsx(qe.IconSearch,{width:n,height:n,className:"text-primary"})}),r&&o.jsx("span",{className:$("caption text-neutrals-800 mt-1",{invisible:!l}),children:s?.searchMinCharsCaption??"Enter at least 2 characters to start searching"})]})},_h=e=>Ee.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ee.createElement("path",{d:"M6.25 4.66668L9.75 8.00001L6.25 11.3333L6.25 4.66668Z",fill:"currentColor"})),bc=({node:e,level:t=1,checkboxIcon:n,selectFilterValue:s,selectHierarchicalNodes:r,expandHierarchicalValue:a})=>{const i=!!e?.children?.length,c=i&&!e.isSelectedValue&&vc(e),l="cursor-pointer text-neutrals-1000 w-6 h-6 shrink-0",d=f.useId(),u=(h,m)=>{if(e?.children?.length){const p=e.children.some(g=>!g.disabled);r?.(p?Th(e):[{...e,isSelectedValue:m}])}else s?.(e.id,m)};return o.jsxs("div",{className:"flex flex-col",children:[o.jsxs("div",{className:"flex items-center",style:{paddingLeft:Sh(t,i)},children:[i&&(e?.isExpanded?o.jsx(_h,{className:l,onClick:()=>a?.(e)}):o.jsx(Ur,{className:l,onClick:()=>a?.(e)})),o.jsx(j.Checkbox,{id:d,label:e?.name,checked:!!e.isSelectedValue,indeterminate:c,checkboxIcon:n,disabled:e?.disabled,onChange:u})]}),i&&e?.isExpanded&&o.jsx(o.Fragment,{children:e?.children?.map(h=>o.jsx(bc,{node:h,level:t+1,checkboxIcon:n,selectFilterValue:s,selectHierarchicalNodes:r,expandHierarchicalValue:a},h?.id))})]},e?.id)},Ih=({treeNodes:e,checkboxIcon:t,selectFilterValue:n,selectHierarchicalNodes:s,expandHierarchicalValue:r})=>o.jsx(o.Fragment,{children:e?.map(a=>o.jsx(bc,{node:a,checkboxIcon:t,selectFilterValue:n,selectHierarchicalNodes:s,expandHierarchicalValue:r},a?.id))}),Oo=({style:e,filterValue:t,checkboxIcon:n,selectFilterValue:s})=>o.jsx("div",{style:e,children:o.jsx(j.Checkbox,{id:t.id,label:t.name,checked:!!t.isSelectedValue,checkboxIcon:n,onChange:s})}),rn=(e,t,n,s,r=ne.Locale.EN)=>{const a=t?.map(i=>{const c=D.findCodelistByDimension(n?.codelists,n?.conceptSchemes,i),l=D.getAvailableCodesFromConstrains(c?.codes,i.id,s,r);return{...i,dimensionValues:l}});return e?.map(i=>{const c=a?.find(m=>m.id===i.id),d=(c?.dimensionValues||[]).map(m=>{const p=i.dimensionValues?.find(g=>g?.id===m?.id)?.isSelectedValue;return{...m,isSelectedValue:p}}),u=new Set(d.map(m=>m.id)),h=c?(i.dimensionValues??[]).filter(m=>!!m.isSelectedValue&&!u.has(m.id)):[];return{...i,isDisabled:!1,dimensionValues:[...d,...h]}})||[]},Ar=(e,t,n)=>{let s=[];return Mn(e,t,n).filter(r=>r.timeRange||r.dimensionValues?.some(a=>a.isSelectedValue)).forEach(r=>{const{id:a,dimensionValues:i}=r;r.isTimeDimension?s=[...s,...Rh(r.timeRange,a)]:s.push({componentCode:a,operator:D.SeriesFilterOperator.EQUALS,value:i?.filter(c=>c.isSelectedValue)?.map(c=>c.id).join(D.GET_v3_FILTER_AND)||""})}),s},Rh=(e,t)=>e==null||e.startPeriod==null||e.endPeriod==null?[]:[{componentCode:t,operator:D.SeriesFilterOperator.GREATER_OR_EQUAL,value:Fo(new Date(e.startPeriod))},{componentCode:t,operator:D.SeriesFilterOperator.LESS_OR_EQUAL,value:Fo(new Date(e.endPeriod),1)}],Ph=1e3*60*60*24,Fo=(e,t=0)=>{e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMinutes(e.getMinutes()-e.getTimezoneOffset());let n=e.getTime();return n+=t?Ph-1:0,e=new Date(n),n.toString()},Ht=e=>[...e].map(t=>({...t,value:t.value.split(",").sort().join(",")})).sort((t,n)=>t.componentCode.localeCompare(n.componentCode)),Vt=new Map,an=new Map;function xc(e,t){return`${e.name??""}::${t}`}function rt(...e){return JSON.stringify(e)}async function ot(e,t,n){const s=xc(e,t);if(Vt.has(s))return Vt.get(s);const r=an.get(s);if(r)return r;const a=n().then(i=>(Vt.set(s,i),i)).finally(()=>{an.delete(s)});return an.set(s,a),a}function Er(e,t){return Vt.has(xc(e,t))}function Vo(){Vt.clear(),an.clear()}const Lh=e=>e.map(t=>({componentCode:t.id||"",operator:ne.QueryFilterType.IN,values:t.dimensionValues?.map(n=>n.id)||[]})),yc=(e,t)=>{const n=t?.timeDimensions?.[0],s=D.getTimeRangeFromAttachment(e,n)||null;return s?D.getQueryTimePeriodFilters(s,n?.id):null},Sc=(e,t,n)=>{const s=Tn(Mn(e,n)),r=s.find(a=>a?.isTimeDimension&&a?.timeRange);return{filterKey:D.getTimeSeriesFilterKey(t||[],Lh(s)),timeFilter:D.getQueryTimePeriodFilters(r?.timeRange,r?.id)}},Oh=e=>{if(!e)return"";const t=String(e.getDate()).padStart(2,"0"),n=String(e.getMonth()+1).padStart(2,"0"),s=e.getFullYear();return`${n}-${t}-${s}`},Fh=e=>{if(!e)return"";const t=String(e.getDate()).padStart(2,"0"),n=String(e.getMonth()+1).padStart(2,"0");return`${e.getFullYear()}-${n}-${t}`},Dc=(e,t,n=Oh)=>Mn(e,t)?.filter(s=>s.timeRange||s.isExcluded||s.dimensionValues?.some(r=>r.isSelectedValue)).map(s=>s?.isTimeDimension?{componentCode:s?.id,operator:ne.QueryFilterType.BETWEEN,values:[n(s?.timeRange?.startPeriod||void 0)||"",n(s?.timeRange?.endPeriod||void 0)||""]}:s.isExcluded?{componentCode:s?.id,operator:ne.QueryFilterType.EXCLUDED,values:[]}:{componentCode:s?.id,operator:ne.QueryFilterType.IN,values:s?.dimensionValues?.filter(r=>r.isSelectedValue)?.map(r=>r.id)||[]}),Vh=(e,t)=>{const n=Mn(e,t).flatMap(r=>r.id?[r.id]:[]),s=e.flatMap(r=>{if(r.filterType!=="shared")return[];const a=r.sourceFilterIdsByDataset?.[t];return a?[a]:[]});return new Set([...n,...s])},Hh=(e,t)=>{const n=new Set(t.map(s=>s.componentCode));return Array.from(e).filter(s=>!n.has(s)).map(s=>({componentCode:s,operator:ne.QueryFilterType.IN,values:[D.GET_v3_FILTER_ALL]}))},Tc=(e,t)=>{const n=Uh(t,e.urn),s=Vh(t,e.urn),r=Hh(s,n),a=(e.filters??[]).filter(i=>!s.has(i.componentCode));return{...e,filters:[...a,...n,...r]}},Mc=(e,t)=>Dc(e,t),Uh=(e,t)=>Dc(e,t,Fh),Ac="COUNTRY",Ec="FREQUENCY",Dt="TIME_PERIOD",Gh=new Set([Ac,Ec,Dt]),on=e=>e?.trim()?.toLocaleUpperCase(),Ho=()=>(e,t)=>{const n=e?.name?.trim()?.toLocaleLowerCase();return n?Bh(n):zh(t||"",e.id)},Bh=e=>`name:${e}`,zh=(e,t)=>`dataset:${e}:id:${t}`,Nc=(e,t)=>e?t?.[e]:void 0,Uo=(e,t)=>{if(!(e?.filterType!=="dataset"||!e.id))return Nc(e.datasetUrn,t)?.[e.id]},jc=(e,t,n)=>Object.entries(Nc(e,n)||{}).find(([,s])=>t(s))?.[0],kc=(e,t,n)=>jc(e,s=>s.subtype===t,n),qh=(e,t)=>jc(e,n=>n.dimensionType==="TIME_PERIOD",t),At=[{id:Ac,subtype:"REGION",getMergedValueKey:Ho()},{id:Ec,subtype:"FREQUENCY",getMergedValueKey:Ho()},{id:Dt,getMergedValueKey:e=>e.id}],Wh=new Map(At.map(e=>[e.id,e])),Br=e=>e?Wh.get(on(e)||""):void 0,$h=(e,t,n)=>{if(e.filterType==="shared")return t.id===on(e.id);if(t.id===Dt)return e.isTimeDimension||Uo(e,n)?.dimensionType==="TIME_PERIOD"||t.id===on(e.id);const s=Uo(e,n);return t.subtype&&s?.subtype===t.subtype?!0:t.id===on(e.id)},pn=(e,t)=>e?At.find(n=>$h(e,n,t)):void 0,Kh=(e,t,n)=>{if(!t)return;const s=e?n?.[e]?.[t]:void 0;return s?.dimensionType==="TIME_PERIOD"?Dt:At.find(a=>!!a.subtype&&a.subtype===s?.subtype)?.id??Br(t)?.id},Jh=e=>!!Br(e),Yh=e=>e?.filterType==="shared"&&Jh(e?.id),_c=(e,t)=>!e||Array.isArray(e.get(t)),Ic=(e,t)=>!e?.dataMessagesMap||e.dataMessagesMap.has(t),Zh=(e,t)=>{const n=new Map;return e.forEach(s=>{s.dimensionValues?.forEach(r=>{const a=t.getMergedValueKey(r,s.datasetUrn),i={datasetUrn:s.datasetUrn,id:r.id,name:r.name,parent:r.parent},c=n.get(a);if(c){c.isSelectedValue=c.isSelectedValue||r.isSelectedValue,c.sourceValues=[...c.sourceValues||[],i];return}n.set(a,{id:a,name:r.name,isSelectedValue:r.isSelectedValue,parent:r.parent,sourceValues:[i]})})}),Array.from(n.values())},Rc=(e,t)=>{const n=new Map,s=[];return e.forEach(a=>{const i=pn(a,t);if(i&&a?.datasetUrn){const c=n.get(i.id)||[];n.set(i.id,[...c,a]);return}s.push(a)}),[...At.flatMap(a=>{const i=n.get(a.id);if(!i?.length)return[];const c={...i[0],id:a.id,datasetUrn:void 0,filterType:"shared",sourceDatasetUrns:Array.from(new Set(i.map(l=>l.datasetUrn).filter(l=>!!l))),sourceFilterIdsByDataset:Object.fromEntries(i.flatMap(l=>l.datasetUrn&&l.id?[[l.datasetUrn,l.id]]:[])),dimensionValues:Zh(i,a)};return c.isTimeDimension&&(c.timeRange=nm(i)),c}),...s]},zr=(e,t,n)=>{const s=e.sourceFilterIdsByDataset?.[t];if(s)return s;if(e.id===Dt)return qh(t,n);const r=Br(e.id);return r?.subtype?kc(t,r.subtype,n):void 0},Pc=(e,t,n,s)=>({...e,id:zr(e,t,s)||e.id,datasetUrn:t,filterType:"dataset",...n?{dimensionValues:n}:{}}),Xh=(e,t)=>(e.sourceDatasetUrns||[]).map(n=>Pc(e,n,void 0,t)),Qh=(e,t)=>({id:t.id,name:t.name,parent:t.parent,isSelectedValue:e.isSelectedValue}),em=(e,t)=>{const n=new Map;return e.dimensionValues?.forEach(s=>{s.sourceValues?.forEach(r=>{const a=r.datasetUrn||"",i=n.get(a),c=Qh(s,r);if(i){i.dimensionValues=[...i.dimensionValues||[],c];return}n.set(a,Pc(e,a,[c],t))})}),n},tm=(e,t=!1,n)=>{if(!Yh(e))return[e];if(e.isTimeDimension)return Xh(e,n);const s=em(e,n);return Array.from(s.values())},nm=e=>{const t=e.map(s=>s.timeRange?.startPeriod).filter(s=>!!s),n=e.map(s=>s.timeRange?.endPeriod).filter(s=>!!s);if(!(!t.length||!n.length))return{startPeriod:new Date(Math.min(...t.map(s=>s.getTime()))),endPeriod:new Date(Math.max(...n.map(s=>s.getTime())))}},Lc=(e,t,n,s)=>t&&t<n?{startPeriod:new Date(n),endPeriod:new Date(n)}:e&&e>s?{startPeriod:new Date(s),endPeriod:new Date(s)}:{startPeriod:e?new Date(Math.max(e.getTime(),n.getTime())):new Date(n),endPeriod:t?new Date(Math.min(t.getTime(),s.getTime())):new Date(s)},sm=(e,t)=>{if(!e.isTimeDimension||!e.timeRange)return e;const{startPeriod:n,endPeriod:s}=D.getAnnotationPeriod(t?.[0]?.annotations);return!n||!s?e:{...e,timeRange:Lc(e.timeRange.startPeriod,e.timeRange.endPeriod,n,s)}},rm=(e,t)=>e?.dimensionsMap?new Map(Array.from(e.dimensionsMap.entries()).map(([n,s])=>[n,cc(s,e?.structuresMap?.get(n),e?.structureDimensionsMap?.get(n),t,n)])):new Map,am=(e,t,n=!0)=>new Map(Array.from(e?.dimensionsMap?.entries()||[]).map(([s,r])=>{const a=_c(e?.constraintsMap,s),i=Ic(e,s),c=r?.map(l=>{if(!a||n&&!i)return{...l,dimensionValues:[]};const d=D.findCodelistByDimension(e?.structuresMap?.get(s)?.codelists,e?.structuresMap?.get(s)?.conceptSchemes,l),u=D.getAvailableCodesFromConstrains(d?.codes,l.id,e?.constraintsMap?.get(s),t);return{...l,dimensionValues:u}})||[];return[s,c]})),im=e=>e.map(t=>({...t,isDisabled:!1,dimensionValues:t.dimensionValues?.filter(n=>n.isSelectedValue)||[]})),Oc=(e,t,n=!0)=>{const s=rm(e,t),r=am(e,t,n);return new Map(Array.from(s?.entries()||[]).map(([a,i])=>{const c=r?.get(a),l=i.map(d=>({...d,dimensionValues:c?.find(u=>u.id===d.id)?.dimensionValues||[]}));return[a,l]}))},Fc=(e,t,n,s)=>{const r=(a,i)=>t?.some(c=>c.urn!==a.urn&&c.filters?.some(l=>l.operator===ne.QueryFilterType.BETWEEN||!l.values?.length?!1:pn({id:l.componentCode,datasetUrn:c.urn,filterType:"dataset"},s)?.id===i.id))??!1;return Rc(t?.flatMap(a=>{const i=a?.urn,c=e?.get(i)||[],l=n?.get(i)||[];return pc(c,a,l).map(u=>{if(u.isTimeDimension||u.filterType!=="dataset")return u;const h=pn(u,s);return!h||h.id===Dt||a.filters?.some(g=>g.componentCode===u.id&&g.operator!==ne.QueryFilterType.BETWEEN)||!r(a,h)||u.dimensionValues?.some(g=>g.isSelectedValue)?u:{...u,dimensionValues:u.dimensionValues?.map(g=>({...g,isSelectedValue:!0}))}})})||[],s)},xt=(e,t,n=!1,s,r=new Set)=>{const a=e?.flatMap(i=>tm(i,n,s))?.reduce((i,c)=>{const l=c?.datasetUrn||"",d=sm(c,t?.get(l));return i.has(l)||i.set(l,[]),i?.get(l)?.push(d),i},new Map);if(r.size>0)for(const i of r)a.delete(i);return a},Vc=(e,t,n,s,r)=>{const a=e.filter(c=>c.filterType==="shared"&&!c.isTimeDimension&&(c.dimensionValues?.some(l=>l.isSelectedValue)??!1));if(!a.length)return new Set(t);const i=(c,l)=>{const d=zr(l,c,s);if(!d)return!1;if(r)return!(r.get(c)??[]).find(p=>p.id===d);const u=n?.find(h=>h.urn===c);return u?!u.filters?.some(h=>h.componentCode===d&&h.operator!==ne.QueryFilterType.BETWEEN):!1};return new Set(t.filter(c=>a.every(l=>l.dimensionValues?.some(d=>d.isSelectedValue&&d.sourceValues?.some(u=>u.datasetUrn===c))||i(c,l))))},Go=(e,t)=>t?(e||[]).filter(n=>t.has(n.urn)):e||[],jt=(e,t)=>t?new Map([...e].filter(([n])=>t.has(n))):e,Hc=(e,t)=>{const n=new Map;if(e?.forEach(s=>{s.filters?.forEach(r=>{if(r.operator===ne.QueryFilterType.BETWEEN||!r.values?.length)return;const a=pn({id:r.componentCode,datasetUrn:s.urn,filterType:"dataset"},t);if(!a||a.id===Dt)return;const i=n.get(a.id)??new Set;i.add(s.urn),n.set(a.id,i)})}),!!n.size)return e?.filter(s=>Array.from(n.values()).every(r=>r.has(s.urn))).map(s=>s.urn)??[]},om=(e,t)=>t?Array.from(new Set(e?.flatMap(n=>n.cubeRegions?.filter(s=>s.isIncluded).flatMap(s=>s.memberSelection?.filter(r=>r.componentId===t).flatMap(r=>r.selectionValues.map(a=>a.memberValue))??[])??[])??[])):[],lm=(e,t,n)=>{if(e.length<2||!t)return e;const s=e.flatMap(i=>At.flatMap(c=>{if(!c.subtype)return[];const l=kc(i.urn,c.subtype,n);return l?[{configId:c.id,dataQuery:i,dimensionId:l,filter:i.filters?.find(d=>d.componentCode===l&&d.operator!==ne.QueryFilterType.BETWEEN),availableValues:om(t.get(i.urn),l)}]:[]})),r=new Map;s.forEach(i=>{r.set(i.configId,[...r.get(i.configId)??[],i])});const a=new Map;return r.forEach(i=>{const c=i.filter(u=>u.filter?.values?.length),l=i.filter(u=>!u.filter);if(!c.length||!l.length)return;const d=new Set(l.flatMap(u=>u.availableValues));d.size&&c.forEach(u=>{const h=u.filter;if(!h?.values?.length)return;const m=new Set(u.availableValues),p=Array.from(new Set([...h.values,...Array.from(d).filter(g=>m.has(g))]));p.length>h.values.length&&a.set(h,p)})}),a.size?e.map(i=>{let c=!1;const l=i.filters?.map(d=>{const u=a.get(d);return u?(c=!0,{...d,values:u}):d});return c?{...i,filters:l}:i}):e},Uc=e=>JSON.stringify(e?.map(t=>({urn:t.urn,filters:t.filters??[]}))??[]),kt=(e,t,n=ne.Locale.EN,s)=>{const r=[];return Array.from(e?.entries())?.forEach(([a,i])=>{const c=t?.dimensionsMap?.get(a),l=t?.structuresMap?.get(a),d=_c(t?.constraintsMap,a),u=Ic(t,a);if(!d||!u){r.push(...im(i));return}const h=t?.constraintsMap?.get(a);r.push(...rn(i,c,l,h,n))}),Rc(r,s)},Mn=(e,t,n)=>t?xt(e,void 0,!1,n).get(t)||[]:e.filter(s=>s.filterType!=="shared"),Gc=(e,t)=>{if(e?.filterType==="shared")return;const n=e?.datasetUrn?t?.get(e.datasetUrn)?.dataflows?.[0]:void 0;return n?D.generateShortUrn(n?.name,"",n?.agencyID):void 0},cm=(e,t)=>e?.length?!!t?.dimensionsMap&&!!t?.structuresMap&&!!t?.structureDimensionsMap&&!!t?.constraintsMap:!1,Bc=(e,t,n)=>Ht(Ar(t,e,n).filter(s=>s.componentCode!==D.TIME_PERIOD)),Bo=(e,t,n,s,r)=>e?.map(a=>{const i=a?.urn??"",c=r??t?.get(i)??[],l=Bc(i,c,s);return n?ot(n.getConstraints,rt(i,l),()=>n.getConstraints(i,l)).then(d=>({urn:i,data:d})):Promise.resolve({urn:i,data:{}})})||[],zo=(e,t,n,s,r)=>!n?.getConstraints||!e?.length?!1:e.some(a=>{const i=a?.urn??"",c=r??t?.get(i)??[],l=Bc(i,c,s);return!Er(n.getConstraints,rt(i,l))}),um=(e,t,n)=>{if(e.length<2)return!1;const s=new Map;for(const r of e){const a=t.dimensionsMap?.get(r.urn);if(a)for(const i of a){const c=i.id;if(!c)continue;const l=n?.[r.urn]?.[c],d=l?.subtype;if(!d||l?.dimensionType==="TIME_PERIOD")continue;const u=At.find(p=>p.subtype===d);if(!u)continue;const h=s.get(u.id)??{datasetsWithExplicitValues:new Set,datasetsWithMissingFilter:new Set},m=r.filters?.find(p=>p.componentCode===c&&p.operator!==ne.QueryFilterType.BETWEEN);m?m.values?.length&&h.datasetsWithExplicitValues.add(r.urn):h.datasetsWithMissingFilter.add(r.urn),s.set(u.id,h)}}return[...s.values()].some(r=>[...r.datasetsWithMissingFilter].some(a=>[...r.datasetsWithExplicitValues].some(i=>i!==a)))},dm=e=>new Map(e?.flatMap(({urn:t,data:n})=>{const s=n?.data?.dataConstraints;return Array.isArray(s)?[[t,s]]:[]})),qo=e=>dm(e.flatMap(t=>t.status==="fulfilled"?[t.value]:[])),Wo=(e,t)=>{const n=new Map(e);return t.forEach((s,r)=>{n.set(r,s)}),n},zc=(e,t,n,s)=>{if(e&&t?.filterType==="shared"&&t?.isTimeDimension){const a=Array.from(s?.values()||[]).flatMap(l=>l||[]).map(l=>D.getAnnotationPeriod(l?.annotations)).filter(l=>l.startPeriod!==null&&l.endPeriod!==null);if(!a.length)return[];const i=new Date(Math.min(...a.map(l=>l.startPeriod.getTime()))),c=new Date(Math.max(...a.map(l=>l.endPeriod.getTime())));return[{id:t.id||D.TIME_PERIOD,annotations:[{id:D.TIME_PERIOD_START_ANNOTATION_KEY,title:i.toISOString()},{id:D.TIME_PERIOD_END_ANNOTATION_KEY,title:c.toISOString()}]}]}return e?s?.get(t?.datasetUrn??"")??[]:n??[]},qc=(e,t,n)=>new Map(t?.map(s=>{const r=s?.urn;return[r,Sc(e.get(r)||[],n?.get(r))]})),$o=(e,t,n,s,r)=>{const a=um(e,t,r);if(!n||!e.length||!a)return;const i={...t,constraintsMap:n},c=Oc(i,s,!1),l=Fc(c,e,n,r),d=xt(l,n,!1,r),u=Vc(l,e.map(m=>m.urn),e,r,d),h=e.filter(m=>u.has(m.urn));return{compatibleUrns:u,filterParamsMap:qc(d,h,t.dimensionsMap)}},Wc=(e,t)=>new Map(e?.map(n=>{const s=n?.urn;return[s,Mc(t?.get(s)||[])]})),fm=(e,t,n)=>{const s=(e.sourceDatasetUrns??[]).filter(c=>!t.has(c));if(s.length===0)return[];if(!n||!e.timeRange)return[{...e,sourceDatasetUrns:s}];const r=s.map(c=>D.getAnnotationPeriod(n.get(c)?.[0]?.annotations)).filter(c=>!!c?.startPeriod&&!!c?.endPeriod);if(r.length===0)return[{...e,sourceDatasetUrns:s}];const a=new Date(Math.min(...r.map(c=>c.startPeriod.getTime()))),i=new Date(Math.max(...r.map(c=>c.endPeriod.getTime())));return[{...e,sourceDatasetUrns:s,timeRange:Lc(e.timeRange.startPeriod,e.timeRange.endPeriod,a,i)}]},hm=(e,t,n)=>t.size===0?e:e.flatMap(s=>{if(s.filterType!=="shared")return[s];if(s.isTimeDimension)return fm(s,t,n);const r=(s.dimensionValues??[]).filter(a=>a.sourceValues?.some(i=>!t.has(i.datasetUrn??"")));return r.length===0?[]:[{...s,dimensionValues:r}]}),qr=e=>Ee.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ee.createElement("path",{d:"M8 14C6.32222 14 4.90278 13.7417 3.74167 13.225C2.58056 12.7083 2 12.0778 2 11.3333V4.66667C2 3.93333 2.58611 3.30556 3.75833 2.78333C4.93056 2.26111 6.34444 2 8 2C9.65556 2 11.0694 2.26111 12.2417 2.78333C13.4139 3.30556 14 3.93333 14 4.66667V11.3333C14 12.0778 13.4194 12.7083 12.2583 13.225C11.0972 13.7417 9.67778 14 8 14ZM8 6.01667C8.98889 6.01667 9.98333 5.875 10.9833 5.59167C11.9833 5.30833 12.5444 5.00556 12.6667 4.68333C12.5444 4.36111 11.9861 4.05556 10.9917 3.76667C9.99722 3.47778 9 3.33333 8 3.33333C6.98889 3.33333 5.99722 3.475 5.025 3.75833C4.05278 4.04167 3.48889 4.35 3.33333 4.68333C3.48889 5.01667 4.05278 5.32222 5.025 5.6C5.99722 5.87778 6.98889 6.01667 8 6.01667ZM8 9.33333C8.46667 9.33333 8.91667 9.31111 9.35 9.26667C9.78333 9.22222 10.1972 9.15833 10.5917 9.075C10.9861 8.99167 11.3583 8.88889 11.7083 8.76667C12.0583 8.64444 12.3778 8.50556 12.6667 8.35V6.35C12.3778 6.50556 12.0583 6.64444 11.7083 6.76667C11.3583 6.88889 10.9861 6.99167 10.5917 7.075C10.1972 7.15833 9.78333 7.22222 9.35 7.26667C8.91667 7.31111 8.46667 7.33333 8 7.33333C7.53333 7.33333 7.07778 7.31111 6.63333 7.26667C6.18889 7.22222 5.76944 7.15833 5.375 7.075C4.98056 6.99167 4.61111 6.88889 4.26667 6.76667C3.92222 6.64444 3.61111 6.50556 3.33333 6.35V8.35C3.61111 8.50556 3.92222 8.64444 4.26667 8.76667C4.61111 8.88889 4.98056 8.99167 5.375 9.075C5.76944 9.15833 6.18889 9.22222 6.63333 9.26667C7.07778 9.31111 7.53333 9.33333 8 9.33333ZM8 12.6667C8.51111 12.6667 9.03056 12.6278 9.55833 12.55C10.0861 12.4722 10.5722 12.3694 11.0167 12.2417C11.4611 12.1139 11.8333 11.9694 12.1333 11.8083C12.4333 11.6472 12.6111 11.4833 12.6667 11.3167V9.68333C12.3778 9.83889 12.0583 9.97778 11.7083 10.1C11.3583 10.2222 10.9861 10.325 10.5917 10.4083C10.1972 10.4917 9.78333 10.5556 9.35 10.6C8.91667 10.6444 8.46667 10.6667 8 10.6667C7.53333 10.6667 7.07778 10.6444 6.63333 10.6C6.18889 10.5556 5.76944 10.4917 5.375 10.4083C4.98056 10.325 4.61111 10.2222 4.26667 10.1C3.92222 9.97778 3.61111 9.83889 3.33333 9.68333V11.3333C3.38889 11.5 3.56389 11.6611 3.85833 11.8167C4.15278 11.9722 4.52222 12.1139 4.96667 12.2417C5.41111 12.3694 5.9 12.4722 6.43333 12.55C6.96667 12.6278 7.48889 12.6667 8 12.6667Z",fill:"currentColor"})),mm=e=>Ee.createElement("svg",{viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ee.createElement("path",{d:"M6.66663 6.175L10.4833 10L6.66663 13.825L7.84163 15L12.8416 10L7.84163 5L6.66663 6.175Z",fill:"currentColor"})),pm=md.FixedSizeList,Ko=24,Jo=232,Cr=({selectedFilter:e,filterValues:t,checkboxIcon:n,isHierarchicalView:s,isVirtualized:r=!0,isScrollable:a=!0,isDisableValues:i,isValuesLoading:c,structuresMap:l,hierarchyTreeNodes:d,isHierarchyLoading:u,selectFilterValue:h,selectHierarchicalNodes:m,expandHierarchicalValue:p})=>{const g=j.useIsMobile(),{isCrossDatasetModeOn:x}=We(),v=c||u;if(!t&&!v)return null;const w=t??[],C=e?Gc(e,l):void 0,b=l?.size===1,y=x&&e?.filterType!=="shared"&&!!e?.title&&(b||!!C),N=w.length*Ko,E=N>Jo?Jo:N;return o.jsxs("div",{className:$("relative",i&&"pointer-events-none opacity-[0.7]",a?"flex h-full min-h-0 flex-col":"flex flex-col"),children:[y&&o.jsxs("div",{className:"mb-2 flex items-center gap-x-1",children:[!b&&o.jsxs(o.Fragment,{children:[o.jsx(qr,{className:"size-4 shrink-0 text-neutrals-700"}),o.jsx("span",{className:"h4 text-neutrals-800",children:C}),o.jsx(mm,{className:"size-4 shrink-0 text-neutrals-1000"})]}),o.jsx("span",{className:"h4 text-neutrals-1000",children:e?.title})]}),v&&o.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 min-h-12",children:o.jsx(j.Loader,{})}),o.jsx("div",{className:$(a?"min-h-0 flex-1 overflow-auto":"overflow-visible",v&&"pointer-events-none opacity-[0.7]"),style:a&&g&&!v?{height:`${E}px`}:void 0,children:d?.length||s?o.jsx(Ih,{treeNodes:d??yh(w),checkboxIcon:n,selectFilterValue:h,selectHierarchicalNodes:m,expandHierarchicalValue:p}):r?o.jsx(pd,{children:({width:T,height:S})=>o.jsx(pm,{itemCount:w.length,itemSize:Ko,width:T,height:S,children:({index:_,style:A})=>o.jsx(Oo,{style:A,filterValue:w[_],checkboxIcon:n,selectFilterValue:h})})}):o.jsx("div",{className:"flex flex-col gap-y-1",children:w.map(T=>o.jsx(Oo,{filterValue:T,checkboxIcon:n,selectFilterValue:h},T.id))})})]})};function gm(e,t){const n=(e??"").split(".").map(Number),s=(t??"").split(".").map(Number),r=Math.max(n.length,s.length);for(let a=0;a<r;a++){const i=(n[a]??0)-(s[a]??0);if(i!==0)return i}return 0}function vm(e){const t=new Map;for(const n of e){const s=`${n.agencyID??""}:${n.id}`,r=t.get(s);(!r||gm(n.version??"",r.version??"")>0)&&t.set(s,n)}return Array.from(t.values())}function Yo(e){return D.generateShortUrn(e.id,e.version??"",e.agencyID??"")}function Zo(e,t,n,s,r){const a=D.getHierarchyCodes(e,t),i=D.getHierarchyAvailableCodes(a,n,s),c=D.getCodeListsData(t),l=Cm(e,c,i.map(d=>d.id),r);return Kc(l)}function $c(e,t,n,s,r){return s?.map(a=>{const{childId:i,agency:c,id:l,version:d}=D.getChildParsedUrn(a.code),u=D.generateShortUrn(l,d,c),h=Object.keys(e??{}).find(b=>D.urnMatchesIgnoreVersion(b,u))??u,p=e?.[h]?.find(b=>b.id===i),g=p?.name||p?.description||i,x=n?D.urnMatchesIgnoreVersion(u,n):!0,v=!x&&(a.hierarchicalCodes?.length??0)>0,w=$c(e,t,n,a.hierarchicalCodes,a.code),C=w.length===0;return v&&C||x&&C&&t&&!t.includes(i??"")?null:{id:a.code,name:g,children:w,isExpanded:!0,disabled:!x&&w.every(b=>b.disabled),isSelectableValue:x,parent:r,metadata:{...a,hierarchicalCodes:void 0}}}).filter(a=>a!==null)??[]}function Cm(e,t,n,s){return!n||n.length===0?[]:$c(t,n,s,e?.hierarchicalCodes,void 0)}function Kc(e){return e.map(t=>{const{childId:n}=D.getChildParsedUrn(t.id??"");return{id:n??t.id??"",name:t.name,isExpanded:t.isExpanded,isSelectedValue:!1,disabled:t.disabled,isSelectableValue:t.isSelectableValue,children:Kc(t.children)}})}function Jc(e,t){return e?.filterType!=="shared"?t:e.dimensionValues?.find(n=>n.id===t||n.sourceValues?.some(s=>s.id===t))?.id}function wm(e){return e?.filterType!=="shared"?new Set(e?.dimensionValues?.filter(t=>t.isSelectedValue).map(t=>t.id)??[]):new Set(e.dimensionValues?.flatMap(t=>t.isSelectedValue?t.sourceValues?.map(n=>n.id)??[]:[])??[])}function bm(e,t){if(!e?.length||t?.filterType!=="shared")return e??[];const n=new Map;return e.forEach(s=>{const r=Jc(t,s.id);r&&n.set(r,{...s,id:r})}),Array.from(n.values())}function xm(e,t){return Jc(t,e)}function Yc(e,t){return e.map(n=>{const s=n.children?.length?Yc(n.children,t):n.children;let r;if(t.has(n.id))r=!0;else if(s?.length&&!n.isSelectableValue){const a=s.filter(i=>!i.disabled);r=a.length>0&&a.every(i=>!!i.isSelectedValue)}else r=!1;return{...n,isSelectedValue:r,children:s}})}function Zc(e,t){return e.map(n=>n.id===t?{...n,isExpanded:!n.isExpanded}:n.children?.length?{...n,children:Zc(n.children,t)}:n)}function Xc(e,t){const n=t.toLowerCase();return e.reduce((s,r)=>{const a=r.name?.toLowerCase().includes(n),i=Xc(r.children??[],t);return(a||i.length>0)&&s.push({...r,isExpanded:!0,children:a?r.children:i}),s},[])}const Qc=f.createContext(null);function ym({children:e,value:t}){return o.jsx(Qc.Provider,{value:t,children:e})}function eu(){const e=f.useContext(Qc);if(!e)throw new Error("useFiltersModal must be used within FiltersModalProvider");return e}const Sm=2,tu=({filtersList:e,selectedFilter:t,initialConstraints:n,structuresMap:s,selectedTimeOption:r,hierarchyState:a})=>{const{titles:i}=De(),{locale:c,isDisableValues:l,isValuesLoading:d,timeRangeOptions:u,filterValuesProps:h,dataQueries:m,selectFilterValue:p,selectHierarchicalNodes:g,expandHierarchicalValue:x,onTimePeriodChange:v}=eu(),[w,C]=f.useState(""),{isCrossDatasetModeOn:b}=We(),y=t?.displayMode===nt.HIERARCHY,N=Ke(t),E=t?.filterType==="shared",T=w?.trim().toLowerCase(),S=b?T.length>=Sm:!!T,_=S&&b&&!E,A=f.useCallback(O=>{if(!O?.dimensionValues)return{filterValues:[],matchedCount:0};const K=O.dimensionValues.filter(J=>J?.name?.toLowerCase()?.includes(T));return{filterValues:O.displayMode===nt.HIERARCHY?D.getFilteredItemsWithParents(O.dimensionValues,K):K,matchedCount:K.length}},[T]),M=f.useMemo(()=>S?A(t).filterValues:t?.dimensionValues,[S,A,t]),k=f.useMemo(()=>_?(e||[]).reduce((O,K)=>{if(Fe(K,t)||K.filterType==="shared")return O;const{filterValues:J,matchedCount:X}=A(K);return X?[...O,{filter:K,filterValues:J,matchedCount:X,isHierarchicalView:K.displayMode===nt.HIERARCHY}]:O},[]):[],[_,e,t,A]),R=f.useMemo(()=>{const O=a?.treeNodes;if(!O?.length)return O;const K=wm(t),J=K.size?Yc(O,K):O;return S?Xc(J,T):J},[a?.treeNodes,t,S,T]),L=R?!R.length:!M?.length,z=!!d||!!a?.isLoading,U=f.useMemo(()=>k.reduce((O,K)=>O+K.matchedCount,0),[k]);f.useEffect(()=>{C("")},[N]);const Z=f.useCallback(O=>{C(O)},[C]);return o.jsx(o.Fragment,{children:t?.isTimeDimension&&n?o.jsx(Eh,{initialConstraints:n,calendarResolution:ne.CalendarResolution.DAY,timeRange:t?.timeRange||null,timeRangeOptions:u||[],calendarStartFromMonday:!0,locale:c,radioIcon:h?.radioIcon,onValueChange:v,calendarIcon:h?.calendarIcon,dateFormat:h?.dateFormat,defaultTimeOption:r,dataQueries:m}):o.jsxs("div",{className:$("flex flex-col py-2 h-full flex-1 min-w-0 sm:border-0","filter-values-container"),children:[o.jsx(wc,{value:w,onChange:Z,searchIconSize:h?.searchIconSize}),o.jsx("div",{className:"body-2 mt-3 flex min-h-0 flex-1 flex-col overflow-auto",children:_?o.jsxs(o.Fragment,{children:[t&&o.jsxs("div",{className:"shrink-0 pb-4",children:[o.jsx(Cr,{selectedFilter:t,filterValues:M,checkboxIcon:h?.checkboxIcon,isHierarchicalView:y,isVirtualized:!1,isScrollable:!1,isDisableValues:l,isValuesLoading:d,structuresMap:s,hierarchyTreeNodes:R,isHierarchyLoading:a?.isLoading,selectFilterValue:p,selectHierarchicalNodes:g,expandHierarchicalValue:x}),!z&&L&&o.jsx("span",{className:"body-2 text-neutrals-700",children:i?.noResultsInSection?.(t.title??"")??`No results found in ${t.title??""}`})]}),o.jsxs("div",{className:"pb-3",children:[o.jsxs("span",{className:"h2 text-neutrals-1000",children:[i?.otherResults??"Other results",":"," ",U]}),!d&&U===0&&o.jsx("p",{className:"body-2 mt-1 text-neutrals-700",children:i?.noResultsInOtherDimensions??"No results found in other dimensions"})]}),k.map(({filter:O,filterValues:K,isHierarchicalView:J})=>o.jsx("div",{className:"shrink-0 pb-4 last:pb-0",children:o.jsx(Cr,{selectedFilter:O,filterValues:K,checkboxIcon:h?.checkboxIcon,isHierarchicalView:J,isVirtualized:!1,isScrollable:!1,isDisableValues:l,isValuesLoading:d,structuresMap:s,selectFilterValue:(X,Q)=>p(X,Q,O),selectHierarchicalNodes:X=>g(X,O),expandHierarchicalValue:X=>x(X,O)})},Ke(O)))]}):o.jsx(Cr,{selectedFilter:t,filterValues:M,checkboxIcon:h?.checkboxIcon,isHierarchicalView:y,isDisableValues:l,isValuesLoading:d,structuresMap:s,hierarchyTreeNodes:R,isHierarchyLoading:a?.isLoading,selectFilterValue:p,selectHierarchicalNodes:g,expandHierarchicalValue:x})})]})})},Dm=({filtersList:e,filter:t,onSelectFilter:n,onSelectDisplayMode:s,onDeleteFilter:r,initialConstraints:a,hideFacetCounterByDefault:i,hierarchyState:c})=>{const{titles:l}=De(),{locale:d,onSelectHierarchy:u}=eu(),h=j.useIsMobile(),[m,p]=f.useState(0),[g,x]=f.useState(!1),v=t?.isTimeDimension&&t?.timeRange,w=f.useMemo(()=>t?.timeRange?.startPeriod&&t?.timeRange?.endPeriod?`${fn(t?.timeRange?.startPeriod,d)} -
6
+ ${fn(t?.timeRange?.endPeriod,d)}`:"",[d,t?.timeRange]);f.useEffect(()=>{p(dc(t?.dimensionValues)?.length)},[t?.dimensionValues]);const C=i?m>0:!0,b=f.useMemo(()=>Ah({isHierarchical:t?.isHierarchical,availableHierarchies:c?.availableHierarchies,titles:l}),[t?.isHierarchical,c?.availableHierarchies,l]),y=c?.isLoading||!t?.isHierarchical&&!c?.availableHierarchies?.length;f.useEffect(()=>{t.isSelectedFilter||x(!1)},[t.isSelectedFilter]);const N=()=>{h&&x(T=>!T),n(t)},E=T=>{if(T==="")u?.(t,null),s?.(t,nt.FLAT_LIST);else if(T===nt.HIERARCHY)u?.(t,null),s?.(t,nt.HIERARCHY);else{const S=c?.availableHierarchies?.find(_=>_.id===T)??null;u?.(t,S)}};return o.jsxs("div",{className:"flex flex-col",children:[o.jsxs("div",{className:$("flex justify-between items-center px-2 h-10 hover:bg-hues-100 sm:h-14 sm:hover:bg-white rounded","filters-facet-item cursor-pointer",t?.isSelectedFilter&&!h&&"bg-hues-100",t?.isDisabled&&"cursor-default pointer-events-none opacity-[0.7]"),onClick:N,children:[o.jsxs("h3",{className:"w-full min-w-0 flex-1 truncate sm:flex sm:items-center",title:t?.title,children:[o.jsx("span",{className:"truncate",children:t?.title}),h&&o.jsx(Ur,{className:$("chevron-icon w-6 h-6 shrink-0",g&&"rotate-180")})]}),o.jsxs("div",{className:"ml-2 flex items-center gap-2 text-neutrals-800",children:[v&&o.jsx("span",{className:"filters-facet-item-counter border-none",children:w}),!v&&C&&o.jsx("span",{className:$("px-2 text-center","filters-facet-item-counter"),children:m?`${m}/${t?.dimensionValues?.length||0}`:l?.all||"All"}),v?null:o.jsxs("div",{className:"filters-facet-item-settings flex items-center gap-2",children:[o.jsx(j.Dropdown,{triggerButton:o.jsx(j.IconButton,{buttonClassName:$("text-button-tertiary w-4 h-4 border-0 p-0","filters-facet-item-icon"),icon:o.jsx(oh,{width:16,height:16}),title:l?.displayOrder||"Display Order",disabled:y}),disabled:y,options:b,selectedOption:c?.selectedHierarchy?.id??(t?.displayMode===nt.HIERARCHY?nt.HIERARCHY:""),onOptionSelect:E}),m>0&&o.jsx(j.IconButton,{buttonClassName:$("text-button-tertiary w-4 h-4 border-0 p-0","filters-facet-item-icon"),icon:o.jsx(oc,{width:16,height:16}),title:l?.reset||"Reset",onClick:T=>{T.stopPropagation(),r?.(t)}})]})]})]}),g&&o.jsx(tu,{filtersList:e,selectedFilter:t,initialConstraints:a,hierarchyState:c})]})},Tm=new Set,Mm=({filtersList:e,hideFacetCounterByDefault:t,onSelectFilter:n,onDeleteFilter:s,onSelectDisplayMode:r,initialConstraints:a,initialConstraintsMap:i,datasetIcon:c,structuresMap:l,hierarchyStateMap:d,dataQueries:u,disabledDatasetUrns:h=Tm,isDatasetFacetSelected:m=!1,onSelectDatasetFacet:p,onClearAllDatasets:g})=>{const{isCrossDatasetModeOn:x}=We(),v=x&&!!u?.length,w=new Set(e.filter(C=>C.filterType==="dataset").map(C=>C.datasetUrn||"")).size;return o.jsxs("div",{className:$("overflow-y-auto advanced-view-filters-list w-[338px] pr-3 h-full sm:w-full"),children:[v&&o.jsx(ih,{dataQueries:u,disabledDatasetUrns:h,isSelected:m,onSelect:p,onClearAll:g}),e.filter(C=>!(C.filterType==="dataset"&&C.datasetUrn&&h.has(C.datasetUrn))).map((C,b,y)=>{const N=y[b-1],T=C.filterType==="dataset"&&w>1&&C.datasetUrn!==N?.datasetUrn?Gc(C,l):void 0;return o.jsxs("div",{className:"min-w-0 shrink-0",children:[T&&o.jsxs("h4",{className:"filters-facet-dataset-name !flex",children:[o.jsx("span",{className:"filters-facet-dataset-icon",children:c}),o.jsx("span",{className:"min-w-0 truncate",title:T,children:T})]}),o.jsx(Dm,{filtersList:y,filter:C,onSelectFilter:n,onSelectDisplayMode:r,onDeleteFilter:s,hideFacetCounterByDefault:t,initialConstraints:zc(x,C,a,i),hierarchyState:d?.get(Ke(C)??"")})]},Ke(C))})]})},Am=({dataQueries:e,disabledDatasetUrns:t,onToggleDataset:n,searchIconSize:s})=>{const[r,a]=f.useState(""),i=r.trim().toLowerCase(),c=e.filter(d=>i.length<2||(d.title??d.urn).toLowerCase().includes(i)),l=e.length-t.size;return o.jsxs("div",{className:"filter-values-container flex h-full min-w-0 flex-1 flex-col py-2 sm:border-0",children:[o.jsx(wc,{value:r,onChange:a,searchIconSize:s}),o.jsx("div",{className:"body-2 mt-3 flex min-h-0 flex-1 flex-col overflow-auto",children:c.map(d=>{const u=!t.has(d.urn),h=u&&l===1;return o.jsx("div",{className:$("py-1",h&&"pointer-events-none"),children:o.jsx(j.Checkbox,{id:d.urn,label:d.title??d.urn,checked:u,disabled:h,disabledScope:"icon",onChange:(m,p)=>n(d.urn,!!p)})},d.urn)})})]})},nu=({filtersList:e,selectedFilter:t,modalProps:n,locale:s,isDisableValues:r,isValuesLoading:a,timeSeriesCount:i,timeRangeOptions:c,initialConstraints:l,initialConstraintsMap:d,datasetIcon:u,structuresMap:h,setSelectedFilter:m,onSelectDisplayMode:p,onDeleteFilter:g,onClearAllFilters:x,updateSelectedFilterValues:v,onTimePeriodChange:w,selectedTimeOption:C,hierarchyStateMap:b,onSelectHierarchy:y,onExpandHierarchyNode:N,dataQueries:E,disabledDatasetUrns:T,onToggleDataset:S,onClearAllDatasets:_})=>{const{titles:A}=De(),M=b?.get(Ke(t)),k=j.useIsMobile(),{isCrossDatasetModeOn:R}=We(),[L,z]=f.useState(!1),U=f.useMemo(()=>hm(e.filter(V=>!(V.filterType==="dataset"&&V.datasetUrn&&T.has(V.datasetUrn))),T,d),[e,T,d]),Z=f.useMemo(()=>t?U.find(V=>Fe(V,t)):void 0,[t,U]),O=Gr(Tn(e))+T.size,K=f.useCallback(()=>{z(!0),m(void 0)},[m]),J=f.useCallback(V=>{z(!1);const W=e?.find(ce=>Fe(ce,V));if(!W){m(void 0);return}m({...W,isSelectedFilter:!0})},[e,m]),X=V=>V?e?.find(W=>Fe(W,V)):void 0,Q=(V,W,ce)=>{const fe=!ce||Fe(ce,t),de=X(ce??t)??ce??t;if(!de)return;const Ne=sn(de)?xm(V,de):V;if(!Ne)return;const Te={...de,dimensionValues:de?.dimensionValues?.map(F=>F?.id===Ne?{...F,isSelectedValue:W}:F)};fe&&m(Te),v&&v(Te)},pe=(V,W)=>{const ce=!W||Fe(W,t),fe=X(W??t)??W??t;if(!fe)return;const de=sn(fe)?bm(V,fe):V??[],Ne=new Set(fe?.dimensionValues?.map(G=>G.id)),Te=sn(fe)?[]:Mh(de,Ne),F={...fe,dimensionValues:[...fe?.dimensionValues?.map(G=>{const oe=de.find(re=>re?.id===G?.id);return oe?{...G,isSelectedValue:oe.isSelectedValue}:G})??[],...Te]};ce&&m(F),v&&v(F)},we=(V,W)=>{const ce=!W||Fe(W,t),fe=X(W??t)??W??t;if(!fe||!V?.id)return;const de=Ke(fe);if((de?b?.get(de):void 0)?.treeNodes?.length){N?.(de,V.id);return}const Te={...fe,dimensionValues:fe?.dimensionValues?.map(F=>F?.id===V?.id?{...F,isExpanded:!V?.isExpanded}:F)};ce&&m(Te),v&&v(Te)},se=(V,W)=>{if(!t)return;const ce={...t,timeRange:V||void 0};w?.(W),m(ce),v&&v(ce)};return o.jsx(ym,{value:{locale:s,isDisableValues:r,isValuesLoading:a,timeRangeOptions:c,filterValuesProps:n?.filterValuesProps,dataQueries:E,onSelectHierarchy:y,selectFilterValue:Q,selectHierarchicalNodes:pe,expandHierarchicalValue:we,onTimePeriodChange:se},children:o.jsxs("div",{className:$("flex flex-row gap-5 flex-1 min-h-0 sm:p-0","filters-settings"),children:[o.jsxs("div",{className:$("h-full sm:w-full",n?.isShowTimeSeriesCount&&"flex flex-col justify-between"),children:[R&&o.jsxs("div",{className:"mb-4 flex items-center justify-between gap-x-4",children:[o.jsxs("span",{className:"body-3 text-neutrals-900",children:[A?.appliedFilters??"Applied filters",":"," ",O]}),o.jsx(j.Button,{buttonClassName:"text-button-tertiary p-0",title:A?.clearAll??"Clear All",onClick:x,isSmallButton:k})]}),o.jsx(Mm,{filtersList:U,hideFacetCounterByDefault:n?.isHideFacetCounterByDefault,onSelectFilter:J,onSelectDisplayMode:p,onDeleteFilter:g,initialConstraints:l,initialConstraintsMap:d,datasetIcon:u,structuresMap:h,hierarchyStateMap:b,dataQueries:E,disabledDatasetUrns:T,isDatasetFacetSelected:L,onSelectDatasetFacet:K,onClearAllDatasets:_}),n?.isShowTimeSeriesCount&&i?o.jsxs("h4",{className:"my-4 text-neutrals-800",children:[A?.timeSeries??"Timeseries",": ",i]}):null]}),!k&&(L?o.jsx(Am,{dataQueries:E??[],disabledDatasetUrns:T,onToggleDataset:S,searchIconSize:n?.filterValuesProps?.searchIconSize}):o.jsx(tu,{filtersList:U,selectedFilter:Z,structuresMap:h,initialConstraints:zc(R,t,l,d),selectedTimeOption:C,hierarchyState:M}))]})})},Em=e=>{const t=e.filterType==="dataset"?[e.datasetUrn]:e.sourceDatasetUrns;return Array.from(new Set((t||[]).filter(n=>!!n)))},Nm=(e,t)=>{if(!t)return!1;const n=e.dataStructureComponents?.dimensionList;return[...n?.dimensions||[],...n?.timeDimensions||[]].some(r=>r.id===t)},Nr=e=>{if(!e.length||e.some(n=>!n))return;const t=Array.from(new Set(e));return t.length===1?t[0]:void 0},jm=(e,t)=>{const n=t?.dataStructures||[];if(!n.length)return[];const s=n.filter(r=>Nm(r,e));return s.length?s:n.length===1?n:[]},km=e=>e.urn??D.generateShortUrn(e.id,e.version,e.agencyID),su=(e,t)=>Nr(jm(e,t).map(km)),_m=(e,t,n,s)=>{if(!e||!t)return;const r=n?.get(t)?.find(l=>l.id===e);if(!r)return;const a=D.getKeyFromUrn(r.localRepresentation?.enumeration);if(a)return a;const i=s?.get(t),c=D.findCodelistByDimension(i?.codelists,i?.conceptSchemes,r);return c?D.getKeyFromUrn(c.urn)??D.generateShortUrn(c.id,c.version,c.agencyID):void 0},Im=(e,t,n)=>{const s=Em(e);return{codelistUrn:Nr(s.map(r=>_m(e.id,r,t,n))),sourceArtefactUrn:Nr(s.map(r=>su(e.id,n?.get(r))))}},Rm=({timeseriesLength:e=0,limitMessages:t})=>{const n=!e||j.SERIES_LIMIT>e;return o.jsx("div",{className:"body-3 flex items-center gap-x-[4px] text-neutrals-800 sm:justify-center sm:text-center",children:n?o.jsx("span",{children:t?.seriesCount?.(e)}):o.jsxs(o.Fragment,{children:[o.jsx("span",{children:t?.warningIcon}),o.jsx("span",{children:t?.counterLimit?.(e,j.SERIES_LIMIT)})]})})},ru=({modalProps:e,onApply:t,onClearAllFilters:n,onClose:s,applyDisabled:r,timeseriesLength:a,limitMessages:i})=>{const{titles:c}=De(),l=j.useIsMobile(),d=e?.footerActionsPosition==="right",u=e?.isShowCancelButton,h=e?.isShowClearAllButton??!0,m=u?d?"justify-end":"justify-start":d?"flex-row items-center justify-between sm:flex-col-reverse sm:gap-y-4":"gap-x-8 flex-row-reverse items-center justify-between sm:flex-col sm:gap-y-4",p=u?d?"items-center gap-x-8":"justify-between":d?"flex-row justify-end items-center sm:flex-col-reverse sm:gap-y-4":"gap-x-8 flex-row-reverse justify-end items-center sm:flex-col-reverse sm:gap-y-4";return o.jsxs("div",{className:$("flex py-4 px-6 modal-footer-wrapper",m),children:[!u&&o.jsx(Rm,{timeseriesLength:a,limitMessages:i}),o.jsxs("div",{className:$("flex",p),children:[h&&o.jsx(j.Button,{iconBefore:l?e?.resetIcon:void 0,buttonClassName:"text-button-tertiary p-0",title:e?.isShowClearIcon?c?.clearAllFilters??"Clear All Filters":c?.clearAll??"Clear All",onClick:()=>n(),isSmallButton:l}),o.jsxs("div",{className:"flex items-center gap-x-3",children:[e?.isShowCancelButton?o.jsx(j.Button,{buttonClassName:"text-button-tertiary sm:h8",title:c?.cancel??"Cancel",onClick:s,isSmallButton:l}):null,o.jsx(j.Button,{buttonClassName:"advanced-view-filters-modal-apply-button",title:c?.apply??"Apply",onClick:t,isSmallButton:l,disabled:r})]})]})]})},Pm=e=>Ee.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Ee.createElement("path",{d:"M3.33333 13.3327V8.66602H2V7.33268H6V8.66602H4.66667V13.3327H3.33333ZM3.33333 5.99935V2.66602H4.66667V5.99935H3.33333ZM6 5.99935V4.66602H7.33333V2.66602H8.66667V4.66602H10V5.99935H6ZM7.33333 13.3327V7.33268H8.66667V13.3327H7.33333ZM11.3333 13.3327V11.3327H10V9.99935H14V11.3327H12.6667V13.3327H11.3333ZM11.3333 8.66602V2.66602H12.6667V8.66602H11.3333Z",fill:"currentColor"}));var Ge=(e=>(e.DATA_GRID="dataGrid",e.METADATA_PER_SERIES="metadataPerSeries",e.CHARTS="charts",e.CHARTS_NAVIGATION="chartsNavigation",e.OPEN_ADVANCED_VIEW="openAdvancedView",e.FILTERS="filters",e.CHART_PER_SERIES="chartPerSeries",e.METADATA_PER_DATASET="metadataPerDataset",e.EXIT_ADVANCED_VIEW="exitAdvancedView",e))(Ge||{});const Wr=["charts","chartsNavigation"],Xo=["dataGrid","metadataPerSeries",...Wr,"openAdvancedView"],au=["filters","chartPerSeries","metadataPerDataset","exitAdvancedView"],mt=(e,t)=>{const n=t?.[`${e}Title`],s=t?.[`${e}Description`];return{title:typeof n=="string"?n:"",description:typeof s=="string"?s:""}},jr=(e,t)=>e.find(n=>!t.infoElements?.[n])||"",Lm=(e,t)=>{if(!e||!t)return"";if(Xo.includes(t)){const s=jr(Xo,e);if(s)return s}const n=jr(au,e);return n||""},iu=(e,t)=>{const n=jr(e,t);return{...t,infoElements:{...t?.infoElements,[t.lastDisplayedElement]:!1,...n?{[n]:!0}:{}},lastDisplayedElement:n}},ou=e=>iu(au,e),Om=e=>iu(Wr,e),Fm=e=>(!e?.infoElements?.charts||!e?.infoElements?.chartsNavigation)&&!Wr.includes(e.lastDisplayedElement),ut=5,Vm=({targetPosition:e,overlayClasses:t,onClose:n})=>o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"overlay overlay-top",style:{height:e.top,top:0-ut,bottom:e.top+ut}}),o.jsx("div",{className:"overlay overlay-bottom",style:{top:e.bottom+ut,bottom:0}}),o.jsx("div",{className:"overlay overlay-left",style:{top:e.top-ut,height:e.height+ut*2,width:e.left,left:0-ut,right:e.left-ut*2}}),o.jsx("div",{className:"overlay overlay-right",style:{top:e.top-ut,left:e.right+ut,height:e.height+ut*2,right:0}}),o.jsx("div",{className:$("outline-block z-10",t),onClick:n,style:{top:e.top,left:e.left,height:e.height,width:e.width}})]}),pt=({reference:e,title:t,description:n,onReferenceClick:s,shouldCloseTooltip:r,shouldMoveToNextStep:a,supressReferenceClick:i})=>{const[c,l]=f.useState(!0),[d,u]=f.useState(!1),h=f.useRef(null),{isShowOnboarding:m,onboardingFileSchema:p,setOnboardingFileSchema:g}=Xe(),{refs:x,floatingStyles:v,context:w,placement:C}=et.useFloating({open:c,onOpenChange:l,placement:"right-start",elements:{reference:e?.current},middleware:[et.offset({mainAxis:12,crossAxis:-4}),et.flip(),et.shift(),et.arrow({element:h})],whileElementsMounted:et.autoUpdate}),b=et.useClick(w),{getFloatingProps:y}=et.useInteractions([b]),N=f.useCallback(()=>{if(m){const _=Lm(p,p?.lastDisplayedElement);g?.({...p,infoElements:{...p?.infoElements,..._?{[_]:!0}:{}},lastDisplayedElement:_})}l?.(!1)},[m,p,g]);f.useEffect(()=>{x.setReference(e?.current??null)},[e,x]);const E=()=>N(),T=e?.current?.getBoundingClientRect();f.useEffect(()=>{r&&!d&&(N(),u(!0))},[r,N,d]);const S=()=>{s?(s?.(),a?N():l(!1)):i||(N(),e?.current?.click())};return o.jsx(o.Fragment,{children:c&&o.jsxs(et.FloatingPortal,{children:[T&&o.jsx(Vm,{overlayClasses:i?"cursor-default":"cursor-pointer",targetPosition:T,onClose:S}),o.jsxs("div",{ref:x.setFloating,style:v,...y(),className:"tooltip z-tooltip max-w-[350px]",children:[o.jsxs("div",{className:"tooltip-header",children:[o.jsx("h3",{children:t}),o.jsx(j.CloseButton,{btnClassNames:"w-4 h-4",onClick:E})]}),o.jsx("div",{className:"tooltip-description",children:o.jsx("p",{children:n})}),o.jsx("div",{ref:h,className:$("tooltip-arrow absolute w-3 h-3 rotate-45",C?.includes("right")?"left-[-4px]":"right-[-6px]",C?.includes("end")?"bottom-2 tooltip-arrow-white":"top-3")})]})]})})},lu=({buttonProps:e,selectedFiltersCount:t=0,isLoading:n,setModalState:s,isModalClosed:r,warningIcon:a,filterIconClassName:i,timeSeriesCount:c})=>{const{titles:l}=De(),d=f.useRef(null),[u,h]=f.useState(""),[m,p]=f.useState(""),[g,x]=f.useState(!1),{onboardingFileSchema:v,isShowOnboarding:w}=Xe(),C=j.SERIES_LIMIT<(c??0),b=f.useMemo(()=>e?.isShowBadge?e?.title:`${e?.title}: ${t}`,[e?.isShowBadge,e?.title,t]);return f.useEffect(()=>{if(w){const{title:y,description:N}=mt(Ge.FILTERS,l);h(y),p(N)}},[l,w]),f.useEffect(()=>{w&&x(v?.lastDisplayedElement===Ge.FILTERS)},[v?.lastDisplayedElement,w]),o.jsx("div",{className:"filter-button-container relative",ref:d,children:n?o.jsx(j.Loader,{}):o.jsxs(o.Fragment,{children:[o.jsx(j.Button,{iconBefore:o.jsx(Pm,{className:$("size-4",i)}),iconAfter:C?a:void 0,title:b,buttonClassName:"text-button-secondary filter-button",isSmallButton:!0,onClick:()=>s(j.PopUpState.Opened)}),e?.isShowBadge&&o.jsx("div",{className:"filter-count-badge",children:o.jsx("h5",{children:t})}),g&&o.jsx(pt,{reference:d,title:u,description:m,onReferenceClick:()=>s(j.PopUpState.Opened),shouldCloseTooltip:r})]})})},cu=f.createContext(null);function Hm({children:e}){const[t,n]=f.useState(j.PopUpState.Closed),[s,r]=f.useState(!1),a=f.useMemo(()=>({modalState:t,setModalState:n,isModalClosed:s,setIsModalClosed:r}),[t,s]);return o.jsx(cu.Provider,{value:a,children:e})}function uu(){const e=f.useContext(cu);if(!e)throw new Error("useFiltersModalState must be used within FiltersModalStateProvider");return e}const Qo=e=>{const t=[];return e.custom_content?.attachments&&t.push(...e.custom_content.attachments),t};function $r(e){return e.type===ve.AttachmentType.MARKDOWN&&e.title!=null&&e.title?.startsWith("URL Query")}function du(e){return e.type===ve.AttachmentType.JSON&&e.title!=null&&e.title?.startsWith("Query (JSON)")}function fu(e){return e.type===ve.AttachmentType.MARKDOWN&&!$r(e)}function Um(e){return e.type===ve.AttachmentType.CSV}function Kr(e){return e.type===ve.AttachmentType.TABLE}function ft(e){return e.type===ve.AttachmentType.CUSTOM_DATA_GRID}function ln(e){return e.type===ve.AttachmentType.CUSTOM_CHART}function Gm(e){return e.type===ve.AttachmentType.PLOTLY}function Jr(e){return e.type===ve.AttachmentType.CUSTOM_CODE_SAMPLE}function vt(e){return e.type===ve.AttachmentType.CROSS_DATASET_GRID}function Bm(e){return Kr(e)||ft(e)||vt(e)}const zm=(e,t)=>e?.filter((n,s)=>n?.custom_content?.attachments&&s<t)?.at(-1),hu=e=>e?.reduce((t,n,s)=>n?.custom_content?.attachments?.some(r=>du(r))?s:t,-1),qm=e=>e?.reduce((t,n)=>n?.role===Pe.Role.Assistant?n:t,{}),Wm=(e,t,n,s,r)=>({role:Pe.Role.System,content:"",custom_content:{attachments:n?.map(a=>{const i=e&&t?.urn===a?.urn?e:a?.filters;return{type:ve.AttachmentType.JSON,title:a?.title,data:JSON.stringify({urn:a?.urn,metadata:a?.metadata,filters:r?r?.get(a?.urn):i,disabled:!!a?.disabled})}})||[],form_schema:s?.custom_content?.form_schema}}),mu=(e,t,n,s,r)=>{if(!e)return[];const a=e.at(-1),i=a?.role===Pe.Role.System,c=i?a?.custom_content?.attachments?.find(u=>u.type==="text/markdown"&&u.data?.includes("```python")):void 0,l=i?e.slice(0,-1):e,d=Wm(s,r,t,qm(l),n);return c&&d.custom_content&&(d.custom_content={...d.custom_content,attachments:[...d.custom_content.attachments??[],c]}),[...l,d]},$m=(e,t,n,s)=>e?.map(r=>({...r,filters:n&&s?.urn===r?.urn?n:r?.filters}))||[],gt={availableHierarchies:[],selectedHierarchy:null,mainHierarchy:null,codelists:[],treeNodes:[],isLoading:!1},pu=({getCodelistUrnForFilter:e,getConstraintsForFilter:t,getSourceArtefactUrn:n,getAvailableHierarchies:s,getHierarchy:r})=>{const[a,i]=f.useState(new Map),c=f.useCallback((m,p)=>{const g=Ke(m);if(!g)return;const x=e(m),v=p??t(m);i(w=>{const C=w.get(g);if(!C?.mainHierarchy)return w;const b=Zo(C.mainHierarchy,C.codelists,m.id??"",v,x),y=new Map(w);return y.set(g,{...C,treeNodes:b}),y})},[e,t]),l=f.useCallback(async m=>{if(!s)return;const p=e(m);if(!p)return;const g=Ke(m);if(g){i(x=>{const v=new Map(x),w=x.get(g)??gt;return v.set(g,{...w,isLoading:!0}),v});try{const x=await s(p,n?.(m)),v=vm(x?.data?.hierarchies??[]);i(w=>{const C=new Map(w),b=w.get(g)??gt;return C.set(g,{...b,availableHierarchies:v,isLoading:!1}),C})}catch{i(x=>{const v=new Map(x),w=x.get(g)??gt;return v.set(g,{...w,isLoading:!1}),v})}}},[s,e,n]),d=f.useCallback(async(m,p)=>{if(!r)return;const g=Ke(m);if(!g)return;const x=e(m);i(v=>{const w=new Map(v),C=v.get(g)??gt;return w.set(g,{...C,isLoading:!0}),w});try{const v=Yo(p),w=await r(v,x),C=w?.data?.hierarchies?.find(N=>Yo(N)===v);if(!C){i(N=>{const E=new Map(N),T=N.get(g)??gt;return E.set(g,{...T,selectedHierarchy:p,mainHierarchy:null,treeNodes:[],isLoading:!1}),E});return}const b=D.resolveCodelistsFromResponse(w?.data),y=Zo(C,b,m.id??"",t(m),x);i(N=>{const E=new Map(N),T=N.get(g)??gt;return E.set(g,{...T,selectedHierarchy:p,mainHierarchy:C,codelists:b,treeNodes:y,isLoading:!1}),E})}catch{i(v=>{const w=new Map(v),C=v.get(g)??gt;return w.set(g,{...C,isLoading:!1}),w})}},[r,e,t]),u=f.useCallback((m,p)=>{if(!m)return;const g=Ke(m);if(g){if(!p){i(x=>{const v=new Map(x),w=x.get(g)??gt;return v.set(g,{...w,selectedHierarchy:null,mainHierarchy:null,treeNodes:[]}),v});return}d(m,p)}},[d]),h=f.useCallback((m,p)=>{i(g=>{const x=g.get(m);if(!x?.treeNodes)return g;const v=new Map(g);return v.set(m,{...x,treeNodes:Zc(x.treeNodes,p)}),v})},[]);return{hierarchyStateMap:a,rebuildHierarchyTree:c,loadAvailableHierarchies:l,onSelectHierarchy:u,onExpandHierarchyNode:h}},Km=(e,t,n,s,r)=>{const a=new Set;if(!t||e.isTimeDimension)return a;const i=e.dimensionValues?.filter(u=>u.isSelectedValue)??[];if(!i.length)return a;const c=D.findCodelistByDimension(n?.codelists,n?.conceptSchemes,t);if(!c?.codes?.length)return a;const l=new Set(c.codes.map(u=>u.id)),d=new Set(D.getAvailableCodesFromConstrains(c.codes,t.id,s,r).map(u=>u.id));return i.forEach(u=>{l.has(u.id)&&!d.has(u.id)&&a.add(u.id)}),a},gu=(e,t,n,s,r,a)=>{let i=!1;const c=e.map(l=>{if(l.isTimeDimension||r&&l.id===r)return l;const d=t?.find(h=>h.id===l.id),u=Km(l,d,n,s,a);return u.size?(i=!0,{...l,dimensionValues:l.dimensionValues?.map(h=>u.has(h.id)?{...h,isSelectedValue:!1}:h)}):l});return{filters:i?c:e,changed:i}},Jm=(e,t,n,s,r,a)=>gu(e,t,n,s,r?.id,a),Ym=(e,t,n,s,r)=>{let a=!1;const i=new Map;return e.forEach((c,l)=>{const d=n?.filterType==="shared"?zr(n,l,r):n?.datasetUrn===l?n.id:void 0,u=gu(c,t?.dimensionsMap?.get(l),t?.structuresMap?.get(l),t?.constraintsMap?.get(l),d,s);a=a||u.changed,i.set(l,u.filters)}),{filtersMap:a?i:e,changed:a}},Zm=new Set,Xm=({actions:e,dimensions:t,structureDimensions:n,structures:s,buttonProps:r,modalProps:a,attachmentsDataQuery:i,dataQueries:c,initialConstraints:l,onFiltersChange:d,locale:u,timeRangeOptions:h,conversationKey:m,conversation:p,setConversation:g,updateConversation:x,updateDataQueries:v,limitMessages:w,filterIconClassName:C})=>{const{titles:b}=De(),{modalState:y,setModalState:N,isModalClosed:E,setIsModalClosed:T}=uu(),[S,_]=f.useState([]),[A,M]=f.useState([]),[k,R]=f.useState(),[L,z]=f.useState([]),[U,Z]=f.useState(void 0),O=f.useRef(l||[]),[K,J]=f.useState([]),[X,Q]=f.useState(),[pe,we]=f.useState(),[se,V]=f.useState(!1),W=f.useRef(0),ce=f.useRef(!1),fe=f.useCallback(()=>{W.current+=1,W.current===1&&V(!0)},[]),de=f.useCallback(()=>{W.current=Math.max(W.current-1,0),W.current===0&&V(!1)},[]),Ne=f.useCallback(Y=>{const me=t?.find(He=>He.id===Y.id);if(!me)return;const ie=D.getKeyFromUrn(me.localRepresentation?.enumeration);if(ie)return ie;const le=D.findCodelistByDimension(s?.codelists,s?.conceptSchemes,me);return le?D.getKeyFromUrn(le.urn)??D.generateShortUrn(le.id,le.version,le.agencyID):void 0},[t,s?.codelists,s?.conceptSchemes]),{hierarchyStateMap:Te,rebuildHierarchyTree:F,loadAvailableHierarchies:G,onSelectHierarchy:oe,onExpandHierarchyNode:re}=pu({getCodelistUrnForFilter:Ne,getConstraintsForFilter:()=>O.current,getSourceArtefactUrn:Y=>su(Y.id,s),getAvailableHierarchies:e?.getAvailableHierarchies,getHierarchy:e?.getHierarchy}),ae=Y=>{const me=Y?S.map(ie=>Fe(ie,Y)?Y:ie):S;we(!0),_(mn(me)),Q?.(!0),ue(Y?.isTimeDimension?hn(me,Y):me,_,Q,Y)};f.useEffect(()=>{y===j.PopUpState.Closed&&J(O.current)},[y]);const ue=f.useCallback((Y,me,ie,le)=>{const He=i?.urn??"",H=Ht(Ar(Y).filter(P=>P.componentCode!==D.TIME_PERIOD)),B=rt(He,H),ee=!!e?.getConstraints&&!Er(e.getConstraints,B);ee&&fe(),(e?ot(e.getConstraints,B,()=>e.getConstraints(He,H)):Promise.resolve(void 0)).then(P=>{const q=P?.data?.dataConstraints||[];if(le){const{filters:Re,changed:Ce}=Jm(Y,t,s,q,le,u);if(Ce){O.current=q,ie?.(!0),we(!0),ue(Re,me,ie,le);return}}const te=rn(Y,t,s,q,u);if(O.current=q,ie?.(!1),me(te),le){const Re=te.find(Ce=>Fe(Ce,le));R(Ce=>Ce&&Re&&Fe(Ce,le)?{...Re,isSelectedFilter:!0}:Ce),F(le,q)}}).catch(()=>{const P=rn(Y,t,s,[],u);if(O.current=[],ie?.(!1),me(P),le){const q=P.find(te=>Fe(te,le));R(te=>te&&q&&Fe(te,le)?{...q,isSelectedFilter:!0}:te)}}).finally(()=>{we(!1),ee&&de()})},[e,i?.urn,t,de,u,F,fe,s]);f.useEffect(()=>{const Y=cc(t,s,n,u),me=t?.map(le=>{const He=D.findCodelistByDimension(s?.codelists,s?.conceptSchemes,le),H=D.getAvailableCodesFromConstrains(He?.codes,le.id,O.current,u);return{...le,dimensionValues:H}}),ie=Y.map(le=>{const He=me?.find(H=>H.id===le.id)?.dimensionValues||[];return{...le,dimensionValues:He}});if(!ce.current){if(!s)return;const le=pc(ie,i,O.current);Q?.(!0),ue(le,M,Q),ce.current=!0}},[t,n,s,i,u,l,ue]),f.useEffect(()=>{A?.length&&z(Tn(A))},[A]),f.useEffect(()=>{_(Y=>hn(Y,k))},[k]),f.useEffect(()=>{if(y===j.PopUpState.Opened){const Y=A.find(me=>!me.isTimeDimension);R(Y?{...Y,isSelectedFilter:!0}:void 0),_(A)}y===j.PopUpState.Closed&&R(void 0)},[A,y]),f.useEffect(()=>{if(!k||k.isTimeDimension)return;const Y=Ke(k);if(!Y)return;Te.get(Y)||G(k)},[k,Te,G]),f.useEffect(()=>{y===j.PopUpState.Opened&&A.forEach(Y=>{if(Y.isTimeDimension)return;const me=Ke(Y);me&&!Te.has(me)&&G(Y)})},[y,A,Te,G]);const he=f.useCallback(async Y=>{const me=Mc(Y),ie=p?{...p,messages:mu(p?.messages,c,void 0,me,i)}:null;g?.(ie),v?.($m(c,void 0,me,i)),await x(decodeURI(m),{name:ie?.name,messages:ie?.messages||[]})},[i,p,m,c,g,x,v]),je=f.useCallback((Y,me)=>{_(ie=>uc(ie,Y,me)),Fe(k,Y)&&R(ie=>ie&&{...ie,displayMode:me})},[k]),Se=f.useCallback(Y=>Sc(Y,t),[t]),ge=f.useMemo(()=>Mr(Se(S),Se(A)),[S,A,Se]),be=f.useCallback((Y,me)=>{const ie=rn(me,t,s,Y,u);O.current=Y,R(le=>ie?.find(He=>Fe(He,le))||le),_(ie),we(!1)},[t,u,s]),Me=f.useCallback(Y=>{we(!0),_(mn(Y));const me=i?.urn??"",ie=Ht(Ar(Y).filter(B=>B.componentCode!==D.TIME_PERIOD)),le=rt(me,ie),He=!!e?.getConstraints&&!Er(e.getConstraints,le);He&&fe(),(e?ot(e.getConstraints,le,()=>e.getConstraints(me,ie)):Promise.resolve(void 0)).then(B=>{be(B?.data?.dataConstraints||[],Y)}).catch(()=>{be([],Y)}).finally(()=>{He&&de()})},[e,i?.urn,de,fe,be]),Le=f.useCallback(Y=>{const me=hc(S,Y);Me(me)},[Me,S]),Be=f.useCallback(()=>{O.current=K,N(j.PopUpState.Closed),T(!0)},[K,N,T]),ze=f.useCallback(()=>{const Y=mc(S);Me(Y)},[Me,S]),ke=f.useCallback(()=>{const Y=Se(S);d?.(Y,O.current,S),M(S),N(j.PopUpState.Closed),T(!0),f.startTransition(()=>{he(S)})},[Se,S,d,he,O,N,T]),Oe=Y=>{Z(Y)},Ve=Number(D.getTimeSeriesCount(O?.current?.[0]?.annotations)),Qe=X||pe||ge;return o.jsxs("div",{className:"filters-container",children:[o.jsx(lu,{buttonProps:r,selectedFiltersCount:Gr(L),isLoading:X,setModalState:N,isModalClosed:E,warningIcon:w?.warningIcon,filterIconClassName:C,timeSeriesCount:Ve}),o.jsx(o.Fragment,{children:y===j.PopUpState.Opened&&o.jsxs(j.Popup,{heading:b?.settings||"Settings",portalId:"filters",size:j.PopUpSize.LG,containerClassName:"advanced-view-filters-modal h-[80%]",dividers:a?.isShowDividers,onClose:Be,closeButtonTitle:b?.close||"Close",children:[o.jsx(nu,{locale:u,timeRangeOptions:h,filtersList:S,selectedFilter:k,isDisableValues:pe,isValuesLoading:se,modalProps:a,initialConstraints:l,timeSeriesCount:`${Ve}`,setSelectedFilter:R,onSelectDisplayMode:je,onDeleteFilter:Le,onClearAllFilters:ze,updateSelectedFilterValues:ae,onTimePeriodChange:Oe,selectedTimeOption:U,hierarchyStateMap:Te,onSelectHierarchy:oe,onExpandHierarchyNode:re,dataQueries:i?[i]:void 0,disabledDatasetUrns:Zm,onToggleDataset:()=>{},onClearAllDatasets:()=>{}}),o.jsx(ru,{onApply:ke,onClose:Be,onClearAllFilters:ze,modalProps:a,applyDisabled:Qe,timeseriesLength:Ve,limitMessages:w})]})})]})},wr=({setToTitle:e,datasetName:t,datasetIcon:n,isShowDatasetDetails:s,queryFilterDetails:r})=>o.jsx("div",{children:r?.map(a=>o.jsxs("div",{className:"body-1 mb-2 flex flex-wrap items-center gap-1",children:[o.jsxs("span",{children:[a?.title,o.jsx("span",{children:e??" set to "}),o.jsx("span",{className:"font-bold",children:a?.valuesTitles?.join(", ")})]}),t&&s&&o.jsxs("span",{className:"attachment-dataset-name caption !mb-0 inline-flex items-center",children:[o.jsx("span",{className:"attachment-dataset-icon mr-1",children:n}),t]})]},a?.title))}),Qm=({titles:e,attachmentInfoList:t,datasetIcon:n,dataQueries:s})=>{const{isCrossDatasetModeOn:r}=We(),{sharedFilterDetails:a,perDatasetInfoList:i}=f.useMemo(()=>{if(!r)return{sharedFilterDetails:[],perDatasetInfoList:[]};const d=new Map,u=[];return t?.forEach(h=>{const m=[];h.queryFiltersDetails?.forEach(p=>{if(Gh.has(p.id)){const g=d.get(p.id);g?d.set(p.id,{...g,valuesTitles:Array.from(new Set([...g.valuesTitles||[],...p.valuesTitles||[]]))}):d.set(p.id,{...p})}else p.valuesTitles?.length&&m.push(p)}),m.length&&u.push({...h,queryFiltersDetails:m})}),{sharedFilterDetails:Array.from(d.values()),perDatasetInfoList:u}},[r,t]),c=s?.some(d=>d.disabled)??!1,l=t?.map(d=>d.datasetName).filter(Boolean)??[];return o.jsxs("div",{className:"attachment-details flex flex-col",children:[o.jsx("p",{className:$("body-1",(t&&t.length<=1||r&&a.length>0)&&"mb-2"),children:e?.queryUpdatedManuallyTitle??"Query has been updated manually."}),c&&l.length>0&&o.jsxs("div",{className:"body-1 mb-2 flex flex-wrap items-center gap-1",children:[o.jsxs("span",{children:[e?.datasetLabel??"Dataset",e?.setToTitle??" set to "]}),l.map(d=>o.jsxs("span",{className:"attachment-dataset-name caption !mb-0 inline-flex items-center",children:[o.jsx("span",{className:"attachment-dataset-icon mr-1",children:n}),d]},d))]}),r?o.jsxs(o.Fragment,{children:[a.length>0&&o.jsx(wr,{setToTitle:e?.setToTitle,queryFilterDetails:a}),i.map(d=>o.jsx(wr,{setToTitle:e?.setToTitle,datasetName:d.datasetName,datasetIcon:n,isShowDatasetDetails:!0,queryFilterDetails:d.queryFiltersDetails},d.datasetName))]}):t?.map(d=>!!d?.queryFiltersDetails?.length&&o.jsx(wr,{setToTitle:e?.setToTitle,datasetName:d?.datasetName,datasetIcon:n,isShowDatasetDetails:t?.length>1,queryFilterDetails:d?.queryFiltersDetails},d?.datasetName))]})},ep=({icon:e,title:t})=>o.jsx("div",{className:$("px-3 py-4 rounded border mt-3","attachment-collapsed"),children:o.jsxs("p",{className:$("flex body-3 items-center"),children:[e,o.jsxs("span",{className:"ml-2",children:[" ",t]})]})}),tp=e=>Ee.createElement("svg",{width:44,height:24,viewBox:"0 0 44 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ee.createElement("rect",{width:44,height:24,rx:12,fill:"currentColor"}),Ee.createElement("circle",{cx:32,cy:12,r:10,fill:"white"})),np=e=>Ee.createElement("svg",{width:44,height:24,viewBox:"0 0 44 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ee.createElement("rect",{width:44,height:24,rx:12,fill:"currentColor"}),Ee.createElement("circle",{cx:12,cy:12,r:10,fill:"white"})),el=[{value:D.SdmxDataFormat.JSON,title:"SDMX-JSON"},{value:D.SdmxDataFormat.XML,title:"SDMX-ML (XML)"},{value:D.SdmxDataFormat.CSV,title:"SDMX-CSV"}],sp=e=>[{value:D.FileColumnsAttribute.ID,title:e?.idOptions||"ID",description:e?.idOptionsDescription},{value:D.FileColumnsAttribute.NAME,title:e?.nameOptions||"Name",description:e?.nameOptionsDescription},{value:D.FileColumnsAttribute.ID_NAME,title:e?.idAndNameOptions||"Combined ID and Name",description:e?.idAndNameOptionsDescription}],tl=({title:e,items:t,selectedValue:n,setSelectedValue:s,infoMessage:r,collapsible:a=!0})=>{const i=o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex flex-col gap-y-1",children:t.map(c=>o.jsx("div",{className:"flex flex-col",children:o.jsx(j.Radio,{id:c.value,checked:n.value===c.value,label:c.title,description:c.description,onChange:()=>{s(c)},radioIcon:o.jsx(qe.IconCircleFilled,{className:"size-3"})},c.value)},c.value))}),r]});return a?o.jsx(j.CollapsibleBlock,{title:e,value:n.title,children:i}):o.jsxs("div",{className:"flex flex-col",children:[o.jsx("div",{className:"flex items-center py-4",children:o.jsx("span",{children:e})}),o.jsx("div",{className:"pb-4",children:i})]})},rp=({title:e,items:t,selectedUrns:n,onToggle:s,collapsible:r=!0,rowsLabel:a="rows"})=>{const i=o.jsx("div",{className:"flex flex-col",children:t.map(c=>o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("div",{className:"min-w-0 flex-1",children:o.jsx(j.Checkbox,{id:c.urn,label:c.name,checked:n.has(c.urn),onChange:s})}),o.jsxs("span",{className:"download-row-count",children:[c.rowCount," ",a]})]},c.urn))});return r?o.jsx(j.CollapsibleBlock,{title:e,children:i}):o.jsxs("div",{className:"flex flex-col",children:[o.jsx("div",{className:"flex items-center py-4",children:o.jsx("span",{children:e})}),o.jsx("div",{className:"pb-4",children:i})]})},ap=e=>{const t=e.metadata?.keyDimensionIdsInDsdOrder,n=e.metadata?.timePeriodDimension;if(!t?.length)return null;const s=t.map(a=>{const i=e.filters?.find(c=>c.componentCode===a);return i?.values?.length?i.values.join(D.GET_v3_FILTER_OR):"*"}).join("."),r=n?D.getTimeQueryFilter(e,{id:n}):null;return{filterKey:s,timeFilter:r}},ip=(e,t,n,s)=>{if(t&&e===D.DownloadType.DATA_IN_TABLE){const i=ap(t);if(i)return i}if(s?.filterKey&&e===D.DownloadType.DATA_IN_TABLE)return s;let r=null,a=null;return t&&n&&e===D.DownloadType.DATA_IN_TABLE&&(r=D.getTimeSeriesFilterKey(n,t.filters??[]),a=D.getTimeQueryFilter(t,D.getTimeDimension(n))),{filterKey:r,timeFilter:a}},op=({dataQuery:e,datasetName:t,onCloseModal:n,type:s=D.DownloadType.FULL_DATASET,locale:r=ne.Locale.EN,dimensions:a,filters:i,urn:c,titles:l,collapsible:d=!0,downloadDatasets:u,rowCount:h,isDownloadInProgress:m=!1,onDownloadStart:p,limitMessages:g,showLimitMessage:x,externalLink:v})=>{const w=sp(l),[C,b]=f.useState(el[0]),[y,N]=f.useState(w[0]),[E,T]=f.useState(!0),[S,_]=f.useState(()=>new Set(u?.map(z=>z.urn)??[])),A=f.useRef(!1);f.useEffect(()=>{_(new Set(u?.map(z=>z.urn)??[]))},[u]);const M=f.useCallback(z=>{_(U=>{const Z=new Set(U);return Z.has(z)?Z.delete(z):Z.add(z),Z})},[]),k=u!==void 0&&(u.length===0||S.size===0),R=f.useCallback(()=>{if(A.current)return;const z=C.value,U=(J,X,Q,pe)=>({dataQuery:J,urn:X,name:Q,rowCount:pe,fileName:`${Q}.${z}`,filters:ip(s,J,a,i)}),O={items:u&&u.length>0?u.filter(J=>S.has(J.urn)).map(J=>U(J.dataQuery,J.urn,J.name,J.rowCount)):[U(e,e?.urn||c||"",t||e?.urn||c||"",h??0)],dataFormat:z,dataFormatTitle:C.title,attribute:y.value,language:r,isMetadata:E};if(!p(O)){A.current=!1;return}A.current=!0,n()},[C.value,C.title,y.value,u,S,e,c,t,h,s,a,i,r,E,p,n]),L=o.jsxs("div",{className:$("download-metadata flex cursor-pointer gap-4",{"download-metadata-active":E}),children:[E?o.jsx(tp,{width:44,height:24,className:"text-primary",onClick:()=>T(!E)}):o.jsx(np,{width:44,height:24,className:"text-neutrals-500",onClick:()=>T(!E)}),o.jsx("div",{children:l?.includeMetadata||"Include Metadata"})]});return o.jsxs(j.Popup,{heading:o.jsx("p",{className:"download-heading h2",children:l?.download||"Download"}),portalId:"filters",size:j.PopUpSize.LG,containerClassName:"download-popup h-[80%]",dividers:!1,onClose:n,closeButtonTitle:l?.close||"Close",children:[!u&&x&&o.jsx("div",{className:"download-info flex flex-col gap-1 px-6 pt-5",children:o.jsx(j.RequestLimitMessage,{limitMessages:g,isDownload:!0,query:v})}),o.jsxs("div",{className:"download-settings flex flex-col overflow-auto p-6",children:[o.jsx(tl,{title:l?.dataFormat||"Data Format",selectedValue:C,setSelectedValue:b,items:el,collapsible:d,infoMessage:o.jsx(j.DownloadFormatMessage,{limitMessages:g,query:v})}),C.value===D.SdmxDataFormat.CSV&&o.jsx(tl,{title:l?.attributes||"Attributes",selectedValue:y,setSelectedValue:N,items:w,collapsible:d}),u&&o.jsxs(o.Fragment,{children:[o.jsx(rp,{title:l?.datasetsToDownload||"Datasets to download",items:u,selectedUrns:S,onToggle:M,collapsible:d,rowsLabel:l?.rows||"rows"}),S.size>1&&o.jsxs(j.InlineAlert,{type:j.InlineAlertType.Note,children:[o.jsx("span",{className:"font-bold",children:l?.filesWillBeDownloaded?.(S.size)??`${S.size} files will be downloaded`})," ",l?.oneFilePerDataset??"- one file per selected dataset."]})]}),d?o.jsx(j.CollapsibleBlock,{title:l?.metadata||"Metadata",value:E?l?.all||"Included":l?.none||"Not included",children:L}):o.jsxs("div",{className:"flex flex-col",children:[o.jsx("div",{className:"flex items-center py-4",children:o.jsx("span",{children:l?.metadata||"Metadata"})}),o.jsx("div",{className:"pb-4",children:L})]})]}),o.jsxs("div",{className:"download-button mt-auto flex items-center gap-x-3 p-6",children:[l?.cancel&&o.jsx(j.Button,{buttonClassName:"text-button-tertiary",title:l.cancel,onClick:n}),o.jsx(j.Button,{buttonClassName:"text-button-primary",title:l?.download||"Download",disabled:k||m,onClick:R})]})]})},lp=({id:e,title:t,version:n,agency:s,isActive:r,isSingleTab:a,onSelectDataset:i})=>o.jsx("div",{className:$("dataset-tab truncate last:mr-4",r?"dataset-tab-active":"border-b-transparent",a?"dataset-tab-single cursor-default":"cursor-pointer"),title:t,onClick:()=>{a||i(D.generateShortUrn(e,n,s))},children:o.jsx("h3",{className:"dataset-tab-title truncate",title:t,children:t})}),cp=({datasets:e,locale:t,initialSelectedDatasetUrn:n,selectDataset:s})=>{const{isOpenedAdvancedView:r}=$e(),[a,i]=f.useState();f.useEffect(()=>{if(!n&&!a&&e?.[0]){const l=D.generateShortUrn(e[0].id,e[0].version,e[0].agencyID);i(l),s?.(l)}else n&&n!==a&&(i(n),s?.(n))},[e,s,n,a]);const c=f.useCallback(l=>{i(l),s?.(l)},[s]);return o.jsx("div",{className:$("dataset-tabs flex w-full items-center justify-between",r&&"hide-advance-button"),children:o.jsx("div",{className:"flex w-full items-center gap-4 overflow-y-auto sm:w-[calc(100%-30px)]",children:e?.map(l=>o.jsx(lp,{id:l?.id,title:D.getLocalizedName(l,t||ne.Locale.EN),version:l?.version,agency:l?.agencyID,isActive:e?.length>1&&a===D.generateShortUrn(l?.id,l?.version,l?.agencyID),isSingleTab:e?.length===1,onSelectDataset:c},l?.id))})})},up=3,dp=({datasets:e,locale:t})=>{const{isOpenedAdvancedView:n}=$e(),s=f.useMemo(()=>(e||[]).map(c=>({urn:D.generateShortUrn(c?.id,c?.version,c?.agencyID),title:D.getLocalizedName(c,t||ne.Locale.EN)})),[e,t]),r=f.useMemo(()=>s.slice(0,up),[s]),a=Math.max(s.length-r.length,0),i=s.filter(c=>!r.some(l=>l.urn===c.urn)).map(c=>c.title).join(`
7
+ `);return o.jsx("div",{className:$("cross-dataset-tabs flex w-full items-center justify-between",n&&"hide-advance-button"),children:o.jsxs("div",{className:"cross-dataset-tabs-list sm:w-[calc(100%-30px)]",children:[r.map((c,l)=>o.jsxs("span",{className:"cross-dataset-tabs-item-wrapper",children:[o.jsx("span",{className:"cross-dataset-tabs-item",title:c.title,children:c.title}),l<r.length-1&&o.jsx("span",{className:"cross-dataset-tabs-separator","aria-hidden":"true"})]},c.urn)),a>0&&o.jsxs("span",{className:"cross-dataset-tabs-counter",title:i,children:["+",a]})]})})},vu=({datasets:e,locale:t,initialSelectedDatasetUrn:n,selectDataset:s})=>{const{isCrossDatasetModeOn:r}=We();return r?o.jsx(dp,{datasets:e,locale:t}):o.jsx(cp,{datasets:e,locale:t,initialSelectedDatasetUrn:n,selectDataset:s})},nl=(e,t)=>{const n=t?.get(e?.urn),s=n?.conceptSchemes||[],r=n?.codelists||[],a=D.getDimensions(n),i=[...a?.dimensions||[],...a?.timeDimensions||[]];return{structures:n,conceptSchemes:s,codelists:r,dimensions:i}},fp=(e,t,n,s,r)=>{const a=t?.filter(c=>!c.disabled)??[],i=new Map;return a?.forEach(c=>{const{conceptSchemes:l,codelists:d,dimensions:u}=nl(c,n);br((c?.filters??[]).filter(h=>h.operator!==ne.QueryFilterType.EXCLUDED),c?.urn,u,l,d,s,r).forEach(h=>{if(h.valuesTitles?.length){const m=i.get(h.id)??[];i.set(h.id,Array.from(new Set([...m,...h.valuesTitles])))}})}),a?.map(c=>{const l=e?.find(x=>x?.urn===c?.urn),{structures:d,conceptSchemes:u,codelists:h,dimensions:m}=nl(c,n),g=hp(br(l?.filters||[],c?.urn,m,u,h,s,r),br(c?.filters??[],c?.urn,m,u,h,s,r)).map(x=>{if(x.valuesTitles?.length)return x;const v=i.get(x.id);return v?.length?{...x,valuesTitles:v}:null}).filter(x=>x!==null);return{datasetName:D.getLocalizedName(d?.dataflows?.[0],s),queryFiltersDetails:g}})},hp=(e,t)=>{const n=new Map(e?.map(s=>[s?.id,s]));return t?.filter(s=>!Rr.isEqual(n?.get(s?.id)?.valuesTitles?.sort(),s?.valuesTitles?.sort()))||[]},br=(e,t,n,s,r,a,i)=>e?.map(c=>{const l=n.find(h=>h?.id===c?.componentCode),d=D.getConcept(l?.conceptIdentity||"",s),u=D.findCodelistByDimension(r,s,l);return{id:Kh(t,c?.componentCode,i)??c?.componentCode,title:D.getLocalizedName(d,a),valuesTitles:c?.operator===ne.QueryFilterType.BETWEEN?[`${fn(ne.getTimePeriod(c?.values?.[0]),a)} - ${fn(ne.getTimePeriod(c?.values?.[1]),a)}`]:c?.values?.map(h=>D.getLocalizedName(u?.codes?.find(m=>m?.id===h),a)||h)}}),mp=(e,t,n)=>{let s="",r="";if(e?.timeFilter){const i=decodeURIComponent(e.timeFilter||"")?.split(":");s=i[1]||"",r=i[3]||""}else if(t){const i=t?.filters?.find(c=>c.componentCode===D.TIME_PERIOD);s=i?.values?.[0]||"",r=i?.values?.[1]||""}return`&filter=${e?.filterKey||D.getTimeSeriesFilterKey(n||[],t?.filters||[])}&startPeriod=${s}&endPeriod=${r}`},kr=(e,t,n,s)=>{const r=n?.metadata?.datasetUrl;if(!r)return"";const a=e?mp(t,n,s):"";return r+a},Cu=e=>Ee.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Ee.createElement("path",{d:"M2.33325 12.3267L6.33325 8.32001L8.99992 10.9867L14.6666 4.61334L13.7266 3.67334L8.99992 8.98667L6.33325 6.32001L1.33325 11.3267L2.33325 12.3267Z",fill:"currentColor"})),pp=e=>Ee.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Ee.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.50644 4.00043L1.97857 7.52207L1.5 7.99979L1.97857 8.47751L5.50644 11.9991L6.46019 11.0437L3.41088 7.99979L6.46019 4.95587L5.50644 4.00043ZM10.4918 4.00043L14.0197 7.52207L14.4983 7.99979L14.0197 8.47751L10.4918 11.9991L9.53809 11.0437L12.5874 7.99979L9.53809 4.95587L10.4918 4.00043Z",fill:"currentColor"})),gp=e=>Ee.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Ee.createElement("path",{d:"M2.3999 4V12H13.5999V4H2.3999ZM5.7359 10.8H3.5999V5.2H5.7359V10.8ZM9.0639 10.8H6.9359V5.2H9.0719V10.8H9.0639ZM12.3999 10.8H10.2639V5.2H12.3999V10.8Z",fill:"currentColor"})),vp=e=>Ee.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Ee.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.18519 10.4815H7.18116C7.31033 10.9089 7.50501 11.3078 7.7535 11.6667H2.18519C1.53333 11.6667 1 11.1333 1 10.4815V2.18519C1 1.53333 1.53333 1 2.18519 1H10.4815C11.1333 1 11.6667 1.53333 11.6667 2.18519V5.02017C11.5296 5.00683 11.3906 5 11.25 5C10.9876 5 10.7307 5.02378 10.4815 5.06931V2.18519H2.18519V10.4815ZM7.69316 6.92288C7.99945 6.45568 8.39531 6.05248 8.85633 5.73769H3.37044V6.92288H7.69316ZM7 9.25C7 8.8544 7.05405 8.47143 7.15517 8.10807H3.37044V9.29326H7.00022L7 9.25ZM3.37044 4.5525H9.29636V3.36731H3.37044V4.5525ZM11.6624 10.9695C12.5981 10.8087 13.2264 9.91979 13.0656 8.98403C12.9049 8.04827 12.016 7.42002 11.0802 7.58078C10.1444 7.74155 9.51618 8.63046 9.67695 9.56621C9.83771 10.502 10.7266 11.1302 11.6624 10.9695ZM11.8656 12.1521C11.9243 12.142 11.9824 12.1303 12.0396 12.1168L14.5611 15.5477L15.5281 14.8371L13.1449 11.5944C13.9785 10.9558 14.4384 9.88763 14.2483 8.78085C13.9753 7.19192 12.4659 6.12513 10.877 6.39811C9.28808 6.67109 8.22129 8.18047 8.49428 9.7694C8.76726 11.3583 10.2766 12.4251 11.8656 12.1521Z",fill:"currentColor"})),Cp=({attachment:e,index:t,selectedAttachmentIndex:n,onSelectedAttachmentChange:s,showTabIcon:r,dataGridTitle:a})=>{const{titles:i}=De(),c=f.useRef(null),[l,d]=f.useState(""),[u,h]=f.useState(""),[m,p]=f.useState(!1),{onboardingFileSchema:g,isShowOnboarding:x}=Xe(),v=f.useCallback((C,b="")=>r?Gm(C)||ln(C)?o.jsx(Cu,{className:b}):ft(C)||vt(C)?o.jsx(gp,{className:b}):$r(C)?o.jsx(vp,{className:b}):fu(C)||Jr(C)?o.jsx(pp,{className:b}):null:null,[r]),w=f.useCallback(C=>ft(C)?a||"Data Grid":C.title,[a]);return f.useEffect(()=>{if(x&&ln(e)){const{title:C,description:b}=mt(Ge.CHARTS,i);d(C),h(b)}},[e,i,x]),f.useEffect(()=>{if(ln(e)&&x){const C=g?.lastDisplayedElement===Ge.CHARTS;p(C),C&&c?.current?.scrollIntoView({block:"end",behavior:"smooth"})}},[g?.lastDisplayedElement,e,x]),o.jsxs("div",{ref:c,className:$("cursor-pointer min-w-30","flex items-center gap-1","attachment-tab",n===t?"attachment-tab-active text-primary":""),onClick:()=>s(t),children:[v(e,"w-4 h-4"),o.jsx("h4",{className:"max-w-[130px] truncate",title:w(e),children:w(e)}),m&&o.jsx(pt,{reference:c,title:l,description:u})]},e.index||t)},wp=({attachments:e,...t})=>o.jsx("div",{className:"attachments-tabs flex w-fit flex-wrap items-center",children:e.map((n,s)=>o.jsx(Cp,{attachment:n,index:s,...t},s))}),bp=({attachments:e,selectedAttachmentIndex:t,selectedAttachment:n,attachmentsStyles:s,externalLink:r,isExternalLinkIncludeFilters:a,limitMessages:i,onSelectedAttachmentChange:c,onDownloadClick:l,showAdvancedView:d,onOpenAdvancedView:u,isTableSettingsOpen:h,onTableSettingsOpen:m})=>{const{isTableSettingsFeatureEnabled:p}=We(),{isOpenedAdvancedView:g}=$e(),{titles:x}=De(),{onboardingFileSchema:v,isShowOnboarding:w}=Xe(),C=f.useRef(null),[b,y]=f.useState(""),[N,E]=f.useState(""),[T,S]=f.useState(!1);f.useEffect(()=>{if(w){const{title:L,description:z}=mt(Ge.OPEN_ADVANCED_VIEW,x);y(L),E(z)}},[x,w]),f.useEffect(()=>{if(w){const L=v?.lastDisplayedElement===Ge.OPEN_ADVANCED_VIEW;S(L),L&&C?.current?.scrollIntoView({block:"center",behavior:"smooth"})}},[v?.lastDisplayedElement,w]);const _=p&&!d&&!!m&&!!(n&&(ft(n)||vt(n))),A=!!n&&(ft(n)||vt(n)),M=!!d&&!g,k=g&&s?.hideDownloadIconInAdvancedView?void 0:s?.downloadIcon,R=!g&&s?.hideDownloadTextInConversationView?"":s?.downloadTitle??"";return o.jsxs("div",{className:"flex w-full min-w-0 items-center justify-between",children:[o.jsx(wp,{dataGridTitle:s?.dataGridTitle,attachments:e,selectedAttachmentIndex:t,showTabIcon:s?.showTabIcon,onSelectedAttachmentChange:c}),o.jsxs("div",{className:"attachments-buttons flex w-fit flex-wrap items-center justify-end gap-x-3",children:[n&&ft(n)&&a&&o.jsx("a",{href:r,target:"_blank",rel:"noreferrer",children:o.jsx(j.Button,{title:i?.dataExplorer||"Data explorer",buttonClassName:"text-button-tertiary small-icon-button [&>svg]:h-[16px] [&>svg]:w-[16px] whitespace-nowrap",iconBefore:i?.dataExplorerIcon})}),A&&o.jsx(j.Button,{title:R,buttonClassName:"text-button-tertiary small-icon-button !p-0 !h-6",textClassName:$("ml-1",s?.downloadButtonTextClassName),onClick:l,iconBefore:k}),A&&M&&o.jsx("span",{className:"advanced-view-button-divider","aria-hidden":"true"}),M&&o.jsx("div",{ref:C,children:o.jsx(j.Button,{title:s?.advancedViewTitle,buttonClassName:"advanced-view-button",textClassName:"ml-1 h4 md:hidden",iconBefore:s?.openAdvancedViewIcon,onClick:u})}),_&&o.jsx(j.Button,{disabled:h,buttonClassName:"text-button-tertiary !p-0 !h-6",textClassName:"ml-1 h4",iconBefore:s?.tableSettingsIcon??o.jsx(qe.IconSettings,{className:"size-4"}),title:s?.tableSettings||"Table settings",onClick:m}),n&&Jr(n)&&o.jsx(j.CopyButton,{title:s?.copyTitle,copiedTitle:s?.copiedTitle,tooltip:s?.copiedTooltip,hoverTooltip:s?.copyHoverTooltip,icon:s?.copyIcon,copiedIcon:s?.copiedIcon,onClick:()=>navigator.clipboard.writeText(n.data??"")})]}),T&&o.jsx(pt,{reference:C,title:b,description:N,onReferenceClick:u,shouldCloseTooltip:g})]})},xp=({downloadTitles:e,attachment:t,actions:n,className:s=""})=>{const r=t.url,[a,i]=f.useState(null);async function c(l){if(l==null)return;const d=await n.getFile(l);i(d)}return o.jsxs("div",{className:`rounded-lg border bg-white p-3 transition-colors ${s}`,children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"min-w-0 flex-1",children:o.jsx("div",{className:"flex items-center gap-2",children:o.jsx("span",{className:"body-2 truncate text-neutrals-800",title:t.title,children:t.title})})}),r&&o.jsx("div",{className:"shrink-0",children:o.jsx(j.Button,{title:e??"Download",onClick:()=>c(t.url),buttonClassName:"text-button-tertiary"})})]}),a&&o.jsx("div",{className:"mt-3",children:o.jsx("pre",{className:"overflow-x-auto rounded-md bg-white p-3",children:o.jsx("code",{children:JSON.stringify(a,null,2)})})})]})},wu="json";function yp(e){return Dp(e)?Sp(e?.slice(wu.length)):e}function Sp(e){let t="";if(e)try{t=JSON.stringify(JSON.parse(e),null,2)}catch{t=e.toString()}return t}function Dp(e){return e?.startsWith(wu)||!1}const Tp=({attachment:e,className:t=""})=>{const n=yp(e.data);return n?o.jsxs("div",{className:`attachment-json rounded-lg border bg-white ${t}`,children:[o.jsx("div",{className:"flex items-center justify-between rounded-t-lg border-b border-neutrals-200 bg-neutrals-100 px-3 py-2",children:o.jsx("div",{className:"flex items-center gap-2",children:o.jsx("h3",{className:"text-neutrals-900",children:e.title})})}),o.jsx("div",{className:"p-3",children:o.jsx("pre",{className:"max-h-96 overflow-auto whitespace-pre-wrap break-words text-neutrals-800",children:o.jsx("code",{children:n})})})]}):null},Mp=e=>{try{const t=new URL(e);return["http:","https:","data:"].includes(t.protocol)}catch{return!1}},Ap=e=>Mp(e)?e:"",Ep=e=>Ee.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ee.createElement("path",{d:"M11.3333 4.66667H8.66659V6.00001H11.3333C12.4333 6.00001 13.3333 6.9 13.3333 8C13.3333 9.1 12.4333 10 11.3333 10H8.66659V11.3333H11.3333C13.1733 11.3333 14.6666 9.84 14.6666 8C14.6666 6.16 13.1733 4.66667 11.3333 4.66667ZM7.33325 10H4.66659C3.56659 10 2.66659 9.1 2.66659 8C2.66659 6.9 3.56659 6.00001 4.66659 6.00001H7.33325V4.66667H4.66659C2.82659 4.66667 1.33325 6.16 1.33325 8C1.33325 9.84 2.82659 11.3333 4.66659 11.3333H7.33325V10ZM5.33325 7.33334H10.6666V8.66667H5.33325V7.33334Z",fill:"currentColor"})),Np=({attachment:e,openLinkTitle:t,className:n=""})=>{const s=Ap(e.data||"");if(!s)return null;const r=a=>{window.open(a,"_blank")?.focus()};return o.jsx("div",{className:`max-w-[500px] rounded-lg border bg-white py-3 pl-4 pr-3 ${n}`,children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("span",{className:"mt-1 shrink-0 text-hues-800",role:"img","aria-label":"Link",children:o.jsx(Ep,{width:16,height:16})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"mb-1",children:o.jsx(j.Link,{url:s,title:e.title})}),o.jsx("div",{className:"truncate break-all text-neutrals-600",children:s})]}),o.jsx("div",{className:"shrink-0",children:o.jsx(j.Button,{title:t??"Open link",onClick:()=>r(s),buttonClassName:"text-button-tertiary"})})]})})},bu=({dimensionsInfo:e})=>o.jsx("div",{className:"sidebar flex min-h-0 w-[176px] flex-col gap-3 overflow-auto",children:e.map(t=>o.jsxs("div",{className:"flex flex-col",children:[o.jsx("h5",{className:"text-neutrals-800",children:t.title}),o.jsx("h5",{className:"font-bold",children:t.value})]},t.title))}),jp=({chart:e,isOpen:t,onClose:n,datasetTitle:s})=>{const{titles:r}=De(),[a,i]=f.useState(j.PopUpState.Closed);f.useEffect(()=>{i(t?j.PopUpState.Opened:j.PopUpState.Closed)},[t]);const c=f.useCallback(()=>{i(j.PopUpState.Closed),n?.()},[n]);return o.jsx(o.Fragment,{children:a===j.PopUpState.Opened&&o.jsxs(j.Popup,{heading:o.jsx("h1",{className:"single-chart-popup-heading",children:r?.chart??"Chart"}),containerClassName:"single-chart-popup h-[80%]",portalId:"single-chart",size:j.PopUpSize.LG,dividers:!1,onClose:c,closeButtonTitle:r?.close??"Close",children:[o.jsxs("div",{className:"single-chart-popup-content flex h-full min-h-0 flex-1 flex-row gap-4",children:[o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[s&&o.jsxs("div",{className:"mb-2 flex items-center gap-1",children:[o.jsx(qr,{className:"size-4 shrink-0 text-neutrals-1000"}),o.jsx("h4",{className:"text-neutrals-1000",children:s})]}),o.jsx(Dl,{option:e.config,className:"size-full",style:{width:"100%",height:"100%"}})]}),o.jsx(bu,{dimensionsInfo:e.dimensions})]}),o.jsx("div",{})]})})},Yr=e=>{const{titles:t}=De(),[n,s]=f.useState(!1),[r,a]=f.useState(),i=f.useRef(null),[c,l]=f.useState(""),[d,u]=f.useState(""),[h,m]=f.useState(!1),{onboardingFileSchema:p,isShowOnboarding:g}=Xe(),{isCrossDatasetModeOn:x}=We(),[v,w]=f.useState(!1),C=f.useMemo(()=>kp(e.value),[e.value]),b=f.useCallback(()=>{a(N=>N??C),s(!0)},[C]),y=f.useCallback(()=>{s(!1),w(!0)},[]);return f.useEffect(()=>{if(g){const{title:N,description:E}=mt(Ge.CHART_PER_SERIES,t);l(N),u(E)}},[t,g]),f.useEffect(()=>{g&&m(p?.lastDisplayedElement===Ge.CHART_PER_SERIES&&e.node.rowIndex===0)},[p?.lastDisplayedElement,e.node.rowIndex,g]),f.useEffect(()=>{a(void 0)},[e.value]),C&&!C.isPlottable?null:o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:i,children:o.jsx(j.IconButton,{title:t?.chart??"Chart",buttonClassName:"!text-neutrals-1000 !border-none !p-1",icon:o.jsx(Cu,{className:"size-5"}),onClick:b})}),h&&o.jsx(pt,{reference:i,title:c,description:d,onReferenceClick:b,shouldCloseTooltip:v}),n&&r&&o.jsx(jp,{chart:r,isOpen:n,onClose:y,datasetTitle:x?e.data?.datasetTitle??void 0:void 0})]})};function kp(e){return typeof e=="function"?e():e}const zt=32,An=32,_p=16,Ct="padding-0",Et=200,St={flex:1,minWidth:Et},Ip=zt,En="observationValueCell",Nn="metadataCell",xu="chartCell",yu="mergedDimensionCell",Su="datasetDetailCell",Ut="Chart_column",Rp=(e,t,n,s,r,a)=>({headerName:"",suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:!0,width:32,maxWidth:32,cellClass:Ct,cellRenderer:Nn,cellRendererParams:{attributesData:t,dataSetData:e,locale:n,metadataSettings:s,titles:r,action:a}});function Du(e,t,n,s=Ip,r,a){return{headerName:"",field:Ut,colId:Ut,suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:"right",width:s,maxWidth:s,minWidth:s,cellClass:Ct,suppressColumnsToolPanel:!0,cellRenderer:Yr,cellRendererParams:{attributesData:t,dataSetData:e,locale:n,titles:r,action:a}}}function Pp(e,t,n,s){return{headerName:"",suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:!0,width:32,maxWidth:32,cellClass:Ct,cellRenderer:Nn,cellRendererParams:{structuresMap:e,attributesDataMap:t,locale:n,titles:s}}}const _r=["index","value"],Lp=e=>({columns:Vp(e),data:Op(e)}),Op=e=>{const t=e.metadata.time_column,n={};for(const s of e.data.data){const{value:r,...a}=s,i=Fp(s,t);n[i]={...n[i]||{},...a,[s[t]]:r}}return Object.values(n)},Fp=(e,t)=>Object.keys(e).filter(n=>!_r.includes(n)&&n!==t).map(n=>e[n]).join("."),Vp=e=>{const{metadata:t,data:n}=e,s=t.time_column,r=t.pinned_columns||[],a=n.schema.fields,i=[],c=n.data.map(m=>m[s]),d=Array.from(new Set(c)).filter(m=>m!=null).map(m=>({field:m,colId:m,headerName:m,cellClass:"text-right",width:Et})),u=r.map(m=>a.find(p=>p.name===m)).filter(m=>m!=null),h=a.filter(m=>!r.includes(m.name)).filter(m=>m!=null);if(u.length>0)for(const m of[...u])m.name===s||_r.includes(m.name)||i.push({colId:m.name,field:m.name,headerName:m.name,pinned:"left",...St,tooltipValueGetter:p=>p.value});for(const m of[...h])m.name===s||_r.includes(m.name)||i.push({colId:m.name,field:m.name,headerName:m.name,pinned:!1,...St,tooltipValueGetter:p=>p.value});return i.push(...d),i},Zr=e=>e*An+zt+_p,Hp=({attachment:e,actions:t,className:n="",showLimitMessage:s})=>{const[r,a]=f.useState(!1),[i,c]=f.useState([]),[l,d]=f.useState(),[u,h]=f.useState(400);f.useEffect(()=>{e.url!=null&&(a(!0),t.getFile(e.url).then(p=>{if(p==null){c([]),d([]),a(!1);return}const{columns:g,data:x}=Lp(p);c(x),d(g),a(!1)}))},[e.url,t]),f.useEffect(()=>{i?(h(Zr(i.length)),s?.(i.length>=j.SERIES_LIMIT)):s?.(!1)},[i,s]);const m=f.useMemo(()=>o.jsx(Pr.AgGridReact,{headerHeight:zt,rowHeight:An,rowData:i,columnDefs:l,enableCellTextSelection:!0,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",autoSizeStrategy:{type:l&&l?.length>5?"fitCellContents":"fitGridWidth"}}),[i,l]);return r?o.jsx(j.Loader,{}):o.jsx("div",{className:`w-full ${n}`,children:o.jsx("div",{className:"ag-theme-quartz max-h-[400px] min-h-[80px] w-full",style:{height:u},children:m})})},Tu=e=>Ee.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ee.createElement("path",{d:"M7.4665 6.39967H8.53317V5.33301H7.4665V6.39967ZM7.4665 10.6663H8.53317V7.46634H7.4665V10.6663ZM7.9945 13.333C5.0505 13.333 2.6665 10.9437 2.6665 7.99967C2.6665 5.05567 5.0505 2.66634 7.9945 2.66634C10.9438 2.66634 13.3332 5.05567 13.3332 7.99967C13.3332 10.9437 10.9438 13.333 7.9945 13.333ZM7.99984 3.73301C5.6425 3.73301 3.73317 5.64234 3.73317 7.99967C3.73317 10.357 5.6425 12.2663 7.99984 12.2663C10.3572 12.2663 12.2665 10.357 12.2665 7.99967C12.2665 5.64234 10.3572 3.73301 7.99984 3.73301Z",fill:"currentColor"})),Up=({title:e,value:t})=>{const n=f.useCallback(()=>Array.isArray(t)?t.join(", "):t,[t]);return o.jsxs("div",{className:"body-3 flex gap-x-3",children:[o.jsxs("p",{title:e,className:"text-neutrals-800",children:[e,":"]}),o.jsx("p",{title:n(),className:"truncate pr-3 font-semibold",children:n()})]})};function Mu(e){const t=f.useRef(null),[n,s]=f.useState(!1),[r,a]=f.useState(!1),i=f.useCallback(()=>{const l=t.current;l&&a(l.scrollHeight>l.offsetHeight)},[]);f.useEffect(()=>{if(n)return;i();const l=t.current;if(!l||typeof ResizeObserver>"u")return;const d=new ResizeObserver(()=>i());return d.observe(l),()=>d.disconnect()},[n,e,i]);const c=f.useCallback(()=>s(l=>!l),[]);return{valueRef:t,isExpanded:n,canToggle:r,toggle:c}}const Au=({isExpanded:e,onToggle:t,title:n})=>o.jsx(j.IconButton,{title:n,buttonClassName:$("border-none p-0 w-6 h-6 shrink-0",e&&"rotate-[180deg]"),isBaseIconStyles:!1,icon:o.jsx(Ur,{width:24,height:24}),onClick:t}),Gp=({title:e,value:t,attachedKeysTitles:n,isDimensionGroup:s,locale:r})=>{const a=f.useMemo(()=>Array.isArray(t)?t?.map(u=>typeof u=="object"?u?.[r]:u)?.join(", "):t,[r,t]),{valueRef:i,isExpanded:c,canToggle:l,toggle:d}=Mu(a);return o.jsxs("div",{className:"metadata-item",children:[!s&&n?.map(u=>o.jsx("div",{title:u,className:"metadata-item-key mb-1 pr-3 text-neutrals-800",children:u},u)),o.jsxs("div",{className:$("flex items-center",l&&"justify-between"),children:[o.jsx("h2",{title:e,className:"metadata-item-title",children:e}),l&&o.jsx(Au,{isExpanded:c,onToggle:d})]}),o.jsx("p",{title:a,className:$("metadata-item-value pr-3",!c&&"line-clamp-4"),ref:i,children:a})]})},Bp=({metadata:e,metadataDescription:t=[],locale:n})=>{const{titles:s}=De();return o.jsxs("div",{className:"metadata-content h-full overflow-hidden",children:[t?.length>0&&o.jsx("div",{className:"metadata-description",children:t?.map(r=>o.jsx(Up,{title:r?.title,value:r?.value},r?.title))}),o.jsx("div",{className:"metadata-list h-full overflow-y-auto",children:e&&e?.length>0?e?.map(r=>o.jsx(Gp,{title:r?.title,value:r?.value,locale:n,attachedKeysTitles:r?.attachedKeysTitles,isDimensionGroup:r?.isDimensionGroup},r?.id||r?.title)):o.jsx("div",{className:"metadata-empty flex h-full items-center justify-center text-neutrals-700",children:s?.noMetadata||"No metadata"})})]})},Xr=({metadata:e,metadataDescription:t=[],isOpenMetadata:n,onCloseMetadata:s,locale:r})=>{const{titles:a}=De(),[i,c]=f.useState(j.PopUpState.Closed);f.useEffect(()=>{c(n?j.PopUpState.Opened:j.PopUpState.Closed)},[n]);const l=f.useCallback(()=>{c(j.PopUpState.Closed),s?.()},[s]);return o.jsx(o.Fragment,{children:i===j.PopUpState.Opened&&o.jsxs(j.Popup,{heading:o.jsx("h1",{className:"metadata-heading",children:a?.metadata||"Metadata"}),containerClassName:"metadata h-[80%]",portalId:"metadata",size:j.PopUpSize.LG,dividers:!1,onClose:l,closeButtonTitle:a?.close||"Close",children:[o.jsx(Bp,{locale:r,metadata:e,metadataDescription:t}),o.jsx("div",{})]})})},dt={dataset:"dataset",agency:"agency",lastUpdated:"lastUpdated"},zp=({dataset:e,agency:t,lastUpdated:n,externalLink:s,formatValue:r})=>o.jsxs("div",{className:"mb-6 flex flex-col gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(qe.IconDatabase,{className:"size-4 text-neutrals-700"}),o.jsx("p",{className:"h4 break-words text-neutrals-1000",children:r(e?.value)}),s&&o.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:o.jsx(qe.IconExternalLink,{className:"size-4 shrink-0 cursor-pointer text-primary"})})]}),t&&o.jsxs("div",{className:"body-3 flex gap-1",children:[o.jsxs("span",{className:"text-neutrals-800",children:[t?.title,":"]}),o.jsx("span",{className:"break-words text-neutrals-1000",children:r(t?.value)})]}),n&&o.jsxs("div",{className:"body-3 flex gap-1",children:[o.jsxs("span",{className:"text-neutrals-800",children:[n?.title,":"]}),o.jsx("span",{className:"break-words text-neutrals-1000",children:r(n?.value)})]})]}),qp=({title:e,value:t,attachedKeysTitles:n,isDimensionGroup:s})=>{const{valueRef:r,isExpanded:a,canToggle:i,toggle:c}=Mu(t);return o.jsxs("div",{className:"flex flex-col gap-1",children:[!s&&n?.map((l,d)=>o.jsx("div",{title:l,className:"body-3 text-neutrals-800",children:l},`${l}-${d}`)),o.jsxs("div",{className:"flex items-center justify-between gap-2 pr-2",children:[o.jsx("p",{title:e,className:"body-3 text-neutrals-800",children:e}),i&&o.jsx(Au,{isExpanded:a,onToggle:c})]}),o.jsx("p",{ref:r,title:t,className:$("body-2 break-words text-neutrals-1000",!a&&"line-clamp-4"),children:t})]})},Wp=new Set(Object.values(dt)),$p=", ",qt=({metadata:e,metadataDescription:t=[],datasetInfo:n,externalLink:s,locale:r})=>{const{titles:a}=De(),i=f.useCallback(p=>Array.isArray(p)?p.map(g=>typeof g=="object"?g?.[r]??"":g).join($p):typeof p=="object"&&p!==null?p?.[r]??"":p??"",[r]),{dataset:c,agency:l,lastUpdated:d,hasStructuredDatasetInfo:u}=f.useMemo(()=>{const p=t.find(b=>b?.id===dt.dataset),g=t.find(b=>b?.id===dt.agency),x=t.find(b=>b?.id===dt.lastUpdated),v=n?.dataset||p,w=n?.agency||g,C=n?.lastUpdated||x;return{dataset:v,agency:w,lastUpdated:C,hasStructuredDatasetInfo:!!v}},[n,t]),h=f.useMemo(()=>u?t.filter(p=>!p?.id||!Wp.has(p.id)):t,[u,t]),m=u||h.length>0||!!e?.length;return o.jsx("div",{className:"flex h-full flex-col overflow-hidden px-5 pb-4",children:m?o.jsxs(o.Fragment,{children:[u&&c&&o.jsx(zp,{dataset:c,agency:l,lastUpdated:d,externalLink:s,formatValue:i}),h.length>0&&o.jsx("div",{className:"mb-4 flex flex-col gap-2",children:h.map((p,g)=>o.jsxs("div",{className:"body-3 flex gap-2",children:[o.jsxs("span",{className:"shrink-0 text-neutrals-800",children:[p?.title||p?.id,":"]}),o.jsx("span",{className:"min-w-0 truncate font-semibold text-neutrals-1000",children:i(p?.value)})]},`${p?.id||p?.title}-${g}`))}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:o.jsx("div",{className:"flex flex-col gap-4",children:e?.map(p=>o.jsx(qp,{title:p?.title||p?.id,value:i(p?.value),attachedKeysTitles:p?.attachedKeysTitles,isDimensionGroup:p?.isDimensionGroup},p?.id||p?.title))})})]}):o.jsx("div",{className:"body-3 flex h-full items-center justify-center text-neutrals-700",children:a?.noMetadata||"No metadata"})})};function jn(e,t){const{externalLink:n,externalLinksMap:s}=e??{};return t!=null&&s!=null?s.get(t):n}const Kp=e=>e?.data[e?.colDef?.field||0]?.obsAttributes,Jp=e=>e?.data?.attributes,Eu=(e,t)=>Object.entries(e?.data).filter(([n])=>t?.get(n)).map(([n,s])=>({name:n,value:String(s)})),sl=(e,t,n)=>{const s=typeof e=="object"?e?.[t]:e;return n?D.getLocalizedName(n?.codes?.find(r=>r?.id===e),t)||"":s},Gt=(e,t,n)=>e?.map(s=>{const r=s?.name||"",a=t?.get(r),i=a?.codes?.length?a:void 0,c=Array.isArray(s?.value)?s?.value.map(l=>sl(l,n,i)):sl(s?.value,n,i);return{id:D.getLocalizedName(i,n)||s?.name,title:D.getLocalizedName(i||a,n),value:c||s?.value}})||[],Wt=(e,t,n)=>({title:n?.dataset||"Dataset",value:D.getLocalizedName(e,t)}),Yp=(e,t,n,s)=>[{...Wt(e,n,s),id:dt.dataset},{id:dt.agency,title:s?.agency??"Agency",value:e?.agencyID},{id:dt.lastUpdated,title:s?.lastUpdated??"Last updated",value:t}],$t=(e,t,n,s)=>({dataset:e?{...Wt(e,n,s),id:dt.dataset}:void 0,agency:e?{id:dt.agency,title:s?.agency??"Agency",value:e?.agencyID}:void 0,lastUpdated:e?{id:dt.lastUpdated,title:s?.lastUpdated??"Last updated",value:t}:void 0}),Nu=(e,t,n)=>({title:D.getDimensionTitle(e?.conceptSchemes,D.getDimensions(e)?.timeDimensions?.[0],t),value:n?.colId||""}),ju=(e,t)=>({title:t?.observation||"Observation",value:e}),ku=(e,t,n,s,r,a)=>{const i={title:s?.timeSeries||"Time Series",value:a?.originalData?.name};return n?[Nu(e,t,r),i,ju(n,s)]:[i]},_u=e=>{const t=e?.dataSets?.[0]?.attributes||[],n=e?.structures?.[0]?.attributes?.dataSet||[];return t?.length?n.reduce((s,r,a)=>{const i=t[a];if(i==null)return s;if(r?.values?.length>0){const c=r.values[i];s.push(c?{...r,values:[c]}:{...r})}else Array.isArray(i)?s.push({...r,values:[{values:i}]}):s.push({...r,values:[{value:i}]});return s},[]):n},rl=(e,t)=>{if(e==null)return;if(typeof e!="object")return String(e);const n=e,s=n[t];if(typeof s=="string")return s;const r=Object.values(n).find(a=>typeof a=="string");return typeof r=="string"?r:void 0},Iu=(e,t,n)=>e?.map(s=>{const r=s?.id,a=s?.values?.[0]?.value,i=(typeof a=="object"?rl(a,n):a)||s?.values?.[0]?.id,c=s?.values?.[0]?.ids||s?.values?.[0]?.values,l=t?.get(r),d=l?.codes?.length?l:void 0,u=D.getLocalizedName(d?.codes?.find(m=>m?.id===i),n)||D.getLocalizedName(s?.values?.[0],n)||i,h=c&&c.map(m=>{const p=typeof m=="object"?rl(m,n):String(m);return D.getLocalizedName(d?.codes?.find(g=>g?.id===p),n)||p}).filter(m=>m!=null);return{id:r,title:D.getLocalizedName(l,n)||r,value:h?.length?h:u}}).filter(({value:s})=>!!s)||[],Zp=(e,t)=>{const n=e?.dataSets?.[0],r=e?.structures?.[0]?.attributes?.dimensionGroup||[],a=n?.dimensionGroupAttributes;return new Map(r.map(i=>{const c=i?.relationship?.dimensions,{codedSeriesKey:l,decodedSeriesKey:d}=Xp(e,t,c);return[i.id,{values:a?.[l]||[],decodedSeriesKey:d,codedSeriesKey:l}]}))},Xp=(e,t,n)=>{const s=e?.structures?.[0],r=[...s?.dimensions.series||[],...s?.dimensions.observation||[]],a=new Array(r?.length)?.fill(""),i=new Array(r?.length)?.fill("");return n&&n?.forEach(c=>{const l=r?.findIndex(h=>h?.id===c)||0,d=t[l],u=r[l]?.values?.findIndex(h=>h?.id===d||h?.value===d)||0;a[l]=u>=0?u:d,i[l]=d}),{codedSeriesKey:a?.join(":"),decodedSeriesKey:i?.join(":")}},Qp=(e,t)=>{if(t==null)return;const n=e?.values?.[t],s=typeof t=="object"&&!Array.isArray(t),r=Array.isArray(t);return n||(s||r?{values:t}:{value:t?.toString()})},eg=e=>{const t=e?.value||e?.id,n=e?.values||e?.ids;return t!=null?[t]:n||[null]},Ru=(e,t,n)=>t==null?t:n?.get(e||"")?.codes?.find(r=>r?.id===t)?.name||t,tg=(e,t,n,s=ne.Locale.EN)=>{const r=n?.dataStructureComponents?.dimensionList,a=[...r?.dimensions||[],...r?.timeDimensions||[]],i=[];return(e?.split(":")||[])?.forEach((l,d)=>{if(l!==""){const u=a?.[d]?.id||"",h=D.getLocalizedName(t?.get(u),s),m=Ru(u,l,t);i.push(`${h}: ${m}`)}}),i},ng=(e,t,n,s,r=ne.Locale.EN)=>{if(!e||!t||!s)return[];const a=e?.structures?.[0]?.attributes?.dimensionGroup||[],i=Zp(e,s);return a?.map((c,l)=>{const d=i?.get(c?.id),u=n?.get(c?.id),h=eg(Qp(c,d?.values?.[l]));return{id:c?.id,title:D.getLocalizedName(u,r),value:Array.isArray(h)?h?.map(m=>Ru(c?.id,m,n)||""):h,attachedKeysTitles:tg(d?.decodedSeriesKey,n,t),isDimensionGroup:!0}})?.filter(({value:c})=>c?.some(l=>!!l))||[]},sg=gd.extendTailwindMerge({extend:{classGroups:{typography:["h1","h2","h3","h4","h5","body-1","body-2","body-3","caption"]}}});function st(...e){return sg($(...e))}function rg({title:e,headerExtension:t,headerClassName:n,onClose:s,bodyClassName:r,panelClassName:a,children:i}){return o.jsxs("div",{className:st("h-full w-[362px] bg-white border-l border-neutrals-500 flex flex-col overflow-hidden",a),children:[o.jsxs("div",{className:st("flex justify-between px-5 py-6",n),children:[o.jsx("div",{className:"h2 text-neutrals-1000",children:e}),o.jsxs("div",{className:"flex items-center gap-2",children:[t,t&&o.jsx("div",{className:"h-3 w-px bg-neutrals-600"}),o.jsx("button",{type:"button",onClick:s,children:o.jsx(qe.IconX,{className:"size-5 text-neutrals-1000"})})]})]}),o.jsx("div",{className:st("flex-1 min-h-0 overflow-hidden",r),children:i})]})}const Pu=f.createContext(null);function ag({children:e}){const[t,n]=f.useState(null),s=f.useCallback(c=>{n(c)},[]),r=f.useCallback(()=>{n(null)},[]),a=f.useCallback(c=>c?t?.id===c:t!==null,[t]),i=f.useMemo(()=>({panel:t,openPanel:s,closePanel:r,isPanelOpen:a}),[t,s,r,a]);return o.jsx(Pu.Provider,{value:i,children:e})}function Lu(){return f.useContext(Pu)}function wt(){const e=Lu();if(!e)return null;const{openPanel:t,closePanel:n,isPanelOpen:s}=e;return{openPanel:t,closePanel:n,isPanelOpen:s}}function Ou({scope:e}){const t=Lu();if(!t)return null;const{panel:n,closePanel:s}=t;if(!n)return null;const r=n.scope??"any";return r!=="any"&&r!==e?null:o.jsx(rg,{title:n.title,headerExtension:n.headerExtension,headerClassName:n.headerClassName,onClose:s,bodyClassName:n.bodyClassName,panelClassName:n.panelClassName,children:n.content})}function xr(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function _t(e){return(t,n)=>{const s=n?.context?String(n.context):"standalone";let r;if(s==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,c=n?.width?String(n.width):i;r=e.formattingValues[c]||e.formattingValues[i]}else{const i=e.defaultWidth,c=n?.width?String(n.width):e.defaultWidth;r=e.values[c]||e.values[i]}const a=e.argumentCallback?e.argumentCallback(t):t;return r[a]}}function It(e){return(t,n={})=>{const s=n.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],a=t.match(r);if(!a)return null;const i=a[0],c=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(c)?og(c,h=>h.test(i)):ig(c,h=>h.test(i));let d;d=e.valueCallback?e.valueCallback(l):l,d=n.valueCallback?n.valueCallback(d):d;const u=t.slice(i.length);return{value:d,rest:u}}}function ig(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function og(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function lg(e){return(t,n={})=>{const s=t.match(e.matchPattern);if(!s)return null;const r=s[0],a=t.match(e.parsePattern);if(!a)return null;let i=e.valueCallback?e.valueCallback(a[0]):a[0];i=n.valueCallback?n.valueCallback(i):i;const c=t.slice(r.length);return{value:i,rest:c}}}const al=Symbol.for("constructDateFrom");function Fu(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&al in e?e[al](t):e instanceof Date?new e.constructor(t):new Date(t)}function cg(e,...t){const n=Fu.bind(null,e||t.find(s=>typeof s=="object"));return t.map(n)}let ug={};function dg(){return ug}function Qr(e,t){return Fu(t||e,e)}function il(e,t){const n=dg(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=Qr(e,t?.in),a=r.getDay(),i=(a<s?7:0)+a-s;return r.setDate(r.getDate()-i),r.setHours(0,0,0,0),r}function Vu(e,t,n){const[s,r]=cg(n?.in,e,t);return+il(s,n)==+il(r,n)}function Rt(e,t){if(e.one!==void 0&&t===1)return e.one;const n=t%10,s=t%100;return n===1&&s!==11?e.singularNominative.replace("{{count}}",String(t)):n>=2&&n<=4&&(s<10||s>20)?e.singularGenitive.replace("{{count}}",String(t)):e.pluralGenitive.replace("{{count}}",String(t))}function Ye(e){return(t,n)=>n&&n.addSuffix?n.comparison&&n.comparison>0?e.future?Rt(e.future,t):"за "+Rt(e.regular,t):e.past?Rt(e.past,t):Rt(e.regular,t)+" тому":Rt(e.regular,t)}const fg=(e,t)=>t&&t.addSuffix?t.comparison&&t.comparison>0?"за півхвилини":"півхвилини тому":"півхвилини",hg={lessThanXSeconds:Ye({regular:{one:"менше секунди",singularNominative:"менше {{count}} секунди",singularGenitive:"менше {{count}} секунд",pluralGenitive:"менше {{count}} секунд"},future:{one:"менше, ніж за секунду",singularNominative:"менше, ніж за {{count}} секунду",singularGenitive:"менше, ніж за {{count}} секунди",pluralGenitive:"менше, ніж за {{count}} секунд"}}),xSeconds:Ye({regular:{singularNominative:"{{count}} секунда",singularGenitive:"{{count}} секунди",pluralGenitive:"{{count}} секунд"},past:{singularNominative:"{{count}} секунду тому",singularGenitive:"{{count}} секунди тому",pluralGenitive:"{{count}} секунд тому"},future:{singularNominative:"за {{count}} секунду",singularGenitive:"за {{count}} секунди",pluralGenitive:"за {{count}} секунд"}}),halfAMinute:fg,lessThanXMinutes:Ye({regular:{one:"менше хвилини",singularNominative:"менше {{count}} хвилини",singularGenitive:"менше {{count}} хвилин",pluralGenitive:"менше {{count}} хвилин"},future:{one:"менше, ніж за хвилину",singularNominative:"менше, ніж за {{count}} хвилину",singularGenitive:"менше, ніж за {{count}} хвилини",pluralGenitive:"менше, ніж за {{count}} хвилин"}}),xMinutes:Ye({regular:{singularNominative:"{{count}} хвилина",singularGenitive:"{{count}} хвилини",pluralGenitive:"{{count}} хвилин"},past:{singularNominative:"{{count}} хвилину тому",singularGenitive:"{{count}} хвилини тому",pluralGenitive:"{{count}} хвилин тому"},future:{singularNominative:"за {{count}} хвилину",singularGenitive:"за {{count}} хвилини",pluralGenitive:"за {{count}} хвилин"}}),aboutXHours:Ye({regular:{singularNominative:"близько {{count}} години",singularGenitive:"близько {{count}} годин",pluralGenitive:"близько {{count}} годин"},future:{singularNominative:"приблизно за {{count}} годину",singularGenitive:"приблизно за {{count}} години",pluralGenitive:"приблизно за {{count}} годин"}}),xHours:Ye({regular:{singularNominative:"{{count}} годину",singularGenitive:"{{count}} години",pluralGenitive:"{{count}} годин"}}),xDays:Ye({regular:{singularNominative:"{{count}} день",singularGenitive:"{{count}} днi",pluralGenitive:"{{count}} днів"}}),aboutXWeeks:Ye({regular:{singularNominative:"близько {{count}} тижня",singularGenitive:"близько {{count}} тижнів",pluralGenitive:"близько {{count}} тижнів"},future:{singularNominative:"приблизно за {{count}} тиждень",singularGenitive:"приблизно за {{count}} тижні",pluralGenitive:"приблизно за {{count}} тижнів"}}),xWeeks:Ye({regular:{singularNominative:"{{count}} тиждень",singularGenitive:"{{count}} тижні",pluralGenitive:"{{count}} тижнів"}}),aboutXMonths:Ye({regular:{singularNominative:"близько {{count}} місяця",singularGenitive:"близько {{count}} місяців",pluralGenitive:"близько {{count}} місяців"},future:{singularNominative:"приблизно за {{count}} місяць",singularGenitive:"приблизно за {{count}} місяці",pluralGenitive:"приблизно за {{count}} місяців"}}),xMonths:Ye({regular:{singularNominative:"{{count}} місяць",singularGenitive:"{{count}} місяці",pluralGenitive:"{{count}} місяців"}}),aboutXYears:Ye({regular:{singularNominative:"близько {{count}} року",singularGenitive:"близько {{count}} років",pluralGenitive:"близько {{count}} років"},future:{singularNominative:"приблизно за {{count}} рік",singularGenitive:"приблизно за {{count}} роки",pluralGenitive:"приблизно за {{count}} років"}}),xYears:Ye({regular:{singularNominative:"{{count}} рік",singularGenitive:"{{count}} роки",pluralGenitive:"{{count}} років"}}),overXYears:Ye({regular:{singularNominative:"більше {{count}} року",singularGenitive:"більше {{count}} років",pluralGenitive:"більше {{count}} років"},future:{singularNominative:"більше, ніж за {{count}} рік",singularGenitive:"більше, ніж за {{count}} роки",pluralGenitive:"більше, ніж за {{count}} років"}}),almostXYears:Ye({regular:{singularNominative:"майже {{count}} рік",singularGenitive:"майже {{count}} роки",pluralGenitive:"майже {{count}} років"},future:{singularNominative:"майже за {{count}} рік",singularGenitive:"майже за {{count}} роки",pluralGenitive:"майже за {{count}} років"}})},mg=(e,t,n)=>(n=n||{},hg[e](t,n)),pg={full:"EEEE, do MMMM y 'р.'",long:"do MMMM y 'р.'",medium:"d MMM y 'р.'",short:"dd.MM.y"},gg={full:"H:mm:ss zzzz",long:"H:mm:ss z",medium:"H:mm:ss",short:"H:mm"},vg={full:"{{date}} 'о' {{time}}",long:"{{date}} 'о' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Cg={date:xr({formats:pg,defaultWidth:"full"}),time:xr({formats:gg,defaultWidth:"full"}),dateTime:xr({formats:vg,defaultWidth:"full"})},ea=["неділю","понеділок","вівторок","середу","четвер","п’ятницю","суботу"];function wg(e){const t=ea[e];switch(e){case 0:case 3:case 5:case 6:return"'у минулу "+t+" о' p";case 1:case 2:case 4:return"'у минулий "+t+" о' p"}}function Hu(e){return"'у "+ea[e]+" о' p"}function bg(e){const t=ea[e];switch(e){case 0:case 3:case 5:case 6:return"'у наступну "+t+" о' p";case 1:case 2:case 4:return"'у наступний "+t+" о' p"}}const xg=(e,t,n)=>{const s=Qr(e),r=s.getDay();return Vu(s,t,n)?Hu(r):wg(r)},yg=(e,t,n)=>{const s=Qr(e),r=s.getDay();return Vu(s,t,n)?Hu(r):bg(r)},Sg={lastWeek:xg,yesterday:"'вчора о' p",today:"'сьогодні о' p",tomorrow:"'завтра о' p",nextWeek:yg,other:"P"},Dg=(e,t,n,s)=>{const r=Sg[e];return typeof r=="function"?r(t,n,s):r},Tg={narrow:["до н.е.","н.е."],abbreviated:["до н. е.","н. е."],wide:["до нашої ери","нашої ери"]},Mg={narrow:["1","2","3","4"],abbreviated:["1-й кв.","2-й кв.","3-й кв.","4-й кв."],wide:["1-й квартал","2-й квартал","3-й квартал","4-й квартал"]},Ag={narrow:["С","Л","Б","К","Т","Ч","Л","С","В","Ж","Л","Г"],abbreviated:["січ.","лют.","берез.","квіт.","трав.","черв.","лип.","серп.","верес.","жовт.","листоп.","груд."],wide:["січень","лютий","березень","квітень","травень","червень","липень","серпень","вересень","жовтень","листопад","грудень"]},Eg={narrow:["С","Л","Б","К","Т","Ч","Л","С","В","Ж","Л","Г"],abbreviated:["січ.","лют.","берез.","квіт.","трав.","черв.","лип.","серп.","верес.","жовт.","листоп.","груд."],wide:["січня","лютого","березня","квітня","травня","червня","липня","серпня","вересня","жовтня","листопада","грудня"]},Ng={narrow:["Н","П","В","С","Ч","П","С"],short:["нд","пн","вт","ср","чт","пт","сб"],abbreviated:["нед","пон","вів","сер","чтв","птн","суб"],wide:["неділя","понеділок","вівторок","середа","четвер","п’ятниця","субота"]},jg={narrow:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранок",afternoon:"день",evening:"веч.",night:"ніч"},abbreviated:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранок",afternoon:"день",evening:"веч.",night:"ніч"},wide:{am:"ДП",pm:"ПП",midnight:"північ",noon:"полудень",morning:"ранок",afternoon:"день",evening:"вечір",night:"ніч"}},kg={narrow:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранку",afternoon:"дня",evening:"веч.",night:"ночі"},abbreviated:{am:"ДП",pm:"ПП",midnight:"півн.",noon:"пол.",morning:"ранку",afternoon:"дня",evening:"веч.",night:"ночі"},wide:{am:"ДП",pm:"ПП",midnight:"північ",noon:"полудень",morning:"ранку",afternoon:"дня",evening:"веч.",night:"ночі"}},_g=(e,t)=>{const n=String(t?.unit),s=Number(e);let r;return n==="date"?s===3||s===23?r="-є":r="-е":n==="minute"||n==="second"||n==="hour"?r="-а":r="-й",s+r},Ig={ordinalNumber:_g,era:_t({values:Tg,defaultWidth:"wide"}),quarter:_t({values:Mg,defaultWidth:"wide",argumentCallback:e=>e-1}),month:_t({values:Ag,defaultWidth:"wide",formattingValues:Eg,defaultFormattingWidth:"wide"}),day:_t({values:Ng,defaultWidth:"wide"}),dayPeriod:_t({values:jg,defaultWidth:"any",formattingValues:kg,defaultFormattingWidth:"wide"})},Rg=/^(\d+)(-?(е|й|є|а|я))?/i,Pg=/\d+/i,Lg={narrow:/^((до )?н\.?\s?е\.?)/i,abbreviated:/^((до )?н\.?\s?е\.?)/i,wide:/^(до нашої ери|нашої ери|наша ера)/i},Og={any:[/^д/i,/^н/i]},Fg={narrow:/^[1234]/i,abbreviated:/^[1234](-?[иі]?й?)? кв.?/i,wide:/^[1234](-?[иі]?й?)? квартал/i},Vg={any:[/1/i,/2/i,/3/i,/4/i]},Hg={narrow:/^[слбктчвжг]/i,abbreviated:/^(січ|лют|бер(ез)?|квіт|трав|черв|лип|серп|вер(ес)?|жовт|лис(топ)?|груд)\.?/i,wide:/^(січень|січня|лютий|лютого|березень|березня|квітень|квітня|травень|травня|червня|червень|липень|липня|серпень|серпня|вересень|вересня|жовтень|жовтня|листопад[а]?|грудень|грудня)/i},Ug={narrow:[/^с/i,/^л/i,/^б/i,/^к/i,/^т/i,/^ч/i,/^л/i,/^с/i,/^в/i,/^ж/i,/^л/i,/^г/i],any:[/^сі/i,/^лю/i,/^б/i,/^к/i,/^т/i,/^ч/i,/^лип/i,/^се/i,/^в/i,/^ж/i,/^лис/i,/^г/i]},Gg={narrow:/^[нпвсч]/i,short:/^(нд|пн|вт|ср|чт|пт|сб)\.?/i,abbreviated:/^(нед|пон|вів|сер|че?тв|птн?|суб)\.?/i,wide:/^(неділ[яі]|понеділ[ок][ка]|вівтор[ок][ка]|серед[аи]|четвер(га)?|п\W*?ятниц[яі]|субот[аи])/i},Bg={narrow:[/^н/i,/^п/i,/^в/i,/^с/i,/^ч/i,/^п/i,/^с/i],any:[/^н/i,/^п[он]/i,/^в/i,/^с[ер]/i,/^ч/i,/^п\W*?[ят]/i,/^с[уб]/i]},zg={narrow:/^([дп]п|півн\.?|пол\.?|ранок|ранку|день|дня|веч\.?|ніч|ночі)/i,abbreviated:/^([дп]п|півн\.?|пол\.?|ранок|ранку|день|дня|веч\.?|ніч|ночі)/i,wide:/^([дп]п|північ|полудень|ранок|ранку|день|дня|вечір|вечора|ніч|ночі)/i},qg={any:{am:/^дп/i,pm:/^пп/i,midnight:/^півн/i,noon:/^пол/i,morning:/^р/i,afternoon:/^д[ен]/i,evening:/^в/i,night:/^н/i}},Wg={ordinalNumber:lg({matchPattern:Rg,parsePattern:Pg,valueCallback:e=>parseInt(e,10)}),era:It({matchPatterns:Lg,defaultMatchWidth:"wide",parsePatterns:Og,defaultParseWidth:"any"}),quarter:It({matchPatterns:Fg,defaultMatchWidth:"wide",parsePatterns:Vg,defaultParseWidth:"any",valueCallback:e=>e+1}),month:It({matchPatterns:Hg,defaultMatchWidth:"wide",parsePatterns:Ug,defaultParseWidth:"any"}),day:It({matchPatterns:Gg,defaultMatchWidth:"wide",parsePatterns:Bg,defaultParseWidth:"any"}),dayPeriod:It({matchPatterns:zg,defaultMatchWidth:"wide",parsePatterns:qg,defaultParseWidth:"any"})},$g={code:"uk",formatDistance:mg,formatLong:Cg,formatRelative:Dg,localize:Ig,match:Wg,options:{weekStartsOn:1,firstWeekContainsDate:1}},Kg=e=>e===ne.Locale.UK?"dd MMM, yyyy":" MMM dd, yyyy hh:mm aa",Kt=(e,t)=>{const n=Kg(t);return e!=null&&e!==""&&n&&$a.isValid(new Date(e))?$a.format(new Date(e),n,t===ne.Locale.UK?{locale:$g}:void 0):""},Uu=e=>{const{titles:t}=De(),n="grid-metadata-side-panel",[s,r]=f.useState(!1),a=f.useRef(null),[i,c]=f.useState(""),[l,d]=f.useState(""),[u,h]=f.useState(!1),{onboardingFileSchema:m,isShowOnboarding:p}=Xe(),{isOpenedAdvancedView:g}=$e(),x=wt(),{isMetadataInSidePanel:v}=We(),[w,C]=f.useState(!1),b=e?.data?.dataset?.urn,y=jn(e?.context,b),N=f.useMemo(()=>e.structuresMap?b!=null?e.structuresMap.get(b):void 0:e.dataSetData,[e.structuresMap,b,e.dataSetData]),E=f.useMemo(()=>e.attributesDataMap?b!=null?e.attributesDataMap.get(b):void 0:e.attributesData,[e.attributesDataMap,b,e.attributesData]),T=f.useMemo(()=>D.getStructureComponentsMap(N),[N]),S=f.useMemo(()=>[Wt(N?.dataflows?.[0],e?.locale,t),...Gt(Eu(e,T),T,e?.locale),...Gt(Jp(e),T,e?.locale),...ng(E,N?.dataStructures?.[0],T,e?.data?.originalData?.parsedTimeSeriesValue,e?.locale)],[e,N,E,T,t]),_=f.useMemo(()=>ku(N,e?.locale,e?.valueFormatted||e?.value,t,e?.colDef,e?.data),[e,N,t]),A=f.useMemo(()=>{const R=N?.dataflows?.[0],L=Kt(D.getLastUpdatedTime(R),e?.locale);return $t(R,L,e?.locale,t)},[N,e?.locale,t]),M=f.useCallback(()=>{if(v&&x){x.openPanel({id:n,scope:g?"advanced":"conversation",title:t?.timeseriesMetadataPanel||"Timeseries Metadata",bodyClassName:"overflow-hidden",content:o.jsx(qt,{locale:e?.locale,metadata:S,datasetInfo:A,externalLink:y,metadataDescription:e?.metadataSettings?.isMetadataDescription?_:[]})}),C(!0);return}r(!0)},[v,g,S,_,A,y,e?.locale,e?.metadataSettings?.isMetadataDescription,t,x]),k=f.useCallback(()=>{r(!1),C(!0)},[]);return f.useEffect(()=>{if(p){const{title:R,description:L}=mt(Ge.METADATA_PER_SERIES,t);c(R),d(L)}},[t,p]),f.useEffect(()=>{if(p){const R=m?.lastDisplayedElement===Ge.METADATA_PER_SERIES&&e.node.rowIndex===0;h(R),R&&setTimeout(()=>{a?.current?.scrollIntoView({block:"end",behavior:"smooth"})})}},[m?.lastDisplayedElement,e.node.rowIndex,p]),o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:a,children:o.jsx(j.IconButton,{title:t?.metadata||"View details",buttonClassName:"!text-neutrals-1000 !border-none !p-1",icon:o.jsx(Tu,{className:"size-5"}),onClick:M})}),u&&o.jsx(pt,{reference:a,title:i,description:l,onReferenceClick:M,shouldCloseTooltip:w}),s&&o.jsx(Xr,{locale:e?.locale,metadata:S,metadataDescription:e?.metadataSettings?.isMetadataDescription?_:[],isOpenMetadata:s,onCloseMetadata:k})]})},Jg=(e,t)=>{const n=Yg(e),s=D.getStructureComponentsMap(n),r=e?.valueFormatted||e?.value,a=Gt(t,s,e?.locale),i=[Wt(n?.dataflows?.[0],e?.locale,e?.titles),...Gt(Eu(e,s),s,e?.locale),...e?.metadataSettings?.isMetadataDescription?[]:[Nu(n,e?.locale,e?.colDef),ju(r,e?.titles)],...a],c=e?.metadataSettings?.isMetadataDescription?ku(n,e?.locale,r,e?.titles,e?.colDef,e?.data):[],l=n?.dataflows?.[0],d=Kt(D.getLastUpdatedTime(l),e?.locale),u=$t(l,d,e?.locale,e?.titles);return{metadata:i,metadataDescription:c,sidePanelDatasetInfo:u}},Yg=e=>{if(e.structuresMap){const t=e?.data?.dataset?.urn;return t!=null?e.structuresMap.get(t):void 0}return e.dataSetData},Zg="observation-metadata-side-panel",Xg=({params:e,obsAttributes:t})=>{const{titles:n}=De(),[s,r]=f.useState(null),{isOpenedAdvancedView:a}=$e(),i=wt(),{isMetadataInSidePanel:c}=We(),l=e?.data?.dataset?.urn,d=jn(e?.context,l),u=f.useCallback(()=>{const m=Jg(e,t);if(c&&i){i.openPanel({id:Zg,scope:a?"advanced":"conversation",title:n?.metadata||"Metadata",bodyClassName:"overflow-hidden",content:o.jsx(qt,{locale:e?.locale,metadata:m.metadata,datasetInfo:m.sidePanelDatasetInfo,externalLink:d,metadataDescription:m.metadataDescription})});return}r(m)},[c,a,d,t,e,i,n]),h=f.useCallback(()=>{r(null)},[]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"relative size-full p-2 text-end",children:[e?.valueFormatted||e?.value,o.jsx("div",{className:"metadata-indicator",title:n?.metadata||"View details",onClick:u})]}),s&&o.jsx(Xr,{locale:e?.locale,metadata:s.metadata,metadataDescription:s.metadataDescription,isOpenMetadata:!0,onCloseMetadata:h})]})},Gu=e=>{const t=Kp(e);return t?.length?o.jsx(Xg,{params:e,obsAttributes:t}):o.jsx("div",{className:"relative size-full p-2 text-end",children:e?.valueFormatted||e?.value})},Bu=({ref:e,fixHeight:t,gridHeight:n,children:s})=>o.jsx("div",{ref:e,className:$("ag-theme-quartz w-full min-h-[80px]",t?"max-h-[400px]":"max-h-full"),style:{height:n},children:s}),Qg=({attachment:e,isDataLoading:t,isChartColumnVisible:n,fixHeight:s,externalLink:r,showLimitMessage:a,onApiReady:i})=>{const{titles:c}=De(),[l,d]=f.useState(!1),[u,h]=f.useState([]),[m,p]=f.useState(),[g,x]=f.useState(400),v=f.useRef(null),[w,C]=f.useState(""),[b,y]=f.useState(""),[N,E]=f.useState(!1),{isShowOnboarding:T,onboardingFileSchema:S,setOnboardingFileSchema:_}=Xe();f.useEffect(()=>{if(e.grid_data==null)d(!0);else{const L=e.grid_data.columns.map(z=>z.colId===Ut?{...z,hide:!n}:z);h(e.grid_data.data),p(L),d(!1)}},[e.grid_data,n]),f.useEffect(()=>{u?(x(Zr(u.length)),a?.(u.length>=j.SERIES_LIMIT)):a?.(!1)},[u,a]),f.useEffect(()=>{if(T){const{title:L,description:z}=mt(Ge.DATA_GRID,c);C(L),y(z)}},[c,T]),f.useEffect(()=>{S&&!S?.infoElements?.dataGrid&&_?.({...S,infoElements:{...S?.infoElements,dataGrid:!0},lastDisplayedElement:Ge.DATA_GRID})},[S,_]),f.useEffect(()=>{if(T){const L=S?.lastDisplayedElement===Ge.DATA_GRID;E(L),!l&&!t&&L&&setTimeout(()=>{v?.current?.scrollIntoView({block:"end",behavior:"smooth"})})}},[S?.lastDisplayedElement,T,t,l]);const A=f.useCallback(L=>{i?.(L.api)},[i]),M=f.useMemo(()=>({externalLink:r}),[r]),k=f.useMemo(()=>({[Nn]:Uu,[En]:Gu,[xu]:Yr}),[]),R=f.useMemo(()=>o.jsx(Pr.AgGridReact,{onGridReady:A,headerHeight:zt,rowHeight:An,rowData:u,enableCellTextSelection:!0,columnDefs:m,context:M,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",components:k,valueCache:!0}),[u,m,A,M,k]);return l||t?o.jsx(j.Loader,{}):o.jsxs("div",{className:"size-full",children:[o.jsx(Bu,{ref:v,fixHeight:s,gridHeight:g,children:R}),N&&o.jsx(pt,{reference:v,title:w,description:b,supressReferenceClick:!0})]})};function Bt(e){if(typeof window>"u")return e(),()=>{};let t;const n=window.requestAnimationFrame(()=>{t=window.setTimeout(e,0)});return()=>{window.cancelAnimationFrame(n),t!=null&&window.clearTimeout(t)}}const e1=200,t1=8,n1=2,s1=({currentIndex:e,totalCount:t,icons:n,onPrev:s,onNext:r})=>{const{titles:a}=De(),i=f.useRef(null),[c,l]=f.useState(""),[d,u]=f.useState(""),[h,m]=f.useState(!1),{onboardingFileSchema:p,isShowOnboarding:g}=Xe();f.useEffect(()=>{if(g){const{title:C,description:b}=mt(Ge.CHARTS_NAVIGATION,a);l(C),u(b)}},[a,g]),f.useEffect(()=>{if(g){const C=p?.lastDisplayedElement===Ge.CHARTS_NAVIGATION;m(C),C&&i?.current?.scrollIntoView({block:"center",behavior:"smooth"})}},[p?.lastDisplayedElement,g]);const x=t>0?e/t*100:0,v=t>0?Math.min(t1*t,e1):0,w=t>0?Math.max(v/t,n1):0;return o.jsxs("div",{className:"flex w-full flex-row items-center justify-center gap-2",children:[o.jsx("div",{className:$("h-[20px] w-[20px] cursor-pointer",e===0?"text-neutrals-700":"text-primary"),onClick:s,children:n?.[un.PREVIOUS]}),o.jsxs("div",{className:"flex flex-col items-center gap-1 pt-[20px]",children:[o.jsx("div",{className:"relative h-[4px] rounded-full bg-neutral-300",style:{width:`${v}px`},children:o.jsx("div",{className:"absolute h-full rounded-full bg-primary",style:{left:`${x}%`,width:`${w}px`}})}),o.jsxs("h5",{className:"text-neutrals-800",children:[e+1,"/",t]})]}),o.jsx("div",{className:$("h-[20px] w-[20px] cursor-pointer",e+1===t?"text-neutrals-700":"text-primary"),onClick:r,ref:i,children:n?.[un.NEXT]}),h&&o.jsx(pt,{reference:i,title:c,description:d})]})},r1=({limitAmount:e,openAdvancedView:t,prefixIcon:n,contentClassName:s})=>{const{titles:r}=De(),[a,i]=f.useState(!1),{refs:c,floatingStyles:l,context:d}=et.useFloating({open:a,onOpenChange:i,placement:"top-start"}),u=et.useHover(d,{handleClose:et.safePolygon({blockPointerEvents:!0})}),{getReferenceProps:h,getFloatingProps:m}=et.useInteractions([u]);return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex w-fit",ref:c.setReference,...h(),children:o.jsxs("div",{className:st("mt-1 flex w-fit items-center gap-1 bg-hues-100 px-4 py-2",s),children:[n,o.jsx("h5",{className:"font-bold",children:r?.limits||"Limited to"}),o.jsxs("h5",{children:[e," ",r?.timeseriesLimit||"Timeseries"]})]})}),a&&o.jsx("div",{className:"floating",ref:c.setFloating,style:l,...m(),children:o.jsxs("div",{className:"z-10 mb-2 flex w-[300px] flex-col gap-2 rounded bg-white p-4 shadow",children:[o.jsxs("div",{children:[o.jsxs("h5",{className:"text-neutrals-900",children:[o.jsx("span",{className:"pr-0.5",children:r?.limitLinkInfoP1_1||"The number of timeseries displayed in a single chart i"}),o.jsxs("span",{className:"pr-0.5 font-bold",children:[r?.limitLinkInfoP1_2||"limited to"," ",e]}),r?.limitLinkInfoP1_3||"for better clarity and performance."]}),o.jsxs("h5",{className:"text-neutrals-900",children:[o.jsx("span",{className:"pr-0.5",children:r?.limitLinkInfoP2_1||"To visualize specific timeseries"}),o.jsx("span",{className:"pr-0.5 font-bold",children:r?.limitLinkInfoP2_2||"filter"}),o.jsx("span",{className:"pr-0.5",children:r?.limitLinkInfoP2_3||"your request, or"}),o.jsx("span",{className:"pr-0.5 font-bold",children:r?.limitLinkInfoP2_4||"refine"}),r?.limitLinkInfoP2_5||"it in the chat."]})]}),t&&o.jsx("h4",{className:"cursor-pointer text-primary",onClick:t,children:r?.limitLinkInfoLink||"Open Advanced View"})]})})]})};function a1(e,t,n){const s=(e.getZr()?.painter).getRenderedCanvas()?.getContext("2d");if(!s)return 0;const r=n.textStyle?.fontSize??12,a=n.textStyle?.fontFamily??"sans-serif";s.font=`${r}px ${a}`;const i=s.measureText(t).width,c=n.itemWidth??25,l=n.itemGap??10;return i+c+l}const i1=({option:e,style:t})=>{const n=f.useRef(null),[s,r]=f.useState(e);f.useEffect(()=>{r(Rr.cloneDeep(e))},[e]);const a=f.useCallback(()=>{const i=n.current?.getEchartsInstance?.();if(!i)return;const l=i.getDom().clientWidth,d=e.legend||{},u=d.itemHeight??14,h=d.textStyle?.fontSize??12,m=i.getModel()?.getComponent("legend")?.getData()||[];let p=0;m.forEach(w=>{const C=w.option.name||"";p+=a1(i,C,d)});const x=Math.max(1,Math.ceil(p/l))*(+u+ +h+6),v=20;r(w=>({...w,grid:{...w.grid||{},bottom:x+v}}))},[e.legend]);return f.useEffect(()=>{a();const i=()=>{a()};return window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i)}},[e,a]),o.jsx(Dl,{notMerge:!0,lazyUpdate:!1,ref:n,option:s,style:t})},o1=({attachment:e,icons:t,isDataLoading:n,openAdvancedView:s,fixHeight:r=!0,limitationInfoPrefixIcon:a,limitationInfoContentClassName:i})=>{const{titles:c}=De(),[l,d]=f.useState(!0),[u,h]=f.useState(),[m,p]=f.useState([]),[g,x]=f.useState(0),[v,w]=f.useState(void 0),[C,b]=f.useState(),{onboardingFileSchema:y,isShowOnboarding:N,setOnboardingFileSchema:E}=Xe(),T=f.useRef(null),{charting_data:S,getChartingData:_}=e;f.useEffect(()=>{if(x(0),S){h(S),d(!1);return}if(!_){h(void 0),d(!0);return}return d(!0),Bt(()=>{try{h(_())}catch(k){console.error("Error building chart data",k),h({units:[]})}finally{d(!1)}})},[S,_]),f.useEffect(()=>{const k=u?.groups??[],R=u?.units??[];p(k.length>0?k.flatMap(L=>L.units.map(z=>({unit:z,groupTitle:L.title}))):R.map(L=>({unit:L})))},[u]),f.useEffect(()=>{const k=m.length>g,R=k?m[g]:m[0];w(!l&&R!=null?R.unit:void 0),b(R?.groupTitle),k||x(0)},[l,m,g]),f.useEffect(()=>{y&&N&&!l&&(Fm(y)&&(E?.(Om(y)),T?.current?.scrollIntoView({block:"center",behavior:"smooth"})),y.lastDisplayedElement===Ge.CHART_PER_SERIES&&E?.(ou(y)))},[l,E,y,N]);const A=f.useCallback(()=>{x(k=>Math.min(k+1,m.length-1))},[m.length]),M=f.useCallback(()=>{x(k=>Math.max(k-1,0))},[]);return l||n?o.jsx(j.Loader,{}):o.jsx("div",{className:"chart-attachment size-full",ref:T,children:u&&o.jsx("div",{className:"flex size-full flex-col gap-4",children:m.length==0||v==null?o.jsx("h4",{className:"ml-1",children:c?.chartInfo||"No data"}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("h3",{className:"chart-attachment-title",children:[c?.chart||"Chart"," ",g+1,"/",m.length]}),o.jsx("span",{className:"h4 chart-attachment-info text-neutrals-700",children:c?.chartInfo||"Chart Information"})]}),o.jsxs("div",{className:$("chart-area overflow-hidden flex flex-row gap-4 h-full ",r&&"max-h-[400px] min-h-[400px]",!r&&"min-h-[300px]"),children:[o.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[C&&o.jsxs("div",{className:"mb-1 flex items-center gap-1",children:[o.jsx(qr,{className:"size-4 shrink-0 text-neutrals-1000"}),o.jsx("h4",{className:"text-neutrals-1000",children:C})]}),o.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[o.jsx(i1,{option:v.config,style:{width:"100%",height:"100%",minHeight:0}}),v.limitedByRowsAmountTo&&o.jsx(r1,{limitAmount:v.limitedByRowsAmountTo,openAdvancedView:s,prefixIcon:a,contentClassName:i}),m.length>1&&o.jsx(s1,{icons:t,currentIndex:g,totalCount:m.length,onNext:A,onPrev:M})]})]}),o.jsx(bu,{dimensionsInfo:v.dimensions})]})]})})})},l1=({attachment:e,className:t})=>{const{data:n,language:s}=e,r=(a,i)=>{a.addCommand(i.KeyCode.F1,()=>{})};return o.jsx("div",{className:st(["h-full w-full [&_.cursors-layer]:hidden",t]),children:o.jsx(vd.Editor,{value:n,language:s,theme:"vs-light",onMount:r,options:{readOnly:!0,contextmenu:!1,scrollBeyondLastLine:!1,minimap:{enabled:!1},wordWrap:"on",automaticLayout:!0,tabSize:2}})})},c1="Dataset",ol="dataset_name",u1="Agency",ll="agency",d1="Country dimensions",Jt="country_aggregated",f1="Indicator dimensions",Yt="indicator_aggregated",h1="Frequency",kn="frequency_aggregated",zu=".";function cl(e){return{columnState:e.getColumnState(),columnGroupState:e.getColumnGroupState()??[]}}function m1(e,t){t&&(e.applyColumnState({state:t.columnState,applyOrder:!0}),e.setColumnGroupState(t.columnGroupState))}const ul=["columnVisible","columnMoved","displayedColumnsChanged","newColumnsLoaded","gridColumnsChanged","columnPinned"];function qu(e,t){f.useEffect(()=>{if(e){for(const n of ul)e.addEventListener(n,t);return()=>{for(const n of ul)e.removeEventListener(n,t)}}},[e,t])}function p1({currentUrn:e}){const[t,n]=f.useState(),[s,r]=f.useState(null),a=f.useRef(new Map),i=f.useRef(new Map),c=f.useCallback(h=>{if(n(h),a.current.has(e))s==null&&r(a.current.get(e)??null);else{const p=cl(h);a.current.set(e,p),r(p)}const m=i.current.get(e);m&&(h.applyColumnState({state:m.columnState,applyOrder:!0}),m.columnGroupState!=null&&h.setColumnGroupState(m.columnGroupState))},[e]);f.useEffect(()=>{r(a.current.get(e)??null)},[e]);const l=f.useCallback(()=>{t&&i.current.set(e,cl(t))},[e,t]),d=f.useCallback(()=>{i.current.delete(e)},[e]),u=f.useCallback(()=>{a.current.delete(e),r(null)},[e]);return qu(t,l),{gridApi:t,onGridApiReady:c,initialColumnsState:s,clearUserColumnState:d,clearInitialColumnState:u}}var tt=(e=>(e.Compact="compact",e.Extended="extended",e))(tt||{});const ta=f.createContext(null);function g1({currentUrn:e,structuresMap:t,locale:n,dataQueries:s,gridViewMode:r=tt.Compact,onGridViewModeChange:a,texts:i,resetIcon:c,children:l}){const{gridApi:d,onGridApiReady:u,initialColumnsState:h,clearUserColumnState:m,clearInitialColumnState:p}=p1({currentUrn:e}),g=f.useCallback(E=>a?.(E),[a]),[x,v]=f.useState(new Map),w=f.useCallback((E,T,S)=>{v(_=>{const A=new Map(_),M=new Map(A.get(E)??[]),k=M.get(T)??{order:[],hidden:new Set};return M.set(T,S(k)),A.set(E,M),A}),d?.refreshCells({columns:[T]})},[d]),C=f.useCallback((E,T,S)=>{w(E,T,_=>({..._,order:S}))},[w]),b=f.useCallback(()=>{v(new Map)},[]),y=f.useCallback((E,T,S,_)=>{w(E,T,A=>{const M=new Set(A.hidden);return _?M.add(S):M.delete(S),{...A,hidden:M}})},[w]),N=f.useMemo(()=>({gridApi:d,onGridApiReady:u,initialColumnsState:h,structuresMap:t,locale:n,dataQueries:s,dimensionCustomization:x,setDimensionKeyOrder:C,setDimensionKeyHidden:y,resetDimensionCustomization:b,clearUserColumnState:m,clearInitialColumnState:p,gridViewMode:r,setGridViewMode:g,texts:i,resetIcon:c}),[d,h,u,t,n,s,x,C,y,b,m,p,r,g,i,c]);return o.jsx(ta.Provider,{value:N,children:l})}function na(){const e=f.useContext(ta);if(!e)throw new Error("useTableSettingsContext must be used within TableSettingsProvider");return e}const v1=()=>f.useContext(ta);function _n(e,t,n){const s=D.getConcept(e.conceptIdentity,t),r=e?.localRepresentation?.enumeration,a=s?.coreRepresentation?.enumeration,i=r||a,c=D.getArtifactByUrnWithWildCard(i,n);return{concept:s,codeList:c||void 0}}function Wu(e,t,n){const s=e.findIndex(r=>r.id===t);return n.originalData.parsedTimeSeriesValue[s]}function sa(e,t,n,s,r){const a=Wu(e,t,s),i=n?.codes?.find(c=>c.id===a);return D.getLocalizedName(i,r)}function C1(e,t,n,s,r=tt.Compact){const a=r===tt.Extended?S1(e,t,n):[b1(e,t,n,s)];return[w1(e,t,n,s),...a,x1(e,t,n,s),...y1(e,t,n)]}function w1(e,t,n,s){const r=a=>{const{structures:i,urn:c,data:l}=Zt(a,e),d=t.get(c)?.region;return l==null||c==null||i==null||d==null?"":Nt(i,d,l,n)};return In(s?.countryDimensions||d1,Jt,r,e,t,n,s)}function b1(e,t,n,s){const r=a=>{const{structures:i,urn:c,data:l}=Zt(a,e),d=t.get(c)?.indicators;return l==null||c==null||i==null||d==null||d.length===0?"":d.map(h=>Nt(i,h,l,n)||"").join(zu)};return In(s?.indicatorDimensions||f1,Yt,r,e,t,n,s)}function x1(e,t,n,s){const r=a=>{const{structures:i,urn:c,data:l}=Zt(a,e),d=t.get(c)?.frequency;return l==null||c==null||i==null||d==null?"":Nt(i,d,l,n)};return In(s?.frequency||h1,kn,r,e,t,n,s)}function y1(e,t,n){const s=new Set;return t.forEach(r=>{r?.other?.forEach(a=>{s.add(a)})}),Array.from(s).map(r=>D1(r,e,t,n))}function S1(e,t,n){const s=new Set;return t.forEach(r=>{r?.indicators?.forEach(a=>{s.add(a)})}),Array.from(s).map(r=>{const a=i=>{const{structures:c,urn:l,data:d}=Zt(i,e),u=t.get(l)?.indicators??[];return d==null||l==null||c==null||!u.includes(r)?"":Nt(c,r,d,n)};return{headerName:$u(r,e,n),field:r,colId:r,valueGetter:a,...St,cellClass:Ct,tooltipValueGetter:i=>i.value}})}function D1(e,t,n,s){const r=a=>{const{structures:i,urn:c,data:l}=Zt(a,t),d=n.get(c)?.other??[];return l==null||c==null||i==null||!d.includes(e)?"":Nt(i,e,l,s)};return{...In($u(e,t,s),e,r,t,n,s),hide:!0}}function $u(e,t,n){for(const s of t.values()){if(!s)continue;const a=(D.getDimensions(s)?.dimensions||[]).find(i=>i.id===e);if(a)return D.getDimensionTitle(s.conceptSchemes,a,n)??e}return e}function In(e,t,n,s,r,a,i){return{headerName:e,field:t,colId:t,valueGetter:n,...St,cellClass:Ct,cellRenderer:yu,tooltipValueGetter:c=>c.value,cellRendererParams:{structuresMap:s,datasetDimensionsSchemesMap:r,locale:a,titles:i,colId:t}}}function Zt(e,t){const{data:n}=e,s=n?.dataset?.urn,r=s==null?void 0:t.get(s);return{data:n,urn:s,structures:r}}function Nt(e,t,n,s){const r=e.conceptSchemes||[],a=e.codelists||[],i=D.getDimensions(e)?.dimensions||[],c=i.find(d=>d.id===t);if(c==null)return;const{codeList:l}=_n(c,r,a);return sa(i,t,l,n,s)}const gn="::";function T1(e,t){return`${e}${gn}${t}`}function yr(e){return e.includes(gn)}function Pt(e){const t=e.indexOf(gn);return{urn:e.slice(0,t),dimensionKey:e.slice(t+gn.length)}}const M1=new Set([Yt]);function Ku(e,t){let n=e;return t?.order.length&&(n=[...t.order.filter(s=>e.includes(s)),...e.filter(s=>!t.order.includes(s))]),t?.hidden.size&&(n=n.filter(s=>!t.hidden.has(s))),n}function A1(e,t,n){const s=n(t);return s?e===Yt?s.indicators:e===Jt?s.region?[s.region]:[]:e===kn?s.frequency?[s.frequency]:[]:[]:[]}function E1(e,t,n){const s=e.getDimensionConfig(t,n);if(s?.alias)return s.alias;const r=e.structuresMap.get(t),i=(r?D.getDimensions(r)?.dimensions??[]:[]).find(c=>c.id===n);return D.getDimensionTitle(r?.conceptSchemes??[],i,e.locale)??n}function N1(e){const t=e.enrichedColIds??M1;return n=>{if(!t.has(n.id))return n;const s=[];for(const{urn:r}of e.dataQueries){const a=A1(n.id,r,e.getDimensionsScheme);if(!a.length)continue;const i=e.dimensionCustomization?.get(r)?.get(n.id),c=i?.order.length?Ku(a,{order:i.order,hidden:new Set}):a,l=c.length>1,d=c.map(m=>({id:T1(r,m),type:"item",label:E1(e,r,m),isChecked:!i?.hidden.has(m),draggable:l,checkable:l})),u=e.structuresMap.get(r),h=D.getLocalizedName(u?.dataflows?.[0],e.locale)??r;s.push({id:r,type:"group",label:h,items:d})}return s.length?s.length===1?{...n,items:s[0].items}:{...n,items:s}:n}}function dl(e,t){return e===Yt?t.indicators??[]:e===Jt?t.region?[t.region]:[]:e===kn?t.frequency?[t.frequency]:[]:t.other?.includes(e)?[e]:[]}function j1(e,t){return e===Yt?t?.indicatorMetadataPanel||"Indicator dimension details":e===Jt?t?.countryMetadataPanel||"Country dimension details":t?.metadata||"Metadata"}const k1="merged-dimension-metadata-side-panel",_1=e=>{const{titles:t}=De(),{isOpenedAdvancedView:n}=$e(),s=wt(),{isMetadataInSidePanel:r}=We(),a=v1(),i=e?.data?.dataset?.urn,c=jn(e?.context,i),l=i!=null?e.structuresMap.get(i):void 0,d=i!=null?e.datasetDimensionsSchemesMap.get(i):void 0,u=a?.dimensionCustomization,h=f.useMemo(()=>{if(!l||!d||i==null)return e.valueFormatted??e.value;const v=u?.get(i)?.get(e.colId);return Ku(dl(e.colId,d),v).map(b=>Nt(l,b,e.data,e.locale)).filter(Boolean).join(zu)},[u,l,d,i,e.valueFormatted,e.value,e.colId,e.data,e.locale]),m=f.useMemo(()=>{if(!l||!d)return[];const v=dl(e.colId,d),w=D.getStructureComponentsMap(l),C=v.filter(b=>e.data[b]!=null).map(b=>({name:b,value:String(e.data[b])}));return Gt(C,w,e.locale)},[l,d,e.colId,e.data,e.locale]),p=f.useMemo(()=>{const v=l?.dataflows?.[0];if(!v)return;const w=Kt(D.getLastUpdatedTime(v),e.locale);return $t(v,w,e.locale,t)},[l,e.locale,t]),g=r&&!!s&&!!e.value&&![kn,Jt].includes(e.colId),x=f.useCallback(()=>{s&&s.openPanel({id:k1,scope:n?"advanced":"conversation",title:j1(e.colId,t),bodyClassName:"overflow-hidden",content:o.jsx(qt,{locale:e.locale,metadata:m,datasetInfo:p,externalLink:c})})},[s,n,e.colId,t,e.locale,m,p,c]);return o.jsxs("div",{className:"relative size-full p-2",children:[h,g&&o.jsx("div",{className:"metadata-indicator",title:t?.metadata||"View details",onClick:x})]})},I1="dataset-detail-metadata-side-panel",R1=e=>{const{titles:t}=De(),{isOpenedAdvancedView:n}=$e(),s=wt(),{isMetadataInSidePanel:r}=We(),a=e?.data?.dataset?.urn,i=jn(e?.context,a),c=a!=null?e.structuresMap.get(a):void 0,l=a!=null?e.attributesDataMap?.get(a):void 0,d=f.useMemo(()=>{const p=c?.dataflows?.[0];if(!p)return;const g=Kt(D.getLastUpdatedTime(p),e.locale);return $t(p,g,e.locale,t)},[c,e.locale,t]),u=f.useMemo(()=>Iu(_u(l),D.getStructureComponentsMap(c),e.locale),[l,c,e.locale]),h=r&&!!s&&!!e.value,m=f.useCallback(()=>{s&&s.openPanel({id:I1,scope:n?"advanced":"conversation",title:t?.datasetMetadataPanel||"Dataset Metadata",bodyClassName:"overflow-hidden",content:o.jsx(qt,{locale:e.locale,metadata:u,datasetInfo:d,externalLink:i})})},[s,n,u,d,i,t,e.locale]);return o.jsxs("div",{className:"relative size-full p-2",children:[e.valueFormatted??e.value,h&&o.jsx("div",{className:"metadata-indicator",title:t?.metadata||"View details",onClick:m})]})},P1=({attachment:e,isDataLoading:t,isChartColumnVisible:n,fixHeight:s,externalLink:r,externalLinksMap:a,showLimitMessage:i,onApiReady:c})=>{const[l,d]=f.useState(!1),[u,h]=f.useState([]),[m,p]=f.useState(),[g,x]=f.useState(400),v=f.useRef(null),w=f.useRef([]);f.useEffect(()=>{if(e.gridContent==null)d(!0);else{const E=e.gridContent.columns.map(T=>T.colId===Ut?{...T,hide:!n}:T);h(e.gridContent.data),p(E),d(!1)}},[e.gridContent,n]),f.useEffect(()=>{u?(x(Zr(u.length)),i?.(u.length>=j.SERIES_LIMIT)):i?.(!1)},[u,i]),f.useEffect(()=>{if(!m||!v.current)return;const E=m.map(A=>A.colId??A.field??"").filter(Boolean),T=w.current,S=new Set(T),_=E.length!==T.length||E.some(A=>!S.has(A));w.current=E,_&&v.current.resetColumnState()},[m]);const C=f.useCallback(E=>{v.current=E.api,c?.(E.api)},[c]),b=f.useMemo(()=>({externalLink:r,externalLinksMap:a}),[r,a]),y=f.useMemo(()=>({[Nn]:Uu,[En]:Gu,[yu]:_1,[xu]:Yr,[Su]:R1}),[]),N=f.useMemo(()=>o.jsx(Pr.AgGridReact,{headerHeight:zt,rowHeight:An,rowData:u,enableCellTextSelection:!0,columnDefs:m,context:b,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",components:y,valueCache:!0,onGridReady:C}),[u,m,b,y,C]);return l||t?o.jsx(j.Loader,{}):o.jsx("div",{className:"size-full",children:o.jsx(Bu,{fixHeight:s,gridHeight:g,children:N})})},L1=({selectedAttachment:e,actions:t,attachmentsStyles:n,isDataLoading:s,externalLink:r,externalLinksMap:a,isOpenedAdvancedView:i,onOpenAdvancedView:c,showLimitMessage:l,onGridApiReady:d})=>o.jsxs("div",{className:"flex min-h-0 w-full flex-1 justify-center",children:[Um(e)&&o.jsx(xp,{actions:t,downloadTitles:n?.downloadTitle,attachment:e}),Kr(e)&&o.jsx(Hp,{actions:t,attachment:e,showLimitMessage:l}),ft(e)&&o.jsx(Qg,{attachment:e,isDataLoading:s,isChartColumnVisible:i,fixHeight:!i,showLimitMessage:l,onApiReady:d,externalLink:r}),vt(e)&&o.jsx(P1,{attachment:e,isDataLoading:s,isChartColumnVisible:i,fixHeight:!i,showLimitMessage:l,onApiReady:d,externalLink:r,externalLinksMap:a}),ln(e)&&o.jsx(o1,{isDataLoading:s,attachment:e,icons:n?.chartingIcons,openAdvancedView:i?void 0:c,fixHeight:!i,limitationInfoPrefixIcon:n?.limitationInfoIcon,limitationInfoContentClassName:n?.limitationInfoContentClassName}),$r(e)&&o.jsx(Np,{attachment:e,openLinkTitle:n?.openLinkTitle}),fu(e)&&o.jsx(Tp,{attachment:e}),Jr(e)&&o.jsx(l1,{attachment:e,className:n?.codeAttachmentContainerClassName})]}),O1=({isOpen:e,alertDetails:t,attachmentsStyles:n,onClose:s})=>{if(!e)return null;const r=t?.progress&&t.progress.total>0?`${Math.min(100,Math.max(0,t.progress.current/t.progress.total*100))}%`:"0%";return o.jsx(j.Alert,{alertDetails:t,infoIcon:n?.infoDownloadIcon,successIcon:n?.successDownloadIcon,errorIcon:n?.errorDownloadIcon,onClose:s,closeButtonTitle:n?.closeTitle||"Close",children:o.jsxs(o.Fragment,{children:[t?.text&&o.jsx("div",{className:"alert-text whitespace-pre-line break-words",title:t.text,children:t.text}),t?.progress&&o.jsx("div",{className:"alert-progress",children:o.jsx("div",{className:"alert-progress-value",style:{width:r}})}),t?.action&&o.jsxs("button",{type:"button",className:"alert-action",disabled:t.action.disabled,onClick:t.action.onClick,title:t.action.title,children:[t.action.icon&&o.jsx("span",{className:"alert-action-icon",children:t.action.icon}),o.jsx("span",{className:"alert-action-text",children:t.action.text})]})]})})},F1=({attachmentsStyles:e,onCancel:t,onRetry:n})=>{const s=f.useCallback(p=>e?.downloadTitles?.downloadStartedText?.(p.dataFormatTitle)??`Preparing ${p.dataFormatTitle} file.`,[e?.downloadTitles]),r=f.useCallback((p,g)=>e?.downloadTitles?.downloadInProgressTitle?.(p,g)??`Downloading file ${p} of ${g}`,[e?.downloadTitles]),a=f.useCallback((p,g)=>e?.downloadTitles?.downloadInProgressText?.(p,g)??`${p} · ${g}`,[e?.downloadTitles]),i=f.useCallback(p=>p.items.length>1?e?.downloadTitles?.downloadSuccessMultipleTitle?.(p.items.length)??`${p.items.length} files downloaded`:e?.downloadTitles?.downloadSuccessTitle?.(p.dataFormatTitle)??`${p.dataFormatTitle} file downloaded`,[e?.downloadTitles]),c=f.useCallback(p=>{if(p.items.length>1)return e?.downloadTitles?.downloadSuccessMultipleText?.(p.items.length)??`${p.items.length} files successfully downloaded`;const[g]=p.items;return e?.downloadTitles?.downloadSuccessText?.(g.fileName,g.rowCount)??`${g.fileName} · ${g.rowCount} rows`},[e?.downloadTitles]),l=f.useCallback(p=>{if(p.items.length>1)return e?.downloadTitles?.downloadFailedMultipleText?.(p.items.length)??`${p.items.length} datasets could not be exported`;const[g]=p.items;return e?.downloadTitles?.downloadFailedText?.(g.name)??`${g.name} could not be exported`},[e?.downloadTitles]),d=f.useCallback(p=>({type:j.AlertType.INFO,title:e?.downloadTitles?.downloadStartedTitle??"Download started",text:s(p),action:{text:e?.downloadTitles?.downloadCancelActionText??e?.downloadTitles?.cancel??"Cancel",icon:e?.downloadInProgressActionIcon,onClick:t}}),[e?.downloadInProgressActionIcon,e?.downloadTitles,s,t]),u=f.useCallback((p,g,x,v)=>({type:j.AlertType.IN_PROGRESS,title:r(g,p.items.length),text:a(v,p.dataFormatTitle),progress:{current:x,total:p.items.length},action:{text:e?.downloadTitles?.downloadCancelActionText??e?.downloadTitles?.cancel??"Cancel",icon:e?.downloadInProgressActionIcon,onClick:t}}),[e?.downloadInProgressActionIcon,e?.downloadTitles,a,r,t]),h=f.useCallback(p=>({type:j.AlertType.SUCCESS,title:i(p),text:c(p)}),[c,i]),m=f.useCallback(p=>({type:j.AlertType.ERROR,title:e?.downloadTitles?.downloadFailedTitle??"Download failed",text:l(p),action:{text:e?.downloadTitles?.downloadRetryActionText??"Retry download",icon:e?.downloadErrorActionIcon,onClick:n}}),[e?.downloadErrorActionIcon,e?.downloadTitles,l,n]);return{getStartedAlertDetails:d,getInProgressAlertDetails:u,getSuccessAlertDetails:h,getErrorAlertDetails:m}},V1=300,H1=({attachmentsStyles:e,downloadDataSet:t})=>{const[n,s]=f.useState(),[r,a]=f.useState(!1),[i,c]=f.useState(),l=f.useRef(null),d=f.useRef(null),u=f.useRef(null),h=f.useRef(!1),m=f.useRef(!1),p=f.useCallback(S=>{c(S),s(!0)},[]),g=f.useCallback(()=>{s(!1)},[]),x=f.useCallback(()=>{m.current=!0,l.current?.abort(),g()},[g]),v=f.useCallback(()=>{const S=d.current;!S||!u.current||u.current(S)},[]),w=f.useCallback(S=>(S instanceof DOMException||S instanceof Error)&&S.name==="AbortError",[]),{getStartedAlertDetails:C,getInProgressAlertDetails:b,getSuccessAlertDetails:y,getErrorAlertDetails:N}=F1({attachmentsStyles:e,onCancel:x,onRetry:v}),E=f.useCallback(async S=>{if(!h.current){h.current=!0,a(!0),m.current=!1,d.current=null;try{const _=[],A=S.items.length>1;A||p(C(S));for(const[M,k]of S.items.entries()){if(m.current)return;A&&p(b(S,M+1,M,k.name));const R=new AbortController;l.current=R;try{await t(k.urn,S.dataFormat,S.language,S.attribute,k.filters,k.fileName,S.isMetadata,R.signal)}catch(L){if(w(L)&&m.current)return;_.push(k),console.error("Failed to download dataset",L)}finally{l.current===R&&(l.current=null)}M<S.items.length-1&&await new Promise(L=>window.setTimeout(L,V1))}if(m.current)return;if(_.length>0){const M={...S,items:_};d.current=M,p(N(M));return}p(y(S))}finally{l.current=null,h.current=!1,a(!1)}}},[t,N,b,C,y,w,p]);return f.useEffect(()=>{u.current=E},[E]),f.useEffect(()=>()=>{m.current=!0,l.current?.abort()},[]),{startDownload:f.useCallback(S=>h.current?!1:(E(S),!0),[E]),isDownloadRunning:r,downloadAlertProps:{isOpen:n,alertDetails:i,attachmentsStyles:e,onClose:g}}};Wa.ModuleRegistry.registerModules([Wa.AllCommunityModule]);const Ju=({attachments:e,actions:t,isSystemAttachments:n,isShowAttachments:s,showAdvancedView:r,currentDataQuery:a,dataQueries:i,attachmentInfoList:c,datasets:l,initialSelectedDatasetUrn:d,isDataLoading:u,isDataSetAttachments:h,locale:m,dimensions:p,filters:g,selectDataset:x,onAdvancedViewOpen:v,isTableSettingsOpen:w,onTableSettingsOpen:C,onTableSettingsClose:b,onGridApiReady:y})=>{const{titles:N,messageStyles:E,attachmentsStyles:T,limitMessages:S,attachmentsConfig:_}=De(),{isCrossDatasetModeOn:A}=We(),[M,k]=f.useState(0),{isOpenedAdvancedView:R,setIsOpenedAdvancedView:L}=$e(),[z,U]=f.useState(j.PopUpState.Closed),[Z,O]=f.useState(!1),[K,J]=f.useState(!1),X=D.DownloadType.DATA_IN_TABLE,Q=f.useMemo(()=>{if(!A||!i?.some(ae=>ae.disabled))return l;const re=new Set(i.filter(ae=>!ae.disabled).map(ae=>ae.urn));return l?.filter(ae=>{const ue=D.generateShortUrn(ae?.id,ae?.version,ae?.agencyID);return re.has(ue)})},[l,i,A]),pe=re=>{k(re)},we=f.useCallback(()=>{v?.(),L(!0),t.updateCurrentDataQuery(a||i?.[0]),t.updateDataQueries(i),t.updateDatasets(l)},[t,a,i,l,L,v]),se=e[M]||null;f.useEffect(()=>{O(h&&(l==null||l?.length==0))},[l,h]),f.useEffect(()=>{w&&se&&!ft(se)&&!vt(se)&&b?.()},[w,se,b]);const V=f.useCallback(()=>{U(j.PopUpState.Closed)},[U]),W=_?.isExternaLinkIncludeFilters,ce=kr(W,g,a||i?.[0],p),fe=f.useMemo(()=>i?.length?new Map(i.map(ae=>[ae.urn,kr(W,void 0,ae)])):void 0,[i,W]),de=f.useMemo(()=>{if(!se||!vt(se))return;const ae=se.gridContent?.data??[],ue=new Map,he=new Map;for(const je of ae){const{dataset:Se,datasetTitle:ge}=je,be=Se?.urn;be&&(ue.set(be,(ue.get(be)??0)+1),!he.has(be)&&ge&&he.set(be,ge))}return Array.from(ue.entries()).map(([je,Se])=>({urn:je,name:he.get(je)??je,rowCount:Se,dataQuery:i?.find(ge=>ge.urn===je)}))},[se,i]),Ne=f.useMemo(()=>{if(se){if(ft(se))return se.grid_data?.data?.length;if(vt(se))return se.gridContent?.data?.length}},[se]),{startDownload:Te,isDownloadRunning:F,downloadAlertProps:G}=H1({attachmentsStyles:T,downloadDataSet:t.downloadDataSet});if(!e||e.length===0)return null;const oe=!R&&Z||!!u;return o.jsx(o.Fragment,{children:R&&!s?o.jsx(ep,{icon:E?.advanceViewIcon,title:E?.openAdvanceViewTitle??"Opened in Advanced view"}):o.jsx("div",{className:$("space-y-3 max-w-full max-h-full h-full",!R&&!n?"pt-5":"pt-0","flex flex-col pb-1"),children:oe?o.jsx(j.Loader,{}):o.jsxs(o.Fragment,{children:[n&&!R&&o.jsx(Qm,{titles:{queryUpdatedManuallyTitle:N?.queryUpdatedManually,setToTitle:N?.setTo,datasetLabel:N?.dataset},datasetIcon:T?.datasetIcon,attachmentInfoList:c,dataQueries:i}),!R&&Q?.length!=null&&Q?.length>0&&o.jsx(vu,{datasets:Q,initialSelectedDatasetUrn:d,locale:m,selectDataset:x}),K&&o.jsx(j.RequestLimitMessage,{limitMessages:S,showAdvancedViewButton:!!se&&Bm(se)&&r,onAdvancedViewClick:we,query:ce}),o.jsx("div",{className:$(!R&&l?.length&&"attachments-bordered","attachments-wrapper h-full min-h-0"),children:o.jsxs("div",{className:"flex h-full max-w-full flex-col items-center gap-4",children:[o.jsx(bp,{attachments:e,selectedAttachmentIndex:M,selectedAttachment:se,attachmentsStyles:T,externalLink:ce,isExternalLinkIncludeFilters:W,limitMessages:S,onSelectedAttachmentChange:pe,onDownloadClick:()=>U(j.PopUpState.Opened),showAdvancedView:r,onOpenAdvancedView:we,isTableSettingsOpen:w,onTableSettingsOpen:C}),se!=null&&o.jsx(L1,{selectedAttachment:se,actions:t,attachmentsStyles:T,isDataLoading:u,isOpenedAdvancedView:R,onOpenAdvancedView:we,showLimitMessage:J,onGridApiReady:y,externalLink:ce,externalLinksMap:fe})]})}),o.jsxs(o.Fragment,{children:[z===j.PopUpState.Opened&&o.jsx(op,{onCloseModal:V,onDownloadStart:Te,isDownloadInProgress:F,dataQuery:a,datasetName:se?.title||"",locale:m,type:X,dimensions:p,filters:g,urn:a?.urn,titles:T?.downloadTitles,rowCount:Ne,collapsible:T?.downloadCollapsible,downloadDatasets:de,limitMessages:S,showLimitMessage:K,externalLink:ce}),o.jsx(O1,{...G})]})]})})})},U1=({label:e,colDef:t})=>!!e.trim()&&!t.suppressColumnsToolPanel;function G1(e){return e.colId??e.field??null}function B1(e){return String(e.headerName??e.field??e.colId??"").trim()}function z1(e){return new Map(e.getColumnState().map(t=>[t.colId,t]))}function q1(e,t){const n=e.getColumnDefs()??[],s=z1(e),r=[];for(const c of n){const l=G1(c);if(!l)continue;const d=B1(c);if(!t({colId:l,label:d,colDef:c}))continue;const u=s.get(l);r.push({id:l,type:"item",label:d,isChecked:!(u?.hide??!1),draggable:!0,checkable:!0})}const a=e.getColumnState().map(c=>c.colId),i=new Map(a.map((c,l)=>[c,l]));return r.sort((c,l)=>{const d=i.get(c.id)??Number.MAX_SAFE_INTEGER,u=i.get(l.id)??Number.MAX_SAFE_INTEGER;return d-u})}function W1(e,t,n){const s=[...t];return e.map(r=>n.has(r)?s.shift()??r:r)}function Sr(e,t){let n=e,s;for(const r of t){if(s=n.find(a=>a.id===r),!s)return;n=s.type==="group"?s.items:s.items??[]}return s?.type==="item"?s:void 0}function $1(e){if(!e.items?.length)return e;if(e.items.every(n=>n.type==="item")){const n=e.items,s=n.filter(a=>a.isChecked!==!1);if(s.length!==1)return e;const[r]=s;return{...e,items:n.map(a=>a===r?{...a,checkable:!1,draggable:!1}:{...a,draggable:!1})}}const t=e.items.map(n=>{if(n.type!=="group")return n;const r=n.items.filter(i=>i.type==="item").filter(i=>i.isChecked!==!1);if(r.length!==1)return n;const[a]=r;return{...n,items:n.items.map(i=>i.type!=="item"?i:i===a?{...i,checkable:!1,draggable:!1}:{...i,draggable:!1})}});return t.every((n,s)=>n===e.items[s])?e:{...e,items:t}}function Ir(e,t){const n=[];for(const s of e){if(s.type==="group"){n.push(...Ir(s.items,t));continue}if(t?.(s)){n.push(s.id);continue}if(s.items?.length){n.push(...Ir(s.items,t));continue}n.push(s.id)}return n}function K1({api:e,searchQuery:t,includeColumn:n=U1,enrichItem:s,onSubItemOrderChange:r,onSubItemVisibilityChange:a}){const[i,c]=f.useState(0),[l,d]=f.useState(new Set),u=f.useCallback(()=>{c(b=>b+1)},[]);qu(e,u);const h=f.useMemo(()=>!e||!e.getColumnState()?[]:q1(e,n),[e,n,i]),m=f.useMemo(()=>(s?h.map(y=>y.type==="item"?s(y):y):h).map(y=>y.type==="item"&&y.items?.length?{...y,isExpanded:l.has(y.id)}:y),[h,s,l]),p=f.useMemo(()=>new Set(h.map(b=>b.id)),[h]),g=f.useMemo(()=>j.filterDraggableListNodes(m,t),[m,t]),x=f.useCallback(b=>{if(!e)return;if(yr(b.itemId)&&a){const{urn:N,dimensionKey:E}=Pt(b.itemId),T=b.path[0];a(N,T,E,!b.nextChecked);return}const y=Sr(m,b.path);!y||!p.has(y.id)||(e.applyColumnState({state:[{colId:y.id,hide:!b.nextChecked}]}),u())},[e,m,p,u,a]),v=f.useCallback(b=>{if(!e)return;if(yr(b.itemId)&&a){const{urn:T,dimensionKey:S}=Pt(b.itemId),_=b.path[0],A=Sr(m,b.path);A?.type==="item"&&a(T,_,S,A.isChecked??!0);return}const y=Sr(m,b.path);if(!y||!p.has(y.id))return;const E=!(e.getColumnState().find(T=>T.colId===y.id)?.hide??!1);e.applyColumnState({state:[{colId:y.id,hide:E}]}),u()},[e,m,p,u,a]),w=f.useCallback(b=>{const y=b.path[b.path.length-1];d(N=>{const E=new Set(N);return b.nextExpanded?E.add(y):E.delete(y),E})},[]),C=f.useCallback(b=>{if(!e)return;const y=e.getColumnState().map(S=>S.colId),N=new Set(h.map(S=>S.id)),E=Ir(b,S=>p.has(S.id)),T=W1(y,E,N);if(e.applyColumnState({state:T.map(S=>({colId:S})),applyOrder:!0}),u(),r){for(const S of b)if(!(S.type!=="item"||!p.has(S.id)||!S.items))if(S.items.some(_=>_.type==="group"))for(const _ of S.items){if(_.type!=="group")continue;const A=_.items.filter(R=>R.type==="item");if(A.length<=1)continue;const M=_.id,k=A.map(R=>Pt(R.id).dimensionKey);r(M,S.id,k)}else{const _=S.items.filter(k=>k.type==="item");if(_.length<=1||!yr(_[0].id))continue;const{urn:A}=Pt(_[0].id),M=_.map(k=>Pt(k.id).dimensionKey);r(A,S.id,M)}}},[e,h,p,u,r]);return{items:m,visibleItems:g,handleToggleChecked:x,handleToggleExpanded:w,handleItemClick:v,handleItemsChange:C}}function J1({api:e,includeColumn:t,enrichItem:n,renderLabel:s,onSubItemOrderChange:r,onSubItemVisibilityChange:a,searchPlaceholder:i}){const[c,l]=f.useState(""),d=f.useCallback(C=>{l(C)},[l]),u=f.useCallback(()=>l(""),[l]),h=f.useMemo(()=>o.jsx("button",{type:"button",onClick:u,children:o.jsx(qe.IconX,{className:"size-4 text-neutrals-1000"})}),[u]),m=f.useCallback(C=>{const b=n?n(C):C;return $1(b)},[n]),{visibleItems:p,handleItemsChange:g,handleToggleChecked:x,handleToggleExpanded:v,handleItemClick:w}=K1({api:e,includeColumn:t,searchQuery:c,enrichItem:m,onSubItemOrderChange:r,onSubItemVisibilityChange:a});return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 px-5",children:[o.jsx(j.InputWithIcon,{inputId:"columns-search-input",containerClasses:"items-center filters-search-input gap-1 !p-2",cssClass:"filters-search-input-text",placeholder:i||"Search",iconBeforeInput:o.jsx(qe.IconSearch,{className:"size-4 text-neutrals-1000"}),iconAfterInput:c?h:void 0,value:c,onChange:d}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:o.jsx(j.DraggableList,{items:p,onItemsChange:g,onToggleChecked:x,onToggleExpanded:v,onItemClick:w,renderLabel:s})})]})}const Y1={},Z1={map:Y1,getDimensionsMetadata:()=>{},getDimensionMetadata:()=>{},getRegionDimension:()=>{},getFrequencyDimension:()=>{},getIndicatorDimensions:()=>[],getDimensionsScheme:()=>{}},ra=f.createContext(Z1);function X1({map:e,children:t}){const n=f.useMemo(()=>{const s={},r={},a={},i=Object.keys(e);for(const c of i){s[c]={},r[c]={};const l=Object.keys(e[c]);for(const d of l){const u=e[c][d];u.subtype&&(s[c][u.subtype]=d),r[c][u.dimensionType]||(r[c][u.dimensionType]=[]),r[c][u.dimensionType].push(d)}a[c]={timePeriod:r[c]?.TIME_PERIOD?.[0]??void 0,frequency:s[c]?.FREQUENCY??void 0,region:s[c]?.REGION??void 0,indicators:r[c]?.INDICATOR??[],other:(r[c]?.NON_INDICATOR??[]).filter(d=>{const u=e[c][d];return u.subtype!=="FREQUENCY"&&u.subtype!=="REGION"})}}return{map:e,getDimensionsMetadata:c=>e[c],getDimensionMetadata:(c,l)=>e[c]?.[l],getRegionDimension:c=>s[c]?.REGION,getFrequencyDimension:c=>s[c]?.FREQUENCY,getIndicatorDimensions:c=>r[c]?.INDICATOR??[],getDimensionsScheme:c=>a[c]}},[e]);return o.jsx(ra.Provider,{value:n,children:t})}function Rn(){return f.useContext(ra)}function Pn(){return f.useContext(ra)}function Q1(){const{dataQueries:e,structuresMap:t,locale:n,gridViewMode:s}=na(),r=Pn(),a=f.useMemo(()=>{const i=new Map;if(!r||!e?.length)return i;for(const{urn:c}of e){const l=r.getDimensionsScheme(c),d=!!l?.other.length,u=s===tt.Extended&&!!l?.indicators?.length;if(!d&&!u)continue;const h=n?D.getLocalizedName(t?.get(c)?.dataflows?.[0],n)??c:c,m=[...l?.other??[],...u?l?.indicators??[]:[]];for(const p of m){const g=i.get(p);g?g.push(h):i.set(p,[h])}}return i},[r,e,t,n,s]);return f.useMemo(()=>{if(!a.size)return;function i(c){const l=a.get(c.id);return l?.length?o.jsxs("span",{className:"flex w-full items-center gap-2 overflow-hidden",children:[o.jsx("span",{className:"min-w-0 flex-1 truncate",title:c.label,children:c.label}),o.jsx("span",{className:"h5 min-w-0 flex-1 truncate text-right text-neutrals-700",title:l.join(", "),children:l.join(", ")})]}):c.label}return i},[a])}var Ie=(e=>(e.Header="header",e.Cell="cell",e))(Ie||{}),Ae=(e=>(e.Focus="focus",e.Default="default",e))(Ae||{});const ev="grid gap-1",tv={gridTemplateColumns:"44px 23px 23px",gridTemplateRows:"repeat(4, 14px)"},nv={gridTemplateColumns:"repeat(4, 21.5px)",gridTemplateRows:"repeat(4, 14px)"},sv={[Ie.Header]:{[Ae.Focus]:"content-center rounded-sm border border-accent-300 bg-accent-300 text-center text-[8px] font-semibold",[Ae.Default]:"rounded-sm bg-semantic-warning border border-accent-300"},[Ie.Cell]:{[Ae.Focus]:"content-center rounded-sm border border-accent-300 bg-hues-100 pl-1 text-left text-[8px] font-semibold",[Ae.Default]:"rounded-sm bg-neutrals-100 border border-accent-300"}},Yu=({rows:e,style:t})=>o.jsx("div",{className:ev,style:t,children:e.map((n,s)=>o.jsx(f.Fragment,{children:n.map((r,a)=>o.jsx("span",{className:st([sv[r.role][r.emphasis],!r.label&&"text-transparent"]),children:r.label||" "},`${s}-${a}`))},s))}),rv=[[{role:Ie.Header,emphasis:Ae.Focus,label:"D1.D2.D3"},{role:Ie.Header,emphasis:Ae.Default},{role:Ie.Header,emphasis:Ae.Default}],[{role:Ie.Cell,emphasis:Ae.Focus,label:"C1.A"},{role:Ie.Cell,emphasis:Ae.Default},{role:Ie.Cell,emphasis:Ae.Default}],[{role:Ie.Cell,emphasis:Ae.Focus,label:"C1.B"},{role:Ie.Cell,emphasis:Ae.Default},{role:Ie.Cell,emphasis:Ae.Default}],[{role:Ie.Cell,emphasis:Ae.Focus,label:"C2.X"},{role:Ie.Cell,emphasis:Ae.Default},{role:Ie.Cell,emphasis:Ae.Default}]],av=()=>o.jsx(Yu,{rows:rv,style:tv}),iv=[[{role:Ie.Header,emphasis:Ae.Focus,label:"D1"},{role:Ie.Header,emphasis:Ae.Focus,label:"D2"},{role:Ie.Header,emphasis:Ae.Focus,label:"D3"},{role:Ie.Header,emphasis:Ae.Default}],[{role:Ie.Cell,emphasis:Ae.Focus,label:"C1"},{role:Ie.Cell,emphasis:Ae.Focus,label:"A"},{role:Ie.Cell,emphasis:Ae.Focus},{role:Ie.Cell,emphasis:Ae.Default}],[{role:Ie.Cell,emphasis:Ae.Focus,label:"C1"},{role:Ie.Cell,emphasis:Ae.Focus,label:"B"},{role:Ie.Cell,emphasis:Ae.Focus},{role:Ie.Cell,emphasis:Ae.Default}],[{role:Ie.Cell,emphasis:Ae.Focus,label:"C2"},{role:Ie.Cell,emphasis:Ae.Focus},{role:Ie.Cell,emphasis:Ae.Focus,label:"X"},{role:Ie.Cell,emphasis:Ae.Default}]],ov=()=>o.jsx(Yu,{rows:iv,style:nv}),fl=({title:e,description:t,visual:n,mode:s,activeMode:r,onClick:a})=>o.jsxs("button",{type:"button",className:st(["flex items-center gap-3 rounded border p-1",s===r&&"border-primary"]),onClick:()=>a(s),children:[o.jsx("div",{className:"rounded-[5px] bg-neutrals-100 px-2 py-1",children:n}),o.jsxs("div",{className:"flex flex-col gap-1 text-left",children:[o.jsx("span",{className:"h4 text-neutrals-1000",children:e}),o.jsx("span",{className:"caption text-neutrals-800",children:t})]})]}),lv=({gridViewMode:e,onModeChange:t,compactViewTitle:n,compactViewDescription:s,extendedViewTitle:r,extendedViewDescription:a})=>o.jsxs("div",{className:"mx-5 my-3 flex flex-col gap-2",children:[o.jsx(fl,{title:n||"Compact view",description:s??o.jsxs(o.Fragment,{children:["Related dimensions ",o.jsx("strong",{children:"combined into a single column."})]}),visual:o.jsx(av,{}),mode:tt.Compact,activeMode:e,onClick:t}),o.jsx(fl,{title:r||"Extended view",description:a??o.jsxs(o.Fragment,{children:["Each dimension displayed in ",o.jsx("strong",{children:"separate column."})]}),visual:o.jsx(ov,{}),mode:tt.Extended,activeMode:e,onClick:t})]}),hl="table-settings-side-panel",cv=()=>{const{gridApi:e,initialColumnsState:t,structuresMap:n,locale:s,dataQueries:r,dimensionCustomization:a,setDimensionKeyOrder:i,setDimensionKeyHidden:c,resetDimensionCustomization:l,clearUserColumnState:d,clearInitialColumnState:u,gridViewMode:h,setGridViewMode:m,texts:p,resetIcon:g}=na(),x=Pn(),v=Q1(),w=f.useCallback(y=>{d(),u(),l(),m(y)},[d,u,l,m]),C=f.useCallback(()=>{e&&(d(),t?m1(e,t):e.resetColumnState(),l())},[d,e,t,l]),b=f.useMemo(()=>{if(!(h!==tt.Compact||!x||!n||!s||!r?.length))return N1({dataQueries:r,structuresMap:n,getDimensionsScheme:x.getDimensionsScheme,getDimensionConfig:(y,N)=>x.map[y]?.[N],locale:s,dimensionCustomization:a})},[h,x,n,s,r,a]);return e?o.jsxs("div",{className:"flex h-full flex-col",children:[o.jsx(lv,{gridViewMode:h,onModeChange:w,compactViewTitle:p?.compactViewTitle,compactViewDescription:p?.compactViewDescription,extendedViewTitle:p?.extendedViewTitle,extendedViewDescription:p?.extendedViewDescription}),o.jsx("hr",{className:"border-neutrals-500"}),o.jsxs("div",{className:"mx-5 mb-4 mt-5 flex items-center justify-between",children:[o.jsx("h3",{className:"text-neutrals-1000",children:p?.columnsDisplayTitle||"Columns display"}),o.jsx("button",{type:"button",className:"text-neutrals-800",onClick:C,children:g??o.jsx(qe.IconRotate,{className:"size-4 rotate-180"})})]}),o.jsx(J1,{api:e,enrichItem:b,renderLabel:v,onSubItemOrderChange:i,onSubItemVisibilityChange:c,searchPlaceholder:p?.columnsSearchPlaceholder})]}):null},uv=e=>{const{attachmentsStyles:t}=De(),{onGridApiReady:n}=na(),s=wt(),r=f.useCallback(()=>{s&&s.openPanel({id:hl,scope:"advanced",title:t?.tableSettings||"Table settings",headerClassName:"border-b border-neutrals-500",content:o.jsx(cv,{})})},[s,t?.tableSettings]);return o.jsx(Ju,{...e,isTableSettingsOpen:s?.isPanelOpen(hl)??!1,onTableSettingsOpen:s?r:void 0,onTableSettingsClose:s?.closePanel,onGridApiReady:n})},dv=({actions:e,structureDataMaps:t,buttonProps:n,modalProps:s,dataQueries:r,onMultipleDataFiltersChange:a,locale:i,timeRangeOptions:c,datasetIcon:l,conversationKey:d,conversation:u,setConversation:h,updateConversation:m,updateDataQueries:p,limitMessages:g,filterIconClassName:x})=>{const{titles:v}=De(),w=Pn(),{modalState:C,setModalState:b,isModalClosed:y,setIsModalClosed:N}=uu(),[E,T]=f.useState([]),[S,_]=f.useState([]),[A,M]=f.useState(),[k,R]=f.useState([]),[L,z]=f.useState(void 0),U=f.useRef(t?.constraintsMap),[Z,O]=f.useState(),[K,J]=f.useState(),[X,Q]=f.useState(),[pe,we]=f.useState(!1),se=f.useRef(0),[V,W]=f.useState(new Set),[ce,fe]=f.useState(new Set),de=f.useRef(u);f.useEffect(()=>{de.current=u},[u]);const Ne=f.useCallback(()=>{se.current+=1,se.current===1&&we(!0)},[]),Te=f.useCallback(()=>{se.current=Math.max(se.current-1,0),se.current===0&&we(!1)},[]),F=f.useMemo(()=>cm(r,t),[r,t]),G=f.useCallback(I=>Im(I,t?.dimensionsMap,t?.structuresMap),[t?.dimensionsMap,t?.structuresMap]),oe=f.useCallback(I=>G(I).codelistUrn,[G]),re=f.useCallback(I=>{const P=I.filterType==="dataset"?I.datasetUrn:I.sourceDatasetUrns?.[0];return P?U.current?.get(P):void 0},[]),ae=f.useCallback(I=>G(I).sourceArtefactUrn,[G]),{hierarchyStateMap:ue,rebuildHierarchyTree:he,loadAvailableHierarchies:je,onSelectHierarchy:Se,onExpandHierarchyNode:ge}=pu({getCodelistUrnForFilter:oe,getConstraintsForFilter:re,getSourceArtefactUrn:ae,getAvailableHierarchies:e?.getAvailableHierarchies,getHierarchy:e?.getHierarchy}),be=I=>{const P=I?E.map(q=>Fe(q,I)?I:q):E;Q(!0),T(mn(P)),J?.(!0),Me(I?.isTimeDimension?hn(P,I):P,T,J,I)};f.useEffect(()=>{C===j.PopUpState.Closed&&O(U.current)},[C]);const Me=f.useCallback((I,P,q,te)=>{const Re=xt(I,U.current,!1,w.map),Ce=zo(r,Re,e,w.map,I);Ce&&Ne();const xe=Bo(r,Re,e,w.map,I);Promise.allSettled(xe).then(Ze=>{const Je=Wo(U.current||t?.constraintsMap,qo(Ze)),at={...t,constraintsMap:Je};if(te){const{filtersMap:bt,changed:lt}=Ym(Re,at,te,i,w.map);if(lt){U.current=Je,q?.(!0),Q(!0);const Xt=kt(bt,at,i,w.map);Me(Xt,P,q,te);return}}const it=kt(Re,at,i,w.map);if(U.current=Je,q?.(!1),P(it),te){const bt=it.find(lt=>Fe(lt,te));M(lt=>lt&&bt&&Fe(lt,te)?{...bt,isSelectedFilter:!0}:lt),he(te,re(te))}}).catch(()=>{const Ze=U.current||t?.constraintsMap||new Map,Je=kt(Re,{...t,constraintsMap:Ze},i,w.map);if(U.current=Ze,q?.(!1),P(Je),te){const at=Je.find(it=>Fe(it,te));M(it=>it&&at&&Fe(it,te)?{...at,isSelectedFilter:!0}:it)}}).finally(()=>{Q(!1),Ce&&Te()})},[e,r,w.map,Te,re,i,he,Ne,t]);f.useEffect(()=>{if(!F){J(!0);return}const I=Oc(t,i),P=r?.map(te=>{if(!te.disabled)return te;const Re=(I.get(te.urn)??[]).filter(Ce=>Ce.filterType==="dataset"&&Ce.id&&!Ce.isTimeDimension).map(Ce=>({componentCode:Ce.id,operator:ne.QueryFilterType.IN,values:[]}));return{...te,filters:Re}}),q=Fc(I,P,t?.constraintsMap,w.map);J?.(!0),Me(q,_,J)},[r,w.map,Me,F,i,t]),f.useEffect(()=>{S?.length&&R(Tn(S))},[S]),f.useEffect(()=>{T(I=>hn(I,A))},[A]),f.useEffect(()=>{if(C===j.PopUpState.Opened){z(void 0);const I=S.find(q=>!q.isTimeDimension);M(I?{...I,isSelectedFilter:!0}:void 0),T(S);const P=new Set(r?.filter(q=>q.disabled).map(q=>q.urn));W(P),fe(P)}C===j.PopUpState.Closed&&M(void 0)},[S,r,C]),f.useEffect(()=>{if(!A||A.isTimeDimension)return;const I=Ke(A);if(!I)return;ue.get(I)||je(A)},[A,ue,je]),f.useEffect(()=>{C===j.PopUpState.Opened&&S.forEach(I=>{if(I.isTimeDimension)return;const P=Ke(I);P&&!ue.has(P)&&je(I)})},[C,S,ue,je]);const Le=f.useCallback(async I=>{const P=de.current,q=r?.map(xe=>({...xe,disabled:V.has(xe.urn)})),te=q?.filter(xe=>!xe.disabled),Re=Wc(te,I),Ce=P?{...P,messages:mu(P.messages,q,Re)}:null;h?.(Ce),p?.(q?.map(xe=>({...xe,filters:xe.disabled?xe.filters??[]:Re.get(xe.urn)??[]}))??[]),await m(decodeURI(d),{name:Ce?.name,messages:Ce?.messages||[]})},[d,r,V,h,m,p]),Be=f.useCallback((I,P)=>{T(q=>uc(q,I,P)),Fe(A,I)&&M(q=>q&&{...q,displayMode:P})},[A]),ze=f.useCallback(I=>qc(I,r,t?.dimensionsMap),[r,t?.dimensionsMap]),ke=f.useMemo(()=>{const I=xt(S,U.current,!1,w.map),P=xt(E,U.current,!1,w.map),q=Mr(ze(I),ze(P)),te=Mr([...ce].sort(),[...V].sort());return q&&te},[S,E,ce,V,ze,w.map]),Oe=f.useCallback((I,P)=>{const q=kt(I,P,i,w.map);U.current=P?.constraintsMap,M(te=>q?.find(Re=>Fe(Re,te))||te),T(q),Q(!1)},[w.map,i]),Ve=f.useCallback((I,P)=>{Q(!0),T(mn(I));const q=xt(I,U.current,!1,w.map),te=U.current||t?.constraintsMap||new Map,Re=zo(P,q,e,w.map,I);Re&&Ne();const Ce=Bo(P,q,e,w.map,I);Promise.allSettled(Ce).then(xe=>{const Ze=Wo(te,qo(xe));Oe(q,{...t,constraintsMap:Ze})}).catch(()=>{Oe(q,{...t,constraintsMap:te})}).finally(()=>{Re&&Te()})},[e,w.map,Te,Ne,t,Oe]),Qe=f.useCallback(I=>{const P=r?.find(te=>te?.urn===I?.datasetUrn),q=hc(E,I);Ve(q,I?.datasetUrn?P?[P]:[]:r)},[Ve,E,r]),Y=f.useCallback(()=>{W(new Set)},[]),me=f.useCallback((I,P)=>{W(q=>{const te=new Set(q);return P?te.delete(I):te.add(I),te})},[]),ie=f.useCallback(()=>{U.current=Z,b(j.PopUpState.Closed),N(!0)},[Z,b,N]),le=f.useCallback(()=>{const I=mc(E);Ve(I,r),W(new Set)},[Ve,E,r]),He=f.useCallback(()=>{const I=r?.map(xe=>({...xe,disabled:V.has(xe.urn)})),P=xt(E,U.current,!1,w.map,V),q=kt(P,{...t,constraintsMap:U.current},i,w.map),te=ze(P),Re=Vc(q,r?.map(xe=>xe.urn)??[],r,w.map,P),Ce=(r?.map(xe=>xe.urn)??[]).filter(xe=>!Re.has(xe));for(const xe of Ce){const Ze=P.get(xe);Ze&&P.set(xe,Ze.map(Je=>!Je.isTimeDimension&&Je.dimensionValues?.length&&!Je.dimensionValues.some(at=>at.isSelectedValue)?{...Je,isExcluded:!0}:Je))}a?.(te,U.current,I?.filter(xe=>Re.has(xe.urn)||xe.disabled),P,q),_(q),b(j.PopUpState.Closed),N(!0),f.startTransition(()=>{Le(P)})},[ze,E,t,i,w.map,a,r,V,Le,b,N]),H=I=>{z(I)},B=f.useMemo(()=>r?.map(I=>{const P=t?.structuresMap?.get(I.urn)?.dataflows?.[0],q=D.getLocalizedName(P,i??""),te=q?D.generateShortUrn(q,"",P?.agencyID):void 0;return te?{...I,title:te}:I}),[r,t?.structuresMap,i]),ee=K||X||ke;return o.jsxs("div",{className:"filters-container",children:[o.jsx(lu,{buttonProps:n,selectedFiltersCount:Gr(k),isLoading:K,setModalState:b,isModalClosed:y,warningIcon:g?.warningIcon,filterIconClassName:x}),o.jsx(o.Fragment,{children:C===j.PopUpState.Opened&&o.jsxs(j.Popup,{heading:v?.settings||"Settings",portalId:"filters",size:j.PopUpSize.LG,containerClassName:"advanced-view-filters-modal h-[80%]",dividers:s?.isShowDividers,onClose:ie,closeButtonTitle:v?.close||"Close",children:[o.jsx(nu,{locale:i,timeRangeOptions:c,filtersList:E,selectedFilter:A,isDisableValues:X,isValuesLoading:pe,modalProps:s,initialConstraintsMap:t?.constraintsMap,datasetIcon:l,structuresMap:t?.structuresMap,setSelectedFilter:M,onSelectDisplayMode:Be,onDeleteFilter:Qe,onClearAllFilters:le,updateSelectedFilterValues:be,onTimePeriodChange:H,selectedTimeOption:L,hierarchyStateMap:ue,onSelectHierarchy:Se,onExpandHierarchyNode:ge,dataQueries:B,disabledDatasetUrns:V,onToggleDataset:me,onClearAllDatasets:Y}),o.jsx(ru,{onApply:He,onClose:ie,onClearAllFilters:le,modalProps:s,applyDisabled:ee,limitMessages:g})]})})]})},fv=({filtersProps:e,actions:t,attachments:n,attachmentsDataQuery:s,dataQueries:r,dimensions:a,locale:i,isDataLoading:c,setIsFiltering:l,filters:d,onFiltersChange:u})=>{const{titles:h,limitMessages:m}=De(),p={getConstraints:t.getConstraints,getAvailableHierarchies:e.actions?.getAvailableHierarchies,getHierarchy:e.actions?.getHierarchy},{isCrossDatasetModeOn:g}=We();return f.useEffect(()=>{c||l?.(!1)},[c,l]),o.jsx("div",{className:"h-full min-h-0 rounded bg-white",children:o.jsxs("div",{className:"flex h-full flex-col gap-4 overflow-x-hidden",children:[o.jsxs("div",{className:"data-details-header flex items-center justify-between",children:[o.jsx("h2",{children:h?.content??"Content"}),g?o.jsx(dv,{attachmentsDataQuery:s,dataQueries:r,updateDataQueries:t?.updateDataQueries,locale:i,actions:p,dimensions:a,...e,onFiltersChange:u,limitMessages:m}):o.jsx(Xm,{attachmentsDataQuery:s,dataQueries:r,updateDataQueries:t?.updateDataQueries,locale:i,actions:p,dimensions:a,...e,onFiltersChange:u,limitMessages:m})]}),o.jsx("div",{className:"advanced-view-attachments-container min-h-0 flex-1",children:o.jsx(uv,{attachments:n,currentDataQuery:s,dataQueries:r,dimensions:a,actions:t,isShowAttachments:!0,isDataSetAttachments:!0,isDataLoading:c,locale:i,filters:d})})]})})},hv=({isShowAgency:e,isShowDatasetBadge:t,dataset:n,data:s,structures:r,metadataSettings:a,locale:i,getDatasetUpdatedTime:c,externalLink:l,datasetIcon:d,externalLinkIcon:u,metadataButtonClassName:h,metadataIconClassName:m,infoSegmentContainerClassName:p,infoSegmentHeaderClassName:g,nameAndMetadataContainerClassName:x})=>{const{titles:v}=De(),w="dataset-metadata-side-panel",[C,b]=f.useState(""),[y,N]=f.useState(!1),E=f.useRef(null),[T,S]=f.useState(""),[_,A]=f.useState(""),[M,k]=f.useState(!1),{onboardingFileSchema:R,isShowOnboarding:L}=Xe(),{isOpenedAdvancedView:z}=$e(),U=wt(),{isMetadataInSidePanel:Z}=We(),[O,K]=f.useState(!1),J=f.useMemo(()=>a?.isMetadataDescription?Yp(n,C,i,v):[],[n,C,i,a?.isMetadataDescription,v]),X=f.useMemo(()=>[...a?.isMetadataDescription?[]:[Wt(n,i,v)],...Iu(_u(s),D.getStructureComponentsMap(r),i)],[s,n,i,a?.isMetadataDescription,r,v]),Q=f.useMemo(()=>$t(n,C,i,v),[n,C,i,v]),pe=f.useCallback(()=>{if(Z&&U){U.openPanel({id:w,scope:z?"advanced":"conversation",title:"Dataset Metadata",bodyClassName:"overflow-hidden",content:o.jsx(qt,{locale:i,metadata:X,metadataDescription:J,datasetInfo:Q,externalLink:l})}),K(!0);return}N(!0)},[J,X,Q,l,Z,z,i,U]),we=f.useCallback(()=>{N(!1),K(!0)},[]);f.useEffect(()=>{const W=c&&c(X)||Kt(D.getLastUpdatedTime(n),i);b(W)},[n,i,X,c]),f.useEffect(()=>{if(L){const{title:V,description:W}=mt(Ge.METADATA_PER_DATASET,v);S(V),A(W)}},[v,L]),f.useEffect(()=>{L&&k(R?.lastDisplayedElement===Ge.METADATA_PER_DATASET)},[R?.lastDisplayedElement,L]);const se=(V,W)=>o.jsxs("div",{className:st("flex gap-1 text-neutrals-1000",p),children:[o.jsxs("span",{className:st("text-neutral-800",g),children:[V,":"]}),o.jsx("span",{children:W})]});return o.jsxs("div",{className:"dataset-info flex flex-col gap-3 bg-white",children:[t&&o.jsxs("div",{className:"bg-accent-500 body-2 flex w-fit items-center gap-1 rounded-[20px] px-2 py-1",children:[d,v?.dataset??"Dataset"]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsxs("div",{role:"heading","aria-level":4,className:st("flex gap-1 items-center h4",x),children:[o.jsx("div",{ref:E,children:o.jsx(j.IconButton,{title:v?.metadata??"View details",buttonClassName:st("!text-neutrals-1000 !border-none !w-4 !h-4 !p-0 shrink-0",h),icon:o.jsx(Tu,{className:st("size-4",m)}),onClick:pe})}),o.jsx("span",{children:D.getLocalizedName(n,i)})]}),l&&o.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",children:u||o.jsx(qe.IconExternalLink,{className:"size-4 shrink-0 cursor-pointer text-primary"})})]}),o.jsxs("div",{className:"body-3 flex items-center gap-2",children:[e&&o.jsxs(o.Fragment,{children:[se(v?.agency??"Agency",n?.agencyID??""),o.jsx("div",{"aria-hidden":"true",className:"h-[14px] border-l border-l-neutral-500"})]}),se(v?.lastUpdated??"Last updated",C)]})]}),M&&o.jsx(pt,{reference:E,title:T,description:_,onReferenceClick:pe,shouldCloseTooltip:O}),y&&o.jsx(Xr,{locale:i,metadata:X,metadataDescription:J,isOpenMetadata:y,onCloseMetadata:we})]})},mv=({locale:e,isShowShare:t,shareConversationProps:n,conversation:s})=>{const{titles:r}=De(),{setIsOpenedAdvancedView:a}=$e(),i=f.useRef(null),[c,l]=f.useState(""),[d,u]=f.useState(""),[h,m]=f.useState(!1),{onboardingFileSchema:p,isShowOnboarding:g}=Xe();return f.useEffect(()=>{if(g){const{title:x,description:v}=mt(Ge.EXIT_ADVANCED_VIEW,r);l(x),u(v)}},[r,g]),f.useEffect(()=>{g&&m(p?.lastDisplayedElement===Ge.EXIT_ADVANCED_VIEW)},[p?.lastDisplayedElement,g]),o.jsxs("header",{className:$("bg-white px-6 py-4 flex justify-between items-center sm:px-0","advanced-view-header"),children:[o.jsxs("div",{className:$("flex gap-3 items-center",!t&&"justify-between w-full","advanced-view-header-title"),children:[o.jsx("div",{ref:i,className:$(!t&&"order-2","flex"),children:o.jsx(j.CloseButton,{btnClassNames:"button-close",onClick:()=>a(!1),title:r?.close||"Close"})}),h&&o.jsx(pt,{reference:i,title:c,description:d,onReferenceClick:()=>a(!1),shouldMoveToNextStep:!0}),o.jsx("h2",{children:r?.advanceViewTitle??"Advanced view"})]}),t&&o.jsx(ql,{locale:e,conversation:s,...n})]})};function pv(e,t,n,s,r,a,i,c,l){const d=gv(e,n),u=l?.startPeriod&&l.endPeriod?D.getAdditionalColumns(c,l):[],h=vv(e,t,n,s,r,a,u);return[Rp(e,t?.data,n,r,a,i),...d,...h,Du(e,t?.data,n,void 0,a,i)]}function gv(e,t){const n=e.conceptSchemes||[],s=e.codelists||[],r=D.getDimensions(e)?.dimensions||[];return r.map(a=>{const{codeList:i,concept:c}=_n(a,n,s),l=d=>{const{data:u,colDef:h}=d,m=h.field;return sa(r,m,i,u,t)};return{headerName:D.getLocalizedName(c,t),field:a.id,colId:a.id,valueGetter:l,...St,tooltipValueGetter:d=>d.value}})}function vv(e,t,n,s,r,a,i){const c=bv(i,D.getTimePeriods(t));return wv(c,(d,u)=>Cv(d,u||d,s,a),e,n,r,a)}const Cv=(e,t,n=ne.defaultFormatNumbers,s)=>({headerName:lc(t,s),colId:e,field:e,type:"numericColumn",suppressColumnsToolPanel:!0,sortable:!1,width:Et,cellClass:["justify-end","cell-with-meta"],valueFormatter:r=>ne.formatNumberBySign(r.value,n)}),wv=(e,t,n,s,r,a)=>{const i=[];return e.sort((l,d)=>D.sortPeriods(l,d)).forEach(l=>{i.push({headerName:l.toString(),field:l.toString(),...t(l.toString()),valueGetter:d=>d.data[d.column.getColId()]?.value?.[0]?.value||null,cellClass:Ct,cellRenderer:En,width:Et,cellRendererParams:{dataSetData:n,locale:s,metadataSettings:r,titles:a}})}),i},bv=(e=[],t=[])=>{if(!e.length)return t;if(!t.length)return e;const n=t.some(d=>D.isYearly(d)),s=t.some(d=>D.isSemiAnnually(d)),r=t.some(d=>D.isQuarterly(d)),a=t.some(d=>D.isMonthly(d)),i=t.some(d=>D.isWeekly(d)),c=t.some(d=>D.isDaily(d)),l=e.filter(d=>D.isYearly(d)?n:D.isSemiAnnually(d)?s:D.isQuarterly(d)?r:D.isMonthly(d)?a:D.isWeekly(d)?i:D.isDaily(d)?c:!0);return Array.from(new Set([...l,...t]))};function xv(e,t,n){const s=t.map(a=>a.id).filter(a=>a!=null),r=n.map(a=>a.id).filter(a=>a!=null);return yv(e,s,r,s)}const yv=(e,t,n,s)=>{const r={};for(const a of e){const i=Tv(a,t),c=Sv(i,s);let l=r[c];if(l==null){l={},r[c]=l;for(const u of s)l[u]=i[u]}const d=gl(a.attributes);if(vl(l,c,d,a),!a.values.length){ml(l,i,n);continue}for(const u of a.values){const h=gl(u.obsAttributes);vl(l,c,d,a),ml(l,i,n,u.dimensionAtObservation,Mv(a,u),h)}}return Object.values(r)},Sv=(e,t)=>t.map(n=>e[n]).join("_"),Dv=(e,t,n)=>t.map(s=>s==="TIME_PERIOD"?n:e[s]).join("_"),ml=(e,t,n,s,r,a)=>{const i=Dv(t,n,s);e[i]={value:r,obsAttributes:a}},Tv=(e,t)=>{const n={},s=e.name.split(".");for(let r=0;r<t.length;r+=1)n[t[r]]=s[r];return n},Mv=(e,t)=>{const n=pl(e.attributes);if(n)return[n];const s=pl(t.obsAttributes);return s?[s]:t.values},pl=(e=[])=>e.find(({name:t})=>t==="OBS_VALUE"),gl=(e=[])=>e.filter(({value:t})=>t),vl=(e,t,n,s)=>{e.attributes??=n,e.id=t,e.originalData=s},Av="#EEEEEE",Ev="#777777";function Nv(e,t,n){const s={animation:!1,tooltip:{trigger:"axis",appendToBody:!0,formatter:r=>{let a=r[0].axisValueLabel+"<br/>";return r.forEach(i=>{i.value!==null&&i.value!==void 0&&(a+=i.marker+" "+i.seriesName+": "+i.value+"<br/>")}),a}},legend:{bottom:0},grid:{left:"3%",right:"3%",bottom:"40px",containLabel:!0},xAxis:{...Cl(n?.ticksColor,n?.labelsColor),type:"category",boundaryGap:!1,data:e},yAxis:{...Cl(n?.ticksColor,n?.labelsColor),type:"value"},series:t};return n?.colors!=null&&(s.color=n.colors),s}function Cl(e=Av,t=Ev){return{splitLine:{show:!0,showMaxLine:!1,lineStyle:{color:[e]}},axisTick:{show:!1},axisLabel:{color:t},axisLine:{lineStyle:{color:e}}}}function Zu(e,t,n,s){return t.map(a=>{const i=D.getDimensions(n)?.dimensions||[],c=i?.find(d=>d.id===a);if(c==null)return e[a]||"";const{codeList:l}=_n(c,n.conceptSchemes||[],n.codelists||[]);return sa(i,a,l,e,s)}).join(" - ")}function jv(e,t){const n=[...t?.metadata?.indicatorDimensions||[]].filter(a=>a!=null),r=D.getDimensions(e)?.dimensions?.filter(a=>a.id!=null&&!n.includes(a.id)&&t?.metadata?.countryDimension!==a.id).map(a=>a.id).filter(a=>a!=null)||[];return[...n,...r]}function kv(e,t,n){const s={};return e.forEach(r=>{const a=_v(r,t,n);s[a]||(s[a]={rows:[]}),s[a].rows.push(r)}),Object.keys(s).map(r=>s[r])}function _v(e,t,n){const s=n.dataStructures?.[0]?.dataStructureComponents?.dimensionList?.dimensions||[];return t.map(a=>s?.find(c=>c.id===a)==null?e[a]||"":Wu(s,a,e)).join(" - ")}function Iv(e,t){const n={};return e.forEach(s=>n[s]=Rv(s,t)),{nonUniqDimensions:e.filter(s=>!n[s])}}function Rv(e,t){const n=t.map(r=>Pv(e,r));return new Set(n).size===1}function Pv(e,t){return t[e]}const Lv="line",tn=10,Ov=2;function Fv(e){return typeof e=="number"?Number.isFinite(e):typeof e=="string"&&e.trim()!==""?Number.isFinite(Number(e)):!1}function Xu(e){const t=(e.groups??[]).flatMap(n=>n.units);return[...e.units,...t].some(n=>n.isPlottable)}function Qu(e,t,n,s,r){const a=aa(t,e,n,s,r,{includeChartData:!1}),c=D.getTimePeriods(t).sort((h,m)=>D.sortPeriods(h,m)),l=jv(e,n),{nonUniqDimensions:d}=Iv(l,a);return{units:kv(a,d,e).map(h=>ed(h,e,n,c,s,r))}}function Vv(e,t,n,s,r){let a;return()=>(a??=Qu(e,t,n,s,r),a)}function Hv(e,t,n,s,r,a){return ed({rows:[e]},n,s,t,r,a)}function ed(e,t,n,s,r,a){const i=qv(e.rows,t,n,r),c=i?.find(u=>D.FREQUENCY_DIMENSION_ID.includes(u?.id))?.id,l=Gv(s,e?.rows?.[0],c),d=Bv(e.rows.length>tn?e.rows.slice(0,tn):e.rows,t,n,r,l);return{rows:e.rows,limitedByRowsAmountTo:e.rows.length>tn?tn:void 0,dimensions:i,config:Nv(l,d,a),isPlottable:Uv(d)}}function Uv(e){return e.some(t=>t.data.filter(Fv).length>=Ov)}function Gv(e,t,n){if(n){const s=t?.[n];if(s===D.Periods.MONTHLY)return e?.filter(r=>D.isMonthly(r));if(s===D.Periods.QUARTERLY)return e?.filter(r=>D.isQuarterly(r));if(s===D.Periods.ANNUAL)return e?.filter(r=>D.isYearly(r))}return e}function Bv(e,t,n,s,r){return e.map(a=>({name:n?.metadata?.countryDimension==null?"":Zu(a,[n?.metadata?.countryDimension],t,s),type:Lv,data:r.map(i=>zv(i,a))}))}function zv(e,t){return t[e]?.value?.[0]?.value||null}function qv(e,t,n,s){const r=n?.metadata?.countryDimension;return(D.getDimensions(t)?.dimensions||[]).map(a=>{if(!(a.id==null||a.id===r))return{id:a.id,title:Wv(a,t,s),value:Zu(e[0],[a.id],t,s)}}).filter(a=>a!=null)}function Wv(e,t,n){const s=t.conceptSchemes||[],r=t.codelists||[],{concept:a}=_n(e,s,r);return D.getLocalizedName(a,n)||e.id}function aa(e,t,n,s,r,a={}){const i=e==null?[]:D.getParsedResponse(e),c=D.getDimensions(t)?.dimensions||[],l=D.getDimensions(t)?.timeDimensions||[],d=xv(i,c,l);return a.includeChartData===!1?d:$v(d,e,t,n,s,r)}function $v(e,t,n,s,r,a){const c=D.getTimePeriods(t).sort((l,d)=>D.sortPeriods(l,d));return e.map(l=>({...l,[Ut]:()=>Hv(l,c,n,s,r,a)}))}function Kv(e,t,n,s,r,a,i,c,l,d,u){return{columns:pv(e,t,s,r,a,c,l,d,u),data:aa(t,e,n,s,i)}}function Jv(e,t,n,s,r,a,i,c,l,d,u){const h=e.dataflows?.[0]?.names?.[s],m=Kv(e,t,n,s,r,a,i,c,l,d,u);return{title:h||c?.dataGrid||"Data Grid",grid_data:m}}function Yv(e){const t=e.replace(/\r\n/g,`
8
8
  `);if(!t.startsWith("```"))return{code:e};const n=t.split(`
9
9
  `),r=n[0].slice(3).trim()||void 0;let a=-1;for(let i=n.length-1;i>0;i--)if(n[i].trim()==="```"){a=i;break}return a===-1?{code:n.slice(1).join(`
10
10
  `),language:r}:{code:n.slice(1,a).join(`
11
- `),language:r}}const Zv=["python"];function td(e,t,n){return e.filter(s=>s.type===we.AttachmentType.MARKDOWN).filter(s=>!t||s.title?.includes(t)).map(s=>{const r=Yv(s.data??"");return{title:n??"Code samples",type:we.AttachmentType.CUSTOM_CODE_SAMPLE,language:r.language,data:r.code}}).filter(s=>Zv.includes(s.language??""))}function nd(e){const{getPythonAttachment:t,dataQueries:n,requestIdRef:s,codeTitle:r,markdownTitle:a,setCodeAttachments:i,onCodeAttachmentUpdated:c}=e,l=++s.current;t(n).then(d=>{l===s.current&&d?.python_code&&(i([{type:we.AttachmentType.CUSTOM_CODE_SAMPLE,data:d.python_code,language:"python",title:r}]),c?.({type:we.AttachmentType.MARKDOWN,title:a,data:`\`\`\`python
11
+ `),language:r}}const Zv=["python"];function td(e,t,n){return e.filter(s=>s.type===ve.AttachmentType.MARKDOWN).filter(s=>!t||s.title?.includes(t)).map(s=>{const r=Yv(s.data??"");return{title:n??"Code samples",type:ve.AttachmentType.CUSTOM_CODE_SAMPLE,language:r.language,data:r.code}}).filter(s=>Zv.includes(s.language??""))}function nd(e){const{getPythonAttachment:t,dataQueries:n,requestIdRef:s,codeTitle:r,markdownTitle:a,setCodeAttachments:i,onCodeAttachmentUpdated:c}=e,l=++s.current;t(n).then(d=>{l===s.current&&d?.python_code&&(i([{type:ve.AttachmentType.CUSTOM_CODE_SAMPLE,data:d.python_code,language:"python",title:r}]),c?.({type:ve.AttachmentType.MARKDOWN,title:a,data:`\`\`\`python
12
12
  ${d.python_code}
13
- \`\`\``}))}).catch(d=>console.error("Error refreshing python attachment:",d))}const Xv="Data Grid",Qv="Data",e0="Chart",t0=e=>({title:e||Xv,type:we.AttachmentType.CUSTOM_DATA_GRID}),sd=e=>({title:e||e0,type:we.AttachmentType.CUSTOM_CHART}),n0=e=>({title:e||Qv,type:we.AttachmentType.CROSS_DATASET_GRID});function rd(e,t,n,s,r,a,i,c,l,d=!1,u,h=!1){const[m,p]=f.useState(),[g,x]=f.useState(),[v,w]=f.useState(),[C,b]=f.useState(),[y,N]=f.useState(t0(i?.dataGrid)),[M,A]=f.useState(sd(i?.chart)),[S,_]=f.useState(!1),[E,T]=f.useState([]),[k,I]=f.useState([]),[L,H]=f.useState([]),[G,Y]=f.useState(!1),[O,$]=f.useState(!1),K=f.useRef(0),[Z,se]=f.useState({startPeriod:null,endPeriod:null}),{getConstraints:ge,getDataSet:he,getDataSetData:xe,putOnboardingFile:F,getPythonAttachment:J}=e,ue=f.useCallback(U=>{if(!U)return;const q=D.getDimensions(U);x(U.dataflows?.[0]||void 0),b(U||void 0),I([...q?.dimensions||[],...q?.timeDimensions||[]])},[]),de=f.useCallback(async U=>{const q=Ht(D.getFiltersDtoFromDataQuery(U));try{const ae=(await it(ge,st(U.urn,q),()=>ge(U.urn,q)))?.data?.dataConstraints||[];w(ae)}catch{w([])}},[ge]),me=f.useCallback(async U=>{const q=l?{data:l}:await it(he,st(U.urn),()=>he(U.urn));if(q?.data){const fe=D.getDimensions(q.data);ue(q.data);const ae=fe?.dimensions==null?null:D.getTimeSeriesFilterKey(fe?.dimensions,U.filters??[]),oe=yc(U,fe);it(xe,st(U.urn,{filterKey:ae,timeFilter:oe}),()=>xe(U.urn,{filterKey:ae,timeFilter:oe})).then(pe=>{$(!0),p(pe||void 0),H(D.getStructureDimensions(pe))}).finally(()=>Y(!1))}},[ue,he,xe,l]);f.useEffect(()=>{ue(l)},[ue,l]),f.useEffect(()=>{async function U(q){Y(!0);try{await Promise.all([...h?[]:[de(q)],me(q)])}catch(fe){console.error("Error loading dataset details",fe)}}n!=null&&!(d&&!l)?U(n):n!=null&&d&&Y(!0)},[n,l,d,de,me,h]);const re=f.useCallback((U,q,fe)=>{try{Y(!0),w(q);const ae=fe?.find(oe=>oe.id===D.TIME_PERIOD)?.timeRange;if(ae&&se(ae),it(xe,st(n?.urn||"",U),()=>xe(n?.urn||"",U)).then(oe=>{$(!0),p(oe||void 0),H(D.getStructureDimensions(oe))}).finally(()=>Y(!1)),J&&n&&fe){const oe=Tc(n,fe),pe=c?.find(Se=>Se.type===we.AttachmentType.MARKDOWN&&Se.data?.includes("```python"))?.title;nd({getPythonAttachment:J,dataQueries:[oe],requestIdRef:K,codeTitle:i?.codeSamples||"Python Code",markdownTitle:pe??n.urn,setCodeAttachments:T,onCodeAttachmentUpdated:u})}}catch(ae){console.error("Error loading dataset data",ae)}},[n,xe,J,i,c,u]);f.useEffect(()=>{if(C!=null&&m!=null&&v?.length){$(!0);const U=Bt(()=>{N(q=>({...q,...Jv(C,m,n,t,s,a,r,i,F,v,Z)})),$(!1)});return()=>{U(),$(!1)}}(m==null||v!==void 0)&&$(!1)},[C,m,i,t,s,n,a,r,v,Z,F]),f.useEffect(()=>{if(C==null||m==null)return;const U=Vv(C,m,n,t,r);return A(q=>({...q,charting_data:void 0,getChartingData:U})),_(!1),Bt(()=>{try{_(Xu(U()))}catch(q){console.error("Error evaluating chart plottability",q),_(!1)}})},[C,m,n,t,r]),f.useEffect(()=>{if(c?.length){const U=td(c,n?.urn,i?.codeSamples);U.length>0&&T(U)}},[c,i,n]);const Q=f.useMemo(()=>[y,...S?[M]:[],...E],[y,M,E,S]);return{dataMessage:m,structures:C,dataset:g,dimensions:k,structureDimensions:L,onFiltersChange:re,constraints:v,isLoadingGridData:G||O,dataSetAttachments:Q}}function ad(e,t,n){let s=-1;if(n)s=e.findIndex(i=>i.id===n);else for(let i=e.length-1;i>=0;i--)if(e[i].role===Ie.Role.System){s=i;break}if(s===-1||e[s].role!==Ie.Role.System)return null;const a=[...(e[s].custom_content?.attachments??[]).filter(i=>!(i.type==="text/markdown"&&i.data?.includes("```python"))),t];return e.map((i,c)=>c===s?{...i,custom_content:{...i.custom_content,attachments:a}}:i)}const wl=async(e,t)=>{const n=new Map,s=D.getFiltersDtoMapFromDataQuery(e);return(await Promise.allSettled(e.map(async a=>{const i=Ht(s?.get(a.urn)||[]);return{urn:a.urn,response:await it(t,st(a.urn,i),()=>t(a.urn,i))}}))).forEach(a=>{if(a.status==="fulfilled"){const i=a.value.response?.data?.dataConstraints;Array.isArray(i)&&n.set(a.value.urn,i)}}),n},s0=()=>({datasetsMap:new Map,dataMessagesMap:new Map,structuresMap:new Map,dimensionsMap:new Map,structureDimensionsMap:new Map}),r0=async(e,t,n,s,r)=>{const a=s0();await Promise.allSettled(e.map(async c=>{const l=await it(t,st(c.urn),()=>t(c.urn));if(l?.data){const d=D.getDimensions(l.data);a.datasetsMap?.set(c?.urn,l?.data?.dataflows?.[0]),a.structuresMap?.set(c?.urn,l?.data),a.dimensionsMap?.set(c?.urn,[...d?.dimensions||[],...d?.timeDimensions||[]])}}));const i=await r?.(a);return await Promise.allSettled(e.map(async c=>{const l=a.structuresMap?.get(c.urn);if(!l||i&&!i.has(c.urn))return;const d=D.getDimensions(l),u=d?.dimensions==null?null:D.getTimeSeriesFilterKey(d?.dimensions,c.filters??[]),h=yc(c,d);await id(c,i?.get(c.urn)??{filterKey:u,timeFilter:h},n).then(({dataMessage:m,structureDimensions:p})=>{a?.dataMessagesMap?.set(c.urn,m),a?.structureDimensionsMap?.set(c.urn,p||[])}).catch(()=>{a?.structureDimensionsMap?.set(c.urn,[])}).finally(()=>s(!1))})),a},id=async(e,t,n)=>{const s=await it(n,st(e.urn,t),()=>n(e.urn,t));return{dataMessage:s,structureDimensions:D.getStructureDimensions(s)}};function a0(e,t,n,s){return[o0(e,s),i0(e,t,n,s)]}function i0(e,t,n,s){const r=a=>{const i=a.data?.dataset?.urn;if(i==null)return"";const l=e.get(i)?.dataflows?.[0];return D.getLocalizedName(l,n)||""};return{headerName:s?.dataset||c1,field:ol,colId:ol,valueGetter:r,...St,tooltipValueGetter:a=>a.value,cellClass:Ct,cellRenderer:Su,cellRendererParams:{structuresMap:e,attributesDataMap:t,locale:n,titles:s}}}function o0(e,t){const n=s=>{const r=s.data?.dataset?.urn;return r==null?"":e.get(r)?.dataflows?.[0]?.agencyID||""};return{headerName:t?.agency||u1,field:ll,colId:ll,valueGetter:n,...St,tooltipValueGetter:s=>s.value}}function l0(e,t,n,s,r){return c0(e).sort((c,l)=>D.sortPeriods(c,l)).map(c=>({...u0(c,s,r),valueGetter:d=>d.data[d.column.getColId()]?.value?.[0]?.value||null,cellClass:Ct,cellRenderer:En,width:Et,cellRendererParams:{structuresMap:t,locale:n,titles:r}}))}function c0(e){const t=new Set;return e.forEach(n=>{if(n==null)return;D.getTimePeriods(n).forEach(r=>t.add(r))}),Array.from(t)}function u0(e,t=ne.defaultFormatNumbers,n){return{headerName:lc(e,n),colId:e,field:e,type:"numericColumn",suppressColumnsToolPanel:!0,sortable:!1,width:Et,cellClass:["justify-end","cell-with-meta"],valueFormatter:s=>ne.formatNumberBySign(s.value,t)}}function d0(e,t,n,s,r,a,i=et.Compact){const c=new Map([...n.entries()].map(([h,m])=>[h,m?.data])),l=a0(e,c,s,r),d=C1(e,t,s,r,i),u=l0(n,e,s,a,r);return[Pp(e,c,s,r),...l,...d,...u,Du(void 0,void 0,s,void 0,r)]}function f0(e,t,n,s,r){const a=[];return n.filter(i=>!i.disabled).forEach(i=>{const c=i.urn,l=t.get(c),d=e.get(c);if(l==null||d==null)return;const u=aa(l,d,i,s,r),h=D.getLocalizedName(d.dataflows?.[0],s);a.push(...u.map(m=>({...m,dataset:{urn:c},datasetTitle:h})))}),a}function h0(e,t,n,s,r,a,i,c,l,d,u,h=et.Compact){const m=m0(e,t,n,s,r,a,i,c,l,d,u,h);return{title:l?.dataGrid||"Data",gridContent:m}}function m0(e,t,n,s,r,a,i,c,l,d,u,h=et.Compact){return{columns:d0(e,n,t,r,l,a,h),data:f0(e,t,s,r,c)}}function p0(e,t,n,s,r){let a;return()=>(a??=g0(e,t,n,s,r),a)}function g0(e,t,n,s,r){const a=n.filter(i=>!i.disabled).flatMap(i=>{const c=e.get(i.urn),l=t.get(i.urn);return!c||!l?[]:[{title:D.getLocalizedName(c.dataflows?.[0],s),units:Qu(c,l,i,s,r).units}]});return{units:a.flatMap(i=>i.units),groups:a}}function od(e,t,n,s,r,a,i,c,l,d=et.Compact,u){const h=Array.isArray(c)?c:void 0,[m,p]=f.useState(),[g,x]=f.useState(),[v,w]=f.useState(!1),[C,b]=f.useState(h?new Set(h):null),[y,N]=f.useState(!1),M=f.useRef(0),A=f.useRef(d),S=f.useRef(m),[_,E]=f.useState(n0(u?.dataGrid)),[T,k]=f.useState(sd(u?.chart)),[I,L]=f.useState(!1),[H,G]=f.useState([]),{getConstraints:Y,getDataSet:O,getDataSetData:$,getPythonAttachment:K}=e,Z=f.useRef(n);Z.current=n;const se=f.useRef(h);se.current=h;const ge=f.useMemo(()=>n?.map(re=>re.urn).join(",")??"",[n]),he=Rn(),{getDimensionsScheme:xe}=he,F=f.useCallback(async re=>{try{const Q=await wl(re.map(fe=>({...fe,filters:[]})),Y),U=lm(re,Q,he.map),q=U===re?Q:await wl(U,Y);return p(fe=>({...fe,constraintsMap:q})),q}catch{const Q=new Map;return p(U=>({...U,constraintsMap:Q})),Q}},[he.map,Y]),J=f.useCallback(async(re,Q)=>{const U=await r0(re,O,$,w,async q=>{const fe=re.filter(oe=>!oe.disabled),ae=$o(fe,q,Q,t,he.map);if(ae)return b(ae.compatibleUrns),ae.filterParamsMap});p(q=>({...q,...U,constraintsMap:Q??q?.constraintsMap}))},[he.map,O,$,t]),ue=f.useCallback(re=>{const Q=new Map;for(const U of re)Q.set(U.urn,xe(U.urn));x(Q)},[xe]);f.useEffect(()=>{async function re(U){const q=se.current;b(q?new Set(q):null),w(!0);try{ue(U);const fe=await F(U);await J(U,fe)}catch(fe){console.error("Error loading dataset details",fe)}finally{w(!1)}}const Q=Z.current;Q?.length&&re(Q)},[ge,F,ue,J]),f.useEffect(()=>{if(i?.length){const re=td(i,void 0,u?.codeSamples);re.length>0&&G(re)}},[i,u]),f.useEffect(()=>{const re=A.current!==d&&S.current===m;A.current=d,S.current=m;const{structuresMap:Q,dataMessagesMap:U,constraintsMap:q}=m??{};if(Q!=null&&Q.size>0&&U!=null&&q!=null&&g!=null&&!v){re||N(!0);const fe=Bt(()=>{const ae=n?.filter(ce=>!ce.disabled),oe=C??new Set((ae??[]).map(ce=>ce.urn)),pe=Go(ae,oe),Se=jt(Q,oe),Ce=jt(U,oe),ye=jt(g,oe);E(ce=>({...ce,...h0(Se,Ce,ye,pe,t,r,a,s,u,q,{},d)})),re||N(!1)});return()=>{fe(),re||N(!1)}}re||N(!1)},[m,n,t,r,a,s,u,g,v,C,d]),f.useEffect(()=>{const{structuresMap:re,dataMessagesMap:Q}=m??{};if(re!=null&&re.size>0&&Q!=null&&!v){const U=n?.filter(Se=>!Se.disabled),q=C??new Set((U??[]).map(Se=>Se.urn)),fe=Go(U,q),ae=jt(re,q),oe=jt(Q,q),pe=p0(ae,oe,fe,t,s);return k(Se=>({...Se,charting_data:void 0,getChartingData:pe})),L(!1),Bt(()=>{try{L(Xu(pe()))}catch(Se){console.error("Error evaluating cross-dataset chart plottability",Se),L(!1)}})}},[m,n,t,s,v,C]);const de=f.useMemo(()=>[_,...I?[T]:[],...H],[_,T,H,I]),me=f.useCallback((re,Q,U,q,fe)=>{try{w(!0);const ae=U?.filter(ce=>!ce.disabled)??[],oe=new Set(ae.map(ce=>ce.urn));if(b(oe),p(ce=>({...ce,constraintsMap:Q})),!ae.length){w(!1);return}const pe=q?Wc(ae,q):void 0,Se=pe?ae.map(ce=>({...ce,filters:pe.get(ce.urn)??[]})):ae,ye=(Q&&m?$o(Se,m,Q,t,he.map):void 0)?.filterParamsMap??re;if(ae.forEach(ce=>{id(ce,ye?.get(ce?.urn),$).then(({dataMessage:Ee,structureDimensions:Pe})=>{N(!0),p(ze=>{const Ge=new Map(ze?.dataMessagesMap),Ve=new Map(ze?.structureDimensionsMap);return Ge.set(ce.urn,Ee),Ve.set(ce.urn,Pe||[]),{...ze,dataMessagesMap:Ge,structureDimensionsMap:Ve}})}).finally(()=>w(!1))}),K&&ae.length){const ce=ae.map(Ee=>Tc(Ee,fe??q?.get(Ee.urn)??[]));nd({getPythonAttachment:K,dataQueries:ce,requestIdRef:M,codeTitle:u?.codeSamples||"Python Code",markdownTitle:"Python Code",setCodeAttachments:G,onCodeAttachmentUpdated:l})}}catch(ae){console.error("Error loading dataset data",ae)}},[he.map,$,K,t,l,m,u]);return{structureDataMaps:m,datasetDimensionsSchemesMap:g,isLoadingGridData:v||y,crossDatasetAttachments:de,activeDatasetUrns:C,onMultipleDataFiltersChange:me}}const ld=f.createContext(void 0),v0={setCrossDatasetAttachmentsState:()=>{}},C0=e=>{if(!e)return"";try{return JSON.stringify({dataQueriesKey:e.dataQueriesKey,activeDatasetUrns:e.activeDatasetUrns,isLoading:!!e.isLoading,attachments:e.attachments})}catch{return JSON.stringify({dataQueriesKey:e.dataQueriesKey,activeDatasetUrns:e.activeDatasetUrns,isLoading:!!e.isLoading,attachmentsLength:e.attachments?.length??0})}},w0=({children:e})=>{const[t,n]=f.useState({}),s=f.useCallback(a=>{const i=C0(a);n(c=>c.signature===i?c:{...a,isLoading:!!a?.isLoading,signature:i})},[]),r=f.useMemo(()=>({...t,setCrossDatasetAttachmentsState:s}),[s,t]);return o.jsx(ld.Provider,{value:r,children:e})},Ln=()=>{const e=f.useContext(ld);return e===void 0?v0:e},b0=({attachmentsProps:e,actions:t,titles:n,shareConversationProps:s,metadataSettings:r,formattingSettings:a,locale:i,advanceViewStyles:c,getDatasetUpdatedTime:l,attachmentsConfig:d,datasetInfoOptions:u,limitMessages:h,...m})=>{const p=f.useMemo(()=>e.currentDataQuery?.urn??e.dataQueries?.[0]?.urn??"default",[e.currentDataQuery?.urn,e.dataQueries]),g=f.useMemo(()=>e?.dataQueries?.filter(Ce=>!Ce.disabled),[e?.dataQueries]),[x,v]=f.useState(et.Compact),{isOpenedAdvancedView:w}=qe(),{activeDatasetUrns:C,dataQueriesKey:b,setCrossDatasetAttachmentsState:y}=Ln(),{isCrossDatasetModeOn:N,isMetadataInSidePanel:M}=Ue(),A=Rn(),S=!M,_=e.datasets??[],E=_.length>1&&!N,T=f.useMemo(()=>{const Ce=m.filtersProps.conversation?.messages??[],ye=hu(Ce);return ye>=0?Ce[ye].custom_content?.attachments:void 0},[m.filtersProps.conversation?.messages]),k=f.useMemo(()=>Uc(e.dataQueries),[e.dataQueries]),I=b===k?C:Hc(e.dataQueries,A.map),L=N&&!!e.dataQueries?.length,H=f.useRef(m.filtersProps.conversation);H.current=m.filtersProps.conversation;const G=f.useCallback(Ce=>{const ye=H.current;if(!ye)return;const ce=ad(ye.messages,Ce);if(!ce)return;const Ee={...ye,messages:ce};m.filtersProps.setConversation?.(Ee),m.filtersProps.updateConversation(decodeURI(m.filtersProps.conversationKey),{name:Ee.name,messages:Ee.messages})},[]),{dataMessage:Y,dataset:O,dimensions:$,structureDimensions:K,structures:Z,dataSetAttachments:se,onFiltersChange:ge,isLoadingGridData:he,constraints:xe}=rd(t,i,e.currentDataQuery,a,e.styles?.chartingStyles,r,n,T,void 0,!1,G,L),{structureDataMaps:F,crossDatasetAttachments:J,activeDatasetUrns:ue,isLoadingGridData:de,onMultipleDataFiltersChange:me}=od(t,i,e.dataQueries,e.styles?.chartingStyles,a,r,T,I,G,x,n);f.useEffect(()=>{if(!N||!e.dataQueries?.length){y();return}F&&y({attachments:J,dataQueriesKey:k,activeDatasetUrns:ue?Array.from(ue):void 0,isLoading:de})},[ue,e.dataQueries?.length,J,k,N,de,y,F]);const[re,Q]=f.useState(),[U,q]=f.useState({filterKey:null,timeFilter:null}),fe=f.useMemo(()=>N?de:he,[N,de,he]),ae=f.useCallback((Ce,ye,ce)=>{q(Ce),Q(!0),ge(Ce,ye,ce)},[ge]),oe=f.useCallback((Ce,ye,ce,Ee,Pe)=>{Q(!0),me(Ce,ye,ce,Ee,Pe)},[me]),pe=f.useCallback(Ce=>{Ce&&t?.updateCurrentDataQuery(e?.dataQueries?.find(ye=>ye?.urn===Ce)||e.currentDataQuery)},[t,e.currentDataQuery,e?.dataQueries]),Se=kr(d?.isExternaLinkIncludeFilters,U,e.currentDataQuery||e.dataQueries?.[0],$);return o.jsx(Cn,{styles:{titles:n,attachmentsStyles:e.styles,formattingSettings:a,limitMessages:h,attachmentsConfig:d},children:o.jsx(g1,{currentUrn:p,structuresMap:F?.structuresMap,locale:i,dataQueries:g,gridViewMode:x,onGridViewModeChange:v,texts:{columnsDisplayTitle:e.styles?.columnsDisplayTitle,columnsSearchPlaceholder:e.styles?.columnsSearchPlaceholder,compactViewTitle:e.styles?.compactViewTitle,compactViewDescription:e.styles?.compactViewDescription,extendedViewTitle:e.styles?.extendedViewTitle,extendedViewDescription:e.styles?.extendedViewDescription},resetIcon:e.styles?.tableSettingsResetIcon,children:o.jsx(Hm,{children:o.jsxs("div",{className:"advanced-view flex h-full min-w-0 flex-1 flex-col",children:[o.jsx(mv,{locale:i,shareConversationProps:s,isShowShare:c?.isShowShare,conversation:m.filtersProps.conversation}),_.length?o.jsxs(o.Fragment,{children:[E&&o.jsx(vu,{datasets:_,initialSelectedDatasetUrn:e?.currentDataQuery?.urn,locale:i,selectDataset:pe}),fe&&!re?o.jsx(j.Loader,{}):o.jsxs(o.Fragment,{children:[S&&o.jsx(hv,{...u,locale:i,dataset:O,data:Y?.data,structures:Z,metadataSettings:r,getDatasetUpdatedTime:l,externalLink:Se}),o.jsxs("div",{className:W("flex flex-1 min-h-0 overflow-auto",S&&"border-t border-neutrals-500"),children:[o.jsx("div",{className:W("flex-1 min-h-0 overflow-auto","advanced-view-filters"),children:o.jsx(fv,{...m,actions:t,attachments:N?J:se,attachmentsDataQuery:e.currentDataQuery,dataQueries:e?.dataQueries,dimensions:$,isDataLoading:fe,locale:i,filtersProps:{...m?.filtersProps,structureDimensions:K,structures:Z,structureDataMaps:F,onFiltersChange:ge,onMultipleDataFiltersChange:oe,initialConstraints:xe},setIsFiltering:Q,filters:U,onFiltersChange:ae})}),w&&o.jsx(Ou,{scope:"advanced"})]})]})]}):o.jsx(j.Loader,{})]})})})})};function x0(e,t,n,s,r,a){const[i,c]=f.useState([]),[l,d]=f.useState(),[u,h]=f.useState(!1),m=f.useRef(void 0);return f.useEffect(()=>{m.current=a},[a]),f.useEffect(()=>{let p=!0;async function g(x){h(!0);try{const v=await Promise.all(x.map(C=>it(e,st(C.urn),()=>e(C.urn))));if(!p)return;const w=v?.map(C=>C?.data?.dataflows?.[0])?.filter(C=>!!C)||[];c(w),t(w),n(x),s(x.find(C=>C.urn===m.current?.urn)??x[0]),d(new Map(v?.map(C=>[D.generateShortUrn(C?.data?.dataflows?.[0]?.id,C?.data?.dataflows?.[0]?.version,C?.data?.dataflows?.[0]?.agencyID),C?.data])))}catch(v){console.error("Error loading datasets",v)}finally{p&&h(!1)}}if(!r?.length){h(!1);return}return g(r),()=>{p=!1}},[r,e,s,n,t]),{datasets:i,datasetStructuresMap:l,isLoading:u}}function bl(e){const t=e?.filter(n=>du(n));if(t?.every(n=>!!n?.data))return t?.map(n=>({title:n?.title,...S0(y0(n?.data))}))}function y0(e){if(e)try{return JSON.parse(e)}catch(t){console.error("Invalid JSON:",t)}return null}function S0(e){return{...e,filters:e?.filters?.map(t=>({...t,componentCode:t?.component_code||t?.componentCode})),metadata:{datasetUrl:e?.metadata?.datasetUrl,countryDimension:e?.metadata?.country_dimension||e?.metadata?.countryDimension,indicatorDimensions:e?.metadata?.indicator_dimensions||e?.metadata?.indicatorDimensions,timePeriodDimension:e?.metadata?.timePeriodDimension,keyDimensionIdsInDsdOrder:e?.metadata?.keyDimensionIdsInDsdOrder}}}var cd=(e=>(e.COMPLETED="completed",e))(cd||{});const D0=({stage:e,stageRef:t,isCurrentStage:n})=>o.jsxs("div",{ref:t,className:"message-stage relative flex pb-8 last:mb-8 last:pb-0",children:[o.jsx("span",{className:"message-stage-line absolute h-full border-l"}),o.jsx(He.IconPointFilled,{className:"message-stage-indicator z-10 flex shrink-0"}),o.jsxs("div",{className:"ml-2 w-full",children:[o.jsxs("div",{className:W("flex gap-2 items-center",e?.content&&"mb-4"),children:[n&&o.jsx(j.Loader,{}),o.jsx("h3",{className:"message-stage-name",children:e?.name})]}),o.jsx("div",{className:"prose max-w-full break-words",children:o.jsx(yl,{remarkPlugins:[Sl],components:{strong:s=>o.jsx("strong",{className:"text-neutrals-1000",...s}),a:({href:s,children:r,...a})=>o.jsx("a",{href:s,target:"_blank",rel:"noreferrer",...a,children:r}),h1:({children:s,...r})=>o.jsx("h1",{className:"h1 text-neutrals-1000",...r,children:s}),h2:({children:s,...r})=>o.jsx("h2",{className:"h2 text-neutrals-1000",...r,children:s}),h3:({children:s,...r})=>o.jsx("h3",{className:"h3 text-neutrals-1000",...r,children:s}),h4:({children:s,...r})=>o.jsx("h4",{className:"h4 text-neutrals-1000",...r,children:s}),h5:({children:s,...r})=>o.jsx("h5",{className:"h5 text-neutrals-1000",...r,children:s}),code:s=>o.jsx("code",{className:"text-neutrals-900",...s}),pre:s=>o.jsx("pre",{className:"border border-neutrals-600 bg-neutrals-100",...s})},children:e?.content})})]})]}),T0=({stages:e,expandIcon:t,processingTitle:n})=>{const[s,r]=f.useState(),[a,i]=f.useState(),c=f.useRef(null),l=f.useRef(null);f.useEffect(()=>{i(e?.filter(u=>u?.status!==cd.COMPLETED)?.at(-1))},[e]),f.useEffect(()=>{s&&l?.current?.scrollIntoView({block:"nearest",behavior:"smooth"})},[s]),f.useEffect(()=>{const u=c.current;let h;if(!u)return;const m=new IntersectionObserver(([p])=>{const g=p?.boundingClientRect?.top;h&&!p?.isIntersecting&&g<h&&r(!1),h=g},{threshold:0});return m.observe(u),()=>m.disconnect()},[]);const d=()=>{r(u=>!u)};return o.jsxs("div",{className:"message-stages",ref:c,children:[o.jsxs("div",{className:W("message-stages-header inline-flex max-w-full items-center cursor-pointer",!a?.name&&"default-header"),onClick:d,children:[o.jsx("p",{className:"message-stages-title truncate",children:a?.name||n||"Processing..."}),o.jsx("i",{className:W("message-stages-expand-icon",s&&"rotated"),children:t})]}),s&&e&&o.jsx("div",{className:"flex flex-col",children:e?.map(u=>o.jsx(D0,{stage:u,stageRef:a?l:null,isCurrentStage:u?.index===a?.index},u.index))})]})},M0=2e3,A0=({message:e,regenerateMessage:t,messageActionsIcons:n,rateResponse:s,isStreaming:r=!1,isReadOnly:a=!1,isRegenerateAvailable:i=!1})=>{const{messageActionsTitles:c}=Me(),l=n?.copy,d=n?.copied,u=n?.regenerate,h=n?.thumbUp,m=n?.thumbDown,p=n?.thumbPressed,[g,x]=f.useState(e.like??Ie.LikeState.NoState),[v,w]=f.useState(!1),C=f.useRef(null),{isAgentAvailable:b}=j.useAgentAvailability();f.useEffect(()=>()=>{C.current&&clearTimeout(C.current)},[]);const y=M=>{e.responseId&&(x(M),s(e.responseId||"",M))},N=()=>{navigator.clipboard.writeText(e.content),w(!0),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{w(!1)},M0)};return o.jsxs("div",{className:W("message-actions","flex gap-x-2 pt-2"),children:[l&&o.jsx("p",{onClick:N,title:c?.copy,children:v&&d?d:l}),i&&u&&!a&&!r&&o.jsx("p",{onClick:b?()=>t?.(e):void 0,"aria-disabled":!b,title:c?.regenerate,className:W(!b&&"opacity-50 !cursor-not-allowed pointer-events-none"),children:u}),h&&!a&&g!==Ie.LikeState.Disliked&&(g===Ie.LikeState.NoState?o.jsx("p",{onClick:()=>y(Ie.LikeState.Liked),title:c?.like,children:h}):o.jsx("p",{title:c?.like,children:p})),m&&!a&&g!==Ie.LikeState.Liked&&(g===Ie.LikeState.NoState?o.jsx("p",{onClick:()=>y(Ie.LikeState.Disliked),title:c?.dislike,children:m}):o.jsx("p",{className:"rotate-180",title:c?.dislike,children:p}))]})},E0=({message:e,onEditClick:t,messageActionsIcons:n,isStreaming:s=!1,isReadOnly:r=!1})=>{const a=n?.copy,i=n?.edit,{isAgentAvailable:c}=j.useAgentAvailability();return o.jsxs("div",{className:W("message-actions","flex gap-x-2 pt-2 ml-12"),children:[a&&o.jsx("p",{onClick:()=>navigator.clipboard.writeText(e.content),children:a}),i&&!s&&!r&&o.jsx("p",{onClick:c?t:void 0,className:W(!c&&"opacity-50 !cursor-not-allowed pointer-events-none"),"aria-disabled":!c,children:i})]})},N0=({content:e,textColorClass:t,onCancel:n,onEditApply:s,editMessageTitles:r})=>{const{isOpenedAdvancedView:a}=qe(),i=f.useRef(null);f.useEffect(()=>{const l=i.current;c(),l&&(l.focus(),l.setSelectionRange(l.value.length,l.value.length))},[]);const c=()=>{const l=i.current;l&&(l.style.height="auto",l.style.height=l.scrollHeight+"px")};return o.jsxs("div",{className:W("max-w-none break-words",a?"body-2":"body-1",t),children:[o.jsx("textarea",{ref:i,className:"w-full resize-none overflow-hidden bg-neutrals-300 outline-none",defaultValue:e,onInput:c}),o.jsxs("div",{className:W("flex gap-x-2 items-center","edit-buttons-wrapper"),children:[o.jsx(j.Button,{buttonClassName:"text-button-secondary small-icon-button",title:r?.cancel,isSmallButton:!0,onClick:n}),o.jsx(j.Button,{buttonClassName:"text-button-primary small-icon-button",title:r?.send,isSmallButton:!0,onClick:()=>s(i.current?.value||"")})]})]})},j0=({message:e,previousMessage:t,actions:n,dataQuery:s,isStreaming:r=!1,isCurrentMessageStreaming:a=!1,showAdvancedView:i,locale:c,metadataSettings:l,onAdvancedViewOpen:d,regenerateMessage:u,selectMessageToSend:h,rateResponse:m,editMessage:p,isReadOnlyConversation:g,isLastNotUserMessage:x,onCodeAttachmentUpdated:v})=>{const{messageStyles:w,attachmentsStyles:C,formattingSettings:b,messageActionsIcons:y,editMessageTitles:N,expandStagesIcon:M,titles:A}=Me(),[S,_]=f.useState(),[E,T]=f.useState(),[k,I]=f.useState([]),[L,H]=f.useState([]),[G,Y]=f.useState(),[O,$]=f.useState(!1),{isCrossDatasetModeOn:K}=Ue(),Z=Rn(),se=e.role===Ie.Role.User,ge=e.role===Ie.Role.System,{datasets:he,datasetStructuresMap:xe,isLoading:F}=x0(n.getDataSet,n.updateDatasets,n.updateDataQueries,n.updateCurrentDataQuery,S,s),[J,ue]=f.useState(!1),[de,me]=f.useState([]);f.useEffect(()=>{T(S?.[0])},[S]);const re=K&&!!S?.length,Q=f.useCallback(ie=>{e.id&&v?.(e.id,ie)},[e.id,v]),{dataSetAttachments:U,dimensions:q,isLoadingGridData:fe}=rd(n,c,E,b,C?.chartingStyles,l,A,e.custom_content?.attachments,E?xe?.get(E.urn):void 0,F,Q,re),ae=f.useMemo(()=>Hc(S,Z.map),[S,Z.map]),{crossDatasetAttachments:oe,isLoadingGridData:pe}=od(n,c,S,C?.chartingStyles,b,l,e.custom_content?.attachments,ae,Q,void 0,A),{isOpenedAdvancedView:Se}=qe(),{attachments:Ce,dataQueriesKey:ye,isLoading:ce}=Ln(),Ee=f.useMemo(()=>Uc(S),[S]),Pe=K&&!!i&&Ce!=null&&ye===Ee,ze=Pe?Ce:oe,Ge=f.useMemo(()=>K?Pe?ce:pe:fe,[K,pe,fe,ce,Pe]),Ve=()=>{se&&ue(!0)},Xe=()=>{ue(!1)},$e=ie=>{Xe(),p?.({...e,content:ie})},Be=f.useCallback(ie=>{ie&&(T(S?.find(le=>le?.urn===ie)),Y(void 0))},[S]);f.useEffect(()=>{const ie=e.custom_content?.form_schema?.properties,le=x?ie?.choice?.oneOf||ie?.completion?.oneOf:[];me(le||[])},[e,x]),f.useEffect(()=>{const ie=Qo(e),le=bl(ie),Le=ie.filter(V=>Kr(V));_(le),H(Le)},[e]),f.useEffect(()=>{$(S!=null&&S.length>0)},[S]),f.useEffect(()=>{s?.urn&&S?.some(ie=>ie?.urn===s.urn)&&Y(s.urn)},[s,S]),f.useEffect(()=>{if(e?.role===Ie.Role.System&&t){const ie=Qo(t),le=bl(ie)||[];S&&le&&xe&&I(fp(le,S,xe,c,Z.map))}},[S,E,xe,Z.map,q,c,e?.role,t]);const ot=f.useCallback(()=>!se&&w?.systemMessageIcon&&!(Se&&!a)?o.jsx("div",{className:W("flex-shrink-0 rounded-full flex items-center justify-center w-[44px] h-[44px]",a?"text-white absolute":"text-neutrals-400"),children:w.systemMessageIcon}):null,[se,w?.systemMessageIcon,Se,a]),X=f.useMemo(()=>o.jsx(Ju,{actions:n,attachments:O?K?ze:U:L,onAdvancedViewOpen:d,isDataSetAttachments:O,datasets:he,initialSelectedDatasetUrn:G,showAdvancedView:i,isSystemAttachments:ge,isDataLoading:Ge,currentDataQuery:E,dataQueries:S,attachmentInfoList:k,locale:c,dimensions:q,selectDataset:Be}),[n,O,U,L,ze,he,G,i,ge,Ge,E,S,k,c,q,Be,d,K]);if(ge&&Se)return null;const ve=a?null:se?J?null:o.jsx(E0,{messageActionsIcons:y,message:e,isStreaming:r,onEditClick:Ve,isReadOnly:g}):ge?null:o.jsx(A0,{messageActionsIcons:y,message:e,isStreaming:r,regenerateMessage:u,rateResponse:m,isReadOnly:g,isRegenerateAvailable:x});return o.jsx("div",{className:W("max-w-full flex",se?"justify-end":"justify-start","message-wrapper"),children:o.jsxs("div",{className:W("flex items-start",se&&!J?"max-w-full":"w-full"),children:[o.jsxs("div",{className:"relative mr-2",children:[ot(),a&&o.jsx(j.Loader,{})]}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:W(se?"bg-neutrals-300 px-6":"pt-0",se?"user-message":"system-message",se&&(J?"w-[100%] ml-0":"ml-12")),children:[!se&&!Se&&e?.custom_content?.stages?o.jsx(T0,{stages:e?.custom_content?.stages,expandIcon:M,processingTitle:w?.processingTitle}):a&&o.jsx("p",{className:"body-1 loading-message text-neutrals-700",children:A?.loading}),J?o.jsx(N0,{content:e.content,onCancel:Xe,onEditApply:$e,editMessageTitles:N}):o.jsx($l,{content:e.content})]}),X,ve,!Se&&!Ge&&o.jsx(Kl,{choiceButtons:de,onClick:h})]})]})})},k0=({messages:e,isStreaming:t=!1,isReadOnly:n,conversationViewState:s,...r})=>{const{scrollBottomIcon:a}=Me(),i=f.useRef(null),c=f.useRef(null),{isOpenedAdvancedView:l}=qe(),d=wt(),[u,h]=f.useState(null),[m,p]=f.useState(!1),g=d?.isPanelOpen()??!1,x=()=>{const y=c.current?.parentElement,N=i.current;if(y&&N){const M=N.offsetTop-y.offsetTop;y.scrollTo({top:M,behavior:"smooth"})}};f.useEffect(()=>{x()},[e,t]),f.useEffect(()=>{!l&&u!==null&&setTimeout(()=>{c?.current?.parentElement?.scrollTo({top:u,behavior:"smooth"})})},[l,u]);const v=()=>{const y=c.current?.parentElement?.scrollTop||null;h(y)},w=()=>{const y=c.current?.parentElement;if(y){const{scrollTop:N,scrollHeight:M,clientHeight:A}=y;N+A>=M?p(!1):!m&&!l&&p(!0)}};f.useEffect(()=>{l&&p(!1)},[l]);const C=j.useDebounce(w,300);f.useEffect(()=>{const y=c.current?.parentElement;return y?.addEventListener("scroll",C),()=>y?.removeEventListener("scroll",C)},[C]);const b=f.useCallback(y=>{const N=ne.linkifyText(y);return o.jsx("div",{className:"whitespace-pre-wrap break-words",children:N.map((M,A)=>M.type==="text"?o.jsx(f.Fragment,{children:M.value},A):o.jsx("a",{href:M.value,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center align-middle",children:o.jsx(He.IconExternalLink,{className:"size-4 shrink-0 cursor-pointer text-primary"})},A))})},[]);return o.jsxs("div",{ref:c,className:"flex size-full justify-center",children:[o.jsxs("div",{className:"chat-messages-wrapper flex w-full flex-col gap-y-6",children:[e.map((y,N)=>{const M=y.id??N;if(y.errorMessage){const E=s?.errorContext?.kind===we.ERROR_CONTEXT_KIND.RATE_LIMIT?j.InlineAlertType.Warning:j.InlineAlertType.Error;return o.jsx(j.InlineAlert,{type:E,children:o.jsx("div",{className:"flex flex-col",children:b(y.errorMessage)})},M)}if(l&&y.role===Ie.Role.System)return null;const A=N===e.length-1,S=qm(e,N),_=hu(e);return o.jsx(j0,{message:y,previousMessage:S,onAdvancedViewOpen:v,isStreaming:t,isCurrentMessageStreaming:t&&A&&y.role===Ie.Role.Assistant,showAdvancedView:N===_&&!n,isLastNotUserMessage:A&&y.role!==Ie.Role.User,...r},M)}),o.jsx("div",{ref:i,className:"h-4"})]}),o.jsx("div",{onClick:x,className:W("fixed sm:hidden bottom-[88px] rounded-[50%] border-[2px] w-[40px] h-[40px] border-primary cursor-pointer text-primary bg-white z-10",g?"right-[402px] lg:right-[386px]":"right-10 lg:right-6","scroll-button-wrapper",m?"block":"hidden"),children:o.jsx("div",{className:"flex size-full items-center justify-center",children:a})})]})},_0=e=>{const t={};return e.choices?.[0]?.delta?.content&&(t.content=e.choices[0].delta.content),e.choices?.[0]?.delta?.custom_content&&(t.custom_content=e.choices[0].delta.custom_content),e.choices?.[0]?.delta?.role&&(t.role=e.choices[0].delta.role),e.id&&(t.responseId=e.id),t},I0="local",R0=e=>!e.permissions?.includes(Ie.SharePermission.WRITE)&&!L0(e),P0=(e,t)=>ud(e)!==t,L0=e=>ud(e)===I0,ud=e=>e.id.split("/")[0],O0=(e,t)=>ia([...t?.messages||[],e]),ia=e=>[...e].map(t=>{const n={role:t.role,content:t.content};return(t.role===Ie.Role.Assistant||t.role===Ie.Role.System)&&t.custom_content!=null&&(t.custom_content.state!=null||t.custom_content.attachments!=null||t.custom_content.form_schema!=null)&&(n.custom_content={},t.custom_content.state!=null&&(n.custom_content.state=t.custom_content.state),t.custom_content.attachments!=null&&(n.custom_content.attachments=H0(t.custom_content.attachments)),t.custom_content.form_schema!=null&&(n.custom_content.form_schema=t.custom_content.form_schema)),t.role===Ie.Role.User&&t.custom_content&&(n.custom_content=t.custom_content),n}),F0=(e,t)=>{const n=t?.messages,s=n?.findIndex(r=>e.id===r.id);return ia(n?.slice(0,s)||[])},V0=(e,t)=>{const n=t?.messages,s=n?.findIndex(r=>e.id===r.id);return ia([...n?.slice(0,s)||[],e])};function H0(e){return e.map(t=>({type:t.type,title:t.title,data:t.data,url:t.url,reference_type:t.reference_type,reference_url:t.reference_url}))}const U0=(e,t,n,s)=>{if(!n||t)return null;const r={id:`msg-${Date.now()}`,role:Ie.Role.User,content:e,timestamp:Date.now()};if(s){const a=s===vn.COMPLETE?cn.COMPLETION:cn.CHOICE;r.custom_content={form_value:{[a]:s}}}return r},G0=(e,t,n)=>`/${t}${n}/${ne.getConversationNavPath(e?.folderId,e?.id)}`,B0=(e,t,n)=>{const s=`${t}/${n}`,r=we.generateConversationId({folderId:s,name:e?.name});return{...e,folderId:s,id:r}},q0=(e,t)=>{const n=e.lastIndexOf(".");return n<=0?`${e}-${t}`:`${e.slice(0,n)}-${t}${e.slice(n)}`},z0=(e,t,n)=>{const s=e.split("/");if(s[0]!=="files"||s.length<3)return e;const r=s.at(-1)??"file",a=q0(r,n);return["files",t,...s.slice(2,-1),a].join("/")},W0=async({conversation:e,bucket:t,getFileBlob:n,putFile:s})=>{const r=ne.getConversationAttachmentUrls(e),a=Date.now();if(!r.length)return e;const i=await Promise.all(r.map(async c=>{const l=z0(c,t,`${a}`);if(l===c)return[c,l];const d=await n(c);return await s(l,d),[c,l]}));return ne.replaceConversationAttachmentUrls(e,Object.fromEntries(i))},$0="AbortError",K0=({error:e,statusMessages:t})=>{if(e){if(e.type===we.DIAL_ERROR_TYPES.RATE_LIMIT_EXCEEDED){const n=e.exceeded_limit?.length?t.getExceededLimitsMessage(e.exceeded_limit):e.display_message??"";throw new ne.HttpError({message:e.message,displayMessage:n,code:e.type,status:e.status??ne.HTTP_ERROR_CODES.TOO_MANY_REQUESTS,details:{kind:we.ERROR_CONTEXT_KIND.RATE_LIMIT,occurredAt:new Date().toISOString(),retryAfterSeconds:Number(e.retry_after??"")}})}throw new ne.HttpError({message:e.message,status:e.status??ne.HTTP_ERROR_CODES.BAD_REQUEST,code:e.code})}},J0=({error:e,statusMessages:t})=>{if(e.code===we.DIAL_ERROR_TYPES.RATE_LIMIT_EXCEEDED){const n=e;return{errorMessage:n.displayMessage??n.message,errorContext:n.details}}return e.code===we.DIAL_ERROR_CODES.CONTENT_FILTER?{errorMessage:t.contentFilterError??e.message}:{errorMessage:e.status===ne.HTTP_ERROR_CODES.SERVICE_UNAVAILABLE?t.serverOverloaded:t.serverError}},xl=(e,t)=>{const n=e.customViewState??{},s=n[we.CUSTOM_VIEW_STATE_KEY]??{};return{...e,customViewState:{...n,[we.CUSTOM_VIEW_STATE_KEY]:{...s,errorContext:t}}}},Y0=()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}},Z0=({conversationKey:e,conversation:t,actions:n,messageStyles:s,attachmentsStyles:r,inputMessageStyles:a,shareConversationProps:i,showConversationHeaderAdvancedView:c=!0,formattingSettings:l,metadataSettings:d,expandStagesIcon:u,locale:h,conversationsRoute:m,token:p,titles:g,dataQuery:x,handleInvalidStreaming:v,onConversationNotFound:w,setConversation:C,setConversations:b,openUrl:y,messageActionsIcons:N,messageActionsTitles:M,editMessageTitles:A,scrollBottomIcon:S,isFinalMessage:_,limitMessages:E,attachmentsConfig:T,headerRightSlot:k,children:I})=>{const[L,H]=f.useState(null),[G,Y]=f.useState(!1),[O,$]=f.useState(!0),{isStreaming:K,setIsStreaming:Z}=Al(),{isOpenedAdvancedView:se}=qe(),{setCrossDatasetAttachmentsState:ge}=Ln(),{isCrossDatasetModeOn:he}=Ue(),{isAgentAvailable:xe}=j.useAgentAvailability(),{statusMessages:F}=Lr(),{onboardingFileSchema:J,onboardingFilePath:ue,onboardingFileName:de,isShowOnboarding:me,setOnboardingFileSchema:re}=Ze();f.useEffect(()=>{J&&n.putOnboardingFile?.(de,ue,J)},[n,J,de,ue]),f.useEffect(()=>{se&&J?.lastDisplayedElement===Fe.OPEN_ADVANCED_VIEW&&re?.(ou(J))},[n,se,re,J]);const Q=f.useCallback(()=>{y(`/${h}${m}`)},[h,m,y]),U=f.useCallback(async()=>{try{const{bucket:V}=await n.getBucket(),B=n.getFileBlob&&n.putFile?await W0({conversation:t,bucket:V,getFileBlob:n.getFileBlob,putFile:n.putFile}):t,ee=B0(B,V,h);await n.createConversation(ee,h);const R=await n.getConversations(h);b(ne.cleanConversationNames(R)),y(G0(ee,h,m))}catch(V){console.error("Failed to save conversation:",V)}},[n,t,m,h,y,b]),q=f.useCallback(async V=>{try{await n.updateConversation(decodeURI(e),{name:V.name,messages:V.messages,customViewState:V.customViewState})}catch(B){console.error("Failed to save conversation:",B)}},[n,e]),fe=f.useCallback((V,B)=>{if(!t)return;const ee=ad(t.messages,B,V);if(!ee)return;const R={...t,messages:ee};C(R),q(R)},[t,C,q]),ae=f.useCallback(V=>{C(B=>B?{...B,messages:[...B?.messages||[],V]}:null)},[C]),oe=f.useCallback(()=>{const V={id:`msg-${Date.now()+1}`,role:Ie.Role.Assistant,content:"",timestamp:Date.now()};return C(B=>B?{...B,messages:[...B.messages,V]}:null),V},[C]),pe=f.useCallback((V,B)=>{const ee=we.mergeMessages?.(V,[B]);if(ee)return C(R=>R?{...R,messages:R.messages.map(P=>P.id===V.id?{...ee}:P)}:null),ee},[C]),Se=f.useCallback((V,B)=>{t?.model?.id&&(n.rateResponse(V,B===Ie.LikeState.Liked,t.model.id),t.messages=t.messages.map(ee=>ee.responseId===V?Rr.merge(ee,{like:B}):ee),q(t))},[n,t,q]),Ce=f.useCallback((V,B)=>{let ee=F.serverError,R,P;if(ne.isHttpError(V)){P=V;const z=J0({error:V,statusMessages:F});ee=z.errorMessage,R=z.errorContext}else P=new ne.HttpError({status:ne.HTTP_ERROR_CODES.INTERNAL_SERVER_ERROR,message:ee});return B&&(B=pe(B,{errorMessage:ee})),v?.(P),{assistantMessage:B,errorContext:R}},[v,F,pe]),ye=f.useCallback(async(V,B,ee)=>{const R=new AbortController;H(R);let P=V,z;if(!ee)return{assistantMessage:P,errorContext:z};const te=ee.custom_fields??{},_e={...te,configuration:{...te.configuration,timezone:Y0(),...he&&{merge_python_code:!0}}};return await we.streamChatResponse?.(encodeURI(ee.id),B,{model:ee.model,signal:R?.signal,onMessage:be=>{K0({error:be.error,statusMessages:F});const De=_0(be);(De.content||De.role||De.responseId)&&(P=pe(P,De))},onError:be=>{if(!Ge(be))throw console.error("Streaming error:",be),be}},p,_e).catch(be=>{if(!Ge(be)){const{assistantMessage:De,errorContext:Ye}=Ce(be,P);P=De,z=Ye}}),{assistantMessage:P,errorContext:z}},[p,pe,Ce,F,he]),ce=f.useCallback(async(V,B,ee,R)=>{if(!B)return;let P=xl(B,R);P={...P,messages:[...B.messages],updatedAt:Date.now()},ee&&P.messages.push(ee),P.messages.push(V),await q(P)},[q]),Ee=f.useCallback(V=>{C(B=>B&&xl(B,V))},[C]),Pe=f.useCallback((V,B)=>{C(ee=>ee?{...ee,messages:ee.messages.filter(R=>R.id!==B.id)}:null)},[C]),ze=f.useCallback(()=>{L&&!L.signal.aborted&&L.abort()},[L]),Ge=V=>V?.name===$0,Ve=f.useCallback(async(V,B,ee,R,P,z=!0)=>{Ge(P)?await ce(R??ee,V,z?B:void 0):Pe(P,B)},[ce,Pe]),Xe=f.useCallback(async(V,B,ee)=>{if(!B||!V)return;const R=U0(V,K,B,ee);let P,z;if(R){ae(R);try{Z(!0),P=oe();const te=O0(R,B),{assistantMessage:_e,errorContext:be}=await ye(P,te,B);Ee(be),z=_e,await ce(z,B,R,be)}catch(te){Ve(B,R,P,z,te)}finally{Z(!1)}}},[K,Z,ae,oe,ye,ce,Ve,Ee]),$e=f.useCallback(async(V,B,ee)=>{let R,P;try{Z(!0),R=oe();const{assistantMessage:z,errorContext:te}=await ye(R,V,B);P=z,Ee(te),await ce(P,B,void 0,te)}catch(z){Ve(B,ee,R,P,z,!1)}finally{Z(!1)}},[Z,ce,Ve,ye,oe,Ee]),Be=f.useCallback(async(V,B)=>{if(!B||!V)return;const ee=F0(V,B),R={...B,messages:B.messages.slice(0,ee.length)};C(P=>P?{...P,...R}:null),$e(ee,R,V)},[C,$e]),{isLastMessageFailed:ot,regenerateLastMessage:X}=f.useMemo(()=>{const V=t?.messages?.at(-1);return{isLastMessageFailed:!!V?.errorMessage,regenerateLastMessage:V&&(()=>Be(V,t))}},[t,Be]),ve=f.useCallback(async(V,B)=>{if(!B||!V)return;const ee=V0(V,B),R={...B,messages:[...B.messages.slice(0,ee.length-1),V]};C(P=>P?{...P,...R}:null),$e(ee,R,V)},[C,$e]);f.useEffect(()=>{Vo(),ge();async function V(){try{$(!0);const{bucket:B}=await n.getBucket(),ee=await n.getConversation(decodeURI(e));C(ee),Y(R0(ee)&&P0(ee,B)),(ee.messages.length===0||ee?.messages?.[0]?.role===Ie.Role.Assistant&&ee?.messages?.length===1)&&Xe(ee.prompt,ee)}catch{Y(!0),w?.()}finally{$(!1)}}return e&&V(),()=>{Vo()}},[e]);const ie=f.useMemo(()=>({getFile:n.getFile,putOnboardingFile:n.putOnboardingFile,getDataSet:n.getDataSet,getDataSetData:n.getDataSetData,getConstraints:n.getConstraints,updateCurrentDataQuery:n.updateCurrentDataQuery,updateDataQueries:n.updateDataQueries,updateDatasets:n.updateDatasets,downloadDataSet:n.downloadDataSet}),[n]);if(O)return o.jsx(j.Loader,{});const le=t?.customViewState?.[we.CUSTOM_VIEW_STATE_KEY],Le=()=>{if(le?.errorContext?.kind===we.ERROR_CONTEXT_KIND.RATE_LIMIT&&we.isRateLimitStillActive(le.errorContext)){const V=we.getRateLimitRestoreDate(le.errorContext);if(V){const B=we.formatDateTime(V);return o.jsx(j.InlineAlert,{type:j.InlineAlertType.Info,children:F.getAssistantRestoreMessage(B.date,B.time)})}}return xe?o.jsx(kl,{onSendMessage:V=>Xe(V,t),onStopStreaming:ze,inProcess:K,sendMessageIcon:a.sendMessageIcon,retryIcon:a.retryIcon,placeholder:g?.askAnything??"Ask anything...",containerClasses:"mt-4",inputClasses:"border-neutrals-600 mr-2",isLastFailed:ot,onRetryFailed:X}):o.jsx(j.InlineAlert,{type:j.InlineAlertType.Error,children:F.assistantUnavailable})};return o.jsx(Cn,{styles:{titles:g,messageStyles:s,attachmentsStyles:r,formattingSettings:l,messageActionsIcons:N,messageActionsTitles:M,editMessageTitles:A,expandStagesIcon:u,scrollBottomIcon:S,limitMessages:E,attachmentsConfig:T},children:o.jsxs("div",{className:W("h-full flex flex-col bg-white conversation-view-wrapper",se&&!c&&"p-4"),children:[se&&!c?null:o.jsx(Wl,{conversation:t,locale:h,isOpenedAdvancedView:se,isShowShareButton:!G&&!me,shareConversationProps:i,rightSlot:k}),o.jsxs("div",{className:"flex min-h-0 min-w-0 w-full flex-1",children:[o.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[o.jsx("div",{className:W("flex-1 min-h-0 flex flex-col items-end scroll-hidden-container",s?.messagesWrapperClass),children:o.jsx(k0,{messages:t?.messages||[],actions:ie,isStreaming:K,isReadOnly:G,metadataSettings:d,dataQuery:x,locale:h,regenerateMessage:V=>Be(V,t),selectMessageToSend:(V,B)=>Xe(V,t,B),rateResponse:Se,editMessage:V=>ve(V,t),isReadOnlyConversation:G||me,conversationViewState:le,onCodeAttachmentUpdated:fe})}),me?null:G?o.jsx("div",{className:"mt-4 flex items-center justify-center",children:o.jsx(j.Button,{iconBefore:o.jsx(He.IconCopy,{width:20,height:20}),title:g?.duplicate??"Duplicate Chat",isSmallButton:!0,onClick:U,buttonClassName:W("text-button-secondary")})}):o.jsx("div",{className:W(a.inputContainerClass),children:Le()}),me&&_&&o.jsx(j.Button,{iconBefore:o.jsx(He.IconPlus,{width:24,height:24}),title:g?.onboardingFooterLink,onClick:Q,isSmallButton:!0,buttonClassName:"text-button-secondary self-center mb-3"}),I]}),!se&&o.jsx(Ou,{scope:"conversation"})]})]})})},X0=({conversationName:e,expandTitle:t,expandIcon:n,onExpand:s})=>o.jsxs("div",{className:"flex h-full w-[51px] shrink-0 flex-col items-center border border-neutrals-400 bg-white",children:[o.jsx("button",{type:"button",className:"mt-[84px] flex size-9 items-center justify-center text-primary","aria-label":t,title:t,onClick:s,children:n}),o.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center overflow-hidden pb-[88px] pt-[72px]",children:o.jsx("span",{className:"h3 min-h-0 flex-1 rotate-180 truncate text-center text-neutrals-1000 [writing-mode:vertical-rl]",title:e,children:e})})]});exports.AdvancedView=b0;exports.AdvancedViewProvider=wd;exports.CUSTOM_CHOICE_ID=vn;exports.ChartingIcon=un;exports.ChatFooter=Yl;exports.ChatMessagesProvider=bd;exports.ChatOnboardingFooter=Jl;exports.CollapsedChatPanel=X0;exports.ConversationView=Z0;exports.ConversationViewFeatureTogglesProvider=jh;exports.ConversationViewMessagesProvider=xd;exports.ConversationViewSidePanelProvider=ag;exports.ConversationViewStylesProvider=Cn;exports.ConversationWelcome=Bd;exports.CrossDatasetAttachmentsProvider=w0;exports.CustomContentProperties=cn;exports.DatasetDimensionsMetadataMapProvider=X1;exports.OnboardingProvider=yd;exports.STAGE_STATUS=jl;exports.useAdvancedView=qe;exports.useChatMessages=Al;exports.useConversationViewFeatureToggles=Ue;exports.useConversationViewMessages=Lr;exports.useConversationViewSidePanelOptional=wt;exports.useConversationViewStyles=Me;exports.useCrossDatasetAttachments=Ln;exports.useDatasetDimensionsMetadataMap=Rn;exports.useDatasetDimensionsMetadataMapOptional=Pn;exports.useOnboarding=Ze;
13
+ \`\`\``}))}).catch(d=>console.error("Error refreshing python attachment:",d))}const Xv="Data Grid",Qv="Data",e0="Chart",t0=e=>({title:e||Xv,type:ve.AttachmentType.CUSTOM_DATA_GRID}),sd=e=>({title:e||e0,type:ve.AttachmentType.CUSTOM_CHART}),n0=e=>({title:e||Qv,type:ve.AttachmentType.CROSS_DATASET_GRID});function rd(e,t,n,s,r,a,i,c,l,d=!1,u,h=!1){const[m,p]=f.useState(),[g,x]=f.useState(),[v,w]=f.useState(),[C,b]=f.useState(),[y,N]=f.useState(t0(i?.dataGrid)),[E,T]=f.useState(sd(i?.chart)),[S,_]=f.useState(!1),[A,M]=f.useState([]),[k,R]=f.useState([]),[L,z]=f.useState([]),[U,Z]=f.useState(!1),[O,K]=f.useState(!1),J=f.useRef(0),[X,Q]=f.useState({startPeriod:null,endPeriod:null}),{getConstraints:pe,getDataSet:we,getDataSetData:se,putOnboardingFile:V,getPythonAttachment:W}=e,ce=f.useCallback(F=>{if(!F)return;const G=D.getDimensions(F);x(F.dataflows?.[0]||void 0),b(F||void 0),R([...G?.dimensions||[],...G?.timeDimensions||[]])},[]),fe=f.useCallback(async F=>{const G=Ht(D.getFiltersDtoFromDataQuery(F));try{const re=(await ot(pe,rt(F.urn,G),()=>pe(F.urn,G)))?.data?.dataConstraints||[];w(re)}catch{w([])}},[pe]),de=f.useCallback(async F=>{const G=l?{data:l}:await ot(we,rt(F.urn),()=>we(F.urn));if(G?.data){const oe=D.getDimensions(G.data);ce(G.data);const re=oe?.dimensions==null?null:D.getTimeSeriesFilterKey(oe?.dimensions,F.filters??[]),ae=yc(F,oe);ot(se,rt(F.urn,{filterKey:re,timeFilter:ae}),()=>se(F.urn,{filterKey:re,timeFilter:ae})).then(ue=>{K(!0),p(ue||void 0),z(D.getStructureDimensions(ue))}).finally(()=>Z(!1))}},[ce,we,se,l]);f.useEffect(()=>{ce(l)},[ce,l]),f.useEffect(()=>{async function F(G){Z(!0);try{await Promise.all([...h?[]:[fe(G)],de(G)])}catch(oe){console.error("Error loading dataset details",oe)}}n!=null&&!(d&&!l)?F(n):n!=null&&d&&Z(!0)},[n,l,d,fe,de,h]);const Ne=f.useCallback((F,G,oe)=>{try{Z(!0),w(G);const re=oe?.find(ae=>ae.id===D.TIME_PERIOD)?.timeRange;if(re&&Q(re),ot(se,rt(n?.urn||"",F),()=>se(n?.urn||"",F)).then(ae=>{K(!0),p(ae||void 0),z(D.getStructureDimensions(ae))}).finally(()=>Z(!1)),W&&n&&oe){const ae=Tc(n,oe),ue=c?.find(he=>he.type===ve.AttachmentType.MARKDOWN&&he.data?.includes("```python"))?.title;nd({getPythonAttachment:W,dataQueries:[ae],requestIdRef:J,codeTitle:i?.codeSamples||"Python Code",markdownTitle:ue??n.urn,setCodeAttachments:M,onCodeAttachmentUpdated:u})}}catch(re){console.error("Error loading dataset data",re)}},[n,se,W,i,c,u]);f.useEffect(()=>{if(C!=null&&m!=null&&v?.length){K(!0);const F=Bt(()=>{N(G=>({...G,...Jv(C,m,n,t,s,a,r,i,V,v,X)})),K(!1)});return()=>{F(),K(!1)}}(m==null||v!==void 0)&&K(!1)},[C,m,i,t,s,n,a,r,v,X,V]),f.useEffect(()=>{if(C==null||m==null)return;const F=Vv(C,m,n,t,r);return T(G=>({...G,charting_data:void 0,getChartingData:F})),_(!1),Bt(()=>{try{_(Xu(F()))}catch(G){console.error("Error evaluating chart plottability",G),_(!1)}})},[C,m,n,t,r]),f.useEffect(()=>{if(c?.length){const F=td(c,n?.urn,i?.codeSamples);F.length>0&&M(F)}},[c,i,n]);const Te=f.useMemo(()=>[y,...S?[E]:[],...A],[y,E,A,S]);return{dataMessage:m,structures:C,dataset:g,dimensions:k,structureDimensions:L,onFiltersChange:Ne,constraints:v,isLoadingGridData:U||O,dataSetAttachments:Te}}function ad(e,t,n){let s=-1;if(n)s=e.findIndex(i=>i.id===n);else for(let i=e.length-1;i>=0;i--)if(e[i].role===Pe.Role.System){s=i;break}if(s===-1||e[s].role!==Pe.Role.System)return null;const a=[...(e[s].custom_content?.attachments??[]).filter(i=>!(i.type==="text/markdown"&&i.data?.includes("```python"))),t];return e.map((i,c)=>c===s?{...i,custom_content:{...i.custom_content,attachments:a}}:i)}const wl=async(e,t)=>{const n=new Map,s=D.getFiltersDtoMapFromDataQuery(e);return(await Promise.allSettled(e.map(async a=>{const i=Ht(s?.get(a.urn)||[]);return{urn:a.urn,response:await ot(t,rt(a.urn,i),()=>t(a.urn,i))}}))).forEach(a=>{if(a.status==="fulfilled"){const i=a.value.response?.data?.dataConstraints;Array.isArray(i)&&n.set(a.value.urn,i)}}),n},s0=()=>({datasetsMap:new Map,dataMessagesMap:new Map,structuresMap:new Map,dimensionsMap:new Map,structureDimensionsMap:new Map}),r0=async(e,t,n,s,r)=>{const a=s0();await Promise.allSettled(e.map(async c=>{const l=await ot(t,rt(c.urn),()=>t(c.urn));if(l?.data){const d=D.getDimensions(l.data);a.datasetsMap?.set(c?.urn,l?.data?.dataflows?.[0]),a.structuresMap?.set(c?.urn,l?.data),a.dimensionsMap?.set(c?.urn,[...d?.dimensions||[],...d?.timeDimensions||[]])}}));const i=await r?.(a);return await Promise.allSettled(e.map(async c=>{const l=a.structuresMap?.get(c.urn);if(!l||i&&!i.has(c.urn))return;const d=D.getDimensions(l),u=d?.dimensions==null?null:D.getTimeSeriesFilterKey(d?.dimensions,c.filters??[]),h=yc(c,d);await id(c,i?.get(c.urn)??{filterKey:u,timeFilter:h},n).then(({dataMessage:m,structureDimensions:p})=>{a?.dataMessagesMap?.set(c.urn,m),a?.structureDimensionsMap?.set(c.urn,p||[])}).catch(()=>{a?.structureDimensionsMap?.set(c.urn,[])}).finally(()=>s(!1))})),a},id=async(e,t,n)=>{const s=await ot(n,rt(e.urn,t),()=>n(e.urn,t));return{dataMessage:s,structureDimensions:D.getStructureDimensions(s)}};function a0(e,t,n,s){return[o0(e,s),i0(e,t,n,s)]}function i0(e,t,n,s){const r=a=>{const i=a.data?.dataset?.urn;if(i==null)return"";const l=e.get(i)?.dataflows?.[0];return D.getLocalizedName(l,n)||""};return{headerName:s?.dataset||c1,field:ol,colId:ol,valueGetter:r,...St,tooltipValueGetter:a=>a.value,cellClass:Ct,cellRenderer:Su,cellRendererParams:{structuresMap:e,attributesDataMap:t,locale:n,titles:s}}}function o0(e,t){const n=s=>{const r=s.data?.dataset?.urn;return r==null?"":e.get(r)?.dataflows?.[0]?.agencyID||""};return{headerName:t?.agency||u1,field:ll,colId:ll,valueGetter:n,...St,tooltipValueGetter:s=>s.value}}function l0(e,t,n,s,r){return c0(e).sort((c,l)=>D.sortPeriods(c,l)).map(c=>({...u0(c,s,r),valueGetter:d=>d.data[d.column.getColId()]?.value?.[0]?.value||null,cellClass:Ct,cellRenderer:En,width:Et,cellRendererParams:{structuresMap:t,locale:n,titles:r}}))}function c0(e){const t=new Set;return e.forEach(n=>{if(n==null)return;D.getTimePeriods(n).forEach(r=>t.add(r))}),Array.from(t)}function u0(e,t=ne.defaultFormatNumbers,n){return{headerName:lc(e,n),colId:e,field:e,type:"numericColumn",suppressColumnsToolPanel:!0,sortable:!1,width:Et,cellClass:["justify-end","cell-with-meta"],valueFormatter:s=>ne.formatNumberBySign(s.value,t)}}function d0(e,t,n,s,r,a,i=tt.Compact){const c=new Map([...n.entries()].map(([h,m])=>[h,m?.data])),l=a0(e,c,s,r),d=C1(e,t,s,r,i),u=l0(n,e,s,a,r);return[Pp(e,c,s,r),...l,...d,...u,Du(void 0,void 0,s,void 0,r)]}function f0(e,t,n,s,r){const a=[];return n.filter(i=>!i.disabled).forEach(i=>{const c=i.urn,l=t.get(c),d=e.get(c);if(l==null||d==null)return;const u=aa(l,d,i,s,r),h=D.getLocalizedName(d.dataflows?.[0],s);a.push(...u.map(m=>({...m,dataset:{urn:c},datasetTitle:h})))}),a}function h0(e,t,n,s,r,a,i,c,l,d,u,h=tt.Compact){const m=m0(e,t,n,s,r,a,i,c,l,d,u,h);return{title:l?.dataGrid||"Data",gridContent:m}}function m0(e,t,n,s,r,a,i,c,l,d,u,h=tt.Compact){return{columns:d0(e,n,t,r,l,a,h),data:f0(e,t,s,r,c)}}function p0(e,t,n,s,r){let a;return()=>(a??=g0(e,t,n,s,r),a)}function g0(e,t,n,s,r){const a=n.filter(i=>!i.disabled).flatMap(i=>{const c=e.get(i.urn),l=t.get(i.urn);return!c||!l?[]:[{title:D.getLocalizedName(c.dataflows?.[0],s),units:Qu(c,l,i,s,r).units}]});return{units:a.flatMap(i=>i.units),groups:a}}const v0=5e3;function od(e,t,n,s,r,a,i,c,l,d=tt.Compact,u){const h=Array.isArray(c)?c:void 0,[m,p]=f.useState(),[g,x]=f.useState(),[v,w]=f.useState(!1),[C,b]=f.useState(h?new Set(h):null),[y,N]=f.useState(!1),E=f.useRef(0),T=f.useRef(d),S=f.useRef(m),_=f.useRef(0),A=f.useRef(null),[M,k]=f.useState(n0(u?.dataGrid)),[R,L]=f.useState(sd(u?.chart)),[z,U]=f.useState(!1),[Z,O]=f.useState([]),{getConstraints:K,getDataSet:J,getDataSetData:X,getPythonAttachment:Q}=e,pe=f.useRef(n);pe.current=n;const we=f.useRef(h);we.current=h;const se=f.useMemo(()=>n?.map(F=>F.urn).join(",")??"",[n]),V=Rn(),{getDimensionsScheme:W}=V,ce=f.useCallback(async F=>{try{const G=await wl(F.map(ae=>({...ae,filters:[]})),K),oe=lm(F,G,V.map),re=oe===F?G:await wl(oe,K);return p(ae=>({...ae,constraintsMap:re})),re}catch{const G=new Map;return p(oe=>({...oe,constraintsMap:G})),G}},[V.map,K]),fe=f.useCallback(async(F,G)=>{const oe=await r0(F,J,X,w,async re=>{const ae=F.filter(he=>!he.disabled),ue=$o(ae,re,G,t,V.map);if(ue)return b(ue.compatibleUrns),ue.filterParamsMap});p(re=>({...re,...oe,constraintsMap:G??re?.constraintsMap}))},[V.map,J,X,t]),de=f.useCallback(F=>{const G=new Map;for(const oe of F)G.set(oe.urn,W(oe.urn));x(G)},[W]);f.useEffect(()=>{async function F(oe){const re=we.current;b(re?new Set(re):null),w(!0);try{de(oe);const ae=await ce(oe);await fe(oe,ae)}catch(ae){console.error("Error loading dataset details",ae)}finally{w(!1)}}const G=pe.current;G?.length&&F(G)},[se,ce,de,fe]),f.useEffect(()=>{if(i?.length){const F=td(i,void 0,u?.codeSamples);F.length>0&&O(F)}},[i,u]),f.useEffect(()=>()=>{A.current!==null&&clearTimeout(A.current)},[]),f.useEffect(()=>{const F=T.current!==d&&S.current===m;T.current=d,S.current=m;const{structuresMap:G,dataMessagesMap:oe,constraintsMap:re}=m??{};if(G!=null&&G.size>0&&oe!=null&&re!=null&&g!=null&&!v){F||N(!0);const ae=Bt(()=>{const ue=n?.filter(Me=>!Me.disabled),he=C??new Set((ue??[]).map(Me=>Me.urn)),je=Go(ue,he),Se=jt(G,he),ge=jt(oe,he),be=jt(g,he);k(Me=>({...Me,...h0(Se,ge,be,je,t,r,a,s,u,re,{},d)})),F||N(!1)});return()=>{ae(),F||N(!1)}}F||N(!1)},[m,n,t,r,a,s,u,g,v,C,d]),f.useEffect(()=>{const{structuresMap:F,dataMessagesMap:G}=m??{};if(F!=null&&F.size>0&&G!=null&&!v){const oe=n?.filter(Se=>!Se.disabled),re=C??new Set((oe??[]).map(Se=>Se.urn)),ae=Go(oe,re),ue=jt(F,re),he=jt(G,re),je=p0(ue,he,ae,t,s);return L(Se=>({...Se,charting_data:void 0,getChartingData:je})),U(!1),Bt(()=>{try{U(Xu(je()))}catch(Se){console.error("Error evaluating cross-dataset chart plottability",Se),U(!1)}})}},[m,n,t,s,v,C]);const Ne=f.useMemo(()=>[M,...z?[R]:[],...Z],[M,R,Z,z]),Te=f.useCallback((F,G,oe,re,ae)=>{try{w(!0);const ue=++_.current;A.current!==null&&(clearTimeout(A.current),A.current=null);const he=oe?.filter(ke=>!ke.disabled)??[],je=new Set(he.map(ke=>ke.urn));if(b(je),p(ke=>({...ke,constraintsMap:G})),!he.length){w(!1);return}const Se=re?Wc(he,re):void 0,ge=Se?he.map(ke=>({...ke,filters:Se.get(ke.urn)??[]})):he,Me=(G&&m?$o(ge,m,G,t,V.map):void 0)?.filterParamsMap??F,Le=new Map,Be=()=>{if(Le.size===0)return;N(!0);const ke=[...Le.values()];Le.clear(),p(Oe=>{const Ve=new Map(Oe?.dataMessagesMap),Qe=new Map(Oe?.structureDimensionsMap);return ke.forEach(({urn:Y,dataMessage:me,structureDimensions:ie})=>{Ve.set(Y,me),Qe.set(Y,ie||[])}),{...Oe,dataMessagesMap:Ve,structureDimensionsMap:Qe}})};A.current=setTimeout(()=>{A.current=null,ue===_.current&&Le.size>0&&(Be(),w(!1))},v0);const ze=he.map(ke=>id(ke,Me?.get(ke?.urn),X).then(({dataMessage:Oe,structureDimensions:Ve})=>{Le.set(ke.urn,{urn:ke.urn,dataMessage:Oe,structureDimensions:Ve})}));if(Promise.allSettled(ze).finally(()=>{ue===_.current&&(A.current!==null&&(clearTimeout(A.current),A.current=null),Be(),w(!1))}),Q&&he.length){const ke=he.map(Oe=>Tc(Oe,ae??re?.get(Oe.urn)??[]));nd({getPythonAttachment:Q,dataQueries:ke,requestIdRef:E,codeTitle:u?.codeSamples||"Python Code",markdownTitle:"Python Code",setCodeAttachments:O,onCodeAttachmentUpdated:l})}}catch(ue){console.error("Error loading dataset data",ue)}},[V.map,X,Q,t,l,m,u]);return{structureDataMaps:m,datasetDimensionsSchemesMap:g,isLoadingGridData:v||y,crossDatasetAttachments:Ne,activeDatasetUrns:C,onMultipleDataFiltersChange:Te}}const ld=f.createContext(void 0),C0={setCrossDatasetAttachmentsState:()=>{}},w0=e=>{if(!e)return"";try{return JSON.stringify({dataQueriesKey:e.dataQueriesKey,activeDatasetUrns:e.activeDatasetUrns,isLoading:!!e.isLoading,attachments:e.attachments})}catch{return JSON.stringify({dataQueriesKey:e.dataQueriesKey,activeDatasetUrns:e.activeDatasetUrns,isLoading:!!e.isLoading,attachmentsLength:e.attachments?.length??0})}},b0=({children:e})=>{const[t,n]=f.useState({}),s=f.useCallback(a=>{const i=w0(a);n(c=>c.signature===i?c:{...a,isLoading:!!a?.isLoading,signature:i})},[]),r=f.useMemo(()=>({...t,setCrossDatasetAttachmentsState:s}),[s,t]);return o.jsx(ld.Provider,{value:r,children:e})},Ln=()=>{const e=f.useContext(ld);return e===void 0?C0:e},x0=({attachmentsProps:e,actions:t,titles:n,shareConversationProps:s,metadataSettings:r,formattingSettings:a,locale:i,advanceViewStyles:c,getDatasetUpdatedTime:l,attachmentsConfig:d,datasetInfoOptions:u,limitMessages:h,...m})=>{const p=f.useMemo(()=>e.currentDataQuery?.urn??e.dataQueries?.[0]?.urn??"default",[e.currentDataQuery?.urn,e.dataQueries]),g=f.useMemo(()=>e?.dataQueries?.filter(ge=>!ge.disabled),[e?.dataQueries]),[x,v]=f.useState(tt.Compact),{isOpenedAdvancedView:w}=$e(),{activeDatasetUrns:C,dataQueriesKey:b,setCrossDatasetAttachmentsState:y}=Ln(),{isCrossDatasetModeOn:N,isMetadataInSidePanel:E}=We(),T=Rn(),S=!E,_=e.datasets??[],A=_.length>1&&!N,M=f.useMemo(()=>{const ge=m.filtersProps.conversation?.messages??[],be=hu(ge);return be>=0?ge[be].custom_content?.attachments:void 0},[m.filtersProps.conversation?.messages]),k=f.useMemo(()=>Uc(e.dataQueries),[e.dataQueries]),R=b===k?C:Hc(e.dataQueries,T.map),L=N&&!!e.dataQueries?.length,z=f.useRef(m.filtersProps.conversation);z.current=m.filtersProps.conversation;const U=f.useCallback(ge=>{const be=z.current;if(!be)return;const Me=ad(be.messages,ge);if(!Me)return;const Le={...be,messages:Me};m.filtersProps.setConversation?.(Le),m.filtersProps.updateConversation(decodeURI(m.filtersProps.conversationKey),{name:Le.name,messages:Le.messages})},[]),{dataMessage:Z,dataset:O,dimensions:K,structureDimensions:J,structures:X,dataSetAttachments:Q,onFiltersChange:pe,isLoadingGridData:we,constraints:se}=rd(t,i,e.currentDataQuery,a,e.styles?.chartingStyles,r,n,M,void 0,!1,U,L),V=S&&!!O,{structureDataMaps:W,crossDatasetAttachments:ce,activeDatasetUrns:fe,isLoadingGridData:de,onMultipleDataFiltersChange:Ne}=od(t,i,e.dataQueries,e.styles?.chartingStyles,a,r,M,R,U,x,n);f.useEffect(()=>{if(!N||!e.dataQueries?.length){y();return}W&&y({attachments:ce,dataQueriesKey:k,activeDatasetUrns:fe?Array.from(fe):void 0,isLoading:de})},[fe,e.dataQueries?.length,ce,k,N,de,y,W]);const[Te,F]=f.useState({filterKey:null,timeFilter:null}),[G,oe]=f.useState(),re=N?de:we,ae=N?ce:Q,ue=f.useCallback((ge,be,Me)=>{F(ge),oe(!0),pe(ge,be,Me)},[pe]),he=f.useCallback((ge,be,Me,Le,Be)=>{oe(!0),Ne(ge,be,Me,Le,Be)},[Ne]),je=f.useCallback(ge=>{ge&&t?.updateCurrentDataQuery(e?.dataQueries?.find(be=>be?.urn===ge)||e.currentDataQuery)},[t,e.currentDataQuery,e?.dataQueries]),Se=kr(d?.isExternaLinkIncludeFilters,Te,e.currentDataQuery||e.dataQueries?.[0],K);return o.jsx(Cn,{styles:{titles:n,attachmentsStyles:e.styles,formattingSettings:a,limitMessages:h,attachmentsConfig:d},children:o.jsx(g1,{currentUrn:p,structuresMap:W?.structuresMap,locale:i,dataQueries:g,gridViewMode:x,onGridViewModeChange:v,texts:{columnsDisplayTitle:e.styles?.columnsDisplayTitle,columnsSearchPlaceholder:e.styles?.columnsSearchPlaceholder,compactViewTitle:e.styles?.compactViewTitle,compactViewDescription:e.styles?.compactViewDescription,extendedViewTitle:e.styles?.extendedViewTitle,extendedViewDescription:e.styles?.extendedViewDescription},resetIcon:e.styles?.tableSettingsResetIcon,children:o.jsx(Hm,{children:o.jsxs("div",{className:"advanced-view flex h-full min-w-0 flex-1 flex-col",children:[o.jsx(mv,{locale:i,shareConversationProps:s,isShowShare:c?.isShowShare,conversation:m.filtersProps.conversation}),_.length?o.jsxs(o.Fragment,{children:[A&&o.jsx(vu,{datasets:_,initialSelectedDatasetUrn:e?.currentDataQuery?.urn,locale:i,selectDataset:je}),re&&!G?o.jsx(j.Loader,{}):o.jsxs(o.Fragment,{children:[V&&o.jsx(hv,{...u,locale:i,dataset:O,data:Z?.data,structures:X,metadataSettings:r,getDatasetUpdatedTime:l,externalLink:Se}),o.jsxs("div",{className:$("flex flex-1 min-h-0 overflow-auto",V&&"border-t border-neutrals-500"),children:[o.jsx("div",{className:$("flex-1 min-h-0 overflow-auto","advanced-view-filters"),children:o.jsx(fv,{...m,actions:t,attachments:ae,attachmentsDataQuery:e.currentDataQuery,dataQueries:e?.dataQueries,dimensions:K,isDataLoading:re,locale:i,filtersProps:{...m?.filtersProps,structureDimensions:J,structures:X,structureDataMaps:W,onFiltersChange:pe,onMultipleDataFiltersChange:he,initialConstraints:se},setIsFiltering:oe,filters:Te,onFiltersChange:ue})}),w&&o.jsx(Ou,{scope:"advanced"})]})]})]}):o.jsx(j.Loader,{})]})})})})};function y0(e,t,n,s,r,a){const[i,c]=f.useState([]),[l,d]=f.useState(),[u,h]=f.useState(!1),m=f.useRef(void 0);return f.useEffect(()=>{m.current=a},[a]),f.useEffect(()=>{let p=!0;async function g(x){h(!0);try{const v=await Promise.all(x.map(C=>ot(e,rt(C.urn),()=>e(C.urn))));if(!p)return;const w=v?.map(C=>C?.data?.dataflows?.[0])?.filter(C=>!!C)||[];c(w),t(w),n(x),s(x.find(C=>C.urn===m.current?.urn)??x[0]),d(new Map(v?.map(C=>[D.generateShortUrn(C?.data?.dataflows?.[0]?.id,C?.data?.dataflows?.[0]?.version,C?.data?.dataflows?.[0]?.agencyID),C?.data])))}catch(v){console.error("Error loading datasets",v)}finally{p&&h(!1)}}if(!r?.length){h(!1);return}return g(r),()=>{p=!1}},[r,e,s,n,t]),{datasets:i,datasetStructuresMap:l,isLoading:u}}function bl(e){const t=e?.filter(n=>du(n));if(t?.every(n=>!!n?.data))return t?.map(n=>({title:n?.title,...D0(S0(n?.data))}))}function S0(e){if(e)try{return JSON.parse(e)}catch(t){console.error("Invalid JSON:",t)}return null}function D0(e){return{...e,filters:e?.filters?.map(t=>({...t,componentCode:t?.component_code||t?.componentCode})),metadata:{datasetUrl:e?.metadata?.datasetUrl,countryDimension:e?.metadata?.country_dimension||e?.metadata?.countryDimension,indicatorDimensions:e?.metadata?.indicator_dimensions||e?.metadata?.indicatorDimensions,timePeriodDimension:e?.metadata?.timePeriodDimension,keyDimensionIdsInDsdOrder:e?.metadata?.keyDimensionIdsInDsdOrder}}}var cd=(e=>(e.COMPLETED="completed",e))(cd||{});const T0=({stage:e,stageRef:t,isCurrentStage:n})=>o.jsxs("div",{ref:t,className:"message-stage relative flex pb-8 last:mb-8 last:pb-0",children:[o.jsx("span",{className:"message-stage-line absolute h-full border-l"}),o.jsx(qe.IconPointFilled,{className:"message-stage-indicator z-10 flex shrink-0"}),o.jsxs("div",{className:"ml-2 w-full",children:[o.jsxs("div",{className:$("flex gap-2 items-center",e?.content&&"mb-4"),children:[n&&o.jsx(j.Loader,{}),o.jsx("h3",{className:"message-stage-name",children:e?.name})]}),o.jsx("div",{className:"prose max-w-full break-words",children:o.jsx(yl,{remarkPlugins:[Sl],components:{strong:s=>o.jsx("strong",{className:"text-neutrals-1000",...s}),a:({href:s,children:r,...a})=>o.jsx("a",{href:s,target:"_blank",rel:"noreferrer",...a,children:r}),h1:({children:s,...r})=>o.jsx("h1",{className:"h1 text-neutrals-1000",...r,children:s}),h2:({children:s,...r})=>o.jsx("h2",{className:"h2 text-neutrals-1000",...r,children:s}),h3:({children:s,...r})=>o.jsx("h3",{className:"h3 text-neutrals-1000",...r,children:s}),h4:({children:s,...r})=>o.jsx("h4",{className:"h4 text-neutrals-1000",...r,children:s}),h5:({children:s,...r})=>o.jsx("h5",{className:"h5 text-neutrals-1000",...r,children:s}),code:s=>o.jsx("code",{className:"text-neutrals-900",...s}),pre:s=>o.jsx("pre",{className:"border border-neutrals-600 bg-neutrals-100",...s})},children:e?.content})})]})]}),M0=({stages:e,expandIcon:t,processingTitle:n})=>{const[s,r]=f.useState(),[a,i]=f.useState(),c=f.useRef(null),l=f.useRef(null);f.useEffect(()=>{i(e?.filter(u=>u?.status!==cd.COMPLETED)?.at(-1))},[e]),f.useEffect(()=>{s&&l?.current?.scrollIntoView({block:"nearest",behavior:"smooth"})},[s]),f.useEffect(()=>{const u=c.current;let h;if(!u)return;const m=new IntersectionObserver(([p])=>{const g=p?.boundingClientRect?.top;h&&!p?.isIntersecting&&g<h&&r(!1),h=g},{threshold:0});return m.observe(u),()=>m.disconnect()},[]);const d=()=>{r(u=>!u)};return o.jsxs("div",{className:"message-stages",ref:c,children:[o.jsxs("div",{className:$("message-stages-header inline-flex max-w-full items-center cursor-pointer",!a?.name&&"default-header"),onClick:d,children:[o.jsx("p",{className:"message-stages-title truncate",children:a?.name||n||"Processing..."}),o.jsx("i",{className:$("message-stages-expand-icon",s&&"rotated"),children:t})]}),s&&e&&o.jsx("div",{className:"flex flex-col",children:e?.map(u=>o.jsx(T0,{stage:u,stageRef:a?l:null,isCurrentStage:u?.index===a?.index},u.index))})]})},A0=2e3,E0=({message:e,regenerateMessage:t,messageActionsIcons:n,rateResponse:s,isStreaming:r=!1,isReadOnly:a=!1,isRegenerateAvailable:i=!1})=>{const{messageActionsTitles:c}=De(),l=n?.copy,d=n?.copied,u=n?.regenerate,h=n?.thumbUp,m=n?.thumbDown,p=n?.thumbPressed,[g,x]=f.useState(e.like??Pe.LikeState.NoState),[v,w]=f.useState(!1),C=f.useRef(null),{isAgentAvailable:b}=j.useAgentAvailability();f.useEffect(()=>()=>{C.current&&clearTimeout(C.current)},[]);const y=E=>{e.responseId&&(x(E),s(e.responseId||"",E))},N=()=>{navigator.clipboard.writeText(e.content),w(!0),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{w(!1)},A0)};return o.jsxs("div",{className:$("message-actions","flex gap-x-2 pt-2"),children:[l&&o.jsx("p",{onClick:N,title:c?.copy,children:v&&d?d:l}),i&&u&&!a&&!r&&o.jsx("p",{onClick:b?()=>t?.(e):void 0,"aria-disabled":!b,title:c?.regenerate,className:$(!b&&"opacity-50 !cursor-not-allowed pointer-events-none"),children:u}),h&&!a&&g!==Pe.LikeState.Disliked&&(g===Pe.LikeState.NoState?o.jsx("p",{onClick:()=>y(Pe.LikeState.Liked),title:c?.like,children:h}):o.jsx("p",{title:c?.like,children:p})),m&&!a&&g!==Pe.LikeState.Liked&&(g===Pe.LikeState.NoState?o.jsx("p",{onClick:()=>y(Pe.LikeState.Disliked),title:c?.dislike,children:m}):o.jsx("p",{className:"rotate-180",title:c?.dislike,children:p}))]})},N0=({message:e,onEditClick:t,messageActionsIcons:n,isStreaming:s=!1,isReadOnly:r=!1})=>{const a=n?.copy,i=n?.edit,{isAgentAvailable:c}=j.useAgentAvailability();return o.jsxs("div",{className:$("message-actions","flex gap-x-2 pt-2 ml-12"),children:[a&&o.jsx("p",{onClick:()=>navigator.clipboard.writeText(e.content),children:a}),i&&!s&&!r&&o.jsx("p",{onClick:c?t:void 0,className:$(!c&&"opacity-50 !cursor-not-allowed pointer-events-none"),"aria-disabled":!c,children:i})]})},j0=({content:e,textColorClass:t,onCancel:n,onEditApply:s,editMessageTitles:r})=>{const{isOpenedAdvancedView:a}=$e(),i=f.useRef(null);f.useEffect(()=>{const l=i.current;c(),l&&(l.focus(),l.setSelectionRange(l.value.length,l.value.length))},[]);const c=()=>{const l=i.current;l&&(l.style.height="auto",l.style.height=l.scrollHeight+"px")};return o.jsxs("div",{className:$("max-w-none break-words",a?"body-2":"body-1",t),children:[o.jsx("textarea",{ref:i,className:"w-full resize-none overflow-hidden bg-neutrals-300 outline-none",defaultValue:e,onInput:c}),o.jsxs("div",{className:$("flex gap-x-2 items-center","edit-buttons-wrapper"),children:[o.jsx(j.Button,{buttonClassName:"text-button-secondary small-icon-button",title:r?.cancel,isSmallButton:!0,onClick:n}),o.jsx(j.Button,{buttonClassName:"text-button-primary small-icon-button",title:r?.send,isSmallButton:!0,onClick:()=>s(i.current?.value||"")})]})]})},k0=({message:e,previousMessage:t,actions:n,dataQuery:s,isStreaming:r=!1,isCurrentMessageStreaming:a=!1,showAdvancedView:i,locale:c,metadataSettings:l,onAdvancedViewOpen:d,regenerateMessage:u,selectMessageToSend:h,rateResponse:m,editMessage:p,isReadOnlyConversation:g,isLastNotUserMessage:x,onCodeAttachmentUpdated:v})=>{const{messageStyles:w,attachmentsStyles:C,formattingSettings:b,messageActionsIcons:y,editMessageTitles:N,expandStagesIcon:E,titles:T}=De(),[S,_]=f.useState(),[A,M]=f.useState(),[k,R]=f.useState([]),[L,z]=f.useState([]),[U,Z]=f.useState(),[O,K]=f.useState(!1),{isCrossDatasetModeOn:J}=We(),X=Rn(),Q=e.role===Pe.Role.User,pe=e.role===Pe.Role.System,{datasets:we,datasetStructuresMap:se,isLoading:V}=y0(n.getDataSet,n.updateDatasets,n.updateDataQueries,n.updateCurrentDataQuery,S,s),[W,ce]=f.useState(!1),[fe,de]=f.useState([]);f.useEffect(()=>{M(S?.[0])},[S]);const Ne=J&&!!S?.length,Te=f.useCallback(ie=>{e.id&&v?.(e.id,ie)},[e.id,v]),{dataSetAttachments:F,dimensions:G,isLoadingGridData:oe}=rd(n,c,A,b,C?.chartingStyles,l,T,e.custom_content?.attachments,A?se?.get(A.urn):void 0,V,Te,Ne),re=f.useMemo(()=>Hc(S,X.map),[S,X.map]),{crossDatasetAttachments:ae,isLoadingGridData:ue}=od(n,c,S,C?.chartingStyles,b,l,e.custom_content?.attachments,re,Te,void 0,T),{isOpenedAdvancedView:he}=$e(),{attachments:je,dataQueriesKey:Se,isLoading:ge}=Ln(),be=f.useMemo(()=>Uc(S),[S]),Me=J&&!!i&&je!=null&&Se===be,Le=Me?je:ae,Be=f.useMemo(()=>J?Me?ge:ue:oe,[J,ue,oe,ge,Me]),ze=()=>{Q&&ce(!0)},ke=()=>{ce(!1)},Oe=ie=>{ke(),p?.({...e,content:ie})},Ve=f.useCallback(ie=>{ie&&(M(S?.find(le=>le?.urn===ie)),Z(void 0))},[S]);f.useEffect(()=>{const ie=e.custom_content?.form_schema?.properties,le=x?ie?.choice?.oneOf||ie?.completion?.oneOf:[];de(le||[])},[e,x]),f.useEffect(()=>{const ie=Qo(e),le=bl(ie),He=ie.filter(H=>Kr(H));_(le),z(He)},[e]),f.useEffect(()=>{K(S!=null&&S.length>0)},[S]),f.useEffect(()=>{s?.urn&&S?.some(ie=>ie?.urn===s.urn)&&Z(s.urn)},[s,S]),f.useEffect(()=>{if(e?.role===Pe.Role.System&&t){const ie=Qo(t),le=bl(ie)||[];S&&le&&se&&R(fp(le,S,se,c,X.map))}},[S,A,se,X.map,G,c,e?.role,t]);const Qe=f.useCallback(()=>!Q&&w?.systemMessageIcon&&!(he&&!a)?o.jsx("div",{className:$("flex-shrink-0 rounded-full flex items-center justify-center w-[44px] h-[44px]",a?"text-white absolute":"text-neutrals-400"),children:w.systemMessageIcon}):null,[Q,w?.systemMessageIcon,he,a]),Y=f.useMemo(()=>o.jsx(Ju,{actions:n,attachments:O?J?Le:F:L,onAdvancedViewOpen:d,isDataSetAttachments:O,datasets:we,initialSelectedDatasetUrn:U,showAdvancedView:i,isSystemAttachments:pe,isDataLoading:Be,currentDataQuery:A,dataQueries:S,attachmentInfoList:k,locale:c,dimensions:G,selectDataset:Ve}),[n,O,F,L,Le,we,U,i,pe,Be,A,S,k,c,G,Ve,d,J]);if(pe&&he)return null;const me=a?null:Q?W?null:o.jsx(N0,{messageActionsIcons:y,message:e,isStreaming:r,onEditClick:ze,isReadOnly:g}):pe?null:o.jsx(E0,{messageActionsIcons:y,message:e,isStreaming:r,regenerateMessage:u,rateResponse:m,isReadOnly:g,isRegenerateAvailable:x});return o.jsx("div",{className:$("max-w-full flex",Q?"justify-end":"justify-start","message-wrapper"),children:o.jsxs("div",{className:$("flex items-start",Q&&!W?"max-w-full":"w-full"),children:[o.jsxs("div",{className:"relative mr-2",children:[Qe(),a&&o.jsx(j.Loader,{})]}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:$(Q?"bg-neutrals-300 px-6":"pt-0",Q?"user-message":"system-message",Q&&(W?"w-[100%] ml-0":"ml-12")),children:[!Q&&!he&&e?.custom_content?.stages?o.jsx(M0,{stages:e?.custom_content?.stages,expandIcon:E,processingTitle:w?.processingTitle}):a&&o.jsx("p",{className:"body-1 loading-message text-neutrals-700",children:T?.loading}),W?o.jsx(j0,{content:e.content,onCancel:ke,onEditApply:Oe,editMessageTitles:N}):o.jsx($l,{content:e.content})]}),Y,me,!he&&!Be&&o.jsx(Kl,{choiceButtons:fe,onClick:h})]})]})})},_0=({messages:e,isStreaming:t=!1,isReadOnly:n,conversationViewState:s,...r})=>{const{scrollBottomIcon:a}=De(),i=f.useRef(null),c=f.useRef(null),{isOpenedAdvancedView:l}=$e(),d=wt(),[u,h]=f.useState(null),[m,p]=f.useState(!1),g=d?.isPanelOpen()??!1,x=()=>{const y=c.current?.parentElement,N=i.current;if(y&&N){const E=N.offsetTop-y.offsetTop;y.scrollTo({top:E,behavior:"smooth"})}};f.useEffect(()=>{x()},[e,t]),f.useEffect(()=>{!l&&u!==null&&setTimeout(()=>{c?.current?.parentElement?.scrollTo({top:u,behavior:"smooth"})})},[l,u]);const v=()=>{const y=c.current?.parentElement?.scrollTop||null;h(y)},w=()=>{const y=c.current?.parentElement;if(y){const{scrollTop:N,scrollHeight:E,clientHeight:T}=y;N+T>=E?p(!1):!m&&!l&&p(!0)}};f.useEffect(()=>{l&&p(!1)},[l]);const C=j.useDebounce(w,300);f.useEffect(()=>{const y=c.current?.parentElement;return y?.addEventListener("scroll",C),()=>y?.removeEventListener("scroll",C)},[C]);const b=f.useCallback(y=>{const N=ne.linkifyText(y);return o.jsx("div",{className:"whitespace-pre-wrap break-words",children:N.map((E,T)=>E.type==="text"?o.jsx(f.Fragment,{children:E.value},T):o.jsx("a",{href:E.value,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center align-middle",children:o.jsx(qe.IconExternalLink,{className:"size-4 shrink-0 cursor-pointer text-primary"})},T))})},[]);return o.jsxs("div",{ref:c,className:"flex size-full justify-center",children:[o.jsxs("div",{className:"chat-messages-wrapper flex w-full flex-col gap-y-6",children:[e.map((y,N)=>{const E=y.id??N;if(y.errorMessage){const A=s?.errorContext?.kind===ve.ERROR_CONTEXT_KIND.RATE_LIMIT?j.InlineAlertType.Warning:j.InlineAlertType.Error;return o.jsx(j.InlineAlert,{type:A,children:o.jsx("div",{className:"flex flex-col",children:b(y.errorMessage)})},E)}if(l&&y.role===Pe.Role.System)return null;const T=N===e.length-1,S=zm(e,N),_=hu(e);return o.jsx(k0,{message:y,previousMessage:S,onAdvancedViewOpen:v,isStreaming:t,isCurrentMessageStreaming:t&&T&&y.role===Pe.Role.Assistant,showAdvancedView:N===_&&!n,isLastNotUserMessage:T&&y.role!==Pe.Role.User,...r},E)}),o.jsx("div",{ref:i,className:"h-4"})]}),o.jsx("div",{onClick:x,className:$("fixed sm:hidden bottom-[88px] rounded-[50%] border-[2px] w-[40px] h-[40px] border-primary cursor-pointer text-primary bg-white z-10",g?"right-[402px] lg:right-[386px]":"right-10 lg:right-6","scroll-button-wrapper",m?"block":"hidden"),children:o.jsx("div",{className:"flex size-full items-center justify-center",children:a})})]})},I0=e=>{const t={};return e.choices?.[0]?.delta?.content&&(t.content=e.choices[0].delta.content),e.choices?.[0]?.delta?.custom_content&&(t.custom_content=e.choices[0].delta.custom_content),e.choices?.[0]?.delta?.role&&(t.role=e.choices[0].delta.role),e.id&&(t.responseId=e.id),t},R0="local",P0=e=>!e.permissions?.includes(Pe.SharePermission.WRITE)&&!O0(e),L0=(e,t)=>ud(e)!==t,O0=e=>ud(e)===R0,ud=e=>e.id.split("/")[0],F0=(e,t)=>ia([...t?.messages||[],e]),ia=e=>[...e].map(t=>{const n={role:t.role,content:t.content};return(t.role===Pe.Role.Assistant||t.role===Pe.Role.System)&&t.custom_content!=null&&(t.custom_content.state!=null||t.custom_content.attachments!=null||t.custom_content.form_schema!=null)&&(n.custom_content={},t.custom_content.state!=null&&(n.custom_content.state=t.custom_content.state),t.custom_content.attachments!=null&&(n.custom_content.attachments=U0(t.custom_content.attachments)),t.custom_content.form_schema!=null&&(n.custom_content.form_schema=t.custom_content.form_schema)),t.role===Pe.Role.User&&t.custom_content&&(n.custom_content=t.custom_content),n}),V0=(e,t)=>{const n=t?.messages,s=n?.findIndex(r=>e.id===r.id);return ia(n?.slice(0,s)||[])},H0=(e,t)=>{const n=t?.messages,s=n?.findIndex(r=>e.id===r.id);return ia([...n?.slice(0,s)||[],e])};function U0(e){return e.map(t=>({type:t.type,title:t.title,data:t.data,url:t.url,reference_type:t.reference_type,reference_url:t.reference_url}))}const G0=(e,t,n,s)=>{if(!n||t)return null;const r={id:`msg-${Date.now()}`,role:Pe.Role.User,content:e,timestamp:Date.now()};if(s){const a=s===vn.COMPLETE?cn.COMPLETION:cn.CHOICE;r.custom_content={form_value:{[a]:s}}}return r},B0=(e,t,n)=>`/${t}${n}/${ne.getConversationNavPath(e?.folderId,e?.id)}`,z0=(e,t,n)=>{const s=`${t}/${n}`,r=ve.generateConversationId({folderId:s,name:e?.name});return{...e,folderId:s,id:r}},q0=(e,t)=>{const n=e.lastIndexOf(".");return n<=0?`${e}-${t}`:`${e.slice(0,n)}-${t}${e.slice(n)}`},W0=(e,t,n)=>{const s=e.split("/");if(s[0]!=="files"||s.length<3)return e;const r=s.at(-1)??"file",a=q0(r,n);return["files",t,...s.slice(2,-1),a].join("/")},$0=async({conversation:e,bucket:t,getFileBlob:n,putFile:s})=>{const r=ne.getConversationAttachmentUrls(e),a=Date.now();if(!r.length)return e;const i=await Promise.all(r.map(async c=>{const l=W0(c,t,`${a}`);if(l===c)return[c,l];const d=await n(c);return await s(l,d),[c,l]}));return ne.replaceConversationAttachmentUrls(e,Object.fromEntries(i))},K0="AbortError",J0=({error:e,statusMessages:t})=>{if(e){if(e.type===ve.DIAL_ERROR_TYPES.RATE_LIMIT_EXCEEDED){const n=e.exceeded_limit?.length?t.getExceededLimitsMessage(e.exceeded_limit):e.display_message??"";throw new ne.HttpError({message:e.message,displayMessage:n,code:e.type,status:e.status??ne.HTTP_ERROR_CODES.TOO_MANY_REQUESTS,details:{kind:ve.ERROR_CONTEXT_KIND.RATE_LIMIT,occurredAt:new Date().toISOString(),retryAfterSeconds:Number(e.retry_after??"")}})}throw new ne.HttpError({message:e.message,status:e.status??ne.HTTP_ERROR_CODES.BAD_REQUEST,code:e.code})}},Y0=({error:e,statusMessages:t})=>{if(e.code===ve.DIAL_ERROR_TYPES.RATE_LIMIT_EXCEEDED){const n=e;return{errorMessage:n.displayMessage??n.message,errorContext:n.details}}return e.code===ve.DIAL_ERROR_CODES.CONTENT_FILTER?{errorMessage:t.contentFilterError??e.message}:{errorMessage:e.status===ne.HTTP_ERROR_CODES.SERVICE_UNAVAILABLE?t.serverOverloaded:t.serverError}},xl=(e,t)=>{const n=e.customViewState??{},s=n[ve.CUSTOM_VIEW_STATE_KEY]??{};return{...e,customViewState:{...n,[ve.CUSTOM_VIEW_STATE_KEY]:{...s,errorContext:t}}}},Z0=()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}},X0=({conversationKey:e,conversation:t,actions:n,messageStyles:s,attachmentsStyles:r,inputMessageStyles:a,shareConversationProps:i,showConversationHeaderAdvancedView:c=!0,formattingSettings:l,metadataSettings:d,expandStagesIcon:u,locale:h,conversationsRoute:m,token:p,titles:g,dataQuery:x,handleInvalidStreaming:v,onConversationNotFound:w,setConversation:C,setConversations:b,openUrl:y,messageActionsIcons:N,messageActionsTitles:E,editMessageTitles:T,scrollBottomIcon:S,isFinalMessage:_,limitMessages:A,attachmentsConfig:M,headerRightSlot:k,children:R})=>{const[L,z]=f.useState(null),[U,Z]=f.useState(!1),[O,K]=f.useState(!0),{isStreaming:J,setIsStreaming:X}=Al(),{isOpenedAdvancedView:Q}=$e(),{setCrossDatasetAttachmentsState:pe}=Ln(),{isCrossDatasetModeOn:we}=We(),{isAgentAvailable:se}=j.useAgentAvailability(),{statusMessages:V}=Lr(),{onboardingFileSchema:W,onboardingFilePath:ce,onboardingFileName:fe,isShowOnboarding:de,setOnboardingFileSchema:Ne}=Xe();f.useEffect(()=>{W&&n.putOnboardingFile?.(fe,ce,W)},[n,W,fe,ce]),f.useEffect(()=>{Q&&W?.lastDisplayedElement===Ge.OPEN_ADVANCED_VIEW&&Ne?.(ou(W))},[n,Q,Ne,W]);const Te=f.useCallback(()=>{y(`/${h}${m}`)},[h,m,y]),F=f.useCallback(async()=>{try{const{bucket:H}=await n.getBucket(),B=n.getFileBlob&&n.putFile?await $0({conversation:t,bucket:H,getFileBlob:n.getFileBlob,putFile:n.putFile}):t,ee=z0(B,H,h);await n.createConversation(ee,h);const I=await n.getConversations(h);b(ne.cleanConversationNames(I)),y(B0(ee,h,m))}catch(H){console.error("Failed to save conversation:",H)}},[n,t,m,h,y,b]),G=f.useCallback(async H=>{try{await n.updateConversation(decodeURI(e),{name:H.name,messages:H.messages,customViewState:H.customViewState})}catch(B){console.error("Failed to save conversation:",B)}},[n,e]),oe=f.useCallback((H,B)=>{if(!t)return;const ee=ad(t.messages,B,H);if(!ee)return;const I={...t,messages:ee};C(I),G(I)},[t,C,G]),re=f.useCallback(H=>{C(B=>B?{...B,messages:[...B?.messages||[],H]}:null)},[C]),ae=f.useCallback(()=>{const H={id:`msg-${Date.now()+1}`,role:Pe.Role.Assistant,content:"",timestamp:Date.now()};return C(B=>B?{...B,messages:[...B.messages,H]}:null),H},[C]),ue=f.useCallback((H,B)=>{const ee=ve.mergeMessages?.(H,[B]);if(ee)return C(I=>I?{...I,messages:I.messages.map(P=>P.id===H.id?{...ee}:P)}:null),ee},[C]),he=f.useCallback((H,B)=>{t?.model?.id&&(n.rateResponse(H,B===Pe.LikeState.Liked,t.model.id),t.messages=t.messages.map(ee=>ee.responseId===H?Rr.merge(ee,{like:B}):ee),G(t))},[n,t,G]),je=f.useCallback((H,B)=>{let ee=V.serverError,I,P;if(ne.isHttpError(H)){P=H;const q=Y0({error:H,statusMessages:V});ee=q.errorMessage,I=q.errorContext}else P=new ne.HttpError({status:ne.HTTP_ERROR_CODES.INTERNAL_SERVER_ERROR,message:ee});return B&&(B=ue(B,{errorMessage:ee})),v?.(P),{assistantMessage:B,errorContext:I}},[v,V,ue]),Se=f.useCallback(async(H,B,ee)=>{const I=new AbortController;z(I);let P=H,q;if(!ee)return{assistantMessage:P,errorContext:q};const te=ee.custom_fields??{},Re={...te,configuration:{...te.configuration,timezone:Z0(),...we&&{merge_python_code:!0}}};return await ve.streamChatResponse?.(encodeURI(ee.id),B,{model:ee.model,signal:I?.signal,onMessage:Ce=>{J0({error:Ce.error,statusMessages:V});const xe=I0(Ce);(xe.content||xe.role||xe.responseId)&&(P=ue(P,xe))},onError:Ce=>{if(!Be(Ce))throw console.error("Streaming error:",Ce),Ce}},p,Re).catch(Ce=>{if(!Be(Ce)){const{assistantMessage:xe,errorContext:Ze}=je(Ce,P);P=xe,q=Ze}}),{assistantMessage:P,errorContext:q}},[p,ue,je,V,we]),ge=f.useCallback(async(H,B,ee,I)=>{if(!B)return;let P=xl(B,I);P={...P,messages:[...B.messages],updatedAt:Date.now()},ee&&P.messages.push(ee),P.messages.push(H),await G(P)},[G]),be=f.useCallback(H=>{C(B=>B&&xl(B,H))},[C]),Me=f.useCallback((H,B)=>{C(ee=>ee?{...ee,messages:ee.messages.filter(I=>I.id!==B.id)}:null)},[C]),Le=f.useCallback(()=>{L&&!L.signal.aborted&&L.abort()},[L]),Be=H=>H?.name===K0,ze=f.useCallback(async(H,B,ee,I,P,q=!0)=>{Be(P)?await ge(I??ee,H,q?B:void 0):Me(P,B)},[ge,Me]),ke=f.useCallback(async(H,B,ee)=>{if(!B||!H)return;const I=G0(H,J,B,ee);let P,q;if(I){re(I);try{X(!0),P=ae();const te=F0(I,B),{assistantMessage:Re,errorContext:Ce}=await Se(P,te,B);be(Ce),q=Re,await ge(q,B,I,Ce)}catch(te){ze(B,I,P,q,te)}finally{X(!1)}}},[J,X,re,ae,Se,ge,ze,be]),Oe=f.useCallback(async(H,B,ee)=>{let I,P;try{X(!0),I=ae();const{assistantMessage:q,errorContext:te}=await Se(I,H,B);P=q,be(te),await ge(P,B,void 0,te)}catch(q){ze(B,ee,I,P,q,!1)}finally{X(!1)}},[X,ge,ze,Se,ae,be]),Ve=f.useCallback(async(H,B)=>{if(!B||!H)return;const ee=V0(H,B),I={...B,messages:B.messages.slice(0,ee.length)};C(P=>P?{...P,...I}:null),Oe(ee,I,H)},[C,Oe]),{isLastMessageFailed:Qe,regenerateLastMessage:Y}=f.useMemo(()=>{const H=t?.messages?.at(-1);return{isLastMessageFailed:!!H?.errorMessage,regenerateLastMessage:H&&(()=>Ve(H,t))}},[t,Ve]),me=f.useCallback(async(H,B)=>{if(!B||!H)return;const ee=H0(H,B),I={...B,messages:[...B.messages.slice(0,ee.length-1),H]};C(P=>P?{...P,...I}:null),Oe(ee,I,H)},[C,Oe]);f.useEffect(()=>{Vo(),pe();async function H(){try{K(!0);const{bucket:B}=await n.getBucket(),ee=await n.getConversation(decodeURI(e));C(ee),Z(P0(ee)&&L0(ee,B)),(ee.messages.length===0||ee?.messages?.[0]?.role===Pe.Role.Assistant&&ee?.messages?.length===1)&&ke(ee.prompt,ee)}catch{Z(!0),w?.()}finally{K(!1)}}return e&&H(),()=>{Vo()}},[e]);const ie=f.useMemo(()=>({getFile:n.getFile,putOnboardingFile:n.putOnboardingFile,getDataSet:n.getDataSet,getDataSetData:n.getDataSetData,getConstraints:n.getConstraints,updateCurrentDataQuery:n.updateCurrentDataQuery,updateDataQueries:n.updateDataQueries,updateDatasets:n.updateDatasets,downloadDataSet:n.downloadDataSet}),[n]);if(O)return o.jsx(j.Loader,{});const le=t?.customViewState?.[ve.CUSTOM_VIEW_STATE_KEY],He=()=>{if(le?.errorContext?.kind===ve.ERROR_CONTEXT_KIND.RATE_LIMIT&&ve.isRateLimitStillActive(le.errorContext)){const H=ve.getRateLimitRestoreDate(le.errorContext);if(H){const B=ve.formatDateTime(H);return o.jsx(j.InlineAlert,{type:j.InlineAlertType.Info,children:V.getAssistantRestoreMessage(B.date,B.time)})}}return se?o.jsx(kl,{onSendMessage:H=>ke(H,t),onStopStreaming:Le,inProcess:J,sendMessageIcon:a.sendMessageIcon,retryIcon:a.retryIcon,placeholder:g?.askAnything??"Ask anything...",containerClasses:"mt-4",inputClasses:"border-neutrals-600 mr-2",isLastFailed:Qe,onRetryFailed:Y}):o.jsx(j.InlineAlert,{type:j.InlineAlertType.Error,children:V.assistantUnavailable})};return o.jsx(Cn,{styles:{titles:g,messageStyles:s,attachmentsStyles:r,formattingSettings:l,messageActionsIcons:N,messageActionsTitles:E,editMessageTitles:T,expandStagesIcon:u,scrollBottomIcon:S,limitMessages:A,attachmentsConfig:M},children:o.jsxs("div",{className:$("h-full flex flex-col bg-white conversation-view-wrapper",Q&&!c&&"p-4"),children:[Q&&!c?null:o.jsx(Wl,{conversation:t,locale:h,isOpenedAdvancedView:Q,isShowShareButton:!U&&!de,shareConversationProps:i,rightSlot:k}),o.jsxs("div",{className:"flex min-h-0 min-w-0 w-full flex-1",children:[o.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[o.jsx("div",{className:$("flex-1 min-h-0 flex flex-col items-end scroll-hidden-container",s?.messagesWrapperClass),children:o.jsx(_0,{messages:t?.messages||[],actions:ie,isStreaming:J,isReadOnly:U,metadataSettings:d,dataQuery:x,locale:h,regenerateMessage:H=>Ve(H,t),selectMessageToSend:(H,B)=>ke(H,t,B),rateResponse:he,editMessage:H=>me(H,t),isReadOnlyConversation:U||de,conversationViewState:le,onCodeAttachmentUpdated:oe})}),de?null:U?o.jsx("div",{className:"mt-4 flex items-center justify-center",children:o.jsx(j.Button,{iconBefore:o.jsx(qe.IconCopy,{width:20,height:20}),title:g?.duplicate??"Duplicate Chat",isSmallButton:!0,onClick:F,buttonClassName:$("text-button-secondary")})}):o.jsx("div",{className:$(a.inputContainerClass),children:He()}),de&&_&&o.jsx(j.Button,{iconBefore:o.jsx(qe.IconPlus,{width:24,height:24}),title:g?.onboardingFooterLink,onClick:Te,isSmallButton:!0,buttonClassName:"text-button-secondary self-center mb-3"}),R]}),!Q&&o.jsx(Ou,{scope:"conversation"})]})]})})},Q0=({conversationName:e,expandTitle:t,expandIcon:n,onExpand:s})=>o.jsxs("div",{className:"flex h-full w-[51px] shrink-0 flex-col items-center border border-neutrals-400 bg-white",children:[o.jsx("button",{type:"button",className:"mt-[84px] flex size-9 items-center justify-center text-primary","aria-label":t,title:t,onClick:s,children:n}),o.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center overflow-hidden pb-[88px] pt-[72px]",children:o.jsx("span",{className:"h3 min-h-0 flex-1 rotate-180 truncate text-center text-neutrals-1000 [writing-mode:vertical-rl]",title:e,children:e})})]});exports.AdvancedView=x0;exports.AdvancedViewProvider=wd;exports.CUSTOM_CHOICE_ID=vn;exports.ChartingIcon=un;exports.ChatFooter=Yl;exports.ChatMessagesProvider=bd;exports.ChatOnboardingFooter=Jl;exports.CollapsedChatPanel=Q0;exports.ConversationView=X0;exports.ConversationViewFeatureTogglesProvider=jh;exports.ConversationViewMessagesProvider=xd;exports.ConversationViewSidePanelProvider=ag;exports.ConversationViewStylesProvider=Cn;exports.ConversationWelcome=Bd;exports.CrossDatasetAttachmentsProvider=b0;exports.CustomContentProperties=cn;exports.DatasetDimensionsMetadataMapProvider=X1;exports.OnboardingProvider=yd;exports.STAGE_STATUS=jl;exports.useAdvancedView=$e;exports.useChatMessages=Al;exports.useConversationViewFeatureToggles=We;exports.useConversationViewMessages=Lr;exports.useConversationViewSidePanelOptional=wt;exports.useConversationViewStyles=De;exports.useCrossDatasetAttachments=Ln;exports.useDatasetDimensionsMetadataMap=Rn;exports.useDatasetDimensionsMetadataMapOptional=Pn;exports.useOnboarding=Xe;