Files
cms-gov/public/assets/js/tinymce/plugins/emoticons/plugin.min.js

1 line
6.5 KiB
JavaScript
Raw Normal View History

!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=t=>e=>t===e,o=e(null),n=e(void 0),s=t=>"function"==typeof t;const r=()=>{},a=()=>!1;class i{tag;value;static singletonNone=new i(!1);constructor(t,e){this.tag=t,this.value=e}static some(t){return new i(!0,t)}static none(){return i.singletonNone}fold(t,e){return this.tag?e(this.value):t()}isSome(){return this.tag}isNone(){return!this.tag}map(t){return this.tag?i.some(t(this.value)):i.none()}bind(t){return this.tag?t(this.value):i.none()}exists(t){return this.tag&&t(this.value)}forall(t){return!this.tag||t(this.value)}filter(t){return!this.tag||t(this.value)?this:i.none()}getOr(t){return this.tag?this.value:t}or(t){return this.tag?this:t}getOrThunk(t){return this.tag?this.value:t()}orThunk(t){return this.tag?this:t()}getOrDie(t){if(this.tag)return this.value;throw new Error(t??"Called getOrDie on None")}static from(t){return null==t?i.none():i.some(t)}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(t){this.tag&&t(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}Array.prototype.slice;const l=(t,e)=>{const o=t.length,n=new Array(o);for(let s=0;s<o;s++){const o=t[s];n[s]=e(o,s)}return n};s(Array.from)&&Array.from;const c=Object.keys,u=Object.hasOwnProperty,g=(t,e)=>{const o=c(t);for(let n=0,s=o.length;n<s;n++){const s=o[n];e(t[s],s)}},m=(t,e)=>u.call(t,e),d=t=>{let e=t;return{get:()=>e,set:t=>{e=t}}},h=(p=(t,e)=>e,(...t)=>{if(0===t.length)throw new Error("Can't merge zero objects");const e={};for(let o=0;o<t.length;o++){const n=t[o];for(const t in n)m(n,t)&&(e[t]=p(e[t],n[t]))}return e});var p;const y=()=>{const t=(t=>{const e=d(i.none()),o=()=>e.get().each(t);return{clear:()=>{o(),e.set(i.none())},isSet:()=>e.get().isSome(),get:()=>e.get(),set:t=>{o(),e.set(i.some(t))}}})(r);return{...t,on:e=>t.get().each(e)}},f=(t,e,o=0,s)=>{const r=t.indexOf(e,o);return-1!==r&&(!!n(s)||r+e.length<=s)};var v=tinymce.util.Tools.resolve("tinymce.Resource");const b=t=>e=>e.options.get(t),w=b("emoticons_database"),j=b("emoticons_database_url"),C=b("emoticons_database_id"),_=b("emoticons_append"),A=b("emoticons_images_url"),k="All",O={symbols:"Symbols",people:"People",animals_and_nature:"Animals and Nature",food_and_drink:"Food and Drink",activity:"Activity",travel_and_places:"Travel and Places",objects:"Objects",flags:"Flags",user:"User Defined"},x=(t,e)=>m(t,e)?t[e]:e,E=t=>{const e=_(t);return o=t=>({keywords:[],category:"user",...t}),((t,e)=>{const o={};return g(t,((t,n)=>{const s=e(t,n);o[s.k]=s.v})),o})(e,((t,e)=>({k:e,v:o(t)})));var o},L=(t,e)=>f(t.title.toLowerCase(),e)||(t=>{for(let n=0,s=t.length;n<s;n++)if(o=t[n],f(o.toLowerCase(),e))return!0;var o;return!1})(t.keywords),S=(t,e,o)=>{const n=[],s=e.toLowerCase(),r=o.fold((()=>a),(t=>e=>e>=t));for(let o=0;o<t.length&&(0!==e.length&&!L(t[o],s)||(n.push({value:t[o].char,text:t[o].title,icon:t[o].char}),!r(n.length)));o++);return n},N="pattern",T=(t,e)=>{const n={pattern:"",results:S(e.listAll(),"",i.some(300))},s=d(k),r=(t=>{let e=null;const n=()=>{o(e)||(clearTimeout(e),e=null)};return{cancel:n,throttle:(...o)=>{n(),e=setTimeout((()=>{e=null,t.apply(null,o)}),200)}}})((t=>{(t=>{const o=t.getData(),n=s.get(),r=e.listCategory(n),a=S(r,o[N],n===k?i.some(300):i.none());t.setData({results:a})})(t)})),a={label:"Search",type:"input",name:N},c={type:"collection",name:"results"},u=()=>({title:"Emojis",size:"normal",body:{type:"tabpanel",tabs:l(e.listCategories(),(t=>({title:t,name:t,items:[a,c]})))},initialData:n,onTabChange:(t,e)=>{s.set(e.newTabName),r.throttle(t)},onChange:r.throttle,onAction:(e,o)=>{"results"===o.name&&(((t,e)=>{t.insertContent(e)})(t,o.value),e.close())},buttons:[{type:"cancel",text:"Close",primary:!0}]}),g=t.windowManager.open(u());g.focus(N),e.hasLoaded()||(g.block("Loading emojis..."),e.waitForLoad().then((()=>{g.redial(u()),r.throttle(g),g.focus(N),g.unblock()})).catch((t=>{g.redial({title:"Emojis",body:{type:"panel",items:[{type:"alertbanner",level:"error",icon:"warning",text:"Could