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,UAAUoF,YAAYvE,EAC/B,GAAC,uBAED,WAAY,WACRf,KAAKa,SAAW,SAAAe,GACZ,IAAMiC,EAAMjC,EAAEC,OAAOmE,QAAQnC,IAC7B,GAAI,MAAQA,EAAK,CACb,IAAMF,EAAQ,EAAK1D,KAAKuC,YAAYqB,GAChCF,GACA,EAAKvC,UAAU,SAAUuC,EAAMM,MAAON,EAAMO,IAEpD,CACJ,EACAlE,KAAKE,UAAUyB,iBAAiB,QAAS3B,KAAKa,SAClD,GAAC,mCAED,SAAsBqF,GAClB,IAAIC,EAQJ,OAPAnG,KAAKgF,kBAAkBoB,MAAK,SAAAL,GACxB,OAAIA,EAAW9B,OAASiC,GAAQH,EAAW7B,KAAOgC,IAC9CC,EAASJ,GACF,EAGf,IACOI,CACX,GAAC,+BAED,SAAkBJ,GACd,OAAO5F,SAASkG,eAAe,wBAA0BN,EAAWxC,GACxE,M,8EA5PC,EAjB0B,GAiB1B,+B,GCpDD+C,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAapH,QAGrB,IAAIC,EAAS+G,EAAyBG,GAAY,CAGjDnH,QAAS,CAAC,GAOX,OAHAsH,EAAoBH,GAAUlH,EAAQA,EAAOD,QAASkH,GAG/CjH,EAAOD,OACf,CCnB0BkH,CAAoB,K,UHO9C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/elan/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/startup"],"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(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"elan\"] = factory();\n})(self, () => {\nreturn ","/**\n * @typedef {Object} ElanPluginParams\n * @property {string|HTMLElement} container CSS selector or HTML element where\n * the ELAN information should be rendered.\n * @property {string} url The location of ELAN XML data\n * @property {?boolean} deferInit Set to true to manually call\n * @property {?Object} tiers If set only shows the data tiers with the `TIER_ID`\n * in this map.\n */\n\n/**\n * Downloads and renders ELAN audio transcription documents alongside the\n * waveform.\n *\n * @implements {PluginClass}\n * @extends {Observer}\n * @example\n * // es6\n * import ElanPlugin from 'wavesurfer.elan.js';\n *\n * // commonjs\n * var ElanPlugin = require('wavesurfer.elan.js');\n *\n * // if you are using <script> tags\n * var ElanPlugin = window.WaveSurfer.elan;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * ElanPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class ElanPlugin {\n /**\n * Elan plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {ElanPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'elan',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n instance: ElanPlugin\n };\n }\n\n Types = {\n ALIGNABLE_ANNOTATION: 'ALIGNABLE_ANNOTATION',\n REF_ANNOTATION: 'REF_ANNOTATION'\n };\n\n constructor(params, ws) {\n this.data = null;\n this.params = params;\n this.container =\n 'string' == typeof params.container\n ? document.querySelector(params.container)\n : params.container;\n\n if (!this.container) {\n throw Error('No container for ELAN');\n }\n }\n\n init() {\n this.bindClick();\n\n if (this.params.url) {\n this.load(this.params.url);\n }\n }\n\n destroy() {\n this.container.removeEventListener('click', this._onClick);\n this.container.removeChild(this.table);\n }\n\n load(url) {\n this.loadXML(url, xml => {\n this.data = this.parseElan(xml);\n this.render();\n this.fireEvent('ready', this.data);\n });\n }\n\n loadXML(url, callback) {\n const xhr = new XMLHttpRequest();\n xhr.open('GET', url, true);\n xhr.responseType = 'document';\n xhr.send();\n xhr.addEventListener('load', e => {\n callback && callback(e.target.responseXML);\n });\n }\n\n parseElan(xml) {\n const _forEach = Array.prototype.forEach;\n const _map = Array.prototype.map;\n\n const data = {\n media: {},\n timeOrder: {},\n tiers: [],\n annotations: {},\n alignableAnnotations: []\n };\n\n const header = xml.querySelector('HEADER');\n const inMilliseconds =\n header.getAttribute('TIME_UNITS') == 'milliseconds';\n const media = header.querySelector('MEDIA_DESCRIPTOR');\n data.media.url = media.getAttribute('MEDIA_URL');\n data.media.type = media.getAttribute('MIME_TYPE');\n\n const timeSlots = xml.querySelectorAll('TIME_ORDER TIME_SLOT');\n const timeOrder = {};\n _forEach.call(timeSlots, slot => {\n let value = parseFloat(slot.getAttribute('TIME_VALUE'));\n // If in milliseconds, convert to seconds with rounding\n if (inMilliseconds) {\n value = Math.round(value * 1e2) / 1e5;\n }\n timeOrder[slot.getAttribute('TIME_SLOT_ID')] = value;\n });\n\n data.tiers = _map.call(xml.querySelectorAll('TIER'), tier => ({\n id: tier.getAttribute('TIER_ID'),\n linguisticTypeRef: tier.getAttribute('LINGUISTIC_TYPE_REF'),\n defaultLocale: tier.getAttribute('DEFAULT_LOCALE'),\n annotations: _map.call(\n tier.querySelectorAll('REF_ANNOTATION, ALIGNABLE_ANNOTATION'),\n node => {\n const annot = {\n type: node.nodeName,\n id: node.getAttribute('ANNOTATION_ID'),\n ref: node.getAttribute('ANNOTATION_REF'),\n value: node\n .querySelector('ANNOTATION_VALUE')\n .textContent.trim()\n };\n\n if (this.Types.ALIGNABLE_ANNOTATION == annot.type) {\n // Add start & end to alignable annotation\n annot.start =\n timeOrder[node.getAttribute('TIME_SLOT_REF1')];\n annot.end =\n timeOrder[node.getAttribute('TIME_SLOT_REF2')];\n // Add to the list of alignable annotations\n data.alignableAnnotations.push(annot);\n }\n\n // Additionally, put into the flat map of all annotations\n data.annotations[annot.id] = annot;\n\n return annot;\n }\n )\n }));\n\n // Create JavaScript references between annotations\n data.tiers.forEach(tier => {\n tier.annotations.forEach(annot => {\n if (null != annot.ref) {\n annot.reference = data.annotations[annot.ref];\n }\n });\n });\n\n // Sort alignable annotations by start & end\n data.alignableAnnotations.sort((a, b) => {\n let d = a.start - b.start;\n if (d == 0) {\n d = b.end - a.end;\n }\n return d;\n });\n\n data.length = data.alignableAnnotations.length;\n\n return data;\n }\n\n render() {\n // apply tiers filter\n let tiers = this.data.tiers;\n if (this.params.tiers) {\n tiers = tiers.filter(tier => tier.id in this.params.tiers);\n }\n\n // denormalize references to alignable annotations\n const backRefs = {};\n let indeces = {};\n tiers.forEach((tier, index) => {\n tier.annotations.forEach(annot => {\n if (\n annot.reference &&\n annot.reference.type == this.Types.ALIGNABLE_ANNOTATION\n ) {\n if (!(annot.reference.id in backRefs)) {\n backRefs[annot.ref] = {};\n }\n backRefs[annot.ref][index] = annot;\n indeces[index] = true;\n }\n });\n });\n indeces = Object.keys(indeces).sort();\n\n this.renderedAlignable = this.data.alignableAnnotations.filter(\n alignable => backRefs[alignable.id]\n );\n\n // table\n const table = (this.table = document.createElement('table'));\n table.className = 'wavesurfer-annotations';\n\n // head\n const thead = document.createElement('thead');\n const headRow = document.createElement('tr');\n thead.appendChild(headRow);\n table.appendChild(thead);\n const th = document.createElement('th');\n th.textContent = 'Time';\n th.className = 'wavesurfer-time';\n headRow.appendChild(th);\n indeces.forEach(index => {\n const tier = tiers[index];\n const th = document.createElement('th');\n th.className = 'wavesurfer-tier-' + tier.id;\n th.textContent = tier.id;\n if (this.params.tiers) { th.style.width = this.params.tiers[tier.id]; }\n headRow.appendChild(th);\n });\n\n // body\n const tbody = document.createElement('tbody');\n table.appendChild(tbody);\n this.renderedAlignable.forEach(alignable => {\n const row = document.createElement('tr');\n row.id = 'wavesurfer-alignable-' + alignable.id;\n tbody.appendChild(row);\n\n const td = document.createElement('td');\n td.className = 'wavesurfer-time';\n td.textContent =\n alignable.start.toFixed(1) + '–' + alignable.end.toFixed(1);\n row.appendChild(td);\n\n const backRef = backRefs[alignable.id];\n indeces.forEach(index => {\n const tier = tiers[index];\n const td = document.createElement('td');\n const annotation = backRef[index];\n if (annotation) {\n td.id = 'wavesurfer-annotation-' + annotation.id;\n td.dataset.ref = alignable.id;\n td.dataset.start = alignable.start;\n td.dataset.end = alignable.end;\n td.textContent = annotation.value;\n }\n td.className = 'wavesurfer-tier-' + tier.id;\n row.appendChild(td);\n });\n });\n\n this.container.innerHTML = '';\n this.container.appendChild(table);\n }\n\n bindClick() {\n this._onClick = e => {\n const ref = e.target.dataset.ref;\n if (null != ref) {\n const annot = this.data.annotations[ref];\n if (annot) {\n this.fireEvent('select', annot.start, annot.end);\n }\n }\n };\n this.container.addEventListener('click', this._onClick);\n }\n\n getRenderedAnnotation(time) {\n let result;\n this.renderedAlignable.some(annotation => {\n if (annotation.start <= time && annotation.end >= time) {\n result = annotation;\n return true;\n }\n return false;\n });\n return result;\n }\n\n getAnnotationNode(annotation) {\n return document.getElementById('wavesurfer-alignable-' + annotation.id);\n }\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","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(375);\n"],"names":["root","factory","exports","module","define","amd","self","ElanPlugin","params","ws","ALIGNABLE_ANNOTATION","REF_ANNOTATION","this","data","container","document","querySelector","Error","name","deferInit","instance","bindClick","url","load","removeEventListener","_onClick","removeChild","table","loadXML","xml","parseElan","render","fireEvent","callback","xhr","XMLHttpRequest","open","responseType","send","addEventListener","e","target","responseXML","_forEach","Array","prototype","forEach","_map","map","media","timeOrder","tiers","annotations","alignableAnnotations","header","inMilliseconds","getAttribute","type","timeSlots","querySelectorAll","call","slot","value","parseFloat","Math","round","tier","id","linguisticTypeRef","defaultLocale","node","annot","nodeName","ref","textContent","trim","Types","start","end","push","reference","sort","a","b","d","length","filter","backRefs","indeces","index","Object","keys","renderedAlignable","alignable","createElement","className","thead","headRow","appendChild","th","style","width","tbody","row","td","toFixed","backRef","annotation","dataset","innerHTML","time","result","some","getElementById","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
\No newline at end of file