(()=>{"use strict";const t=function(){return{field:"last-name",search:"",init:function(){var t=this;this.$watch("search",(function(e){""===e?t.reset():t.searchClients()})),$(".letter").on("click","a",(function(e){t.search=$(e.target).text(),t.field="letter",e.preventDefault()}))},reset:function(){$(".letters-shortcut tbody tr").show()},searchClients:function(){var t=this.search.toLowerCase(),e=this.field;$("tr[data-client-last-name]").each((function(){var n;n="letter"===e?$(this).data("client-last-name"):$(this).data("client-"+e);try{n=(n+"").toLowerCase()}catch(t){n=""}void 0!==n&&("letter"!==e||(n=n.charAt(0))===t)?-1===n.indexOf(t)?$(this).hide():$(this).show():$(this).hide()}))}}};function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=t&&("undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"]);if(null==n)return;var r,o,i=[],a=!0,l=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(i.push(r.value),!e||i.length!==e);a=!0);}catch(t){l=!0,o=t}finally{try{a||null==n.return||n.return()}finally{if(l)throw o}}return i}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}const r=function(){return{colors:[],usedColors:[],addColor:function(){this.colors.push({color:this.randomColor(),name:"Neue Farbe",slug:"new-color-"+(new Date).getTime(),order:parseInt(this.getHighestOrder(this.colors))+1})},removeColor:function(t){this.colors=this.colors.filter((function(e){return e.order!==t})),this.colors.forEach((function(e){e.order>t&&e.order--}))},canBeRemoved:function(t){return 0===this.usedColors.filter((function(e){return e===t})).length},getHighestOrder:function(t){var e=0;return t.forEach((function(t){t.order>e&&(e=t.order)})),e},orderColors:function(t){var e=$(t.target).closest("tr").find('input[type="hidden"][name*="slug"]').val(),n=parseInt($(t.target).val()),r=this.colors.find((function(t){return t.slug===e}));this.colors=this.colors.filter((function(t){return t.slug!==e})),this.colors.splice(n-1,0,r),this.colors.forEach((function(t,e){t.order=e+1}))},randomColor:function(){return"#"+Math.floor(16777215*Math.random()).toString(16)},getBackgroundColor:function(t){var n=t.color,r=hexToRgb(n);if(!r)return n;var o=e(Object.values(r),3);return"rgba("+o[0]+","+o[1]+","+o[2]+", 0.6)"}}};function o(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var i=function(){function t(e,n,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.modal=this.getModal(null!=e?e:"Wirklich senden?",null!=n?n:"Ja",null!=r?r:"Nein")}var e,n,r;return e=t,(n=[{key:"confirm",value:function(){var t=this;return new Promise((function(e,n){t.show(),$("#modal-confirm-yes").on("click",(function(){e(!0)})),$("#modal-confirm-no").on("click",(function(){n(!1),$("span.submitted-form").removeClass("submitted-form")}))}))}},{key:"show",value:function(){var t=$("#modal-confirm");t.length&&t.remove(),$("body").append(this.modal),$("#modal-confirm").modal("show")}},{key:"getModal",value:function(t,e,n){return'<div class="modal fade modal-small" id="modal-confirm" role="dialog" aria-labelledby="modal-confirm" style="width: 40%; margin: 1em auto"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-header"><div class="container-fluid"><button type="button" class="close" data-dismiss="modal" aria-label="Close"></button></div></div><div class="modal-body"><div class="container-fluid"><p>'+t+'</p></div></div><div class="modal-footer"><button id="modal-confirm-no" class="btn btn-default">'+n+'</button><button id="modal-confirm-yes" class="btn btn-primary">'+e+"</button></div></div></div></div>"}}])&&o(e.prototype,n),r&&o(e,r),t}();const a=function(){return{bags:$("#midwifeBags").data("bags"),selectedBag:$("#midwifeBags").data("initial-id"),newBagIndex:Object.keys($("#midwifeBags").data("bags")).length,addNewBag:function(){this.bags["new"+this.newBagIndex]={id:"new"+this.newBagIndex,name:"Neue Tasche",items:[""]},this.selectedBag="new"+this.newBagIndex,this.newBagIndex++},addNewItem:function(t){Object.values(this.bags).find((function(e){return e.id===t})).items.push({value:""})},removeBag:function(t){var e=this;new i("Möchten Sie das wirklich löschen?","Ja","Nein").confirm().then((function(){delete e.bags[t],e.selectedBag=Object.values(e.bags)[0].id})).catch((function(t){})).then((function(){$("#modal-confirm").modal("hide")}))}}};document.addEventListener("alpine:init",(function(){Alpine.data("clientSearchModal",t),Alpine.data("inputTypeColors",r),Alpine.data("midwifeBags",a)}))})();