diff --git a/app/Http/Controllers/CalendarController.php b/app/Http/Controllers/CalendarController.php index 932d40cb73..81a0b03d66 100644 --- a/app/Http/Controllers/CalendarController.php +++ b/app/Http/Controllers/CalendarController.php @@ -10,6 +10,8 @@ use App\Sanitizers\CalendarSanitizer; use App\Services\CalendarService; use App\Traits\TreeControllerTrait; +use App\Http\Requests\ValidateReminderLength; +use App\Services\LengthValidatorService; class CalendarController extends CrudController { @@ -23,6 +25,7 @@ class CalendarController extends CrudController protected $module = 'calendars'; protected CalendarService $calendarService; + protected LengthValidatorService $lengthValidatorService; /** @var string */ protected $model = \App\Models\Calendar::class; @@ -36,10 +39,11 @@ class CalendarController extends CrudController * CalendarController constructor. * @param CalendarService $calendarService */ - public function __construct(CalendarService $calendarService) + public function __construct(CalendarService $calendarService, LengthValidatorService $lengthValidatorService) { parent::__construct(); $this->calendarService = $calendarService; + $this->lengthValidatorService = $lengthValidatorService; } /** @@ -205,4 +209,15 @@ public function today(Calendar $calendar) return redirect()->back() ->with('success', __('calendars.edit.today')); } + + /** + * @param Calendar $calendar + * @return \Illuminate\Http\JsonResponse + * @throws \Illuminate\Auth\Access\AuthorizationException + */ + public function eventLength(Calendar $calendar, ValidateReminderLength $request) + { + $this->authorize('view', $calendar); + return response()->json($this->lengthValidatorService->validateLength($calendar, $request)); + } } diff --git a/app/Http/Requests/ValidateReminderLength.php b/app/Http/Requests/ValidateReminderLength.php new file mode 100644 index 0000000000..29e1abdb02 --- /dev/null +++ b/app/Http/Requests/ValidateReminderLength.php @@ -0,0 +1,33 @@ + 'integer|nullable', + 'month' => 'required|integer', + 'year' => 'required|integer', + 'length' => 'required|integer', + ]; + } +} diff --git a/app/Services/LengthValidatorService.php b/app/Services/LengthValidatorService.php new file mode 100644 index 0000000000..2d371159a9 --- /dev/null +++ b/app/Services/LengthValidatorService.php @@ -0,0 +1,40 @@ +daysInYear(); + $counter = 0; + $monthLength = 0; + foreach ($calendar->monthDataProperties() as $monthData) { + $counter = $counter + 1; + if ($counter >= $month) { + $monthLength = $monthLength + $monthData['data-length']; + } + } + $totalLength = $monthLength - $day + $daysInYear; + if ($length >= $totalLength) { + return [ + 'overflow' => true, + 'message' => __('calendars.warnings.event_length', ['documentation' => link_to('https://docs.kanka.io/en/latest/entities/calendars.html#long-lasting-reminders', ' ' . __('front.menu.documentation'), ['target' => '_blank'], null, false)]), + ]; + } + return [ + 'overflow' => false, + 'message' => __('calendars.warnings.event_length', ['documentation' => link_to('https://docs.kanka.io/en/latest/entities/calendars.html#long-lasting-reminders', ' ' . __('front.menu.documentation'), ['target' => '_blank'], null, false)]), + ]; + } +} diff --git a/lang/en/calendars.php b/lang/en/calendars.php index 81f7584ddb..60ae147c6d 100644 --- a/lang/en/calendars.php +++ b/lang/en/calendars.php @@ -225,4 +225,7 @@ 'moon_offset' => 'The moon first fullmoon offset can\'t be bigger than the length of the calendar\'s first month.', 'format' => 'The Calendar date format is invalid.', ], + 'warnings' => [ + 'event_length' => 'Reminders that span multiple years are only visible on the first two years. Learn more in our :documentation .', + ], ]; diff --git a/public/build/assets/app-bac3247a.js b/public/build/assets/app-bac3247a.js new file mode 100644 index 0000000000..136ce62434 --- /dev/null +++ b/public/build/assets/app-bac3247a.js @@ -0,0 +1 @@ +import{d as re}from"./delete-confirm-fec6aa52.js";import{d as Be}from"./mention-5d95822d.js";import{a as $e}from"./ajax-modal-1230002e.js";import{S as ke}from"./sortable.esm-be94e56d.js";import{_ as j,c as l,a as o,t as c,o as r,n as L,w as He,b as h,F as _,r as k,d as b,e as g,f as S,g as E,h as W,i as Ke,v as Ue,j as Ve,k as xe,l as We}from"./_plugin-vue_export-helper-c420bb3b.js";import{m as Ye}from"./mitt-f7ef348c.js";import{v as Ce}from"./v-click-outside.umd-d5c5f7b0.js";import"./_commonjsHelpers-725317a4.js";$(document).ready(function(){window.initTags=function(){$.each($(".form-tags"),function(){let e=$(this).data("dropdown-parent");$(this).hasClass("select2-hidden-accessible")||$(this).select2({tags:$(this).data("allow-new"),allowClear:$(this).data("allow-clear"),dropdownParent:e||"",minimumInputLength:0,ajax:{quietMillis:500,delay:500,url:$(this).data("url"),dataType:"json",data:function(t){return{q:$.trim(t.term)}},processResults:function(t){return{results:t}},cache:!0},createTag:function(t){var n=$.trim(t.term);return n===""?null:{id:n,text:n,newTag:!0}},templateResult:function(t){var n=$(""+t.text+"");return t.colour&&(n=$(""+t.text+"")),n},templateSelection:function(t,n){if(t.newTag)return $(''+t.text+' ');let a=$(t.element);return t.colour?$(n).addClass(t.colour):a.data("colour")&&$(n).addClass(a.data("colour")),$(n).addClass("text-left"),t.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,a="Si us plau, elimina "+n+" car";return a+=n==1?"àcter":"àcters"},inputTooShort:function(t){var n=t.minimum-t.input.length,a="Si us plau, introdueix "+n+" car";return a+=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,a="Please delete "+n+" character";return n!=1&&(a+="s"),a},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,a="Por favor, elimine "+n+" car";return a+=n==1?"ácter":"acteres"},inputTooShort:function(t){var n=t.minimum-t.input.length,a="Por favor, introduzca "+n+" car";return a+=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/hr",[],function(){function t(n){var a=" "+n+" znak";return n%10<5&&n%10>0&&(n%100<5||n%100>19)?n%10>1&&(a+="a"):a+="ova",a}return{errorLoading:function(){return"Preuzimanje nije uspjelo."},inputTooLong:function(n){return"Unesite "+t(n.input.length-n.maximum)},inputTooShort:function(n){return"Unesite još "+t(n.minimum-n.input.length)},loadingMore:function(){return"Učitavanje rezultata…"},maximumSelected:function(n){return"Maksimalan broj odabranih stavki je "+n.maximum},noResults:function(){return"Nema rezultata"},searching:function(){return"Pretraga…"},removeAllItems:function(){return"Ukloni sve stavke"}}}),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,a="Per favore cancella "+n+" caratter";return a+=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",a="Er "+n+" maar "+t.maximum+" item";return t.maximum!=1&&(a+="s"),a+=" 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"],a=function(i,s){return i===1?s[0]:i>1&&i<=4?s[1]:i>=5?s[2]:void 0};return{errorLoading:function(){return"Nie można załadować wyników."},inputTooLong:function(i){var s=i.input.length-i.maximum;return"Usuń "+s+" "+a(s,t)},inputTooShort:function(i){var s=i.minimum-i.input.length;return"Podaj przynajmniej "+s+" "+a(s,t)},loadingMore:function(){return"Trwa ładowanie…"},maximumSelected:function(i){return"Możesz zaznaczyć tylko "+i.maximum+" "+a(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,a="Apague "+n+" caracter";return n!=1&&(a+="es"),a},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,a,i,s){return n%10<5&&n%10>0&&n%100<5||n%100>20?n%10>1?i:a:s}return{errorLoading:function(){return"Невозможно загрузить результаты"},inputTooLong:function(n){var a=n.input.length-n.maximum,i="Пожалуйста, введите на "+a+" символ";return i+=t(a,"","a","ов"),i+=" меньше"},inputTooShort:function(n){var a=n.minimum-n.input.length,i="Пожалуйста, введите ещё хотя бы "+a+" символ";return i+=t(a,"","a","ов")},loadingMore:function(){return"Загрузка данных…"},maximumSelected:function(n){var a="Вы можете выбрать не более "+n.maximum+" элемент";return a+=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 a=n.input.length-n.maximum;return a==1?"Prosím, zadajte o jeden znak menej":a>=2&&a<=4?"Prosím, zadajte o "+t[a](!0)+" znaky menej":"Prosím, zadajte o "+a+" znakov menej"},inputTooShort:function(n){var a=n.minimum-n.input.length;return a==1?"Prosím, zadajte ešte jeden znak":a<=4?"Prosím, zadajte ešte ďalšie "+t[a](!0)+" znaky":"Prosím, zadajte ešte ďalších "+a+" 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(a){return{q:$.trim(a.term)}},processResults:function(a){return{results:a}},error:function(a){return console.log("error",a),a.status===503&&window.showToast(a.responseJSON.message,"toast-error"),{results:[]}},cache:!0},templateResult:function(a){var i="";return a.image?i=$(""+a.text+""):i=$(""+a.text+""),i},createTag:function(a){return null}})}),$("select.select2-local").select2({placeholder:$(this).data("placeholder"),language:$(this).data("language"),allowClear:!0}),$("select.select2-colour").select2({allowClear:!1,templateResult:le,templateSelection:le}))}});function le(e){if(e.id==="none")return e.text;var t=$('
'+e.text+"
");return t}var U=Array();function Ge(){let t=$(this).data("id");if(t in U)return U[t];var n='
';return $.ajax({url:$(this).data("url"),method:"GET",async:!1,success:function(a){n=a}}),U[t]=n,n}window.ajaxTooltip=function(){$('[data-toggle="tooltip-ajax"]').tooltip({title:Ge,delay:500,trigger:"hover",placement:"auto",template:'',html:!0,sanitize:!1}),$('[data-toggle="tooltip-ajax"]').click(function(){$(this).tooltip("hide")})};$(document).ready(function(){$.each($("form"),function(){$(this).data("shortcut")&&Xe(this)}),Je(),Ze()});function Je(){$(document).bind("keydown",function(e){let t=$(e.target),n=$("#entity-modal"),a=$(".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&&a.length>0){if(z(t)||(n.data("bs.modal")||{}).isShown)return;a[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 Xe(e){$(document).bind("keydown",function(t){if((t.ctrlKey||t.metaKey)&&t.key.toLowerCase()==="s")return console.log("hey"),window.entityFormHasUnsavedChanges=!1,t.shiftKey?V("submit-update"):t.altKey&&V("submit-new"),$(e).submit(),!1;if((t.ctrlKey||t.metaKey)&&t.altKey&&t.key==="c")return window.entityFormHasUnsavedChanges=!1,V("submit-copy"),$(e).submit(),!1})}function V(e){let t=$("#form-submit-main");t&&(t.attr("name",e),$("#submit-mode").attr("name",e))}function Ze(){$('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('0){let i=Object.keys(a).filter(function(s){return!t||t!=a[s].id}).map(function(s){return''+a[s].name+""});i.length>0&&($("#duplicate-entities").html(i.join(", ")),e.fadeIn())}else e.hide()})})}function Se(){if(F=$(".form-submit-actions"),F.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(F,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 nt(){$.each($("form"),function(){$(this).on("submit",function(){window.entityFormHasUnsavedChanges=!1;var e=$(this).find(".btn-primary");return e.length>0&&($.each(e,function(){$(this).hasClass("dropdown-toggle")?$(this).prop("disabled",!0):$(this).prop("disabled",!0).addClass("loading")}),$(this).append('')),!0})})}function it(){T=$("#entity-calendar-form-add"),v=$('[name="calendar_id"]'),$(".entity-calendar-modal-form"),D=$(".entity-calendar-subform"),q=$("#entity-calendar-form-cancel"),Y=$(".entity-calendar-form"),x=$('input[name="calendar_year"]'),C=$('select[name="calendar_month"]'),w=$('select[name="calendar_day"]'),O=$(".entity-calendar-loading"),T.length===1&&(T.on("click",function(e){e.preventDefault(),T.hide(),Y.show();let t=$(this).data("default-calendar");return t&&(v.val(t),q.show(),D.fadeIn(),B(t)),!1}),q.on("click",function(e){e.preventDefault(),v.val(null),q.hide(),G()})),v.length===1&&v.on("change",function(){if(D.hide(),!$(this).val()){G();return}x=$('input[name="calendar_year"]'),C=$('select[name="calendar_month"]'),w=$('select[name="calendar_day"]'),x.length===0&&$('input[name="year"]').length===1&&(x=$('input[name="year"]'),C=$('select[name="month"]'),w=$('input[name="day"]')),B(v.val())}),ft()}function Te(){$("#entity-calendar-modal-add").length!==0&&(T=$("input[name=calendar-data-url]"),v=$('select[name="calendar_id"]'),x=$('input[name="year"]'),C=$('select[name="month"]'),w=$('input[name="day"]'),O=$(".entity-calendar-loading"),D=$(".entity-calendar-subform"),v.on("change",function(){if(D.hide(),!v.val()){G();return}B(v.val())}),v.val()&&(q.show(),D.fadeIn(),B(v.val())),$('.entity-calendar-subform input[name="length"]').focusout(function(){if(!$(this).val())return;let e=$(this).data("url").replace("/0/","/"+v.val()+"/"),t={day:w.val(),month:C.val(),year:x.val(),length:$(this).val()};$.ajax(e,{data:t}).done(function(n){n.overflow==!0?$(".length-warning").show():$(".length-warning").hide()})}))}function at(){if($("#era-form-add").length===0)return;T=$("#era-form-add");let e=$('[name="era_id"]');je=e.val(),v.val()&&ce(e.val()),e.length===1&&e.on("change",function(){$('select[name="position"]'),ce(e.val())})}function B(e){O.show(),e=parseInt(e);var t=$('input[name="calendar-data-url"]').data("url").replace("/0/","/"+e+"/");$.ajax(t).done(function(n){let a=w.val();x.html(""),C.html(""),w.html("");let i=1,s=1;a||(a=n.current.day);let u=parseInt(n.current.month);$.each(n.months,function(d){let p=n.months[d],f=i===u?' selected="selected"':"";C.append('"),i===u&&(s=p.length),i++});for(let d=1;d"+d+"")}O.hide(),D.show(),x.val(n.current.year),$('select[name="calendar_recurring_periodicity"] option').remove(),$.each(n.recurring,function(d,p){$('select[name="calendar_recurring_periodicity"]').append('")}),$('input[name="length"]').val(1),n.length===1&&C.val(n[0].id),rt()})}function ce(e){e=parseInt(e);var t=$('input[name="era-data-url"]').data("url").replace("/0/","/"+e+"/"),n=$('input[name="oldPosition"]').data("url");$.ajax(t).done(function(a){let i=$('select[name="position"]');i.html("");let s=1;$.each(a.positions,function(u){let d=a.positions[u],p=' selected="selected"';n&&!u&&je==e&&i.append('"),u&&i.append('"),s++})})}function G(){Y.hide(),T.show(),$('input[name="calendar_day"]').val(null),$('input[name="calendar_month"]').val(null),$('input[name="calendar_year"]').val(null),$('input[name="calendar_id"]').val(null),console.log("finished?")}function ot(){if(F=$('form[data-unload="1"]'),F.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 De(){$('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"]').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 st(){$(".permission-toggle").change(function(){let t="input[data-action="+$(this).data("action")+"]";$(this).prop("checked")?$(t).prop("checked",!0):$(t).prop("checked",!1)})}function rt(){$.isFunction($.fn.spectrum)&&$(".spectrum").spectrum({preferredFormat:"hex",showInput:!0,showPalette:!0,allowEmpty:!0})}function Ie(){let e=$(".entity-story-block .collapse"),t=$(".entity-story-block .element-toggle");$(".btn-post-collapse").unbind("click").click(function(){return e.collapse("hide"),t.addClass("collapsed"),!1}),$(".btn-post-expand").unbind("click").click(function(){return e.collapse("show"),t.removeClass("collapsed"),!1})}function lt(){$(".sidebar-section-title").click(function(){$(this).next().hasClass("in")?($(this).find(".fa-chevron-down").hide(),$(this).find(".fa-chevron-right").show()):($(this).find(".fa-chevron-right").hide(),$(this).find(".fa-chevron-down").show())})}function Me(){$(".story-load-more").click(function(e){let t=$(this);return e.preventDefault(),$("#story-more-spinner").show(),$(this).hide(),$.ajax({url:$(this).data("url")}).done(function(n){t.parent().remove(),n&&($(".entity-posts").append(n),Me(),Ie(),window.ajaxTooltip())}).fail(function(){$("#story-more-spinner").hide(),t.show()}),!1})}function ct(){$(".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 a=new Date;a.setTime(a.getTime()+30*24*60*60*1e3),document.cookie=e+"="+t+";expires="+a.toUTCString()+";sameSite=Strict"})}function dt(){$(".dynamic-row-add").on("click",function(e){e.preventDefault();let t=$(this).data("target"),n=$(this).data("template");return $("."+t).append('
'+$("#"+n).html()+"
"),de(),!1}),de()}function de(){$.each($(".dynamic-row-delete"),function(){$(this).data("init")!==1&&($(this).data("init",1),$(this).on("click",function(e){e.preventDefault(),$(this).closest(".parent-delete-row").remove()}).on("keydown",function(e){e.key==="Enter"&&$(this).click()}))})}function ut(){$('input[data-toggle="entity-privacy"]').change(function(){let e=$("#entity-is-private");$(this).prop("checked")?e.show():e.hide()})}function ft(){$('select[name="calendar_month"]').change(function(){let e=$(this).find(":selected").data("length");ht(e)})}function ht(e){let t=w.val();t>e&&(t=e),w.html("");for(let n=1;n<=e;n++){let a=n==t?' selected="selected"':"";w.append('")}}var J;$(document).ready(function(){J=$(".post-perm-add"),J.length!==0&&(mt(),Le())});function mt(){J.on("click",function(e){e.preventDefault();let t=$(this).data("type"),n=$('select[name="'+t+'"]');if(!n||!n.val())return!1;let a=n.find(":selected")[0],i=$("#post-perm-"+t+"-template").clone().removeClass("hidden").removeAttr("id"),s=i.html().replace(/\$SELECTEDID\$/g,n.val()).replace(/\$SELECTEDNAME\$/g,a.text);return i.html(s).insertBefore($("#post-perm-target")),$("#post-new-"+t).modal("toggle"),Le(),n.val("").trigger("change"),!1})}function Le(){$.each($(".post-delete-perm"),function(){$(this).unbind("click"),$(this).on("click",function(){$(this).closest(".grid").remove()})})}var ue;$(document).ready(function(){ue=$("#calendar-year-switcher"),ue.length===1&&($("#calendar-year-switcher-field"),$("#add-calendar-event"),pt()),$(document).on("shown.bs.modal",function(){fe()}),$('select[name="recurring_periodicity"]').length===1&&fe(),gt()});function pt(){$(".calendar-event-block").each(function(){$(this).data("toggle")!=="ajax-modal"&&$(this).data("url")&&$(this).click(function(){window.location=$(this).data("url")})})}function fe(){$('select[name="recurring_periodicity"]').change(function(){this.value?$("#add_event_recurring_until").show():$("#add_event_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 gt(){$(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()})}var I,X=300*1e3,Ee,Z=!0;$(document).ready(function(){I=$("#entity-edit-warning"),I.length!==0&&(vt(),_t())});function vt(){Z=!1,I.modal({backdrop:!1}),$("#entity-edit-warning-ignore").click(function(e){e.preventDefault(),he(),Z=!0,$.ajax({url:$(this).data("url"),type:"POST",context:this}).done(function(){I.modal("hide")})}),$("#entity-edit-warning-back").click(function(e){e.preventDefault(),he(),window.location.href=$(this).data("url")})}function he(){I.find(".modal-ajax-body").hide(),I.find(".modal-spinner-body").show(),I.find(".modal-footer").hide()}function _t(){let e=$("#editing-keep-alive");e.length!==0&&(Ee=e.data("url"),setTimeout(ee,X))}function ee(){if(!Z){setTimeout(ee,X);return}$.ajax({url:Ee,type:"POST"}).done(function(){setTimeout(ee,X)})}var y="#entity-modal",R;$(document).ready(function(){$(document).on("shown.bs.modal shown.bs.popover",function(){K()}),$(".quick-creator-subform").click(function(){$.ajax({url:$(this).data("url")}).done(function(e){$(y).find(".modal-content").show().html(e),$(y).find(".modal-spinner").hide(),$(y).modal(),oe()})})});function K(){$('[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()):qe(),$.ajax({url:$(this).data("url"),context:this}).done(function(n){$(y).find(".modal-content").show().html(n),$(y).find(".modal-spinner").hide(),oe(),se()}),!1})}function Pe(){$("#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").fadeIn()}else $(this).parent().parent().find(".duplicate-entity-warning").hide()}))})}function qe(){$(y).find(".modal-content").hide(),$(y).find(".modal-spinner").show()}function oe(){R=$(".quick-creator-submit"),window.initForeignSelect(),window.initTags(),Pe(),Qe(),se(),R.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(),R.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 n=new Option(t._name,t._id),a=$("#"+t._target);if(t._multi){let i=a.val();i.push(t._id),a.append(n).val(i)}else a.children().remove().end().append(n).val(t._id);a.trigger("change"),$(y).find(".modal-content").html("").show(),$(y).find(".modal-spinner").hide(),$(y).modal("toggle"),te();return}$(y).find(".modal-content").html(t).show(),$(y).find(".modal-spinner").hide(),K(),te()}).fail(function(t){if(t.responseJSON.errors){let n=t.responseJSON.errors;Object.keys(n).forEach(function(u){let d=$('#entity-creator-form [name="'+u+'"]');d.length>0&&d.addClass("input-error").parent().append('
'+n[u][0]+"
")});let i=Object.keys(n)[0],s=$('#entity-creator-form input[name="'+i+'"]');if(s[0]){s[0].scrollIntoView({behavior:"smooth"}),$(".tab-content .active").removeClass("active"),$(".nav-tabs li.active").removeClass("active");let u=$('[name="'+i+'"').closest(".tab-pane");u.addClass("active"),$('a[href="#'+u.attr("id")+'"]').closest("li").addClass("active")}}R.prop("disabled",!1).find("i.fa-spin").hide().parent().find("span").show(),$('#entity-creator-form [name="action"]').val("")})})}function Qe(){$("#entity-creator-back").click(function(e){e.preventDefault(),qe(),$.ajax({url:$(this).data("url"),context:this}).done(function(t){let n=$(this).data("target");$(n).find(".modal-content").html(t).show(),$(n).find(".modal-spinner").hide(),K()})})}function se(){$(".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){$("#entity-modal").find(".modal-content").html(t).show(),te()}))}),$(".qq-action-more").unbind("click").on("click",function(e){e.preventDefault(),$(this).hide(),$(".qq-more-fields").show()}),K()}function te(){se(),Pe(),Qe(),oe(),window.initForeignSelect(),window.initTags()}var M,Q,yt=new IntersectionObserver(function(e){e[0].isIntersecting===!0&&ie($(".datagrid-onload"))},{threshold:[0]});$(document).ready(function(){Ae(),Fe(),H(),bt()});function Fe(){$("[data-bulk-action]").on("click",function(){wt($(this).data("bulk-action"))}),$(".bulk-print").on("click",function(e){e.preventDefault();let t=$(this).closest("form");t.find(),t.submit()})}function Ae(){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)}),H()}),$.each($("input[name='model[]']"),function(){$(this).change(function(t){H(),t.preventDefault()})})}function wt(e){var t=[];$.each($("input[name='model[]']"),function(){$(this).prop("checked")&&t.push($(this).val())}),$("#datagrid-bulk-"+e+"-models").val(t.toString())}function H(){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 bt(){ne(),ze(),$t(),H(),ne()}function ne(){$(".datagrid-bulk").click(function(e){e.preventDefault(),M=$(this).closest("form");let t=[];$.each($("input[name='model[]']"),function(){$(this).prop("checked")&&t.push($(this).val())}),$.ajax({url:M.attr("action")+"?action=edit",method:"POST",data:{model:t}}).done(function(n){$("#entity-modal").find(".modal-content").html(n),$("#entity-modal").modal()})}),$(".datagrid-submit").click(function(e){if(e.preventDefault(),M=$(this).closest("form"),M.find('input[name="action"]').val($(this).data("action")),$(this).data("action")==="delete")return $("#datagrid-bulk-delete").modal(),!1;$(".datagrid-bulk-actions").hide(),$(".datagrid-spinner").show(),M.submit()}),$("#datagrid-action-confirm").click(function(){$("#datagrid-bulk-delete").modal("hide"),M.submit()})}function ze(){$.each($('table[data-render="datagrid2"]'),function(){Q=$(this),$(this).find("thead a").click(function(e){e.preventDefault(),ie($(this))}),$(this).closest("#datagrid-parent").find('nav[role="navigation"] a').click(function(e){e.preventDefault(),ie($(this))})}),Ae(),Fe(),ne()}function $t(){$(".datagrid-onload").length!=0&&yt.observe(document.querySelector(".datagrid-onload"))}function ie(e){Q.find("thead").hide(),Q.find("tbody").hide(),Q.find("tfoot").fadeIn();let t=e.attr("href"),n=e.data("url");t==="#"&&n&&(t=n);let a=e.data("target")??"#datagrid-parent";$.ajax(t).done(function(i){i.html&&$(a).html(i.html),i.deletes&&$("#datagrid-delete-forms").html(i.deletes),i.url&&window.history.pushState({},"",i.url),ze(),$(document).trigger("shown.bs.modal"),$e()}).fail(function(i){console.error("datagrid2",i),Q.find("tfoot").addClass("bg-danger")})}$(document).ready(function(){kt(),xt()});function kt(){let e=$("#quick-link-selector");if(e.length===0)return!1;e.change(function(t){t.preventDefault();let n=$(this).find(":selected");$(".quick-link-subform").hide();let a=n.data("target");$(a).show()})}function xt(){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(){Ct()});function Ct(){let e=$("#post-layout-selector");if(e.length===0)return!1;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(){me()}),$(".form-members").count!==0&&me()});function me(){$.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(){jt(),St(),Tt(),It(),Mt(),Lt(),Dt(),Et()});function jt(){$.each($(".form-rpg-systems"),function(){$(this).select2({multiple:!0,allowClear:!0,minimumInputLength:0})})}function St(){$("#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"),$.ajax({method:"post",url:$(this).data("url"),context:this}).done(function(n){n.success&&(n.status?$(this).closest(".box-module").addClass("module-enabled"):$(this).closest(".box-module").removeClass("module-enabled"),window.showToast(n.toast)),$(this).closest(".box-module").find("h3").removeClass("loading")}))})}function Tt(){$(".btn-user-roles").popover({html:!0,sanitize:!1,trigger:"focus"})}function Dt(){$(".public-permission").click(function(e){e.preventDefault(),$(this).addClass("loading"),$.ajax({method:"post",url:$(this).data("url"),context:this}).done(function(t){$(this).removeClass("loading"),t.success&&(t.status?$(this).addClass("enabled"):$(this).removeClass("enabled"),window.showToast(t.toast))})})}function It(){$.each($(".codemirror"),function(){let e=$(this).attr("id");CodeMirror.fromTextArea(document.getElementById(e),{extraKeys:{"Ctrl-Space":"autocomplete"},lineNumbers:!0,lineWrapping:!0,theme:"dracula"})})}function Mt(){let e=[].slice.call(document.querySelectorAll(".nested-sortable"));for(let t=0;t0;return!(i.classList.contains("fixed-position")&&u)}})}function Lt(){let e=$(".campaign-export-btn");e.length!==0&&e.click(function(t){t.preventDefault(),$(this).addClass("loading"),$.ajax({url:e.data("url"),method:"POST",context:this}).done(function(n){$(this).removeClass("loading").hide(),n.error?window.showToast(n.error,"toast-error"):window.showToast(n.success)}).fail(function(n){console.error("campaign export call",n)})})}function Et(){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)})}$(document).ready(function(){pe(),$(document).on("shown.bs.modal shown.bs.popover",function(){pe()})});function pe(){$("[data-clipboard]").length!==0&&$.each($("[data-clipboard]"),function(e){let t=$(this);t.data("loaded")!=1&&(t.data("loaded",1),t.click(function(n){Pt($(this).data("clipboard"),$(this));let a=$(this).data("toast");return a&&window.showToast(a),!1}))})}async function Pt(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(a){console.error(a)}finally{n.remove()}}}$(document).ready(function(){Re()});function Re(){$('.toast-container [data-toggle="dismiss"]').unbind("click").on("click",function(e){e.preventDefault(),$(this).parent().parent().fadeOut()})}window.showToast=function(e,t){t=t||"toast-success";let n=$('
');n.html(''+e+'this.options.collapseScreenSize?e("body").removeClass(i.collapsed).trigger(e.Event(s.expanded)):e("body").addClass(i.open).trigger(e.Event(s.expanded))},u.prototype.close=function(){var f=e(window).width();f>this.options.collapseScreenSize?e("body").addClass(i.collapsed).trigger(e.Event(s.collapsed)):e("body").removeClass(i.open+" "+i.collapsed).trigger(e.Event(s.collapsed))},u.prototype.expandOnHover=function(){e(a.mainSidebar).hover(function(){e("body").is(a.mini+a.collapsed)&&e(window).width()>this.options.collapseScreenSize&&this.expand()}.bind(this),function(){e("body").is(a.expanded)&&this.collapse()}.bind(this))},u.prototype.expand=function(){setTimeout(function(){e("body").removeClass(i.collapsed).addClass(i.expanded)},this.options.expandTransitionDelay)},u.prototype.collapse=function(){setTimeout(function(){e("body").removeClass(i.expanded).addClass(i.collapsed)},this.options.expandTransitionDelay)};function d(f){return this.each(function(){var m=e(this),P=m.data(t);if(!P){var Ne=e.extend({},n,m.data(),typeof f=="object"&&f);m.data(t,P=new u(Ne))}f==="toggle"&&P.toggle()})}var p=window.$.fn.pushMenu;window.$.fn.pushMenu=d,window.$.fn.pushMenu.Constructor=u,window.$.fn.pushMenu.noConflict=function(){return window.$.fn.pushMenu=p,this},window.$(document).on("click",a.button,function(f){f.preventDefault(),d.call(window.$(this),"toggle")}),window.$(window).on("load",function(){d.call(window.$(a.button))})}(jQuery);$(window).ready(function(){qt()});function qt(){$(".banner-notification-dismiss").click(function(e){e.preventDefault(),$.post({url:$(this).data("url"),method:"POST",context:this}).done(function(){let t=$(this).data("dismiss");t&&$(this).closest("."+t).fadeOut()})})}window.initSortable=function(){var e=document.querySelectorAll(".sortable-elements"),t;if(e.length!==0)for(t=0;t{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,"toast-error");return}if(e.status===403){$("#entity-form-403-error").show();return}let n=e.responseJSON.errors,a=[],i=Object.keys(n),s=!0;if(i.forEach(function(f){let m=$('[name="'+f+'"]');m.length>0?m.addClass("input-error").parent().append('
'+n[f][0]+"
"):(s=!1,a.push(n[f][0]))}),!s){let f=$("#entity-form-generic-error .error-logs");f.html(""),a.forEach(function(m){let P=m+"
";f.append(P)}),$("#entity-form-generic-error").show()}if($(this).find(".tab-content").length===0)return;let u=Object.keys(n)[0],d=document.getElementsByName(u);if(!d[0])return;d[0].scrollIntoView({behavior:"smooth"}),$(".tab-content .active").removeClass("active"),$(".nav-tabs li.active").removeClass("active");let p=$('[name="'+u+'"').closest(".tab-pane");p.addClass("active"),$('a[href="#'+p.attr("id")+'"]').closest("li").addClass("active")};const Qt={props:{text:String,title:String}},Ft={class:"mx-5"},At=["title"],zt=o("i",{class:"fa-solid fa-chevrons-left","aria-hidden":"true","data-sidebar":"collapse"},null,-1),Rt=o("i",{class:"fa-solid fa-chevrons-right","aria-hidden":"true","data-sidebar":"expand"},null,-1),Ot={class:"sr-only"};function Nt(e,t,n,a,i,s){return r(),l("div",Ft,[o("span",{role:"button",class:"sidebar-toggle text-center cursor-pointer","data-toggle":"tooltip",title:n.title,"data-placement":"right","data-html":"true",tabindex:"3"},[zt,Rt,o("span",Ot,c(n.text),1)],8,At)])}const Bt=j(Qt,[["render",Nt]]),Ht={props:["entity"],methods:{backgroundImage:function(e){return"url('"+e.image+"')"},preview:function(e){this.emitter.emit("preview",e)}}},Kt=["data-id"],Ut={class:"flex-none"},Vt=["href","title"],Wt={class:"flex-grow truncate pl-1"},Yt=["title"],Gt={class:"entity-type text-xs"};function Jt(e,t,n,a,i,s){return r(),l("div",{class:"flex justify-center gap-1 mb-1 cursor-pointer hover:bg-base-200 rounded p-1 w-full","data-id":n.entity.id,onClick:t[1]||(t[1]=u=>s.preview(n.entity))},[o("div",Ut,[o("a",{href:n.entity.link,style:L({backgroundImage:s.backgroundImage(n.entity)}),onClick:t[0]||(t[0]=He(()=>{},["stop"])),title:n.entity.name,class:"rounded cover-background block h-16 w-16"},null,12,Vt)]),o("div",Wt,[o("div",{class:"font-extrabold entity-name truncate",title:n.entity.name},c(n.entity.name),9,Yt),o("div",Gt,c(n.entity.type),1)])],8,Kt)}const Oe=j(Ht,[["render",Jt]]),Xt={props:["entity"],components:{LookupEntity:Oe},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 mr-2 bg-base-100 text-black text-xs mb-1";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}}},Zt={class:"entity-header p-3 bg-entity-focus"},en={class:"block w-full flex items-center"},tn=["href","title"],nn={key:0,class:"fa-solid fa-skull mx-2","aria-hidden":"true"},an=["href"],on=o("i",{class:"fa-solid fa-external-link","aria-hidden":"true","aria-label":"Open in a new window"},null,-1),sn=[on],rn={key:0,class:"block w-full"},ln={key:1,class:"my-1 w-full"},cn=["href"],dn=["href","data-tag"],un=o("i",{class:"ra ra-tower","aria-hidden":"true","aria-label":"Location"},null,-1),fn=["href","title"],hn={class:"entity-sections"},mn={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"},pn={key:0,class:"tab-profile p-5"},gn={key:0,class:"entity-pinned-attributes"},vn=["data-attribute","data-target"],_n={class:"inline-block uppercase font-extrabold mr-1"},yn=["innerHTML"],wn=o("hr",null,null,-1),bn={class:"uppercase font-extrabold truncate"},$n={key:1,class:"tab-links p-3"},kn={key:0,class:"text-center italic"};function xn(e,t,n,a,i,s){const u=E("LookupEntity");return r(),l(_,null,[o("div",Zt,[o("div",en,[o("a",{class:"text-2xl font-extrabold entity-name",href:n.entity.link,title:n.entity.name},c(n.entity.name),9,tn),n.entity.is_dead?(r(),l("i",nn)):h("",!0),o("a",{class:"ml-2 text-xs",target:"_blank",href:n.entity.link},sn,8,an)]),s.hasTitle()?(r(),l("div",rn,c(n.entity.title),1)):h("",!0),n.entity.tags.length>0?(r(),l("div",ln,[(r(!0),l(_,null,k(n.entity.tags,d=>(r(),l("a",{class:g(s.tagClass(d)),href:d.link},c(d.name),11,cn))),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},[un,b(" "+c(n.entity.location.name),1)],8,dn)):h("",!0),n.entity.image?(r(),l("a",{key:3,href:n.entity.link,style:L({backgroundImage:s.backgroundImage()}),title:n.entity.name,class:"rounded cover-background block w-full aspect-square"},null,12,fn)):h("",!0)]),o("div",hn,[o("div",mn,[o("div",{class:g(s.tabClass("profile")),onClick:t[0]||(t[0]=d=>s.switchTab("profile"))},c(n.entity.texts.profile),3),o("div",{class:g(s.tabClass("links")),onClick:t[1]||(t[1]=d=>s.switchTab("links"))},c(n.entity.texts.connections),3),o("div",{class:g(s.tabClass("access")),onClick:t[2]||(t[2]=d=>s.switchTab("access"))},null,2)]),i.focus_profile?(r(),l("div",pn,[n.entity.attributes.length>0?(r(),l("div",gn,[(r(!0),l(_,null,k(n.entity.attributes,d=>(r(),l("div",{class:"mb-3","data-attribute":d.name,"data-target":d.id},[o("span",_n,c(d.name),1),o("span",{innerHTML:d.value},null,8,yn)],8,vn))),256)),wn])):h("",!0),(r(!0),l(_,null,k(n.entity.profile,d=>(r(),l("div",{class:g(["mb-3",s.profileClass(d)])},[o("div",bn,c(d.field),1),o("div",null,c(d.value),1)],2))),256))])):h("",!0),i.focus_pins?(r(),l("div",$n,[(r(!0),l(_,null,k(n.entity.connections,d=>(r(),S(u,{entity:d},null,8,["entity"]))),256)),n.entity.connections.length===0?(r(),l("p",kn,c(n.entity.texts["no-connections"]),1)):h("",!0)])):h("",!0)])],64)}const Cn=j(Xt,[["render",xn]]),jn={directives:{clickOutside:Ce.directive},props:{api_lookup:String,api_recent:String,placeholder:String,keyboard_tooltip:String},components:{LookupEntity:Oe,EntityPreview:Cn},data(){return{has_drawer:!1,term:null,show_loading:!1,show_recent:!1,show_preview:!1,show_results:!1,recent:[],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);axios.get(this.api_lookup,{params:{q:e,v2:!0}}).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,axios.get(this.api_recent).then(e=>{this.recent=e.data.recent,this.texts.recents=e.data.texts.recents,this.texts.results=e.data.texts.results,this.texts.hint=e.data.texts.hint,this.texts.keyboard=e.data.texts.keyboard,this.texts.empty_results=e.data.texts.empty_results,this.show_loading=!1,this.show_recent=!0,this.has_recent=!0}).catch(e=>{this.show_loading=!1,this.show_recent=!0,this.has_recent=!1})},parseLookupResponse(e,t){this.results=e.data.entities,this.cached[t]=e.data.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,axios.get(e.preview).then(t=>{this.parsePreviewResponse(t)})},parsePreviewResponse(e){this.preview_entity=e.data,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()}},mounted(){this.emitter.on("preview",e=>{this.loadPreview(e)})}},Sn={class:"flex grow mr-2"},Tn={class:"relative grow"},Dn=["placeholder"],In={class:"form-control-feedback hidden-xs hidden-sm"},Mn=["title"],Ln={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"},En={key:0,class:"text-center"},Pn=o("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true","aria-label":"Loading"},null,-1),qn=[Pn],Qn={key:1,class:"search-recent bg-lookup p-2 min-h-full shadow-r flex flex-col items-stretch"},Fn={key:0,class:"flex-none"},An={class:"italic text-xs text-center"},zn={class:"grow"},Rn={key:0,class:"search-results mb-2"},On={class:"text-sm uppercase mb-2 my-2 mx-1"},Nn={key:0,class:"italic m-2"},Bn={key:1,class:"recent-searches"},Hn={class:"text-sm uppercase my-2 mx-1"},Kn={key:1,class:"flex-none text-xs text-center"},Un=o("hr",null,null,-1),Vn=["innerHTML"],Wn={key:2,class:"search-preview bg-lookup min-h-full shadow-r"};function Yn(e,t,n,a,i,s){const u=E("LookupEntity"),d=E("EntityPreview"),p=xe("click-outside");return W((r(),l("div",Sn,[o("div",Tn,[W(o("input",{type:"text",class:"form-control 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=>s.focus()),onFocus:t[2]||(t[2]=f=>s.focus()),onKeydown:t[3]||(t[3]=Ke(f=>s.escape(),["esc"])),placeholder:n.placeholder},null,40,Dn),[[Ue,i.term]]),o("span",In,[o("span",{class:"flex-none keyboard-shortcut py-1",id:"lookup-kb-shortcut","data-toggle":"tooltip",title:n.keyboard_tooltip,"data-html":"true","data-placement":"bottom"},"K",8,Mn)])]),i.show_recent||i.show_loading||i.show_preview?(r(),l("aside",Ln,[i.show_loading?(r(),l("div",En,qn)):h("",!0),i.show_recent?(r(),l("div",Qn,[i.show_results?h("",!0):(r(),l("div",Fn,[o("p",An,c(i.texts.hint),1)])),o("div",zn,[i.show_results?(r(),l("div",Rn,[o("div",On,c(i.texts.results),1),i.results.length===0?(r(),l("div",Nn,c(i.texts.empty_results),1)):(r(!0),l(_,{key:1},k(i.results,f=>(r(),S(u,{entity:f},null,8,["entity"]))),256))])):h("",!0),i.recent.length>0?(r(),l("div",Bn,[o("div",Hn,c(i.texts.recents),1),(r(!0),l(_,null,k(i.recent,f=>(r(),S(u,{entity:f},null,8,["entity"]))),256))])):h("",!0)]),i.show_loading?h("",!0):(r(),l("div",Kn,[Un,o("p",{class:"italic text-xs text-center",innerHTML:i.texts.keyboard},null,8,Vn)]))])):h("",!0),i.show_preview?(r(),l("div",Wn,[Ve(d,{entity:i.preview_entity},null,8,["entity"])])):h("",!0)])):h("",!0)])),[[p,s.onClickOutside]])}const Gn=j(jn,[["render",Yn]]),Jn={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":"")}}},Xn=["href","title"],Zn=["innerHTML"];function ei(e,t,n,a,i,s){return r(),l("a",{class:g(s.campaignClass(n.campaign)),href:n.campaign.url,style:L({backgroundImage:s.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,Zn)],14,Xn)}const ti=j(Jn,[["render",ei]]),ni={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 mb-2 px-2 py-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)})}}},ii=["href","data-id"],ai={class:"flex-none p-2"},oi=["innerHTML"],si=["title"],ri=o("i",{class:"fa-solid fa-times","aria-hidden":"true"},null,-1),li=[ri],ci={key:1,class:"flex-none p-2"},di=o("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),ui=[di],fi=["data-id"],hi={class:"flex-none p-2"},mi=["innerHTML"],pi=["title"],gi=o("i",{class:"fa-solid fa-times","aria-hidden":"true"},null,-1),vi=[gi],_i={key:1,class:"flex-none p-2"},yi=o("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),wi=[yi];function bi(e,t,n,a,i,s){return n.notification.url&&!i.is_dismissed?(r(),l("a",{key:0,class:g(s.backgroundClass(n.notification)),href:n.notification.url,"data-id":n.notification.id},[o("div",ai,[o("i",{class:g(s.iconClass(n.notification)),"aria-hidden":"true"},null,2)]),o("div",{class:"flex-grow p-2",innerHTML:n.notification.text},null,8,oi),this.is_loading?(r(),l("div",ci,ui)):(r(),l("div",{key:0,class:"flex-none p-2 cursor-pointer dismissable",onClick:t[0]||(t[0]=u=>s.dismiss(n.notification)),title:n.notification.dismiss_text},li,8,si))],10,ii)):i.is_dismissed?h("",!0):(r(),l("div",{key:1,class:g(s.backgroundClass(n.notification)),"data-id":n.notification.id},[o("div",hi,[o("i",{class:g(s.iconClass(n.notification)),"aria-hidden":"true"},null,2)]),o("div",{class:"flex-grow p-2",innerHTML:n.notification.text},null,8,mi),this.is_loading?(r(),l("div",_i,wi)):(r(),l("div",{key:0,class:"flex-none p-2 cursor-pointer dismissable",onClick:t[1]||(t[1]=u=>s.dismiss(n.notification)),title:n.notification.dismiss_text},vi,8,pi))],10,fi))}const $i=j(ni,[["render",bi]]),ki={props:["release"],data(){return{is_dismissed:!1,is_loading:!1}},methods:{backgroundClass:function(e){return"release bg-base-200 flex justify-center items-center mb-2 px-2 py-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)})}}},xi=["data-id"],Ci={class:"flex-grow p-2"},ji=["innerHTML","href"],Si=["innerHTML"],Ti=["title"],Di=o("i",{class:"fa-solid fa-times","aria-hidden":"true"},null,-1),Ii=[Di],Mi={key:1,class:"flex-none p-2"},Li=o("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),Ei=[Li];function Pi(e,t,n,a,i,s){return i.is_dismissed?h("",!0):(r(),l("div",{key:0,class:g(s.backgroundClass(n.release)),"data-id":n.release.id},[o("div",Ci,[o("a",{innerHTML:n.release.title,class:"font-bold cursor-pointer block w-full",href:n.release.url,target:"_blank"},null,8,ji),o("p",{innerHTML:n.release.text},null,8,Si)]),this.is_loading?(r(),l("div",Mi,Ei)):(r(),l("div",{key:0,class:"flex-none p-2 cursor-pointer dismissable",onClick:t[0]||(t[0]=u=>s.dismiss(n.release)),title:n.release.dismiss_text},Ii,8,Ti))],10,xi))}const qi=j(ki,[["render",Pi]]),Qi={directives:{clickOutside:Ce.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},pro:{type:Boolean}},components:{Campaign:ti,Notification:$i,Release:qi},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,axios.get(this.api).then(e=>{this.profile=e.data.profile,this.campaigns=e.data.campaigns,this.notifications=e.data.notifications,this.marketplace=e.data.marketplace,this.releases=e.data.releases,this.show_alerts=e.data.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||e{localStorage.setItem("notification-has-alerts-"+this.user_id,t.data.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+")"},campaignIcon:function(){return this.pro?"fa-solid fa-grid":"fa-solid fa-grip"}},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()}},Fi={class:"nav-switcher flex items-center justify-center h-12"},Ai=o("span",{class:"sr-only"},"Campaigns",-1),zi={class:"indicator relative inline-flex w-max"},Ri={key:0,class:"notification-badge left-auto top-auto w-fit inline-flex absolute content-center items-center z-10"},Oi={key:1,class:"profile-box rounded-lg p-2 text-center font-bold"},Ni={key:0,class:"navigation-drawer bg-base-100 h-full overflow-y-auto safsdf fixed top-0 right-0 rounded-l-2xl shadow-lg"},Bi={key:0,class:"temporary p-8 text-center"},Hi=o("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),Ki=[Hi],Ui={key:1,class:""},Vi={class:"header flex"},Wi={key:0,class:"full flex items-center"},Yi={class:"flex-none mr-4 text-2xl"},Gi={class:"flex-grow"},Ji={class:"font-bold"},Xi=["title"],Zi={key:0,class:"full flex items-center"},ea={key:0,class:"flex-none mr-4 profile-box rounded-lg p-2 text-center uppercase font-bold"},ta={class:"flex-grow"},na={class:"font-bold"},ia=["title"],aa={key:0,class:"flex-none profile-box rounded-lg p-2 text-center uppercase font-bold"},oa={key:0,class:"profile p-5"},sa={key:0,class:"notifications mb-5"},ra={class:"flex w-full py-2"},la={class:"flex-grow uppercase font-bold"},ca={class:"flex-grow text-right"},da=["href"],ua={key:0,class:"no-notifications help-block italic"},fa={key:1,class:"releases mb-5"},ha={class:"flex w-full py-2"},ma={class:"flex-grow uppercase font-bold"},pa={key:2,class:"marketplace mb-5"},ga={class:"flex w-full py-2"},va={class:"flex-grow uppercase font-bold"},_a={class:"flex-grow text-right"},ya=["href"],wa={class:"grid grid-cols-3 gap-2"},ba=["href"],$a=o("div",{class:"icon bg-base-200 rounded-full w-14 h-14 mb-1 text-3xl inline-block aspect-square"},[o("i",{class:"fa-solid fa-palette mt-3","aria-hidden":"true"})],-1),ka={class:"text-muted text-xs"},xa=["href"],Ca=o("div",{class:"icon bg-base-200 rounded-full w-14 h-14 mb-1 text-3xl inline-block aspect-square"},[o("i",{class:"fa-solid fa-columns mt-3","aria-hidden":"true"})],-1),ja={class:"text-muted text-xs"},Sa=["href"],Ta=o("div",{class:"icon bg-base-200 rounded-full w-14 h-14 mb-1 text-3xl inline-block aspect-square"},[o("i",{class:"fa-solid fa-dice-d20 mt-3","aria-hidden":"true"})],-1),Da={class:"text-muted text-xs"},Ia={key:3,class:"subscription mb-5"},Ma={class:"uppercase font-bold py-2"},La=["href"],Ea={class:"flex-none p-2"},Pa=["src","alt"],qa={class:"flex-grow p-2"},Qa={class:"font-bold text-lg"},Fa={key:0,class:"more"},Aa=o("br",null,null,-1),za={key:1,class:"more"},Ra={class:"link"},Oa={key:4,class:"m-0 p-0 list-none"},Na=["href"],Ba=o("i",{class:"fa-solid fa-cog mr-3","aria-hidden":"true"},null,-1),Ha=["href"],Ka=o("i",{class:"fa-solid fa-user mr-3","aria-hidden":"true"},null,-1),Ua=["href"],Va=o("i",{class:"fa-solid fa-question-circle mr-3","aria-hidden":"true"},null,-1),Wa=o("i",{class:"fa-solid fa-sign-out mr-3","aria-hidden":"true"},null,-1),Ya={key:5,class:"m-0 p-0 list-none"},Ga=["href"],Ja=o("i",{class:"fa-solid fa-sign-out-alt mr-3","aria-hidden":"true"},null,-1),Xa={key:1,class:"campaigns p-5"},Za={key:0},eo={class:"flex w-full py-2"},to={class:"flex-grow uppercase font-bold"},no={key:0,class:"flex-grow text-right"},io=["href"],ao={class:"grid grid-cols-2 md:grid-cols-3 gap-5"},oo=["href"],so={class:"text-xs text-break uppercase"},ro=o("i",{class:"fa-solid fa-plus","aria-hidden":"true",style:{display:"none"}},null,-1),lo={key:0,class:"following"},co=o("hr",null,null,-1),uo={class:"uppercase"},fo={class:"grid grid-cols-2 md:grid-cols-3 gap-5"},ho=["href"],mo={class:"text-xs uppercase text-break"};function po(e,t,n,a,i,s){const u=E("Notification"),d=E("Release"),p=E("Campaign"),f=xe("click-outside");return r(),l(_,null,[o("div",Fi,[o("div",{class:"campaigns inline cursor-pointer text-center px-3 text-2xl",onClick:t[0]||(t[0]=m=>s.openCampaigns()),"aria-label":"Switch campaigns",tabindex:"0",role:"button"},[o("i",{class:g(s.campaignIcon()),"aria-hidden":"true"},null,2),Ai]),o("div",{class:"profile inline cursor-pointer text-center uppercase pt-1",onClick:t[1]||(t[1]=m=>s.openProfile()),"aria-label":"Profile settings",tabindex:"0",role:"button"},[o("div",zi,[i.show_alerts?(r(),l("span",Ri)):h("",!0),s.showInitials()?(r(),l("div",Oi,c(n.initials),1)):(r(),l("div",{key:2,class:"w-9 h-9 rounded-lg cover-background",style:L({backgroundImage:s.profilePictureUrl()})},null,4))])])]),i.is_expanded?W((r(),l("div",Ni,[i.is_loading?(r(),l("div",Bi,Ki)):(r(),l("div",Ui,[o("div",Vi,[o("div",{class:g(s.blockClass(i.view_campaigns)),onClick:t[2]||(t[2]=m=>s.openCampaigns()),tabindex:"0",role:"button","aria-label":"Campaign list"},[i.view_campaigns?(r(),l("div",Wi,[o("div",Yi,[o("i",{class:g(s.campaignIcon()),"aria-hidden":"true"},null,2)]),o("div",Gi,[o("div",Ji,c(i.campaigns.texts.campaigns),1),o("div",null,c(i.campaigns.texts.count),1)])])):(r(),l("div",{key:1,class:"flex items-center justify-center h-full text-2xl",title:i.campaigns.texts.campaigns},[o("i",{class:g(s.campaignIcon()),"aria-hidden":"true"},null,2)],8,Xi))],2),o("div",{class:g(s.blockClass(i.view_profile)),onClick:t[3]||(t[3]=m=>s.openProfile()),tabindex:"0",role:"button","aria-label":"Profile pane"},[i.view_profile?(r(),l("div",Zi,[s.showInitials()?(r(),l("div",ea,c(n.initials),1)):(r(),l("div",{key:1,class:"flex-none mr-4 w-9 h-9 rounded-lg cover-background",style:L({backgroundImage:s.profilePictureUrl()})},null,4)),o("div",ta,[o("div",na,c(i.profile.name),1),o("div",null,c(i.profile.created),1)])])):(r(),l("div",{key:1,class:"",title:i.profile.your_profile},[s.showInitials()?(r(),l("div",aa,c(n.initials),1)):(r(),l("div",{key:1,class:"flex-none w-9 h-9 rounded-lg cover-background",style:L({backgroundImage:s.profilePictureUrl()})},null,4))],8,ia))],2)]),i.view_profile?(r(),l("div",oa,[i.notifications.title?(r(),l("div",sa,[o("div",ra,[o("div",la,c(i.notifications.title),1),o("div",ca,[o("a",{href:i.notifications.all.url},c(i.notifications.all.text),9,da)])]),(r(!0),l(_,null,k(i.notifications.messages,m=>(r(),S(u,{notification:m},null,8,["notification"]))),256)),i.notifications.messages.length===0?(r(),l("div",ua,c(i.notifications.none),1)):h("",!0)])):h("",!0),i.releases.title&&i.releases.releases.length>0?(r(),l("div",fa,[o("div",ha,[o("div",ma,c(i.releases.title),1)]),(r(!0),l(_,null,k(i.releases.releases,m=>(r(),S(d,{release:m},null,8,["release"]))),256))])):h("",!0),!i.profile.is_impersonating&&i.marketplace.title?(r(),l("div",pa,[o("div",ga,[o("div",va,c(i.marketplace.title),1),o("div",_a,[o("a",{href:i.marketplace.explore.url,target:"_blank"},c(i.marketplace.explore.text),9,ya)])]),o("div",wa,[o("a",{href:i.marketplace.themes.url,class:"border py-2 text-center justify-center rounded-md hover:shadow-md",target:"_blank"},[$a,o("div",null,c(i.marketplace.themes.title),1),o("div",ka,c(i.marketplace.themes.number),1)],8,ba),o("a",{href:i.marketplace.sheets.url,class:"border py-2 text-center justify-center rounded-md hover:shadow-md",target:"_blank"},[Ca,o("div",null,c(i.marketplace.sheets.title),1),o("div",ja,c(i.marketplace.sheets.number),1)],8,xa),o("a",{href:i.marketplace.content.url,class:"border py-2 text-center justify-center rounded-md hover:shadow-md",target:"_blank"},[Ta,o("div",null,c(i.marketplace.content.title),1),o("div",Da,c(i.marketplace.content.number),1)],8,Sa)])])):h("",!0),i.profile.is_impersonating?h("",!0):(r(),l("div",Ia,[o("div",Ma,c(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",Ea,[o("img",{class:"w-16 h-16",src:i.profile.subscription.image,alt:i.profile.subscription.tier},null,8,Pa)]),o("div",qa,[o("div",Qa,c(i.profile.subscription.tier),1),i.profile.subscription.tier!=="Kobold"?(r(),l("div",Fa,[b(c(i.profile.subscription.created),1),Aa,b(" "+c(i.profile.subscription.boosters),1)])):(r(),l("div",za,[b(c(i.profile.subscription.call_to_action)+" ",1),o("div",Ra,c(i.profile.subscription.call_to_action_2),1)]))])],8,La)])),i.profile.is_impersonating?(r(),l("ul",Ya,[o("li",null,[o("a",{href:i.profile.return.url,class:"p-2 mb-2"},[Ja,b(" "+c(i.profile.return.name),1)],8,Ga)])])):(r(),l("ul",Oa,[o("li",null,[o("a",{href:i.profile.urls.settings.url,class:"p-2 mb-2 block"},[Ba,b(" "+c(i.profile.urls.settings.name),1)],8,Na)]),o("li",null,[o("a",{href:i.profile.urls.profile.url,class:"p-2 mb-2 block"},[Ka,b(" "+c(i.profile.urls.profile.name),1)],8,Ha)]),o("li",null,[o("a",{href:i.profile.urls.help.url,class:"p-2 mb-2 block",target:"_blank"},[Va,b(" "+c(i.profile.urls.help.name),1)],8,Ua)]),o("li",null,[o("a",{href:"#",onClick:t[4]||(t[4]=m=>s.logout()),class:"p-2 mb-2 block"},[Wa,b(" "+c(i.profile.urls.logout.name),1)])])]))])):(r(),l("div",Xa,[i.profile.is_impersonating?h("",!0):(r(),l("div",Za,[o("div",eo,[o("div",to,c(i.campaigns.texts.campaigns),1),i.campaigns.member.length>0?(r(),l("div",no,[o("a",{href:i.campaigns.urls.reorder},c(i.campaigns.texts.reorder),9,io)])):h("",!0)]),o("div",ao,[(r(!0),l(_,null,k(i.campaigns.member,m=>(r(),S(p,{campaign:m},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",so,[ro,b(" "+c(i.campaigns.texts.new),1)])],8,oo)]),i.profile.is_impersonating?h("",!0):(r(),l("div",lo,[co,o("p",uo,c(i.campaigns.texts.followed),1),o("div",fo,[(r(!0),l(_,null,k(i.campaigns.following,m=>(r(),S(p,{campaign:m},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",mo,c(i.campaigns.texts.follow),1)],8,ho)])]))]))]))]))])),[[f,s.onClickOutside]]):h("",!0)],64)}const go=j(Qi,[["render",po]]),vo=Ye(),A=We({});A.config.globalProperties.emitter=vo;A.component("nav-toggler",Bt);A.component("nav-search",Gn);A.component("nav-switcher",go);A.mount("#header");$(document).ready(function(){window.kankaIsMobile=window.matchMedia("only screen and (max-width: 760px)"),window.kankaIsMobile.matches||ve(),bo(),window.initForeignSelect(),ge(),wo();let e=$("#delete-confirm-form");e.length>0&&e.on("keyup keypress",function(t){var n=t.keyCode||t.which;if(n===13)return t.preventDefault(),!1}),_o(),yo(),re(),Be(),ae(),ye(),_e(),we(),ko(),be(),$(document).on("shown.bs.modal shown.bs.popover",function(){window.initForeignSelect(),window.initTags(),ae(),ve(),ge(),ye(),_e(),re(),be(),we()})});function ge(){$.isFunction($.fn.spectrum)&&$.each($(".spectrum"),function(){$(this).spectrum({preferredFormat:"hex",showInput:!0,showPalette:!0,allowEmpty:!0,appendTo:$(this).data("append-to")??null})})}function ve(){$('[data-toggle="tooltip"]').tooltip(),window.ajaxTooltip()}function _o(){let e=$(".list-treeview");if(e.length===0)return;let t=e.data("url");$.each($(".table-nested > tbody > tr"),function(){let n=$(this).data("children");parseInt(n)>0&&($(this).addClass("tr-hover cursor-pointer"),$(this).on("click",function(a){let i=$(a.target);a.target.type!=="checkbox"&&i.data("tree")!=="escape"&&(window.location=t+"?parent_id="+$(this).data("id")+"&m=table")}))})}function yo(){let e=$(".nav-tabs li a");e.click(function(n){n.preventDefault(),$(this).data("url")||$(this).tab("show")}),e.on("shown.bs.tab",function(n){n.preventDefault();let a=$(n.target).attr("href").substr(1),i=$(n.target).attr("ajax-modal"),s=$(n.target).data("nohash");if(i&&i==="ajax-modal"||s)return!0;window.location.hash="tab_"+a});let t=window.location.hash.replace("tab_","");$('ul.nav-tabs > li > a[href="'+t+'"]').tab("show")}function _e(){$.each($(".img-delete"),function(){$(this).unbind("click").click(function(e){e.preventDefault(),$("input[name="+$(this).data("target")+"]")[0].value=1,$(this).parent().parent().hide()})})}function ae(){$(".pagination-ajax-links a").on("click",function(e){e.preventDefault();var t=$(".pagination-ajax-body");return t.find(".loading").show(),t.find(".pagination-ajax-content").hide(),$.ajax($(this).attr("href")).done(function(n){t.parent().html(n),ae()}),!1})}function ye(){$('[data-toggle="confirm-delete"]').on("click",function(e){if(e.preventDefault(),$(this).data("confirming")===1){$(this).addClass("loading"),$(this).html("");let t=$(this).data("target");$(t).submit();return}$(this).data("confirming",1),$(this).find("span").html($(this).data("confirm"))}),$('a[data-toggle="delete-form"]').unbind("click").click(function(e){e.preventDefault();let t=$(this).data("target");$(t).submit()})}function wo(){$(".submenu-switcher").change(function(e){e.preventDefault();let t=$(this).find(":selected");window.location.href=t.data("route")})}function we(){$('[data-toggle="dialog"]').click(function(e){e.preventDefault();let t=$(this).data("target");t=document.getElementById(t),t.removeAttribute("open"),t.showModal(),t.addEventListener("click",function(n){let a=t.getBoundingClientRect();!(a.top<=n.clientY&&n.clientY<=a.top+a.height&&a.left<=n.clientX&&n.clientX<=a.left+a.width)&&n.target.tagName==="DIALOG"&&t.close()})}),$('[data-toggle="dialog-ajax"]').click(function(e){e.preventDefault();let t=$(this).data("target"),n=$(this).data("url");t=document.getElementById(t),t.removeAttribute("open"),t.showModal(),t.addEventListener("click",function(a){let i=t.getBoundingClientRect();!(i.top<=a.clientY&&a.clientY<=i.top+i.height&&i.left<=a.clientX&&a.clientX<=i.left+i.width)&&a.target.tagName==="DIALOG"&&t.close()}),$.ajax({url:n}).done(function(a){$(t).html(a).show(),$(document).trigger("shown.bs.modal"),$(".btn-manage-perm").click(function(i){i.preventDefault(),t.close();let s=$(this).data("target");$(s).click()}),$("#quick-privacy-select").change(function(){let i=$(this).data("url");$.ajax({url:i,type:"POST"}).done(function(s){window.showToast(s.toast),s.status?$("body").removeClass("kanka-entity-private"):$("body").addClass("kanka-entity-private")})})})})}function bo(){let e=0;const t={window:$(window).height(),header:$("header").length>0?$("header").outerHeight():0,footer:$(".main-footer").length>0?$(".main-footer").outerHeight():0,sidebar:$(".main-sidebar .sidebar").length>0?$(".main-sidebar .sidebar").height():0,controlSidebar:e};let n=$o(t),a=$(".content-wrapper");n===t.controlSidebar?a.css("min-height",n):n===t.window?a.css("min-height",n-t.header-t.footer):a.css("min-height",n-t.header)}function $o(e){let t=0;return Object.keys(e).forEach(n=>{e[n]>t&&(t=e[n])}),t}function ko(){$('.campaign-head[data-toggle="popover"]').popover()}const be=()=>{$.each($(".btn-feedback"),function(){$(this).data("feedback")!==1&&($(this).data("feedback",1),$(this).on("click",function(){$(this).addClass("loading")}))})}; diff --git a/public/build/assets/app-bc1d87fc.js b/public/build/assets/app-bc1d87fc.js deleted file mode 100644 index 8001e50e1d..0000000000 --- a/public/build/assets/app-bc1d87fc.js +++ /dev/null @@ -1 +0,0 @@ -import{d as re}from"./delete-confirm-fec6aa52.js";import{d as Be}from"./mention-5d95822d.js";import{a as $e}from"./ajax-modal-1230002e.js";import{S as ke}from"./sortable.esm-be94e56d.js";import{_ as x,c as l,a as o,t as c,o as r,n as L,w as He,b as h,F as _,r as b,d as w,e as g,f as C,g as E,h as W,i as Ke,v as Ue,j as Ve,k as xe,l as We}from"./_plugin-vue_export-helper-c420bb3b.js";import{m as Ye}from"./mitt-f7ef348c.js";import{v as Ce}from"./v-click-outside.umd-d5c5f7b0.js";import"./_commonjsHelpers-725317a4.js";$(document).ready(function(){window.initTags=function(){$.each($(".form-tags"),function(){let e=$(this).data("dropdown-parent");$(this).hasClass("select2-hidden-accessible")||$(this).select2({tags:$(this).data("allow-new"),allowClear:$(this).data("allow-clear"),dropdownParent:e||"",minimumInputLength:0,ajax:{quietMillis:500,delay:500,url:$(this).data("url"),dataType:"json",data:function(t){return{q:$.trim(t.term)}},processResults:function(t){return{results:t}},cache:!0},createTag:function(t){var n=$.trim(t.term);return n===""?null:{id:n,text:n,newTag:!0}},templateResult:function(t){var n=$(""+t.text+"");return t.colour&&(n=$(""+t.text+"")),n},templateSelection:function(t,n){if(t.newTag)return $(''+t.text+' ');let a=$(t.element);return t.colour?$(n).addClass(t.colour):a.data("colour")&&$(n).addClass(a.data("colour")),$(n).addClass("text-left"),t.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,a="Si us plau, elimina "+n+" car";return a+=n==1?"àcter":"àcters"},inputTooShort:function(t){var n=t.minimum-t.input.length,a="Si us plau, introdueix "+n+" car";return a+=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,a="Please delete "+n+" character";return n!=1&&(a+="s"),a},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,a="Por favor, elimine "+n+" car";return a+=n==1?"ácter":"acteres"},inputTooShort:function(t){var n=t.minimum-t.input.length,a="Por favor, introduzca "+n+" car";return a+=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/hr",[],function(){function t(n){var a=" "+n+" znak";return n%10<5&&n%10>0&&(n%100<5||n%100>19)?n%10>1&&(a+="a"):a+="ova",a}return{errorLoading:function(){return"Preuzimanje nije uspjelo."},inputTooLong:function(n){return"Unesite "+t(n.input.length-n.maximum)},inputTooShort:function(n){return"Unesite još "+t(n.minimum-n.input.length)},loadingMore:function(){return"Učitavanje rezultata…"},maximumSelected:function(n){return"Maksimalan broj odabranih stavki je "+n.maximum},noResults:function(){return"Nema rezultata"},searching:function(){return"Pretraga…"},removeAllItems:function(){return"Ukloni sve stavke"}}}),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,a="Per favore cancella "+n+" caratter";return a+=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",a="Er "+n+" maar "+t.maximum+" item";return t.maximum!=1&&(a+="s"),a+=" 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"],a=function(i,s){return i===1?s[0]:i>1&&i<=4?s[1]:i>=5?s[2]:void 0};return{errorLoading:function(){return"Nie można załadować wyników."},inputTooLong:function(i){var s=i.input.length-i.maximum;return"Usuń "+s+" "+a(s,t)},inputTooShort:function(i){var s=i.minimum-i.input.length;return"Podaj przynajmniej "+s+" "+a(s,t)},loadingMore:function(){return"Trwa ładowanie…"},maximumSelected:function(i){return"Możesz zaznaczyć tylko "+i.maximum+" "+a(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,a="Apague "+n+" caracter";return n!=1&&(a+="es"),a},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,a,i,s){return n%10<5&&n%10>0&&n%100<5||n%100>20?n%10>1?i:a:s}return{errorLoading:function(){return"Невозможно загрузить результаты"},inputTooLong:function(n){var a=n.input.length-n.maximum,i="Пожалуйста, введите на "+a+" символ";return i+=t(a,"","a","ов"),i+=" меньше"},inputTooShort:function(n){var a=n.minimum-n.input.length,i="Пожалуйста, введите ещё хотя бы "+a+" символ";return i+=t(a,"","a","ов")},loadingMore:function(){return"Загрузка данных…"},maximumSelected:function(n){var a="Вы можете выбрать не более "+n.maximum+" элемент";return a+=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 a=n.input.length-n.maximum;return a==1?"Prosím, zadajte o jeden znak menej":a>=2&&a<=4?"Prosím, zadajte o "+t[a](!0)+" znaky menej":"Prosím, zadajte o "+a+" znakov menej"},inputTooShort:function(n){var a=n.minimum-n.input.length;return a==1?"Prosím, zadajte ešte jeden znak":a<=4?"Prosím, zadajte ešte ďalšie "+t[a](!0)+" znaky":"Prosím, zadajte ešte ďalších "+a+" 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(a){return{q:$.trim(a.term)}},processResults:function(a){return{results:a}},error:function(a){return console.log("error",a),a.status===503&&window.showToast(a.responseJSON.message,"toast-error"),{results:[]}},cache:!0},templateResult:function(a){var i="";return a.image?i=$(""+a.text+""):i=$(""+a.text+""),i},createTag:function(a){return null}})}),$("select.select2-local").select2({placeholder:$(this).data("placeholder"),language:$(this).data("language"),allowClear:!0}),$("select.select2-colour").select2({allowClear:!1,templateResult:le,templateSelection:le}))}});function le(e){if(e.id==="none")return e.text;var t=$('
'+e.text+"
");return t}var U=Array();function Ge(){let t=$(this).data("id");if(t in U)return U[t];var n='
';return $.ajax({url:$(this).data("url"),method:"GET",async:!1,success:function(a){n=a}}),U[t]=n,n}window.ajaxTooltip=function(){$('[data-toggle="tooltip-ajax"]').tooltip({title:Ge,delay:500,trigger:"hover",placement:"auto",template:'',html:!0,sanitize:!1}),$('[data-toggle="tooltip-ajax"]').click(function(){$(this).tooltip("hide")})};$(document).ready(function(){$.each($("form"),function(){$(this).data("shortcut")&&Xe(this)}),Je(),Ze()});function Je(){$(document).bind("keydown",function(e){let t=$(e.target),n=$("#entity-modal"),a=$(".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&&a.length>0){if(z(t)||(n.data("bs.modal")||{}).isShown)return;a[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 Xe(e){$(document).bind("keydown",function(t){if((t.ctrlKey||t.metaKey)&&t.key.toLowerCase()==="s")return console.log("hey"),window.entityFormHasUnsavedChanges=!1,t.shiftKey?V("submit-update"):t.altKey&&V("submit-new"),$(e).submit(),!1;if((t.ctrlKey||t.metaKey)&&t.altKey&&t.key==="c")return window.entityFormHasUnsavedChanges=!1,V("submit-copy"),$(e).submit(),!1})}function V(e){let t=$("#form-submit-main");t&&(t.attr("name",e),$("#submit-mode").attr("name",e))}function Ze(){$('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('0){let i=Object.keys(a).filter(function(s){return!t||t!=a[s].id}).map(function(s){return''+a[s].name+""});i.length>0&&($("#duplicate-entities").html(i.join(", ")),e.fadeIn())}else e.hide()})})}function Se(){if(F=$(".form-submit-actions"),F.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(F,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 nt(){$.each($("form"),function(){$(this).on("submit",function(){window.entityFormHasUnsavedChanges=!1;var e=$(this).find(".btn-primary");return e.length>0&&($.each(e,function(){$(this).hasClass("dropdown-toggle")?$(this).prop("disabled",!0):$(this).prop("disabled",!0).addClass("loading")}),$(this).append('')),!0})})}function it(){j=$("#entity-calendar-form-add"),v=$('[name="calendar_id"]'),$(".entity-calendar-modal-form"),D=$(".entity-calendar-subform"),q=$("#entity-calendar-form-cancel"),Y=$(".entity-calendar-form"),S=$('input[name="calendar_year"]'),T=$('select[name="calendar_month"]'),k=$('select[name="calendar_day"]'),O=$(".entity-calendar-loading"),j.length===1&&(j.on("click",function(e){e.preventDefault(),j.hide(),Y.show();let t=$(this).data("default-calendar");return t&&(v.val(t),q.show(),D.fadeIn(),B(t)),!1}),q.on("click",function(e){e.preventDefault(),v.val(null),q.hide(),G()})),v.length===1&&v.on("change",function(){if(D.hide(),!$(this).val()){G();return}S=$('input[name="calendar_year"]'),T=$('select[name="calendar_month"]'),k=$('select[name="calendar_day"]'),S.length===0&&$('input[name="year"]').length===1&&(S=$('input[name="year"]'),T=$('select[name="month"]'),k=$('input[name="day"]')),B(v.val())}),ft()}function Te(){$("#entity-calendar-modal-add").length!==0&&(j=$("input[name=calendar-data-url]"),v=$('select[name="calendar_id"]'),S=$('input[name="year"]'),T=$('select[name="month"]'),k=$('input[name="day"]'),O=$(".entity-calendar-loading"),D=$(".entity-calendar-subform"),v.on("change",function(){if(D.hide(),!v.val()){G();return}B(v.val())}),v.val()&&(q.show(),D.fadeIn(),B(v.val())))}function at(){if($("#era-form-add").length===0)return;j=$("#era-form-add");let e=$('[name="era_id"]');je=e.val(),v.val()&&ce(e.val()),e.length===1&&e.on("change",function(){$('select[name="position"]'),ce(e.val())})}function B(e){O.show(),e=parseInt(e);var t=$('input[name="calendar-data-url"]').data("url").replace("/0/","/"+e+"/");$.ajax(t).done(function(n){let a=k.val();S.html(""),T.html(""),k.html("");let i=1,s=1;a||(a=n.current.day);let u=parseInt(n.current.month);$.each(n.months,function(d){let p=n.months[d],f=i===u?' selected="selected"':"";T.append('"),i===u&&(s=p.length),i++});for(let d=1;d"+d+"")}O.hide(),D.show(),S.val(n.current.year),$('select[name="calendar_recurring_periodicity"] option').remove(),$.each(n.recurring,function(d,p){$('select[name="calendar_recurring_periodicity"]').append('")}),$('input[name="length"]').val(1),n.length===1&&T.val(n[0].id),rt()})}function ce(e){e=parseInt(e);var t=$('input[name="era-data-url"]').data("url").replace("/0/","/"+e+"/"),n=$('input[name="oldPosition"]').data("url");$.ajax(t).done(function(a){let i=$('select[name="position"]');i.html("");let s=1;$.each(a.positions,function(u){let d=a.positions[u],p=' selected="selected"';n&&!u&&je==e&&i.append('"),u&&i.append('"),s++})})}function G(){Y.hide(),j.show(),$('input[name="calendar_day"]').val(null),$('input[name="calendar_month"]').val(null),$('input[name="calendar_year"]').val(null),$('input[name="calendar_id"]').val(null),console.log("finished?")}function ot(){if(F=$('form[data-unload="1"]'),F.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 De(){$('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"]').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 st(){$(".permission-toggle").change(function(){let t="input[data-action="+$(this).data("action")+"]";$(this).prop("checked")?$(t).prop("checked",!0):$(t).prop("checked",!1)})}function rt(){$.isFunction($.fn.spectrum)&&$(".spectrum").spectrum({preferredFormat:"hex",showInput:!0,showPalette:!0,allowEmpty:!0})}function Ie(){let e=$(".entity-story-block .collapse"),t=$(".entity-story-block .element-toggle");$(".btn-post-collapse").unbind("click").click(function(){return e.collapse("hide"),t.addClass("collapsed"),!1}),$(".btn-post-expand").unbind("click").click(function(){return e.collapse("show"),t.removeClass("collapsed"),!1})}function lt(){$(".sidebar-section-title").click(function(){$(this).next().hasClass("in")?($(this).find(".fa-chevron-down").hide(),$(this).find(".fa-chevron-right").show()):($(this).find(".fa-chevron-right").hide(),$(this).find(".fa-chevron-down").show())})}function Me(){$(".story-load-more").click(function(e){let t=$(this);return e.preventDefault(),$("#story-more-spinner").show(),$(this).hide(),$.ajax({url:$(this).data("url")}).done(function(n){t.parent().remove(),n&&($(".entity-posts").append(n),Me(),Ie(),window.ajaxTooltip())}).fail(function(){$("#story-more-spinner").hide(),t.show()}),!1})}function ct(){$(".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 a=new Date;a.setTime(a.getTime()+30*24*60*60*1e3),document.cookie=e+"="+t+";expires="+a.toUTCString()+";sameSite=Strict"})}function dt(){$(".dynamic-row-add").on("click",function(e){e.preventDefault();let t=$(this).data("target"),n=$(this).data("template");return $("."+t).append('
'+$("#"+n).html()+"
"),de(),!1}),de()}function de(){$.each($(".dynamic-row-delete"),function(){$(this).data("init")!==1&&($(this).data("init",1),$(this).on("click",function(e){e.preventDefault(),$(this).closest(".parent-delete-row").remove()}).on("keydown",function(e){e.key==="Enter"&&$(this).click()}))})}function ut(){$('input[data-toggle="entity-privacy"]').change(function(){let e=$("#entity-is-private");$(this).prop("checked")?e.show():e.hide()})}function ft(){$('select[name="calendar_month"]').change(function(){let e=$(this).find(":selected").data("length");ht(e)})}function ht(e){let t=k.val();t>e&&(t=e),k.html("");for(let n=1;n<=e;n++){let a=n==t?' selected="selected"':"";k.append('")}}var J;$(document).ready(function(){J=$(".post-perm-add"),J.length!==0&&(mt(),Le())});function mt(){J.on("click",function(e){e.preventDefault();let t=$(this).data("type"),n=$('select[name="'+t+'"]');if(!n||!n.val())return!1;let a=n.find(":selected")[0],i=$("#post-perm-"+t+"-template").clone().removeClass("hidden").removeAttr("id"),s=i.html().replace(/\$SELECTEDID\$/g,n.val()).replace(/\$SELECTEDNAME\$/g,a.text);return i.html(s).insertBefore($("#post-perm-target")),$("#post-new-"+t).modal("toggle"),Le(),n.val("").trigger("change"),!1})}function Le(){$.each($(".post-delete-perm"),function(){$(this).unbind("click"),$(this).on("click",function(){$(this).closest(".grid").remove()})})}var ue;$(document).ready(function(){ue=$("#calendar-year-switcher"),ue.length===1&&($("#calendar-year-switcher-field"),$("#add-calendar-event"),pt()),$(document).on("shown.bs.modal",function(){fe()}),$('select[name="recurring_periodicity"]').length===1&&fe(),gt()});function pt(){$(".calendar-event-block").each(function(){$(this).data("toggle")!=="ajax-modal"&&$(this).data("url")&&$(this).click(function(){window.location=$(this).data("url")})})}function fe(){$('select[name="recurring_periodicity"]').change(function(){this.value?$("#add_event_recurring_until").show():$("#add_event_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 gt(){$(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()})}var I,X=300*1e3,Ee,Z=!0;$(document).ready(function(){I=$("#entity-edit-warning"),I.length!==0&&(vt(),_t())});function vt(){Z=!1,I.modal({backdrop:!1}),$("#entity-edit-warning-ignore").click(function(e){e.preventDefault(),he(),Z=!0,$.ajax({url:$(this).data("url"),type:"POST",context:this}).done(function(){I.modal("hide")})}),$("#entity-edit-warning-back").click(function(e){e.preventDefault(),he(),window.location.href=$(this).data("url")})}function he(){I.find(".modal-ajax-body").hide(),I.find(".modal-spinner-body").show(),I.find(".modal-footer").hide()}function _t(){let e=$("#editing-keep-alive");e.length!==0&&(Ee=e.data("url"),setTimeout(ee,X))}function ee(){if(!Z){setTimeout(ee,X);return}$.ajax({url:Ee,type:"POST"}).done(function(){setTimeout(ee,X)})}var y="#entity-modal",R;$(document).ready(function(){$(document).on("shown.bs.modal shown.bs.popover",function(){K()}),$(".quick-creator-subform").click(function(){$.ajax({url:$(this).data("url")}).done(function(e){$(y).find(".modal-content").show().html(e),$(y).find(".modal-spinner").hide(),$(y).modal(),oe()})})});function K(){$('[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()):qe(),$.ajax({url:$(this).data("url"),context:this}).done(function(n){$(y).find(".modal-content").show().html(n),$(y).find(".modal-spinner").hide(),oe(),se()}),!1})}function Pe(){$("#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").fadeIn()}else $(this).parent().parent().find(".duplicate-entity-warning").hide()}))})}function qe(){$(y).find(".modal-content").hide(),$(y).find(".modal-spinner").show()}function oe(){R=$(".quick-creator-submit"),window.initForeignSelect(),window.initTags(),Pe(),Qe(),se(),R.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(),R.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 n=new Option(t._name,t._id),a=$("#"+t._target);if(t._multi){let i=a.val();i.push(t._id),a.append(n).val(i)}else a.children().remove().end().append(n).val(t._id);a.trigger("change"),$(y).find(".modal-content").html("").show(),$(y).find(".modal-spinner").hide(),$(y).modal("toggle"),te();return}$(y).find(".modal-content").html(t).show(),$(y).find(".modal-spinner").hide(),K(),te()}).fail(function(t){if(t.responseJSON.errors){let n=t.responseJSON.errors;Object.keys(n).forEach(function(u){let d=$('#entity-creator-form [name="'+u+'"]');d.length>0&&d.addClass("input-error").parent().append('
'+n[u][0]+"
")});let i=Object.keys(n)[0],s=$('#entity-creator-form input[name="'+i+'"]');if(s[0]){s[0].scrollIntoView({behavior:"smooth"}),$(".tab-content .active").removeClass("active"),$(".nav-tabs li.active").removeClass("active");let u=$('[name="'+i+'"').closest(".tab-pane");u.addClass("active"),$('a[href="#'+u.attr("id")+'"]').closest("li").addClass("active")}}R.prop("disabled",!1).find("i.fa-spin").hide().parent().find("span").show(),$('#entity-creator-form [name="action"]').val("")})})}function Qe(){$("#entity-creator-back").click(function(e){e.preventDefault(),qe(),$.ajax({url:$(this).data("url"),context:this}).done(function(t){let n=$(this).data("target");$(n).find(".modal-content").html(t).show(),$(n).find(".modal-spinner").hide(),K()})})}function se(){$(".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){$("#entity-modal").find(".modal-content").html(t).show(),te()}))}),$(".qq-action-more").unbind("click").on("click",function(e){e.preventDefault(),$(this).hide(),$(".qq-more-fields").show()}),K()}function te(){se(),Pe(),Qe(),oe(),window.initForeignSelect(),window.initTags()}var M,Q,yt=new IntersectionObserver(function(e){e[0].isIntersecting===!0&&ie($(".datagrid-onload"))},{threshold:[0]});$(document).ready(function(){Ae(),Fe(),H(),bt()});function Fe(){$("[data-bulk-action]").on("click",function(){wt($(this).data("bulk-action"))}),$(".bulk-print").on("click",function(e){e.preventDefault();let t=$(this).closest("form");t.find(),t.submit()})}function Ae(){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)}),H()}),$.each($("input[name='model[]']"),function(){$(this).change(function(t){H(),t.preventDefault()})})}function wt(e){var t=[];$.each($("input[name='model[]']"),function(){$(this).prop("checked")&&t.push($(this).val())}),$("#datagrid-bulk-"+e+"-models").val(t.toString())}function H(){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 bt(){ne(),ze(),$t(),H(),ne()}function ne(){$(".datagrid-bulk").click(function(e){e.preventDefault(),M=$(this).closest("form");let t=[];$.each($("input[name='model[]']"),function(){$(this).prop("checked")&&t.push($(this).val())}),$.ajax({url:M.attr("action")+"?action=edit",method:"POST",data:{model:t}}).done(function(n){$("#entity-modal").find(".modal-content").html(n),$("#entity-modal").modal()})}),$(".datagrid-submit").click(function(e){if(e.preventDefault(),M=$(this).closest("form"),M.find('input[name="action"]').val($(this).data("action")),$(this).data("action")==="delete")return $("#datagrid-bulk-delete").modal(),!1;$(".datagrid-bulk-actions").hide(),$(".datagrid-spinner").show(),M.submit()}),$("#datagrid-action-confirm").click(function(){$("#datagrid-bulk-delete").modal("hide"),M.submit()})}function ze(){$.each($('table[data-render="datagrid2"]'),function(){Q=$(this),$(this).find("thead a").click(function(e){e.preventDefault(),ie($(this))}),$(this).closest("#datagrid-parent").find('nav[role="navigation"] a').click(function(e){e.preventDefault(),ie($(this))})}),Ae(),Fe(),ne()}function $t(){$(".datagrid-onload").length!=0&&yt.observe(document.querySelector(".datagrid-onload"))}function ie(e){Q.find("thead").hide(),Q.find("tbody").hide(),Q.find("tfoot").fadeIn();let t=e.attr("href"),n=e.data("url");t==="#"&&n&&(t=n);let a=e.data("target")??"#datagrid-parent";$.ajax(t).done(function(i){i.html&&$(a).html(i.html),i.deletes&&$("#datagrid-delete-forms").html(i.deletes),i.url&&window.history.pushState({},"",i.url),ze(),$(document).trigger("shown.bs.modal"),$e()}).fail(function(i){console.error("datagrid2",i),Q.find("tfoot").addClass("bg-danger")})}$(document).ready(function(){kt(),xt()});function kt(){let e=$("#quick-link-selector");if(e.length===0)return!1;e.change(function(t){t.preventDefault();let n=$(this).find(":selected");$(".quick-link-subform").hide();let a=n.data("target");$(a).show()})}function xt(){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(){Ct()});function Ct(){let e=$("#post-layout-selector");if(e.length===0)return!1;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(){me()}),$(".form-members").count!==0&&me()});function me(){$.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(){jt(),St(),Tt(),It(),Mt(),Lt(),Dt(),Et()});function jt(){$.each($(".form-rpg-systems"),function(){$(this).select2({multiple:!0,allowClear:!0,minimumInputLength:0})})}function St(){$("#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"),$.ajax({method:"post",url:$(this).data("url"),context:this}).done(function(n){n.success&&(n.status?$(this).closest(".box-module").addClass("module-enabled"):$(this).closest(".box-module").removeClass("module-enabled"),window.showToast(n.toast)),$(this).closest(".box-module").find("h3").removeClass("loading")}))})}function Tt(){$(".btn-user-roles").popover({html:!0,sanitize:!1,trigger:"focus"})}function Dt(){$(".public-permission").click(function(e){e.preventDefault(),$(this).addClass("loading"),$.ajax({method:"post",url:$(this).data("url"),context:this}).done(function(t){$(this).removeClass("loading"),t.success&&(t.status?$(this).addClass("enabled"):$(this).removeClass("enabled"),window.showToast(t.toast))})})}function It(){$.each($(".codemirror"),function(){let e=$(this).attr("id");CodeMirror.fromTextArea(document.getElementById(e),{extraKeys:{"Ctrl-Space":"autocomplete"},lineNumbers:!0,lineWrapping:!0,theme:"dracula"})})}function Mt(){let e=[].slice.call(document.querySelectorAll(".nested-sortable"));for(let t=0;t0;return!(i.classList.contains("fixed-position")&&u)}})}function Lt(){let e=$(".campaign-export-btn");e.length!==0&&e.click(function(t){t.preventDefault(),$(this).addClass("loading"),$.ajax({url:e.data("url"),method:"POST",context:this}).done(function(n){$(this).removeClass("loading").hide(),n.error?window.showToast(n.error,"toast-error"):window.showToast(n.success)}).fail(function(n){console.error("campaign export call",n)})})}function Et(){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)})}$(document).ready(function(){pe(),$(document).on("shown.bs.modal shown.bs.popover",function(){pe()})});function pe(){$("[data-clipboard]").length!==0&&$.each($("[data-clipboard]"),function(e){let t=$(this);t.data("loaded")!=1&&(t.data("loaded",1),t.click(function(n){Pt($(this).data("clipboard"),$(this));let a=$(this).data("toast");return a&&window.showToast(a),!1}))})}async function Pt(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(a){console.error(a)}finally{n.remove()}}}$(document).ready(function(){Re()});function Re(){$('.toast-container [data-toggle="dismiss"]').unbind("click").on("click",function(e){e.preventDefault(),$(this).parent().parent().fadeOut()})}window.showToast=function(e,t){t=t||"toast-success";let n=$('
');n.html(''+e+'this.options.collapseScreenSize?e("body").removeClass(i.collapsed).trigger(e.Event(s.expanded)):e("body").addClass(i.open).trigger(e.Event(s.expanded))},u.prototype.close=function(){var f=e(window).width();f>this.options.collapseScreenSize?e("body").addClass(i.collapsed).trigger(e.Event(s.collapsed)):e("body").removeClass(i.open+" "+i.collapsed).trigger(e.Event(s.collapsed))},u.prototype.expandOnHover=function(){e(a.mainSidebar).hover(function(){e("body").is(a.mini+a.collapsed)&&e(window).width()>this.options.collapseScreenSize&&this.expand()}.bind(this),function(){e("body").is(a.expanded)&&this.collapse()}.bind(this))},u.prototype.expand=function(){setTimeout(function(){e("body").removeClass(i.collapsed).addClass(i.expanded)},this.options.expandTransitionDelay)},u.prototype.collapse=function(){setTimeout(function(){e("body").removeClass(i.expanded).addClass(i.collapsed)},this.options.expandTransitionDelay)};function d(f){return this.each(function(){var m=e(this),P=m.data(t);if(!P){var Ne=e.extend({},n,m.data(),typeof f=="object"&&f);m.data(t,P=new u(Ne))}f==="toggle"&&P.toggle()})}var p=window.$.fn.pushMenu;window.$.fn.pushMenu=d,window.$.fn.pushMenu.Constructor=u,window.$.fn.pushMenu.noConflict=function(){return window.$.fn.pushMenu=p,this},window.$(document).on("click",a.button,function(f){f.preventDefault(),d.call(window.$(this),"toggle")}),window.$(window).on("load",function(){d.call(window.$(a.button))})}(jQuery);$(window).ready(function(){qt()});function qt(){$(".banner-notification-dismiss").click(function(e){e.preventDefault(),$.post({url:$(this).data("url"),method:"POST",context:this}).done(function(){let t=$(this).data("dismiss");t&&$(this).closest("."+t).fadeOut()})})}window.initSortable=function(){var e=document.querySelectorAll(".sortable-elements"),t;if(e.length!==0)for(t=0;t{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,"toast-error");return}if(e.status===403){$("#entity-form-403-error").show();return}let n=e.responseJSON.errors,a=[],i=Object.keys(n),s=!0;if(i.forEach(function(f){let m=$('[name="'+f+'"]');m.length>0?m.addClass("input-error").parent().append('
'+n[f][0]+"
"):(s=!1,a.push(n[f][0]))}),!s){let f=$("#entity-form-generic-error .error-logs");f.html(""),a.forEach(function(m){let P=m+"
";f.append(P)}),$("#entity-form-generic-error").show()}if($(this).find(".tab-content").length===0)return;let u=Object.keys(n)[0],d=document.getElementsByName(u);if(!d[0])return;d[0].scrollIntoView({behavior:"smooth"}),$(".tab-content .active").removeClass("active"),$(".nav-tabs li.active").removeClass("active");let p=$('[name="'+u+'"').closest(".tab-pane");p.addClass("active"),$('a[href="#'+p.attr("id")+'"]').closest("li").addClass("active")};const Qt={props:{text:String,title:String}},Ft={class:"mx-5"},At=["title"],zt=o("i",{class:"fa-solid fa-chevrons-left","aria-hidden":"true","data-sidebar":"collapse"},null,-1),Rt=o("i",{class:"fa-solid fa-chevrons-right","aria-hidden":"true","data-sidebar":"expand"},null,-1),Ot={class:"sr-only"};function Nt(e,t,n,a,i,s){return r(),l("div",Ft,[o("span",{role:"button",class:"sidebar-toggle text-center cursor-pointer","data-toggle":"tooltip",title:n.title,"data-placement":"right","data-html":"true",tabindex:"3"},[zt,Rt,o("span",Ot,c(n.text),1)],8,At)])}const Bt=x(Qt,[["render",Nt]]),Ht={props:["entity"],methods:{backgroundImage:function(e){return"url('"+e.image+"')"},preview:function(e){this.emitter.emit("preview",e)}}},Kt=["data-id"],Ut={class:"flex-none"},Vt=["href","title"],Wt={class:"flex-grow truncate pl-1"},Yt=["title"],Gt={class:"entity-type text-xs"};function Jt(e,t,n,a,i,s){return r(),l("div",{class:"flex justify-center gap-1 mb-1 cursor-pointer hover:bg-base-200 rounded p-1 w-full","data-id":n.entity.id,onClick:t[1]||(t[1]=u=>s.preview(n.entity))},[o("div",Ut,[o("a",{href:n.entity.link,style:L({backgroundImage:s.backgroundImage(n.entity)}),onClick:t[0]||(t[0]=He(()=>{},["stop"])),title:n.entity.name,class:"rounded cover-background block h-16 w-16"},null,12,Vt)]),o("div",Wt,[o("div",{class:"font-extrabold entity-name truncate",title:n.entity.name},c(n.entity.name),9,Yt),o("div",Gt,c(n.entity.type),1)])],8,Kt)}const Oe=x(Ht,[["render",Jt]]),Xt={props:["entity"],components:{LookupEntity:Oe},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 mr-2 bg-base-100 text-black text-xs mb-1";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}}},Zt={class:"entity-header p-3 bg-entity-focus"},en={class:"block w-full flex items-center"},tn=["href","title"],nn={key:0,class:"fa-solid fa-skull mx-2","aria-hidden":"true"},an=["href"],on=o("i",{class:"fa-solid fa-external-link","aria-hidden":"true","aria-label":"Open in a new window"},null,-1),sn=[on],rn={key:0,class:"block w-full"},ln={key:1,class:"my-1 w-full"},cn=["href"],dn=["href","data-tag"],un=o("i",{class:"ra ra-tower","aria-hidden":"true","aria-label":"Location"},null,-1),fn=["href","title"],hn={class:"entity-sections"},mn={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"},pn={key:0,class:"tab-profile p-5"},gn={key:0,class:"entity-pinned-attributes"},vn=["data-attribute","data-target"],_n={class:"inline-block uppercase font-extrabold mr-1"},yn=["innerHTML"],wn=o("hr",null,null,-1),bn={class:"uppercase font-extrabold truncate"},$n={key:1,class:"tab-links p-3"},kn={key:0,class:"text-center italic"};function xn(e,t,n,a,i,s){const u=E("LookupEntity");return r(),l(_,null,[o("div",Zt,[o("div",en,[o("a",{class:"text-2xl font-extrabold entity-name",href:n.entity.link,title:n.entity.name},c(n.entity.name),9,tn),n.entity.is_dead?(r(),l("i",nn)):h("",!0),o("a",{class:"ml-2 text-xs",target:"_blank",href:n.entity.link},sn,8,an)]),s.hasTitle()?(r(),l("div",rn,c(n.entity.title),1)):h("",!0),n.entity.tags.length>0?(r(),l("div",ln,[(r(!0),l(_,null,b(n.entity.tags,d=>(r(),l("a",{class:g(s.tagClass(d)),href:d.link},c(d.name),11,cn))),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},[un,w(" "+c(n.entity.location.name),1)],8,dn)):h("",!0),n.entity.image?(r(),l("a",{key:3,href:n.entity.link,style:L({backgroundImage:s.backgroundImage()}),title:n.entity.name,class:"rounded cover-background block w-full aspect-square"},null,12,fn)):h("",!0)]),o("div",hn,[o("div",mn,[o("div",{class:g(s.tabClass("profile")),onClick:t[0]||(t[0]=d=>s.switchTab("profile"))},c(n.entity.texts.profile),3),o("div",{class:g(s.tabClass("links")),onClick:t[1]||(t[1]=d=>s.switchTab("links"))},c(n.entity.texts.connections),3),o("div",{class:g(s.tabClass("access")),onClick:t[2]||(t[2]=d=>s.switchTab("access"))},null,2)]),i.focus_profile?(r(),l("div",pn,[n.entity.attributes.length>0?(r(),l("div",gn,[(r(!0),l(_,null,b(n.entity.attributes,d=>(r(),l("div",{class:"mb-3","data-attribute":d.name,"data-target":d.id},[o("span",_n,c(d.name),1),o("span",{innerHTML:d.value},null,8,yn)],8,vn))),256)),wn])):h("",!0),(r(!0),l(_,null,b(n.entity.profile,d=>(r(),l("div",{class:g(["mb-3",s.profileClass(d)])},[o("div",bn,c(d.field),1),o("div",null,c(d.value),1)],2))),256))])):h("",!0),i.focus_pins?(r(),l("div",$n,[(r(!0),l(_,null,b(n.entity.connections,d=>(r(),C(u,{entity:d},null,8,["entity"]))),256)),n.entity.connections.length===0?(r(),l("p",kn,c(n.entity.texts["no-connections"]),1)):h("",!0)])):h("",!0)])],64)}const Cn=x(Xt,[["render",xn]]),jn={directives:{clickOutside:Ce.directive},props:{api_lookup:String,api_recent:String,placeholder:String,keyboard_tooltip:String},components:{LookupEntity:Oe,EntityPreview:Cn},data(){return{has_drawer:!1,term:null,show_loading:!1,show_recent:!1,show_preview:!1,show_results:!1,recent:[],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);axios.get(this.api_lookup,{params:{q:e,v2:!0}}).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,axios.get(this.api_recent).then(e=>{this.recent=e.data.recent,this.texts.recents=e.data.texts.recents,this.texts.results=e.data.texts.results,this.texts.hint=e.data.texts.hint,this.texts.keyboard=e.data.texts.keyboard,this.texts.empty_results=e.data.texts.empty_results,this.show_loading=!1,this.show_recent=!0,this.has_recent=!0}).catch(e=>{this.show_loading=!1,this.show_recent=!0,this.has_recent=!1})},parseLookupResponse(e,t){this.results=e.data.entities,this.cached[t]=e.data.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,axios.get(e.preview).then(t=>{this.parsePreviewResponse(t)})},parsePreviewResponse(e){this.preview_entity=e.data,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()}},mounted(){this.emitter.on("preview",e=>{this.loadPreview(e)})}},Sn={class:"flex grow mr-2"},Tn={class:"relative grow"},Dn=["placeholder"],In={class:"form-control-feedback hidden-xs hidden-sm"},Mn=["title"],Ln={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"},En={key:0,class:"text-center"},Pn=o("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true","aria-label":"Loading"},null,-1),qn=[Pn],Qn={key:1,class:"search-recent bg-lookup p-2 min-h-full shadow-r flex flex-col items-stretch"},Fn={key:0,class:"flex-none"},An={class:"italic text-xs text-center"},zn={class:"grow"},Rn={key:0,class:"search-results mb-2"},On={class:"text-sm uppercase mb-2 my-2 mx-1"},Nn={key:0,class:"italic m-2"},Bn={key:1,class:"recent-searches"},Hn={class:"text-sm uppercase my-2 mx-1"},Kn={key:1,class:"flex-none text-xs text-center"},Un=o("hr",null,null,-1),Vn=["innerHTML"],Wn={key:2,class:"search-preview bg-lookup min-h-full shadow-r"};function Yn(e,t,n,a,i,s){const u=E("LookupEntity"),d=E("EntityPreview"),p=xe("click-outside");return W((r(),l("div",Sn,[o("div",Tn,[W(o("input",{type:"text",class:"form-control 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=>s.focus()),onFocus:t[2]||(t[2]=f=>s.focus()),onKeydown:t[3]||(t[3]=Ke(f=>s.escape(),["esc"])),placeholder:n.placeholder},null,40,Dn),[[Ue,i.term]]),o("span",In,[o("span",{class:"flex-none keyboard-shortcut py-1",id:"lookup-kb-shortcut","data-toggle":"tooltip",title:n.keyboard_tooltip,"data-html":"true","data-placement":"bottom"},"K",8,Mn)])]),i.show_recent||i.show_loading||i.show_preview?(r(),l("aside",Ln,[i.show_loading?(r(),l("div",En,qn)):h("",!0),i.show_recent?(r(),l("div",Qn,[i.show_results?h("",!0):(r(),l("div",Fn,[o("p",An,c(i.texts.hint),1)])),o("div",zn,[i.show_results?(r(),l("div",Rn,[o("div",On,c(i.texts.results),1),i.results.length===0?(r(),l("div",Nn,c(i.texts.empty_results),1)):(r(!0),l(_,{key:1},b(i.results,f=>(r(),C(u,{entity:f},null,8,["entity"]))),256))])):h("",!0),i.recent.length>0?(r(),l("div",Bn,[o("div",Hn,c(i.texts.recents),1),(r(!0),l(_,null,b(i.recent,f=>(r(),C(u,{entity:f},null,8,["entity"]))),256))])):h("",!0)]),i.show_loading?h("",!0):(r(),l("div",Kn,[Un,o("p",{class:"italic text-xs text-center",innerHTML:i.texts.keyboard},null,8,Vn)]))])):h("",!0),i.show_preview?(r(),l("div",Wn,[Ve(d,{entity:i.preview_entity},null,8,["entity"])])):h("",!0)])):h("",!0)])),[[p,s.onClickOutside]])}const Gn=x(jn,[["render",Yn]]),Jn={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":"")}}},Xn=["href","title"],Zn=["innerHTML"];function ei(e,t,n,a,i,s){return r(),l("a",{class:g(s.campaignClass(n.campaign)),href:n.campaign.url,style:L({backgroundImage:s.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,Zn)],14,Xn)}const ti=x(Jn,[["render",ei]]),ni={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 mb-2 px-2 py-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)})}}},ii=["href","data-id"],ai={class:"flex-none p-2"},oi=["innerHTML"],si=["title"],ri=o("i",{class:"fa-solid fa-times","aria-hidden":"true"},null,-1),li=[ri],ci={key:1,class:"flex-none p-2"},di=o("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),ui=[di],fi=["data-id"],hi={class:"flex-none p-2"},mi=["innerHTML"],pi=["title"],gi=o("i",{class:"fa-solid fa-times","aria-hidden":"true"},null,-1),vi=[gi],_i={key:1,class:"flex-none p-2"},yi=o("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),wi=[yi];function bi(e,t,n,a,i,s){return n.notification.url&&!i.is_dismissed?(r(),l("a",{key:0,class:g(s.backgroundClass(n.notification)),href:n.notification.url,"data-id":n.notification.id},[o("div",ai,[o("i",{class:g(s.iconClass(n.notification)),"aria-hidden":"true"},null,2)]),o("div",{class:"flex-grow p-2",innerHTML:n.notification.text},null,8,oi),this.is_loading?(r(),l("div",ci,ui)):(r(),l("div",{key:0,class:"flex-none p-2 cursor-pointer dismissable",onClick:t[0]||(t[0]=u=>s.dismiss(n.notification)),title:n.notification.dismiss_text},li,8,si))],10,ii)):i.is_dismissed?h("",!0):(r(),l("div",{key:1,class:g(s.backgroundClass(n.notification)),"data-id":n.notification.id},[o("div",hi,[o("i",{class:g(s.iconClass(n.notification)),"aria-hidden":"true"},null,2)]),o("div",{class:"flex-grow p-2",innerHTML:n.notification.text},null,8,mi),this.is_loading?(r(),l("div",_i,wi)):(r(),l("div",{key:0,class:"flex-none p-2 cursor-pointer dismissable",onClick:t[1]||(t[1]=u=>s.dismiss(n.notification)),title:n.notification.dismiss_text},vi,8,pi))],10,fi))}const $i=x(ni,[["render",bi]]),ki={props:["release"],data(){return{is_dismissed:!1,is_loading:!1}},methods:{backgroundClass:function(e){return"release bg-base-200 flex justify-center items-center mb-2 px-2 py-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)})}}},xi=["data-id"],Ci={class:"flex-grow p-2"},ji=["innerHTML","href"],Si=["innerHTML"],Ti=["title"],Di=o("i",{class:"fa-solid fa-times","aria-hidden":"true"},null,-1),Ii=[Di],Mi={key:1,class:"flex-none p-2"},Li=o("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),Ei=[Li];function Pi(e,t,n,a,i,s){return i.is_dismissed?h("",!0):(r(),l("div",{key:0,class:g(s.backgroundClass(n.release)),"data-id":n.release.id},[o("div",Ci,[o("a",{innerHTML:n.release.title,class:"font-bold cursor-pointer block w-full",href:n.release.url,target:"_blank"},null,8,ji),o("p",{innerHTML:n.release.text},null,8,Si)]),this.is_loading?(r(),l("div",Mi,Ei)):(r(),l("div",{key:0,class:"flex-none p-2 cursor-pointer dismissable",onClick:t[0]||(t[0]=u=>s.dismiss(n.release)),title:n.release.dismiss_text},Ii,8,Ti))],10,xi))}const qi=x(ki,[["render",Pi]]),Qi={directives:{clickOutside:Ce.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},pro:{type:Boolean}},components:{Campaign:ti,Notification:$i,Release:qi},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,axios.get(this.api).then(e=>{this.profile=e.data.profile,this.campaigns=e.data.campaigns,this.notifications=e.data.notifications,this.marketplace=e.data.marketplace,this.releases=e.data.releases,this.show_alerts=e.data.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||e{localStorage.setItem("notification-has-alerts-"+this.user_id,t.data.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+")"},campaignIcon:function(){return this.pro?"fa-solid fa-grid":"fa-solid fa-grip"}},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()}},Fi={class:"nav-switcher flex items-center justify-center h-12"},Ai=o("span",{class:"sr-only"},"Campaigns",-1),zi={class:"indicator relative inline-flex w-max"},Ri={key:0,class:"notification-badge left-auto top-auto w-fit inline-flex absolute content-center items-center z-10"},Oi={key:1,class:"profile-box rounded-lg p-2 text-center font-bold"},Ni={key:0,class:"navigation-drawer bg-base-100 h-full overflow-y-auto safsdf fixed top-0 right-0 rounded-l-2xl shadow-lg"},Bi={key:0,class:"temporary p-8 text-center"},Hi=o("i",{class:"fa-solid fa-spinner fa-spin","aria-hidden":"true"},null,-1),Ki=[Hi],Ui={key:1,class:""},Vi={class:"header flex"},Wi={key:0,class:"full flex items-center"},Yi={class:"flex-none mr-4 text-2xl"},Gi={class:"flex-grow"},Ji={class:"font-bold"},Xi=["title"],Zi={key:0,class:"full flex items-center"},ea={key:0,class:"flex-none mr-4 profile-box rounded-lg p-2 text-center uppercase font-bold"},ta={class:"flex-grow"},na={class:"font-bold"},ia=["title"],aa={key:0,class:"flex-none profile-box rounded-lg p-2 text-center uppercase font-bold"},oa={key:0,class:"profile p-5"},sa={key:0,class:"notifications mb-5"},ra={class:"flex w-full py-2"},la={class:"flex-grow uppercase font-bold"},ca={class:"flex-grow text-right"},da=["href"],ua={key:0,class:"no-notifications help-block italic"},fa={key:1,class:"releases mb-5"},ha={class:"flex w-full py-2"},ma={class:"flex-grow uppercase font-bold"},pa={key:2,class:"marketplace mb-5"},ga={class:"flex w-full py-2"},va={class:"flex-grow uppercase font-bold"},_a={class:"flex-grow text-right"},ya=["href"],wa={class:"grid grid-cols-3 gap-2"},ba=["href"],$a=o("div",{class:"icon bg-base-200 rounded-full w-14 h-14 mb-1 text-3xl inline-block aspect-square"},[o("i",{class:"fa-solid fa-palette mt-3","aria-hidden":"true"})],-1),ka={class:"text-muted text-xs"},xa=["href"],Ca=o("div",{class:"icon bg-base-200 rounded-full w-14 h-14 mb-1 text-3xl inline-block aspect-square"},[o("i",{class:"fa-solid fa-columns mt-3","aria-hidden":"true"})],-1),ja={class:"text-muted text-xs"},Sa=["href"],Ta=o("div",{class:"icon bg-base-200 rounded-full w-14 h-14 mb-1 text-3xl inline-block aspect-square"},[o("i",{class:"fa-solid fa-dice-d20 mt-3","aria-hidden":"true"})],-1),Da={class:"text-muted text-xs"},Ia={key:3,class:"subscription mb-5"},Ma={class:"uppercase font-bold py-2"},La=["href"],Ea={class:"flex-none p-2"},Pa=["src","alt"],qa={class:"flex-grow p-2"},Qa={class:"font-bold text-lg"},Fa={key:0,class:"more"},Aa=o("br",null,null,-1),za={key:1,class:"more"},Ra={class:"link"},Oa={key:4,class:"m-0 p-0 list-none"},Na=["href"],Ba=o("i",{class:"fa-solid fa-cog mr-3","aria-hidden":"true"},null,-1),Ha=["href"],Ka=o("i",{class:"fa-solid fa-user mr-3","aria-hidden":"true"},null,-1),Ua=["href"],Va=o("i",{class:"fa-solid fa-question-circle mr-3","aria-hidden":"true"},null,-1),Wa=o("i",{class:"fa-solid fa-sign-out mr-3","aria-hidden":"true"},null,-1),Ya={key:5,class:"m-0 p-0 list-none"},Ga=["href"],Ja=o("i",{class:"fa-solid fa-sign-out-alt mr-3","aria-hidden":"true"},null,-1),Xa={key:1,class:"campaigns p-5"},Za={key:0},eo={class:"flex w-full py-2"},to={class:"flex-grow uppercase font-bold"},no={key:0,class:"flex-grow text-right"},io=["href"],ao={class:"grid grid-cols-2 md:grid-cols-3 gap-5"},oo=["href"],so={class:"text-xs text-break uppercase"},ro=o("i",{class:"fa-solid fa-plus","aria-hidden":"true",style:{display:"none"}},null,-1),lo={key:0,class:"following"},co=o("hr",null,null,-1),uo={class:"uppercase"},fo={class:"grid grid-cols-2 md:grid-cols-3 gap-5"},ho=["href"],mo={class:"text-xs uppercase text-break"};function po(e,t,n,a,i,s){const u=E("Notification"),d=E("Release"),p=E("Campaign"),f=xe("click-outside");return r(),l(_,null,[o("div",Fi,[o("div",{class:"campaigns inline cursor-pointer text-center px-3 text-2xl",onClick:t[0]||(t[0]=m=>s.openCampaigns()),"aria-label":"Switch campaigns",tabindex:"0",role:"button"},[o("i",{class:g(s.campaignIcon()),"aria-hidden":"true"},null,2),Ai]),o("div",{class:"profile inline cursor-pointer text-center uppercase pt-1",onClick:t[1]||(t[1]=m=>s.openProfile()),"aria-label":"Profile settings",tabindex:"0",role:"button"},[o("div",zi,[i.show_alerts?(r(),l("span",Ri)):h("",!0),s.showInitials()?(r(),l("div",Oi,c(n.initials),1)):(r(),l("div",{key:2,class:"w-9 h-9 rounded-lg cover-background",style:L({backgroundImage:s.profilePictureUrl()})},null,4))])])]),i.is_expanded?W((r(),l("div",Ni,[i.is_loading?(r(),l("div",Bi,Ki)):(r(),l("div",Ui,[o("div",Vi,[o("div",{class:g(s.blockClass(i.view_campaigns)),onClick:t[2]||(t[2]=m=>s.openCampaigns()),tabindex:"0",role:"button","aria-label":"Campaign list"},[i.view_campaigns?(r(),l("div",Wi,[o("div",Yi,[o("i",{class:g(s.campaignIcon()),"aria-hidden":"true"},null,2)]),o("div",Gi,[o("div",Ji,c(i.campaigns.texts.campaigns),1),o("div",null,c(i.campaigns.texts.count),1)])])):(r(),l("div",{key:1,class:"flex items-center justify-center h-full text-2xl",title:i.campaigns.texts.campaigns},[o("i",{class:g(s.campaignIcon()),"aria-hidden":"true"},null,2)],8,Xi))],2),o("div",{class:g(s.blockClass(i.view_profile)),onClick:t[3]||(t[3]=m=>s.openProfile()),tabindex:"0",role:"button","aria-label":"Profile pane"},[i.view_profile?(r(),l("div",Zi,[s.showInitials()?(r(),l("div",ea,c(n.initials),1)):(r(),l("div",{key:1,class:"flex-none mr-4 w-9 h-9 rounded-lg cover-background",style:L({backgroundImage:s.profilePictureUrl()})},null,4)),o("div",ta,[o("div",na,c(i.profile.name),1),o("div",null,c(i.profile.created),1)])])):(r(),l("div",{key:1,class:"",title:i.profile.your_profile},[s.showInitials()?(r(),l("div",aa,c(n.initials),1)):(r(),l("div",{key:1,class:"flex-none w-9 h-9 rounded-lg cover-background",style:L({backgroundImage:s.profilePictureUrl()})},null,4))],8,ia))],2)]),i.view_profile?(r(),l("div",oa,[i.notifications.title?(r(),l("div",sa,[o("div",ra,[o("div",la,c(i.notifications.title),1),o("div",ca,[o("a",{href:i.notifications.all.url},c(i.notifications.all.text),9,da)])]),(r(!0),l(_,null,b(i.notifications.messages,m=>(r(),C(u,{notification:m},null,8,["notification"]))),256)),i.notifications.messages.length===0?(r(),l("div",ua,c(i.notifications.none),1)):h("",!0)])):h("",!0),i.releases.title&&i.releases.releases.length>0?(r(),l("div",fa,[o("div",ha,[o("div",ma,c(i.releases.title),1)]),(r(!0),l(_,null,b(i.releases.releases,m=>(r(),C(d,{release:m},null,8,["release"]))),256))])):h("",!0),!i.profile.is_impersonating&&i.marketplace.title?(r(),l("div",pa,[o("div",ga,[o("div",va,c(i.marketplace.title),1),o("div",_a,[o("a",{href:i.marketplace.explore.url,target:"_blank"},c(i.marketplace.explore.text),9,ya)])]),o("div",wa,[o("a",{href:i.marketplace.themes.url,class:"border py-2 text-center justify-center rounded-md hover:shadow-md",target:"_blank"},[$a,o("div",null,c(i.marketplace.themes.title),1),o("div",ka,c(i.marketplace.themes.number),1)],8,ba),o("a",{href:i.marketplace.sheets.url,class:"border py-2 text-center justify-center rounded-md hover:shadow-md",target:"_blank"},[Ca,o("div",null,c(i.marketplace.sheets.title),1),o("div",ja,c(i.marketplace.sheets.number),1)],8,xa),o("a",{href:i.marketplace.content.url,class:"border py-2 text-center justify-center rounded-md hover:shadow-md",target:"_blank"},[Ta,o("div",null,c(i.marketplace.content.title),1),o("div",Da,c(i.marketplace.content.number),1)],8,Sa)])])):h("",!0),i.profile.is_impersonating?h("",!0):(r(),l("div",Ia,[o("div",Ma,c(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",Ea,[o("img",{class:"w-16 h-16",src:i.profile.subscription.image,alt:i.profile.subscription.tier},null,8,Pa)]),o("div",qa,[o("div",Qa,c(i.profile.subscription.tier),1),i.profile.subscription.tier!=="Kobold"?(r(),l("div",Fa,[w(c(i.profile.subscription.created),1),Aa,w(" "+c(i.profile.subscription.boosters),1)])):(r(),l("div",za,[w(c(i.profile.subscription.call_to_action)+" ",1),o("div",Ra,c(i.profile.subscription.call_to_action_2),1)]))])],8,La)])),i.profile.is_impersonating?(r(),l("ul",Ya,[o("li",null,[o("a",{href:i.profile.return.url,class:"p-2 mb-2"},[Ja,w(" "+c(i.profile.return.name),1)],8,Ga)])])):(r(),l("ul",Oa,[o("li",null,[o("a",{href:i.profile.urls.settings.url,class:"p-2 mb-2 block"},[Ba,w(" "+c(i.profile.urls.settings.name),1)],8,Na)]),o("li",null,[o("a",{href:i.profile.urls.profile.url,class:"p-2 mb-2 block"},[Ka,w(" "+c(i.profile.urls.profile.name),1)],8,Ha)]),o("li",null,[o("a",{href:i.profile.urls.help.url,class:"p-2 mb-2 block",target:"_blank"},[Va,w(" "+c(i.profile.urls.help.name),1)],8,Ua)]),o("li",null,[o("a",{href:"#",onClick:t[4]||(t[4]=m=>s.logout()),class:"p-2 mb-2 block"},[Wa,w(" "+c(i.profile.urls.logout.name),1)])])]))])):(r(),l("div",Xa,[i.profile.is_impersonating?h("",!0):(r(),l("div",Za,[o("div",eo,[o("div",to,c(i.campaigns.texts.campaigns),1),i.campaigns.member.length>0?(r(),l("div",no,[o("a",{href:i.campaigns.urls.reorder},c(i.campaigns.texts.reorder),9,io)])):h("",!0)]),o("div",ao,[(r(!0),l(_,null,b(i.campaigns.member,m=>(r(),C(p,{campaign:m},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",so,[ro,w(" "+c(i.campaigns.texts.new),1)])],8,oo)]),i.profile.is_impersonating?h("",!0):(r(),l("div",lo,[co,o("p",uo,c(i.campaigns.texts.followed),1),o("div",fo,[(r(!0),l(_,null,b(i.campaigns.following,m=>(r(),C(p,{campaign:m},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",mo,c(i.campaigns.texts.follow),1)],8,ho)])]))]))]))]))])),[[f,s.onClickOutside]]):h("",!0)],64)}const go=x(Qi,[["render",po]]),vo=Ye(),A=We({});A.config.globalProperties.emitter=vo;A.component("nav-toggler",Bt);A.component("nav-search",Gn);A.component("nav-switcher",go);A.mount("#header");$(document).ready(function(){window.kankaIsMobile=window.matchMedia("only screen and (max-width: 760px)"),window.kankaIsMobile.matches||ve(),bo(),window.initForeignSelect(),ge(),wo();let e=$("#delete-confirm-form");e.length>0&&e.on("keyup keypress",function(t){var n=t.keyCode||t.which;if(n===13)return t.preventDefault(),!1}),_o(),yo(),re(),Be(),ae(),ye(),_e(),we(),ko(),be(),$(document).on("shown.bs.modal shown.bs.popover",function(){window.initForeignSelect(),window.initTags(),ae(),ve(),ge(),ye(),_e(),re(),be(),we()})});function ge(){$.isFunction($.fn.spectrum)&&$.each($(".spectrum"),function(){$(this).spectrum({preferredFormat:"hex",showInput:!0,showPalette:!0,allowEmpty:!0,appendTo:$(this).data("append-to")??null})})}function ve(){$('[data-toggle="tooltip"]').tooltip(),window.ajaxTooltip()}function _o(){let e=$(".list-treeview");if(e.length===0)return;let t=e.data("url");$.each($(".table-nested > tbody > tr"),function(){let n=$(this).data("children");parseInt(n)>0&&($(this).addClass("tr-hover cursor-pointer"),$(this).on("click",function(a){let i=$(a.target);a.target.type!=="checkbox"&&i.data("tree")!=="escape"&&(window.location=t+"?parent_id="+$(this).data("id")+"&m=table")}))})}function yo(){let e=$(".nav-tabs li a");e.click(function(n){n.preventDefault(),$(this).data("url")||$(this).tab("show")}),e.on("shown.bs.tab",function(n){n.preventDefault();let a=$(n.target).attr("href").substr(1),i=$(n.target).attr("ajax-modal"),s=$(n.target).data("nohash");if(i&&i==="ajax-modal"||s)return!0;window.location.hash="tab_"+a});let t=window.location.hash.replace("tab_","");$('ul.nav-tabs > li > a[href="'+t+'"]').tab("show")}function _e(){$.each($(".img-delete"),function(){$(this).unbind("click").click(function(e){e.preventDefault(),$("input[name="+$(this).data("target")+"]")[0].value=1,$(this).parent().parent().hide()})})}function ae(){$(".pagination-ajax-links a").on("click",function(e){e.preventDefault();var t=$(".pagination-ajax-body");return t.find(".loading").show(),t.find(".pagination-ajax-content").hide(),$.ajax($(this).attr("href")).done(function(n){t.parent().html(n),ae()}),!1})}function ye(){$('[data-toggle="confirm-delete"]').on("click",function(e){if(e.preventDefault(),$(this).data("confirming")===1){$(this).addClass("loading"),$(this).html("");let t=$(this).data("target");$(t).submit();return}$(this).data("confirming",1),$(this).find("span").html($(this).data("confirm"))}),$('a[data-toggle="delete-form"]').unbind("click").click(function(e){e.preventDefault();let t=$(this).data("target");$(t).submit()})}function wo(){$(".submenu-switcher").change(function(e){e.preventDefault();let t=$(this).find(":selected");window.location.href=t.data("route")})}function we(){$('[data-toggle="dialog"]').click(function(e){e.preventDefault();let t=$(this).data("target");t=document.getElementById(t),t.removeAttribute("open"),t.showModal(),t.addEventListener("click",function(n){let a=t.getBoundingClientRect();!(a.top<=n.clientY&&n.clientY<=a.top+a.height&&a.left<=n.clientX&&n.clientX<=a.left+a.width)&&n.target.tagName==="DIALOG"&&t.close()})}),$('[data-toggle="dialog-ajax"]').click(function(e){e.preventDefault();let t=$(this).data("target"),n=$(this).data("url");t=document.getElementById(t),t.removeAttribute("open"),t.showModal(),t.addEventListener("click",function(a){let i=t.getBoundingClientRect();!(i.top<=a.clientY&&a.clientY<=i.top+i.height&&i.left<=a.clientX&&a.clientX<=i.left+i.width)&&a.target.tagName==="DIALOG"&&t.close()}),$.ajax({url:n}).done(function(a){$(t).html(a).show(),$(document).trigger("shown.bs.modal"),$(".btn-manage-perm").click(function(i){i.preventDefault(),t.close();let s=$(this).data("target");$(s).click()}),$("#quick-privacy-select").change(function(){let i=$(this).data("url");$.ajax({url:i,type:"POST"}).done(function(s){window.showToast(s.toast),s.status?$("body").removeClass("kanka-entity-private"):$("body").addClass("kanka-entity-private")})})})})}function bo(){let e=0;const t={window:$(window).height(),header:$("header").length>0?$("header").outerHeight():0,footer:$(".main-footer").length>0?$(".main-footer").outerHeight():0,sidebar:$(".main-sidebar .sidebar").length>0?$(".main-sidebar .sidebar").height():0,controlSidebar:e};let n=$o(t),a=$(".content-wrapper");n===t.controlSidebar?a.css("min-height",n):n===t.window?a.css("min-height",n-t.header-t.footer):a.css("min-height",n-t.header)}function $o(e){let t=0;return Object.keys(e).forEach(n=>{e[n]>t&&(t=e[n])}),t}function ko(){$('.campaign-head[data-toggle="popover"]').popover()}const be=()=>{$.each($(".btn-feedback"),function(){$(this).data("feedback")!==1&&($(this).data("feedback",1),$(this).on("click",function(){$(this).addClass("loading")}))})}; diff --git a/public/build/manifest.json b/public/build/manifest.json index 466605f632..74a2a9dfa3 100644 --- a/public/build/manifest.json +++ b/public/build/manifest.json @@ -80,7 +80,7 @@ "src": "resources/js/api.js" }, "resources/js/app.js": { - "file": "assets/app-bc1d87fc.js", + "file": "assets/app-bac3247a.js", "imports": [ "_delete-confirm-fec6aa52.js", "_mention-5d95822d.js", diff --git a/resources/js/crud.js b/resources/js/crud.js index 57051b53a1..5f6071fbd7 100644 --- a/resources/js/crud.js +++ b/resources/js/crud.js @@ -58,7 +58,7 @@ function registerModalLoad() { $('#campaign-delete-form').focus(); }); } - +//this one function registerEntityNameCheck() { if (entityName.data('live-disabled')) { return; @@ -243,7 +243,7 @@ function registerEntityCalendarModal() { return; } // Load month list - loadCalendarDates(entityCalendarField.val()); + loadCalendarDates(entityCalendarField.val()); }); //var defaultCalendarId = entityCalendarAdd.data('default-calendar'); @@ -252,6 +252,28 @@ function registerEntityCalendarModal() { entityCalendarSubForm.fadeIn(); loadCalendarDates(entityCalendarField.val()); } + + $('.entity-calendar-subform input[name="length"]').focusout(function () { + if (!$(this).val()) { + return; + } + let url = $(this).data('url').replace('/0/', '/' + entityCalendarField.val() + '/') + + let params = { + day: entityCalendarDayField.val(), + month: entityCalendarMonthField.val(), + year: entityCalendarYearField.val(), + length: $(this).val(), + } + + $.ajax(url, {data: params}).done(function (data) { + if (data.overflow == true) { + $('.length-warning').show(); + } else { + $('.length-warning').hide(); + } + }); + }); } diff --git a/resources/views/calendars/events/_subform.blade.php b/resources/views/calendars/events/_subform.blade.php index a675561c5d..6a11f5196d 100644 --- a/resources/views/calendars/events/_subform.blade.php +++ b/resources/views/calendars/events/_subform.blade.php @@ -25,9 +25,12 @@ {{ __('calendars.fields.length') }} - {!! Form::number('length', (empty($entityEvent) ? 1 : null), ['placeholder' => __('calendars.placeholders.length'), 'class' => 'form-control', 'maxlength' => 1]) !!} + {!! Form::number('length', (empty($entityEvent) ? 1 : null), ['placeholder' => __('calendars.placeholders.length'), 'class' => 'form-control', 'maxlength' => 1, 'data-url' => route('calendars.event-length', ['calendar' => 0])]) !!} +
diff --git a/routes/campaign.php b/routes/campaign.php index 6dd2a0bbc3..b078e8d633 100644 --- a/routes/campaign.php +++ b/routes/campaign.php @@ -131,6 +131,7 @@ Route::get('/calendars/{calendar}/month-list', 'CalendarController@monthList')->name('calendars.month-list'); Route::get('/calendars/{calendar}/events', 'CalendarController@events')->name('calendars.events'); Route::get('/calendars/{calendar}/today', 'CalendarController@today')->name('calendars.today'); +Route::get('/calendars/{calendar}/validate-length', [\App\Http\Controllers\CalendarController::class, 'eventLength'])->name('calendars.event-length'); // Route::get('/calendars/{calendar}/weather', 'Calendar\CalendarWeatherController@form')->name('calendars.weather.create'); // Route::post('/calendars/{calendar}/weather', 'Calendar\CalendarWeatherController@store')->name('calendars.weather.store');