{"version":3,"file":"event_form_controller-uzI2W62Y.js","sources":["../../../app/javascript/controllers/track/event_form_controller.js"],"sourcesContent":["import { get } from '@rails/request.js'\n\nimport ApplicationController from '@/controllers/application_controller'\n\nexport default class extends ApplicationController {\n static values = {\n actionId: String,\n newEntityUrl: String,\n actionDetails: Object,\n }\n\n static targets = [\n 'showMoreButton',\n 'extra',\n 'actionSelect',\n 'entitySelect',\n 'newEntity',\n 'url',\n 'content',\n ]\n\n expand() {\n this.expanded = true\n\n this.hide(this.showMoreButtonTarget)\n this.show(...this.extraTargets)\n\n this.show(this.urlTarget)\n }\n\n onActionChange({ detail }) {\n this.dispatch('action:change', {\n target: this.entitySelectTarget,\n detail: detail.id,\n })\n\n const groupsWithoutEntities = ['message', 'subscription', 'conversation', 'short_link', 'page', 'form']\n\n if(this.actionDetailsValue.group !== detail.group && !groupsWithoutEntities.includes(detail.group)) {\n get(this.newEntityUrlValue, {\n responseKind: 'turbo-stream',\n query: {\n action_id: detail.id,\n }\n })\n }\n\n this.actionDetailsValue = detail\n\n if(this.actionDetailsValue.group === 'custom' || groupsWithoutEntities.includes(this.actionDetailsValue.group)) {\n this.require(this.entitySelectTarget)\n } else {\n this.optional(this.entitySelectTarget)\n }\n\n if(['cart', 'order'].includes(this.actionDetailsValue.group)) {\n this.element.dataset.controller += ' artifact--order'\n } else {\n this.element.dataset.controller = this.element.dataset.controller.replace(' artifact--order', '')\n }\n\n if(this.actionDetailsValue.group === 'page') {\n this.optional(this.entitySelectTarget)\n this.require(this.urlTarget)\n\n this.expand()\n } else {\n this.require(this.entitySelectTarget)\n this.optional(this.urlTarget)\n }\n }\n\n showNewEntityForm({ currentTarget }) {\n this.hide(this.entitySelectTarget)\n this.show(this.newEntityTarget)\n\n this.optional(this.entitySelectTarget)\n\n this.dispatch('type:set', {\n target: this.entitySelectTarget,\n detail: currentTarget.dataset.type,\n })\n }\n\n hideNewEntityForm() {\n this.hide(this.newEntityTarget)\n this.show(this.entitySelectTarget)\n\n this.element.dataset.controller = this.element.dataset.controller.replace(' artifact--order', '')\n\n this.dispatch('action:focus', {\n target: this.entitySelectTarget,\n })\n }\n\n require(target) {\n this.dispatch('require', {\n target\n })\n }\n\n optional(target) {\n this.dispatch('optional', {\n target\n })\n }\n}\n"],"names":["event_form_controller","ApplicationController","detail","groupsWithoutEntities","get","currentTarget","target","__publicField"],"mappings":"+PAIe,MAAKA,UAASC,CAAsB,CAiBjD,QAAS,CACP,KAAK,SAAW,GAEhB,KAAK,KAAK,KAAK,oBAAoB,EACnC,KAAK,KAAK,GAAG,KAAK,YAAY,EAE9B,KAAK,KAAK,KAAK,SAAS,CAC5B,CAEE,eAAe,CAAE,OAAAC,GAAU,CACzB,KAAK,SAAS,gBAAiB,CAC7B,OAAQ,KAAK,mBACb,OAAQA,EAAO,EAChB,CAAA,EAED,MAAMC,EAAwB,CAAC,UAAW,eAAgB,eAAgB,aAAc,OAAQ,MAAM,EAEnG,KAAK,mBAAmB,QAAUD,EAAO,OAAS,CAACC,EAAsB,SAASD,EAAO,KAAK,GAC/FE,EAAI,KAAK,kBAAmB,CAC1B,aAAc,eACd,MAAO,CACL,UAAWF,EAAO,EAC5B,CACO,CAAA,EAGH,KAAK,mBAAqBA,EAEvB,KAAK,mBAAmB,QAAU,UAAYC,EAAsB,SAAS,KAAK,mBAAmB,KAAK,EAC3G,KAAK,QAAQ,KAAK,kBAAkB,EAEpC,KAAK,SAAS,KAAK,kBAAkB,EAGpC,CAAC,OAAQ,OAAO,EAAE,SAAS,KAAK,mBAAmB,KAAK,EACzD,KAAK,QAAQ,QAAQ,YAAc,mBAEnC,KAAK,QAAQ,QAAQ,WAAa,KAAK,QAAQ,QAAQ,WAAW,QAAQ,mBAAoB,EAAE,EAG/F,KAAK,mBAAmB,QAAU,QACnC,KAAK,SAAS,KAAK,kBAAkB,EACrC,KAAK,QAAQ,KAAK,SAAS,EAE3B,KAAK,OAAM,IAEX,KAAK,QAAQ,KAAK,kBAAkB,EACpC,KAAK,SAAS,KAAK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