\n");var l=function(n){function i(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),function(e,n,i){return n=s(n),function(e,n){if(n&&("object"===t(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(e)}(e,r()?Reflect.construct(n,i||[],s(e).constructor):n.apply(e,i))}(this,i,arguments)}var l,c,h;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e)}(i,n),l=i,h=[{key:"observedAttributes",get:function(){return["visible"]}}],(c=[{key:"connectedCallback",value:function(){this.root=this;var t=o.content.cloneNode(!0);this.root.append(t),"true"===this.visible&&this.wrapper.classList.remove("hidden"),this.initialized=!0}},{key:"visible",get:function(){return this.getAttribute("visible")},set:function(t){this.setAttribute("visible",t)}},{key:"messageWrapper",get:function(){return this.querySelector(".message")}},{key:"wrapper",get:function(){return this.querySelector(".wrapper")}},{key:"attributeChangedCallback",value:function(t,e,n){if(this.initialized)return"visible"===t.toLowerCase()?"true"===n?this.show():this.hide():void 0}},{key:"disconnectedCallback",value:function(){}},{key:"show",value:function(){this.wrapper.classList.remove("hidden"),this.dispatchEvent(new CustomEvent("show"))}},{key:"hide",value:function(){this.wrapper.classList.add("hidden"),this.dispatchEvent(new CustomEvent("hide"))}},{key:"focus",value:function(){this.wrapper.focus()}}])&&e(l.prototype,c),h&&e(l,h),Object.defineProperty(l,"prototype",{writable:!1}),i}(i(HTMLElement));customElements.define("craft-spinner",l)},691:function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,a,s,o=[],l=!0,c=!1;try{if(a=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=a.call(n)).done)&&(o.push(i.value),o.length!==e);l=!0);}catch(t){c=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw r}}return o}}(t,e)||r(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(){"use strict";n=function(){return i};var e,i={},r=Object.prototype,a=r.hasOwnProperty,s=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},l=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",h=o.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(e){u=function(t,e,n){return t[e]=n}}function d(t,e,n,i){var r=e&&e.prototype instanceof y?e:y,a=Object.create(r.prototype),o=new P(i||[]);return s(a,"_invoke",{value:E(t,n,o)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}i.wrap=d;var p="suspendedStart",g="suspendedYield",m="executing",v="completed",b={};function y(){}function C(){}function $(){}var w={};u(w,l,(function(){return this}));var _=Object.getPrototypeOf,S=_&&_(_(M([])));S&&S!==r&&a.call(S,l)&&(w=S);var x=$.prototype=y.prototype=Object.create(w);function I(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function T(e,n){function i(r,s,o,l){var c=f(e[r],e,s);if("throw"!==c.type){var h=c.arg,u=h.value;return u&&"object"==t(u)&&a.call(u,"__await")?n.resolve(u.__await).then((function(t){i("next",t,o,l)}),(function(t){i("throw",t,o,l)})):n.resolve(u).then((function(t){h.value=t,o(h)}),(function(t){return i("throw",t,o,l)}))}l(c.arg)}var r;s(this,"_invoke",{value:function(t,e){function a(){return new n((function(n,r){i(t,e,n,r)}))}return r=r?r.then(a,a):a()}})}function E(t,n,i){var r=p;return function(a,s){if(r===m)throw new Error("Generator is already running");if(r===v){if("throw"===a)throw s;return{value:e,done:!0}}for(i.method=a,i.arg=s;;){var o=i.delegate;if(o){var l=k(o,i);if(l){if(l===b)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===p)throw r=v,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=m;var c=f(t,n,i);if("normal"===c.type){if(r=i.done?v:g,c.arg===b)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(r=v,i.method="throw",i.arg=c.arg)}}}function k(t,n){var i=n.method,r=t.iterator[i];if(r===e)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=e,k(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),b;var a=f(r,t.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,b;var s=a.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,b):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function M(n){if(n||""===n){var i=n[l];if(i)return i.call(n);if("function"==typeof n.next)return n;if(!isNaN(n.length)){var r=-1,s=function t(){for(;++r=0;--r){var s=this.tryEntries[r],o=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),c=a.call(s,"finallyLoc");if(l&&c){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),A(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;A(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:M(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),b}},i}function i(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||r(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){if(t){if("string"==typeof t)return a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n').appendTo(Garnish.$bod);this.$sidebar=$('').appendTo(i).attr({role:"navigation","aria-label":Craft.t("app","Source")}),this.$sourcesContainer=$('
",{class:"thin action"}).append($("",{class:"delete icon",title:Craft.t("app","Delete"),type:"button"})).appendTo(o),o}}),Craft.EditableTable.Row=Garnish.Base.extend({table:null,id:null,niceTexts:null,$tr:null,$tds:null,tds:null,$textareas:null,$deleteBtn:null,get prevRow(){return this.$tr.prev("tr")},get nextRow(){return this.$tr.next("tr")},init:function(t,e){var n=this;this.table=t,this.$tr=$(e),this.$tds=this.$tr.children(),this.tds=[],this.id=this.$tr.attr("data-id"),this.$tr.data("editable-table-row",this);var i=parseInt(this.id.substring(this.table.settings.rowIdPrefix.length));i>this.table.biggestId&&(this.table.biggestId=i),this.$textareas=$(),this.niceTexts=[];var r,a,s,o,l={},c=0;for(r in this.table.columns)if(this.table.columns.hasOwnProperty(r)){if(a=this.table.columns[r],s=this.tds[r]=this.$tds[c],Craft.inArray(a.type,Craft.EditableTable.textualColTypes)){$(".editable-table-preview",s).remove();var h=void 0;"color"===a.type?h=$("input.color-input",s):(h=$("textarea",s),this.$textareas=this.$textareas.add(h),this.niceTexts.push(new Garnish.NiceText(h,{onHeightChange:this.onTextareaHeightChange.bind(this)}))),this.addListener(h,"focus","onTextareaFocus"),this.addListener(h,"mousedown","ignoreNextTextareaFocus"),this.addListener(h,"keypress",{tdIndex:c,type:a.type},"handleKeypress"),this.addListener(h,"input",{type:a.type},"validateValue"),h.trigger("input"),"multiline"!==a.type&&this.addListener(h,"paste",{tdIndex:c,type:a.type},"handlePaste"),l[r]=h}else"checkbox"===a.type&&(o=$('input[type="checkbox"]',s),a.radioMode&&(void 0===this.table.radioCheckboxes[r]&&(this.table.radioCheckboxes[r]=[]),this.table.radioCheckboxes[r].push(o[0]),this.addListener(o,"change",{colId:r},"onRadioCheckboxChange")),a.toggle&&this.addListener(o,"change",{colId:r},(function(t){this.applyToggleCheckbox(t.data.colId)})));$(s).hasClass("disabled")||this.addListener(s,"click",{td:s},(function(t){t.target===t.data.td&&$(t.data.td).find("textarea,input,select,.lightswitch").focus()})),c++}for(r in this.onTextareaHeightChange(),this.table.columns)this.table.columns.hasOwnProperty(r)&&"checkbox"===(a=this.table.columns[r]).type&&a.toggle&&this.applyToggleCheckbox(r);for(r in this.table.columns)this.table.columns.hasOwnProperty(r)&&(!(a=this.table.columns[r]).autopopulate||void 0===l[a.autopopulate]||l[r].val()||l[a.autopopulate].val()||new Craft.HandleGenerator(l[r],l[a.autopopulate],{allowNonAlphaStart:!0}));var u=this.$tr.children().last().find(".delete");this.addListener(u,"click","deleteRow");var d=this.$tr.find("input,textarea,select,.lightswitch");this.addListener(d,"focus",(function(t){$(t.currentTarget).closest("td:not(.disabled)").addClass("focus")})),this.addListener(d,"blur",(function(t){$(t.currentTarget).closest("td").removeClass("focus")}));var f=this.$tr.find("> .action .action-btn");f.length&&(this.actionDisclosure=f.data("trigger")||new Garnish.DisclosureMenu(f),this.$actionMenu=this.actionDisclosure.$container,this.actionDisclosure.on("show",(function(){n.updateDisclosureMenu(),Garnish.firstFocusableElement(n.$actionMenu).focus()})),this.$actionMenuOptions=this.$actionMenu.find("button[data-action]"),this.addListener(this.$actionMenuOptions,"activate",this.handleActionClick))},updateDisclosureMenu:function(){this.prevRow.length?this.$actionMenu.find("button[data-action=moveUp]:first").parent().removeClass("hidden"):this.$actionMenu.find("button[data-action=moveUp]:first").parent().addClass("hidden"),this.nextRow.length?this.$actionMenu.find("button[data-action=moveDown]:first").parent().removeClass("hidden"):this.$actionMenu.find("button[data-action=moveDown]:first").parent().addClass("hidden")},handleActionClick:function(t){t.preventDefault(),this.onActionSelect(t.target)},onActionSelect:function(t){switch($option=$(t),$option.data("action")){case"moveUp":this.moveUp();break;case"moveDown":this.moveDown()}this.actionDisclosure.hide()},moveUp:function(){var t=this.prevRow;t.length&&(this.$tr.insertBefore(t),this.table.updateAllRows())},moveDown:function(){var t=this.nextRow;t.length&&(this.$tr.insertAfter(t),this.table.updateAllRows())},onTextareaFocus:function(t){this.onTextareaHeightChange();var e=$(t.currentTarget);e.data("ignoreNextFocus")?e.data("ignoreNextFocus",!1):window.setTimeout((function(){Craft.selectFullValue(e)}),0)},onRadioCheckboxChange:function(t){if(t.currentTarget.checked)for(var e=0;et&&(t=this.niceTexts[e].height);this.$textareas.css("min-height",t);var n=this.$textareas.filter(":visible").first().parent().height();n>t&&this.$textareas.css("min-height",n)},deleteRow:function(){this.table.deleteRow(this)}},{numericKeyCodes:[9,8,37,38,39,40,45,91,46,190,48,49,50,51,52,53,54,55,56,57]})},8468:function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(){"use strict";e=function(){return i};var n,i={},r=Object.prototype,a=r.hasOwnProperty,s=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},l=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",h=o.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(n){u=function(t,e,n){return t[e]=n}}function d(t,e,n,i){var r=e&&e.prototype instanceof y?e:y,a=Object.create(r.prototype),o=new P(i||[]);return s(a,"_invoke",{value:E(t,n,o)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}i.wrap=d;var p="suspendedStart",g="suspendedYield",m="executing",v="completed",b={};function y(){}function C(){}function $(){}var w={};u(w,l,(function(){return this}));var _=Object.getPrototypeOf,S=_&&_(_(M([])));S&&S!==r&&a.call(S,l)&&(w=S);var x=$.prototype=y.prototype=Object.create(w);function I(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function T(e,n){function i(r,s,o,l){var c=f(e[r],e,s);if("throw"!==c.type){var h=c.arg,u=h.value;return u&&"object"==t(u)&&a.call(u,"__await")?n.resolve(u.__await).then((function(t){i("next",t,o,l)}),(function(t){i("throw",t,o,l)})):n.resolve(u).then((function(t){h.value=t,o(h)}),(function(t){return i("throw",t,o,l)}))}l(c.arg)}var r;s(this,"_invoke",{value:function(t,e){function a(){return new n((function(n,r){i(t,e,n,r)}))}return r=r?r.then(a,a):a()}})}function E(t,e,i){var r=p;return function(a,s){if(r===m)throw new Error("Generator is already running");if(r===v){if("throw"===a)throw s;return{value:n,done:!0}}for(i.method=a,i.arg=s;;){var o=i.delegate;if(o){var l=k(o,i);if(l){if(l===b)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===p)throw r=v,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=m;var c=f(t,e,i);if("normal"===c.type){if(r=i.done?v:g,c.arg===b)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(r=v,i.method="throw",i.arg=c.arg)}}}function k(t,e){var i=e.method,r=t.iterator[i];if(r===n)return e.delegate=null,"throw"===i&&t.iterator.return&&(e.method="return",e.arg=n,k(t,e),"throw"===e.method)||"return"!==i&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+i+"' method")),b;var a=f(r,t.iterator,e.arg);if("throw"===a.type)return e.method="throw",e.arg=a.arg,e.delegate=null,b;var s=a.arg;return s?s.done?(e[t.resultName]=s.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,b):s:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,b)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function M(e){if(e||""===e){var i=e[l];if(i)return i.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,s=function t(){for(;++r=0;--r){var s=this.tryEntries[r],o=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),c=a.call(s,"finallyLoc");if(l&&c){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),A(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;A(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,i){return this.delegate={iterator:M(t),resultName:e,nextLoc:i},"next"===this.method&&(this.arg=n),b}},i}function n(t,e,n,i,r,a,s){try{var o=t[a](s),l=o.value}catch(t){return void n(t)}o.done?e(l):Promise.resolve(l).then(i,r)}function i(t){return function(){var e=this,i=arguments;return new Promise((function(r,a){var s=t.apply(e,i);function o(t){n(s,r,a,o,l,"next",t)}function l(t){n(s,r,a,o,l,"throw",t)}o(void 0)}))}}var r,a;Craft.ElementActionTrigger=Garnish.Base.extend({elementIndex:null,maxLevels:null,newChildUrl:null,$trigger:null,$selectedItems:null,triggerEnabled:!0,init:function(t){if(this.elementIndex=Craft.currentElementIndex,this.elementIndex.triggers.push(this),$.isPlainObject(t)||(t={}),void 0!==t.batch&&(t.bulk=t.batch,delete t.batch),Object.defineProperty(t,"batch",{get:function(){return this.bulk},set:function(t){this.bulk=t}}),this.setSettings(t,Craft.ElementActionTrigger.defaults),this.$trigger=$("#".concat(this.elementIndex.namespaceId(t.type),"-actiontrigger")).data("trigger",this),this.settings.activate){this.$trigger.data("custom-handler",!0);var e=this.$trigger.find("button,.btn");e.length||(e=this.$trigger),this.addListener(e,"activate","handleTriggerActivation")}this.updateTrigger(),this.elementIndex.on("selectionChange",this.updateTrigger.bind(this))},updateTrigger:function(){0!==this.elementIndex.getSelectedElements().length&&(this.validateSelection()?this.enableTrigger():this.disableTrigger())},validateSelection:function(){var t=this;if(this.$selectedItems=this.elementIndex.getSelectedElements(),!this.settings.bulk&&this.$selectedItems.length>1)return!1;if(this.settings.requireId)for(var e=0;e=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){o=!0,a=t},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function r(e,n,i){var r;return r=function(e,n){if("object"!=t(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,"string");if("object"!=t(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n),(n="symbol"==t(r)?r:String(r))in e?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i,e}function a(){"use strict";a=function(){return n};var e,n={},i=Object.prototype,r=i.hasOwnProperty,s=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},l=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",h=o.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(e){u=function(t,e,n){return t[e]=n}}function d(t,e,n,i){var r=e&&e.prototype instanceof y?e:y,a=Object.create(r.prototype),o=new P(i||[]);return s(a,"_invoke",{value:E(t,n,o)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}n.wrap=d;var p="suspendedStart",g="suspendedYield",m="executing",v="completed",b={};function y(){}function C(){}function $(){}var w={};u(w,l,(function(){return this}));var _=Object.getPrototypeOf,S=_&&_(_(M([])));S&&S!==i&&r.call(S,l)&&(w=S);var x=$.prototype=y.prototype=Object.create(w);function I(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function T(e,n){function i(a,s,o,l){var c=f(e[a],e,s);if("throw"!==c.type){var h=c.arg,u=h.value;return u&&"object"==t(u)&&r.call(u,"__await")?n.resolve(u.__await).then((function(t){i("next",t,o,l)}),(function(t){i("throw",t,o,l)})):n.resolve(u).then((function(t){h.value=t,o(h)}),(function(t){return i("throw",t,o,l)}))}l(c.arg)}var a;s(this,"_invoke",{value:function(t,e){function r(){return new n((function(n,r){i(t,e,n,r)}))}return a=a?a.then(r,r):r()}})}function E(t,n,i){var r=p;return function(a,s){if(r===m)throw new Error("Generator is already running");if(r===v){if("throw"===a)throw s;return{value:e,done:!0}}for(i.method=a,i.arg=s;;){var o=i.delegate;if(o){var l=k(o,i);if(l){if(l===b)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===p)throw r=v,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=m;var c=f(t,n,i);if("normal"===c.type){if(r=i.done?v:g,c.arg===b)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(r=v,i.method="throw",i.arg=c.arg)}}}function k(t,n){var i=n.method,r=t.iterator[i];if(r===e)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=e,k(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),b;var a=f(r,t.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,b;var s=a.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,b):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function M(n){if(n||""===n){var i=n[l];if(i)return i.call(n);if("function"==typeof n.next)return n;if(!isNaN(n.length)){var a=-1,s=function t(){for(;++a=0;--a){var s=this.tryEntries[a],o=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var l=r.call(s,"catchLoc"),c=r.call(s,"finallyLoc");if(l&&c){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),A(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;A(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:M(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),b}},n}function s(t,e,n,i,r,a,s){try{var o=t[a](s),l=o.value}catch(t){return void n(t)}o.done?e(l):Promise.resolve(l).then(i,r)}function o(t){return function(){var e=this,n=arguments;return new Promise((function(i,r){var a=t.apply(e,n);function o(t){s(a,i,r,o,l,"next",t)}function l(t){s(a,i,r,o,l,"throw",t)}o(void 0)}))}}function l(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,a,s,o=[],l=!0,c=!1;try{if(a=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=a.call(n)).done)&&(o.push(i.value),o.length!==e);l=!0);}catch(t){c=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw r}}return o}}(t,e)||c(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e){if(t){if("string"==typeof t)return h(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?h(t,e):void 0}}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n",{class:"revision-spinner spinner hidden",title:Craft.t("app","Saving")}).appendTo(g),this.$statusIcon=$("",{class:"revision-status ".concat(this.isFullPage?"invisible":"hidden")}).appendTo(g),this.$expandSiteStatusesBtn=this.$container.find(".expand-status-btn"),this.settings.canEditMultipleSites&&this.addListener(this.$expandSiteStatusesBtn,"click","expandSiteStatuses"),this.settings.previewTargets.length&&this.isFullPage){this.settings.enablePreview&&this.addListener(this.$previewBtn,"click","openPreview");var m=this.$container.find(".preview-btn-container");if(1===this.settings.previewTargets.length){var v=l(this.settings.previewTargets,1)[0];this.createPreviewLink(v).addClass("view-btn btn").attr("aria-label",Craft.t("app","View")).appendTo(m)}else this.createShareMenu(m)}if(this.settings.canSave){if("FORM"!==this.$container.prop("tagName"))throw"Element editors may only be used with forms.";this.isFullPage&&Craft.edition!==Craft.Solo&&(this.$activityContainer=this.$container.find(".activity-container"),this._checkActivity()),this.$container.data("serializer",(function(){return o.serializeForm(!0)})),this.$container.data("initialSerializedValue",this.serializeForm(!0)),Garnish.requestAnimationFrame((function(){o.$container.data("initialSerializedValue",o.serializeForm(!0))})),this.slideout||this.addListener(this.$container,"submit","handleSubmit"),this.settings.isProvisionalDraft?this.initForProvisionalDraft():this.settings.draftId&&!this.settings.isUnpublishedDraft?this.initForDraft():this.settings.canSaveCanonical||this.addListener(this.$container,"submit.saveShortcut",(function(t){t.saveShortcut&&(t.preventDefault(),o.saveDraft(),o.removeListener(o.$container,"submit.saveShortcut"))})),this.listenForChanges(),this.addListener(this.$statusIcon,"click",(function(){o.showStatusHud(o.$statusIcon)})),this.handleDismissibleTips(),this.isFullPage&&Craft.messageReceiver&&Craft.broadcaster.addEventListener("message",(function(t){if("saveDraft"===t.data.event&&t.data.canonicalId===o.settings.canonicalId&&(t.data.draftId===o.settings.draftId||t.data.isProvisionalDraft&&!o.settings.draftId)||"saveElement"===t.data.event&&t.data.id===o.settings.canonicalId&&!o.settings.draftId)(o.settings.reloadOnBroadcastSave||t.data.draftId!==o.settings.draftId)&&(Craft.setUrl(Craft.getUrl(document.location.href,{scrollY:window.scrollY})),window.location.reload());else if("deleteDraft"===t.data.event&&t.data.canonicalId===o.settings.canonicalId&&t.data.draftId===o.settings.draftId){var e=new URL(window.location.href);e.searchParams.delete("draftId"),e.href!==document.location.href?window.location.href=e:(Craft.setUrl(Craft.getUrl(document.location.href,{scrollY:window.scrollY})),window.location.reload())}})),this.activityTooltips={},this.isFullPage&&Craft.ui.setFocusOnErrorSummary(this.$container)}},_createQueue:function(){var t=this,e=new Craft.Queue;return e.on("beforeRun",(function(){t.showSpinner()})),e.on("afterRun",(function(){t.hideSpinner()})),e},get namespace(){return this.settings.namespace},namespaceInputName:function(t){return Craft.namespaceInputName(t,this.namespace)},namespaceId:function(t){return Craft.namespaceId(t,this.namespace)},get listeningForChanges(){return!!this.formObserver},get pauseLevel(){var t,e;return null!==(t=null===(e=this.formObserver)||void 0===e?void 0:e._pauseLevel)&&void 0!==t?t:0},listenForChanges:function(){var t=this;this.formObserver||(this.formObserver=new Craft.FormObserver(this.$container,(function(){t.checkForm()})))},stopListeningForChanges:function(){this.formObserver&&(this.formObserver.destroy(),this.formObserver=null)},pause:function(){var t;null===(t=this.formObserver)||void 0===t||t.pause()},resume:function(){var t;null===(t=this.formObserver)||void 0===t||t.resume()},initForProvisionalDraft:function(){var t,e=this,n=this.$container.find(".discard-changes-btn");if(!n.length){var i,r,a,s=null!==(i=this.settings.$noticeContainer)&&void 0!==i?i:this.isFullPage?Craft.cp.$noticeContainer:this.$container.find(".so-notice");this.isFullPage&&(r=$("#content").height(),a=Garnish.$win.scrollTop());var o=$("",{class:"draft-notice"}).append($("",{class:"draft-icon","aria-hidden":"true","data-icon":"edit"})).append($("",{text:Craft.t("app","Showing your unsaved changes.")})).appendTo(s);if(n=$("",{type:"button",class:"discard-changes-btn btn",text:Craft.t("app","Discard")}).appendTo(o),this.isFullPage){var l=$("#content").height()-r;if(Garnish.$win.scrollTop(a+l),Garnish.$win.scrollTop()===a){Craft.cp.$contentContainer.css("pointer-events","none"),$("#content-header").css("min-height","auto");var c=s.height();s.css({height:c-l,overflow:"hidden"}).velocity({height:c},"fast",(function(){$("#content-header").css("min-height",""),s.css({height:"",overflow:""}),setTimeout((function(){Craft.cp.$contentContainer.css("pointer-events","")}),300)}))}}}this.addListener(n,"keypress,keyup,change,focus,blur,click,mousedown,mouseup",(function(t){t.stopPropagation()})),this.addListener(n,"click",(function(){confirm(Craft.t("app","Are you sure you want to discard your changes?"))&&e.queue.unshift((function(){return new Promise((function(t,n){e.isFullPage?Craft.submitForm(e.$container,{action:"elements/delete-draft",redirect:e.settings.hashedCpEditUrl,params:{draftId:e.settings.draftId,fieldId:e.settings.fieldId,ownerId:e.settings.ownerId,provisional:1}}):Craft.sendActionRequest("POST","elements/delete-draft",{data:{elementId:e.settings.canonicalId,draftId:e.settings.draftId,fieldId:e.settings.fieldId,ownerId:e.settings.ownerId,siteId:e.settings.siteId,provisional:1}}).then((function(t){var n;Craft.cp.displaySuccess(t.data.message),Craft.broadcaster.postMessage({event:"saveElement",id:e.settings.canonicalId}),null===(n=e.slideout)||void 0===n||n.close()})).catch(n)}))}))})),this.isFullPage||null===(t=this.slideout)||void 0===t||t.$cancelBtn.text(Craft.t("app","Close"))},initForDraft:function(){var t=this;this.createEditMetaAction(),this.settings.canSaveCanonical&&Garnish.uiLayerManager.registerShortcut({keyCode:Garnish.S_KEY,ctrl:!0,alt:!0},(function(){Craft.submitForm(t.$container,{action:"elements/apply-draft",redirect:t.settings.hashedCpEditUrl})}),0)},expandSiteStatuses:function(){var t=this;this.removeListener(this.$expandSiteStatusesBtn,"click"),this.$expandSiteStatusesBtn.velocity({opacity:0},"fast",(function(){t.$expandSiteStatusesBtn.remove()}));var e=this.$container.find(".enabled-for-site-".concat(this.settings.siteId,"-field"));if(this.$siteStatusPane=e.parent(),this.settings.revisionId)this._getOtherSupportedSites().forEach((function(e){return t._createSiteStatusField(e)}));else{e.addClass("nested");var n=Craft.ui.createLightswitchField({label:Craft.t("app","Enabled for all sites"),name:this.namespaceInputName("enabled")}).insertBefore(e);n.find("label").css("font-weight","bold"),this.$globalLightswitch=n.find(".lightswitch"),this.settings.revisionId||this._showField(n);var i=Object.values(this.settings.siteStatuses),r=i.includes(!0),a=i.includes(!1),s=r&&a?"-":r?"1":"",o=encodeURIComponent(this.namespaceInputName("enabledForSite[".concat(this.settings.siteId,"]")))+"="+(this.settings.enabledForSite?"1":"");this.$siteLightswitches=e.find(".lightswitch").on("change",this._updateGlobalStatus.bind(this)),this._getOtherSupportedSites().forEach((function(e){return t._createSiteStatusField(e)}));for(var l=encodeURIComponent(this.namespaceInputName("enabled"))+"=".concat(s),c=0;c",{text:Craft.t("app","Add a site..."),class:"visually-hidden",id:i}),a=Craft.ui.createSelect({options:[{label:Craft.t("app","Add a site…")}].concat((t=n.map((function(t){return{label:t.name,value:t.id}})),function(t){if(Array.isArray(t))return h(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||c(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())),labelledBy:i}).addClass("fullwidth");this.$additionalSiteField=Craft.ui.createField(a,{}).addClass("nested add").appendTo(this.$siteStatusPane),r.prependTo(this.$additionalSiteField);var s=a.find("select");s.on("change",(function(){var t=parseInt(s.val()),n=Craft.sites.find((function(e){return e.id===t}));if(n){var i=e.settings.additionalSites.find((function(t){return t.siteId==n.id}));e._createSiteStatusField(n,i.enabledByDefault),e._updateGlobalStatus(),s.val("").find('option[value="'.concat(t,'"]')).remove(),null===e.newSiteIds&&(e.newSiteIds=[]),e.siteIds.push(t),e.newSiteIds.push(t),1===s.find("option").length&&e._removeField(e.$additionalSiteField)}})),this._showField(this.$additionalSiteField)}},showStatusHud:function(t){var e;this.failed?(e='
'.concat(this._saveFailMessage(),"
"),this.httpError&&(e+='
'.concat(Craft.escapeHtml(this.httpError),"
")),400===this.httpStatus&&(e+='"))):e="
".concat(this._saveSuccessMessage(),"
");var n=new Garnish.HUD(t,e,{hudClass:"hud revision-status-hud",onHide:function(){n.destroy()}});n.$mainContainer.find(".refresh-btn").on("click",(function(){window.location.reload()}))},_saveSuccessMessage:function(){return this.settings.isProvisionalDraft||this.settings.isUnpublishedDraft?Craft.t("app","Your changes have been stored."):Craft.t("app","The draft has been saved.")},_saveFailMessage:function(){return this.settings.isProvisionalDraft||this.settings.isUnpublishedDraft?Craft.t("app","Your changes could not be stored."):Craft.t("app","The draft could not be saved.")},spinners:function(){return this.$spinner},showSpinner:function(){this.spinners().removeClass("hidden")},hideSpinner:function(){this.spinners().addClass("hidden")},statusIcons:function(){return this.$statusIcon},createEditMetaAction:function(){if(this.isFullPage){var t=$("#action-menu").disclosureMenu().data("disclosureMenu"),e=t.getFirstDestructiveGroup(),n=t.addGroup(null,!0,e),i=t.addItem({type:"button",icon:"edit",label:Craft.t("app","Edit draft settings")},n);this.addListener(i,"click","showMetaModal")}},createPreviewLink:function(t,e){var n=this,i=$("",{href:this.getTokenizedPreviewUrl(t.url,null,!1),text:e||Craft.t("app","View"),target:"_blank",data:{targetUrl:t.url,targetLabel:t.label}});return this.addListener(i,"click",(function(){setTimeout((function(){n.activatePreviewToken()}),1)})),this.previewLinks.push(i),i},updatePreviewLinks:function(){var t=this;this.previewLinks.forEach((function(e){t.updatePreviewLinkHref(e),t.activatedPreviewToken&&t.removeListener(e,"click")}))},updatePreviewLinkHref:function(t){t.attr("href",this.getTokenizedPreviewUrl(t.data("targetUrl"),null,!1))},activatePreviewToken:function(){this.settings.isLive||(this.activatedPreviewToken=!0,this.updatePreviewLinks())},createShareMenu:function(t){var e=this,n=$("",{type:"button",class:"view-btn btn menubtn",text:Craft.t("app","View")}).appendTo(t),i=$("",{class:"menu"}).appendTo(t),r=$("
").appendTo(i);this.settings.previewTargets.forEach((function(t){$("").append(e.createPreviewLink(t,t.label)).appendTo(r)})),new Garnish.MenuBtn(n)},getPreviewTokenParams:function(){var t={elementType:this.settings.elementType,canonicalId:this.settings.canonicalId,siteId:this.settings.siteId,revisionId:this.settings.revisionId,previewToken:this.settings.previewToken};return this.settings.draftId&&!this.settings.isProvisionalDraft&&(t.draftId=this.settings.draftId),t},getPreviewToken:function(){var t=this;return this.previewTokenQueue.push((function(){return new Promise((function(e,n){t.activatedPreviewToken?e(t.settings.previewToken):Craft.sendActionRequest("POST","preview/create-token",{data:t.getPreviewTokenParams()}).then((function(){t.activatePreviewToken(),e(t.settings.previewToken)})).catch(n)}))}))},getTokenizedPreviewUrl:function(t,e){var n=this,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r={};if(!this.settings.previewParamValue||!e&&this.settings.isLive||(r[e||"x-craft-preview"]=this.settings.previewParamValue),this.settings.siteToken&&(r[Craft.siteToken]=this.settings.siteToken),this.settings.isLive){var a=Craft.getUrl(t,r);return i?new Promise((function(t){t(a)})):a}if(!this.settings.previewToken)throw"Missing preview token";r[Craft.tokenParam]=this.settings.previewToken;var s=Craft.getUrl(t,r);if(this.activatedPreviewToken)return i?new Promise((function(t){t(s)})):s;if(i)return new Promise((function(t,e){n.getPreviewToken().then((function(){t(s)})).catch(e)}));var o=this.getPreviewTokenParams();return o.redirect=s,Craft.getActionUrl("preview/create-token",o)},getPreview:function(){var t,e,n,i=this;return this.preview&&!this.preview.isVisible&&(null===(t=this.preview.elementEditor)||void 0===t?void 0:t.settings.updatedTimestamp)!==this.settings.updatedTimestamp&&(this.preview.destroy(),delete this.preview),this.preview||(this.preview=new Craft.Preview({elementType:this.settings.elementType,elementId:this.settings.isProvisionalDraft?this.settings.canonicalId:this.settings.elementId,draftId:this.settings.isProvisionalDraft?null:this.settings.draftId,revisionId:this.settings.revisionId,siteId:this.settings.siteId,onBeforeLoad:(n=o(a().mark((function t(){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.checkForm(!1,!0);case 2:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})}),this.preview.on("open",(function(){e=i.settings.updatedTimestamp,i.pause()})),this.preview.on("close",o(a().mark((function t(){var n,r,s,o;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i.$previewBtn&&i.$previewBtn.focus(),i.settings.updatedTimestamp===e){t.next=4;break}return t.next=4,i.refreshContent();case 4:null!==(s=null!==(n=null===(r=i.preview.tabManager)||void 0===r?void 0:r.getSelectedTabIndex())&&void 0!==n?n:null)&&(null===(o=i.tabManager)||void 0===o||o.selectTab(s)),i.resume();case 7:case"end":return t.stop()}}),t)})))),this.preview.on("afterSaveDraft",(function(t){var e=t.response;i._handleSaveDraftResponse(e)}))),this.preview},openPreview:(d=o(a().mark((function t(){var e,n,i,r,s;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Garnish.hasAttr(this.$previewBtn,"aria-disabled")){t.next=2;break}return t.abrupt("return");case 2:return this.$previewBtn.attr("aria-disabled",!0),t.prev=3,i=this.getPreview(),t.next=7,i.open();case 7:null!==(r=null!==(e=null===(n=this.tabManager)||void 0===n?void 0:n.getSelectedTabIndex())&&void 0!==e?e:null)&&(null===(s=i.tabManager)||void 0===s||s.selectTab(r));case 9:return t.prev=9,this.$previewBtn.removeAttr("aria-disabled"),t.finish(9);case 12:case"end":return t.stop()}}),t,this,[[3,,9,12]])}))),function(){return d.apply(this,arguments)}),ensureIsDraftOrRevision:function(t){var e=this;return new Promise((function(n,i){if(e.settings.draftId||e.settings.revisionId)n();else{if(t&&e.serializeForm(!0)===e.$container.data("initialSerializedValue"))return void n();e.saveDraft().then(n).catch(i)}}))},setFormValue:function(t,e){var n=this;return o(a().mark((function i(){return a().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!n.settings.revisionId){i.next=2;break}throw"Unable to set form values on a revision.";case 2:return i.next=4,n.checkForm();case 4:if(!n.$container.serialize().split("&").includes("".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(e)))){i.next=7;break}return i.abrupt("return",!1);case 7:if($("",{type:"hidden",name:t,value:e}).prependTo(n.$container),!n.settings.canCreateDrafts){i.next=11;break}return i.next=11,n.saveDraft();case 11:return i.abrupt("return",!0);case 12:case"end":return i.stop()}}),i)})))()},markDeltaNameAsModified:function(t){var e=this;return o(a().mark((function n(){var i;return a().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if((i=e.$container.data("modified-delta-names")||[]).includes(t)){n.next=6;break}return i.push(t),e.$container.data("modified-delta-names",i),n.next=6,e.saveDraft();case 6:case"end":return n.stop()}}),n)})))()},serializeForm:function(t){var e=this.$container.serialize();if(t&&!this.settings.isUnpublishedDraft){var n=encodeURIComponent(this.namespaceInputName("action")),i=encodeURIComponent(this.namespaceInputName("redirect"));e=(e=e.replace(new RegExp("&".concat(Craft.escapeRegex(n),"=[^&]*")),"")).replace(new RegExp("&".concat(Craft.escapeRegex(i),"=[^&]*")),"")}var r={serialized:e=e.replace(/&elementindex-[^&]*/g,"")};return this.trigger("serializeForm",{data:r}),r.serialized},checkForm:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.queue.push((function(){return new Promise((function(i,r){if(e.settings.revisionId)i();else if(void 0!==e.$container.data("initialSerializedValue")){var a=e.serializeForm(!0);t||a!==(e.lastSerializedValue||e.$container.data("initialSerializedValue"))?(null!=n?n:e.enableAutosave)&&e.settings.canCreateDrafts?e._saveDraftInternal(a).then(i).catch((function(t){console.warn("Couldn’t save draft:",t),r(t)})):e.updateFieldLayout(a).then(i).catch((function(t){console.warn("Couldn’t update field layout:",t),r(t)})):i()}else setTimeout((function(){e.checkForm(t).then(i).catch(r)}),500)}))}))},refreshContent:function(t){var e=this;return o(a().mark((function n(){var i;return a().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return e.settings.visibleLayoutElements=[],(i=[e.serializeForm(!0)]).push($.param(r({},e.namespaceInputName("applyParams"),0))),t&&!$.isEmptyObject(t)&&i.push($.param(t)),n.next=6,e.updateFieldLayout(i.join("&"));case 6:case"end":return n.stop()}}),n)})))()},isPreviewActive:function(){return this.preview&&this.preview.isActive},saveDraft:function(t){var e=this;return this.queue.push((function(){return new Promise((function(n,i){e._saveDraftInternal(e.serializeForm(!0),t).then(n).catch(i)}))}))},_saveDraftInternal:function(t,e){var a=this;return new Promise((function(e,s){if(a.submittingForm)s("Form already being submitted.");else{a.lastSerializedValue=t,a.failed=!1,a.httpStatus=null,a.httpError=null,a.cancelToken=axios.CancelToken.source(),a.statusIcons().velocity("stop").css("opacity","").removeClass("hidden invisible checkmark-icon alert-icon fade-out").addClass("hidden"),a.$saveMetaBtn&&a.$saveMetaBtn.addClass("active");var o,c=l(Craft.findModifiedDeltaNames(a.$container.data("initialSerializedValue"),t,a.$container.data("delta-names"),a.$container.data("initial-delta-values"),a.$container.data("modified-delta-names"),!0),1)[0],h=a.prepareData(t,null,!0),u=$(),d=i(c);try{for(d.s();!(o=d.n()).done;){var f=o.value,p=u=u.add(a.$container.find('.field[data-base-input-name="'.concat($.escapeSelector(f),'"]')));u=u.add(p).add(p.parentsUntil(a.$container,".field"))}}catch(t){d.e(t)}finally{d.f()}h.push($.param(r({},a.namespaceInputName("visibleLayoutElements"),a.settings.visibleLayoutElements))),!a.settings.isProvisionalDraft&&a.settings.draftId||h.push("".concat(a.namespaceInputName("provisional"),"=1"));var g=a.$contentContainer.children("[data-layout-tab]:not(.hidden)").data("id");g&&h.push("".concat(a.namespaceInputName("selectedTab"),"=").concat(g)),Craft.sendActionRequest("POST","elements/save-draft",{cancelToken:a.cancelToken.token,headers:a._saveHeaders,data:h.join("&")}).then((function(i){var r;a._afterSaveDraft(),a.settings.previewParamValue=i.data.previewParamValue,a._afterUpdateFieldLayout(t,g,i),a._handleSaveDraftResponse(i),$.isPlainObject(i.data.draftElementUids)&&(a.draftElementUids=n(n({},a.draftElementUids),i.data.draftElementUids));var s=i.data.modifiedAttributes.map((function(t){return t=a.namespaceInputName(t),['[name="'.concat(t,'"]'),'[name^="'.concat(t,'["]')]})).flat().join(",");u=u.add(a.$contentContainer.find(s).parentsUntil(a.$container,".flex-fields > .field")).add(null===(r=a.$sidebar)||void 0===r?void 0:r.find(s).closest(".field")).not(":has(> .status-badge)");for(var o=0;o",{class:"status-badge modified","aria-hidden":"true",title:Craft.t("app","This field has been modified.")}).append($("",{class:"visually-hidden",html:Craft.t("app","This field has been modified.")})));a.afterUpdate(t),a.trigger("afterSaveDraft",{response:i}),Craft.broadcaster&&Craft.broadcaster.postMessage({pageId:Craft.pageId,event:"saveDraft",canonicalId:a.settings.canonicalId,draftId:a.settings.draftId,isProvisionalDraft:a.settings.isProvisionalDraft}),e()})).catch((function(t){a._afterSaveDraft(),a.ignoreFailedRequest||(a.failed=!0,t&&t.response&&(a.httpStatus=t.response.status,a.httpError=t.response.data?t.response.data.message:null),a._showFailStatus(),s(t)),a.ignoreFailedRequest=!1}))}}))},_handleSaveDraftResponse:function(t){var e=this,i=!this.settings.draftId;i&&(this.settings.isProvisionalDraft=!0),this.isFullPage&&(t.data.title&&this.$container.find(".screen-title").text(t.data.title),t.data.docTitle&&(document.title=t.data.docTitle)),this.newSiteIds&&(this.newSiteIds.forEach((function(t){var n=e.settings.additionalSites.find((function(e){return e.siteId==t})),i=!n||void 0===n.enabledByDefault||n.enabledByDefault;Craft.cp.showSiteCrumbMenuItem(t),Craft.cp.setSiteCrumbMenuItemStatus(t,i?"enabled":"disabled")})),this.newSiteIds=null),this.settings.isProvisionalDraft?i&&(this.$container.find("input.action-input").attr("value","elements/apply-draft"),this.settings.elementId=t.data.elementId,this.settings.draftId=t.data.draftId,this.settings.isLive=!1,this.previewToken=null,this.initForProvisionalDraft()):(this.settings.draftName=t.data.draftName,this.isFullPage&&Craft.cp.updateContext(t.data.draftName,t.data.creator?Craft.t("app","Saved {timestamp} by {creator}",{timestamp:t.data.timestamp,creator:t.data.creator}):Craft.t("app","Saved {timestamp}",{timestamp:t.data.timestamp}))),t.data.previewTargets&&JSON.stringify(t.data.previewTargets)!==JSON.stringify(this.settings.previewTargets)&&this.updatePreviewTargets(t.data.previewTargets),i&&(this.updatePreviewLinks(),this.trigger("createProvisionalDraft")),this.$nameTextInput&&this.checkMetaValues(),$.isPlainObject(t.data.draftElementIds)&&(this.draftElementIds=n(n({},this.draftElementIds),t.data.draftElementIds)),this.settings.updatedTimestamp=t.data.updatedTimestamp,this.settings.canonicalUpdatedTimestamp=t.data.canonicalUpdatedTimestamp},_afterSaveDraft:function(){this.$saveMetaBtn&&this.$saveMetaBtn.removeClass("active")},_showFailStatus:function(){this.statusIcons().velocity("stop").css("opacity","").removeClass("hidden checkmark-icon").addClass("alert-icon"),this.setStatusMessage(this._saveFailMessage())},updateFieldLayout:function(t){var e=this;return new Promise((function(n,i){if(e.submittingForm)i("Form already being submitted.");else{e.lastSerializedValue=t,e.cancelToken=axios.CancelToken.source();var a=e.prepareData(t),s=r({},e.namespaceInputName("visibleLayoutElements"),e.settings.visibleLayoutElements);e.settings.isProvisionalDraft&&(s[e.namespaceInputName("provisional")]=1);var o=e.$contentContainer.children("[data-layout-tab]:not(.hidden)").data("id");o&&(s[e.namespaceInputName("selectedTab")]=o),a+="&".concat($.param(s)),Craft.sendActionRequest("POST","elements/update-field-layout",{cancelToken:e.cancelToken.token,headers:e._saveHeaders,data:a}).then((function(i){e._afterUpdateFieldLayout(t,o,i),n()})).catch((function(t){e._afterSaveDraft(),e.ignoreFailedRequest||(e.failed=!0,t&&t.response&&(e.httpStatus=t.response.status,e.httpError=t.response.data?t.response.data.message:null),e._showFailStatus(),i(t)),e.ignoreFailedRequest=!1}))}}))},prepareData:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=Craft.findDeltaData(this.$container.data("initialSerializedValue"),t,this.$container.data("delta-names"),e,this.$container.data("initial-delta-values"),this.$container.data("modified-delta-names"),!0);if(this.settings.draftId&&(i.push("".concat(this.namespaceInputName("draftId"),"=").concat(this.settings.draftId)),this.settings.isProvisionalDraft&&i.push("".concat(this.namespaceInputName("provisional"),"=1"))),null!==this.settings.draftName&&i.push("".concat(this.namespaceInputName("draftName"),"=").concat(this.settings.draftName)),null!==this.settings.fieldId&&i.push("".concat(this.namespaceInputName("fieldId"),"=").concat(this.settings.fieldId)),null!==this.settings.ownerId&&i.push("".concat(this.namespaceInputName("ownerId"),"=").concat(this.settings.ownerId)),this.settings.saveParams)for(var r=0,a=Object.entries(this.settings.saveParams);r",{id:r.namespaceId(g.id),class:"flex-fields","data-id":g.id,"data-layout-tab":g.uid}),g.id!==e&&m.addClass("hidden"),m.appendTo(r.$contentContainer)),h=h.add(m),v=i(g.elements);try{for(v.s();!(b=v.n()).done;)!1!==(y=b.value).html?(u[g.uid]||(u[g.uid]=[]),u[g.uid].push(y.uid),"string"==typeof y.html&&(C=m.children('[data-layout-element="'.concat(y.uid,'"]')),w=$(y.html),C.length?C.replaceWith(w):w.appendTo(m),Craft.initUiElements(w),d=!0)):(_=m.children('[data-layout-element="'.concat(y.uid,'"]'))).length&&Garnish.hasAttr(_,"data-layout-element-placeholder")||(S=$("",{class:"hidden","data-layout-element":y.uid,"data-layout-element-placeholder":""}),_.length?_.replaceWith(S):S.appendTo(m),d=!0)}catch(t){v.e(t)}finally{v.f()}}}catch(t){f.e(t)}finally{f.f()}return(x=r.$contentContainer.children("[data-layout-tab]").not(h).not('[data-layout-tab=""]')).length&&(x.remove(),d=!0),h.filter(":not(.hidden)").length||h.first().removeClass("hidden"),r.settings.visibleLayoutElements=u,(null!==(o=r.settings.updateTabs)&&void 0!==o?o:r.isFullPage?function(t){return Craft.cp.updateTabs(t)}:function(){})(n.data.tabs),e&&c&&e!==c&&(I=r.tabManager)&&((T=I.$tabs.filter('[data-id="'.concat(c,'"]'))).length?I.selectTab(T):I.selectTab(I.$tabs.first())),a.next=16,Craft.appendHeadHtml(n.data.headHtml);case 16:return a.next=18,Craft.appendBodyHtml(n.data.bodyHtml);case 18:d&&(n.data.initialDeltaValues&&Object.assign(r.$container.data("initial-delta-values"),n.data.initialDeltaValues),l&&(r.lastSerializedValue=r.serializeForm(!0))),r.handleDismissibleTips();case 20:case"end":return a.stop()}}),s)})))()},afterUpdate:function(t){this.$container.data("initialSerializedValue",t),this.$container.data("initial-delta-values",{});var e=this.statusIcons().velocity("stop").css("opacity","").removeClass("hidden").addClass("checkmark-icon");this.setStatusMessage(this._saveSuccessMessage()),this.settings.autosaveDrafts||e.velocity("stop").velocity({opacity:0},{delay:2e3,complete:function(){e.addClass("hidden")}}),this.trigger("update"),(this.settings.isProvisionalDraft||this.settings.isUnpublishedDraft)&&Craft.broadcaster&&Craft.broadcaster.postMessage({event:"saveElement",id:this.settings.canonicalId})},setStatusMessage:function(t){this.statusIcons().attr("title",t),Craft.cp.announce(t)},showMetaModal:function(){var t=this;this.metaModal?this.metaModal.show():this.createMetaModal(),Garnish.isMobileBrowser(!0)||setTimeout((function(){t.$nameTextInput.focus()}),100)},createMetaModal:function(){var t=this,e=$("",{class:"modal fitted"}),n=$("",{class:"body"}).appendTo(e),i=$('
").appendTo(i),l=0;l").appendTo(o),s="".concat(Craft.t("app","Existing {type}",{type:Craft.t("app","Tag")}),": ").concat(e.data.tags[l].title),a.attr("aria-label",s),$('').appendTo(a).text(e.data.tags[l].title).data("id",e.data.tags[l].id).addClass(e.data.tags[l].exclude?"disabled":"");e.data.exactMatch||(a=$("").appendTo(o),s="".concat(Craft.t("app","Create {type}",{type:Craft.t("app","Tag")}),": ").concat(r.search),a.attr("aria-label",s),$('').appendTo(a).text(r.search)),o.find(".menu-item:not(.disabled):first").addClass("hover"),t.searchMenu=new Garnish.Menu(i,{anchor:t.$addTagInput,onOptionSelect:t.selectTag.bind(t)}),t.$addTagInput.attr("aria-controls",t.searchMenu.menuId),t.searchMenu.on("show",(function(){t.$addTagInput.attr("aria-expanded","true"),t.focusSelectedOption()})),t.searchMenu.on("hide",(function(){t.$addTagInput.attr("aria-expanded","false"),t.$addTagInput.removeAttr("aria-activedescendant")})),t.addListener(i,"mousedown",(function(){t._ignoreBlur=!0})),t.searchMenu.show()})).catch((function(e){e.response,t.searchMenu&&t.killSearchMenu(),t.$spinner.addClass("hidden"),Craft.cp.announce(Craft.t("app","Loading complete"))}))}else this.$spinner.addClass("hidden")},focusSelectedOption:function(){var t=this.searchMenu.$options.filter(".hover:first");t.length?this.focusOption(t):this.focusFirstOption()},focusFirstOption:function(){var t=this.searchMenu.$options.first();this.focusOption(t)},selectTag:function(t){var e=this,n=$(t);if(!n.hasClass("disabled")){var i=n.data("id"),r=n.text(),a=$("",{class:"chip element small removable","data-id":i,"data-site-id":this.settings.targetSiteId,"data-label":r,"data-editable":"1"}),s=$("").appendTo(this.$elementsContainer);a.appendTo(s);var o=$("",{class:"chip-content"}).appendTo(a),l=$("",{class:"label"}).appendTo(o),c=$("",{class:"label-link"}).appendTo(l);$("",{class:"title",text:r}).appendTo(c),$("",{class:"chip-actions"}).appendTo(o);var h=$("",{type:"hidden",name:this.settings.name+"[]",value:i}).appendTo(o);if(this.$elements=this.$elements.add(a),this.addElements(a),this.killSearchMenu(),this.$addTagInput.val(""),this.$addTagInput.focus(),!i){a.addClass("loading disabled");var u={groupId:this.settings.tagGroupId,title:r};Craft.sendActionRequest("POST","tags/create-tag",{data:u}).then((function(t){a.attr("data-id",t.data.id),h.val(t.data.id),a.removeClass("loading disabled")})).catch((function(t){var n;e.removeElement(a),Craft.cp.displayError(null==t||null===(n=t.response)||void 0===n||null===(n=n.data)||void 0===n?void 0:n.message)}))}}},killSearchMenu:function(){this.searchMenu.hide(),this.searchMenu.destroy(),this.searchMenu=null}},{defaults:{tagGroupId:null}})},3958:function(){Craft.ThumbsElementIndexView=Craft.BaseElementIndexView.extend({getElementContainer:function(){return this.$container.children("ul")}})},3079:function(){Craft.Tooltip=Garnish.Base.extend({_$trigger:null,_message:null,hud:null,$p:null,hoverTimeout:null,triggerHit:!1,shownViaHover:!1,init:function(t,e){var n=this;this.$trigger=$(t),this.message=e,"BUTTON"!==this.$trigger[0].tagName&&"button"!==this.$trigger.attr("role")&&console.error("Toggletip buttons need to be
\n");var l=function(n){function i(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),function(e,n,i){return n=s(n),function(e,n){if(n&&("object"===t(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(e)}(e,r()?Reflect.construct(n,i||[],s(e).constructor):n.apply(e,i))}(this,i,arguments)}var l,c,h;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e)}(i,n),l=i,h=[{key:"observedAttributes",get:function(){return["visible"]}}],(c=[{key:"connectedCallback",value:function(){this.root=this;var t=o.content.cloneNode(!0);this.root.append(t),"true"===this.visible&&this.wrapper.classList.remove("hidden"),this.initialized=!0}},{key:"visible",get:function(){return this.getAttribute("visible")},set:function(t){this.setAttribute("visible",t)}},{key:"messageWrapper",get:function(){return this.querySelector(".message")}},{key:"wrapper",get:function(){return this.querySelector(".wrapper")}},{key:"attributeChangedCallback",value:function(t,e,n){if(this.initialized)return"visible"===t.toLowerCase()?"true"===n?this.show():this.hide():void 0}},{key:"disconnectedCallback",value:function(){}},{key:"show",value:function(){this.wrapper.classList.remove("hidden"),this.dispatchEvent(new CustomEvent("show"))}},{key:"hide",value:function(){this.wrapper.classList.add("hidden"),this.dispatchEvent(new CustomEvent("hide"))}},{key:"focus",value:function(){this.wrapper.focus()}}])&&e(l.prototype,c),h&&e(l,h),Object.defineProperty(l,"prototype",{writable:!1}),i}(i(HTMLElement));customElements.define("craft-spinner",l)},691:function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,a,s,o=[],l=!0,c=!1;try{if(a=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=a.call(n)).done)&&(o.push(i.value),o.length!==e);l=!0);}catch(t){c=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw r}}return o}}(t,e)||r(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(){"use strict";n=function(){return i};var e,i={},r=Object.prototype,a=r.hasOwnProperty,s=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},l=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",h=o.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(e){u=function(t,e,n){return t[e]=n}}function d(t,e,n,i){var r=e&&e.prototype instanceof y?e:y,a=Object.create(r.prototype),o=new P(i||[]);return s(a,"_invoke",{value:E(t,n,o)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}i.wrap=d;var p="suspendedStart",g="suspendedYield",m="executing",v="completed",b={};function y(){}function C(){}function $(){}var w={};u(w,l,(function(){return this}));var _=Object.getPrototypeOf,S=_&&_(_(M([])));S&&S!==r&&a.call(S,l)&&(w=S);var x=$.prototype=y.prototype=Object.create(w);function I(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function T(e,n){function i(r,s,o,l){var c=f(e[r],e,s);if("throw"!==c.type){var h=c.arg,u=h.value;return u&&"object"==t(u)&&a.call(u,"__await")?n.resolve(u.__await).then((function(t){i("next",t,o,l)}),(function(t){i("throw",t,o,l)})):n.resolve(u).then((function(t){h.value=t,o(h)}),(function(t){return i("throw",t,o,l)}))}l(c.arg)}var r;s(this,"_invoke",{value:function(t,e){function a(){return new n((function(n,r){i(t,e,n,r)}))}return r=r?r.then(a,a):a()}})}function E(t,n,i){var r=p;return function(a,s){if(r===m)throw new Error("Generator is already running");if(r===v){if("throw"===a)throw s;return{value:e,done:!0}}for(i.method=a,i.arg=s;;){var o=i.delegate;if(o){var l=k(o,i);if(l){if(l===b)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===p)throw r=v,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=m;var c=f(t,n,i);if("normal"===c.type){if(r=i.done?v:g,c.arg===b)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(r=v,i.method="throw",i.arg=c.arg)}}}function k(t,n){var i=n.method,r=t.iterator[i];if(r===e)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=e,k(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),b;var a=f(r,t.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,b;var s=a.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,b):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function M(n){if(n||""===n){var i=n[l];if(i)return i.call(n);if("function"==typeof n.next)return n;if(!isNaN(n.length)){var r=-1,s=function t(){for(;++r=0;--r){var s=this.tryEntries[r],o=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),c=a.call(s,"finallyLoc");if(l&&c){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),A(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;A(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:M(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),b}},i}function i(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||r(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){if(t){if("string"==typeof t)return a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n').appendTo(Garnish.$bod);this.$sidebar=$('').appendTo(i).attr({role:"navigation","aria-label":Craft.t("app","Source")}),this.$sourcesContainer=$('
");var n=new Garnish.HUD(t,e,{hudClass:"hud revision-status-hud",onHide:function(){n.destroy()}});n.$mainContainer.find(".refresh-btn").on("click",(function(){window.location.reload()}))},_saveSuccessMessage:function(){return this.settings.isProvisionalDraft||this.settings.isUnpublishedDraft?Craft.t("app","Your changes have been stored."):Craft.t("app","The draft has been saved.")},_saveFailMessage:function(){return this.settings.isProvisionalDraft||this.settings.isUnpublishedDraft?Craft.t("app","Your changes could not be stored."):Craft.t("app","The draft could not be saved.")},spinners:function(){return this.$spinner},showSpinner:function(){this.spinners().removeClass("hidden")},hideSpinner:function(){this.spinners().addClass("hidden")},statusIcons:function(){return this.$statusIcon},createEditMetaAction:function(){if(this.isFullPage){var t=$("#action-menu").disclosureMenu().data("disclosureMenu"),e=t.getFirstDestructiveGroup(),n=t.addGroup(null,!0,e),i=t.addItem({type:"button",icon:"edit",label:Craft.t("app","Edit draft settings")},n);this.addListener(i,"click","showMetaModal")}},createPreviewLink:function(t,e){var n=this,i=$("",{href:this.getTokenizedPreviewUrl(t.url,null,!1),text:e||Craft.t("app","View"),target:"_blank",data:{targetUrl:t.url,targetLabel:t.label}});return this.addListener(i,"click",(function(){setTimeout((function(){n.activatePreviewToken()}),1)})),this.previewLinks.push(i),i},updatePreviewLinks:function(){var t=this;this.previewLinks.forEach((function(e){t.updatePreviewLinkHref(e),t.activatedPreviewToken&&t.removeListener(e,"click")}))},updatePreviewLinkHref:function(t){t.attr("href",this.getTokenizedPreviewUrl(t.data("targetUrl"),null,!1))},activatePreviewToken:function(){this.settings.isLive||(this.activatedPreviewToken=!0,this.updatePreviewLinks())},createShareMenu:function(t){var e=this,n=$("",{type:"button",class:"view-btn btn menubtn",text:Craft.t("app","View")}).appendTo(t),i=$("",{class:"menu"}).appendTo(t),r=$("
").appendTo(i);this.settings.previewTargets.forEach((function(t){$("").append(e.createPreviewLink(t,t.label)).appendTo(r)})),new Garnish.MenuBtn(n)},getPreviewTokenParams:function(){var t={elementType:this.settings.elementType,canonicalId:this.settings.canonicalId,siteId:this.settings.siteId,revisionId:this.settings.revisionId,previewToken:this.settings.previewToken};return this.settings.draftId&&!this.settings.isProvisionalDraft&&(t.draftId=this.settings.draftId),t},getPreviewToken:function(){var t=this;return this.previewTokenQueue.push((function(){return new Promise((function(e,n){t.activatedPreviewToken?e(t.settings.previewToken):Craft.sendActionRequest("POST","preview/create-token",{data:t.getPreviewTokenParams()}).then((function(){t.activatePreviewToken(),e(t.settings.previewToken)})).catch(n)}))}))},getTokenizedPreviewUrl:function(t,e){var n=this,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r={};if(!this.settings.previewParamValue||!e&&this.settings.isLive||(r[e||"x-craft-preview"]=this.settings.previewParamValue),this.settings.siteToken&&(r[Craft.siteToken]=this.settings.siteToken),this.settings.isLive){var a=Craft.getUrl(t,r);return i?new Promise((function(t){t(a)})):a}if(!this.settings.previewToken)throw"Missing preview token";r[Craft.tokenParam]=this.settings.previewToken;var s=Craft.getUrl(t,r);if(this.activatedPreviewToken)return i?new Promise((function(t){t(s)})):s;if(i)return new Promise((function(t,e){n.getPreviewToken().then((function(){t(s)})).catch(e)}));var o=this.getPreviewTokenParams();return o.redirect=s,Craft.getActionUrl("preview/create-token",o)},getPreview:function(){var t,e,n,i=this;return this.preview&&!this.preview.isVisible&&(null===(t=this.preview.elementEditor)||void 0===t?void 0:t.settings.updatedTimestamp)!==this.settings.updatedTimestamp&&(this.preview.destroy(),delete this.preview),this.preview||(this.preview=new Craft.Preview({elementType:this.settings.elementType,elementId:this.settings.isProvisionalDraft?this.settings.canonicalId:this.settings.elementId,draftId:this.settings.isProvisionalDraft?null:this.settings.draftId,revisionId:this.settings.revisionId,siteId:this.settings.siteId,onBeforeLoad:(n=o(a().mark((function t(){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.checkForm(!1,!0);case 2:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})}),this.preview.on("open",(function(){e=i.settings.updatedTimestamp,i.pause()})),this.preview.on("close",o(a().mark((function t(){var n,r,s,o;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i.$previewBtn&&i.$previewBtn.focus(),i.settings.updatedTimestamp===e){t.next=4;break}return t.next=4,i.refreshContent();case 4:null!==(s=null!==(n=null===(r=i.preview.tabManager)||void 0===r?void 0:r.getSelectedTabIndex())&&void 0!==n?n:null)&&(null===(o=i.tabManager)||void 0===o||o.selectTab(s)),i.resume();case 7:case"end":return t.stop()}}),t)})))),this.preview.on("afterSaveDraft",(function(t){var e=t.response;i._handleSaveDraftResponse(e)}))),this.preview},openPreview:(d=o(a().mark((function t(){var e,n,i,r,s;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Garnish.hasAttr(this.$previewBtn,"aria-disabled")){t.next=2;break}return t.abrupt("return");case 2:return this.$previewBtn.attr("aria-disabled",!0),t.prev=3,i=this.getPreview(),t.next=7,i.open();case 7:null!==(r=null!==(e=null===(n=this.tabManager)||void 0===n?void 0:n.getSelectedTabIndex())&&void 0!==e?e:null)&&(null===(s=i.tabManager)||void 0===s||s.selectTab(r));case 9:return t.prev=9,this.$previewBtn.removeAttr("aria-disabled"),t.finish(9);case 12:case"end":return t.stop()}}),t,this,[[3,,9,12]])}))),function(){return d.apply(this,arguments)}),ensureIsDraftOrRevision:function(t){var e=this;return new Promise((function(n,i){if(e.settings.draftId||e.settings.revisionId)n();else{if(t&&e.serializeForm(!0)===e.$container.data("initialSerializedValue"))return void n();e.saveDraft().then(n).catch(i)}}))},setFormValue:function(t,e){var n=this;return o(a().mark((function i(){return a().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!n.settings.revisionId){i.next=2;break}throw"Unable to set form values on a revision.";case 2:return i.next=4,n.checkForm();case 4:if(!n.$container.serialize().split("&").includes("".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(e)))){i.next=7;break}return i.abrupt("return",!1);case 7:if($("",{type:"hidden",name:t,value:e}).prependTo(n.$container),!n.settings.canCreateDrafts){i.next=11;break}return i.next=11,n.saveDraft();case 11:return i.abrupt("return",!0);case 12:case"end":return i.stop()}}),i)})))()},markDeltaNameAsModified:function(t){var e=this;return o(a().mark((function n(){var i;return a().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if((i=e.$container.data("modified-delta-names")||[]).includes(t)){n.next=6;break}return i.push(t),e.$container.data("modified-delta-names",i),n.next=6,e.saveDraft();case 6:case"end":return n.stop()}}),n)})))()},serializeForm:function(t){var e=this.$container.serialize();if(t&&!this.settings.isUnpublishedDraft){var n=encodeURIComponent(this.namespaceInputName("action")),i=encodeURIComponent(this.namespaceInputName("redirect"));e=(e=e.replace(new RegExp("&".concat(Craft.escapeRegex(n),"=[^&]*")),"")).replace(new RegExp("&".concat(Craft.escapeRegex(i),"=[^&]*")),"")}var r={serialized:e=e.replace(/&elementindex-[^&]*/g,"")};return this.trigger("serializeForm",{data:r}),r.serialized},checkForm:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.queue.push((function(){return new Promise((function(i,r){if(e.settings.revisionId)i();else if(void 0!==e.$container.data("initialSerializedValue")){var a=e.serializeForm(!0);t||a!==(e.lastSerializedValue||e.$container.data("initialSerializedValue"))?(null!=n?n:e.enableAutosave)&&e.settings.canCreateDrafts?e._saveDraftInternal(a).then(i).catch((function(t){console.warn("Couldn’t save draft:",t),r(t)})):e.updateFieldLayout(a).then(i).catch((function(t){console.warn("Couldn’t update field layout:",t),r(t)})):i()}else setTimeout((function(){e.checkForm(t).then(i).catch(r)}),500)}))}))},refreshContent:function(t){var e=this;return o(a().mark((function n(){var i;return a().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return e.settings.visibleLayoutElements=[],(i=[e.serializeForm(!0)]).push($.param(r({},e.namespaceInputName("applyParams"),0))),t&&!$.isEmptyObject(t)&&i.push($.param(t)),n.next=6,e.updateFieldLayout(i.join("&"));case 6:case"end":return n.stop()}}),n)})))()},isPreviewActive:function(){return this.preview&&this.preview.isActive},saveDraft:function(t){var e=this;return this.queue.push((function(){return new Promise((function(n,i){e._saveDraftInternal(e.serializeForm(!0),t).then(n).catch(i)}))}))},_saveDraftInternal:function(t,e){var a=this;return new Promise((function(e,s){if(a.submittingForm)s("Form already being submitted.");else{a.lastSerializedValue=t,a.failed=!1,a.httpStatus=null,a.httpError=null,a.cancelToken=axios.CancelToken.source(),a.statusIcons().velocity("stop").css("opacity","").removeClass("hidden invisible checkmark-icon alert-icon fade-out").addClass("hidden"),a.$saveMetaBtn&&a.$saveMetaBtn.addClass("active");var o,c=l(Craft.findModifiedDeltaNames(a.$container.data("initialSerializedValue"),t,a.$container.data("delta-names"),a.$container.data("initial-delta-values"),a.$container.data("modified-delta-names"),!0),1)[0],h=a.prepareData(t,null,!0),u=$(),d=i(c);try{for(d.s();!(o=d.n()).done;){var f=o.value,p=u=u.add(a.$container.find('.field[data-base-input-name="'.concat($.escapeSelector(f),'"]')));u=u.add(p).add(p.parentsUntil(a.$container,".field"))}}catch(t){d.e(t)}finally{d.f()}h.push($.param(r({},a.namespaceInputName("visibleLayoutElements"),a.settings.visibleLayoutElements))),!a.settings.isProvisionalDraft&&a.settings.draftId||h.push("".concat(a.namespaceInputName("provisional"),"=1"));var g=a.$contentContainer.children("[data-layout-tab]:not(.hidden)").data("id");g&&h.push("".concat(a.namespaceInputName("selectedTab"),"=").concat(g)),Craft.sendActionRequest("POST","elements/save-draft",{cancelToken:a.cancelToken.token,headers:a._saveHeaders,data:h.join("&")}).then((function(i){var r;a._afterSaveDraft(),a.settings.previewParamValue=i.data.previewParamValue,a._afterUpdateFieldLayout(t,g,i),a._handleSaveDraftResponse(i),$.isPlainObject(i.data.draftElementUids)&&(a.draftElementUids=n(n({},a.draftElementUids),i.data.draftElementUids));var s=i.data.modifiedAttributes.map((function(t){return t=a.namespaceInputName(t),['[name="'.concat(t,'"]'),'[name^="'.concat(t,'["]')]})).flat().join(",");u=u.add(a.$contentContainer.find(s).parentsUntil(a.$container,".flex-fields > .field")).add(null===(r=a.$sidebar)||void 0===r?void 0:r.find(s).closest(".field")).not(":has(> .status-badge)");for(var o=0;o",{class:"status-badge modified","aria-hidden":"true",title:Craft.t("app","This field has been modified.")}).append($("",{class:"visually-hidden",html:Craft.t("app","This field has been modified.")})));a.afterUpdate(t),a.trigger("afterSaveDraft",{response:i}),Craft.broadcaster&&Craft.broadcaster.postMessage({pageId:Craft.pageId,event:"saveDraft",canonicalId:a.settings.canonicalId,draftId:a.settings.draftId,isProvisionalDraft:a.settings.isProvisionalDraft}),e()})).catch((function(t){a._afterSaveDraft(),a.ignoreFailedRequest||(a.failed=!0,t&&t.response&&(a.httpStatus=t.response.status,a.httpError=t.response.data?t.response.data.message:null),a._showFailStatus(),s(t)),a.ignoreFailedRequest=!1}))}}))},_handleSaveDraftResponse:function(t){var e=this,i=!this.settings.draftId;i&&(this.settings.isProvisionalDraft=!0),this.isFullPage&&(t.data.title&&this.$container.find(".screen-title").text(t.data.title),t.data.docTitle&&(document.title=t.data.docTitle)),this.newSiteIds&&(this.newSiteIds.forEach((function(t){var n=e.settings.additionalSites.find((function(e){return e.siteId==t})),i=!n||void 0===n.enabledByDefault||n.enabledByDefault;Craft.cp.showSiteCrumbMenuItem(t),Craft.cp.setSiteCrumbMenuItemStatus(t,i?"enabled":"disabled")})),this.newSiteIds=null),this.settings.isProvisionalDraft?i&&(this.$container.find("input.action-input").attr("value","elements/apply-draft"),this.settings.elementId=t.data.elementId,this.settings.draftId=t.data.draftId,this.settings.isLive=!1,this.previewToken=null,this.initForProvisionalDraft()):(this.settings.draftName=t.data.draftName,this.isFullPage&&Craft.cp.updateContext(t.data.draftName,t.data.creator?Craft.t("app","Saved {timestamp} by {creator}",{timestamp:t.data.timestamp,creator:t.data.creator}):Craft.t("app","Saved {timestamp}",{timestamp:t.data.timestamp}))),t.data.previewTargets&&JSON.stringify(t.data.previewTargets)!==JSON.stringify(this.settings.previewTargets)&&this.updatePreviewTargets(t.data.previewTargets),i&&(this.updatePreviewLinks(),this.trigger("createProvisionalDraft")),this.$nameTextInput&&this.checkMetaValues(),$.isPlainObject(t.data.draftElementIds)&&(this.draftElementIds=n(n({},this.draftElementIds),t.data.draftElementIds)),this.settings.updatedTimestamp=t.data.updatedTimestamp,this.settings.canonicalUpdatedTimestamp=t.data.canonicalUpdatedTimestamp},_afterSaveDraft:function(){this.$saveMetaBtn&&this.$saveMetaBtn.removeClass("active")},_showFailStatus:function(){this.statusIcons().velocity("stop").css("opacity","").removeClass("hidden checkmark-icon").addClass("alert-icon"),this.setStatusMessage(this._saveFailMessage())},updateFieldLayout:function(t){var e=this;return new Promise((function(n,i){if(e.submittingForm)i("Form already being submitted.");else{e.lastSerializedValue=t,e.cancelToken=axios.CancelToken.source();var a=e.prepareData(t),s=r({},e.namespaceInputName("visibleLayoutElements"),e.settings.visibleLayoutElements);e.settings.isProvisionalDraft&&(s[e.namespaceInputName("provisional")]=1);var o=e.$contentContainer.children("[data-layout-tab]:not(.hidden)").data("id");o&&(s[e.namespaceInputName("selectedTab")]=o),a+="&".concat($.param(s)),Craft.sendActionRequest("POST","elements/update-field-layout",{cancelToken:e.cancelToken.token,headers:e._saveHeaders,data:a}).then((function(i){e._afterUpdateFieldLayout(t,o,i),n()})).catch((function(t){e._afterSaveDraft(),e.ignoreFailedRequest||(e.failed=!0,t&&t.response&&(e.httpStatus=t.response.status,e.httpError=t.response.data?t.response.data.message:null),e._showFailStatus(),i(t)),e.ignoreFailedRequest=!1}))}}))},prepareData:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=Craft.findDeltaData(this.$container.data("initialSerializedValue"),t,this.$container.data("delta-names"),e,this.$container.data("initial-delta-values"),this.$container.data("modified-delta-names"),!0);if(this.settings.draftId&&(i.push("".concat(this.namespaceInputName("draftId"),"=").concat(this.settings.draftId)),this.settings.isProvisionalDraft&&i.push("".concat(this.namespaceInputName("provisional"),"=1"))),null!==this.settings.draftName&&i.push("".concat(this.namespaceInputName("draftName"),"=").concat(this.settings.draftName)),null!==this.settings.fieldId&&i.push("".concat(this.namespaceInputName("fieldId"),"=").concat(this.settings.fieldId)),null!==this.settings.ownerId&&i.push("".concat(this.namespaceInputName("ownerId"),"=").concat(this.settings.ownerId)),this.settings.saveParams)for(var r=0,a=Object.entries(this.settings.saveParams);r",{id:r.namespaceId(g.id),class:"flex-fields","data-id":g.id,"data-layout-tab":g.uid}),g.id!==e&&m.addClass("hidden"),m.appendTo(r.$contentContainer)),h=h.add(m),v=i(g.elements);try{for(v.s();!(b=v.n()).done;)!1!==(y=b.value).html?(u[g.uid]||(u[g.uid]=[]),u[g.uid].push(y.uid),"string"==typeof y.html&&(C=m.children('[data-layout-element="'.concat(y.uid,'"]')),w=$(y.html),C.length?C.replaceWith(w):w.appendTo(m),Craft.initUiElements(w),d=!0)):(_=m.children('[data-layout-element="'.concat(y.uid,'"]'))).length&&Garnish.hasAttr(_,"data-layout-element-placeholder")||(S=$("",{class:"hidden","data-layout-element":y.uid,"data-layout-element-placeholder":""}),_.length?_.replaceWith(S):S.appendTo(m),d=!0)}catch(t){v.e(t)}finally{v.f()}}}catch(t){f.e(t)}finally{f.f()}return(x=r.$contentContainer.children("[data-layout-tab]").not(h).not('[data-layout-tab=""]')).length&&(x.remove(),d=!0),h.filter(":not(.hidden)").length||h.first().removeClass("hidden"),r.settings.visibleLayoutElements=u,(null!==(o=r.settings.updateTabs)&&void 0!==o?o:r.isFullPage?function(t){return Craft.cp.updateTabs(t)}:function(){})(n.data.tabs),e&&c&&e!==c&&(I=r.tabManager)&&((T=I.$tabs.filter('[data-id="'.concat(c,'"]'))).length?I.selectTab(T):I.selectTab(I.$tabs.first())),a.next=16,Craft.appendHeadHtml(n.data.headHtml);case 16:return a.next=18,Craft.appendBodyHtml(n.data.bodyHtml);case 18:d&&(n.data.initialDeltaValues&&Object.assign(r.$container.data("initial-delta-values"),n.data.initialDeltaValues),l&&(r.lastSerializedValue=r.serializeForm(!0))),r.handleDismissibleTips();case 20:case"end":return a.stop()}}),s)})))()},afterUpdate:function(t){this.$container.data("initialSerializedValue",t),this.$container.data("initial-delta-values",{});var e=this.statusIcons().velocity("stop").css("opacity","").removeClass("hidden").addClass("checkmark-icon");this.setStatusMessage(this._saveSuccessMessage()),this.settings.autosaveDrafts||e.velocity("stop").velocity({opacity:0},{delay:2e3,complete:function(){e.addClass("hidden")}}),this.trigger("update"),(this.settings.isProvisionalDraft||this.settings.isUnpublishedDraft)&&Craft.broadcaster&&Craft.broadcaster.postMessage({event:"saveElement",id:this.settings.canonicalId})},setStatusMessage:function(t){this.statusIcons().attr("title",t),Craft.cp.announce(t)},showMetaModal:function(){var t=this;this.metaModal?this.metaModal.show():this.createMetaModal(),Garnish.isMobileBrowser(!0)||setTimeout((function(){t.$nameTextInput.focus()}),100)},createMetaModal:function(){var t=this,e=$("",{class:"modal fitted"}),n=$("",{class:"body"}).appendTo(e),i=$('