@epam/statgpt-conversation-view 0.6.0-rc.8 → 0.6.0-rc.9
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 +5 -5
- package/index.mjs +2922 -2903
- package/package.json +6 -6
package/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),d=require("react"),je=require("@epam/ai-dial-shared"),M=require("@epam/statgpt-ui-components"),Ve=require("@tabler/icons-react"),z=require("classnames"),we=require("@epam/statgpt-dial-toolkit"),ee=require("@epam/statgpt-shared-toolkit"),To=require("@epam/statgpt-conversation-list"),Wa=require("react-markdown"),$a=require("remark-gfm"),y=require("@epam/statgpt-sdmx-toolkit"),Eo=require("react-window"),Ao=require("react-virtualized-auto-sizer"),Xe=require("@floating-ui/react"),qs=require("ag-grid-community"),_n=require("lodash"),Ja=require("echarts-for-react"),Vn=require("ag-grid-react"),No=require("tailwind-merge"),Zs=require("date-fns"),ko=require("@monaco-editor/react");function jo(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 Te=jo(d),Ka=d.createContext(void 0),Io=({children:e})=>{const[t,n]=d.useState(!1);return r.jsx(Ka.Provider,{value:{isOpenedAdvancedView:t,setIsOpenedAdvancedView:n},children:e})},We=()=>{const e=d.useContext(Ka);if(e===void 0)throw new Error("useAdvancedView must be used within a AdvancedViewProvider");return e},Ya=d.createContext(void 0),Lo=({children:e})=>{const[t,n]=d.useState(!1);return r.jsx(Ya.Provider,{value:{isStreaming:t,setIsStreaming:n},children:e})},qa=()=>{const e=d.useContext(Ya);if(e===void 0)throw new Error("useChatMessages must be used within a ChatMessagesProvider");return e},Za=d.createContext(null);function Po({value:e,children:t}){const n=d.useMemo(()=>e,[e]);return r.jsx(Za.Provider,{value:n,children:t})}function Un(){const e=d.useContext(Za);if(!e)throw new Error("useConversationViewMessages must be used within ConversationViewMessagesProvider");return e}const Xa=d.createContext(void 0),Ro=({children:e})=>{const[t,n]=d.useState(""),[s,a]=d.useState(""),[i,o]=d.useState(),[c,l]=d.useState();return r.jsx(Xa.Provider,{value:{onboardingFileName:t,onboardingFilePath:s,isShowOnboarding:i,onboardingFileSchema:c,setOnboardingFileName:n,setOnboardingFilePath:a,setIsShowOnboarding:o,setOnboardingFileSchema:l},children:e})},qe=()=>{const e=d.useContext(Xa);if(e===void 0)throw new Error("useOnboarding must be used within a OnboardingProvider");return e};var Xt=(e=>(e.CHOICE="choice",e.COMPLETION="completion",e))(Xt||{}),on=(e=>(e.COMPLETE="complete",e))(on||{}),Qa=(e=>(e.COMPLETED="completed",e))(Qa||{}),Qt=(e=>(e.PREVIOUS="previous",e.NEXT="next",e))(Qt||{});const er=({inProcess:e,disabled:t,containerClasses:n,inputClasses:s,placeholder:a,sendMessageIcon:i,isLastFailed:o,retryIcon:c,onSendMessage:l,onStopStreaming:f,onRetryFailed:u})=>{const[h,m]=d.useState(""),p=d.useCallback(x=>{m(x)},[m]),g=x=>{e||t||(m(""),l(x))},b=x=>{t||x.key===M.KeyboardKey.Enter&&!x.shiftKey&&(o?u?.():g(h.trim()))},C=()=>t?null:o?r.jsx(M.IconButton,{buttonClassName:"input-for-ask-button",onClick:()=>u?.(),icon:c||r.jsx(Ve.IconRefresh,{})}):e?r.jsx(M.IconButton,{buttonClassName:"input-for-ask-button",onClick:()=>f?.(),icon:r.jsx(Ve.IconPlayerStopFilled,{})}):h?r.jsx(M.IconButton,{buttonClassName:"input-for-ask-button",onClick:()=>g(h),icon:i}):null;return r.jsx(M.InputWithIcon,{inputId:"ask-input",containerClasses:n,placeholder:a,onChange:p,onKeyDown:b,disabled:t,cssClass:z(s,"input-for-ask"),value:h,iconAfterInput:C()})},Xs=160,Fo=':;,=/{}%&\\"',Oo=new RegExp(`[${Fo}]|(\r
|
|
2
2
|
|
|
|
3
3
|
|\r| )|[\0-]`,"gm"),_o=(e,t,n,s)=>({name:Vo(s||`${n} ${new Date().toLocaleDateString()}`),folderId:`${e}/${t}`,prompt:s}),Vo=e=>{const t=e?.replace(/\r\n|\r/gm,`
|
|
4
4
|
`).split(`
|
|
5
|
-
`).map(s=>s.replace(Oo," ").trim()).filter(Boolean)[0]??"";return(t.length>Xs?t.substring(0,Xs):t).trim()},Ho=(e,t,n,s,a,i)=>{const o=`${e}/${t}`;return{name:n,folderId:o,prompt:a,id:we.generateConversationId({folderId:o,name:n}),messages:[{role:Ie.Role.Assistant,content:s}],custom_fields:{configuration:{choice:i}}}},tr=u.createContext(null);function on({children:e,styles:t}){return r.jsx(tr.Provider,{value:t??{},children:e})}function ye(){const e=u.useContext(tr);if(!e)throw new Error("useConversationViewStyles must be used within ConversationViewStylesProvider");return e}var Uo=Object.defineProperty,Qt=Object.getOwnPropertySymbols,nr=Object.prototype.hasOwnProperty,sr=Object.prototype.propertyIsEnumerable,Qs=(e,t,n)=>t in e?Uo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,An=(e,t)=>{for(var n in t||(t={}))nr.call(t,n)&&Qs(e,n,t[n]);if(Qt)for(var n of Qt(t))sr.call(t,n)&&Qs(e,n,t[n]);return e},Nn=(e,t)=>{var n={};for(var s in e)nr.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Qt)for(var s of Qt(e))t.indexOf(s)<0&&sr.call(e,s)&&(n[s]=e[s]);return n};var pt;(e=>{const t=class Se{constructor(l,f,d,h){if(this.version=l,this.errorCorrectionLevel=f,this.modules=[],this.isFunction=[],l<Se.MIN_VERSION||l>Se.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(d);if(this.drawCodewords(p),h==-1){let g=1e9;for(let b=0;b<8;b++){this.applyMask(b),this.drawFormatBits(b);const C=this.getPenaltyScore();C<g&&(h=b,g=C),this.applyMask(b)}}a(0<=h&&h<=7),this.mask=h,this.applyMask(h),this.drawFormatBits(h),this.isFunction=[]}static encodeText(l,f){const d=e.QrSegment.makeSegments(l);return Se.encodeSegments(d,f)}static encodeBinary(l,f){const d=e.QrSegment.makeBytes(l);return Se.encodeSegments([d],f)}static encodeSegments(l,f,d=1,h=40,m=-1,p=!0){if(!(Se.MIN_VERSION<=d&&d<=h&&h<=Se.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let g,b;for(g=d;;g++){const v=Se.getNumDataCodewords(g,f)*8,S=o.getTotalBits(l,g);if(S<=v){b=S;break}if(g>=h)throw new RangeError("Data too long")}for(const v of[Se.Ecc.MEDIUM,Se.Ecc.QUARTILE,Se.Ecc.HIGH])p&&b<=Se.getNumDataCodewords(g,v)*8&&(f=v);let C=[];for(const v of l){n(v.mode.modeBits,4,C),n(v.numChars,v.mode.numCharCountBits(g),C);for(const S of v.getData())C.push(S)}a(C.length==b);const x=Se.getNumDataCodewords(g,f)*8;a(C.length<=x),n(0,Math.min(4,x-C.length),C),n(0,(8-C.length%8)%8,C),a(C.length%8==0);for(let v=236;C.length<x;v^=253)n(v,8,C);let w=[];for(;w.length*8<C.length;)w.push(0);return C.forEach((v,S)=>w[S>>>3]|=v<<7-(S&7)),new Se(g,f,w,m)}getModule(l,f){return 0<=l&&l<this.size&&0<=f&&f<this.size&&this.modules[f][l]}getModules(){return this.modules}drawFunctionPatterns(){for(let d=0;d<this.size;d++)this.setFunctionModule(6,d,d%2==0),this.setFunctionModule(d,6,d%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const l=this.getAlignmentPatternPositions(),f=l.length;for(let d=0;d<f;d++)for(let h=0;h<f;h++)d==0&&h==0||d==0&&h==f-1||d==f-1&&h==0||this.drawAlignmentPattern(l[d],l[h]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(l){const f=this.errorCorrectionLevel.formatBits<<3|l;let d=f;for(let m=0;m<10;m++)d=d<<1^(d>>>9)*1335;const h=(f<<10|d)^21522;a(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 d=0;d<12;d++)l=l<<1^(l>>>11)*7973;const f=this.version<<12|l;a(f>>>18==0);for(let d=0;d<18;d++){const h=s(f,d),m=this.size-11+d%3,p=Math.floor(d/3);this.setFunctionModule(m,p,h),this.setFunctionModule(p,m,h)}}drawFinderPattern(l,f){for(let d=-4;d<=4;d++)for(let h=-4;h<=4;h++){const m=Math.max(Math.abs(h),Math.abs(d)),p=l+h,g=f+d;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,m!=2&&m!=4)}}drawAlignmentPattern(l,f){for(let d=-2;d<=2;d++)for(let h=-2;h<=2;h++)this.setFunctionModule(l+h,f+d,Math.max(Math.abs(h),Math.abs(d))!=1)}setFunctionModule(l,f,d){this.modules[f][l]=d,this.isFunction[f][l]=!0}addEccAndInterleave(l){const f=this.version,d=this.errorCorrectionLevel;if(l.length!=Se.getNumDataCodewords(f,d))throw new RangeError("Invalid argument");const h=Se.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][f],m=Se.ECC_CODEWORDS_PER_BLOCK[d.ordinal][f],p=Math.floor(Se.getNumRawDataModules(f)/8),g=h-p%h,b=Math.floor(p/h);let C=[];const x=Se.reedSolomonComputeDivisor(m);for(let v=0,S=0;v<h;v++){let k=l.slice(S,S+b-m+(v<g?0:1));S+=k.length;const T=Se.reedSolomonComputeRemainder(k,x);v<g&&k.push(0),C.push(k.concat(T))}let w=[];for(let v=0;v<C[0].length;v++)C.forEach((S,k)=>{(v!=b-m||k>=g)&&w.push(S[v])});return a(w.length==p),w}drawCodewords(l){if(l.length!=Math.floor(Se.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let f=0;for(let d=this.size-1;d>=1;d-=2){d==6&&(d=5);for(let h=0;h<this.size;h++)for(let m=0;m<2;m++){const p=d-m,b=(d+1&2)==0?this.size-1-h:h;!this.isFunction[b][p]&&f<l.length*8&&(this.modules[b][p]=s(l[f>>>3],7-(f&7)),f++)}}a(f==l.length*8)}applyMask(l){if(l<0||l>7)throw new RangeError("Mask value out of range");for(let f=0;f<this.size;f++)for(let d=0;d<this.size;d++){let h;switch(l){case 0:h=(d+f)%2==0;break;case 1:h=f%2==0;break;case 2:h=d%3==0;break;case 3:h=(d+f)%3==0;break;case 4:h=(Math.floor(d/3)+Math.floor(f/2))%2==0;break;case 5:h=d*f%2+d*f%3==0;break;case 6:h=(d*f%2+d*f%3)%2==0;break;case 7:h=((d+f)%2+d*f%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[f][d]&&h&&(this.modules[f][d]=!this.modules[f][d])}}getPenaltyScore(){let l=0;for(let m=0;m<this.size;m++){let p=!1,g=0,b=[0,0,0,0,0,0,0];for(let C=0;C<this.size;C++)this.modules[m][C]==p?(g++,g==5?l+=Se.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,b),p||(l+=this.finderPenaltyCountPatterns(b)*Se.PENALTY_N3),p=this.modules[m][C],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,b)*Se.PENALTY_N3}for(let m=0;m<this.size;m++){let p=!1,g=0,b=[0,0,0,0,0,0,0];for(let C=0;C<this.size;C++)this.modules[C][m]==p?(g++,g==5?l+=Se.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,b),p||(l+=this.finderPenaltyCountPatterns(b)*Se.PENALTY_N3),p=this.modules[C][m],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,b)*Se.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+=Se.PENALTY_N2)}let f=0;for(const m of this.modules)f=m.reduce((p,g)=>p+(g?1:0),f);const d=this.size*this.size,h=Math.ceil(Math.abs(f*20-d*10)/d)-1;return a(0<=h&&h<=9),l+=h*Se.PENALTY_N4,a(0<=l&&l<=2568888),l}getAlignmentPatternPositions(){if(this.version==1)return[];{const l=Math.floor(this.version/7)+2,f=this.version==32?26:Math.ceil((this.version*4+4)/(l*2-2))*2;let d=[6];for(let h=this.size-7;d.length<l;h-=f)d.splice(1,0,h);return d}}static getNumRawDataModules(l){if(l<Se.MIN_VERSION||l>Se.MAX_VERSION)throw new RangeError("Version number out of range");let f=(16*l+128)*l+64;if(l>=2){const d=Math.floor(l/7)+2;f-=(25*d-10)*d-55,l>=7&&(f-=36)}return a(208<=f&&f<=29648),f}static getNumDataCodewords(l,f){return Math.floor(Se.getNumRawDataModules(l)/8)-Se.ECC_CODEWORDS_PER_BLOCK[f.ordinal][l]*Se.NUM_ERROR_CORRECTION_BLOCKS[f.ordinal][l]}static reedSolomonComputeDivisor(l){if(l<1||l>255)throw new RangeError("Degree out of range");let f=[];for(let h=0;h<l-1;h++)f.push(0);f.push(1);let d=1;for(let h=0;h<l;h++){for(let m=0;m<f.length;m++)f[m]=Se.reedSolomonMultiply(f[m],d),m+1<f.length&&(f[m]^=f[m+1]);d=Se.reedSolomonMultiply(d,2)}return f}static reedSolomonComputeRemainder(l,f){let d=f.map(h=>0);for(const h of l){const m=h^d.shift();d.push(0),f.forEach((p,g)=>d[g]^=Se.reedSolomonMultiply(p,m))}return d}static reedSolomonMultiply(l,f){if(l>>>8||f>>>8)throw new RangeError("Byte out of range");let d=0;for(let h=7;h>=0;h--)d=d<<1^(d>>>7)*285,d^=(f>>>h&1)*l;return a(d>>>8==0),d}finderPenaltyCountPatterns(l){const f=l[1];a(f<=this.size*3);const d=f>0&&l[2]==f&&l[3]==f*3&&l[4]==f&&l[5]==f;return(d&&l[0]>=f*4&&l[6]>=f?1:0)+(d&&l[6]>=f*4&&l[0]>=f?1:0)}finderPenaltyTerminateAndCount(l,f,d){return l&&(this.finderPenaltyAddHistory(f,d),f=0),f+=this.size,this.finderPenaltyAddHistory(f,d),this.finderPenaltyCountPatterns(d)}finderPenaltyAddHistory(l,f){f[0]==0&&(l+=this.size),f.pop(),f.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,f){if(l<0||l>31||c>>>l)throw new RangeError("Value out of range");for(let d=l-1;d>=0;d--)f.push(c>>>d&1)}function s(c,l){return(c>>>l&1)!=0}function a(c){if(!c)throw new Error("Assertion error")}const i=class Fe{constructor(l,f,d){if(this.mode=l,this.numChars=f,this.bitData=d,f<0)throw new RangeError("Invalid argument");this.bitData=d.slice()}static makeBytes(l){let f=[];for(const d of l)n(d,8,f);return new Fe(Fe.Mode.BYTE,l.length,f)}static makeNumeric(l){if(!Fe.isNumeric(l))throw new RangeError("String contains non-numeric characters");let f=[];for(let d=0;d<l.length;){const h=Math.min(l.length-d,3);n(parseInt(l.substring(d,d+h),10),h*3+1,f),d+=h}return new Fe(Fe.Mode.NUMERIC,l.length,f)}static makeAlphanumeric(l){if(!Fe.isAlphanumeric(l))throw new RangeError("String contains unencodable characters in alphanumeric mode");let f=[],d;for(d=0;d+2<=l.length;d+=2){let h=Fe.ALPHANUMERIC_CHARSET.indexOf(l.charAt(d))*45;h+=Fe.ALPHANUMERIC_CHARSET.indexOf(l.charAt(d+1)),n(h,11,f)}return d<l.length&&n(Fe.ALPHANUMERIC_CHARSET.indexOf(l.charAt(d)),6,f),new Fe(Fe.Mode.ALPHANUMERIC,l.length,f)}static makeSegments(l){return l==""?[]:Fe.isNumeric(l)?[Fe.makeNumeric(l)]:Fe.isAlphanumeric(l)?[Fe.makeAlphanumeric(l)]:[Fe.makeBytes(Fe.toUtf8ByteArray(l))]}static makeEci(l){let f=[];if(l<0)throw new RangeError("ECI assignment value out of range");if(l<128)n(l,8,f);else if(l<16384)n(2,2,f),n(l,14,f);else if(l<1e6)n(6,3,f),n(l,21,f);else throw new RangeError("ECI assignment value out of range");return new Fe(Fe.Mode.ECI,0,f)}static isNumeric(l){return Fe.NUMERIC_REGEX.test(l)}static isAlphanumeric(l){return Fe.ALPHANUMERIC_REGEX.test(l)}getData(){return this.bitData.slice()}static getTotalBits(l,f){let d=0;for(const h of l){const m=h.mode.numCharCountBits(f);if(h.numChars>=1<<m)return 1/0;d+=4+m+h.bitData.length}return d}static toUtf8ByteArray(l){l=encodeURI(l);let f=[];for(let d=0;d<l.length;d++)l.charAt(d)!="%"?f.push(l.charCodeAt(d)):(f.push(parseInt(l.substring(d+1,d+3),16)),d+=2);return f}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=i;e.QrSegment=i})(pt||(pt={}));(e=>{(t=>{const n=class{constructor(a,i){this.ordinal=a,this.formatBits=i}};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={}))})(pt||(pt={}));(e=>{(t=>{const n=class{constructor(a,i){this.modeBits=a,this.numBitsCharCount=i}numCharCountBits(a){return this.numBitsCharCount[Math.floor((a+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={}))})(pt||(pt={}));var wt=pt;var Bo={L:wt.QrCode.Ecc.LOW,M:wt.QrCode.Ecc.MEDIUM,Q:wt.QrCode.Ecc.QUARTILE,H:wt.QrCode.Ecc.HIGH},ar=128,rr="L",ir="#FFFFFF",or="#000000",lr=!1,cr=1,Go=4,zo=0,Wo=.1;function dr(e,t=0){const n=[];return e.forEach(function(s,a){let i=null;s.forEach(function(o,c){if(!o&&i!==null){n.push(`M${i+t} ${a+t}h${c-i}v1H${i+t}z`),i=null;return}if(c===s.length-1){if(!o)return;i===null?n.push(`M${c+t},${a+t} h1v1H${c+t}z`):n.push(`M${i+t},${a+t} h${c+1-i}v1H${i+t}z`);return}o&&i===null&&(i=c)})}),n.join("")}function ur(e,t){return e.slice().map((n,s)=>s<t.y||s>=t.y+t.h?n:n.map((a,i)=>i<t.x||i>=t.x+t.w?a:!1))}function $o(e,t,n,s){if(s==null)return null;const a=e.length+n*2,i=Math.floor(t*Wo),o=a/t,c=(s.width||i)*o,l=(s.height||i)*o,f=s.x==null?e.length/2-c/2:s.x*o,d=s.y==null?e.length/2-l/2:s.y*o,h=s.opacity==null?1:s.opacity;let m=null;if(s.excavate){let g=Math.floor(f),b=Math.floor(d),C=Math.ceil(c+f-g),x=Math.ceil(l+d-b);m={x:g,y:b,w:C,h:x}}const p=s.crossOrigin;return{x:f,y:d,h:l,w:c,excavation:m,opacity:h,crossOrigin:p}}function Jo(e,t){return t!=null?Math.max(Math.floor(t),0):e?Go:zo}function fr({value:e,level:t,minVersion:n,includeMargin:s,marginSize:a,imageSettings:i,size:o,boostLevel:c}){let l=u.useMemo(()=>{const g=(Array.isArray(e)?e:[e]).reduce((b,C)=>(b.push(...wt.QrSegment.makeSegments(C)),b),[]);return wt.QrCode.encodeSegments(g,Bo[t],n,void 0,void 0,c)},[e,t,n,c]);const{cells:f,margin:d,numCells:h,calculatedImageSettings:m}=u.useMemo(()=>{let p=l.getModules();const g=Jo(s,a),b=p.length+g*2,C=$o(p,o,g,i);return{cells:p,margin:g,numCells:b,calculatedImageSettings:C}},[l,o,i,s,a]);return{qrcode:l,margin:d,cells:f,numCells:h,calculatedImageSettings:m}}var Ko=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Yo=u.forwardRef(function(t,n){const s=t,{value:a,size:i=ar,level:o=rr,bgColor:c=ir,fgColor:l=or,includeMargin:f=lr,minVersion:d=cr,boostLevel:h,marginSize:m,imageSettings:p}=s,b=Nn(s,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:C}=b,x=Nn(b,["style"]),w=p?.src,v=u.useRef(null),S=u.useRef(null),k=u.useCallback(L=>{v.current=L,typeof n=="function"?n(L):n&&(n.current=L)},[n]),[T,N]=u.useState(!1),{margin:D,cells:R,numCells:E,calculatedImageSettings:A}=fr({value:a,level:o,minVersion:d,boostLevel:h,includeMargin:f,marginSize:m,imageSettings:p,size:i});u.useEffect(()=>{if(v.current!=null){const L=v.current,$=L.getContext("2d");if(!$)return;let J=R;const q=S.current,H=A!=null&&q!==null&&q.complete&&q.naturalHeight!==0&&q.naturalWidth!==0;H&&A.excavation!=null&&(J=ur(R,A.excavation));const K=window.devicePixelRatio||1;L.height=L.width=i*K;const z=i/E*K;$.scale(z,z),$.fillStyle=c,$.fillRect(0,0,E,E),$.fillStyle=l,Ko?$.fill(new Path2D(dr(J,D))):R.forEach(function(ne,se){ne.forEach(function(fe,xe){fe&&$.fillRect(xe+D,se+D,1,1)})}),A&&($.globalAlpha=A.opacity),H&&$.drawImage(q,A.x+D,A.y+D,A.w,A.h)}}),u.useEffect(()=>{N(!1)},[w]);const j=An({height:i,width:i},C);let O=null;return w!=null&&(O=u.createElement("img",{src:w,key:w,style:{display:"none"},onLoad:()=>{N(!0)},ref:S,crossOrigin:A?.crossOrigin})),u.createElement(u.Fragment,null,u.createElement("canvas",An({style:j,height:i,width:i,ref:k,role:"img"},x)),O)});Yo.displayName="QRCodeCanvas";var mr=u.forwardRef(function(t,n){const s=t,{value:a,size:i=ar,level:o=rr,bgColor:c=ir,fgColor:l=or,includeMargin:f=lr,minVersion:d=cr,boostLevel:h,title:m,marginSize:p,imageSettings:g}=s,b=Nn(s,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:C,cells:x,numCells:w,calculatedImageSettings:v}=fr({value:a,level:o,minVersion:d,boostLevel:h,includeMargin:f,marginSize:p,imageSettings:g,size:i});let S=x,k=null;g!=null&&v!=null&&(v.excavation!=null&&(S=ur(x,v.excavation)),k=u.createElement("image",{href:g.src,height:v.h,width:v.w,x:v.x+C,y:v.y+C,preserveAspectRatio:"none",opacity:v.opacity,crossOrigin:v.crossOrigin}));const T=dr(S,C);return u.createElement("svg",An({height:i,width:i,viewBox:`0 0 ${w} ${w}`,ref:n,role:"img"},b),!!m&&u.createElement("title",null,m),u.createElement("path",{fill:c,d:`M0,0 h${w}v${w}H0z`,shapeRendering:"crispEdges"}),u.createElement("path",{fill:l,d:T,shapeRendering:"crispEdges"}),k)});mr.displayName="QRCodeSVG";const qo=(e,t)=>({invitationType:we.InvitationType.LINK,resources:[{url:`conversations/${encodeURI(e)}`},...t]}),Zo=e=>{const t=e?.invitationLink?.split("/").at(-1)||"";return`/${te.SHARE_CONVERSATION_ROUTE}/${t}`},Xo=(e,t)=>t?.find(n=>{const s=e?.id?.split("/")?.pop(),a=n?.url?.split("/")?.pop()||"";return a===s||decodeURI(a)===s}),Qo=e=>e?.messages?.filter(n=>!!n?.custom_content?.attachments)?.flatMap(n=>n?.custom_content?.attachments?.map(s=>({url:s?.url||""}))||[])?.filter(n=>!!n?.url)||[],el=({conversation:e,locale:t,onCloseModal:n,modalDividers:s,getConversation:a,generateConversationLink:i,chatExpiration:o,chatExpirationDays:c,close:l,chatWarning:f,shareLink:d,shareCopyLink:h,shareCopiedLink:m,shareDescription:p,shareRemoveAccessToUsers:g,chatName:b,getSharedConversations:C,revokeSharedConversations:x,baseUrl:w,id:v,clientSharedPage:S,clientSharedProp:k,shareAlertMessage:T})=>{const[N,D]=u.useState(null),[R,E]=u.useState(),[A,j]=u.useState(!1),[O,L]=u.useState(!1),[$,J]=u.useState(),q=u.useRef(null),H=u.useRef(null),K=u.useMemo(()=>e?.id?decodeURI(e.id):v?.[0]&&v?.[1]&&t?decodeURI(`${v[0]}/${t}/${v[1]}`):null,[e?.id,v,t]),z=u.useMemo(()=>{if(!N)return"";const _=w||window.location.origin;if(w&&w!==window.location.origin&&S&&k){const Y=N.split(`/${te.SHARE_CONVERSATION_ROUTE}/`)?.[1];return`${_}/${S}?${k}=${Y}`}return`${_}/${t}${N}`},[w,N,t,S,k]),ne=u.useCallback(async _=>{const Y=await C?.(we.getSharedConversationsRequest(we.ShareTarget.OTHERS));if(Y)return Xo({id:_},Y.resources)},[C]);u.useEffect(()=>{if(!K||q.current===K)return;q.current=K,j(!1),H.current?.abort();const _=new AbortController;return H.current=_,(async()=>{try{const le=await a?.(K),de=qo(K,Qo(le)),ue=await i?.(de),ae=await ne(K);if(_.signal.aborted||!ue)return;D(Zo(ue)),E(ae),j(!0)}catch(le){if(_.signal.aborted)return;j(!1),console.error("Error sharing conversation",le)}})(),()=>{_.abort(),q.current=null}},[K,i,a,ne]);const se=u.useCallback(()=>{H.current?.abort(),q.current=null,n(),D(null),j(!1),L(!1)},[n]),fe=u.useCallback(()=>{L(!0),navigator.clipboard.writeText(z||"")},[z]),xe=async()=>{try{if(J(!0),R&&await x?.({resources:[R]}),K){const _=await ne(K);H.current?.signal.aborted||E(_)}}catch(_){console.error("Error revoking shared conversation",_)}finally{H.current?.signal.aborted||J(!1)}},me=u.useCallback(()=>r.jsx(M.Button,{buttonClassName:O?"text-button-secondary":"text-button-primary",iconBefore:O?r.jsx(Ve.IconCheck,{width:20,height:20}):r.jsx(Ve.IconCopy,{width:20,height:20}),title:O?m??"Copied":h??"Copy link",disabled:O,onClick:fe}),[O,fe,m,h]);return r.jsxs(M.Popup,{heading:d??"Share link",portalId:"share",size:M.PopUpSize.SM,dividers:s,onClose:se,closeButtonTitle:l??"Close",children:[A?r.jsxs("div",{className:"share flex flex-col gap-y-4 overflow-auto px-6 pb-6 sm:p-0",children:[T?r.jsx(M.InlineAlert,{type:M.InlineAlertType.Note,icon:r.jsx(Ve.IconInfoCircle,{width:16,height:16}),children:T}):null,e?.name?r.jsxs("div",{className:"share-info flex w-full",children:[r.jsx("p",{className:"share-info-title body-1 mr-1 text-neutrals-800",children:b??"Chat name:"}),r.jsx("h3",{className:"min-w-0 flex-1 truncate",title:e?.name,children:e?.name})]}):null,r.jsxs("div",{className:"share-info flex",children:[r.jsx("p",{className:"share-info-title body-1 mr-1 text-neutrals-800",children:o??"Link expiration date:"}),r.jsxs("h3",{children:["3 ",c??"days"]})]}),r.jsx(mr,{className:"min-h-[200px] self-center rounded border border-neutrals-600 p-2",value:z,size:200}),r.jsx("p",{className:"body-2 text-neutrals-1000",children:p??"Your name, special instructions, and any messages you add after sharing remain confidential."}),r.jsx(M.InputWithIcon,{containerClasses:"share-input-container",cssClass:"share-input",readonly:!0,placeholder:z,value:z,inputId:"conversationLink",iconAfterInput:me()})]}):r.jsx("div",{className:"flex items-center justify-center p-6",children:r.jsx(M.Loader,{})}),A?e&&R?r.jsx("div",{className:"remove-access",children:r.jsx(M.Button,{title:g??"Remove access to all users",buttonClassName:"remove-access-button py-3 px-4",isSmallButton:!0,disabled:$,onClick:xe})}):r.jsx("p",{className:"body-2 share-footer text-neutrals-800",children:f??"This chat has not been shared with anyone yet."}):r.jsx("div",{})]})},hr=({shareButtonClass:e,shareIcon:t,...n})=>{const[s,a]=u.useState(M.PopUpState.Closed),i=()=>{a(M.PopUpState.Opened)},o=u.useCallback(()=>{a(M.PopUpState.Closed)},[]);return r.jsxs(r.Fragment,{children:[r.jsx(M.Button,{buttonClassName:e||"text-button-secondary",title:n?.share||"Share",iconBefore:t,onClick:i}),s===M.PopUpState.Opened&&r.jsx(el,{onCloseModal:o,...n})]})},pr=({conversation:e,locale:t,isOpenedAdvancedView:n,isShowShareButton:s,shareConversationProps:a,rightSlot:i})=>r.jsx(r.Fragment,{children:r.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:[r.jsx("span",{className:W("flex-1 min-w-0 truncate h4","conversation-view-header-text"),title:e?.name,children:e?.name}),r.jsxs("div",{className:"ml-3 flex items-center gap-4",children:[!n&&s&&r.jsx("div",{className:"flex gap-x-2",children:r.jsx(hr,{conversation:e,locale:t,...a})}),i]})]})}),gr=({content:e,textColorClass:t})=>{const{isOpenedAdvancedView:n}=Ge();return r.jsx("div",{className:W("prose max-w-none break-words",n?"body-2":"body-1",t),children:r.jsx(Wa,{remarkPlugins:[$a],components:{strong:s=>r.jsx("strong",{className:t,...s}),a:({href:s,children:a,...i})=>r.jsx("a",{href:s,target:"_blank",rel:"noreferrer",...i,children:a})},children:e})})},Cr=({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(a=>r.jsx("div",{className:"mt-4",children:r.jsxs("button",{type:"button",className:s,disabled:t,onClick:()=>n(a[Ie.DialSchemaProperties.DialWidgetOptions]?.populateText,a?.const),"aria-label":"button",children:[r.jsx("h3",{className:"mb-1",children:a.title}),a.const!==rn.COMPLETE&&r.jsx("p",{className:"body-1 text-neutrals-800",children:a[Ie.DialSchemaProperties.DialWidgetOptions]?.populateText})]})},a.title))},tl=({messageContent:e,choiceButtons:t,disabled:n,onClick:s,handleOnboardingSkip:a})=>{const{titles:i}=ye();return r.jsxs("div",{className:"onboarding flex size-full flex-1 flex-col overflow-auto",children:[r.jsx(pr,{conversation:{name:i?.onboardingTitle??"Introducing the AI assistant"}}),r.jsxs("div",{className:"onboarding-content flex flex-col",children:[r.jsx(gr,{content:e}),r.jsx("div",{className:"mt-4",children:r.jsx(Cr,{choiceButtons:t,disabled:n,onClick:s})}),r.jsxs("div",{className:"mt-8 flex",children:[r.jsx(M.Button,{title:i?.skipOnboardingNow,buttonClassName:"text-button-secondary mr-4",disabled:n,onClick:()=>a?.(),isSmallButton:!0}),r.jsx(M.Button,{title:i?.refuseOnboarding,buttonClassName:"text-button-tertiary",disabled:n,onClick:()=>a?.(!0),isSmallButton:!0})]})]})]})},wr=({openNewConversation:e})=>{const{titles:t}=ye();return r.jsxs("div",{className:"body-3 bg-accent-300 p-2 text-center",children:[r.jsx("span",{className:"mr-2 text-neutrals-900",children:t?.onboardingFooter}),r.jsxs("span",{onClick:e,className:"inline-flex cursor-pointer align-top",children:[r.jsx(Ve.IconPlus,{width:15,height:15}),r.jsx("p",{className:"ml-1",children:t?.onboardingFooterLink})]})]})},xr=({firstLine:e,secondLine:t})=>{const n=e!=null&&e.trim()!=="",s=t!=null&&t.trim()!=="";return r.jsxs("div",{className:W("text-center body-3",s?"p-0":n?"p-1":"p-3"),children:[n&&r.jsx("div",{className:"text-neutrals-800",children:e}),s&&r.jsx("div",{className:"text-neutrals-800",children:t})]})},nl=({suggestionsList:e,welcomeText:t,welcomeDescription:n,welcomeInputPlaceholder:s,titleIcon:a,actions:i,titles:o,inputMessageStyles:c,suggestionsContainerClass:l,isBottomInputPosition:f,prompt:d,onboardingMessageSchema:h,handleConversationClick:m,setConversations:p,locale:g,setSharedConversations:b})=>{const[C,x]=u.useState(null),[w,v]=u.useState(!0),[S,k]=u.useState(!1),{onboardingFileSchema:T,onboardingFileName:N,onboardingFilePath:D,isShowOnboarding:R,setIsShowOnboarding:E,setOnboardingFileSchema:A}=Ye(),{isAgentAvailable:j}=M.useAgentAvailability(),{statusMessages:O}=Vn();u.useEffect(()=>{(async()=>{try{const H=await i.getBucket();x(H.bucket)}catch(H){console.error(H instanceof Error?H.message:"Request error")}finally{v(!1)}})()},[i]);const L=u.useCallback(async(q,H)=>{if(!C){console.error("No bucket");return}k(!0);try{const K=R?Ho(C,g,o?.onboardingTitle??"Introducing the AI assistant",h?.properties?.choice?.description??"",q,H):_o(C,g,o.newChat??"New chat",q),z=await i.createConversation(K,g,R),ne=await i.getConversations(g),se=await i.getSharedConversations(we.getSharedConversationsRequest(we.ShareTarget.ME));if(h&&T){const fe={...T,isStarted:!0};await i.putOnboardingFile?.(N,D,fe),A?.(fe)}p(te.cleanConversationNames(ne)),b(te.cleanConversationNames(To.transformSharedConversations(se,g))),m(z.folderId,z.id)}catch(K){console.error(K instanceof Error?K.message:"Creation conversation failed"),k(!1)}},[i,C,m,R,g,N,D,T,h,p,A,b,o.newChat,o?.onboardingTitle]),$=u.useCallback(async q=>{if(E(!1),q&&T){const H={...T,isSkipped:!0};await i.putOnboardingFile?.(N,D,H),A?.(H)}},[i,N,D,T,E,A]);u.useEffect(()=>{d&&C&&L(d)},[C,d]);const J=()=>{const q=!C;return j?r.jsxs(r.Fragment,{children:[r.jsx(er,{containerClasses:W(c.inputContainerClass,f&&"order-3 mt-auto"),inputClasses:"mr-2",disabled:q,placeholder:s||o?.askAnything||"Ask anything...",sendMessageIcon:c.sendMessageIcon,onSendMessage:L}),r.jsx("div",{className:W("no-scrollbar max-w-full overflow-x-auto",l),children:r.jsx("div",{className:W("flex flex-wrap justify-center gap-2 sm:flex-nowrap","tags-container"),children:e.map(H=>r.jsx(M.Tag,{title:H.title,text:H[Ie.DialSchemaProperties.DialWidgetOptions]?.populateText,disabled:q,onClick:L},H.title))})})]}):r.jsx(M.InlineAlert,{type:M.InlineAlertType.Error,children:O.assistantUnavailable})};return r.jsx(on,{styles:{titles:o},children:r.jsxs("div",{className:"flex size-full flex-col",children:[S||d&&w?r.jsx(M.Loader,{}):R?r.jsx(tl,{messageContent:h?.properties?.choice?.description||"",choiceButtons:h?.properties?.choice?.oneOf||[],disabled:!C,handleOnboardingSkip:$,onClick:L}):r.jsxs("div",{className:"flex h-full flex-col items-center justify-center sm:px-4",children:[r.jsxs("div",{className:W("flex items-center max-w-full sm-min:px-4",f?"mt-auto mb-8":n?"mb-0":"mb-6"),children:[a,r.jsx("h1",{className:"sm:h2 text-hues-800 text-center",children:t??o?.welcomeTitle??"How can I help you?"})]}),n&&r.jsx("p",{className:"body-1 text-neutrals-900 mb-6 mt-3 max-w-[784px] text-center",children:n}),J()]}),R&&r.jsx(wr,{openNewConversation:()=>E(!1)}),!R&&r.jsx(xr,{firstLine:o.footerFirstLine,secondLine:o.footerSecondLine})]})})},vr=e=>Ae.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ae.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"})),sl=({dataQueries:e,disabledDatasetUrns:t,isSelected:n,onSelect:s,onClearAll:a})=>{const{titles:i}=ye(),o=e.length-t.size,c=t.size>0;return r.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:[r.jsx("h3",{className:"w-full min-w-0 flex-1 truncate",title:i?.dataset??"Dataset",children:r.jsx("span",{className:"truncate",children:i?.dataset??"Dataset"})}),r.jsxs("div",{className:"ml-2 flex items-center gap-2 text-neutrals-800",children:[r.jsx("span",{className:"filters-facet-item-counter px-2 text-center",children:`${o}/${e.length}`}),c&&r.jsx("div",{className:"filters-facet-item-settings flex items-center gap-2",children:r.jsx(M.IconButton,{buttonClassName:"text-button-tertiary w-4 h-4 border-0 p-0 filters-facet-item-icon",icon:r.jsx(vr,{width:16,height:16}),title:i?.reset??"Reset",onClick:l=>{l.stopPropagation(),a()}})})]})]})},Hn=e=>Ae.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ae.createElement("path",{d:"M11.3301 6.25L8.00008 9.75L4.67008 6.25L11.3301 6.25Z",fill:"currentColor"})),al=e=>Ae.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ae.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"}));function br(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Et={exports:{}},rl=Et.exports,ea;function il(){return ea||(ea=1,(function(e,t){(function(n,s){s(t)})(rl,(function(n){var s=function(){return s=Object.assign||function(rt){for(var Gt,vn=1,Mo=arguments.length;vn<Mo;vn++){Gt=arguments[vn];for(var bn in Gt)Object.prototype.hasOwnProperty.call(Gt,bn)&&(rt[bn]=Gt[bn])}return rt},s.apply(this,arguments)},a=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},i={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};a.l10ns.ar=i,a.l10ns;var o=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};o.l10ns.at=c,o.l10ns;var l=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},f={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=f,l.l10ns;var d=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};d.l10ns.be=h,d.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:{}},b={weekdays:{shorthand:["Нд","Пн","Вт","Ср","Чт","Пт","Сб"],longhand:["Неделя","Понеделник","Вторник","Сряда","Четвъртък","Петък","Събота"]},months:{shorthand:["Яну","Фев","Март","Апр","Май","Юни","Юли","Авг","Сеп","Окт","Ное","Дек"],longhand:["Януари","Февруари","Март","Април","Май","Юни","Юли","Август","Септември","Октомври","Ноември","Декември"]},time_24hr:!0,firstDayOfWeek:1};g.l10ns.bg=b,g.l10ns;var C=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},x={weekdays:{shorthand:["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],longhand:["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"]},months:{shorthand:["জানু","ফেব্রু","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],longhand:["জানুয়ারী","ফেব্রুয়ারী","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"]}};C.l10ns.bn=x,C.l10ns;var w=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},v={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(ke){var rt=ke%100;if(rt>3&&rt<21)return"è";switch(rt%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};w.l10ns.cat=w.l10ns.ca=v,w.l10ns;var S=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},k={weekdays:{shorthand:["یەکشەممە","دووشەممە","سێشەممە","چوارشەممە","پێنجشەممە","هەینی","شەممە"],longhand:["یەکشەممە","دووشەممە","سێشەممە","چوارشەممە","پێنجشەممە","هەینی","شەممە"]},months:{shorthand:["ڕێبەندان","ڕەشەمە","نەورۆز","گوڵان","جۆزەردان","پووشپەڕ","گەلاوێژ","خەرمانان","ڕەزبەر","گەڵاڕێزان","سەرماوەز","بەفرانبار"],longhand:["ڕێبەندان","ڕەشەمە","نەورۆز","گوڵان","جۆزەردان","پووشپەڕ","گەلاوێژ","خەرمانان","ڕەزبەر","گەڵاڕێزان","سەرماوەز","بەفرانبار"]},firstDayOfWeek:6,ordinal:function(){return""}};S.l10ns.ckb=k,S.l10ns;var T=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},N={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};T.l10ns.cs=N,T.l10ns;var D=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},R={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(ke){return ke===1?"af":ke===2?"ail":ke===3||ke===4?"ydd":ke===5||ke===6?"ed":ke>=7&&ke<=10||ke==12||ke==15||ke==18||ke==20?"fed":ke==11||ke==13||ke==14||ke==16||ke==17||ke==19?"eg":ke>=21&&ke<=39?"ain":""},time_24hr:!0};D.l10ns.cy=R,D.l10ns;var E=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},A={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=A,E.l10ns;var j=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},O={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};j.l10ns.de=O,j.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(ke){var rt=ke%100;if(rt>3&&rt<21)return"th";switch(rt%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},$=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},J={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};$.l10ns.eo=J,$.l10ns;var q=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},H={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};q.l10ns.es=H,q.l10ns;var K=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},z={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=z,K.l10ns;var ne=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},se={weekdays:{shorthand:["یک","دو","سه","چهار","پنج","جمعه","شنبه"],longhand:["یکشنبه","دوشنبه","سهشنبه","چهارشنبه","پنچشنبه","جمعه","شنبه"]},months:{shorthand:["ژانویه","فوریه","مارس","آوریل","مه","ژوئن","ژوئیه","اوت","سپتامبر","اکتبر","نوامبر","دسامبر"],longhand:["ژانویه","فوریه","مارس","آوریل","مه","ژوئن","ژوئیه","اوت","سپتامبر","اکتبر","نوامبر","دسامبر"]},firstDayOfWeek:6,ordinal:function(){return""}};ne.l10ns.fa=se,ne.l10ns;var fe=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},xe={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};fe.l10ns.fi=xe,fe.l10ns;var me=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},_={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};me.l10ns.fo=_,me.l10ns;var Y=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},le={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(ke){return ke>1?"":"er"},rangeSeparator:" au ",weekAbbreviation:"Sem",scrollTitle:"Défiler pour augmenter la valeur",toggleTitle:"Cliquer pour basculer",time_24hr:!0};Y.l10ns.fr=le,Y.l10ns;var de=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ue={weekdays:{shorthand:["Κυ","Δε","Τρ","Τε","Πέ","Πα","Σά"],longhand:["Κυριακή","Δευτέρα","Τρίτη","Τετάρτη","Πέμπτη","Παρασκευή","Σάββατο"]},months:{shorthand:["Ιαν","Φεβ","Μάρ","Απρ","Μάι","Ιούν","Ιούλ","Αύγ","Σεπ","Οκτ","Νοέ","Δεκ"],longhand:["Ιανουάριος","Φεβρουάριος","Μάρτιος","Απρίλιος","Μάιος","Ιούνιος","Ιούλιος","Αύγουστος","Σεπτέμβριος","Οκτώβριος","Νοέμβριος","Δεκέμβριος"]},firstDayOfWeek:1,ordinal:function(){return""},weekAbbreviation:"Εβδ",rangeSeparator:" έως ",scrollTitle:"Μετακυλήστε για προσαύξηση",toggleTitle:"Κάντε κλικ για αλλαγή",amPM:["ΠΜ","ΜΜ"],yearAriaLabel:"χρόνος",monthAriaLabel:"μήνας",hourAriaLabel:"ώρα",minuteAriaLabel:"λεπτό"};de.l10ns.gr=ue,de.l10ns;var ae=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ee={weekdays:{shorthand:["א","ב","ג","ד","ה","ו","ש"],longhand:["ראשון","שני","שלישי","רביעי","חמישי","שישי","שבת"]},months:{shorthand:["ינו׳","פבר׳","מרץ","אפר׳","מאי","יוני","יולי","אוג׳","ספט׳","אוק׳","נוב׳","דצמ׳"],longhand:["ינואר","פברואר","מרץ","אפריל","מאי","יוני","יולי","אוגוסט","ספטמבר","אוקטובר","נובמבר","דצמבר"]},rangeSeparator:" אל ",time_24hr:!0};ae.l10ns.he=ee,ae.l10ns;var U=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},B={weekdays:{shorthand:["रवि","सोम","मंगल","बुध","गुरु","शुक्र","शनि"],longhand:["रविवार","सोमवार","मंगलवार","बुधवार","गुरुवार","शुक्रवार","शनिवार"]},months:{shorthand:["जन","फर","मार्च","अप्रेल","मई","जून","जूलाई","अग","सित","अक्ट","नव","दि"],longhand:["जनवरी ","फरवरी","मार्च","अप्रेल","मई","जून","जूलाई","अगस्त ","सितम्बर","अक्टूबर","नवम्बर","दिसम्बर"]}};U.l10ns.hi=B,U.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 ge=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},he={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};ge.l10ns.hu=he,ge.l10ns;var ce=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Me={weekdays:{shorthand:["Կիր","Երկ","Երք","Չրք","Հնգ","Ուրբ","Շբթ"],longhand:["Կիրակի","Եկուշաբթի","Երեքշաբթի","Չորեքշաբթի","Հինգշաբթի","Ուրբաթ","Շաբաթ"]},months:{shorthand:["Հնվ","Փտր","Մար","Ապր","Մայ","Հնս","Հլս","Օգս","Սեպ","Հոկ","Նմբ","Դեկ"],longhand:["Հունվար","Փետրվար","Մարտ","Ապրիլ","Մայիս","Հունիս","Հուլիս","Օգոստոս","Սեպտեմբեր","Հոկտեմբեր","Նոյեմբեր","Դեկտեմբեր"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"ՇԲՏ",scrollTitle:"Ոլորեք՝ մեծացնելու համար",toggleTitle:"Սեղմեք՝ փոխելու համար",amPM:["ՄԿ","ԿՀ"],yearAriaLabel:"Տարի",monthAriaLabel:"Ամիս",hourAriaLabel:"Ժամ",minuteAriaLabel:"Րոպե",time_24hr:!0};ce.l10ns.hy=Me,ce.l10ns;var Ne=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ie={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:" - "};Ne.l10ns.id=ie,Ne.l10ns;var Le=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},We={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};Le.l10ns.is=We,Le.l10ns;var Be=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},_e={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};Be.l10ns.it=_e,Be.l10ns;var He=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},qe={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:"分"};He.l10ns.ja=qe,He.l10ns;var $e=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},X={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=X,$e.l10ns;var pe=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ve={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:["오전","오후"]};pe.l10ns.ko=ve,pe.l10ns;var Ce=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},be={weekdays:{shorthand:["អាទិត្យ","ចន្ទ","អង្គារ","ពុធ","ព្រហស.","សុក្រ","សៅរ៍"],longhand:["អាទិត្យ","ចន្ទ","អង្គារ","ពុធ","ព្រហស្បតិ៍","សុក្រ","សៅរ៍"]},months:{shorthand:["មករា","កុម្ភះ","មីនា","មេសា","ឧសភា","មិថុនា","កក្កដា","សីហា","កញ្ញា","តុលា","វិច្ឆិកា","ធ្នូ"],longhand:["មករា","កុម្ភះ","មីនា","មេសា","ឧសភា","មិថុនា","កក្កដា","សីហា","កញ្ញា","តុលា","វិច្ឆិកា","ធ្នូ"]},ordinal:function(){return""},firstDayOfWeek:1,rangeSeparator:" ដល់ ",weekAbbreviation:"សប្តាហ៍",scrollTitle:"រំកិលដើម្បីបង្កើន",toggleTitle:"ចុចដើម្បីផ្លាស់ប្ដូរ",yearAriaLabel:"ឆ្នាំ",time_24hr:!0};Ce.l10ns.km=be,Ce.l10ns;var F=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Q={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:"Жыл"};F.l10ns.kz=Q,F.l10ns;var I=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},P={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};I.l10ns.lt=P,I.l10ns;var V=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Z={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};V.l10ns.lv=Z,V.l10ns;var G=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},De={weekdays:{shorthand:["Не","По","Вт","Ср","Че","Пе","Са"],longhand:["Недела","Понеделник","Вторник","Среда","Четврток","Петок","Сабота"]},months:{shorthand:["Јан","Фев","Мар","Апр","Мај","Јун","Јул","Авг","Сеп","Окт","Ное","Дек"],longhand:["Јануари","Февруари","Март","Април","Мај","Јуни","Јули","Август","Септември","Октомври","Ноември","Декември"]},firstDayOfWeek:1,weekAbbreviation:"Нед.",rangeSeparator:" до ",time_24hr:!0};G.l10ns.mk=De,G.l10ns;var Te=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Je={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=Je,Te.l10ns;var Re=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ze={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""}};Re.l10ns;var et=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Bt={weekdays:{shorthand:["နွေ","လာ","ဂါ","ဟူး","ကြာ","သော","နေ"],longhand:["တနင်္ဂနွေ","တနင်္လာ","အင်္ဂါ","ဗုဒ္ဓဟူး","ကြာသပတေး","သောကြာ","စနေ"]},months:{shorthand:["ဇန်","ဖေ","မတ်","ပြီ","မေ","ဇွန်","လိုင်","သြ","စက်","အောက်","နို","ဒီ"],longhand:["ဇန်နဝါရီ","ဖေဖော်ဝါရီ","မတ်","ဧပြီ","မေ","ဇွန်","ဇူလိုင်","သြဂုတ်","စက်တင်ဘာ","အောက်တိုဘာ","နိုဝင်ဘာ","ဒီဇင်ဘာ"]},firstDayOfWeek:1,ordinal:function(){return""},time_24hr:!0};et.l10ns.my=Bt,et.l10ns;var is=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},os={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(ke){return ke===1||ke===8||ke>=20?"ste":"de"}};is.l10ns.nl=os,is.l10ns;var ls=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},cs={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"."}};ls.l10ns.nn=cs,ls.l10ns;var ds=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},us={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"."}};ds.l10ns.no=us,ds.l10ns;var fs=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ms={weekdays:{shorthand:["ਐਤ","ਸੋਮ","ਮੰਗਲ","ਬੁੱਧ","ਵੀਰ","ਸ਼ੁੱਕਰ","ਸ਼ਨਿੱਚਰ"],longhand:["ਐਤਵਾਰ","ਸੋਮਵਾਰ","ਮੰਗਲਵਾਰ","ਬੁੱਧਵਾਰ","ਵੀਰਵਾਰ","ਸ਼ੁੱਕਰਵਾਰ","ਸ਼ਨਿੱਚਰਵਾਰ"]},months:{shorthand:["ਜਨ","ਫ਼ਰ","ਮਾਰ","ਅਪ੍ਰੈ","ਮਈ","ਜੂਨ","ਜੁਲਾ","ਅਗ","ਸਤੰ","ਅਕ","ਨਵੰ","ਦਸੰ"],longhand:["ਜਨਵਰੀ","ਫ਼ਰਵਰੀ","ਮਾਰਚ","ਅਪ੍ਰੈਲ","ਮਈ","ਜੂਨ","ਜੁਲਾਈ","ਅਗਸਤ","ਸਤੰਬਰ","ਅਕਤੂਬਰ","ਨਵੰਬਰ","ਦਸੰਬਰ"]},time_24hr:!0};fs.l10ns.pa=ms,fs.l10ns;var hs=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ps={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"."}};hs.l10ns.pl=ps,hs.l10ns;var gs=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Cs={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};gs.l10ns.pt=Cs,gs.l10ns;var ws=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},xs={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""}};ws.l10ns.ro=xs,ws.l10ns;var vs=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},bs={weekdays:{shorthand:["Вс","Пн","Вт","Ср","Чт","Пт","Сб"],longhand:["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"]},months:{shorthand:["Янв","Фев","Март","Апр","Май","Июнь","Июль","Авг","Сен","Окт","Ноя","Дек"],longhand:["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Нед.",scrollTitle:"Прокрутите для увеличения",toggleTitle:"Нажмите для переключения",amPM:["ДП","ПП"],yearAriaLabel:"Год",time_24hr:!0};vs.l10ns.ru=bs,vs.l10ns;var Ss=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ys={weekdays:{shorthand:["ඉ","ස","අ","බ","බ්ර","සි","සෙ"],longhand:["ඉරිදා","සඳුදා","අඟහරුවාදා","බදාදා","බ්රහස්පතින්දා","සිකුරාදා","සෙනසුරාදා"]},months:{shorthand:["ජන","පෙබ","මාර්","අප්රේ","මැයි","ජුනි","ජූලි","අගෝ","සැප්","ඔක්","නොවැ","දෙසැ"],longhand:["ජනවාරි","පෙබරවාරි","මාර්තු","අප්රේල්","මැයි","ජුනි","ජූලි","අගෝස්තු","සැප්තැම්බර්","ඔක්තෝබර්","නොවැම්බර්","දෙසැම්බර්"]},time_24hr:!0};Ss.l10ns.si=ys,Ss.l10ns;var Ds=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ms={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"."}};Ds.l10ns.sk=Ms,Ds.l10ns;var Ts=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Es={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"."}};Ts.l10ns.sl=Es,Ts.l10ns;var As=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ns={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};As.l10ns.sq=Ns,As.l10ns;var ks=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},js={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};ks.l10ns.sr=js,ks.l10ns;var Is=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ls={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"."}};Is.l10ns.sv=Ls,Is.l10ns;var Ps=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Rs={weekdays:{shorthand:["อา","จ","อ","พ","พฤ","ศ","ส"],longhand:["อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัสบดี","ศุกร์","เสาร์"]},months:{shorthand:["ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค."],longhand:["มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม"]},firstDayOfWeek:1,rangeSeparator:" ถึง ",scrollTitle:"เลื่อนเพื่อเพิ่มหรือลด",toggleTitle:"คลิกเพื่อเปลี่ยน",time_24hr:!0,ordinal:function(){return""}};Ps.l10ns.th=Rs,Ps.l10ns;var Fs=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Os={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};Fs.l10ns.tr=Os,Fs.l10ns;var _s=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Vs={firstDayOfWeek:1,weekdays:{shorthand:["Нд","Пн","Вт","Ср","Чт","Пт","Сб"],longhand:["Неділя","Понеділок","Вівторок","Середа","Четвер","П'ятниця","Субота"]},months:{shorthand:["Січ","Лют","Бер","Кві","Тра","Чер","Лип","Сер","Вер","Жов","Лис","Гру"],longhand:["Січень","Лютий","Березень","Квітень","Травень","Червень","Липень","Серпень","Вересень","Жовтень","Листопад","Грудень"]},time_24hr:!0};_s.l10ns.uk=Vs,_s.l10ns;var Hs=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Us={weekdays:{shorthand:["Якш","Душ","Сеш","Чор","Пай","Жум","Шан"],longhand:["Якшанба","Душанба","Сешанба","Чоршанба","Пайшанба","Жума","Шанба"]},months:{shorthand:["Янв","Фев","Мар","Апр","Май","Июн","Июл","Авг","Сен","Окт","Ноя","Дек"],longhand:["Январ","Феврал","Март","Апрел","Май","Июн","Июл","Август","Сентябр","Октябр","Ноябр","Декабр"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Ҳафта",scrollTitle:"Катталаштириш учун айлантиринг",toggleTitle:"Ўтиш учун босинг",amPM:["AM","PM"],yearAriaLabel:"Йил",time_24hr:!0};Hs.l10ns.uz=Us,Hs.l10ns;var Bs=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Gs={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};Bs.l10ns.uz_latn=Gs,Bs.l10ns;var zs=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ws={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 "};zs.l10ns.vn=Ws,zs.l10ns;var $s=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Js={weekdays:{shorthand:["周日","周一","周二","周三","周四","周五","周六"],longhand:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},months:{shorthand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],longhand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},rangeSeparator:" 至 ",weekAbbreviation:"周",scrollTitle:"滚动切换",toggleTitle:"点击切换 12/24 小时时制"};$s.l10ns.zh=Js,$s.l10ns;var Ks=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ys={weekdays:{shorthand:["週日","週一","週二","週三","週四","週五","週六"],longhand:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},months:{shorthand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],longhand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},rangeSeparator:" 至 ",weekAbbreviation:"週",scrollTitle:"滾動切換",toggleTitle:"點擊切換 12/24 小時時制"};Ks.l10ns.zh_tw=Ys,Ks.l10ns;var Do={ar:i,at:c,az:f,be:h,bg:b,bn:x,bs:p,ca:v,ckb:k,cat:v,cs:N,cy:R,da:A,de:O,default:s({},L),en:L,eo:J,es:H,et:z,fa:se,fi:xe,fo:_,fr:le,gr:ue,he:ee,hi:B,hr:re,hu:he,hy:Me,id:ie,is:We,it:_e,ja:qe,ka:X,ko:ve,km:be,kz:Q,lt:P,lv:Z,mk:De,mn:Je,ms:Ze,my:Bt,nl:os,nn:cs,no:us,pa:ms,pl:ps,pt:Cs,ro:xs,ru:bs,si:ys,sk:Ms,sl:Es,sq:Ns,sr:js,sv:Ls,th:Rs,tr:Os,uk:Vs,vn:Ws,zh:Js,zh_tw:Ys,uz:Us,uz_latn:Gs};n.default=Do,Object.defineProperty(n,"__esModule",{value:!0})}))})(Et,Et.exports)),Et.exports}var ol=il();const ll=br(ol);var Wt={exports:{}},cl=Wt.exports,ta;function dl(){return ta||(ta=1,(function(e,t){(function(n,s){e.exports=s()})(cl,(function(){var n=function(){return n=Object.assign||function(f){for(var d,h=1,m=arguments.length;h<m;h++){d=arguments[h];for(var p in d)Object.prototype.hasOwnProperty.call(d,p)&&(f[p]=d[p])}return f},n.apply(this,arguments)},s=function(l,f,d){return d.months[f?"shorthand":"longhand"][l]};function a(l){for(;l.firstChild;)l.removeChild(l.firstChild)}function i(l){try{if(typeof l.composedPath=="function"){var f=l.composedPath();return f[0]}return l.target}catch{return l.target}}var o={shorthand:!1,dateFormat:"F Y",altFormat:"F Y",theme:"light"};function c(l){var f=n(n({},o),l);return function(d){d.config.dateFormat=f.dateFormat,d.config.altFormat=f.altFormat;var h={monthsContainer:null};function m(){if(d.rContainer){a(d.rContainer);for(var E=0;E<d.monthElements.length;E++){var A=d.monthElements[E];A.parentNode&&A.parentNode.removeChild(A)}}}function p(){d.rContainer&&(h.monthsContainer=d._createElement("div","flatpickr-monthSelect-months"),h.monthsContainer.tabIndex=-1,g(),d.rContainer.appendChild(h.monthsContainer),d.calendarContainer.classList.add("flatpickr-monthSelect-theme-"+f.theme))}function g(){if(h.monthsContainer){a(h.monthsContainer);for(var E=document.createDocumentFragment(),A=0;A<12;A++){var j=d.createDay("flatpickr-monthSelect-month",new Date(d.currentYear,A),0,A);j.dateObj.getMonth()===new Date().getMonth()&&j.dateObj.getFullYear()===new Date().getFullYear()&&j.classList.add("today"),j.textContent=s(A,f.shorthand,d.l10n),j.addEventListener("click",w),E.appendChild(j)}h.monthsContainer.appendChild(E),d.config.minDate&&d.currentYear===d.config.minDate.getFullYear()?d.prevMonthNav.classList.add("flatpickr-disabled"):d.prevMonthNav.classList.remove("flatpickr-disabled"),d.config.maxDate&&d.currentYear===d.config.maxDate.getFullYear()?d.nextMonthNav.classList.add("flatpickr-disabled"):d.nextMonthNav.classList.remove("flatpickr-disabled")}}function b(){d._bind(d.prevMonthNav,"click",function(E){E.preventDefault(),E.stopPropagation(),d.changeYear(d.currentYear-1),x(),g()}),d._bind(d.nextMonthNav,"click",function(E){E.preventDefault(),E.stopPropagation(),d.changeYear(d.currentYear+1),x(),g()}),d._bind(h.monthsContainer,"mouseover",function(E){d.config.mode==="range"&&d.onMouseOver(i(E),"flatpickr-monthSelect-month")})}function C(){if(d.rContainer&&d.selectedDates.length){for(var E=d.rContainer.querySelectorAll(".flatpickr-monthSelect-month.selected"),A=0;A<E.length;A++)E[A].classList.remove("selected");var j=d.selectedDates[0].getMonth(),O=d.rContainer.querySelector(".flatpickr-monthSelect-month:nth-child("+(j+1)+")");O&&O.classList.add("selected")}}function x(){var E=d.selectedDates[0];if(E&&(E=new Date(E),E.setFullYear(d.currentYear),d.config.minDate&&E<d.config.minDate&&(E=d.config.minDate),d.config.maxDate&&E>d.config.maxDate&&(E=d.config.maxDate),d.currentYear=E.getFullYear()),d.currentYearElement.value=String(d.currentYear),d.rContainer){var A=d.rContainer.querySelectorAll(".flatpickr-monthSelect-month");A.forEach(function(j){j.dateObj.setFullYear(d.currentYear),d.config.minDate&&j.dateObj<d.config.minDate||d.config.maxDate&&j.dateObj>d.config.maxDate?j.classList.add("flatpickr-disabled"):j.classList.remove("flatpickr-disabled")})}C()}function w(E){E.preventDefault(),E.stopPropagation();var A=i(E);if(A instanceof Element&&!A.classList.contains("flatpickr-disabled")&&!A.classList.contains("notAllowed")&&(v(A.dateObj),d.config.closeOnSelect)){var j=d.config.mode==="single",O=d.config.mode==="range"&&d.selectedDates.length===2;(j||O)&&d.close()}}function v(E){var A=new Date(d.currentYear,E.getMonth(),E.getDate()),j=[];switch(d.config.mode){case"single":j=[A];break;case"multiple":j.push(A);break;case"range":d.selectedDates.length===2?j=[A]:(j=d.selectedDates.concat([A]),j.sort(function(O,L){return O.getTime()-L.getTime()}));break}d.setDate(j,!0),C()}var S={37:-1,39:1,40:3,38:-3};function k(E,A,j,O){var L=S[O.keyCode]!==void 0;if(!(!L&&O.keyCode!==13)&&!(!d.rContainer||!h.monthsContainer)){var $=d.rContainer.querySelector(".flatpickr-monthSelect-month.selected"),J=Array.prototype.indexOf.call(h.monthsContainer.children,document.activeElement);if(J===-1){var q=$||h.monthsContainer.firstElementChild;q.focus(),J=q.$i}L?h.monthsContainer.children[(12+J+S[O.keyCode])%12].focus():O.keyCode===13&&h.monthsContainer.contains(document.activeElement)&&v(document.activeElement.dateObj)}}function T(){var E;((E=d.config)===null||E===void 0?void 0:E.mode)==="range"&&d.selectedDates.length===1&&d.clear(!1),d.selectedDates.length||g()}function N(){f._stubbedCurrentMonth=d._initialDate.getMonth(),d._initialDate.setMonth(f._stubbedCurrentMonth),d.currentMonth=f._stubbedCurrentMonth}function D(){f._stubbedCurrentMonth&&(d._initialDate.setMonth(f._stubbedCurrentMonth),d.currentMonth=f._stubbedCurrentMonth,delete f._stubbedCurrentMonth)}function R(){if(h.monthsContainer!==null)for(var E=h.monthsContainer.querySelectorAll(".flatpickr-monthSelect-month"),A=0;A<E.length;A++)E[A].removeEventListener("click",w)}return{onParseConfig:function(){d.config.enableTime=!1},onValueUpdate:C,onKeyDown:k,onReady:[N,m,p,b,C,function(){d.config.onClose.push(T),d.loadedPlugins.push("monthSelect")}],onDestroy:[D,R,function(){d.config.onClose=d.config.onClose.filter(function(E){return E!==T})}]}}}return c}))})(Wt)),Wt.exports}var ul=dl();const fl=br(ul),na=(e,t,n,s,a=!1,i)=>{const o={...ll[s]},c=fl;a&&(o.firstDayOfWeek=1);const l=new Date(e);l.setHours(0,0,0,0);const f=new Date(t);f.setHours(23,59,59,999);const d={minDate:n===te.CalendarResolution.MONTH?new Date(e.getFullYear(),e.getMonth()):l,maxDate:n===te.CalendarResolution.MONTH?new Date(t.getFullYear(),t.getMonth()):f,locale:o};return n===te.CalendarResolution.MONTH?{...d,dateFormat:"M Y",plugins:[new c({shorthand:!0,dateFormat:"M Y"})]}:{...d,monthSelectorType:"static",dateFormat:i||"d.m.Y"}},sa=e=>{e?.setMinutes(e.getMinutes()-e.getTimezoneOffset())},ml={year:"numeric",month:"short",day:"numeric"},en=(e,t)=>e?.toLocaleDateString(t,ml)||"",hl=(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 a=n?new Date(Math.max(n.getTime(),t.startPeriod.getTime())):t.startPeriod,i=s?new Date(Math.min(s.getTime(),t.endPeriod.getTime())):t.endPeriod;return{startPeriod:a,endPeriod:i}},pl=(e,t)=>{const{endPeriod:n}=e,s=n?.getFullYear()||new Date().getFullYear(),a=s+ +t,i=new Date(+t<0?s:a,n?.getMonth()||0,n?.getDate()||1),o=new Date(+t<0?a:s,0,1);return{startPeriod:new Date(Math.max(o.getTime(),e?.startPeriod?.getTime()||0)),endPeriod:i}},gl=e=>({quarterly:e?.quarterly||"Q",monthly:e?.monthly||"M"}),Sr=(e,t)=>{const n=gl(t);return y.isQuarterly(e)&&n?.quarterly?e?.replace(/Q/g,n?.quarterly):y.isMonthly(e)&&n?.monthly?e?.replace(/M/g,n?.monthly):e},Cl=(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},aa=e=>{if(!e?.length)return null;let t=null,n=null;for(const s of e){const a=s.filters?.find(l=>l.componentCode===y.TIME_PERIOD);if(!a)continue;const i=a.values.filter(Boolean),o=i[0]?te.getTimePeriod(i[0]):null,c=i[1]?te.getTimePeriod(i[1]):null;!o||!c||((!t||o<t)&&(t=o),(!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 yr=(e,t,n,s,a)=>e?.map(i=>{const o=y.findCodelistByDimension(t?.codelists,t?.conceptSchemes,i)?.codes,c=y.getAvailableCodes(i,n,o,s),l=o?.some(f=>f?.parent);return{id:i?.id,title:y.getDimensionTitle(t?.conceptSchemes,i,s),dimensionValues:c,isTimeDimension:i?.type===y.DimensionType.TIME_DIMENSION,isHierarchical:l,displayMode:l?tt.HIERARCHY:tt.FLAT_LIST,datasetUrn:a,filterType:"dataset"}})||[],$t=e=>e?.filterType==="shared",ze=e=>{if(e?.id)return $t(e)?`shared:${e.id}`:e?.datasetUrn?`${e.datasetUrn}:${e.id}`:e.id},Pe=(e,t)=>ze(e)===ze(t),tn=(e,t)=>e?.map(n=>t&&Pe(n,t)?{...t,isSelectedFilter:!0}:{...n,isSelectedFilter:!1}),Dr=(e,t,n)=>e?e.map(s=>Pe(s,t)?{...s,displayMode:n}:s):[],Mr=e=>e?.filter(t=>!!t?.isSelectedValue)||[],ln=e=>e?.map(t=>({...t,dimensionValues:Mr(t?.dimensionValues)})).filter(t=>t.dimensionValues?.length||t.timeRange?.startPeriod||t.timeRange?.endPeriod),Un=e=>e?.reduce((t,n)=>(n?.dimensionValues?.length??0)+t,0)||0,Tr=e=>({...e,dimensionValues:e?.dimensionValues?.map(t=>({...t,isSelectedValue:!1})),timeRange:void 0}),Er=(e,t)=>e?.map(n=>Pe(n,t)?Tr(n):n),Ar=e=>e?.map(t=>Tr(t)),Nr=(e,t,n)=>e.map(s=>{const a=t?.filters?.find(o=>o.componentCode===s.id);let i=[];if(a)if(s.isTimeDimension){const o=a.values.filter(h=>!!h),c=y.getAnnotationPeriod(n?.[0]?.annotations),l=o[0]?te.getTimePeriod(o[0]):null,f=o[1]?te.getTimePeriod(o[1]):null;let d=c;return l&&f&&(d=c?hl({startPeriod:l,endPeriod:f},c):{startPeriod:l,endPeriod:f}),{...s,timeRange:d}}else i=s?.dimensionValues?.map(c=>a?.values?.includes(c.id)?{...c,isSelectedValue:!0}:c);else i=s.dimensionValues;return{...s,dimensionValues:i}}),nn=e=>e?.map(t=>({...t,isDisabled:!0})),wl=e=>new Map(e?.map(t=>[t.id,{...t,children:[]}])),xl=e=>{if(!e)return[];const t=wl(e),n=[];return e.forEach(s=>{if(s&&s.parent){const a=t.get(s.parent),i=t.get(s.id);a&&a.children&&i&&(a.children=[...a.children,i])}else{const a=t.get(s.id);a&&n.push(a)}}),n},vl=(e,t=!1)=>t?`${e*M.TREE_NODE_PADDING-M.TREE_NODE_ARROW_SIZE}px`:`${e*M.TREE_NODE_PADDING}px`,kr=e=>e?.children?.reduce((t,n)=>[...t,n,...kr(n)],[])||[],bl=(e,t)=>e?e.filter(n=>!n.disabled).map(n=>({...n,isSelectedValue:t})):[],jr=e=>!!e?.children?.some(t=>t?.isSelectedValue||jr(t)),Sl=e=>{const t=kr(e);if(!e.children?.length)return[{...e,isSelectedValue:!e.isSelectedValue}];const n=(c,l)=>[{...e,isSelectedValue:c},...bl(t,l)];if(!e.isSelectableValue)return e.isSelectedValue?n(!1,!1):n(!0,!0);const s=t.filter(c=>!c.disabled),a=s.some(c=>c.isSelectedValue),i=s.length>0&&s.every(c=>c.isSelectedValue),o=!!e.isSelectedValue;return!o&&!a?n(!0,!0):o&&i?n(!1,!0):!o&&a?n(!0,!1):o&&!a?n(!1,!1):n(!0,!0)},yl=(e,t)=>e.filter(n=>n.isSelectableValue&&!t.has(n.id)).map(n=>({id:n.id,name:n.name,isSelectedValue:n.isSelectedValue})),Dl=({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})`}))],Ml=({calendarResolution:e,timeRange:t,timeRangeOptions:n,calendarStartFromMonday:s=!0,locale:a=te.Locale.EN,radioIcon:i,initialConstraints:o,onValueChange:c,calendarIcon:l,dateFormat:f,defaultTimeOption:d,dataQueries:h})=>{const{titles:m}=ye(),p=Cl(y.getAnnotationPeriod(o?.[0]?.annotations),t),b=!!!(p?.startPeriod||p?.endPeriod)&&!t?aa(h):null,C=b??p,[x,w]=u.useState(t??b),v=!t||t?.startPeriod?.getTime()===C?.startPeriod?.getTime()&&t?.endPeriod?.getTime()===C?.endPeriod?.getTime()?0:te.CUSTOM_PERIOD,[S,k]=u.useState(d??v),T=u.useMemo(()=>{const{startPeriod:A,endPeriod:j}=C,O=A?.getFullYear(),L=j?.getFullYear(),$=new Date().getFullYear();return n.filter(J=>J.value===te.CUSTOM_PERIOD||J.value===0||+J.value>=0&&L-$>=+J.value||+J.value<0&&O-$<+J.value)},[C,n]);u.useEffect(()=>{c(x,S)},[x]),u.useEffect(()=>{if(t!==null)return;const A=y.getAnnotationPeriod(o?.[0]?.annotations);A?.startPeriod||A?.endPeriod||w(aa(h))},[t]);const N=A=>{A&&(sa(A),w(j=>j?{...j,startPeriod:A||null}:{endPeriod:null,startPeriod:A||null}))},D=A=>{A&&(sa(A),w(j=>j?{...j,endPeriod:A||null}:{startPeriod:null,endPeriod:A||null}))};if(C==null)return null;const R=na(C.startPeriod,x?.endPeriod||C.endPeriod,e,a,s,f),E=na(x?.startPeriod||C.startPeriod,C.endPeriod,e,a,s,f);return r.jsxs("div",{className:"mt-3 flex h-full min-w-0 flex-1 flex-col overflow-auto py-2 pr-3",children:[r.jsx("div",{className:"w-full",children:T.map(A=>r.jsx(M.Radio,{id:A.value.toString(),checked:S===A.value,label:A.title,onChange:()=>{const{value:j}=A;k(j),j!==te.CUSTOM_PERIOD&&w(j===0?C:pl(C,j))},radioIcon:i},A.value.toString()))}),r.jsx("div",{className:"w-full",children:S===te.CUSTOM_PERIOD&&r.jsxs("div",{className:"filters-time-period caption mt-3 flex gap-4 text-neutral-700",children:[r.jsx(M.Calendar,{onChange:N,options:R,value:x?.startPeriod||C?.startPeriod,label:m?.from||"From",id:"time-options-start",icon:l}),r.jsx(M.Calendar,{onChange:D,options:E,value:x?.endPeriod||C?.endPeriod,label:m?.to||"To",id:"time-options-end",icon:l,isEndDate:!0})]})})]})},Tl={isMetadataInSidePanel:!1,isCrossDatasetModeOn:!1,isTableSettingsFeatureEnabled:!1},Ir=u.createContext(Tl);function El({children:e,isMetadataInSidePanel:t=!1,isCrossDatasetModeOn:n=!1,isTableSettingsFeatureEnabled:s=!1}){const a=u.useMemo(()=>({isMetadataInSidePanel:t,isCrossDatasetModeOn:n,isTableSettingsFeatureEnabled:s}),[t,n,s]);return r.jsx(Ir.Provider,{value:a,children:e})}function Ue(){return u.useContext(Ir)}const Al=2,Lr=({value:e,onChange:t,searchIconSize:n})=>{const{titles:s}=ye(),{isCrossDatasetModeOn:a}=Ue(),[i,o]=u.useState(!1),c=e.trim().toLowerCase(),l=a&&i&&c.length<Al;return r.jsxs(r.Fragment,{children:[r.jsx(M.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:()=>o(!0),onBlur:()=>o(!1),iconBeforeInput:r.jsx(Ve.IconSearch,{width:n,height:n,className:"text-primary"})}),a&&r.jsx("span",{className:W("caption text-neutrals-800 mt-1",{invisible:!l}),children:s?.searchMinCharsCaption??"Enter at least 2 characters to start searching"})]})},Nl=e=>Ae.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ae.createElement("path",{d:"M6.25 4.66668L9.75 8.00001L6.25 11.3333L6.25 4.66668Z",fill:"currentColor"})),Pr=({node:e,level:t=1,checkboxIcon:n,selectFilterValue:s,selectHierarchicalNodes:a,expandHierarchicalValue:i})=>{const o=!!e?.children?.length,c=o&&!e.isSelectedValue&&jr(e),l="cursor-pointer text-neutrals-1000 w-6 h-6 shrink-0",f=u.useId(),d=(h,m)=>{if(e?.children?.length){const p=e.children.some(g=>!g.disabled);a?.(p?Sl(e):[{...e,isSelectedValue:m}])}else s?.(e.id,m)};return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"flex items-center",style:{paddingLeft:vl(t,o)},children:[o&&(e?.isExpanded?r.jsx(Nl,{className:l,onClick:()=>i?.(e)}):r.jsx(Hn,{className:l,onClick:()=>i?.(e)})),r.jsx(M.Checkbox,{id:f,label:e?.name,checked:!!e.isSelectedValue,indeterminate:c,checkboxIcon:n,disabled:e?.disabled,onChange:d})]}),o&&e?.isExpanded&&r.jsx(r.Fragment,{children:e?.children?.map(h=>r.jsx(Pr,{node:h,level:t+1,checkboxIcon:n,selectFilterValue:s,selectHierarchicalNodes:a,expandHierarchicalValue:i},h?.id))})]},e?.id)},kl=({treeNodes:e,checkboxIcon:t,selectFilterValue:n,selectHierarchicalNodes:s,expandHierarchicalValue:a})=>r.jsx(r.Fragment,{children:e?.map(i=>r.jsx(Pr,{node:i,checkboxIcon:t,selectFilterValue:n,selectHierarchicalNodes:s,expandHierarchicalValue:a},i?.id))}),ra=({style:e,filterValue:t,checkboxIcon:n,selectFilterValue:s})=>r.jsx("div",{style:e,children:r.jsx(M.Checkbox,{id:t.id,label:t.name,checked:!!t.isSelectedValue,checkboxIcon:n,onChange:s})}),Jt=(e,t,n,s,a=te.Locale.EN)=>{const i=t?.map(o=>{const c=y.findCodelistByDimension(n?.codelists,n?.conceptSchemes,o),l=y.getAvailableCodesFromConstrains(c?.codes,o.id,s,a);return{...o,dimensionValues:l}});return e?.map(o=>{const c=i?.find(m=>m.id===o.id),f=(c?.dimensionValues||[]).map(m=>{const p=o.dimensionValues?.find(g=>g?.id===m?.id)?.isSelectedValue;return{...m,isSelectedValue:p}}),d=new Set(f.map(m=>m.id)),h=c?(o.dimensionValues??[]).filter(m=>!!m.isSelectedValue&&!d.has(m.id)):[];return{...o,isDisabled:!1,dimensionValues:[...f,...h]}})||[]},kn=(e,t,n)=>{let s=[];return cn(e,t,n).filter(a=>a.timeRange||a.dimensionValues?.some(i=>i.isSelectedValue)).forEach(a=>{const{id:i,dimensionValues:o}=a;a.isTimeDimension?s=[...s,...jl(a.timeRange,i)]:s.push({componentCode:i,operator:y.SeriesFilterOperator.EQUALS,value:o?.filter(c=>c.isSelectedValue)?.map(c=>c.id).join(y.GET_v3_FILTER_AND)||""})}),s},jl=(e,t)=>e==null||e.startPeriod==null||e.endPeriod==null?[]:[{componentCode:t,operator:y.SeriesFilterOperator.GREATER_OR_EQUAL,value:ia(new Date(e.startPeriod))},{componentCode:t,operator:y.SeriesFilterOperator.LESS_OR_EQUAL,value:ia(new Date(e.endPeriod),1)}],Il=1e3*60*60*24,ia=(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?Il-1:0,e=new Date(n),n.toString()},kt=e=>[...e].map(t=>({...t,value:t.value.split(",").sort().join(",")})).sort((t,n)=>t.componentCode.localeCompare(n.componentCode)),At=new Map,Kt=new Map;function Rr(e,t){return`${e.name??""}::${t}`}function st(...e){return JSON.stringify(e)}async function at(e,t,n){const s=Rr(e,t);if(At.has(s))return At.get(s);const a=Kt.get(s);if(a)return a;const i=n().then(o=>(At.set(s,o),o)).finally(()=>{Kt.delete(s)});return Kt.set(s,i),i}function jn(e,t){return At.has(Rr(e,t))}function oa(){At.clear(),Kt.clear()}const Ll=e=>e.map(t=>({componentCode:t.id||"",operator:te.QueryFilterType.IN,values:t.dimensionValues?.map(n=>n.id)||[]})),Fr=(e,t)=>{const n=t?.timeDimensions?.[0],s=y.getTimeRangeFromAttachment(e,n)||null;return s?y.getQueryTimePeriodFilters(s,n?.id):null},Or=(e,t,n)=>{const s=ln(cn(e,n)),a=s.find(i=>i?.isTimeDimension&&i?.timeRange);return{filterKey:y.getTimeSeriesFilterKey(t||[],Ll(s)),timeFilter:y.getQueryTimePeriodFilters(a?.timeRange,a?.id)}},Pl=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}`},Rl=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}`},_r=(e,t,n=Pl)=>cn(e,t)?.filter(s=>s.timeRange||s.isExcluded||s.dimensionValues?.some(a=>a.isSelectedValue)).map(s=>s?.isTimeDimension?{componentCode:s?.id,operator:te.QueryFilterType.BETWEEN,values:[n(s?.timeRange?.startPeriod||void 0)||"",n(s?.timeRange?.endPeriod||void 0)||""]}:s.isExcluded?{componentCode:s?.id,operator:te.QueryFilterType.EXCLUDED,values:[]}:{componentCode:s?.id,operator:te.QueryFilterType.IN,values:s?.dimensionValues?.filter(a=>a.isSelectedValue)?.map(a=>a.id)||[]}),Fl=(e,t)=>{const n=cn(e,t).flatMap(a=>a.id?[a.id]:[]),s=e.flatMap(a=>{if(a.filterType!=="shared")return[];const i=a.sourceFilterIdsByDataset?.[t];return i?[i]:[]});return new Set([...n,...s])},Ol=(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:te.QueryFilterType.IN,values:[y.GET_v3_FILTER_ALL]}))},Vr=(e,t)=>{const n=_l(t,e.urn),s=Fl(t,e.urn),a=Ol(s,n),i=(e.filters??[]).filter(o=>!s.has(o.componentCode));return{...e,filters:[...i,...n,...a]}},Hr=(e,t)=>_r(e,t),_l=(e,t)=>_r(e,t,Rl),Ur="COUNTRY",Br="FREQUENCY",Ct="TIME_PERIOD",Vl=new Set([Ur,Br,Ct]),Yt=e=>e?.trim()?.toLocaleUpperCase(),la=()=>(e,t)=>{const n=e?.name?.trim()?.toLocaleLowerCase();return n?Hl(n):Ul(t||"",e.id)},Hl=e=>`name:${e}`,Ul=(e,t)=>`dataset:${e}:id:${t}`,Gr=(e,t)=>e?t?.[e]:void 0,ca=(e,t)=>{if(!(e?.filterType!=="dataset"||!e.id))return Gr(e.datasetUrn,t)?.[e.id]},zr=(e,t,n)=>Object.entries(Gr(e,n)||{}).find(([,s])=>t(s))?.[0],Wr=(e,t,n)=>zr(e,s=>s.subtype===t,n),Bl=(e,t)=>zr(e,n=>n.dimensionType==="TIME_PERIOD",t),xt=[{id:Ur,subtype:"REGION",getMergedValueKey:la()},{id:Br,subtype:"FREQUENCY",getMergedValueKey:la()},{id:Ct,getMergedValueKey:e=>e.id}],Gl=new Map(xt.map(e=>[e.id,e])),Bn=e=>e?Gl.get(Yt(e)||""):void 0,zl=(e,t,n)=>{if(e.filterType==="shared")return t.id===Yt(e.id);if(t.id===Ct)return e.isTimeDimension||ca(e,n)?.dimensionType==="TIME_PERIOD"||t.id===Yt(e.id);const s=ca(e,n);return t.subtype&&s?.subtype===t.subtype?!0:t.id===Yt(e.id)},sn=(e,t)=>e?xt.find(n=>zl(e,n,t)):void 0,Wl=(e,t,n)=>{if(!t)return;const s=e?n?.[e]?.[t]:void 0;return s?.dimensionType==="TIME_PERIOD"?Ct:xt.find(i=>!!i.subtype&&i.subtype===s?.subtype)?.id??Bn(t)?.id},$l=e=>!!Bn(e),Jl=e=>e?.filterType==="shared"&&$l(e?.id),$r=(e,t)=>!e||Array.isArray(e.get(t)),Jr=(e,t)=>!e?.dataMessagesMap||e.dataMessagesMap.has(t),Kl=(e,t)=>{const n=new Map;return e.forEach(s=>{s.dimensionValues?.forEach(a=>{const i=t.getMergedValueKey(a,s.datasetUrn),o={datasetUrn:s.datasetUrn,id:a.id,name:a.name,parent:a.parent},c=n.get(i);if(c){c.isSelectedValue=c.isSelectedValue||a.isSelectedValue,c.sourceValues=[...c.sourceValues||[],o];return}n.set(i,{id:i,name:a.name,isSelectedValue:a.isSelectedValue,parent:a.parent,sourceValues:[o]})})}),Array.from(n.values())},Kr=(e,t)=>{const n=new Map,s=[];return e.forEach(i=>{const o=sn(i,t);if(o&&i?.datasetUrn){const c=n.get(o.id)||[];n.set(o.id,[...c,i]);return}s.push(i)}),[...xt.flatMap(i=>{const o=n.get(i.id);if(!o?.length)return[];const c={...o[0],id:i.id,datasetUrn:void 0,filterType:"shared",sourceDatasetUrns:Array.from(new Set(o.map(l=>l.datasetUrn).filter(l=>!!l))),sourceFilterIdsByDataset:Object.fromEntries(o.flatMap(l=>l.datasetUrn&&l.id?[[l.datasetUrn,l.id]]:[])),dimensionValues:Kl(o,i)};return c.isTimeDimension&&(c.timeRange=Ql(o)),c}),...s]},Gn=(e,t,n)=>{const s=e.sourceFilterIdsByDataset?.[t];if(s)return s;if(e.id===Ct)return Bl(t,n);const a=Bn(e.id);return a?.subtype?Wr(t,a.subtype,n):void 0},Yr=(e,t,n,s)=>({...e,id:Gn(e,t,s)||e.id,datasetUrn:t,filterType:"dataset",...n?{dimensionValues:n}:{}}),Yl=(e,t)=>(e.sourceDatasetUrns||[]).map(n=>Yr(e,n,void 0,t)),ql=(e,t)=>({id:t.id,name:t.name,parent:t.parent,isSelectedValue:e.isSelectedValue}),Zl=(e,t)=>{const n=new Map;return e.dimensionValues?.forEach(s=>{s.sourceValues?.forEach(a=>{const i=a.datasetUrn||"",o=n.get(i),c=ql(s,a);if(o){o.dimensionValues=[...o.dimensionValues||[],c];return}n.set(i,Yr(e,i,[c],t))})}),n},Xl=(e,t=!1,n)=>{if(!Jl(e))return[e];if(e.isTimeDimension)return Yl(e,n);const s=Zl(e,n);return Array.from(s.values())},Ql=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())))}},qr=(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)},ec=(e,t)=>{if(!e.isTimeDimension||!e.timeRange)return e;const{startPeriod:n,endPeriod:s}=y.getAnnotationPeriod(t?.[0]?.annotations);return!n||!s?e:{...e,timeRange:qr(e.timeRange.startPeriod,e.timeRange.endPeriod,n,s)}},tc=(e,t)=>e?.dimensionsMap?new Map(Array.from(e.dimensionsMap.entries()).map(([n,s])=>[n,yr(s,e?.structuresMap?.get(n),e?.structureDimensionsMap?.get(n),t,n)])):new Map,nc=(e,t,n=!0)=>new Map(Array.from(e?.dimensionsMap?.entries()||[]).map(([s,a])=>{const i=$r(e?.constraintsMap,s),o=Jr(e,s),c=a?.map(l=>{if(!i||n&&!o)return{...l,dimensionValues:[]};const f=y.findCodelistByDimension(e?.structuresMap?.get(s)?.codelists,e?.structuresMap?.get(s)?.conceptSchemes,l),d=y.getAvailableCodesFromConstrains(f?.codes,l.id,e?.constraintsMap?.get(s),t);return{...l,dimensionValues:d}})||[];return[s,c]})),sc=e=>e.map(t=>({...t,isDisabled:!1,dimensionValues:t.dimensionValues?.filter(n=>n.isSelectedValue)||[]})),Zr=(e,t,n=!0)=>{const s=tc(e,t),a=nc(e,t,n);return new Map(Array.from(s?.entries()||[]).map(([i,o])=>{const c=a?.get(i),l=o.map(f=>({...f,dimensionValues:c?.find(d=>d.id===f.id)?.dimensionValues||[]}));return[i,l]}))},Xr=(e,t,n,s)=>{const a=(i,o)=>t?.some(c=>c.urn!==i.urn&&c.filters?.some(l=>l.operator===te.QueryFilterType.BETWEEN||!l.values?.length?!1:sn({id:l.componentCode,datasetUrn:c.urn,filterType:"dataset"},s)?.id===o.id))??!1;return Kr(t?.flatMap(i=>{const o=i?.urn,c=e?.get(o)||[],l=n?.get(o)||[];return Nr(c,i,l).map(d=>{if(d.isTimeDimension||d.filterType!=="dataset")return d;const h=sn(d,s);return!h||h.id===Ct||i.filters?.some(g=>g.componentCode===d.id&&g.operator!==te.QueryFilterType.BETWEEN)||!a(i,h)||d.dimensionValues?.some(g=>g.isSelectedValue)?d:{...d,dimensionValues:d.dimensionValues?.map(g=>({...g,isSelectedValue:!0}))}})})||[],s)},Nt=(e,t,n=!1,s,a=new Set)=>{const i=e?.flatMap(o=>Xl(o,n,s))?.reduce((o,c)=>{const l=c?.datasetUrn||"",f=ec(c,t?.get(l));return o.has(l)||o.set(l,[]),o?.get(l)?.push(f),o},new Map);if(a.size>0)for(const o of a)i.delete(o);return i},Qr=(e,t,n,s,a)=>{const i=e.filter(c=>c.filterType==="shared"&&!c.isTimeDimension&&(c.dimensionValues?.some(l=>l.isSelectedValue)??!1));if(!i.length)return new Set(t);const o=(c,l)=>{const f=Gn(l,c,s);if(!f)return!1;if(a)return!(a.get(c)??[]).find(p=>p.id===f);const d=n?.find(h=>h.urn===c);return d?!d.filters?.some(h=>h.componentCode===f&&h.operator!==te.QueryFilterType.BETWEEN):!1};return new Set(t.filter(c=>i.every(l=>l.dimensionValues?.some(f=>f.isSelectedValue&&f.sourceValues?.some(d=>d.datasetUrn===c))||o(c,l))))},da=(e,t)=>t?(e||[]).filter(n=>t.has(n.urn)):e||[],St=(e,t)=>t?new Map([...e].filter(([n])=>t.has(n))):e,ei=(e,t)=>{const n=new Map;if(e?.forEach(s=>{s.filters?.forEach(a=>{if(a.operator===te.QueryFilterType.BETWEEN||!a.values?.length)return;const i=sn({id:a.componentCode,datasetUrn:s.urn,filterType:"dataset"},t);if(!i||i.id===Ct)return;const o=n.get(i.id)??new Set;o.add(s.urn),n.set(i.id,o)})}),!!n.size)return e?.filter(s=>Array.from(n.values()).every(a=>a.has(s.urn))).map(s=>s.urn)??[]},ac=(e,t)=>t?Array.from(new Set(e?.flatMap(n=>n.cubeRegions?.filter(s=>s.isIncluded).flatMap(s=>s.memberSelection?.filter(a=>a.componentId===t).flatMap(a=>a.selectionValues.map(i=>i.memberValue))??[])??[])??[])):[],rc=(e,t,n)=>{if(e.length<2||!t)return e;const s=e.flatMap(o=>xt.flatMap(c=>{if(!c.subtype)return[];const l=Wr(o.urn,c.subtype,n);return l?[{configId:c.id,dataQuery:o,dimensionId:l,filter:o.filters?.find(f=>f.componentCode===l&&f.operator!==te.QueryFilterType.BETWEEN),availableValues:ac(t.get(o.urn),l)}]:[]})),a=new Map;s.forEach(o=>{a.set(o.configId,[...a.get(o.configId)??[],o])});const i=new Map;return a.forEach(o=>{const c=o.filter(d=>d.filter?.values?.length),l=o.filter(d=>!d.filter);if(!c.length||!l.length)return;const f=new Set(l.flatMap(d=>d.availableValues));f.size&&c.forEach(d=>{const h=d.filter;if(!h?.values?.length)return;const m=new Set(d.availableValues),p=Array.from(new Set([...h.values,...Array.from(f).filter(g=>m.has(g))]));p.length>h.values.length&&i.set(h,p)})}),i.size?e.map(o=>{let c=!1;const l=o.filters?.map(f=>{const d=i.get(f);return d?(c=!0,{...f,values:d}):f});return c?{...o,filters:l}:o}):e},ti=e=>JSON.stringify(e?.map(t=>({urn:t.urn,filters:t.filters??[]}))??[]),yt=(e,t,n=te.Locale.EN,s)=>{const a=[];return Array.from(e?.entries())?.forEach(([i,o])=>{const c=t?.dimensionsMap?.get(i),l=t?.structuresMap?.get(i),f=$r(t?.constraintsMap,i),d=Jr(t,i);if(!f||!d){a.push(...sc(o));return}const h=t?.constraintsMap?.get(i);a.push(...Jt(o,c,l,h,n))}),Kr(a,s)},cn=(e,t,n)=>t?Nt(e,void 0,!1,n).get(t)||[]:e.filter(s=>s.filterType!=="shared"),ni=(e,t)=>{if(e?.filterType==="shared")return;const n=e?.datasetUrn?t?.get(e.datasetUrn)?.dataflows?.[0]:void 0;return n?y.generateShortUrn(n?.name,"",n?.agencyID):void 0},ic=(e,t)=>e?.length?!!t?.dimensionsMap&&!!t?.structuresMap&&!!t?.structureDimensionsMap&&!!t?.constraintsMap:!1,si=(e,t,n)=>kt(kn(t,e,n).filter(s=>s.componentCode!==y.TIME_PERIOD)),ua=(e,t,n,s,a)=>e?.map(i=>{const o=i?.urn??"",c=a??t?.get(o)??[],l=si(o,c,s);return n?at(n.getConstraints,st(o,l),()=>n.getConstraints(o,l)).then(f=>({urn:o,data:f})):Promise.resolve({urn:o,data:{}})})||[],fa=(e,t,n,s,a)=>!n?.getConstraints||!e?.length?!1:e.some(i=>{const o=i?.urn??"",c=a??t?.get(o)??[],l=si(o,c,s);return!jn(n.getConstraints,st(o,l))}),oc=(e,t,n)=>{if(e.length<2)return!1;const s=new Map;for(const a of e){const i=t.dimensionsMap?.get(a.urn);if(i)for(const o of i){const c=o.id;if(!c)continue;const l=n?.[a.urn]?.[c],f=l?.subtype;if(!f||l?.dimensionType==="TIME_PERIOD")continue;const d=xt.find(p=>p.subtype===f);if(!d)continue;const h=s.get(d.id)??{datasetsWithExplicitValues:new Set,datasetsWithMissingFilter:new Set},m=a.filters?.find(p=>p.componentCode===c&&p.operator!==te.QueryFilterType.BETWEEN);m?m.values?.length&&h.datasetsWithExplicitValues.add(a.urn):h.datasetsWithMissingFilter.add(a.urn),s.set(d.id,h)}}return[...s.values()].some(a=>[...a.datasetsWithMissingFilter].some(i=>[...a.datasetsWithExplicitValues].some(o=>o!==i)))},lc=e=>new Map(e?.flatMap(({urn:t,data:n})=>{const s=n?.data?.dataConstraints;return Array.isArray(s)?[[t,s]]:[]})),ma=e=>lc(e.flatMap(t=>t.status==="fulfilled"?[t.value]:[])),ha=(e,t)=>{const n=new Map(e);return t.forEach((s,a)=>{n.set(a,s)}),n},ai=(e,t,n,s)=>{if(e&&t?.filterType==="shared"&&t?.isTimeDimension){const i=Array.from(s?.values()||[]).flatMap(l=>l||[]).map(l=>y.getAnnotationPeriod(l?.annotations)).filter(l=>l.startPeriod!==null&&l.endPeriod!==null);if(!i.length)return[];const o=new Date(Math.min(...i.map(l=>l.startPeriod.getTime()))),c=new Date(Math.max(...i.map(l=>l.endPeriod.getTime())));return[{id:t.id||y.TIME_PERIOD,annotations:[{id:y.TIME_PERIOD_START_ANNOTATION_KEY,title:o.toISOString()},{id:y.TIME_PERIOD_END_ANNOTATION_KEY,title:c.toISOString()}]}]}return e?s?.get(t?.datasetUrn??"")??[]:n??[]},ri=(e,t,n)=>new Map(t?.map(s=>{const a=s?.urn;return[a,Or(e.get(a)||[],n?.get(a))]})),pa=(e,t,n,s,a)=>{const i=oc(e,t,a);if(!n||!e.length||!i)return;const o={...t,constraintsMap:n},c=Zr(o,s,!1),l=Xr(c,e,n,a),f=Nt(l,n,!1,a),d=Qr(l,e.map(m=>m.urn),e,a,f),h=e.filter(m=>d.has(m.urn));return{compatibleUrns:d,filterParamsMap:ri(f,h,t.dimensionsMap)}},ii=(e,t)=>new Map(e?.map(n=>{const s=n?.urn;return[s,Hr(t?.get(s)||[])]})),cc=(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 a=s.map(c=>y.getAnnotationPeriod(n.get(c)?.[0]?.annotations)).filter(c=>!!c?.startPeriod&&!!c?.endPeriod);if(a.length===0)return[{...e,sourceDatasetUrns:s}];const i=new Date(Math.min(...a.map(c=>c.startPeriod.getTime()))),o=new Date(Math.max(...a.map(c=>c.endPeriod.getTime())));return[{...e,sourceDatasetUrns:s,timeRange:qr(e.timeRange.startPeriod,e.timeRange.endPeriod,i,o)}]},dc=(e,t,n)=>t.size===0?e:e.flatMap(s=>{if(s.filterType!=="shared")return[s];if(s.isTimeDimension)return cc(s,t,n);const a=(s.dimensionValues??[]).filter(i=>i.sourceValues?.some(o=>!t.has(o.datasetUrn??"")));return a.length===0?[]:[{...s,dimensionValues:a}]}),zn=e=>Ae.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ae.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"})),uc=e=>Ae.createElement("svg",{viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ae.createElement("path",{d:"M6.66663 6.175L10.4833 10L6.66663 13.825L7.84163 15L12.8416 10L7.84163 5L6.66663 6.175Z",fill:"currentColor"})),fc=Eo.FixedSizeList,ga=24,Ca=232,Sn=({selectedFilter:e,filterValues:t,checkboxIcon:n,isHierarchicalView:s,isVirtualized:a=!0,isScrollable:i=!0,isDisableValues:o,isValuesLoading:c,structuresMap:l,hierarchyTreeNodes:f,isHierarchyLoading:d,selectFilterValue:h,selectHierarchicalNodes:m,expandHierarchicalValue:p})=>{const g=M.useIsMobile(),{isCrossDatasetModeOn:b}=Ue(),C=c||d;if(!t&&!C)return null;const x=t??[],w=e?ni(e,l):void 0,v=l?.size===1,S=b&&e?.filterType!=="shared"&&!!e?.title&&(v||!!w),k=x.length*ga,T=k>Ca?Ca:k;return r.jsxs("div",{className:W("relative",o&&"pointer-events-none opacity-[0.7]",i?"flex h-full min-h-0 flex-col":"flex flex-col"),children:[S&&r.jsxs("div",{className:"mb-2 flex items-center gap-x-1",children:[!v&&r.jsxs(r.Fragment,{children:[r.jsx(zn,{className:"size-4 shrink-0 text-neutrals-700"}),r.jsx("span",{className:"h4 text-neutrals-800",children:w}),r.jsx(uc,{className:"size-4 shrink-0 text-neutrals-1000"})]}),r.jsx("span",{className:"h4 text-neutrals-1000",children:e?.title})]}),C&&r.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 min-h-12",children:r.jsx(M.Loader,{})}),r.jsx("div",{className:W(i?"min-h-0 flex-1 overflow-auto":"overflow-visible",C&&"pointer-events-none opacity-[0.7]"),style:i&&g&&!C?{height:`${T}px`}:void 0,children:f?.length||s?r.jsx(kl,{treeNodes:f??xl(x),checkboxIcon:n,selectFilterValue:h,selectHierarchicalNodes:m,expandHierarchicalValue:p}):a?r.jsx(Ao,{children:({width:N,height:D})=>r.jsx(fc,{itemCount:x.length,itemSize:ga,width:N,height:D,children:({index:R,style:E})=>r.jsx(ra,{style:E,filterValue:x[R],checkboxIcon:n,selectFilterValue:h})})}):r.jsx("div",{className:"flex flex-col gap-y-1",children:x.map(N=>r.jsx(ra,{filterValue:N,checkboxIcon:n,selectFilterValue:h},N.id))})})]})};function mc(e,t){const n=(e??"").split(".").map(Number),s=(t??"").split(".").map(Number),a=Math.max(n.length,s.length);for(let i=0;i<a;i++){const o=(n[i]??0)-(s[i]??0);if(o!==0)return o}return 0}function hc(e){const t=new Map;for(const n of e){const s=`${n.agencyID??""}:${n.id}`,a=t.get(s);(!a||mc(n.version??"",a.version??"")>0)&&t.set(s,n)}return Array.from(t.values())}function wa(e){return y.generateShortUrn(e.id,e.version??"",e.agencyID??"")}function xa(e,t,n,s,a){const i=y.getHierarchyCodes(e,t),o=y.getHierarchyAvailableCodes(i,n,s),c=y.getCodeListsData(t),l=pc(e,c,o.map(f=>f.id),a);return li(l)}function oi(e,t,n,s,a){return s?.map(i=>{const{childId:o,agency:c,id:l,version:f}=y.getChildParsedUrn(i.code),d=y.generateShortUrn(l,f,c),h=Object.keys(e??{}).find(v=>y.urnMatchesIgnoreVersion(v,d))??d,p=e?.[h]?.find(v=>v.id===o),g=p?.name||p?.description||o,b=n?y.urnMatchesIgnoreVersion(d,n):!0,C=!b&&(i.hierarchicalCodes?.length??0)>0,x=oi(e,t,n,i.hierarchicalCodes,i.code),w=x.length===0;return C&&w||b&&w&&t&&!t.includes(o??"")?null:{id:i.code,name:g,children:x,isExpanded:!0,disabled:!b&&x.every(v=>v.disabled),isSelectableValue:b,parent:a,metadata:{...i,hierarchicalCodes:void 0}}}).filter(i=>i!==null)??[]}function pc(e,t,n,s){return!n||n.length===0?[]:oi(t,n,s,e?.hierarchicalCodes,void 0)}function li(e){return e.map(t=>{const{childId:n}=y.getChildParsedUrn(t.id??"");return{id:n??t.id??"",name:t.name,isExpanded:t.isExpanded,isSelectedValue:!1,disabled:t.disabled,isSelectableValue:t.isSelectableValue,children:li(t.children)}})}function ci(e,t){return e?.filterType!=="shared"?t:e.dimensionValues?.find(n=>n.id===t||n.sourceValues?.some(s=>s.id===t))?.id}function gc(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 Cc(e,t){if(!e?.length||t?.filterType!=="shared")return e??[];const n=new Map;return e.forEach(s=>{const a=ci(t,s.id);a&&n.set(a,{...s,id:a})}),Array.from(n.values())}function wc(e,t){return ci(t,e)}function di(e,t){return e.map(n=>{const s=n.children?.length?di(n.children,t):n.children;let a;if(t.has(n.id))a=!0;else if(s?.length&&!n.isSelectableValue){const i=s.filter(o=>!o.disabled);a=i.length>0&&i.every(o=>!!o.isSelectedValue)}else a=!1;return{...n,isSelectedValue:a,children:s}})}function ui(e,t){return e.map(n=>n.id===t?{...n,isExpanded:!n.isExpanded}:n.children?.length?{...n,children:ui(n.children,t)}:n)}function fi(e,t){const n=t.toLowerCase();return e.reduce((s,a)=>{const i=a.name?.toLowerCase().includes(n),o=fi(a.children??[],t);return(i||o.length>0)&&s.push({...a,isExpanded:!0,children:i?a.children:o}),s},[])}const mi=u.createContext(null);function xc({children:e,value:t}){return r.jsx(mi.Provider,{value:t,children:e})}function hi(){const e=u.useContext(mi);if(!e)throw new Error("useFiltersModal must be used within FiltersModalProvider");return e}const vc=2,pi=({filtersList:e,selectedFilter:t,initialConstraints:n,structuresMap:s,selectedTimeOption:a,hierarchyState:i})=>{const{titles:o}=ye(),{locale:c,isDisableValues:l,isValuesLoading:f,timeRangeOptions:d,filterValuesProps:h,dataQueries:m,selectFilterValue:p,selectHierarchicalNodes:g,expandHierarchicalValue:b,onTimePeriodChange:C}=hi(),[x,w]=u.useState(""),{isCrossDatasetModeOn:v}=Ue(),S=t?.displayMode===tt.HIERARCHY,k=ze(t),T=t?.filterType==="shared",N=x?.trim().toLowerCase(),D=v?N.length>=vc:!!N,R=D&&v&&!T,E=u.useCallback(H=>{if(!H?.dimensionValues)return{filterValues:[],matchedCount:0};const K=H.dimensionValues.filter(z=>z?.name?.toLowerCase()?.includes(N));return{filterValues:H.displayMode===tt.HIERARCHY?y.getFilteredItemsWithParents(H.dimensionValues,K):K,matchedCount:K.length}},[N]),A=u.useMemo(()=>D?E(t).filterValues:t?.dimensionValues,[D,E,t]),j=u.useMemo(()=>R?(e||[]).reduce((H,K)=>{if(Pe(K,t)||K.filterType==="shared")return H;const{filterValues:z,matchedCount:ne}=E(K);return ne?[...H,{filter:K,filterValues:z,matchedCount:ne,isHierarchicalView:K.displayMode===tt.HIERARCHY}]:H},[]):[],[R,e,t,E]),O=u.useMemo(()=>{const H=i?.treeNodes;if(!H?.length)return H;const K=gc(t),z=K.size?di(H,K):H;return D?fi(z,N):z},[i?.treeNodes,t,D,N]),L=O?!O.length:!A?.length,$=!!f||!!i?.isLoading,J=u.useMemo(()=>j.reduce((H,K)=>H+K.matchedCount,0),[j]);u.useEffect(()=>{w("")},[k]);const q=u.useCallback(H=>{w(H)},[w]);return r.jsx(r.Fragment,{children:t?.isTimeDimension&&n?r.jsx(Ml,{initialConstraints:n,calendarResolution:te.CalendarResolution.DAY,timeRange:t?.timeRange||null,timeRangeOptions:d||[],calendarStartFromMonday:!0,locale:c,radioIcon:h?.radioIcon,onValueChange:C,calendarIcon:h?.calendarIcon,dateFormat:h?.dateFormat,defaultTimeOption:a,dataQueries:m}):r.jsxs("div",{className:W("flex flex-col py-2 h-full flex-1 min-w-0 sm:border-0","filter-values-container"),children:[r.jsx(Lr,{value:x,onChange:q,searchIconSize:h?.searchIconSize}),r.jsx("div",{className:"body-2 mt-3 flex min-h-0 flex-1 flex-col overflow-auto",children:R?r.jsxs(r.Fragment,{children:[t&&r.jsxs("div",{className:"shrink-0 pb-4",children:[r.jsx(Sn,{selectedFilter:t,filterValues:A,checkboxIcon:h?.checkboxIcon,isHierarchicalView:S,isVirtualized:!1,isScrollable:!1,isDisableValues:l,isValuesLoading:f,structuresMap:s,hierarchyTreeNodes:O,isHierarchyLoading:i?.isLoading,selectFilterValue:p,selectHierarchicalNodes:g,expandHierarchicalValue:b}),!$&&L&&r.jsx("span",{className:"body-2 text-neutrals-700",children:o?.noResultsInSection?.(t.title??"")??`No results found in ${t.title??""}`})]}),r.jsxs("div",{className:"pb-3",children:[r.jsxs("span",{className:"h2 text-neutrals-1000",children:[o?.otherResults??"Other results",":"," ",J]}),!f&&J===0&&r.jsx("p",{className:"body-2 mt-1 text-neutrals-700",children:o?.noResultsInOtherDimensions??"No results found in other dimensions"})]}),j.map(({filter:H,filterValues:K,isHierarchicalView:z})=>r.jsx("div",{className:"shrink-0 pb-4 last:pb-0",children:r.jsx(Sn,{selectedFilter:H,filterValues:K,checkboxIcon:h?.checkboxIcon,isHierarchicalView:z,isVirtualized:!1,isScrollable:!1,isDisableValues:l,isValuesLoading:f,structuresMap:s,selectFilterValue:(ne,se)=>p(ne,se,H),selectHierarchicalNodes:ne=>g(ne,H),expandHierarchicalValue:ne=>b(ne,H)})},ze(H)))]}):r.jsx(Sn,{selectedFilter:t,filterValues:A,checkboxIcon:h?.checkboxIcon,isHierarchicalView:S,isDisableValues:l,isValuesLoading:f,structuresMap:s,hierarchyTreeNodes:O,isHierarchyLoading:i?.isLoading,selectFilterValue:p,selectHierarchicalNodes:g,expandHierarchicalValue:b})})]})})},bc=({filtersList:e,filter:t,onSelectFilter:n,onSelectDisplayMode:s,onDeleteFilter:a,initialConstraints:i,hideFacetCounterByDefault:o,hierarchyState:c})=>{const{titles:l}=ye(),{locale:f,onSelectHierarchy:d}=hi(),h=M.useIsMobile(),[m,p]=u.useState(0),[g,b]=u.useState(!1),C=t?.isTimeDimension&&t?.timeRange,x=u.useMemo(()=>t?.timeRange?.startPeriod&&t?.timeRange?.endPeriod?`${en(t?.timeRange?.startPeriod,f)} -
|
|
6
|
-
${en(t?.timeRange?.endPeriod,f)}`:"",[f,t?.timeRange]);u.useEffect(()=>{p(Mr(t?.dimensionValues)?.length)},[t?.dimensionValues]);const w=o?m>0:!0,v=u.useMemo(()=>Dl({isHierarchical:t?.isHierarchical,availableHierarchies:c?.availableHierarchies,titles:l}),[t?.isHierarchical,c?.availableHierarchies,l]),S=c?.isLoading||!t?.isHierarchical&&!c?.availableHierarchies?.length;u.useEffect(()=>{t.isSelectedFilter||b(!1)},[t.isSelectedFilter]);const k=()=>{h&&b(N=>!N),n(t)},T=N=>{if(N==="")d?.(t,null),s?.(t,tt.FLAT_LIST);else if(N===tt.HIERARCHY)d?.(t,null),s?.(t,tt.HIERARCHY);else{const D=c?.availableHierarchies?.find(R=>R.id===N)??null;d?.(t,D)}};return r.jsxs("div",{className:"flex flex-col",children:[r.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:k,children:[r.jsxs("h3",{className:"w-full min-w-0 flex-1 truncate sm:flex sm:items-center",title:t?.title,children:[r.jsx("span",{className:"truncate",children:t?.title}),h&&r.jsx(Hn,{className:W("chevron-icon w-6 h-6 shrink-0",g&&"rotate-180")})]}),r.jsxs("div",{className:"ml-2 flex items-center gap-2 text-neutrals-800",children:[C&&r.jsx("span",{className:"filters-facet-item-counter border-none",children:x}),!C&&w&&r.jsx("span",{className:W("px-2 text-center","filters-facet-item-counter"),children:m?`${m}/${t?.dimensionValues?.length||0}`:l?.all||"All"}),C?null:r.jsxs("div",{className:"filters-facet-item-settings flex items-center gap-2",children:[r.jsx(M.Dropdown,{triggerButton:r.jsx(M.IconButton,{buttonClassName:W("text-button-tertiary w-4 h-4 border-0 p-0","filters-facet-item-icon"),icon:r.jsx(al,{width:16,height:16}),title:l?.displayOrder||"Display Order",disabled:S}),disabled:S,options:v,selectedOption:c?.selectedHierarchy?.id??(t?.displayMode===tt.HIERARCHY?tt.HIERARCHY:""),onOptionSelect:T}),m>0&&r.jsx(M.IconButton,{buttonClassName:W("text-button-tertiary w-4 h-4 border-0 p-0","filters-facet-item-icon"),icon:r.jsx(vr,{width:16,height:16}),title:l?.reset||"Reset",onClick:N=>{N.stopPropagation(),a?.(t)}})]})]})]}),g&&r.jsx(pi,{filtersList:e,selectedFilter:t,initialConstraints:i,hierarchyState:c})]})},Sc=new Set,yc=({filtersList:e,hideFacetCounterByDefault:t,onSelectFilter:n,onDeleteFilter:s,onSelectDisplayMode:a,initialConstraints:i,initialConstraintsMap:o,datasetIcon:c,structuresMap:l,hierarchyStateMap:f,dataQueries:d,disabledDatasetUrns:h=Sc,isDatasetFacetSelected:m=!1,onSelectDatasetFacet:p,onClearAllDatasets:g})=>{const{isCrossDatasetModeOn:b}=Ue(),C=new Set(e.filter(x=>x.filterType==="dataset").map(x=>x.datasetUrn||"")).size;return r.jsxs("div",{className:W("overflow-y-auto advanced-view-filters-list min-w-[320px] max-w-[338px] pr-3 h-full sm:max-w-full sm:w-full"),children:[d&&d.length>0&&r.jsx(sl,{dataQueries:d,disabledDatasetUrns:h,isSelected:m,onSelect:p,onClearAll:g}),e.filter(x=>!(x.filterType==="dataset"&&x.datasetUrn&&h.has(x.datasetUrn))).map((x,w,v)=>{const S=v[w-1],T=x.filterType==="dataset"&&C>1&&x.datasetUrn!==S?.datasetUrn?ni(x,l):void 0;return r.jsxs("div",{className:"min-w-0 shrink-0",children:[T&&r.jsxs("h4",{className:"filters-facet-dataset-name !flex",children:[r.jsx("span",{className:"filters-facet-dataset-icon",children:c}),r.jsx("span",{className:"min-w-0 truncate",title:T,children:T})]}),r.jsx(bc,{filtersList:v,filter:x,onSelectFilter:n,onSelectDisplayMode:a,onDeleteFilter:s,hideFacetCounterByDefault:t,initialConstraints:ai(b,x,i,o),hierarchyState:f?.get(ze(x)??"")})]},ze(x))})]})},Dc=({dataQueries:e,disabledDatasetUrns:t,onToggleDataset:n,searchIconSize:s})=>{const[a,i]=u.useState(""),o=a.trim().toLowerCase(),c=e.filter(f=>o.length<2||(f.title??f.urn).toLowerCase().includes(o)),l=e.length-t.size;return r.jsxs("div",{className:"filter-values-container flex h-full min-w-0 flex-1 flex-col py-2 sm:border-0",children:[r.jsx(Lr,{value:a,onChange:i,searchIconSize:s}),r.jsx("div",{className:"body-2 mt-3 flex min-h-0 flex-1 flex-col overflow-auto",children:c.map(f=>{const d=!t.has(f.urn),h=d&&l===1;return r.jsx("div",{className:W("py-1",h&&"pointer-events-none"),children:r.jsx(M.Checkbox,{id:f.urn,label:f.title??f.urn,checked:d,disabled:h,disabledScope:"icon",onChange:(m,p)=>n(f.urn,!!p)})},f.urn)})})]})},gi=({filtersList:e,selectedFilter:t,modalProps:n,locale:s,isDisableValues:a,isValuesLoading:i,timeSeriesCount:o,timeRangeOptions:c,initialConstraints:l,initialConstraintsMap:f,datasetIcon:d,structuresMap:h,setSelectedFilter:m,onSelectDisplayMode:p,onDeleteFilter:g,onClearAllFilters:b,updateSelectedFilterValues:C,onTimePeriodChange:x,selectedTimeOption:w,hierarchyStateMap:v,onSelectHierarchy:S,onExpandHierarchyNode:k,dataQueries:T,disabledDatasetUrns:N,onToggleDataset:D,onClearAllDatasets:R})=>{const{titles:E}=ye(),A=v?.get(ze(t)),j=M.useIsMobile(),{isCrossDatasetModeOn:O}=Ue(),[L,$]=u.useState(!1),J=u.useMemo(()=>dc(e.filter(_=>!(_.filterType==="dataset"&&_.datasetUrn&&N.has(_.datasetUrn))),N,f),[e,N,f]),q=u.useMemo(()=>t?J.find(_=>Pe(_,t)):void 0,[t,J]),H=Un(ln(e))+N.size,K=u.useCallback(()=>{$(!0),m(void 0)},[m]),z=u.useCallback(_=>{$(!1);const Y=e?.find(le=>Pe(le,_));if(!Y){m(void 0);return}m({...Y,isSelectedFilter:!0})},[e,m]),ne=_=>_?e?.find(Y=>Pe(Y,_)):void 0,se=(_,Y,le)=>{const de=!le||Pe(le,t),ue=ne(le??t)??le??t;if(!ue)return;const ae=$t(ue)?wc(_,ue):_;if(!ae)return;const ee={...ue,dimensionValues:ue?.dimensionValues?.map(U=>U?.id===ae?{...U,isSelectedValue:Y}:U)};de&&m(ee),C&&C(ee)},fe=(_,Y)=>{const le=!Y||Pe(Y,t),de=ne(Y??t)??Y??t;if(!de)return;const ue=$t(de)?Cc(_,de):_??[],ae=new Set(de?.dimensionValues?.map(B=>B.id)),ee=$t(de)?[]:yl(ue,ae),U={...de,dimensionValues:[...de?.dimensionValues?.map(B=>{const oe=ue.find(re=>re?.id===B?.id);return oe?{...B,isSelectedValue:oe.isSelectedValue}:B})??[],...ee]};le&&m(U),C&&C(U)},xe=(_,Y)=>{const le=!Y||Pe(Y,t),de=ne(Y??t)??Y??t;if(!de||!_?.id)return;const ue=ze(de);if((ue?v?.get(ue):void 0)?.treeNodes?.length){k?.(ue,_.id);return}const ee={...de,dimensionValues:de?.dimensionValues?.map(U=>U?.id===_?.id?{...U,isExpanded:!_?.isExpanded}:U)};le&&m(ee),C&&C(ee)},me=(_,Y)=>{if(!t)return;const le={...t,timeRange:_||void 0};x?.(Y),m(le),C&&C(le)};return r.jsx(xc,{value:{locale:s,isDisableValues:a,isValuesLoading:i,timeRangeOptions:c,filterValuesProps:n?.filterValuesProps,dataQueries:T,onSelectHierarchy:S,selectFilterValue:se,selectHierarchicalNodes:fe,expandHierarchicalValue:xe,onTimePeriodChange:me},children:r.jsxs("div",{className:W("flex flex-row gap-5 flex-1 min-h-0 sm:p-0","filters-settings"),children:[r.jsxs("div",{className:W("h-full sm:w-full",n?.isShowTimeSeriesCount&&"flex flex-col justify-between"),children:[O&&r.jsxs("div",{className:"mb-4 flex items-center justify-between gap-x-4",children:[r.jsxs("span",{className:"body-3 text-neutrals-900",children:[E?.appliedFilters??"Applied filters",":"," ",H]}),r.jsx(M.Button,{buttonClassName:"text-button-tertiary p-0",title:E?.clearAll??"Clear All",onClick:b,isSmallButton:j})]}),r.jsx(yc,{filtersList:J,hideFacetCounterByDefault:n?.isHideFacetCounterByDefault,onSelectFilter:z,onSelectDisplayMode:p,onDeleteFilter:g,initialConstraints:l,initialConstraintsMap:f,datasetIcon:d,structuresMap:h,hierarchyStateMap:v,dataQueries:T,disabledDatasetUrns:N,isDatasetFacetSelected:L,onSelectDatasetFacet:K,onClearAllDatasets:R}),n?.isShowTimeSeriesCount&&o?r.jsxs("h4",{className:"my-4 text-neutrals-800",children:[E?.timeSeries??"Timeseries",": ",o]}):null]}),!j&&(L?r.jsx(Dc,{dataQueries:T??[],disabledDatasetUrns:N,onToggleDataset:D,searchIconSize:n?.filterValuesProps?.searchIconSize}):r.jsx(pi,{filtersList:J,selectedFilter:q,structuresMap:h,initialConstraints:ai(O,t,l,f),selectedTimeOption:w,hierarchyState:A}))]})})},Mc=e=>{const t=e.filterType==="dataset"?[e.datasetUrn]:e.sourceDatasetUrns;return Array.from(new Set((t||[]).filter(n=>!!n)))},Tc=(e,t)=>{if(!t)return!1;const n=e.dataStructureComponents?.dimensionList;return[...n?.dimensions||[],...n?.timeDimensions||[]].some(a=>a.id===t)},In=e=>{if(!e.length||e.some(n=>!n))return;const t=Array.from(new Set(e));return t.length===1?t[0]:void 0},Ec=(e,t)=>{const n=t?.dataStructures||[];if(!n.length)return[];const s=n.filter(a=>Tc(a,e));return s.length?s:n.length===1?n:[]},Ac=e=>e.urn??y.generateShortUrn(e.id,e.version,e.agencyID),Ci=(e,t)=>In(Ec(e,t).map(Ac)),Nc=(e,t,n,s)=>{if(!e||!t)return;const a=n?.get(t)?.find(l=>l.id===e);if(!a)return;const i=y.getKeyFromUrn(a.localRepresentation?.enumeration);if(i)return i;const o=s?.get(t),c=y.findCodelistByDimension(o?.codelists,o?.conceptSchemes,a);return c?y.getKeyFromUrn(c.urn)??y.generateShortUrn(c.id,c.version,c.agencyID):void 0},kc=(e,t,n)=>{const s=Mc(e);return{codelistUrn:In(s.map(a=>Nc(e.id,a,t,n))),sourceArtefactUrn:In(s.map(a=>Ci(e.id,n?.get(a))))}},jc=({timeseriesLength:e=0,limitMessages:t})=>{const n=!e||M.SERIES_LIMIT>e;return r.jsx("div",{className:"body-3 flex items-center gap-x-[4px] text-neutrals-800 sm:justify-center sm:text-center",children:n?r.jsx("span",{children:t?.seriesCount?.(e)}):r.jsxs(r.Fragment,{children:[r.jsx("span",{children:t?.warningIcon}),r.jsx("span",{children:t?.counterLimit?.(e,M.SERIES_LIMIT)})]})})},wi=({modalProps:e,onApply:t,onClearAllFilters:n,onClose:s,applyDisabled:a,timeseriesLength:i,limitMessages:o})=>{const{titles:c}=ye(),l=M.useIsMobile(),f=e?.footerActionsPosition==="right",d=e?.isShowCancelButton,h=e?.isShowClearAllButton??!0,m=d?f?"justify-end":"justify-start":f?"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=d?f?"items-center gap-x-8":"justify-between":f?"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 r.jsxs("div",{className:W("flex py-4 px-6 modal-footer-wrapper",m),children:[!d&&r.jsx(jc,{timeseriesLength:i,limitMessages:o}),r.jsxs("div",{className:W("flex",p),children:[h&&r.jsx(M.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}),r.jsxs("div",{className:"flex items-center gap-x-3",children:[e?.isShowCancelButton?r.jsx(M.Button,{buttonClassName:"text-button-tertiary sm:h8",title:c?.cancel??"Cancel",onClick:s,isSmallButton:l}):null,r.jsx(M.Button,{buttonClassName:"advanced-view-filters-modal-apply-button",title:c?.apply??"Apply",onClick:t,isSmallButton:l,disabled:a})]})]})]})},Ic=e=>Ae.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Ae.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 Oe=(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))(Oe||{});const Wn=["charts","chartsNavigation"],va=["dataGrid","metadataPerSeries",...Wn,"openAdvancedView"],xi=["filters","chartPerSeries","metadataPerDataset","exitAdvancedView"],ct=(e,t)=>{const n=t?.[`${e}Title`],s=t?.[`${e}Description`];return{title:typeof n=="string"?n:"",description:typeof s=="string"?s:""}},Ln=(e,t)=>e.find(n=>!t.infoElements?.[n])||"",Lc=(e,t)=>{if(!e||!t)return"";if(va.includes(t)){const s=Ln(va,e);if(s)return s}const n=Ln(xi,e);return n||""},vi=(e,t)=>{const n=Ln(e,t);return{...t,infoElements:{...t?.infoElements,[t.lastDisplayedElement]:!1,...n?{[n]:!0}:{}},lastDisplayedElement:n}},bi=e=>vi(xi,e),Pc=e=>vi(Wn,e),Rc=e=>(!e?.infoElements?.charts||!e?.infoElements?.chartsNavigation)&&!Wn.includes(e.lastDisplayedElement),it=5,Fc=({targetPosition:e,overlayClasses:t,onClose:n})=>r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"overlay overlay-top",style:{height:e.top,top:0-it,bottom:e.top+it}}),r.jsx("div",{className:"overlay overlay-bottom",style:{top:e.bottom+it,bottom:0}}),r.jsx("div",{className:"overlay overlay-left",style:{top:e.top-it,height:e.height+it*2,width:e.left,left:0-it,right:e.left-it*2}}),r.jsx("div",{className:"overlay overlay-right",style:{top:e.top-it,left:e.right+it,height:e.height+it*2,right:0}}),r.jsx("div",{className:W("outline-block z-10",t),onClick:n,style:{top:e.top,left:e.left,height:e.height,width:e.width}})]}),dt=({reference:e,title:t,description:n,onReferenceClick:s,shouldCloseTooltip:a,shouldMoveToNextStep:i,supressReferenceClick:o})=>{const[c,l]=u.useState(!0),[f,d]=u.useState(!1),h=u.useRef(null),{isShowOnboarding:m,onboardingFileSchema:p,setOnboardingFileSchema:g}=Ye(),{refs:b,floatingStyles:C,context:x,placement:w}=Xe.useFloating({open:c,onOpenChange:l,placement:"right-start",elements:{reference:e?.current},middleware:[Xe.offset({mainAxis:12,crossAxis:-4}),Xe.flip(),Xe.shift(),Xe.arrow({element:h})],whileElementsMounted:Xe.autoUpdate}),v=Xe.useClick(x),{getFloatingProps:S}=Xe.useInteractions([v]),k=u.useCallback(()=>{if(m){const R=Lc(p,p?.lastDisplayedElement);g?.({...p,infoElements:{...p?.infoElements,...R?{[R]:!0}:{}},lastDisplayedElement:R})}l?.(!1)},[m,p,g]);u.useEffect(()=>{b.setReference(e?.current??null)},[e,b]);const T=()=>k(),N=e?.current?.getBoundingClientRect();u.useEffect(()=>{a&&!f&&(k(),d(!0))},[a,k,f]);const D=()=>{s?(s?.(),i?k():l(!1)):o||(k(),e?.current?.click())};return r.jsx(r.Fragment,{children:c&&r.jsxs(Xe.FloatingPortal,{children:[N&&r.jsx(Fc,{overlayClasses:o?"cursor-default":"cursor-pointer",targetPosition:N,onClose:D}),r.jsxs("div",{ref:b.setFloating,style:C,...S(),className:"tooltip z-tooltip max-w-[350px]",children:[r.jsxs("div",{className:"tooltip-header",children:[r.jsx("h3",{children:t}),r.jsx(M.CloseButton,{btnClassNames:"w-4 h-4",onClick:T})]}),r.jsx("div",{className:"tooltip-description",children:r.jsx("p",{children:n})}),r.jsx("div",{ref:h,className:W("tooltip-arrow absolute w-3 h-3 rotate-45",w?.includes("right")?"left-[-4px]":"right-[-6px]",w?.includes("end")?"bottom-2 tooltip-arrow-white":"top-3")})]})]})})},Si=({buttonProps:e,selectedFiltersCount:t=0,isLoading:n,setModalState:s,isModalClosed:a,warningIcon:i,filterIconClassName:o,timeSeriesCount:c})=>{const{titles:l}=ye(),f=u.useRef(null),[d,h]=u.useState(""),[m,p]=u.useState(""),[g,b]=u.useState(!1),{onboardingFileSchema:C,isShowOnboarding:x}=Ye(),w=M.SERIES_LIMIT<(c??0),v=u.useMemo(()=>e?.isShowBadge?e?.title:`${e?.title}: ${t}`,[e?.isShowBadge,e?.title,t]);return u.useEffect(()=>{if(x){const{title:S,description:k}=ct(Oe.FILTERS,l);h(S),p(k)}},[l,x]),u.useEffect(()=>{x&&b(C?.lastDisplayedElement===Oe.FILTERS)},[C?.lastDisplayedElement,x]),r.jsx("div",{className:"filter-button-container relative",ref:f,children:n?r.jsx(M.Loader,{}):r.jsxs(r.Fragment,{children:[r.jsx(M.Button,{iconBefore:r.jsx(Ic,{className:W("size-4",o)}),iconAfter:w?i:void 0,title:v,buttonClassName:"text-button-secondary filter-button",isSmallButton:!0,onClick:()=>s(M.PopUpState.Opened)}),e?.isShowBadge&&r.jsx("div",{className:"filter-count-badge",children:r.jsx("h5",{children:t})}),g&&r.jsx(dt,{reference:f,title:d,description:m,onReferenceClick:()=>s(M.PopUpState.Opened),shouldCloseTooltip:a})]})})},ba=e=>{const t=[];return e.custom_content?.attachments&&t.push(...e.custom_content.attachments),t};function $n(e){return e.type===we.AttachmentType.MARKDOWN&&e.title!=null&&e.title?.startsWith("URL Query")}function yi(e){return e.type===we.AttachmentType.JSON&&e.title!=null&&e.title?.startsWith("Query (JSON)")}function Di(e){return e.type===we.AttachmentType.MARKDOWN&&!$n(e)}function Oc(e){return e.type===we.AttachmentType.CSV}function Jn(e){return e.type===we.AttachmentType.TABLE}function lt(e){return e.type===we.AttachmentType.CUSTOM_DATA_GRID}function qt(e){return e.type===we.AttachmentType.CUSTOM_CHART}function _c(e){return e.type===we.AttachmentType.PLOTLY}function Kn(e){return e.type===we.AttachmentType.CUSTOM_CODE_SAMPLE}function ft(e){return e.type===we.AttachmentType.CROSS_DATASET_GRID}function Vc(e){return Jn(e)||lt(e)||ft(e)}const Hc=(e,t)=>e?.filter((n,s)=>n?.custom_content?.attachments&&s<t)?.at(-1),Mi=e=>e?.reduce((t,n,s)=>n?.custom_content?.attachments?.some(a=>yi(a))?s:t,-1),Uc=e=>e?.reduce((t,n)=>n?.role===Ie.Role.Assistant?n:t,{}),Bc=(e,t,n,s,a)=>({role:Ie.Role.System,content:"",custom_content:{attachments:n?.map(i=>{const o=e&&t?.urn===i?.urn?e:i?.filters;return{type:we.AttachmentType.JSON,title:i?.title,data:JSON.stringify({urn:i?.urn,metadata:i?.metadata,filters:a?a?.get(i?.urn):o,disabled:!!i?.disabled})}})||[],form_schema:s?.custom_content?.form_schema}}),Ti=(e,t,n,s,a)=>{if(!e)return[];const i=e.at(-1),o=i?.role===Ie.Role.System,c=o?i?.custom_content?.attachments?.find(d=>d.type==="text/markdown"&&d.data?.includes("```python")):void 0,l=o?e.slice(0,-1):e,f=Bc(s,a,t,Uc(l),n);return c&&f.custom_content&&(f.custom_content={...f.custom_content,attachments:[...f.custom_content.attachments??[],c]}),[...l,f]},Gc=(e,t,n,s)=>e?.map(a=>({...a,filters:n&&s?.urn===a?.urn?n:a?.filters}))||[],ut={availableHierarchies:[],selectedHierarchy:null,mainHierarchy:null,codelists:[],treeNodes:[],isLoading:!1},Ei=({getCodelistUrnForFilter:e,getConstraintsForFilter:t,getSourceArtefactUrn:n,getAvailableHierarchies:s,getHierarchy:a})=>{const[i,o]=u.useState(new Map),c=u.useCallback((m,p)=>{const g=ze(m);if(!g)return;const b=e(m),C=p??t(m);o(x=>{const w=x.get(g);if(!w?.mainHierarchy)return x;const v=xa(w.mainHierarchy,w.codelists,m.id??"",C,b),S=new Map(x);return S.set(g,{...w,treeNodes:v}),S})},[e,t]),l=u.useCallback(async m=>{if(!s)return;const p=e(m);if(!p)return;const g=ze(m);if(g){o(b=>{const C=new Map(b),x=b.get(g)??ut;return C.set(g,{...x,isLoading:!0}),C});try{const b=await s(p,n?.(m)),C=hc(b?.data?.hierarchies??[]);o(x=>{const w=new Map(x),v=x.get(g)??ut;return w.set(g,{...v,availableHierarchies:C,isLoading:!1}),w})}catch{o(b=>{const C=new Map(b),x=b.get(g)??ut;return C.set(g,{...x,isLoading:!1}),C})}}},[s,e,n]),f=u.useCallback(async(m,p)=>{if(!a)return;const g=ze(m);if(!g)return;const b=e(m);o(C=>{const x=new Map(C),w=C.get(g)??ut;return x.set(g,{...w,isLoading:!0}),x});try{const C=wa(p),x=await a(C,b),w=x?.data?.hierarchies?.find(k=>wa(k)===C);if(!w){o(k=>{const T=new Map(k),N=k.get(g)??ut;return T.set(g,{...N,selectedHierarchy:p,mainHierarchy:null,treeNodes:[],isLoading:!1}),T});return}const v=y.resolveCodelistsFromResponse(x?.data),S=xa(w,v,m.id??"",t(m),b);o(k=>{const T=new Map(k),N=k.get(g)??ut;return T.set(g,{...N,selectedHierarchy:p,mainHierarchy:w,codelists:v,treeNodes:S,isLoading:!1}),T})}catch{o(C=>{const x=new Map(C),w=C.get(g)??ut;return x.set(g,{...w,isLoading:!1}),x})}},[a,e,t]),d=u.useCallback((m,p)=>{if(!m)return;const g=ze(m);if(g){if(!p){o(b=>{const C=new Map(b),x=b.get(g)??ut;return C.set(g,{...x,selectedHierarchy:null,mainHierarchy:null,treeNodes:[]}),C});return}f(m,p)}},[f]),h=u.useCallback((m,p)=>{o(g=>{const b=g.get(m);if(!b?.treeNodes)return g;const C=new Map(g);return C.set(m,{...b,treeNodes:ui(b.treeNodes,p)}),C})},[]);return{hierarchyStateMap:i,rebuildHierarchyTree:c,loadAvailableHierarchies:l,onSelectHierarchy:d,onExpandHierarchyNode:h}},zc=(e,t,n,s,a)=>{const i=new Set;if(!t||e.isTimeDimension)return i;const o=e.dimensionValues?.filter(d=>d.isSelectedValue)??[];if(!o.length)return i;const c=y.findCodelistByDimension(n?.codelists,n?.conceptSchemes,t);if(!c?.codes?.length)return i;const l=new Set(c.codes.map(d=>d.id)),f=new Set(y.getAvailableCodesFromConstrains(c.codes,t.id,s,a).map(d=>d.id));return o.forEach(d=>{l.has(d.id)&&!f.has(d.id)&&i.add(d.id)}),i},Ai=(e,t,n,s,a,i)=>{let o=!1;const c=e.map(l=>{if(l.isTimeDimension||a&&l.id===a)return l;const f=t?.find(h=>h.id===l.id),d=zc(l,f,n,s,i);return d.size?(o=!0,{...l,dimensionValues:l.dimensionValues?.map(h=>d.has(h.id)?{...h,isSelectedValue:!1}:h)}):l});return{filters:o?c:e,changed:o}},Wc=(e,t,n,s,a,i)=>Ai(e,t,n,s,a?.id,i),$c=(e,t,n,s,a)=>{let i=!1;const o=new Map;return e.forEach((c,l)=>{const f=n?.filterType==="shared"?Gn(n,l,a):n?.datasetUrn===l?n.id:void 0,d=Ai(c,t?.dimensionsMap?.get(l),t?.structuresMap?.get(l),t?.constraintsMap?.get(l),f,s);i=i||d.changed,o.set(l,d.filters)}),{filtersMap:i?o:e,changed:i}},Jc=new Set,Kc=({actions:e,dimensions:t,structureDimensions:n,structures:s,buttonProps:a,modalProps:i,attachmentsDataQuery:o,dataQueries:c,initialConstraints:l,onFiltersChange:f,locale:d,timeRangeOptions:h,conversationKey:m,conversation:p,setConversation:g,updateConversation:b,updateDataQueries:C,limitMessages:x,filterIconClassName:w})=>{const{titles:v}=ye(),[S,k]=u.useState(M.PopUpState.Closed),[T,N]=u.useState([]),[D,R]=u.useState([]),[E,A]=u.useState(),[j,O]=u.useState([]),[L,$]=u.useState(void 0),J=u.useRef(l||[]),[q,H]=u.useState([]),[K,z]=u.useState(),[ne,se]=u.useState(),[fe,xe]=u.useState(!1),me=u.useRef(0),_=u.useRef(!1),[Y,le]=u.useState(!1),de=u.useCallback(()=>{me.current+=1,me.current===1&&xe(!0)},[]),ue=u.useCallback(()=>{me.current=Math.max(me.current-1,0),me.current===0&&xe(!1)},[]),ae=u.useCallback(X=>{const pe=t?.find(be=>be.id===X.id);if(!pe)return;const ve=y.getKeyFromUrn(pe.localRepresentation?.enumeration);if(ve)return ve;const Ce=y.findCodelistByDimension(s?.codelists,s?.conceptSchemes,pe);return Ce?y.getKeyFromUrn(Ce.urn)??y.generateShortUrn(Ce.id,Ce.version,Ce.agencyID):void 0},[t,s?.codelists,s?.conceptSchemes]),{hierarchyStateMap:ee,rebuildHierarchyTree:U,loadAvailableHierarchies:B,onSelectHierarchy:oe,onExpandHierarchyNode:re}=Ei({getCodelistUrnForFilter:ae,getConstraintsForFilter:()=>J.current,getSourceArtefactUrn:X=>Ci(X.id,s),getAvailableHierarchies:e?.getAvailableHierarchies,getHierarchy:e?.getHierarchy}),ge=X=>{const pe=X?T.map(ve=>Pe(ve,X)?X:ve):T;se(!0),N(nn(pe)),z?.(!0),he(X?.isTimeDimension?tn(pe,X):pe,N,z,X)};u.useEffect(()=>{S===M.PopUpState.Closed&&H(J.current)},[S]);const he=u.useCallback((X,pe,ve,Ce)=>{const be=o?.urn??"",F=kt(kn(X).filter(V=>V.componentCode!==y.TIME_PERIOD)),Q=st(be,F),I=!!e?.getConstraints&&!jn(e.getConstraints,Q);I&&de(),(e?at(e.getConstraints,Q,()=>e.getConstraints(be,F)):Promise.resolve(void 0)).then(V=>{const Z=V?.data?.dataConstraints||[];if(Ce){const{filters:De,changed:Te}=Wc(X,t,s,Z,Ce,d);if(Te){J.current=Z,ve?.(!0),se(!0),he(De,pe,ve,Ce);return}}const G=Jt(X,t,s,Z,d);if(J.current=Z,ve?.(!1),pe(G),Ce){const De=G.find(Te=>Pe(Te,Ce));A(Te=>Te&&De&&Pe(Te,Ce)?{...De,isSelectedFilter:!0}:Te),U(Ce,Z)}}).catch(()=>{const V=Jt(X,t,s,[],d);if(J.current=[],ve?.(!1),pe(V),Ce){const Z=V.find(G=>Pe(G,Ce));A(G=>G&&Z&&Pe(G,Ce)?{...Z,isSelectedFilter:!0}:G)}}).finally(()=>{se(!1),I&&ue()})},[e,o?.urn,t,ue,d,U,de,s]);u.useEffect(()=>{const X=yr(t,s,n,d),pe=t?.map(Ce=>{const be=y.findCodelistByDimension(s?.codelists,s?.conceptSchemes,Ce),F=y.getAvailableCodesFromConstrains(be?.codes,Ce.id,J.current,d);return{...Ce,dimensionValues:F}}),ve=X.map(Ce=>{const be=pe?.find(F=>F.id===Ce.id)?.dimensionValues||[];return{...Ce,dimensionValues:be}});if(!_.current){if(!s)return;const Ce=Nr(ve,o,J.current);z?.(!0),he(Ce,R,z),_.current=!0}},[t,n,s,o,d,l,he]),u.useEffect(()=>{D?.length&&O(ln(D))},[D]),u.useEffect(()=>{N(X=>tn(X,E))},[E]),u.useEffect(()=>{if(S===M.PopUpState.Opened){const X=D.find(pe=>!pe.isTimeDimension);A(X?{...X,isSelectedFilter:!0}:void 0),N(D)}S===M.PopUpState.Closed&&A(void 0)},[D,S]),u.useEffect(()=>{if(!E||E.isTimeDimension)return;const X=ze(E);if(!X)return;ee.get(X)||B(E)},[E,ee,B]),u.useEffect(()=>{S===M.PopUpState.Opened&&D.forEach(X=>{if(X.isTimeDimension)return;const pe=ze(X);pe&&!ee.has(pe)&&B(X)})},[S,D,ee,B]);const ce=u.useCallback(async X=>{const pe=Hr(X),ve=p?{...p,messages:Ti(p?.messages,c,void 0,pe,o)}:null;g?.(ve),C?.(Gc(c,void 0,pe,o)),await b(decodeURI(m),{name:ve?.name,messages:ve?.messages||[]})},[o,p,m,c,g,b,C]),Me=u.useCallback((X,pe)=>{N(ve=>Dr(ve,X,pe)),Pe(E,X)&&A(ve=>ve&&{...ve,displayMode:pe})},[E]),Ne=u.useCallback(X=>Or(X,t),[t]),ie=u.useCallback((X,pe)=>{const ve=Jt(pe,t,s,X,d);J.current=X,A(Ce=>ve?.find(be=>Pe(be,Ce))||Ce),N(ve),se(!1)},[t,d,s]),Le=u.useCallback(X=>{se(!0),N(nn(X));const pe=o?.urn??"",ve=kt(kn(X).filter(Q=>Q.componentCode!==y.TIME_PERIOD)),Ce=st(pe,ve),be=!!e?.getConstraints&&!jn(e.getConstraints,Ce);be&&de(),(e?at(e.getConstraints,Ce,()=>e.getConstraints(pe,ve)):Promise.resolve(void 0)).then(Q=>{ie(Q?.data?.dataConstraints||[],X)}).catch(()=>{ie([],X)}).finally(()=>{be&&ue()})},[e,o?.urn,ue,de,ie]),We=u.useCallback(X=>{const pe=Er(T,X);Le(pe)},[Le,T]),Be=u.useCallback(()=>{J.current=q,k(M.PopUpState.Closed),le(!0)},[q]),_e=u.useCallback(()=>{const X=Ar(T);Le(X)},[Le,T]),He=u.useCallback(()=>{const X=Ne(T);f?.(X,J.current,T),R(T),k(M.PopUpState.Closed),le(!0),u.startTransition(()=>{ce(T)})},[Ne,T,f,ce,J]),qe=X=>{$(X)},$e=Number(y.getTimeSeriesCount(J?.current?.[0]?.annotations));return r.jsxs("div",{className:"filters-container",children:[r.jsx(Si,{buttonProps:a,selectedFiltersCount:Un(j),isLoading:K,setModalState:k,isModalClosed:Y,warningIcon:x?.warningIcon,filterIconClassName:w,timeSeriesCount:$e}),r.jsx(r.Fragment,{children:S===M.PopUpState.Opened&&r.jsxs(M.Popup,{heading:v?.settings||"Settings",portalId:"filters",size:M.PopUpSize.LG,containerClassName:"advanced-view-filters-modal h-[80%]",dividers:i?.isShowDividers,onClose:Be,closeButtonTitle:v?.close||"Close",children:[r.jsx(gi,{locale:d,timeRangeOptions:h,filtersList:T,selectedFilter:E,isDisableValues:ne,isValuesLoading:fe,modalProps:i,initialConstraints:l,timeSeriesCount:`${$e}`,setSelectedFilter:A,onSelectDisplayMode:Me,onDeleteFilter:We,onClearAllFilters:_e,updateSelectedFilterValues:ge,onTimePeriodChange:qe,selectedTimeOption:L,hierarchyStateMap:ee,onSelectHierarchy:oe,onExpandHierarchyNode:re,dataQueries:o?[o]:void 0,disabledDatasetUrns:Jc,onToggleDataset:()=>{},onClearAllDatasets:()=>{}}),r.jsx(wi,{onApply:He,onClose:Be,onClearAllFilters:_e,modalProps:i,applyDisabled:K||ne,timeseriesLength:$e,limitMessages:x})]})})]})},yn=({setToTitle:e,datasetName:t,datasetIcon:n,isShowDatasetDetails:s,queryFilterDetails:a})=>r.jsx("div",{children:a?.map(i=>r.jsxs("div",{className:"body-1 mb-2 flex flex-wrap items-center gap-1",children:[r.jsxs("span",{children:[i?.title,r.jsx("span",{children:e??" set to "}),r.jsx("span",{className:"font-bold",children:i?.valuesTitles?.join(", ")})]}),t&&s&&r.jsxs("span",{className:"attachment-dataset-name caption !mb-0 inline-flex items-center",children:[r.jsx("span",{className:"attachment-dataset-icon mr-1",children:n}),t]})]},i?.title))}),Yc=({titles:e,attachmentInfoList:t,datasetIcon:n,dataQueries:s})=>{const{isCrossDatasetModeOn:a}=Ue(),{sharedFilterDetails:i,perDatasetInfoList:o}=u.useMemo(()=>{if(!a)return{sharedFilterDetails:[],perDatasetInfoList:[]};const f=new Map,d=[];return t?.forEach(h=>{const m=[];h.queryFiltersDetails?.forEach(p=>{if(Vl.has(p.id)){const g=f.get(p.id);g?f.set(p.id,{...g,valuesTitles:Array.from(new Set([...g.valuesTitles||[],...p.valuesTitles||[]]))}):f.set(p.id,{...p})}else p.valuesTitles?.length&&m.push(p)}),m.length&&d.push({...h,queryFiltersDetails:m})}),{sharedFilterDetails:Array.from(f.values()),perDatasetInfoList:d}},[a,t]),c=s?.some(f=>f.disabled)??!1,l=t?.map(f=>f.datasetName).filter(Boolean)??[];return r.jsxs("div",{className:"attachment-details flex flex-col",children:[r.jsx("p",{className:W("body-1",(t&&t.length<=1||a&&i.length>0)&&"mb-2"),children:e?.queryUpdatedManuallyTitle??"Query has been updated manually."}),c&&l.length>0&&r.jsxs("div",{className:"body-1 mb-2 flex flex-wrap items-center gap-1",children:[r.jsxs("span",{children:[e?.datasetLabel??"Dataset",e?.setToTitle??" set to "]}),l.map(f=>r.jsxs("span",{className:"attachment-dataset-name caption !mb-0 inline-flex items-center",children:[r.jsx("span",{className:"attachment-dataset-icon mr-1",children:n}),f]},f))]}),a?r.jsxs(r.Fragment,{children:[i.length>0&&r.jsx(yn,{setToTitle:e?.setToTitle,queryFilterDetails:i}),o.map(f=>r.jsx(yn,{setToTitle:e?.setToTitle,datasetName:f.datasetName,datasetIcon:n,isShowDatasetDetails:!0,queryFilterDetails:f.queryFiltersDetails},f.datasetName))]}):t?.map(f=>!!f?.queryFiltersDetails?.length&&r.jsx(yn,{setToTitle:e?.setToTitle,datasetName:f?.datasetName,datasetIcon:n,isShowDatasetDetails:t?.length>1,queryFilterDetails:f?.queryFiltersDetails},f?.datasetName))]})},qc=({icon:e,title:t})=>r.jsx("div",{className:W("px-3 py-4 rounded border mt-3","attachment-collapsed"),children:r.jsxs("p",{className:W("flex body-3 items-center"),children:[e,r.jsxs("span",{className:"ml-2",children:[" ",t]})]})}),Zc=e=>Ae.createElement("svg",{width:44,height:24,viewBox:"0 0 44 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ae.createElement("rect",{width:44,height:24,rx:12,fill:"currentColor"}),Ae.createElement("circle",{cx:32,cy:12,r:10,fill:"white"})),Xc=e=>Ae.createElement("svg",{width:44,height:24,viewBox:"0 0 44 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ae.createElement("rect",{width:44,height:24,rx:12,fill:"currentColor"}),Ae.createElement("circle",{cx:12,cy:12,r:10,fill:"white"})),Sa=[{value:y.SdmxDataFormat.JSON,title:"SDMX-JSON"},{value:y.SdmxDataFormat.XML,title:"SDMX-ML (XML)"},{value:y.SdmxDataFormat.CSV,title:"SDMX-CSV"}],Qc=e=>[{value:y.FileColumnsAttribute.ID,title:e?.idOptions||"ID",description:e?.idOptionsDescription},{value:y.FileColumnsAttribute.NAME,title:e?.nameOptions||"Name",description:e?.nameOptionsDescription},{value:y.FileColumnsAttribute.ID_NAME,title:e?.idAndNameOptions||"Combined ID and Name",description:e?.idAndNameOptionsDescription}],ya=({title:e,items:t,selectedValue:n,setSelectedValue:s,infoMessage:a,collapsible:i=!0})=>{const o=r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex flex-col gap-y-1",children:t.map(c=>r.jsx("div",{className:"flex flex-col",children:r.jsx(M.Radio,{id:c.value,checked:n.value===c.value,label:c.title,description:c.description,onChange:()=>{s(c)},radioIcon:r.jsx(Ve.IconCircleFilled,{className:"size-3"})},c.value)},c.value))}),a]});return i?r.jsx(M.CollapsibleBlock,{title:e,value:n.title,children:o}):r.jsxs("div",{className:"flex flex-col",children:[r.jsx("div",{className:"flex items-center py-4",children:r.jsx("span",{children:e})}),r.jsx("div",{className:"pb-4",children:o})]})},ed=({title:e,items:t,selectedUrns:n,onToggle:s,collapsible:a=!0,rowsLabel:i="rows"})=>{const o=r.jsx("div",{className:"flex flex-col",children:t.map(c=>r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(M.Checkbox,{id:c.urn,label:c.name,checked:n.has(c.urn),onChange:s})}),r.jsxs("span",{className:"download-row-count",children:[c.rowCount," ",i]})]},c.urn))});return a?r.jsx(M.CollapsibleBlock,{title:e,children:o}):r.jsxs("div",{className:"flex flex-col",children:[r.jsx("div",{className:"flex items-center py-4",children:r.jsx("span",{children:e})}),r.jsx("div",{className:"pb-4",children:o})]})},td=e=>{const t=e.metadata?.keyDimensionIdsInDsdOrder,n=e.metadata?.timePeriodDimension;if(!t?.length)return null;const s=t.map(i=>{const o=e.filters?.find(c=>c.componentCode===i);return o?.values?.length?o.values.join(y.GET_v3_FILTER_OR):"*"}).join("."),a=n?y.getTimeQueryFilter(e,{id:n}):null;return{filterKey:s,timeFilter:a}},nd=(e,t,n,s)=>{if(t&&e===y.DownloadType.DATA_IN_TABLE){const o=td(t);if(o)return o}if(s?.filterKey&&e===y.DownloadType.DATA_IN_TABLE)return s;let a=null,i=null;return t&&n&&e===y.DownloadType.DATA_IN_TABLE&&(a=y.getTimeSeriesFilterKey(n,t.filters??[]),i=y.getTimeQueryFilter(t,y.getTimeDimension(n))),{filterKey:a,timeFilter:i}},sd=({dataQuery:e,datasetName:t,onCloseModal:n,type:s=y.DownloadType.FULL_DATASET,locale:a=te.Locale.EN,dimensions:i,filters:o,urn:c,titles:l,collapsible:f=!0,downloadDatasets:d,rowCount:h,isDownloadInProgress:m=!1,onDownloadStart:p,limitMessages:g,showLimitMessage:b,externalLink:C})=>{const x=Qc(l),[w,v]=u.useState(Sa[0]),[S,k]=u.useState(x[0]),[T,N]=u.useState(!0),[D,R]=u.useState(()=>new Set(d?.map($=>$.urn)??[])),E=u.useRef(!1);u.useEffect(()=>{R(new Set(d?.map($=>$.urn)??[]))},[d]);const A=u.useCallback($=>{R(J=>{const q=new Set(J);return q.has($)?q.delete($):q.add($),q})},[]),j=d!==void 0&&(d.length===0||D.size===0),O=u.useCallback(()=>{if(E.current)return;const $=w.value,J=(z,ne,se,fe)=>({dataQuery:z,urn:ne,name:se,rowCount:fe,fileName:`${se}.${$}`,filters:nd(s,z,i,o)}),H={items:d&&d.length>0?d.filter(z=>D.has(z.urn)).map(z=>J(z.dataQuery,z.urn,z.name,z.rowCount)):[J(e,e?.urn||c||"",t||e?.urn||c||"",h??0)],dataFormat:$,dataFormatTitle:w.title,attribute:S.value,language:a,isMetadata:T};if(!p(H)){E.current=!1;return}E.current=!0,n()},[w.value,w.title,S.value,d,D,e,c,t,h,s,i,o,a,T,p,n]),L=r.jsxs("div",{className:W("download-metadata flex cursor-pointer gap-4",{"download-metadata-active":T}),children:[T?r.jsx(Zc,{width:44,height:24,className:"text-primary",onClick:()=>N(!T)}):r.jsx(Xc,{width:44,height:24,className:"text-neutrals-500",onClick:()=>N(!T)}),r.jsx("div",{children:l?.includeMetadata||"Include Metadata"})]});return r.jsxs(M.Popup,{heading:r.jsx("p",{className:"download-heading h2",children:l?.download||"Download"}),portalId:"filters",size:M.PopUpSize.LG,containerClassName:"download-popup h-[80%]",dividers:!1,onClose:n,closeButtonTitle:l?.close||"Close",children:[!d&&b&&r.jsx("div",{className:"download-info flex flex-col gap-1 px-6 pt-5",children:r.jsx(M.RequestLimitMessage,{limitMessages:g,isDownload:!0,query:C})}),r.jsxs("div",{className:"download-settings flex flex-col overflow-auto p-6",children:[r.jsx(ya,{title:l?.dataFormat||"Data Format",selectedValue:w,setSelectedValue:v,items:Sa,collapsible:f,infoMessage:r.jsx(M.DownloadFormatMessage,{limitMessages:g,query:C})}),w.value===y.SdmxDataFormat.CSV&&r.jsx(ya,{title:l?.attributes||"Attributes",selectedValue:S,setSelectedValue:k,items:x,collapsible:f}),d&&r.jsxs(r.Fragment,{children:[r.jsx(ed,{title:l?.datasetsToDownload||"Datasets to download",items:d,selectedUrns:D,onToggle:A,collapsible:f,rowsLabel:l?.rows||"rows"}),D.size>1&&r.jsxs(M.InlineAlert,{type:M.InlineAlertType.Note,children:[r.jsx("span",{className:"font-bold",children:l?.filesWillBeDownloaded?.(D.size)??`${D.size} files will be downloaded`})," ",l?.oneFilePerDataset??"- one file per selected dataset."]})]}),f?r.jsx(M.CollapsibleBlock,{title:l?.metadata||"Metadata",value:T?l?.all||"Included":l?.none||"Not included",children:L}):r.jsxs("div",{className:"flex flex-col",children:[r.jsx("div",{className:"flex items-center py-4",children:r.jsx("span",{children:l?.metadata||"Metadata"})}),r.jsx("div",{className:"pb-4",children:L})]})]}),r.jsxs("div",{className:"download-button mt-auto flex items-center gap-x-3 p-6",children:[l?.cancel&&r.jsx(M.Button,{buttonClassName:"text-button-tertiary",title:l.cancel,onClick:n}),r.jsx(M.Button,{buttonClassName:"text-button-primary",title:l?.download||"Download",disabled:j||m,onClick:O})]})]})},ad=({id:e,title:t,version:n,agency:s,isActive:a,isSingleTab:i,onSelectDataset:o})=>r.jsx("div",{className:W("dataset-tab truncate last:mr-4",a?"dataset-tab-active":"border-b-transparent",i?"dataset-tab-single cursor-default":"cursor-pointer"),title:t,onClick:()=>{i||o(y.generateShortUrn(e,n,s))},children:r.jsx("h3",{className:"dataset-tab-title truncate",title:t,children:t})}),rd=({datasets:e,locale:t,initialSelectedDatasetUrn:n,selectDataset:s})=>{const{isOpenedAdvancedView:a}=Ge(),[i,o]=u.useState();u.useEffect(()=>{if(!n&&!i&&e?.[0]){const l=y.generateShortUrn(e[0].id,e[0].version,e[0].agencyID);o(l),s?.(l)}else n&&n!==i&&(o(n),s?.(n))},[e,s,n,i]);const c=u.useCallback(l=>{o(l),s?.(l)},[s]);return r.jsx("div",{className:W("dataset-tabs flex w-full items-center justify-between",a&&"hide-advance-button"),children:r.jsx("div",{className:"flex w-full items-center gap-4 overflow-y-auto sm:w-[calc(100%-30px)]",children:e?.map(l=>r.jsx(ad,{id:l?.id,title:y.getLocalizedName(l,t||te.Locale.EN),version:l?.version,agency:l?.agencyID,isActive:e?.length>1&&i===y.generateShortUrn(l?.id,l?.version,l?.agencyID),isSingleTab:e?.length===1,onSelectDataset:c},l?.id))})})},id=3,od=({datasets:e,locale:t})=>{const{isOpenedAdvancedView:n}=Ge(),s=u.useMemo(()=>(e||[]).map(c=>({urn:y.generateShortUrn(c?.id,c?.version,c?.agencyID),title:y.getLocalizedName(c,t||te.Locale.EN)})),[e,t]),a=u.useMemo(()=>s.slice(0,id),[s]),i=Math.max(s.length-a.length,0),o=s.filter(c=>!a.some(l=>l.urn===c.urn)).map(c=>c.title).join(`
|
|
7
|
-
`);return r.jsx("div",{className:W("cross-dataset-tabs flex w-full items-center justify-between",n&&"hide-advance-button"),children:r.jsxs("div",{className:"cross-dataset-tabs-list sm:w-[calc(100%-30px)]",children:[a.map((c,l)=>r.jsxs("span",{className:"cross-dataset-tabs-item-wrapper",children:[r.jsx("span",{className:"cross-dataset-tabs-item",title:c.title,children:c.title}),l<a.length-1&&r.jsx("span",{className:"cross-dataset-tabs-separator","aria-hidden":"true"})]},c.urn)),i>0&&r.jsxs("span",{className:"cross-dataset-tabs-counter",title:o,children:["+",i]})]})})},Ni=({datasets:e,locale:t,initialSelectedDatasetUrn:n,selectDataset:s})=>{const{isCrossDatasetModeOn:a}=Ue();return a?r.jsx(od,{datasets:e,locale:t}):r.jsx(rd,{datasets:e,locale:t,initialSelectedDatasetUrn:n,selectDataset:s})},Da=(e,t)=>{const n=t?.get(e?.urn),s=n?.conceptSchemes||[],a=n?.codelists||[],i=y.getDimensions(n),o=[...i?.dimensions||[],...i?.timeDimensions||[]];return{structures:n,conceptSchemes:s,codelists:a,dimensions:o}},ld=(e,t,n,s,a)=>{const i=t?.filter(c=>!c.disabled)??[],o=new Map;return i?.forEach(c=>{const{conceptSchemes:l,codelists:f,dimensions:d}=Da(c,n);Dn((c?.filters??[]).filter(h=>h.operator!==te.QueryFilterType.EXCLUDED),c?.urn,d,l,f,s,a).forEach(h=>{if(h.valuesTitles?.length){const m=o.get(h.id)??[];o.set(h.id,Array.from(new Set([...m,...h.valuesTitles])))}})}),i?.map(c=>{const l=e?.find(b=>b?.urn===c?.urn),{structures:f,conceptSchemes:d,codelists:h,dimensions:m}=Da(c,n),g=cd(Dn(l?.filters||[],c?.urn,m,d,h,s,a),Dn(c?.filters??[],c?.urn,m,d,h,s,a)).map(b=>{if(b.valuesTitles?.length)return b;const C=o.get(b.id);return C?.length?{...b,valuesTitles:C}:null}).filter(b=>b!==null);return{datasetName:y.getLocalizedName(f?.dataflows?.[0],s),queryFiltersDetails:g}})},cd=(e,t)=>{const n=new Map(e?.map(s=>[s?.id,s]));return t?.filter(s=>!On.isEqual(n?.get(s?.id)?.valuesTitles?.sort(),s?.valuesTitles?.sort()))||[]},Dn=(e,t,n,s,a,i,o)=>e?.map(c=>{const l=n.find(h=>h?.id===c?.componentCode),f=y.getConcept(l?.conceptIdentity||"",s),d=y.findCodelistByDimension(a,s,l);return{id:Wl(t,c?.componentCode,o)??c?.componentCode,title:y.getLocalizedName(f,i),valuesTitles:c?.operator===te.QueryFilterType.BETWEEN?[`${en(te.getTimePeriod(c?.values?.[0]),i)} - ${en(te.getTimePeriod(c?.values?.[1]),i)}`]:c?.values?.map(h=>y.getLocalizedName(d?.codes?.find(m=>m?.id===h),i)||h)}}),dd=(e,t,n)=>{let s="",a="";if(e?.timeFilter){const o=decodeURIComponent(e.timeFilter||"")?.split(":");s=o[1]||"",a=o[3]||""}else if(t){const o=t?.filters?.find(c=>c.componentCode===y.TIME_PERIOD);s=o?.values?.[0]||"",a=o?.values?.[1]||""}return`&filter=${e?.filterKey||y.getTimeSeriesFilterKey(n||[],t?.filters||[])}&startPeriod=${s}&endPeriod=${a}`},Pn=(e,t,n,s)=>{const a=n?.metadata?.datasetUrl;if(!a)return"";const i=e?dd(t,n,s):"";return a+i},ki=e=>Ae.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Ae.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"})),ud=e=>Ae.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Ae.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"})),fd=e=>Ae.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Ae.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"})),md=e=>Ae.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Ae.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"})),hd=({attachment:e,index:t,selectedAttachmentIndex:n,onSelectedAttachmentChange:s,showTabIcon:a,dataGridTitle:i})=>{const{titles:o}=ye(),c=u.useRef(null),[l,f]=u.useState(""),[d,h]=u.useState(""),[m,p]=u.useState(!1),{onboardingFileSchema:g,isShowOnboarding:b}=Ye(),C=u.useCallback((w,v="")=>a?_c(w)||qt(w)?r.jsx(ki,{className:v}):lt(w)||ft(w)?r.jsx(fd,{className:v}):$n(w)?r.jsx(md,{className:v}):Di(w)||Kn(w)?r.jsx(ud,{className:v}):null:null,[a]),x=u.useCallback(w=>lt(w)?i||"Data Grid":w.title,[i]);return u.useEffect(()=>{if(b&&qt(e)){const{title:w,description:v}=ct(Oe.CHARTS,o);f(w),h(v)}},[e,o,b]),u.useEffect(()=>{if(qt(e)&&b){const w=g?.lastDisplayedElement===Oe.CHARTS;p(w),w&&c?.current?.scrollIntoView({block:"end",behavior:"smooth"})}},[g?.lastDisplayedElement,e,b]),r.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:[C(e,"w-4 h-4"),r.jsx("h4",{className:"max-w-[130px] truncate",title:x(e),children:x(e)}),m&&r.jsx(dt,{reference:c,title:l,description:d})]},e.index||t)},pd=({attachments:e,...t})=>r.jsx("div",{className:"attachments-tabs flex w-fit flex-wrap items-center",children:e.map((n,s)=>r.jsx(hd,{attachment:n,index:s,...t},s))}),gd=({attachments:e,selectedAttachmentIndex:t,selectedAttachment:n,attachmentsStyles:s,externalLink:a,isExternalLinkIncludeFilters:i,limitMessages:o,onSelectedAttachmentChange:c,onDownloadClick:l,showAdvancedView:f,onOpenAdvancedView:d,isTableSettingsOpen:h,onTableSettingsOpen:m})=>{const{isTableSettingsFeatureEnabled:p}=Ue(),{isOpenedAdvancedView:g}=Ge(),{titles:b}=ye(),{onboardingFileSchema:C,isShowOnboarding:x}=Ye(),w=u.useRef(null),[v,S]=u.useState(""),[k,T]=u.useState(""),[N,D]=u.useState(!1);u.useEffect(()=>{if(x){const{title:L,description:$}=ct(Oe.OPEN_ADVANCED_VIEW,b);S(L),T($)}},[b,x]),u.useEffect(()=>{if(x){const L=C?.lastDisplayedElement===Oe.OPEN_ADVANCED_VIEW;D(L),L&&w?.current?.scrollIntoView({block:"center",behavior:"smooth"})}},[C?.lastDisplayedElement,x]);const R=p&&!f&&!!m&&!!(n&&(lt(n)||ft(n))),E=!!n&&(lt(n)||ft(n)),A=!!f&&!g,j=g&&s?.hideDownloadIconInAdvancedView?void 0:s?.downloadIcon,O=!g&&s?.hideDownloadTextInConversationView?"":s?.downloadTitle??"";return r.jsxs("div",{className:"flex w-full min-w-0 items-center justify-between",children:[r.jsx(pd,{dataGridTitle:s?.dataGridTitle,attachments:e,selectedAttachmentIndex:t,showTabIcon:s?.showTabIcon,onSelectedAttachmentChange:c}),r.jsxs("div",{className:"attachments-buttons flex w-fit flex-wrap items-center justify-end gap-x-3",children:[n&<(n)&&i&&r.jsx("a",{href:a,target:"_blank",rel:"noreferrer",children:r.jsx(M.Button,{title:o?.dataExplorer||"Data explorer",buttonClassName:"text-button-tertiary small-icon-button [&>svg]:h-[16px] [&>svg]:w-[16px] whitespace-nowrap",iconBefore:o?.dataExplorerIcon})}),E&&r.jsx(M.Button,{title:O,buttonClassName:"text-button-tertiary small-icon-button !p-0 !h-6",textClassName:W("ml-1",s?.downloadButtonTextClassName),onClick:l,iconBefore:j}),E&&A&&r.jsx("span",{className:"advanced-view-button-divider","aria-hidden":"true"}),A&&r.jsx("div",{ref:w,children:r.jsx(M.Button,{title:s?.advancedViewTitle,buttonClassName:"advanced-view-button",textClassName:"ml-1 h4 md:hidden",iconBefore:s?.openAdvancedViewIcon,onClick:d})}),R&&r.jsx(M.Button,{disabled:h,buttonClassName:"text-button-tertiary !p-0 !h-6",textClassName:"ml-1 h4",iconBefore:s?.tableSettingsIcon??r.jsx(Ve.IconSettings,{className:"size-4"}),title:s?.tableSettings||"Table settings",onClick:m}),n&&Kn(n)&&r.jsx(M.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??"")})]}),N&&r.jsx(dt,{reference:w,title:v,description:k,onReferenceClick:d,shouldCloseTooltip:g})]})},Cd=({downloadTitles:e,attachment:t,actions:n,className:s=""})=>{const a=t.url,[i,o]=u.useState(null);async function c(l){if(l==null)return;const f=await n.getFile(l);o(f)}return r.jsxs("div",{className:`rounded-lg border bg-white p-3 transition-colors ${s}`,children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("span",{className:"body-2 truncate text-neutrals-800",title:t.title,children:t.title})})}),a&&r.jsx("div",{className:"shrink-0",children:r.jsx(M.Button,{title:e??"Download",onClick:()=>c(t.url),buttonClassName:"text-button-tertiary"})})]}),i&&r.jsx("div",{className:"mt-3",children:r.jsx("pre",{className:"overflow-x-auto rounded-md bg-white p-3",children:r.jsx("code",{children:JSON.stringify(i,null,2)})})})]})},ji="json";function wd(e){return vd(e)?xd(e?.slice(ji.length)):e}function xd(e){let t="";if(e)try{t=JSON.stringify(JSON.parse(e),null,2)}catch{t=e.toString()}return t}function vd(e){return e?.startsWith(ji)||!1}const bd=({attachment:e,className:t=""})=>{const n=wd(e.data);return n?r.jsxs("div",{className:`attachment-json rounded-lg border bg-white ${t}`,children:[r.jsx("div",{className:"flex items-center justify-between rounded-t-lg border-b border-neutrals-200 bg-neutrals-100 px-3 py-2",children:r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("h3",{className:"text-neutrals-900",children:e.title})})}),r.jsx("div",{className:"p-3",children:r.jsx("pre",{className:"max-h-96 overflow-auto whitespace-pre-wrap break-words text-neutrals-800",children:r.jsx("code",{children:n})})})]}):null},Sd=e=>{try{const t=new URL(e);return["http:","https:","data:"].includes(t.protocol)}catch{return!1}},yd=e=>Sd(e)?e:"",Dd=e=>Ae.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ae.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"})),Md=({attachment:e,openLinkTitle:t,className:n=""})=>{const s=yd(e.data||"");if(!s)return null;const a=i=>{window.open(i,"_blank")?.focus()};return r.jsx("div",{className:`max-w-[500px] rounded-lg border bg-white py-3 pl-4 pr-3 ${n}`,children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"mt-1 shrink-0 text-hues-800",role:"img","aria-label":"Link",children:r.jsx(Dd,{width:16,height:16})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"mb-1",children:r.jsx(M.Link,{url:s,title:e.title})}),r.jsx("div",{className:"truncate break-all text-neutrals-600",children:s})]}),r.jsx("div",{className:"shrink-0",children:r.jsx(M.Button,{title:t??"Open link",onClick:()=>a(s),buttonClassName:"text-button-tertiary"})})]})})},Ii=({dimensionsInfo:e})=>r.jsx("div",{className:"sidebar flex min-h-0 w-[176px] flex-col gap-3 overflow-auto",children:e.map(t=>r.jsxs("div",{className:"flex flex-col",children:[r.jsx("h5",{className:"text-neutrals-800",children:t.title}),r.jsx("h5",{className:"font-bold",children:t.value})]},t.title))}),Td=({chart:e,isOpen:t,onClose:n,datasetTitle:s})=>{const{titles:a}=ye(),[i,o]=u.useState(M.PopUpState.Closed);u.useEffect(()=>{o(t?M.PopUpState.Opened:M.PopUpState.Closed)},[t]);const c=u.useCallback(()=>{o(M.PopUpState.Closed),n?.()},[n]);return r.jsx(r.Fragment,{children:i===M.PopUpState.Opened&&r.jsxs(M.Popup,{heading:r.jsx("h1",{className:"single-chart-popup-heading",children:a?.chart??"Chart"}),containerClassName:"single-chart-popup h-[80%]",portalId:"single-chart",size:M.PopUpSize.LG,dividers:!1,onClose:c,closeButtonTitle:a?.close??"Close",children:[r.jsxs("div",{className:"single-chart-popup-content flex h-full min-h-0 flex-1 flex-row gap-4",children:[r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[s&&r.jsxs("div",{className:"mb-2 flex items-center gap-1",children:[r.jsx(zn,{className:"size-4 shrink-0 text-neutrals-1000"}),r.jsx("h4",{className:"text-neutrals-1000",children:s})]}),r.jsx(Ja,{option:e.config,className:"size-full",style:{width:"100%",height:"100%"}})]}),r.jsx(Ii,{dimensionsInfo:e.dimensions})]}),r.jsx("div",{})]})})},Yn=e=>{const{titles:t}=ye(),[n,s]=u.useState(!1),[a,i]=u.useState(),o=u.useRef(null),[c,l]=u.useState(""),[f,d]=u.useState(""),[h,m]=u.useState(!1),{onboardingFileSchema:p,isShowOnboarding:g}=Ye(),{isCrossDatasetModeOn:b}=Ue(),[C,x]=u.useState(!1),w=u.useMemo(()=>Ed(e.value),[e.value]),v=u.useCallback(()=>{i(k=>k??w),s(!0)},[w]),S=u.useCallback(()=>{s(!1),x(!0)},[]);return u.useEffect(()=>{if(g){const{title:k,description:T}=ct(Oe.CHART_PER_SERIES,t);l(k),d(T)}},[t,g]),u.useEffect(()=>{g&&m(p?.lastDisplayedElement===Oe.CHART_PER_SERIES&&e.node.rowIndex===0)},[p?.lastDisplayedElement,e.node.rowIndex,g]),u.useEffect(()=>{i(void 0)},[e.value]),w&&!w.isPlottable?null:r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:o,children:r.jsx(M.IconButton,{title:t?.chart??"Chart",buttonClassName:"!text-neutrals-1000 !border-none !p-1",icon:r.jsx(ki,{className:"size-5"}),onClick:v})}),h&&r.jsx(dt,{reference:o,title:c,description:f,onReferenceClick:v,shouldCloseTooltip:C}),n&&a&&r.jsx(Td,{chart:a,isOpen:n,onClose:S,datasetTitle:b?e.data?.datasetTitle??void 0:void 0})]})};function Ed(e){return typeof e=="function"?e():e}const Pt=32,dn=32,Ad=16,mt="padding-0",vt=200,gt={flex:1,minWidth:vt},Nd=Pt,un="observationValueCell",fn="metadataCell",Li="chartCell",Pi="mergedDimensionCell",Ri="datasetDetailCell",jt="Chart_column",kd=(e,t,n,s,a,i)=>({headerName:"",suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:!0,width:32,maxWidth:32,cellClass:mt,cellRenderer:fn,cellRendererParams:{attributesData:t,dataSetData:e,locale:n,metadataSettings:s,titles:a,action:i}});function Fi(e,t,n,s=Nd,a,i){return{headerName:"",field:jt,colId:jt,suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:"right",width:s,maxWidth:s,minWidth:s,cellClass:mt,suppressColumnsToolPanel:!0,cellRenderer:Yn,cellRendererParams:{attributesData:t,dataSetData:e,locale:n,titles:a,action:i}}}function jd(e,t,n,s){return{headerName:"",suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:!0,width:32,maxWidth:32,cellClass:mt,cellRenderer:fn,cellRendererParams:{structuresMap:e,attributesDataMap:t,locale:n,titles:s}}}const Rn=["index","value"],Id=e=>({columns:Rd(e),data:Ld(e)}),Ld=e=>{const t=e.metadata.time_column,n={};for(const s of e.data.data){const{value:a,...i}=s,o=Pd(s,t);n[o]={...n[o]||{},...i,[s[t]]:a}}return Object.values(n)},Pd=(e,t)=>Object.keys(e).filter(n=>!Rn.includes(n)&&n!==t).map(n=>e[n]).join("."),Rd=e=>{const{metadata:t,data:n}=e,s=t.time_column,a=t.pinned_columns||[],i=n.schema.fields,o=[],c=n.data.map(m=>m[s]),f=Array.from(new Set(c)).filter(m=>m!=null).map(m=>({field:m,colId:m,headerName:m,cellClass:"text-right",width:vt})),d=a.map(m=>i.find(p=>p.name===m)).filter(m=>m!=null),h=i.filter(m=>!a.includes(m.name)).filter(m=>m!=null);if(d.length>0)for(const m of[...d])m.name===s||Rn.includes(m.name)||o.push({colId:m.name,field:m.name,headerName:m.name,pinned:"left",...gt,tooltipValueGetter:p=>p.value});for(const m of[...h])m.name===s||Rn.includes(m.name)||o.push({colId:m.name,field:m.name,headerName:m.name,pinned:!1,...gt,tooltipValueGetter:p=>p.value});return o.push(...f),o},qn=e=>e*dn+Pt+Ad,Fd=({attachment:e,actions:t,className:n="",showLimitMessage:s})=>{const[a,i]=u.useState(!1),[o,c]=u.useState([]),[l,f]=u.useState(),[d,h]=u.useState(400);u.useEffect(()=>{e.url!=null&&(i(!0),t.getFile(e.url).then(p=>{if(p==null){c([]),f([]),i(!1);return}const{columns:g,data:b}=Id(p);c(b),f(g),i(!1)}))},[e.url,t]),u.useEffect(()=>{o?(h(qn(o.length)),s?.(o.length>=M.SERIES_LIMIT)):s?.(!1)},[o,s]);const m=u.useMemo(()=>r.jsx(_n.AgGridReact,{headerHeight:Pt,rowHeight:dn,rowData:o,columnDefs:l,enableCellTextSelection:!0,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",autoSizeStrategy:{type:l&&l?.length>5?"fitCellContents":"fitGridWidth"}}),[o,l]);return a?r.jsx(M.Loader,{}):r.jsx("div",{className:`w-full ${n}`,children:r.jsx("div",{className:"ag-theme-quartz max-h-[400px] min-h-[80px] w-full",style:{height:d},children:m})})},Oi=e=>Ae.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Ae.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"})),Od=({title:e,value:t})=>{const n=u.useCallback(()=>Array.isArray(t)?t.join(", "):t,[t]);return r.jsxs("div",{className:"body-3 flex gap-x-3",children:[r.jsxs("p",{title:e,className:"text-neutrals-800",children:[e,":"]}),r.jsx("p",{title:n(),className:"truncate pr-3 font-semibold",children:n()})]})};function _i(e){const t=u.useRef(null),[n,s]=u.useState(!1),[a,i]=u.useState(!1),o=u.useCallback(()=>{const l=t.current;l&&i(l.scrollHeight>l.offsetHeight)},[]);u.useEffect(()=>{if(n)return;o();const l=t.current;if(!l||typeof ResizeObserver>"u")return;const f=new ResizeObserver(()=>o());return f.observe(l),()=>f.disconnect()},[n,e,o]);const c=u.useCallback(()=>s(l=>!l),[]);return{valueRef:t,isExpanded:n,canToggle:a,toggle:c}}const Vi=({isExpanded:e,onToggle:t,title:n})=>r.jsx(M.IconButton,{title:n,buttonClassName:W("border-none p-0 w-6 h-6 shrink-0",e&&"rotate-[180deg]"),isBaseIconStyles:!1,icon:r.jsx(Hn,{width:24,height:24}),onClick:t}),_d=({title:e,value:t,attachedKeysTitles:n,isDimensionGroup:s,locale:a})=>{const i=u.useMemo(()=>Array.isArray(t)?t?.map(d=>typeof d=="object"?d?.[a]:d)?.join(", "):t,[a,t]),{valueRef:o,isExpanded:c,canToggle:l,toggle:f}=_i(i);return r.jsxs("div",{className:"metadata-item",children:[!s&&n?.map(d=>r.jsx("div",{title:d,className:"metadata-item-key mb-1 pr-3 text-neutrals-800",children:d},d)),r.jsxs("div",{className:W("flex items-center",l&&"justify-between"),children:[r.jsx("h2",{title:e,className:"metadata-item-title",children:e}),l&&r.jsx(Vi,{isExpanded:c,onToggle:f})]}),r.jsx("p",{title:i,className:W("metadata-item-value pr-3",!c&&"line-clamp-4"),ref:o,children:i})]})},Vd=({metadata:e,metadataDescription:t=[],locale:n})=>{const{titles:s}=ye();return r.jsxs("div",{className:"metadata-content h-full overflow-hidden",children:[t?.length>0&&r.jsx("div",{className:"metadata-description",children:t?.map(a=>r.jsx(Od,{title:a?.title,value:a?.value},a?.title))}),r.jsx("div",{className:"metadata-list h-full overflow-y-auto",children:e&&e?.length>0?e?.map(a=>r.jsx(_d,{title:a?.title,value:a?.value,locale:n,attachedKeysTitles:a?.attachedKeysTitles,isDimensionGroup:a?.isDimensionGroup},a?.id||a?.title)):r.jsx("div",{className:"metadata-empty flex h-full items-center justify-center text-neutrals-700",children:s?.noMetadata||"No metadata"})})]})},Zn=({metadata:e,metadataDescription:t=[],isOpenMetadata:n,onCloseMetadata:s,locale:a})=>{const{titles:i}=ye(),[o,c]=u.useState(M.PopUpState.Closed);u.useEffect(()=>{c(n?M.PopUpState.Opened:M.PopUpState.Closed)},[n]);const l=u.useCallback(()=>{c(M.PopUpState.Closed),s?.()},[s]);return r.jsx(r.Fragment,{children:o===M.PopUpState.Opened&&r.jsxs(M.Popup,{heading:r.jsx("h1",{className:"metadata-heading",children:i?.metadata||"Metadata"}),containerClassName:"metadata h-[80%]",portalId:"metadata",size:M.PopUpSize.LG,dividers:!1,onClose:l,closeButtonTitle:i?.close||"Close",children:[r.jsx(Vd,{locale:a,metadata:e,metadataDescription:t}),r.jsx("div",{})]})})},ot={dataset:"dataset",agency:"agency",lastUpdated:"lastUpdated"},Hd=({dataset:e,agency:t,lastUpdated:n,externalLink:s,formatValue:a})=>r.jsxs("div",{className:"mb-6 flex flex-col gap-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ve.IconDatabase,{className:"size-4 text-neutrals-700"}),r.jsx("p",{className:"h4 break-words text-neutrals-1000",children:a(e?.value)}),s&&r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:r.jsx(Ve.IconExternalLink,{className:"size-4 shrink-0 cursor-pointer text-primary"})})]}),t&&r.jsxs("div",{className:"body-3 flex gap-1",children:[r.jsxs("span",{className:"text-neutrals-800",children:[t?.title,":"]}),r.jsx("span",{className:"break-words text-neutrals-1000",children:a(t?.value)})]}),n&&r.jsxs("div",{className:"body-3 flex gap-1",children:[r.jsxs("span",{className:"text-neutrals-800",children:[n?.title,":"]}),r.jsx("span",{className:"break-words text-neutrals-1000",children:a(n?.value)})]})]}),Ud=({title:e,value:t,attachedKeysTitles:n,isDimensionGroup:s})=>{const{valueRef:a,isExpanded:i,canToggle:o,toggle:c}=_i(t);return r.jsxs("div",{className:"flex flex-col gap-1",children:[!s&&n?.map((l,f)=>r.jsx("div",{title:l,className:"body-3 text-neutrals-800",children:l},`${l}-${f}`)),r.jsxs("div",{className:"flex items-center justify-between gap-2 pr-2",children:[r.jsx("p",{title:e,className:"body-3 text-neutrals-800",children:e}),o&&r.jsx(Vi,{isExpanded:i,onToggle:c})]}),r.jsx("p",{ref:a,title:t,className:W("body-2 break-words text-neutrals-1000",!i&&"line-clamp-4"),children:t})]})},Bd=new Set(Object.values(ot)),Gd=", ",Rt=({metadata:e,metadataDescription:t=[],datasetInfo:n,externalLink:s,locale:a})=>{const{titles:i}=ye(),o=u.useCallback(p=>Array.isArray(p)?p.map(g=>typeof g=="object"?g?.[a]??"":g).join(Gd):typeof p=="object"&&p!==null?p?.[a]??"":p??"",[a]),{dataset:c,agency:l,lastUpdated:f,hasStructuredDatasetInfo:d}=u.useMemo(()=>{const p=t.find(v=>v?.id===ot.dataset),g=t.find(v=>v?.id===ot.agency),b=t.find(v=>v?.id===ot.lastUpdated),C=n?.dataset||p,x=n?.agency||g,w=n?.lastUpdated||b;return{dataset:C,agency:x,lastUpdated:w,hasStructuredDatasetInfo:!!C}},[n,t]),h=u.useMemo(()=>d?t.filter(p=>!p?.id||!Bd.has(p.id)):t,[d,t]),m=d||h.length>0||!!e?.length;return r.jsx("div",{className:"flex h-full flex-col overflow-hidden px-5 pb-4",children:m?r.jsxs(r.Fragment,{children:[d&&c&&r.jsx(Hd,{dataset:c,agency:l,lastUpdated:f,externalLink:s,formatValue:o}),h.length>0&&r.jsx("div",{className:"mb-4 flex flex-col gap-2",children:h.map((p,g)=>r.jsxs("div",{className:"body-3 flex gap-2",children:[r.jsxs("span",{className:"shrink-0 text-neutrals-800",children:[p?.title||p?.id,":"]}),r.jsx("span",{className:"min-w-0 truncate font-semibold text-neutrals-1000",children:o(p?.value)})]},`${p?.id||p?.title}-${g}`))}),r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:r.jsx("div",{className:"flex flex-col gap-4",children:e?.map(p=>r.jsx(Ud,{title:p?.title||p?.id,value:o(p?.value),attachedKeysTitles:p?.attachedKeysTitles,isDimensionGroup:p?.isDimensionGroup},p?.id||p?.title))})})]}):r.jsx("div",{className:"body-3 flex h-full items-center justify-center text-neutrals-700",children:i?.noMetadata||"No metadata"})})};function mn(e,t){const{externalLink:n,externalLinksMap:s}=e??{};return t!=null&&s!=null?s.get(t):n}const zd=e=>e?.data[e?.colDef?.field||0]?.obsAttributes,Wd=e=>e?.data?.attributes,Hi=(e,t)=>Object.entries(e?.data).filter(([n])=>t?.get(n)).map(([n,s])=>({name:n,value:String(s)})),Ma=(e,t,n)=>{const s=typeof e=="object"?e?.[t]:e;return n?y.getLocalizedName(n?.codes?.find(a=>a?.id===e),t)||"":s},It=(e,t,n)=>e?.map(s=>{const a=s?.name||"",i=t?.get(a),o=i?.codes?.length?i:void 0,c=Array.isArray(s?.value)?s?.value.map(l=>Ma(l,n,o)):Ma(s?.value,n,o);return{id:y.getLocalizedName(o,n)||s?.name,title:y.getLocalizedName(o||i,n),value:c||s?.value}})||[],Ft=(e,t,n)=>({title:n?.dataset||"Dataset",value:y.getLocalizedName(e,t)}),$d=(e,t,n,s)=>[{...Ft(e,n,s),id:ot.dataset},{id:ot.agency,title:s?.agency??"Agency",value:e?.agencyID},{id:ot.lastUpdated,title:s?.lastUpdated??"Last updated",value:t}],Ot=(e,t,n,s)=>({dataset:e?{...Ft(e,n,s),id:ot.dataset}:void 0,agency:e?{id:ot.agency,title:s?.agency??"Agency",value:e?.agencyID}:void 0,lastUpdated:e?{id:ot.lastUpdated,title:s?.lastUpdated??"Last updated",value:t}:void 0}),Ui=(e,t,n)=>({title:y.getDimensionTitle(e?.conceptSchemes,y.getDimensions(e)?.timeDimensions?.[0],t),value:n?.colId||""}),Bi=(e,t)=>({title:t?.observation||"Observation",value:e}),Gi=(e,t,n,s,a,i)=>{const o={title:s?.timeSeries||"Time Series",value:i?.originalData?.name};return n?[Ui(e,t,a),o,Bi(n,s)]:[o]},zi=e=>{const t=e?.dataSets?.[0]?.attributes||[],n=e?.structures?.[0]?.attributes?.dataSet||[];return t?.length?n.reduce((s,a,i)=>{const o=t[i];if(o==null)return s;if(a?.values?.length>0){const c=a.values[o];s.push(c?{...a,values:[c]}:{...a})}else Array.isArray(o)?s.push({...a,values:[{values:o}]}):s.push({...a,values:[{value:o}]});return s},[]):n},Ta=(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 a=Object.values(n).find(i=>typeof i=="string");return typeof a=="string"?a:void 0},Wi=(e,t,n)=>e?.map(s=>{const a=s?.id,i=s?.values?.[0]?.value,o=(typeof i=="object"?Ta(i,n):i)||s?.values?.[0]?.id,c=s?.values?.[0]?.ids||s?.values?.[0]?.values,l=t?.get(a),f=l?.codes?.length?l:void 0,d=y.getLocalizedName(f?.codes?.find(m=>m?.id===o),n)||y.getLocalizedName(s?.values?.[0],n)||o,h=c&&c.map(m=>{const p=typeof m=="object"?Ta(m,n):String(m);return y.getLocalizedName(f?.codes?.find(g=>g?.id===p),n)||p}).filter(m=>m!=null);return{id:a,title:y.getLocalizedName(l,n)||a,value:h?.length?h:d}}).filter(({value:s})=>!!s)||[],Jd=(e,t)=>{const n=e?.dataSets?.[0],a=e?.structures?.[0]?.attributes?.dimensionGroup||[],i=n?.dimensionGroupAttributes;return new Map(a.map(o=>{const c=o?.relationship?.dimensions,{codedSeriesKey:l,decodedSeriesKey:f}=Kd(e,t,c);return[o.id,{values:i?.[l]||[],decodedSeriesKey:f,codedSeriesKey:l}]}))},Kd=(e,t,n)=>{const s=e?.structures?.[0],a=[...s?.dimensions.series||[],...s?.dimensions.observation||[]],i=new Array(a?.length)?.fill(""),o=new Array(a?.length)?.fill("");return n&&n?.forEach(c=>{const l=a?.findIndex(h=>h?.id===c)||0,f=t[l],d=a[l]?.values?.findIndex(h=>h?.id===f||h?.value===f)||0;i[l]=d>=0?d:f,o[l]=f}),{codedSeriesKey:i?.join(":"),decodedSeriesKey:o?.join(":")}},Yd=(e,t)=>{if(t==null)return;const n=e?.values?.[t],s=typeof t=="object"&&!Array.isArray(t),a=Array.isArray(t);return n||(s||a?{values:t}:{value:t?.toString()})},qd=e=>{const t=e?.value||e?.id,n=e?.values||e?.ids;return t!=null?[t]:n||[null]},$i=(e,t,n)=>t==null?t:n?.get(e||"")?.codes?.find(a=>a?.id===t)?.name||t,Zd=(e,t,n,s=te.Locale.EN)=>{const a=n?.dataStructureComponents?.dimensionList,i=[...a?.dimensions||[],...a?.timeDimensions||[]],o=[];return(e?.split(":")||[])?.forEach((l,f)=>{if(l!==""){const d=i?.[f]?.id||"",h=y.getLocalizedName(t?.get(d),s),m=$i(d,l,t);o.push(`${h}: ${m}`)}}),o},Xd=(e,t,n,s,a=te.Locale.EN)=>{if(!e||!t||!s)return[];const i=e?.structures?.[0]?.attributes?.dimensionGroup||[],o=Jd(e,s);return i?.map((c,l)=>{const f=o?.get(c?.id),d=n?.get(c?.id),h=qd(Yd(c,f?.values?.[l]));return{id:c?.id,title:y.getLocalizedName(d,a),value:Array.isArray(h)?h?.map(m=>$i(c?.id,m,n)||""):h,attachedKeysTitles:Zd(f?.decodedSeriesKey,n,t),isDimensionGroup:!0}})?.filter(({value:c})=>c?.some(l=>!!l))||[]},Qd=No.extendTailwindMerge({extend:{classGroups:{typography:["h1","h2","h3","h4","h5","body-1","body-2","body-3","caption"]}}});function nt(...e){return Qd(W(...e))}function eu({title:e,headerExtension:t,headerClassName:n,onClose:s,bodyClassName:a,panelClassName:i,children:o}){return r.jsxs("div",{className:nt("h-full w-[362px] bg-white border-l border-neutrals-500 flex flex-col overflow-hidden",i),children:[r.jsxs("div",{className:nt("flex justify-between px-5 py-6",n),children:[r.jsx("div",{className:"h2 text-neutrals-1000",children:e}),r.jsxs("div",{className:"flex items-center gap-2",children:[t,t&&r.jsx("div",{className:"h-3 w-px bg-neutrals-600"}),r.jsx("button",{type:"button",onClick:s,children:r.jsx(Ve.IconX,{className:"size-5 text-neutrals-1000"})})]})]}),r.jsx("div",{className:nt("flex-1 min-h-0 overflow-hidden",a),children:o})]})}const Ji=u.createContext(null);function tu({children:e}){const[t,n]=u.useState(null),s=u.useCallback(c=>{n(c)},[]),a=u.useCallback(()=>{n(null)},[]),i=u.useCallback(c=>c?t?.id===c:t!==null,[t]),o=u.useMemo(()=>({panel:t,openPanel:s,closePanel:a,isPanelOpen:i}),[t,s,a,i]);return r.jsx(Ji.Provider,{value:o,children:e})}function Ki(){return u.useContext(Ji)}function ht(){const e=Ki();if(!e)return null;const{openPanel:t,closePanel:n,isPanelOpen:s}=e;return{openPanel:t,closePanel:n,isPanelOpen:s}}function Yi({scope:e}){const t=Ki();if(!t)return null;const{panel:n,closePanel:s}=t;if(!n)return null;const a=n.scope??"any";return a!=="any"&&a!==e?null:r.jsx(eu,{title:n.title,headerExtension:n.headerExtension,headerClassName:n.headerClassName,onClose:s,bodyClassName:n.bodyClassName,panelClassName:n.panelClassName,children:n.content})}function Mn(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function Dt(e){return(t,n)=>{const s=n?.context?String(n.context):"standalone";let a;if(s==="formatting"&&e.formattingValues){const o=e.defaultFormattingWidth||e.defaultWidth,c=n?.width?String(n.width):o;a=e.formattingValues[c]||e.formattingValues[o]}else{const o=e.defaultWidth,c=n?.width?String(n.width):e.defaultWidth;a=e.values[c]||e.values[o]}const i=e.argumentCallback?e.argumentCallback(t):t;return a[i]}}function Mt(e){return(t,n={})=>{const s=n.width,a=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],i=t.match(a);if(!i)return null;const o=i[0],c=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(c)?su(c,h=>h.test(o)):nu(c,h=>h.test(o));let f;f=e.valueCallback?e.valueCallback(l):l,f=n.valueCallback?n.valueCallback(f):f;const d=t.slice(o.length);return{value:f,rest:d}}}function nu(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function su(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function au(e){return(t,n={})=>{const s=t.match(e.matchPattern);if(!s)return null;const a=s[0],i=t.match(e.parsePattern);if(!i)return null;let o=e.valueCallback?e.valueCallback(i[0]):i[0];o=n.valueCallback?n.valueCallback(o):o;const c=t.slice(a.length);return{value:o,rest:c}}}const Ea=Symbol.for("constructDateFrom");function qi(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Ea in e?e[Ea](t):e instanceof Date?new e.constructor(t):new Date(t)}function ru(e,...t){const n=qi.bind(null,e||t.find(s=>typeof s=="object"));return t.map(n)}let iu={};function ou(){return iu}function Xn(e,t){return qi(t||e,e)}function Aa(e,t){const n=ou(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,a=Xn(e,t?.in),i=a.getDay(),o=(i<s?7:0)+i-s;return a.setDate(a.getDate()-o),a.setHours(0,0,0,0),a}function Zi(e,t,n){const[s,a]=ru(n?.in,e,t);return+Aa(s,n)==+Aa(a,n)}function Tt(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 Ke(e){return(t,n)=>n&&n.addSuffix?n.comparison&&n.comparison>0?e.future?Tt(e.future,t):"за "+Tt(e.regular,t):e.past?Tt(e.past,t):Tt(e.regular,t)+" тому":Tt(e.regular,t)}const lu=(e,t)=>t&&t.addSuffix?t.comparison&&t.comparison>0?"за півхвилини":"півхвилини тому":"півхвилини",cu={lessThanXSeconds:Ke({regular:{one:"менше секунди",singularNominative:"менше {{count}} секунди",singularGenitive:"менше {{count}} секунд",pluralGenitive:"менше {{count}} секунд"},future:{one:"менше, ніж за секунду",singularNominative:"менше, ніж за {{count}} секунду",singularGenitive:"менше, ніж за {{count}} секунди",pluralGenitive:"менше, ніж за {{count}} секунд"}}),xSeconds:Ke({regular:{singularNominative:"{{count}} секунда",singularGenitive:"{{count}} секунди",pluralGenitive:"{{count}} секунд"},past:{singularNominative:"{{count}} секунду тому",singularGenitive:"{{count}} секунди тому",pluralGenitive:"{{count}} секунд тому"},future:{singularNominative:"за {{count}} секунду",singularGenitive:"за {{count}} секунди",pluralGenitive:"за {{count}} секунд"}}),halfAMinute:lu,lessThanXMinutes:Ke({regular:{one:"менше хвилини",singularNominative:"менше {{count}} хвилини",singularGenitive:"менше {{count}} хвилин",pluralGenitive:"менше {{count}} хвилин"},future:{one:"менше, ніж за хвилину",singularNominative:"менше, ніж за {{count}} хвилину",singularGenitive:"менше, ніж за {{count}} хвилини",pluralGenitive:"менше, ніж за {{count}} хвилин"}}),xMinutes:Ke({regular:{singularNominative:"{{count}} хвилина",singularGenitive:"{{count}} хвилини",pluralGenitive:"{{count}} хвилин"},past:{singularNominative:"{{count}} хвилину тому",singularGenitive:"{{count}} хвилини тому",pluralGenitive:"{{count}} хвилин тому"},future:{singularNominative:"за {{count}} хвилину",singularGenitive:"за {{count}} хвилини",pluralGenitive:"за {{count}} хвилин"}}),aboutXHours:Ke({regular:{singularNominative:"близько {{count}} години",singularGenitive:"близько {{count}} годин",pluralGenitive:"близько {{count}} годин"},future:{singularNominative:"приблизно за {{count}} годину",singularGenitive:"приблизно за {{count}} години",pluralGenitive:"приблизно за {{count}} годин"}}),xHours:Ke({regular:{singularNominative:"{{count}} годину",singularGenitive:"{{count}} години",pluralGenitive:"{{count}} годин"}}),xDays:Ke({regular:{singularNominative:"{{count}} день",singularGenitive:"{{count}} днi",pluralGenitive:"{{count}} днів"}}),aboutXWeeks:Ke({regular:{singularNominative:"близько {{count}} тижня",singularGenitive:"близько {{count}} тижнів",pluralGenitive:"близько {{count}} тижнів"},future:{singularNominative:"приблизно за {{count}} тиждень",singularGenitive:"приблизно за {{count}} тижні",pluralGenitive:"приблизно за {{count}} тижнів"}}),xWeeks:Ke({regular:{singularNominative:"{{count}} тиждень",singularGenitive:"{{count}} тижні",pluralGenitive:"{{count}} тижнів"}}),aboutXMonths:Ke({regular:{singularNominative:"близько {{count}} місяця",singularGenitive:"близько {{count}} місяців",pluralGenitive:"близько {{count}} місяців"},future:{singularNominative:"приблизно за {{count}} місяць",singularGenitive:"приблизно за {{count}} місяці",pluralGenitive:"приблизно за {{count}} місяців"}}),xMonths:Ke({regular:{singularNominative:"{{count}} місяць",singularGenitive:"{{count}} місяці",pluralGenitive:"{{count}} місяців"}}),aboutXYears:Ke({regular:{singularNominative:"близько {{count}} року",singularGenitive:"близько {{count}} років",pluralGenitive:"близько {{count}} років"},future:{singularNominative:"приблизно за {{count}} рік",singularGenitive:"приблизно за {{count}} роки",pluralGenitive:"приблизно за {{count}} років"}}),xYears:Ke({regular:{singularNominative:"{{count}} рік",singularGenitive:"{{count}} роки",pluralGenitive:"{{count}} років"}}),overXYears:Ke({regular:{singularNominative:"більше {{count}} року",singularGenitive:"більше {{count}} років",pluralGenitive:"більше {{count}} років"},future:{singularNominative:"більше, ніж за {{count}} рік",singularGenitive:"більше, ніж за {{count}} роки",pluralGenitive:"більше, ніж за {{count}} років"}}),almostXYears:Ke({regular:{singularNominative:"майже {{count}} рік",singularGenitive:"майже {{count}} роки",pluralGenitive:"майже {{count}} років"},future:{singularNominative:"майже за {{count}} рік",singularGenitive:"майже за {{count}} роки",pluralGenitive:"майже за {{count}} років"}})},du=(e,t,n)=>(n=n||{},cu[e](t,n)),uu={full:"EEEE, do MMMM y 'р.'",long:"do MMMM y 'р.'",medium:"d MMM y 'р.'",short:"dd.MM.y"},fu={full:"H:mm:ss zzzz",long:"H:mm:ss z",medium:"H:mm:ss",short:"H:mm"},mu={full:"{{date}} 'о' {{time}}",long:"{{date}} 'о' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},hu={date:Mn({formats:uu,defaultWidth:"full"}),time:Mn({formats:fu,defaultWidth:"full"}),dateTime:Mn({formats:mu,defaultWidth:"full"})},Qn=["неділю","понеділок","вівторок","середу","четвер","п’ятницю","суботу"];function pu(e){const t=Qn[e];switch(e){case 0:case 3:case 5:case 6:return"'у минулу "+t+" о' p";case 1:case 2:case 4:return"'у минулий "+t+" о' p"}}function Xi(e){return"'у "+Qn[e]+" о' p"}function gu(e){const t=Qn[e];switch(e){case 0:case 3:case 5:case 6:return"'у наступну "+t+" о' p";case 1:case 2:case 4:return"'у наступний "+t+" о' p"}}const Cu=(e,t,n)=>{const s=Xn(e),a=s.getDay();return Zi(s,t,n)?Xi(a):pu(a)},wu=(e,t,n)=>{const s=Xn(e),a=s.getDay();return Zi(s,t,n)?Xi(a):gu(a)},xu={lastWeek:Cu,yesterday:"'вчора о' p",today:"'сьогодні о' p",tomorrow:"'завтра о' p",nextWeek:wu,other:"P"},vu=(e,t,n,s)=>{const a=xu[e];return typeof a=="function"?a(t,n,s):a},bu={narrow:["до н.е.","н.е."],abbreviated:["до н. е.","н. е."],wide:["до нашої ери","нашої ери"]},Su={narrow:["1","2","3","4"],abbreviated:["1-й кв.","2-й кв.","3-й кв.","4-й кв."],wide:["1-й квартал","2-й квартал","3-й квартал","4-й квартал"]},yu={narrow:["С","Л","Б","К","Т","Ч","Л","С","В","Ж","Л","Г"],abbreviated:["січ.","лют.","берез.","квіт.","трав.","черв.","лип.","серп.","верес.","жовт.","листоп.","груд."],wide:["січень","лютий","березень","квітень","травень","червень","липень","серпень","вересень","жовтень","листопад","грудень"]},Du={narrow:["С","Л","Б","К","Т","Ч","Л","С","В","Ж","Л","Г"],abbreviated:["січ.","лют.","берез.","квіт.","трав.","черв.","лип.","серп.","верес.","жовт.","листоп.","груд."],wide:["січня","лютого","березня","квітня","травня","червня","липня","серпня","вересня","жовтня","листопада","грудня"]},Mu={narrow:["Н","П","В","С","Ч","П","С"],short:["нд","пн","вт","ср","чт","пт","сб"],abbreviated:["нед","пон","вів","сер","чтв","птн","суб"],wide:["неділя","понеділок","вівторок","середа","четвер","п’ятниця","субота"]},Tu={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:"ніч"}},Eu={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:"ночі"}},Au=(e,t)=>{const n=String(t?.unit),s=Number(e);let a;return n==="date"?s===3||s===23?a="-є":a="-е":n==="minute"||n==="second"||n==="hour"?a="-а":a="-й",s+a},Nu={ordinalNumber:Au,era:Dt({values:bu,defaultWidth:"wide"}),quarter:Dt({values:Su,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Dt({values:yu,defaultWidth:"wide",formattingValues:Du,defaultFormattingWidth:"wide"}),day:Dt({values:Mu,defaultWidth:"wide"}),dayPeriod:Dt({values:Tu,defaultWidth:"any",formattingValues:Eu,defaultFormattingWidth:"wide"})},ku=/^(\d+)(-?(е|й|є|а|я))?/i,ju=/\d+/i,Iu={narrow:/^((до )?н\.?\s?е\.?)/i,abbreviated:/^((до )?н\.?\s?е\.?)/i,wide:/^(до нашої ери|нашої ери|наша ера)/i},Lu={any:[/^д/i,/^н/i]},Pu={narrow:/^[1234]/i,abbreviated:/^[1234](-?[иі]?й?)? кв.?/i,wide:/^[1234](-?[иі]?й?)? квартал/i},Ru={any:[/1/i,/2/i,/3/i,/4/i]},Fu={narrow:/^[слбктчвжг]/i,abbreviated:/^(січ|лют|бер(ез)?|квіт|трав|черв|лип|серп|вер(ес)?|жовт|лис(топ)?|груд)\.?/i,wide:/^(січень|січня|лютий|лютого|березень|березня|квітень|квітня|травень|травня|червня|червень|липень|липня|серпень|серпня|вересень|вересня|жовтень|жовтня|листопад[а]?|грудень|грудня)/i},Ou={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]},_u={narrow:/^[нпвсч]/i,short:/^(нд|пн|вт|ср|чт|пт|сб)\.?/i,abbreviated:/^(нед|пон|вів|сер|че?тв|птн?|суб)\.?/i,wide:/^(неділ[яі]|понеділ[ок][ка]|вівтор[ок][ка]|серед[аи]|четвер(га)?|п\W*?ятниц[яі]|субот[аи])/i},Vu={narrow:[/^н/i,/^п/i,/^в/i,/^с/i,/^ч/i,/^п/i,/^с/i],any:[/^н/i,/^п[он]/i,/^в/i,/^с[ер]/i,/^ч/i,/^п\W*?[ят]/i,/^с[уб]/i]},Hu={narrow:/^([дп]п|півн\.?|пол\.?|ранок|ранку|день|дня|веч\.?|ніч|ночі)/i,abbreviated:/^([дп]п|півн\.?|пол\.?|ранок|ранку|день|дня|веч\.?|ніч|ночі)/i,wide:/^([дп]п|північ|полудень|ранок|ранку|день|дня|вечір|вечора|ніч|ночі)/i},Uu={any:{am:/^дп/i,pm:/^пп/i,midnight:/^півн/i,noon:/^пол/i,morning:/^р/i,afternoon:/^д[ен]/i,evening:/^в/i,night:/^н/i}},Bu={ordinalNumber:au({matchPattern:ku,parsePattern:ju,valueCallback:e=>parseInt(e,10)}),era:Mt({matchPatterns:Iu,defaultMatchWidth:"wide",parsePatterns:Lu,defaultParseWidth:"any"}),quarter:Mt({matchPatterns:Pu,defaultMatchWidth:"wide",parsePatterns:Ru,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Mt({matchPatterns:Fu,defaultMatchWidth:"wide",parsePatterns:Ou,defaultParseWidth:"any"}),day:Mt({matchPatterns:_u,defaultMatchWidth:"wide",parsePatterns:Vu,defaultParseWidth:"any"}),dayPeriod:Mt({matchPatterns:Hu,defaultMatchWidth:"wide",parsePatterns:Uu,defaultParseWidth:"any"})},Gu={code:"uk",formatDistance:du,formatLong:hu,formatRelative:vu,localize:Nu,match:Bu,options:{weekStartsOn:1,firstWeekContainsDate:1}},zu=e=>e===te.Locale.UK?"dd MMM, yyyy":" MMM dd, yyyy hh:mm aa",_t=(e,t)=>{const n=zu(t);return e!=null&&e!==""&&n&&Zs.isValid(new Date(e))?Zs.format(new Date(e),n,t===te.Locale.UK?{locale:Gu}:void 0):""},Qi=e=>{const{titles:t}=ye(),n="grid-metadata-side-panel",[s,a]=u.useState(!1),i=u.useRef(null),[o,c]=u.useState(""),[l,f]=u.useState(""),[d,h]=u.useState(!1),{onboardingFileSchema:m,isShowOnboarding:p}=Ye(),{isOpenedAdvancedView:g}=Ge(),b=ht(),{isMetadataInSidePanel:C}=Ue(),[x,w]=u.useState(!1),v=e?.data?.dataset?.urn,S=mn(e?.context,v),k=u.useMemo(()=>e.structuresMap?v!=null?e.structuresMap.get(v):void 0:e.dataSetData,[e.structuresMap,v,e.dataSetData]),T=u.useMemo(()=>e.attributesDataMap?v!=null?e.attributesDataMap.get(v):void 0:e.attributesData,[e.attributesDataMap,v,e.attributesData]),N=u.useMemo(()=>y.getStructureComponentsMap(k),[k]),D=u.useMemo(()=>[Ft(k?.dataflows?.[0],e?.locale,t),...It(Hi(e,N),N,e?.locale),...It(Wd(e),N,e?.locale),...Xd(T,k?.dataStructures?.[0],N,e?.data?.originalData?.parsedTimeSeriesValue,e?.locale)],[e,k,T,N,t]),R=u.useMemo(()=>Gi(k,e?.locale,e?.valueFormatted||e?.value,t,e?.colDef,e?.data),[e,k,t]),E=u.useMemo(()=>{const O=k?.dataflows?.[0],L=_t(y.getLastUpdatedTime(O),e?.locale);return Ot(O,L,e?.locale,t)},[k,e?.locale,t]),A=u.useCallback(()=>{if(C&&b){b.openPanel({id:n,scope:g?"advanced":"conversation",title:t?.timeseriesMetadataPanel||"Timeseries Metadata",bodyClassName:"overflow-hidden",content:r.jsx(Rt,{locale:e?.locale,metadata:D,datasetInfo:E,externalLink:S,metadataDescription:e?.metadataSettings?.isMetadataDescription?R:[]})}),w(!0);return}a(!0)},[C,g,D,R,E,S,e?.locale,e?.metadataSettings?.isMetadataDescription,t,b]),j=u.useCallback(()=>{a(!1),w(!0)},[]);return u.useEffect(()=>{if(p){const{title:O,description:L}=ct(Oe.METADATA_PER_SERIES,t);c(O),f(L)}},[t,p]),u.useEffect(()=>{if(p){const O=m?.lastDisplayedElement===Oe.METADATA_PER_SERIES&&e.node.rowIndex===0;h(O),O&&setTimeout(()=>{i?.current?.scrollIntoView({block:"end",behavior:"smooth"})})}},[m?.lastDisplayedElement,e.node.rowIndex,p]),r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:i,children:r.jsx(M.IconButton,{title:t?.metadata||"View details",buttonClassName:"!text-neutrals-1000 !border-none !p-1",icon:r.jsx(Oi,{className:"size-5"}),onClick:A})}),d&&r.jsx(dt,{reference:i,title:o,description:l,onReferenceClick:A,shouldCloseTooltip:x}),s&&r.jsx(Zn,{locale:e?.locale,metadata:D,metadataDescription:e?.metadataSettings?.isMetadataDescription?R:[],isOpenMetadata:s,onCloseMetadata:j})]})},Wu=(e,t)=>{const n=$u(e),s=y.getStructureComponentsMap(n),a=e?.valueFormatted||e?.value,i=It(t,s,e?.locale),o=[Ft(n?.dataflows?.[0],e?.locale,e?.titles),...It(Hi(e,s),s,e?.locale),...e?.metadataSettings?.isMetadataDescription?[]:[Ui(n,e?.locale,e?.colDef),Bi(a,e?.titles)],...i],c=e?.metadataSettings?.isMetadataDescription?Gi(n,e?.locale,a,e?.titles,e?.colDef,e?.data):[],l=n?.dataflows?.[0],f=_t(y.getLastUpdatedTime(l),e?.locale),d=Ot(l,f,e?.locale,e?.titles);return{metadata:o,metadataDescription:c,sidePanelDatasetInfo:d}},$u=e=>{if(e.structuresMap){const t=e?.data?.dataset?.urn;return t!=null?e.structuresMap.get(t):void 0}return e.dataSetData},Ju="observation-metadata-side-panel",Ku=({params:e,obsAttributes:t})=>{const{titles:n}=ye(),[s,a]=u.useState(null),{isOpenedAdvancedView:i}=Ge(),o=ht(),{isMetadataInSidePanel:c}=Ue(),l=e?.data?.dataset?.urn,f=mn(e?.context,l),d=u.useCallback(()=>{const m=Wu(e,t);if(c&&o){o.openPanel({id:Ju,scope:i?"advanced":"conversation",title:n?.metadata||"Metadata",bodyClassName:"overflow-hidden",content:r.jsx(Rt,{locale:e?.locale,metadata:m.metadata,datasetInfo:m.sidePanelDatasetInfo,externalLink:f,metadataDescription:m.metadataDescription})});return}a(m)},[c,i,f,t,e,o,n]),h=u.useCallback(()=>{a(null)},[]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative size-full p-2 text-end",children:[e?.valueFormatted||e?.value,r.jsx("div",{className:"metadata-indicator",title:n?.metadata||"View details",onClick:d})]}),s&&r.jsx(Zn,{locale:e?.locale,metadata:s.metadata,metadataDescription:s.metadataDescription,isOpenMetadata:!0,onCloseMetadata:h})]})},eo=e=>{const t=zd(e);return t?.length?r.jsx(Ku,{params:e,obsAttributes:t}):r.jsx("div",{className:"relative size-full p-2 text-end",children:e?.valueFormatted||e?.value})},to=({ref:e,fixHeight:t,gridHeight:n,children:s})=>r.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}),Yu=({attachment:e,isDataLoading:t,isChartColumnVisible:n,fixHeight:s,externalLink:a,showLimitMessage:i,onApiReady:o})=>{const{titles:c}=ye(),[l,f]=u.useState(!1),[d,h]=u.useState([]),[m,p]=u.useState(),[g,b]=u.useState(400),C=u.useRef(null),[x,w]=u.useState(""),[v,S]=u.useState(""),[k,T]=u.useState(!1),{isShowOnboarding:N,onboardingFileSchema:D,setOnboardingFileSchema:R}=Ye();u.useEffect(()=>{if(e.grid_data==null)f(!0);else{const L=e.grid_data.columns.map($=>$.colId===jt?{...$,hide:!n}:$);h(e.grid_data.data),p(L),f(!1)}},[e.grid_data,n]),u.useEffect(()=>{d?(b(qn(d.length)),i?.(d.length>=M.SERIES_LIMIT)):i?.(!1)},[d,i]),u.useEffect(()=>{if(N){const{title:L,description:$}=ct(Oe.DATA_GRID,c);w(L),S($)}},[c,N]),u.useEffect(()=>{D&&!D?.infoElements?.dataGrid&&R?.({...D,infoElements:{...D?.infoElements,dataGrid:!0},lastDisplayedElement:Oe.DATA_GRID})},[D,R]),u.useEffect(()=>{if(N){const L=D?.lastDisplayedElement===Oe.DATA_GRID;T(L),!l&&!t&&L&&setTimeout(()=>{C?.current?.scrollIntoView({block:"end",behavior:"smooth"})})}},[D?.lastDisplayedElement,N,t,l]);const E=u.useCallback(L=>{o?.(L.api)},[o]),A=u.useMemo(()=>({externalLink:a}),[a]),j=u.useMemo(()=>({[fn]:Qi,[un]:eo,[Li]:Yn}),[]),O=u.useMemo(()=>r.jsx(_n.AgGridReact,{onGridReady:E,headerHeight:Pt,rowHeight:dn,rowData:d,enableCellTextSelection:!0,columnDefs:m,context:A,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",components:j,valueCache:!0}),[d,m,E,A,j]);return l||t?r.jsx(M.Loader,{}):r.jsxs("div",{className:"size-full",children:[r.jsx(to,{ref:C,fixHeight:s,gridHeight:g,children:O}),k&&r.jsx(dt,{reference:C,title:x,description:v,supressReferenceClick:!0})]})};function Lt(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 qu=200,Zu=8,Xu=2,Qu=({currentIndex:e,totalCount:t,icons:n,onPrev:s,onNext:a})=>{const{titles:i}=ye(),o=u.useRef(null),[c,l]=u.useState(""),[f,d]=u.useState(""),[h,m]=u.useState(!1),{onboardingFileSchema:p,isShowOnboarding:g}=Ye();u.useEffect(()=>{if(g){const{title:w,description:v}=ct(Oe.CHARTS_NAVIGATION,i);l(w),d(v)}},[i,g]),u.useEffect(()=>{if(g){const w=p?.lastDisplayedElement===Oe.CHARTS_NAVIGATION;m(w),w&&o?.current?.scrollIntoView({block:"center",behavior:"smooth"})}},[p?.lastDisplayedElement,g]);const b=t>0?e/t*100:0,C=t>0?Math.min(Zu*t,qu):0,x=t>0?Math.max(C/t,Xu):0;return r.jsxs("div",{className:"flex w-full flex-row items-center justify-center gap-2",children:[r.jsx("div",{className:W("h-[20px] w-[20px] cursor-pointer",e===0?"text-neutrals-700":"text-primary"),onClick:s,children:n?.[Xt.PREVIOUS]}),r.jsxs("div",{className:"flex flex-col items-center gap-1 pt-[20px]",children:[r.jsx("div",{className:"relative h-[4px] rounded-full bg-neutral-300",style:{width:`${C}px`},children:r.jsx("div",{className:"absolute h-full rounded-full bg-primary",style:{left:`${b}%`,width:`${x}px`}})}),r.jsxs("h5",{className:"text-neutrals-800",children:[e+1,"/",t]})]}),r.jsx("div",{className:W("h-[20px] w-[20px] cursor-pointer",e+1===t?"text-neutrals-700":"text-primary"),onClick:a,ref:o,children:n?.[Xt.NEXT]}),h&&r.jsx(dt,{reference:o,title:c,description:f})]})},ef=({limitAmount:e,openAdvancedView:t,prefixIcon:n,contentClassName:s})=>{const{titles:a}=ye(),[i,o]=u.useState(!1),{refs:c,floatingStyles:l,context:f}=Xe.useFloating({open:i,onOpenChange:o,placement:"top-start"}),d=Xe.useHover(f,{handleClose:Xe.safePolygon({blockPointerEvents:!0})}),{getReferenceProps:h,getFloatingProps:m}=Xe.useInteractions([d]);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex w-fit",ref:c.setReference,...h(),children:r.jsxs("div",{className:nt("mt-1 flex w-fit items-center gap-1 bg-hues-100 px-4 py-2",s),children:[n,r.jsx("h5",{className:"font-bold",children:a?.limits||"Limited to"}),r.jsxs("h5",{children:[e," ",a?.timeseriesLimit||"Timeseries"]})]})}),i&&r.jsx("div",{className:"floating",ref:c.setFloating,style:l,...m(),children:r.jsxs("div",{className:"z-10 mb-2 flex w-[300px] flex-col gap-2 rounded bg-white p-4 shadow",children:[r.jsxs("div",{children:[r.jsxs("h5",{className:"text-neutrals-900",children:[r.jsx("span",{className:"pr-0.5",children:a?.limitLinkInfoP1_1||"The number of timeseries displayed in a single chart i"}),r.jsxs("span",{className:"pr-0.5 font-bold",children:[a?.limitLinkInfoP1_2||"limited to"," ",e]}),a?.limitLinkInfoP1_3||"for better clarity and performance."]}),r.jsxs("h5",{className:"text-neutrals-900",children:[r.jsx("span",{className:"pr-0.5",children:a?.limitLinkInfoP2_1||"To visualize specific timeseries"}),r.jsx("span",{className:"pr-0.5 font-bold",children:a?.limitLinkInfoP2_2||"filter"}),r.jsx("span",{className:"pr-0.5",children:a?.limitLinkInfoP2_3||"your request, or"}),r.jsx("span",{className:"pr-0.5 font-bold",children:a?.limitLinkInfoP2_4||"refine"}),a?.limitLinkInfoP2_5||"it in the chat."]})]}),t&&r.jsx("h4",{className:"cursor-pointer text-primary",onClick:t,children:a?.limitLinkInfoLink||"Open Advanced View"})]})})]})};function tf(e,t,n){const s=(e.getZr()?.painter).getRenderedCanvas()?.getContext("2d");if(!s)return 0;const a=n.textStyle?.fontSize??12,i=n.textStyle?.fontFamily??"sans-serif";s.font=`${a}px ${i}`;const o=s.measureText(t).width,c=n.itemWidth??25,l=n.itemGap??10;return o+c+l}const nf=({option:e,style:t})=>{const n=u.useRef(null),[s,a]=u.useState(e);u.useEffect(()=>{a(On.cloneDeep(e))},[e]);const i=u.useCallback(()=>{const o=n.current?.getEchartsInstance?.();if(!o)return;const l=o.getDom().clientWidth,f=e.legend||{},d=f.itemHeight??14,h=f.textStyle?.fontSize??12,m=o.getModel()?.getComponent("legend")?.getData()||[];let p=0;m.forEach(x=>{const w=x.option.name||"";p+=tf(o,w,f)});const b=Math.max(1,Math.ceil(p/l))*(+d+ +h+6),C=20;a(x=>({...x,grid:{...x.grid||{},bottom:b+C}}))},[e.legend]);return u.useEffect(()=>{i();const o=()=>{i()};return window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o)}},[e,i]),r.jsx(Ja,{notMerge:!0,lazyUpdate:!1,ref:n,option:s,style:t})},sf=({attachment:e,icons:t,isDataLoading:n,openAdvancedView:s,fixHeight:a=!0,limitationInfoPrefixIcon:i,limitationInfoContentClassName:o})=>{const{titles:c}=ye(),[l,f]=u.useState(!0),[d,h]=u.useState(),[m,p]=u.useState([]),[g,b]=u.useState(0),[C,x]=u.useState(void 0),[w,v]=u.useState(),{onboardingFileSchema:S,isShowOnboarding:k,setOnboardingFileSchema:T}=Ye(),N=u.useRef(null),{charting_data:D,getChartingData:R}=e;u.useEffect(()=>{if(b(0),D){h(D),f(!1);return}if(!R){h(void 0),f(!0);return}return f(!0),Lt(()=>{try{h(R())}catch(j){console.error("Error building chart data",j),h({units:[]})}finally{f(!1)}})},[D,R]),u.useEffect(()=>{const j=d?.groups??[],O=d?.units??[];p(j.length>0?j.flatMap(L=>L.units.map($=>({unit:$,groupTitle:L.title}))):O.map(L=>({unit:L})))},[d]),u.useEffect(()=>{const j=m.length>g,O=j?m[g]:m[0];x(!l&&O!=null?O.unit:void 0),v(O?.groupTitle),j||b(0)},[l,m,g]),u.useEffect(()=>{S&&k&&!l&&(Rc(S)&&(T?.(Pc(S)),N?.current?.scrollIntoView({block:"center",behavior:"smooth"})),S.lastDisplayedElement===Oe.CHART_PER_SERIES&&T?.(bi(S)))},[l,T,S,k]);const E=u.useCallback(()=>{b(j=>Math.min(j+1,m.length-1))},[m.length]),A=u.useCallback(()=>{b(j=>Math.max(j-1,0))},[]);return l||n?r.jsx(M.Loader,{}):r.jsx("div",{className:"chart-attachment size-full",ref:N,children:d&&r.jsx("div",{className:"flex size-full flex-col gap-4",children:m.length==0||C==null?r.jsx("h4",{className:"ml-1",children:c?.chartInfo||"No data"}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("h3",{className:"chart-attachment-title",children:[c?.chart||"Chart"," ",g+1,"/",m.length]}),r.jsx("span",{className:"h4 chart-attachment-info text-neutrals-700",children:c?.chartInfo||"Chart Information"})]}),r.jsxs("div",{className:W("chart-area overflow-hidden flex flex-row gap-4 h-full ",a&&"max-h-[400px] min-h-[400px]",!a&&"min-h-[300px]"),children:[r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[w&&r.jsxs("div",{className:"mb-1 flex items-center gap-1",children:[r.jsx(zn,{className:"size-4 shrink-0 text-neutrals-1000"}),r.jsx("h4",{className:"text-neutrals-1000",children:w})]}),r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[r.jsx(nf,{option:C.config,style:{width:"100%",height:"100%",minHeight:0}}),C.limitedByRowsAmountTo&&r.jsx(ef,{limitAmount:C.limitedByRowsAmountTo,openAdvancedView:s,prefixIcon:i,contentClassName:o}),m.length>1&&r.jsx(Qu,{icons:t,currentIndex:g,totalCount:m.length,onNext:E,onPrev:A})]})]}),r.jsx(Ii,{dimensionsInfo:C.dimensions})]})]})})})},af=({attachment:e,className:t})=>{const{data:n,language:s}=e,a=(i,o)=>{i.addCommand(o.KeyCode.F1,()=>{})};return r.jsx("div",{className:nt(["h-full w-full [&_.cursors-layer]:hidden",t]),children:r.jsx(ko.Editor,{value:n,language:s,theme:"vs-light",onMount:a,options:{readOnly:!0,contextmenu:!1,scrollBeyondLastLine:!1,minimap:{enabled:!1},wordWrap:"on",automaticLayout:!0,tabSize:2}})})},rf="Dataset",Na="dataset_name",of="Agency",ka="agency",lf="Country dimensions",Vt="country_aggregated",cf="Indicator dimensions",Ht="indicator_aggregated",df="Frequency",hn="frequency_aggregated",no=".";function ja(e){return{columnState:e.getColumnState(),columnGroupState:e.getColumnGroupState()??[]}}function uf(e,t){t&&(e.applyColumnState({state:t.columnState,applyOrder:!0}),e.setColumnGroupState(t.columnGroupState))}const Ia=["columnVisible","columnMoved","displayedColumnsChanged","newColumnsLoaded","gridColumnsChanged","columnPinned"];function so(e,t){u.useEffect(()=>{if(e){for(const n of Ia)e.addEventListener(n,t);return()=>{for(const n of Ia)e.removeEventListener(n,t)}}},[e,t])}function ff({currentUrn:e}){const[t,n]=u.useState(),[s,a]=u.useState(null),i=u.useRef(new Map),o=u.useRef(new Map),c=u.useCallback(h=>{if(n(h),i.current.has(e))s==null&&a(i.current.get(e)??null);else{const p=ja(h);i.current.set(e,p),a(p)}const m=o.current.get(e);m&&(h.applyColumnState({state:m.columnState,applyOrder:!0}),m.columnGroupState!=null&&h.setColumnGroupState(m.columnGroupState))},[e]);u.useEffect(()=>{a(i.current.get(e)??null)},[e]);const l=u.useCallback(()=>{t&&o.current.set(e,ja(t))},[e,t]),f=u.useCallback(()=>{o.current.delete(e)},[e]),d=u.useCallback(()=>{i.current.delete(e),a(null)},[e]);return so(t,l),{gridApi:t,onGridApiReady:c,initialColumnsState:s,clearUserColumnState:f,clearInitialColumnState:d}}var Qe=(e=>(e.Compact="compact",e.Extended="extended",e))(Qe||{});const es=u.createContext(null);function mf({currentUrn:e,structuresMap:t,locale:n,dataQueries:s,gridViewMode:a=Qe.Compact,onGridViewModeChange:i,texts:o,resetIcon:c,children:l}){const{gridApi:f,onGridApiReady:d,initialColumnsState:h,clearUserColumnState:m,clearInitialColumnState:p}=ff({currentUrn:e}),g=u.useCallback(T=>i?.(T),[i]),[b,C]=u.useState(new Map),x=u.useCallback((T,N,D)=>{C(R=>{const E=new Map(R),A=new Map(E.get(T)??[]),j=A.get(N)??{order:[],hidden:new Set};return A.set(N,D(j)),E.set(T,A),E}),f?.refreshCells({columns:[N]})},[f]),w=u.useCallback((T,N,D)=>{x(T,N,R=>({...R,order:D}))},[x]),v=u.useCallback(()=>{C(new Map)},[]),S=u.useCallback((T,N,D,R)=>{x(T,N,E=>{const A=new Set(E.hidden);return R?A.add(D):A.delete(D),{...E,hidden:A}})},[x]),k=u.useMemo(()=>({gridApi:f,onGridApiReady:d,initialColumnsState:h,structuresMap:t,locale:n,dataQueries:s,dimensionCustomization:b,setDimensionKeyOrder:w,setDimensionKeyHidden:S,resetDimensionCustomization:v,clearUserColumnState:m,clearInitialColumnState:p,gridViewMode:a,setGridViewMode:g,texts:o,resetIcon:c}),[f,h,d,t,n,s,b,w,S,v,m,p,a,g,o,c]);return r.jsx(es.Provider,{value:k,children:l})}function ts(){const e=u.useContext(es);if(!e)throw new Error("useTableSettingsContext must be used within TableSettingsProvider");return e}const hf=()=>u.useContext(es);function pn(e,t,n){const s=y.getConcept(e.conceptIdentity,t),a=e?.localRepresentation?.enumeration,i=s?.coreRepresentation?.enumeration,o=a||i,c=y.getArtifactByUrnWithWildCard(o,n);return{concept:s,codeList:c||void 0}}function ao(e,t,n){const s=e.findIndex(a=>a.id===t);return n.originalData.parsedTimeSeriesValue[s]}function ns(e,t,n,s,a){const i=ao(e,t,s),o=n?.codes?.find(c=>c.id===i);return y.getLocalizedName(o,a)}function pf(e,t,n,s,a=Qe.Compact){const i=a===Qe.Extended?vf(e,t,n):[Cf(e,t,n,s)];return[gf(e,t,n,s),...i,wf(e,t,n,s),...xf(e,t,n)]}function gf(e,t,n,s){const a=i=>{const{structures:o,urn:c,data:l}=Ut(i,e),f=t.get(c)?.region;return l==null||c==null||o==null||f==null?"":bt(o,f,l,n)};return gn(s?.countryDimensions||lf,Vt,a,e,t,n,s)}function Cf(e,t,n,s){const a=i=>{const{structures:o,urn:c,data:l}=Ut(i,e),f=t.get(c)?.indicators;return l==null||c==null||o==null||f==null||f.length===0?"":f.map(h=>bt(o,h,l,n)||"").join(no)};return gn(s?.indicatorDimensions||cf,Ht,a,e,t,n,s)}function wf(e,t,n,s){const a=i=>{const{structures:o,urn:c,data:l}=Ut(i,e),f=t.get(c)?.frequency;return l==null||c==null||o==null||f==null?"":bt(o,f,l,n)};return gn(s?.frequency||df,hn,a,e,t,n,s)}function xf(e,t,n){const s=new Set;return t.forEach(a=>{a?.other?.forEach(i=>{s.add(i)})}),Array.from(s).map(a=>bf(a,e,t,n))}function vf(e,t,n){const s=new Set;return t.forEach(a=>{a?.indicators?.forEach(i=>{s.add(i)})}),Array.from(s).map(a=>{const i=o=>{const{structures:c,urn:l,data:f}=Ut(o,e),d=t.get(l)?.indicators??[];return f==null||l==null||c==null||!d.includes(a)?"":bt(c,a,f,n)};return{headerName:ro(a,e,n),field:a,colId:a,valueGetter:i,...gt,cellClass:mt,tooltipValueGetter:o=>o.value}})}function bf(e,t,n,s){const a=i=>{const{structures:o,urn:c,data:l}=Ut(i,t),f=n.get(c)?.other??[];return l==null||c==null||o==null||!f.includes(e)?"":bt(o,e,l,s)};return{...gn(ro(e,t,s),e,a,t,n,s),hide:!0}}function ro(e,t,n){for(const s of t.values()){if(!s)continue;const i=(y.getDimensions(s)?.dimensions||[]).find(o=>o.id===e);if(i)return y.getDimensionTitle(s.conceptSchemes,i,n)??e}return e}function gn(e,t,n,s,a,i,o){return{headerName:e,field:t,colId:t,valueGetter:n,...gt,cellClass:mt,cellRenderer:Pi,tooltipValueGetter:c=>c.value,cellRendererParams:{structuresMap:s,datasetDimensionsSchemesMap:a,locale:i,titles:o,colId:t}}}function Ut(e,t){const{data:n}=e,s=n?.dataset?.urn,a=s==null?void 0:t.get(s);return{data:n,urn:s,structures:a}}function bt(e,t,n,s){const a=e.conceptSchemes||[],i=e.codelists||[],o=y.getDimensions(e)?.dimensions||[],c=o.find(f=>f.id===t);if(c==null)return;const{codeList:l}=pn(c,a,i);return ns(o,t,l,n,s)}const an="::";function Sf(e,t){return`${e}${an}${t}`}function La(e){return e.includes(an)}function Tn(e){const t=e.indexOf(an);return{urn:e.slice(0,t),dimensionKey:e.slice(t+an.length)}}const yf=new Set([Ht]);function io(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 Df(e,t,n){const s=n(t);return s?e===Ht?s.indicators:e===Vt?s.region?[s.region]:[]:e===hn?s.frequency?[s.frequency]:[]:[]:[]}function Mf(e,t,n){const s=e.getDimensionConfig(t,n);if(s?.alias)return s.alias;const a=e.structuresMap.get(t),o=(a?y.getDimensions(a)?.dimensions??[]:[]).find(c=>c.id===n);return y.getDimensionTitle(a?.conceptSchemes??[],o,e.locale)??n}function Tf(e){const t=e.enrichedColIds??yf;return n=>{if(!t.has(n.id))return n;const s=[];for(const{urn:a}of e.dataQueries){const i=Df(n.id,a,e.getDimensionsScheme);if(!i.length)continue;const o=e.dimensionCustomization?.get(a)?.get(n.id),c=o?.order.length?io(i,{order:o.order,hidden:new Set}):i,l=c.length>1,f=c.map(m=>({id:Sf(a,m),type:"item",label:Mf(e,a,m),isChecked:!o?.hidden.has(m),draggable:l,checkable:l})),d=e.structuresMap.get(a),h=y.getLocalizedName(d?.dataflows?.[0],e.locale)??a;s.push({id:a,type:"group",label:h,items:f})}return s.length?{...n,items:s}:n}}function Pa(e,t){return e===Ht?t.indicators??[]:e===Vt?t.region?[t.region]:[]:e===hn?t.frequency?[t.frequency]:[]:t.other?.includes(e)?[e]:[]}function Ef(e,t){return e===Ht?t?.indicatorMetadataPanel||"Indicator dimension details":e===Vt?t?.countryMetadataPanel||"Country dimension details":t?.metadata||"Metadata"}const Af="merged-dimension-metadata-side-panel",Nf=e=>{const{titles:t}=ye(),{isOpenedAdvancedView:n}=Ge(),s=ht(),{isMetadataInSidePanel:a}=Ue(),i=hf(),o=e?.data?.dataset?.urn,c=mn(e?.context,o),l=o!=null?e.structuresMap.get(o):void 0,f=o!=null?e.datasetDimensionsSchemesMap.get(o):void 0,d=i?.dimensionCustomization,h=u.useMemo(()=>{if(!l||!f||o==null)return e.valueFormatted??e.value;const C=d?.get(o)?.get(e.colId);return io(Pa(e.colId,f),C).map(v=>bt(l,v,e.data,e.locale)).filter(Boolean).join(no)},[d,l,f,o,e.valueFormatted,e.value,e.colId,e.data,e.locale]),m=u.useMemo(()=>{if(!l||!f)return[];const C=Pa(e.colId,f),x=y.getStructureComponentsMap(l),w=C.filter(v=>e.data[v]!=null).map(v=>({name:v,value:String(e.data[v])}));return It(w,x,e.locale)},[l,f,e.colId,e.data,e.locale]),p=u.useMemo(()=>{const C=l?.dataflows?.[0];if(!C)return;const x=_t(y.getLastUpdatedTime(C),e.locale);return Ot(C,x,e.locale,t)},[l,e.locale,t]),g=a&&!!s&&!!e.value&&![hn,Vt].includes(e.colId),b=u.useCallback(()=>{s&&s.openPanel({id:Af,scope:n?"advanced":"conversation",title:Ef(e.colId,t),bodyClassName:"overflow-hidden",content:r.jsx(Rt,{locale:e.locale,metadata:m,datasetInfo:p,externalLink:c})})},[s,n,e.colId,t,e.locale,m,p,c]);return r.jsxs("div",{className:"relative size-full p-2",children:[h,g&&r.jsx("div",{className:"metadata-indicator",title:t?.metadata||"View details",onClick:b})]})},kf="dataset-detail-metadata-side-panel",jf=e=>{const{titles:t}=ye(),{isOpenedAdvancedView:n}=Ge(),s=ht(),{isMetadataInSidePanel:a}=Ue(),i=e?.data?.dataset?.urn,o=mn(e?.context,i),c=i!=null?e.structuresMap.get(i):void 0,l=i!=null?e.attributesDataMap?.get(i):void 0,f=u.useMemo(()=>{const p=c?.dataflows?.[0];if(!p)return;const g=_t(y.getLastUpdatedTime(p),e.locale);return Ot(p,g,e.locale,t)},[c,e.locale,t]),d=u.useMemo(()=>Wi(zi(l),y.getStructureComponentsMap(c),e.locale),[l,c,e.locale]),h=a&&!!s&&!!e.value,m=u.useCallback(()=>{s&&s.openPanel({id:kf,scope:n?"advanced":"conversation",title:t?.datasetMetadataPanel||"Dataset Metadata",bodyClassName:"overflow-hidden",content:r.jsx(Rt,{locale:e.locale,metadata:d,datasetInfo:f,externalLink:o})})},[s,n,d,f,o,t,e.locale]);return r.jsxs("div",{className:"relative size-full p-2",children:[e.valueFormatted??e.value,h&&r.jsx("div",{className:"metadata-indicator",title:t?.metadata||"View details",onClick:m})]})},If=({attachment:e,isDataLoading:t,isChartColumnVisible:n,fixHeight:s,externalLink:a,externalLinksMap:i,showLimitMessage:o,onApiReady:c})=>{const[l,f]=u.useState(!1),[d,h]=u.useState([]),[m,p]=u.useState(),[g,b]=u.useState(400),C=u.useRef(null),x=u.useRef([]);u.useEffect(()=>{if(e.gridContent==null)f(!0);else{const T=e.gridContent.columns.map(N=>N.colId===jt?{...N,hide:!n}:N);h(e.gridContent.data),p(T),f(!1)}},[e.gridContent,n]),u.useEffect(()=>{d?(b(qn(d.length)),o?.(d.length>=M.SERIES_LIMIT)):o?.(!1)},[d,o]),u.useEffect(()=>{if(!m||!C.current)return;const T=m.map(E=>E.colId??E.field??"").filter(Boolean),N=x.current,D=new Set(N),R=T.length!==N.length||T.some(E=>!D.has(E));x.current=T,R&&C.current.resetColumnState()},[m]);const w=u.useCallback(T=>{C.current=T.api,c?.(T.api)},[c]),v=u.useMemo(()=>({externalLink:a,externalLinksMap:i}),[a,i]),S=u.useMemo(()=>({[fn]:Qi,[un]:eo,[Pi]:Nf,[Li]:Yn,[Ri]:jf}),[]),k=u.useMemo(()=>r.jsx(_n.AgGridReact,{headerHeight:Pt,rowHeight:dn,rowData:d,enableCellTextSelection:!0,columnDefs:m,context:v,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",components:S,valueCache:!0,onGridReady:w}),[d,m,v,S,w]);return l||t?r.jsx(M.Loader,{}):r.jsx("div",{className:"size-full",children:r.jsx(to,{fixHeight:s,gridHeight:g,children:k})})},Lf=({selectedAttachment:e,actions:t,attachmentsStyles:n,isDataLoading:s,externalLink:a,externalLinksMap:i,isOpenedAdvancedView:o,onOpenAdvancedView:c,showLimitMessage:l,onGridApiReady:f})=>r.jsxs("div",{className:"flex min-h-0 w-full flex-1 justify-center",children:[Oc(e)&&r.jsx(Cd,{actions:t,downloadTitles:n?.downloadTitle,attachment:e}),Jn(e)&&r.jsx(Fd,{actions:t,attachment:e,showLimitMessage:l}),lt(e)&&r.jsx(Yu,{attachment:e,isDataLoading:s,isChartColumnVisible:o,fixHeight:!o,showLimitMessage:l,onApiReady:f,externalLink:a}),ft(e)&&r.jsx(If,{attachment:e,isDataLoading:s,isChartColumnVisible:o,fixHeight:!o,showLimitMessage:l,onApiReady:f,externalLink:a,externalLinksMap:i}),qt(e)&&r.jsx(sf,{isDataLoading:s,attachment:e,icons:n?.chartingIcons,openAdvancedView:o?void 0:c,fixHeight:!o,limitationInfoPrefixIcon:n?.limitationInfoIcon,limitationInfoContentClassName:n?.limitationInfoContentClassName}),$n(e)&&r.jsx(Md,{attachment:e,openLinkTitle:n?.openLinkTitle}),Di(e)&&r.jsx(bd,{attachment:e}),Kn(e)&&r.jsx(af,{attachment:e,className:n?.codeAttachmentContainerClassName})]}),Pf=({isOpen:e,alertDetails:t,attachmentsStyles:n,onClose:s})=>{if(!e)return null;const a=t?.progress&&t.progress.total>0?`${Math.min(100,Math.max(0,t.progress.current/t.progress.total*100))}%`:"0%";return r.jsx(M.Alert,{alertDetails:t,infoIcon:n?.infoDownloadIcon,successIcon:n?.successDownloadIcon,errorIcon:n?.errorDownloadIcon,onClose:s,closeButtonTitle:n?.closeTitle||"Close",children:r.jsxs(r.Fragment,{children:[t?.text&&r.jsx("div",{className:"alert-text whitespace-pre-line break-words",title:t.text,children:t.text}),t?.progress&&r.jsx("div",{className:"alert-progress",children:r.jsx("div",{className:"alert-progress-value",style:{width:a}})}),t?.action&&r.jsxs("button",{type:"button",className:"alert-action",disabled:t.action.disabled,onClick:t.action.onClick,title:t.action.title,children:[t.action.icon&&r.jsx("span",{className:"alert-action-icon",children:t.action.icon}),r.jsx("span",{className:"alert-action-text",children:t.action.text})]})]})})},Rf=({attachmentsStyles:e,onCancel:t,onRetry:n})=>{const s=u.useCallback(p=>e?.downloadTitles?.downloadStartedText?.(p.dataFormatTitle)??`Preparing ${p.dataFormatTitle} file.`,[e?.downloadTitles]),a=u.useCallback((p,g)=>e?.downloadTitles?.downloadInProgressTitle?.(p,g)??`Downloading file ${p} of ${g}`,[e?.downloadTitles]),i=u.useCallback((p,g)=>e?.downloadTitles?.downloadInProgressText?.(p,g)??`${p} · ${g}`,[e?.downloadTitles]),o=u.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=u.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=u.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]),f=u.useCallback(p=>({type:M.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]),d=u.useCallback((p,g,b,C)=>({type:M.AlertType.IN_PROGRESS,title:a(g,p.items.length),text:i(C,p.dataFormatTitle),progress:{current:b,total:p.items.length},action:{text:e?.downloadTitles?.downloadCancelActionText??e?.downloadTitles?.cancel??"Cancel",icon:e?.downloadInProgressActionIcon,onClick:t}}),[e?.downloadInProgressActionIcon,e?.downloadTitles,i,a,t]),h=u.useCallback(p=>({type:M.AlertType.SUCCESS,title:o(p),text:c(p)}),[c,o]),m=u.useCallback(p=>({type:M.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:f,getInProgressAlertDetails:d,getSuccessAlertDetails:h,getErrorAlertDetails:m}},Ff=300,Of=({attachmentsStyles:e,downloadDataSet:t})=>{const[n,s]=u.useState(),[a,i]=u.useState(!1),[o,c]=u.useState(),l=u.useRef(null),f=u.useRef(null),d=u.useRef(null),h=u.useRef(!1),m=u.useRef(!1),p=u.useCallback(D=>{c(D),s(!0)},[]),g=u.useCallback(()=>{s(!1)},[]),b=u.useCallback(()=>{m.current=!0,l.current?.abort(),g()},[g]),C=u.useCallback(()=>{const D=f.current;!D||!d.current||d.current(D)},[]),x=u.useCallback(D=>(D instanceof DOMException||D instanceof Error)&&D.name==="AbortError",[]),{getStartedAlertDetails:w,getInProgressAlertDetails:v,getSuccessAlertDetails:S,getErrorAlertDetails:k}=Rf({attachmentsStyles:e,onCancel:b,onRetry:C}),T=u.useCallback(async D=>{if(!h.current){h.current=!0,i(!0),m.current=!1,f.current=null;try{const R=[],E=D.items.length>1;E||p(w(D));for(const[A,j]of D.items.entries()){if(m.current)return;E&&p(v(D,A+1,A,j.name));const O=new AbortController;l.current=O;try{await t(j.urn,D.dataFormat,D.language,D.attribute,j.filters,j.fileName,D.isMetadata,O.signal)}catch(L){if(x(L)&&m.current)return;R.push(j),console.error("Failed to download dataset",L)}finally{l.current===O&&(l.current=null)}A<D.items.length-1&&await new Promise(L=>window.setTimeout(L,Ff))}if(m.current)return;if(R.length>0){const A={...D,items:R};f.current=A,p(k(A));return}p(S(D))}finally{l.current=null,h.current=!1,i(!1)}}},[t,k,v,w,S,x,p]);return u.useEffect(()=>{d.current=T},[T]),u.useEffect(()=>()=>{m.current=!0,l.current?.abort()},[]),{startDownload:u.useCallback(D=>h.current?!1:(T(D),!0),[T]),isDownloadRunning:a,downloadAlertProps:{isOpen:n,alertDetails:o,attachmentsStyles:e,onClose:g}}};qs.ModuleRegistry.registerModules([qs.AllCommunityModule]);const oo=({attachments:e,actions:t,isSystemAttachments:n,isShowAttachments:s,showAdvancedView:a,currentDataQuery:i,dataQueries:o,attachmentInfoList:c,datasets:l,initialSelectedDatasetUrn:f,isDataLoading:d,isDataSetAttachments:h,locale:m,dimensions:p,filters:g,selectDataset:b,onAdvancedViewOpen:C,isTableSettingsOpen:x,onTableSettingsOpen:w,onTableSettingsClose:v,onGridApiReady:S})=>{const{titles:k,messageStyles:T,attachmentsStyles:N,limitMessages:D,attachmentsConfig:R}=ye(),[E,A]=u.useState(0),[j,O]=u.useState(null),{isOpenedAdvancedView:L,setIsOpenedAdvancedView:$}=Ge(),[J,q]=u.useState(M.PopUpState.Closed),[H,K]=u.useState(!1),[z,ne]=u.useState(!1),se=y.DownloadType.DATA_IN_TABLE,fe=B=>{A(B)},xe=u.useCallback(()=>{C?.(),$(!0),t.updateCurrentDataQuery(i||o?.[0]),t.updateDataQueries(o),t.updateDatasets(l)},[t,i,o,l,$,C]);u.useEffect(()=>{O(e[E]||null)},[e,E]),u.useEffect(()=>{K(h&&(l==null||l?.length==0))},[l,h]),u.useEffect(()=>{x&&j&&!lt(j)&&!ft(j)&&v?.()},[x,j,v]);const me=u.useCallback(()=>{q(M.PopUpState.Closed)},[q]),_=R?.isExternaLinkIncludeFilters,Y=Pn(_,g,i||o?.[0],p),le=u.useMemo(()=>o?.length?new Map(o.map(oe=>[oe.urn,Pn(_,void 0,oe)])):void 0,[o,_]),de=u.useMemo(()=>{if(!j||!ft(j))return;const oe=j.gridContent?.data??[],re=new Map,ge=new Map;for(const he of oe){const{dataset:ce,datasetTitle:Me}=he,Ne=ce?.urn;Ne&&(re.set(Ne,(re.get(Ne)??0)+1),!ge.has(Ne)&&Me&&ge.set(Ne,Me))}return Array.from(re.entries()).map(([he,ce])=>({urn:he,name:ge.get(he)??he,rowCount:ce,dataQuery:o?.find(Me=>Me.urn===he)}))},[j,o]),ue=u.useMemo(()=>{if(j){if(lt(j))return j.grid_data?.data?.length;if(ft(j))return j.gridContent?.data?.length}},[j]),{startDownload:ae,isDownloadRunning:ee,downloadAlertProps:U}=Of({attachmentsStyles:N,downloadDataSet:t.downloadDataSet});return!e||e.length===0?null:r.jsx(r.Fragment,{children:L&&!s?r.jsx(qc,{icon:T?.advanceViewIcon,title:T?.openAdvanceViewTitle??"Opened in Advanced view"}):r.jsxs("div",{className:W("space-y-3 max-w-full max-h-full h-full",!L&&!n?"pt-5":"pt-0","flex flex-col pb-1"),children:[!L&&H?r.jsx(M.Loader,{}):r.jsxs(r.Fragment,{children:[n&&!L&&r.jsx(Yc,{titles:{queryUpdatedManuallyTitle:k?.queryUpdatedManually,setToTitle:k?.setTo,datasetLabel:k?.dataset},datasetIcon:N?.datasetIcon,attachmentInfoList:c,dataQueries:o}),!L&&l?.length!=null&&l?.length>0&&r.jsx(Ni,{datasets:l,initialSelectedDatasetUrn:f,locale:m,selectDataset:b}),z&&r.jsx(M.RequestLimitMessage,{limitMessages:D,showAdvancedViewButton:!!j&&Vc(j)&&a,onAdvancedViewClick:xe,query:Y}),r.jsx("div",{className:W(!L&&l?.length&&"attachments-bordered","attachments-wrapper h-full min-h-0"),children:r.jsxs("div",{className:"flex h-full max-w-full flex-col items-center gap-4",children:[r.jsx(gd,{attachments:e,selectedAttachmentIndex:E,selectedAttachment:j,attachmentsStyles:N,externalLink:Y,isExternalLinkIncludeFilters:_,limitMessages:D,onSelectedAttachmentChange:fe,onDownloadClick:()=>q(M.PopUpState.Opened),showAdvancedView:a,onOpenAdvancedView:xe,isTableSettingsOpen:x,onTableSettingsOpen:w}),j!=null&&r.jsx(Lf,{selectedAttachment:j,actions:t,attachmentsStyles:N,isDataLoading:d,isOpenedAdvancedView:L,onOpenAdvancedView:xe,showLimitMessage:ne,onGridApiReady:S,externalLink:Y,externalLinksMap:le})]})})]}),r.jsxs(r.Fragment,{children:[J===M.PopUpState.Opened&&r.jsx(sd,{onCloseModal:me,onDownloadStart:ae,isDownloadInProgress:ee,dataQuery:i,datasetName:j?.title||"",locale:m,type:se,dimensions:p,filters:g,urn:i?.urn,titles:N?.downloadTitles,rowCount:ue,collapsible:N?.downloadCollapsible,downloadDatasets:de,limitMessages:D,showLimitMessage:z,externalLink:Y}),r.jsx(Pf,{...U})]})]})})},_f=({label:e,colDef:t})=>!!e.trim()&&!t.suppressColumnsToolPanel;function Vf(e){return e.colId??e.field??null}function Hf(e){return String(e.headerName??e.field??e.colId??"").trim()}function Uf(e){return new Map(e.getColumnState().map(t=>[t.colId,t]))}function Bf(e,t){const n=e.getColumnDefs()??[],s=Uf(e),a=[];for(const c of n){const l=Vf(c);if(!l)continue;const f=Hf(c);if(!t({colId:l,label:f,colDef:c}))continue;const d=s.get(l);a.push({id:l,type:"item",label:f,isChecked:!(d?.hide??!1),draggable:!0,checkable:!0})}const i=e.getColumnState().map(c=>c.colId),o=new Map(i.map((c,l)=>[c,l]));return a.sort((c,l)=>{const f=o.get(c.id)??Number.MAX_SAFE_INTEGER,d=o.get(l.id)??Number.MAX_SAFE_INTEGER;return f-d})}function Gf(e,t,n){const s=[...t];return e.map(a=>n.has(a)?s.shift()??a:a)}function En(e,t){let n=e,s;for(const a of t){if(s=n.find(i=>i.id===a),!s)return;n=s.type==="group"?s.items:s.items??[]}return s?.type==="item"?s:void 0}function zf(e){if(!e.items?.length)return e;const t=e.items.map(n=>{if(n.type!=="group")return n;const a=n.items.filter(o=>o.type==="item").filter(o=>o.isChecked!==!1);if(a.length!==1)return n;const[i]=a;return{...n,items:n.items.map(o=>o.type!=="item"?o:o===i?{...o,checkable:!1,draggable:!1}:{...o,draggable:!1})}});return t.every((n,s)=>n===e.items[s])?e:{...e,items:t}}function Fn(e,t){const n=[];for(const s of e){if(s.type==="group"){n.push(...Fn(s.items,t));continue}if(t?.(s)){n.push(s.id);continue}if(s.items?.length){n.push(...Fn(s.items,t));continue}n.push(s.id)}return n}function Wf({api:e,searchQuery:t,includeColumn:n=_f,enrichItem:s,onSubItemOrderChange:a,onSubItemVisibilityChange:i}){const[o,c]=u.useState(0),[l,f]=u.useState(new Set),d=u.useCallback(()=>{c(v=>v+1)},[]);so(e,d);const h=u.useMemo(()=>!e||!e.getColumnState()?[]:Bf(e,n),[e,n,o]),m=u.useMemo(()=>(s?h.map(S=>S.type==="item"?s(S):S):h).map(S=>S.type==="item"&&S.items?.length?{...S,isExpanded:l.has(S.id)}:S),[h,s,l]),p=u.useMemo(()=>new Set(h.map(v=>v.id)),[h]),g=u.useMemo(()=>M.filterDraggableListNodes(m,t),[m,t]),b=u.useCallback(v=>{if(!e)return;if(La(v.itemId)&&i){const{urn:k,dimensionKey:T}=Tn(v.itemId),N=v.path[0];i(k,N,T,!v.nextChecked);return}const S=En(m,v.path);!S||!p.has(S.id)||(e.applyColumnState({state:[{colId:S.id,hide:!v.nextChecked}]}),d())},[e,m,p,d,i]),C=u.useCallback(v=>{if(!e)return;if(La(v.itemId)&&i){const{urn:N,dimensionKey:D}=Tn(v.itemId),R=v.path[0],E=En(m,v.path);E?.type==="item"&&i(N,R,D,E.isChecked??!0);return}const S=En(m,v.path);if(!S||!p.has(S.id))return;const T=!(e.getColumnState().find(N=>N.colId===S.id)?.hide??!1);e.applyColumnState({state:[{colId:S.id,hide:T}]}),d()},[e,m,p,d,i]),x=u.useCallback(v=>{const S=v.path[v.path.length-1];f(k=>{const T=new Set(k);return v.nextExpanded?T.add(S):T.delete(S),T})},[]),w=u.useCallback(v=>{if(!e)return;const S=e.getColumnState().map(D=>D.colId),k=new Set(h.map(D=>D.id)),T=Fn(v,D=>p.has(D.id)),N=Gf(S,T,k);if(e.applyColumnState({state:N.map(D=>({colId:D})),applyOrder:!0}),d(),a){for(const D of v)if(!(D.type!=="item"||!p.has(D.id)||!D.items))for(const R of D.items){if(R.type!=="group")continue;const E=R.items.filter(O=>O.type==="item");if(E.length<=1)continue;const A=R.id,j=E.map(O=>Tn(O.id).dimensionKey);a(A,D.id,j)}}},[e,h,p,d,a]);return{items:m,visibleItems:g,handleToggleChecked:b,handleToggleExpanded:x,handleItemClick:C,handleItemsChange:w}}function $f({api:e,includeColumn:t,enrichItem:n,renderLabel:s,onSubItemOrderChange:a,onSubItemVisibilityChange:i,searchPlaceholder:o}){const[c,l]=u.useState(""),f=u.useCallback(w=>{l(w)},[l]),d=u.useCallback(()=>l(""),[l]),h=u.useMemo(()=>r.jsx("button",{type:"button",onClick:d,children:r.jsx(Ve.IconX,{className:"size-4 text-neutrals-1000"})}),[d]),m=u.useCallback(w=>{const v=n?n(w):w;return zf(v)},[n]),{visibleItems:p,handleItemsChange:g,handleToggleChecked:b,handleToggleExpanded:C,handleItemClick:x}=Wf({api:e,includeColumn:t,searchQuery:c,enrichItem:m,onSubItemOrderChange:a,onSubItemVisibilityChange:i});return r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 px-5",children:[r.jsx(M.InputWithIcon,{inputId:"columns-search-input",containerClasses:"items-center filters-search-input gap-1 !p-2",cssClass:"filters-search-input-text",placeholder:o||"Search",iconBeforeInput:r.jsx(Ve.IconSearch,{className:"size-4 text-neutrals-1000"}),iconAfterInput:c?h:void 0,value:c,onChange:f}),r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:r.jsx(M.DraggableList,{items:p,onItemsChange:g,onToggleChecked:b,onToggleExpanded:C,onItemClick:x,renderLabel:s})})]})}const Jf={},Kf={map:Jf,getDimensionsMetadata:()=>{},getDimensionMetadata:()=>{},getRegionDimension:()=>{},getFrequencyDimension:()=>{},getIndicatorDimensions:()=>[],getDimensionsScheme:()=>{}},ss=u.createContext(Kf);function Yf({map:e,children:t}){const n=u.useMemo(()=>{const s={},a={},i={},o=Object.keys(e);for(const c of o){s[c]={},a[c]={};const l=Object.keys(e[c]);for(const f of l){const d=e[c][f];d.subtype&&(s[c][d.subtype]=f),a[c][d.dimensionType]||(a[c][d.dimensionType]=[]),a[c][d.dimensionType].push(f)}i[c]={timePeriod:a[c]?.TIME_PERIOD?.[0]??void 0,frequency:s[c]?.FREQUENCY??void 0,region:s[c]?.REGION??void 0,indicators:a[c]?.INDICATOR??[],other:(a[c]?.NON_INDICATOR??[]).filter(f=>{const d=e[c][f];return d.subtype!=="FREQUENCY"&&d.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=>a[c]?.INDICATOR??[],getDimensionsScheme:c=>i[c]}},[e]);return r.jsx(ss.Provider,{value:n,children:t})}function Cn(){return u.useContext(ss)}function wn(){return u.useContext(ss)}function qf(){const{dataQueries:e,structuresMap:t,locale:n,gridViewMode:s}=ts(),a=wn(),i=u.useMemo(()=>{const o=new Map;if(!a||!e?.length)return o;for(const{urn:c}of e){const l=a.getDimensionsScheme(c),f=!!l?.other.length,d=s===Qe.Extended&&!!l?.indicators?.length;if(!f&&!d)continue;const h=n?y.getLocalizedName(t?.get(c)?.dataflows?.[0],n)??c:c,m=[...l?.other??[],...d?l?.indicators??[]:[]];for(const p of m){const g=o.get(p);g?g.push(h):o.set(p,[h])}}return o},[a,e,t,n,s]);return u.useMemo(()=>{if(!i.size)return;function o(c){const l=i.get(c.id);return l?.length?r.jsxs("span",{className:"flex w-full items-center gap-2 overflow-hidden",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",title:c.label,children:c.label}),r.jsx("span",{className:"h5 min-w-0 flex-1 truncate text-right text-neutrals-700",title:l.join(", "),children:l.join(", ")})]}):c.label}return o},[i])}var je=(e=>(e.Header="header",e.Cell="cell",e))(je||{}),Ee=(e=>(e.Focus="focus",e.Default="default",e))(Ee||{});const Zf="grid gap-1",Xf={gridTemplateColumns:"44px 23px 23px",gridTemplateRows:"repeat(4, 14px)"},Qf={gridTemplateColumns:"repeat(4, 21.5px)",gridTemplateRows:"repeat(4, 14px)"},em={[je.Header]:{[Ee.Focus]:"content-center rounded-sm border border-accent-300 bg-accent-300 text-center text-[8px] font-semibold",[Ee.Default]:"rounded-sm bg-semantic-warning border border-accent-300"},[je.Cell]:{[Ee.Focus]:"content-center rounded-sm border border-accent-300 bg-hues-100 pl-1 text-left text-[8px] font-semibold",[Ee.Default]:"rounded-sm bg-neutrals-100 border border-accent-300"}},lo=({rows:e,style:t})=>r.jsx("div",{className:Zf,style:t,children:e.map((n,s)=>r.jsx(u.Fragment,{children:n.map((a,i)=>r.jsx("span",{className:nt([em[a.role][a.emphasis],!a.label&&"text-transparent"]),children:a.label||" "},`${s}-${i}`))},s))}),tm=[[{role:je.Header,emphasis:Ee.Focus,label:"D1.D2.D3"},{role:je.Header,emphasis:Ee.Default},{role:je.Header,emphasis:Ee.Default}],[{role:je.Cell,emphasis:Ee.Focus,label:"C1.A"},{role:je.Cell,emphasis:Ee.Default},{role:je.Cell,emphasis:Ee.Default}],[{role:je.Cell,emphasis:Ee.Focus,label:"C1.B"},{role:je.Cell,emphasis:Ee.Default},{role:je.Cell,emphasis:Ee.Default}],[{role:je.Cell,emphasis:Ee.Focus,label:"C2.X"},{role:je.Cell,emphasis:Ee.Default},{role:je.Cell,emphasis:Ee.Default}]],nm=()=>r.jsx(lo,{rows:tm,style:Xf}),sm=[[{role:je.Header,emphasis:Ee.Focus,label:"D1"},{role:je.Header,emphasis:Ee.Focus,label:"D2"},{role:je.Header,emphasis:Ee.Focus,label:"D3"},{role:je.Header,emphasis:Ee.Default}],[{role:je.Cell,emphasis:Ee.Focus,label:"C1"},{role:je.Cell,emphasis:Ee.Focus,label:"A"},{role:je.Cell,emphasis:Ee.Focus},{role:je.Cell,emphasis:Ee.Default}],[{role:je.Cell,emphasis:Ee.Focus,label:"C1"},{role:je.Cell,emphasis:Ee.Focus,label:"B"},{role:je.Cell,emphasis:Ee.Focus},{role:je.Cell,emphasis:Ee.Default}],[{role:je.Cell,emphasis:Ee.Focus,label:"C2"},{role:je.Cell,emphasis:Ee.Focus},{role:je.Cell,emphasis:Ee.Focus,label:"X"},{role:je.Cell,emphasis:Ee.Default}]],am=()=>r.jsx(lo,{rows:sm,style:Qf}),Ra=({title:e,description:t,visual:n,mode:s,activeMode:a,onClick:i})=>r.jsxs("button",{type:"button",className:nt(["flex items-center gap-3 rounded border p-1",s===a&&"border-primary"]),onClick:()=>i(s),children:[r.jsx("div",{className:"rounded-[5px] bg-neutrals-100 px-2 py-1",children:n}),r.jsxs("div",{className:"flex flex-col gap-1 text-left",children:[r.jsx("span",{className:"h4 text-neutrals-1000",children:e}),r.jsx("span",{className:"caption text-neutrals-800",children:t})]})]}),rm=({gridViewMode:e,onModeChange:t,compactViewTitle:n,compactViewDescription:s,extendedViewTitle:a,extendedViewDescription:i})=>r.jsxs("div",{className:"mx-5 my-3 flex flex-col gap-2",children:[r.jsx(Ra,{title:n||"Compact view",description:s??r.jsxs(r.Fragment,{children:["Related dimensions ",r.jsx("strong",{children:"combined into a single column."})]}),visual:r.jsx(nm,{}),mode:Qe.Compact,activeMode:e,onClick:t}),r.jsx(Ra,{title:a||"Extended view",description:i??r.jsxs(r.Fragment,{children:["Each dimension displayed in ",r.jsx("strong",{children:"separate column."})]}),visual:r.jsx(am,{}),mode:Qe.Extended,activeMode:e,onClick:t})]}),Fa="table-settings-side-panel",im=()=>{const{gridApi:e,initialColumnsState:t,structuresMap:n,locale:s,dataQueries:a,dimensionCustomization:i,setDimensionKeyOrder:o,setDimensionKeyHidden:c,resetDimensionCustomization:l,clearUserColumnState:f,clearInitialColumnState:d,gridViewMode:h,setGridViewMode:m,texts:p,resetIcon:g}=ts(),b=wn(),C=qf(),x=u.useCallback(S=>{f(),d(),l(),m(S)},[f,d,l,m]),w=u.useCallback(()=>{e&&(f(),t?uf(e,t):e.resetColumnState(),l())},[f,e,t,l]),v=u.useMemo(()=>{if(!(h!==Qe.Compact||!b||!n||!s||!a?.length))return Tf({dataQueries:a,structuresMap:n,getDimensionsScheme:b.getDimensionsScheme,getDimensionConfig:(S,k)=>b.map[S]?.[k],locale:s,dimensionCustomization:i})},[h,b,n,s,a,i]);return e?r.jsxs("div",{className:"flex h-full flex-col",children:[r.jsx(rm,{gridViewMode:h,onModeChange:x,compactViewTitle:p?.compactViewTitle,compactViewDescription:p?.compactViewDescription,extendedViewTitle:p?.extendedViewTitle,extendedViewDescription:p?.extendedViewDescription}),r.jsx("hr",{className:"border-neutrals-500"}),r.jsxs("div",{className:"mx-5 mb-4 mt-5 flex items-center justify-between",children:[r.jsx("h3",{className:"text-neutrals-1000",children:p?.columnsDisplayTitle||"Columns display"}),r.jsx("button",{type:"button",className:"text-neutrals-800",onClick:w,children:g??r.jsx(Ve.IconRotate,{className:"size-4 rotate-180"})})]}),r.jsx($f,{api:e,enrichItem:v,renderLabel:C,onSubItemOrderChange:o,onSubItemVisibilityChange:c,searchPlaceholder:p?.columnsSearchPlaceholder})]}):null},om=e=>{const{attachmentsStyles:t}=ye(),{onGridApiReady:n}=ts(),s=ht(),a=u.useCallback(()=>{s&&s.openPanel({id:Fa,scope:"advanced",title:t?.tableSettings||"Table settings",headerClassName:"border-b border-neutrals-500",content:r.jsx(im,{})})},[s,t?.tableSettings]);return r.jsx(oo,{...e,isTableSettingsOpen:s?.isPanelOpen(Fa)??!1,onTableSettingsOpen:s?a:void 0,onTableSettingsClose:s?.closePanel,onGridApiReady:n})},lm=({actions:e,structureDataMaps:t,buttonProps:n,modalProps:s,dataQueries:a,onMultipleDataFiltersChange:i,locale:o,timeRangeOptions:c,datasetIcon:l,conversationKey:f,conversation:d,setConversation:h,updateConversation:m,updateDataQueries:p,limitMessages:g,filterIconClassName:b})=>{const{titles:C}=ye(),x=wn(),[w,v]=u.useState(M.PopUpState.Closed),[S,k]=u.useState([]),[T,N]=u.useState([]),[D,R]=u.useState(),[E,A]=u.useState([]),[j,O]=u.useState(void 0),L=u.useRef(t?.constraintsMap),[$,J]=u.useState(),[q,H]=u.useState(),[K,z]=u.useState(),[ne,se]=u.useState(!1),fe=u.useRef(0),[xe,me]=u.useState(!1),[_,Y]=u.useState(new Set),le=u.useRef(d);u.useEffect(()=>{le.current=d},[d]);const de=u.useCallback(()=>{fe.current+=1,fe.current===1&&se(!0)},[]),ue=u.useCallback(()=>{fe.current=Math.max(fe.current-1,0),fe.current===0&&se(!1)},[]),ae=u.useMemo(()=>ic(a,t),[a,t]),ee=u.useCallback(F=>kc(F,t?.dimensionsMap,t?.structuresMap),[t?.dimensionsMap,t?.structuresMap]),U=u.useCallback(F=>ee(F).codelistUrn,[ee]),B=u.useCallback(F=>{const Q=F.filterType==="dataset"?F.datasetUrn:F.sourceDatasetUrns?.[0];return Q?L.current?.get(Q):void 0},[]),oe=u.useCallback(F=>ee(F).sourceArtefactUrn,[ee]),{hierarchyStateMap:re,rebuildHierarchyTree:ge,loadAvailableHierarchies:he,onSelectHierarchy:ce,onExpandHierarchyNode:Me}=Ei({getCodelistUrnForFilter:U,getConstraintsForFilter:B,getSourceArtefactUrn:oe,getAvailableHierarchies:e?.getAvailableHierarchies,getHierarchy:e?.getHierarchy}),Ne=F=>{const Q=F?S.map(I=>Pe(I,F)?F:I):S;z(!0),k(nn(Q)),H?.(!0),ie(F?.isTimeDimension?tn(Q,F):Q,k,H,F)};u.useEffect(()=>{w===M.PopUpState.Closed&&J(L.current)},[w]);const ie=u.useCallback((F,Q,I,P)=>{const V=Nt(F,L.current,!1,x.map),Z=fa(a,V,e,x.map,F);Z&&de();const G=ua(a,V,e,x.map,F);Promise.allSettled(G).then(De=>{const Te=ha(L.current||t?.constraintsMap,ma(De)),Je={...t,constraintsMap:Te};if(P){const{filtersMap:Ze,changed:et}=$c(V,Je,P,o,x.map);if(et){L.current=Te,I?.(!0),z(!0);const Bt=yt(Ze,Je,o,x.map);ie(Bt,Q,I,P);return}}const Re=yt(V,Je,o,x.map);if(L.current=Te,I?.(!1),Q(Re),P){const Ze=Re.find(et=>Pe(et,P));R(et=>et&&Ze&&Pe(et,P)?{...Ze,isSelectedFilter:!0}:et),ge(P,B(P))}}).catch(()=>{const De=L.current||t?.constraintsMap||new Map,Te=yt(V,{...t,constraintsMap:De},o,x.map);if(L.current=De,I?.(!1),Q(Te),P){const Je=Te.find(Re=>Pe(Re,P));R(Re=>Re&&Je&&Pe(Re,P)?{...Je,isSelectedFilter:!0}:Re)}}).finally(()=>{z(!1),Z&&ue()})},[e,a,x.map,ue,B,o,ge,de,t]);u.useEffect(()=>{if(!ae){H(!0);return}const F=Zr(t,o),Q=a?.map(P=>{if(!P.disabled)return P;const V=(F.get(P.urn)??[]).filter(Z=>Z.filterType==="dataset"&&Z.id&&!Z.isTimeDimension).map(Z=>({componentCode:Z.id,operator:te.QueryFilterType.IN,values:[]}));return{...P,filters:V}}),I=Xr(F,Q,t?.constraintsMap,x.map);H?.(!0),ie(I,N,H)},[a,x.map,ie,ae,o,t]),u.useEffect(()=>{T?.length&&A(ln(T))},[T]),u.useEffect(()=>{k(F=>tn(F,D))},[D]),u.useEffect(()=>{if(w===M.PopUpState.Opened){O(void 0);const F=T.find(Q=>!Q.isTimeDimension);R(F?{...F,isSelectedFilter:!0}:void 0),k(T),Y(new Set(a?.filter(Q=>Q.disabled).map(Q=>Q.urn)))}w===M.PopUpState.Closed&&R(void 0)},[T,a,w]),u.useEffect(()=>{if(!D||D.isTimeDimension)return;const F=ze(D);if(!F)return;re.get(F)||he(D)},[D,re,he]),u.useEffect(()=>{w===M.PopUpState.Opened&&T.forEach(F=>{if(F.isTimeDimension)return;const Q=ze(F);Q&&!re.has(Q)&&he(F)})},[w,T,re,he]);const Le=u.useCallback(async F=>{const Q=le.current,I=a?.map(G=>({...G,disabled:_.has(G.urn)})),P=I?.filter(G=>!G.disabled),V=ii(P,F),Z=Q?{...Q,messages:Ti(Q.messages,I,V)}:null;h?.(Z),p?.(I?.map(G=>({...G,filters:G.disabled?G.filters??[]:V.get(G.urn)??[]}))??[]),await m(decodeURI(f),{name:Z?.name,messages:Z?.messages||[]})},[f,a,_,h,m,p]),We=u.useCallback((F,Q)=>{k(I=>Dr(I,F,Q)),Pe(D,F)&&R(I=>I&&{...I,displayMode:Q})},[D]),Be=u.useCallback(F=>ri(F,a,t?.dimensionsMap),[a,t?.dimensionsMap]),_e=u.useCallback((F,Q)=>{const I=yt(F,Q,o,x.map);L.current=Q?.constraintsMap,R(P=>I?.find(V=>Pe(V,P))||P),k(I),z(!1)},[x.map,o]),He=u.useCallback((F,Q)=>{z(!0),k(nn(F));const I=Nt(F,L.current,!1,x.map),P=L.current||t?.constraintsMap||new Map,V=fa(Q,I,e,x.map,F);V&&de();const Z=ua(Q,I,e,x.map,F);Promise.allSettled(Z).then(G=>{const De=ha(P,ma(G));_e(I,{...t,constraintsMap:De})}).catch(()=>{_e(I,{...t,constraintsMap:P})}).finally(()=>{V&&ue()})},[e,x.map,ue,de,t,_e]),qe=u.useCallback(F=>{const Q=a?.find(P=>P?.urn===F?.datasetUrn),I=Er(S,F);He(I,F?.datasetUrn?Q?[Q]:[]:a)},[He,S,a]),$e=u.useCallback(()=>{Y(new Set)},[]),X=u.useCallback((F,Q)=>{Y(I=>{const P=new Set(I);return Q?P.delete(F):P.add(F),P})},[]),pe=u.useCallback(()=>{L.current=$,v(M.PopUpState.Closed),me(!0)},[$]),ve=u.useCallback(()=>{const F=Ar(S);He(F,a),Y(new Set)},[He,S,a]),Ce=u.useCallback(()=>{const F=a?.map(G=>({...G,disabled:_.has(G.urn)})),Q=Nt(S,L.current,!1,x.map,_),I=yt(Q,{...t,constraintsMap:L.current},o,x.map),P=Be(Q),V=Qr(S,a?.map(G=>G.urn)??[],a,x.map,Q),Z=(a?.map(G=>G.urn)??[]).filter(G=>!V.has(G));for(const G of Z){const De=Q.get(G);De&&Q.set(G,De.map(Te=>!Te.isTimeDimension&&Te.dimensionValues?.length&&!Te.dimensionValues.some(Je=>Je.isSelectedValue)?{...Te,isExcluded:!0}:Te))}i?.(P,L.current,F?.filter(G=>V.has(G.urn)||G.disabled),Q,I),N(I),v(M.PopUpState.Closed),me(!0),u.startTransition(()=>{Le(Q)})},[Be,S,t,o,x.map,i,a,_,Le]),be=F=>{O(F)};return r.jsxs("div",{className:"filters-container",children:[r.jsx(Si,{buttonProps:n,selectedFiltersCount:Un(E),isLoading:q,setModalState:v,isModalClosed:xe,warningIcon:g?.warningIcon,filterIconClassName:b}),r.jsx(r.Fragment,{children:w===M.PopUpState.Opened&&r.jsxs(M.Popup,{heading:C?.settings||"Settings",portalId:"filters",size:M.PopUpSize.LG,containerClassName:"advanced-view-filters-modal h-[80%]",dividers:s?.isShowDividers,onClose:pe,closeButtonTitle:C?.close||"Close",children:[r.jsx(gi,{locale:o,timeRangeOptions:c,filtersList:S,selectedFilter:D,isDisableValues:K,isValuesLoading:ne,modalProps:s,initialConstraintsMap:t?.constraintsMap,datasetIcon:l,structuresMap:t?.structuresMap,setSelectedFilter:R,onSelectDisplayMode:We,onDeleteFilter:qe,onClearAllFilters:ve,updateSelectedFilterValues:Ne,onTimePeriodChange:be,selectedTimeOption:j,hierarchyStateMap:re,onSelectHierarchy:ce,onExpandHierarchyNode:Me,dataQueries:a,disabledDatasetUrns:_,onToggleDataset:X,onClearAllDatasets:$e}),r.jsx(wi,{onApply:Ce,onClose:pe,onClearAllFilters:ve,modalProps:s,applyDisabled:q||K,limitMessages:g})]})})]})},cm=({filtersProps:e,actions:t,attachments:n,attachmentsDataQuery:s,dataQueries:a,dimensions:i,locale:o,isDataLoading:c,setIsFiltering:l,filters:f,onFiltersChange:d})=>{const{titles:h,limitMessages:m}=ye(),p={getConstraints:t.getConstraints,getAvailableHierarchies:e.actions?.getAvailableHierarchies,getHierarchy:e.actions?.getHierarchy},{isCrossDatasetModeOn:g}=Ue();return u.useEffect(()=>{c||l?.(!1)},[c,l]),r.jsx("div",{className:"h-full min-h-0 rounded bg-white",children:r.jsxs("div",{className:"flex h-full flex-col gap-4 overflow-x-hidden",children:[r.jsxs("div",{className:"data-details-header flex items-center justify-between",children:[r.jsx("h2",{children:h?.content??"Content"}),g?r.jsx(lm,{attachmentsDataQuery:s,dataQueries:a,updateDataQueries:t?.updateDataQueries,locale:o,actions:p,dimensions:i,...e,onFiltersChange:d,limitMessages:m}):r.jsx(Kc,{attachmentsDataQuery:s,dataQueries:a,updateDataQueries:t?.updateDataQueries,locale:o,actions:p,dimensions:i,...e,onFiltersChange:d,limitMessages:m})]}),r.jsx("div",{className:"advanced-view-attachments-container min-h-0 flex-1",children:r.jsx(om,{attachments:n,currentDataQuery:s,dataQueries:a,dimensions:i,actions:t,isShowAttachments:!0,isDataSetAttachments:!0,isDataLoading:c,locale:o,filters:f})})]})})},dm=({isShowAgency:e,isShowDatasetBadge:t,dataset:n,data:s,structures:a,metadataSettings:i,locale:o,getDatasetUpdatedTime:c,externalLink:l,datasetIcon:f,externalLinkIcon:d,metadataButtonClassName:h,metadataIconClassName:m,infoSegmentContainerClassName:p,infoSegmentHeaderClassName:g,nameAndMetadataContainerClassName:b})=>{const{titles:C}=ye(),x="dataset-metadata-side-panel",[w,v]=u.useState(""),[S,k]=u.useState(!1),T=u.useRef(null),[N,D]=u.useState(""),[R,E]=u.useState(""),[A,j]=u.useState(!1),{onboardingFileSchema:O,isShowOnboarding:L}=Ye(),{isOpenedAdvancedView:$}=Ge(),J=ht(),{isMetadataInSidePanel:q}=Ue(),[H,K]=u.useState(!1),z=u.useMemo(()=>i?.isMetadataDescription?$d(n,w,o,C):[],[n,w,o,i?.isMetadataDescription,C]),ne=u.useMemo(()=>[...i?.isMetadataDescription?[]:[Ft(n,o,C)],...Wi(zi(s),y.getStructureComponentsMap(a),o)],[s,n,o,i?.isMetadataDescription,a,C]),se=u.useMemo(()=>Ot(n,w,o,C),[n,w,o,C]),fe=u.useCallback(()=>{if(q&&J){J.openPanel({id:x,scope:$?"advanced":"conversation",title:"Dataset Metadata",bodyClassName:"overflow-hidden",content:r.jsx(Rt,{locale:o,metadata:ne,metadataDescription:z,datasetInfo:se,externalLink:l})}),K(!0);return}k(!0)},[z,ne,se,l,q,$,o,J]),xe=u.useCallback(()=>{k(!1),K(!0)},[]);u.useEffect(()=>{const Y=c&&c(ne)||_t(y.getLastUpdatedTime(n),o);v(Y)},[n,o,ne,c]),u.useEffect(()=>{if(L){const{title:_,description:Y}=ct(Oe.METADATA_PER_DATASET,C);D(_),E(Y)}},[C,L]),u.useEffect(()=>{L&&j(O?.lastDisplayedElement===Oe.METADATA_PER_DATASET)},[O?.lastDisplayedElement,L]);const me=(_,Y)=>r.jsxs("div",{className:nt("flex gap-1 text-neutrals-1000",p),children:[r.jsxs("span",{className:nt("text-neutral-800",g),children:[_,":"]}),r.jsx("span",{children:Y})]});return r.jsxs("div",{className:"dataset-info flex flex-col gap-3 bg-white",children:[t&&r.jsxs("div",{className:"bg-accent-500 body-2 flex w-fit items-center gap-1 rounded-[20px] px-2 py-1",children:[f,C?.dataset??"Dataset"]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsxs("div",{role:"heading","aria-level":4,className:nt("flex gap-1 items-center h4",b),children:[r.jsx("div",{ref:T,children:r.jsx(M.IconButton,{title:C?.metadata??"View details",buttonClassName:nt("!text-neutrals-1000 !border-none !w-4 !h-4 !p-0 shrink-0",h),icon:r.jsx(Oi,{className:nt("size-4",m)}),onClick:fe})}),r.jsx("span",{children:y.getLocalizedName(n,o)})]}),l&&r.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",children:d||r.jsx(Ve.IconExternalLink,{className:"size-4 shrink-0 cursor-pointer text-primary"})})]}),r.jsxs("div",{className:"body-3 flex items-center gap-2",children:[e&&r.jsxs(r.Fragment,{children:[me(C?.agency??"Agency",n?.agencyID??""),r.jsx("div",{"aria-hidden":"true",className:"h-[14px] border-l border-l-neutral-500"})]}),me(C?.lastUpdated??"Last updated",w)]})]}),A&&r.jsx(dt,{reference:T,title:N,description:R,onReferenceClick:fe,shouldCloseTooltip:H}),S&&r.jsx(Zn,{locale:o,metadata:ne,metadataDescription:z,isOpenMetadata:S,onCloseMetadata:xe})]})},um=({locale:e,isShowShare:t,shareConversationProps:n})=>{const{titles:s}=ye(),{setIsOpenedAdvancedView:a}=Ge(),i=u.useRef(null),[o,c]=u.useState(""),[l,f]=u.useState(""),[d,h]=u.useState(!1),{onboardingFileSchema:m,isShowOnboarding:p}=Ye();return u.useEffect(()=>{if(p){const{title:g,description:b}=ct(Oe.EXIT_ADVANCED_VIEW,s);c(g),f(b)}},[s,p]),u.useEffect(()=>{p&&h(m?.lastDisplayedElement===Oe.EXIT_ADVANCED_VIEW)},[m?.lastDisplayedElement,p]),r.jsxs("header",{className:W("bg-white px-6 py-4 flex justify-between items-center sm:px-0","advanced-view-header"),children:[r.jsxs("div",{className:W("flex gap-3 items-center",!t&&"justify-between w-full","advanced-view-header-title"),children:[r.jsx("div",{ref:i,className:W(!t&&"order-2","flex"),children:r.jsx(M.CloseButton,{btnClassNames:"button-close",onClick:()=>a(!1),title:s?.close||"Close"})}),d&&r.jsx(dt,{reference:i,title:o,description:l,onReferenceClick:()=>a(!1),shouldMoveToNextStep:!0}),r.jsx("h2",{children:s?.advanceViewTitle??"Advanced view"})]}),t&&r.jsx(hr,{locale:e,...n})]})};function fm(e,t,n,s,a,i,o,c,l){const f=mm(e,n),d=l?.startPeriod&&l.endPeriod?y.getAdditionalColumns(c,l):[],h=hm(e,t,n,s,a,i,d);return[kd(e,t?.data,n,a,i,o),...f,...h,Fi(e,t?.data,n,void 0,i,o)]}function mm(e,t){const n=e.conceptSchemes||[],s=e.codelists||[],a=y.getDimensions(e)?.dimensions||[];return a.map(i=>{const{codeList:o,concept:c}=pn(i,n,s),l=f=>{const{data:d,colDef:h}=f,m=h.field;return ns(a,m,o,d,t)};return{headerName:y.getLocalizedName(c,t),field:i.id,colId:i.id,valueGetter:l,...gt,tooltipValueGetter:f=>f.value}})}function hm(e,t,n,s,a,i,o){const c=Cm(o,y.getTimePeriods(t));return gm(c,(f,d)=>pm(f,d||f,s,i),e,n,a,i)}const pm=(e,t,n=te.defaultFormatNumbers,s)=>({headerName:Sr(t,s),colId:e,field:e,type:"numericColumn",suppressColumnsToolPanel:!0,sortable:!1,width:vt,cellClass:["justify-end","cell-with-meta"],valueFormatter:a=>te.formatNumberBySign(a.value,n)}),gm=(e,t,n,s,a,i)=>{const o=[];return e.sort((l,f)=>y.sortPeriods(l,f)).forEach(l=>{o.push({headerName:l.toString(),field:l.toString(),...t(l.toString()),valueGetter:f=>f.data[f.column.getColId()]?.value?.[0]?.value||null,cellClass:mt,cellRenderer:un,width:vt,cellRendererParams:{dataSetData:n,locale:s,metadataSettings:a,titles:i}})}),o},Cm=(e=[],t=[])=>{if(!e.length)return t;if(!t.length)return e;const n=t.some(f=>y.isYearly(f)),s=t.some(f=>y.isSemiAnnually(f)),a=t.some(f=>y.isQuarterly(f)),i=t.some(f=>y.isMonthly(f)),o=t.some(f=>y.isWeekly(f)),c=t.some(f=>y.isDaily(f)),l=e.filter(f=>y.isYearly(f)?n:y.isSemiAnnually(f)?s:y.isQuarterly(f)?a:y.isMonthly(f)?i:y.isWeekly(f)?o:y.isDaily(f)?c:!0);return Array.from(new Set([...l,...t]))};function wm(e,t,n){const s=t.map(i=>i.id).filter(i=>i!=null),a=n.map(i=>i.id).filter(i=>i!=null);return xm(e,s,a,s)}const xm=(e,t,n,s)=>{const a={};for(const i of e){const o=Sm(i,t),c=vm(o,s);let l=a[c];if(l==null){l={},a[c]=l;for(const d of s)l[d]=o[d]}const f=Va(i.attributes);if(Ha(l,c,f,i),!i.values.length){Oa(l,o,n);continue}for(const d of i.values){const h=Va(d.obsAttributes);Ha(l,c,f,i),Oa(l,o,n,d.dimensionAtObservation,ym(i,d),h)}}return Object.values(a)},vm=(e,t)=>t.map(n=>e[n]).join("_"),bm=(e,t,n)=>t.map(s=>s==="TIME_PERIOD"?n:e[s]).join("_"),Oa=(e,t,n,s,a,i)=>{const o=bm(t,n,s);e[o]={value:a,obsAttributes:i}},Sm=(e,t)=>{const n={},s=e.name.split(".");for(let a=0;a<t.length;a+=1)n[t[a]]=s[a];return n},ym=(e,t)=>{const n=_a(e.attributes);if(n)return[n];const s=_a(t.obsAttributes);return s?[s]:t.values},_a=(e=[])=>e.find(({name:t})=>t==="OBS_VALUE"),Va=(e=[])=>e.filter(({value:t})=>t),Ha=(e,t,n,s)=>{e.attributes??=n,e.id=t,e.originalData=s},Dm="#EEEEEE",Mm="#777777";function Tm(e,t,n){const s={animation:!1,tooltip:{trigger:"axis",appendToBody:!0,formatter:a=>{let i=a[0].axisValueLabel+"<br/>";return a.forEach(o=>{o.value!==null&&o.value!==void 0&&(i+=o.marker+" "+o.seriesName+": "+o.value+"<br/>")}),i}},legend:{bottom:0},grid:{left:"3%",right:"3%",bottom:"40px",containLabel:!0},xAxis:{...Ua(n?.ticksColor,n?.labelsColor),type:"category",boundaryGap:!1,data:e},yAxis:{...Ua(n?.ticksColor,n?.labelsColor),type:"value"},series:t};return n?.colors!=null&&(s.color=n.colors),s}function Ua(e=Dm,t=Mm){return{splitLine:{show:!0,showMaxLine:!1,lineStyle:{color:[e]}},axisTick:{show:!1},axisLabel:{color:t},axisLine:{lineStyle:{color:e}}}}function co(e,t,n,s){return t.map(i=>{const o=y.getDimensions(n)?.dimensions||[],c=o?.find(f=>f.id===i);if(c==null)return e[i]||"";const{codeList:l}=pn(c,n.conceptSchemes||[],n.codelists||[]);return ns(o,i,l,e,s)}).join(" - ")}function Em(e,t){const n=[...t?.metadata?.indicatorDimensions||[]].filter(i=>i!=null),a=y.getDimensions(e)?.dimensions?.filter(i=>i.id!=null&&!n.includes(i.id)&&t?.metadata?.countryDimension!==i.id).map(i=>i.id).filter(i=>i!=null)||[];return[...n,...a]}function Am(e,t,n){const s={};return e.forEach(a=>{const i=Nm(a,t,n);s[i]||(s[i]={rows:[]}),s[i].rows.push(a)}),Object.keys(s).map(a=>s[a])}function Nm(e,t,n){const s=n.dataStructures?.[0]?.dataStructureComponents?.dimensionList?.dimensions||[];return t.map(i=>s?.find(c=>c.id===i)==null?e[i]||"":ao(s,i,e)).join(" - ")}function km(e,t){const n={};return e.forEach(s=>n[s]=jm(s,t)),{nonUniqDimensions:e.filter(s=>!n[s])}}function jm(e,t){const n=t.map(a=>Im(e,a));return new Set(n).size===1}function Im(e,t){return t[e]}const Lm="line",zt=10,Pm=2;function Rm(e){return typeof e=="number"?Number.isFinite(e):typeof e=="string"&&e.trim()!==""?Number.isFinite(Number(e)):!1}function uo(e){const t=(e.groups??[]).flatMap(n=>n.units);return[...e.units,...t].some(n=>n.isPlottable)}function fo(e,t,n,s,a){const i=as(t,e,n,s,a,{includeChartData:!1}),c=y.getTimePeriods(t).sort((h,m)=>y.sortPeriods(h,m)),l=Em(e,n),{nonUniqDimensions:f}=km(l,i);return{units:Am(i,f,e).map(h=>mo(h,e,n,c,s,a))}}function Fm(e,t,n,s,a){let i;return()=>(i??=fo(e,t,n,s,a),i)}function Om(e,t,n,s,a,i){return mo({rows:[e]},n,s,t,a,i)}function mo(e,t,n,s,a,i){const o=Bm(e.rows,t,n,a),c=o?.find(d=>y.FREQUENCY_DIMENSION_ID.includes(d?.id))?.id,l=Vm(s,e?.rows?.[0],c),f=Hm(e.rows.length>zt?e.rows.slice(0,zt):e.rows,t,n,a,l);return{rows:e.rows,limitedByRowsAmountTo:e.rows.length>zt?zt:void 0,dimensions:o,config:Tm(l,f,i),isPlottable:_m(f)}}function _m(e){return e.some(t=>t.data.filter(Rm).length>=Pm)}function Vm(e,t,n){if(n){const s=t?.[n];if(s===y.Periods.MONTHLY)return e?.filter(a=>y.isMonthly(a));if(s===y.Periods.QUARTERLY)return e?.filter(a=>y.isQuarterly(a));if(s===y.Periods.ANNUAL)return e?.filter(a=>y.isYearly(a))}return e}function Hm(e,t,n,s,a){return e.map(i=>({name:n?.metadata?.countryDimension==null?"":co(i,[n?.metadata?.countryDimension],t,s),type:Lm,data:a.map(o=>Um(o,i))}))}function Um(e,t){return t[e]?.value?.[0]?.value||null}function Bm(e,t,n,s){const a=n?.metadata?.countryDimension;return(y.getDimensions(t)?.dimensions||[]).map(i=>{if(!(i.id==null||i.id===a))return{id:i.id,title:Gm(i,t,s),value:co(e[0],[i.id],t,s)}}).filter(i=>i!=null)}function Gm(e,t,n){const s=t.conceptSchemes||[],a=t.codelists||[],{concept:i}=pn(e,s,a);return y.getLocalizedName(i,n)||e.id}function as(e,t,n,s,a,i={}){const o=e==null?[]:y.getParsedResponse(e),c=y.getDimensions(t)?.dimensions||[],l=y.getDimensions(t)?.timeDimensions||[],f=wm(o,c,l);return i.includeChartData===!1?f:zm(f,e,t,n,s,a)}function zm(e,t,n,s,a,i){const c=y.getTimePeriods(t).sort((l,f)=>y.sortPeriods(l,f));return e.map(l=>({...l,[jt]:()=>Om(l,c,n,s,a,i)}))}function Wm(e,t,n,s,a,i,o,c,l,f,d){return{columns:fm(e,t,s,a,i,c,l,f,d),data:as(t,e,n,s,o)}}function $m(e,t,n,s,a,i,o,c,l,f,d){const h=e.dataflows?.[0]?.names?.[s],m=Wm(e,t,n,s,a,i,o,c,l,f,d);return{title:h||c?.dataGrid||"Data Grid",grid_data:m}}function Jm(e){const t=e.replace(/\r\n/g,`
|
|
5
|
+
`).map(s=>s.replace(Oo," ").trim()).filter(Boolean)[0]??"";return(t.length>Xs?t.substring(0,Xs):t).trim()},Uo=(e,t,n,s,a,i)=>{const o=`${e}/${t}`;return{name:n,folderId:o,prompt:a,id:we.generateConversationId({folderId:o,name:n}),messages:[{role:je.Role.Assistant,content:s}],custom_fields:{configuration:{choice:i}}}},tr=d.createContext(null);function ln({children:e,styles:t}){return r.jsx(tr.Provider,{value:t??{},children:e})}function ye(){const e=d.useContext(tr);if(!e)throw new Error("useConversationViewStyles must be used within ConversationViewStylesProvider");return e}var Ho=Object.defineProperty,en=Object.getOwnPropertySymbols,nr=Object.prototype.hasOwnProperty,sr=Object.prototype.propertyIsEnumerable,Qs=(e,t,n)=>t in e?Ho(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Nn=(e,t)=>{for(var n in t||(t={}))nr.call(t,n)&&Qs(e,n,t[n]);if(en)for(var n of en(t))sr.call(t,n)&&Qs(e,n,t[n]);return e},kn=(e,t)=>{var n={};for(var s in e)nr.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&en)for(var s of en(e))t.indexOf(s)<0&&sr.call(e,s)&&(n[s]=e[s]);return n};var gt;(e=>{const t=class Se{constructor(l,f,u,h){if(this.version=l,this.errorCorrectionLevel=f,this.modules=[],this.isFunction=[],l<Se.MIN_VERSION||l>Se.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 b=0;b<8;b++){this.applyMask(b),this.drawFormatBits(b);const C=this.getPenaltyScore();C<g&&(h=b,g=C),this.applyMask(b)}}a(0<=h&&h<=7),this.mask=h,this.applyMask(h),this.drawFormatBits(h),this.isFunction=[]}static encodeText(l,f){const u=e.QrSegment.makeSegments(l);return Se.encodeSegments(u,f)}static encodeBinary(l,f){const u=e.QrSegment.makeBytes(l);return Se.encodeSegments([u],f)}static encodeSegments(l,f,u=1,h=40,m=-1,p=!0){if(!(Se.MIN_VERSION<=u&&u<=h&&h<=Se.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let g,b;for(g=u;;g++){const v=Se.getNumDataCodewords(g,f)*8,S=o.getTotalBits(l,g);if(S<=v){b=S;break}if(g>=h)throw new RangeError("Data too long")}for(const v of[Se.Ecc.MEDIUM,Se.Ecc.QUARTILE,Se.Ecc.HIGH])p&&b<=Se.getNumDataCodewords(g,v)*8&&(f=v);let C=[];for(const v of l){n(v.mode.modeBits,4,C),n(v.numChars,v.mode.numCharCountBits(g),C);for(const S of v.getData())C.push(S)}a(C.length==b);const x=Se.getNumDataCodewords(g,f)*8;a(C.length<=x),n(0,Math.min(4,x-C.length),C),n(0,(8-C.length%8)%8,C),a(C.length%8==0);for(let v=236;C.length<x;v^=253)n(v,8,C);let w=[];for(;w.length*8<C.length;)w.push(0);return C.forEach((v,S)=>w[S>>>3]|=v<<7-(S&7)),new Se(g,f,w,m)}getModule(l,f){return 0<=l&&l<this.size&&0<=f&&f<this.size&&this.modules[f][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(),f=l.length;for(let u=0;u<f;u++)for(let h=0;h<f;h++)u==0&&h==0||u==0&&h==f-1||u==f-1&&h==0||this.drawAlignmentPattern(l[u],l[h]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(l){const f=this.errorCorrectionLevel.formatBits<<3|l;let u=f;for(let m=0;m<10;m++)u=u<<1^(u>>>9)*1335;const h=(f<<10|u)^21522;a(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 f=this.version<<12|l;a(f>>>18==0);for(let u=0;u<18;u++){const h=s(f,u),m=this.size-11+u%3,p=Math.floor(u/3);this.setFunctionModule(m,p,h),this.setFunctionModule(p,m,h)}}drawFinderPattern(l,f){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=f+u;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,m!=2&&m!=4)}}drawAlignmentPattern(l,f){for(let u=-2;u<=2;u++)for(let h=-2;h<=2;h++)this.setFunctionModule(l+h,f+u,Math.max(Math.abs(h),Math.abs(u))!=1)}setFunctionModule(l,f,u){this.modules[f][l]=u,this.isFunction[f][l]=!0}addEccAndInterleave(l){const f=this.version,u=this.errorCorrectionLevel;if(l.length!=Se.getNumDataCodewords(f,u))throw new RangeError("Invalid argument");const h=Se.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][f],m=Se.ECC_CODEWORDS_PER_BLOCK[u.ordinal][f],p=Math.floor(Se.getNumRawDataModules(f)/8),g=h-p%h,b=Math.floor(p/h);let C=[];const x=Se.reedSolomonComputeDivisor(m);for(let v=0,S=0;v<h;v++){let k=l.slice(S,S+b-m+(v<g?0:1));S+=k.length;const T=Se.reedSolomonComputeRemainder(k,x);v<g&&k.push(0),C.push(k.concat(T))}let w=[];for(let v=0;v<C[0].length;v++)C.forEach((S,k)=>{(v!=b-m||k>=g)&&w.push(S[v])});return a(w.length==p),w}drawCodewords(l){if(l.length!=Math.floor(Se.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let f=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,b=(u+1&2)==0?this.size-1-h:h;!this.isFunction[b][p]&&f<l.length*8&&(this.modules[b][p]=s(l[f>>>3],7-(f&7)),f++)}}a(f==l.length*8)}applyMask(l){if(l<0||l>7)throw new RangeError("Mask value out of range");for(let f=0;f<this.size;f++)for(let u=0;u<this.size;u++){let h;switch(l){case 0:h=(u+f)%2==0;break;case 1:h=f%2==0;break;case 2:h=u%3==0;break;case 3:h=(u+f)%3==0;break;case 4:h=(Math.floor(u/3)+Math.floor(f/2))%2==0;break;case 5:h=u*f%2+u*f%3==0;break;case 6:h=(u*f%2+u*f%3)%2==0;break;case 7:h=((u+f)%2+u*f%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[f][u]&&h&&(this.modules[f][u]=!this.modules[f][u])}}getPenaltyScore(){let l=0;for(let m=0;m<this.size;m++){let p=!1,g=0,b=[0,0,0,0,0,0,0];for(let C=0;C<this.size;C++)this.modules[m][C]==p?(g++,g==5?l+=Se.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,b),p||(l+=this.finderPenaltyCountPatterns(b)*Se.PENALTY_N3),p=this.modules[m][C],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,b)*Se.PENALTY_N3}for(let m=0;m<this.size;m++){let p=!1,g=0,b=[0,0,0,0,0,0,0];for(let C=0;C<this.size;C++)this.modules[C][m]==p?(g++,g==5?l+=Se.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,b),p||(l+=this.finderPenaltyCountPatterns(b)*Se.PENALTY_N3),p=this.modules[C][m],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,b)*Se.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+=Se.PENALTY_N2)}let f=0;for(const m of this.modules)f=m.reduce((p,g)=>p+(g?1:0),f);const u=this.size*this.size,h=Math.ceil(Math.abs(f*20-u*10)/u)-1;return a(0<=h&&h<=9),l+=h*Se.PENALTY_N4,a(0<=l&&l<=2568888),l}getAlignmentPatternPositions(){if(this.version==1)return[];{const l=Math.floor(this.version/7)+2,f=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-=f)u.splice(1,0,h);return u}}static getNumRawDataModules(l){if(l<Se.MIN_VERSION||l>Se.MAX_VERSION)throw new RangeError("Version number out of range");let f=(16*l+128)*l+64;if(l>=2){const u=Math.floor(l/7)+2;f-=(25*u-10)*u-55,l>=7&&(f-=36)}return a(208<=f&&f<=29648),f}static getNumDataCodewords(l,f){return Math.floor(Se.getNumRawDataModules(l)/8)-Se.ECC_CODEWORDS_PER_BLOCK[f.ordinal][l]*Se.NUM_ERROR_CORRECTION_BLOCKS[f.ordinal][l]}static reedSolomonComputeDivisor(l){if(l<1||l>255)throw new RangeError("Degree out of range");let f=[];for(let h=0;h<l-1;h++)f.push(0);f.push(1);let u=1;for(let h=0;h<l;h++){for(let m=0;m<f.length;m++)f[m]=Se.reedSolomonMultiply(f[m],u),m+1<f.length&&(f[m]^=f[m+1]);u=Se.reedSolomonMultiply(u,2)}return f}static reedSolomonComputeRemainder(l,f){let u=f.map(h=>0);for(const h of l){const m=h^u.shift();u.push(0),f.forEach((p,g)=>u[g]^=Se.reedSolomonMultiply(p,m))}return u}static reedSolomonMultiply(l,f){if(l>>>8||f>>>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^=(f>>>h&1)*l;return a(u>>>8==0),u}finderPenaltyCountPatterns(l){const f=l[1];a(f<=this.size*3);const u=f>0&&l[2]==f&&l[3]==f*3&&l[4]==f&&l[5]==f;return(u&&l[0]>=f*4&&l[6]>=f?1:0)+(u&&l[6]>=f*4&&l[0]>=f?1:0)}finderPenaltyTerminateAndCount(l,f,u){return l&&(this.finderPenaltyAddHistory(f,u),f=0),f+=this.size,this.finderPenaltyAddHistory(f,u),this.finderPenaltyCountPatterns(u)}finderPenaltyAddHistory(l,f){f[0]==0&&(l+=this.size),f.pop(),f.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,f){if(l<0||l>31||c>>>l)throw new RangeError("Value out of range");for(let u=l-1;u>=0;u--)f.push(c>>>u&1)}function s(c,l){return(c>>>l&1)!=0}function a(c){if(!c)throw new Error("Assertion error")}const i=class Fe{constructor(l,f,u){if(this.mode=l,this.numChars=f,this.bitData=u,f<0)throw new RangeError("Invalid argument");this.bitData=u.slice()}static makeBytes(l){let f=[];for(const u of l)n(u,8,f);return new Fe(Fe.Mode.BYTE,l.length,f)}static makeNumeric(l){if(!Fe.isNumeric(l))throw new RangeError("String contains non-numeric characters");let f=[];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,f),u+=h}return new Fe(Fe.Mode.NUMERIC,l.length,f)}static makeAlphanumeric(l){if(!Fe.isAlphanumeric(l))throw new RangeError("String contains unencodable characters in alphanumeric mode");let f=[],u;for(u=0;u+2<=l.length;u+=2){let h=Fe.ALPHANUMERIC_CHARSET.indexOf(l.charAt(u))*45;h+=Fe.ALPHANUMERIC_CHARSET.indexOf(l.charAt(u+1)),n(h,11,f)}return u<l.length&&n(Fe.ALPHANUMERIC_CHARSET.indexOf(l.charAt(u)),6,f),new Fe(Fe.Mode.ALPHANUMERIC,l.length,f)}static makeSegments(l){return l==""?[]:Fe.isNumeric(l)?[Fe.makeNumeric(l)]:Fe.isAlphanumeric(l)?[Fe.makeAlphanumeric(l)]:[Fe.makeBytes(Fe.toUtf8ByteArray(l))]}static makeEci(l){let f=[];if(l<0)throw new RangeError("ECI assignment value out of range");if(l<128)n(l,8,f);else if(l<16384)n(2,2,f),n(l,14,f);else if(l<1e6)n(6,3,f),n(l,21,f);else throw new RangeError("ECI assignment value out of range");return new Fe(Fe.Mode.ECI,0,f)}static isNumeric(l){return Fe.NUMERIC_REGEX.test(l)}static isAlphanumeric(l){return Fe.ALPHANUMERIC_REGEX.test(l)}getData(){return this.bitData.slice()}static getTotalBits(l,f){let u=0;for(const h of l){const m=h.mode.numCharCountBits(f);if(h.numChars>=1<<m)return 1/0;u+=4+m+h.bitData.length}return u}static toUtf8ByteArray(l){l=encodeURI(l);let f=[];for(let u=0;u<l.length;u++)l.charAt(u)!="%"?f.push(l.charCodeAt(u)):(f.push(parseInt(l.substring(u+1,u+3),16)),u+=2);return f}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=i;e.QrSegment=i})(gt||(gt={}));(e=>{(t=>{const n=class{constructor(a,i){this.ordinal=a,this.formatBits=i}};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={}))})(gt||(gt={}));(e=>{(t=>{const n=class{constructor(a,i){this.modeBits=a,this.numBitsCharCount=i}numCharCountBits(a){return this.numBitsCharCount[Math.floor((a+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={}))})(gt||(gt={}));var xt=gt;var Bo={L:xt.QrCode.Ecc.LOW,M:xt.QrCode.Ecc.MEDIUM,Q:xt.QrCode.Ecc.QUARTILE,H:xt.QrCode.Ecc.HIGH},ar=128,rr="L",ir="#FFFFFF",or="#000000",lr=!1,cr=1,Go=4,zo=0,Wo=.1;function dr(e,t=0){const n=[];return e.forEach(function(s,a){let i=null;s.forEach(function(o,c){if(!o&&i!==null){n.push(`M${i+t} ${a+t}h${c-i}v1H${i+t}z`),i=null;return}if(c===s.length-1){if(!o)return;i===null?n.push(`M${c+t},${a+t} h1v1H${c+t}z`):n.push(`M${i+t},${a+t} h${c+1-i}v1H${i+t}z`);return}o&&i===null&&(i=c)})}),n.join("")}function ur(e,t){return e.slice().map((n,s)=>s<t.y||s>=t.y+t.h?n:n.map((a,i)=>i<t.x||i>=t.x+t.w?a:!1))}function $o(e,t,n,s){if(s==null)return null;const a=e.length+n*2,i=Math.floor(t*Wo),o=a/t,c=(s.width||i)*o,l=(s.height||i)*o,f=s.x==null?e.length/2-c/2:s.x*o,u=s.y==null?e.length/2-l/2:s.y*o,h=s.opacity==null?1:s.opacity;let m=null;if(s.excavate){let g=Math.floor(f),b=Math.floor(u),C=Math.ceil(c+f-g),x=Math.ceil(l+u-b);m={x:g,y:b,w:C,h:x}}const p=s.crossOrigin;return{x:f,y:u,h:l,w:c,excavation:m,opacity:h,crossOrigin:p}}function Jo(e,t){return t!=null?Math.max(Math.floor(t),0):e?Go:zo}function fr({value:e,level:t,minVersion:n,includeMargin:s,marginSize:a,imageSettings:i,size:o,boostLevel:c}){let l=d.useMemo(()=>{const g=(Array.isArray(e)?e:[e]).reduce((b,C)=>(b.push(...xt.QrSegment.makeSegments(C)),b),[]);return xt.QrCode.encodeSegments(g,Bo[t],n,void 0,void 0,c)},[e,t,n,c]);const{cells:f,margin:u,numCells:h,calculatedImageSettings:m}=d.useMemo(()=>{let p=l.getModules();const g=Jo(s,a),b=p.length+g*2,C=$o(p,o,g,i);return{cells:p,margin:g,numCells:b,calculatedImageSettings:C}},[l,o,i,s,a]);return{qrcode:l,margin:u,cells:f,numCells:h,calculatedImageSettings:m}}var Ko=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Yo=d.forwardRef(function(t,n){const s=t,{value:a,size:i=ar,level:o=rr,bgColor:c=ir,fgColor:l=or,includeMargin:f=lr,minVersion:u=cr,boostLevel:h,marginSize:m,imageSettings:p}=s,b=kn(s,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:C}=b,x=kn(b,["style"]),w=p?.src,v=d.useRef(null),S=d.useRef(null),k=d.useCallback(L=>{v.current=L,typeof n=="function"?n(L):n&&(n.current=L)},[n]),[T,N]=d.useState(!1),{margin:D,cells:R,numCells:E,calculatedImageSettings:A}=fr({value:a,level:o,minVersion:u,boostLevel:h,includeMargin:f,marginSize:m,imageSettings:p,size:i});d.useEffect(()=>{if(v.current!=null){const L=v.current,W=L.getContext("2d");if(!W)return;let $=R;const q=S.current,U=A!=null&&q!==null&&q.complete&&q.naturalHeight!==0&&q.naturalWidth!==0;U&&A.excavation!=null&&($=ur(R,A.excavation));const J=window.devicePixelRatio||1;L.height=L.width=i*J;const G=i/E*J;W.scale(G,G),W.fillStyle=c,W.fillRect(0,0,E,E),W.fillStyle=l,Ko?W.fill(new Path2D(dr($,D))):R.forEach(function(te,ne){te.forEach(function(fe,xe){fe&&W.fillRect(xe+D,ne+D,1,1)})}),A&&(W.globalAlpha=A.opacity),U&&W.drawImage(q,A.x+D,A.y+D,A.w,A.h)}}),d.useEffect(()=>{N(!1)},[w]);const I=Nn({height:i,width:i},C);let O=null;return w!=null&&(O=d.createElement("img",{src:w,key:w,style:{display:"none"},onLoad:()=>{N(!0)},ref:S,crossOrigin:A?.crossOrigin})),d.createElement(d.Fragment,null,d.createElement("canvas",Nn({style:I,height:i,width:i,ref:k,role:"img"},x)),O)});Yo.displayName="QRCodeCanvas";var mr=d.forwardRef(function(t,n){const s=t,{value:a,size:i=ar,level:o=rr,bgColor:c=ir,fgColor:l=or,includeMargin:f=lr,minVersion:u=cr,boostLevel:h,title:m,marginSize:p,imageSettings:g}=s,b=kn(s,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:C,cells:x,numCells:w,calculatedImageSettings:v}=fr({value:a,level:o,minVersion:u,boostLevel:h,includeMargin:f,marginSize:p,imageSettings:g,size:i});let S=x,k=null;g!=null&&v!=null&&(v.excavation!=null&&(S=ur(x,v.excavation)),k=d.createElement("image",{href:g.src,height:v.h,width:v.w,x:v.x+C,y:v.y+C,preserveAspectRatio:"none",opacity:v.opacity,crossOrigin:v.crossOrigin}));const T=dr(S,C);return d.createElement("svg",Nn({height:i,width:i,viewBox:`0 0 ${w} ${w}`,ref:n,role:"img"},b),!!m&&d.createElement("title",null,m),d.createElement("path",{fill:c,d:`M0,0 h${w}v${w}H0z`,shapeRendering:"crispEdges"}),d.createElement("path",{fill:l,d:T,shapeRendering:"crispEdges"}),k)});mr.displayName="QRCodeSVG";const qo=(e,t)=>({invitationType:we.InvitationType.LINK,resources:[{url:`conversations/${encodeURI(e)}`},...t]}),Zo=e=>{const t=e?.invitationLink?.split("/").at(-1)||"";return`/${ee.SHARE_CONVERSATION_ROUTE}/${t}`},Xo=(e,t)=>t?.find(n=>{const s=e?.id?.split("/")?.pop(),a=n?.url?.split("/")?.pop()||"";return a===s||decodeURI(a)===s}),Qo=e=>e?.messages?.filter(n=>!!n?.custom_content?.attachments)?.flatMap(n=>n?.custom_content?.attachments?.map(s=>({url:s?.url||""}))||[])?.filter(n=>!!n?.url)||[],el=({conversation:e,locale:t,onCloseModal:n,modalDividers:s,getConversation:a,generateConversationLink:i,chatExpiration:o,chatExpirationDays:c,close:l,chatWarning:f,shareLink:u,shareCopyLink:h,shareCopiedLink:m,shareDescription:p,shareRemoveAccessToUsers:g,chatName:b,getSharedConversations:C,revokeSharedConversations:x,baseUrl:w,id:v,clientSharedPage:S,clientSharedProp:k,shareAlertMessage:T})=>{const[N,D]=d.useState(null),[R,E]=d.useState(),[A,I]=d.useState(!1),[O,L]=d.useState(!1),[W,$]=d.useState(),q=d.useRef(null),U=d.useRef(null),J=d.useMemo(()=>e?.id?decodeURI(e.id):v?.[0]&&v?.[1]&&t?decodeURI(`${v[0]}/${t}/${v[1]}`):null,[e?.id,v,t]),G=d.useMemo(()=>{if(!N)return"";const _=w||window.location.origin;if(w&&w!==window.location.origin&&S&&k){const K=N.split(`/${ee.SHARE_CONVERSATION_ROUTE}/`)?.[1];return`${_}/${S}?${k}=${K}`}return`${_}/${t}${N}`},[w,N,t,S,k]),te=d.useCallback(async _=>{const K=await C?.(we.getSharedConversationsRequest(we.ShareTarget.OTHERS));if(K)return Xo({id:_},K.resources)},[C]);d.useEffect(()=>{if(!J||q.current===J)return;q.current=J,I(!1),U.current?.abort();const _=new AbortController;return U.current=_,(async()=>{try{const le=await a?.(J),de=qo(J,Qo(le)),ue=await i?.(de),se=await te(J);if(_.signal.aborted||!ue)return;D(Zo(ue)),E(se),I(!0)}catch(le){if(_.signal.aborted)return;I(!1),console.error("Error sharing conversation",le)}})(),()=>{_.abort(),q.current=null}},[J,i,a,te]);const ne=d.useCallback(()=>{U.current?.abort(),q.current=null,n(),D(null),I(!1),L(!1)},[n]),fe=d.useCallback(()=>{L(!0),navigator.clipboard.writeText(G||"")},[G]),xe=async()=>{try{if($(!0),R&&await x?.({resources:[R]}),J){const _=await te(J);U.current?.signal.aborted||E(_)}}catch(_){console.error("Error revoking shared conversation",_)}finally{U.current?.signal.aborted||$(!1)}},me=d.useCallback(()=>r.jsx(M.Button,{buttonClassName:O?"text-button-secondary":"text-button-primary",iconBefore:O?r.jsx(Ve.IconCheck,{width:20,height:20}):r.jsx(Ve.IconCopy,{width:20,height:20}),title:O?m??"Copied":h??"Copy link",disabled:O,onClick:fe}),[O,fe,m,h]);return r.jsxs(M.Popup,{heading:u??"Share link",portalId:"share",size:M.PopUpSize.SM,dividers:s,onClose:ne,closeButtonTitle:l??"Close",children:[A?r.jsxs("div",{className:"share flex flex-col gap-y-4 overflow-auto px-6 pb-6 sm:p-0",children:[T?r.jsx(M.InlineAlert,{type:M.InlineAlertType.Note,icon:r.jsx(Ve.IconInfoCircle,{width:16,height:16}),children:T}):null,e?.name?r.jsxs("div",{className:"share-info flex w-full",children:[r.jsx("p",{className:"share-info-title body-1 mr-1 text-neutrals-800",children:b??"Chat name:"}),r.jsx("h3",{className:"min-w-0 flex-1 truncate",title:e?.name,children:e?.name})]}):null,r.jsxs("div",{className:"share-info flex",children:[r.jsx("p",{className:"share-info-title body-1 mr-1 text-neutrals-800",children:o??"Link expiration date:"}),r.jsxs("h3",{children:["3 ",c??"days"]})]}),r.jsx(mr,{className:"min-h-[200px] self-center rounded border border-neutrals-600 p-2",value:G,size:200}),r.jsx("p",{className:"body-2 text-neutrals-1000",children:p??"Your name, special instructions, and any messages you add after sharing remain confidential."}),r.jsx(M.InputWithIcon,{containerClasses:"share-input-container",cssClass:"share-input",readonly:!0,placeholder:G,value:G,inputId:"conversationLink",iconAfterInput:me()})]}):r.jsx("div",{className:"flex items-center justify-center p-6",children:r.jsx(M.Loader,{})}),A?e&&R?r.jsx("div",{className:"remove-access",children:r.jsx(M.Button,{title:g??"Remove access to all users",buttonClassName:"remove-access-button py-3 px-4",isSmallButton:!0,disabled:W,onClick:xe})}):r.jsx("p",{className:"body-2 share-footer text-neutrals-800",children:f??"This chat has not been shared with anyone yet."}):r.jsx("div",{})]})},hr=({shareButtonClass:e,shareIcon:t,...n})=>{const[s,a]=d.useState(M.PopUpState.Closed),i=()=>{a(M.PopUpState.Opened)},o=d.useCallback(()=>{a(M.PopUpState.Closed)},[]);return r.jsxs(r.Fragment,{children:[r.jsx(M.Button,{buttonClassName:e||"text-button-secondary",title:n?.share||"Share",iconBefore:t,onClick:i}),s===M.PopUpState.Opened&&r.jsx(el,{onCloseModal:o,...n})]})},pr=({conversation:e,locale:t,isOpenedAdvancedView:n,isShowShareButton:s,shareConversationProps:a,rightSlot:i})=>r.jsx(r.Fragment,{children:r.jsxs("header",{className:z("bg-white border-b px-6 py-2 border-gray-200 flex justify-between items-center sm:hidden","conversation-view-header"),children:[r.jsx("span",{className:z("flex-1 min-w-0 truncate h4","conversation-view-header-text"),title:e?.name,children:e?.name}),r.jsxs("div",{className:"ml-3 flex items-center gap-4",children:[!n&&s&&r.jsx("div",{className:"flex gap-x-2",children:r.jsx(hr,{conversation:e,locale:t,...a})}),i]})]})}),gr=({content:e,textColorClass:t})=>{const{isOpenedAdvancedView:n}=We();return r.jsx("div",{className:z("prose max-w-none break-words",n?"body-2":"body-1",t),children:r.jsx(Wa,{remarkPlugins:[$a],components:{strong:s=>r.jsx("strong",{className:t,...s}),a:({href:s,children:a,...i})=>r.jsx("a",{href:s,target:"_blank",rel:"noreferrer",...i,children:a})},children:e})})},Cr=({choiceButtons:e,disabled:t,onClick:n})=>{const s=z("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(a=>r.jsx("div",{className:"mt-4",children:r.jsxs("button",{type:"button",className:s,disabled:t,onClick:()=>n(a[je.DialSchemaProperties.DialWidgetOptions]?.populateText,a?.const),"aria-label":"button",children:[r.jsx("h3",{className:"mb-1",children:a.title}),a.const!==on.COMPLETE&&r.jsx("p",{className:"body-1 text-neutrals-800",children:a[je.DialSchemaProperties.DialWidgetOptions]?.populateText})]})},a.title))},tl=({messageContent:e,choiceButtons:t,disabled:n,onClick:s,handleOnboardingSkip:a})=>{const{titles:i}=ye();return r.jsxs("div",{className:"onboarding flex size-full flex-1 flex-col overflow-auto",children:[r.jsx(pr,{conversation:{name:i?.onboardingTitle??"Introducing the AI assistant"}}),r.jsxs("div",{className:"onboarding-content flex flex-col",children:[r.jsx(gr,{content:e}),r.jsx("div",{className:"mt-4",children:r.jsx(Cr,{choiceButtons:t,disabled:n,onClick:s})}),r.jsxs("div",{className:"mt-8 flex",children:[r.jsx(M.Button,{title:i?.skipOnboardingNow,buttonClassName:"text-button-secondary mr-4",disabled:n,onClick:()=>a?.(),isSmallButton:!0}),r.jsx(M.Button,{title:i?.refuseOnboarding,buttonClassName:"text-button-tertiary",disabled:n,onClick:()=>a?.(!0),isSmallButton:!0})]})]})]})},wr=({openNewConversation:e})=>{const{titles:t}=ye();return r.jsxs("div",{className:"body-3 bg-accent-300 p-2 text-center",children:[r.jsx("span",{className:"mr-2 text-neutrals-900",children:t?.onboardingFooter}),r.jsxs("span",{onClick:e,className:"inline-flex cursor-pointer align-top",children:[r.jsx(Ve.IconPlus,{width:15,height:15}),r.jsx("p",{className:"ml-1",children:t?.onboardingFooterLink})]})]})},xr=({firstLine:e,secondLine:t})=>{const n=e!=null&&e.trim()!=="",s=t!=null&&t.trim()!=="";return r.jsxs("div",{className:z("text-center body-3",s?"p-0":n?"p-1":"p-3"),children:[n&&r.jsx("div",{className:"text-neutrals-800",children:e}),s&&r.jsx("div",{className:"text-neutrals-800",children:t})]})},nl=({suggestionsList:e,welcomeText:t,welcomeDescription:n,welcomeInputPlaceholder:s,titleIcon:a,actions:i,titles:o,inputMessageStyles:c,suggestionsContainerClass:l,isBottomInputPosition:f,prompt:u,onboardingMessageSchema:h,handleConversationClick:m,setConversations:p,locale:g,setSharedConversations:b})=>{const[C,x]=d.useState(null),[w,v]=d.useState(!0),[S,k]=d.useState(!1),{onboardingFileSchema:T,onboardingFileName:N,onboardingFilePath:D,isShowOnboarding:R,setIsShowOnboarding:E,setOnboardingFileSchema:A}=qe(),{isAgentAvailable:I}=M.useAgentAvailability(),{statusMessages:O}=Un();d.useEffect(()=>{(async()=>{try{const U=await i.getBucket();x(U.bucket)}catch(U){console.error(U instanceof Error?U.message:"Request error")}finally{v(!1)}})()},[i]);const L=d.useCallback(async(q,U)=>{if(!C){console.error("No bucket");return}k(!0);try{const J=R?Uo(C,g,o?.onboardingTitle??"Introducing the AI assistant",h?.properties?.choice?.description??"",q,U):_o(C,g,o.newChat??"New chat",q),G=await i.createConversation(J,g,R),te=await i.getConversations(g),ne=await i.getSharedConversations(we.getSharedConversationsRequest(we.ShareTarget.ME));if(h&&T){const fe={...T,isStarted:!0};await i.putOnboardingFile?.(N,D,fe),A?.(fe)}p(ee.cleanConversationNames(te)),b(ee.cleanConversationNames(To.transformSharedConversations(ne,g))),m(G.folderId,G.id)}catch(J){console.error(J instanceof Error?J.message:"Creation conversation failed"),k(!1)}},[i,C,m,R,g,N,D,T,h,p,A,b,o.newChat,o?.onboardingTitle]),W=d.useCallback(async q=>{if(E(!1),q&&T){const U={...T,isSkipped:!0};await i.putOnboardingFile?.(N,D,U),A?.(U)}},[i,N,D,T,E,A]);d.useEffect(()=>{u&&C&&L(u)},[C,u]);const $=()=>{const q=!C;return I?r.jsxs(r.Fragment,{children:[r.jsx(er,{containerClasses:z(c.inputContainerClass,f&&"order-3 mt-auto"),inputClasses:"mr-2",disabled:q,placeholder:s||o?.askAnything||"Ask anything...",sendMessageIcon:c.sendMessageIcon,onSendMessage:L}),r.jsx("div",{className:z("no-scrollbar max-w-full overflow-x-auto",l),children:r.jsx("div",{className:z("flex flex-wrap justify-center gap-2 sm:flex-nowrap","tags-container"),children:e.map(U=>r.jsx(M.Tag,{title:U.title,text:U[je.DialSchemaProperties.DialWidgetOptions]?.populateText,disabled:q,onClick:L},U.title))})})]}):r.jsx(M.InlineAlert,{type:M.InlineAlertType.Error,children:O.assistantUnavailable})};return r.jsx(ln,{styles:{titles:o},children:r.jsxs("div",{className:"flex size-full flex-col",children:[S||u&&w?r.jsx(M.Loader,{}):R?r.jsx(tl,{messageContent:h?.properties?.choice?.description||"",choiceButtons:h?.properties?.choice?.oneOf||[],disabled:!C,handleOnboardingSkip:W,onClick:L}):r.jsxs("div",{className:"flex h-full flex-col items-center justify-center sm:px-4",children:[r.jsxs("div",{className:z("flex items-center max-w-full sm-min:px-4",f?"mt-auto mb-8":n?"mb-0":"mb-6"),children:[a,r.jsx("h1",{className:"sm:h2 text-hues-800 text-center",children:t??o?.welcomeTitle??"How can I help you?"})]}),n&&r.jsx("p",{className:"body-1 text-neutrals-900 mb-6 mt-3 max-w-[784px] text-center",children:n}),$()]}),R&&r.jsx(wr,{openNewConversation:()=>E(!1)}),!R&&r.jsx(xr,{firstLine:o.footerFirstLine,secondLine:o.footerSecondLine})]})})},vr=e=>Te.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Te.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"})),sl=({dataQueries:e,disabledDatasetUrns:t,isSelected:n,onSelect:s,onClearAll:a})=>{const{titles:i}=ye(),o=e.length-t.size,c=t.size>0;return r.jsxs("div",{className:z("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:[r.jsx("h3",{className:"w-full min-w-0 flex-1 truncate",title:i?.dataset??"Dataset",children:r.jsx("span",{className:"truncate",children:i?.dataset??"Dataset"})}),r.jsxs("div",{className:"ml-2 flex items-center gap-2 text-neutrals-800",children:[r.jsx("span",{className:"filters-facet-item-counter px-2 text-center",children:`${o}/${e.length}`}),c&&r.jsx("div",{className:"filters-facet-item-settings flex items-center gap-2",children:r.jsx(M.IconButton,{buttonClassName:"text-button-tertiary w-4 h-4 border-0 p-0 filters-facet-item-icon",icon:r.jsx(vr,{width:16,height:16}),title:i?.reset??"Reset",onClick:l=>{l.stopPropagation(),a()}})})]})]})},Hn=e=>Te.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Te.createElement("path",{d:"M11.3301 6.25L8.00008 9.75L4.67008 6.25L11.3301 6.25Z",fill:"currentColor"})),al=e=>Te.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Te.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"}));function br(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var At={exports:{}},rl=At.exports,ea;function il(){return ea||(ea=1,(function(e,t){(function(n,s){s(t)})(rl,(function(n){var s=function(){return s=Object.assign||function(rt){for(var zt,bn=1,Mo=arguments.length;bn<Mo;bn++){zt=arguments[bn];for(var Sn in zt)Object.prototype.hasOwnProperty.call(zt,Sn)&&(rt[Sn]=zt[Sn])}return rt},s.apply(this,arguments)},a=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},i={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};a.l10ns.ar=i,a.l10ns;var o=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};o.l10ns.at=c,o.l10ns;var l=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},f={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=f,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:{}},b={weekdays:{shorthand:["Нд","Пн","Вт","Ср","Чт","Пт","Сб"],longhand:["Неделя","Понеделник","Вторник","Сряда","Четвъртък","Петък","Събота"]},months:{shorthand:["Яну","Фев","Март","Апр","Май","Юни","Юли","Авг","Сеп","Окт","Ное","Дек"],longhand:["Януари","Февруари","Март","Април","Май","Юни","Юли","Август","Септември","Октомври","Ноември","Декември"]},time_24hr:!0,firstDayOfWeek:1};g.l10ns.bg=b,g.l10ns;var C=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},x={weekdays:{shorthand:["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],longhand:["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"]},months:{shorthand:["জানু","ফেব্রু","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],longhand:["জানুয়ারী","ফেব্রুয়ারী","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"]}};C.l10ns.bn=x,C.l10ns;var w=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},v={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(Ae){var rt=Ae%100;if(rt>3&&rt<21)return"è";switch(rt%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};w.l10ns.cat=w.l10ns.ca=v,w.l10ns;var S=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},k={weekdays:{shorthand:["یەکشەممە","دووشەممە","سێشەممە","چوارشەممە","پێنجشەممە","هەینی","شەممە"],longhand:["یەکشەممە","دووشەممە","سێشەممە","چوارشەممە","پێنجشەممە","هەینی","شەممە"]},months:{shorthand:["ڕێبەندان","ڕەشەمە","نەورۆز","گوڵان","جۆزەردان","پووشپەڕ","گەلاوێژ","خەرمانان","ڕەزبەر","گەڵاڕێزان","سەرماوەز","بەفرانبار"],longhand:["ڕێبەندان","ڕەشەمە","نەورۆز","گوڵان","جۆزەردان","پووشپەڕ","گەلاوێژ","خەرمانان","ڕەزبەر","گەڵاڕێزان","سەرماوەز","بەفرانبار"]},firstDayOfWeek:6,ordinal:function(){return""}};S.l10ns.ckb=k,S.l10ns;var T=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},N={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};T.l10ns.cs=N,T.l10ns;var D=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},R={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(Ae){return Ae===1?"af":Ae===2?"ail":Ae===3||Ae===4?"ydd":Ae===5||Ae===6?"ed":Ae>=7&&Ae<=10||Ae==12||Ae==15||Ae==18||Ae==20?"fed":Ae==11||Ae==13||Ae==14||Ae==16||Ae==17||Ae==19?"eg":Ae>=21&&Ae<=39?"ain":""},time_24hr:!0};D.l10ns.cy=R,D.l10ns;var E=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},A={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=A,E.l10ns;var I=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},O={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};I.l10ns.de=O,I.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(Ae){var rt=Ae%100;if(rt>3&&rt<21)return"th";switch(rt%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},W=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},$={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};W.l10ns.eo=$,W.l10ns;var q=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},U={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};q.l10ns.es=U,q.l10ns;var J=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},G={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};J.l10ns.et=G,J.l10ns;var te=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ne={weekdays:{shorthand:["یک","دو","سه","چهار","پنج","جمعه","شنبه"],longhand:["یکشنبه","دوشنبه","سهشنبه","چهارشنبه","پنچشنبه","جمعه","شنبه"]},months:{shorthand:["ژانویه","فوریه","مارس","آوریل","مه","ژوئن","ژوئیه","اوت","سپتامبر","اکتبر","نوامبر","دسامبر"],longhand:["ژانویه","فوریه","مارس","آوریل","مه","ژوئن","ژوئیه","اوت","سپتامبر","اکتبر","نوامبر","دسامبر"]},firstDayOfWeek:6,ordinal:function(){return""}};te.l10ns.fa=ne,te.l10ns;var fe=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},xe={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};fe.l10ns.fi=xe,fe.l10ns;var me=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},_={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};me.l10ns.fo=_,me.l10ns;var K=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},le={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(Ae){return Ae>1?"":"er"},rangeSeparator:" au ",weekAbbreviation:"Sem",scrollTitle:"Défiler pour augmenter la valeur",toggleTitle:"Cliquer pour basculer",time_24hr:!0};K.l10ns.fr=le,K.l10ns;var de=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ue={weekdays:{shorthand:["Κυ","Δε","Τρ","Τε","Πέ","Πα","Σά"],longhand:["Κυριακή","Δευτέρα","Τρίτη","Τετάρτη","Πέμπτη","Παρασκευή","Σάββατο"]},months:{shorthand:["Ιαν","Φεβ","Μάρ","Απρ","Μάι","Ιούν","Ιούλ","Αύγ","Σεπ","Οκτ","Νοέ","Δεκ"],longhand:["Ιανουάριος","Φεβρουάριος","Μάρτιος","Απρίλιος","Μάιος","Ιούνιος","Ιούλιος","Αύγουστος","Σεπτέμβριος","Οκτώβριος","Νοέμβριος","Δεκέμβριος"]},firstDayOfWeek:1,ordinal:function(){return""},weekAbbreviation:"Εβδ",rangeSeparator:" έως ",scrollTitle:"Μετακυλήστε για προσαύξηση",toggleTitle:"Κάντε κλικ για αλλαγή",amPM:["ΠΜ","ΜΜ"],yearAriaLabel:"χρόνος",monthAriaLabel:"μήνας",hourAriaLabel:"ώρα",minuteAriaLabel:"λεπτό"};de.l10ns.gr=ue,de.l10ns;var se=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Q={weekdays:{shorthand:["א","ב","ג","ד","ה","ו","ש"],longhand:["ראשון","שני","שלישי","רביעי","חמישי","שישי","שבת"]},months:{shorthand:["ינו׳","פבר׳","מרץ","אפר׳","מאי","יוני","יולי","אוג׳","ספט׳","אוק׳","נוב׳","דצמ׳"],longhand:["ינואר","פברואר","מרץ","אפריל","מאי","יוני","יולי","אוגוסט","ספטמבר","אוקטובר","נובמבר","דצמבר"]},rangeSeparator:" אל ",time_24hr:!0};se.l10ns.he=Q,se.l10ns;var H=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},B={weekdays:{shorthand:["रवि","सोम","मंगल","बुध","गुरु","शुक्र","शनि"],longhand:["रविवार","सोमवार","मंगलवार","बुधवार","गुरुवार","शुक्रवार","शनिवार"]},months:{shorthand:["जन","फर","मार्च","अप्रेल","मई","जून","जूलाई","अग","सित","अक्ट","नव","दि"],longhand:["जनवरी ","फरवरी","मार्च","अप्रेल","मई","जून","जूलाई","अगस्त ","सितम्बर","अक्टूबर","नवम्बर","दिसम्बर"]}};H.l10ns.hi=B,H.l10ns;var oe=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};oe.l10ns.hr=ae,oe.l10ns;var ge=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},he={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};ge.l10ns.hu=he,ge.l10ns;var ce=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},De={weekdays:{shorthand:["Կիր","Երկ","Երք","Չրք","Հնգ","Ուրբ","Շբթ"],longhand:["Կիրակի","Եկուշաբթի","Երեքշաբթի","Չորեքշաբթի","Հինգշաբթի","Ուրբաթ","Շաբաթ"]},months:{shorthand:["Հնվ","Փտր","Մար","Ապր","Մայ","Հնս","Հլս","Օգս","Սեպ","Հոկ","Նմբ","Դեկ"],longhand:["Հունվար","Փետրվար","Մարտ","Ապրիլ","Մայիս","Հունիս","Հուլիս","Օգոստոս","Սեպտեմբեր","Հոկտեմբեր","Նոյեմբեր","Դեկտեմբեր"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"ՇԲՏ",scrollTitle:"Ոլորեք՝ մեծացնելու համար",toggleTitle:"Սեղմեք՝ փոխելու համար",amPM:["ՄԿ","ԿՀ"],yearAriaLabel:"Տարի",monthAriaLabel:"Ամիս",hourAriaLabel:"Ժամ",minuteAriaLabel:"Րոպե",time_24hr:!0};ce.l10ns.hy=De,ce.l10ns;var Ee=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ie={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:" - "};Ee.l10ns.id=ie,Ee.l10ns;var Le=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Je={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};Le.l10ns.is=Je,Le.l10ns;var Ge=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},_e={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};Ge.l10ns.it=_e,Ge.l10ns;var Ue=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ze={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:"分"};Ue.l10ns.ja=Ze,Ue.l10ns;var Ke=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},X={weekdays:{shorthand:["კვ","ორ","სა","ოთ","ხუ","პა","შა"],longhand:["კვირა","ორშაბათი","სამშაბათი","ოთხშაბათი","ხუთშაბათი","პარასკევი","შაბათი"]},months:{shorthand:["იან","თებ","მარ","აპრ","მაი","ივნ","ივლ","აგვ","სექ","ოქტ","ნოე","დეკ"],longhand:["იანვარი","თებერვალი","მარტი","აპრილი","მაისი","ივნისი","ივლისი","აგვისტო","სექტემბერი","ოქტომბერი","ნოემბერი","დეკემბერი"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"კვ.",scrollTitle:"დასქროლეთ გასადიდებლად",toggleTitle:"დააკლიკეთ გადართვისთვის",amPM:["AM","PM"],yearAriaLabel:"წელი",time_24hr:!0};Ke.l10ns.ka=X,Ke.l10ns;var pe=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ve={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:["오전","오후"]};pe.l10ns.ko=ve,pe.l10ns;var Ce=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},be={weekdays:{shorthand:["អាទិត្យ","ចន្ទ","អង្គារ","ពុធ","ព្រហស.","សុក្រ","សៅរ៍"],longhand:["អាទិត្យ","ចន្ទ","អង្គារ","ពុធ","ព្រហស្បតិ៍","សុក្រ","សៅរ៍"]},months:{shorthand:["មករា","កុម្ភះ","មីនា","មេសា","ឧសភា","មិថុនា","កក្កដា","សីហា","កញ្ញា","តុលា","វិច្ឆិកា","ធ្នូ"],longhand:["មករា","កុម្ភះ","មីនា","មេសា","ឧសភា","មិថុនា","កក្កដា","សីហា","កញ្ញា","តុលា","វិច្ឆិកា","ធ្នូ"]},ordinal:function(){return""},firstDayOfWeek:1,rangeSeparator:" ដល់ ",weekAbbreviation:"សប្តាហ៍",scrollTitle:"រំកិលដើម្បីបង្កើន",toggleTitle:"ចុចដើម្បីផ្លាស់ប្ដូរ",yearAriaLabel:"ឆ្នាំ",time_24hr:!0};Ce.l10ns.km=be,Ce.l10ns;var Ie=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},V={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:"Жыл"};Ie.l10ns.kz=V,Ie.l10ns;var j=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},P={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};j.l10ns.lt=P,j.l10ns;var F=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Y={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};F.l10ns.lv=Y,F.l10ns;var Z=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},re={weekdays:{shorthand:["Не","По","Вт","Ср","Че","Пе","Са"],longhand:["Недела","Понеделник","Вторник","Среда","Четврток","Петок","Сабота"]},months:{shorthand:["Јан","Фев","Мар","Апр","Мај","Јун","Јул","Авг","Сеп","Окт","Ное","Дек"],longhand:["Јануари","Февруари","Март","Април","Мај","Јуни","Јули","Август","Септември","Октомври","Ноември","Декември"]},firstDayOfWeek:1,weekAbbreviation:"Нед.",rangeSeparator:" до ",time_24hr:!0};Z.l10ns.mk=re,Z.l10ns;var ke=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},He={firstDayOfWeek:1,weekdays:{shorthand:["Да","Мя","Лх","Пү","Ба","Бя","Ня"],longhand:["Даваа","Мягмар","Лхагва","Пүрэв","Баасан","Бямба","Ням"]},months:{shorthand:["1-р сар","2-р сар","3-р сар","4-р сар","5-р сар","6-р сар","7-р сар","8-р сар","9-р сар","10-р сар","11-р сар","12-р сар"],longhand:["Нэгдүгээр сар","Хоёрдугаар сар","Гуравдугаар сар","Дөрөвдүгээр сар","Тавдугаар сар","Зургаадугаар сар","Долдугаар сар","Наймдугаар сар","Есдүгээр сар","Аравдугаар сар","Арваннэгдүгээр сар","Арванхоёрдугаар сар"]},rangeSeparator:"-с ",time_24hr:!0};ke.l10ns.mn=He,ke.l10ns;var Re=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ze={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""}};Re.l10ns;var lt=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},at={weekdays:{shorthand:["နွေ","လာ","ဂါ","ဟူး","ကြာ","သော","နေ"],longhand:["တနင်္ဂနွေ","တနင်္လာ","အင်္ဂါ","ဗုဒ္ဓဟူး","ကြာသပတေး","သောကြာ","စနေ"]},months:{shorthand:["ဇန်","ဖေ","မတ်","ပြီ","မေ","ဇွန်","လိုင်","သြ","စက်","အောက်","နို","ဒီ"],longhand:["ဇန်နဝါရီ","ဖေဖော်ဝါရီ","မတ်","ဧပြီ","မေ","ဇွန်","ဇူလိုင်","သြဂုတ်","စက်တင်ဘာ","အောက်တိုဘာ","နိုဝင်ဘာ","ဒီဇင်ဘာ"]},firstDayOfWeek:1,ordinal:function(){return""},time_24hr:!0};lt.l10ns.my=at,lt.l10ns;var Gt=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},os={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(Ae){return Ae===1||Ae===8||Ae>=20?"ste":"de"}};Gt.l10ns.nl=os,Gt.l10ns;var ls=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},cs={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"."}};ls.l10ns.nn=cs,ls.l10ns;var ds=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},us={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"."}};ds.l10ns.no=us,ds.l10ns;var fs=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ms={weekdays:{shorthand:["ਐਤ","ਸੋਮ","ਮੰਗਲ","ਬੁੱਧ","ਵੀਰ","ਸ਼ੁੱਕਰ","ਸ਼ਨਿੱਚਰ"],longhand:["ਐਤਵਾਰ","ਸੋਮਵਾਰ","ਮੰਗਲਵਾਰ","ਬੁੱਧਵਾਰ","ਵੀਰਵਾਰ","ਸ਼ੁੱਕਰਵਾਰ","ਸ਼ਨਿੱਚਰਵਾਰ"]},months:{shorthand:["ਜਨ","ਫ਼ਰ","ਮਾਰ","ਅਪ੍ਰੈ","ਮਈ","ਜੂਨ","ਜੁਲਾ","ਅਗ","ਸਤੰ","ਅਕ","ਨਵੰ","ਦਸੰ"],longhand:["ਜਨਵਰੀ","ਫ਼ਰਵਰੀ","ਮਾਰਚ","ਅਪ੍ਰੈਲ","ਮਈ","ਜੂਨ","ਜੁਲਾਈ","ਅਗਸਤ","ਸਤੰਬਰ","ਅਕਤੂਬਰ","ਨਵੰਬਰ","ਦਸੰਬਰ"]},time_24hr:!0};fs.l10ns.pa=ms,fs.l10ns;var hs=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ps={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"."}};hs.l10ns.pl=ps,hs.l10ns;var gs=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Cs={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};gs.l10ns.pt=Cs,gs.l10ns;var ws=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},xs={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""}};ws.l10ns.ro=xs,ws.l10ns;var vs=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},bs={weekdays:{shorthand:["Вс","Пн","Вт","Ср","Чт","Пт","Сб"],longhand:["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"]},months:{shorthand:["Янв","Фев","Март","Апр","Май","Июнь","Июль","Авг","Сен","Окт","Ноя","Дек"],longhand:["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Нед.",scrollTitle:"Прокрутите для увеличения",toggleTitle:"Нажмите для переключения",amPM:["ДП","ПП"],yearAriaLabel:"Год",time_24hr:!0};vs.l10ns.ru=bs,vs.l10ns;var Ss=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},ys={weekdays:{shorthand:["ඉ","ස","අ","බ","බ්ර","සි","සෙ"],longhand:["ඉරිදා","සඳුදා","අඟහරුවාදා","බදාදා","බ්රහස්පතින්දා","සිකුරාදා","සෙනසුරාදා"]},months:{shorthand:["ජන","පෙබ","මාර්","අප්රේ","මැයි","ජුනි","ජූලි","අගෝ","සැප්","ඔක්","නොවැ","දෙසැ"],longhand:["ජනවාරි","පෙබරවාරි","මාර්තු","අප්රේල්","මැයි","ජුනි","ජූලි","අගෝස්තු","සැප්තැම්බර්","ඔක්තෝබර්","නොවැම්බර්","දෙසැම්බර්"]},time_24hr:!0};Ss.l10ns.si=ys,Ss.l10ns;var Ds=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ms={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"."}};Ds.l10ns.sk=Ms,Ds.l10ns;var Ts=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Es={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"."}};Ts.l10ns.sl=Es,Ts.l10ns;var As=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ns={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};As.l10ns.sq=Ns,As.l10ns;var ks=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},js={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};ks.l10ns.sr=js,ks.l10ns;var Is=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ls={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"."}};Is.l10ns.sv=Ls,Is.l10ns;var Ps=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Rs={weekdays:{shorthand:["อา","จ","อ","พ","พฤ","ศ","ส"],longhand:["อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัสบดี","ศุกร์","เสาร์"]},months:{shorthand:["ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค."],longhand:["มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม"]},firstDayOfWeek:1,rangeSeparator:" ถึง ",scrollTitle:"เลื่อนเพื่อเพิ่มหรือลด",toggleTitle:"คลิกเพื่อเปลี่ยน",time_24hr:!0,ordinal:function(){return""}};Ps.l10ns.th=Rs,Ps.l10ns;var Fs=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Os={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};Fs.l10ns.tr=Os,Fs.l10ns;var _s=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Vs={firstDayOfWeek:1,weekdays:{shorthand:["Нд","Пн","Вт","Ср","Чт","Пт","Сб"],longhand:["Неділя","Понеділок","Вівторок","Середа","Четвер","П'ятниця","Субота"]},months:{shorthand:["Січ","Лют","Бер","Кві","Тра","Чер","Лип","Сер","Вер","Жов","Лис","Гру"],longhand:["Січень","Лютий","Березень","Квітень","Травень","Червень","Липень","Серпень","Вересень","Жовтень","Листопад","Грудень"]},time_24hr:!0};_s.l10ns.uk=Vs,_s.l10ns;var Us=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Hs={weekdays:{shorthand:["Якш","Душ","Сеш","Чор","Пай","Жум","Шан"],longhand:["Якшанба","Душанба","Сешанба","Чоршанба","Пайшанба","Жума","Шанба"]},months:{shorthand:["Янв","Фев","Мар","Апр","Май","Июн","Июл","Авг","Сен","Окт","Ноя","Дек"],longhand:["Январ","Феврал","Март","Апрел","Май","Июн","Июл","Август","Сентябр","Октябр","Ноябр","Декабр"]},firstDayOfWeek:1,ordinal:function(){return""},rangeSeparator:" — ",weekAbbreviation:"Ҳафта",scrollTitle:"Катталаштириш учун айлантиринг",toggleTitle:"Ўтиш учун босинг",amPM:["AM","PM"],yearAriaLabel:"Йил",time_24hr:!0};Us.l10ns.uz=Hs,Us.l10ns;var Bs=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Gs={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};Bs.l10ns.uz_latn=Gs,Bs.l10ns;var zs=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ws={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 "};zs.l10ns.vn=Ws,zs.l10ns;var $s=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Js={weekdays:{shorthand:["周日","周一","周二","周三","周四","周五","周六"],longhand:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},months:{shorthand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],longhand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},rangeSeparator:" 至 ",weekAbbreviation:"周",scrollTitle:"滚动切换",toggleTitle:"点击切换 12/24 小时时制"};$s.l10ns.zh=Js,$s.l10ns;var Ks=typeof window<"u"&&window.flatpickr!==void 0?window.flatpickr:{l10ns:{}},Ys={weekdays:{shorthand:["週日","週一","週二","週三","週四","週五","週六"],longhand:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},months:{shorthand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],longhand:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},rangeSeparator:" 至 ",weekAbbreviation:"週",scrollTitle:"滾動切換",toggleTitle:"點擊切換 12/24 小時時制"};Ks.l10ns.zh_tw=Ys,Ks.l10ns;var Do={ar:i,at:c,az:f,be:h,bg:b,bn:x,bs:p,ca:v,ckb:k,cat:v,cs:N,cy:R,da:A,de:O,default:s({},L),en:L,eo:$,es:U,et:G,fa:ne,fi:xe,fo:_,fr:le,gr:ue,he:Q,hi:B,hr:ae,hu:he,hy:De,id:ie,is:Je,it:_e,ja:Ze,ka:X,ko:ve,km:be,kz:V,lt:P,lv:Y,mk:re,mn:He,ms:ze,my:at,nl:os,nn:cs,no:us,pa:ms,pl:ps,pt:Cs,ro:xs,ru:bs,si:ys,sk:Ms,sl:Es,sq:Ns,sr:js,sv:Ls,th:Rs,tr:Os,uk:Vs,vn:Ws,zh:Js,zh_tw:Ys,uz:Hs,uz_latn:Gs};n.default=Do,Object.defineProperty(n,"__esModule",{value:!0})}))})(At,At.exports)),At.exports}var ol=il();const ll=br(ol);var $t={exports:{}},cl=$t.exports,ta;function dl(){return ta||(ta=1,(function(e,t){(function(n,s){e.exports=s()})(cl,(function(){var n=function(){return n=Object.assign||function(f){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)&&(f[p]=u[p])}return f},n.apply(this,arguments)},s=function(l,f,u){return u.months[f?"shorthand":"longhand"][l]};function a(l){for(;l.firstChild;)l.removeChild(l.firstChild)}function i(l){try{if(typeof l.composedPath=="function"){var f=l.composedPath();return f[0]}return l.target}catch{return l.target}}var o={shorthand:!1,dateFormat:"F Y",altFormat:"F Y",theme:"light"};function c(l){var f=n(n({},o),l);return function(u){u.config.dateFormat=f.dateFormat,u.config.altFormat=f.altFormat;var h={monthsContainer:null};function m(){if(u.rContainer){a(u.rContainer);for(var E=0;E<u.monthElements.length;E++){var A=u.monthElements[E];A.parentNode&&A.parentNode.removeChild(A)}}}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-"+f.theme))}function g(){if(h.monthsContainer){a(h.monthsContainer);for(var E=document.createDocumentFragment(),A=0;A<12;A++){var I=u.createDay("flatpickr-monthSelect-month",new Date(u.currentYear,A),0,A);I.dateObj.getMonth()===new Date().getMonth()&&I.dateObj.getFullYear()===new Date().getFullYear()&&I.classList.add("today"),I.textContent=s(A,f.shorthand,u.l10n),I.addEventListener("click",w),E.appendChild(I)}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 b(){u._bind(u.prevMonthNav,"click",function(E){E.preventDefault(),E.stopPropagation(),u.changeYear(u.currentYear-1),x(),g()}),u._bind(u.nextMonthNav,"click",function(E){E.preventDefault(),E.stopPropagation(),u.changeYear(u.currentYear+1),x(),g()}),u._bind(h.monthsContainer,"mouseover",function(E){u.config.mode==="range"&&u.onMouseOver(i(E),"flatpickr-monthSelect-month")})}function C(){if(u.rContainer&&u.selectedDates.length){for(var E=u.rContainer.querySelectorAll(".flatpickr-monthSelect-month.selected"),A=0;A<E.length;A++)E[A].classList.remove("selected");var I=u.selectedDates[0].getMonth(),O=u.rContainer.querySelector(".flatpickr-monthSelect-month:nth-child("+(I+1)+")");O&&O.classList.add("selected")}}function x(){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 A=u.rContainer.querySelectorAll(".flatpickr-monthSelect-month");A.forEach(function(I){I.dateObj.setFullYear(u.currentYear),u.config.minDate&&I.dateObj<u.config.minDate||u.config.maxDate&&I.dateObj>u.config.maxDate?I.classList.add("flatpickr-disabled"):I.classList.remove("flatpickr-disabled")})}C()}function w(E){E.preventDefault(),E.stopPropagation();var A=i(E);if(A instanceof Element&&!A.classList.contains("flatpickr-disabled")&&!A.classList.contains("notAllowed")&&(v(A.dateObj),u.config.closeOnSelect)){var I=u.config.mode==="single",O=u.config.mode==="range"&&u.selectedDates.length===2;(I||O)&&u.close()}}function v(E){var A=new Date(u.currentYear,E.getMonth(),E.getDate()),I=[];switch(u.config.mode){case"single":I=[A];break;case"multiple":I.push(A);break;case"range":u.selectedDates.length===2?I=[A]:(I=u.selectedDates.concat([A]),I.sort(function(O,L){return O.getTime()-L.getTime()}));break}u.setDate(I,!0),C()}var S={37:-1,39:1,40:3,38:-3};function k(E,A,I,O){var L=S[O.keyCode]!==void 0;if(!(!L&&O.keyCode!==13)&&!(!u.rContainer||!h.monthsContainer)){var W=u.rContainer.querySelector(".flatpickr-monthSelect-month.selected"),$=Array.prototype.indexOf.call(h.monthsContainer.children,document.activeElement);if($===-1){var q=W||h.monthsContainer.firstElementChild;q.focus(),$=q.$i}L?h.monthsContainer.children[(12+$+S[O.keyCode])%12].focus():O.keyCode===13&&h.monthsContainer.contains(document.activeElement)&&v(document.activeElement.dateObj)}}function T(){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 N(){f._stubbedCurrentMonth=u._initialDate.getMonth(),u._initialDate.setMonth(f._stubbedCurrentMonth),u.currentMonth=f._stubbedCurrentMonth}function D(){f._stubbedCurrentMonth&&(u._initialDate.setMonth(f._stubbedCurrentMonth),u.currentMonth=f._stubbedCurrentMonth,delete f._stubbedCurrentMonth)}function R(){if(h.monthsContainer!==null)for(var E=h.monthsContainer.querySelectorAll(".flatpickr-monthSelect-month"),A=0;A<E.length;A++)E[A].removeEventListener("click",w)}return{onParseConfig:function(){u.config.enableTime=!1},onValueUpdate:C,onKeyDown:k,onReady:[N,m,p,b,C,function(){u.config.onClose.push(T),u.loadedPlugins.push("monthSelect")}],onDestroy:[D,R,function(){u.config.onClose=u.config.onClose.filter(function(E){return E!==T})}]}}}return c}))})($t)),$t.exports}var ul=dl();const fl=br(ul),na=(e,t,n,s,a=!1,i)=>{const o={...ll[s]},c=fl;a&&(o.firstDayOfWeek=1);const l=new Date(e);l.setHours(0,0,0,0);const f=new Date(t);f.setHours(23,59,59,999);const u={minDate:n===ee.CalendarResolution.MONTH?new Date(e.getFullYear(),e.getMonth()):l,maxDate:n===ee.CalendarResolution.MONTH?new Date(t.getFullYear(),t.getMonth()):f,locale:o};return n===ee.CalendarResolution.MONTH?{...u,dateFormat:"M Y",plugins:[new c({shorthand:!0,dateFormat:"M Y"})]}:{...u,monthSelectorType:"static",dateFormat:i||"d.m.Y"}},sa=e=>{e?.setMinutes(e.getMinutes()-e.getTimezoneOffset())},ml={year:"numeric",month:"short",day:"numeric"},tn=(e,t)=>e?.toLocaleDateString(t,ml)||"",hl=(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 a=n?new Date(Math.max(n.getTime(),t.startPeriod.getTime())):t.startPeriod,i=s?new Date(Math.min(s.getTime(),t.endPeriod.getTime())):t.endPeriod;return{startPeriod:a,endPeriod:i}},pl=(e,t)=>{const{endPeriod:n}=e,s=n?.getFullYear()||new Date().getFullYear(),a=s+ +t,i=new Date(+t<0?s:a,n?.getMonth()||0,n?.getDate()||1),o=new Date(+t<0?a:s,0,1);return{startPeriod:new Date(Math.max(o.getTime(),e?.startPeriod?.getTime()||0)),endPeriod:i}},gl=e=>({quarterly:e?.quarterly||"Q",monthly:e?.monthly||"M"}),Sr=(e,t)=>{const n=gl(t);return y.isQuarterly(e)&&n?.quarterly?e?.replace(/Q/g,n?.quarterly):y.isMonthly(e)&&n?.monthly?e?.replace(/M/g,n?.monthly):e},Cl=(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},aa=e=>{if(!e?.length)return null;let t=null,n=null;for(const s of e){const a=s.filters?.find(l=>l.componentCode===y.TIME_PERIOD);if(!a)continue;const i=a.values.filter(Boolean),o=i[0]?ee.getTimePeriod(i[0]):null,c=i[1]?ee.getTimePeriod(i[1]):null;!o||!c||((!t||o<t)&&(t=o),(!n||c>n)&&(n=c))}return t&&n?{startPeriod:t,endPeriod:n}:null};var et=(e=>(e.FLAT_LIST="FLAT_LIST",e.HIERARCHY="HIERARCHY",e))(et||{});const yr=(e,t,n,s,a)=>e?.map(i=>{const o=y.findCodelistByDimension(t?.codelists,t?.conceptSchemes,i)?.codes,c=y.getAvailableCodes(i,n,o,s),l=o?.some(f=>f?.parent);return{id:i?.id,title:y.getDimensionTitle(t?.conceptSchemes,i,s),dimensionValues:c,isTimeDimension:i?.type===y.DimensionType.TIME_DIMENSION,isHierarchical:l,displayMode:l?et.HIERARCHY:et.FLAT_LIST,datasetUrn:a,filterType:"dataset"}})||[],Jt=e=>e?.filterType==="shared",$e=e=>{if(e?.id)return Jt(e)?`shared:${e.id}`:e?.datasetUrn?`${e.datasetUrn}:${e.id}`:e.id},Pe=(e,t)=>$e(e)===$e(t),nn=(e,t)=>e?.map(n=>t&&Pe(n,t)?{...t,isSelectedFilter:!0}:{...n,isSelectedFilter:!1}),Dr=(e,t,n)=>e?e.map(s=>Pe(s,t)?{...s,displayMode:n}:s):[],Mr=e=>e?.filter(t=>!!t?.isSelectedValue)||[],cn=e=>e?.map(t=>({...t,dimensionValues:Mr(t?.dimensionValues)})).filter(t=>t.dimensionValues?.length||t.timeRange?.startPeriod||t.timeRange?.endPeriod),Bn=e=>e?.reduce((t,n)=>(n?.dimensionValues?.length??0)+t,0)||0,Tr=e=>({...e,dimensionValues:e?.dimensionValues?.map(t=>({...t,isSelectedValue:!1})),timeRange:void 0}),Er=(e,t)=>e?.map(n=>Pe(n,t)?Tr(n):n),Ar=e=>e?.map(t=>Tr(t)),Nr=(e,t,n)=>e.map(s=>{const a=t?.filters?.find(o=>o.componentCode===s.id);let i=[];if(a)if(s.isTimeDimension){const o=a.values.filter(h=>!!h),c=y.getAnnotationPeriod(n?.[0]?.annotations),l=o[0]?ee.getTimePeriod(o[0]):null,f=o[1]?ee.getTimePeriod(o[1]):null;let u=c;return l&&f&&(u=c?hl({startPeriod:l,endPeriod:f},c):{startPeriod:l,endPeriod:f}),{...s,timeRange:u}}else i=s?.dimensionValues?.map(c=>a?.values?.includes(c.id)?{...c,isSelectedValue:!0}:c);else i=s.dimensionValues;return{...s,dimensionValues:i}}),sn=e=>e?.map(t=>({...t,isDisabled:!0})),wl=e=>new Map(e?.map(t=>[t.id,{...t,children:[]}])),xl=e=>{if(!e)return[];const t=wl(e),n=[];return e.forEach(s=>{if(s&&s.parent){const a=t.get(s.parent),i=t.get(s.id);a&&a.children&&i&&(a.children=[...a.children,i])}else{const a=t.get(s.id);a&&n.push(a)}}),n},vl=(e,t=!1)=>t?`${e*M.TREE_NODE_PADDING-M.TREE_NODE_ARROW_SIZE}px`:`${e*M.TREE_NODE_PADDING}px`,kr=e=>e?.children?.reduce((t,n)=>[...t,n,...kr(n)],[])||[],bl=(e,t)=>e?e.filter(n=>!n.disabled).map(n=>({...n,isSelectedValue:t})):[],jr=e=>!!e?.children?.some(t=>t?.isSelectedValue||jr(t)),Sl=e=>{const t=kr(e);if(!e.children?.length)return[{...e,isSelectedValue:!e.isSelectedValue}];const n=(c,l)=>[{...e,isSelectedValue:c},...bl(t,l)];if(!e.isSelectableValue)return e.isSelectedValue?n(!1,!1):n(!0,!0);const s=t.filter(c=>!c.disabled),a=s.some(c=>c.isSelectedValue),i=s.length>0&&s.every(c=>c.isSelectedValue),o=!!e.isSelectedValue;return!o&&!a?n(!0,!0):o&&i?n(!1,!0):!o&&a?n(!0,!1):o&&!a?n(!1,!1):n(!0,!0)},yl=(e,t)=>e.filter(n=>n.isSelectableValue&&!t.has(n.id)).map(n=>({id:n.id,name:n.name,isSelectedValue:n.isSelectedValue})),Dl=({isHierarchical:e,availableHierarchies:t,titles:n})=>[{key:"",title:n?.flatList??"Flat list"},...e?[{key:et.HIERARCHY,title:n?.hierarchy??"Hierarchy by parent"}]:[],...(t??[]).map(s=>({key:s.id,title:`${s.name??s.id} (${s.version})`}))],Ml=({calendarResolution:e,timeRange:t,timeRangeOptions:n,calendarStartFromMonday:s=!0,locale:a=ee.Locale.EN,radioIcon:i,initialConstraints:o,onValueChange:c,calendarIcon:l,dateFormat:f,defaultTimeOption:u,dataQueries:h})=>{const{titles:m}=ye(),p=Cl(y.getAnnotationPeriod(o?.[0]?.annotations),t),b=!!!(p?.startPeriod||p?.endPeriod)&&!t?aa(h):null,C=b??p,[x,w]=d.useState(t??b),v=!t||t?.startPeriod?.getTime()===C?.startPeriod?.getTime()&&t?.endPeriod?.getTime()===C?.endPeriod?.getTime()?0:ee.CUSTOM_PERIOD,[S,k]=d.useState(u??v),T=d.useMemo(()=>{const{startPeriod:A,endPeriod:I}=C,O=A?.getFullYear(),L=I?.getFullYear(),W=new Date().getFullYear();return n.filter($=>$.value===ee.CUSTOM_PERIOD||$.value===0||+$.value>=0&&L-W>=+$.value||+$.value<0&&O-W<+$.value)},[C,n]);d.useEffect(()=>{c(x,S)},[x]),d.useEffect(()=>{if(t!==null)return;const A=y.getAnnotationPeriod(o?.[0]?.annotations);A?.startPeriod||A?.endPeriod||w(aa(h))},[t]);const N=A=>{A&&(sa(A),w(I=>I?{...I,startPeriod:A||null}:{endPeriod:null,startPeriod:A||null}))},D=A=>{A&&(sa(A),w(I=>I?{...I,endPeriod:A||null}:{startPeriod:null,endPeriod:A||null}))};if(C==null)return null;const R=na(C.startPeriod,x?.endPeriod||C.endPeriod,e,a,s,f),E=na(x?.startPeriod||C.startPeriod,C.endPeriod,e,a,s,f);return r.jsxs("div",{className:"mt-3 flex h-full min-w-0 flex-1 flex-col overflow-auto py-2 pr-3",children:[r.jsx("div",{className:"w-full",children:T.map(A=>r.jsx(M.Radio,{id:A.value.toString(),checked:S===A.value,label:A.title,onChange:()=>{const{value:I}=A;k(I),I!==ee.CUSTOM_PERIOD&&w(I===0?C:pl(C,I))},radioIcon:i},A.value.toString()))}),r.jsx("div",{className:"w-full",children:S===ee.CUSTOM_PERIOD&&r.jsxs("div",{className:"filters-time-period caption mt-3 flex gap-4 text-neutral-700",children:[r.jsx(M.Calendar,{onChange:N,options:R,value:x?.startPeriod||C?.startPeriod,label:m?.from||"From",id:"time-options-start",icon:l}),r.jsx(M.Calendar,{onChange:D,options:E,value:x?.endPeriod||C?.endPeriod,label:m?.to||"To",id:"time-options-end",icon:l,isEndDate:!0})]})})]})},Tl={isMetadataInSidePanel:!1,isCrossDatasetModeOn:!1,isTableSettingsFeatureEnabled:!1},Ir=d.createContext(Tl);function El({children:e,isMetadataInSidePanel:t=!1,isCrossDatasetModeOn:n=!1,isTableSettingsFeatureEnabled:s=!1}){const a=d.useMemo(()=>({isMetadataInSidePanel:t,isCrossDatasetModeOn:n,isTableSettingsFeatureEnabled:s}),[t,n,s]);return r.jsx(Ir.Provider,{value:a,children:e})}function Be(){return d.useContext(Ir)}const Al=2,Lr=({value:e,onChange:t,searchIconSize:n})=>{const{titles:s}=ye(),{isCrossDatasetModeOn:a}=Be(),[i,o]=d.useState(!1),c=e.trim().toLowerCase(),l=a&&i&&c.length<Al;return r.jsxs(r.Fragment,{children:[r.jsx(M.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:()=>o(!0),onBlur:()=>o(!1),iconBeforeInput:r.jsx(Ve.IconSearch,{width:n,height:n,className:"text-primary"})}),a&&r.jsx("span",{className:z("caption text-neutrals-800 mt-1",{invisible:!l}),children:s?.searchMinCharsCaption??"Enter at least 2 characters to start searching"})]})},Nl=e=>Te.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Te.createElement("path",{d:"M6.25 4.66668L9.75 8.00001L6.25 11.3333L6.25 4.66668Z",fill:"currentColor"})),Pr=({node:e,level:t=1,checkboxIcon:n,selectFilterValue:s,selectHierarchicalNodes:a,expandHierarchicalValue:i})=>{const o=!!e?.children?.length,c=o&&!e.isSelectedValue&&jr(e),l="cursor-pointer text-neutrals-1000 w-6 h-6 shrink-0",f=d.useId(),u=(h,m)=>{if(e?.children?.length){const p=e.children.some(g=>!g.disabled);a?.(p?Sl(e):[{...e,isSelectedValue:m}])}else s?.(e.id,m)};return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"flex items-center",style:{paddingLeft:vl(t,o)},children:[o&&(e?.isExpanded?r.jsx(Nl,{className:l,onClick:()=>i?.(e)}):r.jsx(Hn,{className:l,onClick:()=>i?.(e)})),r.jsx(M.Checkbox,{id:f,label:e?.name,checked:!!e.isSelectedValue,indeterminate:c,checkboxIcon:n,disabled:e?.disabled,onChange:u})]}),o&&e?.isExpanded&&r.jsx(r.Fragment,{children:e?.children?.map(h=>r.jsx(Pr,{node:h,level:t+1,checkboxIcon:n,selectFilterValue:s,selectHierarchicalNodes:a,expandHierarchicalValue:i},h?.id))})]},e?.id)},kl=({treeNodes:e,checkboxIcon:t,selectFilterValue:n,selectHierarchicalNodes:s,expandHierarchicalValue:a})=>r.jsx(r.Fragment,{children:e?.map(i=>r.jsx(Pr,{node:i,checkboxIcon:t,selectFilterValue:n,selectHierarchicalNodes:s,expandHierarchicalValue:a},i?.id))}),ra=({style:e,filterValue:t,checkboxIcon:n,selectFilterValue:s})=>r.jsx("div",{style:e,children:r.jsx(M.Checkbox,{id:t.id,label:t.name,checked:!!t.isSelectedValue,checkboxIcon:n,onChange:s})}),Kt=(e,t,n,s,a=ee.Locale.EN)=>{const i=t?.map(o=>{const c=y.findCodelistByDimension(n?.codelists,n?.conceptSchemes,o),l=y.getAvailableCodesFromConstrains(c?.codes,o.id,s,a);return{...o,dimensionValues:l}});return e?.map(o=>{const c=i?.find(m=>m.id===o.id),f=(c?.dimensionValues||[]).map(m=>{const p=o.dimensionValues?.find(g=>g?.id===m?.id)?.isSelectedValue;return{...m,isSelectedValue:p}}),u=new Set(f.map(m=>m.id)),h=c?(o.dimensionValues??[]).filter(m=>!!m.isSelectedValue&&!u.has(m.id)):[];return{...o,isDisabled:!1,dimensionValues:[...f,...h]}})||[]},jn=(e,t,n)=>{let s=[];return dn(e,t,n).filter(a=>a.timeRange||a.dimensionValues?.some(i=>i.isSelectedValue)).forEach(a=>{const{id:i,dimensionValues:o}=a;a.isTimeDimension?s=[...s,...jl(a.timeRange,i)]:s.push({componentCode:i,operator:y.SeriesFilterOperator.EQUALS,value:o?.filter(c=>c.isSelectedValue)?.map(c=>c.id).join(y.GET_v3_FILTER_AND)||""})}),s},jl=(e,t)=>e==null||e.startPeriod==null||e.endPeriod==null?[]:[{componentCode:t,operator:y.SeriesFilterOperator.GREATER_OR_EQUAL,value:ia(new Date(e.startPeriod))},{componentCode:t,operator:y.SeriesFilterOperator.LESS_OR_EQUAL,value:ia(new Date(e.endPeriod),1)}],Il=1e3*60*60*24,ia=(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?Il-1:0,e=new Date(n),n.toString()},jt=e=>[...e].map(t=>({...t,value:t.value.split(",").sort().join(",")})).sort((t,n)=>t.componentCode.localeCompare(n.componentCode)),Nt=new Map,Yt=new Map;function Rr(e,t){return`${e.name??""}::${t}`}function nt(...e){return JSON.stringify(e)}async function st(e,t,n){const s=Rr(e,t);if(Nt.has(s))return Nt.get(s);const a=Yt.get(s);if(a)return a;const i=n().then(o=>(Nt.set(s,o),o)).finally(()=>{Yt.delete(s)});return Yt.set(s,i),i}function In(e,t){return Nt.has(Rr(e,t))}function oa(){Nt.clear(),Yt.clear()}const Ll=e=>e.map(t=>({componentCode:t.id||"",operator:ee.QueryFilterType.IN,values:t.dimensionValues?.map(n=>n.id)||[]})),Fr=(e,t)=>{const n=t?.timeDimensions?.[0],s=y.getTimeRangeFromAttachment(e,n)||null;return s?y.getQueryTimePeriodFilters(s,n?.id):null},Or=(e,t,n)=>{const s=cn(dn(e,n)),a=s.find(i=>i?.isTimeDimension&&i?.timeRange);return{filterKey:y.getTimeSeriesFilterKey(t||[],Ll(s)),timeFilter:y.getQueryTimePeriodFilters(a?.timeRange,a?.id)}},Pl=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}`},Rl=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}`},_r=(e,t,n=Pl)=>dn(e,t)?.filter(s=>s.timeRange||s.isExcluded||s.dimensionValues?.some(a=>a.isSelectedValue)).map(s=>s?.isTimeDimension?{componentCode:s?.id,operator:ee.QueryFilterType.BETWEEN,values:[n(s?.timeRange?.startPeriod||void 0)||"",n(s?.timeRange?.endPeriod||void 0)||""]}:s.isExcluded?{componentCode:s?.id,operator:ee.QueryFilterType.EXCLUDED,values:[]}:{componentCode:s?.id,operator:ee.QueryFilterType.IN,values:s?.dimensionValues?.filter(a=>a.isSelectedValue)?.map(a=>a.id)||[]}),Fl=(e,t)=>{const n=dn(e,t).flatMap(a=>a.id?[a.id]:[]),s=e.flatMap(a=>{if(a.filterType!=="shared")return[];const i=a.sourceFilterIdsByDataset?.[t];return i?[i]:[]});return new Set([...n,...s])},Ol=(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:ee.QueryFilterType.IN,values:[y.GET_v3_FILTER_ALL]}))},Vr=(e,t)=>{const n=_l(t,e.urn),s=Fl(t,e.urn),a=Ol(s,n),i=(e.filters??[]).filter(o=>!s.has(o.componentCode));return{...e,filters:[...i,...n,...a]}},Ur=(e,t)=>_r(e,t),_l=(e,t)=>_r(e,t,Rl),Hr="COUNTRY",Br="FREQUENCY",wt="TIME_PERIOD",Vl=new Set([Hr,Br,wt]),qt=e=>e?.trim()?.toLocaleUpperCase(),la=()=>(e,t)=>{const n=e?.name?.trim()?.toLocaleLowerCase();return n?Ul(n):Hl(t||"",e.id)},Ul=e=>`name:${e}`,Hl=(e,t)=>`dataset:${e}:id:${t}`,Gr=(e,t)=>e?t?.[e]:void 0,ca=(e,t)=>{if(!(e?.filterType!=="dataset"||!e.id))return Gr(e.datasetUrn,t)?.[e.id]},zr=(e,t,n)=>Object.entries(Gr(e,n)||{}).find(([,s])=>t(s))?.[0],Wr=(e,t,n)=>zr(e,s=>s.subtype===t,n),Bl=(e,t)=>zr(e,n=>n.dimensionType==="TIME_PERIOD",t),vt=[{id:Hr,subtype:"REGION",getMergedValueKey:la()},{id:Br,subtype:"FREQUENCY",getMergedValueKey:la()},{id:wt,getMergedValueKey:e=>e.id}],Gl=new Map(vt.map(e=>[e.id,e])),Gn=e=>e?Gl.get(qt(e)||""):void 0,zl=(e,t,n)=>{if(e.filterType==="shared")return t.id===qt(e.id);if(t.id===wt)return e.isTimeDimension||ca(e,n)?.dimensionType==="TIME_PERIOD"||t.id===qt(e.id);const s=ca(e,n);return t.subtype&&s?.subtype===t.subtype?!0:t.id===qt(e.id)},an=(e,t)=>e?vt.find(n=>zl(e,n,t)):void 0,Wl=(e,t,n)=>{if(!t)return;const s=e?n?.[e]?.[t]:void 0;return s?.dimensionType==="TIME_PERIOD"?wt:vt.find(i=>!!i.subtype&&i.subtype===s?.subtype)?.id??Gn(t)?.id},$l=e=>!!Gn(e),Jl=e=>e?.filterType==="shared"&&$l(e?.id),$r=(e,t)=>!e||Array.isArray(e.get(t)),Jr=(e,t)=>!e?.dataMessagesMap||e.dataMessagesMap.has(t),Kl=(e,t)=>{const n=new Map;return e.forEach(s=>{s.dimensionValues?.forEach(a=>{const i=t.getMergedValueKey(a,s.datasetUrn),o={datasetUrn:s.datasetUrn,id:a.id,name:a.name,parent:a.parent},c=n.get(i);if(c){c.isSelectedValue=c.isSelectedValue||a.isSelectedValue,c.sourceValues=[...c.sourceValues||[],o];return}n.set(i,{id:i,name:a.name,isSelectedValue:a.isSelectedValue,parent:a.parent,sourceValues:[o]})})}),Array.from(n.values())},Kr=(e,t)=>{const n=new Map,s=[];return e.forEach(i=>{const o=an(i,t);if(o&&i?.datasetUrn){const c=n.get(o.id)||[];n.set(o.id,[...c,i]);return}s.push(i)}),[...vt.flatMap(i=>{const o=n.get(i.id);if(!o?.length)return[];const c={...o[0],id:i.id,datasetUrn:void 0,filterType:"shared",sourceDatasetUrns:Array.from(new Set(o.map(l=>l.datasetUrn).filter(l=>!!l))),sourceFilterIdsByDataset:Object.fromEntries(o.flatMap(l=>l.datasetUrn&&l.id?[[l.datasetUrn,l.id]]:[])),dimensionValues:Kl(o,i)};return c.isTimeDimension&&(c.timeRange=Ql(o)),c}),...s]},zn=(e,t,n)=>{const s=e.sourceFilterIdsByDataset?.[t];if(s)return s;if(e.id===wt)return Bl(t,n);const a=Gn(e.id);return a?.subtype?Wr(t,a.subtype,n):void 0},Yr=(e,t,n,s)=>({...e,id:zn(e,t,s)||e.id,datasetUrn:t,filterType:"dataset",...n?{dimensionValues:n}:{}}),Yl=(e,t)=>(e.sourceDatasetUrns||[]).map(n=>Yr(e,n,void 0,t)),ql=(e,t)=>({id:t.id,name:t.name,parent:t.parent,isSelectedValue:e.isSelectedValue}),Zl=(e,t)=>{const n=new Map;return e.dimensionValues?.forEach(s=>{s.sourceValues?.forEach(a=>{const i=a.datasetUrn||"",o=n.get(i),c=ql(s,a);if(o){o.dimensionValues=[...o.dimensionValues||[],c];return}n.set(i,Yr(e,i,[c],t))})}),n},Xl=(e,t=!1,n)=>{if(!Jl(e))return[e];if(e.isTimeDimension)return Yl(e,n);const s=Zl(e,n);return Array.from(s.values())},Ql=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())))}},qr=(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)},ec=(e,t)=>{if(!e.isTimeDimension||!e.timeRange)return e;const{startPeriod:n,endPeriod:s}=y.getAnnotationPeriod(t?.[0]?.annotations);return!n||!s?e:{...e,timeRange:qr(e.timeRange.startPeriod,e.timeRange.endPeriod,n,s)}},tc=(e,t)=>e?.dimensionsMap?new Map(Array.from(e.dimensionsMap.entries()).map(([n,s])=>[n,yr(s,e?.structuresMap?.get(n),e?.structureDimensionsMap?.get(n),t,n)])):new Map,nc=(e,t,n=!0)=>new Map(Array.from(e?.dimensionsMap?.entries()||[]).map(([s,a])=>{const i=$r(e?.constraintsMap,s),o=Jr(e,s),c=a?.map(l=>{if(!i||n&&!o)return{...l,dimensionValues:[]};const f=y.findCodelistByDimension(e?.structuresMap?.get(s)?.codelists,e?.structuresMap?.get(s)?.conceptSchemes,l),u=y.getAvailableCodesFromConstrains(f?.codes,l.id,e?.constraintsMap?.get(s),t);return{...l,dimensionValues:u}})||[];return[s,c]})),sc=e=>e.map(t=>({...t,isDisabled:!1,dimensionValues:t.dimensionValues?.filter(n=>n.isSelectedValue)||[]})),Zr=(e,t,n=!0)=>{const s=tc(e,t),a=nc(e,t,n);return new Map(Array.from(s?.entries()||[]).map(([i,o])=>{const c=a?.get(i),l=o.map(f=>({...f,dimensionValues:c?.find(u=>u.id===f.id)?.dimensionValues||[]}));return[i,l]}))},Xr=(e,t,n,s)=>{const a=(i,o)=>t?.some(c=>c.urn!==i.urn&&c.filters?.some(l=>l.operator===ee.QueryFilterType.BETWEEN||!l.values?.length?!1:an({id:l.componentCode,datasetUrn:c.urn,filterType:"dataset"},s)?.id===o.id))??!1;return Kr(t?.flatMap(i=>{const o=i?.urn,c=e?.get(o)||[],l=n?.get(o)||[];return Nr(c,i,l).map(u=>{if(u.isTimeDimension||u.filterType!=="dataset")return u;const h=an(u,s);return!h||h.id===wt||i.filters?.some(g=>g.componentCode===u.id&&g.operator!==ee.QueryFilterType.BETWEEN)||!a(i,h)||u.dimensionValues?.some(g=>g.isSelectedValue)?u:{...u,dimensionValues:u.dimensionValues?.map(g=>({...g,isSelectedValue:!0}))}})})||[],s)},kt=(e,t,n=!1,s,a=new Set)=>{const i=e?.flatMap(o=>Xl(o,n,s))?.reduce((o,c)=>{const l=c?.datasetUrn||"",f=ec(c,t?.get(l));return o.has(l)||o.set(l,[]),o?.get(l)?.push(f),o},new Map);if(a.size>0)for(const o of a)i.delete(o);return i},Qr=(e,t,n,s,a)=>{const i=e.filter(c=>c.filterType==="shared"&&!c.isTimeDimension&&(c.dimensionValues?.some(l=>l.isSelectedValue)??!1));if(!i.length)return new Set(t);const o=(c,l)=>{const f=zn(l,c,s);if(!f)return!1;if(a)return!(a.get(c)??[]).find(p=>p.id===f);const u=n?.find(h=>h.urn===c);return u?!u.filters?.some(h=>h.componentCode===f&&h.operator!==ee.QueryFilterType.BETWEEN):!1};return new Set(t.filter(c=>i.every(l=>l.dimensionValues?.some(f=>f.isSelectedValue&&f.sourceValues?.some(u=>u.datasetUrn===c))||o(c,l))))},da=(e,t)=>t?(e||[]).filter(n=>t.has(n.urn)):e||[],yt=(e,t)=>t?new Map([...e].filter(([n])=>t.has(n))):e,ei=(e,t)=>{const n=new Map;if(e?.forEach(s=>{s.filters?.forEach(a=>{if(a.operator===ee.QueryFilterType.BETWEEN||!a.values?.length)return;const i=an({id:a.componentCode,datasetUrn:s.urn,filterType:"dataset"},t);if(!i||i.id===wt)return;const o=n.get(i.id)??new Set;o.add(s.urn),n.set(i.id,o)})}),!!n.size)return e?.filter(s=>Array.from(n.values()).every(a=>a.has(s.urn))).map(s=>s.urn)??[]},ac=(e,t)=>t?Array.from(new Set(e?.flatMap(n=>n.cubeRegions?.filter(s=>s.isIncluded).flatMap(s=>s.memberSelection?.filter(a=>a.componentId===t).flatMap(a=>a.selectionValues.map(i=>i.memberValue))??[])??[])??[])):[],rc=(e,t,n)=>{if(e.length<2||!t)return e;const s=e.flatMap(o=>vt.flatMap(c=>{if(!c.subtype)return[];const l=Wr(o.urn,c.subtype,n);return l?[{configId:c.id,dataQuery:o,dimensionId:l,filter:o.filters?.find(f=>f.componentCode===l&&f.operator!==ee.QueryFilterType.BETWEEN),availableValues:ac(t.get(o.urn),l)}]:[]})),a=new Map;s.forEach(o=>{a.set(o.configId,[...a.get(o.configId)??[],o])});const i=new Map;return a.forEach(o=>{const c=o.filter(u=>u.filter?.values?.length),l=o.filter(u=>!u.filter);if(!c.length||!l.length)return;const f=new Set(l.flatMap(u=>u.availableValues));f.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(f).filter(g=>m.has(g))]));p.length>h.values.length&&i.set(h,p)})}),i.size?e.map(o=>{let c=!1;const l=o.filters?.map(f=>{const u=i.get(f);return u?(c=!0,{...f,values:u}):f});return c?{...o,filters:l}:o}):e},ti=e=>JSON.stringify(e?.map(t=>({urn:t.urn,filters:t.filters??[]}))??[]),Dt=(e,t,n=ee.Locale.EN,s)=>{const a=[];return Array.from(e?.entries())?.forEach(([i,o])=>{const c=t?.dimensionsMap?.get(i),l=t?.structuresMap?.get(i),f=$r(t?.constraintsMap,i),u=Jr(t,i);if(!f||!u){a.push(...sc(o));return}const h=t?.constraintsMap?.get(i);a.push(...Kt(o,c,l,h,n))}),Kr(a,s)},dn=(e,t,n)=>t?kt(e,void 0,!1,n).get(t)||[]:e.filter(s=>s.filterType!=="shared"),ni=(e,t)=>{if(e?.filterType==="shared")return;const n=e?.datasetUrn?t?.get(e.datasetUrn)?.dataflows?.[0]:void 0;return n?y.generateShortUrn(n?.name,"",n?.agencyID):void 0},ic=(e,t)=>e?.length?!!t?.dimensionsMap&&!!t?.structuresMap&&!!t?.structureDimensionsMap&&!!t?.constraintsMap:!1,si=(e,t,n)=>jt(jn(t,e,n).filter(s=>s.componentCode!==y.TIME_PERIOD)),ua=(e,t,n,s,a)=>e?.map(i=>{const o=i?.urn??"",c=a??t?.get(o)??[],l=si(o,c,s);return n?st(n.getConstraints,nt(o,l),()=>n.getConstraints(o,l)).then(f=>({urn:o,data:f})):Promise.resolve({urn:o,data:{}})})||[],fa=(e,t,n,s,a)=>!n?.getConstraints||!e?.length?!1:e.some(i=>{const o=i?.urn??"",c=a??t?.get(o)??[],l=si(o,c,s);return!In(n.getConstraints,nt(o,l))}),oc=(e,t,n)=>{if(e.length<2)return!1;const s=new Map;for(const a of e){const i=t.dimensionsMap?.get(a.urn);if(i)for(const o of i){const c=o.id;if(!c)continue;const l=n?.[a.urn]?.[c],f=l?.subtype;if(!f||l?.dimensionType==="TIME_PERIOD")continue;const u=vt.find(p=>p.subtype===f);if(!u)continue;const h=s.get(u.id)??{datasetsWithExplicitValues:new Set,datasetsWithMissingFilter:new Set},m=a.filters?.find(p=>p.componentCode===c&&p.operator!==ee.QueryFilterType.BETWEEN);m?m.values?.length&&h.datasetsWithExplicitValues.add(a.urn):h.datasetsWithMissingFilter.add(a.urn),s.set(u.id,h)}}return[...s.values()].some(a=>[...a.datasetsWithMissingFilter].some(i=>[...a.datasetsWithExplicitValues].some(o=>o!==i)))},lc=e=>new Map(e?.flatMap(({urn:t,data:n})=>{const s=n?.data?.dataConstraints;return Array.isArray(s)?[[t,s]]:[]})),ma=e=>lc(e.flatMap(t=>t.status==="fulfilled"?[t.value]:[])),ha=(e,t)=>{const n=new Map(e);return t.forEach((s,a)=>{n.set(a,s)}),n},ai=(e,t,n,s)=>{if(e&&t?.filterType==="shared"&&t?.isTimeDimension){const i=Array.from(s?.values()||[]).flatMap(l=>l||[]).map(l=>y.getAnnotationPeriod(l?.annotations)).filter(l=>l.startPeriod!==null&&l.endPeriod!==null);if(!i.length)return[];const o=new Date(Math.min(...i.map(l=>l.startPeriod.getTime()))),c=new Date(Math.max(...i.map(l=>l.endPeriod.getTime())));return[{id:t.id||y.TIME_PERIOD,annotations:[{id:y.TIME_PERIOD_START_ANNOTATION_KEY,title:o.toISOString()},{id:y.TIME_PERIOD_END_ANNOTATION_KEY,title:c.toISOString()}]}]}return e?s?.get(t?.datasetUrn??"")??[]:n??[]},ri=(e,t,n)=>new Map(t?.map(s=>{const a=s?.urn;return[a,Or(e.get(a)||[],n?.get(a))]})),pa=(e,t,n,s,a)=>{const i=oc(e,t,a);if(!n||!e.length||!i)return;const o={...t,constraintsMap:n},c=Zr(o,s,!1),l=Xr(c,e,n,a),f=kt(l,n,!1,a),u=Qr(l,e.map(m=>m.urn),e,a,f),h=e.filter(m=>u.has(m.urn));return{compatibleUrns:u,filterParamsMap:ri(f,h,t.dimensionsMap)}},ii=(e,t)=>new Map(e?.map(n=>{const s=n?.urn;return[s,Ur(t?.get(s)||[])]})),cc=(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 a=s.map(c=>y.getAnnotationPeriod(n.get(c)?.[0]?.annotations)).filter(c=>!!c?.startPeriod&&!!c?.endPeriod);if(a.length===0)return[{...e,sourceDatasetUrns:s}];const i=new Date(Math.min(...a.map(c=>c.startPeriod.getTime()))),o=new Date(Math.max(...a.map(c=>c.endPeriod.getTime())));return[{...e,sourceDatasetUrns:s,timeRange:qr(e.timeRange.startPeriod,e.timeRange.endPeriod,i,o)}]},dc=(e,t,n)=>t.size===0?e:e.flatMap(s=>{if(s.filterType!=="shared")return[s];if(s.isTimeDimension)return cc(s,t,n);const a=(s.dimensionValues??[]).filter(i=>i.sourceValues?.some(o=>!t.has(o.datasetUrn??"")));return a.length===0?[]:[{...s,dimensionValues:a}]}),Wn=e=>Te.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Te.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"})),uc=e=>Te.createElement("svg",{viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Te.createElement("path",{d:"M6.66663 6.175L10.4833 10L6.66663 13.825L7.84163 15L12.8416 10L7.84163 5L6.66663 6.175Z",fill:"currentColor"})),fc=Eo.FixedSizeList,ga=24,Ca=232,yn=({selectedFilter:e,filterValues:t,checkboxIcon:n,isHierarchicalView:s,isVirtualized:a=!0,isScrollable:i=!0,isDisableValues:o,isValuesLoading:c,structuresMap:l,hierarchyTreeNodes:f,isHierarchyLoading:u,selectFilterValue:h,selectHierarchicalNodes:m,expandHierarchicalValue:p})=>{const g=M.useIsMobile(),{isCrossDatasetModeOn:b}=Be(),C=c||u;if(!t&&!C)return null;const x=t??[],w=e?ni(e,l):void 0,v=l?.size===1,S=b&&e?.filterType!=="shared"&&!!e?.title&&(v||!!w),k=x.length*ga,T=k>Ca?Ca:k;return r.jsxs("div",{className:z("relative",o&&"pointer-events-none opacity-[0.7]",i?"flex h-full min-h-0 flex-col":"flex flex-col"),children:[S&&r.jsxs("div",{className:"mb-2 flex items-center gap-x-1",children:[!v&&r.jsxs(r.Fragment,{children:[r.jsx(Wn,{className:"size-4 shrink-0 text-neutrals-700"}),r.jsx("span",{className:"h4 text-neutrals-800",children:w}),r.jsx(uc,{className:"size-4 shrink-0 text-neutrals-1000"})]}),r.jsx("span",{className:"h4 text-neutrals-1000",children:e?.title})]}),C&&r.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 min-h-12",children:r.jsx(M.Loader,{})}),r.jsx("div",{className:z(i?"min-h-0 flex-1 overflow-auto":"overflow-visible",C&&"pointer-events-none opacity-[0.7]"),style:i&&g&&!C?{height:`${T}px`}:void 0,children:f?.length||s?r.jsx(kl,{treeNodes:f??xl(x),checkboxIcon:n,selectFilterValue:h,selectHierarchicalNodes:m,expandHierarchicalValue:p}):a?r.jsx(Ao,{children:({width:N,height:D})=>r.jsx(fc,{itemCount:x.length,itemSize:ga,width:N,height:D,children:({index:R,style:E})=>r.jsx(ra,{style:E,filterValue:x[R],checkboxIcon:n,selectFilterValue:h})})}):r.jsx("div",{className:"flex flex-col gap-y-1",children:x.map(N=>r.jsx(ra,{filterValue:N,checkboxIcon:n,selectFilterValue:h},N.id))})})]})};function mc(e,t){const n=(e??"").split(".").map(Number),s=(t??"").split(".").map(Number),a=Math.max(n.length,s.length);for(let i=0;i<a;i++){const o=(n[i]??0)-(s[i]??0);if(o!==0)return o}return 0}function hc(e){const t=new Map;for(const n of e){const s=`${n.agencyID??""}:${n.id}`,a=t.get(s);(!a||mc(n.version??"",a.version??"")>0)&&t.set(s,n)}return Array.from(t.values())}function wa(e){return y.generateShortUrn(e.id,e.version??"",e.agencyID??"")}function xa(e,t,n,s,a){const i=y.getHierarchyCodes(e,t),o=y.getHierarchyAvailableCodes(i,n,s),c=y.getCodeListsData(t),l=pc(e,c,o.map(f=>f.id),a);return li(l)}function oi(e,t,n,s,a){return s?.map(i=>{const{childId:o,agency:c,id:l,version:f}=y.getChildParsedUrn(i.code),u=y.generateShortUrn(l,f,c),h=Object.keys(e??{}).find(v=>y.urnMatchesIgnoreVersion(v,u))??u,p=e?.[h]?.find(v=>v.id===o),g=p?.name||p?.description||o,b=n?y.urnMatchesIgnoreVersion(u,n):!0,C=!b&&(i.hierarchicalCodes?.length??0)>0,x=oi(e,t,n,i.hierarchicalCodes,i.code),w=x.length===0;return C&&w||b&&w&&t&&!t.includes(o??"")?null:{id:i.code,name:g,children:x,isExpanded:!0,disabled:!b&&x.every(v=>v.disabled),isSelectableValue:b,parent:a,metadata:{...i,hierarchicalCodes:void 0}}}).filter(i=>i!==null)??[]}function pc(e,t,n,s){return!n||n.length===0?[]:oi(t,n,s,e?.hierarchicalCodes,void 0)}function li(e){return e.map(t=>{const{childId:n}=y.getChildParsedUrn(t.id??"");return{id:n??t.id??"",name:t.name,isExpanded:t.isExpanded,isSelectedValue:!1,disabled:t.disabled,isSelectableValue:t.isSelectableValue,children:li(t.children)}})}function ci(e,t){return e?.filterType!=="shared"?t:e.dimensionValues?.find(n=>n.id===t||n.sourceValues?.some(s=>s.id===t))?.id}function gc(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 Cc(e,t){if(!e?.length||t?.filterType!=="shared")return e??[];const n=new Map;return e.forEach(s=>{const a=ci(t,s.id);a&&n.set(a,{...s,id:a})}),Array.from(n.values())}function wc(e,t){return ci(t,e)}function di(e,t){return e.map(n=>{const s=n.children?.length?di(n.children,t):n.children;let a;if(t.has(n.id))a=!0;else if(s?.length&&!n.isSelectableValue){const i=s.filter(o=>!o.disabled);a=i.length>0&&i.every(o=>!!o.isSelectedValue)}else a=!1;return{...n,isSelectedValue:a,children:s}})}function ui(e,t){return e.map(n=>n.id===t?{...n,isExpanded:!n.isExpanded}:n.children?.length?{...n,children:ui(n.children,t)}:n)}function fi(e,t){const n=t.toLowerCase();return e.reduce((s,a)=>{const i=a.name?.toLowerCase().includes(n),o=fi(a.children??[],t);return(i||o.length>0)&&s.push({...a,isExpanded:!0,children:i?a.children:o}),s},[])}const mi=d.createContext(null);function xc({children:e,value:t}){return r.jsx(mi.Provider,{value:t,children:e})}function hi(){const e=d.useContext(mi);if(!e)throw new Error("useFiltersModal must be used within FiltersModalProvider");return e}const vc=2,pi=({filtersList:e,selectedFilter:t,initialConstraints:n,structuresMap:s,selectedTimeOption:a,hierarchyState:i})=>{const{titles:o}=ye(),{locale:c,isDisableValues:l,isValuesLoading:f,timeRangeOptions:u,filterValuesProps:h,dataQueries:m,selectFilterValue:p,selectHierarchicalNodes:g,expandHierarchicalValue:b,onTimePeriodChange:C}=hi(),[x,w]=d.useState(""),{isCrossDatasetModeOn:v}=Be(),S=t?.displayMode===et.HIERARCHY,k=$e(t),T=t?.filterType==="shared",N=x?.trim().toLowerCase(),D=v?N.length>=vc:!!N,R=D&&v&&!T,E=d.useCallback(U=>{if(!U?.dimensionValues)return{filterValues:[],matchedCount:0};const J=U.dimensionValues.filter(G=>G?.name?.toLowerCase()?.includes(N));return{filterValues:U.displayMode===et.HIERARCHY?y.getFilteredItemsWithParents(U.dimensionValues,J):J,matchedCount:J.length}},[N]),A=d.useMemo(()=>D?E(t).filterValues:t?.dimensionValues,[D,E,t]),I=d.useMemo(()=>R?(e||[]).reduce((U,J)=>{if(Pe(J,t)||J.filterType==="shared")return U;const{filterValues:G,matchedCount:te}=E(J);return te?[...U,{filter:J,filterValues:G,matchedCount:te,isHierarchicalView:J.displayMode===et.HIERARCHY}]:U},[]):[],[R,e,t,E]),O=d.useMemo(()=>{const U=i?.treeNodes;if(!U?.length)return U;const J=gc(t),G=J.size?di(U,J):U;return D?fi(G,N):G},[i?.treeNodes,t,D,N]),L=O?!O.length:!A?.length,W=!!f||!!i?.isLoading,$=d.useMemo(()=>I.reduce((U,J)=>U+J.matchedCount,0),[I]);d.useEffect(()=>{w("")},[k]);const q=d.useCallback(U=>{w(U)},[w]);return r.jsx(r.Fragment,{children:t?.isTimeDimension&&n?r.jsx(Ml,{initialConstraints:n,calendarResolution:ee.CalendarResolution.DAY,timeRange:t?.timeRange||null,timeRangeOptions:u||[],calendarStartFromMonday:!0,locale:c,radioIcon:h?.radioIcon,onValueChange:C,calendarIcon:h?.calendarIcon,dateFormat:h?.dateFormat,defaultTimeOption:a,dataQueries:m}):r.jsxs("div",{className:z("flex flex-col py-2 h-full flex-1 min-w-0 sm:border-0","filter-values-container"),children:[r.jsx(Lr,{value:x,onChange:q,searchIconSize:h?.searchIconSize}),r.jsx("div",{className:"body-2 mt-3 flex min-h-0 flex-1 flex-col overflow-auto",children:R?r.jsxs(r.Fragment,{children:[t&&r.jsxs("div",{className:"shrink-0 pb-4",children:[r.jsx(yn,{selectedFilter:t,filterValues:A,checkboxIcon:h?.checkboxIcon,isHierarchicalView:S,isVirtualized:!1,isScrollable:!1,isDisableValues:l,isValuesLoading:f,structuresMap:s,hierarchyTreeNodes:O,isHierarchyLoading:i?.isLoading,selectFilterValue:p,selectHierarchicalNodes:g,expandHierarchicalValue:b}),!W&&L&&r.jsx("span",{className:"body-2 text-neutrals-700",children:o?.noResultsInSection?.(t.title??"")??`No results found in ${t.title??""}`})]}),r.jsxs("div",{className:"pb-3",children:[r.jsxs("span",{className:"h2 text-neutrals-1000",children:[o?.otherResults??"Other results",":"," ",$]}),!f&&$===0&&r.jsx("p",{className:"body-2 mt-1 text-neutrals-700",children:o?.noResultsInOtherDimensions??"No results found in other dimensions"})]}),I.map(({filter:U,filterValues:J,isHierarchicalView:G})=>r.jsx("div",{className:"shrink-0 pb-4 last:pb-0",children:r.jsx(yn,{selectedFilter:U,filterValues:J,checkboxIcon:h?.checkboxIcon,isHierarchicalView:G,isVirtualized:!1,isScrollable:!1,isDisableValues:l,isValuesLoading:f,structuresMap:s,selectFilterValue:(te,ne)=>p(te,ne,U),selectHierarchicalNodes:te=>g(te,U),expandHierarchicalValue:te=>b(te,U)})},$e(U)))]}):r.jsx(yn,{selectedFilter:t,filterValues:A,checkboxIcon:h?.checkboxIcon,isHierarchicalView:S,isDisableValues:l,isValuesLoading:f,structuresMap:s,hierarchyTreeNodes:O,isHierarchyLoading:i?.isLoading,selectFilterValue:p,selectHierarchicalNodes:g,expandHierarchicalValue:b})})]})})},bc=({filtersList:e,filter:t,onSelectFilter:n,onSelectDisplayMode:s,onDeleteFilter:a,initialConstraints:i,hideFacetCounterByDefault:o,hierarchyState:c})=>{const{titles:l}=ye(),{locale:f,onSelectHierarchy:u}=hi(),h=M.useIsMobile(),[m,p]=d.useState(0),[g,b]=d.useState(!1),C=t?.isTimeDimension&&t?.timeRange,x=d.useMemo(()=>t?.timeRange?.startPeriod&&t?.timeRange?.endPeriod?`${tn(t?.timeRange?.startPeriod,f)} -
|
|
6
|
+
${tn(t?.timeRange?.endPeriod,f)}`:"",[f,t?.timeRange]);d.useEffect(()=>{p(Mr(t?.dimensionValues)?.length)},[t?.dimensionValues]);const w=o?m>0:!0,v=d.useMemo(()=>Dl({isHierarchical:t?.isHierarchical,availableHierarchies:c?.availableHierarchies,titles:l}),[t?.isHierarchical,c?.availableHierarchies,l]),S=c?.isLoading||!t?.isHierarchical&&!c?.availableHierarchies?.length;d.useEffect(()=>{t.isSelectedFilter||b(!1)},[t.isSelectedFilter]);const k=()=>{h&&b(N=>!N),n(t)},T=N=>{if(N==="")u?.(t,null),s?.(t,et.FLAT_LIST);else if(N===et.HIERARCHY)u?.(t,null),s?.(t,et.HIERARCHY);else{const D=c?.availableHierarchies?.find(R=>R.id===N)??null;u?.(t,D)}};return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:z("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:k,children:[r.jsxs("h3",{className:"w-full min-w-0 flex-1 truncate sm:flex sm:items-center",title:t?.title,children:[r.jsx("span",{className:"truncate",children:t?.title}),h&&r.jsx(Hn,{className:z("chevron-icon w-6 h-6 shrink-0",g&&"rotate-180")})]}),r.jsxs("div",{className:"ml-2 flex items-center gap-2 text-neutrals-800",children:[C&&r.jsx("span",{className:"filters-facet-item-counter border-none",children:x}),!C&&w&&r.jsx("span",{className:z("px-2 text-center","filters-facet-item-counter"),children:m?`${m}/${t?.dimensionValues?.length||0}`:l?.all||"All"}),C?null:r.jsxs("div",{className:"filters-facet-item-settings flex items-center gap-2",children:[r.jsx(M.Dropdown,{triggerButton:r.jsx(M.IconButton,{buttonClassName:z("text-button-tertiary w-4 h-4 border-0 p-0","filters-facet-item-icon"),icon:r.jsx(al,{width:16,height:16}),title:l?.displayOrder||"Display Order",disabled:S}),disabled:S,options:v,selectedOption:c?.selectedHierarchy?.id??(t?.displayMode===et.HIERARCHY?et.HIERARCHY:""),onOptionSelect:T}),m>0&&r.jsx(M.IconButton,{buttonClassName:z("text-button-tertiary w-4 h-4 border-0 p-0","filters-facet-item-icon"),icon:r.jsx(vr,{width:16,height:16}),title:l?.reset||"Reset",onClick:N=>{N.stopPropagation(),a?.(t)}})]})]})]}),g&&r.jsx(pi,{filtersList:e,selectedFilter:t,initialConstraints:i,hierarchyState:c})]})},Sc=new Set,yc=({filtersList:e,hideFacetCounterByDefault:t,onSelectFilter:n,onDeleteFilter:s,onSelectDisplayMode:a,initialConstraints:i,initialConstraintsMap:o,datasetIcon:c,structuresMap:l,hierarchyStateMap:f,dataQueries:u,disabledDatasetUrns:h=Sc,isDatasetFacetSelected:m=!1,onSelectDatasetFacet:p,onClearAllDatasets:g})=>{const{isCrossDatasetModeOn:b}=Be(),C=new Set(e.filter(x=>x.filterType==="dataset").map(x=>x.datasetUrn||"")).size;return r.jsxs("div",{className:z("overflow-y-auto advanced-view-filters-list min-w-[320px] max-w-[338px] pr-3 h-full sm:max-w-full sm:w-full"),children:[u&&u.length>0&&r.jsx(sl,{dataQueries:u,disabledDatasetUrns:h,isSelected:m,onSelect:p,onClearAll:g}),e.filter(x=>!(x.filterType==="dataset"&&x.datasetUrn&&h.has(x.datasetUrn))).map((x,w,v)=>{const S=v[w-1],T=x.filterType==="dataset"&&C>1&&x.datasetUrn!==S?.datasetUrn?ni(x,l):void 0;return r.jsxs("div",{className:"min-w-0 shrink-0",children:[T&&r.jsxs("h4",{className:"filters-facet-dataset-name !flex",children:[r.jsx("span",{className:"filters-facet-dataset-icon",children:c}),r.jsx("span",{className:"min-w-0 truncate",title:T,children:T})]}),r.jsx(bc,{filtersList:v,filter:x,onSelectFilter:n,onSelectDisplayMode:a,onDeleteFilter:s,hideFacetCounterByDefault:t,initialConstraints:ai(b,x,i,o),hierarchyState:f?.get($e(x)??"")})]},$e(x))})]})},Dc=({dataQueries:e,disabledDatasetUrns:t,onToggleDataset:n,searchIconSize:s})=>{const[a,i]=d.useState(""),o=a.trim().toLowerCase(),c=e.filter(f=>o.length<2||(f.title??f.urn).toLowerCase().includes(o)),l=e.length-t.size;return r.jsxs("div",{className:"filter-values-container flex h-full min-w-0 flex-1 flex-col py-2 sm:border-0",children:[r.jsx(Lr,{value:a,onChange:i,searchIconSize:s}),r.jsx("div",{className:"body-2 mt-3 flex min-h-0 flex-1 flex-col overflow-auto",children:c.map(f=>{const u=!t.has(f.urn),h=u&&l===1;return r.jsx("div",{className:z("py-1",h&&"pointer-events-none"),children:r.jsx(M.Checkbox,{id:f.urn,label:f.title??f.urn,checked:u,disabled:h,disabledScope:"icon",onChange:(m,p)=>n(f.urn,!!p)})},f.urn)})})]})},gi=({filtersList:e,selectedFilter:t,modalProps:n,locale:s,isDisableValues:a,isValuesLoading:i,timeSeriesCount:o,timeRangeOptions:c,initialConstraints:l,initialConstraintsMap:f,datasetIcon:u,structuresMap:h,setSelectedFilter:m,onSelectDisplayMode:p,onDeleteFilter:g,onClearAllFilters:b,updateSelectedFilterValues:C,onTimePeriodChange:x,selectedTimeOption:w,hierarchyStateMap:v,onSelectHierarchy:S,onExpandHierarchyNode:k,dataQueries:T,disabledDatasetUrns:N,onToggleDataset:D,onClearAllDatasets:R})=>{const{titles:E}=ye(),A=v?.get($e(t)),I=M.useIsMobile(),{isCrossDatasetModeOn:O}=Be(),[L,W]=d.useState(!1),$=d.useMemo(()=>dc(e.filter(_=>!(_.filterType==="dataset"&&_.datasetUrn&&N.has(_.datasetUrn))),N,f),[e,N,f]),q=d.useMemo(()=>t?$.find(_=>Pe(_,t)):void 0,[t,$]),U=Bn(cn(e))+N.size,J=d.useCallback(()=>{W(!0),m(void 0)},[m]),G=d.useCallback(_=>{W(!1);const K=e?.find(le=>Pe(le,_));if(!K){m(void 0);return}m({...K,isSelectedFilter:!0})},[e,m]),te=_=>_?e?.find(K=>Pe(K,_)):void 0,ne=(_,K,le)=>{const de=!le||Pe(le,t),ue=te(le??t)??le??t;if(!ue)return;const se=Jt(ue)?wc(_,ue):_;if(!se)return;const Q={...ue,dimensionValues:ue?.dimensionValues?.map(H=>H?.id===se?{...H,isSelectedValue:K}:H)};de&&m(Q),C&&C(Q)},fe=(_,K)=>{const le=!K||Pe(K,t),de=te(K??t)??K??t;if(!de)return;const ue=Jt(de)?Cc(_,de):_??[],se=new Set(de?.dimensionValues?.map(B=>B.id)),Q=Jt(de)?[]:yl(ue,se),H={...de,dimensionValues:[...de?.dimensionValues?.map(B=>{const oe=ue.find(ae=>ae?.id===B?.id);return oe?{...B,isSelectedValue:oe.isSelectedValue}:B})??[],...Q]};le&&m(H),C&&C(H)},xe=(_,K)=>{const le=!K||Pe(K,t),de=te(K??t)??K??t;if(!de||!_?.id)return;const ue=$e(de);if((ue?v?.get(ue):void 0)?.treeNodes?.length){k?.(ue,_.id);return}const Q={...de,dimensionValues:de?.dimensionValues?.map(H=>H?.id===_?.id?{...H,isExpanded:!_?.isExpanded}:H)};le&&m(Q),C&&C(Q)},me=(_,K)=>{if(!t)return;const le={...t,timeRange:_||void 0};x?.(K),m(le),C&&C(le)};return r.jsx(xc,{value:{locale:s,isDisableValues:a,isValuesLoading:i,timeRangeOptions:c,filterValuesProps:n?.filterValuesProps,dataQueries:T,onSelectHierarchy:S,selectFilterValue:ne,selectHierarchicalNodes:fe,expandHierarchicalValue:xe,onTimePeriodChange:me},children:r.jsxs("div",{className:z("flex flex-row gap-5 flex-1 min-h-0 sm:p-0","filters-settings"),children:[r.jsxs("div",{className:z("h-full sm:w-full",n?.isShowTimeSeriesCount&&"flex flex-col justify-between"),children:[O&&r.jsxs("div",{className:"mb-4 flex items-center justify-between gap-x-4",children:[r.jsxs("span",{className:"body-3 text-neutrals-900",children:[E?.appliedFilters??"Applied filters",":"," ",U]}),r.jsx(M.Button,{buttonClassName:"text-button-tertiary p-0",title:E?.clearAll??"Clear All",onClick:b,isSmallButton:I})]}),r.jsx(yc,{filtersList:$,hideFacetCounterByDefault:n?.isHideFacetCounterByDefault,onSelectFilter:G,onSelectDisplayMode:p,onDeleteFilter:g,initialConstraints:l,initialConstraintsMap:f,datasetIcon:u,structuresMap:h,hierarchyStateMap:v,dataQueries:T,disabledDatasetUrns:N,isDatasetFacetSelected:L,onSelectDatasetFacet:J,onClearAllDatasets:R}),n?.isShowTimeSeriesCount&&o?r.jsxs("h4",{className:"my-4 text-neutrals-800",children:[E?.timeSeries??"Timeseries",": ",o]}):null]}),!I&&(L?r.jsx(Dc,{dataQueries:T??[],disabledDatasetUrns:N,onToggleDataset:D,searchIconSize:n?.filterValuesProps?.searchIconSize}):r.jsx(pi,{filtersList:$,selectedFilter:q,structuresMap:h,initialConstraints:ai(O,t,l,f),selectedTimeOption:w,hierarchyState:A}))]})})},Mc=e=>{const t=e.filterType==="dataset"?[e.datasetUrn]:e.sourceDatasetUrns;return Array.from(new Set((t||[]).filter(n=>!!n)))},Tc=(e,t)=>{if(!t)return!1;const n=e.dataStructureComponents?.dimensionList;return[...n?.dimensions||[],...n?.timeDimensions||[]].some(a=>a.id===t)},Ln=e=>{if(!e.length||e.some(n=>!n))return;const t=Array.from(new Set(e));return t.length===1?t[0]:void 0},Ec=(e,t)=>{const n=t?.dataStructures||[];if(!n.length)return[];const s=n.filter(a=>Tc(a,e));return s.length?s:n.length===1?n:[]},Ac=e=>e.urn??y.generateShortUrn(e.id,e.version,e.agencyID),Ci=(e,t)=>Ln(Ec(e,t).map(Ac)),Nc=(e,t,n,s)=>{if(!e||!t)return;const a=n?.get(t)?.find(l=>l.id===e);if(!a)return;const i=y.getKeyFromUrn(a.localRepresentation?.enumeration);if(i)return i;const o=s?.get(t),c=y.findCodelistByDimension(o?.codelists,o?.conceptSchemes,a);return c?y.getKeyFromUrn(c.urn)??y.generateShortUrn(c.id,c.version,c.agencyID):void 0},kc=(e,t,n)=>{const s=Mc(e);return{codelistUrn:Ln(s.map(a=>Nc(e.id,a,t,n))),sourceArtefactUrn:Ln(s.map(a=>Ci(e.id,n?.get(a))))}},jc=({timeseriesLength:e=0,limitMessages:t})=>{const n=!e||M.SERIES_LIMIT>e;return r.jsx("div",{className:"body-3 flex items-center gap-x-[4px] text-neutrals-800 sm:justify-center sm:text-center",children:n?r.jsx("span",{children:t?.seriesCount?.(e)}):r.jsxs(r.Fragment,{children:[r.jsx("span",{children:t?.warningIcon}),r.jsx("span",{children:t?.counterLimit?.(e,M.SERIES_LIMIT)})]})})},wi=({modalProps:e,onApply:t,onClearAllFilters:n,onClose:s,applyDisabled:a,timeseriesLength:i,limitMessages:o})=>{const{titles:c}=ye(),l=M.useIsMobile(),f=e?.footerActionsPosition==="right",u=e?.isShowCancelButton,h=e?.isShowClearAllButton??!0,m=u?f?"justify-end":"justify-start":f?"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?f?"items-center gap-x-8":"justify-between":f?"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 r.jsxs("div",{className:z("flex py-4 px-6 modal-footer-wrapper",m),children:[!u&&r.jsx(jc,{timeseriesLength:i,limitMessages:o}),r.jsxs("div",{className:z("flex",p),children:[h&&r.jsx(M.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}),r.jsxs("div",{className:"flex items-center gap-x-3",children:[e?.isShowCancelButton?r.jsx(M.Button,{buttonClassName:"text-button-tertiary sm:h8",title:c?.cancel??"Cancel",onClick:s,isSmallButton:l}):null,r.jsx(M.Button,{buttonClassName:"advanced-view-filters-modal-apply-button",title:c?.apply??"Apply",onClick:t,isSmallButton:l,disabled:a})]})]})]})},Ic=e=>Te.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Te.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 Oe=(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))(Oe||{});const $n=["charts","chartsNavigation"],va=["dataGrid","metadataPerSeries",...$n,"openAdvancedView"],xi=["filters","chartPerSeries","metadataPerDataset","exitAdvancedView"],dt=(e,t)=>{const n=t?.[`${e}Title`],s=t?.[`${e}Description`];return{title:typeof n=="string"?n:"",description:typeof s=="string"?s:""}},Pn=(e,t)=>e.find(n=>!t.infoElements?.[n])||"",Lc=(e,t)=>{if(!e||!t)return"";if(va.includes(t)){const s=Pn(va,e);if(s)return s}const n=Pn(xi,e);return n||""},vi=(e,t)=>{const n=Pn(e,t);return{...t,infoElements:{...t?.infoElements,[t.lastDisplayedElement]:!1,...n?{[n]:!0}:{}},lastDisplayedElement:n}},bi=e=>vi(xi,e),Pc=e=>vi($n,e),Rc=e=>(!e?.infoElements?.charts||!e?.infoElements?.chartsNavigation)&&!$n.includes(e.lastDisplayedElement),it=5,Fc=({targetPosition:e,overlayClasses:t,onClose:n})=>r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"overlay overlay-top",style:{height:e.top,top:0-it,bottom:e.top+it}}),r.jsx("div",{className:"overlay overlay-bottom",style:{top:e.bottom+it,bottom:0}}),r.jsx("div",{className:"overlay overlay-left",style:{top:e.top-it,height:e.height+it*2,width:e.left,left:0-it,right:e.left-it*2}}),r.jsx("div",{className:"overlay overlay-right",style:{top:e.top-it,left:e.right+it,height:e.height+it*2,right:0}}),r.jsx("div",{className:z("outline-block z-10",t),onClick:n,style:{top:e.top,left:e.left,height:e.height,width:e.width}})]}),ut=({reference:e,title:t,description:n,onReferenceClick:s,shouldCloseTooltip:a,shouldMoveToNextStep:i,supressReferenceClick:o})=>{const[c,l]=d.useState(!0),[f,u]=d.useState(!1),h=d.useRef(null),{isShowOnboarding:m,onboardingFileSchema:p,setOnboardingFileSchema:g}=qe(),{refs:b,floatingStyles:C,context:x,placement:w}=Xe.useFloating({open:c,onOpenChange:l,placement:"right-start",elements:{reference:e?.current},middleware:[Xe.offset({mainAxis:12,crossAxis:-4}),Xe.flip(),Xe.shift(),Xe.arrow({element:h})],whileElementsMounted:Xe.autoUpdate}),v=Xe.useClick(x),{getFloatingProps:S}=Xe.useInteractions([v]),k=d.useCallback(()=>{if(m){const R=Lc(p,p?.lastDisplayedElement);g?.({...p,infoElements:{...p?.infoElements,...R?{[R]:!0}:{}},lastDisplayedElement:R})}l?.(!1)},[m,p,g]);d.useEffect(()=>{b.setReference(e?.current??null)},[e,b]);const T=()=>k(),N=e?.current?.getBoundingClientRect();d.useEffect(()=>{a&&!f&&(k(),u(!0))},[a,k,f]);const D=()=>{s?(s?.(),i?k():l(!1)):o||(k(),e?.current?.click())};return r.jsx(r.Fragment,{children:c&&r.jsxs(Xe.FloatingPortal,{children:[N&&r.jsx(Fc,{overlayClasses:o?"cursor-default":"cursor-pointer",targetPosition:N,onClose:D}),r.jsxs("div",{ref:b.setFloating,style:C,...S(),className:"tooltip z-tooltip max-w-[350px]",children:[r.jsxs("div",{className:"tooltip-header",children:[r.jsx("h3",{children:t}),r.jsx(M.CloseButton,{btnClassNames:"w-4 h-4",onClick:T})]}),r.jsx("div",{className:"tooltip-description",children:r.jsx("p",{children:n})}),r.jsx("div",{ref:h,className:z("tooltip-arrow absolute w-3 h-3 rotate-45",w?.includes("right")?"left-[-4px]":"right-[-6px]",w?.includes("end")?"bottom-2 tooltip-arrow-white":"top-3")})]})]})})},Si=({buttonProps:e,selectedFiltersCount:t=0,isLoading:n,setModalState:s,isModalClosed:a,warningIcon:i,filterIconClassName:o,timeSeriesCount:c})=>{const{titles:l}=ye(),f=d.useRef(null),[u,h]=d.useState(""),[m,p]=d.useState(""),[g,b]=d.useState(!1),{onboardingFileSchema:C,isShowOnboarding:x}=qe(),w=M.SERIES_LIMIT<(c??0),v=d.useMemo(()=>e?.isShowBadge?e?.title:`${e?.title}: ${t}`,[e?.isShowBadge,e?.title,t]);return d.useEffect(()=>{if(x){const{title:S,description:k}=dt(Oe.FILTERS,l);h(S),p(k)}},[l,x]),d.useEffect(()=>{x&&b(C?.lastDisplayedElement===Oe.FILTERS)},[C?.lastDisplayedElement,x]),r.jsx("div",{className:"filter-button-container relative",ref:f,children:n?r.jsx(M.Loader,{}):r.jsxs(r.Fragment,{children:[r.jsx(M.Button,{iconBefore:r.jsx(Ic,{className:z("size-4",o)}),iconAfter:w?i:void 0,title:v,buttonClassName:"text-button-secondary filter-button",isSmallButton:!0,onClick:()=>s(M.PopUpState.Opened)}),e?.isShowBadge&&r.jsx("div",{className:"filter-count-badge",children:r.jsx("h5",{children:t})}),g&&r.jsx(ut,{reference:f,title:u,description:m,onReferenceClick:()=>s(M.PopUpState.Opened),shouldCloseTooltip:a})]})})},ba=e=>{const t=[];return e.custom_content?.attachments&&t.push(...e.custom_content.attachments),t};function Jn(e){return e.type===we.AttachmentType.MARKDOWN&&e.title!=null&&e.title?.startsWith("URL Query")}function yi(e){return e.type===we.AttachmentType.JSON&&e.title!=null&&e.title?.startsWith("Query (JSON)")}function Di(e){return e.type===we.AttachmentType.MARKDOWN&&!Jn(e)}function Oc(e){return e.type===we.AttachmentType.CSV}function Kn(e){return e.type===we.AttachmentType.TABLE}function ct(e){return e.type===we.AttachmentType.CUSTOM_DATA_GRID}function Zt(e){return e.type===we.AttachmentType.CUSTOM_CHART}function _c(e){return e.type===we.AttachmentType.PLOTLY}function Yn(e){return e.type===we.AttachmentType.CUSTOM_CODE_SAMPLE}function mt(e){return e.type===we.AttachmentType.CROSS_DATASET_GRID}function Vc(e){return Kn(e)||ct(e)||mt(e)}const Uc=(e,t)=>e?.filter((n,s)=>n?.custom_content?.attachments&&s<t)?.at(-1),Mi=e=>e?.reduce((t,n,s)=>n?.custom_content?.attachments?.some(a=>yi(a))?s:t,-1),Hc=e=>e?.reduce((t,n)=>n?.role===je.Role.Assistant?n:t,{}),Bc=(e,t,n,s,a)=>({role:je.Role.System,content:"",custom_content:{attachments:n?.map(i=>{const o=e&&t?.urn===i?.urn?e:i?.filters;return{type:we.AttachmentType.JSON,title:i?.title,data:JSON.stringify({urn:i?.urn,metadata:i?.metadata,filters:a?a?.get(i?.urn):o,disabled:!!i?.disabled})}})||[],form_schema:s?.custom_content?.form_schema}}),Ti=(e,t,n,s,a)=>{if(!e)return[];const i=e.at(-1),o=i?.role===je.Role.System,c=o?i?.custom_content?.attachments?.find(u=>u.type==="text/markdown"&&u.data?.includes("```python")):void 0,l=o?e.slice(0,-1):e,f=Bc(s,a,t,Hc(l),n);return c&&f.custom_content&&(f.custom_content={...f.custom_content,attachments:[...f.custom_content.attachments??[],c]}),[...l,f]},Gc=(e,t,n,s)=>e?.map(a=>({...a,filters:n&&s?.urn===a?.urn?n:a?.filters}))||[],ft={availableHierarchies:[],selectedHierarchy:null,mainHierarchy:null,codelists:[],treeNodes:[],isLoading:!1},Ei=({getCodelistUrnForFilter:e,getConstraintsForFilter:t,getSourceArtefactUrn:n,getAvailableHierarchies:s,getHierarchy:a})=>{const[i,o]=d.useState(new Map),c=d.useCallback((m,p)=>{const g=$e(m);if(!g)return;const b=e(m),C=p??t(m);o(x=>{const w=x.get(g);if(!w?.mainHierarchy)return x;const v=xa(w.mainHierarchy,w.codelists,m.id??"",C,b),S=new Map(x);return S.set(g,{...w,treeNodes:v}),S})},[e,t]),l=d.useCallback(async m=>{if(!s)return;const p=e(m);if(!p)return;const g=$e(m);if(g){o(b=>{const C=new Map(b),x=b.get(g)??ft;return C.set(g,{...x,isLoading:!0}),C});try{const b=await s(p,n?.(m)),C=hc(b?.data?.hierarchies??[]);o(x=>{const w=new Map(x),v=x.get(g)??ft;return w.set(g,{...v,availableHierarchies:C,isLoading:!1}),w})}catch{o(b=>{const C=new Map(b),x=b.get(g)??ft;return C.set(g,{...x,isLoading:!1}),C})}}},[s,e,n]),f=d.useCallback(async(m,p)=>{if(!a)return;const g=$e(m);if(!g)return;const b=e(m);o(C=>{const x=new Map(C),w=C.get(g)??ft;return x.set(g,{...w,isLoading:!0}),x});try{const C=wa(p),x=await a(C,b),w=x?.data?.hierarchies?.find(k=>wa(k)===C);if(!w){o(k=>{const T=new Map(k),N=k.get(g)??ft;return T.set(g,{...N,selectedHierarchy:p,mainHierarchy:null,treeNodes:[],isLoading:!1}),T});return}const v=y.resolveCodelistsFromResponse(x?.data),S=xa(w,v,m.id??"",t(m),b);o(k=>{const T=new Map(k),N=k.get(g)??ft;return T.set(g,{...N,selectedHierarchy:p,mainHierarchy:w,codelists:v,treeNodes:S,isLoading:!1}),T})}catch{o(C=>{const x=new Map(C),w=C.get(g)??ft;return x.set(g,{...w,isLoading:!1}),x})}},[a,e,t]),u=d.useCallback((m,p)=>{if(!m)return;const g=$e(m);if(g){if(!p){o(b=>{const C=new Map(b),x=b.get(g)??ft;return C.set(g,{...x,selectedHierarchy:null,mainHierarchy:null,treeNodes:[]}),C});return}f(m,p)}},[f]),h=d.useCallback((m,p)=>{o(g=>{const b=g.get(m);if(!b?.treeNodes)return g;const C=new Map(g);return C.set(m,{...b,treeNodes:ui(b.treeNodes,p)}),C})},[]);return{hierarchyStateMap:i,rebuildHierarchyTree:c,loadAvailableHierarchies:l,onSelectHierarchy:u,onExpandHierarchyNode:h}},zc=(e,t,n,s,a)=>{const i=new Set;if(!t||e.isTimeDimension)return i;const o=e.dimensionValues?.filter(u=>u.isSelectedValue)??[];if(!o.length)return i;const c=y.findCodelistByDimension(n?.codelists,n?.conceptSchemes,t);if(!c?.codes?.length)return i;const l=new Set(c.codes.map(u=>u.id)),f=new Set(y.getAvailableCodesFromConstrains(c.codes,t.id,s,a).map(u=>u.id));return o.forEach(u=>{l.has(u.id)&&!f.has(u.id)&&i.add(u.id)}),i},Ai=(e,t,n,s,a,i)=>{let o=!1;const c=e.map(l=>{if(l.isTimeDimension||a&&l.id===a)return l;const f=t?.find(h=>h.id===l.id),u=zc(l,f,n,s,i);return u.size?(o=!0,{...l,dimensionValues:l.dimensionValues?.map(h=>u.has(h.id)?{...h,isSelectedValue:!1}:h)}):l});return{filters:o?c:e,changed:o}},Wc=(e,t,n,s,a,i)=>Ai(e,t,n,s,a?.id,i),$c=(e,t,n,s,a)=>{let i=!1;const o=new Map;return e.forEach((c,l)=>{const f=n?.filterType==="shared"?zn(n,l,a):n?.datasetUrn===l?n.id:void 0,u=Ai(c,t?.dimensionsMap?.get(l),t?.structuresMap?.get(l),t?.constraintsMap?.get(l),f,s);i=i||u.changed,o.set(l,u.filters)}),{filtersMap:i?o:e,changed:i}},Jc=new Set,Kc=({actions:e,dimensions:t,structureDimensions:n,structures:s,buttonProps:a,modalProps:i,attachmentsDataQuery:o,dataQueries:c,initialConstraints:l,onFiltersChange:f,locale:u,timeRangeOptions:h,conversationKey:m,conversation:p,setConversation:g,updateConversation:b,updateDataQueries:C,limitMessages:x,filterIconClassName:w})=>{const{titles:v}=ye(),[S,k]=d.useState(M.PopUpState.Closed),[T,N]=d.useState([]),[D,R]=d.useState([]),[E,A]=d.useState(),[I,O]=d.useState([]),[L,W]=d.useState(void 0),$=d.useRef(l||[]),[q,U]=d.useState([]),[J,G]=d.useState(),[te,ne]=d.useState(),[fe,xe]=d.useState(!1),me=d.useRef(0),_=d.useRef(!1),[K,le]=d.useState(!1),de=d.useCallback(()=>{me.current+=1,me.current===1&&xe(!0)},[]),ue=d.useCallback(()=>{me.current=Math.max(me.current-1,0),me.current===0&&xe(!1)},[]),se=d.useCallback(X=>{const pe=t?.find(be=>be.id===X.id);if(!pe)return;const ve=y.getKeyFromUrn(pe.localRepresentation?.enumeration);if(ve)return ve;const Ce=y.findCodelistByDimension(s?.codelists,s?.conceptSchemes,pe);return Ce?y.getKeyFromUrn(Ce.urn)??y.generateShortUrn(Ce.id,Ce.version,Ce.agencyID):void 0},[t,s?.codelists,s?.conceptSchemes]),{hierarchyStateMap:Q,rebuildHierarchyTree:H,loadAvailableHierarchies:B,onSelectHierarchy:oe,onExpandHierarchyNode:ae}=Ei({getCodelistUrnForFilter:se,getConstraintsForFilter:()=>$.current,getSourceArtefactUrn:X=>Ci(X.id,s),getAvailableHierarchies:e?.getAvailableHierarchies,getHierarchy:e?.getHierarchy}),ge=X=>{const pe=X?T.map(ve=>Pe(ve,X)?X:ve):T;ne(!0),N(sn(pe)),G?.(!0),he(X?.isTimeDimension?nn(pe,X):pe,N,G,X)};d.useEffect(()=>{S===M.PopUpState.Closed&&U($.current)},[S]);const he=d.useCallback((X,pe,ve,Ce)=>{const be=o?.urn??"",Ie=jt(jn(X).filter(F=>F.componentCode!==y.TIME_PERIOD)),V=nt(be,Ie),j=!!e?.getConstraints&&!In(e.getConstraints,V);j&&de(),(e?st(e.getConstraints,V,()=>e.getConstraints(be,Ie)):Promise.resolve(void 0)).then(F=>{const Y=F?.data?.dataConstraints||[];if(Ce){const{filters:re,changed:ke}=Wc(X,t,s,Y,Ce,u);if(ke){$.current=Y,ve?.(!0),ne(!0),he(re,pe,ve,Ce);return}}const Z=Kt(X,t,s,Y,u);if($.current=Y,ve?.(!1),pe(Z),Ce){const re=Z.find(ke=>Pe(ke,Ce));A(ke=>ke&&re&&Pe(ke,Ce)?{...re,isSelectedFilter:!0}:ke),H(Ce,Y)}}).catch(()=>{const F=Kt(X,t,s,[],u);if($.current=[],ve?.(!1),pe(F),Ce){const Y=F.find(Z=>Pe(Z,Ce));A(Z=>Z&&Y&&Pe(Z,Ce)?{...Y,isSelectedFilter:!0}:Z)}}).finally(()=>{ne(!1),j&&ue()})},[e,o?.urn,t,ue,u,H,de,s]);d.useEffect(()=>{const X=yr(t,s,n,u),pe=t?.map(Ce=>{const be=y.findCodelistByDimension(s?.codelists,s?.conceptSchemes,Ce),Ie=y.getAvailableCodesFromConstrains(be?.codes,Ce.id,$.current,u);return{...Ce,dimensionValues:Ie}}),ve=X.map(Ce=>{const be=pe?.find(Ie=>Ie.id===Ce.id)?.dimensionValues||[];return{...Ce,dimensionValues:be}});if(!_.current){if(!s)return;const Ce=Nr(ve,o,$.current);G?.(!0),he(Ce,R,G),_.current=!0}},[t,n,s,o,u,l,he]),d.useEffect(()=>{D?.length&&O(cn(D))},[D]),d.useEffect(()=>{N(X=>nn(X,E))},[E]),d.useEffect(()=>{if(S===M.PopUpState.Opened){const X=D.find(pe=>!pe.isTimeDimension);A(X?{...X,isSelectedFilter:!0}:void 0),N(D)}S===M.PopUpState.Closed&&A(void 0)},[D,S]),d.useEffect(()=>{if(!E||E.isTimeDimension)return;const X=$e(E);if(!X)return;Q.get(X)||B(E)},[E,Q,B]),d.useEffect(()=>{S===M.PopUpState.Opened&&D.forEach(X=>{if(X.isTimeDimension)return;const pe=$e(X);pe&&!Q.has(pe)&&B(X)})},[S,D,Q,B]);const ce=d.useCallback(async X=>{const pe=Ur(X),ve=p?{...p,messages:Ti(p?.messages,c,void 0,pe,o)}:null;g?.(ve),C?.(Gc(c,void 0,pe,o)),await b(decodeURI(m),{name:ve?.name,messages:ve?.messages||[]})},[o,p,m,c,g,b,C]),De=d.useCallback((X,pe)=>{N(ve=>Dr(ve,X,pe)),Pe(E,X)&&A(ve=>ve&&{...ve,displayMode:pe})},[E]),Ee=d.useCallback(X=>Or(X,t),[t]),ie=d.useCallback((X,pe)=>{const ve=Kt(pe,t,s,X,u);$.current=X,A(Ce=>ve?.find(be=>Pe(be,Ce))||Ce),N(ve),ne(!1)},[t,u,s]),Le=d.useCallback(X=>{ne(!0),N(sn(X));const pe=o?.urn??"",ve=jt(jn(X).filter(V=>V.componentCode!==y.TIME_PERIOD)),Ce=nt(pe,ve),be=!!e?.getConstraints&&!In(e.getConstraints,Ce);be&&de(),(e?st(e.getConstraints,Ce,()=>e.getConstraints(pe,ve)):Promise.resolve(void 0)).then(V=>{ie(V?.data?.dataConstraints||[],X)}).catch(()=>{ie([],X)}).finally(()=>{be&&ue()})},[e,o?.urn,ue,de,ie]),Je=d.useCallback(X=>{const pe=Er(T,X);Le(pe)},[Le,T]),Ge=d.useCallback(()=>{$.current=q,k(M.PopUpState.Closed),le(!0)},[q]),_e=d.useCallback(()=>{const X=Ar(T);Le(X)},[Le,T]),Ue=d.useCallback(()=>{const X=Ee(T);f?.(X,$.current,T),R(T),k(M.PopUpState.Closed),le(!0),d.startTransition(()=>{ce(T)})},[Ee,T,f,ce,$]),Ze=X=>{W(X)},Ke=Number(y.getTimeSeriesCount($?.current?.[0]?.annotations));return r.jsxs("div",{className:"filters-container",children:[r.jsx(Si,{buttonProps:a,selectedFiltersCount:Bn(I),isLoading:J,setModalState:k,isModalClosed:K,warningIcon:x?.warningIcon,filterIconClassName:w,timeSeriesCount:Ke}),r.jsx(r.Fragment,{children:S===M.PopUpState.Opened&&r.jsxs(M.Popup,{heading:v?.settings||"Settings",portalId:"filters",size:M.PopUpSize.LG,containerClassName:"advanced-view-filters-modal h-[80%]",dividers:i?.isShowDividers,onClose:Ge,closeButtonTitle:v?.close||"Close",children:[r.jsx(gi,{locale:u,timeRangeOptions:h,filtersList:T,selectedFilter:E,isDisableValues:te,isValuesLoading:fe,modalProps:i,initialConstraints:l,timeSeriesCount:`${Ke}`,setSelectedFilter:A,onSelectDisplayMode:De,onDeleteFilter:Je,onClearAllFilters:_e,updateSelectedFilterValues:ge,onTimePeriodChange:Ze,selectedTimeOption:L,hierarchyStateMap:Q,onSelectHierarchy:oe,onExpandHierarchyNode:ae,dataQueries:o?[o]:void 0,disabledDatasetUrns:Jc,onToggleDataset:()=>{},onClearAllDatasets:()=>{}}),r.jsx(wi,{onApply:Ue,onClose:Ge,onClearAllFilters:_e,modalProps:i,applyDisabled:J||te,timeseriesLength:Ke,limitMessages:x})]})})]})},Dn=({setToTitle:e,datasetName:t,datasetIcon:n,isShowDatasetDetails:s,queryFilterDetails:a})=>r.jsx("div",{children:a?.map(i=>r.jsxs("div",{className:"body-1 mb-2 flex flex-wrap items-center gap-1",children:[r.jsxs("span",{children:[i?.title,r.jsx("span",{children:e??" set to "}),r.jsx("span",{className:"font-bold",children:i?.valuesTitles?.join(", ")})]}),t&&s&&r.jsxs("span",{className:"attachment-dataset-name caption !mb-0 inline-flex items-center",children:[r.jsx("span",{className:"attachment-dataset-icon mr-1",children:n}),t]})]},i?.title))}),Yc=({titles:e,attachmentInfoList:t,datasetIcon:n,dataQueries:s})=>{const{isCrossDatasetModeOn:a}=Be(),{sharedFilterDetails:i,perDatasetInfoList:o}=d.useMemo(()=>{if(!a)return{sharedFilterDetails:[],perDatasetInfoList:[]};const f=new Map,u=[];return t?.forEach(h=>{const m=[];h.queryFiltersDetails?.forEach(p=>{if(Vl.has(p.id)){const g=f.get(p.id);g?f.set(p.id,{...g,valuesTitles:Array.from(new Set([...g.valuesTitles||[],...p.valuesTitles||[]]))}):f.set(p.id,{...p})}else p.valuesTitles?.length&&m.push(p)}),m.length&&u.push({...h,queryFiltersDetails:m})}),{sharedFilterDetails:Array.from(f.values()),perDatasetInfoList:u}},[a,t]),c=s?.some(f=>f.disabled)??!1,l=t?.map(f=>f.datasetName).filter(Boolean)??[];return r.jsxs("div",{className:"attachment-details flex flex-col",children:[r.jsx("p",{className:z("body-1",(t&&t.length<=1||a&&i.length>0)&&"mb-2"),children:e?.queryUpdatedManuallyTitle??"Query has been updated manually."}),c&&l.length>0&&r.jsxs("div",{className:"body-1 mb-2 flex flex-wrap items-center gap-1",children:[r.jsxs("span",{children:[e?.datasetLabel??"Dataset",e?.setToTitle??" set to "]}),l.map(f=>r.jsxs("span",{className:"attachment-dataset-name caption !mb-0 inline-flex items-center",children:[r.jsx("span",{className:"attachment-dataset-icon mr-1",children:n}),f]},f))]}),a?r.jsxs(r.Fragment,{children:[i.length>0&&r.jsx(Dn,{setToTitle:e?.setToTitle,queryFilterDetails:i}),o.map(f=>r.jsx(Dn,{setToTitle:e?.setToTitle,datasetName:f.datasetName,datasetIcon:n,isShowDatasetDetails:!0,queryFilterDetails:f.queryFiltersDetails},f.datasetName))]}):t?.map(f=>!!f?.queryFiltersDetails?.length&&r.jsx(Dn,{setToTitle:e?.setToTitle,datasetName:f?.datasetName,datasetIcon:n,isShowDatasetDetails:t?.length>1,queryFilterDetails:f?.queryFiltersDetails},f?.datasetName))]})},qc=({icon:e,title:t})=>r.jsx("div",{className:z("px-3 py-4 rounded border mt-3","attachment-collapsed"),children:r.jsxs("p",{className:z("flex body-3 items-center"),children:[e,r.jsxs("span",{className:"ml-2",children:[" ",t]})]})}),Zc=e=>Te.createElement("svg",{width:44,height:24,viewBox:"0 0 44 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Te.createElement("rect",{width:44,height:24,rx:12,fill:"currentColor"}),Te.createElement("circle",{cx:32,cy:12,r:10,fill:"white"})),Xc=e=>Te.createElement("svg",{width:44,height:24,viewBox:"0 0 44 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Te.createElement("rect",{width:44,height:24,rx:12,fill:"currentColor"}),Te.createElement("circle",{cx:12,cy:12,r:10,fill:"white"})),Sa=[{value:y.SdmxDataFormat.JSON,title:"SDMX-JSON"},{value:y.SdmxDataFormat.XML,title:"SDMX-ML (XML)"},{value:y.SdmxDataFormat.CSV,title:"SDMX-CSV"}],Qc=e=>[{value:y.FileColumnsAttribute.ID,title:e?.idOptions||"ID",description:e?.idOptionsDescription},{value:y.FileColumnsAttribute.NAME,title:e?.nameOptions||"Name",description:e?.nameOptionsDescription},{value:y.FileColumnsAttribute.ID_NAME,title:e?.idAndNameOptions||"Combined ID and Name",description:e?.idAndNameOptionsDescription}],ya=({title:e,items:t,selectedValue:n,setSelectedValue:s,infoMessage:a,collapsible:i=!0})=>{const o=r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex flex-col gap-y-1",children:t.map(c=>r.jsx("div",{className:"flex flex-col",children:r.jsx(M.Radio,{id:c.value,checked:n.value===c.value,label:c.title,description:c.description,onChange:()=>{s(c)},radioIcon:r.jsx(Ve.IconCircleFilled,{className:"size-3"})},c.value)},c.value))}),a]});return i?r.jsx(M.CollapsibleBlock,{title:e,value:n.title,children:o}):r.jsxs("div",{className:"flex flex-col",children:[r.jsx("div",{className:"flex items-center py-4",children:r.jsx("span",{children:e})}),r.jsx("div",{className:"pb-4",children:o})]})},ed=({title:e,items:t,selectedUrns:n,onToggle:s,collapsible:a=!0,rowsLabel:i="rows"})=>{const o=r.jsx("div",{className:"flex flex-col",children:t.map(c=>r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(M.Checkbox,{id:c.urn,label:c.name,checked:n.has(c.urn),onChange:s})}),r.jsxs("span",{className:"download-row-count",children:[c.rowCount," ",i]})]},c.urn))});return a?r.jsx(M.CollapsibleBlock,{title:e,children:o}):r.jsxs("div",{className:"flex flex-col",children:[r.jsx("div",{className:"flex items-center py-4",children:r.jsx("span",{children:e})}),r.jsx("div",{className:"pb-4",children:o})]})},td=e=>{const t=e.metadata?.keyDimensionIdsInDsdOrder,n=e.metadata?.timePeriodDimension;if(!t?.length)return null;const s=t.map(i=>{const o=e.filters?.find(c=>c.componentCode===i);return o?.values?.length?o.values.join(y.GET_v3_FILTER_OR):"*"}).join("."),a=n?y.getTimeQueryFilter(e,{id:n}):null;return{filterKey:s,timeFilter:a}},nd=(e,t,n,s)=>{if(t&&e===y.DownloadType.DATA_IN_TABLE){const o=td(t);if(o)return o}if(s?.filterKey&&e===y.DownloadType.DATA_IN_TABLE)return s;let a=null,i=null;return t&&n&&e===y.DownloadType.DATA_IN_TABLE&&(a=y.getTimeSeriesFilterKey(n,t.filters??[]),i=y.getTimeQueryFilter(t,y.getTimeDimension(n))),{filterKey:a,timeFilter:i}},sd=({dataQuery:e,datasetName:t,onCloseModal:n,type:s=y.DownloadType.FULL_DATASET,locale:a=ee.Locale.EN,dimensions:i,filters:o,urn:c,titles:l,collapsible:f=!0,downloadDatasets:u,rowCount:h,isDownloadInProgress:m=!1,onDownloadStart:p,limitMessages:g,showLimitMessage:b,externalLink:C})=>{const x=Qc(l),[w,v]=d.useState(Sa[0]),[S,k]=d.useState(x[0]),[T,N]=d.useState(!0),[D,R]=d.useState(()=>new Set(u?.map(W=>W.urn)??[])),E=d.useRef(!1);d.useEffect(()=>{R(new Set(u?.map(W=>W.urn)??[]))},[u]);const A=d.useCallback(W=>{R($=>{const q=new Set($);return q.has(W)?q.delete(W):q.add(W),q})},[]),I=u!==void 0&&(u.length===0||D.size===0),O=d.useCallback(()=>{if(E.current)return;const W=w.value,$=(G,te,ne,fe)=>({dataQuery:G,urn:te,name:ne,rowCount:fe,fileName:`${ne}.${W}`,filters:nd(s,G,i,o)}),U={items:u&&u.length>0?u.filter(G=>D.has(G.urn)).map(G=>$(G.dataQuery,G.urn,G.name,G.rowCount)):[$(e,e?.urn||c||"",t||e?.urn||c||"",h??0)],dataFormat:W,dataFormatTitle:w.title,attribute:S.value,language:a,isMetadata:T};if(!p(U)){E.current=!1;return}E.current=!0,n()},[w.value,w.title,S.value,u,D,e,c,t,h,s,i,o,a,T,p,n]),L=r.jsxs("div",{className:z("download-metadata flex cursor-pointer gap-4",{"download-metadata-active":T}),children:[T?r.jsx(Zc,{width:44,height:24,className:"text-primary",onClick:()=>N(!T)}):r.jsx(Xc,{width:44,height:24,className:"text-neutrals-500",onClick:()=>N(!T)}),r.jsx("div",{children:l?.includeMetadata||"Include Metadata"})]});return r.jsxs(M.Popup,{heading:r.jsx("p",{className:"download-heading h2",children:l?.download||"Download"}),portalId:"filters",size:M.PopUpSize.LG,containerClassName:"download-popup h-[80%]",dividers:!1,onClose:n,closeButtonTitle:l?.close||"Close",children:[!u&&b&&r.jsx("div",{className:"download-info flex flex-col gap-1 px-6 pt-5",children:r.jsx(M.RequestLimitMessage,{limitMessages:g,isDownload:!0,query:C})}),r.jsxs("div",{className:"download-settings flex flex-col overflow-auto p-6",children:[r.jsx(ya,{title:l?.dataFormat||"Data Format",selectedValue:w,setSelectedValue:v,items:Sa,collapsible:f,infoMessage:r.jsx(M.DownloadFormatMessage,{limitMessages:g,query:C})}),w.value===y.SdmxDataFormat.CSV&&r.jsx(ya,{title:l?.attributes||"Attributes",selectedValue:S,setSelectedValue:k,items:x,collapsible:f}),u&&r.jsxs(r.Fragment,{children:[r.jsx(ed,{title:l?.datasetsToDownload||"Datasets to download",items:u,selectedUrns:D,onToggle:A,collapsible:f,rowsLabel:l?.rows||"rows"}),D.size>1&&r.jsxs(M.InlineAlert,{type:M.InlineAlertType.Note,children:[r.jsx("span",{className:"font-bold",children:l?.filesWillBeDownloaded?.(D.size)??`${D.size} files will be downloaded`})," ",l?.oneFilePerDataset??"- one file per selected dataset."]})]}),f?r.jsx(M.CollapsibleBlock,{title:l?.metadata||"Metadata",value:T?l?.all||"Included":l?.none||"Not included",children:L}):r.jsxs("div",{className:"flex flex-col",children:[r.jsx("div",{className:"flex items-center py-4",children:r.jsx("span",{children:l?.metadata||"Metadata"})}),r.jsx("div",{className:"pb-4",children:L})]})]}),r.jsxs("div",{className:"download-button mt-auto flex items-center gap-x-3 p-6",children:[l?.cancel&&r.jsx(M.Button,{buttonClassName:"text-button-tertiary",title:l.cancel,onClick:n}),r.jsx(M.Button,{buttonClassName:"text-button-primary",title:l?.download||"Download",disabled:I||m,onClick:O})]})]})},ad=({id:e,title:t,version:n,agency:s,isActive:a,isSingleTab:i,onSelectDataset:o})=>r.jsx("div",{className:z("dataset-tab truncate last:mr-4",a?"dataset-tab-active":"border-b-transparent",i?"dataset-tab-single cursor-default":"cursor-pointer"),title:t,onClick:()=>{i||o(y.generateShortUrn(e,n,s))},children:r.jsx("h3",{className:"dataset-tab-title truncate",title:t,children:t})}),rd=({datasets:e,locale:t,initialSelectedDatasetUrn:n,selectDataset:s})=>{const{isOpenedAdvancedView:a}=We(),[i,o]=d.useState();d.useEffect(()=>{if(!n&&!i&&e?.[0]){const l=y.generateShortUrn(e[0].id,e[0].version,e[0].agencyID);o(l),s?.(l)}else n&&n!==i&&(o(n),s?.(n))},[e,s,n,i]);const c=d.useCallback(l=>{o(l),s?.(l)},[s]);return r.jsx("div",{className:z("dataset-tabs flex w-full items-center justify-between",a&&"hide-advance-button"),children:r.jsx("div",{className:"flex w-full items-center gap-4 overflow-y-auto sm:w-[calc(100%-30px)]",children:e?.map(l=>r.jsx(ad,{id:l?.id,title:y.getLocalizedName(l,t||ee.Locale.EN),version:l?.version,agency:l?.agencyID,isActive:e?.length>1&&i===y.generateShortUrn(l?.id,l?.version,l?.agencyID),isSingleTab:e?.length===1,onSelectDataset:c},l?.id))})})},id=3,od=({datasets:e,locale:t})=>{const{isOpenedAdvancedView:n}=We(),s=d.useMemo(()=>(e||[]).map(c=>({urn:y.generateShortUrn(c?.id,c?.version,c?.agencyID),title:y.getLocalizedName(c,t||ee.Locale.EN)})),[e,t]),a=d.useMemo(()=>s.slice(0,id),[s]),i=Math.max(s.length-a.length,0),o=s.filter(c=>!a.some(l=>l.urn===c.urn)).map(c=>c.title).join(`
|
|
7
|
+
`);return r.jsx("div",{className:z("cross-dataset-tabs flex w-full items-center justify-between",n&&"hide-advance-button"),children:r.jsxs("div",{className:"cross-dataset-tabs-list sm:w-[calc(100%-30px)]",children:[a.map((c,l)=>r.jsxs("span",{className:"cross-dataset-tabs-item-wrapper",children:[r.jsx("span",{className:"cross-dataset-tabs-item",title:c.title,children:c.title}),l<a.length-1&&r.jsx("span",{className:"cross-dataset-tabs-separator","aria-hidden":"true"})]},c.urn)),i>0&&r.jsxs("span",{className:"cross-dataset-tabs-counter",title:o,children:["+",i]})]})})},Ni=({datasets:e,locale:t,initialSelectedDatasetUrn:n,selectDataset:s})=>{const{isCrossDatasetModeOn:a}=Be();return a?r.jsx(od,{datasets:e,locale:t}):r.jsx(rd,{datasets:e,locale:t,initialSelectedDatasetUrn:n,selectDataset:s})},Da=(e,t)=>{const n=t?.get(e?.urn),s=n?.conceptSchemes||[],a=n?.codelists||[],i=y.getDimensions(n),o=[...i?.dimensions||[],...i?.timeDimensions||[]];return{structures:n,conceptSchemes:s,codelists:a,dimensions:o}},ld=(e,t,n,s,a)=>{const i=t?.filter(c=>!c.disabled)??[],o=new Map;return i?.forEach(c=>{const{conceptSchemes:l,codelists:f,dimensions:u}=Da(c,n);Mn((c?.filters??[]).filter(h=>h.operator!==ee.QueryFilterType.EXCLUDED),c?.urn,u,l,f,s,a).forEach(h=>{if(h.valuesTitles?.length){const m=o.get(h.id)??[];o.set(h.id,Array.from(new Set([...m,...h.valuesTitles])))}})}),i?.map(c=>{const l=e?.find(b=>b?.urn===c?.urn),{structures:f,conceptSchemes:u,codelists:h,dimensions:m}=Da(c,n),g=cd(Mn(l?.filters||[],c?.urn,m,u,h,s,a),Mn(c?.filters??[],c?.urn,m,u,h,s,a)).map(b=>{if(b.valuesTitles?.length)return b;const C=o.get(b.id);return C?.length?{...b,valuesTitles:C}:null}).filter(b=>b!==null);return{datasetName:y.getLocalizedName(f?.dataflows?.[0],s),queryFiltersDetails:g}})},cd=(e,t)=>{const n=new Map(e?.map(s=>[s?.id,s]));return t?.filter(s=>!_n.isEqual(n?.get(s?.id)?.valuesTitles?.sort(),s?.valuesTitles?.sort()))||[]},Mn=(e,t,n,s,a,i,o)=>e?.map(c=>{const l=n.find(h=>h?.id===c?.componentCode),f=y.getConcept(l?.conceptIdentity||"",s),u=y.findCodelistByDimension(a,s,l);return{id:Wl(t,c?.componentCode,o)??c?.componentCode,title:y.getLocalizedName(f,i),valuesTitles:c?.operator===ee.QueryFilterType.BETWEEN?[`${tn(ee.getTimePeriod(c?.values?.[0]),i)} - ${tn(ee.getTimePeriod(c?.values?.[1]),i)}`]:c?.values?.map(h=>y.getLocalizedName(u?.codes?.find(m=>m?.id===h),i)||h)}}),dd=(e,t,n)=>{let s="",a="";if(e?.timeFilter){const o=decodeURIComponent(e.timeFilter||"")?.split(":");s=o[1]||"",a=o[3]||""}else if(t){const o=t?.filters?.find(c=>c.componentCode===y.TIME_PERIOD);s=o?.values?.[0]||"",a=o?.values?.[1]||""}return`&filter=${e?.filterKey||y.getTimeSeriesFilterKey(n||[],t?.filters||[])}&startPeriod=${s}&endPeriod=${a}`},Rn=(e,t,n,s)=>{const a=n?.metadata?.datasetUrl;if(!a)return"";const i=e?dd(t,n,s):"";return a+i},ki=e=>Te.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Te.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"})),ud=e=>Te.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Te.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"})),fd=e=>Te.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Te.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"})),md=e=>Te.createElement("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...e},Te.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"})),hd=({attachment:e,index:t,selectedAttachmentIndex:n,onSelectedAttachmentChange:s,showTabIcon:a,dataGridTitle:i})=>{const{titles:o}=ye(),c=d.useRef(null),[l,f]=d.useState(""),[u,h]=d.useState(""),[m,p]=d.useState(!1),{onboardingFileSchema:g,isShowOnboarding:b}=qe(),C=d.useCallback((w,v="")=>a?_c(w)||Zt(w)?r.jsx(ki,{className:v}):ct(w)||mt(w)?r.jsx(fd,{className:v}):Jn(w)?r.jsx(md,{className:v}):Di(w)||Yn(w)?r.jsx(ud,{className:v}):null:null,[a]),x=d.useCallback(w=>ct(w)?i||"Data Grid":w.title,[i]);return d.useEffect(()=>{if(b&&Zt(e)){const{title:w,description:v}=dt(Oe.CHARTS,o);f(w),h(v)}},[e,o,b]),d.useEffect(()=>{if(Zt(e)&&b){const w=g?.lastDisplayedElement===Oe.CHARTS;p(w),w&&c?.current?.scrollIntoView({block:"end",behavior:"smooth"})}},[g?.lastDisplayedElement,e,b]),r.jsxs("div",{ref:c,className:z("cursor-pointer min-w-30","flex items-center gap-1","attachment-tab",n===t?"attachment-tab-active text-primary":""),onClick:()=>s(t),children:[C(e,"w-4 h-4"),r.jsx("h4",{className:"max-w-[130px] truncate",title:x(e),children:x(e)}),m&&r.jsx(ut,{reference:c,title:l,description:u})]},e.index||t)},pd=({attachments:e,...t})=>r.jsx("div",{className:"attachments-tabs flex w-fit flex-wrap items-center",children:e.map((n,s)=>r.jsx(hd,{attachment:n,index:s,...t},s))}),gd=({attachments:e,selectedAttachmentIndex:t,selectedAttachment:n,attachmentsStyles:s,externalLink:a,isExternalLinkIncludeFilters:i,limitMessages:o,onSelectedAttachmentChange:c,onDownloadClick:l,showAdvancedView:f,onOpenAdvancedView:u,isTableSettingsOpen:h,onTableSettingsOpen:m})=>{const{isTableSettingsFeatureEnabled:p}=Be(),{isOpenedAdvancedView:g}=We(),{titles:b}=ye(),{onboardingFileSchema:C,isShowOnboarding:x}=qe(),w=d.useRef(null),[v,S]=d.useState(""),[k,T]=d.useState(""),[N,D]=d.useState(!1);d.useEffect(()=>{if(x){const{title:L,description:W}=dt(Oe.OPEN_ADVANCED_VIEW,b);S(L),T(W)}},[b,x]),d.useEffect(()=>{if(x){const L=C?.lastDisplayedElement===Oe.OPEN_ADVANCED_VIEW;D(L),L&&w?.current?.scrollIntoView({block:"center",behavior:"smooth"})}},[C?.lastDisplayedElement,x]);const R=p&&!f&&!!m&&!!(n&&(ct(n)||mt(n))),E=!!n&&(ct(n)||mt(n)),A=!!f&&!g,I=g&&s?.hideDownloadIconInAdvancedView?void 0:s?.downloadIcon,O=!g&&s?.hideDownloadTextInConversationView?"":s?.downloadTitle??"";return r.jsxs("div",{className:"flex w-full min-w-0 items-center justify-between",children:[r.jsx(pd,{dataGridTitle:s?.dataGridTitle,attachments:e,selectedAttachmentIndex:t,showTabIcon:s?.showTabIcon,onSelectedAttachmentChange:c}),r.jsxs("div",{className:"attachments-buttons flex w-fit flex-wrap items-center justify-end gap-x-3",children:[n&&ct(n)&&i&&r.jsx("a",{href:a,target:"_blank",rel:"noreferrer",children:r.jsx(M.Button,{title:o?.dataExplorer||"Data explorer",buttonClassName:"text-button-tertiary small-icon-button [&>svg]:h-[16px] [&>svg]:w-[16px] whitespace-nowrap",iconBefore:o?.dataExplorerIcon})}),E&&r.jsx(M.Button,{title:O,buttonClassName:"text-button-tertiary small-icon-button !p-0 !h-6",textClassName:z("ml-1",s?.downloadButtonTextClassName),onClick:l,iconBefore:I}),E&&A&&r.jsx("span",{className:"advanced-view-button-divider","aria-hidden":"true"}),A&&r.jsx("div",{ref:w,children:r.jsx(M.Button,{title:s?.advancedViewTitle,buttonClassName:"advanced-view-button",textClassName:"ml-1 h4 md:hidden",iconBefore:s?.openAdvancedViewIcon,onClick:u})}),R&&r.jsx(M.Button,{disabled:h,buttonClassName:"text-button-tertiary !p-0 !h-6",textClassName:"ml-1 h4",iconBefore:s?.tableSettingsIcon??r.jsx(Ve.IconSettings,{className:"size-4"}),title:s?.tableSettings||"Table settings",onClick:m}),n&&Yn(n)&&r.jsx(M.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??"")})]}),N&&r.jsx(ut,{reference:w,title:v,description:k,onReferenceClick:u,shouldCloseTooltip:g})]})},Cd=({downloadTitles:e,attachment:t,actions:n,className:s=""})=>{const a=t.url,[i,o]=d.useState(null);async function c(l){if(l==null)return;const f=await n.getFile(l);o(f)}return r.jsxs("div",{className:`rounded-lg border bg-white p-3 transition-colors ${s}`,children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("span",{className:"body-2 truncate text-neutrals-800",title:t.title,children:t.title})})}),a&&r.jsx("div",{className:"shrink-0",children:r.jsx(M.Button,{title:e??"Download",onClick:()=>c(t.url),buttonClassName:"text-button-tertiary"})})]}),i&&r.jsx("div",{className:"mt-3",children:r.jsx("pre",{className:"overflow-x-auto rounded-md bg-white p-3",children:r.jsx("code",{children:JSON.stringify(i,null,2)})})})]})},ji="json";function wd(e){return vd(e)?xd(e?.slice(ji.length)):e}function xd(e){let t="";if(e)try{t=JSON.stringify(JSON.parse(e),null,2)}catch{t=e.toString()}return t}function vd(e){return e?.startsWith(ji)||!1}const bd=({attachment:e,className:t=""})=>{const n=wd(e.data);return n?r.jsxs("div",{className:`attachment-json rounded-lg border bg-white ${t}`,children:[r.jsx("div",{className:"flex items-center justify-between rounded-t-lg border-b border-neutrals-200 bg-neutrals-100 px-3 py-2",children:r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("h3",{className:"text-neutrals-900",children:e.title})})}),r.jsx("div",{className:"p-3",children:r.jsx("pre",{className:"max-h-96 overflow-auto whitespace-pre-wrap break-words text-neutrals-800",children:r.jsx("code",{children:n})})})]}):null},Sd=e=>{try{const t=new URL(e);return["http:","https:","data:"].includes(t.protocol)}catch{return!1}},yd=e=>Sd(e)?e:"",Dd=e=>Te.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Te.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"})),Md=({attachment:e,openLinkTitle:t,className:n=""})=>{const s=yd(e.data||"");if(!s)return null;const a=i=>{window.open(i,"_blank")?.focus()};return r.jsx("div",{className:`max-w-[500px] rounded-lg border bg-white py-3 pl-4 pr-3 ${n}`,children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"mt-1 shrink-0 text-hues-800",role:"img","aria-label":"Link",children:r.jsx(Dd,{width:16,height:16})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"mb-1",children:r.jsx(M.Link,{url:s,title:e.title})}),r.jsx("div",{className:"truncate break-all text-neutrals-600",children:s})]}),r.jsx("div",{className:"shrink-0",children:r.jsx(M.Button,{title:t??"Open link",onClick:()=>a(s),buttonClassName:"text-button-tertiary"})})]})})},Ii=({dimensionsInfo:e})=>r.jsx("div",{className:"sidebar flex min-h-0 w-[176px] flex-col gap-3 overflow-auto",children:e.map(t=>r.jsxs("div",{className:"flex flex-col",children:[r.jsx("h5",{className:"text-neutrals-800",children:t.title}),r.jsx("h5",{className:"font-bold",children:t.value})]},t.title))}),Td=({chart:e,isOpen:t,onClose:n,datasetTitle:s})=>{const{titles:a}=ye(),[i,o]=d.useState(M.PopUpState.Closed);d.useEffect(()=>{o(t?M.PopUpState.Opened:M.PopUpState.Closed)},[t]);const c=d.useCallback(()=>{o(M.PopUpState.Closed),n?.()},[n]);return r.jsx(r.Fragment,{children:i===M.PopUpState.Opened&&r.jsxs(M.Popup,{heading:r.jsx("h1",{className:"single-chart-popup-heading",children:a?.chart??"Chart"}),containerClassName:"single-chart-popup h-[80%]",portalId:"single-chart",size:M.PopUpSize.LG,dividers:!1,onClose:c,closeButtonTitle:a?.close??"Close",children:[r.jsxs("div",{className:"single-chart-popup-content flex h-full min-h-0 flex-1 flex-row gap-4",children:[r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[s&&r.jsxs("div",{className:"mb-2 flex items-center gap-1",children:[r.jsx(Wn,{className:"size-4 shrink-0 text-neutrals-1000"}),r.jsx("h4",{className:"text-neutrals-1000",children:s})]}),r.jsx(Ja,{option:e.config,className:"size-full",style:{width:"100%",height:"100%"}})]}),r.jsx(Ii,{dimensionsInfo:e.dimensions})]}),r.jsx("div",{})]})})},qn=e=>{const{titles:t}=ye(),[n,s]=d.useState(!1),[a,i]=d.useState(),o=d.useRef(null),[c,l]=d.useState(""),[f,u]=d.useState(""),[h,m]=d.useState(!1),{onboardingFileSchema:p,isShowOnboarding:g}=qe(),{isCrossDatasetModeOn:b}=Be(),[C,x]=d.useState(!1),w=d.useMemo(()=>Ed(e.value),[e.value]),v=d.useCallback(()=>{i(k=>k??w),s(!0)},[w]),S=d.useCallback(()=>{s(!1),x(!0)},[]);return d.useEffect(()=>{if(g){const{title:k,description:T}=dt(Oe.CHART_PER_SERIES,t);l(k),u(T)}},[t,g]),d.useEffect(()=>{g&&m(p?.lastDisplayedElement===Oe.CHART_PER_SERIES&&e.node.rowIndex===0)},[p?.lastDisplayedElement,e.node.rowIndex,g]),d.useEffect(()=>{i(void 0)},[e.value]),w&&!w.isPlottable?null:r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:o,children:r.jsx(M.IconButton,{title:t?.chart??"Chart",buttonClassName:"!text-neutrals-1000 !border-none !p-1",icon:r.jsx(ki,{className:"size-5"}),onClick:v})}),h&&r.jsx(ut,{reference:o,title:c,description:f,onReferenceClick:v,shouldCloseTooltip:C}),n&&a&&r.jsx(Td,{chart:a,isOpen:n,onClose:S,datasetTitle:b?e.data?.datasetTitle??void 0:void 0})]})};function Ed(e){return typeof e=="function"?e():e}const Rt=32,un=32,Ad=16,ht="padding-0",bt=200,Ct={flex:1,minWidth:bt},Nd=Rt,fn="observationValueCell",mn="metadataCell",Li="chartCell",Pi="mergedDimensionCell",Ri="datasetDetailCell",It="Chart_column",kd=(e,t,n,s,a,i)=>({headerName:"",suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:!0,width:32,maxWidth:32,cellClass:ht,cellRenderer:mn,cellRendererParams:{attributesData:t,dataSetData:e,locale:n,metadataSettings:s,titles:a,action:i}});function Fi(e,t,n,s=Nd,a,i){return{headerName:"",field:It,colId:It,suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:"right",width:s,maxWidth:s,minWidth:s,cellClass:ht,suppressColumnsToolPanel:!0,cellRenderer:qn,cellRendererParams:{attributesData:t,dataSetData:e,locale:n,titles:a,action:i}}}function jd(e,t,n,s){return{headerName:"",suppressHeaderMenuButton:!0,suppressNavigable:!0,sortable:!1,editable:!1,pinned:!0,width:32,maxWidth:32,cellClass:ht,cellRenderer:mn,cellRendererParams:{structuresMap:e,attributesDataMap:t,locale:n,titles:s}}}const Fn=["index","value"],Id=e=>({columns:Rd(e),data:Ld(e)}),Ld=e=>{const t=e.metadata.time_column,n={};for(const s of e.data.data){const{value:a,...i}=s,o=Pd(s,t);n[o]={...n[o]||{},...i,[s[t]]:a}}return Object.values(n)},Pd=(e,t)=>Object.keys(e).filter(n=>!Fn.includes(n)&&n!==t).map(n=>e[n]).join("."),Rd=e=>{const{metadata:t,data:n}=e,s=t.time_column,a=t.pinned_columns||[],i=n.schema.fields,o=[],c=n.data.map(m=>m[s]),f=Array.from(new Set(c)).filter(m=>m!=null).map(m=>({field:m,colId:m,headerName:m,cellClass:"text-right",width:bt})),u=a.map(m=>i.find(p=>p.name===m)).filter(m=>m!=null),h=i.filter(m=>!a.includes(m.name)).filter(m=>m!=null);if(u.length>0)for(const m of[...u])m.name===s||Fn.includes(m.name)||o.push({colId:m.name,field:m.name,headerName:m.name,pinned:"left",...Ct,tooltipValueGetter:p=>p.value});for(const m of[...h])m.name===s||Fn.includes(m.name)||o.push({colId:m.name,field:m.name,headerName:m.name,pinned:!1,...Ct,tooltipValueGetter:p=>p.value});return o.push(...f),o},Zn=e=>e*un+Rt+Ad,Fd=({attachment:e,actions:t,className:n="",showLimitMessage:s})=>{const[a,i]=d.useState(!1),[o,c]=d.useState([]),[l,f]=d.useState(),[u,h]=d.useState(400);d.useEffect(()=>{e.url!=null&&(i(!0),t.getFile(e.url).then(p=>{if(p==null){c([]),f([]),i(!1);return}const{columns:g,data:b}=Id(p);c(b),f(g),i(!1)}))},[e.url,t]),d.useEffect(()=>{o?(h(Zn(o.length)),s?.(o.length>=M.SERIES_LIMIT)):s?.(!1)},[o,s]);const m=d.useMemo(()=>r.jsx(Vn.AgGridReact,{headerHeight:Rt,rowHeight:un,rowData:o,columnDefs:l,enableCellTextSelection:!0,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",autoSizeStrategy:{type:l&&l?.length>5?"fitCellContents":"fitGridWidth"}}),[o,l]);return a?r.jsx(M.Loader,{}):r.jsx("div",{className:`w-full ${n}`,children:r.jsx("div",{className:"ag-theme-quartz max-h-[400px] min-h-[80px] w-full",style:{height:u},children:m})})},Oi=e=>Te.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},Te.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"})),Od=({title:e,value:t})=>{const n=d.useCallback(()=>Array.isArray(t)?t.join(", "):t,[t]);return r.jsxs("div",{className:"body-3 flex gap-x-3",children:[r.jsxs("p",{title:e,className:"text-neutrals-800",children:[e,":"]}),r.jsx("p",{title:n(),className:"truncate pr-3 font-semibold",children:n()})]})};function _i(e){const t=d.useRef(null),[n,s]=d.useState(!1),[a,i]=d.useState(!1),o=d.useCallback(()=>{const l=t.current;l&&i(l.scrollHeight>l.offsetHeight)},[]);d.useEffect(()=>{if(n)return;o();const l=t.current;if(!l||typeof ResizeObserver>"u")return;const f=new ResizeObserver(()=>o());return f.observe(l),()=>f.disconnect()},[n,e,o]);const c=d.useCallback(()=>s(l=>!l),[]);return{valueRef:t,isExpanded:n,canToggle:a,toggle:c}}const Vi=({isExpanded:e,onToggle:t,title:n})=>r.jsx(M.IconButton,{title:n,buttonClassName:z("border-none p-0 w-6 h-6 shrink-0",e&&"rotate-[180deg]"),isBaseIconStyles:!1,icon:r.jsx(Hn,{width:24,height:24}),onClick:t}),_d=({title:e,value:t,attachedKeysTitles:n,isDimensionGroup:s,locale:a})=>{const i=d.useMemo(()=>Array.isArray(t)?t?.map(u=>typeof u=="object"?u?.[a]:u)?.join(", "):t,[a,t]),{valueRef:o,isExpanded:c,canToggle:l,toggle:f}=_i(i);return r.jsxs("div",{className:"metadata-item",children:[!s&&n?.map(u=>r.jsx("div",{title:u,className:"metadata-item-key mb-1 pr-3 text-neutrals-800",children:u},u)),r.jsxs("div",{className:z("flex items-center",l&&"justify-between"),children:[r.jsx("h2",{title:e,className:"metadata-item-title",children:e}),l&&r.jsx(Vi,{isExpanded:c,onToggle:f})]}),r.jsx("p",{title:i,className:z("metadata-item-value pr-3",!c&&"line-clamp-4"),ref:o,children:i})]})},Vd=({metadata:e,metadataDescription:t=[],locale:n})=>{const{titles:s}=ye();return r.jsxs("div",{className:"metadata-content h-full overflow-hidden",children:[t?.length>0&&r.jsx("div",{className:"metadata-description",children:t?.map(a=>r.jsx(Od,{title:a?.title,value:a?.value},a?.title))}),r.jsx("div",{className:"metadata-list h-full overflow-y-auto",children:e&&e?.length>0?e?.map(a=>r.jsx(_d,{title:a?.title,value:a?.value,locale:n,attachedKeysTitles:a?.attachedKeysTitles,isDimensionGroup:a?.isDimensionGroup},a?.id||a?.title)):r.jsx("div",{className:"metadata-empty flex h-full items-center justify-center text-neutrals-700",children:s?.noMetadata||"No metadata"})})]})},Xn=({metadata:e,metadataDescription:t=[],isOpenMetadata:n,onCloseMetadata:s,locale:a})=>{const{titles:i}=ye(),[o,c]=d.useState(M.PopUpState.Closed);d.useEffect(()=>{c(n?M.PopUpState.Opened:M.PopUpState.Closed)},[n]);const l=d.useCallback(()=>{c(M.PopUpState.Closed),s?.()},[s]);return r.jsx(r.Fragment,{children:o===M.PopUpState.Opened&&r.jsxs(M.Popup,{heading:r.jsx("h1",{className:"metadata-heading",children:i?.metadata||"Metadata"}),containerClassName:"metadata h-[80%]",portalId:"metadata",size:M.PopUpSize.LG,dividers:!1,onClose:l,closeButtonTitle:i?.close||"Close",children:[r.jsx(Vd,{locale:a,metadata:e,metadataDescription:t}),r.jsx("div",{})]})})},ot={dataset:"dataset",agency:"agency",lastUpdated:"lastUpdated"},Ud=({dataset:e,agency:t,lastUpdated:n,externalLink:s,formatValue:a})=>r.jsxs("div",{className:"mb-6 flex flex-col gap-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ve.IconDatabase,{className:"size-4 text-neutrals-700"}),r.jsx("p",{className:"h4 break-words text-neutrals-1000",children:a(e?.value)}),s&&r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:r.jsx(Ve.IconExternalLink,{className:"size-4 shrink-0 cursor-pointer text-primary"})})]}),t&&r.jsxs("div",{className:"body-3 flex gap-1",children:[r.jsxs("span",{className:"text-neutrals-800",children:[t?.title,":"]}),r.jsx("span",{className:"break-words text-neutrals-1000",children:a(t?.value)})]}),n&&r.jsxs("div",{className:"body-3 flex gap-1",children:[r.jsxs("span",{className:"text-neutrals-800",children:[n?.title,":"]}),r.jsx("span",{className:"break-words text-neutrals-1000",children:a(n?.value)})]})]}),Hd=({title:e,value:t,attachedKeysTitles:n,isDimensionGroup:s})=>{const{valueRef:a,isExpanded:i,canToggle:o,toggle:c}=_i(t);return r.jsxs("div",{className:"flex flex-col gap-1",children:[!s&&n?.map((l,f)=>r.jsx("div",{title:l,className:"body-3 text-neutrals-800",children:l},`${l}-${f}`)),r.jsxs("div",{className:"flex items-center justify-between gap-2 pr-2",children:[r.jsx("p",{title:e,className:"body-3 text-neutrals-800",children:e}),o&&r.jsx(Vi,{isExpanded:i,onToggle:c})]}),r.jsx("p",{ref:a,title:t,className:z("body-2 break-words text-neutrals-1000",!i&&"line-clamp-4"),children:t})]})},Bd=new Set(Object.values(ot)),Gd=", ",Ft=({metadata:e,metadataDescription:t=[],datasetInfo:n,externalLink:s,locale:a})=>{const{titles:i}=ye(),o=d.useCallback(p=>Array.isArray(p)?p.map(g=>typeof g=="object"?g?.[a]??"":g).join(Gd):typeof p=="object"&&p!==null?p?.[a]??"":p??"",[a]),{dataset:c,agency:l,lastUpdated:f,hasStructuredDatasetInfo:u}=d.useMemo(()=>{const p=t.find(v=>v?.id===ot.dataset),g=t.find(v=>v?.id===ot.agency),b=t.find(v=>v?.id===ot.lastUpdated),C=n?.dataset||p,x=n?.agency||g,w=n?.lastUpdated||b;return{dataset:C,agency:x,lastUpdated:w,hasStructuredDatasetInfo:!!C}},[n,t]),h=d.useMemo(()=>u?t.filter(p=>!p?.id||!Bd.has(p.id)):t,[u,t]),m=u||h.length>0||!!e?.length;return r.jsx("div",{className:"flex h-full flex-col overflow-hidden px-5 pb-4",children:m?r.jsxs(r.Fragment,{children:[u&&c&&r.jsx(Ud,{dataset:c,agency:l,lastUpdated:f,externalLink:s,formatValue:o}),h.length>0&&r.jsx("div",{className:"mb-4 flex flex-col gap-2",children:h.map((p,g)=>r.jsxs("div",{className:"body-3 flex gap-2",children:[r.jsxs("span",{className:"shrink-0 text-neutrals-800",children:[p?.title||p?.id,":"]}),r.jsx("span",{className:"min-w-0 truncate font-semibold text-neutrals-1000",children:o(p?.value)})]},`${p?.id||p?.title}-${g}`))}),r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:r.jsx("div",{className:"flex flex-col gap-4",children:e?.map(p=>r.jsx(Hd,{title:p?.title||p?.id,value:o(p?.value),attachedKeysTitles:p?.attachedKeysTitles,isDimensionGroup:p?.isDimensionGroup},p?.id||p?.title))})})]}):r.jsx("div",{className:"body-3 flex h-full items-center justify-center text-neutrals-700",children:i?.noMetadata||"No metadata"})})};function hn(e,t){const{externalLink:n,externalLinksMap:s}=e??{};return t!=null&&s!=null?s.get(t):n}const zd=e=>e?.data[e?.colDef?.field||0]?.obsAttributes,Wd=e=>e?.data?.attributes,Ui=(e,t)=>Object.entries(e?.data).filter(([n])=>t?.get(n)).map(([n,s])=>({name:n,value:String(s)})),Ma=(e,t,n)=>{const s=typeof e=="object"?e?.[t]:e;return n?y.getLocalizedName(n?.codes?.find(a=>a?.id===e),t)||"":s},Lt=(e,t,n)=>e?.map(s=>{const a=s?.name||"",i=t?.get(a),o=i?.codes?.length?i:void 0,c=Array.isArray(s?.value)?s?.value.map(l=>Ma(l,n,o)):Ma(s?.value,n,o);return{id:y.getLocalizedName(o,n)||s?.name,title:y.getLocalizedName(o||i,n),value:c||s?.value}})||[],Ot=(e,t,n)=>({title:n?.dataset||"Dataset",value:y.getLocalizedName(e,t)}),$d=(e,t,n,s)=>[{...Ot(e,n,s),id:ot.dataset},{id:ot.agency,title:s?.agency??"Agency",value:e?.agencyID},{id:ot.lastUpdated,title:s?.lastUpdated??"Last updated",value:t}],_t=(e,t,n,s)=>({dataset:e?{...Ot(e,n,s),id:ot.dataset}:void 0,agency:e?{id:ot.agency,title:s?.agency??"Agency",value:e?.agencyID}:void 0,lastUpdated:e?{id:ot.lastUpdated,title:s?.lastUpdated??"Last updated",value:t}:void 0}),Hi=(e,t,n)=>({title:y.getDimensionTitle(e?.conceptSchemes,y.getDimensions(e)?.timeDimensions?.[0],t),value:n?.colId||""}),Bi=(e,t)=>({title:t?.observation||"Observation",value:e}),Gi=(e,t,n,s,a,i)=>{const o={title:s?.timeSeries||"Time Series",value:i?.originalData?.name};return n?[Hi(e,t,a),o,Bi(n,s)]:[o]},zi=e=>{const t=e?.dataSets?.[0]?.attributes||[],n=e?.structures?.[0]?.attributes?.dataSet||[];return t?.length?n.reduce((s,a,i)=>{const o=t[i];if(o==null)return s;if(a?.values?.length>0){const c=a.values[o];s.push(c?{...a,values:[c]}:{...a})}else Array.isArray(o)?s.push({...a,values:[{values:o}]}):s.push({...a,values:[{value:o}]});return s},[]):n},Ta=(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 a=Object.values(n).find(i=>typeof i=="string");return typeof a=="string"?a:void 0},Wi=(e,t,n)=>e?.map(s=>{const a=s?.id,i=s?.values?.[0]?.value,o=(typeof i=="object"?Ta(i,n):i)||s?.values?.[0]?.id,c=s?.values?.[0]?.ids||s?.values?.[0]?.values,l=t?.get(a),f=l?.codes?.length?l:void 0,u=y.getLocalizedName(f?.codes?.find(m=>m?.id===o),n)||y.getLocalizedName(s?.values?.[0],n)||o,h=c&&c.map(m=>{const p=typeof m=="object"?Ta(m,n):String(m);return y.getLocalizedName(f?.codes?.find(g=>g?.id===p),n)||p}).filter(m=>m!=null);return{id:a,title:y.getLocalizedName(l,n)||a,value:h?.length?h:u}}).filter(({value:s})=>!!s)||[],Jd=(e,t)=>{const n=e?.dataSets?.[0],a=e?.structures?.[0]?.attributes?.dimensionGroup||[],i=n?.dimensionGroupAttributes;return new Map(a.map(o=>{const c=o?.relationship?.dimensions,{codedSeriesKey:l,decodedSeriesKey:f}=Kd(e,t,c);return[o.id,{values:i?.[l]||[],decodedSeriesKey:f,codedSeriesKey:l}]}))},Kd=(e,t,n)=>{const s=e?.structures?.[0],a=[...s?.dimensions.series||[],...s?.dimensions.observation||[]],i=new Array(a?.length)?.fill(""),o=new Array(a?.length)?.fill("");return n&&n?.forEach(c=>{const l=a?.findIndex(h=>h?.id===c)||0,f=t[l],u=a[l]?.values?.findIndex(h=>h?.id===f||h?.value===f)||0;i[l]=u>=0?u:f,o[l]=f}),{codedSeriesKey:i?.join(":"),decodedSeriesKey:o?.join(":")}},Yd=(e,t)=>{if(t==null)return;const n=e?.values?.[t],s=typeof t=="object"&&!Array.isArray(t),a=Array.isArray(t);return n||(s||a?{values:t}:{value:t?.toString()})},qd=e=>{const t=e?.value||e?.id,n=e?.values||e?.ids;return t!=null?[t]:n||[null]},$i=(e,t,n)=>t==null?t:n?.get(e||"")?.codes?.find(a=>a?.id===t)?.name||t,Zd=(e,t,n,s=ee.Locale.EN)=>{const a=n?.dataStructureComponents?.dimensionList,i=[...a?.dimensions||[],...a?.timeDimensions||[]],o=[];return(e?.split(":")||[])?.forEach((l,f)=>{if(l!==""){const u=i?.[f]?.id||"",h=y.getLocalizedName(t?.get(u),s),m=$i(u,l,t);o.push(`${h}: ${m}`)}}),o},Xd=(e,t,n,s,a=ee.Locale.EN)=>{if(!e||!t||!s)return[];const i=e?.structures?.[0]?.attributes?.dimensionGroup||[],o=Jd(e,s);return i?.map((c,l)=>{const f=o?.get(c?.id),u=n?.get(c?.id),h=qd(Yd(c,f?.values?.[l]));return{id:c?.id,title:y.getLocalizedName(u,a),value:Array.isArray(h)?h?.map(m=>$i(c?.id,m,n)||""):h,attachedKeysTitles:Zd(f?.decodedSeriesKey,n,t),isDimensionGroup:!0}})?.filter(({value:c})=>c?.some(l=>!!l))||[]},Qd=No.extendTailwindMerge({extend:{classGroups:{typography:["h1","h2","h3","h4","h5","body-1","body-2","body-3","caption"]}}});function tt(...e){return Qd(z(...e))}function eu({title:e,headerExtension:t,headerClassName:n,onClose:s,bodyClassName:a,panelClassName:i,children:o}){return r.jsxs("div",{className:tt("h-full w-[362px] bg-white border-l border-neutrals-500 flex flex-col overflow-hidden",i),children:[r.jsxs("div",{className:tt("flex justify-between px-5 py-6",n),children:[r.jsx("div",{className:"h2 text-neutrals-1000",children:e}),r.jsxs("div",{className:"flex items-center gap-2",children:[t,t&&r.jsx("div",{className:"h-3 w-px bg-neutrals-600"}),r.jsx("button",{type:"button",onClick:s,children:r.jsx(Ve.IconX,{className:"size-5 text-neutrals-1000"})})]})]}),r.jsx("div",{className:tt("flex-1 min-h-0 overflow-hidden",a),children:o})]})}const Ji=d.createContext(null);function tu({children:e}){const[t,n]=d.useState(null),s=d.useCallback(c=>{n(c)},[]),a=d.useCallback(()=>{n(null)},[]),i=d.useCallback(c=>c?t?.id===c:t!==null,[t]),o=d.useMemo(()=>({panel:t,openPanel:s,closePanel:a,isPanelOpen:i}),[t,s,a,i]);return r.jsx(Ji.Provider,{value:o,children:e})}function Ki(){return d.useContext(Ji)}function pt(){const e=Ki();if(!e)return null;const{openPanel:t,closePanel:n,isPanelOpen:s}=e;return{openPanel:t,closePanel:n,isPanelOpen:s}}function Yi({scope:e}){const t=Ki();if(!t)return null;const{panel:n,closePanel:s}=t;if(!n)return null;const a=n.scope??"any";return a!=="any"&&a!==e?null:r.jsx(eu,{title:n.title,headerExtension:n.headerExtension,headerClassName:n.headerClassName,onClose:s,bodyClassName:n.bodyClassName,panelClassName:n.panelClassName,children:n.content})}function Tn(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function Mt(e){return(t,n)=>{const s=n?.context?String(n.context):"standalone";let a;if(s==="formatting"&&e.formattingValues){const o=e.defaultFormattingWidth||e.defaultWidth,c=n?.width?String(n.width):o;a=e.formattingValues[c]||e.formattingValues[o]}else{const o=e.defaultWidth,c=n?.width?String(n.width):e.defaultWidth;a=e.values[c]||e.values[o]}const i=e.argumentCallback?e.argumentCallback(t):t;return a[i]}}function Tt(e){return(t,n={})=>{const s=n.width,a=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],i=t.match(a);if(!i)return null;const o=i[0],c=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(c)?su(c,h=>h.test(o)):nu(c,h=>h.test(o));let f;f=e.valueCallback?e.valueCallback(l):l,f=n.valueCallback?n.valueCallback(f):f;const u=t.slice(o.length);return{value:f,rest:u}}}function nu(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function su(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function au(e){return(t,n={})=>{const s=t.match(e.matchPattern);if(!s)return null;const a=s[0],i=t.match(e.parsePattern);if(!i)return null;let o=e.valueCallback?e.valueCallback(i[0]):i[0];o=n.valueCallback?n.valueCallback(o):o;const c=t.slice(a.length);return{value:o,rest:c}}}const Ea=Symbol.for("constructDateFrom");function qi(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Ea in e?e[Ea](t):e instanceof Date?new e.constructor(t):new Date(t)}function ru(e,...t){const n=qi.bind(null,e||t.find(s=>typeof s=="object"));return t.map(n)}let iu={};function ou(){return iu}function Qn(e,t){return qi(t||e,e)}function Aa(e,t){const n=ou(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,a=Qn(e,t?.in),i=a.getDay(),o=(i<s?7:0)+i-s;return a.setDate(a.getDate()-o),a.setHours(0,0,0,0),a}function Zi(e,t,n){const[s,a]=ru(n?.in,e,t);return+Aa(s,n)==+Aa(a,n)}function Et(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?Et(e.future,t):"за "+Et(e.regular,t):e.past?Et(e.past,t):Et(e.regular,t)+" тому":Et(e.regular,t)}const lu=(e,t)=>t&&t.addSuffix?t.comparison&&t.comparison>0?"за півхвилини":"півхвилини тому":"півхвилини",cu={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:lu,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}} років"}})},du=(e,t,n)=>(n=n||{},cu[e](t,n)),uu={full:"EEEE, do MMMM y 'р.'",long:"do MMMM y 'р.'",medium:"d MMM y 'р.'",short:"dd.MM.y"},fu={full:"H:mm:ss zzzz",long:"H:mm:ss z",medium:"H:mm:ss",short:"H:mm"},mu={full:"{{date}} 'о' {{time}}",long:"{{date}} 'о' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},hu={date:Tn({formats:uu,defaultWidth:"full"}),time:Tn({formats:fu,defaultWidth:"full"}),dateTime:Tn({formats:mu,defaultWidth:"full"})},es=["неділю","понеділок","вівторок","середу","четвер","п’ятницю","суботу"];function pu(e){const t=es[e];switch(e){case 0:case 3:case 5:case 6:return"'у минулу "+t+" о' p";case 1:case 2:case 4:return"'у минулий "+t+" о' p"}}function Xi(e){return"'у "+es[e]+" о' p"}function gu(e){const t=es[e];switch(e){case 0:case 3:case 5:case 6:return"'у наступну "+t+" о' p";case 1:case 2:case 4:return"'у наступний "+t+" о' p"}}const Cu=(e,t,n)=>{const s=Qn(e),a=s.getDay();return Zi(s,t,n)?Xi(a):pu(a)},wu=(e,t,n)=>{const s=Qn(e),a=s.getDay();return Zi(s,t,n)?Xi(a):gu(a)},xu={lastWeek:Cu,yesterday:"'вчора о' p",today:"'сьогодні о' p",tomorrow:"'завтра о' p",nextWeek:wu,other:"P"},vu=(e,t,n,s)=>{const a=xu[e];return typeof a=="function"?a(t,n,s):a},bu={narrow:["до н.е.","н.е."],abbreviated:["до н. е.","н. е."],wide:["до нашої ери","нашої ери"]},Su={narrow:["1","2","3","4"],abbreviated:["1-й кв.","2-й кв.","3-й кв.","4-й кв."],wide:["1-й квартал","2-й квартал","3-й квартал","4-й квартал"]},yu={narrow:["С","Л","Б","К","Т","Ч","Л","С","В","Ж","Л","Г"],abbreviated:["січ.","лют.","берез.","квіт.","трав.","черв.","лип.","серп.","верес.","жовт.","листоп.","груд."],wide:["січень","лютий","березень","квітень","травень","червень","липень","серпень","вересень","жовтень","листопад","грудень"]},Du={narrow:["С","Л","Б","К","Т","Ч","Л","С","В","Ж","Л","Г"],abbreviated:["січ.","лют.","берез.","квіт.","трав.","черв.","лип.","серп.","верес.","жовт.","листоп.","груд."],wide:["січня","лютого","березня","квітня","травня","червня","липня","серпня","вересня","жовтня","листопада","грудня"]},Mu={narrow:["Н","П","В","С","Ч","П","С"],short:["нд","пн","вт","ср","чт","пт","сб"],abbreviated:["нед","пон","вів","сер","чтв","птн","суб"],wide:["неділя","понеділок","вівторок","середа","четвер","п’ятниця","субота"]},Tu={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:"ніч"}},Eu={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:"ночі"}},Au=(e,t)=>{const n=String(t?.unit),s=Number(e);let a;return n==="date"?s===3||s===23?a="-є":a="-е":n==="minute"||n==="second"||n==="hour"?a="-а":a="-й",s+a},Nu={ordinalNumber:Au,era:Mt({values:bu,defaultWidth:"wide"}),quarter:Mt({values:Su,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Mt({values:yu,defaultWidth:"wide",formattingValues:Du,defaultFormattingWidth:"wide"}),day:Mt({values:Mu,defaultWidth:"wide"}),dayPeriod:Mt({values:Tu,defaultWidth:"any",formattingValues:Eu,defaultFormattingWidth:"wide"})},ku=/^(\d+)(-?(е|й|є|а|я))?/i,ju=/\d+/i,Iu={narrow:/^((до )?н\.?\s?е\.?)/i,abbreviated:/^((до )?н\.?\s?е\.?)/i,wide:/^(до нашої ери|нашої ери|наша ера)/i},Lu={any:[/^д/i,/^н/i]},Pu={narrow:/^[1234]/i,abbreviated:/^[1234](-?[иі]?й?)? кв.?/i,wide:/^[1234](-?[иі]?й?)? квартал/i},Ru={any:[/1/i,/2/i,/3/i,/4/i]},Fu={narrow:/^[слбктчвжг]/i,abbreviated:/^(січ|лют|бер(ез)?|квіт|трав|черв|лип|серп|вер(ес)?|жовт|лис(топ)?|груд)\.?/i,wide:/^(січень|січня|лютий|лютого|березень|березня|квітень|квітня|травень|травня|червня|червень|липень|липня|серпень|серпня|вересень|вересня|жовтень|жовтня|листопад[а]?|грудень|грудня)/i},Ou={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]},_u={narrow:/^[нпвсч]/i,short:/^(нд|пн|вт|ср|чт|пт|сб)\.?/i,abbreviated:/^(нед|пон|вів|сер|че?тв|птн?|суб)\.?/i,wide:/^(неділ[яі]|понеділ[ок][ка]|вівтор[ок][ка]|серед[аи]|четвер(га)?|п\W*?ятниц[яі]|субот[аи])/i},Vu={narrow:[/^н/i,/^п/i,/^в/i,/^с/i,/^ч/i,/^п/i,/^с/i],any:[/^н/i,/^п[он]/i,/^в/i,/^с[ер]/i,/^ч/i,/^п\W*?[ят]/i,/^с[уб]/i]},Uu={narrow:/^([дп]п|півн\.?|пол\.?|ранок|ранку|день|дня|веч\.?|ніч|ночі)/i,abbreviated:/^([дп]п|півн\.?|пол\.?|ранок|ранку|день|дня|веч\.?|ніч|ночі)/i,wide:/^([дп]п|північ|полудень|ранок|ранку|день|дня|вечір|вечора|ніч|ночі)/i},Hu={any:{am:/^дп/i,pm:/^пп/i,midnight:/^півн/i,noon:/^пол/i,morning:/^р/i,afternoon:/^д[ен]/i,evening:/^в/i,night:/^н/i}},Bu={ordinalNumber:au({matchPattern:ku,parsePattern:ju,valueCallback:e=>parseInt(e,10)}),era:Tt({matchPatterns:Iu,defaultMatchWidth:"wide",parsePatterns:Lu,defaultParseWidth:"any"}),quarter:Tt({matchPatterns:Pu,defaultMatchWidth:"wide",parsePatterns:Ru,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Tt({matchPatterns:Fu,defaultMatchWidth:"wide",parsePatterns:Ou,defaultParseWidth:"any"}),day:Tt({matchPatterns:_u,defaultMatchWidth:"wide",parsePatterns:Vu,defaultParseWidth:"any"}),dayPeriod:Tt({matchPatterns:Uu,defaultMatchWidth:"wide",parsePatterns:Hu,defaultParseWidth:"any"})},Gu={code:"uk",formatDistance:du,formatLong:hu,formatRelative:vu,localize:Nu,match:Bu,options:{weekStartsOn:1,firstWeekContainsDate:1}},zu=e=>e===ee.Locale.UK?"dd MMM, yyyy":" MMM dd, yyyy hh:mm aa",Vt=(e,t)=>{const n=zu(t);return e!=null&&e!==""&&n&&Zs.isValid(new Date(e))?Zs.format(new Date(e),n,t===ee.Locale.UK?{locale:Gu}:void 0):""},Qi=e=>{const{titles:t}=ye(),n="grid-metadata-side-panel",[s,a]=d.useState(!1),i=d.useRef(null),[o,c]=d.useState(""),[l,f]=d.useState(""),[u,h]=d.useState(!1),{onboardingFileSchema:m,isShowOnboarding:p}=qe(),{isOpenedAdvancedView:g}=We(),b=pt(),{isMetadataInSidePanel:C}=Be(),[x,w]=d.useState(!1),v=e?.data?.dataset?.urn,S=hn(e?.context,v),k=d.useMemo(()=>e.structuresMap?v!=null?e.structuresMap.get(v):void 0:e.dataSetData,[e.structuresMap,v,e.dataSetData]),T=d.useMemo(()=>e.attributesDataMap?v!=null?e.attributesDataMap.get(v):void 0:e.attributesData,[e.attributesDataMap,v,e.attributesData]),N=d.useMemo(()=>y.getStructureComponentsMap(k),[k]),D=d.useMemo(()=>[Ot(k?.dataflows?.[0],e?.locale,t),...Lt(Ui(e,N),N,e?.locale),...Lt(Wd(e),N,e?.locale),...Xd(T,k?.dataStructures?.[0],N,e?.data?.originalData?.parsedTimeSeriesValue,e?.locale)],[e,k,T,N,t]),R=d.useMemo(()=>Gi(k,e?.locale,e?.valueFormatted||e?.value,t,e?.colDef,e?.data),[e,k,t]),E=d.useMemo(()=>{const O=k?.dataflows?.[0],L=Vt(y.getLastUpdatedTime(O),e?.locale);return _t(O,L,e?.locale,t)},[k,e?.locale,t]),A=d.useCallback(()=>{if(C&&b){b.openPanel({id:n,scope:g?"advanced":"conversation",title:t?.timeseriesMetadataPanel||"Timeseries Metadata",bodyClassName:"overflow-hidden",content:r.jsx(Ft,{locale:e?.locale,metadata:D,datasetInfo:E,externalLink:S,metadataDescription:e?.metadataSettings?.isMetadataDescription?R:[]})}),w(!0);return}a(!0)},[C,g,D,R,E,S,e?.locale,e?.metadataSettings?.isMetadataDescription,t,b]),I=d.useCallback(()=>{a(!1),w(!0)},[]);return d.useEffect(()=>{if(p){const{title:O,description:L}=dt(Oe.METADATA_PER_SERIES,t);c(O),f(L)}},[t,p]),d.useEffect(()=>{if(p){const O=m?.lastDisplayedElement===Oe.METADATA_PER_SERIES&&e.node.rowIndex===0;h(O),O&&setTimeout(()=>{i?.current?.scrollIntoView({block:"end",behavior:"smooth"})})}},[m?.lastDisplayedElement,e.node.rowIndex,p]),r.jsxs(r.Fragment,{children:[r.jsx("div",{ref:i,children:r.jsx(M.IconButton,{title:t?.metadata||"View details",buttonClassName:"!text-neutrals-1000 !border-none !p-1",icon:r.jsx(Oi,{className:"size-5"}),onClick:A})}),u&&r.jsx(ut,{reference:i,title:o,description:l,onReferenceClick:A,shouldCloseTooltip:x}),s&&r.jsx(Xn,{locale:e?.locale,metadata:D,metadataDescription:e?.metadataSettings?.isMetadataDescription?R:[],isOpenMetadata:s,onCloseMetadata:I})]})},Wu=(e,t)=>{const n=$u(e),s=y.getStructureComponentsMap(n),a=e?.valueFormatted||e?.value,i=Lt(t,s,e?.locale),o=[Ot(n?.dataflows?.[0],e?.locale,e?.titles),...Lt(Ui(e,s),s,e?.locale),...e?.metadataSettings?.isMetadataDescription?[]:[Hi(n,e?.locale,e?.colDef),Bi(a,e?.titles)],...i],c=e?.metadataSettings?.isMetadataDescription?Gi(n,e?.locale,a,e?.titles,e?.colDef,e?.data):[],l=n?.dataflows?.[0],f=Vt(y.getLastUpdatedTime(l),e?.locale),u=_t(l,f,e?.locale,e?.titles);return{metadata:o,metadataDescription:c,sidePanelDatasetInfo:u}},$u=e=>{if(e.structuresMap){const t=e?.data?.dataset?.urn;return t!=null?e.structuresMap.get(t):void 0}return e.dataSetData},Ju="observation-metadata-side-panel",Ku=({params:e,obsAttributes:t})=>{const{titles:n}=ye(),[s,a]=d.useState(null),{isOpenedAdvancedView:i}=We(),o=pt(),{isMetadataInSidePanel:c}=Be(),l=e?.data?.dataset?.urn,f=hn(e?.context,l),u=d.useCallback(()=>{const m=Wu(e,t);if(c&&o){o.openPanel({id:Ju,scope:i?"advanced":"conversation",title:n?.metadata||"Metadata",bodyClassName:"overflow-hidden",content:r.jsx(Ft,{locale:e?.locale,metadata:m.metadata,datasetInfo:m.sidePanelDatasetInfo,externalLink:f,metadataDescription:m.metadataDescription})});return}a(m)},[c,i,f,t,e,o,n]),h=d.useCallback(()=>{a(null)},[]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative size-full p-2 text-end",children:[e?.valueFormatted||e?.value,r.jsx("div",{className:"metadata-indicator",title:n?.metadata||"View details",onClick:u})]}),s&&r.jsx(Xn,{locale:e?.locale,metadata:s.metadata,metadataDescription:s.metadataDescription,isOpenMetadata:!0,onCloseMetadata:h})]})},eo=e=>{const t=zd(e);return t?.length?r.jsx(Ku,{params:e,obsAttributes:t}):r.jsx("div",{className:"relative size-full p-2 text-end",children:e?.valueFormatted||e?.value})},to=({ref:e,fixHeight:t,gridHeight:n,children:s})=>r.jsx("div",{ref:e,className:z("ag-theme-quartz w-full min-h-[80px]",t?"max-h-[400px]":"max-h-full"),style:{height:n},children:s}),Yu=({attachment:e,isDataLoading:t,isChartColumnVisible:n,fixHeight:s,externalLink:a,showLimitMessage:i,onApiReady:o})=>{const{titles:c}=ye(),[l,f]=d.useState(!1),[u,h]=d.useState([]),[m,p]=d.useState(),[g,b]=d.useState(400),C=d.useRef(null),[x,w]=d.useState(""),[v,S]=d.useState(""),[k,T]=d.useState(!1),{isShowOnboarding:N,onboardingFileSchema:D,setOnboardingFileSchema:R}=qe();d.useEffect(()=>{if(e.grid_data==null)f(!0);else{const L=e.grid_data.columns.map(W=>W.colId===It?{...W,hide:!n}:W);h(e.grid_data.data),p(L),f(!1)}},[e.grid_data,n]),d.useEffect(()=>{u?(b(Zn(u.length)),i?.(u.length>=M.SERIES_LIMIT)):i?.(!1)},[u,i]),d.useEffect(()=>{if(N){const{title:L,description:W}=dt(Oe.DATA_GRID,c);w(L),S(W)}},[c,N]),d.useEffect(()=>{D&&!D?.infoElements?.dataGrid&&R?.({...D,infoElements:{...D?.infoElements,dataGrid:!0},lastDisplayedElement:Oe.DATA_GRID})},[D,R]),d.useEffect(()=>{if(N){const L=D?.lastDisplayedElement===Oe.DATA_GRID;T(L),!l&&!t&&L&&setTimeout(()=>{C?.current?.scrollIntoView({block:"end",behavior:"smooth"})})}},[D?.lastDisplayedElement,N,t,l]);const E=d.useCallback(L=>{o?.(L.api)},[o]),A=d.useMemo(()=>({externalLink:a}),[a]),I=d.useMemo(()=>({[mn]:Qi,[fn]:eo,[Li]:qn}),[]),O=d.useMemo(()=>r.jsx(Vn.AgGridReact,{onGridReady:E,headerHeight:Rt,rowHeight:un,rowData:u,enableCellTextSelection:!0,columnDefs:m,context:A,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",components:I,valueCache:!0}),[u,m,E,A,I]);return l||t?r.jsx(M.Loader,{}):r.jsxs("div",{className:"size-full",children:[r.jsx(to,{ref:C,fixHeight:s,gridHeight:g,children:O}),k&&r.jsx(ut,{reference:C,title:x,description:v,supressReferenceClick:!0})]})};function Pt(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 qu=200,Zu=8,Xu=2,Qu=({currentIndex:e,totalCount:t,icons:n,onPrev:s,onNext:a})=>{const{titles:i}=ye(),o=d.useRef(null),[c,l]=d.useState(""),[f,u]=d.useState(""),[h,m]=d.useState(!1),{onboardingFileSchema:p,isShowOnboarding:g}=qe();d.useEffect(()=>{if(g){const{title:w,description:v}=dt(Oe.CHARTS_NAVIGATION,i);l(w),u(v)}},[i,g]),d.useEffect(()=>{if(g){const w=p?.lastDisplayedElement===Oe.CHARTS_NAVIGATION;m(w),w&&o?.current?.scrollIntoView({block:"center",behavior:"smooth"})}},[p?.lastDisplayedElement,g]);const b=t>0?e/t*100:0,C=t>0?Math.min(Zu*t,qu):0,x=t>0?Math.max(C/t,Xu):0;return r.jsxs("div",{className:"flex w-full flex-row items-center justify-center gap-2",children:[r.jsx("div",{className:z("h-[20px] w-[20px] cursor-pointer",e===0?"text-neutrals-700":"text-primary"),onClick:s,children:n?.[Qt.PREVIOUS]}),r.jsxs("div",{className:"flex flex-col items-center gap-1 pt-[20px]",children:[r.jsx("div",{className:"relative h-[4px] rounded-full bg-neutral-300",style:{width:`${C}px`},children:r.jsx("div",{className:"absolute h-full rounded-full bg-primary",style:{left:`${b}%`,width:`${x}px`}})}),r.jsxs("h5",{className:"text-neutrals-800",children:[e+1,"/",t]})]}),r.jsx("div",{className:z("h-[20px] w-[20px] cursor-pointer",e+1===t?"text-neutrals-700":"text-primary"),onClick:a,ref:o,children:n?.[Qt.NEXT]}),h&&r.jsx(ut,{reference:o,title:c,description:f})]})},ef=({limitAmount:e,openAdvancedView:t,prefixIcon:n,contentClassName:s})=>{const{titles:a}=ye(),[i,o]=d.useState(!1),{refs:c,floatingStyles:l,context:f}=Xe.useFloating({open:i,onOpenChange:o,placement:"top-start"}),u=Xe.useHover(f,{handleClose:Xe.safePolygon({blockPointerEvents:!0})}),{getReferenceProps:h,getFloatingProps:m}=Xe.useInteractions([u]);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex w-fit",ref:c.setReference,...h(),children:r.jsxs("div",{className:tt("mt-1 flex w-fit items-center gap-1 bg-hues-100 px-4 py-2",s),children:[n,r.jsx("h5",{className:"font-bold",children:a?.limits||"Limited to"}),r.jsxs("h5",{children:[e," ",a?.timeseriesLimit||"Timeseries"]})]})}),i&&r.jsx("div",{className:"floating",ref:c.setFloating,style:l,...m(),children:r.jsxs("div",{className:"z-10 mb-2 flex w-[300px] flex-col gap-2 rounded bg-white p-4 shadow",children:[r.jsxs("div",{children:[r.jsxs("h5",{className:"text-neutrals-900",children:[r.jsx("span",{className:"pr-0.5",children:a?.limitLinkInfoP1_1||"The number of timeseries displayed in a single chart i"}),r.jsxs("span",{className:"pr-0.5 font-bold",children:[a?.limitLinkInfoP1_2||"limited to"," ",e]}),a?.limitLinkInfoP1_3||"for better clarity and performance."]}),r.jsxs("h5",{className:"text-neutrals-900",children:[r.jsx("span",{className:"pr-0.5",children:a?.limitLinkInfoP2_1||"To visualize specific timeseries"}),r.jsx("span",{className:"pr-0.5 font-bold",children:a?.limitLinkInfoP2_2||"filter"}),r.jsx("span",{className:"pr-0.5",children:a?.limitLinkInfoP2_3||"your request, or"}),r.jsx("span",{className:"pr-0.5 font-bold",children:a?.limitLinkInfoP2_4||"refine"}),a?.limitLinkInfoP2_5||"it in the chat."]})]}),t&&r.jsx("h4",{className:"cursor-pointer text-primary",onClick:t,children:a?.limitLinkInfoLink||"Open Advanced View"})]})})]})};function tf(e,t,n){const s=(e.getZr()?.painter).getRenderedCanvas()?.getContext("2d");if(!s)return 0;const a=n.textStyle?.fontSize??12,i=n.textStyle?.fontFamily??"sans-serif";s.font=`${a}px ${i}`;const o=s.measureText(t).width,c=n.itemWidth??25,l=n.itemGap??10;return o+c+l}const nf=({option:e,style:t})=>{const n=d.useRef(null),[s,a]=d.useState(e);d.useEffect(()=>{a(_n.cloneDeep(e))},[e]);const i=d.useCallback(()=>{const o=n.current?.getEchartsInstance?.();if(!o)return;const l=o.getDom().clientWidth,f=e.legend||{},u=f.itemHeight??14,h=f.textStyle?.fontSize??12,m=o.getModel()?.getComponent("legend")?.getData()||[];let p=0;m.forEach(x=>{const w=x.option.name||"";p+=tf(o,w,f)});const b=Math.max(1,Math.ceil(p/l))*(+u+ +h+6),C=20;a(x=>({...x,grid:{...x.grid||{},bottom:b+C}}))},[e.legend]);return d.useEffect(()=>{i();const o=()=>{i()};return window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o)}},[e,i]),r.jsx(Ja,{notMerge:!0,lazyUpdate:!1,ref:n,option:s,style:t})},sf=({attachment:e,icons:t,isDataLoading:n,openAdvancedView:s,fixHeight:a=!0,limitationInfoPrefixIcon:i,limitationInfoContentClassName:o})=>{const{titles:c}=ye(),[l,f]=d.useState(!0),[u,h]=d.useState(),[m,p]=d.useState([]),[g,b]=d.useState(0),[C,x]=d.useState(void 0),[w,v]=d.useState(),{onboardingFileSchema:S,isShowOnboarding:k,setOnboardingFileSchema:T}=qe(),N=d.useRef(null),{charting_data:D,getChartingData:R}=e;d.useEffect(()=>{if(b(0),D){h(D),f(!1);return}if(!R){h(void 0),f(!0);return}return f(!0),Pt(()=>{try{h(R())}catch(I){console.error("Error building chart data",I),h({units:[]})}finally{f(!1)}})},[D,R]),d.useEffect(()=>{const I=u?.groups??[],O=u?.units??[];p(I.length>0?I.flatMap(L=>L.units.map(W=>({unit:W,groupTitle:L.title}))):O.map(L=>({unit:L})))},[u]),d.useEffect(()=>{const I=m.length>g,O=I?m[g]:m[0];x(!l&&O!=null?O.unit:void 0),v(O?.groupTitle),I||b(0)},[l,m,g]),d.useEffect(()=>{S&&k&&!l&&(Rc(S)&&(T?.(Pc(S)),N?.current?.scrollIntoView({block:"center",behavior:"smooth"})),S.lastDisplayedElement===Oe.CHART_PER_SERIES&&T?.(bi(S)))},[l,T,S,k]);const E=d.useCallback(()=>{b(I=>Math.min(I+1,m.length-1))},[m.length]),A=d.useCallback(()=>{b(I=>Math.max(I-1,0))},[]);return l||n?r.jsx(M.Loader,{}):r.jsx("div",{className:"chart-attachment size-full",ref:N,children:u&&r.jsx("div",{className:"flex size-full flex-col gap-4",children:m.length==0||C==null?r.jsx("h4",{className:"ml-1",children:c?.chartInfo||"No data"}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("h3",{className:"chart-attachment-title",children:[c?.chart||"Chart"," ",g+1,"/",m.length]}),r.jsx("span",{className:"h4 chart-attachment-info text-neutrals-700",children:c?.chartInfo||"Chart Information"})]}),r.jsxs("div",{className:z("chart-area overflow-hidden flex flex-row gap-4 h-full ",a&&"max-h-[400px] min-h-[400px]",!a&&"min-h-[300px]"),children:[r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[w&&r.jsxs("div",{className:"mb-1 flex items-center gap-1",children:[r.jsx(Wn,{className:"size-4 shrink-0 text-neutrals-1000"}),r.jsx("h4",{className:"text-neutrals-1000",children:w})]}),r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[r.jsx(nf,{option:C.config,style:{width:"100%",height:"100%",minHeight:0}}),C.limitedByRowsAmountTo&&r.jsx(ef,{limitAmount:C.limitedByRowsAmountTo,openAdvancedView:s,prefixIcon:i,contentClassName:o}),m.length>1&&r.jsx(Qu,{icons:t,currentIndex:g,totalCount:m.length,onNext:E,onPrev:A})]})]}),r.jsx(Ii,{dimensionsInfo:C.dimensions})]})]})})})},af=({attachment:e,className:t})=>{const{data:n,language:s}=e,a=(i,o)=>{i.addCommand(o.KeyCode.F1,()=>{})};return r.jsx("div",{className:tt(["h-full w-full [&_.cursors-layer]:hidden",t]),children:r.jsx(ko.Editor,{value:n,language:s,theme:"vs-light",onMount:a,options:{readOnly:!0,contextmenu:!1,scrollBeyondLastLine:!1,minimap:{enabled:!1},wordWrap:"on",automaticLayout:!0,tabSize:2}})})},rf="Dataset",Na="dataset_name",of="Agency",ka="agency",lf="Country dimensions",Ut="country_aggregated",cf="Indicator dimensions",Ht="indicator_aggregated",df="Frequency",pn="frequency_aggregated",no=".";function ja(e){return{columnState:e.getColumnState(),columnGroupState:e.getColumnGroupState()??[]}}function uf(e,t){t&&(e.applyColumnState({state:t.columnState,applyOrder:!0}),e.setColumnGroupState(t.columnGroupState))}const Ia=["columnVisible","columnMoved","displayedColumnsChanged","newColumnsLoaded","gridColumnsChanged","columnPinned"];function so(e,t){d.useEffect(()=>{if(e){for(const n of Ia)e.addEventListener(n,t);return()=>{for(const n of Ia)e.removeEventListener(n,t)}}},[e,t])}function ff({currentUrn:e}){const[t,n]=d.useState(),[s,a]=d.useState(null),i=d.useRef(new Map),o=d.useRef(new Map),c=d.useCallback(h=>{if(n(h),i.current.has(e))s==null&&a(i.current.get(e)??null);else{const p=ja(h);i.current.set(e,p),a(p)}const m=o.current.get(e);m&&(h.applyColumnState({state:m.columnState,applyOrder:!0}),m.columnGroupState!=null&&h.setColumnGroupState(m.columnGroupState))},[e]);d.useEffect(()=>{a(i.current.get(e)??null)},[e]);const l=d.useCallback(()=>{t&&o.current.set(e,ja(t))},[e,t]),f=d.useCallback(()=>{o.current.delete(e)},[e]),u=d.useCallback(()=>{i.current.delete(e),a(null)},[e]);return so(t,l),{gridApi:t,onGridApiReady:c,initialColumnsState:s,clearUserColumnState:f,clearInitialColumnState:u}}var Qe=(e=>(e.Compact="compact",e.Extended="extended",e))(Qe||{});const ts=d.createContext(null);function mf({currentUrn:e,structuresMap:t,locale:n,dataQueries:s,gridViewMode:a=Qe.Compact,onGridViewModeChange:i,texts:o,resetIcon:c,children:l}){const{gridApi:f,onGridApiReady:u,initialColumnsState:h,clearUserColumnState:m,clearInitialColumnState:p}=ff({currentUrn:e}),g=d.useCallback(T=>i?.(T),[i]),[b,C]=d.useState(new Map),x=d.useCallback((T,N,D)=>{C(R=>{const E=new Map(R),A=new Map(E.get(T)??[]),I=A.get(N)??{order:[],hidden:new Set};return A.set(N,D(I)),E.set(T,A),E}),f?.refreshCells({columns:[N]})},[f]),w=d.useCallback((T,N,D)=>{x(T,N,R=>({...R,order:D}))},[x]),v=d.useCallback(()=>{C(new Map)},[]),S=d.useCallback((T,N,D,R)=>{x(T,N,E=>{const A=new Set(E.hidden);return R?A.add(D):A.delete(D),{...E,hidden:A}})},[x]),k=d.useMemo(()=>({gridApi:f,onGridApiReady:u,initialColumnsState:h,structuresMap:t,locale:n,dataQueries:s,dimensionCustomization:b,setDimensionKeyOrder:w,setDimensionKeyHidden:S,resetDimensionCustomization:v,clearUserColumnState:m,clearInitialColumnState:p,gridViewMode:a,setGridViewMode:g,texts:o,resetIcon:c}),[f,h,u,t,n,s,b,w,S,v,m,p,a,g,o,c]);return r.jsx(ts.Provider,{value:k,children:l})}function ns(){const e=d.useContext(ts);if(!e)throw new Error("useTableSettingsContext must be used within TableSettingsProvider");return e}const hf=()=>d.useContext(ts);function gn(e,t,n){const s=y.getConcept(e.conceptIdentity,t),a=e?.localRepresentation?.enumeration,i=s?.coreRepresentation?.enumeration,o=a||i,c=y.getArtifactByUrnWithWildCard(o,n);return{concept:s,codeList:c||void 0}}function ao(e,t,n){const s=e.findIndex(a=>a.id===t);return n.originalData.parsedTimeSeriesValue[s]}function ss(e,t,n,s,a){const i=ao(e,t,s),o=n?.codes?.find(c=>c.id===i);return y.getLocalizedName(o,a)}function pf(e,t,n,s,a=Qe.Compact){const i=a===Qe.Extended?vf(e,t,n):[Cf(e,t,n,s)];return[gf(e,t,n,s),...i,wf(e,t,n,s),...xf(e,t,n)]}function gf(e,t,n,s){const a=i=>{const{structures:o,urn:c,data:l}=Bt(i,e),f=t.get(c)?.region;return l==null||c==null||o==null||f==null?"":St(o,f,l,n)};return Cn(s?.countryDimensions||lf,Ut,a,e,t,n,s)}function Cf(e,t,n,s){const a=i=>{const{structures:o,urn:c,data:l}=Bt(i,e),f=t.get(c)?.indicators;return l==null||c==null||o==null||f==null||f.length===0?"":f.map(h=>St(o,h,l,n)||"").join(no)};return Cn(s?.indicatorDimensions||cf,Ht,a,e,t,n,s)}function wf(e,t,n,s){const a=i=>{const{structures:o,urn:c,data:l}=Bt(i,e),f=t.get(c)?.frequency;return l==null||c==null||o==null||f==null?"":St(o,f,l,n)};return Cn(s?.frequency||df,pn,a,e,t,n,s)}function xf(e,t,n){const s=new Set;return t.forEach(a=>{a?.other?.forEach(i=>{s.add(i)})}),Array.from(s).map(a=>bf(a,e,t,n))}function vf(e,t,n){const s=new Set;return t.forEach(a=>{a?.indicators?.forEach(i=>{s.add(i)})}),Array.from(s).map(a=>{const i=o=>{const{structures:c,urn:l,data:f}=Bt(o,e),u=t.get(l)?.indicators??[];return f==null||l==null||c==null||!u.includes(a)?"":St(c,a,f,n)};return{headerName:ro(a,e,n),field:a,colId:a,valueGetter:i,...Ct,cellClass:ht,tooltipValueGetter:o=>o.value}})}function bf(e,t,n,s){const a=i=>{const{structures:o,urn:c,data:l}=Bt(i,t),f=n.get(c)?.other??[];return l==null||c==null||o==null||!f.includes(e)?"":St(o,e,l,s)};return{...Cn(ro(e,t,s),e,a,t,n,s),hide:!0}}function ro(e,t,n){for(const s of t.values()){if(!s)continue;const i=(y.getDimensions(s)?.dimensions||[]).find(o=>o.id===e);if(i)return y.getDimensionTitle(s.conceptSchemes,i,n)??e}return e}function Cn(e,t,n,s,a,i,o){return{headerName:e,field:t,colId:t,valueGetter:n,...Ct,cellClass:ht,cellRenderer:Pi,tooltipValueGetter:c=>c.value,cellRendererParams:{structuresMap:s,datasetDimensionsSchemesMap:a,locale:i,titles:o,colId:t}}}function Bt(e,t){const{data:n}=e,s=n?.dataset?.urn,a=s==null?void 0:t.get(s);return{data:n,urn:s,structures:a}}function St(e,t,n,s){const a=e.conceptSchemes||[],i=e.codelists||[],o=y.getDimensions(e)?.dimensions||[],c=o.find(f=>f.id===t);if(c==null)return;const{codeList:l}=gn(c,a,i);return ss(o,t,l,n,s)}const rn="::";function Sf(e,t){return`${e}${rn}${t}`}function La(e){return e.includes(rn)}function En(e){const t=e.indexOf(rn);return{urn:e.slice(0,t),dimensionKey:e.slice(t+rn.length)}}const yf=new Set([Ht]);function io(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 Df(e,t,n){const s=n(t);return s?e===Ht?s.indicators:e===Ut?s.region?[s.region]:[]:e===pn?s.frequency?[s.frequency]:[]:[]:[]}function Mf(e,t,n){const s=e.getDimensionConfig(t,n);if(s?.alias)return s.alias;const a=e.structuresMap.get(t),o=(a?y.getDimensions(a)?.dimensions??[]:[]).find(c=>c.id===n);return y.getDimensionTitle(a?.conceptSchemes??[],o,e.locale)??n}function Tf(e){const t=e.enrichedColIds??yf;return n=>{if(!t.has(n.id))return n;const s=[];for(const{urn:a}of e.dataQueries){const i=Df(n.id,a,e.getDimensionsScheme);if(!i.length)continue;const o=e.dimensionCustomization?.get(a)?.get(n.id),c=o?.order.length?io(i,{order:o.order,hidden:new Set}):i,l=c.length>1,f=c.map(m=>({id:Sf(a,m),type:"item",label:Mf(e,a,m),isChecked:!o?.hidden.has(m),draggable:l,checkable:l})),u=e.structuresMap.get(a),h=y.getLocalizedName(u?.dataflows?.[0],e.locale)??a;s.push({id:a,type:"group",label:h,items:f})}return s.length?{...n,items:s}:n}}function Pa(e,t){return e===Ht?t.indicators??[]:e===Ut?t.region?[t.region]:[]:e===pn?t.frequency?[t.frequency]:[]:t.other?.includes(e)?[e]:[]}function Ef(e,t){return e===Ht?t?.indicatorMetadataPanel||"Indicator dimension details":e===Ut?t?.countryMetadataPanel||"Country dimension details":t?.metadata||"Metadata"}const Af="merged-dimension-metadata-side-panel",Nf=e=>{const{titles:t}=ye(),{isOpenedAdvancedView:n}=We(),s=pt(),{isMetadataInSidePanel:a}=Be(),i=hf(),o=e?.data?.dataset?.urn,c=hn(e?.context,o),l=o!=null?e.structuresMap.get(o):void 0,f=o!=null?e.datasetDimensionsSchemesMap.get(o):void 0,u=i?.dimensionCustomization,h=d.useMemo(()=>{if(!l||!f||o==null)return e.valueFormatted??e.value;const C=u?.get(o)?.get(e.colId);return io(Pa(e.colId,f),C).map(v=>St(l,v,e.data,e.locale)).filter(Boolean).join(no)},[u,l,f,o,e.valueFormatted,e.value,e.colId,e.data,e.locale]),m=d.useMemo(()=>{if(!l||!f)return[];const C=Pa(e.colId,f),x=y.getStructureComponentsMap(l),w=C.filter(v=>e.data[v]!=null).map(v=>({name:v,value:String(e.data[v])}));return Lt(w,x,e.locale)},[l,f,e.colId,e.data,e.locale]),p=d.useMemo(()=>{const C=l?.dataflows?.[0];if(!C)return;const x=Vt(y.getLastUpdatedTime(C),e.locale);return _t(C,x,e.locale,t)},[l,e.locale,t]),g=a&&!!s&&!!e.value&&![pn,Ut].includes(e.colId),b=d.useCallback(()=>{s&&s.openPanel({id:Af,scope:n?"advanced":"conversation",title:Ef(e.colId,t),bodyClassName:"overflow-hidden",content:r.jsx(Ft,{locale:e.locale,metadata:m,datasetInfo:p,externalLink:c})})},[s,n,e.colId,t,e.locale,m,p,c]);return r.jsxs("div",{className:"relative size-full p-2",children:[h,g&&r.jsx("div",{className:"metadata-indicator",title:t?.metadata||"View details",onClick:b})]})},kf="dataset-detail-metadata-side-panel",jf=e=>{const{titles:t}=ye(),{isOpenedAdvancedView:n}=We(),s=pt(),{isMetadataInSidePanel:a}=Be(),i=e?.data?.dataset?.urn,o=hn(e?.context,i),c=i!=null?e.structuresMap.get(i):void 0,l=i!=null?e.attributesDataMap?.get(i):void 0,f=d.useMemo(()=>{const p=c?.dataflows?.[0];if(!p)return;const g=Vt(y.getLastUpdatedTime(p),e.locale);return _t(p,g,e.locale,t)},[c,e.locale,t]),u=d.useMemo(()=>Wi(zi(l),y.getStructureComponentsMap(c),e.locale),[l,c,e.locale]),h=a&&!!s&&!!e.value,m=d.useCallback(()=>{s&&s.openPanel({id:kf,scope:n?"advanced":"conversation",title:t?.datasetMetadataPanel||"Dataset Metadata",bodyClassName:"overflow-hidden",content:r.jsx(Ft,{locale:e.locale,metadata:u,datasetInfo:f,externalLink:o})})},[s,n,u,f,o,t,e.locale]);return r.jsxs("div",{className:"relative size-full p-2",children:[e.valueFormatted??e.value,h&&r.jsx("div",{className:"metadata-indicator",title:t?.metadata||"View details",onClick:m})]})},If=({attachment:e,isDataLoading:t,isChartColumnVisible:n,fixHeight:s,externalLink:a,externalLinksMap:i,showLimitMessage:o,onApiReady:c})=>{const[l,f]=d.useState(!1),[u,h]=d.useState([]),[m,p]=d.useState(),[g,b]=d.useState(400),C=d.useRef(null),x=d.useRef([]);d.useEffect(()=>{if(e.gridContent==null)f(!0);else{const T=e.gridContent.columns.map(N=>N.colId===It?{...N,hide:!n}:N);h(e.gridContent.data),p(T),f(!1)}},[e.gridContent,n]),d.useEffect(()=>{u?(b(Zn(u.length)),o?.(u.length>=M.SERIES_LIMIT)):o?.(!1)},[u,o]),d.useEffect(()=>{if(!m||!C.current)return;const T=m.map(E=>E.colId??E.field??"").filter(Boolean),N=x.current,D=new Set(N),R=T.length!==N.length||T.some(E=>!D.has(E));x.current=T,R&&C.current.resetColumnState()},[m]);const w=d.useCallback(T=>{C.current=T.api,c?.(T.api)},[c]),v=d.useMemo(()=>({externalLink:a,externalLinksMap:i}),[a,i]),S=d.useMemo(()=>({[mn]:Qi,[fn]:eo,[Pi]:Nf,[Li]:qn,[Ri]:jf}),[]),k=d.useMemo(()=>r.jsx(Vn.AgGridReact,{headerHeight:Rt,rowHeight:un,rowData:u,enableCellTextSelection:!0,columnDefs:m,context:v,domLayout:"normal",tooltipShowDelay:0,tooltipShowMode:"whenTruncated",components:S,valueCache:!0,onGridReady:w}),[u,m,v,S,w]);return l||t?r.jsx(M.Loader,{}):r.jsx("div",{className:"size-full",children:r.jsx(to,{fixHeight:s,gridHeight:g,children:k})})},Lf=({selectedAttachment:e,actions:t,attachmentsStyles:n,isDataLoading:s,externalLink:a,externalLinksMap:i,isOpenedAdvancedView:o,onOpenAdvancedView:c,showLimitMessage:l,onGridApiReady:f})=>r.jsxs("div",{className:"flex min-h-0 w-full flex-1 justify-center",children:[Oc(e)&&r.jsx(Cd,{actions:t,downloadTitles:n?.downloadTitle,attachment:e}),Kn(e)&&r.jsx(Fd,{actions:t,attachment:e,showLimitMessage:l}),ct(e)&&r.jsx(Yu,{attachment:e,isDataLoading:s,isChartColumnVisible:o,fixHeight:!o,showLimitMessage:l,onApiReady:f,externalLink:a}),mt(e)&&r.jsx(If,{attachment:e,isDataLoading:s,isChartColumnVisible:o,fixHeight:!o,showLimitMessage:l,onApiReady:f,externalLink:a,externalLinksMap:i}),Zt(e)&&r.jsx(sf,{isDataLoading:s,attachment:e,icons:n?.chartingIcons,openAdvancedView:o?void 0:c,fixHeight:!o,limitationInfoPrefixIcon:n?.limitationInfoIcon,limitationInfoContentClassName:n?.limitationInfoContentClassName}),Jn(e)&&r.jsx(Md,{attachment:e,openLinkTitle:n?.openLinkTitle}),Di(e)&&r.jsx(bd,{attachment:e}),Yn(e)&&r.jsx(af,{attachment:e,className:n?.codeAttachmentContainerClassName})]}),Pf=({isOpen:e,alertDetails:t,attachmentsStyles:n,onClose:s})=>{if(!e)return null;const a=t?.progress&&t.progress.total>0?`${Math.min(100,Math.max(0,t.progress.current/t.progress.total*100))}%`:"0%";return r.jsx(M.Alert,{alertDetails:t,infoIcon:n?.infoDownloadIcon,successIcon:n?.successDownloadIcon,errorIcon:n?.errorDownloadIcon,onClose:s,closeButtonTitle:n?.closeTitle||"Close",children:r.jsxs(r.Fragment,{children:[t?.text&&r.jsx("div",{className:"alert-text whitespace-pre-line break-words",title:t.text,children:t.text}),t?.progress&&r.jsx("div",{className:"alert-progress",children:r.jsx("div",{className:"alert-progress-value",style:{width:a}})}),t?.action&&r.jsxs("button",{type:"button",className:"alert-action",disabled:t.action.disabled,onClick:t.action.onClick,title:t.action.title,children:[t.action.icon&&r.jsx("span",{className:"alert-action-icon",children:t.action.icon}),r.jsx("span",{className:"alert-action-text",children:t.action.text})]})]})})},Rf=({attachmentsStyles:e,onCancel:t,onRetry:n})=>{const s=d.useCallback(p=>e?.downloadTitles?.downloadStartedText?.(p.dataFormatTitle)??`Preparing ${p.dataFormatTitle} file.`,[e?.downloadTitles]),a=d.useCallback((p,g)=>e?.downloadTitles?.downloadInProgressTitle?.(p,g)??`Downloading file ${p} of ${g}`,[e?.downloadTitles]),i=d.useCallback((p,g)=>e?.downloadTitles?.downloadInProgressText?.(p,g)??`${p} · ${g}`,[e?.downloadTitles]),o=d.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=d.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=d.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]),f=d.useCallback(p=>({type:M.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=d.useCallback((p,g,b,C)=>({type:M.AlertType.IN_PROGRESS,title:a(g,p.items.length),text:i(C,p.dataFormatTitle),progress:{current:b,total:p.items.length},action:{text:e?.downloadTitles?.downloadCancelActionText??e?.downloadTitles?.cancel??"Cancel",icon:e?.downloadInProgressActionIcon,onClick:t}}),[e?.downloadInProgressActionIcon,e?.downloadTitles,i,a,t]),h=d.useCallback(p=>({type:M.AlertType.SUCCESS,title:o(p),text:c(p)}),[c,o]),m=d.useCallback(p=>({type:M.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:f,getInProgressAlertDetails:u,getSuccessAlertDetails:h,getErrorAlertDetails:m}},Ff=300,Of=({attachmentsStyles:e,downloadDataSet:t})=>{const[n,s]=d.useState(),[a,i]=d.useState(!1),[o,c]=d.useState(),l=d.useRef(null),f=d.useRef(null),u=d.useRef(null),h=d.useRef(!1),m=d.useRef(!1),p=d.useCallback(D=>{c(D),s(!0)},[]),g=d.useCallback(()=>{s(!1)},[]),b=d.useCallback(()=>{m.current=!0,l.current?.abort(),g()},[g]),C=d.useCallback(()=>{const D=f.current;!D||!u.current||u.current(D)},[]),x=d.useCallback(D=>(D instanceof DOMException||D instanceof Error)&&D.name==="AbortError",[]),{getStartedAlertDetails:w,getInProgressAlertDetails:v,getSuccessAlertDetails:S,getErrorAlertDetails:k}=Rf({attachmentsStyles:e,onCancel:b,onRetry:C}),T=d.useCallback(async D=>{if(!h.current){h.current=!0,i(!0),m.current=!1,f.current=null;try{const R=[],E=D.items.length>1;E||p(w(D));for(const[A,I]of D.items.entries()){if(m.current)return;E&&p(v(D,A+1,A,I.name));const O=new AbortController;l.current=O;try{await t(I.urn,D.dataFormat,D.language,D.attribute,I.filters,I.fileName,D.isMetadata,O.signal)}catch(L){if(x(L)&&m.current)return;R.push(I),console.error("Failed to download dataset",L)}finally{l.current===O&&(l.current=null)}A<D.items.length-1&&await new Promise(L=>window.setTimeout(L,Ff))}if(m.current)return;if(R.length>0){const A={...D,items:R};f.current=A,p(k(A));return}p(S(D))}finally{l.current=null,h.current=!1,i(!1)}}},[t,k,v,w,S,x,p]);return d.useEffect(()=>{u.current=T},[T]),d.useEffect(()=>()=>{m.current=!0,l.current?.abort()},[]),{startDownload:d.useCallback(D=>h.current?!1:(T(D),!0),[T]),isDownloadRunning:a,downloadAlertProps:{isOpen:n,alertDetails:o,attachmentsStyles:e,onClose:g}}};qs.ModuleRegistry.registerModules([qs.AllCommunityModule]);const oo=({attachments:e,actions:t,isSystemAttachments:n,isShowAttachments:s,showAdvancedView:a,currentDataQuery:i,dataQueries:o,attachmentInfoList:c,datasets:l,initialSelectedDatasetUrn:f,isDataLoading:u,isDataSetAttachments:h,locale:m,dimensions:p,filters:g,selectDataset:b,onAdvancedViewOpen:C,isTableSettingsOpen:x,onTableSettingsOpen:w,onTableSettingsClose:v,onGridApiReady:S})=>{const{titles:k,messageStyles:T,attachmentsStyles:N,limitMessages:D,attachmentsConfig:R}=ye(),[E,A]=d.useState(0),[I,O]=d.useState(null),{isOpenedAdvancedView:L,setIsOpenedAdvancedView:W}=We(),[$,q]=d.useState(M.PopUpState.Closed),[U,J]=d.useState(!1),[G,te]=d.useState(!1),ne=y.DownloadType.DATA_IN_TABLE,fe=B=>{A(B)},xe=d.useCallback(()=>{C?.(),W(!0),t.updateCurrentDataQuery(i||o?.[0]),t.updateDataQueries(o),t.updateDatasets(l)},[t,i,o,l,W,C]);d.useEffect(()=>{O(e[E]||null)},[e,E]),d.useEffect(()=>{J(h&&(l==null||l?.length==0))},[l,h]),d.useEffect(()=>{x&&I&&!ct(I)&&!mt(I)&&v?.()},[x,I,v]);const me=d.useCallback(()=>{q(M.PopUpState.Closed)},[q]),_=R?.isExternaLinkIncludeFilters,K=Rn(_,g,i||o?.[0],p),le=d.useMemo(()=>o?.length?new Map(o.map(oe=>[oe.urn,Rn(_,void 0,oe)])):void 0,[o,_]),de=d.useMemo(()=>{if(!I||!mt(I))return;const oe=I.gridContent?.data??[],ae=new Map,ge=new Map;for(const he of oe){const{dataset:ce,datasetTitle:De}=he,Ee=ce?.urn;Ee&&(ae.set(Ee,(ae.get(Ee)??0)+1),!ge.has(Ee)&&De&&ge.set(Ee,De))}return Array.from(ae.entries()).map(([he,ce])=>({urn:he,name:ge.get(he)??he,rowCount:ce,dataQuery:o?.find(De=>De.urn===he)}))},[I,o]),ue=d.useMemo(()=>{if(I){if(ct(I))return I.grid_data?.data?.length;if(mt(I))return I.gridContent?.data?.length}},[I]),{startDownload:se,isDownloadRunning:Q,downloadAlertProps:H}=Of({attachmentsStyles:N,downloadDataSet:t.downloadDataSet});return!e||e.length===0?null:r.jsx(r.Fragment,{children:L&&!s?r.jsx(qc,{icon:T?.advanceViewIcon,title:T?.openAdvanceViewTitle??"Opened in Advanced view"}):r.jsxs("div",{className:z("space-y-3 max-w-full max-h-full h-full",!L&&!n?"pt-5":"pt-0","flex flex-col pb-1"),children:[!L&&U?r.jsx(M.Loader,{}):r.jsxs(r.Fragment,{children:[n&&!L&&r.jsx(Yc,{titles:{queryUpdatedManuallyTitle:k?.queryUpdatedManually,setToTitle:k?.setTo,datasetLabel:k?.dataset},datasetIcon:N?.datasetIcon,attachmentInfoList:c,dataQueries:o}),!L&&l?.length!=null&&l?.length>0&&r.jsx(Ni,{datasets:l,initialSelectedDatasetUrn:f,locale:m,selectDataset:b}),G&&r.jsx(M.RequestLimitMessage,{limitMessages:D,showAdvancedViewButton:!!I&&Vc(I)&&a,onAdvancedViewClick:xe,query:K}),r.jsx("div",{className:z(!L&&l?.length&&"attachments-bordered","attachments-wrapper h-full min-h-0"),children:r.jsxs("div",{className:"flex h-full max-w-full flex-col items-center gap-4",children:[r.jsx(gd,{attachments:e,selectedAttachmentIndex:E,selectedAttachment:I,attachmentsStyles:N,externalLink:K,isExternalLinkIncludeFilters:_,limitMessages:D,onSelectedAttachmentChange:fe,onDownloadClick:()=>q(M.PopUpState.Opened),showAdvancedView:a,onOpenAdvancedView:xe,isTableSettingsOpen:x,onTableSettingsOpen:w}),I!=null&&r.jsx(Lf,{selectedAttachment:I,actions:t,attachmentsStyles:N,isDataLoading:u,isOpenedAdvancedView:L,onOpenAdvancedView:xe,showLimitMessage:te,onGridApiReady:S,externalLink:K,externalLinksMap:le})]})})]}),r.jsxs(r.Fragment,{children:[$===M.PopUpState.Opened&&r.jsx(sd,{onCloseModal:me,onDownloadStart:se,isDownloadInProgress:Q,dataQuery:i,datasetName:I?.title||"",locale:m,type:ne,dimensions:p,filters:g,urn:i?.urn,titles:N?.downloadTitles,rowCount:ue,collapsible:N?.downloadCollapsible,downloadDatasets:de,limitMessages:D,showLimitMessage:G,externalLink:K}),r.jsx(Pf,{...H})]})]})})},_f=({label:e,colDef:t})=>!!e.trim()&&!t.suppressColumnsToolPanel;function Vf(e){return e.colId??e.field??null}function Uf(e){return String(e.headerName??e.field??e.colId??"").trim()}function Hf(e){return new Map(e.getColumnState().map(t=>[t.colId,t]))}function Bf(e,t){const n=e.getColumnDefs()??[],s=Hf(e),a=[];for(const c of n){const l=Vf(c);if(!l)continue;const f=Uf(c);if(!t({colId:l,label:f,colDef:c}))continue;const u=s.get(l);a.push({id:l,type:"item",label:f,isChecked:!(u?.hide??!1),draggable:!0,checkable:!0})}const i=e.getColumnState().map(c=>c.colId),o=new Map(i.map((c,l)=>[c,l]));return a.sort((c,l)=>{const f=o.get(c.id)??Number.MAX_SAFE_INTEGER,u=o.get(l.id)??Number.MAX_SAFE_INTEGER;return f-u})}function Gf(e,t,n){const s=[...t];return e.map(a=>n.has(a)?s.shift()??a:a)}function An(e,t){let n=e,s;for(const a of t){if(s=n.find(i=>i.id===a),!s)return;n=s.type==="group"?s.items:s.items??[]}return s?.type==="item"?s:void 0}function zf(e){if(!e.items?.length)return e;const t=e.items.map(n=>{if(n.type!=="group")return n;const a=n.items.filter(o=>o.type==="item").filter(o=>o.isChecked!==!1);if(a.length!==1)return n;const[i]=a;return{...n,items:n.items.map(o=>o.type!=="item"?o:o===i?{...o,checkable:!1,draggable:!1}:{...o,draggable:!1})}});return t.every((n,s)=>n===e.items[s])?e:{...e,items:t}}function On(e,t){const n=[];for(const s of e){if(s.type==="group"){n.push(...On(s.items,t));continue}if(t?.(s)){n.push(s.id);continue}if(s.items?.length){n.push(...On(s.items,t));continue}n.push(s.id)}return n}function Wf({api:e,searchQuery:t,includeColumn:n=_f,enrichItem:s,onSubItemOrderChange:a,onSubItemVisibilityChange:i}){const[o,c]=d.useState(0),[l,f]=d.useState(new Set),u=d.useCallback(()=>{c(v=>v+1)},[]);so(e,u);const h=d.useMemo(()=>!e||!e.getColumnState()?[]:Bf(e,n),[e,n,o]),m=d.useMemo(()=>(s?h.map(S=>S.type==="item"?s(S):S):h).map(S=>S.type==="item"&&S.items?.length?{...S,isExpanded:l.has(S.id)}:S),[h,s,l]),p=d.useMemo(()=>new Set(h.map(v=>v.id)),[h]),g=d.useMemo(()=>M.filterDraggableListNodes(m,t),[m,t]),b=d.useCallback(v=>{if(!e)return;if(La(v.itemId)&&i){const{urn:k,dimensionKey:T}=En(v.itemId),N=v.path[0];i(k,N,T,!v.nextChecked);return}const S=An(m,v.path);!S||!p.has(S.id)||(e.applyColumnState({state:[{colId:S.id,hide:!v.nextChecked}]}),u())},[e,m,p,u,i]),C=d.useCallback(v=>{if(!e)return;if(La(v.itemId)&&i){const{urn:N,dimensionKey:D}=En(v.itemId),R=v.path[0],E=An(m,v.path);E?.type==="item"&&i(N,R,D,E.isChecked??!0);return}const S=An(m,v.path);if(!S||!p.has(S.id))return;const T=!(e.getColumnState().find(N=>N.colId===S.id)?.hide??!1);e.applyColumnState({state:[{colId:S.id,hide:T}]}),u()},[e,m,p,u,i]),x=d.useCallback(v=>{const S=v.path[v.path.length-1];f(k=>{const T=new Set(k);return v.nextExpanded?T.add(S):T.delete(S),T})},[]),w=d.useCallback(v=>{if(!e)return;const S=e.getColumnState().map(D=>D.colId),k=new Set(h.map(D=>D.id)),T=On(v,D=>p.has(D.id)),N=Gf(S,T,k);if(e.applyColumnState({state:N.map(D=>({colId:D})),applyOrder:!0}),u(),a){for(const D of v)if(!(D.type!=="item"||!p.has(D.id)||!D.items))for(const R of D.items){if(R.type!=="group")continue;const E=R.items.filter(O=>O.type==="item");if(E.length<=1)continue;const A=R.id,I=E.map(O=>En(O.id).dimensionKey);a(A,D.id,I)}}},[e,h,p,u,a]);return{items:m,visibleItems:g,handleToggleChecked:b,handleToggleExpanded:x,handleItemClick:C,handleItemsChange:w}}function $f({api:e,includeColumn:t,enrichItem:n,renderLabel:s,onSubItemOrderChange:a,onSubItemVisibilityChange:i,searchPlaceholder:o}){const[c,l]=d.useState(""),f=d.useCallback(w=>{l(w)},[l]),u=d.useCallback(()=>l(""),[l]),h=d.useMemo(()=>r.jsx("button",{type:"button",onClick:u,children:r.jsx(Ve.IconX,{className:"size-4 text-neutrals-1000"})}),[u]),m=d.useCallback(w=>{const v=n?n(w):w;return zf(v)},[n]),{visibleItems:p,handleItemsChange:g,handleToggleChecked:b,handleToggleExpanded:C,handleItemClick:x}=Wf({api:e,includeColumn:t,searchQuery:c,enrichItem:m,onSubItemOrderChange:a,onSubItemVisibilityChange:i});return r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 px-5",children:[r.jsx(M.InputWithIcon,{inputId:"columns-search-input",containerClasses:"items-center filters-search-input gap-1 !p-2",cssClass:"filters-search-input-text",placeholder:o||"Search",iconBeforeInput:r.jsx(Ve.IconSearch,{className:"size-4 text-neutrals-1000"}),iconAfterInput:c?h:void 0,value:c,onChange:f}),r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:r.jsx(M.DraggableList,{items:p,onItemsChange:g,onToggleChecked:b,onToggleExpanded:C,onItemClick:x,renderLabel:s})})]})}const Jf={},Kf={map:Jf,getDimensionsMetadata:()=>{},getDimensionMetadata:()=>{},getRegionDimension:()=>{},getFrequencyDimension:()=>{},getIndicatorDimensions:()=>[],getDimensionsScheme:()=>{}},as=d.createContext(Kf);function Yf({map:e,children:t}){const n=d.useMemo(()=>{const s={},a={},i={},o=Object.keys(e);for(const c of o){s[c]={},a[c]={};const l=Object.keys(e[c]);for(const f of l){const u=e[c][f];u.subtype&&(s[c][u.subtype]=f),a[c][u.dimensionType]||(a[c][u.dimensionType]=[]),a[c][u.dimensionType].push(f)}i[c]={timePeriod:a[c]?.TIME_PERIOD?.[0]??void 0,frequency:s[c]?.FREQUENCY??void 0,region:s[c]?.REGION??void 0,indicators:a[c]?.INDICATOR??[],other:(a[c]?.NON_INDICATOR??[]).filter(f=>{const u=e[c][f];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=>a[c]?.INDICATOR??[],getDimensionsScheme:c=>i[c]}},[e]);return r.jsx(as.Provider,{value:n,children:t})}function wn(){return d.useContext(as)}function xn(){return d.useContext(as)}function qf(){const{dataQueries:e,structuresMap:t,locale:n,gridViewMode:s}=ns(),a=xn(),i=d.useMemo(()=>{const o=new Map;if(!a||!e?.length)return o;for(const{urn:c}of e){const l=a.getDimensionsScheme(c),f=!!l?.other.length,u=s===Qe.Extended&&!!l?.indicators?.length;if(!f&&!u)continue;const h=n?y.getLocalizedName(t?.get(c)?.dataflows?.[0],n)??c:c,m=[...l?.other??[],...u?l?.indicators??[]:[]];for(const p of m){const g=o.get(p);g?g.push(h):o.set(p,[h])}}return o},[a,e,t,n,s]);return d.useMemo(()=>{if(!i.size)return;function o(c){const l=i.get(c.id);return l?.length?r.jsxs("span",{className:"flex w-full items-center gap-2 overflow-hidden",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",title:c.label,children:c.label}),r.jsx("span",{className:"h5 min-w-0 flex-1 truncate text-right text-neutrals-700",title:l.join(", "),children:l.join(", ")})]}):c.label}return o},[i])}var Ne=(e=>(e.Header="header",e.Cell="cell",e))(Ne||{}),Me=(e=>(e.Focus="focus",e.Default="default",e))(Me||{});const Zf="grid gap-1",Xf={gridTemplateColumns:"44px 23px 23px",gridTemplateRows:"repeat(4, 14px)"},Qf={gridTemplateColumns:"repeat(4, 21.5px)",gridTemplateRows:"repeat(4, 14px)"},em={[Ne.Header]:{[Me.Focus]:"content-center rounded-sm border border-accent-300 bg-accent-300 text-center text-[8px] font-semibold",[Me.Default]:"rounded-sm bg-semantic-warning border border-accent-300"},[Ne.Cell]:{[Me.Focus]:"content-center rounded-sm border border-accent-300 bg-hues-100 pl-1 text-left text-[8px] font-semibold",[Me.Default]:"rounded-sm bg-neutrals-100 border border-accent-300"}},lo=({rows:e,style:t})=>r.jsx("div",{className:Zf,style:t,children:e.map((n,s)=>r.jsx(d.Fragment,{children:n.map((a,i)=>r.jsx("span",{className:tt([em[a.role][a.emphasis],!a.label&&"text-transparent"]),children:a.label||" "},`${s}-${i}`))},s))}),tm=[[{role:Ne.Header,emphasis:Me.Focus,label:"D1.D2.D3"},{role:Ne.Header,emphasis:Me.Default},{role:Ne.Header,emphasis:Me.Default}],[{role:Ne.Cell,emphasis:Me.Focus,label:"C1.A"},{role:Ne.Cell,emphasis:Me.Default},{role:Ne.Cell,emphasis:Me.Default}],[{role:Ne.Cell,emphasis:Me.Focus,label:"C1.B"},{role:Ne.Cell,emphasis:Me.Default},{role:Ne.Cell,emphasis:Me.Default}],[{role:Ne.Cell,emphasis:Me.Focus,label:"C2.X"},{role:Ne.Cell,emphasis:Me.Default},{role:Ne.Cell,emphasis:Me.Default}]],nm=()=>r.jsx(lo,{rows:tm,style:Xf}),sm=[[{role:Ne.Header,emphasis:Me.Focus,label:"D1"},{role:Ne.Header,emphasis:Me.Focus,label:"D2"},{role:Ne.Header,emphasis:Me.Focus,label:"D3"},{role:Ne.Header,emphasis:Me.Default}],[{role:Ne.Cell,emphasis:Me.Focus,label:"C1"},{role:Ne.Cell,emphasis:Me.Focus,label:"A"},{role:Ne.Cell,emphasis:Me.Focus},{role:Ne.Cell,emphasis:Me.Default}],[{role:Ne.Cell,emphasis:Me.Focus,label:"C1"},{role:Ne.Cell,emphasis:Me.Focus,label:"B"},{role:Ne.Cell,emphasis:Me.Focus},{role:Ne.Cell,emphasis:Me.Default}],[{role:Ne.Cell,emphasis:Me.Focus,label:"C2"},{role:Ne.Cell,emphasis:Me.Focus},{role:Ne.Cell,emphasis:Me.Focus,label:"X"},{role:Ne.Cell,emphasis:Me.Default}]],am=()=>r.jsx(lo,{rows:sm,style:Qf}),Ra=({title:e,description:t,visual:n,mode:s,activeMode:a,onClick:i})=>r.jsxs("button",{type:"button",className:tt(["flex items-center gap-3 rounded border p-1",s===a&&"border-primary"]),onClick:()=>i(s),children:[r.jsx("div",{className:"rounded-[5px] bg-neutrals-100 px-2 py-1",children:n}),r.jsxs("div",{className:"flex flex-col gap-1 text-left",children:[r.jsx("span",{className:"h4 text-neutrals-1000",children:e}),r.jsx("span",{className:"caption text-neutrals-800",children:t})]})]}),rm=({gridViewMode:e,onModeChange:t,compactViewTitle:n,compactViewDescription:s,extendedViewTitle:a,extendedViewDescription:i})=>r.jsxs("div",{className:"mx-5 my-3 flex flex-col gap-2",children:[r.jsx(Ra,{title:n||"Compact view",description:s??r.jsxs(r.Fragment,{children:["Related dimensions ",r.jsx("strong",{children:"combined into a single column."})]}),visual:r.jsx(nm,{}),mode:Qe.Compact,activeMode:e,onClick:t}),r.jsx(Ra,{title:a||"Extended view",description:i??r.jsxs(r.Fragment,{children:["Each dimension displayed in ",r.jsx("strong",{children:"separate column."})]}),visual:r.jsx(am,{}),mode:Qe.Extended,activeMode:e,onClick:t})]}),Fa="table-settings-side-panel",im=()=>{const{gridApi:e,initialColumnsState:t,structuresMap:n,locale:s,dataQueries:a,dimensionCustomization:i,setDimensionKeyOrder:o,setDimensionKeyHidden:c,resetDimensionCustomization:l,clearUserColumnState:f,clearInitialColumnState:u,gridViewMode:h,setGridViewMode:m,texts:p,resetIcon:g}=ns(),b=xn(),C=qf(),x=d.useCallback(S=>{f(),u(),l(),m(S)},[f,u,l,m]),w=d.useCallback(()=>{e&&(f(),t?uf(e,t):e.resetColumnState(),l())},[f,e,t,l]),v=d.useMemo(()=>{if(!(h!==Qe.Compact||!b||!n||!s||!a?.length))return Tf({dataQueries:a,structuresMap:n,getDimensionsScheme:b.getDimensionsScheme,getDimensionConfig:(S,k)=>b.map[S]?.[k],locale:s,dimensionCustomization:i})},[h,b,n,s,a,i]);return e?r.jsxs("div",{className:"flex h-full flex-col",children:[r.jsx(rm,{gridViewMode:h,onModeChange:x,compactViewTitle:p?.compactViewTitle,compactViewDescription:p?.compactViewDescription,extendedViewTitle:p?.extendedViewTitle,extendedViewDescription:p?.extendedViewDescription}),r.jsx("hr",{className:"border-neutrals-500"}),r.jsxs("div",{className:"mx-5 mb-4 mt-5 flex items-center justify-between",children:[r.jsx("h3",{className:"text-neutrals-1000",children:p?.columnsDisplayTitle||"Columns display"}),r.jsx("button",{type:"button",className:"text-neutrals-800",onClick:w,children:g??r.jsx(Ve.IconRotate,{className:"size-4 rotate-180"})})]}),r.jsx($f,{api:e,enrichItem:v,renderLabel:C,onSubItemOrderChange:o,onSubItemVisibilityChange:c,searchPlaceholder:p?.columnsSearchPlaceholder})]}):null},om=e=>{const{attachmentsStyles:t}=ye(),{onGridApiReady:n}=ns(),s=pt(),a=d.useCallback(()=>{s&&s.openPanel({id:Fa,scope:"advanced",title:t?.tableSettings||"Table settings",headerClassName:"border-b border-neutrals-500",content:r.jsx(im,{})})},[s,t?.tableSettings]);return r.jsx(oo,{...e,isTableSettingsOpen:s?.isPanelOpen(Fa)??!1,onTableSettingsOpen:s?a:void 0,onTableSettingsClose:s?.closePanel,onGridApiReady:n})},lm=({actions:e,structureDataMaps:t,buttonProps:n,modalProps:s,dataQueries:a,onMultipleDataFiltersChange:i,locale:o,timeRangeOptions:c,datasetIcon:l,conversationKey:f,conversation:u,setConversation:h,updateConversation:m,updateDataQueries:p,limitMessages:g,filterIconClassName:b})=>{const{titles:C}=ye(),x=xn(),[w,v]=d.useState(M.PopUpState.Closed),[S,k]=d.useState([]),[T,N]=d.useState([]),[D,R]=d.useState(),[E,A]=d.useState([]),[I,O]=d.useState(void 0),L=d.useRef(t?.constraintsMap),[W,$]=d.useState(),[q,U]=d.useState(),[J,G]=d.useState(),[te,ne]=d.useState(!1),fe=d.useRef(0),[xe,me]=d.useState(!1),[_,K]=d.useState(new Set),le=d.useRef(u);d.useEffect(()=>{le.current=u},[u]);const de=d.useCallback(()=>{fe.current+=1,fe.current===1&&ne(!0)},[]),ue=d.useCallback(()=>{fe.current=Math.max(fe.current-1,0),fe.current===0&&ne(!1)},[]),se=d.useMemo(()=>ic(a,t),[a,t]),Q=d.useCallback(V=>kc(V,t?.dimensionsMap,t?.structuresMap),[t?.dimensionsMap,t?.structuresMap]),H=d.useCallback(V=>Q(V).codelistUrn,[Q]),B=d.useCallback(V=>{const j=V.filterType==="dataset"?V.datasetUrn:V.sourceDatasetUrns?.[0];return j?L.current?.get(j):void 0},[]),oe=d.useCallback(V=>Q(V).sourceArtefactUrn,[Q]),{hierarchyStateMap:ae,rebuildHierarchyTree:ge,loadAvailableHierarchies:he,onSelectHierarchy:ce,onExpandHierarchyNode:De}=Ei({getCodelistUrnForFilter:H,getConstraintsForFilter:B,getSourceArtefactUrn:oe,getAvailableHierarchies:e?.getAvailableHierarchies,getHierarchy:e?.getHierarchy}),Ee=V=>{const j=V?S.map(P=>Pe(P,V)?V:P):S;G(!0),k(sn(j)),U?.(!0),ie(V?.isTimeDimension?nn(j,V):j,k,U,V)};d.useEffect(()=>{w===M.PopUpState.Closed&&$(L.current)},[w]);const ie=d.useCallback((V,j,P,F)=>{const Y=kt(V,L.current,!1,x.map),Z=fa(a,Y,e,x.map,V);Z&&de();const re=ua(a,Y,e,x.map,V);Promise.allSettled(re).then(ke=>{const He=ha(L.current||t?.constraintsMap,ma(ke)),Re={...t,constraintsMap:He};if(F){const{filtersMap:lt,changed:at}=$c(Y,Re,F,o,x.map);if(at){L.current=He,P?.(!0),G(!0);const Gt=Dt(lt,Re,o,x.map);ie(Gt,j,P,F);return}}const ze=Dt(Y,Re,o,x.map);if(L.current=He,P?.(!1),j(ze),F){const lt=ze.find(at=>Pe(at,F));R(at=>at&<&&Pe(at,F)?{...lt,isSelectedFilter:!0}:at),ge(F,B(F))}}).catch(()=>{const ke=L.current||t?.constraintsMap||new Map,He=Dt(Y,{...t,constraintsMap:ke},o,x.map);if(L.current=ke,P?.(!1),j(He),F){const Re=He.find(ze=>Pe(ze,F));R(ze=>ze&&Re&&Pe(ze,F)?{...Re,isSelectedFilter:!0}:ze)}}).finally(()=>{G(!1),Z&&ue()})},[e,a,x.map,ue,B,o,ge,de,t]);d.useEffect(()=>{if(!se){U(!0);return}const V=Zr(t,o),j=a?.map(F=>{if(!F.disabled)return F;const Y=(V.get(F.urn)??[]).filter(Z=>Z.filterType==="dataset"&&Z.id&&!Z.isTimeDimension).map(Z=>({componentCode:Z.id,operator:ee.QueryFilterType.IN,values:[]}));return{...F,filters:Y}}),P=Xr(V,j,t?.constraintsMap,x.map);U?.(!0),ie(P,N,U)},[a,x.map,ie,se,o,t]),d.useEffect(()=>{T?.length&&A(cn(T))},[T]),d.useEffect(()=>{k(V=>nn(V,D))},[D]),d.useEffect(()=>{if(w===M.PopUpState.Opened){O(void 0);const V=T.find(j=>!j.isTimeDimension);R(V?{...V,isSelectedFilter:!0}:void 0),k(T),K(new Set(a?.filter(j=>j.disabled).map(j=>j.urn)))}w===M.PopUpState.Closed&&R(void 0)},[T,a,w]),d.useEffect(()=>{if(!D||D.isTimeDimension)return;const V=$e(D);if(!V)return;ae.get(V)||he(D)},[D,ae,he]),d.useEffect(()=>{w===M.PopUpState.Opened&&T.forEach(V=>{if(V.isTimeDimension)return;const j=$e(V);j&&!ae.has(j)&&he(V)})},[w,T,ae,he]);const Le=d.useCallback(async V=>{const j=le.current,P=a?.map(re=>({...re,disabled:_.has(re.urn)})),F=P?.filter(re=>!re.disabled),Y=ii(F,V),Z=j?{...j,messages:Ti(j.messages,P,Y)}:null;h?.(Z),p?.(P?.map(re=>({...re,filters:re.disabled?re.filters??[]:Y.get(re.urn)??[]}))??[]),await m(decodeURI(f),{name:Z?.name,messages:Z?.messages||[]})},[f,a,_,h,m,p]),Je=d.useCallback((V,j)=>{k(P=>Dr(P,V,j)),Pe(D,V)&&R(P=>P&&{...P,displayMode:j})},[D]),Ge=d.useCallback(V=>ri(V,a,t?.dimensionsMap),[a,t?.dimensionsMap]),_e=d.useCallback((V,j)=>{const P=Dt(V,j,o,x.map);L.current=j?.constraintsMap,R(F=>P?.find(Y=>Pe(Y,F))||F),k(P),G(!1)},[x.map,o]),Ue=d.useCallback((V,j)=>{G(!0),k(sn(V));const P=kt(V,L.current,!1,x.map),F=L.current||t?.constraintsMap||new Map,Y=fa(j,P,e,x.map,V);Y&&de();const Z=ua(j,P,e,x.map,V);Promise.allSettled(Z).then(re=>{const ke=ha(F,ma(re));_e(P,{...t,constraintsMap:ke})}).catch(()=>{_e(P,{...t,constraintsMap:F})}).finally(()=>{Y&&ue()})},[e,x.map,ue,de,t,_e]),Ze=d.useCallback(V=>{const j=a?.find(F=>F?.urn===V?.datasetUrn),P=Er(S,V);Ue(P,V?.datasetUrn?j?[j]:[]:a)},[Ue,S,a]),Ke=d.useCallback(()=>{K(new Set)},[]),X=d.useCallback((V,j)=>{K(P=>{const F=new Set(P);return j?F.delete(V):F.add(V),F})},[]),pe=d.useCallback(()=>{L.current=W,v(M.PopUpState.Closed),me(!0)},[W]),ve=d.useCallback(()=>{const V=Ar(S);Ue(V,a),K(new Set)},[Ue,S,a]),Ce=d.useCallback(()=>{const V=a?.map(re=>({...re,disabled:_.has(re.urn)})),j=kt(S,L.current,!1,x.map,_),P=Dt(j,{...t,constraintsMap:L.current},o,x.map),F=Ge(j),Y=Qr(S,a?.map(re=>re.urn)??[],a,x.map,j),Z=(a?.map(re=>re.urn)??[]).filter(re=>!Y.has(re));for(const re of Z){const ke=j.get(re);ke&&j.set(re,ke.map(He=>!He.isTimeDimension&&He.dimensionValues?.length&&!He.dimensionValues.some(Re=>Re.isSelectedValue)?{...He,isExcluded:!0}:He))}i?.(F,L.current,V?.filter(re=>Y.has(re.urn)||re.disabled),j,P),N(P),v(M.PopUpState.Closed),me(!0),d.startTransition(()=>{Le(j)})},[Ge,S,t,o,x.map,i,a,_,Le]),be=V=>{O(V)},Ie=d.useMemo(()=>a?.map(V=>{const j=t?.structuresMap?.get(V.urn)?.dataflows?.[0],P=y.getLocalizedName(j,o??""),F=P?y.generateShortUrn(P,"",j?.agencyID):void 0;return F?{...V,title:F}:V}),[a,t?.structuresMap,o]);return r.jsxs("div",{className:"filters-container",children:[r.jsx(Si,{buttonProps:n,selectedFiltersCount:Bn(E),isLoading:q,setModalState:v,isModalClosed:xe,warningIcon:g?.warningIcon,filterIconClassName:b}),r.jsx(r.Fragment,{children:w===M.PopUpState.Opened&&r.jsxs(M.Popup,{heading:C?.settings||"Settings",portalId:"filters",size:M.PopUpSize.LG,containerClassName:"advanced-view-filters-modal h-[80%]",dividers:s?.isShowDividers,onClose:pe,closeButtonTitle:C?.close||"Close",children:[r.jsx(gi,{locale:o,timeRangeOptions:c,filtersList:S,selectedFilter:D,isDisableValues:J,isValuesLoading:te,modalProps:s,initialConstraintsMap:t?.constraintsMap,datasetIcon:l,structuresMap:t?.structuresMap,setSelectedFilter:R,onSelectDisplayMode:Je,onDeleteFilter:Ze,onClearAllFilters:ve,updateSelectedFilterValues:Ee,onTimePeriodChange:be,selectedTimeOption:I,hierarchyStateMap:ae,onSelectHierarchy:ce,onExpandHierarchyNode:De,dataQueries:Ie,disabledDatasetUrns:_,onToggleDataset:X,onClearAllDatasets:Ke}),r.jsx(wi,{onApply:Ce,onClose:pe,onClearAllFilters:ve,modalProps:s,applyDisabled:q||J,limitMessages:g})]})})]})},cm=({filtersProps:e,actions:t,attachments:n,attachmentsDataQuery:s,dataQueries:a,dimensions:i,locale:o,isDataLoading:c,setIsFiltering:l,filters:f,onFiltersChange:u})=>{const{titles:h,limitMessages:m}=ye(),p={getConstraints:t.getConstraints,getAvailableHierarchies:e.actions?.getAvailableHierarchies,getHierarchy:e.actions?.getHierarchy},{isCrossDatasetModeOn:g}=Be();return d.useEffect(()=>{c||l?.(!1)},[c,l]),r.jsx("div",{className:"h-full min-h-0 rounded bg-white",children:r.jsxs("div",{className:"flex h-full flex-col gap-4 overflow-x-hidden",children:[r.jsxs("div",{className:"data-details-header flex items-center justify-between",children:[r.jsx("h2",{children:h?.content??"Content"}),g?r.jsx(lm,{attachmentsDataQuery:s,dataQueries:a,updateDataQueries:t?.updateDataQueries,locale:o,actions:p,dimensions:i,...e,onFiltersChange:u,limitMessages:m}):r.jsx(Kc,{attachmentsDataQuery:s,dataQueries:a,updateDataQueries:t?.updateDataQueries,locale:o,actions:p,dimensions:i,...e,onFiltersChange:u,limitMessages:m})]}),r.jsx("div",{className:"advanced-view-attachments-container min-h-0 flex-1",children:r.jsx(om,{attachments:n,currentDataQuery:s,dataQueries:a,dimensions:i,actions:t,isShowAttachments:!0,isDataSetAttachments:!0,isDataLoading:c,locale:o,filters:f})})]})})},dm=({isShowAgency:e,isShowDatasetBadge:t,dataset:n,data:s,structures:a,metadataSettings:i,locale:o,getDatasetUpdatedTime:c,externalLink:l,datasetIcon:f,externalLinkIcon:u,metadataButtonClassName:h,metadataIconClassName:m,infoSegmentContainerClassName:p,infoSegmentHeaderClassName:g,nameAndMetadataContainerClassName:b})=>{const{titles:C}=ye(),x="dataset-metadata-side-panel",[w,v]=d.useState(""),[S,k]=d.useState(!1),T=d.useRef(null),[N,D]=d.useState(""),[R,E]=d.useState(""),[A,I]=d.useState(!1),{onboardingFileSchema:O,isShowOnboarding:L}=qe(),{isOpenedAdvancedView:W}=We(),$=pt(),{isMetadataInSidePanel:q}=Be(),[U,J]=d.useState(!1),G=d.useMemo(()=>i?.isMetadataDescription?$d(n,w,o,C):[],[n,w,o,i?.isMetadataDescription,C]),te=d.useMemo(()=>[...i?.isMetadataDescription?[]:[Ot(n,o,C)],...Wi(zi(s),y.getStructureComponentsMap(a),o)],[s,n,o,i?.isMetadataDescription,a,C]),ne=d.useMemo(()=>_t(n,w,o,C),[n,w,o,C]),fe=d.useCallback(()=>{if(q&&$){$.openPanel({id:x,scope:W?"advanced":"conversation",title:"Dataset Metadata",bodyClassName:"overflow-hidden",content:r.jsx(Ft,{locale:o,metadata:te,metadataDescription:G,datasetInfo:ne,externalLink:l})}),J(!0);return}k(!0)},[G,te,ne,l,q,W,o,$]),xe=d.useCallback(()=>{k(!1),J(!0)},[]);d.useEffect(()=>{const K=c&&c(te)||Vt(y.getLastUpdatedTime(n),o);v(K)},[n,o,te,c]),d.useEffect(()=>{if(L){const{title:_,description:K}=dt(Oe.METADATA_PER_DATASET,C);D(_),E(K)}},[C,L]),d.useEffect(()=>{L&&I(O?.lastDisplayedElement===Oe.METADATA_PER_DATASET)},[O?.lastDisplayedElement,L]);const me=(_,K)=>r.jsxs("div",{className:tt("flex gap-1 text-neutrals-1000",p),children:[r.jsxs("span",{className:tt("text-neutral-800",g),children:[_,":"]}),r.jsx("span",{children:K})]});return r.jsxs("div",{className:"dataset-info flex flex-col gap-3 bg-white",children:[t&&r.jsxs("div",{className:"bg-accent-500 body-2 flex w-fit items-center gap-1 rounded-[20px] px-2 py-1",children:[f,C?.dataset??"Dataset"]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsxs("div",{role:"heading","aria-level":4,className:tt("flex gap-1 items-center h4",b),children:[r.jsx("div",{ref:T,children:r.jsx(M.IconButton,{title:C?.metadata??"View details",buttonClassName:tt("!text-neutrals-1000 !border-none !w-4 !h-4 !p-0 shrink-0",h),icon:r.jsx(Oi,{className:tt("size-4",m)}),onClick:fe})}),r.jsx("span",{children:y.getLocalizedName(n,o)})]}),l&&r.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",children:u||r.jsx(Ve.IconExternalLink,{className:"size-4 shrink-0 cursor-pointer text-primary"})})]}),r.jsxs("div",{className:"body-3 flex items-center gap-2",children:[e&&r.jsxs(r.Fragment,{children:[me(C?.agency??"Agency",n?.agencyID??""),r.jsx("div",{"aria-hidden":"true",className:"h-[14px] border-l border-l-neutral-500"})]}),me(C?.lastUpdated??"Last updated",w)]})]}),A&&r.jsx(ut,{reference:T,title:N,description:R,onReferenceClick:fe,shouldCloseTooltip:U}),S&&r.jsx(Xn,{locale:o,metadata:te,metadataDescription:G,isOpenMetadata:S,onCloseMetadata:xe})]})},um=({locale:e,isShowShare:t,shareConversationProps:n,conversation:s})=>{const{titles:a}=ye(),{setIsOpenedAdvancedView:i}=We(),o=d.useRef(null),[c,l]=d.useState(""),[f,u]=d.useState(""),[h,m]=d.useState(!1),{onboardingFileSchema:p,isShowOnboarding:g}=qe();return d.useEffect(()=>{if(g){const{title:b,description:C}=dt(Oe.EXIT_ADVANCED_VIEW,a);l(b),u(C)}},[a,g]),d.useEffect(()=>{g&&m(p?.lastDisplayedElement===Oe.EXIT_ADVANCED_VIEW)},[p?.lastDisplayedElement,g]),r.jsxs("header",{className:z("bg-white px-6 py-4 flex justify-between items-center sm:px-0","advanced-view-header"),children:[r.jsxs("div",{className:z("flex gap-3 items-center",!t&&"justify-between w-full","advanced-view-header-title"),children:[r.jsx("div",{ref:o,className:z(!t&&"order-2","flex"),children:r.jsx(M.CloseButton,{btnClassNames:"button-close",onClick:()=>i(!1),title:a?.close||"Close"})}),h&&r.jsx(ut,{reference:o,title:c,description:f,onReferenceClick:()=>i(!1),shouldMoveToNextStep:!0}),r.jsx("h2",{children:a?.advanceViewTitle??"Advanced view"})]}),t&&r.jsx(hr,{locale:e,conversation:s,...n})]})};function fm(e,t,n,s,a,i,o,c,l){const f=mm(e,n),u=l?.startPeriod&&l.endPeriod?y.getAdditionalColumns(c,l):[],h=hm(e,t,n,s,a,i,u);return[kd(e,t?.data,n,a,i,o),...f,...h,Fi(e,t?.data,n,void 0,i,o)]}function mm(e,t){const n=e.conceptSchemes||[],s=e.codelists||[],a=y.getDimensions(e)?.dimensions||[];return a.map(i=>{const{codeList:o,concept:c}=gn(i,n,s),l=f=>{const{data:u,colDef:h}=f,m=h.field;return ss(a,m,o,u,t)};return{headerName:y.getLocalizedName(c,t),field:i.id,colId:i.id,valueGetter:l,...Ct,tooltipValueGetter:f=>f.value}})}function hm(e,t,n,s,a,i,o){const c=Cm(o,y.getTimePeriods(t));return gm(c,(f,u)=>pm(f,u||f,s,i),e,n,a,i)}const pm=(e,t,n=ee.defaultFormatNumbers,s)=>({headerName:Sr(t,s),colId:e,field:e,type:"numericColumn",suppressColumnsToolPanel:!0,sortable:!1,width:bt,cellClass:["justify-end","cell-with-meta"],valueFormatter:a=>ee.formatNumberBySign(a.value,n)}),gm=(e,t,n,s,a,i)=>{const o=[];return e.sort((l,f)=>y.sortPeriods(l,f)).forEach(l=>{o.push({headerName:l.toString(),field:l.toString(),...t(l.toString()),valueGetter:f=>f.data[f.column.getColId()]?.value?.[0]?.value||null,cellClass:ht,cellRenderer:fn,width:bt,cellRendererParams:{dataSetData:n,locale:s,metadataSettings:a,titles:i}})}),o},Cm=(e=[],t=[])=>{if(!e.length)return t;if(!t.length)return e;const n=t.some(f=>y.isYearly(f)),s=t.some(f=>y.isSemiAnnually(f)),a=t.some(f=>y.isQuarterly(f)),i=t.some(f=>y.isMonthly(f)),o=t.some(f=>y.isWeekly(f)),c=t.some(f=>y.isDaily(f)),l=e.filter(f=>y.isYearly(f)?n:y.isSemiAnnually(f)?s:y.isQuarterly(f)?a:y.isMonthly(f)?i:y.isWeekly(f)?o:y.isDaily(f)?c:!0);return Array.from(new Set([...l,...t]))};function wm(e,t,n){const s=t.map(i=>i.id).filter(i=>i!=null),a=n.map(i=>i.id).filter(i=>i!=null);return xm(e,s,a,s)}const xm=(e,t,n,s)=>{const a={};for(const i of e){const o=Sm(i,t),c=vm(o,s);let l=a[c];if(l==null){l={},a[c]=l;for(const u of s)l[u]=o[u]}const f=Va(i.attributes);if(Ua(l,c,f,i),!i.values.length){Oa(l,o,n);continue}for(const u of i.values){const h=Va(u.obsAttributes);Ua(l,c,f,i),Oa(l,o,n,u.dimensionAtObservation,ym(i,u),h)}}return Object.values(a)},vm=(e,t)=>t.map(n=>e[n]).join("_"),bm=(e,t,n)=>t.map(s=>s==="TIME_PERIOD"?n:e[s]).join("_"),Oa=(e,t,n,s,a,i)=>{const o=bm(t,n,s);e[o]={value:a,obsAttributes:i}},Sm=(e,t)=>{const n={},s=e.name.split(".");for(let a=0;a<t.length;a+=1)n[t[a]]=s[a];return n},ym=(e,t)=>{const n=_a(e.attributes);if(n)return[n];const s=_a(t.obsAttributes);return s?[s]:t.values},_a=(e=[])=>e.find(({name:t})=>t==="OBS_VALUE"),Va=(e=[])=>e.filter(({value:t})=>t),Ua=(e,t,n,s)=>{e.attributes??=n,e.id=t,e.originalData=s},Dm="#EEEEEE",Mm="#777777";function Tm(e,t,n){const s={animation:!1,tooltip:{trigger:"axis",appendToBody:!0,formatter:a=>{let i=a[0].axisValueLabel+"<br/>";return a.forEach(o=>{o.value!==null&&o.value!==void 0&&(i+=o.marker+" "+o.seriesName+": "+o.value+"<br/>")}),i}},legend:{bottom:0},grid:{left:"3%",right:"3%",bottom:"40px",containLabel:!0},xAxis:{...Ha(n?.ticksColor,n?.labelsColor),type:"category",boundaryGap:!1,data:e},yAxis:{...Ha(n?.ticksColor,n?.labelsColor),type:"value"},series:t};return n?.colors!=null&&(s.color=n.colors),s}function Ha(e=Dm,t=Mm){return{splitLine:{show:!0,showMaxLine:!1,lineStyle:{color:[e]}},axisTick:{show:!1},axisLabel:{color:t},axisLine:{lineStyle:{color:e}}}}function co(e,t,n,s){return t.map(i=>{const o=y.getDimensions(n)?.dimensions||[],c=o?.find(f=>f.id===i);if(c==null)return e[i]||"";const{codeList:l}=gn(c,n.conceptSchemes||[],n.codelists||[]);return ss(o,i,l,e,s)}).join(" - ")}function Em(e,t){const n=[...t?.metadata?.indicatorDimensions||[]].filter(i=>i!=null),a=y.getDimensions(e)?.dimensions?.filter(i=>i.id!=null&&!n.includes(i.id)&&t?.metadata?.countryDimension!==i.id).map(i=>i.id).filter(i=>i!=null)||[];return[...n,...a]}function Am(e,t,n){const s={};return e.forEach(a=>{const i=Nm(a,t,n);s[i]||(s[i]={rows:[]}),s[i].rows.push(a)}),Object.keys(s).map(a=>s[a])}function Nm(e,t,n){const s=n.dataStructures?.[0]?.dataStructureComponents?.dimensionList?.dimensions||[];return t.map(i=>s?.find(c=>c.id===i)==null?e[i]||"":ao(s,i,e)).join(" - ")}function km(e,t){const n={};return e.forEach(s=>n[s]=jm(s,t)),{nonUniqDimensions:e.filter(s=>!n[s])}}function jm(e,t){const n=t.map(a=>Im(e,a));return new Set(n).size===1}function Im(e,t){return t[e]}const Lm="line",Wt=10,Pm=2;function Rm(e){return typeof e=="number"?Number.isFinite(e):typeof e=="string"&&e.trim()!==""?Number.isFinite(Number(e)):!1}function uo(e){const t=(e.groups??[]).flatMap(n=>n.units);return[...e.units,...t].some(n=>n.isPlottable)}function fo(e,t,n,s,a){const i=rs(t,e,n,s,a,{includeChartData:!1}),c=y.getTimePeriods(t).sort((h,m)=>y.sortPeriods(h,m)),l=Em(e,n),{nonUniqDimensions:f}=km(l,i);return{units:Am(i,f,e).map(h=>mo(h,e,n,c,s,a))}}function Fm(e,t,n,s,a){let i;return()=>(i??=fo(e,t,n,s,a),i)}function Om(e,t,n,s,a,i){return mo({rows:[e]},n,s,t,a,i)}function mo(e,t,n,s,a,i){const o=Bm(e.rows,t,n,a),c=o?.find(u=>y.FREQUENCY_DIMENSION_ID.includes(u?.id))?.id,l=Vm(s,e?.rows?.[0],c),f=Um(e.rows.length>Wt?e.rows.slice(0,Wt):e.rows,t,n,a,l);return{rows:e.rows,limitedByRowsAmountTo:e.rows.length>Wt?Wt:void 0,dimensions:o,config:Tm(l,f,i),isPlottable:_m(f)}}function _m(e){return e.some(t=>t.data.filter(Rm).length>=Pm)}function Vm(e,t,n){if(n){const s=t?.[n];if(s===y.Periods.MONTHLY)return e?.filter(a=>y.isMonthly(a));if(s===y.Periods.QUARTERLY)return e?.filter(a=>y.isQuarterly(a));if(s===y.Periods.ANNUAL)return e?.filter(a=>y.isYearly(a))}return e}function Um(e,t,n,s,a){return e.map(i=>({name:n?.metadata?.countryDimension==null?"":co(i,[n?.metadata?.countryDimension],t,s),type:Lm,data:a.map(o=>Hm(o,i))}))}function Hm(e,t){return t[e]?.value?.[0]?.value||null}function Bm(e,t,n,s){const a=n?.metadata?.countryDimension;return(y.getDimensions(t)?.dimensions||[]).map(i=>{if(!(i.id==null||i.id===a))return{id:i.id,title:Gm(i,t,s),value:co(e[0],[i.id],t,s)}}).filter(i=>i!=null)}function Gm(e,t,n){const s=t.conceptSchemes||[],a=t.codelists||[],{concept:i}=gn(e,s,a);return y.getLocalizedName(i,n)||e.id}function rs(e,t,n,s,a,i={}){const o=e==null?[]:y.getParsedResponse(e),c=y.getDimensions(t)?.dimensions||[],l=y.getDimensions(t)?.timeDimensions||[],f=wm(o,c,l);return i.includeChartData===!1?f:zm(f,e,t,n,s,a)}function zm(e,t,n,s,a,i){const c=y.getTimePeriods(t).sort((l,f)=>y.sortPeriods(l,f));return e.map(l=>({...l,[It]:()=>Om(l,c,n,s,a,i)}))}function Wm(e,t,n,s,a,i,o,c,l,f,u){return{columns:fm(e,t,s,a,i,c,l,f,u),data:rs(t,e,n,s,o)}}function $m(e,t,n,s,a,i,o,c,l,f,u){const h=e.dataflows?.[0]?.names?.[s],m=Wm(e,t,n,s,a,i,o,c,l,f,u);return{title:h||c?.dataGrid||"Data Grid",grid_data:m}}function Jm(e){const t=e.replace(/\r\n/g,`
|
|
8
8
|
`);if(!t.startsWith("```"))return{code:e};const n=t.split(`
|
|
9
9
|
`),a=n[0].slice(3).trim()||void 0;let i=-1;for(let o=n.length-1;o>0;o--)if(n[o].trim()==="```"){i=o;break}return i===-1?{code:n.slice(1).join(`
|
|
10
10
|
`),language:a}:{code:n.slice(1,i).join(`
|
|
11
11
|
`),language:a}}const Km=["python"];function ho(e,t,n){return e.filter(s=>s.type===we.AttachmentType.MARKDOWN).filter(s=>!t||s.title?.includes(t)).map(s=>{const a=Jm(s.data??"");return{title:n??"Code samples",type:we.AttachmentType.CUSTOM_CODE_SAMPLE,language:a.language,data:a.code}}).filter(s=>Km.includes(s.language??""))}function po(e){const{getPythonAttachment:t,dataQueries:n,requestIdRef:s,codeTitle:a,markdownTitle:i,setCodeAttachments:o,onCodeAttachmentUpdated:c}=e,l=++s.current;t(n).then(f=>{l===s.current&&f?.python_code&&(o([{type:we.AttachmentType.CUSTOM_CODE_SAMPLE,data:f.python_code,language:"python",title:a}]),c?.({type:we.AttachmentType.MARKDOWN,title:i,data:`\`\`\`python
|
|
12
12
|
${f.python_code}
|
|
13
|
-
\`\`\``}))}).catch(f=>console.error("Error refreshing python attachment:",f))}const Ym="Data Grid",qm="Data",Zm="Chart",Xm=e=>({title:e||Ym,type:we.AttachmentType.CUSTOM_DATA_GRID}),go=e=>({title:e||Zm,type:we.AttachmentType.CUSTOM_CHART}),Qm=e=>({title:e||qm,type:we.AttachmentType.CROSS_DATASET_GRID});function Co(e,t,n,s,a,i,o,c,l,f=!1,d,h=!1){const[m,p]=u.useState(),[g,b]=u.useState(),[C,x]=u.useState(),[w,v]=u.useState(),[S,k]=u.useState(Xm(o?.dataGrid)),[T,N]=u.useState(go(o?.chart)),[D,R]=u.useState(!1),[E,A]=u.useState([]),[j,O]=u.useState([]),[L,$]=u.useState([]),[J,q]=u.useState(!1),[H,K]=u.useState(!1),z=u.useRef(0),[ne,se]=u.useState({startPeriod:null,endPeriod:null}),{getConstraints:fe,getDataSet:xe,getDataSetData:me,putOnboardingFile:_,getPythonAttachment:Y}=e,le=u.useCallback(U=>{if(!U)return;const B=y.getDimensions(U);b(U.dataflows?.[0]||void 0),v(U||void 0),O([...B?.dimensions||[],...B?.timeDimensions||[]])},[]),de=u.useCallback(async U=>{const B=kt(y.getFiltersDtoFromDataQuery(U));try{const re=(await at(fe,st(U.urn,B),()=>fe(U.urn,B)))?.data?.dataConstraints||[];x(re)}catch{x([])}},[fe]),ue=u.useCallback(async U=>{const B=l?{data:l}:await at(xe,st(U.urn),()=>xe(U.urn));if(B?.data){const oe=y.getDimensions(B.data);le(B.data);const re=oe?.dimensions==null?null:y.getTimeSeriesFilterKey(oe?.dimensions,U.filters??[]),ge=Fr(U,oe);at(me,st(U.urn,{filterKey:re,timeFilter:ge}),()=>me(U.urn,{filterKey:re,timeFilter:ge})).then(he=>{K(!0),p(he||void 0),$(y.getStructureDimensions(he))}).finally(()=>q(!1))}},[le,xe,me,l]);u.useEffect(()=>{le(l)},[le,l]),u.useEffect(()=>{async function U(B){q(!0);try{await Promise.all([...h?[]:[de(B)],ue(B)])}catch(oe){console.error("Error loading dataset details",oe)}}n!=null&&!(f&&!l)?U(n):n!=null&&f&&q(!0)},[n,l,f,de,ue,h]);const ae=u.useCallback((U,B,oe)=>{try{q(!0),x(B);const re=oe?.find(ge=>ge.id===y.TIME_PERIOD)?.timeRange;if(re&&se(re),at(me,st(n?.urn||"",U),()=>me(n?.urn||"",U)).then(ge=>{K(!0),p(ge||void 0),$(y.getStructureDimensions(ge))}).finally(()=>q(!1)),Y&&n&&oe){const ge=Vr(n,oe),he=c?.find(ce=>ce.type===we.AttachmentType.MARKDOWN&&ce.data?.includes("```python"))?.title;po({getPythonAttachment:Y,dataQueries:[ge],requestIdRef:z,codeTitle:o?.codeSamples||"Python Code",markdownTitle:he??n.urn,setCodeAttachments:A,onCodeAttachmentUpdated:d})}}catch(re){console.error("Error loading dataset data",re)}},[n,me,Y,o,c,d]);u.useEffect(()=>{if(w!=null&&m!=null&&C?.length){K(!0);const U=Lt(()=>{k(B=>({...B,...$m(w,m,n,t,s,i,a,o,_,C,ne)})),K(!1)});return()=>{U(),K(!1)}}(m==null||C!==void 0)&&K(!1)},[w,m,o,t,s,n,i,a,C,ne,_]),u.useEffect(()=>{if(w==null||m==null)return;const U=Fm(w,m,n,t,a);return N(B=>({...B,charting_data:void 0,getChartingData:U})),R(!1),Lt(()=>{try{R(uo(U()))}catch(B){console.error("Error evaluating chart plottability",B),R(!1)}})},[w,m,n,t,a]),u.useEffect(()=>{if(c?.length){const U=ho(c,n?.urn,o?.codeSamples);U.length>0&&A(U)}},[c,o,n]);const ee=u.useMemo(()=>[S,...D?[T]:[],...E],[S,T,E,D]);return{dataMessage:m,structures:w,dataset:g,dimensions:j,structureDimensions:L,onFiltersChange:ae,constraints:C,isLoadingGridData:J||H,dataSetAttachments:ee}}function wo(e,t,n){let s=-1;if(n)s=e.findIndex(o=>o.id===n);else for(let o=e.length-1;o>=0;o--)if(e[o].role===Ie.Role.System){s=o;break}if(s===-1||e[s].role!==Ie.Role.System)return null;const i=[...(e[s].custom_content?.attachments??[]).filter(o=>!(o.type==="text/markdown"&&o.data?.includes("```python"))),t];return e.map((o,c)=>c===s?{...o,custom_content:{...o.custom_content,attachments:i}}:o)}const Ba=async(e,t)=>{const n=new Map,s=y.getFiltersDtoMapFromDataQuery(e);return(await Promise.allSettled(e.map(async i=>{const o=kt(s?.get(i.urn)||[]);return{urn:i.urn,response:await at(t,st(i.urn,o),()=>t(i.urn,o))}}))).forEach(i=>{if(i.status==="fulfilled"){const o=i.value.response?.data?.dataConstraints;Array.isArray(o)&&n.set(i.value.urn,o)}}),n},eh=()=>({datasetsMap:new Map,dataMessagesMap:new Map,structuresMap:new Map,dimensionsMap:new Map,structureDimensionsMap:new Map}),th=async(e,t,n,s,a)=>{const i=eh();await Promise.allSettled(e.map(async c=>{const l=await at(t,st(c.urn),()=>t(c.urn));if(l?.data){const f=y.getDimensions(l.data);i.datasetsMap?.set(c?.urn,l?.data?.dataflows?.[0]),i.structuresMap?.set(c?.urn,l?.data),i.dimensionsMap?.set(c?.urn,[...f?.dimensions||[],...f?.timeDimensions||[]])}}));const o=await a?.(i);return await Promise.allSettled(e.map(async c=>{const l=i.structuresMap?.get(c.urn);if(!l||o&&!o.has(c.urn))return;const f=y.getDimensions(l),d=f?.dimensions==null?null:y.getTimeSeriesFilterKey(f?.dimensions,c.filters??[]),h=Fr(c,f);await xo(c,o?.get(c.urn)??{filterKey:d,timeFilter:h},n).then(({dataMessage:m,structureDimensions:p})=>{i?.dataMessagesMap?.set(c.urn,m),i?.structureDimensionsMap?.set(c.urn,p||[])}).catch(()=>{i?.structureDimensionsMap?.set(c.urn,[])}).finally(()=>s(!1))})),i},xo=async(e,t,n)=>{const s=await at(n,st(e.urn,t),()=>n(e.urn,t));return{dataMessage:s,structureDimensions:y.getStructureDimensions(s)}};function nh(e,t,n,s){return[ah(e,s),sh(e,t,n,s)]}function sh(e,t,n,s){const a=i=>{const o=i.data?.dataset?.urn;if(o==null)return"";const l=e.get(o)?.dataflows?.[0];return y.getLocalizedName(l,n)||""};return{headerName:s?.dataset||rf,field:Na,colId:Na,valueGetter:a,...gt,tooltipValueGetter:i=>i.value,cellClass:mt,cellRenderer:Ri,cellRendererParams:{structuresMap:e,attributesDataMap:t,locale:n,titles:s}}}function ah(e,t){const n=s=>{const a=s.data?.dataset?.urn;return a==null?"":e.get(a)?.dataflows?.[0]?.agencyID||""};return{headerName:t?.agency||of,field:ka,colId:ka,valueGetter:n,...gt,tooltipValueGetter:s=>s.value}}function rh(e,t,n,s,a){return ih(e).sort((c,l)=>y.sortPeriods(c,l)).map(c=>({...oh(c,s,a),valueGetter:f=>f.data[f.column.getColId()]?.value?.[0]?.value||null,cellClass:mt,cellRenderer:un,width:vt,cellRendererParams:{structuresMap:t,locale:n,titles:a}}))}function ih(e){const t=new Set;return e.forEach(n=>{if(n==null)return;y.getTimePeriods(n).forEach(a=>t.add(a))}),Array.from(t)}function oh(e,t=te.defaultFormatNumbers,n){return{headerName:Sr(e,n),colId:e,field:e,type:"numericColumn",suppressColumnsToolPanel:!0,sortable:!1,width:vt,cellClass:["justify-end","cell-with-meta"],valueFormatter:s=>te.formatNumberBySign(s.value,t)}}function lh(e,t,n,s,a,i,o=Qe.Compact){const c=new Map([...n.entries()].map(([h,m])=>[h,m?.data])),l=nh(e,c,s,a),f=pf(e,t,s,a,o),d=rh(n,e,s,i,a);return[jd(e,c,s,a),...l,...f,...d,Fi(void 0,void 0,s,void 0,a)]}function ch(e,t,n,s,a){const i=[];return n.filter(o=>!o.disabled).forEach(o=>{const c=o.urn,l=t.get(c),f=e.get(c);if(l==null||f==null)return;const d=as(l,f,o,s,a),h=y.getLocalizedName(f.dataflows?.[0],s);i.push(...d.map(m=>({...m,dataset:{urn:c},datasetTitle:h})))}),i}function dh(e,t,n,s,a,i,o,c,l,f,d,h=Qe.Compact){const m=uh(e,t,n,s,a,i,o,c,l,f,d,h);return{title:l?.dataGrid||"Data",gridContent:m}}function uh(e,t,n,s,a,i,o,c,l,f,d,h=Qe.Compact){return{columns:lh(e,n,t,a,l,i,h),data:ch(e,t,s,a,c)}}function fh(e,t,n,s,a){let i;return()=>(i??=mh(e,t,n,s,a),i)}function mh(e,t,n,s,a){const i=n.filter(o=>!o.disabled).flatMap(o=>{const c=e.get(o.urn),l=t.get(o.urn);return!c||!l?[]:[{title:y.getLocalizedName(c.dataflows?.[0],s),units:fo(c,l,o,s,a).units}]});return{units:i.flatMap(o=>o.units),groups:i}}function vo(e,t,n,s,a,i,o,c,l,f=Qe.Compact,d){const h=Array.isArray(c)?c:void 0,[m,p]=u.useState(),[g,b]=u.useState(),[C,x]=u.useState(!1),[w,v]=u.useState(h?new Set(h):null),[S,k]=u.useState(!1),T=u.useRef(0),N=u.useRef(f),D=u.useRef(m),[R,E]=u.useState(Qm(d?.dataGrid)),[A,j]=u.useState(go(d?.chart)),[O,L]=u.useState(!1),[$,J]=u.useState([]),{getConstraints:q,getDataSet:H,getDataSetData:K,getPythonAttachment:z}=e,ne=u.useRef(n);ne.current=n;const se=u.useRef(h);se.current=h;const fe=u.useMemo(()=>n?.map(ae=>ae.urn).join(",")??"",[n]),xe=Cn(),{getDimensionsScheme:me}=xe,_=u.useCallback(async ae=>{try{const ee=await Ba(ae.map(oe=>({...oe,filters:[]})),q),U=rc(ae,ee,xe.map),B=U===ae?ee:await Ba(U,q);return p(oe=>({...oe,constraintsMap:B})),B}catch{const ee=new Map;return p(U=>({...U,constraintsMap:ee})),ee}},[xe.map,q]),Y=u.useCallback(async(ae,ee)=>{const U=await th(ae,H,K,x,async B=>{const oe=ae.filter(ge=>!ge.disabled),re=pa(oe,B,ee,t,xe.map);if(re)return v(re.compatibleUrns),re.filterParamsMap});p(B=>({...B,...U,constraintsMap:ee??B?.constraintsMap}))},[xe.map,H,K,t]),le=u.useCallback(ae=>{const ee=new Map;for(const U of ae)ee.set(U.urn,me(U.urn));b(ee)},[me]);u.useEffect(()=>{async function ae(U){const B=se.current;v(B?new Set(B):null),x(!0);try{le(U);const oe=await _(U);await Y(U,oe)}catch(oe){console.error("Error loading dataset details",oe)}finally{x(!1)}}const ee=ne.current;ee?.length&&ae(ee)},[fe,_,le,Y]),u.useEffect(()=>{if(o?.length){const ae=ho(o,void 0,d?.codeSamples);ae.length>0&&J(ae)}},[o,d]),u.useEffect(()=>{const ae=N.current!==f&&D.current===m;N.current=f,D.current=m;const{structuresMap:ee,dataMessagesMap:U,constraintsMap:B}=m??{};if(ee!=null&&ee.size>0&&U!=null&&B!=null&&g!=null&&!C){ae||k(!0);const oe=Lt(()=>{const re=n?.filter(ie=>!ie.disabled),ge=w??new Set((re??[]).map(ie=>ie.urn)),he=da(re,ge),ce=St(ee,ge),Me=St(U,ge),Ne=St(g,ge);E(ie=>({...ie,...dh(ce,Me,Ne,he,t,a,i,s,d,B,{},f)})),ae||k(!1)});return()=>{oe(),ae||k(!1)}}ae||k(!1)},[m,n,t,a,i,s,d,g,C,w,f]),u.useEffect(()=>{const{structuresMap:ae,dataMessagesMap:ee}=m??{};if(ae!=null&&ae.size>0&&ee!=null&&!C){const U=n?.filter(ce=>!ce.disabled),B=w??new Set((U??[]).map(ce=>ce.urn)),oe=da(U,B),re=St(ae,B),ge=St(ee,B),he=fh(re,ge,oe,t,s);return j(ce=>({...ce,charting_data:void 0,getChartingData:he})),L(!1),Lt(()=>{try{L(uo(he()))}catch(ce){console.error("Error evaluating cross-dataset chart plottability",ce),L(!1)}})}},[m,n,t,s,C,w]);const de=u.useMemo(()=>[R,...O?[A]:[],...$],[R,A,$,O]),ue=u.useCallback((ae,ee,U,B,oe)=>{try{x(!0);const re=U?.filter(ie=>!ie.disabled)??[],ge=new Set(re.map(ie=>ie.urn));if(v(ge),p(ie=>({...ie,constraintsMap:ee})),!re.length){x(!1);return}const he=B?ii(re,B):void 0,ce=he?re.map(ie=>({...ie,filters:he.get(ie.urn)??[]})):re,Ne=(ee&&m?pa(ce,m,ee,t,xe.map):void 0)?.filterParamsMap??ae;if(re.forEach(ie=>{xo(ie,Ne?.get(ie?.urn),K).then(({dataMessage:Le,structureDimensions:We})=>{k(!0),p(Be=>{const _e=new Map(Be?.dataMessagesMap),He=new Map(Be?.structureDimensionsMap);return _e.set(ie.urn,Le),He.set(ie.urn,We||[]),{...Be,dataMessagesMap:_e,structureDimensionsMap:He}})}).finally(()=>x(!1))}),z&&re.length){const ie=re.map(Le=>Vr(Le,oe??B?.get(Le.urn)??[]));po({getPythonAttachment:z,dataQueries:ie,requestIdRef:T,codeTitle:d?.codeSamples||"Python Code",markdownTitle:"Python Code",setCodeAttachments:J,onCodeAttachmentUpdated:l})}}catch(re){console.error("Error loading dataset data",re)}},[xe.map,K,z,t,l,m,d]);return{structureDataMaps:m,datasetDimensionsSchemesMap:g,isLoadingGridData:C||S,crossDatasetAttachments:de,activeDatasetUrns:w,onMultipleDataFiltersChange:ue}}const bo=u.createContext(void 0),hh={setCrossDatasetAttachmentsState:()=>{}},ph=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})}},gh=({children:e})=>{const[t,n]=u.useState({}),s=u.useCallback(i=>{const o=ph(i);n(c=>c.signature===o?c:{...i,isLoading:!!i?.isLoading,signature:o})},[]),a=u.useMemo(()=>({...t,setCrossDatasetAttachmentsState:s}),[s,t]);return r.jsx(bo.Provider,{value:a,children:e})},xn=()=>{const e=u.useContext(bo);return e===void 0?hh:e},Ch=({attachmentsProps:e,actions:t,titles:n,shareConversationProps:s,metadataSettings:a,formattingSettings:i,locale:o,advanceViewStyles:c,getDatasetUpdatedTime:l,attachmentsConfig:f,datasetInfoOptions:d,limitMessages:h,...m})=>{const p=u.useMemo(()=>e.currentDataQuery?.urn??e.dataQueries?.[0]?.urn??"default",[e.currentDataQuery?.urn,e.dataQueries]),[g,b]=u.useState(Qe.Compact),{isOpenedAdvancedView:C}=Ge(),{activeDatasetUrns:x,dataQueriesKey:w,setCrossDatasetAttachmentsState:v}=xn(),{isCrossDatasetModeOn:S,isMetadataInSidePanel:k}=Ue(),T=Cn(),N=!k,D=e.datasets??[],R=D.length>1&&!S,E=u.useMemo(()=>{const ce=m.filtersProps.conversation?.messages??[],Me=Mi(ce);return Me>=0?ce[Me].custom_content?.attachments:void 0},[m.filtersProps.conversation?.messages]),A=u.useMemo(()=>ti(e.dataQueries),[e.dataQueries]),j=w===A?x:ei(e.dataQueries,T.map),O=S&&!!e.dataQueries?.length,L=u.useRef(m.filtersProps.conversation);L.current=m.filtersProps.conversation;const $=u.useCallback(ce=>{const Me=L.current;if(!Me)return;const Ne=wo(Me.messages,ce);if(!Ne)return;const ie={...Me,messages:Ne};m.filtersProps.setConversation?.(ie),m.filtersProps.updateConversation(decodeURI(m.filtersProps.conversationKey),{name:ie.name,messages:ie.messages})},[]),{dataMessage:J,dataset:q,dimensions:H,structureDimensions:K,structures:z,dataSetAttachments:ne,onFiltersChange:se,isLoadingGridData:fe,constraints:xe}=Co(t,o,e.currentDataQuery,i,e.styles?.chartingStyles,a,n,E,void 0,!1,$,O),{structureDataMaps:me,crossDatasetAttachments:_,activeDatasetUrns:Y,isLoadingGridData:le,onMultipleDataFiltersChange:de}=vo(t,o,e.dataQueries,e.styles?.chartingStyles,i,a,E,j,$,g,n);u.useEffect(()=>{if(!S||!e.dataQueries?.length){v();return}me&&v({attachments:_,dataQueriesKey:A,activeDatasetUrns:Y?Array.from(Y):void 0,isLoading:le})},[Y,e.dataQueries?.length,_,A,S,le,v,me]);const[ue,ae]=u.useState(),[ee,U]=u.useState({filterKey:null,timeFilter:null}),B=u.useMemo(()=>S?le:fe,[S,le,fe]),oe=u.useCallback((ce,Me,Ne)=>{U(ce),ae(!0),se(ce,Me,Ne)},[se]),re=u.useCallback((ce,Me,Ne,ie,Le)=>{ae(!0),de(ce,Me,Ne,ie,Le)},[de]),ge=u.useCallback(ce=>{ce&&t?.updateCurrentDataQuery(e?.dataQueries?.find(Me=>Me?.urn===ce)||e.currentDataQuery)},[t,e.currentDataQuery,e?.dataQueries]),he=Pn(f?.isExternaLinkIncludeFilters,ee,e.currentDataQuery||e.dataQueries?.[0],H);return r.jsx(on,{styles:{titles:n,attachmentsStyles:e.styles,formattingSettings:i,limitMessages:h,attachmentsConfig:f},children:r.jsx(mf,{currentUrn:p,structuresMap:me?.structuresMap,locale:o,dataQueries:e?.dataQueries,gridViewMode:g,onGridViewModeChange:b,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:r.jsxs("div",{className:"advanced-view flex h-full min-w-0 flex-1 flex-col",children:[r.jsx(um,{locale:o,shareConversationProps:s,isShowShare:c?.isShowShare}),D.length?r.jsxs(r.Fragment,{children:[R&&r.jsx(Ni,{datasets:D,initialSelectedDatasetUrn:e?.currentDataQuery?.urn,locale:o,selectDataset:ge}),B&&!ue?r.jsx(M.Loader,{}):r.jsxs(r.Fragment,{children:[N&&r.jsx(dm,{...d,locale:o,dataset:q,data:J?.data,structures:z,metadataSettings:a,getDatasetUpdatedTime:l,externalLink:he}),r.jsxs("div",{className:W("flex flex-1 min-h-0 overflow-auto",N&&"border-t border-neutrals-500"),children:[r.jsx("div",{className:W("flex-1 min-h-0 overflow-auto","advanced-view-filters"),children:r.jsx(cm,{...m,actions:t,attachments:S?_:ne,attachmentsDataQuery:e.currentDataQuery,dataQueries:e?.dataQueries,dimensions:H,isDataLoading:B,locale:o,filtersProps:{...m?.filtersProps,structureDimensions:K,structures:z,structureDataMaps:me,onFiltersChange:se,onMultipleDataFiltersChange:re,initialConstraints:xe},setIsFiltering:ae,filters:ee,onFiltersChange:oe})}),C&&r.jsx(Yi,{scope:"advanced"})]})]})]}):r.jsx(M.Loader,{})]})})})};function wh(e,t,n,s,a,i){const[o,c]=u.useState([]),[l,f]=u.useState(),[d,h]=u.useState(!1),m=u.useRef(void 0);return u.useEffect(()=>{m.current=i},[i]),u.useEffect(()=>{let p=!0;async function g(b){h(!0);try{const C=await Promise.all(b.map(w=>at(e,st(w.urn),()=>e(w.urn))));if(!p)return;const x=C?.map(w=>w?.data?.dataflows?.[0])?.filter(w=>!!w)||[];c(x),t(x),n(b),s(b.find(w=>w.urn===m.current?.urn)??b[0]),f(new Map(C?.map(w=>[y.generateShortUrn(w?.data?.dataflows?.[0]?.id,w?.data?.dataflows?.[0]?.version,w?.data?.dataflows?.[0]?.agencyID),w?.data])))}catch(C){console.error("Error loading datasets",C)}finally{p&&h(!1)}}if(!a?.length){h(!1);return}return g(a),()=>{p=!1}},[a,e,s,n,t]),{datasets:o,datasetStructuresMap:l,isLoading:d}}function Ga(e){const t=e?.filter(n=>yi(n));if(t?.every(n=>!!n?.data))return t?.map(n=>({title:n?.title,...vh(xh(n?.data))}))}function xh(e){if(e)try{return JSON.parse(e)}catch(t){console.error("Invalid JSON:",t)}return null}function vh(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 So=(e=>(e.COMPLETED="completed",e))(So||{});const bh=({stage:e,stageRef:t,isCurrentStage:n})=>r.jsxs("div",{ref:t,className:"message-stage relative flex pb-8 last:mb-8 last:pb-0",children:[r.jsx("span",{className:"message-stage-line absolute h-full border-l"}),r.jsx(Ve.IconPointFilled,{className:"message-stage-indicator z-10 flex shrink-0"}),r.jsxs("div",{className:"ml-2 w-full",children:[r.jsxs("div",{className:W("flex gap-2 items-center",e?.content&&"mb-4"),children:[n&&r.jsx(M.Loader,{}),r.jsx("h3",{className:"message-stage-name",children:e?.name})]}),r.jsx("div",{className:"prose max-w-full break-words",children:r.jsx(Wa,{remarkPlugins:[$a],components:{strong:s=>r.jsx("strong",{className:"text-neutrals-1000",...s}),a:({href:s,children:a,...i})=>r.jsx("a",{href:s,target:"_blank",rel:"noreferrer",...i,children:a}),h1:({children:s,...a})=>r.jsx("h1",{className:"h1 text-neutrals-1000",...a,children:s}),h2:({children:s,...a})=>r.jsx("h2",{className:"h2 text-neutrals-1000",...a,children:s}),h3:({children:s,...a})=>r.jsx("h3",{className:"h3 text-neutrals-1000",...a,children:s}),h4:({children:s,...a})=>r.jsx("h4",{className:"h4 text-neutrals-1000",...a,children:s}),h5:({children:s,...a})=>r.jsx("h5",{className:"h5 text-neutrals-1000",...a,children:s}),code:s=>r.jsx("code",{className:"text-neutrals-900",...s}),pre:s=>r.jsx("pre",{className:"border border-neutrals-600 bg-neutrals-100",...s})},children:e?.content})})]})]}),Sh=({stages:e,expandIcon:t,processingTitle:n})=>{const[s,a]=u.useState(),[i,o]=u.useState(),c=u.useRef(null),l=u.useRef(null);u.useEffect(()=>{o(e?.filter(d=>d?.status!==So.COMPLETED)?.at(-1))},[e]),u.useEffect(()=>{s&&l?.current?.scrollIntoView({block:"nearest",behavior:"smooth"})},[s]),u.useEffect(()=>{const d=c.current;let h;if(!d)return;const m=new IntersectionObserver(([p])=>{const g=p?.boundingClientRect?.top;h&&!p?.isIntersecting&&g<h&&a(!1),h=g},{threshold:0});return m.observe(d),()=>m.disconnect()},[]);const f=()=>{a(d=>!d)};return r.jsxs("div",{className:"message-stages",ref:c,children:[r.jsxs("div",{className:W("message-stages-header inline-flex max-w-full items-center cursor-pointer",!i?.name&&"default-header"),onClick:f,children:[r.jsx("p",{className:"message-stages-title truncate",children:i?.name||n||"Processing..."}),r.jsx("i",{className:W("message-stages-expand-icon",s&&"rotated"),children:t})]}),s&&e&&r.jsx("div",{className:"flex flex-col",children:e?.map(d=>r.jsx(bh,{stage:d,stageRef:i?l:null,isCurrentStage:d?.index===i?.index},d.index))})]})},yh=2e3,Dh=({message:e,regenerateMessage:t,messageActionsIcons:n,rateResponse:s,isStreaming:a=!1,isReadOnly:i=!1,isRegenerateAvailable:o=!1})=>{const{messageActionsTitles:c}=ye(),l=n?.copy,f=n?.copied,d=n?.regenerate,h=n?.thumbUp,m=n?.thumbDown,p=n?.thumbPressed,[g,b]=u.useState(e.like??Ie.LikeState.NoState),[C,x]=u.useState(!1),w=u.useRef(null),{isAgentAvailable:v}=M.useAgentAvailability();u.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]);const S=T=>{e.responseId&&(b(T),s(e.responseId||"",T))},k=()=>{navigator.clipboard.writeText(e.content),x(!0),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{x(!1)},yh)};return r.jsxs("div",{className:W("message-actions","flex gap-x-2 pt-2"),children:[l&&r.jsx("p",{onClick:k,title:c?.copy,children:C&&f?f:l}),o&&d&&!i&&!a&&r.jsx("p",{onClick:v?()=>t?.(e):void 0,"aria-disabled":!v,title:c?.regenerate,className:W(!v&&"opacity-50 !cursor-not-allowed pointer-events-none"),children:d}),h&&!i&&g!==Ie.LikeState.Disliked&&(g===Ie.LikeState.NoState?r.jsx("p",{onClick:()=>S(Ie.LikeState.Liked),title:c?.like,children:h}):r.jsx("p",{title:c?.like,children:p})),m&&!i&&g!==Ie.LikeState.Liked&&(g===Ie.LikeState.NoState?r.jsx("p",{onClick:()=>S(Ie.LikeState.Disliked),title:c?.dislike,children:m}):r.jsx("p",{className:"rotate-180",title:c?.dislike,children:p}))]})},Mh=({message:e,onEditClick:t,messageActionsIcons:n,isStreaming:s=!1,isReadOnly:a=!1})=>{const i=n?.copy,o=n?.edit,{isAgentAvailable:c}=M.useAgentAvailability();return r.jsxs("div",{className:W("message-actions","flex gap-x-2 pt-2 ml-12"),children:[i&&r.jsx("p",{onClick:()=>navigator.clipboard.writeText(e.content),children:i}),o&&!s&&!a&&r.jsx("p",{onClick:c?t:void 0,className:W(!c&&"opacity-50 !cursor-not-allowed pointer-events-none"),"aria-disabled":!c,children:o})]})},Th=({content:e,textColorClass:t,onCancel:n,onEditApply:s,editMessageTitles:a})=>{const{isOpenedAdvancedView:i}=Ge(),o=u.useRef(null);u.useEffect(()=>{const l=o.current;c(),l&&(l.focus(),l.setSelectionRange(l.value.length,l.value.length))},[]);const c=()=>{const l=o.current;l&&(l.style.height="auto",l.style.height=l.scrollHeight+"px")};return r.jsxs("div",{className:W("max-w-none break-words",i?"body-2":"body-1",t),children:[r.jsx("textarea",{ref:o,className:"w-full resize-none overflow-hidden bg-neutrals-300 outline-none",defaultValue:e,onInput:c}),r.jsxs("div",{className:W("flex gap-x-2 items-center","edit-buttons-wrapper"),children:[r.jsx(M.Button,{buttonClassName:"text-button-secondary small-icon-button",title:a?.cancel,isSmallButton:!0,onClick:n}),r.jsx(M.Button,{buttonClassName:"text-button-primary small-icon-button",title:a?.send,isSmallButton:!0,onClick:()=>s(o.current?.value||"")})]})]})},Eh=({message:e,previousMessage:t,actions:n,dataQuery:s,isStreaming:a=!1,isCurrentMessageStreaming:i=!1,showAdvancedView:o,locale:c,metadataSettings:l,onAdvancedViewOpen:f,regenerateMessage:d,selectMessageToSend:h,rateResponse:m,editMessage:p,isReadOnlyConversation:g,isLastNotUserMessage:b,onCodeAttachmentUpdated:C})=>{const{messageStyles:x,attachmentsStyles:w,formattingSettings:v,messageActionsIcons:S,editMessageTitles:k,expandStagesIcon:T,titles:N}=ye(),[D,R]=u.useState(),[E,A]=u.useState(),[j,O]=u.useState([]),[L,$]=u.useState([]),[J,q]=u.useState(),[H,K]=u.useState(!1),{isCrossDatasetModeOn:z}=Ue(),ne=Cn(),se=e.role===Ie.Role.User,fe=e.role===Ie.Role.System,{datasets:xe,datasetStructuresMap:me,isLoading:_}=wh(n.getDataSet,n.updateDatasets,n.updateDataQueries,n.updateCurrentDataQuery,D,s),[Y,le]=u.useState(!1),[de,ue]=u.useState([]);u.useEffect(()=>{A(D?.[0])},[D]);const ae=z&&!!D?.length,ee=u.useCallback(be=>{e.id&&C?.(e.id,be)},[e.id,C]),{dataSetAttachments:U,dimensions:B,isLoadingGridData:oe}=Co(n,c,E,v,w?.chartingStyles,l,N,e.custom_content?.attachments,E?me?.get(E.urn):void 0,_,ee,ae),re=u.useMemo(()=>ei(D,ne.map),[D,ne.map]),{crossDatasetAttachments:ge,isLoadingGridData:he}=vo(n,c,D,w?.chartingStyles,v,l,e.custom_content?.attachments,re,ee,void 0,N),{isOpenedAdvancedView:ce}=Ge(),{attachments:Me,dataQueriesKey:Ne,isLoading:ie}=xn(),Le=u.useMemo(()=>ti(D),[D]),We=z&&!!o&&Me!=null&&Ne===Le,Be=We?Me:ge,_e=u.useMemo(()=>z?We?ie:he:oe,[z,he,oe,ie,We]),He=()=>{se&&le(!0)},qe=()=>{le(!1)},$e=be=>{qe(),p?.({...e,content:be})},X=u.useCallback(be=>{be&&(A(D?.find(F=>F?.urn===be)),q(void 0))},[D]);u.useEffect(()=>{const be=e.custom_content?.form_schema?.properties,F=b?be?.choice?.oneOf||be?.completion?.oneOf:[];ue(F||[])},[e,b]),u.useEffect(()=>{const be=ba(e),F=Ga(be),Q=be.filter(I=>Jn(I));R(F),$(Q)},[e]),u.useEffect(()=>{K(D!=null&&D.length>0)},[D]),u.useEffect(()=>{s?.urn&&D?.some(be=>be?.urn===s.urn)&&q(s.urn)},[s,D]),u.useEffect(()=>{if(e?.role===Ie.Role.System&&t){const be=ba(t),F=Ga(be)||[];D&&F&&me&&O(ld(F,D,me,c,ne.map))}},[D,E,me,ne.map,B,c,e?.role,t]);const pe=u.useCallback(()=>!se&&x?.systemMessageIcon&&!(ce&&!i)?r.jsx("div",{className:W("flex-shrink-0 rounded-full flex items-center justify-center w-[44px] h-[44px]",i?"text-white absolute":"text-neutrals-400"),children:x.systemMessageIcon}):null,[se,x?.systemMessageIcon,ce,i]),ve=u.useMemo(()=>r.jsx(oo,{actions:n,attachments:H?z?Be:U:L,onAdvancedViewOpen:f,isDataSetAttachments:H,datasets:xe,initialSelectedDatasetUrn:J,showAdvancedView:o,isSystemAttachments:fe,isDataLoading:_e,currentDataQuery:E,dataQueries:D,attachmentInfoList:j,locale:c,dimensions:B,selectDataset:X}),[n,H,U,L,Be,xe,J,o,fe,_e,E,D,j,c,B,X,f,z]);if(fe&&ce)return null;const Ce=i?null:se?Y?null:r.jsx(Mh,{messageActionsIcons:S,message:e,isStreaming:a,onEditClick:He,isReadOnly:g}):fe?null:r.jsx(Dh,{messageActionsIcons:S,message:e,isStreaming:a,regenerateMessage:d,rateResponse:m,isReadOnly:g,isRegenerateAvailable:b});return r.jsx("div",{className:W("max-w-full flex",se?"justify-end":"justify-start","message-wrapper"),children:r.jsxs("div",{className:W("flex items-start",se&&!Y?"max-w-full":"w-full"),children:[r.jsxs("div",{className:"relative mr-2",children:[pe(),i&&r.jsx(M.Loader,{})]}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:W(se?"bg-neutrals-300 px-6":"pt-0",se?"user-message":"system-message",se&&(Y?"w-[100%] ml-0":"ml-12")),children:[!se&&!ce&&e?.custom_content?.stages?r.jsx(Sh,{stages:e?.custom_content?.stages,expandIcon:T,processingTitle:x?.processingTitle}):i&&r.jsx("p",{className:"body-1 loading-message text-neutrals-700",children:N?.loading}),Y?r.jsx(Th,{content:e.content,onCancel:qe,onEditApply:$e,editMessageTitles:k}):r.jsx(gr,{content:e.content})]}),ve,Ce,!ce&&!_e&&r.jsx(Cr,{choiceButtons:de,onClick:h})]})]})})},Ah=({messages:e,isStreaming:t=!1,isReadOnly:n,conversationViewState:s,...a})=>{const{scrollBottomIcon:i}=ye(),o=u.useRef(null),c=u.useRef(null),{isOpenedAdvancedView:l}=Ge(),f=ht(),[d,h]=u.useState(null),[m,p]=u.useState(!1),g=f?.isPanelOpen()??!1,b=()=>{const S=c.current?.parentElement,k=o.current;if(S&&k){const T=k.offsetTop-S.offsetTop;S.scrollTo({top:T,behavior:"smooth"})}};u.useEffect(()=>{b()},[e,t]),u.useEffect(()=>{!l&&d!==null&&setTimeout(()=>{c?.current?.parentElement?.scrollTo({top:d,behavior:"smooth"})})},[l,d]);const C=()=>{const S=c.current?.parentElement?.scrollTop||null;h(S)},x=()=>{const S=c.current?.parentElement;if(S){const{scrollTop:k,scrollHeight:T,clientHeight:N}=S;k+N>=T?p(!1):!m&&!l&&p(!0)}};u.useEffect(()=>{l&&p(!1)},[l]);const w=M.useDebounce(x,300);u.useEffect(()=>{const S=c.current?.parentElement;return S?.addEventListener("scroll",w),()=>S?.removeEventListener("scroll",w)},[w]);const v=u.useCallback(S=>{const k=te.linkifyText(S);return r.jsx("div",{className:"whitespace-pre-wrap break-words",children:k.map((T,N)=>T.type==="text"?r.jsx(u.Fragment,{children:T.value},N):r.jsx("a",{href:T.value,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center align-middle",children:r.jsx(Ve.IconExternalLink,{className:"size-4 shrink-0 cursor-pointer text-primary"})},N))})},[]);return r.jsxs("div",{ref:c,className:"flex size-full justify-center",children:[r.jsxs("div",{className:"chat-messages-wrapper flex w-full flex-col gap-y-6",children:[e.map((S,k)=>{const T=S.id??k;if(S.errorMessage){const E=s?.errorContext?.kind===we.ERROR_CONTEXT_KIND.RATE_LIMIT?M.InlineAlertType.Warning:M.InlineAlertType.Error;return r.jsx(M.InlineAlert,{type:E,children:r.jsx("div",{className:"flex flex-col",children:v(S.errorMessage)})},T)}if(l&&S.role===Ie.Role.System)return null;const N=k===e.length-1,D=Hc(e,k),R=Mi(e);return r.jsx(Eh,{message:S,previousMessage:D,onAdvancedViewOpen:C,isStreaming:t,isCurrentMessageStreaming:t&&N&&S.role===Ie.Role.Assistant,showAdvancedView:k===R&&!n,isLastNotUserMessage:N&&S.role!==Ie.Role.User,...a},T)}),r.jsx("div",{ref:o,className:"h-4"})]}),r.jsx("div",{onClick:b,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:r.jsx("div",{className:"flex size-full items-center justify-center",children:i})})]})},Nh=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},kh="local",jh=e=>!e.permissions?.includes(Ie.SharePermission.WRITE)&&!Lh(e),Ih=(e,t)=>yo(e)!==t,Lh=e=>yo(e)===kh,yo=e=>e.id.split("/")[0],Ph=(e,t)=>rs([...t?.messages||[],e]),rs=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=Oh(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}),Rh=(e,t)=>{const n=t?.messages,s=n?.findIndex(a=>e.id===a.id);return rs(n?.slice(0,s)||[])},Fh=(e,t)=>{const n=t?.messages,s=n?.findIndex(a=>e.id===a.id);return rs([...n?.slice(0,s)||[],e])};function Oh(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 _h=(e,t,n,s)=>{if(!n||t)return null;const a={id:`msg-${Date.now()}`,role:Ie.Role.User,content:e,timestamp:Date.now()};if(s){const i=s===rn.COMPLETE?Zt.COMPLETION:Zt.CHOICE;a.custom_content={form_value:{[i]:s}}}return a},Vh=(e,t,n)=>`/${t}${n}/${te.getConversationNavPath(e?.folderId,e?.id)}`,Hh=(e,t,n)=>{const s=`${t}/${n}`,a=we.generateConversationId({folderId:s,name:e?.name});return{...e,folderId:s,id:a}},Uh=(e,t)=>{const n=e.lastIndexOf(".");return n<=0?`${e}-${t}`:`${e.slice(0,n)}-${t}${e.slice(n)}`},Bh=(e,t,n)=>{const s=e.split("/");if(s[0]!=="files"||s.length<3)return e;const a=s.at(-1)??"file",i=Uh(a,n);return["files",t,...s.slice(2,-1),i].join("/")},Gh=async({conversation:e,bucket:t,getFileBlob:n,putFile:s})=>{const a=te.getConversationAttachmentUrls(e),i=Date.now();if(!a.length)return e;const o=await Promise.all(a.map(async c=>{const l=Bh(c,t,`${i}`);if(l===c)return[c,l];const f=await n(c);return await s(l,f),[c,l]}));return te.replaceConversationAttachmentUrls(e,Object.fromEntries(o))},zh="AbortError",Wh=({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 te.HttpError({message:e.message,displayMessage:n,code:e.type,status:e.status??te.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 te.HttpError({message:e.message,status:e.status??te.HTTP_ERROR_CODES.BAD_REQUEST,code:e.code})}},$h=({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===te.HTTP_ERROR_CODES.SERVICE_UNAVAILABLE?t.serverOverloaded:t.serverError}},za=(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}}}},Jh=()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}},Kh=({conversationKey:e,conversation:t,actions:n,messageStyles:s,attachmentsStyles:a,inputMessageStyles:i,shareConversationProps:o,showConversationHeaderAdvancedView:c=!0,formattingSettings:l,metadataSettings:f,expandStagesIcon:d,locale:h,conversationsRoute:m,token:p,titles:g,dataQuery:b,handleInvalidStreaming:C,onConversationNotFound:x,setConversation:w,setConversations:v,openUrl:S,messageActionsIcons:k,messageActionsTitles:T,editMessageTitles:N,scrollBottomIcon:D,isFinalMessage:R,limitMessages:E,attachmentsConfig:A,headerRightSlot:j,children:O})=>{const[L,$]=u.useState(null),[J,q]=u.useState(!1),[H,K]=u.useState(!0),{isStreaming:z,setIsStreaming:ne}=qa(),{isOpenedAdvancedView:se}=Ge(),{setCrossDatasetAttachmentsState:fe}=xn(),{isCrossDatasetModeOn:xe}=Ue(),{isAgentAvailable:me}=M.useAgentAvailability(),{statusMessages:_}=Vn(),{onboardingFileSchema:Y,onboardingFilePath:le,onboardingFileName:de,isShowOnboarding:ue,setOnboardingFileSchema:ae}=Ye();u.useEffect(()=>{Y&&n.putOnboardingFile?.(de,le,Y)},[n,Y,de,le]),u.useEffect(()=>{se&&Y?.lastDisplayedElement===Oe.OPEN_ADVANCED_VIEW&&ae?.(bi(Y))},[n,se,ae,Y]);const ee=u.useCallback(()=>{S(`/${h}${m}`)},[h,m,S]),U=u.useCallback(async()=>{try{const{bucket:I}=await n.getBucket(),P=n.getFileBlob&&n.putFile?await Gh({conversation:t,bucket:I,getFileBlob:n.getFileBlob,putFile:n.putFile}):t,V=Hh(P,I,h);await n.createConversation(V,h);const Z=await n.getConversations(h);v(te.cleanConversationNames(Z)),S(Vh(V,h,m))}catch(I){console.error("Failed to save conversation:",I)}},[n,t,m,h,S,v]),B=u.useCallback(async I=>{try{await n.updateConversation(decodeURI(e),{name:I.name,messages:I.messages,customViewState:I.customViewState})}catch(P){console.error("Failed to save conversation:",P)}},[n,e]),oe=u.useCallback((I,P)=>{if(!t)return;const V=wo(t.messages,P,I);if(!V)return;const Z={...t,messages:V};w(Z),B(Z)},[t,w,B]),re=u.useCallback(I=>{w(P=>P?{...P,messages:[...P?.messages||[],I]}:null)},[w]),ge=u.useCallback(()=>{const I={id:`msg-${Date.now()+1}`,role:Ie.Role.Assistant,content:"",timestamp:Date.now()};return w(P=>P?{...P,messages:[...P.messages,I]}:null),I},[w]),he=u.useCallback((I,P)=>{const V=we.mergeMessages?.(I,[P]);if(V)return w(Z=>Z?{...Z,messages:Z.messages.map(G=>G.id===I.id?{...V}:G)}:null),V},[w]),ce=u.useCallback((I,P)=>{t?.model?.id&&(n.rateResponse(I,P===Ie.LikeState.Liked,t.model.id),t.messages=t.messages.map(V=>V.responseId===I?On.merge(V,{like:P}):V),B(t))},[n,t,B]),Me=u.useCallback((I,P)=>{let V=_.serverError,Z,G;if(te.isHttpError(I)){G=I;const De=$h({error:I,statusMessages:_});V=De.errorMessage,Z=De.errorContext}else G=new te.HttpError({status:te.HTTP_ERROR_CODES.INTERNAL_SERVER_ERROR,message:V});return P&&(P=he(P,{errorMessage:V})),C?.(G),{assistantMessage:P,errorContext:Z}},[C,_,he]),Ne=u.useCallback(async(I,P,V)=>{const Z=new AbortController;$(Z);let G=I,De;if(!V)return{assistantMessage:G,errorContext:De};const Te=V.custom_fields??{},Je={...Te,configuration:{...Te.configuration,timezone:Jh(),...xe&&{merge_python_code:!0}}};return await we.streamChatResponse?.(encodeURI(V.id),P,{model:V.model,signal:Z?.signal,onMessage:Re=>{Wh({error:Re.error,statusMessages:_});const Ze=Nh(Re);(Ze.content||Ze.role||Ze.responseId)&&(G=he(G,Ze))},onError:Re=>{if(!_e(Re))throw console.error("Streaming error:",Re),Re}},p,Je).catch(Re=>{if(!_e(Re)){const{assistantMessage:Ze,errorContext:et}=Me(Re,G);G=Ze,De=et}}),{assistantMessage:G,errorContext:De}},[p,he,Me,_,xe]),ie=u.useCallback(async(I,P,V,Z)=>{if(!P)return;let G=za(P,Z);G={...G,messages:[...P.messages],updatedAt:Date.now()},V&&G.messages.push(V),G.messages.push(I),await B(G)},[B]),Le=u.useCallback(I=>{w(P=>P&&za(P,I))},[w]),We=u.useCallback((I,P)=>{w(V=>V?{...V,messages:V.messages.filter(Z=>Z.id!==P.id)}:null)},[w]),Be=u.useCallback(()=>{L&&!L.signal.aborted&&L.abort()},[L]),_e=I=>I?.name===zh,He=u.useCallback(async(I,P,V,Z,G,De=!0)=>{_e(G)?await ie(Z??V,I,De?P:void 0):We(G,P)},[ie,We]),qe=u.useCallback(async(I,P,V)=>{if(!P||!I)return;const Z=_h(I,z,P,V);let G,De;if(Z){re(Z);try{ne(!0),G=ge();const Te=Ph(Z,P),{assistantMessage:Je,errorContext:Re}=await Ne(G,Te,P);Le(Re),De=Je,await ie(De,P,Z,Re)}catch(Te){He(P,Z,G,De,Te)}finally{ne(!1)}}},[z,ne,re,ge,Ne,ie,He,Le]),$e=u.useCallback(async(I,P,V)=>{let Z,G;try{ne(!0),Z=ge();const{assistantMessage:De,errorContext:Te}=await Ne(Z,I,P);G=De,Le(Te),await ie(G,P,void 0,Te)}catch(De){He(P,V,Z,G,De,!1)}finally{ne(!1)}},[ne,ie,He,Ne,ge,Le]),X=u.useCallback(async(I,P)=>{if(!P||!I)return;const V=Rh(I,P),Z={...P,messages:P.messages.slice(0,V.length)};w(G=>G?{...G,...Z}:null),$e(V,Z,I)},[w,$e]),{isLastMessageFailed:pe,regenerateLastMessage:ve}=u.useMemo(()=>{const I=t?.messages?.at(-1);return{isLastMessageFailed:!!I?.errorMessage,regenerateLastMessage:I&&(()=>X(I,t))}},[t,X]),Ce=u.useCallback(async(I,P)=>{if(!P||!I)return;const V=Fh(I,P),Z={...P,messages:[...P.messages.slice(0,V.length-1),I]};w(G=>G?{...G,...Z}:null),$e(V,Z,I)},[w,$e]);u.useEffect(()=>{oa(),fe();async function I(){try{K(!0);const{bucket:P}=await n.getBucket(),V=await n.getConversation(decodeURI(e));w(V),q(jh(V)&&Ih(V,P)),(V.messages.length===0||V?.messages?.[0]?.role===Ie.Role.Assistant&&V?.messages?.length===1)&&qe(V.prompt,V)}catch{q(!0),x?.()}finally{K(!1)}}return e&&I(),()=>{oa()}},[e]);const be=u.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(H)return r.jsx(M.Loader,{});const F=t?.customViewState?.[we.CUSTOM_VIEW_STATE_KEY],Q=()=>{if(F?.errorContext?.kind===we.ERROR_CONTEXT_KIND.RATE_LIMIT&&we.isRateLimitStillActive(F.errorContext)){const I=we.getRateLimitRestoreDate(F.errorContext);if(I){const P=we.formatDateTime(I);return r.jsx(M.InlineAlert,{type:M.InlineAlertType.Info,children:_.getAssistantRestoreMessage(P.date,P.time)})}}return me?r.jsx(er,{onSendMessage:I=>qe(I,t),onStopStreaming:Be,inProcess:z,sendMessageIcon:i.sendMessageIcon,retryIcon:i.retryIcon,placeholder:g?.askAnything??"Ask anything...",containerClasses:"mt-4",inputClasses:"border-neutrals-600 mr-2",isLastFailed:pe,onRetryFailed:ve}):r.jsx(M.InlineAlert,{type:M.InlineAlertType.Error,children:_.assistantUnavailable})};return r.jsx(on,{styles:{titles:g,messageStyles:s,attachmentsStyles:a,formattingSettings:l,messageActionsIcons:k,messageActionsTitles:T,editMessageTitles:N,expandStagesIcon:d,scrollBottomIcon:D,limitMessages:E,attachmentsConfig:A},children:r.jsxs("div",{className:W("h-full flex flex-col bg-white conversation-view-wrapper",se&&!c?"p-4":"pr-2"),children:[se&&!c?null:r.jsx(pr,{conversation:t,locale:h,isOpenedAdvancedView:se,isShowShareButton:!J&&!ue,shareConversationProps:o,rightSlot:j}),r.jsxs("div",{className:"flex min-h-0 min-w-0 w-full flex-1",children:[r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[r.jsx("div",{className:W("flex-1 min-h-0 flex flex-col items-end scroll-hidden-container",s?.messagesWrapperClass),children:r.jsx(Ah,{messages:t?.messages||[],actions:be,isStreaming:z,isReadOnly:J,metadataSettings:f,dataQuery:b,locale:h,regenerateMessage:I=>X(I,t),selectMessageToSend:(I,P)=>qe(I,t,P),rateResponse:ce,editMessage:I=>Ce(I,t),isReadOnlyConversation:J||ue,conversationViewState:F,onCodeAttachmentUpdated:oe})}),ue?null:J?r.jsx("div",{className:"mt-4 flex items-center justify-center",children:r.jsx(M.Button,{iconBefore:r.jsx(Ve.IconCopy,{width:20,height:20}),title:g?.duplicate??"Duplicate Chat",isSmallButton:!0,onClick:U,buttonClassName:W("text-button-secondary")})}):r.jsx("div",{className:W(i.inputContainerClass),children:Q()}),ue&&R&&r.jsx(M.Button,{iconBefore:r.jsx(Ve.IconPlus,{width:24,height:24}),title:g?.onboardingFooterLink,onClick:ee,isSmallButton:!0,buttonClassName:"text-button-secondary self-center mb-3"}),O]}),!se&&r.jsx(Yi,{scope:"conversation"})]})]})})},Yh=({conversationName:e,expandTitle:t,expandIcon:n,onExpand:s})=>r.jsxs("div",{className:"flex h-full w-[51px] shrink-0 flex-col items-center border border-neutrals-400 bg-white",children:[r.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}),r.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center overflow-hidden pb-[88px] pt-[72px]",children:r.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=Ch;exports.AdvancedViewProvider=Io;exports.CUSTOM_CHOICE_ID=rn;exports.ChartingIcon=Xt;exports.ChatFooter=xr;exports.ChatMessagesProvider=Lo;exports.ChatOnboardingFooter=wr;exports.CollapsedChatPanel=Yh;exports.ConversationView=Kh;exports.ConversationViewFeatureTogglesProvider=El;exports.ConversationViewMessagesProvider=Po;exports.ConversationViewSidePanelProvider=tu;exports.ConversationViewStylesProvider=on;exports.ConversationWelcome=nl;exports.CrossDatasetAttachmentsProvider=gh;exports.CustomContentProperties=Zt;exports.DatasetDimensionsMetadataMapProvider=Yf;exports.OnboardingProvider=Ro;exports.STAGE_STATUS=Qa;exports.useAdvancedView=Ge;exports.useChatMessages=qa;exports.useConversationViewFeatureToggles=Ue;exports.useConversationViewMessages=Vn;exports.useConversationViewSidePanelOptional=ht;exports.useConversationViewStyles=ye;exports.useCrossDatasetAttachments=xn;exports.useDatasetDimensionsMetadataMap=Cn;exports.useDatasetDimensionsMetadataMapOptional=wn;exports.useOnboarding=Ye;
|
|
13
|
+
\`\`\``}))}).catch(f=>console.error("Error refreshing python attachment:",f))}const Ym="Data Grid",qm="Data",Zm="Chart",Xm=e=>({title:e||Ym,type:we.AttachmentType.CUSTOM_DATA_GRID}),go=e=>({title:e||Zm,type:we.AttachmentType.CUSTOM_CHART}),Qm=e=>({title:e||qm,type:we.AttachmentType.CROSS_DATASET_GRID});function Co(e,t,n,s,a,i,o,c,l,f=!1,u,h=!1){const[m,p]=d.useState(),[g,b]=d.useState(),[C,x]=d.useState(),[w,v]=d.useState(),[S,k]=d.useState(Xm(o?.dataGrid)),[T,N]=d.useState(go(o?.chart)),[D,R]=d.useState(!1),[E,A]=d.useState([]),[I,O]=d.useState([]),[L,W]=d.useState([]),[$,q]=d.useState(!1),[U,J]=d.useState(!1),G=d.useRef(0),[te,ne]=d.useState({startPeriod:null,endPeriod:null}),{getConstraints:fe,getDataSet:xe,getDataSetData:me,putOnboardingFile:_,getPythonAttachment:K}=e,le=d.useCallback(H=>{if(!H)return;const B=y.getDimensions(H);b(H.dataflows?.[0]||void 0),v(H||void 0),O([...B?.dimensions||[],...B?.timeDimensions||[]])},[]),de=d.useCallback(async H=>{const B=jt(y.getFiltersDtoFromDataQuery(H));try{const ae=(await st(fe,nt(H.urn,B),()=>fe(H.urn,B)))?.data?.dataConstraints||[];x(ae)}catch{x([])}},[fe]),ue=d.useCallback(async H=>{const B=l?{data:l}:await st(xe,nt(H.urn),()=>xe(H.urn));if(B?.data){const oe=y.getDimensions(B.data);le(B.data);const ae=oe?.dimensions==null?null:y.getTimeSeriesFilterKey(oe?.dimensions,H.filters??[]),ge=Fr(H,oe);st(me,nt(H.urn,{filterKey:ae,timeFilter:ge}),()=>me(H.urn,{filterKey:ae,timeFilter:ge})).then(he=>{J(!0),p(he||void 0),W(y.getStructureDimensions(he))}).finally(()=>q(!1))}},[le,xe,me,l]);d.useEffect(()=>{le(l)},[le,l]),d.useEffect(()=>{async function H(B){q(!0);try{await Promise.all([...h?[]:[de(B)],ue(B)])}catch(oe){console.error("Error loading dataset details",oe)}}n!=null&&!(f&&!l)?H(n):n!=null&&f&&q(!0)},[n,l,f,de,ue,h]);const se=d.useCallback((H,B,oe)=>{try{q(!0),x(B);const ae=oe?.find(ge=>ge.id===y.TIME_PERIOD)?.timeRange;if(ae&&ne(ae),st(me,nt(n?.urn||"",H),()=>me(n?.urn||"",H)).then(ge=>{J(!0),p(ge||void 0),W(y.getStructureDimensions(ge))}).finally(()=>q(!1)),K&&n&&oe){const ge=Vr(n,oe),he=c?.find(ce=>ce.type===we.AttachmentType.MARKDOWN&&ce.data?.includes("```python"))?.title;po({getPythonAttachment:K,dataQueries:[ge],requestIdRef:G,codeTitle:o?.codeSamples||"Python Code",markdownTitle:he??n.urn,setCodeAttachments:A,onCodeAttachmentUpdated:u})}}catch(ae){console.error("Error loading dataset data",ae)}},[n,me,K,o,c,u]);d.useEffect(()=>{if(w!=null&&m!=null&&C?.length){J(!0);const H=Pt(()=>{k(B=>({...B,...$m(w,m,n,t,s,i,a,o,_,C,te)})),J(!1)});return()=>{H(),J(!1)}}(m==null||C!==void 0)&&J(!1)},[w,m,o,t,s,n,i,a,C,te,_]),d.useEffect(()=>{if(w==null||m==null)return;const H=Fm(w,m,n,t,a);return N(B=>({...B,charting_data:void 0,getChartingData:H})),R(!1),Pt(()=>{try{R(uo(H()))}catch(B){console.error("Error evaluating chart plottability",B),R(!1)}})},[w,m,n,t,a]),d.useEffect(()=>{if(c?.length){const H=ho(c,n?.urn,o?.codeSamples);H.length>0&&A(H)}},[c,o,n]);const Q=d.useMemo(()=>[S,...D?[T]:[],...E],[S,T,E,D]);return{dataMessage:m,structures:w,dataset:g,dimensions:I,structureDimensions:L,onFiltersChange:se,constraints:C,isLoadingGridData:$||U,dataSetAttachments:Q}}function wo(e,t,n){let s=-1;if(n)s=e.findIndex(o=>o.id===n);else for(let o=e.length-1;o>=0;o--)if(e[o].role===je.Role.System){s=o;break}if(s===-1||e[s].role!==je.Role.System)return null;const i=[...(e[s].custom_content?.attachments??[]).filter(o=>!(o.type==="text/markdown"&&o.data?.includes("```python"))),t];return e.map((o,c)=>c===s?{...o,custom_content:{...o.custom_content,attachments:i}}:o)}const Ba=async(e,t)=>{const n=new Map,s=y.getFiltersDtoMapFromDataQuery(e);return(await Promise.allSettled(e.map(async i=>{const o=jt(s?.get(i.urn)||[]);return{urn:i.urn,response:await st(t,nt(i.urn,o),()=>t(i.urn,o))}}))).forEach(i=>{if(i.status==="fulfilled"){const o=i.value.response?.data?.dataConstraints;Array.isArray(o)&&n.set(i.value.urn,o)}}),n},eh=()=>({datasetsMap:new Map,dataMessagesMap:new Map,structuresMap:new Map,dimensionsMap:new Map,structureDimensionsMap:new Map}),th=async(e,t,n,s,a)=>{const i=eh();await Promise.allSettled(e.map(async c=>{const l=await st(t,nt(c.urn),()=>t(c.urn));if(l?.data){const f=y.getDimensions(l.data);i.datasetsMap?.set(c?.urn,l?.data?.dataflows?.[0]),i.structuresMap?.set(c?.urn,l?.data),i.dimensionsMap?.set(c?.urn,[...f?.dimensions||[],...f?.timeDimensions||[]])}}));const o=await a?.(i);return await Promise.allSettled(e.map(async c=>{const l=i.structuresMap?.get(c.urn);if(!l||o&&!o.has(c.urn))return;const f=y.getDimensions(l),u=f?.dimensions==null?null:y.getTimeSeriesFilterKey(f?.dimensions,c.filters??[]),h=Fr(c,f);await xo(c,o?.get(c.urn)??{filterKey:u,timeFilter:h},n).then(({dataMessage:m,structureDimensions:p})=>{i?.dataMessagesMap?.set(c.urn,m),i?.structureDimensionsMap?.set(c.urn,p||[])}).catch(()=>{i?.structureDimensionsMap?.set(c.urn,[])}).finally(()=>s(!1))})),i},xo=async(e,t,n)=>{const s=await st(n,nt(e.urn,t),()=>n(e.urn,t));return{dataMessage:s,structureDimensions:y.getStructureDimensions(s)}};function nh(e,t,n,s){return[ah(e,s),sh(e,t,n,s)]}function sh(e,t,n,s){const a=i=>{const o=i.data?.dataset?.urn;if(o==null)return"";const l=e.get(o)?.dataflows?.[0];return y.getLocalizedName(l,n)||""};return{headerName:s?.dataset||rf,field:Na,colId:Na,valueGetter:a,...Ct,tooltipValueGetter:i=>i.value,cellClass:ht,cellRenderer:Ri,cellRendererParams:{structuresMap:e,attributesDataMap:t,locale:n,titles:s}}}function ah(e,t){const n=s=>{const a=s.data?.dataset?.urn;return a==null?"":e.get(a)?.dataflows?.[0]?.agencyID||""};return{headerName:t?.agency||of,field:ka,colId:ka,valueGetter:n,...Ct,tooltipValueGetter:s=>s.value}}function rh(e,t,n,s,a){return ih(e).sort((c,l)=>y.sortPeriods(c,l)).map(c=>({...oh(c,s,a),valueGetter:f=>f.data[f.column.getColId()]?.value?.[0]?.value||null,cellClass:ht,cellRenderer:fn,width:bt,cellRendererParams:{structuresMap:t,locale:n,titles:a}}))}function ih(e){const t=new Set;return e.forEach(n=>{if(n==null)return;y.getTimePeriods(n).forEach(a=>t.add(a))}),Array.from(t)}function oh(e,t=ee.defaultFormatNumbers,n){return{headerName:Sr(e,n),colId:e,field:e,type:"numericColumn",suppressColumnsToolPanel:!0,sortable:!1,width:bt,cellClass:["justify-end","cell-with-meta"],valueFormatter:s=>ee.formatNumberBySign(s.value,t)}}function lh(e,t,n,s,a,i,o=Qe.Compact){const c=new Map([...n.entries()].map(([h,m])=>[h,m?.data])),l=nh(e,c,s,a),f=pf(e,t,s,a,o),u=rh(n,e,s,i,a);return[jd(e,c,s,a),...l,...f,...u,Fi(void 0,void 0,s,void 0,a)]}function ch(e,t,n,s,a){const i=[];return n.filter(o=>!o.disabled).forEach(o=>{const c=o.urn,l=t.get(c),f=e.get(c);if(l==null||f==null)return;const u=rs(l,f,o,s,a),h=y.getLocalizedName(f.dataflows?.[0],s);i.push(...u.map(m=>({...m,dataset:{urn:c},datasetTitle:h})))}),i}function dh(e,t,n,s,a,i,o,c,l,f,u,h=Qe.Compact){const m=uh(e,t,n,s,a,i,o,c,l,f,u,h);return{title:l?.dataGrid||"Data",gridContent:m}}function uh(e,t,n,s,a,i,o,c,l,f,u,h=Qe.Compact){return{columns:lh(e,n,t,a,l,i,h),data:ch(e,t,s,a,c)}}function fh(e,t,n,s,a){let i;return()=>(i??=mh(e,t,n,s,a),i)}function mh(e,t,n,s,a){const i=n.filter(o=>!o.disabled).flatMap(o=>{const c=e.get(o.urn),l=t.get(o.urn);return!c||!l?[]:[{title:y.getLocalizedName(c.dataflows?.[0],s),units:fo(c,l,o,s,a).units}]});return{units:i.flatMap(o=>o.units),groups:i}}function vo(e,t,n,s,a,i,o,c,l,f=Qe.Compact,u){const h=Array.isArray(c)?c:void 0,[m,p]=d.useState(),[g,b]=d.useState(),[C,x]=d.useState(!1),[w,v]=d.useState(h?new Set(h):null),[S,k]=d.useState(!1),T=d.useRef(0),N=d.useRef(f),D=d.useRef(m),[R,E]=d.useState(Qm(u?.dataGrid)),[A,I]=d.useState(go(u?.chart)),[O,L]=d.useState(!1),[W,$]=d.useState([]),{getConstraints:q,getDataSet:U,getDataSetData:J,getPythonAttachment:G}=e,te=d.useRef(n);te.current=n;const ne=d.useRef(h);ne.current=h;const fe=d.useMemo(()=>n?.map(se=>se.urn).join(",")??"",[n]),xe=wn(),{getDimensionsScheme:me}=xe,_=d.useCallback(async se=>{try{const Q=await Ba(se.map(oe=>({...oe,filters:[]})),q),H=rc(se,Q,xe.map),B=H===se?Q:await Ba(H,q);return p(oe=>({...oe,constraintsMap:B})),B}catch{const Q=new Map;return p(H=>({...H,constraintsMap:Q})),Q}},[xe.map,q]),K=d.useCallback(async(se,Q)=>{const H=await th(se,U,J,x,async B=>{const oe=se.filter(ge=>!ge.disabled),ae=pa(oe,B,Q,t,xe.map);if(ae)return v(ae.compatibleUrns),ae.filterParamsMap});p(B=>({...B,...H,constraintsMap:Q??B?.constraintsMap}))},[xe.map,U,J,t]),le=d.useCallback(se=>{const Q=new Map;for(const H of se)Q.set(H.urn,me(H.urn));b(Q)},[me]);d.useEffect(()=>{async function se(H){const B=ne.current;v(B?new Set(B):null),x(!0);try{le(H);const oe=await _(H);await K(H,oe)}catch(oe){console.error("Error loading dataset details",oe)}finally{x(!1)}}const Q=te.current;Q?.length&&se(Q)},[fe,_,le,K]),d.useEffect(()=>{if(o?.length){const se=ho(o,void 0,u?.codeSamples);se.length>0&&$(se)}},[o,u]),d.useEffect(()=>{const se=N.current!==f&&D.current===m;N.current=f,D.current=m;const{structuresMap:Q,dataMessagesMap:H,constraintsMap:B}=m??{};if(Q!=null&&Q.size>0&&H!=null&&B!=null&&g!=null&&!C){se||k(!0);const oe=Pt(()=>{const ae=n?.filter(ie=>!ie.disabled),ge=w??new Set((ae??[]).map(ie=>ie.urn)),he=da(ae,ge),ce=yt(Q,ge),De=yt(H,ge),Ee=yt(g,ge);E(ie=>({...ie,...dh(ce,De,Ee,he,t,a,i,s,u,B,{},f)})),se||k(!1)});return()=>{oe(),se||k(!1)}}se||k(!1)},[m,n,t,a,i,s,u,g,C,w,f]),d.useEffect(()=>{const{structuresMap:se,dataMessagesMap:Q}=m??{};if(se!=null&&se.size>0&&Q!=null&&!C){const H=n?.filter(ce=>!ce.disabled),B=w??new Set((H??[]).map(ce=>ce.urn)),oe=da(H,B),ae=yt(se,B),ge=yt(Q,B),he=fh(ae,ge,oe,t,s);return I(ce=>({...ce,charting_data:void 0,getChartingData:he})),L(!1),Pt(()=>{try{L(uo(he()))}catch(ce){console.error("Error evaluating cross-dataset chart plottability",ce),L(!1)}})}},[m,n,t,s,C,w]);const de=d.useMemo(()=>[R,...O?[A]:[],...W],[R,A,W,O]),ue=d.useCallback((se,Q,H,B,oe)=>{try{x(!0);const ae=H?.filter(ie=>!ie.disabled)??[],ge=new Set(ae.map(ie=>ie.urn));if(v(ge),p(ie=>({...ie,constraintsMap:Q})),!ae.length){x(!1);return}const he=B?ii(ae,B):void 0,ce=he?ae.map(ie=>({...ie,filters:he.get(ie.urn)??[]})):ae,Ee=(Q&&m?pa(ce,m,Q,t,xe.map):void 0)?.filterParamsMap??se;if(ae.forEach(ie=>{xo(ie,Ee?.get(ie?.urn),J).then(({dataMessage:Le,structureDimensions:Je})=>{k(!0),p(Ge=>{const _e=new Map(Ge?.dataMessagesMap),Ue=new Map(Ge?.structureDimensionsMap);return _e.set(ie.urn,Le),Ue.set(ie.urn,Je||[]),{...Ge,dataMessagesMap:_e,structureDimensionsMap:Ue}})}).finally(()=>x(!1))}),G&&ae.length){const ie=ae.map(Le=>Vr(Le,oe??B?.get(Le.urn)??[]));po({getPythonAttachment:G,dataQueries:ie,requestIdRef:T,codeTitle:u?.codeSamples||"Python Code",markdownTitle:"Python Code",setCodeAttachments:$,onCodeAttachmentUpdated:l})}}catch(ae){console.error("Error loading dataset data",ae)}},[xe.map,J,G,t,l,m,u]);return{structureDataMaps:m,datasetDimensionsSchemesMap:g,isLoadingGridData:C||S,crossDatasetAttachments:de,activeDatasetUrns:w,onMultipleDataFiltersChange:ue}}const bo=d.createContext(void 0),hh={setCrossDatasetAttachmentsState:()=>{}},ph=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})}},gh=({children:e})=>{const[t,n]=d.useState({}),s=d.useCallback(i=>{const o=ph(i);n(c=>c.signature===o?c:{...i,isLoading:!!i?.isLoading,signature:o})},[]),a=d.useMemo(()=>({...t,setCrossDatasetAttachmentsState:s}),[s,t]);return r.jsx(bo.Provider,{value:a,children:e})},vn=()=>{const e=d.useContext(bo);return e===void 0?hh:e},Ch=({attachmentsProps:e,actions:t,titles:n,shareConversationProps:s,metadataSettings:a,formattingSettings:i,locale:o,advanceViewStyles:c,getDatasetUpdatedTime:l,attachmentsConfig:f,datasetInfoOptions:u,limitMessages:h,...m})=>{const p=d.useMemo(()=>e.currentDataQuery?.urn??e.dataQueries?.[0]?.urn??"default",[e.currentDataQuery?.urn,e.dataQueries]),[g,b]=d.useState(Qe.Compact),{isOpenedAdvancedView:C}=We(),{activeDatasetUrns:x,dataQueriesKey:w,setCrossDatasetAttachmentsState:v}=vn(),{isCrossDatasetModeOn:S,isMetadataInSidePanel:k}=Be(),T=wn(),N=!k,D=e.datasets??[],R=D.length>1&&!S,E=d.useMemo(()=>{const ce=m.filtersProps.conversation?.messages??[],De=Mi(ce);return De>=0?ce[De].custom_content?.attachments:void 0},[m.filtersProps.conversation?.messages]),A=d.useMemo(()=>ti(e.dataQueries),[e.dataQueries]),I=w===A?x:ei(e.dataQueries,T.map),O=S&&!!e.dataQueries?.length,L=d.useRef(m.filtersProps.conversation);L.current=m.filtersProps.conversation;const W=d.useCallback(ce=>{const De=L.current;if(!De)return;const Ee=wo(De.messages,ce);if(!Ee)return;const ie={...De,messages:Ee};m.filtersProps.setConversation?.(ie),m.filtersProps.updateConversation(decodeURI(m.filtersProps.conversationKey),{name:ie.name,messages:ie.messages})},[]),{dataMessage:$,dataset:q,dimensions:U,structureDimensions:J,structures:G,dataSetAttachments:te,onFiltersChange:ne,isLoadingGridData:fe,constraints:xe}=Co(t,o,e.currentDataQuery,i,e.styles?.chartingStyles,a,n,E,void 0,!1,W,O),{structureDataMaps:me,crossDatasetAttachments:_,activeDatasetUrns:K,isLoadingGridData:le,onMultipleDataFiltersChange:de}=vo(t,o,e.dataQueries,e.styles?.chartingStyles,i,a,E,I,W,g,n);d.useEffect(()=>{if(!S||!e.dataQueries?.length){v();return}me&&v({attachments:_,dataQueriesKey:A,activeDatasetUrns:K?Array.from(K):void 0,isLoading:le})},[K,e.dataQueries?.length,_,A,S,le,v,me]);const[ue,se]=d.useState(),[Q,H]=d.useState({filterKey:null,timeFilter:null}),B=d.useMemo(()=>S?le:fe,[S,le,fe]),oe=d.useCallback((ce,De,Ee)=>{H(ce),se(!0),ne(ce,De,Ee)},[ne]),ae=d.useCallback((ce,De,Ee,ie,Le)=>{se(!0),de(ce,De,Ee,ie,Le)},[de]),ge=d.useCallback(ce=>{ce&&t?.updateCurrentDataQuery(e?.dataQueries?.find(De=>De?.urn===ce)||e.currentDataQuery)},[t,e.currentDataQuery,e?.dataQueries]),he=Rn(f?.isExternaLinkIncludeFilters,Q,e.currentDataQuery||e.dataQueries?.[0],U);return r.jsx(ln,{styles:{titles:n,attachmentsStyles:e.styles,formattingSettings:i,limitMessages:h,attachmentsConfig:f},children:r.jsx(mf,{currentUrn:p,structuresMap:me?.structuresMap,locale:o,dataQueries:e?.dataQueries,gridViewMode:g,onGridViewModeChange:b,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:r.jsxs("div",{className:"advanced-view flex h-full min-w-0 flex-1 flex-col",children:[r.jsx(um,{locale:o,shareConversationProps:s,isShowShare:c?.isShowShare,conversation:m.filtersProps.conversation}),D.length?r.jsxs(r.Fragment,{children:[R&&r.jsx(Ni,{datasets:D,initialSelectedDatasetUrn:e?.currentDataQuery?.urn,locale:o,selectDataset:ge}),B&&!ue?r.jsx(M.Loader,{}):r.jsxs(r.Fragment,{children:[N&&r.jsx(dm,{...u,locale:o,dataset:q,data:$?.data,structures:G,metadataSettings:a,getDatasetUpdatedTime:l,externalLink:he}),r.jsxs("div",{className:z("flex flex-1 min-h-0 overflow-auto",N&&"border-t border-neutrals-500"),children:[r.jsx("div",{className:z("flex-1 min-h-0 overflow-auto","advanced-view-filters"),children:r.jsx(cm,{...m,actions:t,attachments:S?_:te,attachmentsDataQuery:e.currentDataQuery,dataQueries:e?.dataQueries,dimensions:U,isDataLoading:B,locale:o,filtersProps:{...m?.filtersProps,structureDimensions:J,structures:G,structureDataMaps:me,onFiltersChange:ne,onMultipleDataFiltersChange:ae,initialConstraints:xe},setIsFiltering:se,filters:Q,onFiltersChange:oe})}),C&&r.jsx(Yi,{scope:"advanced"})]})]})]}):r.jsx(M.Loader,{})]})})})};function wh(e,t,n,s,a,i){const[o,c]=d.useState([]),[l,f]=d.useState(),[u,h]=d.useState(!1),m=d.useRef(void 0);return d.useEffect(()=>{m.current=i},[i]),d.useEffect(()=>{let p=!0;async function g(b){h(!0);try{const C=await Promise.all(b.map(w=>st(e,nt(w.urn),()=>e(w.urn))));if(!p)return;const x=C?.map(w=>w?.data?.dataflows?.[0])?.filter(w=>!!w)||[];c(x),t(x),n(b),s(b.find(w=>w.urn===m.current?.urn)??b[0]),f(new Map(C?.map(w=>[y.generateShortUrn(w?.data?.dataflows?.[0]?.id,w?.data?.dataflows?.[0]?.version,w?.data?.dataflows?.[0]?.agencyID),w?.data])))}catch(C){console.error("Error loading datasets",C)}finally{p&&h(!1)}}if(!a?.length){h(!1);return}return g(a),()=>{p=!1}},[a,e,s,n,t]),{datasets:o,datasetStructuresMap:l,isLoading:u}}function Ga(e){const t=e?.filter(n=>yi(n));if(t?.every(n=>!!n?.data))return t?.map(n=>({title:n?.title,...vh(xh(n?.data))}))}function xh(e){if(e)try{return JSON.parse(e)}catch(t){console.error("Invalid JSON:",t)}return null}function vh(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 So=(e=>(e.COMPLETED="completed",e))(So||{});const bh=({stage:e,stageRef:t,isCurrentStage:n})=>r.jsxs("div",{ref:t,className:"message-stage relative flex pb-8 last:mb-8 last:pb-0",children:[r.jsx("span",{className:"message-stage-line absolute h-full border-l"}),r.jsx(Ve.IconPointFilled,{className:"message-stage-indicator z-10 flex shrink-0"}),r.jsxs("div",{className:"ml-2 w-full",children:[r.jsxs("div",{className:z("flex gap-2 items-center",e?.content&&"mb-4"),children:[n&&r.jsx(M.Loader,{}),r.jsx("h3",{className:"message-stage-name",children:e?.name})]}),r.jsx("div",{className:"prose max-w-full break-words",children:r.jsx(Wa,{remarkPlugins:[$a],components:{strong:s=>r.jsx("strong",{className:"text-neutrals-1000",...s}),a:({href:s,children:a,...i})=>r.jsx("a",{href:s,target:"_blank",rel:"noreferrer",...i,children:a}),h1:({children:s,...a})=>r.jsx("h1",{className:"h1 text-neutrals-1000",...a,children:s}),h2:({children:s,...a})=>r.jsx("h2",{className:"h2 text-neutrals-1000",...a,children:s}),h3:({children:s,...a})=>r.jsx("h3",{className:"h3 text-neutrals-1000",...a,children:s}),h4:({children:s,...a})=>r.jsx("h4",{className:"h4 text-neutrals-1000",...a,children:s}),h5:({children:s,...a})=>r.jsx("h5",{className:"h5 text-neutrals-1000",...a,children:s}),code:s=>r.jsx("code",{className:"text-neutrals-900",...s}),pre:s=>r.jsx("pre",{className:"border border-neutrals-600 bg-neutrals-100",...s})},children:e?.content})})]})]}),Sh=({stages:e,expandIcon:t,processingTitle:n})=>{const[s,a]=d.useState(),[i,o]=d.useState(),c=d.useRef(null),l=d.useRef(null);d.useEffect(()=>{o(e?.filter(u=>u?.status!==So.COMPLETED)?.at(-1))},[e]),d.useEffect(()=>{s&&l?.current?.scrollIntoView({block:"nearest",behavior:"smooth"})},[s]),d.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&&a(!1),h=g},{threshold:0});return m.observe(u),()=>m.disconnect()},[]);const f=()=>{a(u=>!u)};return r.jsxs("div",{className:"message-stages",ref:c,children:[r.jsxs("div",{className:z("message-stages-header inline-flex max-w-full items-center cursor-pointer",!i?.name&&"default-header"),onClick:f,children:[r.jsx("p",{className:"message-stages-title truncate",children:i?.name||n||"Processing..."}),r.jsx("i",{className:z("message-stages-expand-icon",s&&"rotated"),children:t})]}),s&&e&&r.jsx("div",{className:"flex flex-col",children:e?.map(u=>r.jsx(bh,{stage:u,stageRef:i?l:null,isCurrentStage:u?.index===i?.index},u.index))})]})},yh=2e3,Dh=({message:e,regenerateMessage:t,messageActionsIcons:n,rateResponse:s,isStreaming:a=!1,isReadOnly:i=!1,isRegenerateAvailable:o=!1})=>{const{messageActionsTitles:c}=ye(),l=n?.copy,f=n?.copied,u=n?.regenerate,h=n?.thumbUp,m=n?.thumbDown,p=n?.thumbPressed,[g,b]=d.useState(e.like??je.LikeState.NoState),[C,x]=d.useState(!1),w=d.useRef(null),{isAgentAvailable:v}=M.useAgentAvailability();d.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]);const S=T=>{e.responseId&&(b(T),s(e.responseId||"",T))},k=()=>{navigator.clipboard.writeText(e.content),x(!0),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{x(!1)},yh)};return r.jsxs("div",{className:z("message-actions","flex gap-x-2 pt-2"),children:[l&&r.jsx("p",{onClick:k,title:c?.copy,children:C&&f?f:l}),o&&u&&!i&&!a&&r.jsx("p",{onClick:v?()=>t?.(e):void 0,"aria-disabled":!v,title:c?.regenerate,className:z(!v&&"opacity-50 !cursor-not-allowed pointer-events-none"),children:u}),h&&!i&&g!==je.LikeState.Disliked&&(g===je.LikeState.NoState?r.jsx("p",{onClick:()=>S(je.LikeState.Liked),title:c?.like,children:h}):r.jsx("p",{title:c?.like,children:p})),m&&!i&&g!==je.LikeState.Liked&&(g===je.LikeState.NoState?r.jsx("p",{onClick:()=>S(je.LikeState.Disliked),title:c?.dislike,children:m}):r.jsx("p",{className:"rotate-180",title:c?.dislike,children:p}))]})},Mh=({message:e,onEditClick:t,messageActionsIcons:n,isStreaming:s=!1,isReadOnly:a=!1})=>{const i=n?.copy,o=n?.edit,{isAgentAvailable:c}=M.useAgentAvailability();return r.jsxs("div",{className:z("message-actions","flex gap-x-2 pt-2 ml-12"),children:[i&&r.jsx("p",{onClick:()=>navigator.clipboard.writeText(e.content),children:i}),o&&!s&&!a&&r.jsx("p",{onClick:c?t:void 0,className:z(!c&&"opacity-50 !cursor-not-allowed pointer-events-none"),"aria-disabled":!c,children:o})]})},Th=({content:e,textColorClass:t,onCancel:n,onEditApply:s,editMessageTitles:a})=>{const{isOpenedAdvancedView:i}=We(),o=d.useRef(null);d.useEffect(()=>{const l=o.current;c(),l&&(l.focus(),l.setSelectionRange(l.value.length,l.value.length))},[]);const c=()=>{const l=o.current;l&&(l.style.height="auto",l.style.height=l.scrollHeight+"px")};return r.jsxs("div",{className:z("max-w-none break-words",i?"body-2":"body-1",t),children:[r.jsx("textarea",{ref:o,className:"w-full resize-none overflow-hidden bg-neutrals-300 outline-none",defaultValue:e,onInput:c}),r.jsxs("div",{className:z("flex gap-x-2 items-center","edit-buttons-wrapper"),children:[r.jsx(M.Button,{buttonClassName:"text-button-secondary small-icon-button",title:a?.cancel,isSmallButton:!0,onClick:n}),r.jsx(M.Button,{buttonClassName:"text-button-primary small-icon-button",title:a?.send,isSmallButton:!0,onClick:()=>s(o.current?.value||"")})]})]})},Eh=({message:e,previousMessage:t,actions:n,dataQuery:s,isStreaming:a=!1,isCurrentMessageStreaming:i=!1,showAdvancedView:o,locale:c,metadataSettings:l,onAdvancedViewOpen:f,regenerateMessage:u,selectMessageToSend:h,rateResponse:m,editMessage:p,isReadOnlyConversation:g,isLastNotUserMessage:b,onCodeAttachmentUpdated:C})=>{const{messageStyles:x,attachmentsStyles:w,formattingSettings:v,messageActionsIcons:S,editMessageTitles:k,expandStagesIcon:T,titles:N}=ye(),[D,R]=d.useState(),[E,A]=d.useState(),[I,O]=d.useState([]),[L,W]=d.useState([]),[$,q]=d.useState(),[U,J]=d.useState(!1),{isCrossDatasetModeOn:G}=Be(),te=wn(),ne=e.role===je.Role.User,fe=e.role===je.Role.System,{datasets:xe,datasetStructuresMap:me,isLoading:_}=wh(n.getDataSet,n.updateDatasets,n.updateDataQueries,n.updateCurrentDataQuery,D,s),[K,le]=d.useState(!1),[de,ue]=d.useState([]);d.useEffect(()=>{A(D?.[0])},[D]);const se=G&&!!D?.length,Q=d.useCallback(be=>{e.id&&C?.(e.id,be)},[e.id,C]),{dataSetAttachments:H,dimensions:B,isLoadingGridData:oe}=Co(n,c,E,v,w?.chartingStyles,l,N,e.custom_content?.attachments,E?me?.get(E.urn):void 0,_,Q,se),ae=d.useMemo(()=>ei(D,te.map),[D,te.map]),{crossDatasetAttachments:ge,isLoadingGridData:he}=vo(n,c,D,w?.chartingStyles,v,l,e.custom_content?.attachments,ae,Q,void 0,N),{isOpenedAdvancedView:ce}=We(),{attachments:De,dataQueriesKey:Ee,isLoading:ie}=vn(),Le=d.useMemo(()=>ti(D),[D]),Je=G&&!!o&&De!=null&&Ee===Le,Ge=Je?De:ge,_e=d.useMemo(()=>G?Je?ie:he:oe,[G,he,oe,ie,Je]),Ue=()=>{ne&&le(!0)},Ze=()=>{le(!1)},Ke=be=>{Ze(),p?.({...e,content:be})},X=d.useCallback(be=>{be&&(A(D?.find(Ie=>Ie?.urn===be)),q(void 0))},[D]);d.useEffect(()=>{const be=e.custom_content?.form_schema?.properties,Ie=b?be?.choice?.oneOf||be?.completion?.oneOf:[];ue(Ie||[])},[e,b]),d.useEffect(()=>{const be=ba(e),Ie=Ga(be),V=be.filter(j=>Kn(j));R(Ie),W(V)},[e]),d.useEffect(()=>{J(D!=null&&D.length>0)},[D]),d.useEffect(()=>{s?.urn&&D?.some(be=>be?.urn===s.urn)&&q(s.urn)},[s,D]),d.useEffect(()=>{if(e?.role===je.Role.System&&t){const be=ba(t),Ie=Ga(be)||[];D&&Ie&&me&&O(ld(Ie,D,me,c,te.map))}},[D,E,me,te.map,B,c,e?.role,t]);const pe=d.useCallback(()=>!ne&&x?.systemMessageIcon&&!(ce&&!i)?r.jsx("div",{className:z("flex-shrink-0 rounded-full flex items-center justify-center w-[44px] h-[44px]",i?"text-white absolute":"text-neutrals-400"),children:x.systemMessageIcon}):null,[ne,x?.systemMessageIcon,ce,i]),ve=d.useMemo(()=>r.jsx(oo,{actions:n,attachments:U?G?Ge:H:L,onAdvancedViewOpen:f,isDataSetAttachments:U,datasets:xe,initialSelectedDatasetUrn:$,showAdvancedView:o,isSystemAttachments:fe,isDataLoading:_e,currentDataQuery:E,dataQueries:D,attachmentInfoList:I,locale:c,dimensions:B,selectDataset:X}),[n,U,H,L,Ge,xe,$,o,fe,_e,E,D,I,c,B,X,f,G]);if(fe&&ce)return null;const Ce=i?null:ne?K?null:r.jsx(Mh,{messageActionsIcons:S,message:e,isStreaming:a,onEditClick:Ue,isReadOnly:g}):fe?null:r.jsx(Dh,{messageActionsIcons:S,message:e,isStreaming:a,regenerateMessage:u,rateResponse:m,isReadOnly:g,isRegenerateAvailable:b});return r.jsx("div",{className:z("max-w-full flex",ne?"justify-end":"justify-start","message-wrapper"),children:r.jsxs("div",{className:z("flex items-start",ne&&!K?"max-w-full":"w-full"),children:[r.jsxs("div",{className:"relative mr-2",children:[pe(),i&&r.jsx(M.Loader,{})]}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:z(ne?"bg-neutrals-300 px-6":"pt-0",ne?"user-message":"system-message",ne&&(K?"w-[100%] ml-0":"ml-12")),children:[!ne&&!ce&&e?.custom_content?.stages?r.jsx(Sh,{stages:e?.custom_content?.stages,expandIcon:T,processingTitle:x?.processingTitle}):i&&r.jsx("p",{className:"body-1 loading-message text-neutrals-700",children:N?.loading}),K?r.jsx(Th,{content:e.content,onCancel:Ze,onEditApply:Ke,editMessageTitles:k}):r.jsx(gr,{content:e.content})]}),ve,Ce,!ce&&!_e&&r.jsx(Cr,{choiceButtons:de,onClick:h})]})]})})},Ah=({messages:e,isStreaming:t=!1,isReadOnly:n,conversationViewState:s,...a})=>{const{scrollBottomIcon:i}=ye(),o=d.useRef(null),c=d.useRef(null),{isOpenedAdvancedView:l}=We(),f=pt(),[u,h]=d.useState(null),[m,p]=d.useState(!1),g=f?.isPanelOpen()??!1,b=()=>{const S=c.current?.parentElement,k=o.current;if(S&&k){const T=k.offsetTop-S.offsetTop;S.scrollTo({top:T,behavior:"smooth"})}};d.useEffect(()=>{b()},[e,t]),d.useEffect(()=>{!l&&u!==null&&setTimeout(()=>{c?.current?.parentElement?.scrollTo({top:u,behavior:"smooth"})})},[l,u]);const C=()=>{const S=c.current?.parentElement?.scrollTop||null;h(S)},x=()=>{const S=c.current?.parentElement;if(S){const{scrollTop:k,scrollHeight:T,clientHeight:N}=S;k+N>=T?p(!1):!m&&!l&&p(!0)}};d.useEffect(()=>{l&&p(!1)},[l]);const w=M.useDebounce(x,300);d.useEffect(()=>{const S=c.current?.parentElement;return S?.addEventListener("scroll",w),()=>S?.removeEventListener("scroll",w)},[w]);const v=d.useCallback(S=>{const k=ee.linkifyText(S);return r.jsx("div",{className:"whitespace-pre-wrap break-words",children:k.map((T,N)=>T.type==="text"?r.jsx(d.Fragment,{children:T.value},N):r.jsx("a",{href:T.value,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center align-middle",children:r.jsx(Ve.IconExternalLink,{className:"size-4 shrink-0 cursor-pointer text-primary"})},N))})},[]);return r.jsxs("div",{ref:c,className:"flex size-full justify-center",children:[r.jsxs("div",{className:"chat-messages-wrapper flex w-full flex-col gap-y-6",children:[e.map((S,k)=>{const T=S.id??k;if(S.errorMessage){const E=s?.errorContext?.kind===we.ERROR_CONTEXT_KIND.RATE_LIMIT?M.InlineAlertType.Warning:M.InlineAlertType.Error;return r.jsx(M.InlineAlert,{type:E,children:r.jsx("div",{className:"flex flex-col",children:v(S.errorMessage)})},T)}if(l&&S.role===je.Role.System)return null;const N=k===e.length-1,D=Uc(e,k),R=Mi(e);return r.jsx(Eh,{message:S,previousMessage:D,onAdvancedViewOpen:C,isStreaming:t,isCurrentMessageStreaming:t&&N&&S.role===je.Role.Assistant,showAdvancedView:k===R&&!n,isLastNotUserMessage:N&&S.role!==je.Role.User,...a},T)}),r.jsx("div",{ref:o,className:"h-4"})]}),r.jsx("div",{onClick:b,className:z("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:r.jsx("div",{className:"flex size-full items-center justify-center",children:i})})]})},Nh=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},kh="local",jh=e=>!e.permissions?.includes(je.SharePermission.WRITE)&&!Lh(e),Ih=(e,t)=>yo(e)!==t,Lh=e=>yo(e)===kh,yo=e=>e.id.split("/")[0],Ph=(e,t)=>is([...t?.messages||[],e]),is=e=>[...e].map(t=>{const n={role:t.role,content:t.content};return(t.role===je.Role.Assistant||t.role===je.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=Oh(t.custom_content.attachments)),t.custom_content.form_schema!=null&&(n.custom_content.form_schema=t.custom_content.form_schema)),t.role===je.Role.User&&t.custom_content&&(n.custom_content=t.custom_content),n}),Rh=(e,t)=>{const n=t?.messages,s=n?.findIndex(a=>e.id===a.id);return is(n?.slice(0,s)||[])},Fh=(e,t)=>{const n=t?.messages,s=n?.findIndex(a=>e.id===a.id);return is([...n?.slice(0,s)||[],e])};function Oh(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 _h=(e,t,n,s)=>{if(!n||t)return null;const a={id:`msg-${Date.now()}`,role:je.Role.User,content:e,timestamp:Date.now()};if(s){const i=s===on.COMPLETE?Xt.COMPLETION:Xt.CHOICE;a.custom_content={form_value:{[i]:s}}}return a},Vh=(e,t,n)=>`/${t}${n}/${ee.getConversationNavPath(e?.folderId,e?.id)}`,Uh=(e,t,n)=>{const s=`${t}/${n}`,a=we.generateConversationId({folderId:s,name:e?.name});return{...e,folderId:s,id:a}},Hh=(e,t)=>{const n=e.lastIndexOf(".");return n<=0?`${e}-${t}`:`${e.slice(0,n)}-${t}${e.slice(n)}`},Bh=(e,t,n)=>{const s=e.split("/");if(s[0]!=="files"||s.length<3)return e;const a=s.at(-1)??"file",i=Hh(a,n);return["files",t,...s.slice(2,-1),i].join("/")},Gh=async({conversation:e,bucket:t,getFileBlob:n,putFile:s})=>{const a=ee.getConversationAttachmentUrls(e),i=Date.now();if(!a.length)return e;const o=await Promise.all(a.map(async c=>{const l=Bh(c,t,`${i}`);if(l===c)return[c,l];const f=await n(c);return await s(l,f),[c,l]}));return ee.replaceConversationAttachmentUrls(e,Object.fromEntries(o))},zh="AbortError",Wh=({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 ee.HttpError({message:e.message,displayMessage:n,code:e.type,status:e.status??ee.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 ee.HttpError({message:e.message,status:e.status??ee.HTTP_ERROR_CODES.BAD_REQUEST,code:e.code})}},$h=({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===ee.HTTP_ERROR_CODES.SERVICE_UNAVAILABLE?t.serverOverloaded:t.serverError}},za=(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}}}},Jh=()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}},Kh=({conversationKey:e,conversation:t,actions:n,messageStyles:s,attachmentsStyles:a,inputMessageStyles:i,shareConversationProps:o,showConversationHeaderAdvancedView:c=!0,formattingSettings:l,metadataSettings:f,expandStagesIcon:u,locale:h,conversationsRoute:m,token:p,titles:g,dataQuery:b,handleInvalidStreaming:C,onConversationNotFound:x,setConversation:w,setConversations:v,openUrl:S,messageActionsIcons:k,messageActionsTitles:T,editMessageTitles:N,scrollBottomIcon:D,isFinalMessage:R,limitMessages:E,attachmentsConfig:A,headerRightSlot:I,children:O})=>{const[L,W]=d.useState(null),[$,q]=d.useState(!1),[U,J]=d.useState(!0),{isStreaming:G,setIsStreaming:te}=qa(),{isOpenedAdvancedView:ne}=We(),{setCrossDatasetAttachmentsState:fe}=vn(),{isCrossDatasetModeOn:xe}=Be(),{isAgentAvailable:me}=M.useAgentAvailability(),{statusMessages:_}=Un(),{onboardingFileSchema:K,onboardingFilePath:le,onboardingFileName:de,isShowOnboarding:ue,setOnboardingFileSchema:se}=qe();d.useEffect(()=>{K&&n.putOnboardingFile?.(de,le,K)},[n,K,de,le]),d.useEffect(()=>{ne&&K?.lastDisplayedElement===Oe.OPEN_ADVANCED_VIEW&&se?.(bi(K))},[n,ne,se,K]);const Q=d.useCallback(()=>{S(`/${h}${m}`)},[h,m,S]),H=d.useCallback(async()=>{try{const{bucket:j}=await n.getBucket(),P=n.getFileBlob&&n.putFile?await Gh({conversation:t,bucket:j,getFileBlob:n.getFileBlob,putFile:n.putFile}):t,F=Uh(P,j,h);await n.createConversation(F,h);const Y=await n.getConversations(h);v(ee.cleanConversationNames(Y)),S(Vh(F,h,m))}catch(j){console.error("Failed to save conversation:",j)}},[n,t,m,h,S,v]),B=d.useCallback(async j=>{try{await n.updateConversation(decodeURI(e),{name:j.name,messages:j.messages,customViewState:j.customViewState})}catch(P){console.error("Failed to save conversation:",P)}},[n,e]),oe=d.useCallback((j,P)=>{if(!t)return;const F=wo(t.messages,P,j);if(!F)return;const Y={...t,messages:F};w(Y),B(Y)},[t,w,B]),ae=d.useCallback(j=>{w(P=>P?{...P,messages:[...P?.messages||[],j]}:null)},[w]),ge=d.useCallback(()=>{const j={id:`msg-${Date.now()+1}`,role:je.Role.Assistant,content:"",timestamp:Date.now()};return w(P=>P?{...P,messages:[...P.messages,j]}:null),j},[w]),he=d.useCallback((j,P)=>{const F=we.mergeMessages?.(j,[P]);if(F)return w(Y=>Y?{...Y,messages:Y.messages.map(Z=>Z.id===j.id?{...F}:Z)}:null),F},[w]),ce=d.useCallback((j,P)=>{t?.model?.id&&(n.rateResponse(j,P===je.LikeState.Liked,t.model.id),t.messages=t.messages.map(F=>F.responseId===j?_n.merge(F,{like:P}):F),B(t))},[n,t,B]),De=d.useCallback((j,P)=>{let F=_.serverError,Y,Z;if(ee.isHttpError(j)){Z=j;const re=$h({error:j,statusMessages:_});F=re.errorMessage,Y=re.errorContext}else Z=new ee.HttpError({status:ee.HTTP_ERROR_CODES.INTERNAL_SERVER_ERROR,message:F});return P&&(P=he(P,{errorMessage:F})),C?.(Z),{assistantMessage:P,errorContext:Y}},[C,_,he]),Ee=d.useCallback(async(j,P,F)=>{const Y=new AbortController;W(Y);let Z=j,re;if(!F)return{assistantMessage:Z,errorContext:re};const ke=F.custom_fields??{},He={...ke,configuration:{...ke.configuration,timezone:Jh(),...xe&&{merge_python_code:!0}}};return await we.streamChatResponse?.(encodeURI(F.id),P,{model:F.model,signal:Y?.signal,onMessage:Re=>{Wh({error:Re.error,statusMessages:_});const ze=Nh(Re);(ze.content||ze.role||ze.responseId)&&(Z=he(Z,ze))},onError:Re=>{if(!_e(Re))throw console.error("Streaming error:",Re),Re}},p,He).catch(Re=>{if(!_e(Re)){const{assistantMessage:ze,errorContext:lt}=De(Re,Z);Z=ze,re=lt}}),{assistantMessage:Z,errorContext:re}},[p,he,De,_,xe]),ie=d.useCallback(async(j,P,F,Y)=>{if(!P)return;let Z=za(P,Y);Z={...Z,messages:[...P.messages],updatedAt:Date.now()},F&&Z.messages.push(F),Z.messages.push(j),await B(Z)},[B]),Le=d.useCallback(j=>{w(P=>P&&za(P,j))},[w]),Je=d.useCallback((j,P)=>{w(F=>F?{...F,messages:F.messages.filter(Y=>Y.id!==P.id)}:null)},[w]),Ge=d.useCallback(()=>{L&&!L.signal.aborted&&L.abort()},[L]),_e=j=>j?.name===zh,Ue=d.useCallback(async(j,P,F,Y,Z,re=!0)=>{_e(Z)?await ie(Y??F,j,re?P:void 0):Je(Z,P)},[ie,Je]),Ze=d.useCallback(async(j,P,F)=>{if(!P||!j)return;const Y=_h(j,G,P,F);let Z,re;if(Y){ae(Y);try{te(!0),Z=ge();const ke=Ph(Y,P),{assistantMessage:He,errorContext:Re}=await Ee(Z,ke,P);Le(Re),re=He,await ie(re,P,Y,Re)}catch(ke){Ue(P,Y,Z,re,ke)}finally{te(!1)}}},[G,te,ae,ge,Ee,ie,Ue,Le]),Ke=d.useCallback(async(j,P,F)=>{let Y,Z;try{te(!0),Y=ge();const{assistantMessage:re,errorContext:ke}=await Ee(Y,j,P);Z=re,Le(ke),await ie(Z,P,void 0,ke)}catch(re){Ue(P,F,Y,Z,re,!1)}finally{te(!1)}},[te,ie,Ue,Ee,ge,Le]),X=d.useCallback(async(j,P)=>{if(!P||!j)return;const F=Rh(j,P),Y={...P,messages:P.messages.slice(0,F.length)};w(Z=>Z?{...Z,...Y}:null),Ke(F,Y,j)},[w,Ke]),{isLastMessageFailed:pe,regenerateLastMessage:ve}=d.useMemo(()=>{const j=t?.messages?.at(-1);return{isLastMessageFailed:!!j?.errorMessage,regenerateLastMessage:j&&(()=>X(j,t))}},[t,X]),Ce=d.useCallback(async(j,P)=>{if(!P||!j)return;const F=Fh(j,P),Y={...P,messages:[...P.messages.slice(0,F.length-1),j]};w(Z=>Z?{...Z,...Y}:null),Ke(F,Y,j)},[w,Ke]);d.useEffect(()=>{oa(),fe();async function j(){try{J(!0);const{bucket:P}=await n.getBucket(),F=await n.getConversation(decodeURI(e));w(F),q(jh(F)&&Ih(F,P)),(F.messages.length===0||F?.messages?.[0]?.role===je.Role.Assistant&&F?.messages?.length===1)&&Ze(F.prompt,F)}catch{q(!0),x?.()}finally{J(!1)}}return e&&j(),()=>{oa()}},[e]);const be=d.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(U)return r.jsx(M.Loader,{});const Ie=t?.customViewState?.[we.CUSTOM_VIEW_STATE_KEY],V=()=>{if(Ie?.errorContext?.kind===we.ERROR_CONTEXT_KIND.RATE_LIMIT&&we.isRateLimitStillActive(Ie.errorContext)){const j=we.getRateLimitRestoreDate(Ie.errorContext);if(j){const P=we.formatDateTime(j);return r.jsx(M.InlineAlert,{type:M.InlineAlertType.Info,children:_.getAssistantRestoreMessage(P.date,P.time)})}}return me?r.jsx(er,{onSendMessage:j=>Ze(j,t),onStopStreaming:Ge,inProcess:G,sendMessageIcon:i.sendMessageIcon,retryIcon:i.retryIcon,placeholder:g?.askAnything??"Ask anything...",containerClasses:"mt-4",inputClasses:"border-neutrals-600 mr-2",isLastFailed:pe,onRetryFailed:ve}):r.jsx(M.InlineAlert,{type:M.InlineAlertType.Error,children:_.assistantUnavailable})};return r.jsx(ln,{styles:{titles:g,messageStyles:s,attachmentsStyles:a,formattingSettings:l,messageActionsIcons:k,messageActionsTitles:T,editMessageTitles:N,expandStagesIcon:u,scrollBottomIcon:D,limitMessages:E,attachmentsConfig:A},children:r.jsxs("div",{className:z("h-full flex flex-col bg-white conversation-view-wrapper",ne&&!c?"p-4":"pr-2"),children:[ne&&!c?null:r.jsx(pr,{conversation:t,locale:h,isOpenedAdvancedView:ne,isShowShareButton:!$&&!ue,shareConversationProps:o,rightSlot:I}),r.jsxs("div",{className:"flex min-h-0 min-w-0 w-full flex-1",children:[r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[r.jsx("div",{className:z("flex-1 min-h-0 flex flex-col items-end scroll-hidden-container",s?.messagesWrapperClass),children:r.jsx(Ah,{messages:t?.messages||[],actions:be,isStreaming:G,isReadOnly:$,metadataSettings:f,dataQuery:b,locale:h,regenerateMessage:j=>X(j,t),selectMessageToSend:(j,P)=>Ze(j,t,P),rateResponse:ce,editMessage:j=>Ce(j,t),isReadOnlyConversation:$||ue,conversationViewState:Ie,onCodeAttachmentUpdated:oe})}),ue?null:$?r.jsx("div",{className:"mt-4 flex items-center justify-center",children:r.jsx(M.Button,{iconBefore:r.jsx(Ve.IconCopy,{width:20,height:20}),title:g?.duplicate??"Duplicate Chat",isSmallButton:!0,onClick:H,buttonClassName:z("text-button-secondary")})}):r.jsx("div",{className:z(i.inputContainerClass),children:V()}),ue&&R&&r.jsx(M.Button,{iconBefore:r.jsx(Ve.IconPlus,{width:24,height:24}),title:g?.onboardingFooterLink,onClick:Q,isSmallButton:!0,buttonClassName:"text-button-secondary self-center mb-3"}),O]}),!ne&&r.jsx(Yi,{scope:"conversation"})]})]})})},Yh=({conversationName:e,expandTitle:t,expandIcon:n,onExpand:s})=>r.jsxs("div",{className:"flex h-full w-[51px] shrink-0 flex-col items-center border border-neutrals-400 bg-white",children:[r.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}),r.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center overflow-hidden pb-[88px] pt-[72px]",children:r.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=Ch;exports.AdvancedViewProvider=Io;exports.CUSTOM_CHOICE_ID=on;exports.ChartingIcon=Qt;exports.ChatFooter=xr;exports.ChatMessagesProvider=Lo;exports.ChatOnboardingFooter=wr;exports.CollapsedChatPanel=Yh;exports.ConversationView=Kh;exports.ConversationViewFeatureTogglesProvider=El;exports.ConversationViewMessagesProvider=Po;exports.ConversationViewSidePanelProvider=tu;exports.ConversationViewStylesProvider=ln;exports.ConversationWelcome=nl;exports.CrossDatasetAttachmentsProvider=gh;exports.CustomContentProperties=Xt;exports.DatasetDimensionsMetadataMapProvider=Yf;exports.OnboardingProvider=Ro;exports.STAGE_STATUS=Qa;exports.useAdvancedView=We;exports.useChatMessages=qa;exports.useConversationViewFeatureToggles=Be;exports.useConversationViewMessages=Un;exports.useConversationViewSidePanelOptional=pt;exports.useConversationViewStyles=ye;exports.useCrossDatasetAttachments=vn;exports.useDatasetDimensionsMetadataMap=wn;exports.useDatasetDimensionsMetadataMapOptional=xn;exports.useOnboarding=qe;
|