1import{b as n}from"/assets/chunks/chunk-KWI774O3.js";import"/assets/chunks/chunk-XDTPXY5K.js";var i=class extends n{static targets=["label","filledIcon","outlineIcon"];get heartContainers(){return document.querySelectorAll('[data-name="heartContainer"]')}async create(t){let a=t.currentTarget,o=a.dataset.offerId;try{let r=await(await fetch("/favorites",{method:"POST",headers:{"X-CSRF-Token":window.getCsrfToken(),"Content-Type":"application/json"},body:JSON.stringify({offer_id:o})})).json();r.success&&(this.updateHeartIcons(a,"destroy",r),this.updateAllMatchingContainers(o,"destroy",r),this.hasLabelTarget&&(this.labelTarget.innerText=this.element.dataset.removeLabel))}catch(e){console.error("Error creating favorite:",e)}}async destroy(t){let a=t.currentTarget,o=a.dataset.favoriteId;if(o)try{let r=await(await fetch(`/favorites/${o}`,{method:"DELETE",headers:{"X-CSRF-Token":window.getCsrfToken(),"Content-Type":"application/json"}})).json();r.success&&(this.updateHeartIcons(a,"create",r),this.updateAllMatchingContainers(a.dataset.offerId,"create",r),this.hasLabelTarget&&(this.labelTarget.innerText=this.element.dataset.addLabel))}catch(e){console.error("Error destroying favorite:",e)}}updateHeartIcons(t,a,o){let e=a==="destroy";t.dataset.action=`click->favorite#${a}`,e?t.dataset.favoriteId=o.id:delete t.dataset.favoriteId;let r=t.querySelector('[data-favorite-target="filledIcon"]'),s=t.querySelector('[data-favorite-target="outlineIcon"]');r&&s&&(r.classList.toggle("hidden",!e),s.classList.toggle("hidden",e))}updateAllMatchingContainers(t,a,o){this.heartContainers.forEach(e=>{e.dataset.offerId===t&&this.updateHeartIcons(e,a,o)})}};export{i as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.