phanpy-cz/assets/compose-IeRiPb7Z.js
2024-08-09 07:39:48 +02:00

27 lines
80 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var Lt=s=>{throw TypeError(s)};var rt=(s,e,n)=>e.has(s)||Lt("Cannot "+n);var B=(s,e,n)=>(rt(s,e,"read from private field"),n?n.call(s):e.get(s)),re=(s,e,n)=>e.has(s)?Lt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,n),de=(s,e,n,a)=>(rt(s,e,"write to private field"),a?a.call(s,n):e.set(s,n),n),G=(s,e,n)=>(rt(s,e,"access private method"),n);import{F as on,B as rn,_ as ln,a as _e,a8 as cn,w as zt,u as un,i as Ht,b as dn,I as K,y as St,h as Nt,a9 as hn,M as Ve,s as ke,a4 as pn,a0 as mn,n as gn,O as fn,X as Qe,c as vn,d as At,l as bn,x as yn}from"./fuse-4Bvpr1kU.js";import{s as le,a as bt,h as H,A as W,f as xn,al as Ut,d as Le,y as ee,m as wn,am as kn,T as Re,c as t,k as Ce,b as En,L as et,j as Fn,D as Cn,u as Ln,q as It,x as Wt}from"./useTitle-Mh8hVeGN.js";import{e as zn}from"./tinyld-light-PxOyhYWY.js";import"./index-CeOZgm-k.js";class Sn{constructor(e,n,{tabInsertsSuggestions:a,defaultFirstOption:r}={}){this.input=e,this.list=n,this.tabInsertsSuggestions=a??!0,this.defaultFirstOption=r??!1,this.isComposing=!1,n.id||(n.id=`combobox-${Math.random().toString().slice(2,6)}`),this.ctrlBindings=!!navigator.userAgent.match(/Macintosh/),this.keyboardEventHandler=m=>An(m,this),this.compositionEventHandler=m=>Mn(m,this),this.inputHandler=this.clearSelection.bind(this),e.setAttribute("role","combobox"),e.setAttribute("aria-controls",n.id),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("aria-haspopup","listbox")}destroy(){this.clearSelection(),this.stop(),this.input.removeAttribute("role"),this.input.removeAttribute("aria-controls"),this.input.removeAttribute("aria-expanded"),this.input.removeAttribute("aria-autocomplete"),this.input.removeAttribute("aria-haspopup")}start(){this.input.setAttribute("aria-expanded","true"),this.input.addEventListener("compositionstart",this.compositionEventHandler),this.input.addEventListener("compositionend",this.compositionEventHandler),this.input.addEventListener("input",this.inputHandler),this.input.addEventListener("keydown",this.keyboardEventHandler),this.list.addEventListener("click",Mt),this.indicateDefaultOption()}stop(){this.clearSelection(),this.input.setAttribute("aria-expanded","false"),this.input.removeEventListener("compositionstart",this.compositionEventHandler),this.input.removeEventListener("compositionend",this.compositionEventHandler),this.input.removeEventListener("input",this.inputHandler),this.input.removeEventListener("keydown",this.keyboardEventHandler),this.list.removeEventListener("click",Mt)}indicateDefaultOption(){var e;this.defaultFirstOption&&((e=Array.from(this.list.querySelectorAll('[role="option"]:not([aria-disabled="true"])')).filter(lt)[0])===null||e===void 0||e.setAttribute("data-combobox-option-default","true"))}navigate(e=1){const n=Array.from(this.list.querySelectorAll('[aria-selected="true"]')).filter(lt)[0],a=Array.from(this.list.querySelectorAll('[role="option"]')).filter(lt),r=a.indexOf(n);if(r===a.length-1&&e===1||r===0&&e===-1){this.clearSelection(),this.input.focus();return}let m=e===1?0:a.length-1;if(n&&r>=0){const v=r+e;v>=0&&v<a.length&&(m=v)}const u=a[m];if(u)for(const v of a)v.removeAttribute("data-combobox-option-default"),u===v?(this.input.setAttribute("aria-activedescendant",u.id),u.setAttribute("aria-selected","true"),$n(this.list,u)):v.removeAttribute("aria-selected")}clearSelection(){this.input.removeAttribute("aria-activedescendant");for(const e of this.list.querySelectorAll('[aria-selected="true"]'))e.removeAttribute("aria-selected");this.indicateDefaultOption()}}function An(s,e){if(!(s.shiftKey||s.metaKey||s.altKey)&&!(!e.ctrlBindings&&s.ctrlKey)&&!e.isComposing)switch(s.key){case"Enter":$t(e.input,e.list)&&s.preventDefault();break;case"Tab":e.tabInsertsSuggestions&&$t(e.input,e.list)&&s.preventDefault();break;case"Escape":e.clearSelection();break;case"ArrowDown":e.navigate(1),s.preventDefault();break;case"ArrowUp":e.navigate(-1),s.preventDefault();break;case"n":e.ctrlBindings&&s.ctrlKey&&(e.navigate(1),s.preventDefault());break;case"p":e.ctrlBindings&&s.ctrlKey&&(e.navigate(-1),s.preventDefault());break;default:if(s.ctrlKey)break;e.clearSelection()}}function Mt(s){if(!(s.target instanceof Element))return;const e=s.target.closest('[role="option"]');e&&e.getAttribute("aria-disabled")!=="true"&&In(e)}function $t(s,e){const n=e.querySelector('[aria-selected="true"], [data-combobox-option-default="true"]');return n?(n.getAttribute("aria-disabled")==="true"||n.click(),!0):!1}function In(s){s.dispatchEvent(new CustomEvent("combobox-commit",{bubbles:!0}))}function lt(s){return!s.hidden&&!(s instanceof HTMLInputElement&&s.type==="hidden")&&(s.offsetWidth>0||s.offsetHeight>0)}function Mn(s,e){e.isComposing=s.type==="compositionstart",document.getElementById(e.input.getAttribute("aria-controls")||"")&&e.clearSelection()}function $n(s,e){Tn(s,e)||(s.scrollTop=e.offsetTop)}function Tn(s,e){const n=s.scrollTop,a=n+s.clientHeight,r=e.offsetTop,m=r+e.clientHeight;return r>=n&&m<=a}const Bn=/\s|\(|\[/;function _n(s,e,n,{multiWord:a,lookBackIndex:r,lastMatchPosition:m}={multiWord:!1,lookBackIndex:0,lastMatchPosition:null}){let u=s.lastIndexOf(e,n-1);if(u===-1||u<r)return;if(a){if(m!=null){if(m===u)return;u=m-e.length}if(s[u+1]===" "&&n>=u+e.length+1||s.lastIndexOf(`
`,n-1)>u||s.lastIndexOf(".",n-1)>u)return}else if(s.lastIndexOf(" ",n-1)>u)return;const v=s[u-1];return v&&!Bn.test(v)?void 0:{text:s.substring(u+e.length,n),position:u+e.length}}class Rn extends HTMLElement{}class Dn extends Event{constructor(){super("update")}}const ct=new WeakMap;var De,je,Ee,fe,Y,Te,ze,Se,pt,Ae,Ge,Ye,Ze,Pe,Fe;const xt=class xt extends Rn{constructor(n){super();re(this,Y);re(this,De,new MutationObserver(()=>G(this,Y,Ye).call(this)));re(this,je,new ResizeObserver(()=>G(this,Y,Ge).call(this)));re(this,Ee);re(this,fe);re(this,ze,0);re(this,Se,0);re(this,Ae,!1);re(this,Pe,()=>G(this,Y,Ze).call(this));re(this,Fe,n=>{G(this,Y,Te).call(this,a=>{(n.target===document||n.target===window||n.target instanceof Node&&n.target.contains(a))&&G(this,Y,Ge).call(this)})});de(this,Ee,new WeakRef(n)),de(this,fe,document.createElement("div")),B(this,fe).style.position="absolute",B(this,fe).style.pointerEvents="none",n.after(B(this,fe)),B(this,fe).appendChild(this)}static for(n){const a=ct.get(n)??new xt(n);return ct.set(n,a),a}forceUpdate(){G(this,Y,Ye).call(this),G(this,Y,Ze).call(this)}connectedCallback(){const n=B(this,Ee).deref();if(!n)return this.remove();this.style.pointerEvents="none",this.style.userSelect="none",this.style.overflow="hidden",this.style.display="block",this.style.visibility="hidden",n instanceof HTMLTextAreaElement?(this.style.whiteSpace="pre-wrap",this.style.wordWrap="break-word"):(this.style.whiteSpace="nowrap",this.style.display="table-cell",this.style.verticalAlign="middle"),this.setAttribute("aria-hidden","true"),G(this,Y,Ye).call(this),G(this,Y,Ze).call(this),B(this,De).observe(n,{attributeFilter:["style","dir"]}),B(this,je).observe(n),document.addEventListener("scroll",B(this,Fe),{capture:!0}),window.addEventListener("resize",B(this,Fe),{capture:!0}),n.addEventListener("input",B(this,Pe),{capture:!0})}disconnectedCallback(){B(this,fe).remove(),B(this,De).disconnect(),B(this,je).disconnect(),document.removeEventListener("scroll",B(this,Fe),{capture:!0}),window.removeEventListener("resize",B(this,Fe),{capture:!0});const n=B(this,Ee).deref();n&&(n.removeEventListener("input",B(this,Pe),{capture:!0}),ct.delete(n))}};De=new WeakMap,je=new WeakMap,Ee=new WeakMap,fe=new WeakMap,Y=new WeakSet,Te=function(n){const a=B(this,Ee).deref();return a?n(a):this.remove()},ze=new WeakMap,Se=new WeakMap,pt=function(){G(this,Y,Te).call(this,n=>{const a=window.getComputedStyle(n);this.style.height=a.height,this.style.width=a.width,n.clientHeight!==this.clientHeight&&(this.style.height=`calc(${a.height} + ${n.clientHeight-this.clientHeight}px)`),n.clientWidth!==this.clientWidth&&(this.style.width=`calc(${a.width} + ${n.clientWidth-this.clientWidth}px)`);const r=n.getBoundingClientRect(),m=this.getBoundingClientRect();de(this,ze,B(this,ze)+r.left-m.left),de(this,Se,B(this,Se)+r.top-m.top),this.style.transform=`translate(${B(this,ze)}px, ${B(this,Se)}px)`,this.scrollTop=n.scrollTop,this.scrollLeft=n.scrollLeft,this.dispatchEvent(new Dn)})},Ae=new WeakMap,Ge=function(){B(this,Ae)||(de(this,Ae,!0),requestAnimationFrame(()=>{G(this,Y,pt).call(this),de(this,Ae,!1)}))},Ye=function(){G(this,Y,Te).call(this,n=>{const a=window.getComputedStyle(n);for(const r of jn)this.style[r]=a[r];G(this,Y,Ge).call(this)})},Ze=function(){G(this,Y,Te).call(this,n=>{this.textContent=n.value,G(this,Y,pt).call(this)})},Pe=new WeakMap,Fe=new WeakMap;let Je=xt;const jn=["direction","writingMode","unicodeBidi","textOrientation","boxSizing","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","MozTabSize"];try{customElements.define("input-style-clone",Je)}catch(s){if(!(s instanceof DOMException&&s.name==="NotSupportedError"))throw s}var pe,Ie,Me,ce,gt,qt,ft,Be;const Xe=class Xe{constructor(e,n=0,a=n){re(this,ce);re(this,pe);re(this,Ie);re(this,Me);de(this,pe,e),de(this,Ie,n),de(this,Me,a)}static fromSelection(e){const{selectionStart:n,selectionEnd:a}=e;return new Xe(e,n??void 0,a??void 0)}get collapsed(){return this.startOffset===this.endOffset}get commonAncestorContainer(){return B(this,pe)}get endContainer(){return B(this,pe)}get startContainer(){return B(this,pe)}get startOffset(){return B(this,Ie)}get endOffset(){return B(this,Me)}setStartOffset(e){de(this,Ie,G(this,ce,ft).call(this,e))}setEndOffset(e){de(this,Me,G(this,ce,ft).call(this,e))}collapse(e=!1){e?this.setEndOffset(this.startOffset):this.setStartOffset(this.endOffset)}cloneContents(){return G(this,ce,Be).call(this).cloneContents()}cloneRange(){return new Xe(B(this,pe),this.startOffset,this.endOffset)}getBoundingClientRect(){return G(this,ce,Be).call(this).getBoundingClientRect()}getClientRects(){return G(this,ce,Be).call(this).getClientRects()}toString(){return G(this,ce,Be).call(this).toString()}getStyleClone(){return B(this,ce,gt)}};pe=new WeakMap,Ie=new WeakMap,Me=new WeakMap,ce=new WeakSet,gt=function(){return Je.for(B(this,pe))},qt=function(){return B(this,ce,gt)},ft=function(e){return Math.max(0,Math.min(e,B(this,pe).value.length))},Be=function(){const e=document.createRange(),n=B(this,ce,qt).childNodes[0];return n&&(e.setStart(n,this.startOffset),e.setEnd(n,this.endOffset)),e};let mt=Xe;const qe=new WeakMap;class Pn{constructor(e,n){this.expander=e,this.input=n,this.combobox=null,this.menu=null,this.match=null,this.justPasted=!1,this.lookBackIndex=0,this.oninput=this.onInput.bind(this),this.onpaste=this.onPaste.bind(this),this.onkeydown=this.onKeydown.bind(this),this.oncommit=this.onCommit.bind(this),this.onmousedown=this.onMousedown.bind(this),this.onblur=this.onBlur.bind(this),this.interactingWithList=!1,n.addEventListener("paste",this.onpaste),n.addEventListener("input",this.oninput),n.addEventListener("keydown",this.onkeydown),n.addEventListener("blur",this.onblur)}destroy(){this.input.removeEventListener("paste",this.onpaste),this.input.removeEventListener("input",this.oninput),this.input.removeEventListener("keydown",this.onkeydown),this.input.removeEventListener("blur",this.onblur)}dismissMenu(){this.deactivate()&&(this.lookBackIndex=this.input.selectionEnd||this.lookBackIndex)}activate(e,n){var a,r;this.input!==document.activeElement&&this.input!==((r=(a=document.activeElement)===null||a===void 0?void 0:a.shadowRoot)===null||r===void 0?void 0:r.activeElement)||(this.deactivate(),this.menu=n,n.id||(n.id=`text-expander-${Math.floor(Math.random()*1e5).toString()}`),this.expander.append(n),this.combobox=new Sn(this.input,n),this.expander.dispatchEvent(new Event("text-expander-activate")),this.positionMenu(n,e.position),this.combobox.start(),n.addEventListener("combobox-commit",this.oncommit),n.addEventListener("mousedown",this.onmousedown),this.combobox.navigate(1))}positionMenu(e,n){const a=new mt(this.input,n).getBoundingClientRect(),r={left:a.left,top:a.top+a.height},m=e.getBoundingClientRect(),u={left:r.left-m.left,top:r.top-m.top};if(u.left!==0||u.top!==0){const v=getComputedStyle(e);e.style.left=v.left?`calc(${v.left} + ${u.left}px)`:`${u.left}px`,e.style.top=v.top?`calc(${v.top} + ${u.top}px)`:`${u.top}px`}}deactivate(){const e=this.menu;return!e||!this.combobox?!1:(this.expander.dispatchEvent(new Event("text-expander-deactivate")),this.menu=null,e.removeEventListener("combobox-commit",this.oncommit),e.removeEventListener("mousedown",this.onmousedown),this.combobox.destroy(),this.combobox=null,e.remove(),!0)}onCommit({target:e}){var n;const a=e;if(!(a instanceof HTMLElement)||!this.combobox)return;const r=this.match;if(!r)return;const m=this.input.value.substring(0,r.position-r.key.length),u=this.input.value.substring(r.position+r.text.length),v={item:a,key:r.key,value:null,continue:!1};if(!this.expander.dispatchEvent(new CustomEvent("text-expander-value",{cancelable:!0,detail:v}))||!v.value)return;let R=(n=this.expander.getAttribute("suffix"))!==null&&n!==void 0?n:" ";v.continue&&(R="");const C=`${v.value}${R}`;this.input.value=m+C+u;const k=m.length+C.length;this.deactivate(),this.input.focus({preventScroll:!0}),this.input.selectionStart=k,this.input.selectionEnd=k,v.continue||(this.lookBackIndex=k,this.match=null),this.expander.dispatchEvent(new CustomEvent("text-expander-committed",{cancelable:!1,detail:{input:this.input}}))}onBlur(){if(this.interactingWithList){this.interactingWithList=!1;return}this.deactivate()}onPaste(){this.justPasted=!0}async onInput(){if(this.justPasted){this.justPasted=!1;return}const e=this.findMatch();if(e){this.match=e;const n=await this.notifyProviders(e);if(!this.match)return;n?this.activate(e,n):this.deactivate()}else this.match=null,this.deactivate()}findMatch(){const e=this.input.selectionEnd||0,n=this.input.value;e<=this.lookBackIndex&&(this.lookBackIndex=e-1);for(const{key:a,multiWord:r}of this.expander.keys){const m=_n(n,a,e,{multiWord:r,lookBackIndex:this.lookBackIndex,lastMatchPosition:this.match?this.match.position:null});if(m)return{text:m.text,key:a,position:m.position}}}async notifyProviders(e){const n=[],a=v=>n.push(v);return this.expander.dispatchEvent(new CustomEvent("text-expander-change",{cancelable:!0,detail:{provide:a,text:e.text,key:e.key}}))?(await Promise.all(n)).filter(v=>v.matched).map(v=>v.fragment)[0]:void 0}onMousedown(){this.interactingWithList=!0}onKeydown(e){e.key==="Escape"&&(this.match=null,this.deactivate()&&(this.lookBackIndex=this.input.selectionEnd||this.lookBackIndex,e.stopImmediatePropagation(),e.preventDefault()))}}class Tt extends HTMLElement{get keys(){const e=this.getAttribute("keys"),n=e?e.split(" "):[],a=this.getAttribute("multiword"),r=a?a.split(" "):[],m=r.length===0&&this.hasAttribute("multiword");return n.map(u=>({key:u,multiWord:m||r.includes(u)}))}connectedCallback(){const e=this.querySelector('input[type="text"], textarea');if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))return;const n=new Pn(this,e);qe.set(this,n)}disconnectedCallback(){const e=qe.get(this);e&&(e.destroy(),qe.delete(this))}dismiss(){const e=qe.get(this);e&&e.dismissMenu()}}window.customElements.get("text-expander")||(window.TextExpanderElement=Tt,window.customElements.define("text-expander",Tt));function On({onlyFirst:s=!1}={}){const e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,s?void 0:"g")}const Hn=On();function Nn(s){if(typeof s!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof s}\``);return s.replace(Hn,"")}const Un=new Intl.Segmenter;function Bt(s,{countAnsiEscapeCodes:e=!1}={}){if(s===""||(e||(s=Nn(s)),s===""))return 0;let n=0;for(const a of Un.segment(s))n++;return n}const Wn="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.0'%20viewBox='0%200%20641%20223'%3e%3cpath%20fill='%23aaa'%20d='M86%20214c-9-1-17-4-24-8l-6-3-5-5-5-4-4-6-4-6-3-8-2-8v-27l2-9%203-9%204-6%204-6%205-5%205-5%207-3%206-4%207-2%207-2%2012-1h12l7%201%208%202%207%204%207%203%205%205%205%204-10%2010-10%209-4-3-10-5-5-1H88l-5%202-6%203-3%204-4%204-2%205-2%206v6l-1%207%201%207%202%207%203%205%202%204%204%203%204%203%205%202%206%202h9l10-1%205-2%206-3v-16H91v-27h59v54l-1%203-2%203-5%204-4%204-5%203-5%202-8%202-8%202-10%201H92l-6-1zm266-62V91h34v46h44V91h34v121h-34v-46h-44v46h-34v-61zm-182-1V90h34v121h-34v-60zm59-1V90h35l36%201%205%202c3%200%208%202%2010%204l5%202%204%205%205%204%203%207%203%207%201%2013v13l-4%206-3%207-4%204-5%205-5%202-5%203-6%202-5%201-18%201h-18v32h-34v-61zm67-2%203-2%202-4%202-5v-5l-2-4-2-4-3-2-3-3h-30v31h30l3-2zm226%2039v-24l-8-12-18-28a1751%201751%200%200%200-20-31v-2h39l7%2012%2012%2021%206%209%2013-21%2013-21h38v2l-41%2061-7%2010v48h-34v-24zM109%2066l-4-1-5-5-5-4-1-5-3-9v-5l1-5c2-7%203-10%208-15l4-4%207-2%207-2h7l6%201%205%202%205%202%203%204%204%203%202%206%202%205v13l-2%205-2%206-4%204-3%203-5%202-4%202-9%201h-9l-5-2zm22-11%204-2%203-4%202-5V34l-2-4-2-4-3-2-4-3-5-1h-6l-4%202-5%202-2%204-3%205-1%203v4l1%205%202%205%202%202%205%203%204%202h10l4-2zM37%2039V11h33l3%201%203%202%204%203%203%203%201%205%201%204v5l-1%204-3%204-3%205-4%201-3%202-11%201H49v16H37V39zm31%200%203-2%201-2%201-2v-4l-1-3-3-2-2-2H49v18h15l4-1zm107%2025a512%20512%200%200%200-19-53h14l4%2014%206%2019%201%204%201-1%207-19%205-17h9l6%2019%207%2018v-1l2-6%205-17%204-13h14v1l-4%2012-16%2041v2h-5l-5-1-6-15-6-15-1%201-3%207-6%2015-2%208h-11l-1-3zm74-25V11h42v11h-29v2l-1%205v4h29v11h-28v11h2l15%201h13v11h-43V39zm55%200V11h33l5%203%205%202%202%204%202%205v10l-2%203-1%204-5%203-5%203%205%205%208%2010%203%204h-14l-7-9-8-10h-9v19h-12V39zm33-3%202-3v-6l-3-3-2-3h-18v16h1v1h17l2-2zm26%203V11h42v11h-29l-1%206v5h29v11h-28v5l-1%205%201%201v1h30v11h-43V39zm54%200V11h17l18%201%204%202%205%203%202%204%203%204%202%206%201%206v5c-1%206-3%2012-6%2015l-3%204-5%203-5%202-17%201h-16V39zm33%2014%205-5%202-3v-6l-1-6-1-3-1-3-4-3-3-2h-5l-6-1-3%201h-3v34h9l8-1%203-2zm50-14V11h34l5%202%204%202%202%203%202%203v9l-2%202-3%204-1%201%203%203%203%204%201%203%201%204-1%204-1%204-3%203-3%203-5%201-5%201h-31V39zm34%2015%202-1v-6l-2-2-2-2h-20v13h20l2-2zm-3-22%204-2v-6l-2-1-2-2h-19v12h16l4-1zm42%2024V45l-6-9-11-17-5-8h15l4%208%207%2011%202%203%207-11%207-11h14l-11%2016-11%2017v23h-12V56z'/%3e%3c/svg%3e",yt=[["aa","Afar","Afaraf"],["ab","Abkhaz","аҧсуа бызшәа"],["ae","Avestan","avesta"],["af","Afrikaans","Afrikaans"],["ak","Akan","Akan"],["am","Amharic","አማርኛ"],["an","Aragonese","aragonés"],["ar","Arabic","اللغة العربية"],["as","Assamese","অসমীয়া"],["av","Avaric","авар мацӀ"],["ay","Aymara","aymar aru"],["az","Azerbaijani","azərbaycan dili"],["ba","Bashkir","башҡорт теле"],["be","Belarusian","беларуская мова"],["bg","Bulgarian","български език"],["bh","Bihari","भोजपुरी"],["bi","Bislama","Bislama"],["bm","Bambara","bamanankan"],["bn","Bengali","বাংলা"],["bo","Tibetan","བོད་ཡིག"],["br","Breton","brezhoneg"],["bs","Bosnian","bosanski jezik"],["ca","Catalan","Català"],["ce","Chechen","нохчийн мотт"],["ch","Chamorro","Chamoru"],["co","Corsican","corsu"],["cr","Cree","ᓀᐦᐃᔭᐍᐏᐣ"],["cs","Czech","čeština"],["cu","Old Church Slavonic","ѩзыкъ словѣньскъ"],["cv","Chuvash","чӑваш чӗлхи"],["cy","Welsh","Cymraeg"],["da","Danish","dansk"],["de","German","Deutsch"],["dv","Divehi","Dhivehi"],["dz","Dzongkha","རྫོང་ཁ"],["ee","Ewe","Eʋegbe"],["el","Greek","Ελληνικά"],["en","English","English"],["eo","Esperanto","Esperanto"],["es","Spanish","Español"],["et","Estonian","eesti"],["eu","Basque","euskara"],["fa","Persian","فارسی"],["ff","Fula","Fulfulde"],["fi","Finnish","suomi"],["fj","Fijian","Vakaviti"],["fo","Faroese","føroyskt"],["fr","French","Français"],["fy","Western Frisian","Frysk"],["ga","Irish","Gaeilge"],["gd","Scottish Gaelic","Gàidhlig"],["gl","Galician","galego"],["gu","Gujarati","ગુજરાતી"],["gv","Manx","Gaelg"],["ha","Hausa","هَوُسَ"],["he","Hebrew","עברית"],["hi","Hindi","हिन्दी"],["ho","Hiri Motu","Hiri Motu"],["hr","Croatian","Hrvatski"],["ht","Haitian","Kreyòl ayisyen"],["hu","Hungarian","magyar"],["hy","Armenian","Հայերեն"],["hz","Herero","Otjiherero"],["ia","Interlingua","Interlingua"],["id","Indonesian","Bahasa Indonesia"],["ie","Interlingue","Interlingue"],["ig","Igbo","Asụsụ Igbo"],["ii","Nuosu","ꆈꌠ꒿ Nuosuhxop"],["ik","Inupiaq","Iñupiaq"],["io","Ido","Ido"],["is","Icelandic","Íslenska"],["it","Italian","Italiano"],["iu","Inuktitut","ᐃᓄᒃᑎᑐᑦ"],["ja","Japanese","日本語"],["jv","Javanese","basa Jawa"],["ka","Georgian","ქართული"],["kg","Kongo","Kikongo"],["ki","Kikuyu","Gĩkũyũ"],["kj","Kwanyama","Kuanyama"],["kk","Kazakh","қазақ тілі"],["kl","Kalaallisut","kalaallisut"],["km","Khmer","ខេមរភាសា"],["kn","Kannada","ಕನ್ನಡ"],["ko","Korean","한국어"],["kr","Kanuri","Kanuri"],["ks","Kashmiri","कश्मीरी"],["ku","Kurmanji (Kurdish)","Kurmancî"],["kv","Komi","коми кыв"],["kw","Cornish","Kernewek"],["ky","Kyrgyz","Кыргызча"],["la","Latin","latine"],["lb","Luxembourgish","Lëtzebuergesch"],["lg","Ganda","Luganda"],["li","Limburgish","Limburgs"],["ln","Lingala","Lingála"],["lo","Lao","ລາວ"],["lt","Lithuanian","lietuvių kalba"],["lu","Luba-Katanga","Tshiluba"],["lv","Latvian","latviešu valoda"],["mg","Malagasy","fiteny malagasy"],["mh","Marshallese","Kajin M̧ajeļ"],["mi","Māori","te reo Māori"],["mk","Macedonian","македонски јазик"],["ml","Malayalam","മലയാളം"],["mn","Mongolian","Монгол хэл"],["mr","Marathi","मराठी"],["ms","Malay","Bahasa Melayu"],["mt","Maltese","Malti"],["my","Burmese","ဗမာစာ"],["na","Nauru","Ekakairũ Naoero"],["nb","Norwegian Bokmål","Norsk bokmål"],["nd","Northern Ndebele","isiNdebele"],["ne","Nepali","नेपाली"],["ng","Ndonga","Owambo"],["nl","Dutch","Nederlands"],["nn","Norwegian Nynorsk","Norsk Nynorsk"],["no","Norwegian","Norsk"],["nr","Southern Ndebele","isiNdebele"],["nv","Navajo","Diné bizaad"],["ny","Chichewa","chiCheŵa"],["oc","Occitan","occitan"],["oj","Ojibwe","ᐊᓂᔑᓈᐯᒧᐎᓐ"],["om","Oromo","Afaan Oromoo"],["or","Oriya","ଓଡ଼ିଆ"],["os","Ossetian","ирон æвзаг"],["pa","Panjabi","ਪੰਜਾਬੀ"],["pi","Pāli","पाऴि"],["pl","Polish","Polski"],["ps","Pashto","پښتو"],["pt","Portuguese","Português"],["qu","Quechua","Runa Simi"],["rm","Romansh","rumantsch grischun"],["rn","Kirundi","Ikirundi"],["ro","Romanian","Română"],["ru","Russian","Русский"],["rw","Kinyarwanda","Ikinyarwanda"],["sa","Sanskrit","संस्कृतम्"],["sc","Sardinian","sardu"],["sd","Sindhi","सिन्धी"],["se","Northern Sami","Davvisámegiella"],["sg","Sango","yângâ tî sängö"],["si","Sinhala","සිංහල"],["sk","Slovak","slovenčina"],["sl","Slovenian","slovenščina"],["sn","Shona","chiShona"],["so","Somali","Soomaaliga"],["sq","Albanian","Shqip"],["sr","Serbian","српски језик"],["ss","Swati","SiSwati"],["st","Southern Sotho","Sesotho"],["su","Sundanese","Basa Sunda"],["sv","Swedish","Svenska"],["sw","Swahili","Kiswahili"],["ta","Tamil","தமிழ்"],["te","Telugu","తెలుగు"],["tg","Tajik","тоҷикӣ"],["th","Thai","ไทย"],["ti","Tigrinya","ትግርኛ"],["tk","Turkmen","Türkmen"],["tl","Tagalog","Wikang Tagalog"],["tn","Tswana","Setswana"],["to","Tonga","faka Tonga"],["tr","Turkish","Türkçe"],["ts","Tsonga","Xitsonga"],["tt","Tatar","татар теле"],["tw","Twi","Twi"],["ty","Tahitian","Reo Tahiti"],["ug","Uyghur","ئۇيغۇرچە‎"],["uk","Ukrainian","Українська"],["ur","Urdu","اردو"],["uz","Uzbek","Ўзбек"],["ve","Venda","Tshivenḓa"],["vi","Vietnamese","Tiếng Việt"],["vo","Volapük","Volapük"],["wa","Walloon","walon"],["wo","Wolof","Wollof"],["xh","Xhosa","isiXhosa"],["yi","Yiddish","ייִדיש"],["yo","Yoruba","Yorùbá"],["za","Zhuang","Saɯ cueŋƅ"],["zh","Chinese","中文"],["zu","Zulu","isiZulu"],["zh-CN","Chinese (China)","简体中文"],["zh-HK","Chinese (Hong Kong)","繁體中文(香港)"],["zh-TW","Chinese (Taiwan)","繁體中文(臺灣)"],["zh-YUE","Cantonese","廣東話"],["ast","Asturian","Asturianu"],["chr","Cherokee","ᏣᎳᎩ ᎦᏬᏂᎯᏍᏗ"],["ckb","Sorani (Kurdish)","سۆرانی"],["cnr","Montenegrin","crnogorski"],["jbo","Lojban","la .lojban."],["kab","Kabyle","Taqbaylit"],["ldn","Láadan","Láadan"],["lfn","Lingua Franca Nova","lingua franca nova"],["sco","Scots","Scots"],["sma","Southern Sami","Åarjelsaemien Gïele"],["smj","Lule Sami","Julevsámegiella"],["szl","Silesian","ślůnsko godka"],["tok","Toki Pona","toki pona"],["xal","Kalmyk","Хальмг келн"],["zba","Balaibalan","باليبلن"],["zgh","Standard Moroccan Tamazight","ⵜⴰⵎⴰⵣⵉⵖⵜ"]],qn="(((?:[^A-Za-z0-9@$#\\uFFFE\\uFEFF\\uFFFF]|[\\u202A-\\u202E\\u061C\\u200E\\u200F\\u2066\\u2067\\u2068\\u2069]|^))((https?:\\/\\/)((?:(?:(?:[^/\\!'#%&'\\(\\)*\\+,\\\\\\-\\.\\/:;<=>\\?@\\[\\]\\^_{|}~\\$//\\x09-\\x0D\\x20\\x85\\xA0\\u1680\\u180E\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000//\\uFFFE\\uFEFF\\uFFFF//\\u202A-\\u202E\\u061C\\u200E\\u200F\\u2066\\u2067\\u2068\\u2069/](?:[_-]|[^/\\!'#%&'\\(\\)*\\+,\\\\\\-\\.\\/:;<=>\\?@\\[\\]\\^_{|}~\\$//\\x09-\\x0D\\x20\\x85\\xA0\\u1680\\u180E\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000//\\uFFFE\\uFEFF\\uFFFF//\\u202A-\\u202E\\u061C\\u200E\\u200F\\u2066\\u2067\\u2068\\u2069/])*)?[^/\\!'#%&'\\(\\)*\\+,\\\\\\-\\.\\/:;<=>\\?@\\[\\]\\^_{|}~\\$//\\x09-\\x0D\\x20\\x85\\xA0\\u1680\\u180E\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000//\\uFFFE\\uFEFF\\uFFFF//\\u202A-\\u202E\\u061C\\u200E\\u200F\\u2066\\u2067\\u2068\\u2069/]\\.)*(?:(?:[^/\\!'#%&'\\(\\)*\\+,\\\\\\-\\.\\/:;<=>\\?@\\[\\]\\^_{|}~\\$//\\x09-\\x0D\\x20\\x85\\xA0\\u1680\\u180E\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000//\\uFFFE\\uFEFF\\uFFFF//\\u202A-\\u202E\\u061C\\u200E\\u200F\\u2066\\u2067\\u2068\\u2069/](?:-|[^/\\!'#%&'\\(\\)*\\+,\\\\\\-\\.\\/:;<=>\\?@\\[\\]\\^_{|}~\\$//\\x09-\\x0D\\x20\\x85\\xA0\\u1680\\u180E\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000//\\uFFFE\\uFEFF\\uFFFF//\\u202A-\\u202E\\u061C\\u200E\\u200F\\u2066\\u2067\\u2068\\u2069/])*)?[^/\\!'#%&'\\(\\)*\\+,\\\\\\-\\.\\/:;<=>\\?@\\[\\]\\^_{|}~\\$//\\x09-\\x0D\\x20\\x85\\xA0\\u1680\\u180E\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000//\\uFFFE\\uFEFF\\uFFFF//\\u202A-\\u202E\\u061C\\u200E\\u200F\\u2066\\u2067\\u2068\\u2069/]\\.)(?:(?:(?:삼성|닷컴|닷넷|香格里拉|餐厅|食品|飞利浦|電訊盈科|集团|通販|购物|谷歌|诺基亚|联通|网络|网站|网店|网址|组织机构|移动|珠宝|点看|游戏|淡马锡|机构|書籍|时尚|新闻|政府|政务|招聘|手表|手机|我爱你|慈善|微博|广东|工行|家電|娱乐|天主教|大拿|大众汽车|在线|嘉里大酒店|嘉里|商标|商店|商城|公益|公司|八卦|健康|信息|佛山|企业|中文网|中信|世界|ポイント|ファッション|セール|ストア|コム|グーグル|クラウド|みんな|คอม|संगठन|नेट|कॉम|همراه|موقع|موبايلي|كوم|كاثوليك|عرب|شبكة|بيتك|بازار|العليان|ارامكو|اتصالات|ابوظبي|קום|сайт|рус|орг|онлайн|москва|ком|католик|дети|zuerich|zone|zippo|zip|zero|zara|zappos|yun|youtube|you|yokohama|yoga|yodobashi|yandex|yamaxun|yahoo|yachts|xyz|xxx|xperia|xin|xihuan|xfinity|xerox|xbox|wtf|wtc|wow|world|works|work|woodside|wolterskluwer|wme|winners|wine|windows|win|williamhill|wiki|wien|whoswho|weir|weibo|wedding|wed|website|weber|webcam|weatherchannel|weather|watches|watch|warman|wanggou|wang|walter|walmart|wales|vuelos|voyage|voto|voting|vote|volvo|volkswagen|vodka|vlaanderen|vivo|viva|vistaprint|vista|vision|visa|virgin|vip|vin|villas|viking|vig|video|viajes|vet|versicherung|vermögensberatung|vermögensberater|verisign|ventures|vegas|vanguard|vana|vacations|ups|uol|uno|university|unicom|uconnect|ubs|ubank|tvs|tushu|tunes|tui|tube|trv|trust|travelersinsurance|travelers|travelchannel|travel|training|trading|trade|toys|toyota|town|tours|total|toshiba|toray|top|tools|tokyo|today|tmall|tkmaxx|tjx|tjmaxx|tirol|tires|tips|tiffany|tienda|tickets|tiaa|theatre|theater|thd|teva|tennis|temasek|telefonica|telecity|tel|technology|tech|team|tdk|tci|taxi|tax|tattoo|tatar|tatamotors|target|taobao|talk|taipei|tab|systems|symantec|sydney|swiss|swiftcover|swatch|suzuki|surgery|surf|support|supply|supplies|sucks|style|study|studio|stream|store|storage|stockholm|stcgroup|stc|statoil|statefarm|statebank|starhub|star|staples|stada|srt|srl|spreadbetting|spot|sport|spiegel|space|soy|sony|song|solutions|solar|sohu|software|softbank|social|soccer|sncf|smile|smart|sling|skype|sky|skin|ski|site|singles|sina|silk|shriram|showtime|show|shouji|shopping|shop|shoes|shiksha|shia|shell|shaw|sharp|shangrila|sfr|sexy|sex|sew|seven|ses|services|sener|select|seek|security|secure|seat|search|scot|scor|scjohnson|science|schwarz|schule|school|scholarships|schmidt|schaeffler|scb|sca|sbs|sbi|saxo|save|sas|sarl|sapo|sap|sanofi|sandvikcoromant|sandvik|samsung|samsclub|salon|sale|sakura|safety|safe|saarland|ryukyu|rwe|run|ruhr|rugby|rsvp|room|rogers|rodeo|rocks|rocher|rmit|rip|rio|ril|rightathome|ricoh|richardli|rich|rexroth|reviews|review|restaurant|rest|republican|report|repair|rentals|rent|ren|reliance|reit|reisen|reise|rehab|redumbrella|redstone|red|recipes|realty|realtor|realestate|read|raid|radio|racing|qvc|quest|quebec|qpon|pwc|pub|prudential|pru|protection|property|properties|promo|progressive|prof|productions|prod|pro|prime|press|praxi|pramerica|post|porn|politie|poker|pohl|pnc|plus|plumbing|playstation|play|place|pizza|pioneer|pink|ping|pin|pid|pictures|pictet|pics|piaget|physio|photos|photography|photo|phone|philips|phd|pharmacy|pfizer|pet|pccw|pay|passagens|party|parts|partners|pars|paris|panerai|panasonic|pamperedchef|page|ovh|ott|otsuka|osaka|origins|orientexpress|organic|org|orange|oracle|open|ooo|onyourside|online|onl|ong|one|omega|ollo|oldnavy|olayangroup|olayan|okinawa|office|off|observer|obi|nyc|ntt|nrw|nra|nowtv|nowruz|now|norton|northwesternmutual|nokia|nissay|nissan|ninja|nikon|nike|nico|nhk|ngo|nfl|nexus|nextdirect|next|news|newholland|new|neustar|network|netflix|netbank|net|nec|nba|navy|natura|nationwide|name|nagoya|nadex|nab|mutuelle|mutual|museum|mtr|mtpc|mtn|msd|movistar|movie|mov|motorcycles|moto|moscow|mortgage|mormon|mopar|montblanc|monster|money|monash|mom|moi|moe|moda|mobily|mobile|mobi|mma|mls|mlb|mitsubishi|mit|mint|mini|mil|microsoft|miami|metlife|merckmsd|meo|menu|men|memorial|meme|melbourne|meet|media|med|mckinsey|mcdonalds|mcd|mba|mattel|maserati|marshalls|marriott|markets|marketing|market|map|mango|management|man|makeup|maison|maif|madrid|macys|luxury|luxe|lupin|lundbeck|ltda|ltd|lplfinancial|lpl|love|lotto|lotte|london|lol|loft|locus|locker|loans|loan|llp|llc|lixil|living|live|lipsy|link|linde|lincoln|limo|limited|lilly|like|lighting|lifestyle|lifeinsurance|life|lidl|liaison|lgbt|lexus|lego|legal|lefrak|leclerc|lease|lds|lawyer|law|latrobe|latino|lat|lasalle|lanxess|landrover|land|lancome|lancia|lancaster|lamer|lamborghini|ladbrokes|lacaixa|kyoto|kuokgroup|kred|krd|kpn|kpmg|kosher|komatsu|koeln|kiwi|kitchen|kindle|kinder|kim|kia|kfh|kerryproperties|kerrylogistics|kerryhotels|kddi|kaufen|juniper|juegos|jprs|jpmorgan|joy|jot|joburg|jobs|jnj|jmp|jll|jlc|jio|jewelry|jetzt|jeep|jcp|jcb|java|jaguar|iwc|iveco|itv|itau|istanbul|ist|ismaili|iselect|irish|ipiranga|investments|intuit|international|intel|int|insure|insurance|institute|ink|ing|info|infiniti|industries|inc|immobilien|immo|imdb|imamat|ikano|iinet|ifm|ieee|icu|ice|icbc|ibm|hyundai|hyatt|hughes|htc|hsbc|how|house|hotmail|hotels|hoteles|hot|hosting|host|hospital|horse|honeywell|honda|homesense|homes|homegoods|homedepot|holiday|holdings|hockey|hkt|hiv|hitachi|hisamitsu|hiphop|hgtv|hermes|here|helsinki|help|healthcare|health|hdfcbank|hdfc|hbo|haus|hangout|hamburg|hair|guru|guitars|guide|guge|gucci|guardian|group|grocery|gripe|green|gratis|graphics|grainger|gov|got|gop|google|goog|goodyear|goodhands|goo|golf|goldpoint|gold|godaddy|gmx|gmo|gmbh|gmail|globo|global|gle|glass|glade|giving|gives|gifts|gift|ggee|george|genting|gent|gea|gdn|gbiz|gay|garden|gap|games|game|gallup|gallo|gallery|gal|fyi|futbol|furniture|fund|fun|fujixerox|fujitsu|ftr|frontier|frontdoor|frogans|frl|fresenius|free|fox|foundation|forum|forsale|forex|ford|football|foodnetwork|food|foo|fly|flsmidth|flowers|florist|flir|flights|flickr|fitness|fit|fishing|fish|firmdale|firestone|fire|financial|finance|final|film|fido|fidelity|fiat|ferrero|ferrari|feedback|fedex|fast|fashion|farmers|farm|fans|fan|family|faith|fairwinds|fail|fage|extraspace|express|exposed|expert|exchange|everbank|events|eus|eurovision|etisalat|esurance|estate|esq|erni|ericsson|equipment|epson|epost|enterprises|engineering|engineer|energy|emerck|email|education|edu|edeka|eco|eat|earth|dvr|dvag|durban|dupont|duns|dunlop|duck|dubai|dtv|drive|download|dot|doosan|domains|doha|dog|dodge|doctor|docs|dnp|diy|dish|discover|discount|directory|direct|digital|diet|diamonds|dhl|dev|design|desi|dentist|dental|democrat|delta|deloitte|dell|delivery|degree|deals|dealer|deal|dds|dclk|day|datsun|dating|date|data|dance|dad|dabur|cyou|cymru|cuisinella|csc|cruises|cruise|crs|crown|cricket|creditunion|creditcard|credit|cpa|courses|coupons|coupon|country|corsica|coop|cool|cookingchannel|cooking|contractors|contact|consulting|construction|condos|comsec|computer|compare|company|community|commbank|comcast|com|cologne|college|coffee|codes|coach|clubmed|club|cloud|clothing|clinique|clinic|click|cleaning|claims|cityeats|city|citic|citi|citadel|cisco|circle|cipriani|church|chrysler|chrome|christmas|chloe|chintai|cheap|chat|chase|charity|channel|chanel|cfd|cfa|cern|ceo|center|ceb|cbs|cbre|cbn|cba|catholic|catering|cat|casino|cash|caseih|case|casa|cartier|cars|careers|career|care|cards|caravan|car|capitalone|capital|capetown|canon|cancerresearch|camp|camera|cam|calvinklein|call|cal|cafe|cab|bzh|buzz|buy|business|builders|build|bugatti|budapest|brussels|brother|broker|broadway|bridgestone|bradesco|box|boutique|bot|boston|bostik|bosch|boots|booking|book|boo|bond|bom|bofa|boehringer|boats|bnpparibas|bnl|bmw|bms|blue|bloomberg|blog|blockbuster|blanco|blackfriday|black|biz|bio|bingo|bing|bike|bid|bible|bharti|bet|bestbuy|best|berlin|bentley|beer|beauty|beats|bcn|bcg|bbva|bbt|bbc|bayern|bauhaus|basketball|baseball|bargains|barefoot|barclays|barclaycard|barcelona|bar|bank|band|bananarepublic|banamex|baidu|baby|azure|axa|aws|avianca|autos|auto|author|auspost|audio|audible|audi|auction|attorney|athleta|associates|asia|asda|arte|art|arpa|army|archi|aramco|arab|aquarelle|apple|app|apartments|aol|anz|anquan|android|analytics|amsterdam|amica|amfam|amex|americanfamily|americanexpress|alstom|alsace|ally|allstate|allfinanz|alipay|alibaba|alfaromeo|akdn|airtel|airforce|airbus|aigo|aig|agency|agakhan|africa|afl|afamilycompany|aetna|aero|aeg|adult|ads|adac|actor|active|aco|accountants|accountant|accenture|academy|abudhabi|abogado|able|abc|abbvie|abbott|abb|abarth|aarp|aaa|onion)(?=[^0-9a-zA-Z@+-]|$))|(?:(?:한국|香港|澳門|新加坡|台灣|台湾|中國|中国|გე|ລາວ|ไทย|ලංකා|ഭാരതം|ಭಾರತ|భారత్|சிங்கப்பூர்|இலங்கை|இந்தியா|ଭାରତ|ભારત|ਭਾਰਤ|ভাৰত|ভারত|বাংলা|भारोत|भारतम्|भारत|ڀارت|پاکستان|موريتانيا|مليسيا|مصر|قطر|فلسطين|عمان|عراق|سورية|سودان|تونس|بھارت|بارت|ایران|امارات|المغرب|السعودية|الجزائر|البحرين|الاردن|հայ|қаз|укр|срб|рф|мон|мкд|ею|бел|бг|ευ|ελ|zw|zm|za|yt|ye|ws|wf|vu|vn|vi|vg|ve|vc|va|uz|uy|us|um|uk|ug|ua|tz|tw|tv|tt|tr|tp|to|tn|tm|tl|tk|tj|th|tg|tf|td|tc|sz|sy|sx|sv|su|st|ss|sr|so|sn|sm|sl|sk|sj|si|sh|sg|se|sd|sc|sb|sa|rw|ru|rs|ro|re|qa|py|pw|pt|ps|pr|pn|pm|pl|pk|ph|pg|pf|pe|pa|om|nz|nu|nr|np|no|nl|ni|ng|nf|ne|nc|na|mz|my|mx|mw|mv|mu|mt|ms|mr|mq|mp|mo|mn|mm|ml|mk|mh|mg|mf|me|md|mc|ma|ly|lv|lu|lt|ls|lr|lk|li|lc|lb|la|kz|ky|kw|kr|kp|kn|km|ki|kh|kg|ke|jp|jo|jm|je|it|is|ir|iq|io|in|im|il|ie|id|hu|ht|hr|hn|hm|hk|gy|gw|gu|gt|gs|gr|gq|gp|gn|gm|gl|gi|gh|gg|gf|ge|gd|gb|ga|fr|fo|fm|fk|fj|fi|eu|et|es|er|eh|eg|ee|ec|dz|do|dm|dk|dj|de|cz|cy|cx|cw|cv|cu|cr|co|cn|cm|cl|ck|ci|ch|cg|cf|cd|cc|ca|bz|by|bw|bv|bt|bs|br|bq|bo|bn|bm|bl|bj|bi|bh|bg|bf|be|bd|bb|ba|az|ax|aw|au|at|as|ar|aq|ao|an|am|al|ai|ag|af|ae|ad|ac)(?=[^0-9a-zA-Z@+-]|$))|(?:xn--[\\-0-9a-z]+))))(?::([0-9]+))?(\\/(?:(?:[a-z\\u0400-\\u04FF0-9!\\*';:=\\+,\\.\\$\\/%#\\[\\]\\-\\u2013_~@\\|&\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\xFF\\u0100-\\u024F\\u0253\\u0254\\u0256\\u0257\\u0259\\u025B\\u0263\\u0268\\u026F\\u0272\\u0289\\u028B\\u02BB\\u0300-\\u036F\\u1E00-\\u1EFF]*(?:\\((?:[a-z\\u0400-\\u04FF0-9!\\*';:=\\+,\\.\\$\\/%#\\[\\]\\-\\u2013_~@\\|&\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\xFF\\u0100-\\u024F\\u0253\\u0254\\u0256\\u0257\\u0259\\u025B\\u0263\\u0268\\u026F\\u0272\\u0289\\u028B\\u02BB\\u0300-\\u036F\\u1E00-\\u1EFF]+|(?:[a-z\\u0400-\\u04FF0-9!\\*';:=\\+,\\.\\$\\/%#\\[\\]\\-\\u2013_~@\\|&\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\xFF\\u0100-\\u024F\\u0253\\u0254\\u0256\\u0257\\u0259\\u025B\\u0263\\u0268\\u026F\\u0272\\u0289\\u028B\\u02BB\\u0300-\\u036F\\u1E00-\\u1EFF]*\\([a-z\\u0400-\\u04FF0-9!\\*';:=\\+,\\.\\$\\/%#\\[\\]\\-\\u2013_~@\\|&\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\xFF\\u0100-\\u024F\\u0253\\u0254\\u0256\\u0257\\u0259\\u025B\\u0263\\u0268\\u026F\\u0272\\u0289\\u028B\\u02BB\\u0300-\\u036F\\u1E00-\\u1EFF]+\\)[a-z\\u0400-\\u04FF0-9!\\*';:=\\+,\\.\\$\\/%#\\[\\]\\-\\u2013_~@\\|&\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\xFF\\u0100-\\u024F\\u0253\\u0254\\u0256\\u0257\\u0259\\u025B\\u0263\\u0268\\u026F\\u0272\\u0289\\u028B\\u02BB\\u0300-\\u036F\\u1E00-\\u1EFF]*))\\)[a-z\\u0400-\\u04FF0-9!\\*';:=\\+,\\.\\$\\/%#\\[\\]\\-\\u2013_~@\\|&\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\xFF\\u0100-\\u024F\\u0253\\u0254\\u0256\\u0257\\u0259\\u025B\\u0263\\u0268\\u026F\\u0272\\u0289\\u028B\\u02BB\\u0300-\\u036F\\u1E00-\\u1EFF]*)*[\\+\\-a-z\\u0400-\\u04FF0-9=_#\\/\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\xFF\\u0100-\\u024F\\u0253\\u0254\\u0256\\u0257\\u0259\\u025B\\u0263\\u0268\\u026F\\u0272\\u0289\\u028B\\u02BB\\u0300-\\u036F\\u1E00-\\u1EFF]|(?:\\((?:[a-z\\u0400-\\u04FF0-9!\\*';:=\\+,\\.\\$\\/%#\\[\\]\\-\\u2013_~@\\|&\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\xFF\\u0100-\\u024F\\u0253\\u0254\\u0256\\u0257\\u0259\\u025B\\u0263\\u0268\\u026F\\u0272\\u0289\\u028B\\u02BB\\u0300-\\u036F\\u1E00-\\u1EFF]+|(?:[a-z\\u0400-\\u04FF0-9!\\*';:=\\+,\\.\\$\\/%#\\[\\]\\-\\u2013_~@\\|&\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\xFF\\u0100-\\u024F\\u0253\\u0254\\u0256\\u0257\\u0259\\u025B\\u0263\\u0268\\u026F\\u0272\\u0289\\u028B\\u02BB\\u0300-\\u036F\\u1E00-\\u1EFF]*\\([a-z\\u0400-\\u04FF0-9!\\*';:=\\+,\\.\\$\\/%#\\[\\]\\-\\u2013_~@\\|&\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\xFF\\u0100-\\u024F\\u0253\\u0254\\u0256\\u0257\\u0259\\u025B\\u0263\\u0268\\u026F\\u0272\\u0289\\u028B\\u02BB\\u0300-\\u036F\\u1E00-\\u1EFF]+\\)[a-z\\u0400-\\u04FF0-9!\\*';:=\\+,\\.\\$\\/%#\\[\\]\\-\\u2013_~@\\|&\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\xFF\\u0100-\\u024F\\u0253\\u0254\\u0256\\u0257\\u0259\\u025B\\u0263\\u0268\\u026F\\u0272\\u0289\\u028B\\u02BB\\u0300-\\u036F\\u1E00-\\u1EFF]*))\\)))|(?:@[a-z\\u0400-\\u04FF0-9!\\*';:=\\+,\\.\\$\\/%#\\[\\]\\-\\u2013_~@\\|&\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\xFF\\u0100-\\u024F\\u0253\\u0254\\u0256\\u0257\\u0259\\u025B\\u0263\\u0268\\u026F\\u0272\\u0289\\u028B\\u02BB\\u0300-\\u036F\\u1E00-\\u1EFF]+\\/))*)?(\\?[a-z0-9!?\\*'@\\(\\);:&=\\+\\$\\/%#\\[\\]\\-_\\.,~|]*[a-z0-9\\-_&=#\\/])?))",Kn="gi",_t={source:qn,flags:Kn};var Vn={BASE_URL:"./",DEV:!1,MODE:"production",PHANPY_CLIENT_NAME:"Phanpy",PHANPY_LINGVA_INSTANCES:"lingva.phanpy.social lingva.lunar.icu lingva.garudalinux.org translate.plausibility.cloud",PHANPY_PRIVACY_POLICY_URL:"https://github.com/cheeaun/phanpy/blob/main/PRIVACY.MD",PHANPY_WEBSITE:"https://phanpy.social",PROD:!0,SSR:!1,VITE_APP_ENV:"production"};const{PHANPY_IMG_ALT_API_URL:ut,PHANPY_GIPHY_API_KEY:Gn}=Vn,Yn=yt.reduce((s,e)=>{const[n,a,r]=e;return s[n]={common:a,native:r},s},{}),Kt={"5 minutes":5*60,"30 minutes":30*60,"1 hour":60*60,"6 hours":6*60*60,"12 hours":12*60*60,"1 day":24*60*60,"3 days":3*24*60*60,"7 days":7*24*60*60},Zn=Object.values(Kt),Rt=24*60*60,Dt=s=>{if(!s)return Rt;const e=(new Date(s).getTime()-Date.now())/1e3;return Zn.find(n=>n>=e)||Rt},ye=document.createElement("ul");ye.role="listbox";ye.className="text-expander-menu";const Jn=16,Xn=new IntersectionObserver(s=>{s.forEach(e=>{if(e.isIntersecting){const{left:n,width:a}=e.boundingClientRect,{innerWidth:r}=window;if(n+a>r){const m=on()?"right":"left";ye.style[m]=r-a-Jn+"px"}}})});Xn.observe(ye);const we=rn([new Intl.DateTimeFormat().resolvedOptions().locale,...navigator.languages],yt.map(s=>s[0]),"en"),Vt=new RegExp(_t.source,_t.flags),Qn=/(^|[^\/\w])@(([a-z0-9_]+)@[a-z0-9\.\-]+[a-z0-9]+)/gi,ei="$2xxxxxxxxxxxxxxxxxxxxxxx";function ti(s){return s.replace(Vt,ei).replace(Qn,"$1@$3")}const ni=/[a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?/i,ii=new RegExp(`(^|[^=\\/\\w])(@${ni.source}(?:@[\\p{L}\\w.-]+[\\w]+)?)`,"uig"),si=new RegExp("(^|[^=\\/\\w])(#[a-z0-9_]+([a-z0-9_.]+[a-z0-9_]+)?)(?![\\/\\w])","ig"),ai="[a-zA-Z0-9_]{2,}",oi=new RegExp(`(^|[^=\\/\\w])(:${ai}:)(?=[^A-Za-z0-9_:]|$)`,"g"),ri=new Intl.Segmenter;function dt(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function li(s,{maxCharacters:e=1/0}){const{composerCharacterCount:n}=le;if(n>e){let a="",r="";const m=ri.segment(s);for(const{segment:u,index:v}of m)v<e?a+=u:r+=u;return r&&(r='<mark class="compose-highlight-exceeded">'+dt(r)+"</mark>"),dt(a)+r}return dt(s).replace(Vt,'$2<mark class="compose-highlight-url">$3</mark>').replace(ii,'$1<mark class="compose-highlight-mention">$2</mark>').replace(si,'$1<mark class="compose-highlight-hashtag">$2</mark>').replace(oi,'$1<mark class="compose-highlight-emoji-shortcode">$2</mark>')}const ci=new Intl.RelativeTimeFormat,vt=100;function Ci({onClose:s,replyToStatus:e,editStatus:n,draftStatus:a,standalone:r,hasOpener:m}){var Ct;const{masto:u,instance:v}=bt(),[g,R]=H("default"),C=W((a==null?void 0:a.uid)||ln()),k=xn(),z=k.info,Z=Ut(),{statuses:{maxCharacters:D,maxMediaAttachments:I,charactersReservedPerUrl:se}={},mediaAttachments:{supportedMimeTypes:J=[],imageSizeLimit:c,imageMatrixLimit:h,videoSizeLimit:p,videoMatrixLimit:f,videoFrameRateLimit:E}={},polls:{maxOptions:y,maxCharactersPerOption:T,maxExpiration:q,minExpiration:ue}={}}=Z||{},S=W(),X=W(),[V,U]=H("public"),[j,te]=H(!1),[O,ie]=H(Le.session.get("currentLanguage")||we),ae=W(O),[M,A]=H([]),[$,L]=H(null),N=Le.account.get("preferences")||{},Q=()=>{S.current&&S.current.dispatchEvent(new Event("input"))},oe=()=>{setTimeout(()=>{var o,l,b;S.current&&((l=(o=a==null?void 0:a.status)==null?void 0:o.startsWith)!=null&&l.call(o,`
`)&&(S.current.selectionStart=0,S.current.selectionEnd=0),(b=S.current)==null||b.focus())},300)};ee(()=>{if(e){const{spoilerText:o,visibility:l,language:b,sensitive:d}=e;o&&X.current&&(X.current.value=o);const x=[...new Set([e.account.acct,...e.mentions.map(w=>w.acct)])].filter(w=>w!==z.acct);x.length>0&&(S.current.value=`${x.map(w=>`@${w}`).join(" ")} `,Q()),oe(),U(l==="public"&&N["posting:default:visibility"]?N["posting:default:visibility"]:l),ie(b||N.postingDefaultLanguage||we),te(d&&!!o)}else if(n){const{visibility:o,language:l,sensitive:b,poll:d,mediaAttachments:_}=n,x=!!(d!=null&&d.options)&&{...d,options:d.options.map(w=>(w==null?void 0:w.title)||w),expiresIn:(d==null?void 0:d.expiresIn)||Dt(d.expiresAt)};R("loading"),(async()=>{try{const w=await u.v1.statuses.$select(n.id).source.fetch(),{text:F,spoilerText:P}=w;S.current.value=F,S.current.dataset.source=F,Q(),oe(),X.current.value=P,U(o),ie(l||presf.postingDefaultLanguage||we),te(b),x&&L(x),A(_),R("default")}catch(w){alert((w==null?void 0:w.reason)||w),R("error")}})()}else oe(),N["posting:default:visibility"]&&U(N["posting:default:visibility"]),N["posting:default:language"]&&ie(N["posting:default:language"]),N["posting:default:sensitive"]&&te(N["posting:default:sensitive"]);if(a){const{status:o,spoilerText:l,visibility:b,language:d,sensitive:_,poll:x,mediaAttachments:w}=a,F=!!(x!=null&&x.options)&&{...x,options:x.options.map(P=>(P==null?void 0:P.title)||P),expiresIn:(x==null?void 0:x.expiresIn)||Dt(x.expiresAt)};S.current.value=o,Q(),oe(),l&&(X.current.value=l),b&&U(b),ie(d||N.postingDefaultLanguage||we),_!==null&&te(_),F&&L(F),w&&A(w)}},[a,n,e]);const he=W(),ve="You have unsaved changes. Discard this post?",xe=()=>{const{value:o,dataset:l}=S.current;if(g==="loading")return!1;const b=(o||"").trim().replace(new RegExp("^\\p{White_Space}+|\\p{White_Space}+$","gu"),""),d=M.length>0;if(!b&&!d||M.length>0&&M.every(P=>P.id))return!0;const x=(e==null?void 0:e.account.id)===z.id,w=e&&o.trim()===`@${e.account.acct}`;return!!(!x&&w||o===(l==null?void 0:l.source))},Oe=()=>xe()?!0:confirm(ve);ee(()=>{const o=l=>{xe()||(l.preventDefault(),l.returnValue=ve)};return window.addEventListener("beforeunload",o,{capture:!0}),()=>window.removeEventListener("beforeunload",o,{capture:!0})},[]);const Zt=()=>{const{value:o}=S.current,{value:l}=X.current;return Bt(ti(o))+Bt(l)},tt=()=>{const o=Zt();le.composerCharacterCount=o};ee(tt,[]);const wt=window.CloseWatcher,nt=W(!1);_e("esc",()=>{nt.current=!0},{enabled:!wt,enableOnFormTags:!0}),_e("esc",()=>{!r&&nt.current&&Oe()&&s(),nt.current=!1},{enabled:!wt,enableOnFormTags:!0,keyup:!0,ignoreEventWhen:o=>{const l=document.querySelectorAll("#modal-container > *"),b=!!l,d=l.length===1&&l[0].querySelector("#compose-container");return b&&!d}}),cn(()=>{!r&&Oe()&&s()},[r,Oe,s]);const kt=W({}),Et=()=>`${wn()}#${C.current}`,it=()=>{if(n||le.composerState.minimized)return;const o=Et(),l={key:o,replyTo:e?{id:e.id,account:{id:e.account.id,username:e.account.username,acct:e.account.acct}}:null,draftStatus:{uid:C.current,status:S.current.value,spoilerText:X.current.value,visibility:V,language:O,sensitive:j,poll:$,mediaAttachments:M}};!kn(l,kt.current)&&!xe()&&(zt.drafts.set(o,{...l,state:"unsaved",updatedAt:Date.now()}).then(()=>{}).catch(b=>{}),kt.current=structuredClone(l))};un(it,5e3),ee(()=>(it(),()=>{zt.drafts.del(Et())}),[]),ee(()=>{const o=b=>{const{items:d}=b.clipboardData||b.dataTransfer,_=[];for(let x=0;x<d.length;x++){const w=d[x];if(w.kind==="file"){const F=w.getAsFile();F&&J.includes(F.type)&&_.push(F)}}if(_.length>0&&M.length>=I){alert(`You can only attach up to ${I} files.`);return}if(_.length>0){b.preventDefault(),b.stopPropagation();const x=I-M.length,w=_.slice(0,x);if(w.length<=0){alert(`You can only attach up to ${I} files.`);return}const F=w.map(P=>({file:P,type:P.type,size:P.size,url:URL.createObjectURL(P),id:null,description:null}));A([...M,...F])}};window.addEventListener("paste",o);const l=b=>{b.dataTransfer.items.length>0&&(b.preventDefault(),b.stopPropagation())};return window.addEventListener("dragover",l),window.addEventListener("drop",o),()=>{window.removeEventListener("paste",o),window.removeEventListener("dragover",l),window.removeEventListener("drop",o)}},[M]);const[He,st]=H(!1),[Ne,Ue]=H(!1),[Jt,at]=H(!1),[me,Xt]=H(null),[Qt,en]=Re(()=>{const o=[],l=[],{contentTranslationHideLanguages:b=[]}=le.settings;return yt.forEach(d=>{const[_]=d;_===O||_===ae.current||_===we||b.includes(_)||me!=null&&me.length&&me.includes(_)?o.push(d):l.push(d)}),o.sort(([d,_],[x,w])=>d===O?-1:x===O?1:_.localeCompare(w)),l.sort(([d,_],[x,w])=>_.localeCompare(w)),[o,l]},[O,me]),Ft=Re(()=>!!(e!=null&&e.createdAt)&&Math.floor((Date.now()-new Date(e.createdAt))/(1e3*60*60*24*30)),[e]),tn=()=>{it(),le.composerState.minimized=!0};return t("div",{id:"compose-container-outer",children:[t("div",{id:"compose-container",class:r?"standalone":"",children:[t("div",{class:"compose-top",children:[(z==null?void 0:z.avatarStatic)&&t(Ht,{account:z,accountInstance:k.instanceURL,hideDisplayName:!0,useAvatarStatic:!0}),r?m&&t("button",{type:"button",class:"light pop-button",disabled:g==="loading",onClick:()=>{var o;if(!window.opener){alert("Looks like you closed the parent window.");return}if(window.opener.__STATES__.showCompose){if((o=window.opener.__STATES__.composerState)!=null&&o.publishing){alert("Looks like you already have a compose field open in the parent window and currently publishing. Please wait for it to be done and try again later.");return}if(!confirm("Looks like you already have a compose field open in the parent window. Popping in this window will discard the changes you made in the parent window. Continue?"))return}s({fn:()=>{const l={editStatus:n,replyToStatus:e,draftStatus:{uid:C.current,status:S.current.value,spoilerText:X.current.value,visibility:V,language:O,sensitive:j,poll:$,mediaAttachments:M}};window.opener.__COMPOSE__=l,window.opener.__STATES__.showCompose?(window.opener.__STATES__.showCompose=!1,setTimeout(()=>{window.opener.__STATES__.showCompose=!0},10)):window.opener.__STATES__.showCompose=!0,window.opener.__STATES__.composerState.minimized&&(window.opener.__STATES__.composerState.minimized=!1)}})},children:t(K,{icon:"popin",alt:"Pop in"})}):t("span",{class:"compose-controls",children:[t("button",{type:"button",class:"plain4 pop-button",disabled:g==="loading",onClick:()=>{dn({editStatus:n,replyToStatus:e,draftStatus:{uid:C.current,status:S.current.value,spoilerText:X.current.value,visibility:V,language:O,sensitive:j,poll:$,mediaAttachments:M}})&&s()},children:t(K,{icon:"popout",alt:"Pop out"})}),t("button",{type:"button",class:"plain4 min-button",onClick:tn,children:t(K,{icon:"minimize",alt:"Minimize"})})," ",t("button",{type:"button",class:"light close-button",disabled:g==="loading",onClick:()=>{Oe()&&s()},children:t(K,{icon:"x"})})]})]}),!!e&&t("div",{class:"status-preview",children:[t(St,{status:e,size:"s",previewMode:!0}),t("div",{class:"status-preview-legend reply-to",children:["Replying to @",e.account.acct||e.account.username,"s post",Ft>=3&&t(Ce,{children:[" ","(",t("strong",{children:ci.format(-Ft,"month")}),")"]})]})]}),!!n&&t("div",{class:"status-preview",children:[t(St,{status:n,size:"s",previewMode:!0}),t("div",{class:"status-preview-legend",children:"Editing source post"})]}),t("form",{ref:he,class:`form-visibility-${V}`,style:{pointerEvents:g==="loading"?"none":"auto",opacity:g==="loading"?.5:1},onKeyDown:o=>{o.key==="Enter"&&(o.ctrlKey||o.metaKey)&&he.current.dispatchEvent(new Event("submit",{cancelable:!0}))},onSubmit:o=>{o.preventDefault();const l=new FormData(o.target),b=Object.fromEntries(l.entries());let{status:d,visibility:_,sensitive:x,spoilerText:w}=b;if(x=x==="on",$){if($.options.length<2){alert("Poll must have at least 2 options");return}if($.options.some(F=>F==="")){alert("Some poll choices are empty");return}}M.length>0&&M.some(P=>{var ne,$e;return!(($e=(ne=P.description)==null?void 0:ne.trim)!=null&&$e.call(ne))})&&!confirm("Some media have no descriptions. Continue?")||(w=x&&w||void 0,d=d===""?void 0:d,le.composerState.publishing=!0,R("loading"),(async()=>{try{if(M.length>0){const ne=M.map(ge=>{const{file:We,description:nn,id:sn}=ge;if(sn)return ge;{const an=Ot({file:We,description:nn});return u.v2.media.create(an).then(ot=>(ot.id&&(ge.id=ot.id),ot))}}),$e=await Promise.allSettled(ne);if($e.some(ge=>{var We;return ge.status==="rejected"||!((We=ge.value)!=null&&We.id)})){le.composerState.publishing=!1,le.composerState.publishingError=!0,R("error"),$e.forEach(ge=>{ge.status==="rejected"&&alert(ge.reason||`Attachment #${i} failed`)});return}}let F={status:d,spoiler_text:w,language:O,sensitive:x,poll:$,media_ids:M.map(ne=>ne.id)};n&&Nt("@mastodon/edit-media-attributes")?F.media_attributes=M.map(ne=>({id:ne.id,description:ne.description})):n||(F.visibility=_,F.in_reply_to_id=(e==null?void 0:e.id)||void 0),F=Ot(F);let P;if(n)P=await u.v1.statuses.$select(n.id).update(F),En(P,v,{skipThreading:!0});else try{P=await u.v1.statuses.create(F,{requestInit:{headers:{"Idempotency-Key":C.current}}})}catch{P=await u.v1.statuses.create(F)}le.composerState.minimized=!1,le.composerState.publishing=!1,R("default"),s({type:n?"edit":e?"reply":"post",newStatus:P,instance:v})}catch(F){le.composerState.publishing=!1,le.composerState.publishingError=!0,alert((F==null?void 0:F.reason)||F),R("error")}})())},children:[t("div",{class:"toolbar stretch",children:[t("input",{ref:X,type:"text",name:"spoilerText",placeholder:"Content warning",disabled:g==="loading",class:"spoiler-text-field",lang:O,spellCheck:"true",dir:"auto",style:{opacity:j?1:0,pointerEvents:j?"auto":"none"},onInput:()=>{tt()}}),t("label",{class:`toolbar-button ${j?"highlight":""}`,title:"Content warning or sensitive media",children:[t("input",{name:"sensitive",type:"checkbox",checked:j,disabled:g==="loading",onChange:o=>{var b,d;const l=o.target.checked;te(l),l?(b=X.current)==null||b.focus():(d=S.current)==null||d.focus()}}),t(K,{icon:`eye-${j?"close":"open"}`})]})," ",t("label",{class:`toolbar-button ${V!=="public"&&!j?"show-field":""} ${V!=="public"?"highlight":""}`,title:`Visibility: ${V}`,children:[t(K,{icon:hn[V],alt:V}),t("select",{name:"visibility",value:V,onChange:o=>{U(o.target.value)},disabled:g==="loading"||!!n,dir:"auto",children:[t("option",{value:"public",children:["Public ",t(K,{icon:"earth"})]}),t("option",{value:"unlisted",children:"Unlisted"}),t("option",{value:"private",children:"Followers only"}),t("option",{value:"direct",children:"Private mention"})]})]})," "]}),t(hi,{ref:S,placeholder:e?"Post your reply":n?"Edit your post":"What are you doing?",required:(M==null?void 0:M.length)===0,disabled:g==="loading",lang:O,onInput:()=>{tt()},maxCharacters:D,performSearch:o=>{const{type:l,q:b,limit:d}=o;return l==="accounts"?u.v1.accounts.search.list({q:b,limit:d,resolve:!1}):u.v2.search.fetch(o)},onTrigger:o=>{(o==null?void 0:o.name)==="custom-emojis"?Ue({defaultSearchTerm:(o==null?void 0:o.defaultSearchTerm)||null}):(o==null?void 0:o.name)==="mention"?st({defaultSearchTerm:(o==null?void 0:o.defaultSearchTerm)||null}):(o==null?void 0:o.name)==="auto-detect-language"&&(o!=null&&o.languages)&&Xt(o.languages)}}),(M==null?void 0:M.length)>0&&t("div",{class:"media-attachments",children:[M.map((o,l)=>{const{id:b,file:d}=o,_=(d==null?void 0:d.size)+(d==null?void 0:d.type)+(d==null?void 0:d.name);return t(mi,{attachment:o,disabled:g==="loading",lang:O,onDescriptionChange:x=>{A(w=>{const F=[...w];return F[l].description=x,F})},onRemove:()=>{A(x=>x.filter((w,F)=>F!==l))}},b||_||l)}),t("label",{class:"media-sensitive",children:[t("input",{name:"sensitive",type:"checkbox",checked:j,disabled:g==="loading",onChange:o=>{const l=o.target.checked;te(l)}})," ",t("span",{children:"Mark media as sensitive"})," ",t(K,{icon:`eye-${j?"close":"open"}`})]})]}),!!$&&t(gi,{lang:O,maxOptions:y,maxExpiration:q,minExpiration:ue,maxCharactersPerOption:T,poll:$,disabled:g==="loading",onInput:o=>{if(o){const l={...o};L(l)}else L(null)}}),t("div",{class:"toolbar wrap",style:{justifyContent:"flex-end"},children:[t("span",{children:[t("label",{class:"toolbar-button",children:[t("input",{type:"file",accept:J.join(","),multiple:M.length<I-1,disabled:g==="loading"||M.length>=I||!!$,onChange:o=>{const l=o.target.files;if(!l)return;const b=Array.from(l).map(d=>({file:d,type:d.type,size:d.size,url:URL.createObjectURL(d),id:null,description:null}));M.length+b.length>I?alert(`You can only attach up to ${I} files.`):A(d=>d.concat(b)),o.target.value=""}}),t(K,{icon:"attachment"})]}),y==null||y>1&&t(Ce,{children:t("button",{type:"button",class:"toolbar-button",disabled:g==="loading"||!!$||!!M.length,onClick:()=>{L({options:["",""],expiresIn:24*60*60,multiple:!1})},children:t(K,{icon:"poll",alt:"Add poll"})})}),t("button",{type:"button",class:"toolbar-button",disabled:g==="loading",onClick:()=>{Ue(!0)},children:t(K,{icon:"emoji2"})}),!!le.settings.composerGIFPicker&&t("button",{type:"button",class:"toolbar-button gif-picker-button",disabled:g==="loading"||M.length>=I||!!$,onClick:()=>{at(!0)},children:t("span",{children:"GIF"})})]}),t("div",{class:"spacer"}),g==="loading"?t(et,{abrupt:!0}):t(pi,{maxCharacters:D,hidden:g==="loading"}),t("label",{class:`toolbar-button ${O!==ae.current||me!=null&&me.length&&!me.includes(O)?"highlight":""}`,children:[t("span",{class:"icon-text",children:(Ct=Yn[O])==null?void 0:Ct.native}),t("select",{name:"language",value:O,onChange:o=>{const{value:l}=o.target;ie(l||we),Le.session.set("currentLanguage",l||we)},disabled:g==="loading",dir:"auto",children:[Qt.map(([o,l,b])=>t("option",{value:o,children:[l," (",b,")"]},o)),t("hr",{}),en.map(([o,l,b])=>t("option",{value:o,children:[l," (",b,")"]},o))]})]})," ",t("button",{type:"submit",class:"large",disabled:g==="loading",children:e?"Reply":n?"Update":"Post"})]})]})]}),He&&t(Ve,{onClick:o=>{o.target===o.currentTarget&&st(!1)},children:t(fi,{masto:u,instance:v,onClose:()=>{st(!1)},defaultSearchTerm:He==null?void 0:He.defaultSearchTerm,onSelect:o=>{const l=S.current;if(!l)return;const{selectionStart:b,selectionEnd:d}=l,_=l.value,x=_.slice(0,b),w=x?/[\s\t\n\r]$/.test(x)?"":" ":"",F=_.slice(d),P=/^[\s\t\n\r]/.test(F)?"":" ",ne=x+w+"@"+o+P+F;l.value=ne,l.selectionStart=l.selectionEnd=d+1+o.length+P.length,l.focus(),l.dispatchEvent(new Event("input"))}})}),Ne&&t(Ve,{onClick:o=>{o.target===o.currentTarget&&Ue(!1)},children:t(vi,{masto:u,instance:v,onClose:()=>{Ue(!1)},defaultSearchTerm:Ne==null?void 0:Ne.defaultSearchTerm,onSelect:o=>{const l=S.current;if(!l)return;const{selectionStart:b,selectionEnd:d}=l,_=l.value,x=_.slice(0,b),w=x?/[\s\t\n\r]$/.test(x)?"":" ":"",F=_.slice(d),P=/^[\s\t\n\r]/.test(F)?"":" ",ne=x+w+o+P+F;l.value=ne,l.selectionStart=l.selectionEnd=d+o.length+P.length,l.focus(),l.dispatchEvent(new Event("input"))}})}),Jt&&t(Ve,{onClick:o=>{o.target===o.currentTarget&&at(!1)},children:t(yi,{onClose:()=>at(!1),onSelect:({url:o,type:l,alt_text:b})=>{if(M.length>=I){alert(`You can only attach up to ${I} files.`);return}(async()=>{var _,x;let d;try{d=ke({text:"Downloading GIF…",duration:-1});const w=await fetch(o,{referrerPolicy:"no-referrer"}).then(ne=>ne.blob()),F=new File([w],l==="video/mp4"?"video.mp4":"image.gif",{type:l}),P=[...M,{file:F,type:l,size:F.size,id:null,description:b||""}];A(P),(_=d==null?void 0:d.hideToast)==null||_.call(d)}catch{(x=d==null?void 0:d.hideToast)==null||x.call(d),ke("Failed to download GIF")}})()}})})]})}function jt(s){if(!s)return;const{value:e,offsetHeight:n,scrollHeight:a,clientHeight:r}=s;if(n<window.innerHeight){const m=n-r,u=e?a+m+"px":null;s.style.height=u}}async function ui(s,e){const a=(await e.v1.customEmojis.list()).filter(m=>m.visibleInPicker),r=new pn(a,{keys:["shortcode"],findAllMatches:!0});return[a,r]}const Gt=Fn(ui,{matchesArg:(s,e)=>s.instance===e.instance,maxAge:30*60*1e3}),di=s=>{const e=zn(s);return e!=null&&e.length?e.slice(0,2).map(n=>n.lang):null},hi=Cn((s,e)=>{var J;const{masto:n,instance:a}=bt(),[r,m]=H(((J=e.current)==null?void 0:J.value)||""),{maxCharacters:u,performSearch:v=()=>{},onTrigger:g=()=>{},...R}=s,C=W();ee(()=>{Gt(a,n).then(c=>{const[h,p]=c;C.current=p}).catch(c=>{})},[]);const k=W(),z=W("");ee(()=>{let c,h,p;return k.current&&(c=f=>{var ue;const{key:E,provide:y,text:T}=f.detail;if(z.current=T,T===""){y(Promise.resolve({matched:!1}));return}if(E===":"){const S=(ue=C.current)==null?void 0:ue.search(T,{limit:5});let X="";S.forEach(({item:V})=>{const{shortcode:U,url:j}=V;X+=`
<li role="option" data-value="${be(U)}">
<img src="${be(j)}" width="16" height="16" alt="" loading="lazy" />
${be(U)}
</li>`}),X+=`<li role="option" data-value="" data-more="${T}">More…</li>`,ye.innerHTML=X,y(Promise.resolve({matched:S.length>0,fragment:ye}));return}const q={"@":"accounts","#":"hashtags"}[E];y(new Promise(S=>{v({type:q,q:T,limit:5}).then(V=>{if(T!==z.current)return;const U=V[q]||V;let j="";U.forEach(te=>{var Q;const{name:O,avatarStatic:ie,displayName:ae,username:M,acct:A,emojis:$,history:L}=te,N=mn(ae,$);if(A)j+=`
<li role="option" data-value="${be(A)}">
<span class="avatar">
<img src="${be(ie)}" width="16" height="16" alt="" loading="lazy" />
</span>
<span>
<b>${N||M}</b>
<br><span class="bidi-isolate">@${be(A)}</span>
</span>
</li>
`;else{const oe=(Q=L==null?void 0:L.reduce)==null?void 0:Q.call(L,(he,ve)=>he+ +ve.uses,0);j+=`
<li role="option" data-value="${be(O)}">
<span class="grow">#<b>${be(O)}</b></span>
${oe?`<span class="count">${gn(oe)}</span>`:""}
</li>
`}}),q==="accounts"&&(j+=`<li role="option" data-value="" data-more="${T}">More…</li>`),ye.innerHTML=j,S({matched:U.length>0,fragment:ye})})}))},k.current.addEventListener("text-expander-change",c),h=f=>{const{key:E,item:y}=f.detail,{value:T,more:q}=y.dataset;E===":"?(f.detail.value=T?`:${T}:`:"",q&&(f.detail.continue=!0,setTimeout(()=>{g==null||g({name:"custom-emojis",defaultSearchTerm:q})},300))):E==="@"?(f.detail.value=T?`@${T} `:"",q&&(f.detail.continue=!0,setTimeout(()=>{g==null||g({name:"mention",defaultSearchTerm:q})},300))):f.detail.value=`${E}${T}`},k.current.addEventListener("text-expander-value",h),p=f=>{const{input:E}=f.detail;if(m(E.value),e.current){const y=new Event("input",{bubbles:!0});e.current.dispatchEvent(y)}},k.current.addEventListener("text-expander-committed",p)),()=>{k.current&&(k.current.removeEventListener("text-expander-change",c),k.current.removeEventListener("text-expander-value",h),k.current.removeEventListener("text-expander-committed",p))}},[]),ee(()=>{const c=e.current;if(!c)return;new ResizeObserver(()=>{if(k.current){const{height:p}=c.getBoundingClientRect();k.current.style.height=p+"px"}}).observe(c)},[]);const Z=W(0),D=W(),I=fn(c=>{var f;if(!D.current)return;if(Z.current>3){D.current.innerHTML="",D.current=null,(f=I==null?void 0:I.cancel)==null||f.call(I);return}let h,p;Z.current<=3&&(h=Date.now()),D.current.innerHTML=li(c,{maxCharacters:u})+`
`,Z.current<=3&&(p=Date.now()),h&&p&&p-h>50&&Z.current++},500),se=Qe(()=>{var f,E;const c=(f=D.current)==null?void 0:f.cloneNode(!0);if(!c)return;c.querySelectorAll("mark").forEach(y=>{y.remove()});const h=(E=c.innerText)==null?void 0:E.trim();if(!h)return;const p=di(h);p!=null&&p.length&&(g==null||g({name:"auto-detect-language",languages:p}))},2e3);return t("text-expander",{ref:k,keys:"@ # :",class:"compose-field-container",children:[t("textarea",{class:"compose-field",autoCapitalize:"sentences",autoComplete:"on",autoCorrect:"on",spellCheck:"true",dir:"auto",rows:"6",cols:"50",...R,ref:e,name:"status",value:r,onKeyDown:c=>{const{key:h,target:p}=c;if(h==="Enter"&&!(c.ctrlKey||c.metaKey))try{const{value:f,selectionStart:E}=p,T=f.slice(0,E).split(`
`).slice(-1)[0];if(T&&/^\s*(-|\d+\.)\s/.test(T)){const[q,ue,S,X,V]=T.match(/^(\s*)(-|\d+\.)(\s+)(.+)?/)||[];if(V){c.preventDefault();const[U]=S.match(/\d+/)||[],j=U?`${+U+1}.`:"-",te=`
${ue}${j}${X}`;p.setRangeText(te,E,E);const O=E+te.length;p.setSelectionRange(O,O)}else{const U=E-T.length;p.setRangeText("",U,E)}jt(p),p.dispatchEvent(new Event("input"))}}catch{}D.current&&(D.current.scrollTop=p.scrollTop)},onInput:c=>{var f;const{target:h}=c,p=h.value.replace(/\u200b/g,"");m(p),jt(h),(f=s.onInput)==null||f.call(s,c),I(p),se()},style:{width:"100%",height:"4em"},onScroll:c=>{if(D.current){const{scrollTop:h}=c.target;D.current.scrollTop=h}}}),t("div",{ref:D,class:"compose-highlight","aria-hidden":"true"})]})});function pi({maxCharacters:s=500,hidden:e}){const a=Ln(le).composerCharacterCount,r=s-a;return e?t("span",{class:"char-counter",hidden:!0}):t("span",{class:"char-counter",title:`${r}/${s}`,style:{"--percentage":a/s*100},children:[t("meter",{class:`${r<=-10?"explode":r<=0?"danger":r<=20?"warning":""}`,value:a,max:s}),t("span",{class:"counter",children:r})]})}function Ke(s){const e=["bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];let n=0;for(;s>=1024;)s/=1024,n++;return`${s.toFixed(0).toLocaleString()} ${e[n]}`}function Pt(s,e,n,a){const r=Math.sqrt(e/s),m=Math.floor(n*r),u=Math.floor(a*r);return{newWidth:m,newHeight:u}}function mi({attachment:s,disabled:e,lang:n,onDescriptionChange:a=()=>{},onRemove:r=()=>{}}){const[m,u]=H("default"),v=Nt("@mastodon/edit-media-attributes"),{type:g,id:R,file:C}=s,k=Re(()=>C?URL.createObjectURL(C):s.url,[C,s.url]),z=!!(C!=null&&C.size),Z=z?Ut():{},{mediaAttachments:{imageSizeLimit:D,imageMatrixLimit:I,videoSizeLimit:se,videoMatrixLimit:J,videoFrameRateLimit:c}={}}=Z||{},[h,p]=H(()=>z?g.startsWith("image")&&D&&C.size>D?{type:"imageSizeLimit",details:{imageSize:C.size,imageSizeLimit:D}}:g.startsWith("video")&&se&&C.size>se?{type:"videoSizeLimit",details:{videoSize:C.size,videoSizeLimit:se}}:null:null),[f,E]=H({});ee(()=>{!z||!I||(f==null?void 0:f.matrix)>I&&p({type:"imageMatrixLimit",details:{imageMatrix:f==null?void 0:f.matrix,imageMatrixLimit:I,width:f==null?void 0:f.width,height:f==null?void 0:f.height}})},[f,I,z]);const[y,T]=H({});ee(()=>{!z||!J||(y==null?void 0:y.matrix)>J&&p({type:"videoMatrixLimit",details:{videoMatrix:y==null?void 0:y.matrix,videoMatrixLimit:J,width:y==null?void 0:y.width,height:y==null?void 0:y.height}})},[y,J,z]);const[q,ue]=H(s.description),[S,X]=g.split("/"),V=Qe(a,250);ee(()=>{V(q)},[q,V]);const[U,j]=H(!1),te=W(null);ee(()=>{let A;return U&&te.current&&(A=setTimeout(()=>{te.current.focus()},100)),()=>{clearTimeout(A)}},[U]);const O=t(Ce,{children:R&&!v?t("div",{class:"media-desc",children:[t("span",{class:"tag",children:"Uploaded"}),t("p",{title:q,children:s.description||t("i",{children:"No description"})})]}):t("textarea",{ref:te,value:q||"",lang:n,placeholder:{image:"Image description",video:"Video description",audio:"Audio description"}[S],autoCapitalize:"sentences",autoComplete:"on",autoCorrect:"on",spellCheck:"true",dir:"auto",disabled:e||m==="loading",class:m==="loading"?"loading":"",maxlength:"1500",onInput:A=>{const{value:$}=A.target;ue($)}})}),ie=W(null);ee(()=>()=>{var A,$;($=(A=ie.current)==null?void 0:A.hideToast)==null||$.call(A)},[]);const ae=W(null),M=A=>{const{type:$,details:L}=A;switch($){case"imageSizeLimit":{const{imageSize:N,imageSizeLimit:Q}=L;return`File size too large. Uploading might encounter issues. Try reduce the file size from ${Ke(N)} to ${Ke(Q)} or lower.`}case"imageMatrixLimit":{const{imageMatrix:N,imageMatrixLimit:Q,width:oe,height:he}=L,{newWidth:ve,newHeight:xe}=Pt(N,Q,oe,he);return`Dimension too large. Uploading might encounter issues. Try reduce dimension from ${oe.toLocaleString()}×${he.toLocaleString()}px to ${ve.toLocaleString()}×${xe.toLocaleString()}px.`}case"videoSizeLimit":{const{videoSize:N,videoSizeLimit:Q}=L;return`File size too large. Uploading might encounter issues. Try reduce the file size from ${Ke(N)} to ${Ke(Q)} or lower.`}case"videoMatrixLimit":{const{videoMatrix:N,videoMatrixLimit:Q,width:oe,height:he}=L,{newWidth:ve,newHeight:xe}=Pt(N,Q,oe,he);return`Dimension too large. Uploading might encounter issues. Try reduce dimension from ${oe.toLocaleString()}×${he.toLocaleString()}px to ${ve.toLocaleString()}×${xe.toLocaleString()}px.`}case"videoFrameRateLimit":return"Frame rate too high. Uploading might encounter issues."}};return t(Ce,{children:[t("div",{class:"media-attachment",children:[t("div",{class:"media-preview",tabIndex:"0",onClick:()=>{j(!0)},children:S==="image"?t("img",{src:k,alt:"",onLoad:A=>{if(!z)return;const{naturalWidth:$,naturalHeight:L}=A.target;E({matrix:$*L,width:$,height:L})}}):S==="video"||S==="gifv"?t("video",{src:k+"#t=0.1",playsinline:!0,muted:!0,disablePictureInPicture:!0,preload:"metadata",onLoadedMetadata:A=>{if(!z)return;const{videoWidth:$,videoHeight:L}=A.target;$&&L&&T({matrix:$*L,width:$,height:L})}}):S==="audio"?t("audio",{src:k,controls:!0}):null}),O,t("div",{class:"media-aside",children:[t("button",{type:"button",class:"plain close-button",disabled:e,onClick:r,children:t(K,{icon:"x"})}),!!h&&t("button",{type:"button",class:"media-error",title:M(h),onClick:()=>{ae.current&&ae.current.hideToast(),ae.current=ke({text:M(h),duration:1e4})},children:t(K,{icon:"alert"})})]})]}),U&&t(Ve,{onClose:()=>{j(!1)},children:t("div",{id:"media-sheet",class:"sheet sheet-max",children:[t("button",{type:"button",class:"sheet-close",onClick:()=>{j(!1)},children:t(K,{icon:"x"})}),t("header",{children:t("h2",{children:{image:"Edit image description",video:"Edit video description",audio:"Edit audio description"}[S]})}),t("main",{tabIndex:"-1",children:[t("div",{class:"media-preview",children:S==="image"?t("img",{src:k,alt:""}):S==="video"||S==="gifv"?t("video",{src:k,playsinline:!0,controls:!0}):S==="audio"?t("audio",{src:k,controls:!0}):null}),t("div",{class:"media-form",children:[O,t("footer",{children:[S==="image"&&/^(png|jpe?g|gif|webp)$/i.test(X)&&!!le.settings.mediaAltGenerator&&!!ut&&t(vn,{portal:{target:document.body},containerProps:{style:{zIndex:1001}},align:"center",position:"anchor",overflow:"auto",menuButton:t("button",{type:"button",title:"More",class:"plain",children:t(K,{icon:"more",size:"l",alt:"More"})}),children:[t(At,{disabled:m==="loading",onClick:()=>{u("loading"),ie.current=ke({text:"Generating description. Please wait...",duration:-1}),async function(){var A,$;try{const L=new FormData;L.append("image",C);const N=await fetch(ut,{method:"POST",body:L}).then(Q=>Q.json());if(N.error)throw new Error(N.error);ue(N.description)}catch(L){ke(`Failed to generate description${L!=null&&L.message?`: ${L.message}`:""}`)}finally{u("default"),($=(A=ie.current)==null?void 0:A.hideToast)==null||$.call(A)}}()},children:[t(K,{icon:"sparkles2"}),n&&n!=="en"?t("small",{children:["Generate description…",t("br",{}),"(English)"]}):t("span",{children:"Generate description…"})]}),!!n&&n!=="en"&&t(At,{disabled:m==="loading",onClick:()=>{u("loading"),ie.current=ke({text:"Generating description. Please wait...",duration:-1}),async function(){var A,$;try{const L=new FormData;L.append("image",C);const N=`?lang=${n}`,Q=await fetch(ut+N,{method:"POST",body:L}).then(oe=>oe.json());if(Q.error)throw new Error(Q.error);ue(Q.description)}catch(L){ke(`Failed to generate description${L!=null&&L.message?`: ${L.message}`:""}`)}finally{u("default"),($=(A=ie.current)==null?void 0:A.hideToast)==null||$.call(A)}}()},children:[t(K,{icon:"sparkles2"}),t("small",{children:["Generate description…",t("br",{}),"(",bn(n),")"," ",t("span",{class:"more-insignificant",children:"— experimental"})]})]})]}),t("button",{type:"button",class:"light block",onClick:()=>{j(!1)},disabled:m==="loading",children:"Done"})]})]})]})]})})]})}function gi({lang:s,poll:e,disabled:n,onInput:a=()=>{},maxOptions:r,maxExpiration:m,minExpiration:u,maxCharactersPerOption:v}){const{options:g,expiresIn:R,multiple:C}=e;return t("div",{class:`poll ${C?"multiple":""}`,children:[t("div",{class:"poll-choices",children:g.map((k,z)=>t("div",{class:"poll-choice",children:[t("input",{required:!0,type:"text",value:k,disabled:n,maxlength:v,placeholder:`Choice ${z+1}`,lang:s,spellCheck:"true",dir:"auto",onInput:Z=>{const{value:D}=Z.target;g[z]=D,a(e)}}),t("button",{type:"button",class:"plain2 poll-button",disabled:n||g.length<=1,onClick:()=>{g.splice(z,1),a(e)},children:t(K,{icon:"x",size:"s"})})]},z))}),t("div",{class:"poll-toolbar",children:[t("button",{type:"button",class:"plain2 poll-button",disabled:n||g.length>=r,onClick:()=>{g.push(""),a(e)},children:"+"})," ",t("label",{class:"multiple-choices",children:[t("input",{type:"checkbox",checked:C,disabled:n,onChange:k=>{const{checked:z}=k.target;e.multiple=z,a(e)}})," ","Multiple choices"]}),t("label",{class:"expires-in",children:["Duration"," ",t("select",{value:R,disabled:n,onChange:k=>{const{value:z}=k.target;e.expiresIn=z,a(e)},children:Object.entries(Kt).filter(([k,z])=>z>=u&&z<=m).map(([k,z])=>t("option",{value:z,children:k},z))})]})]}),t("div",{class:"poll-toolbar",children:t("button",{type:"button",class:"plain remove-poll-button",disabled:n,onClick:()=>{a(null)},children:"Remove poll"})})]})}function be(s){return s.replace(/[&<>"']/g,function(e){return"&#"+e.charCodeAt(0)+";"})}function Ot(s){for(let e in s)(s[e]===null||s[e]===void 0)&&delete s[e];return s}function fi({onClose:s=()=>{},onSelect:e=()=>{},defaultSearchTerm:n}){const{masto:a}=bt(),[r,m]=H("default"),[u,v]=H([]),[g,R]=H({}),[C,k]=H(0),z=async c=>{if(!(c!=null&&c.length))return;const h=await yn(c,g);h&&R({...g,...h})},Z=c=>{c&&(m("loading"),(async()=>{try{const h=await a.v1.accounts.search.list({q:c,limit:40,resolve:!1});v(h),z(h),m("default")}catch{m("error")}})())},D=Qe(Z,1e3);ee(()=>{Z()},[Z]);const I=W();ee(()=>{I.current&&(I.current.focus(),I.current.value&&(I.current.selectionStart=I.current.value.length,I.current.selectionEnd=I.current.value.length))},[]),ee(()=>{n&&Z(n)},[n]);const se=c=>{const h=c.acct;e(h),s()};_e("enter",()=>{const c=u[C];c&&se(c)},{preventDefault:!0,enableOnFormTags:["input"]});const J=W();return _e("down",()=>{C<u.length-1?k(C+1):k(0),setTimeout(()=>{const c=J.current.querySelector(".selected");c&&c.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},1)},{preventDefault:!0,enableOnFormTags:["input"]}),_e("up",()=>{C>0?k(C-1):k(u.length-1),setTimeout(()=>{const c=J.current.querySelector(".selected");c&&c.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},1)},{preventDefault:!0,enableOnFormTags:["input"]}),t("div",{id:"mention-sheet",class:"sheet",children:[!!s&&t("button",{type:"button",class:"sheet-close",onClick:s,children:t(K,{icon:"x"})}),t("header",{children:t("form",{onSubmit:c=>{var h;c.preventDefault(),(h=D.flush)==null||h.call(D)},children:t("input",{ref:I,required:!0,type:"search",class:"block",placeholder:"Search accounts",onInput:c=>{const{value:h}=c.target;D(h)},autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellCheck:"false",dir:"auto",defaultValue:n||""})})}),t("main",{children:(u==null?void 0:u.length)>0?t("ul",{ref:J,class:`accounts-list ${r==="loading"?"loading":""}`,children:u.map((c,h)=>{const p=g[c.id];return t("li",{class:h===C?"selected":"",children:[t(Ht,{avatarSize:"xxl",account:c,relationship:p,showStats:!0,showActivity:!0}),t("button",{type:"button",class:"plain2",onClick:()=>{se(c)},children:t(K,{icon:"plus",size:"xl"})})]},c.id)})}):r==="loading"?t("div",{class:"ui-state",children:t(et,{abrupt:!0})}):r==="error"?t("div",{class:"ui-state",children:t("p",{children:"Error loading accounts"})}):null})]})}function vi({masto:s,instance:e,onClose:n=()=>{},onSelect:a=()=>{},defaultSearchTerm:r}){const[m,u]=H("default"),v=W([]),[g,R]=H([]),C=Re(()=>Le.account.get("recentlyUsedCustomEmojis")||[]),k=W();ee(()=>{u("loading"),(async()=>{try{const[h,p]=await Gt(e,s);k.current=p,R(h),u("default")}catch{u("error")}})()},[]);const z=Re(()=>{const h={"--recent--":C.filter(f=>g.find(E=>E.shortcode===f.shortcode))},p=[];return g.forEach(f=>{var E,y;if((y=(E=v.current)==null?void 0:E.push)==null||y.call(E,f),!f.category){p.push(f);return}h[f.category]||(h[f.category]=[]),h[f.category].push(f)}),p.length&&(h["--others--"]=p),h},[g]),Z=W(),[D,I]=H(null),se=It(h=>{var f,E,y;const{value:p}=h.target;if(p){const T=(f=k.current)==null?void 0:f.search(p,{limit:vt});I(T.map(q=>q.item)),(y=(E=Z.current)==null?void 0:E.scrollTo)==null||y.call(E,0,0)}else I(null)},[g]);ee(()=>{r&&(g!=null&&g.length)&&se({target:{value:r}})},[r,se,g]);const J=It(h=>{a==null||a(h),n==null||n(),queueMicrotask(()=>{let p=Le.account.get("recentlyUsedCustomEmojis")||[];const f=p.findIndex(E=>E.shortcode===h.shortcode);f!==-1?(p.splice(f,1),p.unshift(h)):(p.unshift(h),p=p.filter(E=>{var y,T;return(T=(y=v.current)==null?void 0:y.find)==null?void 0:T.call(y,q=>q.shortcode===E.shortcode)}),p=p.slice(0,10)),Le.account.set("recentlyUsedCustomEmojis",p)})},[a]),c=W();return ee(()=>{c.current&&(c.current.focus(),c.current.value&&(c.current.selectionStart=c.current.value.length,c.current.selectionEnd=c.current.value.length))},[]),t("div",{id:"custom-emojis-sheet",class:"sheet",children:[!!n&&t("button",{type:"button",class:"sheet-close",onClick:n,children:t(K,{icon:"x"})}),t("header",{children:[t("div",{children:[t("b",{children:"Custom emojis"})," ",m==="loading"?t(et,{}):t("small",{class:"insignificant",children:[" • ",e]})]}),t("form",{onSubmit:h=>{h.preventDefault();const p=D[0];p&&J(`:${p.shortcode}:`)},children:t("input",{ref:c,type:"search",placeholder:"Search emoji",onInput:se,autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellCheck:"false",dir:"auto",defaultValue:r||""})})]}),t("main",{ref:Z,children:D!==null?t("ul",{class:"custom-emojis-matches custom-emojis-list",children:D.map(h=>t("li",{class:"custom-emojis-match",children:t(Yt,{emoji:h,onClick:()=>{J(`:${h.shortcode}:`)},showCode:!0})},h.shortcode))}):t("div",{class:"custom-emojis-list",children:[m==="error"&&t("div",{class:"ui-state",children:t("p",{children:"Error loading custom emojis"})}),m==="default"&&Object.entries(z).map(([h,p])=>!!(p!=null&&p.length)&&t(Ce,{children:[t("div",{class:"section-header",children:{"--recent--":"Recently used","--others--":"Others"}[h]||h}),t(bi,{emojis:p,onSelect:J})]}))]})})]})}const bi=Wt(({emojis:s,onSelect:e})=>{const[n,a]=H(vt),r=s.length>n;return t("section",{children:[s.slice(0,n).map(m=>t(Yt,{emoji:m,onClick:()=>{e(`:${m.shortcode}:`)}},m.shortcode)),r&&t("button",{type:"button",class:"plain small",onClick:()=>a(n+vt),children:[(s.length-n).toLocaleString()," more…"]})]})}),Yt=Wt(({emoji:s,onClick:e,showCode:n})=>{const a=r=>{const u=r.currentTarget.closest("main");if(u){const v=u.getBoundingClientRect(),g=r.currentTarget.getBoundingClientRect(),R=r.currentTarget.classList;g.left<v.left+88?(R.add("edge-left"),R.remove("edge-right")):g.right>v.right-88?(R.add("edge-right"),R.remove("edge-left")):R.remove("edge-left","edge-right")}};return t("button",{type:"button",className:"plain4",onClick:e,"data-title":n?void 0:s.shortcode,onPointerEnter:a,onFocus:a,children:[t("picture",{children:[!!s.staticUrl&&t("source",{srcSet:s.staticUrl,media:"(prefers-reduced-motion: reduce)"}),t("img",{className:"shortcode-emoji",src:s.url||s.staticUrl,alt:s.shortcode,width:"24",height:"24",loading:"lazy",decoding:"async"})]}),n&&t(Ce,{children:[" ",t("code",{children:s.shortcode})]})]})}),ht=20;function yi({onClose:s=()=>{},onSelect:e=()=>{}}){var z,Z,D,I,se,J;const[n,a]=H("default"),[r,m]=H([]),u=W(null),v=W(null),g=W(0),R=W(null);function C({offset:c}){var h,p,f;(h=v.current)!=null&&h.value&&(a("loading"),(f=(p=R.current)==null?void 0:p.scrollTo)==null||f.call(p,{top:0,left:0,behavior:"smooth"}),(async()=>{var E;try{const y={api_key:Gn,q:v.current.value,rating:"g",limit:ht,bundle:"messaging_non_clips",offset:c},T=await fetch("https://api.giphy.com/v1/gifs/search?"+new URLSearchParams(y),{referrerPolicy:"no-referrer"}).then(q=>q.json());g.current=((E=T.pagination)==null?void 0:E.offset)||0,m(T),a("results")}catch{a("error")}})())}ee(()=>{var c;(c=v.current)==null||c.focus()},[]);const k=Qe(()=>{C({offset:0})},1e3);return t("div",{id:"gif-picker-sheet",class:"sheet",children:[!!s&&t("button",{type:"button",class:"sheet-close",onClick:s,children:t(K,{icon:"x"})}),t("header",{children:t("form",{ref:u,onSubmit:c=>{c.preventDefault(),C({offset:0})},children:[t("input",{ref:v,type:"search",name:"q",placeholder:"Search GIFs",required:!0,autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellCheck:"false",dir:"auto",onInput:k}),t("input",{type:"image",class:"powered-button",src:Wn,width:"86",height:"30"})]})}),t("main",{ref:R,class:n==="loading"?"loading":"",children:[n==="default"&&t("div",{class:"ui-state",children:t("p",{class:"insignificant",children:"Type to search GIFs"})}),n==="loading"&&!((z=r==null?void 0:r.data)!=null&&z.length)&&t("div",{class:"ui-state",children:t(et,{abrupt:!0})}),((Z=r==null?void 0:r.data)==null?void 0:Z.length)>0?t(Ce,{children:[t("ul",{children:r.data.map(c=>{const{id:h,images:p,title:f,alt_text:E}=c,{fixed_height_small:y,fixed_height_downsampled:T,fixed_height:q,original:ue}=p,S=y!=null&&y.url?y:T!=null&&T.url?T:q;let{url:X,webp:V,width:U,height:j}=S;+j>100&&(U=U/j*100,j=100);const te=URL.parse(X),O=te.origin+te.pathname;let ie;if(V){const ae=URL.parse(V);ie=ae.origin+ae.pathname}return t("li",{children:t("button",{type:"button",onClick:()=>{const{mp4:ae,url:M}=ue,A=ae||M,$=URL.parse(A),L=$.origin+$.pathname;s(),e({url:L,type:ae?"video/mp4":"image/gif",alt_text:E||f})},children:t("figure",{style:{"--figure-width":U+"px"},children:[t("picture",{children:[ie&&t("source",{srcset:ie,type:"image/webp"}),t("img",{src:O,width:U,height:j,loading:"lazy",decoding:"async",alt:E,referrerpolicy:"no-referrer",onLoad:ae=>{ae.target.style.backgroundColor="transparent"}})]}),t("figcaption",{children:E||f})]})})},h)})}),t("p",{class:"pagination",children:[((D=r.pagination)==null?void 0:D.offset)>0&&t("button",{type:"button",class:"light small",disabled:n==="loading",onClick:()=>{var c;C({offset:((c=r.pagination)==null?void 0:c.offset)-ht})},children:[t(K,{icon:"chevron-left"}),t("span",{children:"Previous"})]}),t("span",{}),((I=r.pagination)==null?void 0:I.offset)+((se=r.pagination)==null?void 0:se.count)<((J=r.pagination)==null?void 0:J.total_count)&&t("button",{type:"button",class:"light small",disabled:n==="loading",onClick:()=>{var c;C({offset:((c=r.pagination)==null?void 0:c.offset)+ht})},children:[t("span",{children:"Next"})," ",t(K,{icon:"chevron-right"})]})]})]}):n==="results"&&t("div",{class:"ui-state",children:t("p",{children:"No results"})}),n==="error"&&t("div",{class:"ui-state",children:t("p",{children:"Error loading GIFs"})})]})]})}export{Ci as default};
//# sourceMappingURL=compose-IeRiPb7Z.js.map