1class BaseSwitcher{constructor(rootEl){this.root=rootEl;this.list=rootEl?.querySelector('.trp-switcher-dropdown-list')||null;this.isOpen=!1;this._pendingFocusOnOpen=!1;if(!this.root||!this.list)return;if(!this.list.id){this.list.id=`trp-list-${Math.random().toString(36).slice(2, 9)}`} 2this._onTe=(e)=>{if(e.target!==this.list||e.propertyName!=='max-height')return;this.root.classList.remove('is-transitioning');if(!this.isOpen){this.list.hidden=!0;this.list.setAttribute('inert','')}else if(this._pendingFocusOnOpen){this._pendingFocusOnOpen=!1;const first=this.list.querySelector('[role="option"], a, button, [tabindex]:not([tabindex="-1"])');first?.focus?.({preventScroll:!0})}};this.list.addEventListener('transitionend',this._onTe);this.collapse();this.setAutoWidth();this.bindKeyboard()} 3_hasAnimatedTransition(){if(!this.list)return!1;const cs=getComputedStyle(this.list);const durationsRaw=cs.transitionDuration||'';if(!durationsRaw)return!1;const durations=durationsRaw.split(',').map(str=>parseFloat(str)||0);return durations.some(d=>d>0)} 4collapse(){this.list.hidden=!0;this.list.setAttribute('inert','');this.setExpanded(!1);this.root.classList.remove('is-transitioning')} 5setAutoWidth(){const bonusWidth=10;const cs=getComputedStyle(this.root);const declaredWidth=cs.getPropertyValue('--switcher-width').trim();if(declaredWidth==='auto'&&this.root.querySelector('.trp-language-item-name')){const initialWidth=this.root.getBoundingClientRect().width;this.root.style.setProperty('--switcher-width',(initialWidth+bonusWidth)+'px')}} 6setExpanded(open){const trigger=this.root.querySelector('.trp-language-item__current[role="button"]');const val=String(!!open);trigger?.setAttribute('aria-expanded',val);this.root.classList.toggle('is-open',!!open)} 7setOpen(open,{source=null}={}){if(!this.root||!this.list||open===this.isOpen)return;const prefersReduced=window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches;const hasTransition=!prefersReduced&&this._hasAnimatedTransition();this.isOpen=open;if(!hasTransition){if(open){this.list.hidden=!1;this.list.removeAttribute('inert');this.setExpanded(!0);this._pendingFocusOnOpen=(source?.type==='keydown');if(this._pendingFocusOnOpen){this._pendingFocusOnOpen=!1;const first=this.list.querySelector('[role="option"], a, button, [tabindex]:not([tabindex="-1"])');first?.focus?.({preventScroll:!0})}}else{this.setExpanded(!1);this.list.hidden=!0;this.list.setAttribute('inert','');this._pendingFocusOnOpen=!1} 8return} 9if(open){this.list.hidden=!1;this.list.removeAttribute('inert');this._pendingFocusOnOpen=(source?.type==='keydown');this.root.classList.add('is-transitioning');requestAnimationFrame(()=>this.setExpanded(!0))}else{this.root.classList.add('is-transitioning');this.setExpanded(!1)}} 10bindKeyboard(){const trigger=this.root.querySelector('.trp-language-item__current[role="button"]');if(!trigger)return;trigger.addEventListener('keydown',(e)=>{const inList=!!e.target.closest?.('.trp-switcher-dropdown-list');if(e.key==='Enter'||e.key===' '){e.preventDefault();this.setOpen(!this.isOpen,{source:e});return} 11if(e.key==='ArrowDown'&&!this.isOpen){e.preventDefault();this.setOpen(!0,{source:e})} 12if(e.key==='Escape'){this.setOpen(!1,{source:e});trigger.focus?.()}})}} 13class ShortcodeSwitcher extends BaseSwitcher{constructor(wrapper){const overlay=wrapper.querySelector('.trp-language-switcher.trp-shortcode-overlay')||[...wrapper.querySelectorAll('.trp-language-switcher')].find(el=>el.classList.contains('trp-shortcode-overlay'));overlay.hidden=!1;overlay.removeAttribute('hidden');overlay.removeAttribute('inert');if('inert' in overlay)overlay.inert=!1;super(overlay);if(!this.root||!this.list)return;const control=this.root.querySelector('.trp-language-item__current[role="button"]');if(control&&this.list&&!control.hasAttribute('aria-controls')){control.setAttribute('aria-controls',this.list.id)} 14const isClickMode=this.root.classList.contains('trp-open-on-click')||wrapper.dataset.openMode==='click'||wrapper.classList.contains('trp-open-on-click');if(isClickMode){this.root.addEventListener('click',(e)=>{const inList=e.target.closest('.trp-switcher-dropdown-list');if(!inList){e.preventDefault();e.stopPropagation();this.setOpen(!this.isOpen,{source:e})}},!0);this.onDocClick=(evt)=>{if(!wrapper.contains(evt.target))this.setOpen(!1,{source:evt})};document.addEventListener('click',this.onDocClick,!0);wrapper.addEventListener('focusout',()=>{setTimeout(()=>{if(!wrapper.contains(document.activeElement)){this.setOpen(!1,{source:'keyboard'})}},0)})}else{this.root.addEventListener('mouseenter',(e)=>this.setOpen(!0,{source:e}));this.root.addEventListener('mouseleave',(e)=>this.setOpen(!1,{source:e}))}}} 15class FloaterSwitcher extends BaseSwitcher{constructor(el){super(el);el.addEventListener('mouseenter',(e)=>this.setOpen(!0,{source:e}));el.addEventListener('mouseleave',(e)=>this.setOpen(!1,{source:e}));this.onDocClick=(evt)=>{if(!el.contains(evt.target))this.setOpen(!1,{source:evt})};document.addEventListener('click',this.onDocClick,!0)}} 16document.addEventListener('DOMContentLoaded',()=>{initLanguageSwitchers(document);
16if(inGutenberg()&&!getEditorDoc().querySelector(WRAPPER)){observeWrapperUntilFound()} 17if(!inGutenberg()) 18observeShortcodeSwitcher()});const TRP_BOUND=new WeakSet();const mark=(el)=>TRP_BOUND.add(el);const isMarked=(el)=>TRP_BOUND.has(el);const WRAPPER='.trp-shortcode-switcher__wrapper';const OVERLAY='.trp-language-switcher:not(.trp-opposite-button):not(.trp-ald-language-selector)';function inGutenberg(){return document.body?.classList?.contains('block-editor-page')||!!(window.wp?.data?.select?.('core/block-editor'))} 19function getEditorDoc(){const ifr=document.querySelector('iframe[name="editor-canvas"], .editor-canvas__iframe');return(ifr&&ifr.contentDocument)?ifr.contentDocument:document} 20function initLanguageSwitchers(root=document){const floater=root.querySelector('.trp-language-switcher.trp-ls-dropdown:not(.trp-shortcode-switcher):not(.trp-opposite-language)');if(floater) 21new FloaterSwitcher(floater);root.querySelectorAll(WRAPPER).forEach(wrapper=>{const overlay=wrapper.querySelector(OVERLAY);if(overlay&&!isMarked(overlay)){mark(overlay);new ShortcodeSwitcher(wrapper)}})} 22function observeShortcodeSwitcher(){const initWrapper=(wrapper)=>{if(!wrapper) 23return;const overlay=wrapper.querySelector(OVERLAY);if(!overlay||isMarked(overlay)) 24return;mark(overlay);new ShortcodeSwitcher(wrapper)} 25const mo=new MutationObserver((mutations)=>{for(const m of mutations){for(const n of m.addedNodes){if(n.nodeType!==1) 26continue;if(n.matches?.(WRAPPER)) 27initWrapper(n);n.querySelectorAll?.(WRAPPER).forEach(initWrapper)}}});mo.observe(document,{childList:!0,subtree:!0})} 28function observeWrapperUntilFound(){const edDoc=getEditorDoc();const existing=edDoc.querySelector(WRAPPER);if(existing){initLanguageSwitchers(edDoc);return} 29const findCanvasIframe=()=>document.querySelector('iframe[name="editor-canvas"], .editor-canvas__iframe');const iframeNow=findCanvasIframe();if(iframeNow){watchIframe(iframeNow);return} 30const outerMO=new MutationObserver((mutations)=>{for(const m of mutations){for(const n of m.addedNodes){if(n.nodeType!==1)continue;const iframe=n.matches?.('iframe[name="editor-canvas"], .editor-canvas__iframe')?n:n.querySelector?.('iframe[name="editor-canvas"], .editor-canvas__iframe');if(iframe){outerMO.disconnect();watchIframe(iframe);return} 31const wrapper=n.matches?.(WRAPPER)?n:n.querySelector?.(WRAPPER);if(wrapper){outerMO.disconnect();initLanguageSwitchers(document);return}}}});outerMO.observe(document,{childList:!0,subtree:!0});function watchIframe(iframe){tryAttachInside();iframe.addEventListener('load',tryAttachInside);function tryAttachInside(){let doc;try{doc=iframe.contentDocument||iframe.contentWindow?.document}catch(e){console.warn('Cannot access iframe content due to cross-origin restrictions',e);return} 32if(!doc)return;const hit=doc.querySelector(WRAPPER);if(hit){initLanguageSwitchers(doc);return} 33const innerMO=new MutationObserver((muts)=>{for(const mm of muts){for(const nn of mm.addedNodes){if(nn.nodeType!==1)continue;if(nn.matches?.(WRAPPER)||nn.querySelector?.(WRAPPER)){innerMO.disconnect();initLanguageSwitchers(doc);return}}} 34if(doc.querySelector(WRAPPER)){innerMO.disconnect();initLanguageSwitchers(doc)}});innerMO.observe(doc,{childList:!0,subtree:!0})}}}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.