{"version":3,"file":"event_controller-BESXpEjW.js","sources":["../../../app/javascript/controllers/track/event_controller.js"],"sourcesContent":["import ApplicationController from '../application_controller'\n\nimport { Current } from '../models/current'\nimport { useUpdatableTimestamp } from \"../mixins/useUpdatableTimestamp\"\nimport { useLineNotifiers } from \"../mixins/useLineNotifiers\"\n\nexport default class extends ApplicationController {\n static values = {\n id: String,\n timestamp: String,\n url: String,\n groupId: String,\n groupSize: { type: Number, default: 1 },\n }\n\n static targets = [\n 'timestamp',\n 'shareButton',\n 'deleteButton',\n 'menu',\n ]\n\n connect() {\n super.connect()\n\n if (this.element.getAttribute('data-dropdown-open-value') === 'true') {\n this.element.scrollIntoView({\n behaviour: 'smooth',\n block: 'nearest',\n })\n }\n\n if(Current.user.role.agent) {\n this.element.deleteButtonTargets.forEach(element => element.remove())\n }\n\n useUpdatableTimestamp(this)\n useLineNotifiers(this)\n\n this.updateTimestampEveryMinute()\n }\n\n disconnect() {\n clearInterval(this.timestampInterval)\n\n this.dispatch('hide', {\n target: document.getElementById('track-event-modal'),\n detail: this.idValue,\n })\n }\n\n updateTimestampEveryMinute() {\n this.timestampInterval = setInterval(() => {\n this.timestampTarget.innerHTML = this.timeAgoInWordsWithParsing(this.timestampValue)\n }, 30000)\n }\n\n moveInboxToSavepoint() {\n const inbox = document.getElementById('chat')\n\n if (inbox) {\n return this.dispatch('scroll-to-view', {\n target: document.getElementById('chat'),\n detail: this.element.dataset.messageId || this.element.id,\n })\n }\n\n Turbo.visit(this.urlValue)\n }\n\n share({ currentTarget }) {\n currentTarget.blur()\n\n const url = new URL(document.location.href)\n url.searchParams.set('activity', this.element.id.split('_').pop())\n\n navigator.clipboard.writeText(url.toString())\n\n clearTimeout(this.timeout)\n this.shareButtonTarget.innerText = this.translations.track.events.event.options.shared\n\n this.timeout = this.nextTick(() => {\n this.shareButtonTarget.innerText = this.translations.track.events.event.options.share\n }, 3000)\n }\n\n showModal() {\n this.dispatch('show', {\n target: document.getElementById('track-event-modal'),\n detail: {\n id: this.idValue,\n size: this.groupSizeValue,\n groupId: this.groupIdValue,\n }\n })\n }\n\n showLine() {\n this.element.setAttribute('data-line-active', true)\n this.moveLineToThisElement()\n }\n\n resetTabs({ detail }) {\n this.element.setAttribute('data-tabs-index-value', 0)\n this.element.removeAttribute('data-line-active')\n }\n}\n"],"names":["event_controller","ApplicationController","Current","element","useUpdatableTimestamp","useLineNotifiers","currentTarget","url","detail","__publicField"],"mappings":"oUAMe,MAAKA,UAASC,CAAsB,CAgBjD,SAAU,CACR,MAAM,QAAO,EAET,KAAK,QAAQ,aAAa,0BAA0B,IAAM,QAC5D,KAAK,QAAQ,eAAe,CAC1B,UAAW,SACX,MAAO,SACR,CAAA,EAGAC,EAAQ,KAAK,KAAK,OACnB,KAAK,QAAQ,oBAAoB,QAAQC,GAAWA,EAAQ,OAAQ,CAAA,EAGtEC,EAAsB,IAAI,EAC1BC,EAAiB,IAAI,EAErB,KAAK,2BAA0B,CACnC,CAEE,YAAa,CACX,cAAc,KAAK,iBAAiB,EAEpC,KAAK,SAAS,OAAQ,CACpB,OAAQ,SAAS,eAAe,mBAAmB,EACnD,OAAQ,KAAK,OACd,CAAA,CACL,CAEE,4BAA6B,CAC3B,KAAK,kBAAoB,YAAY,IAAM,CACzC,KAAK,gBAAgB,UAAY,KAAK,0BAA0B,KAAK,cAAc,CACzF,EAAO,GAAK,CACZ,CAEE,sBAAuB,CAGrB,GAFc,SAAS,eAAe,MAAM,EAG1C,OAAO,KAAK,SAAS,iBAAkB,CACrC,OAAQ,SAAS,eAAe,MAAM,EACtC,OAAQ,KAAK,QAAQ,QAAQ,WAAa,KAAK,QAAQ,EACxD,CAAA,EAGH,MAAM,MAAM,KAAK,QAAQ,CAC7B,CAEE,MAAM,CAAE,cAAAC,GAAiB,CACvBA,EAAc,KAAI,EAElB,MAAMC,EAAM,IAAI,IAAI,SAAS,SAAS,IAAI,EAC1CA,EAAI,aAAa,IAAI,WAAY,KAAK,QAAQ,GAAG,MAAM,GAAG,EAA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