silex-website-builder-goodevent
Version:
Free and easy website builder for everyone.
1 lines • 1.39 MB
JavaScript
!function(e){var t={};function i(s){if(t[s])return t[s].exports;var o=t[s]={i:s,l:!1,exports:{}};return e[s].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=e,i.c=t,i.d=function(e,t,s){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(s,o,function(t){return e[t]}.bind(null,o));return s},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=7)}([function(e,t,i){"use strict";(function(e,s){var o,n=i(3);o="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==e?e:s;var r=Object(n.a)(o);t.a=r}).call(this,i(5),i(6)(e))},function(e,t,i){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});var i=function(){return function(e,t,i){this.name=e,this.version=t,this.os=i}}();t.BrowserInfo=i;var s=function(){return function(t){this.version=t,this.name="node",this.os=e.platform}}();t.NodeInfo=s;var o=function(){return function(){this.bot=!0,this.name="bot",this.version=null,this.os=null}}();t.BotInfo=o;var n=3,r=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["vivaldi",/Vivaldi\/([0-9\.]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/Edg\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/]],l=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/],["Search Bot",/(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves\/Teoma)|(ia_archiver)/]];function a(e){var t=""!==e&&r.reduce(function(t,i){var s=i[0],o=i[1];if(t)return t;var n=o.exec(e);return!!n&&[s,n]},!1);if(!t)return null;var s=t[0],l=t[1];if("searchbot"===s)return new o;var a=l[1]&&l[1].split(/[._]/).slice(0,3);return a?a.length<n&&(a=a.concat(function(e){for(var t=[],i=0;i<e;i++)t.push("0");return t}(n-a.length))):a=[],new i(s,a.join("."),c(e))}function c(e){for(var t=0,i=l.length;t<i;t++){var s=l[t],o=s[0];if(s[1].test(e))return o}return null}function h(){return void 0!==e&&e.version?new s(e.version.slice(1)):null}t.detect=function(){return"undefined"!=typeof navigator?a(navigator.userAgent):h()},t.parseUserAgent=a,t.detectOS=c,t.getNodeVersion=h}).call(this,i(4))},function(e,t,i){var s,o,n;o=[t,e],void 0===(n="function"==typeof(s=function(e,t){"use strict";t.exports=d;var i=8,s=9,o=13,n=37,r=39,l=46,a=188,c=",",h="placeholder pattern spellcheck autocomplete autocapitalize autofocus accessKey accept lang minLength maxLength required".split(" ");function d(e){function t(e,t,i,s){var o=document.createElement(e);for(var n in t&&(o.className=t),i&&(o.textContent=i),s)o.setAttribute("data-"+n,s[n]);return o}function d(e,t){return!0===t?Array.prototype.slice.call(S.querySelectorAll(e)):S.querySelector(e)}function u(){return d(".tag",!0).map(function(e){return e.textContent}).concat(S.input.value||[]).join(c)}function p(){e.value=u(),e.dispatchEvent(new Event("change"))}function m(i){if(~i.indexOf(c)&&(i=i.split(c)),Array.isArray(i))return i.forEach(m);var s=i&&i.trim();if(!s)return!1;if(!e.getAttribute("duplicates")){var o=function(){var e=d('[data-tag="'+s+'"]');if(e)return e.classList.add("dupe"),setTimeout(function(){return e.classList.remove("dupe")},100),{v:!1}}();if("object"==typeof o)return o.v}S.insertBefore(t("span","tag",s,{tag:s}),S.input)}function g(e){var t=d(".selected");t&&t.classList.remove("selected"),e&&e.classList.add("selected")}function b(){var e=d(".tag",!0).pop(),t=S.offsetWidth;t&&(S.input.style.width=Math.max(t-(e?e.offsetLeft+e.offsetWidth:5)-5,t/4)+"px")}function y(e){"string"==typeof e||Array.isArray(e)||(e=S.input.value),!1!==m(e)&&(S.input.value="",p(),b())}function E(e){return e.target.classList.contains("tag")&&g(e.target),e.target===S.input?g():(S.input.focus(),e.preventDefault(),!1)}var S=t("div","tags-input"),f=e.nextSibling;e.parentNode[f?"insertBefore":"appendChild"](S,f),e.style.cssText="position:absolute;left:0;top:-99px;width:1px;height:1px;opacity:0.01;",e.tabIndex=-1,S.input=t("input"),S.input.setAttribute("type","text"),h.forEach(function(t){if(e[t]!==S.input[t]){S.input[t]=e[t];try{delete e[t]}catch(e){}}}),S.appendChild(S.input),e.addEventListener("focus",function(){S.input.focus()}),S.input.addEventListener("focus",function(){S.classList.add("focus"),g()}),S.input.addEventListener("blur",function(){S.classList.remove("focus"),g(),y()}),S.input.addEventListener("keydown",function(e){var t=S.input,c=e.keyCode||e.which,h=d(".tag.selected"),u=t.selectionStart===t.selectionEnd&&t.selectionStart,m=d(".tag",!0).pop();if(b(),c===o||c===a||c===s){if(!t.value&&c!==a)return;y()}else if(c===l&&h)h.nextSibling!==S.input&&g(h.nextSibling),S.removeChild(h),b(),p();else if(c===i)if(h)g(h.previousSibling),S.removeChild(h),b(),p();else{if(!m||0!==u)return;g(m)}else if(c===n)if(h)h.previousSibling&&g(h.previousSibling);else{if(0!==u)return;g(m)}else{if(c!==r)return g();if(!h)return;g(h.nextSibling)}return e.preventDefault(),!1}),S.input.addEventListener("input",function(){e.value=u(),e.dispatchEvent(new Event("input"))}),S.input.addEventListener("paste",function(){return setTimeout(y,0)}),S.addEventListener("mousedown",E),S.addEventListener("touchstart",E),S.setValue=function(e){d(".tag",!0).forEach(function(e){return S.removeChild(e)}),y(e)},S.getValue=u,y(e.value)}d.enhance=d.tagsInput=d})?s.apply(t,o):s)||(e.exports=n)},function(e,t,i){"use strict";function s(e){var t,i=e.Symbol;return"function"==typeof i?i.observable?t=i.observable:(t=i("observable"),i.observable=t):t="@@observable",t}i.d(t,"a",function(){return s})},function(e,t){var i,s,o=e.exports={};function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function l(e){if(i===setTimeout)return setTimeout(e,0);if((i===n||!i)&&setTimeout)return i=setTimeout,setTimeout(e,0);try{return i(e,0)}catch(t){try{return i.call(null,e,0)}catch(t){return i.call(this,e,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:n}catch(e){i=n}try{s="function"==typeof clearTimeout?clearTimeout:r}catch(e){s=r}}();var a,c=[],h=!1,d=-1;function u(){h&&a&&(h=!1,a.length?c=a.concat(c):d=-1,c.length&&p())}function p(){if(!h){var e=l(u);h=!0;for(var t=c.length;t;){for(a=c,c=[];++d<t;)a&&a[d].run();d=-1,t=c.length}a=null,h=!1,function(e){if(s===clearTimeout)return clearTimeout(e);if((s===r||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(e);try{s(e)}catch(t){try{return s.call(null,e)}catch(t){return s.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function g(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];c.push(new m(e,t)),1!==c.length||h||l(p)},m.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=g,o.addListener=g,o.once=g,o.off=g,o.removeListener=g,o.removeAllListeners=g,o.emit=g,o.prependListener=g,o.prependOnceListener=g,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"==typeof window&&(i=window)}e.exports=i},function(e,t){e.exports=function(e){if(!e.webpackPolyfill){var t=Object.create(e);t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),Object.defineProperty(t,"exports",{enumerable:!0}),t.webpackPolyfill=1}return t}},function(e,t,i){"use strict";i.r(t);var s=i(1);class o{}o.debug={debugMode:!1,preventQuit:!1,debugScript:"/js/debug.js"},o.WIKI_SILEX="https://github.com/silexlabs/Silex/wiki",o.WIKI_SILEX_CUSTOM_CSS_CLASS="https://github.com/silexlabs/Silex/wiki/Silex-CSS-editor#custom-css-classes",o.CROWD_FUNDING="http://crowdfunding.silex.me/",o.ISSUES_SILEX="https://github.com/silexlabs/Silex/issues?state=open",o.DOWNLOADS_TEMPLATE_SILEX="https://github.com/silexlabs/Silex/issues?labels=template&state=open",o.DOWNLOADS_WIDGET_SILEX="https://github.com/silexlabs/Silex/issues?labels=widget&state=open",o.ABOUT_SILEX_LABS="http://www.silexlabs.org/",o.SUBSCRIBE_SILEX_LABS="http://eepurl.com/F48q5",o.SOCIAL_DIASPORA="https://diasp.org/people/f37438103a9b013250aa2a0000053625",o.SOCIAL_TWITTER="http://twitter.com/silexlabs",o.SOCIAL_FB="http://www.facebook.com/silexlabs",o.FORK_CODE="https://github.com/silexlabs/Silex",o.CONTRIBUTE="https://github.com/silexlabs/Silex/wiki/Contribute",o.shortcuts=[{label:"New File",id:"file.new",key:"n",altKey:!0},{label:"Open File...",id:"file.open",key:"o",ctrlKey:!0},{label:"Save File",id:"file.save",key:"s",ctrlKey:!0},{label:"Save As...",id:"file.saveas",key:"s",ctrlKey:!0,shiftKey:!0},{label:"Publish",id:"file.publish",key:"p",ctrlKey:!0},{label:"Settings...",id:"file.publish.settings",key:"o",altKey:!0},{label:"Copy",id:"edit.copy.selection",key:"c",ctrlKey:!0,input:!1},{label:"Paste",id:"edit.paste.selection",key:"v",ctrlKey:!0,input:!1},{label:"Duplicate",id:"edit.duplicate.selection",key:"D",ctrlKey:!0,input:!1},{label:"Undo",id:"edit.undo",key:"z",ctrlKey:!0,input:!1},{label:"Redo",id:"edit.redo",key:"z",ctrlKey:!0,shiftKey:!0,input:!1},{label:"Delete selection",id:"edit.delete.selection",key:"Delete",input:!1},{label:"Empty selection",id:"edit.empty.selection",key:"Escape",input:!1},{label:"Rename page",id:"edit.rename.page",key:"r",altKey:!0},{label:"Preview",id:"view.file",key:"v",altKey:!0},{label:"Preview in Responsize",id:"view.file.responsize",key:"v",shiftKey:!0,altKey:!0},{label:"Mobile editor",id:"tools.mobile.mode",key:"m",altKey:!0},{label:"HTML <head> editor",id:"view.open.htmlHeadEditor",key:"e",altKey:!0},{label:"JS scripts editor",id:"view.open.jsEditor",key:"j",altKey:!0},{label:"CSS styles editor",id:"view.open.cssEditor",key:"d",altKey:!0},{label:"Text box",id:"insert.text",key:"t",altKey:!0},{label:"Image...",id:"insert.image",key:"i",altKey:!0},{label:"Container",id:"insert.container",key:"c",altKey:!0},{label:"HTML box",id:"insert.html",key:"h",altKey:!0},{label:"Section",id:"insert.section",key:"s",altKey:!0},{label:"New page",id:"insert.page",key:"p",altKey:!0}];class n{}n.WEBSITE_CONTEXT_RUNTIME_CLASS_NAME="silex-runtime",n.WEBSITE_CONTEXT_EDITOR_CLASS_NAME="silex-editor",n.WEBSITE_CONTEXT_PUBLISHED_CLASS_NAME="silex-published",n.PAGED_CLASS_NAME="paged-element",n.PAGEABLE_PLUGIN_READY_CLASS_NAME="pageable-plugin-created",n.PAGED_HIDDEN_CLASS_NAME="paged-element-hidden",n.PAGES_CONTAINER_CLASS_NAME="silex-pages",n.PAGED_VISIBLE_CLASS_NAME="paged-element-visible",n.PAGE_LINK_ACTIVE_CLASS_NAME="page-link-active",n.LOADING_ELEMENT_CSS_CLASS="loading-image",n.TYPE_PAGE="page-element",n.TYPE_CONTAINER="container-element",n.TYPE_SECTION="section-element",n.TYPE_CONTAINER_CONTENT="silex-container-content",n.TYPE_IMAGE="image-element",n.TYPE_TEXT="text-element",n.TYPE_HTML="html-element",n.TYPE_ATTR="data-silex-type",n.ELEMENT_ID_ATTR_NAME="data-silex-id",n.STATIC_ASSET_ATTR="data-silex-static",n.ELEMENT_CONTENT_CLASS_NAME="silex-element-content",n.WEBSITE_WIDTH_CLASS_NAME="website-width",n.LINK_ATTR="data-silex-href",n.STAGE_COMPONENT_SELECTED_CLASS_NAME="selected",n.STAGE_COMPONENT_NOT_SELECTED_CLASS_NAME="not-selected",n.SELECTED_CLASS_NAME="silex-selected",n.HIDE_ON_MOBILE="hide-on-mobile",n.HIDE_ON_DESKTOP="hide-on-desktop",n.EDITABLE_CLASS_NAME="editable-style",n.PREVENT_RESIZABLE_CLASS_NAME="prevent-resizable",n.PREVENT_RESIZABLE_TOP_CLASS_NAME="prevent-resizable-top",n.PREVENT_RESIZABLE_LEFT_CLASS_NAME="prevent-resizable-left",n.PREVENT_RESIZABLE_BOTTOM_CLASS_NAME="prevent-resizable-bottom",n.PREVENT_RESIZABLE_RIGHT_CLASS_NAME="prevent-resizable-right",n.PREVENT_SELECTABLE_CLASS_NAME="prevent-selectable",n.PREVENT_DRAGGABLE_CLASS_NAME="prevent-draggable",n.PREVENT_DROPPABLE_CLASS_NAME="prevent-droppable",n.SILEX_USE_HEIGHT_NOT_MINHEIGHT="silex-use-height-not-minheight",n.SILEX_STYLE_ELEMENT_CSS_CLASS="silex-style",n.SILEX_SCRIPT_ELEMENT_CSS_CLASS="silex-script",n.CUSTOM_FONTS_CSS_CLASS="silex-custom-font",n.ENABLE_MOBILE_CSS_CLASS="enable-mobile",n.SILEX_CURRENT_PAGE_ID="current-page-style",n.SILEX_TEMP_TAGS_CSS_CLASS="silex-temp-tag",n.RISZE_HANDLE_CSS_CLASS="ui-resizable-handle",n.JSON_STYLE_TAG_CLASS_NAME="silex-json-styles",n.INLINE_STYLE_TAG_CLASS_NAME="silex-inline-styles",n.HEAD_TAG_START="\x3c!-- Silex HEAD tag do not remove --\x3e",n.HEAD_TAG_STOP="\x3c!-- End of Silex HEAD tag do not remove --\x3e",n.COMPONENT_CLASS_NAME="silex-component",n.STYLE_CLASS_NAME="silex-prodotype-style",n.BODY_STYLE_NAME="All style",n.BODY_STYLE_CSS_CLASS="all-style",n.EMPTY_STYLE_CLASS_NAME="empty-style-class-name",n.EMPTY_STYLE_DISPLAY_NAME="",n.COMPONENT_TYPE="component",n.STYLE_TYPE="style",n.STYLE_VISIBILITY=["desktop","mobile"],n.SILEX_CLASS_NAMES=[n.PREVENT_DROPPABLE_CLASS_NAME,n.SILEX_USE_HEIGHT_NOT_MINHEIGHT,n.PREVENT_RESIZABLE_CLASS_NAME,n.PREVENT_RESIZABLE_TOP_CLASS_NAME,n.PREVENT_RESIZABLE_LEFT_CLASS_NAME,n.PREVENT_RESIZABLE_BOTTOM_CLASS_NAME,n.PREVENT_RESIZABLE_RIGHT_CLASS_NAME,n.PREVENT_SELECTABLE_CLASS_NAME,n.PREVENT_DRAGGABLE_CLASS_NAME,n.EDITABLE_CLASS_NAME,n.ENABLE_MOBILE_CSS_CLASS,n.PAGED_CLASS_NAME,n.PAGED_HIDDEN_CLASS_NAME,n.PAGED_VISIBLE_CLASS_NAME,n.PAGEABLE_PLUGIN_READY_CLASS_NAME,n.PAGE_LINK_ACTIVE_CLASS_NAME,n.STAGE_COMPONENT_SELECTED_CLASS_NAME,n.STAGE_COMPONENT_NOT_SELECTED_CLASS_NAME,n.SELECTED_CLASS_NAME,n.ELEMENT_CONTENT_CLASS_NAME,n.TYPE_CONTAINER_CONTENT,n.WEBSITE_WIDTH_CLASS_NAME,n.TYPE_CONTAINER,n.TYPE_SECTION,n.TYPE_IMAGE,n.TYPE_TEXT,n.TYPE_HTML,n.HIDE_ON_MOBILE,n.COMPONENT_CLASS_NAME,n.WEBSITE_CONTEXT_EDITOR_CLASS_NAME,n.WEBSITE_CONTEXT_PUBLISHED_CLASS_NAME,n.WEBSITE_CONTEXT_RUNTIME_CLASS_NAME,n.BODY_STYLE_CSS_CLASS],n.SILEX_TEMP_CLASS_NAMES=[n.PAGE_LINK_ACTIVE_CLASS_NAME,n.PAGEABLE_PLUGIN_READY_CLASS_NAME,n.PAGED_HIDDEN_CLASS_NAME,n.PAGED_VISIBLE_CLASS_NAME,n.STAGE_COMPONENT_SELECTED_CLASS_NAME,n.STAGE_COMPONENT_NOT_SELECTED_CLASS_NAME,n.SELECTED_CLASS_NAME],n.SILEX_CLASS_NAMES_TO_REMOVE_AT_PUBLISH=[n.PREVENT_DROPPABLE_CLASS_NAME,n.SILEX_USE_HEIGHT_NOT_MINHEIGHT,n.PREVENT_RESIZABLE_CLASS_NAME,n.PREVENT_RESIZABLE_TOP_CLASS_NAME,n.PREVENT_RESIZABLE_LEFT_CLASS_NAME,n.PREVENT_RESIZABLE_BOTTOM_CLASS_NAME,n.PREVENT_RESIZABLE_RIGHT_CLASS_NAME,n.PREVENT_SELECTABLE_CLASS_NAME,n.PREVENT_DRAGGABLE_CLASS_NAME,n.PAGED_CLASS_NAME,n.PAGED_HIDDEN_CLASS_NAME,n.PAGED_VISIBLE_CLASS_NAME,n.PAGEABLE_PLUGIN_READY_CLASS_NAME,n.PAGE_LINK_ACTIVE_CLASS_NAME,n.STAGE_COMPONENT_SELECTED_CLASS_NAME,n.STAGE_COMPONENT_NOT_SELECTED_CLASS_NAME,n.SELECTED_CLASS_NAME],n.ELEMENTS_TO_REMOVE_AT_PUBLISH=[".prodotype-preview",'meta[name="publicationPath"]',`.${n.JSON_STYLE_TAG_CLASS_NAME}`];class r{static getInstance(){return r.instance=r.instance||new r,r.instance}trackAction(e,t,i,s){window.tracker&&window.tracker.log&&window.tracker.log(...arguments)}trackOnError(e,t,i,s,o){window.tracker&&window.tracker.error&&window.tracker.error(...arguments)}}r.SILEX_ACTIONS_CATEGORY="silex-event";class l{constructor(e){this.delay=e,this.isDirty=!1,this.cbk=null}callWhenReady(e){this.isDirty?this.cbk=e:(this.isDirty=!0,e(),this.startDirty())}startDirty(){setTimeout(()=>{null===this.cbk?this.isDirty=!1:(this.cbk(),this.cbk=null,this.startDirty())},this.delay)}}let a;function c(){return a||(a={stage:document.querySelector("#silex-stage-iframe"),fileExplorer:document.querySelector("#silex-file-explorer"),contextMenu:document.querySelector(".silex-context-menu"),menu:document.querySelector(".silex-menu"),breadCrumbs:document.querySelector(".silex-bread-crumbs"),pageTool:document.querySelector(".silex-page-tool"),htmlEditor:document.querySelector(".silex-html-editor"),cssEditor:document.querySelector(".silex-css-editor"),jsEditor:document.querySelector(".silex-js-editor"),settingsDialog:document.querySelector(".silex-settings-dialog"),dashboard:document.querySelector(".silex-dashboard"),propertyTool:document.querySelector(".silex-property-tool"),textFormatBar:document.querySelector(".silex-text-format-bar"),workspace:document.querySelector(".silex-workspace"),verticalSplitter:document.querySelector(".vertical-splitter")}),a}class h{constructor(){throw new Error("this is a static class and it canot be instanciated")}static get isActive(){return!!h.currentDialog&&!document.querySelector(".alerts").classList.contains("closed")}static get currentDialog(){return document.querySelector(`.${h.NOTIFICATION_CSS_CLASS}`)}static close(e=!1){if(h.currentDialog){document.querySelector(".alerts").classList.add("closed");const t=e?h.cbkOk:h.cbkCancel;h.currentDialog.remove(),h.cbkCancel=null,h.cbkOk=null,t()}}static alert(e,t,i,s="ok"){h.close(),h.create(h.getMarkup({labelOk:s,title:e,content:t})),h.cbkCancel=h.cbkOk=()=>i(),h.currentDialog.querySelector(`#${h.NOTIFICATION_CSS_CLASS}_ok`).onclick=e=>h.close()}static prompt(e,t,i,s,o,n="ok",r="cancel"){h.close(),h.create(h.getMarkup({labelOk:n,labelCancel:r,defaultValue:i,title:e,content:t,placeholder:s}));const l=h.currentDialog.querySelector(`#${h.NOTIFICATION_CSS_CLASS}_value`);h.cbkOk=()=>{o(!0,l.value)},h.cbkCancel=()=>{o(!1,null)},h.currentDialog.querySelector(`#${h.NOTIFICATION_CSS_CLASS}_ok`).onclick=e=>h.close(!0),h.currentDialog.querySelector(`#${h.NOTIFICATION_CSS_CLASS}_cancel`).onclick=e=>h.close(!1)}static confirm(e,t,i,s="ok",o="cancel"){h.close(),h.create(h.getMarkup({labelOk:s,labelCancel:o,title:e,content:t})),h.cbkOk=()=>i(!0),h.cbkCancel=()=>i(!1),h.currentDialog.querySelector(`#${h.NOTIFICATION_CSS_CLASS}_ok`).onclick=e=>h.close(!0),h.currentDialog.querySelector(`#${h.NOTIFICATION_CSS_CLASS}_cancel`).onclick=e=>h.close(!1)}static notifySuccess(e){const t=document.querySelector(".alerts-notify"),i=document.createElement("p");i.innerHTML=e,t.appendChild(i);const s=setTimeout(()=>{i.remove()},h.NOTIFICATION_DURATION_MS);i.onclick=e=>{clearTimeout(s),i.remove()}}static notifyError(e){console.error(e),h.notifySuccess(e)}static setContent(e,t=!1){if(h.currentDialog){const i=h.currentDialog.querySelector(`.${h.NOTIFICATION_CSS_CLASS}_content`);t||(i.innerHTML=""),i.appendChild(e)}}static setText(e){if(h.currentDialog){const t=document.createElement("div");t.insertAdjacentHTML("afterbegin",`<p>${e}</p>`),h.setContent(t)}}static addButton(e){h.currentDialog&&h.currentDialog.querySelector(`.${h.NOTIFICATION_CSS_CLASS}_buttons`)}static setInfoPanel(e){if(h.currentDialog){let t=h.currentDialog.querySelector(`#${h.NOTIFICATION_CSS_CLASS}_info`);t||((t=document.createElement("div")).insertAdjacentHTML("afterbegin",`<p class="${h.NOTIFICATION_CSS_CLASS}_info"></p>`),h.setContent(t,!0));const i=c().stage.querySelector("iframe");t.style.maxHeight=Math.round(2*i.clientHeight/3)+"px",h.currentDialog.insertBefore(t,h.currentDialog.childNodes[h.currentDialog.childNodes.length-1]),t.innerHTML="",t.appendChild(e)}}static getMarkup(e){return`\n <section class="${h.NOTIFICATION_CSS_CLASS}">\n <h2>${e.title}</h2>\n <p class="${h.NOTIFICATION_CSS_CLASS}_content">\n ${e.content}\n ${void 0!==e.defaultValue?`\n <input\n id="${h.NOTIFICATION_CSS_CLASS}_value"\n ${e.placeholder?`placeholder="${e.placeholder}"`:""}\n class="block-dialog" type="text" value="${e.defaultValue}"\n >`:""}\n </p>\n <div class="${h.NOTIFICATION_CSS_CLASS}_buttons">\n ${e.labelCancel?`<input id="${h.NOTIFICATION_CSS_CLASS}_cancel" type="button" value="${e.labelCancel}">`:""}\n ${e.labelOk?`<input id="${h.NOTIFICATION_CSS_CLASS}_ok" type="button" value="${e.labelOk}">`:""}\n </div>\n </section>\n `}static create(e){const t=document.querySelector(".alerts");t.insertAdjacentHTML("afterbegin",e),t.classList.remove("closed");const i=h.currentDialog.querySelector(`#${h.NOTIFICATION_CSS_CLASS}_value`);i&&i.focus()}}h.NOTIFICATION_DURATION_MS=3e4,h.NOTIFICATION_CSS_CLASS="notification-dialog";class d{constructor(){this.ce=null}static getInstance(){return d.instance=d.instance||new d,d.instance}ready(e){const t=c();t.fileExplorer.contentWindow.ce?(this.ce=t.fileExplorer.contentWindow.ce,e()):(null==this.cbks&&(this.cbks=[],t.fileExplorer.addEventListener("load",e=>{this.ce=t.fileExplorer.contentWindow.ce,this.cbks.forEach(e=>e()),this.cbks=[]})),this.cbks.push(e))}write(e,t,i,s,o){const n=new XMLHttpRequest;n.onload=()=>{if(200===n.status)s();else{const e=new Event("error"),t=this.getErrorMessage(n);o&&o(e,t)}};const r=`/website/ce/${e.service}/put/${e.path}`;n.open("PUT",r),n.setRequestHeader("Content-Type","text/plain; charset=utf-8"),n.send(JSON.stringify({html:t,userHead:i}))}read(e,t,i){this.loadLocal(e.absPath,t,i)}getErrorMessage(e){let t="";try{const i=JSON.parse(e.responseText);i.message&&(t=i.message)}catch(e){}if(""===t)if(""!==e.responseText)t=e.responseText;else switch(e.status){case 404:t="File not found.";break;case 401:t="You are not connected to the cloud service you are trying to use.";break;default:t="Unknown error with HTTP status "+e.status}return""===t?null:t}loadLocal(e,t,i){const s="/website"+e,o=new XMLHttpRequest;o.addEventListener("load",e=>{if(200===o.status){const e=JSON.parse(o.responseText);e.message&&h.alert("Open a website",e.message,()=>{}),t(e.html,e.userHead)}else{const e=new Event("error"),t=this.getErrorMessage(o);i(e,t)}}),o.addEventListener("error",t=>{console.error("could not load website",e,"from",s,t),i&&i(t,"Network error, please check your internet connection or try again later.")}),o.open("GET",s),o.send()}getServices(e,t){this.ce.getServices().then(t=>{e(t)}).catch(i=>{console.error("Error: could not get the list of services",i),t?t(i,"Error: could not get the list of services"):e([])})}}class u{constructor(e,t){this.model=e,this.view=t,u.focusInput.style.left="-1000px",u.focusInput.style.position="absolute",document.body.appendChild(u.focusInput)}static resetFocus(){setTimeout(()=>{u.focusInput.focus(),u.focusInput.blur(),document.getSelection().removeAllRanges()},0)}getBodyElement(){return this.model.file.getContentDocument().body}getSelection(){const e=this.view.stageWrapper.getSelection().map(e=>e.el);if(!e||0===e.length){const e=this.getBodyElement();return e?[e]:(console.warn("Could not get body element because it is not created yet."),[])}const t=[];return e.forEach(e=>{t.push(e)}),t}emptySelection(){this.setSelection([])}setSelection(e){0===e.length&&(e=[this.getBodyElement()]);const t=this.view.stageWrapper.getSelection().map(e=>e.el);0===t.filter(t=>!e.find(e=>e===t)).length&&0===e.filter(e=>!t.find(t=>t===e)).length||this.view.stageWrapper.setSelection(e),this.refreshViews(e)}refreshViews(e=this.getSelection()){const t=this.model.page.getPages(),i=this.model.page.getCurrentPage();this.view.pageTool.redraw(e,t,i),this.view.propertyTool.redraw(this.view.stageWrapper.getSelection(),t,i),this.view.textFormatBar.redraw(e,t,i),this.view.contextMenu.redraw(e,t,i),this.view.breadCrumbs.redraw(e,t,i),this.view.htmlEditor.setSelection(e)}removeWysihtmlMarkup(e){Array.from(e.querySelectorAll(".wysihtml-editor")).forEach(e=>{e.classList.remove("wysihtml-sandbox","wysihtml-editor"),e.removeAttribute("contenteditable")})}}u.focusInput=document.createElement("input");class p{constructor(e){if(this.isOpen=!1,e.name&&(this.name=e.name,p.dialogs.set(this.name,this)),!e.element)throw new Error('Modal dialog options missing a "element" field');if(this.element=e.element,!e.onOpen)throw new Error('Modal dialog options missing a "onOpen" field');if(this.onOpen=e.onOpen,!e.onClose)throw new Error('Modal dialog options missing a "onClose" field');this.onClose=e.onClose,this.element.classList.add(p.MODAL_DIALOG_CLASS_NAME),this.element.classList.add(p.HIDE_DIALOG_CLASS_NAME);const t=this.element.querySelector(".close-btn");t&&(t.onclick=e=>this.close()),document.addEventListener("keydown",e=>{this.isOpen&&"Escape"===e.key&&(this.close(),e.preventDefault(),e.stopPropagation())})}static open(e,t=null){p.dialogs.has(e)?p.dialogs.get(e).open(t):console.error("could not open dialog",e,p.dialogs)}static close(){p.currentDialog?p.currentDialog.close():console.error("could not close dialog, there is no dialog opened")}open(e){this.isOpen?console.warn("this dialog is already opened",this.name?this.name:""):(this.isOpen=!0,p.currentDialog&&p.currentDialog.close(),p.currentDialog=this,this.element.classList.remove(p.HIDE_DIALOG_CLASS_NAME),this.onOpen(e))}close(){this.isOpen?(this.isOpen=!1,p.currentDialog=null,this.onClose(),u.resetFocus(),this.element.classList.add(p.HIDE_DIALOG_CLASS_NAME)):console.warn("dialog is already closed",this.name?this.name:"")}}p.dialogs=new Map,p.HIDE_DIALOG_CLASS_NAME="silex-hide-dialog",p.MODAL_DIALOG_CLASS_NAME="silex-modal-dialog";class m{constructor(e,t,i){this.element=e,this.model=t,this.controller=i,this.ce=null,d.getInstance().ready(()=>{this.ce=d.getInstance().ce}),this.modalDialog=new p({name:"File explorer",element:e,onOpen:e=>{},onClose:()=>{}})}static get IMAGE_EXTENSIONS(){return[".jpg",".jpeg",".png",".gif",".svg"]}static get HTML_EXTENSIONS(){return[".html",".htm"]}addAbsPath(e){return null===e?e:Object.assign({absPath:`/ce/${e.service}/get/${e.path}`},e)}openFile(e){return this.open(),this.ce.openFile(e).then(e=>this.addAbsPath(e)).then(e=>(this.close(),e))}openFiles(e){return this.open(),this.ce.openFiles(e).then(e=>this.addAbsPath(e)).then(e=>(this.close(),e))}openFolder(){return this.open(),this.ce.openFolder().then(e=>this.addAbsPath(e)).then(e=>(this.close(),e))}saveAs(e,t){return this.open(),this.ce.saveAs(e,t).then(e=>this.addAbsPath(e)).then(e=>(this.close(),e))}open(){this.modalDialog.open()}close(){this.modalDialog.close()}}const g=["href","rel","target","type","title","download"],b={href:"",target:"",title:"",rel:"",type:"",download:""};class y{constructor(e){this.model=e}open(e,t,i){const s=Object.assign({},b,e),o=!s.href.startsWith("#!");h.prompt('\n Link editor <a class="link-editor-help-button fa fa-question-circle" target="_blank" href="https://github.com/silexlabs/Silex/wiki/Editor-UI#link-editor"> Help</a>\n ',"unused","unused","unused",(e,t)=>{if(e){const e=g.reduce((e,t)=>{const i=r.querySelector("."+t);return i?e[t]=i.value:console.error("could not get data from for attribute",t),e},{}),t=r.querySelector("#link-editor-external").checked,s=r.querySelector(".page").value,o={href:t?e.href:s};""!==e.target&&(o.target=e.target),""!==e.rel&&(o.rel=e.rel),""!==e.title&&(o.title=e.title),""!==e.type&&(o.type=e.type),""!==e.download&&(o.download=e.download),i(o)}});const n=document.createElement("fragment");n.innerHTML='\n <button class="alertify-button alertify-button-cancel alertify-button-remove">remove link</button>\n ',n.querySelector(".alertify-button-remove").onclick=e=>{h.close(),i(null)},h.addButton(n);const r=document.createElement("div");r.insertAdjacentHTML("afterbegin",this.getDialogHtml({isExternal:o,linkData:s,pageNames:t})),Array.from(r.querySelectorAll(".link-editor-tab-label")).forEach(e=>{e.onclick=t=>{Array.from(r.querySelectorAll(".link-editor-tab-label.checked")).forEach(e=>e.classList.remove("checked")),e.classList.add("checked")}}),h.setContent(r)}getDialogHtml({isExternal:e,linkData:t,pageNames:i}){return`\n <section class="link-editor">\n <div class="labels">\n <label for="link-editor-external" title="External Link" class="link-editor-tab-label first-button fa fa-lg fa-link${e?" checked ":""}"></label>\n <label for="link-editor-internal" title="Link to a page" class="link-editor-tab-label last-button fa fa-lg fa-file"${e?"":" checked "}></label>\n <div class="space"></div>\n </div>\n <div class="link-editor-body">\n <input autocomplete="nope" id="link-editor-external" class="link-editor-radio" type="radio" name="link-editor-tab-group"${e?" checked ":""}/>\n <div class="link-editor-tab link-editor-tab-external">\n <div class="link-editor-tab-container">\n <label for="link-editor-href">External link</label>\n <div class="flex">\n <input autocomplete="nope" spellcheck="false" id="link-editor-href" class="big alertify-text href tabbed" type="url" value="${e?t.href:""}">\n <select autocomplete="nope" id="link-editor-target" class="alertify-text target">\n <option${""===t.target?" selected ":""} value=""></option>\n <option${"_self"===t.target?" selected ":""} value="_self">_self</option>\n <option${"_blank"===t.target?" selected ":""} value="_blank">_blank</option>\n <option${"_parent"===t.target?" selected ":""} value="_parent">_parent</option>\n <option${"_top"===t.target?" selected ":""} value="_top">_top</option>\n </select>\n </div>\n </div>\n </div>\n <input autocomplete="nope" id="link-editor-internal" class="link-editor-radio" type="radio" name="link-editor-tab-group"${e?"":" checked "}/>\n <div class="link-editor-tab link-editor-tab-internal">\n <div class="link-editor-tab-container">\n <label for="link-editor-page">Page</label>\n <select autocomplete="nope" class="tabbed alertify-text page big" id="link-editor-page">\n <option value=""${e?" selected ":""}></option>\n ${i.map(i=>`<option value="#!${i}"${e||"#!"+i!==t.href?"":" selected "} >\n ${this.model.page.getDisplayName(i)}\n </option>`)}\n </select>\n </div>\n </div>\n <div class="link-editor-tab-container">\n <div class="link-editor-2col">\n <label for="link-editor-title">Title</label>\n <input autocomplete="nope" id="link-editor-title" class="alertify-text title big" type="text" value="${t.title}">\n </div>\n </div>\n <hr>\n <div class="link-editor-advanced-container">\n <input autocomplete="nope" id="link-editor-show-advanced" type="checkbox">\n <label for="link-editor-show-advanced">Advanced params</label>\n <div class="link-editor-advanced">\n <label for="link-editor-rel">The "rel" attribute. Describes the relationship between the current document and the destination.</label>\n <input autocomplete="nope" id="link-editor-rel" class="alertify-text rel" type="text" value="${t.rel}">\n <label for="link-editor-type">The "type" attribute. Specifies the MIME type of the linked resource.</label>\n <input autocomplete="nope" id="link-editor-type" class="alertify-text type" type="text" value="${t.type}">\n <label for="link-editor-download">The "download" attribute. Indicates that the link is to be used for downloading a resource (such as a file). The author can specify a default file name by providing a value.</label>\n <input autocomplete="nope" id="link-editor-download" class="alertify-text download" type="text" value="${t.download}">\n </div>\n </div>\n </div>\n </section>\n `}}var E=function(e,t,i,s){return new(i||(i=Promise))(function(o,n){function r(e){try{a(s.next(e))}catch(e){n(e)}}function l(e){try{a(s.throw(e))}catch(e){n(e)}}function a(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,l)}a((s=s.apply(e,t||[])).next())})};class S{constructor(e,t){this.model=e,this.view=t,this.undoReset(),this.tracker=r.getInstance(),window.onerror=(e,t,i,s,o)=>this.tracker.trackOnError(e,t,i),this.undoCheckpointInvalidationManager=new l(1e3),this.linkDialog=new y(this.model)}track(e,t){this.tracker.trackAction("controller-events","request",t,0),e.then(e=>(this.tracker.trackAction("controller-events","success",t,1),e)).catch(e=>{throw this.tracker.trackAction("controller-events","error",t,-1),e})}isDirty(){return S.lastSaveUndoIdx!==S.undoHistory.length-1}hasRedo(){return S.redoHistory.length>0}hasUndo(){return S.undoHistory.length>0}undoredo(e){e.then(e=>(e&&this.undoCheckPoint(),e))}undoCheckPoint(){this.undoCheckpointInvalidationManager.callWhenReady(()=>{S.redoHistory=[],S.getStatePending++,this.getStateAsync(e=>{S.getStatePending--,0===S.undoHistory.length||S.undoHistory[S.undoHistory.length-1].html!==e.html||S.undoHistory[S.undoHistory.length-1].page!==e.page?(S.undoHistory.push(e),this.view.menu.redraw()):console.warn("Did not store undo state, because nothing has changed")})})}getStateAsync(e){const t=this.view.stageWrapper.getScroll();this.model.file.getHtmlAsync(i=>{e({html:i,page:this.model.page.getCurrentPage(),scrollX:t.x,scrollY:t.y})})}getState(){const e=this.view.stageWrapper.getScroll();return{html:this.model.file.getHtml(),page:this.model.page.getCurrentPage(),scrollX:e.x,scrollY:e.y}}restoreState(e){this.model.file.setHtml(e.html,()=>{this.model.page.setCurrentPage(e.page),this.view.stageWrapper.setScroll({x:e.scrollX,y:e.scrollY})},!1)}undoReset(){S.undoHistory=[],S.redoHistory=[],S.lastSaveUndoIdx=-1}browseBgImage(){return E(this,void 0,void 0,function*(){this.tracker.trackAction("controller-events","request","selectBgImage",0);try{const e=yield this.view.fileExplorer.openFile(m.IMAGE_EXTENSIONS);if(e){const t=this.model.body.getSelection()[0];this.undoCheckPoint(),this.model.element.setBgImage(t,e.absPath),this.tracker.trackAction("controller-events","success","selectBgImage",1)}}catch(e){h.notifyError(`Error: I could not load the image. \n${e.message||""}`),this.tracker.trackAction("controller-events","error","selectBgImage",-1)}})}browseAndAddImage(){this.tracker.trackAction("controller-events","request","insert.image",0),this.view.fileExplorer.openFile(m.IMAGE_EXTENSIONS).then(e=>{if(e){this.undoCheckPoint();const t=this.addElement(n.TYPE_IMAGE);this.model.element.setImageUrl(t,e.absPath,(e,t)=>{this.tracker.trackAction("controller-events","success","insert.image",1)},(e,t)=>{h.notifyError("Error: I did not manage to load the image. \n"+t),this.model.element.removeElement(e),this.tracker.trackAction("controller-events","error","insert.image",-1)})}}).catch(e=>{h.notifyError("Error: I did not manage to load the image. \n"+(e.message||"")),this.tracker.trackAction("controller-events","error","insert.image",-1)}),this.view.workspace.redraw(this.view)}styleChanged(e,t,i,s){i||(i=this.model.body.getSelection()),!1!==s&&this.undoCheckPoint(),i.forEach(i=>{if(["top","left","width","height","min-height"].indexOf(e)>=0){const s=this.view.stageWrapper.getState(i);this.view.stageWrapper.setState(i,Object.assign({},s,{metrics:Object.assign({},s.metrics,{computedStyleRect:Object.assign({},s.metrics.computedStyleRect,{top:"top"===e?parseInt(t):s.metrics.computedStyleRect.top,left:"left"===e?parseInt(t):s.metrics.computedStyleRect.left,width:"width"===e?parseInt(t):s.metrics.computedStyleRect.width,height:"height"===e||"min-height"===e?parseInt(t):s.metrics.computedStyleRect.height})})}))}else this.model.element.setStyle(i,e,t)}),this.refreshView()}multipleStylesChanged(e,t){t||(t=this.model.body.getSelection()),this.undoCheckPoint(),t.forEach(t=>{this.model.property.setStyle(t,e)}),this.refreshView()}propertyChanged(e,t,i,s){i||(i=this.model.body.getSelection()),this.undoCheckPoint(),i.forEach(i=>{this.model.element.setProperty(i,e,t,s)}),this.refreshView()}setClassName(e){this.undoCheckPoint(),this.model.body.getSelection().forEach(t=>{this.model.element.setClassName(t,e),this.view.breadCrumbs.redraw()}),this.refreshView()}getUserInputPageName(e,t){h.prompt("Page name","Enter a name for your page!",e,"Your page name",(e,i)=>{if(e&&i&&i.length>0){const e=i;i="page-"+(i=i.replace(/\W+/g,"-").toLowerCase());const s=this.model.page.getPages();let o=!1;s.forEach(e=>{e===i&&(o=!0)}),o?this.openPage(i):t(i,e)}t()})}openPage(e){this.undoCheckPoint(),this.model.page.setCurrentPage(e)}addElement(e,t){this.tracker.trackAction("controller-events","request","insert."+e,0),this.undoCheckPoint();const i=this.model.element.createElement(e);return t&&this.model.component.initComponent(i,t),this.model.element.initElement(i),this.doAddElement(i),this.tracker.trackAction("controller-events","success","insert."+e,1),i}doAddElement(e){const t=this.model.page.getCurrentPage();this.model.page.removeFromAllPages(e),this.model.page.addToPage(e,t),this.checkElementVisibility(e),this.model.body.setSelection([e])}checkElementVisibility(e){if(null!=this.model.page.getParentPage(e)){this.model.page.getPagesForElement(e).forEach(t=>this.model.page.removeFromPage(e,t))}}setTitle(e){this.undoCheckPoint(),this.model.head.setTitle(e)}setLang(e){this.undoCheckPoint(),this.model.head.setLang(e)}toggleAdvanced(){document.body.classList.contains("advanced-mode-on")?(document.body.classList.remove("advanced-mode-on"),document.body.classList.add("advanced-mode-off")):(document.body.classList.add("advanced-mode-on"),document.body.classList.remove("advanced-mode-off"))}emptySelection(){this.model.body.emptySelection()}refreshView(){const e=this.model.page.getPages(),t=this.model.page.getCurrentPage();this.view.propertyTool.redraw(this.view.stageWrapper.getSelection(),e,t),this.view.textFormatBar.redraw(this.model.body.getSelection(),e,t),this.view.stageWrapper.redraw()}getMobileMode(){return this.view.workspace.getMobileEditor()}setMobileMode(e){this.view.workspace.setMobileEditor(e),this.refreshView()}toggleMobileMode(){this.view.workspace.setMobileEditor(!this.view.workspace.getMobileEditor()),this.refreshView()}save(e,t,i){this.tracker.trackAction("controller-events","request","file.save",0),e&&!this.model.file.isTemplate?this.doSave(e,t,i):this.view.fileExplorer.saveAs("editable.html",m.HTML_EXTENSIONS).then(e=>{null!=e&&this.doSave(e,t,i)}).catch(e=>{this.tracker.trackAction("controller-events","error","file.save",-1),i&&i(e)})}doSave(e,t,i){this.model.file.fileInfo=e;let s=this.model.file.getHtml();s.indexOf("url('"")>-1&&(console.warn("I have found HTML entities in some urls, there us probably an error in the save process."),this.tracker.trackAction("controller-events","warning","file.save.corrupted",-1),s=s.replace(/url\('"()(.+?)\1"'\)/gi,(e,t,i)=>"url('"+i+"')")),this.model.file.saveAs(e,s,()=>{this.tracker.trackAction("controller-events","success","file.save",1),S.lastSaveUndoIdx=S.undoHistory.length-1,this.fileOperationSuccess("File is saved.",!1),this.view.workspace.setPreviewWindowLocation(),t&&t()},(e,t)=>{h.alert("Save website","Error: I did not manage to save the file. \n"+(t||e.message||""),()=>{i&&i(e)}),this.tracker.trackAction("controller-events","error","file.save",-1)})}fileOperationSuccess(e,t){t&&(this.view.jsEditor.close(),this.view.cssEditor.close(),this.view.htmlEditor.close(),this.view.settingsDialog.redraw(),this.view.contextMenu.redraw(),this.view.breadCrumbs.redraw()),e&&h.notifySuccess(e)}}S.lastSaveUndoIdx=-1,S.undoHistory=[],S.redoHistory=[],S.clipboard=null,S.getStatePending=0;class f extends S{constructor(e,t){super(e,t)}hasElementsToPaste(){return!!S.clipboard&&S.clipboard.length>0}}class C extends S{constructor(e,t){super(e,t)}changed(e){this.model.head.setHeadStyle(e)}}class v{constructor(){throw new Error("this is a static class and it canot be instanciated")}static refreshImage(e,t){const i=e.src;e.onload=i=>{e.onload=null,t()},e.src=v.addCacheControl(i)}static addCacheControl(e){return(e=v.removeCacheControl(e)).indexOf("?")>0?e+="&":e+="?",e+=v.CACHE_CONTROL_PARAM_NAME+"="+Date.now()}static removeCacheControl(e){if(e.indexOf(v.CACHE_CONTROL_PARAM_NAME)>0){const t=new RegExp("([?|&|&]"+v.CACHE_CONTROL_PARAM_NAME+"=[0-9]*[&*]?)","gi");e=e.replace(t,(e,t,i)=>"?"===t.charAt(0)&&"&"===t.charAt(t.length-1)?"?":"&"===t.charAt(t.length-1)||"&"===t.charAt(0)?"&":"")}return e}static deactivateScripts(e){return e.replace(/<script.*class="silex-script".*?>/gi,'<script type="text/notjavascript" class="silex-script">')}static reactivateScripts(e){return e.replace(/type="text\/notjavascript"/gi,'type="text/javascript"')}static renderList(e,t){let i="";return t.forEach(t=>{let s=e;for(const e in t){const i=t[e];s=s.replace(new RegExp("{{"+e+"}}","g"),i)}i+=s}),i}}v.CACHE_CONTROL_PARAM_NAME="silex-cache-control";class w{static styleToObject(e){const t={};for(const i of e)t[i]=e[i];return t}static styleToString(e,t){if("string"==typeof e)return e;t||(t="");let i="";for(const s in e)e[s]&&"string"==typeof e[s]&&""!==e[s]&&s.match(/[^0-9]/)&&(i+=t+s+": "+e[s]+"; ");return i}static hexToRgb(e){console.warn("why convert",e,"to RGB?");const t=parseInt(e.substr(1),16);return[t>>16,t>>8&255,255&t]}static hexToRgba(e){if(0!==e.indexOf("#"))return e;if(9!==e.length)return console.error("Error in length "+e+" - "+e.length),e;const t=w.hexToArray(e);return"rgba("+t[0]+","+t[1]+","+t[2]+","+t[3]+")"}static hexToArray(e){if(0!==e.indexOf("#"))return null;return e=e.replace("#",""),[parseInt(e.substring(0,2),16),parseInt(e.substring(2,4),16),parseInt(e.substring(4,6),16),parseInt(e.substring(6,8),16)/255]}static rgbToHex(e){return w.rgbaToHex(e).substr(0,7)}static rgbaToHex(e){if(0!==e.indexOf("rgb"))return e;const t=w.rgbaToArray(e);let i=t[0].toString(16);i.length<2&&(i="0"+i);let s=t[1].toString(16);s.length<2&&(s="0"+s);let o=t[2].toString(16);o.length<2&&(o="0"+o);let n=t[3].toString(16);return n.length<2&&(n="0"+n),"#"+(i+s+o+n)}static rgbaToArray(e){if(0!==e.indexOf("rgb"))return null;const t=(e=(e=0!==e.indexOf("rgba")?e.replace("rgb",""):e.replace("rgba","")).replace(" ","")).substring(1,e.length-1).split(",");return t.length<4&&t.push("1"),[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),255*parseFloat(t[3])]}}class T{static updateFileInfo(e,t){if(!e)return null;const i=Object.assign({},e,t);return Object.assign({},i,{url:T.getBaseUrl()+i.service+"/get/"+i.path})}static getBaseUrl(){return window.location.href}static getRootUrl(e){const t=e||window.location.href,i=t.indexOf("//"),s=t.indexOf("/",i+2);return t.substr(0,s)}static getHost(e){const t=T.getRootUrl(e);return t.substr(t.indexOf("//")+2)}static isAbsoluteUrl(e){return 0===e.indexOf("http")||0===e.indexOf("//")}static removeUrlKeyword(e){return e.startsWith("url(")&&(e=e.substr(4)),e.endsWith(")")&&(e=e.substr(0,e.length-1)),(e.startsWith("'")||e.startsWith('"'))&&(e=e.substr(1)),(e.endsWith("'")||e.endsWith('"'))&&(e=e.substr(0,e.length-1)),e.startsWith(""")&&(e=e.substr(6)),e.endsWith(""")&&(e=e.substr(0,e.length-6)),e.startsWith("%5C")&&(e=e.substr(3)),e.startsWith("%22")&&(e=e.substr(3)),e.endsWith("%22")&&(e=e.substr(0,e.length-3)),e.endsWith("%5C")&&(e=e.substr(0,e.length-3)),e}static addUrlKeyword(e){return`url('${e}')`}}var _,A=function(e,t,i,s){return new(i||(i=Promise))(function(o,n){function r(e){try{a(s.next(e))}catch(e){n(e)}}function l(e){try{a(s.throw(e))}catch(e){n(e)}}function a(e){e.done?o(e.value):new i(function(t){t(e.value)}).then(r,l)}a((s=s.apply(e,t||[])).next())})};class L{}L.UP="UP",L.DOWN="DOWN",L.TOP="TOP",L.BOTTOM="BOTTOM";class k{constructor(e,t){this.model=e,this.view=t}static loadImage(e){return A(this,void 0,void 0,function*(){return new Promise((t,i)=>{const s=new Image;s.onload=e=>{s.onload=null,s.onerror=null,t(s)},s.onerror=e=>{s.onload=null,s.onerror=null,i(e)},s.src=e})})}getTabs(e){let t="";for(let i=0;i<e;i++)t+=" ";return t}noSectionContent(e){return this.isSectionContent(e)?e.parentElement:e}getType(e){return e.getAttribute(n.TYPE_ATTR)}isElementContent(e){return e.classList.contains(n.ELEMENT_CONTENT_CLASS_NAME)}isSection(e){return!(!e||!e.classList)&&e.classList.contains(n.TYPE_SECTION)}isSectionContent(e){return!(!e||!e.classList)&&e.classList.contains(n.TYPE_CONTAINER_CONTENT)}getHideOnMobile(e){return!(!e||!e.classList)&&this.noSectionContent(e).classList.contains(n.HIDE_ON_MOBILE)}setHideOnMobile(e,t){t?this.noSectionContent(e).classList.add(n.HIDE_ON_MOBILE):this.noSectionContent(e).classList.remove(n.HIDE_ON_MOBILE)}getHideOnDesktop(e){return!(!e||!e.classList)&&this.noSectionContent(e).classList.contains(n.HIDE_ON_DESKTOP)}setHideOnDesktop(e,t){t?this.noSectionContent(e).classList.add(n.HIDE_ON_DESKTOP):this.noSectionContent(e).classList.remove(n.HIDE_ON_DESKTOP)}getAllStyles(e){const t=this.model.property.getStyle(e);return w.styleToString(t)}getStyle(e,t){const i=this.view.workspace.getMobileEditor();let s=this.model.property.getStyle(e,i);return s&&s[t]?s[t]:i&&(s=this.model.property.getStyle(e,!1))&&s[t]?s[t]:null}setStyle(e,t,i,s){let o=this.model.property.getStyle(e);o||(o={}),o[t]!==i&&(o[t]=null!=i?i:"",this.model.property.setStyle(e,o))}setProperty(e,t,i,s){s&&(e=this.getContentNode(e)),null!=i?e.setAttribute(t,i):e.removeAttribute(t)}setBgImage(e,t){t?this.setStyle(e,"background-image",T.addUrlKeyword(t)):this.setStyle(e,"background-image"),this.model.body.refreshViews()}getInnerHtml(e){let t=this.getContentNode(e).innerHTML;return t=v.reactivateScripts(t)}setInnerHtml(e,t){const i=this.getContentNode(e);t=v.deactivateScripts(t),i.innerHTML=t}getContentNode(e){const t=e.querySelector(":scope > ."+n.ELEMENT_CONTENT_CLASS_NAME);return!t&&[n.TYPE_IMAGE,n.TYPE_HTML,n.TYPE_SECTION].indexOf(this.getType(e))>-1&&console.warn("This element is supposed to have a content container",e),t||e}move(e,t){switch(e=this.noSectionContent(e),t){case L.UP:const i=this.getNextElement(e,!0);i&&e.parentElement.insertBefore(i,e);break;case L.DOWN:const s=this.getNextElement(e,!1);s&&e.parentElement.insertBefore(s,e.nextSibling);break;case L.TOP:e.parentElement.appendChild(e);break;case L.BOTTOM:e.parentElement.insertBefore(e,e.parentElement.childNodes[0])}this.view.stageWrapper.redraw()}getNextElement(e,t){let i=e;for(;i=t?i.nextSibling:i.previousSibling;)if(1===i.nodeType){const e=i;if(null!=this.getType(e)&&(this.model.page.isInPage(e)||0===this.model.page.getPagesForElement(e).length))return e}return null}getImageUrl(e){let t="";if(e.getAttribute(n.TYPE_ATTR)===n.TYPE_IMAGE){const i=this.getContentNode(e);i?t=i.getAttribute("src"):console.error("The image could not be retrieved from the element.",e)}else console.error("The element is not an image.",e);return t}setImageUrl(e,t,i,s){return A(this,void 0,void 0,function*(){if(e.getAttribute(n.TYPE_ATTR)===n.TYPE_IMAGE){if(this.getContentNode(e)){e.classList.add(n.LOADING_ELEMENT_CSS_CLASS),Array.from(e.querySelectorAll("img."+n.ELEMENT_CONTENT_CLASS_NAME)).forEach(e=>{e.parentElement.removeChild(e)});try{const o=yield k.loadImage(t);this.setStyle(e,"width",o.naturalWidth+"px",!0),this.setStyle(e,this.getHeightStyleName(e),o.naturalHeight+"px",!0),i&&i(e,o),e.appendChild(o),o.classList.add(n.ELEMENT_CONTENT_CLASS_NAME),e.classList.remove(n.LOADING_ELEMENT_CSS_CLASS),this.model.body.refreshViews(),this.view.stageWrapper.redraw()}catch(t){console.error("An error occured while loading the image.",e,t),s&&s(e,"An error occured while loading the image.")}}else console.error("The image could not be retrieved from the element.",e),s&&s(e,"The image could not be retrieved from the element.")}else console.error("The element is not an image.",e),s&&s(e,"The element is not an image.")})}removeElement(e){e=this.noSectionContent(e),Array.from(e.querySelectorAll(`.${n.EDITABLE_CLASS_NAME}`)).concat([e]).forEach(e=>{this.model.body.getBodyElement()!==e&&e.parentElement&&(this.model.property.setElementComponentData(e),this.model.property.setStyle(e,null,!0),this.model.property.setStyle(e,null,!1),e.parentElement.removeChild(e),this.view.stageWrapper.removeElement(e))}),this.view.stageWrapper.redraw()}addElement(e,t,i=0){if(this.isSection(t)&&e!==this.model.body.getBodyElement())throw new Error("Cannot add a section to other than the body");if(i>0){const e=this.model.property.getStyle(t,!1);e.left=par