/*!
 * Tiny Enhanced Media Embed plugin
 *
 * Copyright (c) 2023 Ephox Corporation DBA Tiny Technologies, Inc.
 * Licensed under the Tiny commercial license. See https://www.tiny.cloud/legal/
 *
 * Version: 8.3.0-112
 */

/*!
 * This resource uses the code from the following libraries:
 *
 * specificity
 *  Copyright (c) 2022 Bramus Van Damme - https://www.bram.us/
 *  https://github.com/keeganstreet/specificity
 *
 */

!function(){"use strict";const e=Object.getPrototypeOf,t=(e,t,n)=>!!n(e,t.prototype)||e.constructor?.name===t.name,n=e=>n=>(e=>{const n=typeof e;return null===e?"null":"object"===n&&Array.isArray(e)?"array":"object"===n&&t(e,String,((e,t)=>t.isPrototypeOf(e)))?"string":n})(n)===e,r=e=>t=>typeof t===e,o=n("string"),s=n("object"),i=n=>((n,r)=>s(n)&&t(n,r,((t,n)=>e(t)===n)))(n,Object),a=n("array"),l=r("boolean"),c=e=>undefined===e;const u=e=>null==e,h=e=>!u(e),d=r("function"),p=r("number"),f=()=>{},m=e=>()=>e,g=e=>e,y=e=>e(),k=m(!1),v=m(!0);class S{tag;value;static singletonNone=new S(!1);constructor(e,t){this.tag=e,this.value=t}static some(e){return new S(!0,e)}static none(){return S.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?S.some(e(this.value)):S.none()}bind(e){return this.tag?e(this.value):S.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:S.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(e??"Called getOrDie on None")}static from(e){return h(e)?S.some(e):S.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}const b=Array.prototype.slice,C=Array.prototype.indexOf,w=Array.prototype.push,x=(e,t)=>((e,t)=>C.call(e,t))(e,t)>-1,A=(e,t)=>{for(let n=0,r=e.length;n<r;n++)if(t(e[n],n))return!0;return!1},T=(e,t)=>{const n=e.length,r=new Array(n);for(let o=0;o<n;o++){const n=e[o];r[o]=t(n,o)}return r},L=(e,t)=>{for(let n=0,r=e.length;n<r;n++)t(e[n],n)},E=(e,t)=>{const n=[];for(let r=0,o=e.length;r<o;r++){const o=e[r];t(o,r)&&n.push(o)}return n},O=(e,t,n)=>(L(e,((e,r)=>{n=t(n,e,r)})),n),_=(e,t)=>((e,t,n)=>{for(let r=0,o=e.length;r<o;r++){const o=e[r];if(t(o,r))return S.some(o);if(n(o,r))break}return S.none()})(e,t,k),P=(e,t)=>(e=>{const t=[];for(let n=0,r=e.length;n<r;++n){if(!a(e[n]))throw new Error("Arr.flatten item "+n+" was not an array, input: "+e);w.apply(t,e[n])}return t})(T(e,t)),R=d(Array.from)?Array.from:e=>b.call(e),I=Object.keys,N=Object.hasOwnProperty,M=(e,t)=>{const n=I(e);for(let r=0,o=n.length;r<o;r++){const o=n[r];t(e[o],o)}},j=(e,t)=>$(e,((e,n)=>({k:n,v:t(e,n)}))),$=(e,t)=>{const n={};return M(e,((e,r)=>{const o=t(e,r);n[o.k]=o.v})),n},D=(e,t)=>B(e,t)?S.from(e[t]):S.none(),B=(e,t)=>N.call(e,t),F=e=>{let t=S.none(),n=[];const r=e=>{o()?s(e):n.push(e)},o=()=>t.isSome(),s=e=>{t.each((t=>{setTimeout((()=>{e(t)}),0)}))};return e((e=>{o()||(t=S.some(e),L(n,s),n=[])})),{get:r,map:e=>F((t=>{r((n=>{t(e(n))}))})),isReady:o}},U={nu:F,pure:e=>F((t=>{t(e)}))},z=e=>{setTimeout((()=>{throw e}),0)},V=e=>{const t=t=>{e().then(t,z)};return{map:t=>V((()=>e().then(t))),bind:t=>V((()=>e().then((e=>t(e).toPromise())))),anonBind:t=>V((()=>e().then((()=>t.toPromise())))),toLazy:()=>U.nu(t),toCached:()=>{let t=null;return V((()=>(null===t&&(t=e()),t)))},toPromise:e,get:t}},q=e=>V((()=>new Promise(e))),H=e=>V((()=>Promise.resolve(e))),J=e=>{const t=t=>t(e),n=m(e),r=()=>o,o={tag:!0,inner:e,fold:(t,n)=>n(e),isValue:v,isError:k,map:t=>G.value(t(e)),mapError:r,bind:t,exists:t,forall:t,getOr:n,or:r,getOrThunk:n,orThunk:r,getOrDie:n,each:t=>{t(e)},toOptional:()=>S.some(e)};return o},W=e=>{const t=()=>n,n={tag:!1,inner:e,fold:(t,n)=>t(e),isValue:k,isError:v,map:t,mapError:t=>G.error(t(e)),bind:t,exists:k,forall:v,getOr:g,or:g,getOrThunk:y,orThunk:y,getOrDie:(r=String(e),()=>{throw new Error(r)}),each:f,toOptional:S.none};var r;return n},G={value:J,error:W,fromOption:(e,t)=>e.fold((()=>W(t)),J)},K=e=>({...e,toCached:()=>K(e.toCached()),bindFuture:t=>K(e.bind((e=>e.fold((e=>H(G.error(e))),(e=>t(e)))))),bindResult:t=>K(e.map((e=>e.bind(t)))),mapResult:t=>K(e.map((e=>e.map(t)))),mapError:t=>K(e.map((e=>e.mapError(t)))),foldResult:(t,n)=>e.map((e=>e.fold(t,n))),withTimeout:(t,n)=>K(q((r=>{let o=!1;const s=setTimeout((()=>{o=!0,r(G.error(n()))}),t);e.get((e=>{o||(clearTimeout(s),r(e))}))})))}),Q=e=>K(q(e)),Y=e=>K(H(G.value(e))),X={nu:Q,wrap:K,pure:Y,value:Y,error:e=>K(H(G.error(e))),fromResult:e=>K(H(e)),fromFuture:e=>K(e.map(G.value)),fromPromise:e=>Q((t=>{e.then((e=>{t(G.value(e))}),(e=>{t(G.error(e))}))}))},Z=(ee=(e,t)=>i(e)&&i(t)?Z(e,t):t,(...e)=>{if(0===e.length)throw new Error("Can't merge zero objects");const t={};for(let n=0;n<e.length;n++){const r=e[n];for(const e in r)B(r,e)&&(t[e]=ee(t[e],r[e]))}return t});var ee;const te=(e,t)=>((e,t)=>""===t||e.length>=t.length&&e.substr(0,0+t.length)===t)(e,t),ne=(e,t)=>{const{type:n,message:r}=t;e.notificationManager.open({type:n,text:r})},re=e=>{(e=>{switch(e){case"error":return console.error;case"info":return console.info;case"warn":return console.warn;default:return console.log}})(e.type)(e.message)},oe=(e,t)=>{const{protect:n,allowList:r=[],blockList:o=[]}=null!=e?e:{};let s;return s=h(n)?n:r.length>0||o.length>0||t,{protect:s,allowList:r,blockList:o}},se=e=>{const{protect:t,allowList:n,blockList:r}=null!=e?e:{};return e=>{const o=e.toLowerCase();return n.length>0?!A(n,(e=>e.toLowerCase()===o)):r.length>0?A(r,(e=>e.toLowerCase()===o)):t}},ie=e=>{const t=se(e);return(e,n)=>{const r=((e,t)=>`${e}:${t}`)(n,e.toLowerCase());return t(r)}},ae=(e,t,n,r)=>{const o=Reflect.get(e,"on"),s={protectedEventHandlers:[],cleanupScheduled:!1},i=(e,t)=>{r&&console.log(`[EventsProxy] ${e}`,t||"")},a=t=>{"invalid"===t&&s.protectedEventHandlers.length>0&&(i("Removing event handlers",s.protectedEventHandlers),L(s.protectedEventHandlers,(t=>{e.off(t.name,t.callback)})),s.protectedEventHandlers=[])},l=t.onStatusChange(a);return e.on("remove",l),(r,l,c)=>{i(`Adding event listener: ${r}`,{shouldProtect:n(r)});const u=((e,r)=>{const o=n(e),i=t.getStatus(),a=o&&"invalid"===i?f:r;return o&&s.protectedEventHandlers.push({name:e,callback:a}),a})(r,l);return s.cleanupScheduled||(s.cleanupScheduled=!0,window.setTimeout((()=>{a(t.getStatus()),s.cleanupScheduled=!1}),0)),Reflect.apply(o,e,[r,u,c])}},le=(e,t,n)=>r=>{const o="invalid"!==t.getStatus()&&h(n)?n(r):f,s=((e,t,n)=>{const r=e=>{"invalid"===e&&n.setEnabled(!1)},o=()=>r(t.getStatus());r(t.getStatus()),e.on("NodeChange",o);const s=t.onStatusChange(r);return()=>{e.off("NodeChange",o),s()}})(e,t,r);return e=>{null==o||o(e),s()}},ce=(e,t,n)=>(...r)=>{var o;return"invalid"===e.getStatus()?n:null!==(o=null==t?void 0:t(...r))&&void 0!==o?o:n},ue=(e,t)=>ce(e,t,Promise.resolve([])),he=(e,t)=>ce(e,t,[]),de=(e,t)=>ce(e,t,!1),pe=(e,t,n,r)=>{const s=t=>{const{command:s,value:i}=t,a=S.from(i).filter(o).map((e=>e.toLowerCase())),l=s.toLowerCase()===r.toLowerCase(),c=a.exists((e=>n.has(e))),u=a.exists((t=>t===e.queryCommandValue(r)));l&&c&&!u&&t.preventDefault()},i=t.onStatusChange((t=>{if("invalid"===t){e.on("BeforeExecCommand",s);const t=()=>{const t=e.queryCommandValue(r);n.has(t.toLowerCase())&&e.execCommand(r,!1,t)};e.initialized?t():e.on("init",t)}}));e.on("remove",(()=>{i(),e.off("BeforeExecCommand",s)}))},fe=(e,t,n,r,s,i=!1)=>{const a=new Set,l=new Set,c=(e,t)=>{i&&console.log(`[UiProxy] ${e}`,t||"")};((e,t,n)=>{pe(e,t,n,"ToggleView")})(e,n,a),((e,t,n)=>{pe(e,t,n,"ToggleSidebar")})(e,n,l);const u=(t,o,i,a)=>{const l=s(t,i);return c(`${a}: ${t}`,{spec:o,context:r,shouldProtect:l}),l?{...o,onSetup:le(e,n,o.onSetup)}:o};return new Proxy(t,{get:(e,t,i)=>{const h=Reflect.get(e,t,i);if(!o(t))return h;switch(t){case"addButton":case"addGroupToolbarButton":case"addToggleButton":case"addMenuButton":case"addSplitButton":return(...n)=>{const[r,o,...s]=n,i=u(r,o,"button",String(t));return Reflect.apply(h,e,[r,i,...s])};case"addMenuItem":case"addToggleMenuItem":case"addNestedMenuItem":return(...n)=>{const[r,o,...s]=n,i=u(r,o,"menuitem",String(t));return Reflect.apply(h,e,[r,i,...s])};case"addAutocompleter":return(...o)=>{const[i,a,...l]=o,u=s(i,"autocompleter");if(c(`${String(t)}: ${i}`,{spec:a,context:r,shouldProtect:u}),u){const t={...a,fetch:ue(n,a.fetch)};return Reflect.apply(h,e,[i,t,...l])}return Reflect.apply(h,e,[i,a,...l])};case"addSidebar":return(...n)=>{const[o,i,...a]=n,u=s(o,"sidebar");if(c(`${String(t)}: ${o}`,{spec:i,context:r,shouldProtect:u}),u){l.add(o.toLowerCase());const t={...i};return Reflect.apply(h,e,[o,t,...a])}return Reflect.apply(h,e,[o,i,...a])};case"addView":return(...n)=>{const[o,i,...l]=n,u=s(o,"view");if(c(`${String(t)}: ${o}`,{spec:i,context:r,shouldProtect:u}),u){a.add(o.toLowerCase());const t={...i};return Reflect.apply(h,e,[o,t,...l])}return Reflect.apply(h,e,[o,i,...l])};case"addContextMenu":return(...o)=>{const[i,a,...l]=o,u=s(i,"contextmenu");if(c(`${String(t)}: ${i}`,{spec:a,context:r,shouldProtect:u}),u){const t={...a,update:he(n,a.update)};return Reflect.apply(h,e,[i,t,...l])}return Reflect.apply(h,e,[i,a,...l])};case"addContextToolbar":case"addContextForm":return(...o)=>{const[i,a,...l]=o,u=s(i,"contexttoolbar");if(c(`${String(t)}: ${i}`,{spec:a,context:r,shouldProtect:u}),u){const t={...a,predicate:de(n,a.predicate)};return Reflect.apply(h,e,[i,t,...l])}return Reflect.apply(h,e,[i,a,...l])};case"addIcon":case"getAll":case"addContext":return h}}})},me=new Set(["addCommand","addCommands","addQueryStateHandler","addQueryValueHandler"]),ge=e=>(t,n)=>{e&&console.log(`[EditorProxy] ${t}`,n||"")},ye=(e,t)=>{const{statusProvider:n,uiContext:r,protection:o,debug:s=!1}=t,{events:i,commands:a,ui:l}=o;ge(s)("Creating enhanced editor with options:",{hasStatusProvider:!!n,uiContext:r,debug:s,protection:o});const{editorUiProxy:c,editorCommandsProxy:u,editorEventListenerProxy:h}=((e,t,n,r,o,s,i)=>{const a=s.protect?{...e.ui,registry:fe(e,e.ui.registry,t,n,ie(s),i)}:e.ui,l=r.protect?((e,t,n,r,o)=>{const s={protectedCommands:[],cleanupScheduled:!1},i=(e,t)=>{o&&console.log(`[CommandsProxy] ${e}`,t||"")},a=(e,t)=>{const o=r(e),i=n.getStatus();return o&&s.protectedCommands.push(e),o&&"invalid"===i?f:t},l=t=>{"invalid"===t&&s.protectedCommands.length>0&&(i("Removing commands",s.protectedCommands),L(s.protectedCommands,(t=>{e.editorCommands.removeCommand(t)})),s.protectedCommands=[])},c=()=>{s.cleanupScheduled||(s.cleanupScheduled=!0,window.setTimeout((()=>{l(n.getStatus()),s.cleanupScheduled=!1}),0))},u=n.onStatusChange(l);return e.on("remove",u),new Proxy(t,{get:(e,n,o)=>{if(i(`Accessing property: ${String(n)}`),"addCommand"===n){const s=Reflect.get(e,n,o);return(e,n,...o)=>{i(`Adding command: ${e}`,{shouldProtect:r(e)});const l=a(e,n);return c(),Reflect.apply(s,t,[e,l,...o])}}if("addCommands"===n){const r=Reflect.get(e,n,o);return(e,n="exec")=>{i(`Adding commands (${n})`,{commandCount:Object.keys(e).length,willApplyEnforcement:"exec"===n});const o="exec"!==n?e:j(e,((e,t)=>a(t,e)));return c(),Reflect.apply(r,t,[o,n])}}return Reflect.get(e,n,o)}})})(e,e.editorCommands,t,se(r),i):e.editorCommands;return{editorUiProxy:a,editorCommandsProxy:l,editorEventListenerProxy:o.protect?ae(e,t,se(o),i):e.on.bind(e)}})(e,n,r||"",a,i,l,s),p=((e,t,n,r)=>(o,s,i)=>{const a=String(s);if("on"===s)return ge(r)("on intercepted"),n;if(me.has(a))return ge(r)(`${a} intercepted`),t[a].bind(t);if("editorCommands"===s)return ge(r)("editorCommands accessed"),t;if("ui"===s)return ge(r)("ui accessed"),e;const l=Reflect.get(o,s,i);return d(l)?l.bind(o):l})(c,u,h,s);return new Proxy(e,{get:p,set:(e,t,n,r)=>Reflect.set(e,t,n,r),has:(e,t)=>Reflect.has(e,t),ownKeys:e=>Reflect.ownKeys(e),getOwnPropertyDescriptor:(e,t)=>Reflect.getOwnPropertyDescriptor(e,t),defineProperty:(e,t,n)=>Reflect.defineProperty(e,t,n),deleteProperty:(e,t)=>Reflect.deleteProperty(e,t),isExtensible:e=>Reflect.isExtensible(e),preventExtensions:e=>Reflect.preventExtensions(e),getPrototypeOf:e=>Reflect.getPrototypeOf(e),setPrototypeOf:(e,t)=>Reflect.setPrototypeOf(e,t)})},ke=e=>parseInt(e,10),ve=(e,t)=>{const n=e-t;return 0===n?0:n>0?1:-1},Se=(e,t,n)=>({major:e,minor:t,patch:n}),be=e=>{const t=/([0-9]+)\.([0-9]+)\.([0-9]+)(?:(\-.+)?)/.exec(e);return t?Se(ke(t[1]),ke(t[2]),ke(t[3])):Se(0,0,0)},Ce=(e,t)=>!!e&&-1===((e,t)=>{const n=ve(e.major,t.major);if(0!==n)return n;const r=ve(e.minor,t.minor);if(0!==r)return r;const o=ve(e.patch,t.patch);return 0!==o?o:0})((e=>be((e=>[e.majorVersion,e.minorVersion].join(".").split(".").slice(0,3).join("."))(e)))(e),be(t)),we=be("8.3.0"),xe=`${we.major}.${we.minor}.0`,Ae=`${we.major+1}.0.0`,Te=(e,t)=>{const{setup:n,protection:r}=t;return(o,s)=>{if(!((e,t)=>Ce(e,xe)?(console.error(`The "${t}" plugin requires at least version ${xe} of TinyMCE.`),!1):!!Ce(e,Ae)||(console.error(`The "${t}" plugin requires at least version ${xe} of TinyMCE but less than ${Ae}.`),!1))(tinymce,e)||((e,t)=>!!(e=>{var t;const n=null===(t=e.options.get("license_key"))||void 0===t?void 0:t.toLowerCase(),r=e.options.get("online_license_key");return u(r)&&"gpl"===n})(e)&&(((e,t)=>{const{console:n,editor:r}=t;h(r)&&(e._skinLoaded?ne(e,r):e.on("SkinLoaded",(()=>{ne(e,r)}))),h(n)&&re(n)})(e,{console:{type:"error",message:[`The "${t}" plugin requires a valid TinyMCE license key.`,"Read more: https://www.tiny.cloud/docs/tinymce/latest/license-key/"].join(" ")}}),!0))(o,e))return{};const i=(e=>{const{protect:t=!0,events:n,commands:r,ui:o,api:s}=null!=e?e:{};return{protect:t,events:oe(n,false),commands:oe(r,true),ui:oe(o,true),api:oe(s,true)}})(r),a=((e="pre-validation")=>{const t=(e=>{let t=e;return{get:()=>t,set:e=>{t=e}}})(e),n=new Set;let r=!1;const{enableLogging:o=!1}={},s=(e,...t)=>{o&&console.log(`[StatusProvider] ${e}`,...t)};return{setStatus:e=>{const r=t.get();if(r===e)return s("Status unchanged:",e),!1;t.set(e),s("Status changed:",r,"->",e);const o={currentStatus:e,previousStatus:r},i=Array.from(n);return L(i,(e=>{e(o.currentStatus,o.previousStatus)})),!0},onStatusChange:e=>(n.add(e),s("Callback registered, total listeners:",n.size),()=>{n.delete(e)&&s("Callback unregistered, remaining listeners:",n.size)}),getStatus:t.get,hasListeners:()=>n.size>0,destroy:()=>{r||(s("Destroying StatusProvider, clearing",n.size,"listeners"),n.clear(),r=!0)}}})(),l=((e,t,n)=>{const r=`commercial-license-${t}`;return e.ui.registry.addContext(r,(()=>"invalid"!==n.getStatus()&&!e.mode.isReadOnly())),e.licenseKeyManager.validate({plugin:t}).then((e=>{n.setStatus(e?"valid":"invalid")}),(e=>{console.error(e),console.error(`An unknown error occurred when trying to validate "${t}" plugin.`),n.setStatus("invalid")})),{ui:{context:r}}})(o,e,a),c=i.protect?ye(o,{statusProvider:a,uiContext:l.ui.context,debug:t.debug||!1,protection:i}):o,p=((e,t)=>({pluginCode:e,enforcer:{isInvalid:()=>"invalid"===t.getStatus(),onInvalid:e=>t.onStatusChange(((t,n)=>{"invalid"===t&&e(t,n)}))}}))(e,a);return((e,t,n,r)=>{if(t.protect&&t.api.protect&&h(e)){const s=se(t.api);return(o=e=>"invalid"===n.getStatus()&&s(e),(e,t)=>j(e,((e,n)=>d(e)?(...r)=>{if(o(n.toLowerCase())){const e=`Method "${h(t)?`${t}.`:""}${n}" is not available due to license key restrictions.`,r=new Error(e);throw console.error(e),r}return e(...r)}:e)))(e,r)}var o;return e})(n(c,s,p),i,a,e)}},Le=e=>t=>t.options.get(e),Ee=Le("mediaembed_content_css"),Oe=Le("mediaembed_max_width"),_e=Le("mediaembed_inline_styles"),Pe=Le("mediaembed_service_url"),Re=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},Ie=(e,t)=>{const n=(t||document).createElement(e);return Re(n)},Ne=Re,Me=(e,t)=>{const n=e.dom;if(1!==n.nodeType)return!1;{const e=n;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},je=e=>1===(e=>e.dom.nodeType)(e),$e=e=>t=>je(t)&&t.dom.nodeName.toLowerCase()===e,De=e=>S.from(e.dom.parentNode).map(Ne),Be=e=>S.from(e.dom.nextSibling).map(Ne),Fe=e=>T(e.dom.childNodes,Ne),Ue=e=>(e=>{const t=e.dom.childNodes;return S.from(t[0]).map(Ne)})(e),ze=(e,t)=>{Be(e).fold((()=>{De(e).each((e=>{Ve(e,t)}))}),(e=>{((e,t)=>{De(e).each((n=>{n.dom.insertBefore(t.dom,e.dom)}))})(e,t)}))},Ve=(e,t)=>{e.dom.appendChild(t.dom)},qe=(e,t,n)=>{((e,t,n)=>{if(!(o(n)||l(n)||p(n)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",n,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,n+"")})(e.dom,t,n)},He=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Je=e=>{const t=Ie("div"),n=Ne(e.dom.cloneNode(!0));return Ve(t,n),(e=>e.dom.innerHTML)(t)},We=(e,t,n)=>{if(!o(n))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",n,":: Element ",e),new Error("CSS value must be a string: "+n);(e=>void 0!==e.style&&d(e.style.getPropertyValue))(e)&&e.style.setProperty(t,n)},Ge=(e,t,n)=>{const r=e.dom;We(r,t,n)},Ke=(e,t)=>{const n=e.dom;M(t,((e,t)=>{We(n,t,e)}))},Qe=e=>e.dom.textContent,Ye=(e,t)=>(e=>E(Fe(e),(e=>Me(e,t))))(e),Xe=(e,t)=>{const n=t[t.length-1];return(e=>{for(let o=0,s=e.length;o<s;o++)if(t=e[o],r=void 0,r=n,t.dom===r.dom)return S.some(o);var t,r;return S.none()})(e).getOrDie("how is it possible you can't find a br you just found?")},Ze=e=>E(Ye(e,"br"),(e=>Be(e).isSome())),et=e=>O(e,((e,t)=>e+Qe(t)),""),tt=e=>{const t=Ze(e);if(t.length>0){const n=Fe(e),r=Xe(n,t),o=n.slice(r+1);return et(o)}return S.from(Qe(e)).getOr("")};var nt=Object.create,rt=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,st=Object.getOwnPropertyNames,it=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty,lt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ct=(e,t)=>{for(var n in t)rt(e,n,{get:t[n],enumerable:!0})},ut=lt((e=>{var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");e.encode=function(e){if(0<=e&&e<t.length)return t[e];throw new TypeError("Must be between 0 and 63: "+e)},e.decode=function(e){return 65<=e&&e<=90?e-65:97<=e&&e<=122?e-97+26:48<=e&&e<=57?e-48+52:43==e?62:47==e?63:-1}})),ht=lt((e=>{var t=ut();e.encode=function(e){var n,r,o="",s=(r=e)<0?1+(-r<<1):0+(r<<1);do{n=31&s,(s>>>=5)>0&&(n|=32),o+=t.encode(n)}while(s>0);return o},e.decode=function(e,n,r){var o,s,i=e.length,a=0,l=0;do{if(n>=i)throw new Error("Expected more digits in base 64 VLQ value.");if(-1===(s=t.decode(e.charCodeAt(n++))))throw new Error("Invalid base64 digit: "+e.charAt(n-1));o=!!(32&s),a+=(s&=31)<<l,l+=5}while(o);r.value=function(e){var t=e>>1;return 1&~e?t:-t}(a),r.rest=n}})),dt=lt((e=>{e.getArg=function(e,t,n){if(t in e)return e[t];if(3===arguments.length)return n;throw new Error('"'+t+'" is a required argument.')};var t=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,n=/^data:.+\,.+$/;function r(e){var n=e.match(t);return n?{scheme:n[1],auth:n[2],host:n[3],port:n[4],path:n[5]}:null}function o(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}e.urlParse=r,e.urlGenerate=o;var s=function(){var t=[];return function(n){for(var s=0;s<t.length;s++)if(t[s].input===n){var i=t[0];return t[0]=t[s],t[s]=i,t[0].result}var a=function(t){var n=t,s=r(t);if(s){if(!s.path)return t;n=s.path}for(var i=e.isAbsolute(n),a=[],l=0,c=0;;){if(l=c,-1===(c=n.indexOf("/",l))){a.push(n.slice(l));break}for(a.push(n.slice(l,c));c<n.length&&"/"===n[c];)c++}var u,h=0;for(c=a.length-1;c>=0;c--)"."===(u=a[c])?a.splice(c,1):".."===u?h++:h>0&&(""===u?(a.splice(c+1,h),h=0):(a.splice(c,2),h--));return""===(n=a.join("/"))&&(n=i?"/":"."),s?(s.path=n,o(s)):n}(n);return t.unshift({input:n,result:a}),t.length>32&&t.pop(),a}}();function i(e,t){""===e&&(e="."),""===t&&(t=".");var i=r(t),a=r(e);if(a&&(e=a.path||"/"),i&&!i.scheme)return a&&(i.scheme=a.scheme),o(i);if(i||t.match(n))return t;if(a&&!a.host&&!a.path)return a.host=t,o(a);var l="/"===t.charAt(0)?t:s(e.replace(/\/+$/,"")+"/"+t);return a?(a.path=l,o(a)):l}e.normalize=s,e.join=i,e.isAbsolute=function(e){return"/"===e.charAt(0)||t.test(e)},e.relative=function(e,t){""===e&&(e="."),e=e.replace(/\/$/,"");for(var n=0;0!==t.indexOf(e+"/");){var r=e.lastIndexOf("/");if(r<0||(e=e.slice(0,r)).match(/^([^\/]+:\/)?\/*$/))return t;++n}return Array(n+1).join("../")+t.substr(e.length+1)};var a=!("__proto__"in Object.create(null));function l(e){return e}function c(e){if(!e)return!1;var t=e.length;if(t<9||95!==e.charCodeAt(t-1)||95!==e.charCodeAt(t-2)||111!==e.charCodeAt(t-3)||116!==e.charCodeAt(t-4)||111!==e.charCodeAt(t-5)||114!==e.charCodeAt(t-6)||112!==e.charCodeAt(t-7)||95!==e.charCodeAt(t-8)||95!==e.charCodeAt(t-9))return!1;for(var n=t-10;n>=0;n--)if(36!==e.charCodeAt(n))return!1;return!0}function u(e,t){return e===t?0:null===e?1:null===t?-1:e>t?1:-1}e.toSetString=a?l:function(e){return c(e)?"$"+e:e},e.fromSetString=a?l:function(e){return c(e)?e.slice(1):e},e.compareByOriginalPositions=function(e,t,n){var r=u(e.source,t.source);return 0!==r||0!=(r=e.originalLine-t.originalLine)||0!=(r=e.originalColumn-t.originalColumn)||n||0!=(r=e.generatedColumn-t.generatedColumn)||0!=(r=e.generatedLine-t.generatedLine)?r:u(e.name,t.name)},e.compareByOriginalPositionsNoSource=function(e,t,n){var r;return 0!=(r=e.originalLine-t.originalLine)||0!=(r=e.originalColumn-t.originalColumn)||n||0!=(r=e.generatedColumn-t.generatedColumn)||0!=(r=e.generatedLine-t.generatedLine)?r:u(e.name,t.name)},e.compareByGeneratedPositionsDeflated=function(e,t,n){var r=e.generatedLine-t.generatedLine;return 0!==r||0!=(r=e.generatedColumn-t.generatedColumn)||n||0!==(r=u(e.source,t.source))||0!=(r=e.originalLine-t.originalLine)||0!=(r=e.originalColumn-t.originalColumn)?r:u(e.name,t.name)},e.compareByGeneratedPositionsDeflatedNoLine=function(e,t,n){var r=e.generatedColumn-t.generatedColumn;return 0!==r||n||0!==(r=u(e.source,t.source))||0!=(r=e.originalLine-t.originalLine)||0!=(r=e.originalColumn-t.originalColumn)?r:u(e.name,t.name)},e.compareByGeneratedPositionsInflated=function(e,t){var n=e.generatedLine-t.generatedLine;return 0!==n||0!=(n=e.generatedColumn-t.generatedColumn)||0!==(n=u(e.source,t.source))||0!=(n=e.originalLine-t.originalLine)||0!=(n=e.originalColumn-t.originalColumn)?n:u(e.name,t.name)},e.parseSourceMapInput=function(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))},e.computeSourceURL=function(e,t,n){if(t=t||"",e&&("/"!==e[e.length-1]&&"/"!==t[0]&&(e+="/"),t=e+t),n){var a=r(n);if(!a)throw new Error("sourceMapURL could not be parsed");if(a.path){var l=a.path.lastIndexOf("/");l>=0&&(a.path=a.path.substring(0,l+1))}t=i(o(a),t)}return s(t)}})),pt=lt((e=>{var t=dt(),n=Object.prototype.hasOwnProperty,r=typeof Map<"u";function o(){this._array=[],this._set=r?new Map:Object.create(null)}o.fromArray=function(e,t){for(var n=new o,r=0,s=e.length;r<s;r++)n.add(e[r],t);return n},o.prototype.size=function(){return r?this._set.size:Object.getOwnPropertyNames(this._set).length},o.prototype.add=function(e,o){var s=r?e:t.toSetString(e),i=r?this.has(e):n.call(this._set,s),a=this._array.length;(!i||o)&&this._array.push(e),i||(r?this._set.set(e,a):this._set[s]=a)},o.prototype.has=function(e){if(r)return this._set.has(e);var o=t.toSetString(e);return n.call(this._set,o)},o.prototype.indexOf=function(e){if(r){var o=this._set.get(e);if(o>=0)return o}else{var s=t.toSetString(e);if(n.call(this._set,s))return this._set[s]}throw new Error('"'+e+'" is not in the set.')},o.prototype.at=function(e){if(e>=0&&e<this._array.length)return this._array[e];throw new Error("No element indexed by "+e)},o.prototype.toArray=function(){return this._array.slice()},e.ArraySet=o})),ft=lt((e=>{var t=dt();function n(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}n.prototype.unsortedForEach=function(e,t){this._array.forEach(e,t)},n.prototype.add=function(e){!function(e,n){var r=e.generatedLine,o=n.generatedLine,s=e.generatedColumn,i=n.generatedColumn;return o>r||o==r&&i>=s||t.compareByGeneratedPositionsInflated(e,n)<=0}(this._last,e)?(this._sorted=!1,this._array.push(e)):(this._last=e,this._array.push(e))},n.prototype.toArray=function(){return this._sorted||(this._array.sort(t.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},e.MappingList=n})),mt=lt((e=>{var t=ht(),n=dt(),r=pt().ArraySet,o=ft().MappingList;function s(e){e||(e={}),this._file=n.getArg(e,"file",null),this._sourceRoot=n.getArg(e,"sourceRoot",null),this._skipValidation=n.getArg(e,"skipValidation",!1),this._sources=new r,this._names=new r,this._mappings=new o,this._sourcesContents=null}s.prototype._version=3,s.fromSourceMap=function(e){var t=e.sourceRoot,r=new s({file:e.file,sourceRoot:t});return e.eachMapping((function(e){var o={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(o.source=e.source,null!=t&&(o.source=n.relative(t,o.source)),o.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(o.name=e.name)),r.addMapping(o)})),e.sources.forEach((function(o){var s=o;null!==t&&(s=n.relative(t,o)),r._sources.has(s)||r._sources.add(s);var i=e.sourceContentFor(o);null!=i&&r.setSourceContent(o,i)})),r},s.prototype.addMapping=function(e){var t=n.getArg(e,"generated"),r=n.getArg(e,"original",null),o=n.getArg(e,"source",null),s=n.getArg(e,"name",null);this._skipValidation||this._validateMapping(t,r,o,s),null!=o&&(o=String(o),this._sources.has(o)||this._sources.add(o)),null!=s&&(s=String(s),this._names.has(s)||this._names.add(s)),this._mappings.add({generatedLine:t.line,generatedColumn:t.column,originalLine:null!=r&&r.line,originalColumn:null!=r&&r.column,source:o,name:s})},s.prototype.setSourceContent=function(e,t){var r=e;null!=this._sourceRoot&&(r=n.relative(this._sourceRoot,r)),null!=t?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[n.toSetString(r)]=t):this._sourcesContents&&(delete this._sourcesContents[n.toSetString(r)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},s.prototype.applySourceMap=function(e,t,o){var s=t;if(null==t){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');s=e.file}var i=this._sourceRoot;null!=i&&(s=n.relative(i,s));var a=new r,l=new r;this._mappings.unsortedForEach((function(t){if(t.source===s&&null!=t.originalLine){var r=e.originalPositionFor({line:t.originalLine,column:t.originalColumn});null!=r.source&&(t.source=r.source,null!=o&&(t.source=n.join(o,t.source)),null!=i&&(t.source=n.relative(i,t.source)),t.originalLine=r.line,t.originalColumn=r.column,null!=r.name&&(t.name=r.name))}var c=t.source;null!=c&&!a.has(c)&&a.add(c);var u=t.name;null!=u&&!l.has(u)&&l.add(u)}),this),this._sources=a,this._names=l,e.sources.forEach((function(t){var r=e.sourceContentFor(t);null!=r&&(null!=o&&(t=n.join(o,t)),null!=i&&(t=n.relative(i,t)),this.setSourceContent(t,r))}),this)},s.prototype._validateMapping=function(e,t,n,r){if(t&&"number"!=typeof t.line&&"number"!=typeof t.column)throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0)||t||n||r){if(e&&"line"in e&&"column"in e&&t&&"line"in t&&"column"in t&&e.line>0&&e.column>=0&&t.line>0&&t.column>=0&&n)return;throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:n,original:t,name:r}))}},s.prototype._serializeMappings=function(){for(var e,r,o,s,i=0,a=1,l=0,c=0,u=0,h=0,d="",p=this._mappings.toArray(),f=0,m=p.length;f<m;f++){if(e="",(r=p[f]).generatedLine!==a)for(i=0;r.generatedLine!==a;)e+=";",a++;else if(f>0){if(!n.compareByGeneratedPositionsInflated(r,p[f-1]))continue;e+=","}e+=t.encode(r.generatedColumn-i),i=r.generatedColumn,null!=r.source&&(s=this._sources.indexOf(r.source),e+=t.encode(s-h),h=s,e+=t.encode(r.originalLine-1-c),c=r.originalLine-1,e+=t.encode(r.originalColumn-l),l=r.originalColumn,null!=r.name&&(o=this._names.indexOf(r.name),e+=t.encode(o-u),u=o)),d+=e}return d},s.prototype._generateSourcesContent=function(e,t){return e.map((function(e){if(!this._sourcesContents)return null;null!=t&&(e=n.relative(t,e));var r=n.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,r)?this._sourcesContents[r]:null}),this)},s.prototype.toJSON=function(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(e.file=this._file),null!=this._sourceRoot&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e},s.prototype.toString=function(){return JSON.stringify(this.toJSON())},e.SourceMapGenerator=s}));function gt(e){return e>=48&&e<=57}function yt(e){return gt(e)||e>=65&&e<=70||e>=97&&e<=102}function kt(e){return e>=65&&e<=90}function vt(e){return function(e){return kt(e)||function(e){return e>=97&&e<=122}(e)}(e)||function(e){return e>=128}(e)||95===e}function St(e){return vt(e)||gt(e)||45===e}function bt(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e}function Ct(e){return 10===e||13===e||12===e}function wt(e){return Ct(e)||32===e||9===e}function xt(e,t){return!(92!==e||Ct(t)||0===t)}function At(e,t,n){return 45===e?vt(t)||45===t||xt(t,n):!!vt(e)||92===e&&xt(e,t)}function Tt(e,t,n){return 43===e||45===e?gt(t)?2:46===t&&gt(n)?3:0:46===e?gt(t)?2:0:gt(e)?1:0}function Lt(e){return 65279===e||65534===e?1:0}var Et=new Array(128),Ot=130;for(let e=0;e<Et.length;e++)Et[e]=(wt(e)?Ot:gt(e)&&131)||vt(e)&&132||bt(e)&&133||e||128;function _t(e){return e<128?Et[e]:132}function Pt(e,t){return t<e.length?e.charCodeAt(t):0}function Rt(e,t,n){return 13===n&&10===Pt(e,t+1)?2:1}function It(e,t,n){let r=e.charCodeAt(t);return kt(r)&&(r|=32),r===n}function Nt(e,t,n,r){if(n-t!==r.length||t<0||n>e.length)return!1;for(let o=t;o<n;o++){let n=r.charCodeAt(o-t),s=e.charCodeAt(o);if(kt(s)&&(s|=32),s!==n)return!1}return!0}function Mt(e,t){for(;t<e.length&&wt(e.charCodeAt(t));t++);return t}function jt(e,t){for(;t<e.length&&gt(e.charCodeAt(t));t++);return t}function $t(e,t){if(yt(Pt(e,(t+=2)-1))){for(let n=Math.min(e.length,t+5);t<n&&yt(Pt(e,t));t++);let n=Pt(e,t);wt(n)&&(t+=Rt(e,t,n))}return t}function Dt(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(!St(n)){if(xt(n,Pt(e,t+1))){t=$t(e,t)-1;continue}break}}return t}function Bt(e,t){let n=e.charCodeAt(t);if((43===n||45===n)&&(n=e.charCodeAt(t+=1)),gt(n)&&(t=jt(e,t+1),n=e.charCodeAt(t)),46===n&&gt(e.charCodeAt(t+1))&&(t=jt(e,t+=2)),It(e,t,101)){let r=0;n=e.charCodeAt(t+1),(45===n||43===n)&&(r=1,n=e.charCodeAt(t+2)),gt(n)&&(t=jt(e,t+1+r+1))}return t}function Ft(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(41===n){t++;break}xt(n,Pt(e,t+1))&&(t=$t(e,t))}return t}function Ut(e){if(1===e.length&&!yt(e.charCodeAt(0)))return e[0];let t=parseInt(e,16);return(0===t||t>=55296&&t<=57343||t>1114111)&&(t=65533),String.fromCodePoint(t)}var zt=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token"];function Vt(e=null,t){return null===e||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}function qt(e){let t=e.source,n=t.length,r=t.length>0?Lt(t.charCodeAt(0)):0,o=Vt(e.lines,n),s=Vt(e.columns,n),i=e.startLine,a=e.startColumn;for(let e=r;e<n;e++){let r=t.charCodeAt(e);o[e]=i,s[e]=a++,(10===r||13===r||12===r)&&(13===r&&e+1<n&&10===t.charCodeAt(e+1)&&(e++,o[e]=i,s[e]=a),i++,a=1)}o[n]=i,s[n]=a,e.lines=o,e.columns=s,e.computed=!0}var Ht=class{constructor(){this.lines=null,this.columns=null,this.computed=!1}setSource(e,t=0,n=1,r=1){this.source=e,this.startOffset=t,this.startLine=n,this.startColumn=r,this.computed=!1}getLocation(e,t){return this.computed||qt(this),{source:t,offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}}getLocationRange(e,t,n){return this.computed||qt(this),{source:n,start:{offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]},end:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}}},Jt=16777215,Wt=24,Gt=new Map([[2,22],[21,22],[19,20],[23,24]]),Kt=class{constructor(e,t){this.setSource(e,t)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(e="",t=()=>{}){let n=(e=String(e||"")).length,r=Vt(this.offsetAndType,e.length+1),o=Vt(this.balance,e.length+1),s=0,i=0,a=0,l=-1;for(this.offsetAndType=null,this.balance=null,t(e,((e,t,c)=>{switch(e){default:o[s]=n;break;case i:{let e=a&Jt;for(a=o[e],i=a>>Wt,o[s]=e,o[e++]=s;e<s;e++)o[e]===n&&(o[e]=s);break}case 21:case 2:case 19:case 23:o[s]=a,i=Gt.get(e),a=i<<Wt|s}r[s++]=e<<Wt|c,-1===l&&(l=t)})),r[s]=0|n,o[s]=n,o[n]=n;0!==a;){let e=a&Jt;a=o[e],o[e]=n}this.source=e,this.firstCharOffset=-1===l?0:l,this.tokenCount=s,this.offsetAndType=r,this.balance=o,this.reset(),this.next()}lookupType(e){return(e+=this.tokenIndex)<this.tokenCount?this.offsetAndType[e]>>Wt:0}lookupOffset(e){return(e+=this.tokenIndex)<this.tokenCount?this.offsetAndType[e-1]&Jt:this.source.length}lookupValue(e,t){return(e+=this.tokenIndex)<this.tokenCount&&Nt(this.source,this.offsetAndType[e-1]&Jt,this.offsetAndType[e]&Jt,t)}getTokenStart(e){return e===this.tokenIndex?this.tokenStart:e>0?e<this.tokenCount?this.offsetAndType[e-1]&Jt:this.offsetAndType[this.tokenCount]&Jt:this.firstCharOffset}substrToCursor(e){return this.source.substring(e,this.tokenStart)}isBalanceEdge(e){return this.balance[this.tokenIndex]<e}isDelim(e,t){return t?9===this.lookupType(t)&&this.source.charCodeAt(this.lookupOffset(t))===e:9===this.tokenType&&this.source.charCodeAt(this.tokenStart)===e}skip(e){let t=this.tokenIndex+e;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=this.offsetAndType[t-1]&Jt,t=this.offsetAndType[t],this.tokenType=t>>Wt,this.tokenEnd=t&Jt):(this.tokenIndex=this.tokenCount,this.next())}next(){let e=this.tokenIndex+1;e<this.tokenCount?(this.tokenIndex=e,this.tokenStart=this.tokenEnd,e=this.offsetAndType[e],this.tokenType=e>>Wt,this.tokenEnd=e&Jt):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=0,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;13===this.tokenType||25===this.tokenType;)this.next()}skipUntilBalanced(e,t){let n,r,o=e;e:for(;o<this.tokenCount&&(n=this.balance[o],!(n<e));o++)switch(r=o>0?this.offsetAndType[o-1]&Jt:this.firstCharOffset,t(this.source.charCodeAt(r))){case 1:break e;case 2:o++;break e;default:this.balance[n]===o&&(o=n)}this.skip(o-this.tokenIndex)}forEachToken(e){for(let t=0,n=this.firstCharOffset;t<this.tokenCount;t++){let r=n,o=this.offsetAndType[t],s=o&Jt;n=s,e(o>>Wt,r,s,t)}}dump(){let e=new Array(this.tokenCount);return this.forEachToken(((t,n,r,o)=>{e[o]={idx:o,type:zt[t],chunk:this.source.substring(n,r),balance:this.balance[o]}})),e}};function Qt(e,t){function n(t){return t<a?e.charCodeAt(t):0}function r(){return c=Bt(e,c),At(n(c),n(c+1),n(c+2))?(i=12,void(c=Dt(e,c))):37===n(c)?(i=11,void c++):void(i=10)}function o(){let t=c;return c=Dt(e,c),Nt(e,t,c,"url")&&40===n(c)?(c=Mt(e,c+1),34===n(c)||39===n(c)?(i=2,void(c=t+4)):void function(){for(i=7,c=Mt(e,c);c<e.length;c++){let t=e.charCodeAt(c);switch(_t(t)){case 41:return void c++;case Ot:return c=Mt(e,c),41===n(c)||c>=e.length?void(c<e.length&&c++):(c=Ft(e,c),void(i=8));case 34:case 39:case 40:case 133:return c=Ft(e,c),void(i=8);case 92:if(xt(t,n(c+1))){c=$t(e,c)-1;break}return c=Ft(e,c),void(i=8)}}}()):40===n(c)?(i=2,void c++):void(i=1)}function s(t){for(t||(t=n(c++)),i=5;c<e.length;c++){let r=e.charCodeAt(c);switch(_t(r)){case t:return void c++;case Ot:if(Ct(r))return c+=Rt(e,c,r),void(i=6);break;case 92:if(c===e.length-1)break;let o=n(c+1);Ct(o)?c+=Rt(e,c+1,o):xt(r,o)&&(c=$t(e,c)-1)}}}let i,a=(e=String(e||"")).length,l=Lt(n(0)),c=l;for(;c<a;){let a=e.charCodeAt(c);switch(_t(a)){case Ot:i=13,c=Mt(e,c+1);break;case 34:s();break;case 35:St(n(c+1))||xt(n(c+1),n(c+2))?(i=4,c=Dt(e,c+1)):(i=9,c++);break;case 39:s();break;case 40:i=21,c++;break;case 41:i=22,c++;break;case 43:Tt(a,n(c+1),n(c+2))?r():(i=9,c++);break;case 44:i=18,c++;break;case 45:Tt(a,n(c+1),n(c+2))?r():45===n(c+1)&&62===n(c+2)?(i=15,c+=3):At(a,n(c+1),n(c+2))?o():(i=9,c++);break;case 46:Tt(a,n(c+1),n(c+2))?r():(i=9,c++);break;case 47:42===n(c+1)?(i=25,c=e.indexOf("*/",c+2),c=-1===c?e.length:c+2):(i=9,c++);break;case 58:i=16,c++;break;case 59:i=17,c++;break;case 60:33===n(c+1)&&45===n(c+2)&&45===n(c+3)?(i=14,c+=4):(i=9,c++);break;case 64:At(n(c+1),n(c+2),n(c+3))?(i=3,c=Dt(e,c+1)):(i=9,c++);break;case 91:i=19,c++;break;case 92:xt(a,n(c+1))?o():(i=9,c++);break;case 93:i=20,c++;break;case 123:i=23,c++;break;case 125:i=24,c++;break;case 131:r();break;case 132:o();break;default:i=9,c++}t(i,l,l=c)}}var Yt,Xt=(Yt=mt(),((e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of st(t))!at.call(e,n)&&"default"!==n&&rt(e,n,{get:()=>t[n],enumerable:!(r=ot(t,n))||r.enumerable});return e})((e=>rt(e,"__esModule",{value:!0}))(rt(null!=Yt?nt(it(Yt)):{},"default",{value:Yt,enumerable:!0})),Yt)),Zt=new Set(["Atrule","Selector","Declaration"]),en={};ct(en,{safe:()=>an,spec:()=>sn});var tn=(e,t)=>{if(9===e&&(e=t),"string"==typeof e){let t=e.charCodeAt(0);return t>127?32768:t<<8}return e},nn=[[1,1],[1,2],[1,7],[1,8],[1,"-"],[1,10],[1,11],[1,12],[1,15],[1,21],[3,1],[3,2],[3,7],[3,8],[3,"-"],[3,10],[3,11],[3,12],[3,15],[4,1],[4,2],[4,7],[4,8],[4,"-"],[4,10],[4,11],[4,12],[4,15],[12,1],[12,2],[12,7],[12,8],[12,"-"],[12,10],[12,11],[12,12],[12,15],["#",1],["#",2],["#",7],["#",8],["#","-"],["#",10],["#",11],["#",12],["#",15],["-",1],["-",2],["-",7],["-",8],["-","-"],["-",10],["-",11],["-",12],["-",15],[10,1],[10,2],[10,7],[10,8],[10,10],[10,11],[10,12],[10,"%"],[10,15],["@",1],["@",2],["@",7],["@",8],["@","-"],["@",15],[".",10],[".",11],[".",12],["+",10],["+",11],["+",12],["/","*"]],rn=nn.concat([[1,4],[12,4],[4,4],[3,21],[3,5],[3,16],[11,11],[11,12],[11,2],[11,"-"],[22,1],[22,2],[22,11],[22,12],[22,4],[22,"-"]]);function on(e){let t=new Set(e.map((([e,t])=>tn(e)<<16|tn(t))));return function(e,n,r){let o=tn(n,r),s=r.charCodeAt(0);return(45===s&&1!==n&&2!==n&&15!==n||43===s?t.has(e<<16|s<<8):t.has(e<<16|o))&&this.emit(" ",13,!0),o}}var sn=on(nn),an=on(rn);function ln(e,t){if("function"!=typeof t)e.children.forEach(this.node,this);else{let n=null;e.children.forEach((e=>{null!==n&&t.call(this,n),this.node(e),n=e}))}}function cn(e){Qt(e,((t,n,r)=>{this.token(t,e.slice(n,r))}))}var un={};ct(un,{AnPlusB:()=>Sn,Atrule:()=>bn,AtrulePrelude:()=>Cn,AttributeSelector:()=>Tn,Block:()=>Ln,Brackets:()=>En,CDC:()=>On,CDO:()=>_n,ClassSelector:()=>Rn,Combinator:()=>Nn,Comment:()=>Mn,Declaration:()=>jn,DeclarationList:()=>$n,Dimension:()=>Dn,Function:()=>Bn,Hash:()=>Fn,IdSelector:()=>qn,Identifier:()=>zn,MediaFeature:()=>Hn,MediaQuery:()=>Jn,MediaQueryList:()=>Wn,NestingSelector:()=>Kn,Nth:()=>Yn,Number:()=>Xn,Operator:()=>Zn,Parentheses:()=>er,Percentage:()=>nr,PseudoClassSelector:()=>or,PseudoElementSelector:()=>ir,Ratio:()=>ar,Raw:()=>ur,Rule:()=>hr,Selector:()=>pr,SelectorList:()=>mr,String:()=>Sr,StyleSheet:()=>br,TypeSelector:()=>xr,UnicodeRange:()=>Ar,Url:()=>Rr,Value:()=>Ir,WhiteSpace:()=>Nr});var hn=43,dn=45,pn=110,fn=!0;function mn(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===hn||r===dn)&&(t&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)gt(this.charCodeAt(n))||this.error("Integer is expected",n)}function gn(e){return mn.call(this,0,e)}function yn(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let n="";switch(t){case pn:n="N is expected";break;case dn:n="HyphenMinus is expected"}this.error(n,this.tokenStart+e)}}function kn(){let e=0,t=0,n=this.tokenType;for(;13===n||25===n;)n=this.lookupType(++e);if(10!==n){if(!this.isDelim(hn,e)&&!this.isDelim(dn,e))return null;t=this.isDelim(hn,e)?hn:dn;do{n=this.lookupType(++e)}while(13===n||25===n);10!==n&&(this.skip(e),gn.call(this,fn))}return e>0&&this.skip(e),0===t&&(n=this.charCodeAt(this.tokenStart),n!==hn&&n!==dn&&this.error("Number sign is expected")),gn.call(this,0!==t),t===dn?"-"+this.consume(10):this.consume(10)}function vn(){let e=this.tokenStart,t=null,n=null;if(10===this.tokenType)gn.call(this,!1),n=this.consume(10);else if(1===this.tokenType&&this.cmpChar(this.tokenStart,dn))switch(t="-1",yn.call(this,1,pn),this.tokenEnd-this.tokenStart){case 2:this.next(),n=kn.call(this);break;case 3:yn.call(this,2,dn),this.next(),this.skipSC(),gn.call(this,fn),n="-"+this.consume(10);break;default:yn.call(this,2,dn),mn.call(this,3,fn),this.next(),n=this.substrToCursor(e+2)}else if(1===this.tokenType||this.isDelim(hn)&&1===this.lookupType(1)){let r=0;switch(t="1",this.isDelim(hn)&&(r=1,this.next()),yn.call(this,0,pn),this.tokenEnd-this.tokenStart){case 1:this.next(),n=kn.call(this);break;case 2:yn.call(this,1,dn),this.next(),this.skipSC(),gn.call(this,fn),n="-"+this.consume(10);break;default:yn.call(this,1,dn),mn.call(this,2,fn),this.next(),n=this.substrToCursor(e+r+1)}}else if(12===this.tokenType){let r=this.charCodeAt(this.tokenStart),o=r===hn||r===dn,s=this.tokenStart+o;for(;s<this.tokenEnd&&gt(this.charCodeAt(s));s++);s===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),yn.call(this,s-this.tokenStart,pn),t=this.substring(e,s),s+1===this.tokenEnd?(this.next(),n=kn.call(this)):(yn.call(this,s-this.tokenStart+1,dn),s+2===this.tokenEnd?(this.next(),this.skipSC(),gn.call(this,fn),n="-"+this.consume(10)):(mn.call(this,s-this.tokenStart+2,fn),this.next(),n=this.substrToCursor(s+1)))}else this.error();return null!==t&&t.charCodeAt(0)===hn&&(t=t.substr(1)),null!==n&&n.charCodeAt(0)===hn&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:n}}function Sn(e){if(e.a){let t=("+1"===e.a||"1"===e.a?"n":"-1"===e.a&&"-n")||e.a+"n";if(e.b){let n="-"===e.b[0]||"+"===e.b[0]?e.b:"+"+e.b;this.tokenize(t+n)}else this.tokenize(t)}else this.tokenize(e.b)}function bn(e){this.token(3,"@"+e.name),null!==e.prelude&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}function Cn(e){this.children(e)}function wn(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(42)?(t=!0,this.next()):this.isDelim(124)||this.eat(1),this.isDelim(124)?61!==this.charCodeAt(this.tokenStart+1)?(this.next(),this.eat(1)):t&&this.error("Identifier is expected",this.tokenEnd):t&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function xn(){let e=this.tokenStart,t=this.charCodeAt(e);return 61!==t&&126!==t&&94!==t&&36!==t&&42!==t&&124!==t&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),61!==t&&(this.isDelim(61)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function An(){let e,t=this.tokenStart,n=null,r=null,o=null;return this.eat(19),this.skipSC(),e=wn.call(this),this.skipSC(),20!==this.tokenType&&(1!==this.tokenType&&(n=xn.call(this),this.skipSC(),r=5===this.tokenType?this.String():this.Identifier(),this.skipSC()),1===this.tokenType&&(o=this.consume(1),this.skipSC())),this.eat(20),{type:"AttributeSelector",loc:this.getLocation(t,this.tokenStart),name:e,matcher:n,value:r,flags:o}}function Tn(e){this.token(9,"["),this.node(e.name),null!==e.matcher&&(this.tokenize(e.matcher),this.node(e.value)),null!==e.flags&&this.token(1,e.flags),this.token(9,"]")}function Ln(e){this.token(23,"{"),this.children(e,(e=>{"Declaration"===e.type&&this.token(17,";")})),this.token(24,"}")}function En(e){this.token(9,"["),this.children(e),this.token(9,"]")}function On(){this.token(15,"--\x3e")}function _n(){this.token(14,"\x3c!--")}function Pn(){return this.eatDelim(46),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function Rn(e){this.token(9,"."),this.token(1,e.name)}function In(){let e,t=this.tokenStart;switch(this.tokenType){case 13:e=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case 62:case 43:case 126:this.next();break;case 47:this.next(),this.eatIdent("deep"),this.eatDelim(47);break;default:this.error("Combinator is expected")}e=this.substrToCursor(t)}return{type:"Combinator",loc:this.getLocation(t,this.tokenStart),name:e}}function Nn(e){this.tokenize(e.name)}function Mn(e){this.token(25,"/*"+e.value+"*/")}function jn(e){this.token(1,e.property),this.token(16,":"),this.node(e.value),e.important&&(this.token(9,"!"),this.token(1,!0===e.important?"important":e.important))}function $n(e){this.children(e,(e=>{"Declaration"===e.type&&this.token(17,";")}))}function Dn(e){this.token(12,e.value+e.unit)}function Bn(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}function Fn(e){this.token(4,"#"+e.value)}function Un(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function zn(e){this.token(1,e.name)}function Vn(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function qn(e){this.token(9,"#"+e.name)}function Hn(e){this.token(21,"("),this.token(1,e.name),null!==e.value&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}function Jn(e){this.children(e)}function Wn(e){this.children(e,(()=>this.token(18,",")))}function Gn(){let e=this.tokenStart;return this.eatDelim(38),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function Kn(){this.token(9,"&")}function Qn(){this.skipSC();let e,t=this.tokenStart,n=t,r=null;return e=this.lookupValue(0,"odd")||this.lookupValue(0,"even")?this.Identifier():this.AnPlusB(),n=this.tokenStart,this.skipSC(),this.lookupValue(0,"of")&&(this.next(),r=this.SelectorList(),n=this.tokenStart),{type:"Nth",loc:this.getLocation(t,n),nth:e,selector:r}}function Yn(e){this.node(e.nth),null!==e.selector&&(this.token(1,"of"),this.node(e.selector))}function Xn(e){this.token(10,e.value)}function Zn(e){this.tokenize(e.value)}function er(e){this.token(21,"("),this.children(e),this.token(22,")")}function tr(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function nr(e){this.token(11,e.value+"%")}function rr(){let e,t,n=this.tokenStart,r=null;return this.eat(16),2===this.tokenType?(e=this.consumeFunctionName(),t=e.toLowerCase(),hasOwnProperty.call(this.pseudo,t)?(this.skipSC(),r=this.pseudo[t].call(this),this.skipSC()):(r=this.createList(),r.push(this.Raw(this.tokenIndex,null,!1))),this.eat(22)):e=this.consume(1),{type:"PseudoClassSelector",loc:this.getLocation(n,this.tokenStart),name:e,children:r}}function or(e){this.token(16,":"),null===e.children?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}function sr(){let e,t,n=this.tokenStart,r=null;return this.eat(16),this.eat(16),2===this.tokenType?(e=this.consumeFunctionName(),t=e.toLowerCase(),hasOwnProperty.call(this.pseudo,t)?(this.skipSC(),r=this.pseudo[t].call(this),this.skipSC()):(r=this.createList(),r.push(this.Raw(this.tokenIndex,null,!1))),this.eat(22)):e=this.consume(1),{type:"PseudoElementSelector",loc:this.getLocation(n,this.tokenStart),name:e,children:r}}function ir(e){this.token(16,":"),this.token(16,":"),null===e.children?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}function ar(e){this.token(10,e.left),this.token(9,"/"),this.token(10,e.right)}function lr(){return this.tokenIndex>0&&13===this.lookupType(-1)?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function cr(e,t,n){let r,o=this.getTokenStart(e);return this.skipUntilBalanced(e,t||this.consumeUntilBalanceEnd),r=n&&this.tokenStart>o?lr.call(this):this.tokenStart,{type:"Raw",loc:this.getLocation(o,r),value:this.substring(o,r)}}function ur(e){this.tokenize(e.value)}function hr(e){this.node(e.prelude),this.node(e.block)}function dr(){let e=this.readSequence(this.scope.Selector);return null===this.getFirstListNode(e)&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(e),children:e}}function pr(e){this.children(e)}function fr(){let e=this.createList();for(;!this.eof&&(e.push(this.Selector()),18===this.tokenType);)this.next();return{type:"SelectorList",loc:this.getLocationFromList(e),children:e}}function mr(e){this.children(e,(()=>this.token(18,",")))}var gr=92,yr=34;function kr(e){let t=e.length,n=e.charCodeAt(0),r=n===yr||39===n?1:0,o=1===r&&t>1&&e.charCodeAt(t-1)===n?t-2:t-1,s="";for(let n=r;n<=o;n++){let r=e.charCodeAt(n);if(r===gr){if(n===o){n!==t-1&&(s=e.substr(n+1));break}if(r=e.charCodeAt(++n),xt(gr,r)){let t=n-1,r=$t(e,t);n=r-1,s+=Ut(e.substring(t+1,r))}else 13===r&&10===e.charCodeAt(n+1)&&n++}else s+=e[n]}return s}function vr(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:kr(this.consume(5))}}function Sr(e){this.token(5,function(e){let t=yr,n="",r=!1;for(let o=0;o<e.length;o++){let s=e.charCodeAt(o);0!==s?s<=31||127===s?(n+="\\"+s.toString(16),r=!0):s===t||s===gr?(n+="\\"+e.charAt(o),r=!1):(r&&(yt(s)||wt(s))&&(n+=" "),n+=e.charAt(o),r=!1):n+="\ufffd"}return'"'+n+'"'}(e.value))}function br(e){this.children(e)}function Cr(){1!==this.tokenType&&!1===this.isDelim(42)&&this.error("Identifier or asterisk is expected"),this.next()}function wr(){let e=this.tokenStart;return this.isDelim(124)?(this.next(),Cr.call(this)):(Cr.call(this),this.isDelim(124)&&(this.next(),Cr.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function xr(e){this.tokenize(e.name)}function Ar(e){this.tokenize(e.value)}var Tr=32,Lr=92,Er=34,Or=39,_r=40,Pr=41;function Rr(e){this.token(7,function(e){let t="",n=!1;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);0!==o?o<=31||127===o?(t+="\\"+o.toString(16),n=!0):o===Tr||o===Lr||o===Er||o===Or||o===_r||o===Pr?(t+="\\"+e.charAt(r),n=!1):(n&&yt(o)&&(t+=" "),t+=e.charAt(r),n=!1):t+="\ufffd"}return"url("+t+")"}(e.value))}function Ir(e){this.children(e)}function Nr(e){this.token(13,e.value)}var Mr=function(e){let t=new Map;for(let n in e.node){let r=e.node[n];"function"==typeof(r.generate||r)&&t.set(n,r.generate||r)}return function(e,n){let r="",o=0,s={node(e){if(!t.has(e.type))throw new Error("Unknown node type: "+e.type);t.get(e.type).call(i,e)},tokenBefore:an,token(e,t){o=this.tokenBefore(o,e,t),this.emit(t,e,!1),9===e&&92===t.charCodeAt(0)&&this.emit("\n",13,!0)},emit(e){r+=e},result:()=>r};n&&("function"==typeof n.decorator&&(s=n.decorator(s)),n.sourceMap&&(s=function(e){let t=new Xt.SourceMapGenerator,n={line:1,column:0},r={line:0,column:0},o={line:1,column:0},s={generated:o},i=1,a=0,l=!1,c=e.node;e.node=function(e){if(e.loc&&e.loc.start&&Zt.has(e.type)){let c=e.loc.start.line,u=e.loc.start.column-1;(r.line!==c||r.column!==u)&&(r.line=c,r.column=u,n.line=i,n.column=a,l&&(l=!1,(n.line!==o.line||n.column!==o.column)&&t.addMapping(s)),l=!0,t.addMapping({source:e.loc.source,original:r,generated:n}))}c.call(this,e),l&&Zt.has(e.type)&&(o.line=i,o.column=a)};let u=e.emit;e.emit=function(e,t,n){for(let t=0;t<e.length;t++)10===e.charCodeAt(t)?(i++,a=0):a++;u(e,t,n)};let h=e.result;return e.result=function(){return l&&t.addMapping(s),{css:h(),map:t}},e}(s)),n.mode in en&&(s.tokenBefore=en[n.mode]));let i={node:e=>s.node(e),children:ln,token:(e,t)=>s.token(e,t),tokenize:cn};return s.node(e),s.result()}}({node:un}),jr=null,$r=class{static createItem(e){return{prev:null,next:null,data:e}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(e){return $r.createItem(e)}allocateCursor(e,t){let n;return null!==jr?(n=jr,jr=jr.cursor,n.prev=e,n.next=t,n.cursor=this.cursor):n={prev:e,next:t,cursor:this.cursor},this.cursor=n,n}releaseCursor(){let{cursor:e}=this;this.cursor=e.cursor,e.prev=null,e.next=null,e.cursor=jr,jr=e}updateCursors(e,t,n,r){let{cursor:o}=this;for(;null!==o;)o.prev===e&&(o.prev=t),o.next===n&&(o.next=r),o=o.cursor}*[Symbol.iterator](){for(let e=this.head;null!==e;e=e.next)yield e.data}get size(){let e=0;for(let t=this.head;null!==t;t=t.next)e++;return e}get isEmpty(){return null===this.head}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(e){let t=null;this.head=null;for(let n of e){let e=$r.createItem(n);null!==t?t.next=e:this.head=e,e.prev=t,t=e}return this.tail=t,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(e,t=this){let n=this.allocateCursor(null,this.head);for(;null!==n.next;){let r=n.next;n.next=r.next,e.call(t,r.data,r,this)}this.releaseCursor()}forEachRight(e,t=this){let n=this.allocateCursor(this.tail,null);for(;null!==n.prev;){let r=n.prev;n.prev=r.prev,e.call(t,r.data,r,this)}this.releaseCursor()}reduce(e,t,n=this){let r,o=this.allocateCursor(null,this.head),s=t;for(;null!==o.next;)r=o.next,o.next=r.next,s=e.call(n,s,r.data,r,this);return this.releaseCursor(),s}reduceRight(e,t,n=this){let r,o=this.allocateCursor(this.tail,null),s=t;for(;null!==o.prev;)r=o.prev,o.prev=r.prev,s=e.call(n,s,r.data,r,this);return this.releaseCursor(),s}some(e,t=this){for(let n=this.head;null!==n;n=n.next)if(e.call(t,n.data,n,this))return!0;return!1}map(e,t=this){let n=new $r;for(let r=this.head;null!==r;r=r.next)n.appendData(e.call(t,r.data,r,this));return n}filter(e,t=this){let n=new $r;for(let r=this.head;null!==r;r=r.next)e.call(t,r.data,r,this)&&n.appendData(r.data);return n}nextUntil(e,t,n=this){if(null===e)return;let r=this.allocateCursor(null,e);for(;null!==r.next;){let e=r.next;if(r.next=e.next,t.call(n,e.data,e,this))break}this.releaseCursor()}prevUntil(e,t,n=this){if(null===e)return;let r=this.allocateCursor(e,null);for(;null!==r.prev;){let e=r.prev;if(r.prev=e.prev,t.call(n,e.data,e,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){let e=new $r;for(let t of this)e.appendData(t);return e}prepend(e){return this.updateCursors(null,e,this.head,e),null!==this.head?(this.head.prev=e,e.next=this.head):this.tail=e,this.head=e,this}prependData(e){return this.prepend($r.createItem(e))}append(e){return this.insert(e)}appendData(e){return this.insert($r.createItem(e))}insert(e,t=null){if(null!==t)if(this.updateCursors(t.prev,e,t,e),null===t.prev){if(this.head!==t)throw new Error("before doesn't belong to list");this.head=e,t.prev=e,e.next=t,this.updateCursors(null,e)}else t.prev.next=e,e.prev=t.prev,t.prev=e,e.next=t;else this.updateCursors(this.tail,e,null,e),null!==this.tail?(this.tail.next=e,e.prev=this.tail):this.head=e,this.tail=e;return this}insertData(e,t){return this.insert($r.createItem(e),t)}remove(e){if(this.updateCursors(e,e.prev,e,e.next),null!==e.prev)e.prev.next=e.next;else{if(this.head!==e)throw new Error("item doesn't belong to list");this.head=e.next}if(null!==e.next)e.next.prev=e.prev;else{if(this.tail!==e)throw new Error("item doesn't belong to list");this.tail=e.prev}return e.prev=null,e.next=null,e}push(e){this.insert($r.createItem(e))}pop(){return null!==this.tail?this.remove(this.tail):null}unshift(e){this.prepend($r.createItem(e))}shift(){return null!==this.head?this.remove(this.head):null}prependList(e){return this.insertList(e,this.head)}appendList(e){return this.insertList(e)}insertList(e,t){return null===e.head||(null!=t?(this.updateCursors(t.prev,e.tail,t,e.head),null!==t.prev?(t.prev.next=e.head,e.head.prev=t.prev):this.head=e.head,t.prev=e.tail,e.tail.next=t):(this.updateCursors(this.tail,e.tail,null,e.head),null!==this.tail?(this.tail.next=e.head,e.head.prev=this.tail):this.head=e.head,this.tail=e.tail),e.head=null,e.tail=null),this}replace(e,t){"head"in t?this.insertList(t,e):this.insert(t,e),this.remove(e)}};function Dr({source:e,line:t,column:n},r){function o(e,t){return s.slice(e,t).map(((t,n)=>String(e+n+1).padStart(l)+" |"+t)).join("\n")}let s=e.split(/\r\n?|\n|\f/),i=Math.max(1,t-r)-1,a=Math.min(t+r,s.length+1),l=Math.max(4,String(a).length)+1,c=0;(n+=3*(s[t-1].substr(0,n-1).match(/\t/g)||[]).length)>100&&(c=n-60+3,n=58);for(let e=i;e<=a;e++)e>=0&&e<s.length&&(s[e]=s[e].replace(/\t/g,"    "),s[e]=(c>0&&s[e].length>c?"\u2026":"")+s[e].substr(c,98)+(s[e].length>c+100-1?"\u2026":""));return[o(i,t),new Array(n+l+2).join("-")+"^",o(t,a)].filter(Boolean).join("\n")}function Br(e,t,n,r,o){return Object.assign(function(e,t){let n=Object.create(SyntaxError.prototype),r=new Error;return Object.assign(n,{name:e,message:t,get stack(){return(r.stack||"").replace(/^(.+\n){1,3}/,`${e}: ${t}\n`)}})}("SyntaxError",e),{source:t,offset:n,line:r,column:o,sourceFragment:e=>Dr({source:t,line:r,column:o},isNaN(e)?0:e),get formattedMessage(){return`Parse error: ${e}\n`+Dr({source:t,line:r,column:o},2)}})}function Fr(e){let t=this.createList(),n=!1,r={recognizer:e};for(;!this.eof;){switch(this.tokenType){case 25:this.next();continue;case 13:n=!0,this.next();continue}let o=e.getNode.call(this,r);if(void 0===o)break;n&&(e.onWhiteSpace&&e.onWhiteSpace.call(this,o,t,r),n=!1),t.push(o)}return n&&e.onWhiteSpace&&e.onWhiteSpace.call(this,null,t,r),t}var Ur=()=>{};function zr(e){return function(){return this[e]()}}function Vr(e){let t=Object.create(null);for(let n in e){let r=e[n],o=r.parse||r;o&&(t[n]=o)}return t}var qr={parse(){return this.createSingleNodeList(this.SelectorList())}},Hr={parse(){return this.createSingleNodeList(this.Selector())}},Jr={parse(){return this.createSingleNodeList(this.Identifier())}},Wr={parse(){return this.createSingleNodeList(this.Nth())}},Gr={dir:Jr,has:qr,lang:Jr,matches:qr,is:qr,"-moz-any":qr,"-webkit-any":qr,where:qr,not:qr,"nth-child":Wr,"nth-last-child":Wr,"nth-last-of-type":Wr,"nth-of-type":Wr,slotted:Hr,host:Hr,"host-context":Hr},Kr={};ct(Kr,{AnPlusB:()=>vn,AttributeSelector:()=>An,ClassSelector:()=>Pn,Combinator:()=>In,IdSelector:()=>Vn,Identifier:()=>Un,NestingSelector:()=>Gn,Nth:()=>Qn,Percentage:()=>tr,PseudoClassSelector:()=>rr,PseudoElementSelector:()=>sr,Raw:()=>cr,Selector:()=>dr,SelectorList:()=>fr,String:()=>vr,TypeSelector:()=>wr});var Qr=function(e){let t="",n="<unknown>",r=!1,o=Ur,s=!1,i=new Ht,a=Object.assign(new Kt,function(e){let t={context:Object.create(null),scope:Object.assign(Object.create(null),e.scope),atrule:Vr(e.atrule),pseudo:Vr(e.pseudo),node:Vr(e.node)};for(let n in e.parseContext)switch(typeof e.parseContext[n]){case"function":t.context[n]=e.parseContext[n];break;case"string":t.context[n]=zr(e.parseContext[n])}return{config:t,...t,...t.node}}(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:Fr,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket:e=>123===e?1:0,consumeUntilLeftCurlyBracketOrSemicolon:e=>123===e||59===e?1:0,consumeUntilExclamationMarkOrSemicolon:e=>33===e||59===e?1:0,consumeUntilSemicolonIncluded:e=>59===e?2:0,createList:()=>new $r,createSingleNodeList:e=>(new $r).appendData(e),getFirstListNode:e=>e&&e.first,getLastListNode:e=>e&&e.last,parseWithFallback(e,t){let n=this.tokenIndex;try{return e.call(this)}catch(e){if(s)throw e;let r=t.call(this,n);return s=!0,o(e,r),s=!1,r}},lookupNonWSType(e){let t;do{if(t=this.lookupType(e++),13!==t)return t}while(0!==t);return 0},charCodeAt:e=>e>=0&&e<t.length?t.charCodeAt(e):0,substring:(e,n)=>t.substring(e,n),substrToCursor(e){return this.source.substring(e,this.tokenStart)},cmpChar:(e,n)=>It(t,e,n),cmpStr:(e,n,r)=>Nt(t,e,n,r),consume(e){let t=this.tokenStart;return this.eat(e),this.substrToCursor(t)},consumeFunctionName(){let e=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),e},consumeNumber(e){let n=t.substring(this.tokenStart,Bt(t,this.tokenStart));return this.eat(e),n},eat(e){if(this.tokenType!==e){let t=zt[e].slice(0,-6).replace(/-/g," ").replace(/^./,(e=>e.toUpperCase())),n=`${/[[\](){}]/.test(t)?`"${t}"`:t} is expected`,r=this.tokenStart;switch(e){case 1:2===this.tokenType||7===this.tokenType?(r=this.tokenEnd-1,n="Identifier is expected but function found"):n="Identifier is expected";break;case 4:this.isDelim(35)&&(this.next(),r++,n="Name is expected");break;case 11:10===this.tokenType&&(r=this.tokenEnd,n="Percent sign is expected")}this.error(n,r)}this.next()},eatIdent(e){(1!==this.tokenType||!1===this.lookupValue(0,e))&&this.error(`Identifier "${e}" is expected`),this.next()},eatDelim(e){this.isDelim(e)||this.error(`Delim "${String.fromCharCode(e)}" is expected`),this.next()},getLocation:(e,t)=>r?i.getLocationRange(e,t,n):null,getLocationFromList(e){if(r){let t=this.getFirstListNode(e),r=this.getLastListNode(e);return i.getLocationRange(null!==t?t.loc.start.offset-i.startOffset:this.tokenStart,null!==r?r.loc.end.offset-i.startOffset:this.tokenStart,n)}return null},error(e,n){let r=typeof n<"u"&&n<t.length?i.getLocation(n):this.eof?i.getLocation(function(e,t){for(;t>=0&&wt(e.charCodeAt(t));t--);return t+1}(t,t.length-1)):i.getLocation(this.tokenStart);throw new Br(e||"Unexpected input",t,r.offset,r.line,r.column)}});return Object.assign((function(e,l){t=e,l=l||{},a.setSource(t,Qt),i.setSource(t,l.offset,l.line,l.column),n=l.filename||"<unknown>",r=Boolean(l.positions),o="function"==typeof l.onParseError?l.onParseError:Ur,s=!1,a.parseAtrulePrelude=!("parseAtrulePrelude"in l)||Boolean(l.parseAtrulePrelude),a.parseRulePrelude=!("parseRulePrelude"in l)||Boolean(l.parseRulePrelude),a.parseValue=!("parseValue"in l)||Boolean(l.parseValue),a.parseCustomProperty="parseCustomProperty"in l&&Boolean(l.parseCustomProperty);let{context:c="default",onComment:u}=l;if(!(c in a.context))throw new Error("Unknown context `"+c+"`");"function"==typeof u&&a.forEachToken(((e,n,r)=>{if(25===e){let e=a.getLocation(n,r),o=Nt(t,r-2,r,"*/")?t.slice(n+2,r-2):t.slice(n+2,r);u(o,e)}}));let h=a.context[c].call(a,l);return a.eof||a.error(),h}),{SyntaxError:Br,config:a.config})}({parseContext:{default:"SelectorList",selectorList:"SelectorList",selector:"Selector"},scope:{Selector:{onWhiteSpace:function(e,t){null!==t.last&&"Combinator"!==t.last.type&&null!==e&&"Combinator"!==e.type&&t.push({type:"Combinator",loc:null,name:" "})},getNode:function(){switch(this.tokenType){case 19:return this.AttributeSelector();case 4:return this.IdSelector();case 16:return 16===this.lookupType(1)?this.PseudoElementSelector():this.PseudoClassSelector();case 1:return this.TypeSelector();case 10:case 11:return this.Percentage();case 12:46===this.charCodeAt(this.tokenStart)&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:switch(this.charCodeAt(this.tokenStart)){case 43:case 62:case 126:case 47:return this.Combinator();case 46:return this.ClassSelector();case 42:case 124:return this.TypeSelector();case 35:return this.IdSelector();case 38:return this.NestingSelector()}}}}},atrule:{},pseudo:Gr,node:Kr}),Yr=(e,t)=>e.a===t.a?e.b===t.b?e.c-t.c:e.b-t.b:e.a-t.a,Xr=(e,t)=>0===Yr(e,t),Zr=(e,t)=>Yr(e,t)>0,eo=(e,t)=>Yr(e,t)<0,to=(e,t="ASC")=>{let n=e.sort(Yr);return"DESC"===t?n.reverse():n},no=(...e)=>to(e,"ASC"),ro=(...e)=>to(e,"DESC"),oo=(...e)=>ro(...e)[0],so=e=>{let t={a:0,b:0,c:0};return e.children.forEach((e=>{switch(e.type){case"IdSelector":t.a+=1;break;case"AttributeSelector":case"ClassSelector":t.b+=1;break;case"PseudoClassSelector":switch(e.name.toLowerCase()){case"where":break;case"is":case"matches":case"-webkit-any":case"-moz-any":case"any":case"not":case"has":if(e.children){let n=oo(...io(e.children.first));t.a+=n.a,t.b+=n.b,t.c+=n.c}break;case"nth-child":case"nth-last-child":if(t.b+=1,e.children.first.selector){let n=oo(...io(e.children.first.selector));t.a+=n.a,t.b+=n.b,t.c+=n.c}break;case"host-context":case"host":if(t.b+=1,e.children){let n={type:"Selector",children:[]},r=!1;e.children.first.children.forEach((e=>!r&&("Combinator"===e.type?(r=!0,!1):void n.children.push(e))));let o=io(n)[0];t.a+=o.a,t.b+=o.b,t.c+=o.c}break;case"after":case"before":case"first-letter":case"first-line":t.c+=1;break;default:t.b+=1}break;case"PseudoElementSelector":switch(e.name){case"slotted":if(t.c+=1,e.children){let n={type:"Selector",children:[]},r=!1;e.children.first.children.forEach((e=>!r&&("Combinator"===e.type?(r=!0,!1):void n.children.push(e))));let o=io(n)[0];t.a+=o.a,t.b+=o.b,t.c+=o.c}break;case"view-transition-group":case"view-transition-image-pair":case"view-transition-old":case"view-transition-new":if(e.children&&"*"===e.children.first.value)break;t.c+=1;break;default:t.c+=1}break;case"TypeSelector":let n=e.name;n.includes("|")&&(n=n.split("|")[1]),"*"!==n&&(t.c+=1)}})),new ao(t,e)},io=e=>{if(!e)return[];let t=(e=>{if("string"==typeof e||e instanceof String)try{return Qr(e,{context:"selectorList"})}catch(t){throw new TypeError(`Could not convert passed in source '${e}' to SelectorList: ${t.message}`)}if(e instanceof Object){if(e.type&&["Selector","SelectorList"].includes(e.type))return e;if(e.type&&"Raw"===e.type)try{return Qr(e.value,{context:"selectorList"})}catch(e){throw new TypeError(`Could not convert passed in source to SelectorList: ${e.message}`)}throw new TypeError("Passed in source is an Object but no AST / AST of the type Selector or SelectorList")}throw new TypeError("Passed in source is not a String nor an Object. I don't know what to do with it.")})(e);if("Selector"===t.type)return[so(e)];if("SelectorList"===t.type){let e=[];return t.children.forEach((t=>{let n=so(t);e.push(n)})),e}},ao=class{constructor(e,t=null){this.value=e,this.selector=t}get a(){return this.value.a}set a(e){throw new Error("Manipulating the port of the specificity directly is not allowed. Instead, directly set a new value")}get b(){return this.value.b}set b(e){throw new Error("Manipulating the port of the specificity directly is not allowed. Instead, directly set a new value")}get c(){return this.value.c}set c(e){throw new Error("Manipulating the port of the specificity directly is not allowed. Instead, directly set a new value")}selectorString(){return"string"==typeof this.selector||this.selector instanceof String?this.selector:this.selector instanceof Object&&"Selector"===this.selector.type?Mr(this.selector):""}toObject(){return this.value}toArray(){return[this.value.a,this.value.b,this.value.c]}toString(){return`(${this.value.a},${this.value.b},${this.value.c})`}toJSON(){return{selector:this.selectorString(),asObject:this.toObject(),asArray:this.toArray(),asString:this.toString()}}isEqualTo(e){return Xr(this,e)}isGreaterThan(e){return Zr(this,e)}isLessThan(e){return eo(this,e)}static calculate(e){return io(e)}static compare(e,t){return Yr(e,t)}static equals(e,t){return Xr(e,t)}static lessThan(e,t){return eo(e,t)}static greaterThan(e,t){return Zr(e,t)}static min(...e){return((...e)=>no(...e)[0])(...e)}static max(...e){return oo(...e)}static sortAsc(...e){return no(...e)}static sortDesc(...e){return ro(...e)}};const lo=e=>{const t=new Map,n=e=>{const n=t.get(e);if(h(n))return n;{const n=ao.calculate(e)[0];return t.set(e,n),n}};return(e=>{const t=b.call(e,0);return t.sort(((e,t)=>{const r=n(e.selector),o=n(t.selector);return ao.compare(r,o)})),t})(e)},co=e=>{const t={};return L(e,(n=>{const r=e.getPropertyValue(n);o(r)&&(t[n]=r)})),t},uo=e=>({selector:e.selectorText,styles:co(e.style)}),ho=e=>{const t=e.cssRules;return P(t,(e=>(e=>e.type===window.CSSRule.IMPORT_RULE)(e)&&h(e.styleSheet)?ho(e.styleSheet):(e=>e.type===window.CSSRule.STYLE_RULE)(e)?[uo(e)]:[]))},po=(e,t)=>((e,t)=>{const n={};var r;return((e,t,n,r)=>{M(e,((e,o)=>{(t(e,o)?n:r)(e,o)}))})(e,t,(r=n,(e,t)=>{r[t]=e}),f),n})(O(t,((e,t)=>({...e,...t.styles})),{}),((t,n)=>!x(e.dom.style,n))),fo=(e,t,n)=>{const r=(e=>{const t=(e=>P(e,(e=>(e=>-1!==e.selector.indexOf(","))(e)?(e=>{const t=e.selector.split(/,(?![^(]*\))/g);return T(t,(t=>{const n=t.trim();return{...e,selector:n}}))})(e):[e])))(e);return lo(t)})(e);((e,t)=>{const n=[],r=document.createTreeWalker(e.dom,NodeFilter.SHOW_ELEMENT);for(;h(r.nextNode());){const e=Ne(r.currentNode),o=E(t,(t=>Me(e,t.selector)));if(o.length>0){const t=po(e,o);Ke(e,t),n.push(e)}}L(n,(e=>void e.dom.removeAttribute("class")))})(t,r)},mo=e=>{return t=(e=>{const t=e.dom.styleSheets;return Array.prototype.slice.call(t)})(e),P(t,ho);var t},go=(e,t,n)=>((e,t,r)=>{const o=((e,t)=>E(e,(e=>te(e.selector,t))))(mo(t),n);fo(o,r)})(0,e,t),yo=e=>je(e)?e:Be(e).fold((()=>e),yo),ko=(e,t)=>{const n=e.parser.parse(t,{isRootContent:!0,forced_root_block:!1}),r=tinymce.html.Serializer({validate:!0},e.schema).serialize(n),o=Ne(e.dom.createFragment(r));return xo(e,o)},vo=$e("video"),So=$e("audio"),bo=$e("div"),Co=$e("a"),wo=(e,t)=>{const n=e.dom.createFragment(t);return yo(Ne(n.firstChild))},xo=(e,t)=>{if(_e(e)){const n=Ie("div");Ve(n,t);const r=e.getDoc(),o=Ne(r);go(o,n,".ephox-summary-card");const s=((e,t)=>{const n=void 0===t?document:t.dom;return 1!==(r=n).nodeType&&9!==r.nodeType&&11!==r.nodeType||0===r.childElementCount?[]:T(n.querySelectorAll(e),Ne);var r})("*[style]",n);return L(s,(e=>{var t;(t=e,S.from(((e,t)=>{const n=e.dom.getAttribute(t);return null===n?void 0:n})(t,"style"))).each((t=>qe(e,"data-mce-style",t)))})),(e=>{const t=document.createDocumentFragment();return L(e,(e=>{t.appendChild(e.dom)})),Ne(t)})(Fe(n))}return t},Ao=(e,t,n)=>((e,t,n)=>{const r=Ie("div"),o=(e=>Ne(e.dom.cloneNode(!0)))(t),s=bo(o)?o:(e=>((vo(e)||So(e))&&Ge(e,"width","100%"),So(e)&&Ge(e,"min-width","100px"),e))(o);return Ve(r,s),Ge(r,"max-width",n+"px"),qe(r,"data-ephox-embed-iri",e),qe(r,"contentEditable",!1),r})(e,t,n),To=(e,t,n)=>Co(t)?t:Ao(e,t,n),Lo=(e,t,n)=>{const r=wo(e,n);return Je(To(t,r,Oe(e)))},Eo=(e,t,n,r)=>{const o=To(n,wo(e,r),Oe(e));bo(o)?((e,t,n)=>{const r=ko(e,Je(n));Ue(r).each((n=>{e.undoManager.transact((()=>{ze(t,n),He(t)}))}))})(e,t,o):((e,t,n)=>{const r=ko(e,Je(n));e.undoManager.transact((()=>{var e;(e=t).dom.textContent="",L(Fe(e),(e=>{He(e)})),Ve(t,r)}))})(e,t,o)},Oo=e=>{const t=(e=>{const t=e.split(" "),n={};return L(t,(e=>{n[e.toLowerCase()]=!0})),n})(e);return e=>!!e&&e.nodeName.toLowerCase()in t},_o=Oo("h1 h2 h3 h4 h5 h6 p span div"),Po=Oo("strong em b span a br"),Ro=e=>_o(e.dom)&&(e=>{return _((e=>e?R(e.querySelectorAll("*")):[])(e),(t=Po,e=>!t(e))).isNone();var t})(e.dom),Io=e=>/^https?:\/\/\S+$/i.test(e.trim()),No=e=>S.from(e).filter(Ro).map(tt).filter(Io),Mo=(e,t,n,r)=>{const o=(s=Ne(e.newBlock),S.from(s.dom.previousSibling).map(Ne));var s;o.filter(je).bind(No).map((e=>{n.getAndHandleResponse(e,(n=>{const r=n.recommended().html();((e,t,n,r)=>{t.filter((e=>De(e).isSome())).each((t=>{const o=Ze(t);o.length>0?((e,t,n,r,o)=>{const s=Fe(t),i=Xe(s,n),a=s.slice(i),l=s.slice(i+1);if(et(l)===r){const n=To(r,wo(e,o),Oe(e));bo(n)?((e,t,n,r)=>{const o=ko(e,Je(r));Ue(o).each((r=>{e.undoManager.transact((()=>{ze(t,r),L(n,He)}))}))})(e,t,a,n):((e,t,n,r)=>{const o=ko(e,Je(r));e.undoManager.transact((()=>{L(n,He),Ve(t,o)}))})(e,t,l,n)}})(e,t,o,n,r):Eo(e,t,n,r)}))})(t,o,e,r)}),r.logError)}))},jo=e=>{L(e,(e=>{const t=new tinymce.html.Node("span",1);t.attr("class","mce-shim"),t.attr("data-mce-bogus","1"),e.append(t),e.attr("contenteditable","false")}))},$o=e=>{L(e,(e=>{e.attr("contenteditable",null)}))},Do="media_url_resolver",Bo=[{code:404,message:"The specified url was not found."},{code:600,message:"The specified service did not respond correctly."},{code:601,message:"The specified service did not respond correctly."}],Fo=(e,t)=>_(Bo,(e=>e.code===t)).fold((()=>"Server didn't produce a valid result. ("+t+")"),(e=>e.message));var Uo;!function(e){e[e.Error=0]="Error",e[e.Value=1]="Value"}(Uo||(Uo={}));const zo=(e,t,n)=>e.stype===Uo.Error?t(e.serror):n(e.svalue),Vo=e=>({stype:Uo.Value,svalue:e}),qo=e=>({stype:Uo.Error,serror:e}),Ho=zo,Jo=e=>s(e)&&I(e).length>100?" removed due to size":JSON.stringify(e,null,2),Wo=(e,t)=>qo([{path:e,getErrorInfo:t}]),Go=e=>({extract:(t,n)=>{return r=e(n),o=e=>((e,t)=>Wo(e,m(t)))(t,e),r.stype===Uo.Error?o(r.serror):r;var r,o},toString:m("val")}),Ko=Go(Vo),Qo=m(Ko),Yo=(e,t,n)=>{switch(e.tag){case"field":return t(e.key,e.newKey,e.presence,e.prop);case"custom":return n(e.newKey,e.instantiator)}},Xo=(e,t,n,r)=>r(D(e,t).getOrThunk((()=>n(e)))),Zo=(e,t,n,r,o)=>{const s=e=>o.extract(t.concat([r]),e),i=e=>e.fold((()=>Vo(S.none())),(e=>{const n=o.extract(t.concat([r]),e);return s=n,i=S.some,s.stype===Uo.Value?{stype:Uo.Value,svalue:i(s.svalue)}:s;var s,i}));switch(e.tag){case"required":return((e,t,n,r)=>D(t,n).fold((()=>((e,t,n)=>Wo(e,(()=>'Could not find valid *required* value for "'+t+'" in '+Jo(n))))(e,n,t)),r))(t,n,r,s);case"defaultedThunk":return Xo(n,r,e.process,s);case"option":return((e,t,n)=>n(D(e,t)))(n,r,i);case"defaultedOptionThunk":return((e,t,n,r)=>r(D(e,t).map((t=>!0===t?n(e):t))))(n,r,e.process,i);case"mergeWithThunk":return Xo(n,r,m({}),(t=>{const r=Z(e.process(n),t);return s(r)}))}},es=e=>({extract:(t,n)=>((e,t,n)=>{const r={},o=[];for(const s of n)Yo(s,((n,s,i,a)=>{const l=Zo(i,e,t,n,a);Ho(l,(e=>{o.push(...e)}),(e=>{r[s]=e}))}),((e,n)=>{r[e]=n(t)}));return o.length>0?qo(o):Vo(r)})(t,n,e),toString:()=>{const t=T(e,(e=>Yo(e,((e,t,n,r)=>e+" -> "+r.toString()),((e,t)=>"state("+e+")"))));return"obj{\n"+t.join("\n")+"}"}}),ts=(e,t,n)=>{return r=((e,t,n)=>((e,t)=>e.stype===Uo.Error?{stype:Uo.Error,serror:t(e.serror)}:e)(t.extract([e],n),(e=>({input:n,errors:e}))))(e,t,n),zo(r,G.error,G.value);var r},ns=e=>"Errors: \n"+(e=>{const t=e.length>10?e.slice(0,10).concat([{path:[],getErrorInfo:m("... (only showing first ten failures)")}]):e;return T(t,(e=>"Failed path: ("+e.path.join(" > ")+")\n"+e.getErrorInfo()))})(e.errors).join("\n")+"\n\nInput object: "+Jo(e.input),rs=(e,t,n,r)=>({tag:"field",key:e,newKey:t,presence:n,prop:r}),os=e=>rs(e,e,{tag:"required",process:{}},Qo()),ss=()=>(new Date).getTime();var is;!function(e){e.JSON="json",e.Blob="blob",e.Text="text",e.FormData="formdata",e.MultipartFormData="multipart/form-data"}(is||(is={}));const as=e=>q((t=>{const n=new FileReader;n.onload=e=>{const n=e.target?e.target.result:"";t(n)},n.readAsText(e)})),ls=e=>{try{const t=JSON.parse(e);return G.value(t)}catch{return G.error("Response was not JSON.")}},cs=e=>H(e.response),us=(e,t)=>0===t.status?"Unknown HTTP error (possible cross-domain request)":`Could not load url ${e}: ${(e=>""===e.statusText?404===e.status?"Not Found":`Response code ${e.status}`:e.statusText)(t)}`,hs=(e,t)=>t.map((t=>{const n=(e=>{const t=[];return M(e,((e,n)=>{var r;t.push((r=e,encodeURIComponent(n)+"="+encodeURIComponent(r)))})),t})(t),r=((e,t,n=0,r)=>{const o=e.indexOf(t,n);return-1!==o&&(!!c(r)||o+t.length<=r)})(e,"?")?"&":"?";return n.length>0?e+r+n.join("&"):e})).getOr(e),ds=e=>X.nu((t=>{const n=new XMLHttpRequest;n.open(e.method,hs(e.url,S.from(e.query)),!0);const r=(e=>{const t=(n=e.body,S.from(n).bind((e=>{switch(e.type){case is.JSON:return S.some("application/json");case is.FormData:return S.some("application/x-www-form-urlencoded; charset=UTF-8");case is.MultipartFormData:return S.none();case is.Text:default:return S.some("text/plain")}})));var n;const r=!0===e.credentials?S.some(!0):S.none(),o=(e=>{switch(e){case is.Blob:return"application/octet-stream";case is.JSON:return"application/json, text/javascript";case is.Text:return"text/plain";default:return""}})(e.responseType)+", */*; q=0.01",s=void 0!==e.headers?e.headers:{};return{contentType:t,responseType:(e=>{switch(e){case is.JSON:return S.none();case is.Blob:return S.some("blob");case is.Text:return S.some("text");default:return S.none()}})(e.responseType),credentials:r,accept:o,headers:s,progress:d(e.progress)?S.some(e.progress):S.none()}})(e);((e,t)=>{t.contentType.each((t=>e.setRequestHeader("Content-Type",t))),e.setRequestHeader("Accept",t.accept),t.credentials.each((t=>e.withCredentials=t)),t.responseType.each((t=>e.responseType=t)),t.progress.each((t=>e.upload.addEventListener("progress",(e=>t(e.loaded,e.total))))),M(t.headers,((t,n)=>e.setRequestHeader(n,t)))})(n,r);const o=()=>{((e,t,n)=>((e,t)=>{switch(e){case is.JSON:return ls(t.response).fold((()=>cs(t)),H);case is.Blob:return(e=>S.from(e.response).map(as).getOr(H("no response content")))(t);case is.Text:default:return cs(t)}})(t,n).map((t=>({message:us(e,n),status:n.status,responseText:t}))))(e.url,e.responseType,n).get((e=>t(G.error(e))))};var s;n.onerror=o,n.onload=()=>{0!==n.status||te(e.url,"file:")?n.status<100||n.status>=400?o():((e,t)=>{const n=e=>X.error({message:e,status:t.status,responseText:t.responseText});switch(e){case is.JSON:return ls(t.response).fold(n,X.pure);case is.Blob:case is.Text:return X.pure(t.response);default:return n("unknown data type")}})(e.responseType,n).get(t):o()},(s=e.body,S.from(s).map((e=>e.type===is.JSON?JSON.stringify(e.data):e.type===is.FormData||e.type===is.MultipartFormData?(e=>{const t=new FormData;return M(e,((e,n)=>{t.append(n,e)})),t})(e.data):e.data))).fold((()=>n.send()),(e=>{n.send(e)}))})),ps=e=>{const t=e.responseText;return s(t)?t:e.message},fs=(e,t,n=ps)=>{const r=(e=>D(e,"tiny-api-key").orThunk((()=>D(e,"tinymce-api-key"))).orThunk((()=>D(e,"textbox-api-key"))).getOrUndefined())(t);return{execute:o=>{const s=j(o,(e=>l(e)?String(e):e)),i=((e,t)=>{const n=-1===e.indexOf("?")?"?":"&";return t?e+n+"apiKey="+encodeURIComponent(t):e})((a=s,e.replace(/\$\{([^{}]*)\}/g,((e,t)=>{const n=a[t];return(e=>{const t=typeof e;return"string"===t||"number"===t})(n)?n.toString():e}))),r);var a;const c=(u={url:i,responseType:is.JSON,credentials:!0,headers:t},ds({...u,method:"get",body:{type:is.Text,data:""}})).mapError(n);var u;return X.wrap(c)},cancelCurrent:f}},ms="iframely",gs="oembed",ys="fallback",ks="wikipedia",vs=e=>"["+e.join(", ")+"]",Ss=[ms,gs,ys],bs=(e,t,n)=>A(t,(t=>x(e,t)))?G.error("Embed response source: "+vs(e)+" contains more than one of "+vs(Ss)):G.value(n),Cs=es([os("url"),os("maxWidth"),(e=>rs(e,e,{tag:"defaultedThunk",process:m(!1)},Qo()))("fresh")]),ws=es([os("status_code"),os("sub_code"),os("msg")]),xs=es([os("html"),(As="rels",Ts=[rs("source","source",{tag:"required",process:{}},(Ls=e=>a(e)?(e=>x(e,ms)?bs(e,[gs,ys,ks],ms):x(e,gs)?bs(e,[ms,ys,ks],gs):x(e,ys)?bs(e,[ms,gs,ks],ys):x(e,ks)?bs(e,[ms,gs,ys],ks):G.error("Embed response source: "+vs(e)+" did not contain any of: "+vs(Ss)))(e):G.error("Sources was not an array: "+e),Go((e=>Ls(e).fold(qo,Vo)))))],rs(As,As,{tag:"required",process:{}},es(Ts)))]);var As,Ts,Ls,Es=e=>ts("EmbedResponse.failure",ws,e).fold((e=>G.error({code:m(600),subcode:m(0),msg:()=>ns(e)})),(e=>G.error({code:m(e.status_code),subcode:m(e.sub_code),msg:m(e.msg)}))),Os=e=>ts("EmbedResponse.success",xs,e).fold((e=>G.error({code:m(601),subcode:m(0),msg:()=>ns(e)})),(e=>G.value({recommended:()=>({html:m(e.html),source:m(e.rels.source)})})));const _s=(e,t,n)=>{const r=((e,t=36e5)=>{const n={},r=(e,t,r)=>{n[e]={result:t,timestamp:r}},o=(e,n)=>e-n<t,i=m(n);return s(e)&&(e=>{const t=ss();M(e,((e,n)=>{o(t,e.timestamp)&&r(n,e.result,e.timestamp)}))})(e),{set:r,get:(e,t)=>S.from(n[t]).filter((t=>o(e,t.timestamp))).map((e=>e.result)),dump:i}})(n),o=fs(e+"/1/embed?url=${url}&maxWidth=${maxWidth}",t);return{checkOne:(e,t,n=!1)=>{const s=ss(),i=((n,r,s,i,a)=>(a?S.none():r.get(i,s)).fold((()=>((n,r)=>{const s={url:encodeURIComponent(e),maxWidth:t,fresh:r},i=(a="ephox.media.service.one.ajax.service.get",l=Cs,c=s,ts(a,l,c).fold((e=>{throw new Error(ns(e))}),g));var a,l,c;return o.execute(i)})(0,a).mapResult((e=>(r.set(s,e,i),e)))),(e=>X.pure(e))))(0,r,t+"&"+e,s,n);return X.wrap(i.map((e=>e.fold(Es,Os))))},dumpCache:r.dump}};((e,t)=>{const{i18n:n=!0}=t;n&&tinymce.PluginManager.requireLangPack(e,"ar,bg-BG,ca,cs,da,de,el,es,eu,fa,fi,fr-FR,he-IL,hi,hr,hu-HU,id,it,ja,kk,ko-KR,ms,nb-NO,nl,pl,pt-BR,pt-PT,ro,ru,sk,sl-SI,sv-SE,th-TH,tr,uk,vi,zh-CN,zh-TW"),tinymce.PluginManager.add(e,Te(e,t))})("mediaembed",{setup:(e,t,n)=>{((e,t)=>{const n=e.options.register;n("mediaembed_content_css",{processor:"string",default:t+"/content.min.css"}),n("mediaembed_max_width",{processor:"number",default:650}),n("mediaembed_inline_styles",{processor:"boolean",default:!1}),n("mediaembed_service_url",{processor:"string",default:""}),n("mediaembed_api_key",{processor:"string"})})(e,t);const r=(e=>{let t;const n=t=>{const n=(e=>{if("string"==typeof e)return{message:e};{const t=e.code();return{message:Fo(e.msg(),t),code:t}}})(t);((e,t)=>{e.dispatch("MediaEmbedError",t)})(e,n),console.error(`Media embed error: ${n.message}`)};return{formatMessage:Fo,logDialogError:e=>{const r=e.msg();r!==t&&n(e),t=r},logError:n}})(e),o=(e=>{const t=(n=Pe(e),r=(e=>{var t;return null!==(t=e.options.get("mediaembed_api_key"))&&void 0!==t?t:e.options.get("api_key")})(e),_s(n,r?{"tinymce-api-key":r}:{}));var n,r;const o=(e,n,r)=>t.checkOne(e,n,r),s={};return{getOne:o,dumpCache:()=>{},getAndHandleResponse:(t,n,r)=>{void 0!==s[t]?s[t]=s[t].concat(n):(s[t]=[n],o(t.trim(),Oe(e)).get((e=>e.fold((e=>{r(e),delete s[t]}),(e=>{L(s[t],(t=>{t(e)})),delete s[t]})))))}}})(e);(e=>{e.on("click keyup touchend",(()=>{const t=e.selection.getNode();t&&e.dom.getAttrib(t,"data-ephox-embed-iri")&&e.dom.getAttrib(t,"data-mce-selected")&&t.setAttribute("data-mce-selected","2")})),e.on("PreInit",(()=>{e.parser.addAttributeFilter("data-ephox-embed-iri",jo),e.serializer.addAttributeFilter("data-ephox-embed-iri",$o)}))})(e),(e=>{const t=Ee(e);e.on("PreInit",(()=>{const n="mediaembed/content.css";tinymce.Resource.has(n)?e.dom.styleSheetLoader.loadRawCss(n,tinymce.Resource.get(n)):e.contentCSS.push(e.documentBaseURI.toAbsolute(t))}))})(e),e.on("SkinLoaded",(()=>{Pe(e).length>0?(((e,t,n,r)=>{e.on("NewBlock",(o=>{r.isInvalid()||Mo(o,e,t,n)}))})(e,o,r,n.enforcer),((e,t,n)=>{const r=e.options;r.isRegistered(Do)&&!r.isSet(Do)&&r.set(Do,((e,t,n)=>r=>new Promise(((o,s)=>{Io(r.url)||o({html:""}),t.getAndHandleResponse(r.url,(t=>{const n=t.recommended().html();o({html:Lo(e,r.url,n)})}),(e=>{n.logDialogError(e),s({msg:n.formatMessage(e.msg(),e.code())})}))})))(e,t,n))})(e,o,r)):r.logError("You need to specify the mediaembed_service_url setting")}))},i18n:!1})}();