diff --git a/app/Jobs/CalendarsClearElapsed.php b/app/Jobs/CalendarsClearElapsed.php new file mode 100644 index 0000000000..458611e8a0 --- /dev/null +++ b/app/Jobs/CalendarsClearElapsed.php @@ -0,0 +1,41 @@ +id = $calendar->id; + } + + /** + * Execute the job. + */ + public function handle(): void + { + $calendar = Calendar::find($this->id); + if (!$calendar) { + return; + } + + $model = new EntityEvent(); + DB::update('UPDATE ' . $model->getTable() . ' SET elapsed = NULL WHERE calendar_id = \'' . $calendar->id . '\''); + } +} diff --git a/app/Models/EntityEvent.php b/app/Models/EntityEvent.php index 51f0c0f7bf..15aeb9995a 100644 --- a/app/Models/EntityEvent.php +++ b/app/Models/EntityEvent.php @@ -27,7 +27,7 @@ * @property int|null $recurring_until * @property string $recurring_periodicity * @property int $type_id - * @property int $elapsed + * @property int|null $elapsed * * @property Calendar|null $calendar * @property EntityEvent|null $death @@ -244,6 +244,11 @@ public function isPastDate(int $year, int $month, int $day): bool */ public function calcElapsed(EntityEvent $event = null): int { + // Have the value cached? Don't bother with more work + if (empty($event) && !empty($this->elapsed)) { + return $this->elapsed; + } + if (!empty($event)) { $year = $event->year; $month = $event->month; @@ -262,14 +267,25 @@ public function calcElapsed(EntityEvent $event = null): int $years = $year - $baseYear; if ($month < $this->month) { - return $years - 1; + return $this->saveElapsed($years - 1, empty($event)); } if ($month > $this->month) { - return $years; + return $this->saveElapsed($years, empty($event)); } // Same month - return $years - ($day < $this->day ? 1 : 0); + return $this->saveElapsed($years - ($day < $this->day ? 1 : 0), empty($event)); + } + + protected function saveElapsed(int $number, bool $save): int + { + // If comparing two days, don't save the "elapsed" part, we need to re-calc those one each page load + if (!$save) { + return $number; + } + $this->elapsed = $number; + $this->saveQuietly(); + return $this->elapsed; } /** diff --git a/app/Observers/CalendarObserver.php b/app/Observers/CalendarObserver.php index 2efe4150b8..410b16b6de 100644 --- a/app/Observers/CalendarObserver.php +++ b/app/Observers/CalendarObserver.php @@ -2,6 +2,15 @@ namespace App\Observers; +use App\Jobs\CalendarsClearElapsed; +use App\Models\MiscModel; + class CalendarObserver extends MiscObserver { + public function updated(MiscModel $model) + { + if ($model->isDirty(['date'])) { + CalendarsClearElapsed::dispatch($model); + } + } } diff --git a/app/Observers/EntityEventObserver.php b/app/Observers/EntityEventObserver.php index 4d45fa3cdd..6f0cf3595d 100644 --- a/app/Observers/EntityEventObserver.php +++ b/app/Observers/EntityEventObserver.php @@ -15,4 +15,12 @@ public function saving(EntityEvent $entityEvent) $entityEvent->recurring_until = null; } } + + public function updating(EntityEvent $entityEvent) + { + // When updating and elapsed isn't dirty (calculated on the overview), reset it + if ($entityEvent->isDirty(['year', 'month', 'day', 'calendar_id'])) { + $entityEvent->elapsed = null; + } + } } diff --git a/app/Services/Calendars/AdvancerService.php b/app/Services/Calendars/AdvancerService.php index 92020636b8..2730ac739e 100644 --- a/app/Services/Calendars/AdvancerService.php +++ b/app/Services/Calendars/AdvancerService.php @@ -2,6 +2,7 @@ namespace App\Services\Calendars; +use App\Jobs\CalendarsClearElapsed; use App\Models\Calendar; class AdvancerService @@ -42,7 +43,7 @@ public function advance(): self $year++; } $this->calendar->date = $year . '-' . $month . ($day !== false ? '-' . $day : null); - $this->calendar->saveQuietly(); + $this->calendar->save(); return $this; } @@ -68,7 +69,8 @@ public function retreat(): self $year--; } $this->calendar->date = $year . '-' . $month . '-' . $day; - $this->calendar->saveQuietly(); + $this->calendar->save(); + CalendarsClearElapsed::dispatch($this->calendar); return $this; } } diff --git a/public/build/assets/app-b968c210.js b/public/build/assets/app-b968c210.js new file mode 100644 index 0000000000..6205fcc7f0 --- /dev/null +++ b/public/build/assets/app-b968c210.js @@ -0,0 +1 @@ +import{t as U,C as W}from"./tippy.esm-24ef6cb2.js";import{d as ot}from"./mention-6dbb4e38.js";import{S as Me}from"./sortable.esm-be94e56d.js";import{_ as S,c as l,a as o,t as d,o as r,n as E,w as te,b as h,F as v,r as b,d as y,e as g,f as L,g as j,h as ne,i as at,v as rt,j as F,k as Ie,l as lt}from"./_plugin-vue_export-helper-c420bb3b.js";import{m as ct}from"./mitt-f7ef348c.js";import{v as Ae}from"./v-click-outside.umd-d5c5f7b0.js";import"./_commonjsHelpers-725317a4.js";$(document).ready(function(){window.initTags=function(){$.each($(".form-tags"),function(){$(this).hasClass("select2-hidden-accessible")||$(this).select2({tags:$(this).data("allow-new"),allowClear:$(this).data("allow-clear"),dropdownParent:$(this).data("dropdown-parent")||"",minimumInputLength:0,ajax:{quietMillis:500,delay:500,url:$(this).data("url"),dataType:"json",data:function(e){return{q:$.trim(e.term)}},processResults:function(e){return{results:e}},cache:!0},createTag:function(e){var t=$.trim(e.term);return t===""?null:{id:t,text:t,newTag:!0}},templateResult:function(e){var t=$(""+e.text+"");return e.colour&&(t=$(""+e.text+"")),t},templateSelection:function(e,t){if(e.newTag)return $(''+e.text+' ');let n=$(e.element);return e.colour?$(t).addClass(e.colour):n.data("colour")&&$(t).addClass(n.data("colour")),$(t).addClass("text-left"),e.text}})})},window.initTags()});/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/ca",[],function(){return{errorLoading:function(){return"La càrrega ha fallat"},inputTooLong:function(t){var n=t.input.length-t.maximum,s="Si us plau, elimina "+n+" car";return s+=n==1?"àcter":"àcters"},inputTooShort:function(t){var n=t.minimum-t.input.length,s="Si us plau, introdueix "+n+" car";return s+=n==1?"àcter":"àcters"},loadingMore:function(){return"Carregant més resultats…"},maximumSelected:function(t){var n="Només es pot seleccionar "+t.maximum+" element";return t.maximum!=1&&(n+="s"),n},noResults:function(){return"No s'han trobat resultats"},searching:function(){return"Cercant…"},removeAllItems:function(){return"Treu tots els elements"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/de",[],function(){return{errorLoading:function(){return"Die Ergebnisse konnten nicht geladen werden."},inputTooLong:function(t){return"Bitte "+(t.input.length-t.maximum)+" Zeichen weniger eingeben"},inputTooShort:function(t){return"Bitte "+(t.minimum-t.input.length)+" Zeichen mehr eingeben"},loadingMore:function(){return"Lade mehr Ergebnisse…"},maximumSelected:function(t){var n="Sie können nur "+t.maximum+" Element";return t.maximum!=1&&(n+="e"),n+=" auswählen"},noResults:function(){return"Keine Übereinstimmungen gefunden"},searching:function(){return"Suche…"},removeAllItems:function(){return"Entferne alle Elemente"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(t){var n=t.input.length-t.maximum,s="Please delete "+n+" character";return n!=1&&(s+="s"),s},inputTooShort:function(t){return"Please enter "+(t.minimum-t.input.length)+" or more characters"},loadingMore:function(){return"Loading more results…"},maximumSelected:function(t){var n="You can only select "+t.maximum+" item";return t.maximum!=1&&(n+="s"),n},noResults:function(){return"No results found"},searching:function(){return"Searching…"},removeAllItems:function(){return"Remove all items"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/es",[],function(){return{errorLoading:function(){return"No se pudieron cargar los resultados"},inputTooLong:function(t){var n=t.input.length-t.maximum,s="Por favor, elimine "+n+" car";return s+=n==1?"ácter":"acteres"},inputTooShort:function(t){var n=t.minimum-t.input.length,s="Por favor, introduzca "+n+" car";return s+=n==1?"ácter":"acteres"},loadingMore:function(){return"Cargando más resultados…"},maximumSelected:function(t){var n="Sólo puede seleccionar "+t.maximum+" elemento";return t.maximum!=1&&(n+="s"),n},noResults:function(){return"No se encontraron resultados"},searching:function(){return"Buscando…"},removeAllItems:function(){return"Eliminar todos los elementos"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/fr",[],function(){return{errorLoading:function(){return"Les résultats ne peuvent pas être chargés."},inputTooLong:function(t){var n=t.input.length-t.maximum;return"Supprimez "+n+" caractère"+(n>1?"s":"")},inputTooShort:function(t){var n=t.minimum-t.input.length;return"Saisissez au moins "+n+" caractère"+(n>1?"s":"")},loadingMore:function(){return"Chargement de résultats supplémentaires…"},maximumSelected:function(t){return"Vous pouvez seulement sélectionner "+t.maximum+" élément"+(t.maximum>1?"s":"")},noResults:function(){return"Aucun résultat trouvé"},searching:function(){return"Recherche en cours…"},removeAllItems:function(){return"Supprimer tous les éléments"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/hu",[],function(){return{errorLoading:function(){return"Az eredmények betöltése nem sikerült."},inputTooLong:function(t){return"Túl hosszú. "+(t.input.length-t.maximum)+" karakterrel több, mint kellene."},inputTooShort:function(t){return"Túl rövid. Még "+(t.minimum-t.input.length)+" karakter hiányzik."},loadingMore:function(){return"Töltés…"},maximumSelected:function(t){return"Csak "+t.maximum+" elemet lehet kiválasztani."},noResults:function(){return"Nincs találat."},searching:function(){return"Keresés…"},removeAllItems:function(){return"Távolítson el minden elemet"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/it",[],function(){return{errorLoading:function(){return"I risultati non possono essere caricati."},inputTooLong:function(t){var n=t.input.length-t.maximum,s="Per favore cancella "+n+" caratter";return s+=n!==1?"i":"e"},inputTooShort:function(t){return"Per favore inserisci "+(t.minimum-t.input.length)+" o più caratteri"},loadingMore:function(){return"Caricando più risultati…"},maximumSelected:function(t){var n="Puoi selezionare solo "+t.maximum+" element";return t.maximum!==1?n+="i":n+="o",n},noResults:function(){return"Nessun risultato trovato"},searching:function(){return"Sto cercando…"},removeAllItems:function(){return"Rimuovi tutti gli oggetti"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/nl",[],function(){return{errorLoading:function(){return"De resultaten konden niet worden geladen."},inputTooLong:function(t){return"Gelieve "+(t.input.length-t.maximum)+" karakters te verwijderen"},inputTooShort:function(t){return"Gelieve "+(t.minimum-t.input.length)+" of meer karakters in te voeren"},loadingMore:function(){return"Meer resultaten laden…"},maximumSelected:function(t){var n=t.maximum==1?"kan":"kunnen",s="Er "+n+" maar "+t.maximum+" item";return t.maximum!=1&&(s+="s"),s+=" worden geselecteerd"},noResults:function(){return"Geen resultaten gevonden…"},searching:function(){return"Zoeken…"},removeAllItems:function(){return"Verwijder alle items"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/pl",[],function(){var t=["znak","znaki","znaków"],n=["element","elementy","elementów"],s=function(i,a){return i===1?a[0]:i>1&&i<=4?a[1]:i>=5?a[2]:void 0};return{errorLoading:function(){return"Nie można załadować wyników."},inputTooLong:function(i){var a=i.input.length-i.maximum;return"Usuń "+a+" "+s(a,t)},inputTooShort:function(i){var a=i.minimum-i.input.length;return"Podaj przynajmniej "+a+" "+s(a,t)},loadingMore:function(){return"Trwa ładowanie…"},maximumSelected:function(i){return"Możesz zaznaczyć tylko "+i.maximum+" "+s(i.maximum,n)},noResults:function(){return"Brak wyników"},searching:function(){return"Trwa wyszukiwanie…"},removeAllItems:function(){return"Usuń wszystkie przedmioty"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/pt-BR",[],function(){return{errorLoading:function(){return"Os resultados não puderam ser carregados."},inputTooLong:function(t){var n=t.input.length-t.maximum,s="Apague "+n+" caracter";return n!=1&&(s+="es"),s},inputTooShort:function(t){return"Digite "+(t.minimum-t.input.length)+" ou mais caracteres"},loadingMore:function(){return"Carregando mais resultados…"},maximumSelected:function(t){var n="Você só pode selecionar "+t.maximum+" ite";return t.maximum==1?n+="m":n+="ns",n},noResults:function(){return"Nenhum resultado encontrado"},searching:function(){return"Buscando…"},removeAllItems:function(){return"Remover todos os itens"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/ru",[],function(){function t(n,s,i,a){return n%10<5&&n%10>0&&n%100<5||n%100>20?n%10>1?i:s:a}return{errorLoading:function(){return"Невозможно загрузить результаты"},inputTooLong:function(n){var s=n.input.length-n.maximum,i="Пожалуйста, введите на "+s+" символ";return i+=t(s,"","a","ов"),i+=" меньше"},inputTooShort:function(n){var s=n.minimum-n.input.length,i="Пожалуйста, введите ещё хотя бы "+s+" символ";return i+=t(s,"","a","ов")},loadingMore:function(){return"Загрузка данных…"},maximumSelected:function(n){var s="Вы можете выбрать не более "+n.maximum+" элемент";return s+=t(n.maximum,"","a","ов")},noResults:function(){return"Совпадений не найдено"},searching:function(){return"Поиск…"},removeAllItems:function(){return"Удалить все элементы"}}}),e.define,e.require})();/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;e.define("select2/i18n/sk",[],function(){var t={2:function(n){return n?"dva":"dve"},3:function(){return"tri"},4:function(){return"štyri"}};return{errorLoading:function(){return"Výsledky sa nepodarilo načítať."},inputTooLong:function(n){var s=n.input.length-n.maximum;return s==1?"Prosím, zadajte o jeden znak menej":s>=2&&s<=4?"Prosím, zadajte o "+t[s](!0)+" znaky menej":"Prosím, zadajte o "+s+" znakov menej"},inputTooShort:function(n){var s=n.minimum-n.input.length;return s==1?"Prosím, zadajte ešte jeden znak":s<=4?"Prosím, zadajte ešte ďalšie "+t[s](!0)+" znaky":"Prosím, zadajte ešte ďalších "+s+" znakov"},loadingMore:function(){return"Načítanie ďalších výsledkov…"},maximumSelected:function(n){return n.maximum==1?"Môžete zvoliť len jednu položku":n.maximum>=2&&n.maximum<=4?"Môžete zvoliť najviac "+t[n.maximum](!1)+" položky":"Môžete zvoliť najviac "+n.maximum+" položiek"},noResults:function(){return"Nenašli sa žiadne položky"},searching:function(){return"Vyhľadávanie…"},removeAllItems:function(){return"Odstráňte všetky položky"}}}),e.define,e.require})();$(document).ready(function(){window.initForeignSelect=function(){$("select.select2").length!==0&&($.each($("select.select2"),function(e){if($(this).hasClass("select2-hidden-accessible"))return;if($(this).hasClass("campaign-genres")){$(this).select2({tags:!1,allowClear:!0,dropdownParent:"",width:"100%",maximumSelectionLength:3});return}let t=$(this).data("allow-clear"),n=$(this).data("dropdown-parent");$(this).select2({tags:!1,placeholder:$(this).data("placeholder"),allowClear:t||!0,language:$(this).data("language"),minimumInputLength:0,dropdownParent:n||"",width:"100%",ajax:{delay:500,quietMillis:500,url:$(this).data("url"),dataType:"json",data:function(s){return{q:$.trim(s.term)}},processResults:function(s){return{results:s}},error:function(s){return console.log("error",s),s.status===503&&window.showToast(s.responseJSON.message,"error"),{results:[]}},cache:!0},templateResult:function(s){var i="";return s.image?i=$(""+s.text+""):i=$(""+s.text+""),i},createTag:function(s){return null}})}),$("select.select2-local").select2({placeholder:$(this).data("placeholder"),language:$(this).data("language"),allowClear:!0}),$("select.select2-colour").select2({allowClear:!1,templateResult:ve,templateSelection:ve}))}});function ve(e){return e.id==="none"?e.text:$('
'+e.text+"
")}$(document).ready(function(){$.each($("form"),function(){$(this).data("shortcut")&&ut(this)}),dt(),_e(),$(document).on("shown.bs.modal",()=>{_e()})});function dt(){$(document).bind("keydown",function(e){let t=$(e.target),n=$("#entity-modal"),s=$(".quick-creator-button"),i=$('[data-keyboard="edit"]');if(e.key==="]"){if(z(t))return;$(".sidebar-toggle").click().blur()}else{if(e.key==="k")return z(t)?void 0:($("#entity-lookup").focus(),!1);if(e.key==="n"&&!(e.ctrlKey||e.metaKey)&&!e.altKey&&s.length>0){if(z(t)||(n.data("bs.modal")||{}).isShown)return;s[0].click()}else if(e.key==="e"&&!(e.ctrlKey||e.metaKey)&&i.length===1){if(z(t)||(n.data("bs.modal")||{}).isShown)return;i[0].click()}else e.key==="Escape"&&n.has(".qq-modal-selection").length===1&&n.modal("hide")}})}function z(e){return e.length===0?!1:e.is("input")||e.is("select")||e.is("textarea")||e.attr("contentEditable")==="true"||e.hasClass("CodeMirror")}function ut(e){$(document).bind("keydown",function(t){if((t.ctrlKey||t.metaKey)&&t.key.toLowerCase()==="s")return window.entityFormHasUnsavedChanges=!1,t.shiftKey?G("submit-update"):t.altKey&&G("submit-new"),$(e).submit(),!1;if((t.ctrlKey||t.metaKey)&&t.altKey&&t.key==="c")return window.entityFormHasUnsavedChanges=!1,G("submit-copy"),$(e).submit(),!1})}function G(e){let t=$("#form-submit-main");t&&(t.attr("name",e),$("#submit-mode").attr("name",e))}const _e=()=>{$('input[data-paste="fontawesome"]').on("paste",function(e){e.preventDefault();let t;if(e.clipboardData||e.originalEvent.clipboardData?t=(e.originalEvent||e).clipboardData.getData("text/plain"):window.clipboardData&&(t=window.clipboardData.getData("Text")),t.startsWith('i.json()).then(i=>{s.innerHTML="",i.forEach(a=>{let c=document.createElement("a");c.href=a.url,c.text=a.name,s.append(c)}),i.length>0&&t.show()})})}function Pe(){if(P=$(".form-submit-actions"),P.length===0)return;let e=$("#form-submit-main"),t=$("#submit-mode");if(t===void 0)throw new Error("No submit mode hidden input found");$.each(P,function(){$(this).data("loaded")!==1&&($(this).data("loaded",1),$(this).unbind("click").on("click",function(){return t.attr("name",$(this).data("action")),e.trigger("click"),!1}))})}function mt(){$.each($("form"),function(){$(this).on("submit",function(){window.entityFormHasUnsavedChanges=!1;var e=$(this).find(".btn-primary");return e.length>0&&($.each(e,function(){$(this).parent().hasClass("dropdown")||$(this).hasClass("quick-creator-subform")?$(this).prop("disabled",!0):$(this).prop("disabled",!0).addClass("loading")}),$(this).append('')),!0})})}function pt(){q=$("#entity-calendar-form-add"),w=$('select[name="calendar_id"]'),J=$('input[name="calendar_id"]'),$(".entity-calendar-modal-form"),T=$(".entity-calendar-subform"),I=$("#entity-calendar-form-cancel"),ie=$(".entity-calendar-form"),k=$('input[name="calendar_year"]'),C=$('select[name="calendar_month"]'),x=$('select[name="calendar_day"]'),B=$(".entity-calendar-loading"),q.length===1&&(q.on("click",function(e){e.preventDefault(),q.hide(),ie.show();let t=$(this).data("default-calendar");return t&&(J.val(t),I.show(),T.show(),N(t)),!1}),I.on("click",function(e){e.preventDefault(),w.val(null),J.val(null),I.hide(),se()})),w.length===1&&w.on("change",function(){if(T.hide(),!$(this).val())return se(),!1;k=$('input[name="calendar_year"]'),C=$('select[name="calendar_month"]'),x=$('select[name="calendar_day"]'),k.length===0&&$('input[name="year"]').length===1&&(k=$('input[name="year"]'),C=$('select[name="month"]'),x=$('input[name="day"]')),N(w.val())}),xt()}function Qe(){$("#entity-calendar-modal-add").length!==0&&(q=$("input[name=calendar-data-url]"),w=$('select[name="calendar_id"]'),k=$('input[name="year"]'),C=$('select[name="month"]'),x=$('input[name="day"]'),B=$(".entity-calendar-loading"),T=$(".entity-calendar-subform"),w.on("change",function(){if(T.hide(),!w.val()){se();return}N(w.val())}),w.val()&&(I.show(),T.show(),N(w.val())),$('.entity-calendar-subform input[name="length"]').focusout(function(){if(!$(this).val())return;let e=$(this).data("url").replace("/0/","/"+w.val()+"/"),t={day:x.val(),month:C.val(),year:k.val(),length:$(this).val()};$.ajax(e,{data:t}).done(function(n){n.overflow==!0?$(".length-warning").show():$(".length-warning").hide()})}))}const N=e=>{B.show(),e=parseInt(e);var t=$('input[name="calendar-data-url"]').data("url").replace("/0/","/"+e+"/");fetch(t).then(n=>n.json()).then(n=>{let s=x.val();k.html(""),C.html(""),x.html("");let i=1,a=1;s||(s=n.current.day);let c=parseInt(n.current.month);$.each(n.months,function(u){let m=n.months[u],f=i===c?' selected="selected"':"";C.append('"),i===c&&(a=m.length),i++});for(let u=1;u"+u+"")}B.hide(),T.show(),k.val(n.current.year),$("select.reminder-periodicity option").remove(),$.each(n.recurring,function(u,m){$("select.reminder-periodicity").append('")}),$('input[name="length"]').val(1),n.length===1&&C.val(n[0].id)})};function se(){ie.hide(),q.show(),$('input[name="calendar_day"]').val(null),$('input[name="calendar_month"]').val(null),$('input[name="calendar_year"]').val(null),$('select[name="calendar_id"]').val(null)}function gt(){if(P=$('form[data-unload="1"]'),P.length===0)return;let e=$("#form-submit-main");$(document).on("change",":input",function(){$(this).data("skip-unsaved")||(window.entityFormHasUnsavedChanges=!0)}),e.length===1&&$(window).bind("beforeunload",function(t){if(window.entityFormHasUnsavedChanges)return"Unsaved data warning"})}function ze(){$('form[data-maintenance="1"]').each(function(){$(this).data("with-maintenance")!==!0&&($(this).data("with-maintenance",!0),$(this).submit(function(e){if($(this).data("checked-maintenance")===!0)return!0;e.preventDefault();let t={url:$(this).attr("action"),method:$(this).attr("method"),data:$(this).serialize(),context:this};if($(this).find('input[type="file"]').not(".note-image-input").length>0){let n=new FormData(this);t={url:$(this).attr("action"),method:$(this).attr("method"),data:n,cache:!1,contentType:!1,processData:!1,context:this}}$.ajax(t).done(function(){$(this).data("checked-maintenance",!0).submit()}).fail(function(n){window.formErrorHandler(n,this)})}))})}function vt(){$(".permission-toggle").change(function(){let t="input[data-action="+$(this).data("action")+"]";$(this).prop("checked")?$(t).prop("checked",!0):$(t).prop("checked",!1)})}function Fe(){$(".btn-post-collapse").unbind("click").click(function(){return document.querySelectorAll(".element-toggle").forEach(t=>{t.classList.add("animate-collapsed"),document.querySelector(t.dataset.target).classList.add("hidden")}),!1}),$(".btn-post-expand").unbind("click").click(function(){return document.querySelectorAll(".element-toggle").forEach(t=>{t.classList.remove("animate-collapsed"),document.querySelector(t.dataset.target).classList.remove("hidden")}),!1})}function Re(){$(".story-load-more").click(function(e){e.preventDefault();let t=$(this);return $(this).addClass("loading"),_t($(this).data("url")).then(n=>{t.parent().remove(),$(".entity-posts").append(n),Re(),Fe(),$(document).trigger("shown.bs.modal")}).catch(()=>{t.removeClass("loading")}),!1})}async function _t(e){return await(await fetch(e)).text()}function yt(){$(".domain-trust").click(function(){let e="kanka_trusted_domains",t=document.cookie.match("(^|;) ?"+e+"=([^;]*)(;|$)");t=t?t[2]:"";let n=$(this).data("domain");t.includes(n)||(t&&(t+="|"),t+=n);let s=new Date;s.setTime(s.getTime()+30*24*60*60*1e3),document.cookie=e+"="+t+";expires="+s.toUTCString()+";sameSite=Strict"})}function wt(){$(".dynamic-row-add").on("click",function(e){e.preventDefault();let t=$(this).data("target"),n=$(this).data("template");return $("."+t).append('
'+$("#"+n).html()+"
"),ye(),$(document).trigger("shown.bs.modal"),!1}),ye()}function ye(){$.each($(".dynamic-row-delete"),function(){$(this).data("init")!==1&&$(this).data("init",1).on("click",function(e){e.preventDefault(),$(this).closest(".parent-delete-row").remove()}).on("keydown",function(e){e.key==="Enter"&&$(this).click()})})}function bt(){$('input[data-toggle="entity-privacy"]').change(function(){let e=$("#entity-is-private");$(this).prop("checked")?e.show():e.hide()})}function xt(){$('select[name="calendar_month"]').change(function(){let e=$(this).find(":selected").data("length");kt(e)})}function kt(e){let t=x.val();t>e&&(t=e),x.html("");for(let n=1;n<=e;n++){let s=n==t?' selected="selected"':"";x.append('")}}var oe;$(document).ready(function(){we(),$(document).on("shown.bs.modal shown.bs.popover",function(){we()}),oe=$(".post-perm-add"),oe.length!==0&&($t(),Be())});function $t(){oe.on("click",function(e){e.preventDefault();let t=$(this).data("type"),n=$('select[name="'+t+'"]');if(!n||!n.val())return!1;let s=n.find(":selected")[0],i=$("#post-perm-"+t+"-template").clone().removeClass("hidden").removeAttr("id"),a=i.html().replace(/\$SELECTEDID\$/g,n.val()).replace(/\$SELECTEDNAME\$/g,s.text);return i.html(a).insertBefore($("#post-perm-target")),document.getElementById("post-new-"+t).close(),Be(),n.val("").trigger("change"),!1})}function Be(){$.each($(".post-delete-perm"),function(){$(this).unbind("click"),$(this).on("click",function(){$(this).closest(".grid").remove()})})}const we=()=>{$("form.post-visibility").on("submit",function(e){return e.preventDefault(),$.post({url:$(this).attr("action"),data:{visibility_id:$(this).find('[name="visibility_id"]').val()}}).done(function(t){document.getElementById("primary-dialog").close(),$("#visibility-icon-"+t.post_id).html(t.icon),window.showToast(t.toast)}),!1})};var be;$(document).ready(function(){be=$("#calendar-year-switcher"),be.length===1&&($("#calendar-year-switcher-field"),$("#add-calendar-event"),Ct()),$(document).on("shown.bs.modal",function(){xe()}),$('select[name="recurring_periodicity"]').length===1&&xe(),St()});function Ct(){$(".calendar-event-block").each(function(){$(this).data("toggle")!=="dialog"&&$(this).data("url")&&$(this).click(function(){window.location=$(this).data("url")})})}function xe(){$('select[name="recurring_periodicity"]').change(function(){this.value?$(".field-recurring-until").show():$(".field-recurring-until").hide()}),$("#calendar-action-existing").click(function(e){e.preventDefault(),$("#calendar-event-first").hide(),$(".calendar-new-event-field").hide(),$("#calendar-event-subform").fadeToggle(),$("#calendar-event-submit").toggle()}),$("#calendar-action-new").click(function(e){e.preventDefault(),$("#calendar-event-first").hide(),$(".calendar-existing-event-field").hide(),$("#calendar-event-subform").fadeToggle(),$("#calendar-event-submit").toggle()}),$("#calendar-event-switch").click(function(e){e.preventDefault(),$("#calendar-event-subform").hide(),$("#calendar-event-first").fadeToggle(),$(".calendar-existing-event-field").show(),$(".calendar-new-event-field").show(),$("#calendar-event-submit").toggle()})}function St(){$('[data-shortcut="previous"]').length!==0&&$(document).bind("keydown",function(e){(e.ctrlKey||e.metaKey)&&e.which===37?$('[data-shortcut="previous"]').addClass("loading")[0].click():(e.ctrlKey||e.metaKey)&&e.which===39&&$('[data-shortcut="next"]').addClass("loading")[0].click()})}const He=document.querySelector("dialog#edit-warning"),ae=300*1e3;let Ne,re=!0;$(document).ready(function(){if(!He)return;let e=document.querySelector('input[name="edit-warning"]');window.openDialog("edit-warning",e.dataset.url),$(document).on("shown.bs.modal",function(){Lt()}),jt()});function Lt(){re=!1,$("#entity-edit-warning-ignore").click(function(e){e.preventDefault(),re=!0,$.ajax({url:$(this).data("url"),type:"POST",context:this}).done(function(){He.close()})})}function jt(){let e=$("#editing-keep-alive");e.length!==0&&(Ne=e.data("url"),setTimeout(le,ae))}function le(){if(!re){setTimeout(le,ae);return}$.ajax({url:Ne,type:"POST"}).done(function(){setTimeout(le,ae)})}var M;let ce,ke,O;$(document).ready(function(){$(document).on("shown.bs.modal shown.bs.popover",function(){V()}),$(".quick-creator-subform").click(function(){$(document).on("shown.bs.modal",function(){me()}),window.openDialog("primary-dialog",$(this).data("url"))})});function V(){ce=$("#qq-modal-loading"),ke=$("#qq-modal-selection"),O=$("#qq-modal-form"),$('[data-toggle="entity-creator"]').unbind("click").click(function(e){return e.preventDefault(),$(this).data("type")==="inline"?($(".quick-creator-body").hide(),$(".quick-creator-footer").hide(),$(".quick-creator-loading").show()):Ke(),$.ajax({url:$(this).data("url"),context:this}).done(function(n){ce.hide(),ke.hide(),O.show().html(n),me(),pe(),$(document).trigger("shown.bs.modal")}),!1})}function Oe(){$("#qq-name-field").unbind("focusout").focusout(function(){$(this).val()&&($(this).parent().parent().find(".duplicate-entity-warning").hide(),$.ajax({url:$(this).data("live")+"?q="+$(this).val()+"&type="+$(this).data("type"),context:this}).done(function(e){if(e.length>0){let t=Object.keys(e).map(function(n){return''+e[n].name+""}).join(", ");$(this).parent().parent().find(".duplicate-entities").html(t),$(this).parent().parent().find(".duplicate-entity-warning").show()}else $(this).parent().parent().find(".duplicate-entity-warning").hide()}))})}function Ke(){$("#qq-modal-form").hide(),$("#qq-modal-selection").hide(),$("#qq-modal-loading").show()}function me(){M=$(".quick-creator-submit"),M.length!==0&&(Oe(),Ue(),pe(),M.on("click",function(e){let t=$(this).data("action");return t&&$('#entity-creator-form [name="action"]').val(t),!0}),$("#entity-creator-form").submit(function(e){e.preventDefault(),M.prop("disabled",!0).find("span").hide().parent().find("i.fa-spin").show(),$("div.text-error").remove(),$.post({url:$(this).attr("action"),data:$(this).serialize(),context:this}).done(function(t){if(typeof t=="object"){if(t.redirect){window.location.replace(t.redirect);return}let s=new Option(t._name,t._id),i=$("#"+t._target);if(t._multi){let c=i.val();c.push(t._id),i.append(s).val(c)}else i.children().remove().end().append(s).val(t._id);i.trigger("change"),$("#qq-modal-form").html("").show(),$("#qq-modal-loading").hide(),$("#qq-modal-selection").show(),document.getElementById("primary-dialog").close(),de();return}let n=document.getElementById("qq-modal-form");n.innerHTML=t,V(),de()}).fail(function(t){if(t.responseJSON.errors){let n=t.responseJSON.errors;Object.keys(n).forEach(function(c){let u=$('#entity-creator-form [name="'+c+'"]');u.length>0&&u.addClass("input-error").parent().append('
'+n[c][0]+"
")});let i=Object.keys(n)[0],a=$('#entity-creator-form input[name="'+i+'"]');if(a[0]){a[0].scrollIntoView({behavior:"smooth"}),$(".tab-content .active").removeClass("active"),$(".nav-tabs li.active").removeClass("active");let c=$('[name="'+i+'"').closest(".tab-pane");c.addClass("active"),$('a[href="#'+c.attr("id")+'"]').closest("li").addClass("active")}}M.prop("disabled",!1).find("i.fa-spin").hide().parent().find("span").show(),$('#entity-creator-form [name="action"]').val("")})}))}function Ue(){$("#entity-creator-back").click(function(e){e.preventDefault(),Ke(),$.ajax({url:$(this).data("url"),context:this}).done(function(t){$(this).data("target"),O.html(t).show(),ce.hide(),V()})})}function pe(){$(".qq-mode-toggle").unbind("click").on("click",function(e){e.preventDefault(),!$(this).hasClass("active")&&($(".qq-mode-toggle").removeClass("active"),$(this).addClass("active"),$(".quick-creator-body").hide(),$(".quick-creator-footer").hide(),$(".quick-creator-loading").show(),$.ajax({url:$(this).data("url")}).done(function(t){O.html(t).show(),de(),$(document).trigger("shown.bs.modal")}))}),$(".qq-action-more").unbind("click").on("click",function(e){e.preventDefault(),$(this).hide(),$(".qq-more-fields").show()}),V()}function de(){pe(),Oe(),Ue(),me()}var D,A,Tt=new IntersectionObserver(function(e){e[0].isIntersecting===!0&&fe($(".datagrid-onload"))},{threshold:[0]});$(document).ready(function(){Ve(),ue(),K(),qt(),$(document).on("shown.bs.modal",function(){ue(),ge()})});function ue(){$("[data-bulk-action]").unbind("click").on("click",function(){Dt($(this).data("bulk-action"))}),$(".bulk-print").unbind("click").on("click",function(e){e.preventDefault();let t=$(this).closest("form");t.find(),t.submit()})}function Ve(){var e=$("#datagrid-select-all");e.length>0&&e.unbind("click").click(function(){$(this).prop("checked")?$.each($("input[name='model[]']"),function(){$(this).prop("checked",!0)}):$.each($("input[name='model[]']"),function(){$(this).prop("checked",!1)}),K()}),$.each($("input[name='model[]']"),function(){$(this).change(function(t){K(),t.preventDefault()})})}function Dt(e){var t=[];$.each($("input[name='model[]']"),function(){$(this).prop("checked")&&t.push($(this).val())}),e==="ajax"?$(document).on("shown.bs.modal",function(){$("#primary-dialog").find('input[name="models"]').val(t.toString())}):$("#datagrid-bulk-"+e+"-models").val(t.toString())}function K(){var e=!0;$.each($("input[name='model[]']"),function(){$(this).prop("checked")&&(e=!1)}),e?$(".datagrid-bulk-actions .btn2").prop("disabled",!0).addClass("btn-disabled"):$(".datagrid-bulk-actions .btn2").prop("disabled",!1).removeClass("btn-disabled").removeClass("disabled")}function qt(){ge(),We(),Et(),K()}function ge(){$(".datagrid-bulk").unbind("click").click(function(e){e.preventDefault(),D=$(this).closest("form");let t=[];$.each($("input[name='model[]']"),function(){$(this).prop("checked")&&t.push($(this).val())}),$.ajax({url:D.attr("action")+"?action=edit",method:"POST",data:{model:t}}).done(function(n){let s=document.getElementById("primary-dialog");s.innerHTML=n,s.show()})}),$(".datagrid-submit").click(function(e){if(e.preventDefault(),D=$(this).closest("form"),D.find('input[name="action"]').val($(this).data("action")),$(this).data("action")==="delete")return window.openDialog("datagrid-bulk-delete"),!1;$(".datagrid-bulk-actions").hide(),$(".datagrid-spinner").show(),D.submit()}),$("#datagrid-action-confirm").click(function(){window.closeDialog("datagrid-bulk-delete"),D.submit()})}function We(){$.each($('table[data-render="datagrid2"]'),function(){A=$(this),$(this).find("thead a").click(function(e){e.preventDefault(),fe($(this))}),$(this).closest("#datagrid-parent").find('nav[role="navigation"] a').click(function(e){e.preventDefault(),fe($(this))})}),Ve(),ue(),ge()}function Et(){$(".datagrid-onload").length!=0&&Tt.observe(document.querySelector(".datagrid-onload"))}function fe(e){A.find("thead").hide(),A.find("tbody").hide(),A.find("tfoot").show();let t=e.attr("href"),n=e.data("url");t==="#"&&n&&(t=n);let s=e.data("target")??"#datagrid-parent";$.ajax(t).done(function(i){i.html&&$(s).html(i.html),i.deletes&&$("#datagrid-delete-forms").html(i.deletes),i.url&&window.history.pushState({},"",i.url),We(),$(document).trigger("shown.bs.modal")}).fail(function(i){console.error("datagrid2",i),A.find("tfoot").addClass("bg-danger")})}const Ge=()=>{document.querySelectorAll('[data-animate="collapse"]').forEach(t=>{t.addEventListener("click",Mt)})};function Mt(e){let t=this.dataset.target;t||(t=this.hash),document.querySelectorAll(t).forEach(s=>{s.classList.toggle("hidden")}),this.classList.toggle("animate-collapsed")}$(document).on("shown.bs.modal",function(){Ge()});Ge();$(document).ready(function(){It(),At()});function It(){let e=$("#bookmark-selector");if(e.length===0)return!1;e.change(function(t){t.preventDefault();let n=$(this).find(":selected");$(".bookmark-subform").addClass("hidden");let s=n.data("target");$(s).removeClass("hidden")})}function At(){let e=$("#entity-selector");if(e.length===0)return!1;e.val()!=""&&$("#filter-subform").show(),e.change(function(){e.val()==""?($("#filter-subform").hide(),console.log(e.val())):$("#filter-subform").show()})}$(document).ready(function(){Pt()});function Pt(){let e=$("#post-layout-selector");e.length!==0&&e.change(function(t){t.preventDefault(),$(this).find(":selected").val()===""?($("#field-entry").show(),$("#field-location").show(),$("#field-display").show(),$("#post-layout-subform").hide()):($("#field-entry").hide(),$("#field-location").hide(),$("#field-display").hide(),$("#post-layout-subform").show())})}$(document).ready(function(){$(document).on("shown.bs.modal shown.bs.popover",function(){$e()}),$(".form-members").count!==0&&$e()});function $e(){$.each($(".form-members"),function(){let e=$(this);if(e.data("loaded")===1)return;e.data("loaded",1);let t=e.data("allow-clear");e.select2({tags:!0,allowClear:t||!0,minimumInputLength:0,ajax:{quietMillis:500,delay:500,url:e.data("url"),dataType:"json",data:function(n){return{q:$.trim(n.term)}},processResults:function(n){return{results:n}},cache:!0},createTag:function(){}})})}$(document).ready(function(){Qt(),zt(),Ft(),Ht(),Nt(),Rt(),Ot(),Kt()});function Qt(){$.each($(".form-rpg-systems"),function(){$(this).select2({multiple:!0,allowClear:!0,minimumInputLength:0})})}function zt(){$("#campaign-modules").length!==0&&$('input[name="enabled"]').change(function(e){e.preventDefault();let t=$(this).closest(".box-module").find("h3");t.hasClass("loading")||(t.addClass("loading"),axios.post($(this).data("url")).then(n=>{let s=$(this);s.closest(".box-module").find("h3").removeClass("loading"),n.data.success&&(n.data.status?s.closest(".box-module").addClass("module-enabled"):s.closest(".box-module").removeClass("module-enabled"),window.showToast(n.data.toast))}))})}function Ft(){$(".btn-user-roles").popover({html:!0,sanitize:!1,trigger:"focus"})}function Rt(){document.querySelectorAll(".public-permission").forEach(t=>{t.addEventListener("click",Bt)})}function Bt(e){e.preventDefault(),this.classList.add("loading"),axios.post(this.dataset.url).then(t=>{this.classList.remove("loading"),t.data.success&&(t.data.status?$(this).addClass("enabled"):$(this).removeClass("enabled"),window.showToast(t.data.toast))})}function Ht(){$.each($(".codemirror"),function(){let e=$(this).attr("id");CodeMirror.fromTextArea(document.getElementById(e),{extraKeys:{"Ctrl-Space":"autocomplete"},lineNumbers:!0,lineWrapping:!0,theme:"dracula"})})}function Nt(){let e=[].slice.call(document.querySelectorAll(".nested-sortable"));for(let t=0;t0;return!(i.classList.contains("fixed-position")&&c)}})}function Ot(){let e=$("form#campaign-style");e.length!==0&&e.on("submit",function(t){let n=$($(this).data("error"));return $('textarea[name="content"]').val().length<$(this).data("max-content")?(n.hide(),!0):(n.show(),$("form .submit-group .btn").prop("disabled",!1),!1)})}function Kt(){$('input[name="vanity"]').focusout(function(e){let t=$(this).val(),n=$("#vanity-error"),s=$("#vanity-success"),i=$("#vanity-loading");if(n.html("").hide(),s.hide(),!t)return;i.show();let a={};a.vanity=t,$.post({url:$(this).data("url"),method:"POST",context:this,data:a}).done(function(c){$(this).val(c.vanity),s.find("code").html(c.vanity),s.show(),n.hide(),i.hide()}).fail(function(c){let u="";c.responseJSON.errors.vanity.forEach(m=>u+=m+" "),n.html(u).show(),s.hide(),i.hide()})})}const Je=()=>{document.querySelectorAll("[data-clipboard]").forEach(t=>{t.addEventListener("click",Ut,!1)})};function Ut(e){e.preventDefault(),Vt(this.dataset.clipboard,this);let t=this.dataset.toast;return t&&window.showToast(t),!1}async function Vt(e,t){if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(e);else{const n=document.createElement("textarea");n.value=e,n.style.position="absolute",n.style.left="-999999px",t.append(n),n.select();try{document.execCommand("copy")}catch(s){console.error(s)}finally{n.remove()}}}Je();$(document).on("shown.bs.modal",function(e){Je()});$(document).ready(function(){Ye()});function Ye(){$('.toast-container [data-toggle="dismiss"]').unbind("click").on("click",function(e){e.preventDefault();let t=$(this).closest(".toast-message");t.removeClass("opacity-100").addClass("opacity-0"),setTimeout(function(){t.remove()},150)})}window.showToast=function(e,t){t=t||"bg-success text-success-content",t==="error"&&(t="bg-error text-error-content");let n=$('
');n.html('
'+e+'this.options.collapseScreenSize?e("body").removeClass(i.collapsed).trigger(e.Event(a.expanded)):e("body").addClass(i.open).trigger(e.Event(a.expanded))},c.prototype.close=function(){var f=e(window).width();f>this.options.collapseScreenSize?e("body").addClass(i.collapsed).trigger(e.Event(a.collapsed)):e("body").removeClass(i.open+" "+i.collapsed).trigger(e.Event(a.collapsed))},c.prototype.expandOnHover=function(){e(s.mainSidebar).hover(function(){e("body").is(s.mini+s.collapsed)&&e(window).width()>this.options.collapseScreenSize&&this.expand()}.bind(this),function(){e("body").is(s.expanded)&&this.collapse()}.bind(this))},c.prototype.expand=function(){setTimeout(function(){e("body").removeClass(i.collapsed).addClass(i.expanded)},this.options.expandTransitionDelay)},c.prototype.collapse=function(){setTimeout(function(){e("body").removeClass(i.expanded).addClass(i.collapsed)},this.options.expandTransitionDelay)};function u(f){return this.each(function(){var _=e(this),p=_.data(t);if(!p){var st=e.extend({},n,_.data(),typeof f=="object"&&f);_.data(t,p=new c(st))}f==="toggle"&&p.toggle()})}var m=window.$.fn.pushMenu;window.$.fn.pushMenu=u,window.$.fn.pushMenu.Constructor=c,window.$.fn.pushMenu.noConflict=function(){return window.$.fn.pushMenu=m,this},window.$(document).on("click",s.button,function(f){f.preventDefault(),u.call(window.$(this),"toggle")}),window.$(window).on("load",function(){u.call(window.$(s.button))})}(jQuery);const Wt=()=>{document.querySelectorAll(".banner-notification-dismiss").forEach(e=>{e.addEventListener("click",Gt,!1)}),document.querySelectorAll('[data-dismiss="tutorial"]').forEach(e=>{e.addEventListener("click",Jt,!1)})};function Gt(e){e.preventDefault();let t=this.dataset.dismiss;axios.post(this.dataset.url).then(()=>{if(!t)return;let n=document.querySelector(t);n&&n.classList.add("hidden")})}function Jt(e){e.preventDefault();let t=this.dataset.target;axios.post(this.dataset.url).then(()=>{if(!t)return;let n=document.querySelector(t);n&&n.classList.add("hidden")})}Wt();let Xe;$(document).ready(function(){Yt()});function Yt(){let e=$("#element-era-id");e.length!==0&&(Xe=e.val(),e.length===1&&e.on("change",function(){Xt(e.val())}))}function Xt(e){e=parseInt(e);let t=$('input[name="era-data-url"]').data("url").replace("/0/","/"+e+"/"),n=$('input[name="oldPosition"]').data("url");$.ajax(t).done(function(s){let i=$('select[name="position"]');i.html("");let a=1;$.each(s.positions,function(c){let u=s.positions[c],m=' selected="selected"';n&&!c&&Xe==e&&i.append('"),c&&i.append('"),a++})})}window.initSortable=function(){let e=document.querySelectorAll(".sortable-elements");e.length!==0&&e.forEach(t=>{let n={},s=t.dataset.handle;s&&(n.handle=s),Me.create(t,n)})};window.initSortable();window.formErrorHandler=function(e,t){if($(".input-error").removeClass("input-error"),$(".text-error").remove(),$(t).find(".btn-primary").prop("disabled",!1).removeClass("loading"),e.status===503){window.showToast(e.responseJSON.message,"error");return}if(e.status===403){$("#entity-form-403-error").show();return}let n=e.responseJSON.errors,s=[],i=Object.keys(n),a=!0;if(i.forEach(function(f){let _=$('[name="'+f+'"]');_.length>0?_.addClass("input-error").parent().append('
'+n[f][0]+"
"):(a=!1,s.push(n[f][0])),window.showToast(n[f][0],"error")}),!a){let f=$("#entity-form-generic-error .error-logs");f.html(""),s.forEach(function(_){let p=_+"
";f.append(p)}),$("#entity-form-generic-error").show()}if($(t).find(".tab-content").length===0)return;let c=Object.keys(n)[0],u=document.getElementsByName(c);if(!u[0])return;$(".tab-content .active").removeClass("active"),$(".nav-tabs li.active").removeClass("active");let m=$('[name="'+c+'"').closest(".tab-pane");m.addClass("active"),$('a[href="#'+m.attr("id")+'"]').closest("li").addClass("active"),u[0].scrollIntoView({behavior:"smooth"})};const Y=document.getElementById("dialog-backdrop");let X;const Zt=()=>{document.querySelectorAll('[data-toggle="dialog"]').forEach(e=>{e.addEventListener("click",Ce)}),document.querySelectorAll('[data-toggle="dialog-ajax"]').forEach(e=>{e.addEventListener("click",Ce)})};function Ce(e){e.preventDefault();let t=this.dataset.target;if(!t)return;let n=this.dataset.url;Ze(t,n)}const Ze=(e,t)=>{e=document.getElementById(e),e.removeAttribute("open"),e.show(),Y.classList.remove("hidden"),e.dataset.dismissible!=="false"&&Y.addEventListener("click",function(n){e.close()}),e.addEventListener("click",function(n){let s=e.getBoundingClientRect();!(s.top<=n.clientY&&n.clientY<=s.top+s.height&&s.left<=n.clientX&&n.clientX<=s.left+s.width)&&n.target.tagName==="DIALOG"&&e.close()}),e.addEventListener("close",function(n){Y.classList.add("hidden")}),t&&en(t,e)},en=(e,t)=>{X?t.innerHTML=X:X=t.innerHTML,fetch(e,{headers:{"X-Requested-With":"XMLHttpRequest"}}).then(n=>n.text()).then(n=>{t.innerHTML=n,t.show(),$(document).trigger("shown.bs.modal"),$(".btn-manage-perm").click(function(s){s.preventDefault(),t.close();let i=$(this).data("target");$(i).click()})})},tn=e=>{document.getElementById(e).close()};window.initDialogs=Zt;window.openDialog=Ze;window.closeDialog=tn;const nn={props:{text:String,title:String}},sn={class:"mx-5"},on=["data-title"],an=o("i",{class:"fa-solid fa-chevrons-left","aria-hidden":"true","data-sidebar":"collapse"},null,-1),rn=o("i",{class:"fa-solid fa-chevrons-right","aria-hidden":"true","data-sidebar":"expand"},null,-1),ln={class:"sr-only"};function cn(e,t,n,s,i,a){return r(),l("div",sn,[o("span",{role:"button",class:"sidebar-toggle text-center cursor-pointer","data-toggle":"tooltip","data-title":n.title,"data-placement":"right","data-html":"true",tabindex:"3"},[an,rn,o("span",ln,d(n.text),1)],8,on)])}const dn=S(nn,[["render",cn]]),un={props:["entity"],methods:{backgroundImage:function(e){return"url('"+e.image+"')"},preview:function(e){this.emitter.emit("preview",e)}}},fn=["data-id"],hn={class:"flex-none"},mn=["href","title"],pn={class:"flex-grow truncate pl-1"},gn=["title"],vn={class:"entity-type text-xs"};function _n(e,t,n,s,i,a){return r(),l("div",{class:"flex justify-center gap-1 cursor-pointer hover:bg-base-200 rounded w-full","data-id":n.entity.id,onClick:t[1]||(t[1]=c=>a.preview(n.entity))},[o("div",hn,[o("a",{href:n.entity.link,style:E({backgroundImage:a.backgroundImage(n.entity)}),onClick:t[0]||(t[0]=te(()=>{},["stop"])),title:n.entity.name,class:"rounded cover-background block h-16 w-16"},null,12,mn)]),o("div",pn,[o("div",{class:"font-extrabold entity-name truncate",title:n.entity.name},d(n.entity.name),9,gn),o("div",vn,d(n.entity.type),1)])],8,fn)}const et=S(un,[["render",_n]]),yn={props:["entity"],components:{LookupEntity:et},data(){return{focus_profile:!0,focus_pins:!1,focus_access:!1}},methods:{hasTitle(){return this.entity.title},tagClass(e){let t="inline-block rounded-xl px-3 py-1 bg-base-100 text-base-content text-xs";return e.colour&&(t+=" bg-"+e.colour,e.colour==="black"&&(t+=" text-white")),t},backgroundImage:function(){return"url('"+this.entity.image+"')"},tabClass:function(e){let t="p-1 px-1 mx-1 pt-2 select-none text-center truncate border-b-2 border-solid border-r-0 border-t-0 border-l-0";return e==="profile"&&this.focus_profile||e==="links"&&this.focus_pins||e==="access"&&this.focus_access?t+=" font-black border-slate-600":t+=" cursor-pointer border-base-100",t},switchTab:function(e){this.focus_profile=!1,this.focus_pins=!1,this.focus_access=!1,e==="profile"?this.focus_profile=!0:e==="links"?this.focus_pins=!0:e==="access"&&(this.focus_access=!0)},profileClass:function(e){return"entity-profile-"+e.slug}}},wn={class:"entity-header p-3 bg-entity-focus"},bn={class:"w-full flex items-center"},xn=["href","title"],kn={key:0,class:"fa-solid fa-skull mx-2","aria-hidden":"true"},$n=["href"],Cn=o("i",{class:"fa-solid fa-external-link","aria-hidden":"true","aria-label":"Open in a new window"},null,-1),Sn=[Cn],Ln={key:0,class:"block w-full"},jn={key:1,class:"my-1 w-full flex flex-wrap gap-1"},Tn=["href"],Dn=["href","data-tag"],qn=o("i",{class:"fa-duotone circle-location-arrow","aria-hidden":"true","aria-label":"Location"},null,-1),En=["href","title"],Mn={class:"entity-sections"},In={class:"tabs flex my-2 justify-center items-center border-solid border-slate-600 border-b-2 border-r-0 border-t-0 border-l-0"},An={key:0,class:"tab-profile p-5 flex flex-col gap-5"},Pn={key:0,class:"entity-pinned-attributes flex flex-col gap-3"},Qn=["data-attribute","data-target"],zn={class:"inline-block uppercase font-extrabold mr-1"},Fn=["innerHTML"],Rn={key:1},Bn={class:"flex flex-col gap-3"},Hn={class:"uppercase font-extrabold truncate"},Nn={key:1,class:"tab-links p-3"},On={key:0,class:"text-center italic"};function Kn(e,t,n,s,i,a){const c=j("LookupEntity");return r(),l(v,null,[o("div",wn,[o("div",bn,[o("a",{class:"text-2xl font-extrabold entity-name",href:n.entity.link,title:n.entity.name},d(n.entity.name),9,xn),n.entity.is_dead?(r(),l("i",kn)):h("",!0),o("a",{class:"ml-2 text-xs",target:"_blank",href:n.entity.link},Sn,8,$n)]),a.hasTitle()?(r(),l("div",Ln,d(n.entity.title),1)):h("",!0),n.entity.tags.length>0?(r(),l("div",jn,[(r(!0),l(v,null,b(n.entity.tags,u=>(r(),l("a",{class:g(a.tagClass(u)),href:u.link},d(u.name),11,Tn))),256))])):h("",!0),n.entity.location?(r(),l("a",{key:2,class:"block w-full cursor-pointer my-2",href:n.entity.location.link,"data-tag":n.entity.id},[qn,y(" "+d(n.entity.location.name),1)],8,Dn)):h("",!0),n.entity.image?(r(),l("a",{key:3,href:n.entity.link,style:E({backgroundImage:a.backgroundImage()}),title:n.entity.name,class:"rounded cover-background block w-full aspect-square"},null,12,En)):h("",!0)]),o("div",Mn,[o("div",In,[o("div",{class:g(a.tabClass("profile")),onClick:t[0]||(t[0]=u=>a.switchTab("profile"))},d(n.entity.texts.profile),3),o("div",{class:g(a.tabClass("links")),onClick:t[1]||(t[1]=u=>a.switchTab("links"))},d(n.entity.texts.connections),3),o("div",{class:g(a.tabClass("access")),onClick:t[2]||(t[2]=u=>a.switchTab("access"))},null,2)]),i.focus_profile?(r(),l("div",An,[n.entity.attributes.length>0?(r(),l("div",Pn,[(r(!0),l(v,null,b(n.entity.attributes,u=>(r(),l("div",{class:"","data-attribute":u.name,"data-target":u.id},[o("span",zn,d(u.name),1),o("span",{innerHTML:u.value},null,8,Fn)],8,Qn))),256))])):h("",!0),n.entity.attributes.length>0?(r(),l("hr",Rn)):h("",!0),o("div",Bn,[(r(!0),l(v,null,b(n.entity.profile,u=>(r(),l("div",{class:g(["",a.profileClass(u)])},[o("div",Hn,d(u.field),1),o("div",null,d(u.value),1)],2))),256))])])):h("",!0),i.focus_pins?(r(),l("div",Nn,[(r(!0),l(v,null,b(n.entity.connections,u=>(r(),L(c,{entity:u},null,8,["entity"]))),256)),n.entity.connections.length===0?(r(),l("p",On,d(n.entity.texts["no-connections"]),1)):h("",!0)])):h("",!0)])],64)}const Un=S(yn,[["render",Kn]]),Vn={directives:{clickOutside:Ae.directive},props:{api_lookup:String,api_recent:String,placeholder:String,keyboard_tooltip:String},components:{LookupEntity:et,EntityPreview:Un},data(){return{has_drawer:!1,term:null,show_loading:!1,show_recent:!1,show_preview:!1,show_results:!1,show_bookmarks:!1,recent:[],bookmarks:[],indexes:[],results:[],cached:{},has_recent:!1,texts:{},timeout_id:null,preview_entity:null}},watch:{term(e,t){this.termChanged()}},methods:{termChanged(){this.term.trim().length<3||(this.timeout_id!==void 0&&clearTimeout(this.timeout_id),this.show_loading=!0,this.timeout_id=setTimeout(()=>this.lookup(),500))},lookup(){let e=this.term.trim(),t=e.toLowerCase().replace(/ /g,"-").replace(/ [^\w-]+/g,"");if(this.cached[t])return this.displayCached(t);fetch(this.api_lookup+"?"+new URLSearchParams({q:e,v2:!0})).then(n=>n.json()).then(n=>this.parseLookupResponse(n,t))},focus(){this.api_recent&&(this.show_preview=!1,this.has_drawer=!0,this.fetch())},escape(){this.timeout_id!==void 0&&clearTimeout(this.timeout_id),this.close()},fetch(){if(this.has_recent){this.show_recent=!0;return}this.show_loading=!0,fetch(this.api_recent).then(e=>e.json()).then(e=>{this.recent=e.recent,this.bookmarks=e.bookmarks,this.indexes=e.indexes,this.texts.recents=e.texts.recents,this.texts.results=e.texts.results,this.texts.hint=e.texts.hint,this.texts.bookmarks=e.texts.bookmarks,this.texts.index=e.texts.index,this.texts.keyboard=e.texts.keyboard,this.texts.empty_results=e.texts.empty_results,this.show_loading=!1,this.show_recent=!0,this.has_recent=!0,this.bookmarks.length>0?this.show_bookmarks=!0:this.show_bookmarks=!1}).catch(e=>{this.show_loading=!1,this.show_recent=!0,this.has_recent=!1})},parseLookupResponse(e,t){this.results=e.entities,this.cached[t]=e.entities,this.showResults()},displayCached(e){this.results=this.cached[e],this.showResults()},showResults(){this.timeout_id=null,this.show_preview=!1,this.show_loading=!1,this.show_results=!0},loadPreview(e){this.show_loading=!0,fetch(e.preview).then(t=>t.json()).then(t=>this.parsePreviewResponse(t))},parsePreviewResponse(e){this.preview_entity=e,this.show_loading=!1,this.show_preview=!0,this.show_recent=!1},onClickOutside(e){this.close()},close(){this.show_recent=!1,this.show_loading=!1,this.show_preview=!1,this.$refs.searchField.blur()},showBookmarks(){this.show_bookmarks=!0},showIndexes(){this.show_bookmarks=!1},modeClass(e){return e&&this.show_bookmarks||!e&&!this.show_bookmarks?" underline":""}},mounted(){this.emitter.on("preview",e=>{this.loadPreview(e)})}},Wn={class:"flex grow mr-2"},Gn={class:"relative grow field flex items-center"},Jn=["placeholder"],Yn={class:"absolute right-1 hidden md:inline"},Xn=["data-title"],Zn={key:0,class:"search-drawer absolute top-0 left-0 mt-12 h-sidebar w-sidebar bg-navbar bg-base-100 shadow-r overflow-y-auto"},ei={key:0,class:"text-center"},ti=o("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true","aria-label":"Loading"},null,-1),ni=[ti],ii={key:1,class:"search-recent bg-lookup p-2 min-h-full shadow-r flex flex-col items-stretch"},si={key:0,class:"flex-none"},oi={class:"italic text-xs text-center"},ai={class:"grow flex flex-col gap-5 p-2"},ri={key:0,class:"search-results flex flex-col gap-2"},li={class:"text-sm uppercase"},ci={key:0,class:"text-neutral-content text-sm"},di={key:1,class:"recent-searches flex flex-col gap-2"},ui={class:"text-sm uppercase"},fi={key:2,class:"flex gap-5 justify-center"},hi={key:3,class:"flex flex-col gap-4"},mi=["href","title"],pi={key:4,class:"flex flex-col gap-4"},gi=["href","title"],vi={key:1,class:"flex-none text-xs text-center"},_i=o("hr",null,null,-1),yi=["innerHTML"],wi={key:2,class:"search-preview bg-lookup min-h-full shadow-r"};function bi(e,t,n,s,i,a){const c=j("LookupEntity"),u=j("EntityPreview"),m=Ie("click-outside");return ne((r(),l("div",Wn,[o("div",Gn,[ne(o("input",{type:"text",class:"leading-4 w-20 md:w-full",maxlength:"25",ref:"searchField",id:"entity-lookup","onUpdate:modelValue":t[0]||(t[0]=f=>i.term=f),onClick:t[1]||(t[1]=f=>a.focus()),onFocus:t[2]||(t[2]=f=>a.focus()),onKeydown:t[3]||(t[3]=at(f=>a.escape(),["esc"])),placeholder:n.placeholder},null,40,Jn),[[rt,i.term]]),o("span",Yn,[o("span",{class:"flex-none keyboard-shortcut py-1",id:"lookup-kb-shortcut","data-toggle":"tooltip","data-title":n.keyboard_tooltip,"data-html":"true","data-placement":"bottom"}," K ",8,Xn)])]),i.show_recent||i.show_loading||i.show_preview?(r(),l("aside",Zn,[i.show_loading?(r(),l("div",ei,ni)):h("",!0),i.show_recent?(r(),l("div",ii,[i.show_results?h("",!0):(r(),l("div",si,[o("p",oi,d(i.texts.hint),1)])),o("div",ai,[i.show_results?(r(),l("div",ri,[o("div",li,d(i.texts.results),1),i.results.length===0?(r(),l("div",ci,d(i.texts.empty_results),1)):(r(!0),l(v,{key:1},b(i.results,f=>(r(),L(c,{entity:f},null,8,["entity"]))),256))])):h("",!0),i.recent.length>0?(r(),l("div",di,[o("div",ui,d(i.texts.recents),1),(r(!0),l(v,null,b(i.recent,f=>(r(),L(c,{entity:f},null,8,["entity"]))),256))])):h("",!0),i.bookmarks.length>0?(r(),l("div",fi,[i.bookmarks.length>0?(r(),l("button",{key:0,class:g(["grow text-sm uppercase hover:underline",this.modeClass(!0)]),onClick:t[4]||(t[4]=f=>a.showBookmarks())},d(i.texts.bookmarks),3)):h("",!0),o("button",{class:g(["grow text-sm uppercase hover:underline",this.modeClass(!1)]),onClick:t[5]||(t[5]=f=>a.showIndexes())},d(i.texts.index),3)])):h("",!0),i.show_bookmarks?(r(),l("div",hi,[(r(!0),l(v,null,b(i.bookmarks,f=>(r(),l("a",{href:f.url,onClick:t[6]||(t[6]=te(()=>{},["stop"])),title:f.text,class:"flex gap-2 items-center"},[o("i",{class:g(["w-4",f.icon]),"aria-hidden":"true"},null,2),y(" "+d(f.text),1)],8,mi))),256))])):(r(),l("div",pi,[(r(!0),l(v,null,b(i.indexes,f=>(r(),l("a",{href:f.url,onClick:t[7]||(t[7]=te(()=>{},["stop"])),title:f.name,class:"flex gap-2 items-center"},[o("i",{class:g(["w-4 text-center",f.icon]),"aria-hidden":"true"},null,2),y(" "+d(f.name),1)],8,gi))),256))]))]),i.show_loading?h("",!0):(r(),l("div",vi,[_i,o("p",{class:"italic text-xs text-center",innerHTML:i.texts.keyboard},null,8,yi)]))])):h("",!0),i.show_preview?(r(),l("div",wi,[F(u,{entity:i.preview_entity},null,8,["entity"])])):h("",!0)])):h("",!0)])),[[m,a.onClickOutside]])}const xi=S(Vn,[["render",bi]]),ki={props:["campaign"],methods:{backgroundImage:function(e){return e.image?"url("+e.image+")":""},campaignClass:function(e){return"campaign flex items-end border border-solid rounded-lg cover-background relative h-24 overflow-hidden text-break shadow-xs hover:shadow-md border-0"+(e.is_boosted?" boosted":"")}}},$i=["href","title"],Ci=["innerHTML"];function Si(e,t,n,s,i,a){return r(),l("a",{class:g(a.campaignClass(n.campaign)),href:n.campaign.url,style:E({backgroundImage:a.backgroundImage(n.campaign)}),title:n.campaign.name},[o("div",{class:"flex items-end justify-center name w-full text-xs p-2 pt-6 text-center",innerHTML:n.campaign.name},null,8,Ci)],14,$i)}const Li=S(ki,[["render",Si]]),ji={props:["notification"],data(){return{is_dismissed:!1,is_loading:!1}},methods:{backgroundClass:function(e){let t="notification bg-base-200 flex justify-center items-center p-2 rounded-md";return e.is_read?t:t+" unread"},iconClass:function(e){return"fa-solid fa-"+e.icon},dismiss:function(e){this.is_loading=!0,axios.post(e.dismiss).then(()=>{this.is_dismissed=!0,this.emitter.emit("read_notification",e)})}}},Ti=["data-id"],Di={class:"flex-none p-2"},qi=["innerHTML","href"],Ei=["title"],Mi=o("i",{class:"fa-solid fa-times","aria-hidden":"true"},null,-1),Ii=[Mi],Ai={key:1,class:"flex-none p-2"},Pi=o("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),Qi=[Pi],zi=["data-id"],Fi={class:"flex-none p-2"},Ri=["innerHTML"],Bi=["title"],Hi=o("i",{class:"fa-solid fa-times","aria-hidden":"true"},null,-1),Ni=[Hi],Oi={key:1,class:"flex-none p-2"},Ki=o("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),Ui=[Ki];function Vi(e,t,n,s,i,a){return n.notification.url&&!i.is_dismissed?(r(),l("div",{key:0,class:g(a.backgroundClass(n.notification)),"data-id":n.notification.id},[o("div",Di,[o("i",{class:g(a.iconClass(n.notification)),"aria-hidden":"true"},null,2)]),o("a",{class:"flex-grow p-2 break-all",innerHTML:n.notification.text,href:n.notification.url},null,8,qi),this.is_loading?(r(),l("div",Ai,Qi)):(r(),l("div",{key:0,class:"flex-none p-2 cursor-pointer dismissable",onClick:t[0]||(t[0]=c=>a.dismiss(n.notification)),title:n.notification.dismiss_text},Ii,8,Ei))],10,Ti)):i.is_dismissed?h("",!0):(r(),l("div",{key:1,class:g(a.backgroundClass(n.notification)),"data-id":n.notification.id},[o("div",Fi,[o("i",{class:g(a.iconClass(n.notification)),"aria-hidden":"true"},null,2)]),o("div",{class:"flex-grow p-2",innerHTML:n.notification.text},null,8,Ri),this.is_loading?(r(),l("div",Oi,Ui)):(r(),l("div",{key:0,class:"flex-none p-2 cursor-pointer dismissable",onClick:t[1]||(t[1]=c=>a.dismiss(n.notification)),title:n.notification.dismiss_text},Ni,8,Bi))],10,zi))}const Wi=S(ji,[["render",Vi]]),Gi={props:["release"],data(){return{is_dismissed:!1,is_loading:!1}},methods:{backgroundClass:function(e){return"release bg-base-200 flex justify-center items-center p-2 rounded-md"},dismiss:function(e){this.is_loading=!0,axios.post(e.dismiss).then(()=>{this.is_dismissed=!0,this.emitter.emit("read_release",e)})}}},Ji=["data-id"],Yi={class:"flex-grow p-2"},Xi=["innerHTML","href"],Zi=["innerHTML"],es=["title"],ts=o("i",{class:"fa-solid fa-times","aria-hidden":"true"},null,-1),ns=[ts],is={key:1,class:"flex-none p-2"},ss=o("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),os=[ss];function as(e,t,n,s,i,a){return i.is_dismissed?h("",!0):(r(),l("div",{key:0,class:g(a.backgroundClass(n.release)),"data-id":n.release.id},[o("div",Yi,[o("a",{innerHTML:n.release.title,class:"font-bold cursor-pointer block w-full",href:n.release.url,target:"_blank"},null,8,Xi),o("p",{innerHTML:n.release.text},null,8,Zi)]),this.is_loading?(r(),l("div",is,os)):(r(),l("div",{key:0,class:"flex-none p-2 cursor-pointer dismissable",onClick:t[0]||(t[0]=c=>a.dismiss(n.release)),title:n.release.dismiss_text},ns,8,es))],10,Ji))}const rs=S(Gi,[["render",as]]),ls=o("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[o("g",{transform:"translate(-219.000000, -200.000000)",fill:"currentcolor"},[o("g",{id:"icons",transform:"translate(56.000000, 160.000000)"},[o("path",{d:"M181.9,54 L179.8,54 C178.63975,54 177.7,54.895 177.7,56 L177.7,58 C177.7,59.105 178.63975,60 179.8,60 L181.9,60 C183.06025,60 184,59.105 184,58 L184,56 C184,54.895 183.06025,54 181.9,54 M174.55,54 L172.45,54 C171.28975,54 170.35,54.895 170.35,56 L170.35,58 C170.35,59.105 171.28975,60 172.45,60 L174.55,60 C175.71025,60 176.65,59.105 176.65,58 L176.65,56 C176.65,54.895 175.71025,54 174.55,54 M167.2,54 L165.1,54 C163.93975,54 163,54.895 163,56 L163,58 C163,59.105 163.93975,60 165.1,60 L167.2,60 C168.36025,60 169.3,59.105 169.3,58 L169.3,56 C169.3,54.895 168.36025,54 167.2,54 M181.9,47 L179.8,47 C178.63975,47 177.7,47.895 177.7,49 L177.7,51 C177.7,52.105 178.63975,53 179.8,53 L181.9,53 C183.06025,53 184,52.105 184,51 L184,49 C184,47.895 183.06025,47 181.9,47 M174.55,47 L172.45,47 C171.28975,47 170.35,47.895 170.35,49 L170.35,51 C170.35,52.105 171.28975,53 172.45,53 L174.55,53 C175.71025,53 176.65,52.105 176.65,51 L176.65,49 C176.65,47.895 175.71025,47 174.55,47 M167.2,47 L165.1,47 C163.93975,47 163,47.895 163,49 L163,51 C163,52.105 163.93975,53 165.1,53 L167.2,53 C168.36025,53 169.3,52.105 169.3,51 L169.3,49 C169.3,47.895 168.36025,47 167.2,47 M181.9,40 L179.8,40 C178.63975,40 177.7,40.895 177.7,42 L177.7,44 C177.7,45.105 178.63975,46 179.8,46 L181.9,46 C183.06025,46 184,45.105 184,44 L184,42 C184,40.895 183.06025,40 181.9,40 M174.55,40 L172.45,40 C171.28975,40 170.35,40.895 170.35,42 L170.35,44 C170.35,45.105 171.28975,46 172.45,46 L174.55,46 C175.71025,46 176.65,45.105 176.65,44 L176.65,42 C176.65,40.895 175.71025,40 174.55,40 M169.3,42 L169.3,44 C169.3,45.105 168.36025,46 167.2,46 L165.1,46 C163.93975,46 163,45.105 163,44 L163,42 C163,40.895 163.93975,40 165.1,40 L167.2,40 C168.36025,40 169.3,40.895 169.3,42"})])])],-1),cs=[ls],ds={__name:"GridSvg",props:{size:Number},setup(e){const t=e;function n(){return"w-"+t.size+" h-"+t.size}return(s,i)=>(r(),l("svg",{class:g(n()),viewBox:"0 -0.5 21 21",version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true"},cs,2))}},us={directives:{clickOutside:Ae.directive},props:{user_id:{type:String},api:{type:String},fetch:{type:String},initials:{type:String},avatar:{type:String},campaign_id:void 0,has_alerts:{type:Boolean}},components:{GridSvg:ds,Campaign:Li,Notification:Wi,Release:rs},data(){return{alert_delta:60*1e3,is_loading:!1,is_expanded:!1,has_data:!1,view_campaigns:!1,view_profile:!1,profile:{},campaigns:{},notifications:{},marketplace:{},releases:{},show_alerts:!1,is_loaded:!1}},methods:{openCampaigns:function(){this.view_campaigns=!0,this.view_profile=!1,this.loadData()},openProfile:function(){this.view_profile=!0,this.view_campaigns=!1,this.loadData()},loadData:function(){this.is_expanded=!0,!this.has_data&&(this.is_loading=!0,fetch(this.api).then(e=>e.json()).then(e=>{this.profile=e.profile,this.campaigns=e.campaigns,this.notifications=e.notifications,this.marketplace=e.marketplace,this.releases=e.releases,this.show_alerts=e.has_unread,this.has_data=!0,this.is_loading=!1,this.is_loaded=!0}))},blockClass:function(e){return e?"block p-4 flex-grow items-center focus:box-shadow":"block p-4 items-center bg-base-200 cursor-pointer flex-none focus:box-shadow"},logout:function(){document.getElementById("logout-form").submit()},onClickOutside(e){this.is_expanded=!1},readRelease:function(e){let t=this.releases.releases.findIndex(n=>n.id===e.id);this.releases.releases.slice(t,1),this.updateUnread()},readNotification:function(e){let t=this.notifications.messages.findIndex(n=>n.id==e.id);this.notifications.messages.slice(t,1),this.updateUnread()},updateUnread:function(){this.notifications.messages.length===0&&this.releases.releases.length===0&&(this.show_alerts=!1)},updateAlerts:function(){let e=localStorage.getItem("last_notification-"+this.user_id),n=new Date().getTime()-60*5e3;if(!e||et.json()).then(t=>{localStorage.setItem("notification-has-alerts-"+this.user_id,t.has_alerts),this.updateAlerts()})},queueFetch:function(){let e=this;setTimeout(function(){e.updateAlerts()}.bind(this),this.alert_delta)},showInitials:function(){return this.avatar.startsWith("/images/")},profilePictureUrl:function(){return"url("+this.avatar+")"}},mounted(){this.emitter.on("read_release",e=>{this.readRelease(e)}),this.emitter.on("read_notification",e=>{this.readNotification(e)}),this.show_alerts=this.has_alerts,this.queueFetch()}},fs={class:"nav-switcher flex items-center justify-center h-12"},hs=o("span",{class:"sr-only"},"Campaigns",-1),ms={class:"indicator relative inline-flex w-max"},ps={key:0,class:"notification-badge left-auto top-auto w-fit inline-flex absolute content-center items-center z-10"},gs={key:1,class:"profile-box rounded-lg p-2 text-center font-bold"},vs={key:0,class:"navigation-drawer bg-base-100 h-full overflow-y-auto fixed top-0 right-0 rounded-l-2xl shadow-lg"},_s={key:0,class:"temporary p-8 text-center"},ys=o("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),ws=[ys],bs={key:1,class:""},xs={class:"header flex"},ks={key:0,class:"full flex items-center gap-4"},$s={class:"flex-none"},Cs={class:"flex-grow"},Ss={class:"font-bold"},Ls=["title"],js={key:0,class:"full flex items-center gap-4"},Ts={key:0,class:"flex-none profile-box rounded-lg p-2 text-center uppercase font-bold"},Ds={class:"flex-grow"},qs={class:"font-bold"},Es=["title"],Ms={key:0,class:"flex-none profile-box rounded-lg p-2 text-center uppercase font-bold"},Is={key:0,class:"profile p-5 flex flex-col gap-5"},As={key:0,class:"notifications"},Ps={class:"flex w-full py-2"},Qs={class:"flex-grow uppercase font-bold"},zs={class:"flex-grow text-right"},Fs=["href"],Rs={class:"flex flex-col gap-2"},Bs={key:0,class:"no-notifications help-block text-neutral-content italic"},Hs={key:1,class:"releases"},Ns={class:"flex w-full py-2"},Os={class:"flex-grow uppercase font-bold"},Ks={class:"flex flex-col gap-2"},Us={key:2,class:"marketplace"},Vs={class:"flex w-full py-2"},Ws={class:"flex-grow uppercase font-bold"},Gs={class:"flex-grow text-right"},Js=["href"],Ys={class:"grid grid-cols-3 gap-2"},Xs=["href"],Zs=o("div",{class:"icon bg-base-200 rounded-full w-14 h-14 text-3xl aspect-square flex justify-center items-center"},[o("i",{class:"fa-solid fa-palette","aria-hidden":"true"})],-1),eo={class:"text-muted text-xs"},to=["href"],no=o("div",{class:"icon bg-base-200 rounded-full w-14 h-14 text-3xl aspect-square flex justify-center items-center"},[o("i",{class:"fa-solid fa-columns","aria-hidden":"true"})],-1),io={class:"text-muted text-xs"},so=["href"],oo=o("div",{class:"icon bg-base-200 rounded-full w-14 h-14 text-3xl aspect-square flex justify-center items-center"},[o("i",{class:"fa-solid fa-dice-d20","aria-hidden":"true"})],-1),ao={class:"text-muted text-xs"},ro={key:3,class:"subscription"},lo={class:"uppercase font-bold py-2"},co=["href"],uo={class:"flex-none p-2"},fo=["src","alt"],ho={class:"flex-grow p-2"},mo={class:"font-bold text-lg"},po={key:0,class:"more"},go=o("br",null,null,-1),vo={key:1,class:"more"},_o={class:"link flex gap-1 items-center"},yo=o("i",{class:"fa-duotone fa-credit-card","aria-hidden":"true"},null,-1),wo=o("i",{class:"fa-brands fa-paypal","aria-hidden":"true"},null,-1),bo={key:4,class:"m-0 p-0 list-none flex flex-col gap-2"},xo=["href"],ko=o("i",{class:"fa-solid fa-cog mr-3","aria-hidden":"true"},null,-1),$o=["href"],Co=o("i",{class:"fa-solid fa-user mr-3","aria-hidden":"true"},null,-1),So=["href"],Lo=o("i",{class:"fa-solid fa-question-circle mr-3","aria-hidden":"true"},null,-1),jo=o("i",{class:"fa-solid fa-sign-out mr-3","aria-hidden":"true"},null,-1),To={key:5,class:"m-0 p-0 list-none flex flex-col gap-2"},Do=["href"],qo=o("i",{class:"fa-solid fa-sign-out-alt mr-3","aria-hidden":"true"},null,-1),Eo={key:1,class:"campaigns p-5"},Mo={key:0,class:"campaigns flex flex-col gap-5"},Io={class:"flex flex-col gap-2"},Ao={class:"flex w-full"},Po={class:"flex-grow uppercase font-bold"},Qo={key:0,class:"flex-grow text-right"},zo=["href"],Fo={class:"grid grid-cols-2 md:grid-cols-3 gap-5"},Ro=["href"],Bo={class:"text-xs text-break uppercase"},Ho=o("i",{class:"fa-solid fa-plus","aria-hidden":"true",style:{display:"none"}},null,-1),No={key:0},Oo={class:"flex flex-col gap-2"},Ko={key:0,class:"uppercase"},Uo={key:1,class:"grid grid-cols-2 md:grid-cols-3 gap-5 following"},Vo=["href"],Wo={class:"text-xs uppercase text-break"};function Go(e,t,n,s,i,a){const c=j("GridSvg"),u=j("Notification"),m=j("Release"),f=j("Campaign"),_=Ie("click-outside");return r(),l(v,null,[o("div",fs,[o("div",{class:"campaigns inline cursor-pointer text-center px-3 text-2xl",onClick:t[0]||(t[0]=p=>a.openCampaigns()),"aria-label":"Switch campaigns",tabindex:"0",role:"button"},[F(c,{size:7}),hs]),o("div",{class:"profile inline cursor-pointer text-center uppercase pt-1",onClick:t[1]||(t[1]=p=>a.openProfile()),"aria-label":"Profile settings",tabindex:"0",role:"button"},[o("div",ms,[i.show_alerts?(r(),l("span",ps)):h("",!0),a.showInitials()?(r(),l("div",gs,d(n.initials),1)):(r(),l("div",{key:2,class:"w-9 h-9 rounded-lg cover-background",style:E({backgroundImage:a.profilePictureUrl()})},null,4))])])]),i.is_expanded?ne((r(),l("div",vs,[i.is_loading?(r(),l("div",_s,ws)):(r(),l("div",bs,[o("div",xs,[o("div",{class:g(a.blockClass(i.view_campaigns)),onClick:t[2]||(t[2]=p=>a.openCampaigns()),tabindex:"0",role:"button","aria-label":"Campaign list"},[i.view_campaigns?(r(),l("div",ks,[o("div",$s,[F(c,{size:6})]),o("div",Cs,[o("div",Ss,d(i.campaigns.texts.campaigns),1),o("div",null,d(i.campaigns.texts.count),1)])])):(r(),l("div",{key:1,class:"flex items-center justify-center h-full",title:i.campaigns.texts.campaigns},[F(c,{size:6})],8,Ls))],2),o("div",{class:g(a.blockClass(i.view_profile)),onClick:t[3]||(t[3]=p=>a.openProfile()),tabindex:"0",role:"button","aria-label":"Profile pane"},[i.view_profile?(r(),l("div",js,[a.showInitials()?(r(),l("div",Ts,d(n.initials),1)):(r(),l("div",{key:1,class:"flex-none w-9 h-9 rounded-lg cover-background",style:E({backgroundImage:a.profilePictureUrl()})},null,4)),o("div",Ds,[o("div",qs,d(i.profile.name),1),o("div",null,d(i.profile.created),1)])])):(r(),l("div",{key:1,class:"",title:i.profile.your_profile},[a.showInitials()?(r(),l("div",Ms,d(n.initials),1)):(r(),l("div",{key:1,class:"flex-none w-9 h-9 rounded-lg cover-background",style:E({backgroundImage:a.profilePictureUrl()})},null,4))],8,Es))],2)]),i.view_profile?(r(),l("div",Is,[i.notifications.title?(r(),l("div",As,[o("div",Ps,[o("div",Qs,d(i.notifications.title),1),o("div",zs,[o("a",{href:i.notifications.all.url},d(i.notifications.all.text),9,Fs)])]),o("div",Rs,[(r(!0),l(v,null,b(i.notifications.messages,p=>(r(),L(u,{notification:p},null,8,["notification"]))),256))]),i.notifications.messages.length===0?(r(),l("div",Bs,d(i.notifications.none),1)):h("",!0)])):h("",!0),i.releases.title&&i.releases.releases.length>0?(r(),l("div",Hs,[o("div",Ns,[o("div",Os,d(i.releases.title),1)]),o("div",Ks,[(r(!0),l(v,null,b(i.releases.releases,p=>(r(),L(m,{release:p},null,8,["release"]))),256))])])):h("",!0),!i.profile.is_impersonating&&i.marketplace.title?(r(),l("div",Us,[o("div",Vs,[o("div",Ws,d(i.marketplace.title),1),o("div",Gs,[o("a",{href:i.marketplace.explore.url,target:"_blank"},d(i.marketplace.explore.text),9,Js)])]),o("div",Ys,[o("a",{href:i.marketplace.themes.url,class:"border py-2 items-center justify-center rounded-md hover:shadow-md flex flex-col gap-1",target:"_blank"},[Zs,o("div",null,d(i.marketplace.themes.title),1),o("div",eo,d(i.marketplace.themes.number),1)],8,Xs),o("a",{href:i.marketplace.sheets.url,class:"border py-2 items-center justify-center rounded-md hover:shadow-md flex flex-col gap-1",target:"_blank"},[no,o("div",null,d(i.marketplace.sheets.title),1),o("div",io,d(i.marketplace.sheets.number),1)],8,to),o("a",{href:i.marketplace.content.url,class:"border py-2 items-center justify-center rounded-md hover:shadow-md flex flex-col gap-1",target:"_blank"},[oo,o("div",null,d(i.marketplace.content.title),1),o("div",ao,d(i.marketplace.content.number),1)],8,so)])])):h("",!0),!i.profile.is_impersonating&&i.profile.subscription?(r(),l("div",ro,[o("div",lo,d(i.profile.subscription.title),1),o("a",{class:"border rounded-lg flex justify-center items-center hover:shadow-md",href:i.profile.urls.subscription},[o("div",uo,[o("img",{class:"w-16 h-16",src:i.profile.subscription.image,alt:i.profile.subscription.tier},null,8,fo)]),o("div",ho,[o("div",mo,d(i.profile.subscription.tier),1),i.profile.subscription.tier!=="Kobold"?(r(),l("div",po,[y(d(i.profile.subscription.created),1),go,y(" "+d(i.profile.subscription.boosters),1)])):(r(),l("div",vo,[y(d(i.profile.subscription.call_to_action)+" ",1),o("div",_o,[y(d(i.profile.subscription.call_to_action_2)+" ",1),yo,wo])]))])],8,co)])):h("",!0),i.profile.is_impersonating?(r(),l("ul",To,[o("li",null,[o("a",{href:i.profile.return.url,class:""},[qo,y(" "+d(i.profile.return.name),1)],8,Do)])])):(r(),l("ul",bo,[o("li",null,[o("a",{href:i.profile.urls.settings.url,class:"p-2 block"},[ko,y(" "+d(i.profile.urls.settings.name),1)],8,xo)]),o("li",null,[o("a",{href:i.profile.urls.profile.url,class:"p-2 block"},[Co,y(" "+d(i.profile.urls.profile.name),1)],8,$o)]),o("li",null,[o("a",{href:i.profile.urls.help.url,class:"p-2 block",target:"_blank"},[Lo,y(" "+d(i.profile.urls.help.name),1)],8,So)]),o("li",null,[o("a",{href:"#",onClick:t[4]||(t[4]=p=>a.logout()),class:"p-2 block"},[jo,y(" "+d(i.profile.urls.logout.name),1)])])]))])):(r(),l("div",Eo,[i.profile.is_impersonating?h("",!0):(r(),l("div",Mo,[o("div",Io,[o("div",Ao,[o("div",Po,d(i.campaigns.texts.campaigns),1),i.campaigns.member.length>0?(r(),l("div",Qo,[o("a",{href:i.campaigns.urls.reorder},d(i.campaigns.texts.reorder),9,zo)])):h("",!0)]),o("div",Fo,[(r(!0),l(v,null,b(i.campaigns.member,p=>(r(),L(f,{campaign:p},null,8,["campaign"]))),256)),o("a",{href:i.campaigns.urls.new,class:"new-campaign flex items-center text-center border-dashed border rounded-lg h-24 p-2 overflow-hidden"},[o("span",Bo,[Ho,y(" "+d(i.campaigns.texts.new),1)])],8,Ro)])]),i.profile.is_impersonating?h("",!0):(r(),l("hr",No)),o("div",Oo,[i.profile.is_impersonating?h("",!0):(r(),l("p",Ko,d(i.campaigns.texts.followed),1)),i.profile.is_impersonating?h("",!0):(r(),l("div",Uo,[(r(!0),l(v,null,b(i.campaigns.following,p=>(r(),L(f,{campaign:p},null,8,["campaign"]))),256)),o("a",{href:i.campaigns.urls.follow,class:"new-campaign flex items-center text-center border-dashed border rounded-lg h-24 p-2 overflow-hidden"},[o("span",Wo,d(i.campaigns.texts.follow),1)],8,Vo)]))])]))]))]))])),[[_,a.onClickOutside]]):h("",!0)],64)}const Jo=S(us,[["render",Go]]),Yo=ct(),Q=lt({});Q.config.globalProperties.emitter=Yo;Q.component("nav-toggler",dn);Q.component("nav-search",xi);Q.component("nav-switcher",Jo);Q.mount("#header");const Z=Array(),tt=()=>{document.querySelectorAll('[data-toggle="tooltip-ajax"]').forEach(t=>{t.dataset.loaded!=="1"&&(t.dataset.loaded="1",U(t,{theme:"kanka",placement:t.dataset.direction??"bottom",allowHTML:!0,interactive:!0,delay:500,appendTo:t.dataset.append??document.body,content:'