{"version":3,"file":"content_controller-pTOlKyH-.js","sources":["../../../app/javascript/controllers/audience/content_controller.js"],"sourcesContent":["import ApplicationController from '../application_controller'\n\nexport default class extends ApplicationController {\n static values = {\n path: String,\n searchUrl: String,\n newEventUrl: String,\n }\n\n static targets = [\n 'mainContent',\n 'detailPane',\n 'detailPaneContainer',\n 'detailPaneSkeleton',\n 'link',\n 'frameReload',\n 'mainFrame',\n 'list',\n 'navigationLink',\n 'searchUrl',\n 'linksContainer',\n 'content',\n 'info',\n 'searchInput',\n 'searchContainer',\n 'conflict',\n ]\n\n initialize() {\n super.initialize()\n this.popStateListener = this.popStateListener.bind(this)\n\n this.element.querySelectorAll('x-pane').forEach(pane => pane.remove())\n\n if(this.hasNavigationLinkTarget) {\n this.navigationLinkTarget.remove()\n }\n }\n\n connect() {\n window.addEventListener('popstate', this.popStateListener)\n this.nextTick(this.popStateListener)\n\n super.connect()\n }\n\n disconnect() {\n window.removeEventListener('popstate', this.popStateListener)\n super.disconnect()\n }\n\n popStateListener() {\n const path = window.location.pathname\n\n if(path === this.pathValue) {\n this.collapse()\n\n document\n .querySelector('.audience--contact-card[data-active]')\n ?.removeAttribute('data-active')\n\n this.show(this.contentTarget)\n this.hide(this.detailPaneContainerTarget)\n }\n\n if(!path.includes('conflicts')) {\n this.conflictTargets.forEach(element => element.remove())\n }\n }\n\n showSkeleton() {\n this.expand(true)\n }\n\n expand(hideEventsContainer = false) {\n this.mainContentTarget.classList.remove('max-w-1200')\n\n this.hide(this.contentTarget)\n this.show(this.detailPaneContainerTarget)\n\n this.hide(this.detailPaneTarget)\n\n if(hideEventsContainer && typeof hideEventsContainer === 'boolean') {\n this.detailPaneSkeletonTarget.querySelector('[data-events-container]').classList.add('hidden')\n }\n\n this.show(this.detailPaneSkeletonTarget)\n }\n\n collapse() {\n this.mainContentTarget.classList.add('max-w-1200')\n\n this.show(this.contentTarget)\n this.hide(this.detailPaneContainerTarget)\n\n if(this.hasLinksContainerTarget) {\n this.hide(this.linksContainerTarget)\n }\n\n this.hide(this.detailPaneSkeletonTarget)\n this.hide(this.detailPaneTarget)\n\n this.detailPaneSkeletonTarget.querySelector('[data-events-container]').classList.remove('hidden')\n document.getElementById('new_event').href = this.newEventUrlValue\n }\n\n showLinksContainer() {\n if(this.onMobile) {\n this.show(this.linksContainerTarget)\n this.hide(this.contentTarget)\n }\n }\n\n hideLinksContainer() {\n if(this.onMobile) {\n this.hide(this.linksContainerTarget)\n this.show(this.contentTarget)\n }\n }\n\n closeDetailPane() {\n this.show(this.contentTarget)\n this.detailPaneContainerTarget.classList.add('hidden', 'md:block')\n }\n\n infoTargetConnected() {\n this.expand()\n\n this.show(this.detailPaneTarget)\n this.hide(this.detailPaneSkeletonTarget)\n }\n\n updatePathValue({ detail }) {\n const { path, count: contactsCount, exportUrl, batchUrl } = detail\n\n this.element.setAttribute('data-audience--radio-export-url-value', exportUrl)\n this.element.setAttribute('data-audience--radio-batch-url-value', batchUrl)\n this.element.setAttribute('data-audience--radio-count-value', contactsCount)\n\n this.pathValue = path\n this.searchInputTarget.placeholder = this.translations.placeholders.search_audience.replace('%{number}', contactsCount)\n\n if(!path.includes('conflicts')) {\n this.conflictTargets.forEach(element => element.remove())\n }\n\n if(parseInt(contactsCount) === 0) {\n this.addClass(this.searchContainerTarget, 'invisible')\n } else {\n this.removeClass(this.searchContainerTarget, 'invisible')\n }\n }\n}\n"],"names":["content_controller","ApplicationController","pane","path","_a","element","hideEventsContainer","detail","contactsCount","exportUrl","batchUrl","__publicField"],"mappings":"uNAEe,MAAKA,UAASC,CAAsB,CA0BjD,YAAa,CACX,MAAM,WAAU,EAChB,KAAK,iBAAmB,KAAK,iBAAiB,KAAK,IAAI,EAEvD,KAAK,QAAQ,iBAAiB,QAAQ,EAAE,QAAQC,GAAQA,EAAK,OAAQ,CAAA,EAElE,KAAK,yBACN,KAAK,qBAAqB,OAAM,CAEtC,CAEE,SAAU,CACR,OAAO,iBAAiB,WAAY,KAAK,gBAAgB,EACzD,KAAK,SAA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