import{r as t}from"./p-613e7266.js";import{a as i}from"./p-25a090c9.js";import{s as e}from"./p-d65a44ad.js";import{w as n}from"./p-f14d706d.js";import{P as o}from"./p-82e61072.js";import"./p-b70d1ec1.js";const s=({number:t,name:i,isFav:e,toggleFavUrl:n,constructionYear:o,subEquipments:s,location:a,serviceAgreement:h,detailLink:c,inProduction:m,discontinued:d})=>`\n
\n | \n \n ${d?l(d,t):""}${i}\n | \n ${t} | \n ${m?r(m):o} | \n ${s} | \n ${a} | \n ${void 0!==h?`${h} | `:""}\n | \n
\n `,r=t=>`${t}`,l=(t,i)=>!!t&&``,a=({number:t,discontinued:i})=>i?`\n `:"";var h;!function(t){t.BENDING="bending",t.PUNCHING="punching",t.SPAREPARTS="spareparts"}(h||(h={}));const c=t=>{switch(t){case h.BENDING:return"cart-bending-tools";case h.PUNCHING:return"cart-punching-tools";case h.SPAREPARTS:return"cart-genuine-parts";default:return"cart"}};let m=class{constructor(i){t(this,i),this.url="",this.sortFormSelector="",this.filterSelector="",this.tableSelector="",this.tilesContainerSelector="",this.totalNumberSelector="",this.filteredNumberSelector="",this.scrollSensorSelector="",this.chooseShopText="",this.sortForm=null,this.filter=null,this.filterForm=null,this.table=null,this.tooltipContainer=null,this.tableBody=null,this.tilesContainer=null,this.filteredNumberElements=null,this.totalNumberElements=null,this.nextPage="",this.scrollSensor=null,this.activeFiltersContainer=null,this.activeFiltersLabel=null}componentDidLoad(){this.setSortForm(),this.setFilter(),this.setTilesContainer(),this.setTable(),this.setScrollSensor(),this.setTotalNumberElements(),this.setFilteredNumberElements(),this.requestData(this.url)}setSortForm(){""!==this.sortFormSelector&&(this.sortForm=document.querySelector(this.sortFormSelector),this.sortForm.addEventListener("submit",(t=>t.preventDefault())),this.sortForm.addEventListener("change",(()=>{this.requestData(this.url),this.syncSortStateToTable()})))}syncSortStateToTable(){if(null===this.table||null===this.sortForm)return;const{value:t}=this.sortForm.querySelector("select"),i=this.table.querySelector('ux-table-sort[sorted-direction="desc"], ux-table-sort[sorted-direction="asc"]');null!==i&&(i.sortedDirection="");const e=this.table.querySelector(`ux-table-sort[asc-name="${t}"]`),n=this.table.querySelector(`ux-table-sort[desc-name="${t}"]`);null!==e&&(e.sortedDirection="asc"),null!==n&&(n.sortedDirection="desc")}setFilter(){""!==this.filterSelector&&(this.filter=document.querySelector(this.filterSelector),null!==this.filter&&(n(this.filter,(()=>this.setFilterForm())),this.filter.addEventListener("uxFilterChange",(()=>{this.setActiveFilterLabelVisibility(),this.requestData(this.url)}))))}setTotalNumberElements(){""!==this.totalNumberSelector&&(this.totalNumberElements=document.querySelectorAll(this.totalNumberSelector))}setFilteredNumberElements(){""!==this.filteredNumberSelector&&(this.filteredNumberElements=document.querySelectorAll(this.filteredNumberSelector))}setFilterForm(){var t;this.filterForm=this.filter.querySelector("form"),null===(t=this.filterForm)||void 0===t||t.addEventListener("submit",(t=>t.preventDefault())),this.activeFiltersContainer=this.filter.querySelector(".ux-tag-list"),null!==this.activeFiltersContainer&&(this.activeFiltersLabel=this.activeFiltersContainer.parentElement.querySelector(".ux-label")),this.setActiveFilterLabelVisibility()}setActiveFilterLabelVisibility(){null!==this.activeFiltersLabel&&null!==this.activeFiltersContainer&&(this.activeFiltersLabel.style.display=this.activeFiltersContainer.querySelectorAll("ux-tag").length>0?"":"none")}updateNumbers(t,i){d(this.filteredNumberElements,t.toString()),d(this.totalNumberElements,i.toString())}setTable(){var t;if(""!==this.tableSelector&&(this.table=document.querySelector(this.tableSelector),this.tableBody=null===(t=this.table)||void 0===t?void 0:t.querySelector("tbody"),null!==this.table&&null!==this.sortForm&&(this.table.addEventListener("uxTableSort",(t=>{const i=t.detail;""!==i&&(this.sortForm.querySelector("select").value=i,this.requestData(this.url))})),this.syncSortStateToTable()),null!==this.table)){const t=this.table.closest("ux-table");this.tooltipContainer=document.createElement("div"),this.tooltipContainer.className="mymachine-table-tooltip-container",t.after(this.tooltipContainer)}}setScrollSensor(){""!==this.scrollSensorSelector&&(this.scrollSensor=document.querySelector(this.scrollSensorSelector),null!==this.scrollSensor&&this.scrollSensor.addEventListener("uxInfiniteScrollSensorScrolledIntoView",(()=>{this.requestData(this.nextPage)})))}setTilesContainer(){""!==this.tilesContainerSelector&&(this.tilesContainer=document.querySelector(this.tilesContainerSelector))}initialRequest(){this.requestData(this.url)}requestData(t){if(""===t)return;const n=function(t){return t.indexOf("mock-data/")>-1}(t)?{}:{method:"POST",body:e(this.sortForm)+"&"+e(this.filterForm),headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}};i(t,n).then((i=>{this.url===t&&(this.clearExistingData(),this.replaceFilter(i.filterHTML)),this.appendItemsToTable(i.items),this.appendItemsToTiles(i.items),this.updateNumbers(i.filteredCount,i.totalCount),this.nextPage=i.nextPage||"",""!==this.nextPage&&null!==this.scrollSensor&&(this.scrollSensor.hasFired=!1)}))}replaceFilter(t){if("string"==typeof t&&t.length>0&&null!==this.filter){const i=this.filter.parentElement;null!==i&&(i.style.height=`${i.offsetHeight}px`),this.filter.outerHTML=t,this.setFilter(),setTimeout((()=>{i.style.height="auto"}),200)}}clearExistingData(){null!==this.tableBody&&(this.tableBody.textContent=""),null!==this.tooltipContainer&&(this.tooltipContainer.textContent=""),null!==this.tilesContainer&&(this.tilesContainer.textContent="")}appendItemsToTable(t){null!==this.tableBody&&(this.tableBody.insertAdjacentHTML("beforeend",t.map(s).join("")),this.tooltipContainer.insertAdjacentHTML("beforeend",t.map(a).join("")))}appendItemsToTiles(t){var i;null!==this.tilesContainer&&this.tilesContainer.insertAdjacentHTML("beforeend",t.map((i=this.chooseShopText,({number:t,name:e,isFav:n,toggleFavUrl:o,shopLinks:s=[],inProduction:r,image:l,detailLink:a,discontinued:h})=>`\n 0?`\n shop-link="${s[0].link}"\n shop-link-title="${s[0].linkText}"\n shop-link-icon="${c(s[0].shopType)}"\n `:""}\n ${s&&s.length>1?`\n shop-link-2="${s[1].link}"\n shop-link-2-title="${s[1].linkText}"\n shop-link-2-icon="${c(s[1].shopType)}"\n `:""}\n choose-shop-title="${i}"\n sync-id="${t}"\n toggle-fav-url="${o}"\n is-fav="${n}"\n >\n ${h?`\n \n \n \n
`:""}\n \n `)).join(""))}render(){return null}static get watchers(){return{sortFormSelector:["setSortForm"],filterSelector:["setFilter"],totalNumberSelector:["setTotalNumberElements"],filteredNumberSelector:["setFilteredNumberElements"],tableSelector:["setTable"],scrollSensorSelector:["setScrollSensor"],tilesContainerSelector:["setTilesContainer"],url:["initialRequest"]}}};function d(t,i){null!==t&&[].forEach.call(t,(t=>t.textContent=i))}m.style='.mymachine-overview__cta-buttons-container{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;-ms-flex-direction:column;flex-direction:column;margin-bottom:10px}@media only screen and (min-width: 768px){.mymachine-overview__cta-buttons-container{-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap}}@media only screen and (min-width: 1024px){.mymachine-overview__cta-buttons-container{margin-top:10px}}.mymachine-overview__cta-buttons-container>*{min-width:100%;margin-bottom:15px}@media only screen and (min-width: 768px){.mymachine-overview__cta-buttons-container>*{min-width:auto;margin-right:20px}}.mymachine-overview__cta-buttons-container>*:nth-child(3){margin-left:auto;display:none}@media only screen and (min-width: 1024px){.mymachine-overview__cta-buttons-container>*:nth-child(3){display:block}}.mymachine-overview .mymachine-overview__direct-search-element{-ms-flex-order:-1;order:-1;margin-bottom:20px;border-bottom:1px solid #e2e2e2}@media only screen and (min-width: 768px){.mymachine-overview .mymachine-overview__direct-search-element{min-width:100%}}@media only screen and (min-width: 1024px){.mymachine-overview .mymachine-overview__direct-search-element{display:none;-ms-flex-order:1;order:1}}.mymachine-overview__filter-container::before,.mymachine-overview__filter-container::after{content:" ";display:table}.mymachine-overview__filter-container::after{clear:both}.mymachine-overview__filter-container .ux-tag{background-color:#285172}.mymachine-overview__filter-container .ux-label{min-width:auto;padding-right:20px}.mymachine-overview__filter-dropdown{min-width:250px;position:relative;margin-bottom:20px}@media only screen and (min-width: 768px){.mymachine-overview__filter-dropdown{max-width:300px;display:inline-block;margin-right:18px}}.mymachine-overview__filter-checkboxes{display:inline-block}@media only screen and (max-width: 1070px){.mymachine-overview__filter-checkboxes{display:block;margin:10px 0 20px}}.mymachine-overview__filter-checkbox:not(:last-child){margin-right:15px}@media (min-width: 1025px){.mymachine-overview .ux-button-group{position:absolute;right:0;top:0}}@media (max-width: 1024px){.mymachine-overview .ux-button-group{float:right;margin-left:25px}}.mymachine-overview__result-set{position:relative}@media (min-width: 1440px){.mymachine-overview__result-set{text-align:center}}@media (max-width: 1439px){.mymachine-overview__result-set{text-align:left}}.mymachine-overview__sort{font-size:16px;background-color:#fff}@media (min-width: 1025px){.mymachine-overview__sort{position:absolute;right:115px;top:0}}@media (max-width: 1024px){.mymachine-overview__sort{float:right;margin-bottom:0;margin-left:25px}}@media (max-width: 567px){.mymachine-overview__sort{margin-top:30px}}.mymachine-overview__tiles-container{max-width:1140px;margin:0 auto}.mymachine-overview__tiles-container .ux-tile{max-width:none;margin-bottom:30px}.mymachine-overview__tiles-container .ux-tile-body{overflow:hidden}.mymachine-overview__table-container .ux-toggle-button{font-size:21px}';export{m as ux_iws_data_controller_mymachine}