@silexlabs/silex
Version:
Free and easy website builder for everyone.
75 lines • 1.6 MB
JavaScript
/*! For license information please see main.js.LICENSE.txt */
var silex;(()=>{var t={69:function(t){"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window&&window,t.exports=(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{default:()=>n});const n=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.on("load",(()=>{const n={placeholder:"Search...",appendTo:null,appendBefore:null,...e},o=t.Config.selectorManager.pStylePrefix,i=`${o}filter-styles`,s=document.createElement("div");s.innerHTML=`\n <style>\n #${i}-btn {\n position: absolute;\n right: 0;\n border: none;\n padding: 5px;\n margin: 5px;\n line-height: 1;\n border-radius: 50%;\n width: 25px;\n height: 25px;\n border: 1px solid;\n z-index: 1;\n display: flex;\n justify-content: center;\n align-items: center;\n transition: opacity .15s ease;\n cursor: pointer;\n opacity: .75;\n }\n .empty #${i}-btn {\n cursor: initial;\n opacity: .25;\n }\n </style>\n\n <button\n id="${i}-btn"\n class="gjs-field gjs-sm-properties gjs-two-color"\n >X</button>\n <input id="${i}" type="text" class="gjs-field gjs-sm-properties gjs-two-color" placeholder="${n.placeholder}" />\n `;const a=t.getContainer().querySelector(`.${o}clm-tags`),l="string"==typeof n.appendBefore?document.querySelector(n.appendBefore):n.appendBefore,u="string"==typeof n.appendTo?document.querySelector(n.appendTo):n.appendTo,p=l?l.parentElement:u??a.parentElement.parentElement;p.insertBefore(s,l??a.parentElement.parentElement.lastElementChild);const d=p.querySelector(`#${i}`);d.onkeyup=()=>c(t,d,p),p.querySelector(`#${i}-btn`).onclick=()=>{d.value="",c(t,d,p)},t.on("component:selected component:styleUpdate style:target",(()=>{r(t),setTimeout((()=>c(t,d,p)))}))}))};function r(t){l(t).forEach((t=>{!function(t){const e=o.get(t);e?.sector.setOpen(e?.initial),o.delete(t)}(t),t.getProperties().forEach((t=>{!function(t){const e=s.get(t);e?.property.set("visible",e?.initial),s.delete(t)}(t)}))}))}const o=new WeakMap;function i(t,e){o.has(t)||o.set(t,{sector:t,initial:t.isOpen()}),t.setOpen(e)}const s=new WeakMap;function a(t,e){s.has(t)||s.set(t,{property:t,initial:t.get("visible")}),t.set("visible",e)}function l(t){return t.StyleManager.getSectors().toArray().filter((t=>t.isVisible()))}function c(t,e,n){if(e.value){n.classList.remove("empty");const r=function(t){return l(t).flatMap((t=>t.getProperties().flatMap((e=>"composite"===e.getType()?e.properties.map((n=>({sector:t,property:e,subprop:n}))):{sector:t,property:e})))).map((t=>{let{sector:e,property:n,subprop:r}=t;return{searchable:`\n ${e.get("name")}\n ${n.get("name")}\n ${n.get("options")?.map((t=>t.id)).join(", ")??""}\n ${r?.get("name")??""}\n ${r?.get("options")?.map((t=>t.id)).join(", ")??""}\n `,sector:e,property:n}}))}(t).filter((t=>t.searchable.toLowerCase().includes(e.value.toLowerCase())));l(t).forEach((t=>{i(t,!1),t.getProperties().forEach((t=>a(t,!1)))})),r.forEach((t=>{i(t.sector,!0),a(t.property,!0)}))}else n.classList.add("empty"),r(t)}return e})()},190:function(t){var e;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window&&window,e=()=>(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{cmdGetCss:()=>Tt,cmdGetHtml:()=>At,cmdOpenFonts:()=>ut,default:()=>Pt,fontsDialogPlugin:()=>mt,getHtml:()=>Ot,refresh:()=>St});const n=globalThis,r=n.trustedTypes,o=r?r.createPolicy("lit-html",{createHTML:t=>t}):void 0,i="$lit$",s=`lit$${Math.random().toFixed(9).slice(2)}$`,a="?"+s,l=`<${a}>`,c=document,u=()=>c.createComment(""),p=t=>null===t||"object"!=typeof t&&"function"!=typeof t,d=Array.isArray,f=t=>d(t)||"function"==typeof t?.[Symbol.iterator],h="[ \t\n\f\r]",g=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,m=/>/g,y=RegExp(`>|${h}(?:([^\\s"'>=/]+)(${h}*=${h}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),b=/'/g,w=/"/g,_=/^(?:script|style|textarea|title)$/i,x=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),C=x(1),S=(x(2),x(3),Symbol.for("lit-noChange")),O=Symbol.for("lit-nothing"),T=new WeakMap,A=c.createTreeWalker(c,129);function E(t,e){if(!d(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==o?o.createHTML(e):e}const k=(t,e)=>{const n=t.length-1,r=[];let o,a=2===e?"<svg>":3===e?"<math>":"",c=g;for(let e=0;e<n;e++){const n=t[e];let u,p,d=-1,f=0;for(;f<n.length&&(c.lastIndex=f,p=c.exec(n),null!==p);)f=c.lastIndex,c===g?"!--"===p[1]?c=v:void 0!==p[1]?c=m:void 0!==p[2]?(_.test(p[2])&&(o=RegExp("</"+p[2],"g")),c=y):void 0!==p[3]&&(c=y):c===y?">"===p[0]?(c=o??g,d=-1):void 0===p[1]?d=-2:(d=c.lastIndex-p[2].length,u=p[1],c=void 0===p[3]?y:'"'===p[3]?w:b):c===w||c===b?c=y:c===v||c===m?c=g:(c=y,o=void 0);const h=c===y&&t[e+1].startsWith("/>")?" ":"";a+=c===g?n+l:d>=0?(r.push(u),n.slice(0,d)+i+n.slice(d)+s+h):n+s+(-2===d?e:h)}return[E(t,a+(t[n]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),r]};class P{constructor({strings:t,_$litType$:e},n){let o;this.parts=[];let l=0,c=0;const p=t.length-1,d=this.parts,[f,h]=k(t,e);if(this.el=P.createElement(f,n),A.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(o=A.nextNode())&&d.length<p;){if(1===o.nodeType){if(o.hasAttributes())for(const t of o.getAttributeNames())if(t.endsWith(i)){const e=h[c++],n=o.getAttribute(t).split(s),r=/([.?@])?(.*)/.exec(e);d.push({type:1,index:l,name:r[2],strings:n,ctor:"."===r[1]?D:"?"===r[1]?I:"@"===r[1]?L:N}),o.removeAttribute(t)}else t.startsWith(s)&&(d.push({type:6,index:l}),o.removeAttribute(t));if(_.test(o.tagName)){const t=o.textContent.split(s),e=t.length-1;if(e>0){o.textContent=r?r.emptyScript:"";for(let n=0;n<e;n++)o.append(t[n],u()),A.nextNode(),d.push({type:2,index:++l});o.append(t[e],u())}}}else if(8===o.nodeType)if(o.data===a)d.push({type:2,index:l});else{let t=-1;for(;-1!==(t=o.data.indexOf(s,t+1));)d.push({type:7,index:l}),t+=s.length-1}l++}}static createElement(t,e){const n=c.createElement("template");return n.innerHTML=t,n}}function j(t,e,n=t,r){if(e===S)return e;let o=void 0!==r?n._$Co?.[r]:n._$Cl;const i=p(e)?void 0:e._$litDirective$;return o?.constructor!==i&&(o?._$AO?.(!1),void 0===i?o=void 0:(o=new i(t),o._$AT(t,n,r)),void 0!==r?(n._$Co??=[])[r]=o:n._$Cl=o),void 0!==o&&(e=j(t,o._$AS(t,e.values),o,r)),e}class M{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:n}=this._$AD,r=(t?.creationScope??c).importNode(e,!0);A.currentNode=r;let o=A.nextNode(),i=0,s=0,a=n[0];for(;void 0!==a;){if(i===a.index){let e;2===a.type?e=new $(o,o.nextSibling,this,t):1===a.type?e=new a.ctor(o,a.name,a.strings,this,t):6===a.type&&(e=new R(o,this,t)),this._$AV.push(e),a=n[++s]}i!==a?.index&&(o=A.nextNode(),i++)}return A.currentNode=c,r}p(t){let e=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}class ${get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,n,r){this.type=2,this._$AH=O,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=j(this,t,e),p(t)?t===O||null==t||""===t?(this._$AH!==O&&this._$AR(),this._$AH=O):t!==this._$AH&&t!==S&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):f(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==O&&p(this._$AH)?this._$AA.nextSibling.data=t:this.T(c.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:n}=t,r="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=P.createElement(E(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(e);else{const t=new M(r,this),n=t.u(this.options);t.p(e),this.T(n),this._$AH=t}}_$AC(t){let e=T.get(t.strings);return void 0===e&&T.set(t.strings,e=new P(t)),e}k(t){d(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,r=0;for(const o of t)r===e.length?e.push(n=new $(this.O(u()),this.O(u()),this,this.options)):n=e[r],n._$AI(o),r++;r<e.length&&(this._$AR(n&&n._$AB.nextSibling,r),e.length=r)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class N{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,r,o){this.type=1,this._$AH=O,this._$AN=void 0,this.element=t,this.name=e,this._$AM=r,this.options=o,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=O}_$AI(t,e=this,n,r){const o=this.strings;let i=!1;if(void 0===o)t=j(this,t,e,0),i=!p(t)||t!==this._$AH&&t!==S,i&&(this._$AH=t);else{const r=t;let s,a;for(t=o[0],s=0;s<o.length-1;s++)a=j(this,r[n+s],e,s),a===S&&(a=this._$AH[s]),i||=!p(a)||a!==this._$AH[s],a===O?t=O:t!==O&&(t+=(a??"")+o[s+1]),this._$AH[s]=a}i&&!r&&this.j(t)}j(t){t===O?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class D extends N{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===O?void 0:t}}class I extends N{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==O)}}class L extends N{constructor(t,e,n,r,o){super(t,e,n,r,o),this.type=5}_$AI(t,e=this){if((t=j(this,t,e,0)??O)===S)return;const n=this._$AH,r=t===O&&n!==O||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,o=t!==O&&(n===O||r);r&&this.element.removeEventListener(this.name,this,n),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class R{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){j(this,t)}}const H={M:i,P:s,A:a,C:1,L:k,R:M,D:f,V:j,I:$,H:N,N:I,U:L,B:D,F:R},V=n.litHtmlPolyfillSupport;V?.(P,$),(n.litHtmlVersions??=[]).push("3.3.0");const F=t=>(...e)=>({_$litDirective$:t,values:e});class U{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,n){this._$Ct=t,this._$AM=e,this._$Ci=n}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}const{I:B}=H,z=t=>void 0===t.strings,W={},q=F(class extends U{constructor(t){if(super(t),3!==t.type&&1!==t.type&&4!==t.type)throw Error("The `live` directive is not allowed on child or event bindings");if(!z(t))throw Error("`live` bindings can only contain a single expression")}render(t){return t}update(t,[e]){if(e===S||e===O)return e;const n=t.element,r=t.name;if(3===t.type){if(e===n[r])return S}else if(4===t.type){if(!!e===n.hasAttribute(r))return S}else if(1===t.type&&n.getAttribute(r)===e+"")return S;return((t,e=W)=>{t._$AH=e})(t),e}});function*G(t,e){if(void 0!==t){let n=0;for(const r of t)yield e(r,n++)}}const K="important",Y=" !"+K,J=F(class extends U{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce(((e,n)=>{const r=t[n];return null==r?e:e+`${n=n.includes("-")?n:n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${r};`}),"")}update(t,[e]){const{style:n}=t.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(e)),this.render(e);for(const t of this.ft)null==e[t]&&(this.ft.delete(t),t.includes("-")?n.removeProperty(t):n[t]=null);for(const t in e){const r=e[t];if(null!=r){this.ft.add(t);const e="string"==typeof r&&r.endsWith(Y);t.includes("-")||e?n.setProperty(t,e?r.slice(0,-11):r,e?K:""):n[t]=r}}return S}}),X=(t,e)=>{const n=t._$AN;if(void 0===n)return!1;for(const t of n)t._$AO?.(e,!1),X(t,e);return!0},Z=t=>{let e,n;do{if(void 0===(e=t._$AM))break;n=e._$AN,n.delete(t),t=e}while(0===n?.size)},Q=t=>{for(let e;e=t._$AM;t=e){let n=e._$AN;if(void 0===n)e._$AN=n=new Set;else if(n.has(t))break;n.add(t),nt(e)}};function tt(t){void 0!==this._$AN?(Z(this),this._$AM=t,Q(this)):this._$AM=t}function et(t,e=!1,n=0){const r=this._$AH,o=this._$AN;if(void 0!==o&&0!==o.size)if(e)if(Array.isArray(r))for(let t=n;t<r.length;t++)X(r[t],!1),Z(r[t]);else null!=r&&(X(r,!1),Z(r));else X(this,t)}const nt=t=>{2==t.type&&(t._$AP??=et,t._$AQ??=tt)};class rt extends U{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,n){super._$AT(t,e,n),Q(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(X(this,t),Z(this))}setValue(t){if(z(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}const ot=()=>new it;class it{}const st=new WeakMap,at=F(class extends rt{render(t){return O}update(t,[e]){const n=e!==this.G;return n&&void 0!==this.G&&this.rt(void 0),(n||this.lt!==this.ct)&&(this.G=e,this.ht=t.options?.host,this.rt(this.ct=t.element)),O}rt(t){if(this.isConnected||(t=void 0),"function"==typeof this.G){const e=this.ht??globalThis;let n=st.get(e);void 0===n&&(n=new WeakMap,st.set(e,n)),void 0!==n.get(this.G)&&this.G.call(this.ht,void 0),n.set(this.G,t),void 0!==t&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){return"function"==typeof this.G?st.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),lt=document.createElement("div");let ct;const ut="open-fonts",pt="silex-loaded-fonts-list";let dt,ft,ht=[],gt="https://fonts.googleapis.com",vt="https://www.googleapis.com";try{dt=JSON.parse(localStorage.getItem(pt))}catch(i){console.error("Could not get fonts from local storage:",i)}const mt=(t,e)=>{if(ht=t.StyleManager.getBuiltIn("font-family").options,e.server_url&&(gt=e.server_url),e.api_url&&(vt=e.api_url),!e.api_key)throw new Error(t.I18n.t("grapesjs-fonts.You must provide Google font api key"));t.Commands.add(ut,{run:(n,r)=>(ct=t.Modal.open({title:t.I18n.t("grapesjs-fonts.Fonts"),content:"",attributes:{class:"fonts-dialog"}}).onceClose((()=>{t.stopCommand(ut)})),ct.setContent(lt),async function(t){ft=structuredClone(t.getModel().get("fonts")||[])}(t),wt(t,e,[]),async function(t){return dt=dt??(await(await fetch(t)).json())?.items,localStorage.setItem(pt,JSON.stringify(dt)),await async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((e=>setTimeout((()=>e()),t)))}(),dt}(`${vt}/webfonts/v1/webfonts?key=${e.api_key}`).then((n=>{wt(t,e,n);const r=lt.querySelector("form");r.onsubmit=n=>{n.preventDefault(),function(t,e){const n=t.getModel();n.set("fonts",ft),xt(t,ft),Ct(t,ft,e),n.set("changesCount",t.getDirtyCount()+1)}(t,e),t.stopCommand(ut)},r.querySelector("input")?.focus()})),ct),stop:()=>{ct.close()}}),t.on("storage:start:store",(e=>{e.fonts=t.getModel().get("fonts")})),t.on("storage:end:load",(n=>{const r=n.fonts||[];t.getModel().set("fonts",r),setTimeout((()=>St(t,e)),1e3)})),t.on("canvas:frame:load",(()=>St(t,e))),t.on("page",(()=>St(t,e)))},yt=ot(),bt=ot();function wt(t,e,n){const r=yt.value,o=n.filter((t=>function(t,e){const n=new RegExp(e,"i");return-1!==t.search(n)}(t.family,r?.value||"")));r?.focus(),((t,e)=>{const n=e;let r=n._$litPart$;if(void 0===r){const t=null;n._$litPart$=r=new $(e.insertBefore(u(),t),t,void 0,{})}r._$AI(t)})(C`
<form class="silex-form grapesjs-fonts">
<div class="silex-form__group">
<div class="silex-bar">
<input
style=${J({width:"100%"})}
placeholder="${t.I18n.t("grapesjs-fonts.Search")}"
type="text"
${at(yt)}
@keydown=${()=>{setTimeout((()=>wt(t,e,n)))}}/>
<select
style=${J({width:"150px"})}
${at(bt)}
>
${G(o,(t=>C`
<option value=${t.family}>${t.family}</option>
`))}
</select>
<button class="silex-button"
?disabled=${!bt.value||0===o.length}
type="button" @click=${()=>{!function(t,e,n,r){const o=r.family,i=`"${r.family}", ${r.category}`;n.push({name:o,value:i,variants:[]})}(0,0,ft,o[bt.value.selectedIndex]),wt(t,e,n)}}>
${t.I18n.t("grapesjs-fonts.Add font")}
</button>
</div>
</div>
<hr/>
<div
class="silex-form__element">
<h2>${t.I18n.t("grapesjs-fonts.Installed fonts")}</h2>
<ol class="silex-list">
${G(ft,(r=>{return C`
<li>
<div class="silex-list__item__header">
<h4>${r.name}</h4>
</div>
<div class="silex-list__item__body">
<fieldset class="silex-group--simple full-width">
<legend>CSS rules</legend>
<input
class="full-width"
type="text"
name="name"
.value=${q(r.value)}
@change=${o=>{var i,s;i=r,s=o.target.value,i.value=s,wt(t,e,n)}}
/>
</fieldset>
<fieldset class="silex-group--simple full-width">
<legend>Variants</legend>
${G((o=r,n.find((t=>o.name===t.family)))?.variants.filter((t=>""===t.replace(/[a-z]/g,""))),(o=>C`
<div>
<input
id=${r.name+o}
type="checkbox"
value=${o}
?checked=${r.variants?.includes(o)}
@change=${i=>{!function(t,e,n,r,o){const i=n.variants?.includes(r);i&&!o?n.variants=n.variants.filter((t=>t!==r)):!i&&o&&n.variants.push(r)}(0,0,r,o,i.target.checked),wt(t,e,n)}}
/><label for=${r.name+o}>${o}</label>
</div>
`))}
</fieldset>
</div>
<div class="silex-list__item__footer">
<button class="silex-button" type="button" @click=${()=>{!function(t,e,n){const r=e.findIndex((t=>t===n));e.splice(r,1)}(0,ft,r),wt(t,e,n)}}>${t.I18n.t("grapesjs-fonts.Remove")}</button>
</div>
</li>
`;var o}))}
</ol>
</div>
<footer>
<input class="silex-button" type="button" @click=${()=>t.stopCommand(ut)} value="${t.I18n.t("grapesjs-fonts.Cancel")}">
<input class="silex-button" type="submit" value="${t.I18n.t("grapesjs-fonts.Save")}">
</footer>
</form>
`,lt)}const _t="data-silex-gstatic";function xt(t,e){const n=t.Canvas.getDocument();if(!n)return;!function(t,e){const n=t.head.querySelectorAll(`[${e}]`);Array.from(n).forEach((t=>t.remove()))}(n,_t);const r=Ot(e,_t);n.head.insertAdjacentHTML("beforeend",r)}function Ct(t,e,n){const r=t.StyleManager.getProperty("typography","font-family");r&&(n.preserveDefaultFonts?e=ht.concat(e):0===e.length&&(e=ht),r.setOptions(e))}function St(t,e){const n=t.getModel().get("fonts")||[];xt(t,n),Ct(t,n,e)}function Ot(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const n=`<link href="${gt}" rel="preconnect" ${e}><link href="https://fonts.gstatic.com" rel="preconnect" crossorigin ${e}>`,r=t.map((t=>{const n=(t.variants.length?":":"")+t.variants.map((t=>t.replace(/\d+/g,""))).filter((t=>!!t)).join(",");return`<link href="${gt}/css?family=${t.name.replace(/ /g,"+")}${n}&display=swap" rel="stylesheet" ${e}>`})).join("");return n+r}const Tt="get-fonts-css",At="get-fonts-html",Et={"grapesjs-fonts":{Fonts:"Fonts","You must provide Google font api key":"You must provide Google font api key, see https://developers.google.com/fonts/docs/developer_api#APIKey",Search:"Search fonts...","Add font":"Install font",Remove:"Remove",Save:"Save",Cancel:"Cancel","Installed fonts":"Installed fonts"}},kt={"grapesjs-fonts":{Fonts:"Polices","You must provide Google font api key":"Vous devez fournir une clé API Google font, voir https://developers.google.com/fonts/docs/developer_api#APIKey",Family:"Famille",Search:"Rechercher une police","Add font":"Installer la police",Remove:"Supprimer",Save:"Enregistrer",Cancel:"Annuler","Installed fonts":"Polices installées"}},Pt=function(t){const e={i18n:{},preserveDefaultFonts:!0,...arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}};t.I18n&&t.I18n.addMessages({en:Et,fr:kt,...e.i18n}),function(t){t.Commands.add(Tt,(()=>{throw new Error("Not implemented")})),t.Commands.add(At,(t=>Ot(t.getModel().get("fonts")||[])))}(t),mt(t,e)};return e})(),t.exports=e()},175:function(t){var e;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window&&window,e=()=>(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{cmdKeymapsDialog:()=>Y,default:()=>X,defaultOptions:()=>J});const n=globalThis,r=n.trustedTypes,o=r?r.createPolicy("lit-html",{createHTML:t=>t}):void 0,i="$lit$",s=`lit$${Math.random().toFixed(9).slice(2)}$`,a="?"+s,l=`<${a}>`,c=document,u=()=>c.createComment(""),p=t=>null===t||"object"!=typeof t&&"function"!=typeof t,d=Array.isArray,f="[ \t\n\f\r]",h=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,g=/-->/g,v=/>/g,m=RegExp(`>|${f}(?:([^\\s"'>=/]+)(${f}*=${f}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),y=/'/g,b=/"/g,w=/^(?:script|style|textarea|title)$/i,_=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),x=_(1),C=(_(2),_(3),Symbol.for("lit-noChange")),S=Symbol.for("lit-nothing"),O=new WeakMap,T=c.createTreeWalker(c,129);function A(t,e){if(!d(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==o?o.createHTML(e):e}const E=(t,e)=>{const n=t.length-1,r=[];let o,a=2===e?"<svg>":3===e?"<math>":"",c=h;for(let e=0;e<n;e++){const n=t[e];let u,p,d=-1,f=0;for(;f<n.length&&(c.lastIndex=f,p=c.exec(n),null!==p);)f=c.lastIndex,c===h?"!--"===p[1]?c=g:void 0!==p[1]?c=v:void 0!==p[2]?(w.test(p[2])&&(o=RegExp("</"+p[2],"g")),c=m):void 0!==p[3]&&(c=m):c===m?">"===p[0]?(c=o??h,d=-1):void 0===p[1]?d=-2:(d=c.lastIndex-p[2].length,u=p[1],c=void 0===p[3]?m:'"'===p[3]?b:y):c===b||c===y?c=m:c===g||c===v?c=h:(c=m,o=void 0);const _=c===m&&t[e+1].startsWith("/>")?" ":"";a+=c===h?n+l:d>=0?(r.push(u),n.slice(0,d)+i+n.slice(d)+s+_):n+s+(-2===d?e:_)}return[A(t,a+(t[n]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),r]};class k{constructor({strings:t,_$litType$:e},n){let o;this.parts=[];let l=0,c=0;const p=t.length-1,d=this.parts,[f,h]=E(t,e);if(this.el=k.createElement(f,n),T.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(o=T.nextNode())&&d.length<p;){if(1===o.nodeType){if(o.hasAttributes())for(const t of o.getAttributeNames())if(t.endsWith(i)){const e=h[c++],n=o.getAttribute(t).split(s),r=/([.?@])?(.*)/.exec(e);d.push({type:1,index:l,name:r[2],strings:n,ctor:"."===r[1]?N:"?"===r[1]?D:"@"===r[1]?I:$}),o.removeAttribute(t)}else t.startsWith(s)&&(d.push({type:6,index:l}),o.removeAttribute(t));if(w.test(o.tagName)){const t=o.textContent.split(s),e=t.length-1;if(e>0){o.textContent=r?r.emptyScript:"";for(let n=0;n<e;n++)o.append(t[n],u()),T.nextNode(),d.push({type:2,index:++l});o.append(t[e],u())}}}else if(8===o.nodeType)if(o.data===a)d.push({type:2,index:l});else{let t=-1;for(;-1!==(t=o.data.indexOf(s,t+1));)d.push({type:7,index:l}),t+=s.length-1}l++}}static createElement(t,e){const n=c.createElement("template");return n.innerHTML=t,n}}function P(t,e,n=t,r){if(e===C)return e;let o=void 0!==r?n._$Co?.[r]:n._$Cl;const i=p(e)?void 0:e._$litDirective$;return o?.constructor!==i&&(o?._$AO?.(!1),void 0===i?o=void 0:(o=new i(t),o._$AT(t,n,r)),void 0!==r?(n._$Co??=[])[r]=o:n._$Cl=o),void 0!==o&&(e=P(t,o._$AS(t,e.values),o,r)),e}class j{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:n}=this._$AD,r=(t?.creationScope??c).importNode(e,!0);T.currentNode=r;let o=T.nextNode(),i=0,s=0,a=n[0];for(;void 0!==a;){if(i===a.index){let e;2===a.type?e=new M(o,o.nextSibling,this,t):1===a.type?e=new a.ctor(o,a.name,a.strings,this,t):6===a.type&&(e=new L(o,this,t)),this._$AV.push(e),a=n[++s]}i!==a?.index&&(o=T.nextNode(),i++)}return T.currentNode=c,r}p(t){let e=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}class M{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,n,r){this.type=2,this._$AH=S,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=P(this,t,e),p(t)?t===S||null==t||""===t?(this._$AH!==S&&this._$AR(),this._$AH=S):t!==this._$AH&&t!==C&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>d(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==S&&p(this._$AH)?this._$AA.nextSibling.data=t:this.T(c.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:n}=t,r="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=k.createElement(A(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(e);else{const t=new j(r,this),n=t.u(this.options);t.p(e),this.T(n),this._$AH=t}}_$AC(t){let e=O.get(t.strings);return void 0===e&&O.set(t.strings,e=new k(t)),e}k(t){d(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,r=0;for(const o of t)r===e.length?e.push(n=new M(this.O(u()),this.O(u()),this,this.options)):n=e[r],n._$AI(o),r++;r<e.length&&(this._$AR(n&&n._$AB.nextSibling,r),e.length=r)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class ${get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,r,o){this.type=1,this._$AH=S,this._$AN=void 0,this.element=t,this.name=e,this._$AM=r,this.options=o,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=S}_$AI(t,e=this,n,r){const o=this.strings;let i=!1;if(void 0===o)t=P(this,t,e,0),i=!p(t)||t!==this._$AH&&t!==C,i&&(this._$AH=t);else{const r=t;let s,a;for(t=o[0],s=0;s<o.length-1;s++)a=P(this,r[n+s],e,s),a===C&&(a=this._$AH[s]),i||=!p(a)||a!==this._$AH[s],a===S?t=S:t!==S&&(t+=(a??"")+o[s+1]),this._$AH[s]=a}i&&!r&&this.j(t)}j(t){t===S?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class N extends ${constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===S?void 0:t}}class D extends ${constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==S)}}class I extends ${constructor(t,e,n,r,o){super(t,e,n,r,o),this.type=5}_$AI(t,e=this){if((t=P(this,t,e,0)??S)===C)return;const n=this._$AH,r=t===S&&n!==S||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,o=t!==S&&(n===S||r);r&&this.element.removeEventListener(this.name,this,n),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class L{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){P(this,t)}}const R=n.litHtmlPolyfillSupport;R?.(k,M),(n.litHtmlVersions??=[]).push("3.3.0");var H,V,F,U,B,z=function(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t},W=function(){function t(t,e){this.manager=t,this.options=e,this.isOpen=!1,this.renderDialog()}return t.prototype.open=function(){this.isOpen=!0,this.renderDialog()},t.prototype.close=function(){this.isOpen=!1,this.renderDialog()},t.prototype.renderCSS=function(){var t;return null!==(t=this.options.css)&&void 0!==t?t:"\n#keymaps-dialog {\n position: absolute;\n bottom: 50px;\n left: 50%;\n background-color: #333333;\n border: #404040 solid 1px;\n border-radius: 10px;\n z-index: 1000;\n padding: 15px 18px 25px 28px;\n box-shadow: 0 10px 25px rgba(0, 0, 0, 0.33);\n transform: scaleY(0.5) translate(-50%, 0);\n transform-origin: bottom center;\n opacity: 0;\n pointer-events: none;\n transition: transform 0.2s, opacity 0.2s;\n}\n\n#keymaps-dialog.open {\n transform: scaleY(1) translate(-50%, 0);\n opacity: 1;\n}\n\n#keymaps-dialog.fade-out {\n animation: keymaps-fade-out 0.2s;\n}\n\n#keymaps-dialog header {\n margin-bottom: 12px;\n}\n\n#keymaps-dialog main {\n display: flex;\n position: relative;\n max-width: 80vw;\n overflow-x: auto;\n overflow-y: hidden;\n}\n\n#keymaps-dialog .mask {\n position: sticky;\n flex-shrink: 0;\n top: 0;\n bottom: 0;\n width: 10px;\n right: 0;\n background-image: linear-gradient(to right, transparent, #333333 90%);\n}\n\n#keymaps-dialog .category {\n margin-right: 15px;\n}\n\n#keymaps-dialog .category:last-of-type {\n margin-right: 0;\n}\n\n#keymaps-dialog ul {\n display: grid;\n grid-auto-flow: column;\n grid-template-rows: repeat(9, 1fr);\n grid-template-columns: 1fr;\n grid-column-gap: 15px;\n grid-row-gap: 2px;\n list-style: none;\n}\n\n#keymaps-dialog * {\n cursor: default;\n padding: 0;\n margin: 0;\n color: #ddd;\n font-family: Ubuntu, sans-serif;\n}\n\n#keymap-dialog *::selection, #keymap-dialog *::-moz-selection {\n background-color: transparent;\n}\n\n#keymaps-dialog h3 {\n text-align: center;\n font-size: 0.85rem;\n opacity: 0.5;\n}\n\n#keymaps-dialog h4 {\n font-size: 0.85rem;\n margin-bottom: 12px;\n}\n\n#keymaps-dialog span {\n font-size: 0.75rem;\n}\n\n#keymaps-dialog .keymap {\n display: flex;\n align-items: center;\n border-radius: 7px;\n padding: 6px 20px 6px 5px;\n white-space: nowrap;\n}\n\n#keymaps-dialog .keymap:nth-child(odd) {\n background-color: #404040;\n}\n\n#keymaps-dialog .keys {\n display: flex;\n align-items: center;\n margin-right: 8px;\n}\n\n#keymaps-dialog .key {\n height: 1rem;\n line-height: 1rem;\n display: inline-block;\n vertical-align: middle;\n border-radius: 4px;\n background-color: #ffffff20;\n color: #ddd;\n padding: 0 5px;\n margin-right: 5px;\n}\n\n#keymaps-dialog .name {\n white-space: nowrap;\n}\n\n"},t.prototype.renderDialog=function(){var t=this.manager.keymapsRegistry;((t,e)=>{const n=e;let r=n._$litPart$;if(void 0===r){const t=null;n._$litPart$=r=new M(e.insertBefore(u(),t),t,void 0,{})}r._$AI(t)})(x(B||(B=z(["\n <style>",'</style>\n <div id="keymaps-dialog" class="','">\n <header>\n <h3>Keyboard Shortcuts ',"</h3>\n </header>\n <main>\n ",'\n <div class="mask"></div>\n </main>\n </div>\n '],["\n <style>",'</style>\n <div id="keymaps-dialog" class="','">\n <header>\n <h3>Keyboard Shortcuts ',"</h3>\n </header>\n <main>\n ",'\n <div class="mask"></div>\n </main>\n </div>\n '])),this.renderCSS(),this.isOpen?"open":"",this.options.longPressDuration&&this.options.longPressKey?x(H||(H=z(["(hold "," to show)"],["(hold "," to show)"])),q(this.options.longPressKey)):"",t&&Object.keys(t).map((function(e){return x(U||(U=z(['\n <section class="category">\n <h4>',"</h4>\n <ul>\n ","\n </ul>\n </section>\n "],['\n <section class="category">\n <h4>',"</h4>\n <ul>\n ","\n </ul>\n </section>\n "])),e,t[e].map((function(t){return x(F||(F=z(['\n <li class="keymap">\n <div class="keys">\n ','\n </div>\n <span class="name">',"</span>\n </li>\n "],['\n <li class="keymap">\n <div class="keys">\n ','\n </div>\n <span class="name">',"</span>\n </li>\n "])),t.keys.map((function(t){return x(V||(V=z(['\n <span class="key">',"</span>\n "],['\n <span class="key">',"</span>\n "])),t)})),t.name)})))}))),document.body)},t}();function q(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}var G=function(){function t(t,e){var n=this;this.editor=t,this.dialog=new W(this,e),this.keymapsRegistry={},t.on("keymap:add keymap:remove",(function(){n.updateRegistry()}))}return t.prototype.updateRegistry=function(){var t=this.editor.Keymaps.getAll();for(var e in this.keymapsRegistry={},t){var n=e.split(":"),r=q(n[0]),o=n[1].split("-").map(q).join(" "),i=t[e].keys.split(",")[0].replace(/\b/,"").split("+").map(q);this.keymapsRegistry[r]||(this.keymapsRegistry[r]=[]),this.keymapsRegistry[r].push({name:o,keys:i})}},t.prototype.openDialog=function(){this.dialog.open()},t.prototype.closeDialog=function(){this.dialog.close()},t}(),K=function(){return K=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},K.apply(this,arguments)},Y="open-keymaps-dialog",J={longPressKey:"shift",longPressDuration:800,shortcut:"shift+k",css:null};const X=function(t,e){void 0===e&&(e={});var n=K(K({},J),e),r=new G(t,n);t.Commands.add(Y,{run:function(t){r.openDialog()},stop:function(t){r.closeDialog()}});var o=!1;if(n.shortcut&&t.Keymaps.add("general:toggle-shortcuts-help",n.shortcut,(function(){t.Commands.isActive(Y)?(o=!1,t.stopCommand(Y)):(o=!0,t.runCommand(Y))})),n.longPressDuration&&n.longPressKey){var i=void 0;document.addEventListener("keydown",(function(e){e.key.toLowerCase()===n.longPressKey&&(i||(i=setTimeout((function(){t.runCommand(Y)}),n.longPressDuration)))})),document.addEventListener("keyup",(function(e){e.key.toLowerCase()!==n.longPressKey||o||(i&&(clearTimeout(i),i=void 0),t.stopCommand(Y))}))}};return e})(),t.exports=e()},924:function(t){"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window&&window,t.exports=(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function n(t,e){Object.keys(e).forEach((function(n){t.style[n]=e[n]}))}t.r(e),t.d(e,{default:()=>r});const r=function(t,e){void 0===e&&(e={});var r={appendTo:document.body,start:!0,style:{padding:"4px",backgroundColor:"white",opacity:.6,position:"fixed",zIndex:10,transition:"width 0.2s ease-out",pointerEvents:"none"},visibleStyle:{visibility:"visible",width:"100%"},hiddenStyle:{visibility:"hidden",width:"0%"}},o=Object.assign(r,e),i=document.createElement("div");t.on("load",(function(){var t="string"==typeof o.appendTo?document.querySelector(o.appendTo):o.appendTo;o.start?t.insertBefore(i,t.firstChild):t.appendChild(i)})),n(i,o.style),i.style.visibility="hidden",t.on("storage:start",(function(){n(i,o.visibleStyle)})),t.on("storage:end",(function(){n(i,o.hiddenStyle)}))};return e})()},756:function(t){var e;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window&&window,e=()=>(()=>{var t={482:(t,e,n)=>{var r,o,i;i="object"==typeof self&&self.self===self&&self||"object"==typeof n.g&&n.g.global===n.g&&n.g,r=[n(23),n(651),e],o=function(t,e,n){i.Backbone=function(t,e,n,r){var o=t.Backbone,i=Array.prototype.slice;e.VERSION="1.4.1",e.$=r,e.noConflict=function(){return t.Backbone=o,this},e.emulateHTTP=!1,e.emulateJSON=!1;var s,a=e.Events={},l=/\s+/,c=function(t,e,r,o,i){var s,a=0;if(r&&"object"==typeof r){void 0!==o&&"context"in i&&void 0===i.context&&(i.context=o);for(s=n.keys(r);a<s.length;a++)e=c(t,e,s[a],r[s[a]],i)}else if(r&&l.test(r))for(s=r.split(l);a<s.length;a++)e=t(e,s[a],o,i);else e=t(e,r,o,i);return e};a.on=function(t,e,n){return this._events=c(u,this._events||{},t,e,{context:n,ctx:this,listening:s}),s&&((this._listeners||(this._listeners={}))[s.id]=s,s.interop=!1),this},a.listenTo=function(t,e,r){if(!t)return this;var o=t._listenId||(t._listenId=n.uniqueId("l")),i=this._listeningTo||(this._listeningTo={}),a=s=i[o];a||(this._listenId||(this._listenId=n.uniqueId("l")),a=s=i[o]=new v(this,t));var l=p(t,e,r,this);if(s=void 0,l)throw l;return a.interop&&a.on(e,r),this};var u=function(t,e,n,r){if(n){var o=t[e]||(t[e]=[]),i=r.context,s=r.ctx,a=r.listening;a&&a.count++,o.push({callback:n,context:i,ctx:i||s,listening:a})}return t},p=function(t,e,n,r){try{t.on(e,n,r)}catch(t){return t}};a.off=function(t,e,n){return this._events?(this._events=c(d,this._events,t,e,{context:n,listeners:this._listeners}),this):this},a.stopListening=function(t,e,r){var o=this._listeningTo;if(!o)return this;for(var i=t?[t._listenId]:n.keys(o),s=0;s<i.length;s++){var a=o[i[s]];if(!a)break;a.obj.off(e,r,this),a.interop&&a.off(e,r)}return n.isEmpty(o)&&(this._listeningTo=void 0),this};var d=function(t,e,r,o){if(t){var i,s=o.context,a=o.listeners,l=0;if(e||s||r){for(i=e?[e]:n.keys(t);l<i.length;l++){var c=t[e=i[l]];if(!c)break;for(var u=[],p=0;p<c.length;p++){var d=c[p];if(r&&r!==d.callback&&r!==d.callback._callback||s&&s!==d.context)u.push(d);else{var f=d.listening;f&&f.off(e,r)}}u.length?t[e]=u:delete t[e]}return t}for(i=n.keys(a);l<i.length;l++)a[i[l]].cleanup()}};a.once=function(t,e,n){var r=c(f,{},t,e,this.off.bind(this));return"string"==typeof t&&null==n&&(e=void 0),this.on(r,e,n)},a.listenToOnce=function(t,e,n){var r=c(f,{},e,n,this.stopListening.bind(this,t));return this.listenTo(t,r)};var f=function(t,e,r,o){if(r){var i=t[e]=n.once((function(){o(e,i),r.apply(this,arguments)}));i._callback=r}return t};a.trigger=function(t){if(!this._events)return this;for(var e=Math.max(0,arguments.length-1),n=Array(e),r=0;r<e;r++)n[r]=arguments[r+1];return c(h,this._events,t,void 0,n),this};var h=function(t,e,n,r){if(t){var o=t[e],i=t.all;o&&i&&(i=i.slice()),o&&g(o,r),i&&g(i,[e].concat(r))}return t},g=function(t,e){var n,r=-1,o=t.length,i=e[0],s=e[1],a=e[2];switch(e.length){case 0:for(;++r<o;)(n=t[r]).callback.call(n.ctx);return;case 1:for(;++r<o;)(n=t[r]).callback.call(n.ctx,i);return;case 2:for(;++r<o;)(n=t[r]).callback.call(n.ctx,i,s);return;case 3:for(;++r<o;)(n=t[r]).callback.call(n.ctx,i,s,a);return;default:for(;++r<o;)(n=t[r]).callback.apply(n.ctx,e);return}},v=function(t,e){this.id=t._listenId,this.listener=t,this.obj=e,this.interop=!0,this.count=0,this._events=void 0};v.prototype.on=a.on,v.prototype.off=function(t,e){var n;this.interop?(this._events=c(d,this._events,t,e,{context:void 0,listeners:void 0}),n=!this._events):(this.count--,n=0===this.count),n&&this.cleanup()},v.prototype.cleanup=function(){delete this.listener._listeningTo[this.obj._listenId],this.interop||delete this.obj._listeners[this.id]},a.bind=a.on,a.unbind=a.off,n.extend(e,a);var m=e.Model=function(t,e){var r=t||{};e||(e={}),this.preinitialize.apply(this,arguments),this.cid=n.uniqueId(this.cidPrefix),this.attributes={},e.collection&&(this.collection=e.collection),e.parse&&(r=this.parse(r,e)||{});var o=n.result(this,"defaults");r=n.defaults(n.extend({},o,r),o),this.set(r,e),this.changed={},this.initialize.apply(this,arguments)};n.extend(m.prototype,a,{changed:null,validationError:null,idAttribute:"id",cidPrefix:"c",preinitialize:function(){},initialize:function(){},toJSON:function(t){return n.clone(this.attributes)},sync:function(){return e.sync.apply(this,arguments)},get:function(t){return this.attributes[t]},escape:function(t){return n.escape(this.get(t))},has:function(t){return null!=this.get(t)},matches:function(t){return!!n.iteratee(t,this)(this.attributes)},set:function(t,e,r){if(null==t)return this;var o;if("object"==typeof t?(o=t,r=e):(o={})[t]=e,r||(r={}),!this._validate(o,r))return!1;var i=r.unset,s=r.silent,a=[],l=this._changing;this._changing=!0,l||(this._previousAttributes=n.clone(this.attributes),this.changed={});var c=this.attributes,u=this.changed,p=this._previousAttributes;for(var d in o)e=o[d],n.isEqual(c[d],e)||a.push(d),n.isEqual(p[d],e)?delete u[d]:u[d]=e,i?delete c[d]:c[d]=e;if(this.idAttribute in o){var f=this.id;this.id=this.get(this.idAttribute),this.trigger("changeId",this,f,r)}if(!s){a.length&&(this._pending=r);for(var h=0;h<a.length;h++)this.trigger("change:"+a[h],this,c[a[h]],r)}if(l)return this;if(!s)for(;this._pending;)r=this._pending,this._pending=!1,this.trigger("change",this,r);return this._pending=!1,this._changing=!1,this},unset:function(t,e){return this.set(t,void 0,n.extend({},e,{unset:!0}))},clear:function(t){var e={};for(var r in this.attributes)e[r]=void 0;return this.set(e,n.extend({},t,{unset:!0}))},hasChanged:function(t){return null==t?!n.isEmpty(this.changed):n.has(this.changed,t)},changedAttributes:function(t){if(!t)return!!this.hasChanged()&&n.clone(this.changed);var e,r=this._changing?this._previousAttributes:this.attributes,o={};for(var i in t){var s=t[i];n.isEqual(r[i],s)||(o[i]=s,e=!0)}return!!e&&o},previous:function(t){return null!=t&&this._previousAttributes?this._previousAttributes[t]:null},previousAttributes:function(){return n.clone(this._previousAttributes)},fetch:function(t){t=n.extend({parse:!0},t);var e=this,r=t.success;return t.success=function(n){var o=t.parse?e.parse(n,t):n;if(!e.set(o,t))return!1;r&&r.call(t.context,e,n,t),e.trigger("sync",e,n,t)},z(this,t),this.sync("read",this,t)},save:function(t,e,r){var o;null==t||"object"==typeof t?(o=t,r=e):(o={})[t]=e;var i=(r=n.extend({validate:!0,parse:!0},r)).wait;if(o&&!i){if(!this.set(o,r))return!1}else if(!this._validate(o,r))return!1;var s=this,a=r.success,l=this.attributes;r.success=function(t){s.attributes=l;var e=r.parse?s.parse(t,r):t;if(i&&(e=n.extend({},o,e)),e&&!s.set(e,r))return!1;a&&a.call(r.context,s,t,r),s.trigger("sync",s,t,r)},z(this,r),o&&i&&(this.attributes=n.extend({},l,o));var c=this.isNew()?"create":r.patch?"patch":"update";"patch"!==c||r.attrs||(r.attrs=o);var u=this.sync(c,this,r);return this.attributes=l,u},destroy:function(t){t=t?n.clone(t):{};var e=this,r=t.success,o=t.wait,i=function(){e.stopListening(),e.trigger("destroy",e,e.collection,t)};t.success=function(n){o&&i(),r&&r.call(t.context,e,n,t),e.isNew()||e.trigger("sync",e,n,t)};var s=!1;return this.isNew()?n.defer(t.success):(z(this,t),s=this.sync("delete",this,t)),o||i(),s},url:function(){var t=n.result(this,"urlRoot")||n.result(this.collection,"url")||B();if(this.isNew())return t;var e=this.get(this.idAttribute);return t.replace(/[^\/]$/,"$&/")+encodeURIComponent(e)},parse:function(t,e){return t},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return!this.has(this.idAttribute)},isValid:function(t){return this._validate({},n.extend({},t,{validate:!0}))},_validate:function(t,e){if(!e.validate||!this.validate)return!0;t=n.extend({},this.attributes,t);var r=this.validationError=this.validate(t,e)||null;return!r||(this.trigger("invalid",this,r,n.extend(e,{validationError:r})),!1)}});var y=e.Collection=function(t,e){e||(e={}),this.preinitialize.apply(this,arguments),e.model&&(this.model=e.model),void 0!==e.comparator&&(this.comparator=e.comparator),this._reset(),this.initialize.apply(this,arguments),t&&this.reset(t,n.extend({silent:!0},e))},b={add:!0,remove:!0,merge:!0},w={add:!0,remove:!1},_=function(t,e,n){n=Math.min(Math.max(n,0),t.length);var r,o=Array(t.length-n),i=e.length;for(r=0;r<o.length;r++)o[r]=t[r+n];for(r=0;r<i;r++)t[r+n]=e[r];for(r=0;r<o.length;r++)t[r+i+n]=o[r]};n.extend(y.prototype,a,{model:m,preinitialize:function(){},initialize:function(){},toJSON:function(t){return this.map((function(e){return e.toJSON(t)}))},sync:function(){return e.sync.apply(this,arguments)},add:function(t,e){return this.set(t,n.extend({merge:!1},e,w))},remove:function(t,e){e=n.extend({},e);var r=!n.isArray(t);t=r?[t]:t.slice();var o=this._removeModels(t,e);return!e.silent&&o.length&&(e.changes={added:[],merged:[],removed:o},this.trigger("update",this,e)),r?o[0]:o},set:function(t,e){if(null!=t){(e=n.extend({},b,e)).parse&&!this._isModel(t)&&(t=this.parse(t,e)||[]);var r=!n.isArray(t);t=r?[t]:t.slice();var o=e.at;null!=o&&(o=+o),o>this.length&&(o=this.length),o<0&&(o+=this.length+1);var i,s,a=[],l=[],c=[],u=[],p={},d=e.add,f=e.merge,h=e.remove,g=!1,v=this.comparator&&null==o&&!1!==e.sort,m=n.isString(this.comparator)?this.comparator:null;for(s=0;s<t.length;s++){i=t[s];var y=this.get(i);if(y){if(f&&i!==y){var w=this._isModel(i)?i.attributes:i;e.parse&&(w=y.parse(w,e)),y.set(w,e),c.push(y),v&&!g&&(g=y.hasChanged(m))}p[y.cid]||(p[y.cid]=!0,a.push(y)),t[s]=y}else d&&(i=t[s]=this._prepareModel(i,e))&&(l.push(i),this._addReference(i,e),p[i.cid]=!0,a.push(i))}if(h){for(s=0;s<this.length;s++)p[(i=this.models[s]).cid]||u.push(i);u.length&&this._removeModels(u,e)}var x=!1,C=!v&&d&&h;if(a.length&&C?(x=this.length!==a.length||n.some(this.models,(function(t,e){return t!==a[e]})),this.models.length=0,_(this.models,a,0),this.length=this.models.length):l.length&&(v&&(g=!0),_(this.models,l,null==o?this.length:o),this.length=this.models.length),g&&this.sort({silent:!0}),!e.silent){for(s=0;s<l.length;s++)null!=o&&(e.index=o+s),(i=l[s]).trigger("add",i,this,e);(g||x)&&this.trigger("sort",this,e),(l.length||u.length||c.length)&&(e.changes={added:l,removed:u,merged:c},this.trigger("update",this,e))}return r?t[0]:t}},reset:function(t,e){e=e?n.clone(e):{};for(var r=0;r<this.models.length;r++)this._removeReference(this.models[r],e);return e.previousModels=this.models,this._reset(),t=this.add(t,n.extend({silent:!0},e)),e.silent||this.trigger("reset",this,e),t},push:function(t,e){return this.add(t,n.extend({at:this.length},e))},pop:function(t){var e=this.at(this.length-1);return this.remove(e,t)},unshift:function(t,e){return this.add(t,n.extend({at:0},e))},shift:function(t){var e=this.at(0);return this.remove(e,t)},slice:function(){return i.apply(this.models,arguments)},get:function(t){if(null!=t)return this._byId[t]||this._byId[this.modelId(this._isModel(t)?t.attributes:t,t.idAttribute)]||t.cid&&this._byId[t.cid]},has:function(t){return null!=this.get(t)},at:function(t){return t<0&&(t+=this.length),this.models[t]},where:function(t,e){return this[e?"find":"filter"](t)},findWhere:function(t){return this.where(t,!0)},sort:function(t){var e=this.comparator;if(!e)throw new Error("Cannot sort a set without a comparator");t||(t={});var r=e.length;return n.isFunction(e)&&(e=e.bind(this)),1===r||n.isString(e)?this.models=this.sortBy(e):this.models.sort(e),t.silent||this.trigger("sort",this,t),this},pluck:function(t){return this.map(t+"")},fetch:function(t){var e=(t=n.extend({parse:!0},t)).success,r=this;return t.success=function(n){var o=t.reset?"reset":"set";r[o](n,t),e&&e.call(t.context,r,n,t),r.trigger("sync",r,n,t)},z(this,t),this.sync("read",this,t)},create:function(t,e){var r=(e=e?n.clone(e):{}).wait;if(!(t=this._prepareModel(t,e)))return!1;r||this.add(t,e);var o=this,i=e.success;return e.success=function(t,e,n){r&&o.add(t,n),i&&i.call(n.context,t,e,n)},t.save(null,e),t},parse:function(t,e){return t},clone:function(){return new this.constructor(this.models,{model:this.model,comparator:this.comparator})},modelId:function(t,e){return t[e||this.model.prototype.idAttribute||"id"]},values:function(){return new C(this,S)},keys:function(){return new C(this,O)},entries:function(){return new C(this,T)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(t,e){return this._isModel(t)?(t.collection||(t.collection=this),t):((e=e?n.clone(e):{}).collection=this,(r=this.model.prototype?new this.model(t,e):this.model(t,e)).validationError?(this.trigger("invalid",this,r.validationError,e),!1):r);var r},_removeModels:function(t,e){for(var n=[],r=0;r<t.length;r++){var o=this.get(t[r]);if(o){var i=this.indexOf(o);this.models.splice(i,1),this.length--,delete this._byId[o.cid];var s=this.modelId(o.attributes,o.idAttribute);null!=s&&delete this._byId[s],e.silent||(e.index=i,o.trigger("remove",o,this,e)),n.push(o),this._removeReference(o,e)}}return n},_isModel:function(t){return t instanceof m},_addReference:function(t,e){this._byId[t.cid]=t;var n=this.modelId(t.attributes,t.idAttribute);null!=n&&(this._byId[n]=t),t.on("all",this._onModelEvent,this)},_removeReference:function(t,e){delete this._byId[t.cid];var n=this.modelId(t.attributes,t.idAttribute);null!=n&&delete this._byId[n],this===t.collection&&delete t.collection,t.off("all",this._onModelEvent,this)},_onModelE