{"version":3,"file":"answer_field_controller-BARud7mk.js","sources":["../../../app/javascript/controllers/automation/answer_field_controller.js"],"sourcesContent":["import ApplicationController from '@/controllers/application_controller'\n\nexport default class extends ApplicationController {\n static values = {\n query: { type: String, default: 'similarity' },\n body: String,\n }\n\n static targets = [\n 'input',\n 'queryOption',\n 'queryPlaceholder',\n 'emojiNotice',\n ]\n\n connect() {\n if(!this.isTemplate) {\n this.enable(this.inputTarget)\n }\n\n super.connect()\n }\n\n onQueryChange({ currentTarget }) {\n this.queryValue = currentTarget.dataset.query\n this.queryPlaceholderTarget.querySelector('p').innerText = currentTarget.dataset.text\n\n this.queryOptionTargets.forEach((option) => {\n if(option === currentTarget) {\n option.classList.add('bg-lavender-light')\n } else {\n option.classList.remove('bg-lavender-light')\n }\n })\n\n this.focus(this.inputTarget, { moveCursorToEnd: true })\n this.changed()\n }\n\n focusInput() {\n this.focus(this.inputTarget, { moveCursorToEnd: true })\n }\n\n changed() {\n const emojiRegex = /[\\u{1F600}-\\u{1F64F}\\u{1F300}-\\u{1F5FF}\\u{1F680}-\\u{1F6FF}\\u{1F700}-\\u{1F77F}\\u{1F780}-\\u{1F7FF}\\u{1F800}-\\u{1F8FF}\\u{1F900}-\\u{1F9FF}\\u{1FA00}-\\u{1FA6F}\\u{1FA70}-\\u{1FAFF}\\u{1FB00}-\\u{1FBFF}]/gu;\n\n if (emojiRegex.test(this.inputTarget.value)) {\n this.inputTarget.value = this.inputTarget.value.replace(emojiRegex, '')\n this.emojiNoticeTarget.classList.remove('hidden')\n } else {\n this.emojiNoticeTarget.classList.add('hidden')\n }\n\n this.dispatch('changed', {\n detail: {\n id: this.element.dataset.id,\n query: this.queryValue,\n body: this.inputTarget.value,\n text: t.applied_filters.query[this.queryValue],\n }\n })\n }\n\n get isTemplate() {\n return this.element.getAttribute('data-automation--answers-target') === 'template'\n }\n}\n"],"names":["answer_field_controller","ApplicationController","currentTarget","option","emojiRegex","__publicField"],"mappings":"uNAEe,MAAKA,UAASC,CAAsB,CAajD,SAAU,CACJ,KAAK,YACP,KAAK,OAAO,KAAK,WAAW,EAG9B,MAAM,QAAO,CACjB,CAEE,cAAc,CAAE,cAAAC,GAAiB,CAC/B,KAAK,WAAaA,EAAc,QAAQ,MACxC,KAAK,uBAAuB,cAAc,GAAG,EAAE,UAAYA,EAAc,QAAQ,KAEjF,KAAK,mBAAmB,QAASC,GAAW,CACvCA,IAAWD,EACZC,EAAO,UAAU,IAAI,mBAAmB,EAExCA,EAAO,UAAU,OAAO,mBAAmB,CAE9C,CAAA,EAED,KAAK,MAAM,KAAK,YAAa,CAAE,gBAAiB,EAAM,CAAA,EACtD,KAAK,QAAO,CAChB,CAEE,YAAa,CACX,KAAK,MAAM,KAAK,YAAa,CAAE,gBAAiB,EAAM,CAAA,CAC1D,CAEE,SAAU,CACR,MAAMC,EAAa,qMAEfA,EAAW,KAAK,KAAK,YAAY,KAAK,GACxC,KAAK,YAAY,MAAQ,KAAK,YAAY,MAAM,QAAQA,EAAY,EAAE,EACtE,KAAK,kBAAkB,UAAU,OAAO,QAAQ,GAEhD,KAAK,kBAAkB,UAAU,IAAI,QAAQ,EAG/C,KAAK,SAAS,UAAW,CACvB,OAAQ,CACN,GAAI,KAAK,QAAQ,QAAQ,GACzB,MAAO,KAAK,WACZ,KAAM,KAAK,YAAY,MACvB,KAAM,EAAE,gBAAgB,MAAM,KAAK,UAAU,CACrD,CACK,CAAA,CACL,CAEE,IAAI,YAAa,CACf,OAAO,KAAK,QAAQ,aAAa,iCAAiC,IAAM,UAC5E,CACA,CA/DEC,EADkBL,EACX,SAAS,CACd,MAAO,CAAE,KAAM,OAAQ,QAAS,YAAc,EAC9C,KAAM,MACV,GAEEK,EANkBL,EAMX,UAAU,CACf,QACA,cACA,mBACA,aACJ"}