survey-analytics 2.3.16 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.3.16
2
+ * surveyjs - SurveyJS Dashboard library v2.4.0
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: SEE LICENSE IN LICENSE
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.3.16
2
+ * surveyjs - SurveyJS Dashboard library v2.4.0
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: SEE LICENSE IN LICENSE
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.3.16
2
+ * surveyjs - SurveyJS Dashboard library v2.4.0
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: SEE LICENSE IN LICENSE
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"survey.analytics.mongo.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;;;;;;;;;;;;;;;;ACTqD;AACR;AAI7C;IACE,wBAAoB,EAAM,EAAU,KAAmB;QAAnC,OAAE,GAAF,EAAE,CAAI;QAAU,UAAK,GAAL,KAAK,CAAc;IACvD,CAAC;IAED,+BAAM,GAAN,UAAO,cAAsB,EAAE,MAAM;QAArC,iBAWC;QAVC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACtC,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YACjC,KAAI,CAAC,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;iBACjD,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AAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;AAClG,CAAC;AACD,SAAS,+BAA+B,CAAC,MAAM;IAC7C,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,CAAC,OAAO,CAAC,cAAI;QACjB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC;IAC3B,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;AAClE,CAAC;AAEM,IAAM,YAAY,GAAG;IAC1B,SAAS,EAAE,4BAA4B;IACvC,YAAY,EAAE,4BAA4B;IAC1C,UAAU,EAAE,4BAA4B;IACxC,UAAU,EAAE,4BAA4B;IACxC,QAAQ,EAAE,4BAA4B;IACtC,QAAQ,EAAE,4BAA4B;IACtC,QAAQ,EAAE,4BAA4B;IACtC,WAAW,EAAE,+BAA+B;CAC7C,CAAC;;;;;;;UChCF;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;;;ACNyB","sources":["webpack://SurveyAnalyticsTabulator/webpack/universalModuleDefinition","webpack://SurveyAnalyticsMongo/./src/mongo/index.ts","webpack://SurveyAnalyticsMongo/./src/mongo/pipelines.ts","webpack://SurveyAnalyticsMongo/./src/mongo/result-transformers.ts","webpack://SurveyAnalyticsTabulator/webpack/bootstrap","webpack://SurveyAnalyticsTabulator/webpack/runtime/define property getters","webpack://SurveyAnalyticsTabulator/webpack/runtime/hasOwnProperty shorthand","webpack://SurveyAnalyticsTabulator/webpack/runtime/make namespace object","webpack://SurveyAnalyticsMongo/./src/entries/mongo.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"SurveyAnalyticsMongo\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SurveyAnalyticsMongo\"] = factory();\n\telse\n\t\troot[\"SurveyAnalyticsMongo\"] = factory();\n})(this, () => {\nreturn ","import { Db } from \"mongodb\";\nimport { transformers } from \"./result-transformers\";\nimport { createPipeline } from \"./pipelines\";\n\nexport interface IFilterItem { field: string, value: any }\n\nexport class MongoDbAdapter {\n constructor(private db: Db, private getId: () => string) {\n }\n\n create(collectionName: string, object) {\n object.id = object.id || this.getId();\n return new Promise((resolve, reject) => {\n this.db.collection(collectionName).insertOne(object)\n .then((results) => {\n resolve(object.id);\n })\n .catch((e) => {\n reject(JSON.stringify(e));\n });\n });\n }\n\n retrieve(collectionName: string, filter: Array<IFilterItem>) {\n filter = filter || [];\n const query = {};\n filter.forEach(fi => query[fi.field] = fi.value);\n return new Promise((resolve, reject) => {\n this.db.collection(collectionName).find(query).toArray()\n .then((results) => {\n resolve(results);\n })\n .catch((e) => {\n reject(JSON.stringify(e));\n });\n });\n }\n\n update(collectionName: string, object) {\n return new Promise((resolve, reject) => {\n this.db.collection(collectionName).updateOne({ id: object.id }, { $set: object })\n .then((results) => {\n resolve(results);\n })\n .catch((e) => {\n reject(JSON.stringify(e));\n });\n });\n }\n\n delete(collectionName: string, id) {\n return new Promise((resolve, reject) => {\n this.db.collection(collectionName).deleteMany({ id: id })\n .then((results) => {\n resolve(results);\n })\n .catch((e) => {\n reject(JSON.stringify(e));\n });\n });\n }\n\n retrievePaginated(collectionName: string, filter, order, offset: number, limit: number) {\n filter = filter || [];\n let query = {};\n filter.forEach(fi => {\n if (!!fi.value) {\n let val = fi.value;\n query[fi.field] = val;\n }\n });\n let sort = {};\n order.forEach(fi => {\n sort[fi.field] = fi.value == \"desc\" ? -1 : 1;\n });\n return new Promise((resolve, reject) => {\n this.db.collection(collectionName).count(query).then(count => {\n this.db.collection(collectionName).find(query).sort(sort).skip(offset).limit(limit).toArray()\n .then((results) => {\n const result = { data: results, totalCount: count };\n resolve(result);\n })\n .catch((e) => {\n reject(JSON.stringify(e));\n });\n });\n });\n }\n\n retrieveSummary(collectionName: string, surveyId: string, questionId: string, questionType: string, visualizerType: string, filter: Array<IFilterItem>) {\n const pipeline = createPipeline(surveyId, questionId, visualizerType, questionType);\n return new Promise((resolve, reject) => {\n this.db.collection(collectionName).aggregate(pipeline).toArray()\n .then((results) => {\n const transformer = transformers[visualizerType] || transformers[questionType] || (r => r);\n const result = transformer(results);\n resolve(result);\n })\n .catch((e) => {\n reject(JSON.stringify(e));\n });\n });\n }\n}\n\n","export function createPipeline(surveyId: string, questionId: string, visualizerType: string, questionType: string): any[] {\n const singleChoicePipeline = [\n { $match: { postid: surveyId } },\n { $project: { value: \"$json.\" + questionId } },\n { $match: { value: { $exists: true } } },\n {\n $group: {\n _id: \"$value\",\n count: { $sum: 1 },\n }\n }\n ];\n const multipleChoicePipeline = [\n { $match: { postid: surveyId } },\n { $project: { value: \"$json.\" + questionId } },\n { $match: { value: { $exists: true } } },\n { $unwind: \"$value\" },\n {\n $group: {\n _id: \"$value\",\n count: { $sum: 1 },\n }\n }\n ];\n const numberPipeline = [\n { $match: { postid: surveyId } },\n { $project: { value: \"$json.\" + questionId } },\n { $match: { value: { $exists: true } } },\n {\n $group: {\n _id: null,\n count: { $sum: 1 },\n average: { $avg: \"$value\" },\n min: { $min: \"$value\" },\n max: { $max: \"$value\" },\n values: { $push: \"$value\" }\n }\n }\n ];\n const histogramPipeline = [\n { $match: { postid: surveyId } },\n { $project: { value: \"$json.\" + questionId } },\n { $match: { value: { $exists: true } } },\n {\n $bucketAuto: {\n groupBy: \"$value\",\n buckets: 10,\n output: {\n count: { $sum: 1 },\n minValue: { $min: \"$value\" },\n maxValue: { $max: \"$value\" }\n }\n }\n },\n {\n $project: {\n _id: 0,\n start: \"$minValue\",\n end: \"$maxValue\",\n label: {\n $concat: [\n { $toString: { $round: [\"$minValue\", 2] } },\n \" - \",\n { $toString: { $round: [\"$maxValue\", 2] } }\n ]\n },\n count: 1\n }\n }\n ];\n const mongoPipelines = {\n \"boolean\": singleChoicePipeline,\n \"radiogroup\": singleChoicePipeline,\n \"dropdown\": singleChoicePipeline,\n \"checkbox\": multipleChoicePipeline,\n \"tagbox\": multipleChoicePipeline,\n \"number\": numberPipeline,\n \"rating\": numberPipeline,\n \"histogram\": histogramPipeline\n };\n const pipeline = mongoPipelines[visualizerType] || mongoPipelines[questionType] || [];\n return pipeline;\n}\n","function choiceTransformationPipeline(result) {\n let res = {};\n let totalCount = 0;\n result.forEach(item => {\n res[item._id] = item.count;\n totalCount += item.count;\n });\n return { data: res, totalCount: totalCount };\n}\nfunction numberTransformationPipeline(result) {\n if (result.length == 0) return { value: 0, minValue: 0, maxValue: 0 };\n return { data: { value: result[0].average, minValue: result[0].min, maxValue: result[0].max } };\n}\nfunction histogramTransformationPipeline(result) {\n let res = [];\n let totalCount = 0;\n result.forEach(item => {\n res.push(item.count);\n totalCount += item.count;\n });\n return { data: res, intervals: result, totalCount: totalCount };\n}\n\nexport const transformers = {\n \"boolean\": choiceTransformationPipeline,\n \"radiogroup\": choiceTransformationPipeline,\n \"dropdown\": choiceTransformationPipeline,\n \"checkbox\": choiceTransformationPipeline,\n \"tagbox\": choiceTransformationPipeline,\n \"number\": numberTransformationPipeline,\n \"rating\": numberTransformationPipeline,\n \"histogram\": histogramTransformationPipeline\n};\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from \"../mongo\";"],"names":[],"sourceRoot":""}
1
+ {"version":3,"file":"survey.analytics.mongo.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;;;;;;;;;;;;;;;;ACTqD;AACR;AAI7C;IACE,wBAAoB,EAAM,EAAU,KAAmB;QAAnC,OAAE,GAAF,EAAE,CAAI;QAAU,UAAK,GAAL,KAAK,CAAc;IACvD,CAAC;IAED,+BAAM,GAAN,UAAO,cAAsB,EAAE,MAAM;QAArC,iBAWC;QAVC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACtC,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YACjC,KAAI,CAAC,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,MAAM,CA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AC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;AAClG,CAAC;AACD,SAAS,+BAA+B,CAAC,MAAM;IAC7C,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,CAAC,OAAO,CAAC,cAAI;QACjB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC;IAC3B,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;AAClE,CAAC;AAEM,IAAM,YAAY,GAAG;IAC1B,SAAS,EAAE,4BAA4B;IACvC,YAAY,EAAE,4BAA4B;IAC1C,UAAU,EAAE,4BAA4B;IACxC,UAAU,EAAE,4BAA4B;IACxC,QAAQ,EAAE,4BAA4B;IACtC,QAAQ,EAAE,4BAA4B;IACtC,QAAQ,EAAE,4BAA4B;IACtC,WAAW,EAAE,+BAA+B;CAC7C,CAAC;;;;;;;UChCF;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;;;ACNyB","sources":["webpack://SurveyAnalyticsTabulator/webpack/universalModuleDefinition","webpack://SurveyAnalyticsMongo/./src/mongo/index.ts","webpack://SurveyAnalyticsMongo/./src/mongo/pipelines.ts","webpack://SurveyAnalyticsMongo/./src/mongo/result-transformers.ts","webpack://SurveyAnalyticsTabulator/webpack/bootstrap","webpack://SurveyAnalyticsTabulator/webpack/runtime/define property getters","webpack://SurveyAnalyticsTabulator/webpack/runtime/hasOwnProperty shorthand","webpack://SurveyAnalyticsTabulator/webpack/runtime/make namespace object","webpack://SurveyAnalyticsMongo/./src/entries/mongo.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"SurveyAnalyticsMongo\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SurveyAnalyticsMongo\"] = factory();\n\telse\n\t\troot[\"SurveyAnalyticsMongo\"] = factory();\n})(this, () => {\nreturn ","import { Db } from \"mongodb\";\nimport { transformers } from \"./result-transformers\";\nimport { createPipeline } from \"./pipelines\";\n\nexport interface IFilterItem { field: string, value: any }\n\nexport class MongoDbAdapter {\n constructor(private db: Db, private getId: () => string) {\n }\n\n create(collectionName: string, object) {\n object.id = object.id || this.getId();\n return new Promise((resolve, reject) => {\n this.db.collection(collectionName).insertOne(object)\n .then((results) => {\n resolve(object.id);\n })\n .catch((e) => {\n reject(JSON.stringify(e));\n });\n });\n }\n\n retrieve(collectionName: string, filter: Array<IFilterItem>) {\n filter = filter || [];\n const query = {};\n filter.forEach(fi => query[fi.field] = fi.value);\n return new Promise((resolve, reject) => {\n this.db.collection(collectionName).find(query).toArray()\n .then((results) => {\n resolve(results);\n })\n .catch((e) => {\n reject(JSON.stringify(e));\n });\n });\n }\n\n update(collectionName: string, object) {\n return new Promise((resolve, reject) => {\n this.db.collection(collectionName).updateOne({ id: object.id }, { $set: object })\n .then((results) => {\n resolve(results);\n })\n .catch((e) => {\n reject(JSON.stringify(e));\n });\n });\n }\n\n delete(collectionName: string, id) {\n return new Promise((resolve, reject) => {\n this.db.collection(collectionName).deleteMany({ id: id })\n .then((results) => {\n resolve(results);\n })\n .catch((e) => {\n reject(JSON.stringify(e));\n });\n });\n }\n\n retrievePaginated(collectionName: string, filter, order, offset: number, limit: number) {\n filter = filter || [];\n let query = {};\n filter.forEach(fi => {\n if(!!fi.value) {\n let val = fi.value;\n query[fi.field] = val;\n }\n });\n let sort = {};\n order.forEach(fi => {\n sort[fi.field] = fi.value == \"desc\" ? -1 : 1;\n });\n return new Promise((resolve, reject) => {\n this.db.collection(collectionName).count(query).then(count => {\n this.db.collection(collectionName).find(query).sort(sort).skip(offset).limit(limit).toArray()\n .then((results) => {\n const result = { data: results, totalCount: count };\n resolve(result);\n })\n .catch((e) => {\n reject(JSON.stringify(e));\n });\n });\n });\n }\n\n retrieveSummary(collectionName: string, surveyId: string, questionId: string, questionType: string, visualizerType: string, filter: Array<IFilterItem>) {\n const pipeline = createPipeline(surveyId, questionId, visualizerType, questionType);\n return new Promise((resolve, reject) => {\n this.db.collection(collectionName).aggregate(pipeline).toArray()\n .then((results) => {\n const transformer = transformers[visualizerType] || transformers[questionType] || (r => r);\n const result = transformer(results);\n resolve(result);\n })\n .catch((e) => {\n reject(JSON.stringify(e));\n });\n });\n }\n}\n\n","export function createPipeline(surveyId: string, questionId: string, visualizerType: string, questionType: string): any[] {\n const singleChoicePipeline = [\n { $match: { postid: surveyId } },\n { $project: { value: \"$json.\" + questionId } },\n { $match: { value: { $exists: true } } },\n {\n $group: {\n _id: \"$value\",\n count: { $sum: 1 },\n }\n }\n ];\n const multipleChoicePipeline = [\n { $match: { postid: surveyId } },\n { $project: { value: \"$json.\" + questionId } },\n { $match: { value: { $exists: true } } },\n { $unwind: \"$value\" },\n {\n $group: {\n _id: \"$value\",\n count: { $sum: 1 },\n }\n }\n ];\n const numberPipeline = [\n { $match: { postid: surveyId } },\n { $project: { value: \"$json.\" + questionId } },\n { $match: { value: { $exists: true } } },\n {\n $group: {\n _id: null,\n count: { $sum: 1 },\n average: { $avg: \"$value\" },\n min: { $min: \"$value\" },\n max: { $max: \"$value\" },\n values: { $push: \"$value\" }\n }\n }\n ];\n const histogramPipeline = [\n { $match: { postid: surveyId } },\n { $project: { value: \"$json.\" + questionId } },\n { $match: { value: { $exists: true } } },\n {\n $bucketAuto: {\n groupBy: \"$value\",\n buckets: 10,\n output: {\n count: { $sum: 1 },\n minValue: { $min: \"$value\" },\n maxValue: { $max: \"$value\" }\n }\n }\n },\n {\n $project: {\n _id: 0,\n start: \"$minValue\",\n end: \"$maxValue\",\n label: {\n $concat: [\n { $toString: { $round: [\"$minValue\", 2] } },\n \" - \",\n { $toString: { $round: [\"$maxValue\", 2] } }\n ]\n },\n count: 1\n }\n }\n ];\n const mongoPipelines = {\n \"boolean\": singleChoicePipeline,\n \"radiogroup\": singleChoicePipeline,\n \"dropdown\": singleChoicePipeline,\n \"checkbox\": multipleChoicePipeline,\n \"tagbox\": multipleChoicePipeline,\n \"number\": numberPipeline,\n \"rating\": numberPipeline,\n \"histogram\": histogramPipeline\n };\n const pipeline = mongoPipelines[visualizerType] || mongoPipelines[questionType] || [];\n return pipeline;\n}\n","function choiceTransformationPipeline(result) {\n let res = {};\n let totalCount = 0;\n result.forEach(item => {\n res[item._id] = item.count;\n totalCount += item.count;\n });\n return { data: res, totalCount: totalCount };\n}\nfunction numberTransformationPipeline(result) {\n if(result.length == 0) return { value: 0, minValue: 0, maxValue: 0 };\n return { data: { value: result[0].average, minValue: result[0].min, maxValue: result[0].max } };\n}\nfunction histogramTransformationPipeline(result) {\n let res = [];\n let totalCount = 0;\n result.forEach(item => {\n res.push(item.count);\n totalCount += item.count;\n });\n return { data: res, intervals: result, totalCount: totalCount };\n}\n\nexport const transformers = {\n \"boolean\": choiceTransformationPipeline,\n \"radiogroup\": choiceTransformationPipeline,\n \"dropdown\": choiceTransformationPipeline,\n \"checkbox\": choiceTransformationPipeline,\n \"tagbox\": choiceTransformationPipeline,\n \"number\": numberTransformationPipeline,\n \"rating\": numberTransformationPipeline,\n \"histogram\": histogramTransformationPipeline\n};\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from \"../mongo\";"],"names":[],"sourceRoot":""}
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.3.16
2
+ * surveyjs - SurveyJS Dashboard library v2.4.0
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: SEE LICENSE IN LICENSE
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.3.16
2
+ * surveyjs - SurveyJS Dashboard library v2.4.0
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: SEE LICENSE IN LICENSE
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS Dashboard library v2.3.16
2
+ * surveyjs - SurveyJS Dashboard library v2.4.0
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: SEE LICENSE IN LICENSE
5
5
  */