@gjsify/example-gtk-adwaita-storybook 0.64.13-next.283 → 0.64.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-main.js +3 -3
- package/package.json +6 -7
package/dist/browser-main.js
CHANGED
|
@@ -12,10 +12,10 @@ var e=Object.defineProperty,__name=(t,n)=>e(t,`name`,{value:n,configurable:!0});
|
|
|
12
12
|
\v\f\r`.includes(e[r]);)r++;let i=e[r]===`-`;(e[r]===`-`||e[r]===`+`)&&r++;let digit=e=>e===void 0?-1:parseInt(e,n);n===16&&e[r]===`0`&&(e[r+1]===`x`||e[r+1]===`X`)&&digit(e[r+2])>=0&&(r+=2);let a=r,o=0n;for(;r<e.length&&/^[0-9A-Fa-f]$/.test(e[r])&&digit(e[r])>=0;)o=o*(n===16?16n:10n)+fn[digit(e[r])],r++;if(r===a)return{value:0n,end:t,isOverflow:!1};let s=(1n<<64n)-1n;return o>s?{value:s,end:r,isOverflow:!0}:{value:i&&o>0n?s+1n-o:o,end:r,isOverflow:!1}}const isPermittedCharacter=e=>0n<e&&e<=55295n||57344n<=e&&e<=65533n||65536n<=e&&e<=1114111n,pn=`most likely you used an ampersand character without intending to start an entity — escape ampersand as &`,mn=[[`lt;`,`<`],[`gt;`,`>`],[`amp;`,`&`],[`quot;`,`"`],[`apos;`,`'`]];function unescape(e,t,n,r){let fail=(r,i)=>{throw new MarkupFailure(`Error on line ${markupPosition(e,n).line-(t.slice(r).match(/\n/g)?.length??0)}: ${i}`,n)},i=``;for(let e=0;e<t.length;e++){let n=t[e];if(r&&(n===` `||n===`
|
|
13
13
|
`)&&(n=` `),n===`\r`&&(n=r?` `:`
|
|
14
14
|
`,t[e+1]===`
|
|
15
|
-
`&&e++),t[e]!==`&`){i+=n;continue}if(e++,t[e]===`#`){e++;let n=10;t[e]===`x`&&(n=16,e++);let r=strtoul(t,e,n);r.end===e||r.isOverflow?fail(e,`Failed to parse “${t.slice(e,r.end)}”, which should have been a digit inside a character reference (ê for example) — perhaps the digit is too large`):t[r.end]===`;`?isPermittedCharacter(r.value)||fail(e,`Character reference “${t.slice(e,r.end)}” does not encode a permitted character`):fail(e,`Character reference did not end with a semicolon; ${pn}`),i+=String.fromCodePoint(Number(r.value)),e=r.end;continue}let a=mn.find(([n])=>t.startsWith(n,e));if(a!==void 0){i+=a[1],e+=a[0].length-1;continue}t[e]===`;`&&fail(e,`Empty entity “&;” seen; valid entities are: & " < > '`);let o=t.indexOf(`;`,e);o>=0&&fail(e,`Entity name “${t.slice(e,o)}” is not known`),fail(e,`Entity did not end with a semicolon; ${pn}`)}return i}function parseMarkup$1(e,t){try{return scan(e,t),null}catch(t){if(!(t instanceof MarkupFailure))throw t;return{message:t.message,...markupPosition(e,t.at)}}}__name(parseMarkup$1,`parseMarkup`);function scan(e,t){let n=e.length,r=[],i=0,a=0,o=0,s=!0,c=[],l=``,u=``,d=`"`,f=0,p=0,top=()=>r[r.length-1]??``,at=t=>String.fromCodePoint(e.codePointAt(t)),fail=t=>{let n=markupPosition(e,a);throw new MarkupFailure(`Error on line ${n.line} char ${n.character}: ${t}`,a)},skipSpaces=()=>{for(;a<n&&isXmlSpace(e[a]);)a++},nameEnd=()=>{for(;a<n&&!isNameEnd(e[a])&&!isXmlSpace(e[a]);)a++},emitStart=()=>{let e=nameError(top());e!==null&&fail(e);let n=t.start(top(),c);if(n!==null)throw new MarkupFailure(n,a)},emitEnd=()=>{t.end(r.pop())};for(;a<n;)switch(i){case 0:if(skipSpaces(),a===n)break;e[a]!==`<`&&fail(`Document must begin with an element (e.g. <book>)`),a++,i=1,s=!1;break;case 1:e[a]===`?`||e[a]===`!`?(f=a-1,p=1,i=14):e[a]===`/`?(a++,i=11):isNameEnd(e[a])?fail(`“${at(a)}” is not a valid character following a “<” character; it may not begin an element name`):(o=a,i=4);break;case 4:if(nameEnd(),a===n)break;r.push(e.slice(o,a)),c=[],i=7;break;case 7:if(skipSpaces(),a===n)break;e[a]===`/`?(a++,i=3,emitStart()):e[a]===`>`?(a++,i=2,emitStart()):e[a]===`=`?fail(`Odd character “=”, expected a “>” or “/” character to end the start tag of element “${top()}”, or optionally an attribute; perhaps you used an invalid character in an attribute name`):(o=a,i=5);break;case 5:if(nameEnd(),a===n)break;l=e.slice(o,a),i=6;break;case 6:{if(skipSpaces(),a===n)break;let t=nameError(l);t!==null&&fail(t),c.push(l),e[a]!==`=`&&fail(`Odd character “${at(a)}”, expected a “=” after attribute name “${l}” of element “${top()}”`),a++,i=8;break}case 8:if(skipSpaces(),a===n)break;e[a]!==`"`&&e[a]!==`'`&&fail(`Odd character “${at(a)}”, expected an open quote mark after the equals sign when giving value for attribute “${l}” of element “${top()}”`),d=e[a],a++,o=a,i=9;break;case 9:{let t=e.indexOf(d,a);if(t<0){a=n;break}a=t,unescape(e,e.slice(o,t),t,!0),a++,i=7;break}case 3:e[a]!==`>`&&fail(`Odd character “${at(a)}”, expected a “>” character to end the empty-element tag “${top()}”`),a++,i=2,emitEnd();break;case 2:r.length===0?i=0:(o=a,i=10);break;case 10:{let r=e.indexOf(`<`,a);if(r<0){a=n;break}a=r;let s=e.slice(o,r);s.length>0&&t.text(unescape(e,s,r,!1),top()),a++,i=1;break}case 11:isNameEnd(e[a])&&fail(`“${at(a)}” is not a valid character following the characters “</”; “${at(a)}” may not begin an element name`),o=a,i=12;break;case 12:if(nameEnd(),a===n)break;u=e.slice(o,a),i=13;break;case 13:if(skipSpaces(),a===n)break;e[a]!==`>`&&fail(`“${at(a)}” is not a valid character following the close element name “${u}”; the allowed character is “>”`),r.length===0&&fail(`Element “${u}” was closed, no element is currently open`),u!==top()&&fail(`Element “${u}” was closed, but the currently open element is “${top()}”`),a++,i=2,emitEnd();break;case 14:for(;a<n;a++){if(e[a]===`<`&&p++,e[a]!==`>`)continue;p--;let t=e.slice(f,a);if(t[1]===`?`&&t.endsWith(`?`)||t.startsWith(`<!--`)&&t.endsWith(`--`)||t.startsWith(`<![CDATA[`)&&t.endsWith(`]]`)||t.startsWith(`<!DOCTYPE`)&&p===0)break}if(a===n)break;a++,i=2;break}s&&fail(`Document was empty or contained only whitespace`);let m=r.length===0;switch(i){case 1:fail(`Document ended unexpectedly just after an open angle bracket “<”`);break;case 2:case 10:m||fail(`Document ended unexpectedly with elements still open — “${top()}” was the last element opened`);break;case 3:fail(`Document ended unexpectedly, expected to see a close angle bracket ending the tag <${top()}/>`);break;case 4:fail(`Document ended unexpectedly inside an element name`);break;case 5:case 6:fail(`Document ended unexpectedly inside an attribute name`);break;case 7:fail(`Document ended unexpectedly inside an element-opening tag.`);break;case 8:fail(`Document ended unexpectedly after the equals sign following an attribute name; no attribute value`);break;case 9:fail(`Document ended unexpectedly while inside an attribute value`);break;case 11:case 12:case 13:fail(m?`Document ended unexpectedly inside the close tag for an unopened element`:`Document ended unexpectedly inside the close tag for element “${top()}”`);break;case 14:fail(`Document ended unexpectedly inside a comment or processing instruction`);break;case 0:break}}const R={NORMAL:0,HIGH:1},hn=new WeakMap;var Toast=class extends GObjectObject$1{static{this[x]=`Adw.Toast`}get_title(){return this.title}set_title(e){this.title=e}get_timeout(){return this.timeout}set_timeout(e){this.timeout=e}get_priority(){return this.priority}set_priority(e){this.priority=e}get_button_label(){return this.button_label}set_button_label(e){this.button_label=e}get_action_name(){return this.action_name}set_action_name(e){this.action_name=e}get_use_markup(){return this.use_markup}set_use_markup(e){this.use_markup=e}dismiss(){hn.has(this)&&this.emit(`dismissed`)}};registerBaseClass(Toast,`AdwToast`,{"button-clicked":[],dismissed:[]},[y.string(`title`,``,``,v.READWRITE,``),y.uint(`timeout`,``,``,v.READWRITE,0,Dt,5),y.int(`priority`,``,``,v.READWRITE,R.NORMAL,R.HIGH,R.NORMAL),y.string(`button-label`,``,``,v.READWRITE,null),y.string(`action-name`,``,``,v.READWRITE,null),y.boolean(`use-markup`,``,``,v.READWRITE,!0)]);var ToastOverlayQueue=class{constructor(e){this._queue=[],this._handlers=new Map,this._current=null,this._timer=null,this._options=e}get current(){return this._current}get pending(){return this._queue.length}add_toast(e){let t=hn.get(e);if(t===this){this._current===e?this._startTimer(e):this._bump(e);return}if(t!==void 0)throw Error(`Adding toast '${e.title}', but it has already been added to a different AdwToastOverlay`);if(hn.set(e,this),this._handlers.set(e,e.connect(`dismissed`,()=>this._dismissed(e))),this._current===null)this._show(e);else if(e.priority===R.HIGH){let t=this._current;this._queue.unshift(t),this._hideCurrent(),this._show(e)}else this._queue.push(e)}dismiss_all(){for(let e of this._queue.splice(0))this._disconnect(e),e.dismiss(),hn.delete(e);this._current?.dismiss()}_dismissed(e){if(this._disconnect(e),hn.delete(e),e===this._current){this._hideCurrent();let e=this._queue.shift();e&&this._show(e)}else{let t=this._queue.indexOf(e);t!==-1&&this._queue.splice(t,1)}}_bump(e){if(this._queue.splice(this._queue.indexOf(e),1),e.priority===R.HIGH){this._queue.unshift(e);return}let t=this._queue.findIndex(e=>e.priority!==R.HIGH);this._queue.splice(t===-1?this._queue.length:t,0,e)}_show(e){this._current=e,this._options.onShow(e),this._startTimer(e)}_hideCurrent(){let e=this._current;e!==null&&(this._clearTimer(),this._current=null,this._options.onHide(e))}_startTimer(e){this._clearTimer(),e.timeout>0&&(this._timer=this._options.scheduler.schedule(()=>{this._timer=null,this._current===e&&e.dismiss()},e.timeout*1e3))}_clearTimer(){this._timer!==null&&(this._options.scheduler.cancel(this._timer),this._timer=null)}_disconnect(e){let t=this._handlers.get(e);t!==void 0&&(e.disconnect(t),this._handlers.delete(e))}};const gn=new Set([`none`,`single`,`multiple`]);function normalizeListSelectionMode(e){return typeof e==`string`&&gn.has(e)?e:`single`}function normalizeSelection(e,t){let n=new Set;for(let r of e)Number.isInteger(r)&&r>=0&&r<t&&n.add(r);return[...n].sort((e,t)=>e-t)}function listViewSelect(e,t,n,r,i,a={}){let o=normalizeSelection(e,r);if(i===`none`)return{selection:[],anchor:t};if(!Number.isInteger(n)||n<0||n>=r)return{selection:o,anchor:t};let s=new Set(o);if(i===`multiple`&&a.extend&&t>=0&&t<r){let e=Math.min(t,n),i=Math.max(t,n),o=[];for(let t=e;t<=i;t++)o.push(t);if(a.modify)if(s.has(t))for(let e of o)s.add(e);else for(let e of o)s.delete(e);else{s.clear();for(let e of o)s.add(e)}return{selection:normalizeSelection(s,r),anchor:n}}return a.modify?s.has(n)?i===`multiple`&&s.delete(n):(i===`multiple`||s.clear(),s.add(n)):(s.clear(),s.add(n)),{selection:normalizeSelection(s,r),anchor:n}}function listViewSelectAll(e,t){return t===`multiple`?Array.from({length:e},(e,t)=>t):[]}var ListViewState=class{constructor(){this._model=[],this._selection=[],this._anchor=-1,this._mode=`single`,this._itemListeners=new Set,this._selectionListeners=new Set}subscribeItems(e){return this._itemListeners.add(e),()=>{this._itemListeners.delete(e)}}subscribeSelection(e){return this._selectionListeners.add(e),()=>{this._selectionListeners.delete(e)}}get model(){return this._model.map(e=>({value:e.value,label:e.label}))}get count(){return this._model.length}get selection(){return[...this._selection]}get selectionMode(){return this._mode}setModel(e){let t=Array.isArray(e)?e:[],n=listItemsChanged(this._model,t);this._model=t.map(e=>({value:e.value,label:e.label}));let r=normalizeSelection(this._selection,this._model.length),i=r.length!==this._selection.length;if(this._selection=r,this._anchor>=this._model.length&&(this._anchor=-1),n)for(let e of[...this._itemListeners])e(n);i&&this._emitSelection(!1)}setSelectionMode(e){e!==this._mode&&(this._mode=e,e===`none`&&this._selection.length>0?(this._selection=[],this._emitSelection(!1)):e===`single`&&this._selection.length>1&&(this._selection=this._selection.includes(this._anchor)?[this._anchor]:[this._selection[0]],this._emitSelection(!1)))}isSelected(e){return this._selection.includes(e)}selectItem(e,t={},n=!0){let r=listViewSelect(this._selection,this._anchor,e,this._model.length,this._mode,t);return this._anchor=r.anchor,this._applySelection(r.selection,n)}selectAll(e=!1){return this._applySelection(listViewSelectAll(this._model.length,this._mode),e)}unselectAll(e=!1){return this._applySelection([],e)}setSelection(e,t=!1){let n=normalizeSelection(e,this._model.length),r=this._mode===`none`?[]:this._mode===`single`?n.slice(0,1):n;return r.length>0&&(this._anchor=r[r.length-1]),this._applySelection(r,t)}itemContext(e){let t=this._model[e];return t===void 0?null:{item:{value:t.value,label:t.label},position:e,selected:this.isSelected(e)}}_applySelection(e,t){return e.length===this._selection.length&&e.every((e,t)=>e===this._selection[t])?!1:(this._selection=e,this._emitSelection(t),!0)}_emitSelection(e){let t={selection:[...this._selection],interactive:e};for(let e of[...this._selectionListeners])e(t)}};function gridViewColumns(e,t,n,r=1,i=7){let a=Math.max(1,Math.floor(r)),o=Math.max(1,Math.floor(i)),s=Math.floor((e+n)/Math.max(1,t+n));return Math.min(Math.max(s,a),Math.max(a,o))}function listItemField(e,t){return t===`value`?e.value:e.label}function normalizeColumnViewColumns(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&`key`in e).map(e=>{let t=e.key===`value`?`value`:`label`;return{key:t,title:e.title===void 0?t:String(e.title),id:e.id===void 0?t:String(e.id),expand:e.expand===!0,fixedWidth:typeof e.fixedWidth==`number`?e.fixedWidth:-1,visible:e.visible!==!1,sortable:e.sortable===!0}}):[]}function parseColumnViewColumns(e){if(!e)return[];try{return normalizeColumnViewColumns(JSON.parse(e))}catch{return[]}}function columnViewSort(e,t){if(t.sortable!==!0)return e;let n=t.id??t.key;return e!==null&&e.column===n?{column:n,descending:!e.descending}:{column:n,descending:!1}}function columnViewTracks(e){return e.filter(e=>e.visible!==!1).map(e=>{let t=e.fixedWidth??-1;return t>0?{kind:`fixed`,css:`${t}px`}:e.expand===!0?{kind:`flex`,weight:1}:{kind:`auto`}})}const _n={indents:0,expander:`none`,level:1};function treeExpanderLayout(e,t={}){if(!e)return _n;let n=t.indentForDepth!==!1,r=t.indentForIcon!==!1,i=t.hideExpander===!0,a=n?Math.max(0,Math.floor(e.depth)):0,o=e.expandable&&!i;return!o&&r&&a++,{indents:a,expander:o?e.expanded?`expanded`:`collapsed`:`none`,level:a+1}}function treeExpanderAction(e,t={}){if(e===`+`||e===`*`)return`expand`;if(e===`-`||e===`/`)return`collapse`;if(e===` `&&t.ctrlKey===!0)return`toggle`;if(t.shiftKey!==!0)return`none`;let n=t.rtl===!0;return e===`ArrowRight`?n?`collapse`:`expand`:e===`ArrowLeft`?n?`expand`:`collapse`:`none`}function treeExpanderExpanded(e,t){switch(t){case`expand`:return!0;case`collapse`:return!1;case`toggle`:return!e;case`none`:return e}}var ExpanderState=class{constructor(){this._expanded=!1,this._enableExpansion=!0,this._listeners=new Set}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}_emit(){for(let e of[...this._listeners])e(this._expanded)}get expanded(){return this._expanded}get enableExpansion(){return this._enableExpansion}setExpanded(e){let t=!!e&&this._enableExpansion;return t===this._expanded?!1:(this._expanded=t,this._emit(),!0)}setEnableExpansion(e){let t=!!e;return t===this._enableExpansion?[]:(this._enableExpansion=t,this.setExpanded(t)?[`expanded`,`enable-expansion`]:[`enable-expansion`])}toggle(){return this.setExpanded(!this._expanded)}expand(){return this.setExpanded(!0)}collapse(){return this.setExpanded(!1)}};function watchItemsChanged(e,t){if(typeof e.connect!=`function`||typeof e.disconnect!=`function`)return()=>{};let n=e.connect(`items-changed`,(...e)=>{let[n,r,i]=e.slice(1);t({position:n??0,removed:r??0,added:i??0})});return()=>void e.disconnect?.(n)}var ComboState=class{constructor(){this._model=null,this._options=[],this._selected=-1,this._unwatch=null,this._listeners=new Set,this._itemListeners=new Set,this._notifyListeners=new Set}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}subscribeNotify(e){return this._notifyListeners.add(e),()=>{this._notifyListeners.delete(e)}}subscribeItems(e){return this._itemListeners.add(e),()=>{this._itemListeners.delete(e)}}_emit(e){let t={selected:this._selected,value:this.selectedValue,label:this.selectedLabel,interactive:e};for(let e of[...this._listeners])e(t)}_notify(e){for(let t of[...this._notifyListeners])t(e)}_emitItems(e){for(let t of[...this._itemListeners])t(e)}_setIndex(e,t){return e===this._selected?!1:(this._selected=e,this._emit(t),this._notify(`selected`),this._notify(`selected-item`),!0)}get model(){return this._model}get options(){return this._options.map(e=>({value:e.value,label:e.label}))}get selectedItem(){return!this._model||this._selected<0?null:this._model.get_item(this._selected)??null}setModel(e){if(e===this._model)return;this._unwatch?.(),this._unwatch=null;let t=this._options;this._model=e,this._options=e?normalizeComboOptions(e):[],this._selected=this._options.length===0?-1:0,e&&(this._unwatch=watchItemsChanged(e,e=>this._onItemsChanged(e)));let n=listItemsChanged(t,this._options);n&&this._emitItems(n),this._emit(!1),e&&(this._notify(`selected`),this._notify(`selected-item`)),this._notify(`model`)}_onItemsChanged(e){this._options=this._model?normalizeComboOptions(this._model):[],this._emitItems(e);let t=this._selected,n=this._options.length;if(t===-1){if(n===0)return;this._selected=0,this._emit(!1),this._notify(`selected-item`),this._notify(`selected`);return}if(!(t<e.position)){if(t>=e.position+e.removed){this._selected=t+e.added-e.removed,this._emit(!1),this._notify(`selected`);return}this._selected=n===0?-1:Math.min(e.position,n-1),this._emit(!1),this._notify(`selected-item`),this._selected!==t&&this._notify(`selected`)}}get selectedIndex(){return this._selected}get presentsChooser(){return this._options.length>1}setSelectedIndex(e){return this.hasIndex(e)?this._setIndex(e,!1):!1}get selectedValue(){return this._options[this._selected]?.value??``}get selectedLabel(){return this._options[this._selected]?.label??``}setSelectedValue(e){let t=this._options.findIndex(t=>t.value===e);return t>=0?this.setSelectedIndex(t):!1}hasIndex(e){return Number.isFinite(e)&&e>=0&&e<this._options.length}select(e){return!this.hasIndex(e)||e===this._selected?!1:this._setIndex(e,!0)}get count(){return this._options.length}},ToggleGroupState=class{constructor(){this._labels=[],this._selected=0,this._listeners=new Set}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}_emit(){let e={selected:this._selected,value:this.selectedValue};for(let t of[...this._listeners])t(e)}get labels(){return this._labels}setLabels(e){this._labels=Array.isArray(e)?e:[],this._selected>=this._labels.length&&(this._selected=0)}get selected(){return this._selected}setSelected(e){let t=Number.isFinite(e)?e:0;return t===this._selected||t<0||t>=this._labels.length?!1:(this._selected=t,this._emit(),!0)}get selectedValue(){return this._labels[this._selected]??``}get count(){return this._labels.length}};function keptToggles(e){let t=new Set,n=[];for(let r of e){let e=r.name??null;e!==null&&t.has(e)||(e!==null&&t.add(e),n.push(r))}return n}function toggleIndexOfName(e,t){return e.indexOf(t)}const vn=[`left`,`right`,`center`,`fill`];function labelDisplayText(e,t,n){let r=e??``,i=t?stripLabelMarkup(r)??r:r;return n?stripMnemonic(i):i}function normalizeLabelXalign$1(e){let t=typeof e==`number`?e:Number.parseFloat(String(e??``));return Number.isFinite(t)?glibClamp(t,0,1):.5}__name(normalizeLabelXalign$1,`normalizeLabelXalign`);function normalizeLabelJustify(e){return vn.includes(e)?e:`left`}function normalizeLabelYalign(e){let t=typeof e==`number`?e:Number.parseFloat(String(e??``));return Number.isFinite(t)?glibClamp(t,0,1):.5}function labelYalignAlignItems(e){return e<.25?`flex-start`:e>.75?`flex-end`:`center`}const yn=[`none`,`start`,`middle`,`end`];function normalizeLabelEllipsize(e){return yn.includes(e)?e:`none`}function labelEllipsizeOverflowValue(e){return e===`none`?`clip`:`ellipsis`}const bn=[`word`,`char`,`word-char`];function normalizeLabelWrapMode(e){return bn.includes(e)?e:`word`}function normalizeLabelCharCount(e,t){let n=typeof e==`number`?e:Number.parseInt(String(e??``),10);return Number.isFinite(n)?Math.max(t,Math.trunc(n)):t}function normalizeLabelWidthChars(e){return normalizeLabelCharCount(e,-1)}function normalizeLabelMaxWidthChars(e){return normalizeLabelCharCount(e,-1)}function normalizeLabelLines(e){return normalizeLabelCharCount(e,-1)}function labelEffectiveLines(e,t){return t===`none`?null:e>0?e:1}function labelWidthCharsExtent(e,t){return{minCh:e>=0?e:null,maxCh:t>=0?Math.max(e,t):null}}const xn={bold:!1,italic:!1,underline:!1,strikethrough:!1,monospace:!1,sizeSteps:0,script:null,spans:[]};function withTag(e,t,n){switch(t){case`b`:return{...e,bold:!0};case`i`:return{...e,italic:!0};case`u`:return{...e,underline:!0};case`s`:return{...e,strikethrough:!0};case`tt`:return{...e,monospace:!0};case`big`:return{...e,sizeSteps:e.sizeSteps+1};case`small`:return{...e,sizeSteps:e.sizeSteps-1};case`sub`:return{...e,script:`sub`};case`sup`:return{...e,script:`sup`};case`span`:return{...e,spans:[...e.spans,n]};default:return e}}function sameStyle(e,t){let n=e.style;return e.link===t.link&&n.bold===t.style.bold&&n.italic===t.style.italic&&n.underline===t.style.underline&&n.strikethrough===t.style.strikethrough&&n.monospace===t.style.monospace&&n.sizeSteps===t.style.sizeSteps&&n.script===t.style.script&&n.spans.length===t.style.spans.length&&n.spans.every((e,n)=>e===t.style.spans[n])}function labelMarkupRender(e,t=[]){let n=parseLabelMarkup(e??``);if(n===null)return null;let r=[],i=[],a=``,walk=(e,t)=>{for(let n of e){if(n.kind===`text`){if(n.text===``)continue;let e=r[r.length-1];e!==void 0&&sameStyle(e,t)?r[r.length-1]={...e,text:e.text+n.text}:r.push({text:n.text,style:t.style,link:t.link}),a+=n.text;continue}if(n.kind===`link`){let e=i.length,r=a.length;i.push({href:n.href,title:n.title,cssClass:n.cssClass,start:r,end:r,visited:!1}),walk(n.children,{style:t.style,link:e}),i[e]={...i[e],end:a.length};continue}walk(n.children,{style:withTag(t.style,n.tag,n.attributes),link:t.link})}};return walk(n,{style:xn,link:null}),{text:a,runs:r,links:labelLinksInheritVisited(i,t)}}function labelLinksInheritVisited(e,t){return t.length===0?e:e.map(e=>{let n=t.find(t=>t.href===e.href);return n===void 0||!n.visited?e:{...e,visited:!0}})}function labelLinksHaveTooltip(e){return e.some(e=>e.title!==null)}function labelHasLinks(e){return e.length>0}function labelActivateLink(e,t){return t.emit()?!0:t.rooted?(t.launch(e),!0):!1}function labelLinkVisited(e,t){let n=e[t];return n===void 0||n.visited?e:e.map(e=>e.href===n.href?{...e,visited:!0}:e)}const Sn=[0,1,2],Cn=new WeakMap;function syncDirection(e){let t=Cn.get(e);t===void 0||!e.isConnected||(t===0?e.removeAttribute(`dir`):e.dir=t===2?`rtl`:`ltr`)}function widgetTreeMembers(){return{set_direction(e){if(!Sn.includes(e))throw TypeError(`${e} is not a valid value for enum argument dir`);Cn.set(this,e),syncDirection(this)},get_direction(){return Cn.get(this)??1},get_visible(){return!this.hasAttribute(`hidden`)},set_visible(e){this.toggleAttribute(`hidden`,!e)},get_first_child(){return this.firstElementChild},get_last_child(){return this.lastElementChild},get_next_sibling(){return this.nextElementSibling},get_prev_sibling(){return this.previousElementSibling},get_parent(){return this.parentElement},get_width(){return this.offsetWidth},get_height(){return this.offsetHeight},compute_point(e,t){return computePoint(this,e,t)},add_css_class(e){this.classList.add(e)},remove_css_class(e){this.classList.remove(e)},has_css_class(e){return this.classList.contains(e)},insert_action_group(e,t){insertActionGroup(this,e,t)}}}const wn=`Back`;function describeNavigationDiagnostic(e){switch(e.code){case`duplicate-tag`:return`Duplicate page tag in AdwNavigationView: ${e.tag}`;case`already-in-stack`:return e.tag===void 0?`Page '${e.title}' is already in navigation stack`:`Page with the tag '${e.tag}' is already in navigation stack`;case`tag-not-found`:return`No page with the tag '${e.tag}' found in AdwNavigationView`;case`not-in-stack`:return`Page '${e.title}' is not in the navigation stack`}}var NavigationViewState=class{constructor(e={}){this._registry=new Map,this._tags=new Map,this._stack=[],this._listeners=new Set,this._pendingRemoval=null,this._animateTransitions=e.animateTransitions??!0,this._popOnEscape=e.popOnEscape??!0,this._onDiagnostic=e.onDiagnostic??null}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}get stack(){return[...this._stack]}get depth(){return this._stack.length}get pages(){return[...this._registry.keys()]}get visiblePage(){return this._stack.length===0?null:this._stack[this._stack.length-1]}get visiblePageTag(){let e=this.visiblePage;return e===null?null:this.tagOf(e)}get animateTransitions(){return this._animateTransitions}get popOnEscape(){return this._popOnEscape}setAnimateTransitions(e){let t=!!e;return t===this._animateTransitions?!1:(this._animateTransitions=t,!0)}setPopOnEscape(e){let t=!!e;return t===this._popOnEscape?!1:(this._popOnEscape=t,!0)}isRegistered(e){return this._registry.has(e)}isInStack(e){return this._stack.includes(e)}isRemoveOnPop(e){return this._registry.get(e)?.removeOnPop===!0}tagOf(e){return this._registry.get(e)?.tag??null}titleOf(e){return this._registry.get(e)?.title??``}canPopOf(e){return this._registry.get(e)?.canPop??!0}findPage(e){return this._tags.get(e)??null}getPreviousPage(e){let t=this._stack.indexOf(e);return t<=0?null:this._stack[t-1]}add(e,t={}){let n=this._registry.get(e);return n===void 0?this._addPage(e,t,!0):n.removeOnPop&&this._stack.includes(e)?(n.removeOnPop=!1,!0):(n.tag!==null&&this._diagnose({code:`duplicate-tag`,tag:n.tag}),!1)}remove(e){let t=this._registry.get(e);return t===void 0?!1:(this._pendingRemoval===e&&(this._pendingRemoval=null),this._stack.includes(e)?(t.removeOnPop=!0,!0):(this._unregister(e),!0))}setTag(e,t){let n=this._registry.get(e);if(n===void 0)return!1;let r=t??null;return r===n.tag?!1:r!==null&&this._tags.has(r)?(this._diagnose({code:`duplicate-tag`,tag:r}),!1):(n.tag!==null&&this._tags.delete(n.tag),n.tag=r,r!==null&&this._tags.set(r,e),!0)}setTitle(e,t){if(typeof t!=`string`)return!1;let n=this._registry.get(e);return n===void 0||n.title===t?!1:(n.title=t,!0)}setCanPop(e,t){let n=this._registry.get(e);if(n===void 0)return!1;let r=!!t;return r===n.canPop?!1:(n.canPop=r,!0)}push(e,t={}){return this._maybeAddPage(e,t)?this._pushToStack(e,`push`,this._animateTransitions,!1):!1}pushByTag(e){let t=this.findPage(e);return t===null?(this._diagnose({code:`tag-not-found`,tag:e}),!1):this._pushToStack(t,`push`,this._animateTransitions,!0)}pop(){let e=this.visiblePage;if(e===null)return!1;let t=this.getPreviousPage(e);return t===null?!1:(this._popFromStack(t,this._animateTransitions),!0)}popToPage(e){return e===this.visiblePage?!1:this._stack.includes(e)?(this._popFromStack(e,this._animateTransitions),!0):(this._diagnose({code:`not-in-stack`,title:this.titleOf(e)}),!1)}popToTag(e){let t=this.findPage(e);return t===null?(this._diagnose({code:`tag-not-found`,tag:e}),!1):this.popToPage(t)}replace(e,t){let n=this.visiblePage,r=n,i=n!==null,a=!1,o=[],s=new Set;for(let t of e)t!=null&&s.add(t);for(let e=this._stack.length-1;e>=0;e--){let t=this._stack[e],n=this._registry.get(t);n===void 0||!n.removeOnPop||s.has(t)||(t===r&&(a=n.tag!==null,r=null),this._unregister(t)&&o.push(t))}this._stack.length=0;let c=new Set;for(let n of e)if(n!=null){if(c.has(n)){this._diagnose({code:`already-in-stack`,title:this.titleOf(n)});continue}this._maybeAddPage(n,t?.(n)??{})&&(c.add(n),this._stack.push(n))}let l=this.visiblePage,u;u=l===null?r===null?{animate:!1,tagNotify:i&&a,removeAfterTransition:null}:this._beginSwitch(r,null,!0,!1,o):r===l?{animate:!1,tagNotify:!1,removeAfterTransition:null}:this._beginSwitch(r,l,!0,!1,o),this._emitChange(`replace`,n,!0,[],o,u)}replaceWithTags(e){let t=e.map(e=>{let t=this.findPage(e);return t===null&&this._diagnose({code:`tag-not-found`,tag:e}),t});this.replace(t)}finishTransition(){let e=this._resolvePendingRemoval();return e===null?[]:[e]}canGoBack(){let e=this.visiblePage;return e===null||!this.canPopOf(e)?!1:this.getPreviousPage(e)!==null}backButtonTooltip(e=wn){if(!this.canGoBack())return null;let t=this.getPreviousPage(this.visiblePage);if(t===null)return null;let n=this.titleOf(t);return n.length>0?n:e}popFromShortcut(){let e=this.visiblePage;return e===null?`propagate`:this.canPopOf(e)?this.pop()?`stop`:`propagate`:`stop`}popFromEscape(){return this._popOnEscape?this.popFromShortcut():`propagate`}_diagnose(e){this._onDiagnostic?.(e)}_emit(e){for(let t of[...this._listeners])t(e)}_emitChange(e,t,n,r,i,a){let o=this.visiblePage;this._emit({stack:[...this._stack],visiblePage:o,visiblePageTag:o===null?null:this.tagOf(o),previousVisiblePage:t,reason:e,popped:[...r],removed:[...i],removeAfterTransition:a.removeAfterTransition,animate:a.animate,pop:n,tagNotify:a.tagNotify})}_addPage(e,t,n){let r=t.tag??null;return r!==null&&this._tags.has(r)?(this._diagnose({code:`duplicate-tag`,tag:r}),!1):(this._registry.set(e,{tag:r,title:t.title??``,canPop:t.canPop===void 0?!0:!!t.canPop,removeOnPop:!1}),r!==null&&this._tags.set(r,e),n&&this._stack.length===0&&this._pushToStack(e,`add`,!1,!1),!0)}_maybeAddPage(e,t){if(this._registry.has(e))return!0;let n=t.tag??null;if(n!==null&&this._tags.has(n))return this._diagnose({code:`duplicate-tag`,tag:n}),!1;if(!this._addPage(e,t,!1))return!1;let r=this._registry.get(e);return r!==void 0&&(r.removeOnPop=!0),!0}_pushToStack(e,t,n,r){if(this._stack.includes(e))return this._diagnose(r?{code:`already-in-stack`,tag:this.tagOf(e)}:{code:`already-in-stack`,title:this.titleOf(e)}),!1;let i=this.visiblePage,a=[];this._stack.push(e);let o=this._beginSwitch(i,e,!1,n,a);return this._emitChange(t,i,!1,[],a,o),!0}_popFromStack(e,t){let n=this.visiblePage;if(e===n)return;let r=this._stack.indexOf(e),i=this._stack.slice(r+1).reverse();this._stack.length=r+1;let a=[],o=this._beginSwitch(n,e,!0,t,a);for(let e of i)e!==n&&this._registry.get(e)?.removeOnPop===!0&&this._unregister(e)&&a.push(e);this._emitChange(`pop`,n,!0,i,a,o)}_beginSwitch(e,t,n,r,i){if(this._pendingRemoval!==null&&this._pendingRemoval!==e){let e=this._resolvePendingRemoval();e!==null&&i.push(e)}let a=null;return n&&e!==null&&this._registry.get(e)?.removeOnPop===!0&&!this._stack.includes(e)&&(a=e,this._pendingRemoval=e),{animate:r&&e!==null,tagNotify:e!==null&&this.tagOf(e)!==null||t!==null&&this.tagOf(t)!==null,removeAfterTransition:a}}_resolvePendingRemoval(){let e=this._pendingRemoval;if(e===null)return null;if(this._pendingRemoval=null,this._stack.includes(e)){let t=this._registry.get(e);return t!==void 0&&(t.removeOnPop=!0),null}return this._unregister(e)?e:null}_unregister(e){let t=this._registry.get(e);return t===void 0?!1:(t.tag!==null&&this._tags.get(t.tag)===e&&this._tags.delete(t.tag),this._registry.delete(e),!0)}};function clampSidebarSelection(e,t){return!Number.isInteger(e)||e<0||e>=t?-1:e}function adjustSidebarSelection(e,t,n,r,i,a){if(t===0&&n>0)return clampSidebarSelection(0,n);let o=e>>>0,s=r>>>0;return s<=o&&s+i>o?-1:s<=o?clampSidebarSelection(o+a-i>>>0,n):e}function flattenSidebarItems(e,t){let n=[],r=[],i=0;return e.forEach((e,a)=>{r.push(i),e.items.forEach((e,r)=>{let o=i+r;t&&!t(e,o)||n.push({index:o,sectionIndex:a,sectionItemIndex:r,item:e,titleVisible:stringIsNotEmpty(e.title),subtitleVisible:stringIsNotEmpty(e.subtitle),iconVisible:stringIsNotEmpty(e.iconName)})}),i+=e.items.length}),{items:n,sectionFirstIndex:r}}function deriveSidebarHeaders(e,t){let n=[],r=null;for(let i of t){if(r===i.sectionIndex)continue;let t=r===null;r=i.sectionIndex;let a=e[i.sectionIndex]?.title??``;t&&a.length===0||n.push({sectionIndex:i.sectionIndex,kind:a.length>0?`title`:`separator`,title:a,first:t})}return n}var SidebarState=class{constructor(){this._mode=`sidebar`,this._sections=[],this._filter=null,this._selected=-1,this._items=[],this._sectionFirstIndex=[],this._visibleItems=[],this._headers=[],this._listeners=new Set}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}_emit(e,t){let n={selected:this._selected,previous:e,item:this.selectedItem,interactive:t};for(let e of[...this._listeners])e(n)}_applySelected(e,t){if(e===this._selected)return!1;let n=this._selected;return this._selected=e,this._emit(n,t),!0}_invalidate(){let e=flattenSidebarItems(this._sections),t=this._filter;this._items=e.items,this._sectionFirstIndex=e.sectionFirstIndex,this._visibleItems=t?this._items.filter(e=>t(e.item,e.index)):this._items,this._headers=deriveSidebarHeaders(this._sections,this._visibleItems)}get mode(){return this._mode}setMode(e){return e===this._mode?!1:(this._mode=e,!0)}get selectionVisible(){return this._mode===`sidebar`}get sections(){return this._sections}setSections(e){let t=this.count;this._sections=[...e],this._invalidate();let n=adjustSidebarSelection(adjustSidebarSelection(this._selected,t,0,0,t,0),0,this.count,0,0,this.count);this._applySelected(n,!1)}insertSection(e,t){let n=this.count,r=this._sections.length,i=Number.isInteger(t)&&t>=0&&t<r?t:r;this._sections.splice(i,0,e),this._invalidate();let a=this._sectionFirstIndex[i]??0,o=adjustSidebarSelection(this._selected,n,this.count,a,0,e.items.length);return this._applySelected(o,!1),i}removeSectionAt(e){let t=this.sectionAt(e);if(!t)return!1;let n=this.count,r=this._sectionFirstIndex[e]??0,i=t.items.length;return this._sections.splice(e,1),this._invalidate(),this._applySelected(adjustSidebarSelection(this._selected,n,this.count,r,i,0),!1),!0}removeAllSections(){let e=this.count;this._sections=[],this._invalidate(),this._applySelected(adjustSidebarSelection(this._selected,e,0,0,e,0),!1)}refresh(){this._invalidate()}sectionAt(e){if(!(!Number.isInteger(e)||e<0))return this._sections[e]}sectionFirstIndex(e){return this._sectionFirstIndex[e]??0}get count(){return this._items.length}get items(){return this._items}itemAt(e){if(!(!Number.isInteger(e)||e<0))return this._items[e]?.item}get filter(){return this._filter}setFilter(e){e!==this._filter&&(this._filter=e,this._invalidate())}get visibleItems(){return this._visibleItems}get headers(){return this._headers}get isEmpty(){return this._visibleItems.length===0}get selected(){return this._selected}get selectedItem(){return this.itemAt(this._selected)}setSelected(e){return this._applySelected(clampSidebarSelection(e,this.count),!1)}activate(e){let t=this._visibleItems.find(t=>t.index===e);return!t||t.item.visible===!1||t.item.enabled===!1?{index:e,activated:!1,selectionChanged:!1}:{index:e,activated:!0,selectionChanged:this._applySelected(clampSidebarSelection(e,this.count),!0)}}};const Tn=1200,En=Math.PI*.35,Dn=Math.PI*.015,On=Math.PI*.9,kn=Math.PI*.9,An=Math.PI*.7,jn=Math.PI*1.1,Mn=Math.PI*1.35,z=kn+jn+Mn-An;53*Math.PI*2/z;const Nn=jn-An/2;function normalizeSpinnerAngle(e){let t=e;for(;t<0;)t+=Math.PI*2;for(;t>Math.PI*2;)t-=Math.PI*2;return t}function spinnerArcStart(e){let t=e%z,n=t>jn?1:easeInOutSine(t/jn);return adwLerp(Dn,On,n)-t*On/z}function spinnerArcEnd(e){let t=e%z,n=jn-An,r;return r=t<n?0:t>z-kn?1:easeInOutSine((t-n)/Mn),adwLerp(0,On-Dn,r)-t*On/z}function spinnerArc(e){let t=e,n=normalizeSpinnerAngle(t+spinnerArcStart(t)+En),r=normalizeSpinnerAngle(t+spinnerArcEnd(t)+En),i=n-r;for(;i<=0;)i+=Math.PI*2;return{start:n,end:r,length:i}}function spinnerProgressAt(e){let t=Tn*53;return(e%t+t)%t/Tn*Math.PI*2}const Pn={shift:`shift`,shft:`shift`,control:`control`,ctrl:`control`,ctl:`control`,alt:`alt`,mod1:`alt`,meta:`meta`,super:`super`,hyper:`hyper`,primary:`primary`},Fn=[`hyper`,`super`,`control`,`alt`,`shift`,`meta`],In={hyper:{default:`Hyper`,apple:`Hyper`},super:{default:`Super`,apple:`Super`},control:{default:`Ctrl`,apple:`⌃`},alt:{default:`Alt`,apple:`⌥`},shift:{default:`Shift`,apple:`⇧`},meta:{default:`Meta`,apple:`⌘`}},Ln={Shift:`shift`,Control:`control`,Alt:`alt`,Meta:`meta`,Super:`super`,Hyper:`hyper`},Rn={exclam:`!`,quotedbl:`"`,numbersign:`#`,dollar:`$`,percent:`%`,ampersand:`&`,apostrophe:`'`,parenleft:`(`,parenright:`)`,asterisk:`*`,plus:`+`,comma:`,`,minus:`-`,period:`.`,slash:`/`,colon:`:`,semicolon:`;`,less:`<`,equal:`=`,greater:`>`,question:`?`,at:`@`,bracketleft:`[`,backslash:`\\`,bracketright:`]`,asciicircum:`^`,underscore:`_`,grave:"`",braceleft:`{`,bar:`|`,braceright:`}`,asciitilde:`~`},zn={Left:{default:`←`},Up:{default:`↑`},Right:{default:`→`},Down:{default:`↓`},space:{default:`␣`},Return:{default:`⏎`},Page_Up:{default:`Page_Up`},Page_Down:{default:`Page_Down`},Escape:{apple:`⎋`},Tab:{apple:`⇥`},BackSpace:{apple:`⌫`},Delete:{apple:`⌦`}};function parseAccelerator(e,t=`default`){let n=new Set,r=e;for(;r.startsWith(`<`);){let e=r.indexOf(`>`);if(e===-1)return null;let i=r.slice(1,e).toLowerCase();if(r=r.slice(e+1),i===`release`)continue;let a=Pn[i];if(!a)return null;n.add(a===`primary`?t===`apple`?`meta`:`control`:a)}return r.length===0?null:{modifiers:n,key:r}}function keycapForKey(e,t){let n=/^([A-Za-z]+)_([LR])$/.exec(e);if(n&&Ln[n[1]]){let e=Ln[n[1]];return{label:In[e][t],sideMarker:n[2]}}let r=zn[e];if(r){let e=t===`apple`?r.apple??r.default:r.default;if(e)return{label:e}}let i=/^KP_(.+)$/.exec(e);if(i){let e=printableFor(i[1]);if(e)return{label:`KP ${e.toUpperCase()}`}}let a=printableFor(e);return a?{label:a===`\\`?`Backslash`:a.toUpperCase()}:{label:e.length===1?e.toUpperCase():e}}function printableFor(e){if(e.length===1){let t=e.codePointAt(0)??0;return t>32&&t<127?e:null}return Rn[e]??null}function shortcutKeycaps(e,t=`default`){let n=parseAccelerator(e,t);if(!n)return null;let r=[];for(let e of Fn)n.modifiers.has(e)&&r.push({label:In[e][t]});return r.push(keycapForKey(n.key,t)),r}function accessibleFor(e){return e.map(e=>e.sideMarker?`${e.label} ${e.sideMarker}`:e.label).join(`+`)}function parseShortcutLabel(e,t={}){let{disabledText:n=``,direction:r=`ltr`,platform:i=`default`}=t;if(e.length===0)return{nodes:[{kind:`disabled`,text:n}],accessibleLabel:n,error:null};let a=[],o=``,s=null,combination=e=>{for(let t of e.split(`&`)){let e=shortcutKeycaps(t,i);if(!e)return s=t,!1;a.push({kind:`keys`,keys:e}),o+=accessibleFor(e)}return!0},sequence=e=>{let t=r===`rtl`?`←`:`→`,n=e.split(`+`);for(let[e,r]of n.entries())if(e>0&&(a.push({kind:`separator`,text:t}),o+=t),!combination(r))return!1;return!0},range=e=>{let t=e.indexOf(`...`);return t===-1?sequence(e):sequence(e.slice(0,t))?(a.push({kind:`separator`,text:`⋯`}),o+=`…`,sequence(e.slice(t+3))):!1};for(let[t,n]of e.split(` `).entries())if(t>0&&(a.push({kind:`separator`,text:`/`}),o+=` `),!range(n))break;return{nodes:a,accessibleLabel:o,error:s}}const Bn=[`px`,`pt`,`sp`];function adwLengthToPx(e,t,n=96){switch(e){case`pt`:return t*n/72;case`sp`:return t*n/96;default:return t}}function normalizeLengthUnit(e,t){return Bn.includes(e)?e:t}function isSidebarAtVisualStart(e,t=`ltr`){return e===`start`==(t!==`rtl`)}function fractionOf(e){return e.sidebarWidthFraction??.25}function resolveSidebarBounds(e,t=0,n={}){let r=e.sidebarWidthUnit??`sp`,i=e.dpi??96,a=n.ceil?Math.ceil:Math.trunc,o=adwLengthToPx(r,e.minSidebarWidth??180,i),s=adwLengthToPx(r,e.maxSidebarWidth??280,i),c=a(Math.max(t,o));return{min:c,max:a(Math.max(c,s))}}function resolveOverlaySidebarWidth(e){let t=resolveSidebarBounds(e,e.sidebarChildMin??0,{ceil:!0});if(e.collapsed)return glibClamp(e.totalWidth,t.min,t.max);let n=glibClamp(Math.trunc(e.totalWidth*fractionOf(e)),t.min,t.max);return Math.min(n,e.totalWidth-(e.contentMin??0))}function layoutOverlaySplitView(e){let{totalWidth:t,showProgress:n,collapsed:r}=e,i=e.sidebarWidth,a=isSidebarAtVisualStart(e.sidebarPosition??`start`,e.direction??`ltr`),o=i,s=Math.trunc(i*n),c=s>i,l={shieldVisible:r&&n>0,sidebarPainted:n>0,shadowProgress:1-Math.min(n,+!!r),shadowSide:a?`left`:`right`};return r?(c&&(o=s),{sidebar:{x:a?c?0:s-i:t-s,width:o},content:{x:0,width:t},...l}):(c&&(o=s,s=i),a?{sidebar:{x:s-i,width:o},content:{x:s,width:t-s},...l}:{sidebar:{x:t-(c?o:s),width:o},content:{x:0,width:t-s},...l})}function tagsConflict(e,t){return e==null||t==null?!1:e===t}function resolveNavigationStack(e){let{hasSidebar:t,hasContent:n,showContent:r}=e,i=e.sidebarPosition===`end`;if(e.changingPage&&t&&n)return r?i?{stack:[`content`],transition:`pop`,page:`sidebar`}:{stack:[`sidebar`,`content`],transition:`push`,page:`content`}:i?{stack:[`content`,`sidebar`],transition:`push`,page:`sidebar`}:{stack:[`sidebar`],transition:`pop`,page:`content`};let a=[];return i?(n&&a.push(`content`),t&&(!r||!n)&&a.push(`sidebar`)):(t&&a.push(`sidebar`),n&&(r||!t)&&a.push(`content`)),{stack:a,transition:`replace`,page:null}}function resolveNavigationAction(e){if(e.action===`pop`)return e.showContent&&e.hasSidebar&&e.hasContent?{kind:`set-show-content`,showContent:!1}:{kind:`delegate`};let{tag:t}=e;return e.contentTag!==null&&e.contentTag!==void 0&&t===e.contentTag?e.showContent&&e.collapsed?{kind:`already-in-stack`,tag:t}:{kind:`set-show-content`,showContent:!0}:e.sidebarTag!==null&&e.sidebarTag!==void 0&&t===e.sidebarTag?{kind:`already-in-stack`,tag:t}:{kind:`delegate`}}const B={alreadyInStack:e=>`Page with the tag '${e}' is already in the navigation stack`,notFound:e=>`No page with the tag '${e}' found in AdwNavigationSplitView`,sidebarCollision:e=>`Trying to add sidebar with the tag '${e}' to AdwNavigationSplitView, but content already has the same tag`,contentCollision:e=>`Trying to add content with the tag '${e}' to AdwNavigationSplitView, but sidebar already has the same tag`,sidebarTagCollision:e=>`Trying to set the sidebar's tag to '${e}', but the content already has the same tag`,contentTagCollision:e=>`Trying to set the content's tag to '${e}', but the sidebar already has the same tag`};var NavigationSplitViewState=class{constructor(e={}){this._sidebar=null,this._content=null,this._sidebarTag=null,this._contentTag=null,this._listeners=new Set,this._sidebarPosition=e.sidebarPosition??`start`,this._collapsed=e.collapsed??!1,this._showContent=e.showContent??!1,this._handlers={onCritical:e.onCritical,onDelegate:e.onDelegate}}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}_emit(e,t,n=!1){let r={property:e,interactive:n,plan:t};for(let e of[...this._listeners])e(r)}_critical(e){this._handlers.onCritical?.(e)}_plan(e=!1){return resolveNavigationStack({hasSidebar:this._sidebar!==null,hasContent:this._content!==null,sidebarPosition:this._sidebarPosition,showContent:this._showContent,changingPage:e})}get collapsed(){return this._collapsed}get showContent(){return this._showContent}get sidebarPosition(){return this._sidebarPosition}get sidebar(){return this._sidebar}get content(){return this._content}get sidebarTag(){return this._sidebarTag}get contentTag(){return this._contentTag}get stack(){return this._plan()}get visiblePane(){let{stack:e}=this._plan();return e[e.length-1]??null}setSidebar(e){if(e===this._sidebar)return!1;let t=e?.tag??null;return tagsConflict(t,this._contentTag)?(this._critical(B.sidebarCollision(t)),!1):(this._sidebar=e,this._sidebarTag=t,this._emit(`sidebar`,this._plan()),!0)}setContent(e){if(e===this._content)return!1;let t=e?.tag??null;return tagsConflict(this._sidebarTag,t)?(this._critical(B.contentCollision(t)),!1):(this._content=e,this._contentTag=t,this._emit(`content`,this._plan()),!0)}setTag(e,t){return e===`sidebar`?(this._sidebarTag=t,tagsConflict(this._sidebarTag,this._contentTag)?(this._critical(B.sidebarTagCollision(t)),this._sidebarTag=null,!1):!0):(this._contentTag=t,tagsConflict(this._sidebarTag,this._contentTag)?(this._critical(B.contentTagCollision(t)),this._contentTag=null,!1):!0)}setSidebarPosition(e){return e===this._sidebarPosition?!1:(this._sidebarPosition=e,this._emit(`sidebar-position`,this._plan()),!0)}setCollapsed(e){let t=!!e;return t===this._collapsed?!1:(this._collapsed=t,this._emit(`collapsed`,this._plan()),!0)}setShowContent(e,t=!1){let n=!!e;if(n===this._showContent)return!1;this._showContent=n;let r=this._collapsed&&this._sidebar!==null&&this._content!==null;return this._emit(`show-content`,this._plan(r),t),!0}push(e){return this._runAction(resolveNavigationAction({action:`push`,tag:e,sidebarTag:this._sidebarTag,contentTag:this._contentTag,showContent:this._showContent,collapsed:this._collapsed}),`push`,e)}pop(){return this._runAction(resolveNavigationAction({action:`pop`,hasSidebar:this._sidebar!==null,hasContent:this._content!==null,showContent:this._showContent}),`pop`)}_runAction(e,t,n){switch(e.kind){case`set-show-content`:return this.setShowContent(e.showContent,!0),e;case`already-in-stack`:return this._critical(B.alreadyInStack(e.tag)),e;default:return this._handlers.onDelegate?.(t,n)||t===`pop`?e:(this._critical(B.notFound(n??``)),{kind:`not-found`,tag:n??``})}}};const Vn={animate(e){return e.onValue(e.to),e.onDone(),{cancel:()=>{}}}};var OverlaySplitViewState=class{constructor(e={}){this._swipeActive=!1,this._animation=null,this._listeners=new Set,this._showSidebar=e.showSidebar??!0,this._collapsed=e.collapsed??!1,this._pinSidebar=e.pinSidebar??!1,this._sidebarPosition=e.sidebarPosition??`start`,this._enableShowGesture=e.enableShowGesture??!0,this._enableHideGesture=e.enableHideGesture??!0,this._showProgress=+!!this._showSidebar,this._animator=e.animator??Vn}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}_emit(e,t=!1){let n={property:e,showSidebar:this._showSidebar,collapsed:this._collapsed,showProgress:this._showProgress,shieldVisible:this.shieldVisible,interactive:t};for(let e of[...this._listeners])e(n)}get showSidebar(){return this._showSidebar}get collapsed(){return this._collapsed}get pinSidebar(){return this._pinSidebar}get sidebarPosition(){return this._sidebarPosition}get enableShowGesture(){return this._enableShowGesture}get enableHideGesture(){return this._enableHideGesture}get showProgress(){return this._showProgress}get shieldVisible(){return this._collapsed&&this._showProgress>0}get sidebarPainted(){return this._showProgress>0}get sidebarFocusable(){return!this._collapsed||this._showSidebar}get contentFocusable(){return!this._collapsed||!this._showSidebar}setShowSidebar(e,t={}){let n=!!e;if(n===this._showSidebar)return!1;this._showSidebar=n;let r=+!!n,i=t.animate??!0;return i||(this._cancelAnimation(),this._showProgress=r),this._emit(`show-sidebar`,t.interactive??!1),i&&!this._swipeActive&&this._startAnimation(r,t.velocity??0),!0}setCollapsed(e){let t=!!e;return t===this._collapsed?!1:(this._collapsed=t,this._pinSidebar||this.setShowSidebar(!t,{animate:!1}),this._emit(`collapsed`),!0)}setPinSidebar(e){let t=!!e;return t===this._pinSidebar?!1:(this._pinSidebar=t,this._emit(`pin-sidebar`),!0)}setSidebarPosition(e){return e===this._sidebarPosition?!1:(this._sidebarPosition=e,this._emit(`sidebar-position`),!0)}setEnableShowGesture(e){let t=!!e;return t===this._enableShowGesture?!1:(this._enableShowGesture=t,!0)}setEnableHideGesture(e){let t=!!e;return t===this._enableHideGesture?!1:(this._enableHideGesture=t,!0)}setShowProgress(e){this._showProgress=e,this._emit(`show-progress`)}escape(){return this._showProgress<2**-52||!this._collapsed?!1:(this.setShowSidebar(!1,{interactive:!0}),!0)}dismissShield(){return this.setShowSidebar(!1,{interactive:!0})}get swipeActive(){return this._swipeActive}beginSwipe(){this._cancelAnimation(),this._swipeActive=!0}endSwipe(e,t=0){if(!this._swipeActive)return{kind:`animate`,to:this._showProgress};this._swipeActive=!1;let n=resolveSwipeRelease({to:e,showSidebar:this._showSidebar});return n.kind===`animate`?this._startAnimation(n.to,t):this.setShowSidebar(n.showSidebar,{velocity:t,interactive:!0}),n}get snapPoints(){return resolveSwipeSnapPoints({showProgress:this._showProgress,enableShowGesture:this._enableShowGesture,enableHideGesture:this._enableHideGesture,swipeActive:this._swipeActive})}_cancelAnimation(){this._animation?.cancel(),this._animation=null}_startAnimation(e,t){this._cancelAnimation();let n=!1,r=this._animator.animate({from:this._showProgress,to:e,velocity:t,clamp:e<.5,onValue:e=>this.setShowProgress(e),onDone:()=>{n=!0,this._animation=null}});n||(this._animation=r)}};function resolveSwipeSnapPoints(e){let t=e.showProgress>0||e.enableShowGesture||e.swipeActive,n=e.showProgress<1||e.enableHideGesture||e.swipeActive;return t&&n?[0,1]:[+!!t]}function resolveSwipeStart(e){let t=Math.abs(e.showProgress-1)<2**-52||e.showProgress>1,n=Math.abs(e.showProgress)<2**-52||e.showProgress<0;return!(t&&!e.collapsed&&e.direction===`forward`||n&&!e.enableShowGesture||t&&!e.enableHideGesture)}function resolveSwipeRelease(e){return e.to>0===e.showSidebar?{kind:`animate`,to:e.to}:{kind:`set-show-sidebar`,showSidebar:e.to>0}}function swipeCancelProgress(e){let t=e<0?-Math.round(-e):Math.round(e);return t===0?0:t}function resolveSwipeArea(e){if(!e.isDrag)return{x:0,y:0,width:0,height:0};let t=Math.max(Math.trunc(e.sidebarWidth*e.showProgress),32);return{x:isSidebarAtVisualStart(e.sidebarPosition??`start`,e.direction??`ltr`)?0:e.totalWidth-t,y:0,width:t,height:e.totalHeight}}const Hn={none:`open-menu-symbolic`,down:`pan-down-symbolic`,up:`pan-up-symbolic`,left:`pan-start-symbolic`,right:`pan-end-symbolic`,none:`pan-down-symbolic`},Un=[`none`,`up`,`down`,`left`,`right`],Wn=[`child`,`label`,`icon-name`],Gn={set:Object.freeze([`menu-model`,`popover`]),clear:Object.freeze([`popover`,`menu-model`])};function splitButtonStyleClasses(e,t){let n=[];return t!==null&&t.length>0&&n.push(`image-button`),e!==null&&e.length>0&&n.push(`text-button`),n}function resolveDropdownTooltip(e){return typeof e==`string`&&e.length>0?{text:e,markup:!0}:{text:`More Options`,markup:!1}}function splitButtonArrowIcon(e){return Hn[e]??Hn.down}function splitButtonPopupDirection(e){return e===`none`||!Un.includes(e)?`down`:e}const Kn=splitButtonPopupDirection;function isSplitButtonDirection(e){return typeof e==`string`&&Un.includes(e)}function splitButtonRootState(e,t){return{active:e.active||t.active||e.keyboardActivating||t.keyboardActivating,checked:e.checked||t.checked}}const menuKey=e=>e===null?``:JSON.stringify(e);function internalContent(e){return Object.freeze({adwInternalContent:e})}function derivedPopover(){return Object.freeze({adwDerivedPopover:!0})}var SplitButtonState=class{constructor(){this._mode=`empty`,this._label=null,this._iconName=null,this._child=null,this._useUnderline=!1,this._menuModel=null,this._popover=null,this._direction=`down`,this._dropdownTooltip=``,this._open=!1,this._listeners=new Set}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}_emit(e,t){let n={mode:this._mode,label:this._label,iconName:this.iconName,child:this._child,styleClasses:this.styleClasses,dropdownEnabled:this.dropdownEnabled,open:this._open,notified:e,interactive:t};for(let e of[...this._listeners])e(n)}_contentNotify(e){let t={child:this._child!==null,label:this._label!==null,"icon-name":this.iconName!==null},n=[e];for(let r of Wn)r!==e&&t[r]&&n.push(r);return n}get mode(){return this._mode}get label(){return this._label}setLabel(e){if(typeof e!=`string`||e===this._label)return!1;let t=this._contentNotify(`label`);return this._child=this._mode===`label`?this._child:internalContent(`label`),this._mode=`label`,this._label=e,this._iconName=null,this._emit(t,!1),!0}get iconName(){return gtkButtonIconNameReadback(this._iconName)}setIconName(e){if(typeof e!=`string`||e===this.iconName)return!1;let t=this._contentNotify(`icon-name`);return this._child=this._mode===`icon`?this._child:internalContent(`icon`),this._mode=`icon`,this._iconName=e,this._label=null,this._emit(t,!1),!0}get child(){return this._child}setChild(e){let t=e??null;if(t===this._child)return!1;let n=this._contentNotify(`child`);return this._mode=t===null?`empty`:`child`,this._child=t,this._label=null,this._iconName=null,this._emit(n,!1),!0}get styleClasses(){return splitButtonStyleClasses(this._label,this.iconName)}get useUnderline(){return this._useUnderline}setUseUnderline(e){let t=!!e;return t===this._useUnderline?!1:(this._useUnderline=t,this._emit([`use-underline`],!1),!0)}get menuModel(){return this._menuModel}setMenuModel(e){let t=normalizeMenuModel(e),n=t.length>0?t:null;if(menuKey(n)===menuKey(this._menuModel))return!1;let r=n===null?null:derivedPopover();return this._menuModel=n,this._popover=r,this.dropdownEnabled||(this._open=!1),this._emit(Gn[n===null?`clear`:`set`],!1),!0}get popover(){return this._popover}setPopover(e){let t=e??null;return t===this._popover?!1:(this._menuModel=null,this._popover=t,this.dropdownEnabled||(this._open=!1),this._emit(Gn[t===null?`clear`:`set`],!1),!0)}get dropdownEnabled(){return this._menuModel!==null||this._popover!==null}get direction(){return this._direction}setDirection(e){return!isSplitButtonDirection(e)||e===this._direction?!1:(this._direction=e,this._emit([`direction`],!1),!0)}get arrowIcon(){return splitButtonArrowIcon(this._direction)}get dropdownTooltip(){return this._dropdownTooltip}setDropdownTooltip(e){return typeof e!=`string`||e===this._dropdownTooltip?!1:(this._dropdownTooltip=e,this._emit([`dropdown-tooltip`],!1),!0)}get open(){return this._open}_setOpen(e,t){return e&&!this.dropdownEnabled||e===this._open?!1:(this._open=e,this._emit([],t),!0)}openMenu(){return this._setOpen(!0,!1)}closeMenu(){return this._setOpen(!1,!1)}toggleMenu(){return this._setOpen(!this._open,!0)}activateMenuItem(e){if(this._menuModel===null)return null;let t=menuItemAt(this._menuModel,e);return t===null?null:(this._setOpen(!1,!0),t)}};function menuAssignments(e,t){let n=[],r=e.props?.[`menu-model`];if(r!==void 0){let i=typeof r==`string`?t?.[r]:void 0;if(i===void 0)throw Error(`${e.tag} menu-model: ${JSON.stringify(r)} names no menu: the file declares [${Object.keys(t??{}).join(`, `)}] (ADR 0097 § 1).`);n.push([`menu-model`,normalizeMenuModel(i)])}for(let[t,r]of Object.entries(e.menuModels??{}))n.push([t,normalizeMenuModel(r)]);return n}const qn=[`narrow`,`wide`],Jn=[`labels`,`icons`,`both`];function isViewSwitcherPolicy(e){return e===`narrow`||e===`wide`}function isInlineViewSwitcherDisplayMode(e){return e===`labels`||e===`icons`||e===`both`}function createViewSwitcherPage(e){return{name:e.name,title:e.title??null,iconName:e.iconName??null,visible:e.visible??!0,useUnderline:e.useUnderline??!1,badgeNumber:normalizeBadgeNumber(e.badgeNumber),needsAttention:e.needsAttention??!1,startsSection:e.startsSection??!1,sectionTitle:e.sectionTitle??null}}function viewSwitcherPageFromStackPage(e){return createViewSwitcherPage({name:e.name,title:e.title,iconName:e.icon.length>0?e.icon:null,visible:e.visible,badgeNumber:e.badgeNumber,needsAttention:e.needsAttention,useUnderline:e.useUnderline,startsSection:e.startsSection,sectionTitle:e.sectionTitle})}function viewSwitcherPagesFromStack(e){return e.map(e=>viewSwitcherPageFromStackPage(e))}function viewSwitcherSidebarSections(e){let t=[];for(let n of e)t.length===0||n.startsSection===!0?t.push({title:n.sectionTitle??``,pages:[n]}):t[t.length-1].pages.push(n);return t}function isViewSwitcherButtonVisible(e){return e.visible&&(isPresent(e.title)||isPresent(e.iconName))}function viewSwitcherIconName(e){return isPresent(e)&&e.length>0?e:`image-missing`}function viewSwitcherLabel(e){return isPresent(e.title)?e.useUnderline?stripMnemonic(e.title):e.title:``}function viewSwitcherBadgeLabel(e){let t=normalizeBadgeNumber(e);return t>999?`999+`:t===0?``:String(t)}const Yn={attentionRequested:`Attention requested.`,badgeOverflow:`Has a badge: more than 999.`,badge:e=>`Has a badge: ${e}.`};function viewSwitcherIndicatorDescription(e,t,n=Yn){let r=normalizeBadgeNumber(t),i=e?n.attentionRequested:``,a=``;return r>999?a=n.badgeOverflow:r>0&&(a=n.badge(r)),i&&a?`${a} ${i}`:i||a}function inlineToggleTooltip(e,t){return t===`icons`?viewSwitcherLabel(e):``}function shouldRevealViewSwitcherBar(e,t){if(!e)return!1;let n=0;for(let e of t)if(e.visible&&(n++,n>1))return!0;return!1}function viewSwitcherButtonOrientation(e){return e===`wide`?`horizontal`:`vertical`}function buildViewSwitcherButtons(e,t,n,r=Yn){let i=viewSwitcherButtonOrientation(n);return e.map((e,n)=>({pageIndex:n,name:e.name,label:viewSwitcherLabel(e),iconName:viewSwitcherIconName(e.iconName),visible:isViewSwitcherButtonVisible(e),selected:n===t,orientation:i,badgeLabel:viewSwitcherBadgeLabel(e.badgeNumber),needsAttention:e.needsAttention,description:viewSwitcherIndicatorDescription(e.needsAttention,e.badgeNumber,r)}))}function buildInlineToggles(e,t,n=Yn){let r=t!==`labels`,i=t!==`icons`,a=[];return e.forEach((e,o)=>{e.visible&&a.push({toggleIndex:a.length,pageIndex:o,name:e.name,label:viewSwitcherLabel(e),iconName:viewSwitcherIconName(e.iconName),showIcon:r,showLabel:i,tooltip:inlineToggleTooltip(e,t),badgeLabel:viewSwitcherBadgeLabel(e.badgeNumber),needsAttention:e.needsAttention,description:viewSwitcherIndicatorDescription(e.needsAttention,e.badgeNumber,n)})}),a}function toggleIndexForPage(e,t){if(!Number.isInteger(t)||t<0||t>=e.length||!e[t].visible)return-1;let n=0;for(let r=0;r<t;r++)e[r].visible&&n++;return n}var ViewSwitcherDragSwitch=class{constructor(e){this._timers=new Map,this._scheduler=e.scheduler,this._onSwitch=e.onSwitch,this._delay=e.delay??500}enter(e,t){if(!Number.isInteger(e)||e<0||e===t||this._timers.has(e))return!1;let n=this._scheduler.schedule(()=>{this._timers.delete(e),this._onSwitch(e)},this._delay);return this._timers.set(e,n),!0}leave(e){let t=this._timers.get(e);t!==void 0&&(this._timers.delete(e),this._scheduler.cancel(t))}cancel(){for(let e of this._timers.values())this._scheduler.cancel(e);this._timers.clear()}get pending(){return[...this._timers.keys()].sort((e,t)=>e-t)}},ViewSwitcherState=class{constructor(e={}){this._pages=[],this._pagesView=null,this._stack=new ViewStackState,this._listeners=new Set,this._drag=e.scheduler?new ViewSwitcherDragSwitch({scheduler:e.scheduler,delay:e.dragSwitchDelay,onSwitch:e=>{this.setSelected(e)}}):null,this._subscribeStack()}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}get pages(){return this._pagesView??=Object.freeze(this._pages.slice()),this._pagesView}setPages(e){let t=this.selected,n=t>=0?this.selectedName:null;this._pages=e.map(e=>createViewSwitcherPage(e)),this._pagesView=null;let r=new ViewStackState;for(let e of this._pages)r.addPage({name:e.name,title:e.title,visible:e.visible});if(n!==null){let e=r.indexOfName(n);e>=0&&r.setVisibleIndex(e,!1)}this._stack=r,this._subscribeStack(),this._drag?.cancel(),(this.selected!==t||this.selectedName!==(n??``))&&this._emit(!1)}get selected(){return this._stack.visibleIndex}get selectedName(){return this._stack.visibleName}get selectedPage(){return this._pages[this.selected]}get count(){return this._pages.length}setSelected(e,t=!0){return this._stack.setVisibleIndex(e,t)}selectName(e,t=!0){return this._stack.setVisibleName(e,t)}setPageVisible(e,t){let n=this._pages.findIndex(t=>t.name===e);if(n<0)return!1;let r=this._pages[n],i=!!t;return r.visible===i?!1:(this._pages[n]={...r,visible:i},this._pagesView=null,this._stack.setPageVisible(e,i))}dragEnter(e){this._drag?.enter(e,this.selected)}dragLeave(e){this._drag?.leave(e)}cancelDrag(){this._drag?.cancel()}get pendingDragSwitches(){return this._drag?.pending??[]}get diagnostics(){return this._stack.diagnostics}_subscribeStack(){this._stack.subscribe(e=>this._emit(e.interactive))}_emit(e){let t=this.selectedPage,n={selected:this.selected,name:t?.name??``,title:t?viewSwitcherLabel(t):``,interactive:e};for(let e of[...this._listeners])e(n)}},ViewSwitcherBarState=class{constructor(){this._reveal=!1,this._revealed=!1,this._pages=[],this._listeners=new Set}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}get reveal(){return this._reveal}get revealed(){return this._revealed}setReveal(e){let t=!!e;return t===this._reveal?!1:(this._reveal=t,this._refresh(),!0)}setPages(e){return this._pages=e,this._refresh()}_refresh(){let e=shouldRevealViewSwitcherBar(this._reveal,this._pages);if(e===this._revealed)return!1;this._revealed=e;let t={reveal:this._reveal,revealed:this._revealed};for(let e of[...this._listeners])e(t);return!0}};function isPresent(e){return e!=null}function normalizeBadgeNumber(e){return typeof e!=`number`||!Number.isFinite(e)?0:Math.max(0,Math.trunc(e))}const Xn=new Map([[`µ`,`μ`],[`ß`,`ss`],[`ʼn`,`ʼn`],[`ſ`,`s`],[`ǰ`,`ǰ`],[`ͅ`,`ι`],[`ΐ`,`ΐ`],[`ΰ`,`ΰ`],[`ς`,`σ`],[`ϐ`,`β`],[`ϑ`,`θ`],[`ϕ`,`φ`],[`ϖ`,`π`],[`ϰ`,`κ`],[`ϱ`,`ρ`],[`ϵ`,`ε`],[`և`,`եւ`],[`ᲀ`,`в`],[`ᲁ`,`д`],[`ᲂ`,`о`],[`ᲃ`,`с`],[`ᲄ`,`т`],[`ᲅ`,`т`],[`ᲆ`,`ъ`],[`ᲇ`,`ѣ`],[`ᲈ`,`ꙋ`],[`ẖ`,`ẖ`],[`ẗ`,`ẗ`],[`ẘ`,`ẘ`],[`ẙ`,`ẙ`],[`ẚ`,`aʾ`],[`ẛ`,`ṡ`],[`ὐ`,`ὐ`],[`ὒ`,`ὒ`],[`ὔ`,`ὔ`],[`ὖ`,`ὖ`],[`ᾀ`,`ἀι`],[`ᾁ`,`ἁι`],[`ᾂ`,`ἂι`],[`ᾃ`,`ἃι`],[`ᾄ`,`ἄι`],[`ᾅ`,`ἅι`],[`ᾆ`,`ἆι`],[`ᾇ`,`ἇι`],[`ᾐ`,`ἠι`],[`ᾑ`,`ἡι`],[`ᾒ`,`ἢι`],[`ᾓ`,`ἣι`],[`ᾔ`,`ἤι`],[`ᾕ`,`ἥι`],[`ᾖ`,`ἦι`],[`ᾗ`,`ἧι`],[`ᾠ`,`ὠι`],[`ᾡ`,`ὡι`],[`ᾢ`,`ὢι`],[`ᾣ`,`ὣι`],[`ᾤ`,`ὤι`],[`ᾥ`,`ὥι`],[`ᾦ`,`ὦι`],[`ᾧ`,`ὧι`],[`ᾲ`,`ὰι`],[`ᾳ`,`αι`],[`ᾴ`,`άι`],[`ᾶ`,`ᾶ`],[`ᾷ`,`ᾶι`],[`ι`,`ι`],[`ῂ`,`ὴι`],[`ῃ`,`ηι`],[`ῄ`,`ήι`],[`ῆ`,`ῆ`],[`ῇ`,`ῆι`],[`ῒ`,`ῒ`],[`ΐ`,`ΐ`],[`ῖ`,`ῖ`],[`ῗ`,`ῗ`],[`ῢ`,`ῢ`],[`ΰ`,`ΰ`],[`ῤ`,`ῤ`],[`ῦ`,`ῦ`],[`ῧ`,`ῧ`],[`ῲ`,`ὼι`],[`ῳ`,`ωι`],[`ῴ`,`ώι`],[`ῶ`,`ῶ`],[`ῷ`,`ῶι`],[`ff`,`ff`],[`fi`,`fi`],[`fl`,`fl`],[`ffi`,`ffi`],[`ffl`,`ffl`],[`ſt`,`st`],[`st`,`st`],[`ﬓ`,`մն`],[`ﬔ`,`մե`],[`ﬕ`,`մի`],[`ﬖ`,`վն`],[`ﬗ`,`մխ`]]);function foldCherokee(e){if(e>=43888&&e<=43967)return String.fromCodePoint(e-43888+5024);if(e>=5112&&e<=5117)return String.fromCodePoint(e-8)}const defaultCaseFolder=e=>{let t=``;for(let n of e.toLowerCase()){let e=n.codePointAt(0);if(e<181){t+=n;continue}t+=Xn.get(n)??foldCherokee(e)??n}return t};function makeComparable(e,t={},n=defaultCaseFolder){let r=n(e??``);return(t.useMarkup??!0)&&(r=stripMarkup(r)??r),(t.allowUnderline??!0)&&(t.useUnderline??!1)&&(r=stripMnemonic(r)),r}function displayedLabelText(e,t){let n=e??``;return t?stripMarkup(n)??n:n}function derivePreferencesGroupHeader(e){let t=e.useMarkup??!0,n=stringIsNotEmpty(displayedLabelText(e.title,t)),r=stringIsNotEmpty(displayedLabelText(e.description,t)),i=e.hasHeaderSuffix??!1;return{titleVisible:n,descriptionVisible:r,headerVisible:n||r||i,singleLine:!r&&(i||n),listboxVisible:(e.rowCount??0)>0}}function countVisiblePages(e){let t=0;for(let n of e)n.visible!==!1&&(t+=1);return t}function collectSearchRows(e){let t=[];for(let n of e)if(n.visible!==!1){for(let e of n.groups)if(e.visible!==!1)for(let r of e.rows)r.visible!==!1&&r.title!==``&&t.push({page:n,group:e,row:r})}return t}function rowMatchesQuery(e,t,n=defaultCaseFolder){let r=n(t??``),i={useMarkup:e.useMarkup,useUnderline:e.useUnderline};return makeComparable(e.title,{...i,allowUnderline:!0},n).includes(r)?!0:e.isActionRow?makeComparable(e.subtitle,{...i,allowUnderline:!1},n).includes(r):!1}function createSearchRowSubtitle(e){let t=e.groupTitle??null;t===``&&(t=null);let n=null;return e.pageTitle!==void 0&&e.pageTitle!==null&&(n=e.pageUseUnderline?stripMnemonic(e.pageTitle):e.pageTitle,(e.rowUseMarkup??!0)&&(n=escapeMarkup(n)),n===``&&(n=null)),t===null?n:e.nVisiblePages<=1?t:`${n??e.untitledPageLabel??`Untitled page`} → ${t}`}function searchPreferences(e,t,n={}){let r=n.fold??defaultCaseFolder,i=countVisiblePages(e),a=[];for(let{page:o,group:s,row:c}of collectSearchRows(e))rowMatchesQuery(c,t,r)&&a.push({title:c.title,subtitle:createSearchRowSubtitle({groupTitle:s.title,pageTitle:o.title??``,pageUseUnderline:o.useUnderline,rowUseMarkup:c.useMarkup,nVisiblePages:i,untitledPageLabel:n.untitledPageLabel}),useMarkup:c.useMarkup??!0,useUnderline:c.useUnderline??!1,page:o,group:s,row:c});return a}function scrollMaxValue(e){return e.upper-e.pageSize}function isScrolledFromStart(e){return e.value>e.lower}function isScrolledFromEnd(e){return e.value<scrollMaxValue(e)}const Zn=[`undershoot-top`,`undershoot-bottom`,`undershoot-start`,`undershoot-end`];function scrollUndershootClasses(e){let t=[],{vertical:n,horizontal:r}=e;return n&&(isScrolledFromStart(n)&&t.push(`undershoot-top`),isScrolledFromEnd(n)&&t.push(`undershoot-bottom`)),r&&(isScrolledFromStart(r)&&t.push(`undershoot-start`),isScrolledFromEnd(r)&&t.push(`undershoot-end`)),t}function overshootDistance(e,t){let n=scrollMaxValue(t);return e<t.lower?e-t.lower:e>n?e-n:0}function accumulateOvershoot(e,t,n){let r=n.lower-100,i=scrollMaxValue(n)+100;return Math.min(Math.max(e+t,r),i)}var PopoverState=class{constructor(){this._open=!1,this._listeners=new Set}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}_emit(e){let t={open:this._open,interactive:e};for(let e of[...this._listeners])e(t)}_setOpen(e,t){return e===this._open?!1:(this._open=e,this._emit(t),!0)}get open(){return this._open}popup(){return this._setOpen(!0,!1)}popdown(){return this._setOpen(!1,!1)}toggle(){return this._setOpen(!this._open,!0)}dismiss(){return this._setOpen(!1,!0)}};function resolvePopoverKey(e,t){if(e===`Escape`)return{action:`close`,index:-1};let n=Number.isFinite(t.itemCount)?Math.max(0,Math.trunc(t.itemCount)):0;if(n===0)return{action:`none`,index:-1};let r=t.currentIndex,i=Number.isFinite(r)&&r>=0&&r<n?Math.trunc(r):-1,a=t.hasSearch===!0&&i<0;switch(e){case`ArrowDown`:return{action:`focus`,index:i<0?0:(i+1)%n};case`ArrowUp`:return{action:`focus`,index:i<0?n-1:(i-1+n)%n};case`Home`:return a?{action:`none`,index:-1}:{action:`focus`,index:0};case`End`:return a?{action:`none`,index:-1}:{action:`focus`,index:n-1};case`Enter`:case` `:return i<0?{action:`none`,index:-1}:{action:`activate`,index:i};default:return{action:`none`,index:-1}}}const Qn=[`none`,`fill`,`spread`],$n=[`minimum`,`natural`],er=[`start-to-end`,`end-to-start`];function normalizeWrapBoxSpacing(e){let t=typeof e==`number`?e:Number.parseFloat(String(e??``));return!Number.isFinite(t)||t<0?0:t}function normalizeWrapBoxAlign(e){let t=typeof e==`number`?e:Number.parseFloat(String(e??``));return Number.isFinite(t)?Math.min(1,Math.max(0,t)):0}function normalizeWrapBoxJustify(e){return Qn.includes(e)?e:`none`}function normalizeWrapPolicy(e){return $n.includes(e)?e:`natural`}function normalizeNaturalLineLength(e){let t=typeof e==`number`?e:Number.parseFloat(String(e??``));return!Number.isFinite(t)||t<0?-1:Math.trunc(t)}function normalizeWrapBoxLengthUnit(e){return normalizeLengthUnit(e,`px`)}function normalizeWrapBoxPackDirection(e){return er.includes(e)?e:`start-to-end`}function wrapBoxLengthToPx(e,t,n=96){return e<0?-1:adwLengthToPx(t,e,n)}function resolveWrapBoxLine(e){let t=e.lastLine&&!e.justifyLastLine?`none`:e.justify;if(t===`none`)return{justify:`none`,growChildren:!1,growGaps:!1,align:e.align};let n=t===`spread`&&e.childrenInLine>1;return{justify:t,growChildren:!n,growGaps:n,align:0}}function wrapPolicyFlexShrink(e){return+(e===`minimum`)}function resolveWrapBoxChildOrder(e){let{children:t,child:n,op:r}=e,i=e.sibling??null;if(i!==null&&i===n)return null;let a=t.indexOf(n);if(r===`insert-after`&&a!==-1||r===`reorder-after`&&a===-1)return null;let o=a===-1?[...t]:t.filter((e,t)=>t!==a);if(i===null)return[n,...o];let s=o.indexOf(i);return s===-1?null:[...o.slice(0,s+1),n,...o.slice(s+1)]}var WindowMemberState=class{constructor(e,t={}){this._active=!1,this._focus=null,this._notify=e,this._maximized=t.maximized??!1}get active(){return this._active}get maximized(){return this._maximized}get focus(){return this._focus}reportActive(e){return this._active===e?!1:(this._active=e,this._notify(`is-active`),!0)}reportMaximized(e){return this._maximized===e?!1:(this._maximized=e,this._notify(`maximized`),!0)}reportFocus(e){return this._focus===e?!1:(this._focus=e,this._notify(`focus-widget`),!0)}};function stepDefaultSize(e,t,n){if(!Number.isInteger(t)||!Number.isInteger(n)||t<-1||n<-1)return null;let r=[];return n!==e[1]&&r.push(`default-height`),t!==e[0]&&r.push(`default-width`),{width:t,height:n,changed:r}}var CloseRequestState=class{constructor(){this._emitting=!1}get emitting(){return this._emitting}close(e){if(!e.realized||this._emitting)return`ignored`;let t;this._emitting=!0;try{e.emit()?t=`handled`:e.hideOnClose?(e.hide(),t=`hidden`):t=`destroyed`}finally{this._emitting=!1}return t===`destroyed`&&e.destroy(),t}};const tr=`--accent-bg-color`,nr=`--accent-color`;function isAdwaitaDark(e){return e.closest(`.theme-dark`)?!0:e.closest(`.theme-light`)?!1:globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1}const rr=new WeakSet;function hasAppChosenAccent(e){return rr.has(e)}function writeAdwaitaAccent(e,t,n){t.style.setProperty(tr,adwaitaAccentBgColor(e)),t.style.setProperty(nr,adwaitaAccentColor(e,n))}function applyAdwaitaAccent(e,t={}){let n=t.target??document.documentElement;rr.add(n),writeAdwaitaAccent(e,n,t.dark??isAdwaitaDark(n))}function clearAdwaitaAccent(e=document.documentElement){rr.delete(e),e.style.removeProperty(tr),e.style.removeProperty(nr)}let V={},ir=!1,ar=null,or=!1;function readSystemAccent(){if(typeof CSS>`u`||!CSS.supports(`color`,`AccentColor`))return null;let e=document.createElement(`span`);e.style.color=`AccentColor`,e.style.display=`none`,document.documentElement.append(e);let t=getComputedStyle(e).color;e.remove();let n=parseAdwRgb(t);return n?{accent:nearestAccent(n),accentRgb:formatAdwRgb(n)}:null}function resolve(){if(V.accent&&V.accent!==Pe)return{accent:V.accent,source:`handoff`};let e=V.accentRgb?parseAdwRgb(V.accentRgb):null;if(e)return{accent:nearestAccent(e),source:`handoff`};if(V.accent===Pe){let e=readSystemAccent();if(e)return{accent:e.accent,source:`system`}}return null}function syncScheme(e){let t=V.colorScheme,n=t===`dark`?`theme-dark`:t===`light`?`theme-light`:null;n!==ar&&(ar&&e.classList.remove(ar),ar=null,n&&!e.classList.contains(`theme-dark`)&&!e.classList.contains(`theme-light`)&&(e.classList.add(n),ar=n))}function sync(){let e=document.documentElement;if(syncScheme(e),hasAppChosenAccent(e))return;let t=resolve();t?(writeAdwaitaAccent(t.accent,e,isAdwaitaDark(e)),ir=!0):ir&&=(clearAdwaitaAccent(e),!1)}const isHandoffMeta=e=>e.nodeName===`META`&&e.getAttribute(`name`)?.startsWith(`adw-`)===!0;function touchesHandoffMeta(e){return e.type===`attributes`?isHandoffMeta(e.target)||e.attributeName===`name`&&e.oldValue?.startsWith(`adw-`)===!0:[...e.addedNodes,...e.removedNodes].some(isHandoffMeta)}function readMetaHandoff(){V=appearanceFromMeta(e=>document.head.querySelector(`meta[name="${e}"]`)?.getAttribute(`content`)??null)}function followDesktopAppearance(){or||typeof document>`u`||(or=!0,readMetaHandoff(),sync(),new MutationObserver(e=>{e.some(touchesHandoffMeta)&&(readMetaHandoff(),sync())}).observe(document.head,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`content`,`name`],attributeOldValue:!0}),globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).addEventListener(`change`,sync),globalThis.addEventListener(`focus`,()=>{V.accent===Pe&&sync()}))}function observeAdaptiveSize(e,t){let n=new ResizeObserver(e=>{let n=e[e.length-1];if(!n)return;let r=n.borderBoxSize?.[0];t(r?{width:r.inlineSize,height:r.blockSize}:{width:n.contentRect.width,height:n.contentRect.height})});return n.observe(e),()=>n.disconnect()}function addBreakpoints(e,t){return observeAdaptiveSize(e,e=>{for(let n of t)n.evaluate(e)})}function bindBreakpointSetter(e,t,n,r=!1){return t?addBreakpoints(e,[new AdwBreakpoint(t,{onApply:()=>n(!0),onUnapply:()=>n(!1)},r)]):()=>{}}const sr=`adw-scroll-shaded`,cr=`--adw-overshoot`,lr=[`overshoot-top`,`overshoot-bottom`],ur=new Set([`auto`,`scroll`,`overlay`]);function adjustmentsOf(e){let t=getComputedStyle(e);return{vertical:ur.has(t.overflowY)?{value:e.scrollTop,lower:0,upper:e.scrollHeight,pageSize:e.clientHeight}:void 0,horizontal:ur.has(t.overflowX)?{value:e.scrollLeft,lower:0,upper:e.scrollWidth,pageSize:e.clientWidth}:void 0}}function isScroller(e){let t=getComputedStyle(e);return ur.has(t.overflowY)||ur.has(t.overflowX)}function wheelDeltaPx(e,t){return e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*t:e.deltaY}var AdwScrollShading=class{_root;_mutations=null;_resize=null;_unclamped=new WeakMap;_settleTimers=new WeakMap;_shaded=new Set;_pendingScan=0;_undershootEdges={top:!0,bottom:!0};_onOvershoot;constructor(e,t={}){this._root=e,this._onOvershoot=t.onOvershoot??null}setUndershootEdges(e){if(!(e.top===this._undershootEdges.top&&e.bottom===this._undershootEdges.bottom)){this._undershootEdges={...e};for(let e of this._shaded)this._update(e)}}connect(){this._mutations||(this._root.addEventListener(`scroll`,this._onScroll,{capture:!0,passive:!0}),this._root.addEventListener(`wheel`,this._onWheel,{capture:!0,passive:!0}),this._mutations=new MutationObserver(()=>this._scheduleRefresh()),this._mutations.observe(this._root,{childList:!0,subtree:!0}),this._resize=new ResizeObserver(()=>this._scheduleRefresh()),this._resize.observe(this._root),this.refresh())}disconnect(){this._root.removeEventListener(`scroll`,this._onScroll,{capture:!0}),this._root.removeEventListener(`wheel`,this._onWheel,{capture:!0}),this._mutations?.disconnect(),this._mutations=null,this._resize?.disconnect(),this._resize=null,this._pendingScan&&cancelAnimationFrame(this._pendingScan),this._pendingScan=0;for(let e of this._shaded)this._clear(e);this._shaded.clear()}_scheduleRefresh(){this._pendingScan||=requestAnimationFrame(()=>{this._pendingScan=0,this.refresh()})}refresh(){let e=new Set;isScroller(this._root)&&e.add(this._root);for(let t of this._root.querySelectorAll(`*`))isScroller(t)&&e.add(t);for(let t of this._shaded)e.has(t)||this._clear(t);this._shaded=e;for(let t of e)this._update(t)}_clear(e){e.classList.remove(sr,...Zn,...lr),e.style.removeProperty(cr)}_update(e){e.classList.add(sr);let t=scrollUndershootClasses(adjustmentsOf(e));for(let n of Zn){let r=(n!==`undershoot-top`||this._undershootEdges.top)&&(n!==`undershoot-bottom`||this._undershootEdges.bottom);e.classList.toggle(n,r&&t.includes(n))}}_onScroll=e=>{let t=e.target;t instanceof HTMLElement&&this._shaded.has(t)&&this._update(t)};_onWheel=e=>{let t=e.target instanceof HTMLElement?this._scrollerFor(e.target):null;if(!t)return;let{vertical:n}=adjustmentsOf(t);if(!n)return;let r=this._unclamped.get(t)??n.value,i=accumulateOvershoot(overshootDistance(r,n)===0?n.value:r,wheelDeltaPx(e,n.pageSize),n);this._unclamped.set(t,i),this._applyOvershoot(t,overshootDistance(i,n)),clearTimeout(this._settleTimers.get(t)),this._settleTimers.set(t,setTimeout(()=>{this._unclamped.set(t,t.scrollTop),this._applyOvershoot(t,0)},50))};_applyOvershoot(e,t){e.classList.toggle(`overshoot-top`,t<0),e.classList.toggle(`overshoot-bottom`,t>0),t===0?e.style.removeProperty(cr):e.style.setProperty(cr,`${Math.abs(t)}px`),this._onOvershoot?.(t)}_scrollerFor(e){for(let t=e;t;t=t.parentElement){if(this._shaded.has(t))return t;if(t===this._root)break}return null}};function walk(e,t,n){n(e,t),(e.children??[]).forEach((e,r)=>walk(e,`${t} > ${e.tag}[${r}]`,n))}function authoredNodes(e,t=e.tag){let n=[];return walk(e,t,(e,t)=>n.push({node:e,path:t})),n}function constructUsesOf(e){let t=[];return[{tree:e,address:e.tag},...(e.siblings??[]).map((t,n)=>({tree:t,address:`${e.tag} > sibling[${n}] ${t.tag}`}))].forEach(({tree:e,address:n},r)=>{r>0&&t.push({kind:`sibling-object`,path:n}),collectUses(e,n,t)}),t}function treeNodesOf(e){return[...authoredNodes(e,e.tag),...(e.siblings??[]).flatMap((t,n)=>authoredNodes(t,`${e.tag} > sibling[${n}] ${t.tag}`))]}function collectUses(e,t,n){for(let{node:r,path:i}of authoredNodes(e,t))r.layout!==void 0&&n.push({kind:`layout`,path:i}),r.accessibility!==void 0&&n.push({kind:`accessibility`,path:i}),r.extensions?.strings!==void 0&&n.push({kind:`strings`,path:i}),r.extensions?.responses!==void 0&&n.push({kind:`responses`,path:i}),r.page!==void 0&&n.push({kind:`page`,path:i}),r.extern===!0&&n.push({kind:`extern`,path:i}),r.signals?.forEach(()=>n.push({kind:`signal`,path:i})),Object.keys(r.bindings??{}).forEach(()=>n.push({kind:`bind`,path:i})),r.breakpoints?.forEach(()=>n.push({kind:`breakpoint`,path:i}))}var UnsupportedConstructError=class extends Error{constructor(e,t){let n=t.map(e=>` ${e.kind} at ${e.path} — ${e.reason}`).join(`
|
|
16
|
-
`);super(`this tree cannot be rendered by ${e}: ${t.length} construct(s) it refuses.\n${n}`),this.name=`UnsupportedConstructError`,this.renderer=e,this.refused=t}};function assertTreeConstructs(e,t,n,r){let i=[];for(let r of constructUsesOf(n)){let n=t[r.kind];if(n===void 0)throw Error(`${e}'s capabilities declare no row for the construct '${r.kind}'.`);n!==`implemented`&&i.push({...r,reason:n.refused})}if(r!==void 0&&t.accessibility===`implemented`)for(let{node:e,path:t}of treeNodesOf(n))for(let n of Object.keys(e.accessibility??{}))r.includes(n)||i.push({kind:`accessibility`,path:t,reason:`'${n}' has no accessibility door here; only ${r.join(`, `)} are written`});if(i.length>0)throw new UnsupportedConstructError(e,i)}const hostTagOf=e=>{if(!/^(?:Adw|Gtk)[A-Z]\w*$/.test(e))throw Error(`hostTagOf: ${e} is not a GIR class name`);let t=[];for(let n=0;n<e.length;n++){let r=e.charAt(n);if(r>=`A`&&r<=`Z`&&n>0){let r=e.charAt(n-1),i=e.charAt(n+1);(!(r>=`A`&&r<=`Z`)||i>=`a`&&i<=`z`)&&t.push(`-`)}t.push(r.toLowerCase())}return t.join(``)},attributeOf=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),propertyOf=e=>e.replace(/[-_]([a-z0-9])/g,(e,t)=>t.toUpperCase()),dr={"margin-start":`margin-inline-start`,"margin-end":`margin-inline-end`,"margin-top":`margin-top`,"margin-bottom":`margin-bottom`},fr=[`hexpand`,`vexpand`],pr={"width-request":`min-width`,"height-request":`min-height`};function widgetLengthStyle(e,t){let n=dr[e];if(n!==void 0)return[n,`${Number(t)}px`];let r=pr[e];if(r!==void 0)return[r,Number(t)<0?null:`${Number(t)}px`]}const mr=new Map([[`adw-toggle-group`,new Set([`sensitive`])],[`adw-toggle`,new Set([`enabled`])],[`adw-alert-response`,new Set([`enabled`])],[`adw-sidebar-item`,new Set([`enabled`,`visible`])],[`gtk-editable-label`,new Set([`editable`])],[`adw-entry-row`,new Set([`editable`,`show-apply-button`])],[`gtk-text`,new Set([`editable`])],[`gtk-text-view`,new Set([`editable`])],[`adw-navigation-page`,new Set([`can-pop`])],[`gtk-action-bar`,new Set([`revealed`])],[`adw-password-entry-row`,new Set([`revealed`])]]);function isValueBasedBooleanAttr(e,t){let n=mr.get(e);return n!==void 0&&n.has(t)}const hr={layout:`implemented`,accessibility:`implemented`,strings:`implemented`,responses:`implemented`,page:`implemented`,extern:`implemented`,signal:`implemented`,bind:`implemented`,breakpoint:`implemented`,"sibling-object":`implemented`};function dispatchedSignalsOf(e){let t=[];for(let n=e.constructor;typeof n==`function`;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,`signals`)?.value;e!==void 0&&t.unshift(e)}return Object.assign({},...t)}const H=new WeakMap,gr=new Set,_r=new WeakMap;let U=null;function isMapped(e){return e.isConnected&&e.checkVisibility()}function depthOf(e){let t=0;for(let n=e.parentElement;n!==null;n=n.parentElement)t++;return t}function recheck(){let e=[];for(let t of gr){let n=t.deref();if(n===void 0){gr.delete(t);continue}let r=H.get(n);isMapped(n)!==r.mapped&&e.push(n)}if(e.length===0)return;let deepestFirst=e=>e.map(e=>[e,depthOf(e)]).sort((e,t)=>t[1]-e[1]),t=deepestFirst(e.filter(e=>H.get(e).mapped)),n=deepestFirst(e.filter(e=>!H.get(e).mapped));for(let[e]of[...t,...n]){let t=H.get(e);t.mapped=!t.mapped,e.dispatchEvent(new CustomEvent(t.mapped?`map`:`unmap`))}}function observe(){U===null&&(U=new MutationObserver(recheck),U.observe(document,{childList:!0,subtree:!0,attributes:!0}),document.addEventListener(`toggle`,recheck,!0))}function unobserve(){U===null||gr.size>0||(U.disconnect(),U=null,document.removeEventListener(`toggle`,recheck,!0))}function watchMapping(e){let t=H.get(e);if(t===void 0||t.listeners===0){t={mapped:isMapped(e),listeners:0},H.set(e,t);let n=new WeakRef(e);_r.set(e,n),gr.add(n),observe()}t.listeners++;let n=!0;return()=>{if(!n)return;n=!1;let t=H.get(e);--t.listeners>0||(gr.delete(_r.get(e)),_r.delete(e),unobserve())}}const vr=new WeakSet,yr=new WeakMap,br=new WeakSet;let xr=0;function hasElementApi(e){return br.has(e)}function eventOf(e,t){let n=dispatchedSignalsOf(e),r=n[t]??(t.startsWith(`notify::`)?n[`notify::${attributeOf(t.slice(8))}`]:void 0);if(r===void 0)throw Error(`<${e.localName}> declares no signal '${t}'. It dispatches: ${Object.keys(n).join(`, `)||`none`}.`);return r}function inheritedDescriptor(e,t){for(let n=Object.getPrototypeOf(e);n!==null;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(e!==void 0)return e}}function notifyElement(e,t){let n=propertyOf(t);e.dispatchEvent(new CustomEvent(eventOf(e,`notify::${t}`),{bubbles:!0,detail:{[n]:e[n]}}))}function ensureNotifying(e,t){let n=propertyOf(t),r=yr.get(e)??new Set;if(r.has(n)||(r.add(n),yr.set(e,r),Object.getOwnPropertyDescriptor(e,n)!==void 0))return;let i=inheritedDescriptor(e,n);if(i?.get===void 0||i.set===void 0)return;let{get:a,set:o}=i,s=eventOf(e,`notify::${t}`);Object.defineProperty(e,n,{configurable:!0,enumerable:!1,get(){return a.call(this)},set(e){let n=a.call(this),r=!1,mark=e=>{e.target===this&&(r=!0)};this.addEventListener(s,mark);try{o.call(this,e)}finally{this.removeEventListener(s,mark)}!r&&a.call(this)!==n&¬ifyElement(this,t)}})}function signalOwner(e,t,n){for(let r=e instanceof Element?e:null;r!==null;r=r.parentElement)if(dispatchedSignalsOf(r)[t]===n)return r;return null}function listenElement(e,t,n){let r=eventOf(e,t),i=t.startsWith(`notify::`);i&&ensureNotifying(e,t.slice(8));let listener=a=>{i&&a.target!==e||!i&&!vr.has(a)&&signalOwner(a.target,t,r)!==e||n(e,...vr.has(a)?a.detail:[])===!0&&a.cancelable&&(a.preventDefault(),a.stopImmediatePropagation())};e.addEventListener(r,listener);let a=t===`map`||t===`unmap`?watchMapping(e):void 0;return()=>{e.removeEventListener(r,listener),a?.()}}function dispatchElement(e,t,n){let r=eventOf(e,t),i=new CustomEvent(r,{detail:n,bubbles:r.startsWith(`notify::`)});vr.add(i),e.dispatchEvent(i)}function installSensitive(e){if(`sensitive`in e)return;let t=e.constructor.observedAttributes??[],n=`disabled`in e||t.includes(`disabled`);Object.defineProperty(e,"sensitive",{configurable:!0,enumerable:!1,get:()=>n?!e.hasAttribute(`disabled`):e.getAttribute(`aria-disabled`)!==`true`,set:t=>{n?e.toggleAttribute(`disabled`,!t):t?e.removeAttribute(`aria-disabled`):e.setAttribute(`aria-disabled`,`true`)}})}const Sr=new WeakSet,Cr=new WeakSet;function hasInstalledVisible(e){if(Sr.has(e))return!0;let t=inheritedDescriptor(e,`visible`)?.get;return t!==void 0&&Cr.has(t)}function installVisible(e){if(`visible`in e)return;Sr.add(e);let define=(t,n)=>Object.defineProperty(e,t,{configurable:!0,enumerable:!1,...n}),set=t=>{let n=!e.hidden;e.toggleAttribute(`hidden`,!t),!e.hidden!==n&&`notify::visible`in dispatchedSignalsOf(e)&¬ifyElement(e,`visible`)};define(`visible`,{get:()=>!e.hidden,set}),`get_visible`in e||define(`get_visible`,{value:()=>!e.hidden,writable:!0}),`set_visible`in e||define(`set_visible`,{value:set,writable:!0})}function installElementApi(e){let t=e.connect;if(typeof t==`function`&&!wr.has(t))return;br.add(e);let n=new Map,define=(t,n)=>Object.defineProperty(e,t,{value:n,configurable:!0,writable:!0,enumerable:!1});define(`connect`,(t,r)=>{let i=listenElement(e,t,r),a=++xr;return n.set(a,i),a}),define(`disconnect`,t=>{let r=n.get(t);if(r===void 0)throw Error(`No handler with id ${t} is connected to <${e.localName}>`);n.delete(t),r()}),define(`emit`,(t,...n)=>dispatchElement(e,t,n)),define(`notify`,t=>notifyElement(e,t)),define(`get_property`,t=>(eventOf(e,`notify::${t}`),e[propertyOf(t)])),define(`set_property`,(t,n)=>{eventOf(e,`notify::${t}`);let r=propertyOf(t),i=inheritedDescriptor(e,r);if(i!==void 0&&i.get!==void 0&&i.set===void 0)throw Error(`Property '${t}' of <${e.localName}> is read-only`);e[r]=n}),define(`add_css_class`,t=>e.classList.add(t)),define(`remove_css_class`,t=>e.classList.remove(t)),define(`has_css_class`,t=>e.classList.contains(t))}const wr=new WeakSet;function markLazyElementApi(e){for(let t of[`connect`,`disconnect`,`emit`,`notify`])wr.add(e[t])}const Tr=new Set([`connect`,`disconnect`,`emit`,`notify`,`get_property`,`set_property`]);function endpointOf(e){return hasElementApi(e)?new Proxy(e,{get(e,t){if(typeof t!=`string`||Tr.has(t))return Reflect.get(e,t,e);let n=Reflect.get(e,propertyOf(t),e);return typeof n==`function`?n.bind(e):n},set(e,t,n){return Reflect.set(e,typeof t==`string`?propertyOf(t):t,n,e)}}):e}const Er=new WeakMap;function isContent(e){return e instanceof Element?!0:e.nodeType===Node.TEXT_NODE&&(e.textContent??``).trim()!==``}function bindSlottedChildren(e,t,n){let r=new Map,i=[],a=null;for(let e of t){let t=e.claims;e.name!==void 0&&r.set(e.name,e),t!==void 0&&i.push([t,e]),e.name===void 0&&t===void 0&&(a=e)}let o=new Set,s=null,slotFor=e=>{if(o.has(e))return null;let t=e instanceof Element?e.getAttribute(`slot`)??``:``;if(t!==``)return r.get(t)??null;for(let[t,n]of i)if(t(e))return n;return a},route=t=>{let n=slotFor(t);return n===null?null:`into`in n?(n.into.appendChild(t),n):(n.consume(t),t.parentNode===e&&e.removeChild(t),n)},c={slots:t,slotFor,install(...t){let r=[];for(let t of Array.from(e.childNodes)){if(route(t)!==null||t.parentNode!==e||!isContent(t))continue;r.push(t);let n=t instanceof Element?t.getAttribute(`slot`)??``:``;console.warn(`'${n}' is not a valid child type of '${e.localName}'`)}o=new Set(t),e.replaceChildren(...t,...r),s?.disconnect(),s=new MutationObserver(t=>{for(let r of t)if(r.target===e)for(let e of r.addedNodes){let t=route(e);t!==null&&n?.(e,t)}}),s.observe(e,{childList:!0})}};return Er.set(e,c),c}const Dr=new Map;function registerTemplateClass(e,t){let n=Dr.get(e);if(n!==void 0&&n!==t)throw Error(`the template class '${e}' is already registered as <${n}>.`);Dr.set(e,t)}function isTemplateTag(e){for(let t of Dr.values())if(t===e)return!0;return!1}function templateTagFor(e){let t=Dr.get(e);if(t===void 0)throw Error(`the tree uses the class '$${e}', which no registerTemplateClass() call registered: adwaita-web cannot build a class it does not know.`);if(customElements.get(t)===void 0)throw Error(`the class '$${e}' is registered as <${t}>, which nothing has defined in the custom element registry, so the element would stay an empty unknown tag.`);return t}function booleanAttribute$2(e,t){return e===null?t:e!==`false`}__name(booleanAttribute$2,`booleanAttribute`);function writeBooleanAttribute$1(e,t,n){n?e.setAttribute(t,`true`):e.setAttribute(t,`false`)}__name(writeBooleanAttribute$1,`writeBooleanAttribute`);function isWritable(e,t){for(let n=e;n!==null;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(e!==void 0)return e.set!==void 0||e.writable===!0}return!1}function buildSiblings(e,t){let n=new Map;for(let r of e.siblings??[]){if(r.id===void 0)throw Error(`the sibling \`${r.tag}\` has no id, so nothing could ever ask for it: give it one in the .blp.`);n.set(r.id,buildNode$1(r,t))}return n}function newRecord(e,t,n){return{placed:[],extended:[],ids:new Map,binds:[],breakpointHosts:[],disposers:[],...e===void 0?{}:{scope:e},...t===void 0?{}:{observeSize:t},...n===void 0?{}:{template:n,connects:[]}}}function bindBreakpoints(e,t,n){let r=createBreakpointDriver((t.breakpoints??[]).map(t=>{if(parseBreakpointCondition(t.condition)===null)throw Error(`<${e.localName}> \`condition ("${t.condition}")\` is not an Adwaita breakpoint condition.`);return{condition:t.condition,setters:t.setters.map(t=>{let r=n.ids.get(t.object);if(r===void 0)throw Error(`<${e.localName}> breakpoint setter \`${t.object}.${t.property}\` names no object: nothing in this tree has the id '${t.object}'.`);return{object:r,property:t.property,value:t.value}})}}),{read(e,t){let n=propertyOf(t),r=e[n];return typeof r==`boolean`&&isWritable(e,n)?{member:r}:{attribute:e.getAttribute(attributeOf(t))}},write(e,t,n){let r=propertyOf(t);if(typeof n==`object`&&n&&`member`in n)e[r]=n.member;else if(typeof n==`object`&&n&&`attribute`in n){let r=n.attribute;r===null?e.removeAttribute(attributeOf(t)):e.setAttribute(attributeOf(t),r)}else typeof n==`boolean`&&isWritable(e,r)?e[r]=n:writeProp(e,t,n)}});n.disposers.push((n.observeSize??observeAdaptiveSize)(e,e=>r.evaluate(e)))}function bindProperty(e,t){if(t.template!==void 0)return bindThroughEngine(e,t.template,t);let{el:n,property:r,source:i,sourceProperty:a,flags:o}=e,s=`<${n.localName}> \`${r}: bind ${i}.${a}\``,c=t.ids.get(i);if(c===void 0)throw Error(`${s} names no object: nothing in this tree has the id '${i}'.`);if(o.length>0)throw Error(`${s} carries ${o.join(`, `)}: adwaita-web binds the plain form only until each flag is verified against GObject.`);let l=`notify::${a}`,u=dispatchedSignalsOf(c),d=u[l];if(d===void 0)throw Error(`${s}: <${c.localName}> dispatches no '${l}', so the target would follow the source once and never again. It dispatches: ${Object.keys(u).join(`, `)||`none`}.`);let f=propertyOf(r),p=propertyOf(a);if(!isWritable(n,f))throw Error(`${s}: <${n.localName}> has no writable property '${f}'.`);let follow=()=>{n[f]=c[p]};follow(),c.addEventListener(d,follow)}function bindThroughEngine(e,t,n){let{el:r,property:i,source:a,sourceProperty:o,flags:s}=e,c=`<${r.localName}> \`${i}: bind ${a}.${o}\``,l=a===`template`?t.instance:n.ids.get(a);if(l===void 0)throw Error(`${c} names no object: nothing in this tree has the id '${a}'.`);let u=[`bidirectional`,`inverted`,`no-sync-create`],d=s.filter(e=>!u.includes(e));if(d.length>0)throw Error(`${c} carries ${d.join(`, `)}, which is not a bind flag.`);if(hasElementApi(r)&&!isWritable(r,propertyOf(i)))throw Error(`${c}: <${r.localName}> has no writable property '${propertyOf(i)}'.`);let f=[];s.includes(`bidirectional`)&&f.push(`bidirectional`),s.includes(`inverted`)&&f.push(`invert-boolean`),s.includes(`no-sync-create`)||f.push(`sync-create`),t.bind(endpointOf(l),o,endpointOf(r),i,f)}function writeProp(e,t,n){let r=attributeOf(t),i=propertyOf(t),a=fr.find(e=>e===r);a!==void 0&&typeof n==`boolean`?e.setAttribute(a,n?``:`false`):r===`visible`&&typeof n==`boolean`&&hasInstalledVisible(e)||isTemplateTag(e.localName)&&i in e?e[i]=n:typeof n==`boolean`&&isValueBasedBooleanAttr(e.localName,r)?writeBooleanAttribute$1(e,r,n):n===!1&&isWritable(e,i)?e[i]=!1:typeof n==`boolean`?e.toggleAttribute(r,n):e.setAttribute(r,String(n));let o=widgetLengthStyle(r,n);o!==void 0&&(o[1]===null?e.style.removeProperty(o[0]):e.style.setProperty(o[0],o[1]))}function buildNode$1(e,t){let n=document.createElement(e.extern===!0?templateTagFor(e.tag):hostTagOf(e.tag));if(t.template!==void 0&&installElementApi(n),installVisible(n),e.id!==void 0){if(t.ids.has(e.id))throw Error(`Two nodes of this tree carry the id '${e.id}'; GtkBuilder refuses a duplicate id.`);n.id=e.id,t.ids.set(e.id,n)}collectNode(n,e,t),writeLook(n,e,t.menus),bindSignals(n,e,t),e.extensions!==void 0&&t.extended.push({el:n,node:e});for(let r of buildChildren(n,e,t))n.append(r);return n}__name(buildNode$1,`buildNode`);function collectNode(e,t,n){for(let[r,i]of Object.entries(t.bindings??{}))r===`sensitive`&&installSensitive(e),n.binds.push({el:e,property:r,source:i.source,sourceProperty:i.property,flags:i.flags??[]});t.breakpoints!==void 0&&n.breakpointHosts.push({el:e,node:t})}function writeLook(e,t,n){for(let[n,r]of Object.entries(t.props??{}))n!==`menu-model`&&writeProp(e,n,r);for(let[r,i]of menuAssignments(t,n))e[propertyOf(r)]=i;t.styleClasses!==void 0&&t.styleClasses.length>0&&e.classList.add(...t.styleClasses),writeExtensions(e,t),writeAccessibility(e,t)}const Or={label:`aria-label`,description:`aria-description`};function writeAccessibility(e,t){for(let[n,r]of Object.entries(t.accessibility??{}))e.setAttribute(Or[n],String(r.value))}const kr={row:{property:`gridRow`,span:!1},column:{property:`gridColumn`,span:!1},"row-span":{property:`gridRow`,span:!0},"column-span":{property:`gridColumn`,span:!0}};function writeGridCell(e,t,n){let r=n.layout??{};if(e.localName!==`gtk-grid`)throw Error(`layout (${Object.keys(r).join(`, `)}) on \`${n.tag}\` under \`${e.localName}\`: this renderer's only layout manager is the grid, so the placement would be dropped.`);let i={row:0,column:0,"row-span":1,"column-span":1};for(let[e,t]of Object.entries(r)){if(kr[e]===void 0)throw Error(`layout \`${e}\` on \`${n.tag}\` reaches nothing: a grid child takes ${Object.keys(kr).join(`, `)}.`);if(typeof t!=`number`||!Number.isInteger(t))throw Error(`layout \`${e}: ${String(t)}\` on \`${n.tag}\` is not a whole number.`);i[e]=t}t.style.gridRow=`${i.row+1} / span ${i[`row-span`]}`,t.style.gridColumn=`${i.column+1} / span ${i[`column-span`]}`}function buildChildren(e,t,n){let r=[];for(let i of t.children??[]){let t=buildNode$1(i,n);i.layout!==void 0&&writeGridCell(e,t,i),i.page!==void 0&&writePage(e,t,i),i.slot!==void 0&&(t.setAttribute(`slot`,i.slot),n.placed.push({parent:e,child:t,slot:i.slot})),r.push(t)}return r}function buildTemplateTree(e,t,n){assertTreeConstructs(`adwaita-web`,hr,e,Object.keys(Or));let r=newRecord(void 0,void 0,t);r.menus=e.menus,e.id!==void 0&&r.ids.set(e.id,n),collectNode(n,e,r),bindSignals(n,e,r);let i=buildChildren(n,e,r);buildSiblings(e,r);for(let e of r.connects??[])e();for(let e of r.binds)bindProperty(e,r);for(let e of r.breakpointHosts)bindBreakpoints(e.el,e.node,r);return{children:i,objects:Object.fromEntries(r.ids),finish:()=>writeLook(n,e,e.menus)}}function bindSignals(e,t,n){let r=dispatchedSignalsOf(e);for(let i of t.signals??[]){let t=i.detail===void 0?i.name:`${i.name}::${i.detail}`,a=r[t];if(a===void 0)throw Error(`<${e.localName}> declares no signal '${t}', so the handler '${i.handler}' would never run. It dispatches: ${Object.keys(r).join(`, `)||`none`}.`);if(n.template!==void 0){if(i.flags?.includes(`after`)===!0)throw Error(`the handler '${i.handler}' for '${t}' uses after, which is not in the GObject subset.`);let r=n.template;n.connects.push(()=>{let a=i.object===void 0?void 0:i.object===`template`?r.instance:n.ids.get(i.object);if(i.object!==void 0&&a===void 0)throw Error(`the handler '${i.handler}' for '${t}' names the object '${i.object}', which nothing in this tree has.`);e.connect(t,r.handler(i.handler,{object:a,flags:i.flags}))});continue}if(i.object!==void 0||(i.flags?.length??0)>0)throw Error(`the handler '${i.handler}' for '${t}' uses ${i.object===void 0?``:`an object `}${(i.flags??[]).join(`, `)}: adwaita-web binds plain handlers only until each of those is verified against GTK.`);let o=n.scope?.[i.handler];if(typeof o!=`function`)throw Error(`the tree binds the handler '${i.handler}' for '${t}', and the scope ${n.scope===void 0?"was not given (pass `scope`)":`has no such function`}.`);e.addEventListener(a,e=>o.call(n.scope,e))}}function writeExtensions(e,t){let n=t.extensions?.strings;n!==void 0&&e.setAttribute(`strings`,JSON.stringify(n.map(e=>e.value)));for(let n of t.extensions?.responses??[]){let t=document.createElement(`adw-alert-response`);t.id=n.id,n.appearance!==void 0&&t.setAttribute(`appearance`,n.appearance),n.enabled===!1&&t.setAttribute(`enabled`,`false`),t.textContent=n.label,e.append(t)}}function writePage(e,t,n){let{page:r}=n;if(e.localName===`gtk-notebook`)r?.label!==void 0&&t.setAttribute(`tab-label`,r.label);else if(e.localName===`gtk-stack`)r?.name!==void 0&&t.setAttribute(`name`,r.name),r?.label!==void 0&&t.setAttribute(`title`,r.label);else throw Error(`adwaita-web's shared-tree builder: <${n.tag}> has a page, and <${e.localName}> has no pages.`)}const Ar=new Map;function modifierState(e){return!!e.shiftKey|(e.ctrlKey?4:0)|(e.altKey?8:0)|(e.metaKey?67108864:0)}const jr={setStyles(e){if(typeof document>`u`)return;let t=new Set(e.map(e=>e.owner));for(let[e,n]of Ar)t.has(e)||(n.remove(),Ar.delete(e));for(let{owner:t,css:n,priority:r}of e){let e=Ar.get(t);e||(e=document.createElement(`style`),Ar.set(t,e)),e.dataset.gtkPriority=String(r),e.textContent!==n&&(e.textContent=n),document.head.append(e)}},openUri(e){typeof globalThis>`u`||globalThis.open(e,`_blank`,`noopener`)},fontName(){if(typeof document>`u`||!document.body)return null;let e=getComputedStyle(document.body),t=e.fontFamily.split(`,`)[0]?.trim().replace(/^["']|["']$/g,``),n=Number.parseFloat(e.fontSize);return!t||!Number.isFinite(n)?null:`${t} ${Math.round(n*.75*10)/10}`},listenKeys(e,t){let n=e;n.hasAttribute(`tabindex`)||n.setAttribute(`tabindex`,`-1`);let listen=e=>n=>{let r=n;t({key:r.key,keycode:r.keyCode,state:modifierState(r),pressed:e})&&r.preventDefault()},r=listen(!0),i=listen(!1);return n.addEventListener(`keydown`,r),n.addEventListener(`keyup`,i),()=>{n.removeEventListener(`keydown`,r),n.removeEventListener(`keyup`,i)}}},W=createGtkPlatform(jr);W.CssProvider,W.StyleContext,W.Settings;const Mr=W.IconTheme;W.EventControllerKey,W.show_uri;const Nr=new Set;function onIconThemeChanged(e){return Nr.add(e),()=>{Nr.delete(e)}}function hasSymbolic(e){return e===``?!1:getComputedStyle(document.documentElement).getPropertyValue(`--icon-${e}`).trim()!==``}function lookupIcon(e,t={}){if(e==null||e===``)return null;let n=resourceIcon(e,t);if(n!==null)return n;let r=normalizeIconName(e);return r===``?{kind:`missing`}:{kind:`symbolic`,name:r}}const Pr=Mr.get_for_display(null),Fr=new Map;Pr.connect(`changed`,()=>{for(let e of Fr.values())e!==null&&URL.revokeObjectURL(e);Fr.clear();for(let e of Nr)e()});const Ir={".svg":`image/svg+xml`,".png":`image/png`};function resourceUrl(e){let t=Fr.get(e);if(t!==void 0)return t;let n=null,r=Ir[e.slice(e.lastIndexOf(`.`))];if(r===void 0)console.warn(`Gtk.IconTheme: ${e} is not an SVG or a PNG, which is all a browser draws (ADR 0116 § 4).`);else try{let t=resources_lookup_data(e,0).get_data();n=URL.createObjectURL(new Blob([t],{type:r}))}catch(t){console.warn(`Gtk.IconTheme: ${e} cannot be drawn: ${t.message}`)}return Fr.set(e,n),n}function resourceIcon(e,t){let n=lookupResourceIcon(Pr,{names:iconLookupNames(e,t.direction??null),get size(){return t.size??16},scale:t.scale??1,themeHas:e=>hasSymbolic(normalizeIconName(e))});return n===null?null:n.kind===`theme`?{kind:`symbolic`,name:normalizeIconName(n.name)}:{kind:`resource`,name:n.name,path:n.path,url:resourceUrl(n.path),symbolic:n.symbolic}}let G=null;function interceptCopy(e,t){if(!e)return t(),!1;let n=G,r={data:e,wrote:!1};G=r;try{t()}finally{G=n}return r.wrote}const Lr={writeText(e){if(G){G.data.setData(`text/plain`,e),G.wrote=!0;return}return typeof navigator>`u`||!navigator.clipboard?Promise.reject(Error(`navigator.clipboard is not available here`)):navigator.clipboard.writeText(e)}},Rr={name:`adwaita-web`,requiresWindow:!1,start(e){return new Promise(t=>{let go=()=>{e(),t()};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,go,{once:!0}):go()})},detach(e){e.remove()},exit(){},iconTheme:()=>Mr.get_for_display(null),guardUnload(e){e?globalThis.addEventListener(`beforeunload`,confirmUnload):globalThis.removeEventListener(`beforeunload`,confirmUnload)}};function confirmUnload(e){e.preventDefault(),e.returnValue=``}function parentOfElement(e){if(!(e instanceof Element))return null;let t=e.anchor;return t instanceof Element?t:e.parentElement}function activateWidgetAction(e,t,n=null){return activateWidgetAction$1(e,t,parentOfElement,n)}function menuActionsOfElement(e,t){return menuActionsFor(t,e,parentOfElement)}function activateElementMenuItem(e,t){return activateMenuItem(t,e,parentOfElement)}var GioApplication=class extends GioApplicationBase{static host=Rr};withGtkApplication(GioApplication);const zr=new WeakMap;function followAccelerators(e,t){zr.get(e)?.(),zr.delete(e),t!==null&&zr.set(e,jr.listenKeys(e,t=>dispatchAccelerator(e,t,parentOfElement)))}function defineWindowApplication(e){defineWindowApplicationMembers(e,followAccelerators)}const Br={b:{element:`b`},i:{element:`i`},u:{element:`u`},s:{element:`s`},tt:{element:`span`,style:{"font-family":`monospace`}},big:{element:`span`,style:{"font-size":`larger`}},small:{element:`span`,style:{"font-size":`smaller`}},sub:{element:`sub`},sup:{element:`sup`},markup:{element:`span`,style:{display:`contents`}},span:{element:`span`}},Vr={weight:`font-weight`,style:`font-style`,underline:`text-decoration-line`,strikethrough:`text-decoration-line`,font_family:`font-family`,size:`font-size`},Hr={font_weight:`weight`,font_style:`style`,face:`font_family`,font_size:`size`},Ur={weight:{ultralight:`100`,light:`300`,normal:`400`,medium:`500`,semibold:`600`,bold:`bold`,ultrabold:`700`,heavy:`900`},style:{normal:`normal`,oblique:`oblique`,italic:`italic`}};function buildNode(e,t){if(e.kind===`text`)return t.createTextNode(e.text);let n=Br[e.tag];if(n===void 0)return null;let r=t.createElement(n.element);if(n.style!==void 0)for(let[e,t]of Object.entries(n.style))r.style.setProperty(e,t);e.tag===`span`&&applySpanAttributes(r,e.attributes);for(let n of e.children){let e=buildNode(n,t);e!==null&&r.append(e)}return r}function applySpanAttributes(e,t){let n=[];for(let[r,i]of Object.entries(t)){let t=Hr[r]??r,a=Vr[t];if(a===void 0)continue;if(t===`underline`){i!==`none`&&n.push(`underline`);continue}if(t===`strikethrough`){i!==`false`&&i!==`none`&&n.push(`line-through`);continue}if(t===`font_family`){let t=sanitizeFontFamily(i);t!==null&&e.style.setProperty(a,t);continue}if(t===`size`){let t=sanitizeFontSize(i);t!==null&&e.style.setProperty(a,t);continue}if(t===`weight`&&/^[0-9]{1,4}$/.test(i)&&+i>=1&&+i<=1e3){e.style.setProperty(a,i);continue}let o=Ur[t]?.[i];o!==void 0&&e.style.setProperty(a,o)}n.length>0&&e.style.setProperty(`text-decoration-line`,n.join(` `))}const Wr=new Set([`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`,`ui-serif`,`ui-sans-serif`,`ui-monospace`,`ui-rounded`]);function sanitizeFontFamily(e){let t=[];for(let n of e.split(`,`)){let e=n.trim();if(e!==``){if(!Wr.has(e.toLowerCase())&&!/^["']?[A-Za-z0-9 _-]+["']?$/.test(e))return null;t.push(e)}}return t.length>0?t.join(`, `):null}function sanitizeFontSize(e){let t=e.trim(),n={"xx-small":`xx-small`,"x-small":`x-small`,small:`small`,medium:`medium`,large:`large`,"x-large":`x-large`,"xx-large":`xx-large`,smaller:`smaller`,larger:`larger`}[t];return n===void 0?/^[0-9]+$/.test(t)?`${t/1024}pt`:/^[0-9]+(\.[0-9]+)?pt$/.test(t)||/^[0-9]+(\.[0-9]+)?%$/.test(t)?t:null:n}function renderPangoMarkup(e,t){let n=parsePangoMarkup(t);if(n===null){e.textContent=t;return}let r=e.ownerDocument??document;e.replaceChildren(...n.map(e=>buildNode(e,r)).filter(e=>e!==null))}var WidgetElement=class extends HTMLElement{static signals={map:`map`,unmap:`unmap`};get visible(){return!this.hidden}set visible(e){let t=!this.hidden;this.toggleAttribute(`hidden`,!e),!this.hidden!==t&&`notify::visible`in dispatchedSignalsOf(this)&¬ifyElement(this,`visible`)}get_visible(){return this.visible}set_visible(e){this.visible=e}get_first_child(){return this.firstElementChild}get_last_child(){return this.lastElementChild}get_next_sibling(){return this.nextElementSibling}get_prev_sibling(){return this.previousElementSibling}get_parent(){return this.parentElement}get_width(){return this.offsetWidth}get_height(){return this.offsetHeight}connect(e,t){return installElementApi(this),this.connect(e,t)}disconnect(e){installElementApi(this),this.disconnect(e)}emit(e,...t){installElementApi(this),this.emit(e,...t)}notify(e){installElementApi(this),this.notify(e)}get_mapped(){return isMapped(this)}};markLazyElementApi(WidgetElement.prototype),Cr.add(Object.getOwnPropertyDescriptor(WidgetElement.prototype,`visible`).get);var TooltipElement=class extends WidgetElement{get tooltip_text(){return this.getAttribute(`tooltip-text`)}set tooltip_text(e){e==null?this.removeAttribute(`tooltip-text`):this.setAttribute(`tooltip-text`,e)}get tooltipText(){return this.tooltip_text}set tooltipText(e){this.tooltip_text=e}get_tooltip_text(){return this.tooltip_text}set_tooltip_text(e){this.tooltip_text=e}};function cssUrl(e){return`url("${e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}")`}const Gr=`adw-icon--`;var GtkImage=class extends WidgetElement{static get observedAttributes(){return[`icon-name`,`size`]}get iconName(){return this.getAttribute(`icon-name`)??``}set iconName(e){e===null?this.removeAttribute(`icon-name`):this.setAttribute(`icon-name`,e)}get resolvedIconName(){return normalizeIconName(this.getAttribute(`icon-name`))}get size(){let e=Number.parseFloat(this.getAttribute(`size`)??``);return Number.isFinite(e)&&e>0?e:null}set size(e){e===null?this.removeAttribute(`size`):this.setAttribute(`size`,String(e))}_unsubscribe=null;connectedCallback(){this._unsubscribe??=onIconThemeChanged(()=>this._render()),this._render()}disconnectedCallback(){this._unsubscribe?.(),this._unsubscribe=null}attributeChangedCallback(){this._render()}_request(){let measure=()=>{if(this.size!==null)return this.size;let e=this.isConnected?Number.parseFloat(getComputedStyle(this).width):NaN;return Number.isFinite(e)&&e>0?Math.round(e):16};return{get size(){return measure()},scale:Math.max(1,Math.round(globalThis.devicePixelRatio??1)),direction:this.matches(`:dir(rtl)`)?`rtl`:`ltr`}}_render(){this.classList.add(`adw-icon`);let e=[...this.classList].filter(e=>e.startsWith(Gr));this.classList.remove(...e);let t=lookupIcon(this.getAttribute(`icon-name`),this._request()),n=t?.kind===`resource`&&t.url===null?{kind:`missing`}:t,r=n?.kind===`resource`&&!n.symbolic?n.url:null,i=n?.kind===`resource`&&n.symbolic?n.url:null;this.classList.toggle(`adw-icon-color`,r!==null),r===null?this.style.removeProperty(`background-image`):this.style.backgroundImage=cssUrl(r),i===null?(this.style.removeProperty(`mask-image`),this.style.removeProperty(`-webkit-mask-image`),this.style.removeProperty(`background-color`)):(this.style.setProperty(`mask-image`,cssUrl(i)),this.style.setProperty(`-webkit-mask-image`,cssUrl(i)),this.style.backgroundColor=`currentColor`),n?.kind===`symbolic`?this.classList.add(`${Gr}${n.name}`):n?.kind===`missing`&&this.classList.add(`${Gr}image-missing`),this.setAttribute(`aria-hidden`,`true`);let a=this.size;if(a===null)this.style.removeProperty(`width`),this.style.removeProperty(`height`),this.style.removeProperty(`mask-size`),this.style.removeProperty(`-webkit-mask-size`);else{let e=`${a}px`;this.style.width=e,this.style.height=e,this.style.setProperty(`mask-size`,e),this.style.setProperty(`-webkit-mask-size`,e)}}};function createGtkImage(e,...t){let n=document.createElement(`gtk-image`);return e!==null&&n.setAttribute(`icon-name`,e),t.length>0&&n.classList.add(...t),n}customElements.define(`gtk-image`,GtkImage);const Kr={schedule:(e,t)=>setTimeout(e,t),cancel:e=>clearTimeout(e)};var AdwToastOverlay=class extends WidgetElement{_toasts;_initialized=!1;_queue;_scheduler=Kr;_currentEl=null;constructor(){super(),this._queue=new ToastOverlayQueue({scheduler:{schedule:(e,t)=>this._scheduler.schedule(e,t),cancel:e=>this._scheduler.cancel(e)},onShow:e=>this._mountToast(e),onHide:()=>this._unmountToast(this._queue.pending>0)})}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=document.createElement(`div`);e.className=`adw-toast-overlay-content`,this._toasts=document.createElement(`div`),this._toasts.className=`adw-toast-overlay-toasts`,bindSlottedChildren(this,[{name:`child`,into:e},{into:e}]).install(e,this._toasts)}get scheduler(){return this._scheduler}set scheduler(e){this._scheduler=e}get currentToast(){return this._queue.current}get pendingToasts(){return this._queue.pending}add_toast(e){this._toasts||this.connectedCallback(),this._queue.add_toast(e)}dismiss_all(){this._queue.dismiss_all()}_mountToast(e){let t=document.createElement(`div`);t.className=`adw-toast`;let n=document.createElement(`div`);n.className=`adw-toast-content-wrapper`;let r=document.createElement(`span`);if(r.className=`adw-toast-title`,e.use_markup?renderPangoMarkup(r,e.title):r.textContent=e.title,n.appendChild(r),t.appendChild(n),e.button_label){let n=document.createElement(`button`);n.type=`button`,n.className=`adw-toast-action-button`,n.textContent=e.button_label,n.addEventListener(`click`,()=>{e.emit(`button-clicked`),e.action_name&&activateWidgetAction(this,e.action_name),e.dismiss()}),t.appendChild(n)}let i=document.createElement(`button`);i.type=`button`,i.className=`adw-toast-close-button`,i.setAttribute(`aria-label`,`Close`),i.appendChild(createGtkImage(`window-close`)),i.addEventListener(`click`,()=>e.dismiss()),t.appendChild(i),this._toasts.appendChild(t),this._currentEl=t,requestAnimationFrame(()=>{t.classList.add(`visible`)})}_unmountToast(e){let t=this._currentEl;if(this._currentEl=null,t){if(e){t.remove();return}t.classList.remove(`visible`),t.classList.add(`hiding`),t.addEventListener(`transitionend`,()=>t.remove(),{once:!0}),this._scheduler.schedule(()=>{t.parentNode&&t.remove()},300)}}};customElements.define(`adw-toast-overlay`,AdwToastOverlay);const qr=[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`,`);var AdwModalSurface=class{_init;_previouslyFocused=null;constructor(e){this._init=e,e.surface.setAttribute(`role`,e.role),e.surface.setAttribute(`aria-modal`,`true`),e.surface.hasAttribute(`tabindex`)||(e.surface.tabIndex=-1),e.host.addEventListener(`keydown`,e=>this._onKeyDown(e))}focusables(){return Array.from(this._init.surface.querySelectorAll(qr)).filter(e=>!e.hasAttribute(`disabled`)&&!e.hidden&&e.getClientRects().length>0)}present(){let e=document.activeElement;this._previouslyFocused=e instanceof HTMLElement&&e!==this._init.host?e:null;let t=this.focusables(),n=this._init.initialFocus?.(t);((n&&t.includes(n)?n:void 0)??t[0]??this._init.surface).focus()}dismiss(){let e=this._previouslyFocused;this._previouslyFocused=null,e&&e.isConnected&&e.focus()}_onKeyDown(e){if(!this._init.isOpen())return;if(e.key===`Escape`){e.stopPropagation(),this._init.onEscape();return}if(e.key!==`Tab`)return;e.stopPropagation();let t=this.focusables();if(t.length===0){e.preventDefault(),this._init.surface.focus();return}let n=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&(i===n||i===this._init.surface||i===this._init.host)?(e.preventDefault(),r.focus()):!e.shiftKey&&(i===r||i===this._init.host)&&(e.preventDefault(),n.focus())}};function rowLabel(e){return stripMnemonic(C[e])}var AdwAboutDialog=class extends WidgetElement{_initialized=!1;_scrimEl;_sheetEl;_modal;_navView;_scrollEl;_mainToolbarEl;_developers=[];_designers=[];_artists=[];_documenters=[];_licenseState={...ye};_reflecting=!1;_creditSections=[];_acknowledgementSections=[];_legalSections=[];_links=[];_releaseNotesSegments=[];_toastOverlay;static get observedAttributes(){return[`application-name`,`application-icon`,`developer-name`,`version`,`comments`,`website`,`support-url`,`issue-url`,`copyright`,`license`,`license-type`,`license-url`,`translator-credits`,`release-notes`,`release-notes-version`,`debug-info`,`open`]}static new_from_appdata(e,t){refuseNewFromAppdata()}get applicationName(){return this.getAttribute(`application-name`)??``}set applicationName(e){this.setAttribute(`application-name`,e)}get applicationIcon(){return this.getAttribute(`application-icon`)??``}set applicationIcon(e){this.setAttribute(`application-icon`,e)}get developerName(){return this.getAttribute(`developer-name`)??``}set developerName(e){this.setAttribute(`developer-name`,e)}get version(){return this.getAttribute(`version`)??``}set version(e){this.setAttribute(`version`,e)}get comments(){return this.getAttribute(`comments`)??``}set comments(e){this.setAttribute(`comments`,e)}get website(){return this.getAttribute(`website`)??``}set website(e){this.setAttribute(`website`,e)}get supportUrl(){return this.getAttribute(`support-url`)??``}set supportUrl(e){this.setAttribute(`support-url`,e)}get issueUrl(){return this.getAttribute(`issue-url`)??``}set issueUrl(e){this.setAttribute(`issue-url`,e)}get copyright(){return this.getAttribute(`copyright`)??``}set copyright(e){this.setAttribute(`copyright`,e)}get license(){return this._licenseState.license}set license(e){this.setAttribute(`license`,e)}get licenseType(){return this._licenseState.licenseType}set licenseType(e){this.setAttribute(`license-type`,String(e))}get translatorCredits(){return this.getAttribute(`translator-credits`)??``}set translatorCredits(e){this.setAttribute(`translator-credits`,e)}get licenseUrl(){return this.getAttribute(`license-url`)??``}set licenseUrl(e){this.setAttribute(`license-url`,e)}get releaseNotes(){return this.getAttribute(`release-notes`)??``}set releaseNotes(e){this.setAttribute(`release-notes`,e)}get releaseNotesVersion(){return this.getAttribute(`release-notes-version`)??``}set releaseNotesVersion(e){this.setAttribute(`release-notes-version`,e)}get debugInfo(){return this.getAttribute(`debug-info`)??``}set debugInfo(e){this.setAttribute(`debug-info`,e)}add_link(e,t){this._links.push({title:e,url:t}),this._initialized&&this._render()}add_credit_section(e,t){this._creditSections.push({title:e,people:[...t]}),this._initialized&&this._render()}add_acknowledgement_section(e,t){this._acknowledgementSections.push({title:e,people:[...t]}),this._initialized&&this._render()}add_legal_section(e,t,n,r){isLicenseType(n)&&(this._legalSections.push({title:e,copyright:t,licenseType:n,license:r}),this._initialized&&this._render())}get open(){return this.hasAttribute(`open`)}set open(e){e?this.setAttribute(`open`,``):this.removeAttribute(`open`)}get developers(){return this._developers}set developers(e){this._developers=[...e],this._initialized&&this._render()}get designers(){return this._designers}set designers(e){this._designers=[...e],this._initialized&&this._render()}get artists(){return this._artists}set artists(e){this._artists=[...e],this._initialized&&this._render()}get documenters(){return this._documenters}set documenters(e){this._documenters=[...e],this._initialized&&this._render()}present(){this.open=!0}close(){this.open=!1}connectedCallback(){this._initialized||(this._initialized=!0,this._scrimEl=document.createElement(`div`),this._scrimEl.className=`adw-about-dialog-scrim`,this._scrimEl.addEventListener(`click`,()=>this.close()),this._sheetEl=document.createElement(`div`),this._sheetEl.className=`adw-about-dialog-sheet`,this._sheetEl.setAttribute(`aria-label`,C.dialogTitle),this._toastOverlay=document.createElement(`adw-toast-overlay`),this._sheetEl.appendChild(this._toastOverlay),this.replaceChildren(this._scrimEl,this._sheetEl),this._modal=new AdwModalSurface({host:this,surface:this._sheetEl,role:`dialog`,isOpen:()=>this.open,onEscape:()=>this.close()}),this._render())}attributeChangedCallback(e,t,n){if(t!==n){if(e===`license`||e===`license-type`){this._reflecting||this._applyLicenseAttribute(e,n),this._initialized&&!this._reflecting&&this._render();return}if((e===`release-notes`||e===`release-notes-version`)&&(this._releaseNotesSegments=releaseNotesBuffer({releaseNotes:this.releaseNotes,releaseNotesVersion:this.releaseNotesVersion,version:this.version},C).segments),this._initialized){if(e===`open`){this._syncOpen(),this.dispatchEvent(new CustomEvent(`notify::open`,{bubbles:!0,detail:{open:this.open}})),this.open||this.dispatchEvent(new CustomEvent(`closed`,{bubbles:!0}));return}this._render()}}}_applyLicenseAttribute(e,t){let n=e===`license`?setLicense(this._licenseState,t??``):setLicenseType(this._licenseState,this._parseLicenseType(t));this._licenseState=n.state,this._reflectLicense();for(let e of n.notify)this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{license:this._licenseState.license,licenseType:this._licenseState.licenseType}}))}_parseLicenseType(e){return e===null?S.UNKNOWN:/^-?\d+$/.test(e.trim())?Number(e):licenseTypeForNick(e.trim())??-1}_reflectLicense(){let{license:e,licenseType:t}=this._licenseState;this._reflecting=!0;try{e.length===0?this.removeAttribute(`license`):this.getAttribute(`license`)!==e&&this.setAttribute(`license`,e);let n=this.getAttribute(`license-type`);t===S.UNKNOWN?n!==null&&this.removeAttribute(`license-type`):(n===null||this._parseLicenseType(n)!==t)&&this.setAttribute(`license-type`,String(t))}finally{this._reflecting=!1}}_syncOpen(){this.classList.toggle(`open`,this.open),this.open?(this._navView.replace?.([`main`]),this._scrollEl.scrollTop=0,this._updateHeaderTitle(),this._modal.present()):this._modal.dismiss()}_creditsSections(){return creditsSections({developers:this._developers,designers:this._designers,artists:this._artists,documenters:this._documenters,translatorCredits:this.translatorCredits,creditSections:this._creditSections})}_legalInput(){return{copyright:this.copyright,licenseType:this._licenseState.licenseType,license:this._licenseState.license,legalSections:this._legalSections}}_render(){let e=this._creditsSections(),t=acknowledgementSections(this._acknowledgementSections),n=aboutDialogVisibility({applicationIcon:this.applicationIcon,applicationName:this.applicationName,developerName:this.developerName,version:this.version,comments:this.comments,website:this.website,supportUrl:this.supportUrl,issueUrl:this.issueUrl,debugInfo:this.debugInfo,releaseNotes:this.releaseNotes,hasCustomLinks:this._links.length>0,hasCredits:e.length>0,hasLegal:legalVisible(this._legalInput()),hasAcknowledgements:t.length>0});this._navView?.remove(),this._navView=document.createElement(`adw-navigation-view`),this._navView.append(this._buildMainPage(n)),n.whatsNewRow&&this._navView.append(this._buildWhatsNewPage()),n.detailsRow&&this._navView.append(this._buildDetailsPage(n)),n.troubleshootingRow&&this._navView.append(this._buildTroubleshootingPage(),this._buildDebugInfoPage()),n.creditsRow&&this._navView.append(this._buildCreditsPage(e)),n.legalRow&&this._navView.append(this._buildLegalPage()),n.acknowledgementsRow&&this._navView.append(this._buildAcknowledgementsPage(t)),(this._toastOverlay.querySelector(`:scope > .adw-toast-overlay-content`)??this._toastOverlay).appendChild(this._navView),this.classList.toggle(`open`,this.open)}_buildPage(e,t,n,r=t){let i=document.createElement(`adw-navigation-page`);i.setAttribute(`title`,t),i.setAttribute(`tag`,e);let a=document.createElement(`adw-header-bar`);if(a.setAttribute(`title`,r),n){let e=document.createElement(`button`);e.type=`button`,e.className=`adw-button flat circular adw-about-dialog-close`,e.setAttribute(`aria-label`,`Close`),e.addEventListener(`click`,()=>this.close());let endApply=()=>{let t=a.endSection??null;t&&t.appendChild(e)};queueMicrotask(endApply)}let o=document.createElement(`div`);o.className=`adw-about-dialog-scroll`;let s=document.createElement(`div`);s.className=`adw-about-dialog-clamp`;let c=document.createElement(`div`);c.className=`adw-about-dialog-page-body`,s.appendChild(c),o.appendChild(s);let l=document.createElement(`div`);return l.className=`adw-about-dialog-toolbar-view`,l.append(a,o),i.appendChild(l),e===`main`&&(this._scrollEl=o,this._mainToolbarEl=l,l.classList.add(`main-page`),o.addEventListener(`scroll`,()=>this._updateHeaderTitle())),{page:i,body:c,header:a}}_buildMainPage(e){let{page:t,body:n}=this._buildPage(`main`,C.dialogTitle,!0,this.applicationName);if(e.appIcon&&n.appendChild(createGtkImage(this.applicationIcon,`adw-about-dialog-icon`)),e.appName){let e=document.createElement(`span`);e.className=`adw-about-dialog-name`,e.textContent=this.applicationName,n.appendChild(e)}if(e.developerName){let e=document.createElement(`span`);e.className=`adw-about-dialog-developer`,e.textContent=this.developerName,n.appendChild(e)}if(e.version){let e=document.createElement(`span`);e.className=`adw-about-dialog-version`,e.textContent=this.version,n.appendChild(e)}let r=[];e.whatsNewRow&&r.push(this._buildNavRow(rowLabel(`whatsNewRow`),`whatsnew`)),e.detailsRow&&r.push(this._buildNavRow(rowLabel(`detailsRow`),`details`)),e.websiteRow&&r.push(this._buildLinkRow(rowLabel(`websiteRow`),this.website));let i=[];e.supportRow&&i.push(this._buildLinkRow(rowLabel(`supportRow`),this.supportUrl)),e.issueRow&&i.push(this._buildLinkRow(rowLabel(`issueRow`),this.issueUrl)),e.troubleshootingRow&&i.push(this._buildNavRow(rowLabel(`troubleshootingRow`),`troubleshooting`));let a=[];return e.creditsRow&&a.push(this._buildNavRow(rowLabel(`creditsRow`),`credits`)),e.legalRow&&a.push(this._buildNavRow(rowLabel(`legalRow`),`legal`)),e.acknowledgementsRow&&a.push(this._buildNavRow(rowLabel(`acknowledgementsRow`),`acknowledgements`)),e.detailsGroup&&n.appendChild(this._buildGroup(`details`,r)),e.supportGroup&&n.appendChild(this._buildGroup(`support`,i)),e.creditsLegalGroup&&n.appendChild(this._buildGroup(`credits-legal`,a)),t}_buildGroup(e,t,n){let r=document.createElement(`adw-preferences-group`);e!==null&&r.setAttribute(`data-group`,e),n!==void 0&&r.setAttribute(`title`,n);for(let e of t)r.appendChild(e);let i=document.createElement(`div`);return i.className=`adw-about-dialog-rows`,i.appendChild(r),i}_buildNavRow(e,t){let n=document.createElement(`adw-action-row`);n.setAttribute(`title`,e),n.setAttribute(`activatable`,``);let r=createGtkImage(`go-next`,`adw-about-dialog-chevron`);return r.setAttribute(`slot`,`suffix`),n.appendChild(r),n.addEventListener(`activated`,()=>{this._navView.push?.(t)}),n}_activateLink(e){let t=new CustomEvent(`activate-link`,{bubbles:!0,cancelable:!0,detail:{uri:e}});this.dispatchEvent(t)&&globalThis.open(e,`_blank`,`noopener,noreferrer`)}_buildDetailsPage(e){let{page:t,body:n}=this._buildPage(`details`,C.detailsPage,!1);if(e.commentsLabel){let e=document.createElement(`p`);e.className=`adw-about-dialog-comments`,e.textContent=this.comments,n.appendChild(e)}if(e.linksGroup){let t=[];e.detailsWebsiteRow&&t.push(this._buildLinkRow(rowLabel(`websiteRow`),this.website));for(let e of this._links)t.push(this._buildLinkRow(stripMnemonic(e.title),e.url));n.appendChild(this._buildGroup(`links`,t))}return t}_buildWhatsNewPage(){let{page:e,body:t}=this._buildPage(`whatsnew`,C.whatsNewPage,!1),n=document.createElement(`div`);n.className=`adw-about-dialog-release-notes`;for(let e of this._releaseNotesSegments){let t=document.createElement(`span`);e.tag!==null&&(t.dataset.tag=e.tag),t.textContent=e.text,n.appendChild(t)}return t.appendChild(n),e}_buildTroubleshootingPage(){let{page:e,body:t}=this._buildPage(`troubleshooting`,C.troubleshootingPage,!1),n=document.createElement(`p`);return n.className=`adw-about-dialog-comments`,n.textContent=C.troubleshootingIntro,t.append(n,this._buildGroup(null,[this._buildNavRow(rowLabel(`debugInfoRow`),`debuginfo`)])),e}_buildDebugInfoPage(){let{page:e,body:t}=this._buildPage(`debuginfo`,C.debugInfoPage,!1),n=document.createElement(`pre`);n.className=`adw-about-dialog-debug-info`,n.textContent=this.debugInfo;let r=document.createElement(`button`);return r.type=`button`,r.className=`adw-button pill adw-about-dialog-copy`,r.textContent=rowLabel(`copyText`),r.addEventListener(`click`,()=>this._copyProperty(this.debugInfo)),t.append(n,r),e}_copyProperty(e){e.length!==0&&(Promise.resolve(Lr.writeText(e)).catch(()=>void 0),this._toastOverlay.add_toast(new Toast({title:C.copiedToast})))}_buildLinkRow(e,t){let n=document.createElement(`adw-action-row`);return n.setAttribute(`title`,e),this._makeLinkRow(n,t),n}_makeLinkRow(e,t){e.setAttribute(`activatable`,``),e.setAttribute(`role`,`link`),e.classList.add(`link`,`adw-about-dialog-link-row`);let n=linkRowTooltip(t);n!==null&&e.setAttribute(`tooltip-text`,n);let r=createGtkImage(linkRowIconName(t),`adw-about-dialog-link-icon`);r.setAttribute(`slot`,`suffix`),r.setAttribute(`aria-hidden`,`true`),e.appendChild(r),e.addEventListener(`activated`,()=>this._activateLink(t))}_buildCreditsPage(e){return this._buildCreditGroupsPage(`credits`,C.creditsPage,e)}_buildAcknowledgementsPage(e){return this._buildCreditGroupsPage(`acknowledgements`,C.acknowledgementsPage,e)}_buildCreditGroupsPage(e,t,n){let{page:r,body:i}=this._buildPage(e,t,!1);for(let e of n){let t=e.people.map(e=>this._buildCreditRow(e));i.appendChild(this._buildGroup(null,t,e.title??void 0))}return r}_buildCreditRow(e){let t=document.createElement(`adw-action-row`);if(t.setAttribute(`title`,e.name),e.link!==null){let n=e.uri??``;this._makeLinkRow(t,n)}return t}_buildLegalPage(){let{page:e,body:t}=this._buildPage(`legal`,C.legalPage,!1),n=this._legalInput(),r=legalSections(n),i=legalSectionVisible(n.copyright,n.licenseType,n.license);for(let[e,a]of r.entries()){if(a.title!==null){let e=document.createElement(`p`);e.className=`adw-about-dialog-legal-title`,e.textContent=a.title,t.appendChild(e)}let r=document.createElement(`p`);r.className=`adw-about-dialog-license`,e===0&&i&&this.licenseUrl&&n.licenseType===S.CUSTOM?(this._renderLegalLabel(r,this.copyright),this.copyright.length>0&&r.append(`
|
|
15
|
+
`&&e++),t[e]!==`&`){i+=n;continue}if(e++,t[e]===`#`){e++;let n=10;t[e]===`x`&&(n=16,e++);let r=strtoul(t,e,n);r.end===e||r.isOverflow?fail(e,`Failed to parse “${t.slice(e,r.end)}”, which should have been a digit inside a character reference (ê for example) — perhaps the digit is too large`):t[r.end]===`;`?isPermittedCharacter(r.value)||fail(e,`Character reference “${t.slice(e,r.end)}” does not encode a permitted character`):fail(e,`Character reference did not end with a semicolon; ${pn}`),i+=String.fromCodePoint(Number(r.value)),e=r.end;continue}let a=mn.find(([n])=>t.startsWith(n,e));if(a!==void 0){i+=a[1],e+=a[0].length-1;continue}t[e]===`;`&&fail(e,`Empty entity “&;” seen; valid entities are: & " < > '`);let o=t.indexOf(`;`,e);o>=0&&fail(e,`Entity name “${t.slice(e,o)}” is not known`),fail(e,`Entity did not end with a semicolon; ${pn}`)}return i}function parseMarkup$1(e,t){try{return scan(e,t),null}catch(t){if(!(t instanceof MarkupFailure))throw t;return{message:t.message,...markupPosition(e,t.at)}}}__name(parseMarkup$1,`parseMarkup`);function scan(e,t){let n=e.length,r=[],i=0,a=0,o=0,s=!0,c=[],l=``,u=``,d=`"`,f=0,p=0,top=()=>r[r.length-1]??``,at=t=>String.fromCodePoint(e.codePointAt(t)),fail=t=>{let n=markupPosition(e,a);throw new MarkupFailure(`Error on line ${n.line} char ${n.character}: ${t}`,a)},skipSpaces=()=>{for(;a<n&&isXmlSpace(e[a]);)a++},nameEnd=()=>{for(;a<n&&!isNameEnd(e[a])&&!isXmlSpace(e[a]);)a++},emitStart=()=>{let e=nameError(top());e!==null&&fail(e);let n=t.start(top(),c);if(n!==null)throw new MarkupFailure(n,a)},emitEnd=()=>{t.end(r.pop())};for(;a<n;)switch(i){case 0:if(skipSpaces(),a===n)break;e[a]!==`<`&&fail(`Document must begin with an element (e.g. <book>)`),a++,i=1,s=!1;break;case 1:e[a]===`?`||e[a]===`!`?(f=a-1,p=1,i=14):e[a]===`/`?(a++,i=11):isNameEnd(e[a])?fail(`“${at(a)}” is not a valid character following a “<” character; it may not begin an element name`):(o=a,i=4);break;case 4:if(nameEnd(),a===n)break;r.push(e.slice(o,a)),c=[],i=7;break;case 7:if(skipSpaces(),a===n)break;e[a]===`/`?(a++,i=3,emitStart()):e[a]===`>`?(a++,i=2,emitStart()):e[a]===`=`?fail(`Odd character “=”, expected a “>” or “/” character to end the start tag of element “${top()}”, or optionally an attribute; perhaps you used an invalid character in an attribute name`):(o=a,i=5);break;case 5:if(nameEnd(),a===n)break;l=e.slice(o,a),i=6;break;case 6:{if(skipSpaces(),a===n)break;let t=nameError(l);t!==null&&fail(t),c.push(l),e[a]!==`=`&&fail(`Odd character “${at(a)}”, expected a “=” after attribute name “${l}” of element “${top()}”`),a++,i=8;break}case 8:if(skipSpaces(),a===n)break;e[a]!==`"`&&e[a]!==`'`&&fail(`Odd character “${at(a)}”, expected an open quote mark after the equals sign when giving value for attribute “${l}” of element “${top()}”`),d=e[a],a++,o=a,i=9;break;case 9:{let t=e.indexOf(d,a);if(t<0){a=n;break}a=t,unescape(e,e.slice(o,t),t,!0),a++,i=7;break}case 3:e[a]!==`>`&&fail(`Odd character “${at(a)}”, expected a “>” character to end the empty-element tag “${top()}”`),a++,i=2,emitEnd();break;case 2:r.length===0?i=0:(o=a,i=10);break;case 10:{let r=e.indexOf(`<`,a);if(r<0){a=n;break}a=r;let s=e.slice(o,r);s.length>0&&t.text(unescape(e,s,r,!1),top()),a++,i=1;break}case 11:isNameEnd(e[a])&&fail(`“${at(a)}” is not a valid character following the characters “</”; “${at(a)}” may not begin an element name`),o=a,i=12;break;case 12:if(nameEnd(),a===n)break;u=e.slice(o,a),i=13;break;case 13:if(skipSpaces(),a===n)break;e[a]!==`>`&&fail(`“${at(a)}” is not a valid character following the close element name “${u}”; the allowed character is “>”`),r.length===0&&fail(`Element “${u}” was closed, no element is currently open`),u!==top()&&fail(`Element “${u}” was closed, but the currently open element is “${top()}”`),a++,i=2,emitEnd();break;case 14:for(;a<n;a++){if(e[a]===`<`&&p++,e[a]!==`>`)continue;p--;let t=e.slice(f,a);if(t[1]===`?`&&t.endsWith(`?`)||t.startsWith(`<!--`)&&t.endsWith(`--`)||t.startsWith(`<![CDATA[`)&&t.endsWith(`]]`)||t.startsWith(`<!DOCTYPE`)&&p===0)break}if(a===n)break;a++,i=2;break}s&&fail(`Document was empty or contained only whitespace`);let m=r.length===0;switch(i){case 1:fail(`Document ended unexpectedly just after an open angle bracket “<”`);break;case 2:case 10:m||fail(`Document ended unexpectedly with elements still open — “${top()}” was the last element opened`);break;case 3:fail(`Document ended unexpectedly, expected to see a close angle bracket ending the tag <${top()}/>`);break;case 4:fail(`Document ended unexpectedly inside an element name`);break;case 5:case 6:fail(`Document ended unexpectedly inside an attribute name`);break;case 7:fail(`Document ended unexpectedly inside an element-opening tag.`);break;case 8:fail(`Document ended unexpectedly after the equals sign following an attribute name; no attribute value`);break;case 9:fail(`Document ended unexpectedly while inside an attribute value`);break;case 11:case 12:case 13:fail(m?`Document ended unexpectedly inside the close tag for an unopened element`:`Document ended unexpectedly inside the close tag for element “${top()}”`);break;case 14:fail(`Document ended unexpectedly inside a comment or processing instruction`);break;case 0:break}}const R={NORMAL:0,HIGH:1},hn=new WeakMap;var Toast=class extends GObjectObject$1{static{this[x]=`Adw.Toast`}get_title(){return this.title}set_title(e){this.title=e}get_timeout(){return this.timeout}set_timeout(e){this.timeout=e}get_priority(){return this.priority}set_priority(e){this.priority=e}get_button_label(){return this.button_label}set_button_label(e){this.button_label=e}get_action_name(){return this.action_name}set_action_name(e){this.action_name=e}get_use_markup(){return this.use_markup}set_use_markup(e){this.use_markup=e}dismiss(){hn.has(this)&&this.emit(`dismissed`)}};registerBaseClass(Toast,`AdwToast`,{"button-clicked":[],dismissed:[]},[y.string(`title`,``,``,v.READWRITE,``),y.uint(`timeout`,``,``,v.READWRITE,0,Dt,5),y.int(`priority`,``,``,v.READWRITE,R.NORMAL,R.HIGH,R.NORMAL),y.string(`button-label`,``,``,v.READWRITE,null),y.string(`action-name`,``,``,v.READWRITE,null),y.boolean(`use-markup`,``,``,v.READWRITE,!0)]);var ToastOverlayQueue=class{constructor(e){this._queue=[],this._handlers=new Map,this._current=null,this._timer=null,this._options=e}get current(){return this._current}get pending(){return this._queue.length}add_toast(e){let t=hn.get(e);if(t===this){this._current===e?this._startTimer(e):this._bump(e);return}if(t!==void 0)throw Error(`Adding toast '${e.title}', but it has already been added to a different AdwToastOverlay`);if(hn.set(e,this),this._handlers.set(e,e.connect(`dismissed`,()=>this._dismissed(e))),this._current===null)this._show(e);else if(e.priority===R.HIGH){let t=this._current;this._queue.unshift(t),this._hideCurrent(),this._show(e)}else this._queue.push(e)}dismiss_all(){for(let e of this._queue.splice(0))this._disconnect(e),e.dismiss(),hn.delete(e);this._current?.dismiss()}_dismissed(e){if(this._disconnect(e),hn.delete(e),e===this._current){this._hideCurrent();let e=this._queue.shift();e&&this._show(e)}else{let t=this._queue.indexOf(e);t!==-1&&this._queue.splice(t,1)}}_bump(e){if(this._queue.splice(this._queue.indexOf(e),1),e.priority===R.HIGH){this._queue.unshift(e);return}let t=this._queue.findIndex(e=>e.priority!==R.HIGH);this._queue.splice(t===-1?this._queue.length:t,0,e)}_show(e){this._current=e,this._options.onShow(e),this._startTimer(e)}_hideCurrent(){let e=this._current;e!==null&&(this._clearTimer(),this._current=null,this._options.onHide(e))}_startTimer(e){this._clearTimer(),e.timeout>0&&(this._timer=this._options.scheduler.schedule(()=>{this._timer=null,this._current===e&&e.dismiss()},e.timeout*1e3))}_clearTimer(){this._timer!==null&&(this._options.scheduler.cancel(this._timer),this._timer=null)}_disconnect(e){let t=this._handlers.get(e);t!==void 0&&(e.disconnect(t),this._handlers.delete(e))}};const gn=new Set([`none`,`single`,`multiple`]);function normalizeListSelectionMode(e){return typeof e==`string`&&gn.has(e)?e:`single`}function normalizeSelection(e,t){let n=new Set;for(let r of e)Number.isInteger(r)&&r>=0&&r<t&&n.add(r);return[...n].sort((e,t)=>e-t)}function listViewSelect(e,t,n,r,i,a={}){let o=normalizeSelection(e,r);if(i===`none`)return{selection:[],anchor:t};if(!Number.isInteger(n)||n<0||n>=r)return{selection:o,anchor:t};let s=new Set(o);if(i===`multiple`&&a.extend&&t>=0&&t<r){let e=Math.min(t,n),i=Math.max(t,n),o=[];for(let t=e;t<=i;t++)o.push(t);if(a.modify)if(s.has(t))for(let e of o)s.add(e);else for(let e of o)s.delete(e);else{s.clear();for(let e of o)s.add(e)}return{selection:normalizeSelection(s,r),anchor:n}}return a.modify?s.has(n)?i===`multiple`&&s.delete(n):(i===`multiple`||s.clear(),s.add(n)):(s.clear(),s.add(n)),{selection:normalizeSelection(s,r),anchor:n}}function listViewSelectAll(e,t){return t===`multiple`?Array.from({length:e},(e,t)=>t):[]}var ListViewState=class{constructor(){this._model=[],this._selection=[],this._anchor=-1,this._mode=`single`,this._itemListeners=new Set,this._selectionListeners=new Set}subscribeItems(e){return this._itemListeners.add(e),()=>{this._itemListeners.delete(e)}}subscribeSelection(e){return this._selectionListeners.add(e),()=>{this._selectionListeners.delete(e)}}get model(){return this._model.map(e=>({value:e.value,label:e.label}))}get count(){return this._model.length}get selection(){return[...this._selection]}get selectionMode(){return this._mode}setModel(e){let t=Array.isArray(e)?e:[],n=listItemsChanged(this._model,t);this._model=t.map(e=>({value:e.value,label:e.label}));let r=normalizeSelection(this._selection,this._model.length),i=r.length!==this._selection.length;if(this._selection=r,this._anchor>=this._model.length&&(this._anchor=-1),n)for(let e of[...this._itemListeners])e(n);i&&this._emitSelection(!1)}setSelectionMode(e){e!==this._mode&&(this._mode=e,e===`none`&&this._selection.length>0?(this._selection=[],this._emitSelection(!1)):e===`single`&&this._selection.length>1&&(this._selection=this._selection.includes(this._anchor)?[this._anchor]:[this._selection[0]],this._emitSelection(!1)))}isSelected(e){return this._selection.includes(e)}selectItem(e,t={},n=!0){let r=listViewSelect(this._selection,this._anchor,e,this._model.length,this._mode,t);return this._anchor=r.anchor,this._applySelection(r.selection,n)}selectAll(e=!1){return this._applySelection(listViewSelectAll(this._model.length,this._mode),e)}unselectAll(e=!1){return this._applySelection([],e)}setSelection(e,t=!1){let n=normalizeSelection(e,this._model.length),r=this._mode===`none`?[]:this._mode===`single`?n.slice(0,1):n;return r.length>0&&(this._anchor=r[r.length-1]),this._applySelection(r,t)}itemContext(e){let t=this._model[e];return t===void 0?null:{item:{value:t.value,label:t.label},position:e,selected:this.isSelected(e)}}_applySelection(e,t){return e.length===this._selection.length&&e.every((e,t)=>e===this._selection[t])?!1:(this._selection=e,this._emitSelection(t),!0)}_emitSelection(e){let t={selection:[...this._selection],interactive:e};for(let e of[...this._selectionListeners])e(t)}};function gridViewColumns(e,t,n,r=1,i=7){let a=Math.max(1,Math.floor(r)),o=Math.max(1,Math.floor(i)),s=Math.floor((e+n)/Math.max(1,t+n));return Math.min(Math.max(s,a),Math.max(a,o))}function listItemField(e,t){return t===`value`?e.value:e.label}function normalizeColumnViewColumns(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&`key`in e).map(e=>{let t=e.key===`value`?`value`:`label`;return{key:t,title:e.title===void 0?t:String(e.title),id:e.id===void 0?t:String(e.id),expand:e.expand===!0,fixedWidth:typeof e.fixedWidth==`number`?e.fixedWidth:-1,visible:e.visible!==!1,sortable:e.sortable===!0}}):[]}function parseColumnViewColumns(e){if(!e)return[];try{return normalizeColumnViewColumns(JSON.parse(e))}catch{return[]}}function columnViewSort(e,t){if(t.sortable!==!0)return e;let n=t.id??t.key;return e!==null&&e.column===n?{column:n,descending:!e.descending}:{column:n,descending:!1}}function columnViewTracks(e){return e.filter(e=>e.visible!==!1).map(e=>{let t=e.fixedWidth??-1;return t>0?{kind:`fixed`,css:`${t}px`}:e.expand===!0?{kind:`flex`,weight:1}:{kind:`auto`}})}const _n={indents:0,expander:`none`,level:1};function treeExpanderLayout(e,t={}){if(!e)return _n;let n=t.indentForDepth!==!1,r=t.indentForIcon!==!1,i=t.hideExpander===!0,a=n?Math.max(0,Math.floor(e.depth)):0,o=e.expandable&&!i;return!o&&r&&a++,{indents:a,expander:o?e.expanded?`expanded`:`collapsed`:`none`,level:a+1}}function treeExpanderAction(e,t={}){if(e===`+`||e===`*`)return`expand`;if(e===`-`||e===`/`)return`collapse`;if(e===` `&&t.ctrlKey===!0)return`toggle`;if(t.shiftKey!==!0)return`none`;let n=t.rtl===!0;return e===`ArrowRight`?n?`collapse`:`expand`:e===`ArrowLeft`?n?`expand`:`collapse`:`none`}function treeExpanderExpanded(e,t){switch(t){case`expand`:return!0;case`collapse`:return!1;case`toggle`:return!e;case`none`:return e}}var ExpanderState=class{constructor(){this._expanded=!1,this._enableExpansion=!0,this._listeners=new Set}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}_emit(){for(let e of[...this._listeners])e(this._expanded)}get expanded(){return this._expanded}get enableExpansion(){return this._enableExpansion}setExpanded(e){let t=!!e&&this._enableExpansion;return t===this._expanded?!1:(this._expanded=t,this._emit(),!0)}setEnableExpansion(e){let t=!!e;return t===this._enableExpansion?[]:(this._enableExpansion=t,this.setExpanded(t)?[`expanded`,`enable-expansion`]:[`enable-expansion`])}toggle(){return this.setExpanded(!this._expanded)}expand(){return this.setExpanded(!0)}collapse(){return this.setExpanded(!1)}};function watchItemsChanged(e,t){if(typeof e.connect!=`function`||typeof e.disconnect!=`function`)return()=>{};let n=e.connect(`items-changed`,(...e)=>{let[n,r,i]=e.slice(1);t({position:n??0,removed:r??0,added:i??0})});return()=>void e.disconnect?.(n)}var ComboState=class{constructor(){this._model=null,this._options=[],this._selected=-1,this._unwatch=null,this._listeners=new Set,this._itemListeners=new Set,this._notifyListeners=new Set}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}subscribeNotify(e){return this._notifyListeners.add(e),()=>{this._notifyListeners.delete(e)}}subscribeItems(e){return this._itemListeners.add(e),()=>{this._itemListeners.delete(e)}}_emit(e){let t={selected:this._selected,value:this.selectedValue,label:this.selectedLabel,interactive:e};for(let e of[...this._listeners])e(t)}_notify(e){for(let t of[...this._notifyListeners])t(e)}_emitItems(e){for(let t of[...this._itemListeners])t(e)}_setIndex(e,t){return e===this._selected?!1:(this._selected=e,this._emit(t),this._notify(`selected`),this._notify(`selected-item`),!0)}get model(){return this._model}get options(){return this._options.map(e=>({value:e.value,label:e.label}))}get selectedItem(){return!this._model||this._selected<0?null:this._model.get_item(this._selected)??null}setModel(e){if(e===this._model)return;this._unwatch?.(),this._unwatch=null;let t=this._options;this._model=e,this._options=e?normalizeComboOptions(e):[],this._selected=this._options.length===0?-1:0,e&&(this._unwatch=watchItemsChanged(e,e=>this._onItemsChanged(e)));let n=listItemsChanged(t,this._options);n&&this._emitItems(n),this._emit(!1),e&&(this._notify(`selected`),this._notify(`selected-item`)),this._notify(`model`)}_onItemsChanged(e){this._options=this._model?normalizeComboOptions(this._model):[],this._emitItems(e);let t=this._selected,n=this._options.length;if(t===-1){if(n===0)return;this._selected=0,this._emit(!1),this._notify(`selected-item`),this._notify(`selected`);return}if(!(t<e.position)){if(t>=e.position+e.removed){this._selected=t+e.added-e.removed,this._emit(!1),this._notify(`selected`);return}this._selected=n===0?-1:Math.min(e.position,n-1),this._emit(!1),this._notify(`selected-item`),this._selected!==t&&this._notify(`selected`)}}get selectedIndex(){return this._selected}get presentsChooser(){return this._options.length>1}setSelectedIndex(e){return this.hasIndex(e)?this._setIndex(e,!1):!1}get selectedValue(){return this._options[this._selected]?.value??``}get selectedLabel(){return this._options[this._selected]?.label??``}setSelectedValue(e){let t=this._options.findIndex(t=>t.value===e);return t>=0?this.setSelectedIndex(t):!1}hasIndex(e){return Number.isFinite(e)&&e>=0&&e<this._options.length}select(e){return!this.hasIndex(e)||e===this._selected?!1:this._setIndex(e,!0)}get count(){return this._options.length}},ToggleGroupState=class{constructor(){this._labels=[],this._selected=0,this._listeners=new Set}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}_emit(){let e={selected:this._selected,value:this.selectedValue};for(let t of[...this._listeners])t(e)}get labels(){return this._labels}setLabels(e){this._labels=Array.isArray(e)?e:[],this._selected>=this._labels.length&&(this._selected=0)}get selected(){return this._selected}setSelected(e){let t=Number.isFinite(e)?e:0;return t===this._selected||t<0||t>=this._labels.length?!1:(this._selected=t,this._emit(),!0)}get selectedValue(){return this._labels[this._selected]??``}get count(){return this._labels.length}};function keptToggles(e){let t=new Set,n=[];for(let r of e){let e=r.name??null;e!==null&&t.has(e)||(e!==null&&t.add(e),n.push(r))}return n}function toggleIndexOfName(e,t){return e.indexOf(t)}const vn=[`left`,`right`,`center`,`fill`];function labelDisplayText(e,t,n){let r=e??``,i=t?stripLabelMarkup(r)??r:r;return n?stripMnemonic(i):i}function normalizeLabelXalign$1(e){let t=typeof e==`number`?e:Number.parseFloat(String(e??``));return Number.isFinite(t)?glibClamp(t,0,1):.5}__name(normalizeLabelXalign$1,`normalizeLabelXalign`);function normalizeLabelJustify(e){return vn.includes(e)?e:`left`}function normalizeLabelYalign(e){let t=typeof e==`number`?e:Number.parseFloat(String(e??``));return Number.isFinite(t)?glibClamp(t,0,1):.5}function labelYalignAlignItems(e){return e<.25?`flex-start`:e>.75?`flex-end`:`center`}const yn=[`none`,`start`,`middle`,`end`];function normalizeLabelEllipsize(e){return yn.includes(e)?e:`none`}function labelEllipsizeOverflowValue(e){return e===`none`?`clip`:`ellipsis`}const bn=[`word`,`char`,`word-char`];function normalizeLabelWrapMode(e){return bn.includes(e)?e:`word`}function normalizeLabelCharCount(e,t){let n=typeof e==`number`?e:Number.parseInt(String(e??``),10);return Number.isFinite(n)?Math.max(t,Math.trunc(n)):t}function normalizeLabelWidthChars(e){return normalizeLabelCharCount(e,-1)}function normalizeLabelMaxWidthChars(e){return normalizeLabelCharCount(e,-1)}function normalizeLabelLines(e){return normalizeLabelCharCount(e,-1)}function labelEffectiveLines(e,t){return t===`none`?null:e>0?e:1}function labelWidthCharsExtent(e,t){return{minCh:e>=0?e:null,maxCh:t>=0?Math.max(e,t):null}}const xn={bold:!1,italic:!1,underline:!1,strikethrough:!1,monospace:!1,sizeSteps:0,script:null,spans:[]};function withTag(e,t,n){switch(t){case`b`:return{...e,bold:!0};case`i`:return{...e,italic:!0};case`u`:return{...e,underline:!0};case`s`:return{...e,strikethrough:!0};case`tt`:return{...e,monospace:!0};case`big`:return{...e,sizeSteps:e.sizeSteps+1};case`small`:return{...e,sizeSteps:e.sizeSteps-1};case`sub`:return{...e,script:`sub`};case`sup`:return{...e,script:`sup`};case`span`:return{...e,spans:[...e.spans,n]};default:return e}}function sameStyle(e,t){let n=e.style;return e.link===t.link&&n.bold===t.style.bold&&n.italic===t.style.italic&&n.underline===t.style.underline&&n.strikethrough===t.style.strikethrough&&n.monospace===t.style.monospace&&n.sizeSteps===t.style.sizeSteps&&n.script===t.style.script&&n.spans.length===t.style.spans.length&&n.spans.every((e,n)=>e===t.style.spans[n])}function labelMarkupRender(e,t=[]){let n=parseLabelMarkup(e??``);if(n===null)return null;let r=[],i=[],a=``,walk=(e,t)=>{for(let n of e){if(n.kind===`text`){if(n.text===``)continue;let e=r[r.length-1];e!==void 0&&sameStyle(e,t)?r[r.length-1]={...e,text:e.text+n.text}:r.push({text:n.text,style:t.style,link:t.link}),a+=n.text;continue}if(n.kind===`link`){let e=i.length,r=a.length;i.push({href:n.href,title:n.title,cssClass:n.cssClass,start:r,end:r,visited:!1}),walk(n.children,{style:t.style,link:e}),i[e]={...i[e],end:a.length};continue}walk(n.children,{style:withTag(t.style,n.tag,n.attributes),link:t.link})}};return walk(n,{style:xn,link:null}),{text:a,runs:r,links:labelLinksInheritVisited(i,t)}}function labelLinksInheritVisited(e,t){return t.length===0?e:e.map(e=>{let n=t.find(t=>t.href===e.href);return n===void 0||!n.visited?e:{...e,visited:!0}})}function labelLinksHaveTooltip(e){return e.some(e=>e.title!==null)}function labelHasLinks(e){return e.length>0}function labelActivateLink(e,t){return t.emit()?!0:t.rooted?(t.launch(e),!0):!1}function labelLinkVisited(e,t){let n=e[t];return n===void 0||n.visited?e:e.map(e=>e.href===n.href?{...e,visited:!0}:e)}const Sn=[0,1,2],Cn=new WeakMap;function isWidgetNode(e){return e!=null&&e.localName.includes(`-`)}function widgetSibling(e,t){for(let n=e;n!==null;n=t(n))if(isWidgetNode(n))return n;return null}function syncDirection(e){let t=Cn.get(e);t===void 0||!e.isConnected||(t===0?e.removeAttribute(`dir`):e.dir=t===2?`rtl`:`ltr`)}function widgetTreeMembers(){return{set_direction(e){if(!Sn.includes(e))throw TypeError(`${e} is not a valid value for enum argument dir`);Cn.set(this,e),syncDirection(this)},get_direction(){return Cn.get(this)??1},get_visible(){return!this.hasAttribute(`hidden`)},set_visible(e){this.toggleAttribute(`hidden`,!e)},get_first_child(){return widgetSibling(this.firstElementChild,e=>e.nextElementSibling)},get_last_child(){return widgetSibling(this.lastElementChild,e=>e.previousElementSibling)},get_next_sibling(){return widgetSibling(this.nextElementSibling,e=>e.nextElementSibling)},get_prev_sibling(){return widgetSibling(this.previousElementSibling,e=>e.previousElementSibling)},get_parent(){return widgetSibling(this.parentElement,e=>e.parentElement)},get_width(){return this.offsetWidth},get_height(){return this.offsetHeight},compute_point(e,t){return computePoint(this,e,t)},add_css_class(e){this.classList.add(e)},remove_css_class(e){this.classList.remove(e)},has_css_class(e){return this.classList.contains(e)},insert_action_group(e,t){insertActionGroup(this,e,t)}}}const wn=`Back`;function describeNavigationDiagnostic(e){switch(e.code){case`duplicate-tag`:return`Duplicate page tag in AdwNavigationView: ${e.tag}`;case`already-in-stack`:return e.tag===void 0?`Page '${e.title}' is already in navigation stack`:`Page with the tag '${e.tag}' is already in navigation stack`;case`tag-not-found`:return`No page with the tag '${e.tag}' found in AdwNavigationView`;case`not-in-stack`:return`Page '${e.title}' is not in the navigation stack`}}var NavigationViewState=class{constructor(e={}){this._registry=new Map,this._tags=new Map,this._stack=[],this._listeners=new Set,this._pendingRemoval=null,this._animateTransitions=e.animateTransitions??!0,this._popOnEscape=e.popOnEscape??!0,this._onDiagnostic=e.onDiagnostic??null}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}get stack(){return[...this._stack]}get depth(){return this._stack.length}get pages(){return[...this._registry.keys()]}get visiblePage(){return this._stack.length===0?null:this._stack[this._stack.length-1]}get visiblePageTag(){let e=this.visiblePage;return e===null?null:this.tagOf(e)}get animateTransitions(){return this._animateTransitions}get popOnEscape(){return this._popOnEscape}setAnimateTransitions(e){let t=!!e;return t===this._animateTransitions?!1:(this._animateTransitions=t,!0)}setPopOnEscape(e){let t=!!e;return t===this._popOnEscape?!1:(this._popOnEscape=t,!0)}isRegistered(e){return this._registry.has(e)}isInStack(e){return this._stack.includes(e)}isRemoveOnPop(e){return this._registry.get(e)?.removeOnPop===!0}tagOf(e){return this._registry.get(e)?.tag??null}titleOf(e){return this._registry.get(e)?.title??``}canPopOf(e){return this._registry.get(e)?.canPop??!0}findPage(e){return this._tags.get(e)??null}getPreviousPage(e){let t=this._stack.indexOf(e);return t<=0?null:this._stack[t-1]}add(e,t={}){let n=this._registry.get(e);return n===void 0?this._addPage(e,t,!0):n.removeOnPop&&this._stack.includes(e)?(n.removeOnPop=!1,!0):(n.tag!==null&&this._diagnose({code:`duplicate-tag`,tag:n.tag}),!1)}remove(e){let t=this._registry.get(e);return t===void 0?!1:(this._pendingRemoval===e&&(this._pendingRemoval=null),this._stack.includes(e)?(t.removeOnPop=!0,!0):(this._unregister(e),!0))}setTag(e,t){let n=this._registry.get(e);if(n===void 0)return!1;let r=t??null;return r===n.tag?!1:r!==null&&this._tags.has(r)?(this._diagnose({code:`duplicate-tag`,tag:r}),!1):(n.tag!==null&&this._tags.delete(n.tag),n.tag=r,r!==null&&this._tags.set(r,e),!0)}setTitle(e,t){if(typeof t!=`string`)return!1;let n=this._registry.get(e);return n===void 0||n.title===t?!1:(n.title=t,!0)}setCanPop(e,t){let n=this._registry.get(e);if(n===void 0)return!1;let r=!!t;return r===n.canPop?!1:(n.canPop=r,!0)}push(e,t={}){return this._maybeAddPage(e,t)?this._pushToStack(e,`push`,this._animateTransitions,!1):!1}pushByTag(e){let t=this.findPage(e);return t===null?(this._diagnose({code:`tag-not-found`,tag:e}),!1):this._pushToStack(t,`push`,this._animateTransitions,!0)}pop(){let e=this.visiblePage;if(e===null)return!1;let t=this.getPreviousPage(e);return t===null?!1:(this._popFromStack(t,this._animateTransitions),!0)}popToPage(e){return e===this.visiblePage?!1:this._stack.includes(e)?(this._popFromStack(e,this._animateTransitions),!0):(this._diagnose({code:`not-in-stack`,title:this.titleOf(e)}),!1)}popToTag(e){let t=this.findPage(e);return t===null?(this._diagnose({code:`tag-not-found`,tag:e}),!1):this.popToPage(t)}replace(e,t){let n=this.visiblePage,r=n,i=n!==null,a=!1,o=[],s=new Set;for(let t of e)t!=null&&s.add(t);for(let e=this._stack.length-1;e>=0;e--){let t=this._stack[e],n=this._registry.get(t);n===void 0||!n.removeOnPop||s.has(t)||(t===r&&(a=n.tag!==null,r=null),this._unregister(t)&&o.push(t))}this._stack.length=0;let c=new Set;for(let n of e)if(n!=null){if(c.has(n)){this._diagnose({code:`already-in-stack`,title:this.titleOf(n)});continue}this._maybeAddPage(n,t?.(n)??{})&&(c.add(n),this._stack.push(n))}let l=this.visiblePage,u;u=l===null?r===null?{animate:!1,tagNotify:i&&a,removeAfterTransition:null}:this._beginSwitch(r,null,!0,!1,o):r===l?{animate:!1,tagNotify:!1,removeAfterTransition:null}:this._beginSwitch(r,l,!0,!1,o),this._emitChange(`replace`,n,!0,[],o,u)}replaceWithTags(e){let t=e.map(e=>{let t=this.findPage(e);return t===null&&this._diagnose({code:`tag-not-found`,tag:e}),t});this.replace(t)}finishTransition(){let e=this._resolvePendingRemoval();return e===null?[]:[e]}canGoBack(){let e=this.visiblePage;return e===null||!this.canPopOf(e)?!1:this.getPreviousPage(e)!==null}backButtonTooltip(e=wn){if(!this.canGoBack())return null;let t=this.getPreviousPage(this.visiblePage);if(t===null)return null;let n=this.titleOf(t);return n.length>0?n:e}popFromShortcut(){let e=this.visiblePage;return e===null?`propagate`:this.canPopOf(e)?this.pop()?`stop`:`propagate`:`stop`}popFromEscape(){return this._popOnEscape?this.popFromShortcut():`propagate`}_diagnose(e){this._onDiagnostic?.(e)}_emit(e){for(let t of[...this._listeners])t(e)}_emitChange(e,t,n,r,i,a){let o=this.visiblePage;this._emit({stack:[...this._stack],visiblePage:o,visiblePageTag:o===null?null:this.tagOf(o),previousVisiblePage:t,reason:e,popped:[...r],removed:[...i],removeAfterTransition:a.removeAfterTransition,animate:a.animate,pop:n,tagNotify:a.tagNotify})}_addPage(e,t,n){let r=t.tag??null;return r!==null&&this._tags.has(r)?(this._diagnose({code:`duplicate-tag`,tag:r}),!1):(this._registry.set(e,{tag:r,title:t.title??``,canPop:t.canPop===void 0?!0:!!t.canPop,removeOnPop:!1}),r!==null&&this._tags.set(r,e),n&&this._stack.length===0&&this._pushToStack(e,`add`,!1,!1),!0)}_maybeAddPage(e,t){if(this._registry.has(e))return!0;let n=t.tag??null;if(n!==null&&this._tags.has(n))return this._diagnose({code:`duplicate-tag`,tag:n}),!1;if(!this._addPage(e,t,!1))return!1;let r=this._registry.get(e);return r!==void 0&&(r.removeOnPop=!0),!0}_pushToStack(e,t,n,r){if(this._stack.includes(e))return this._diagnose(r?{code:`already-in-stack`,tag:this.tagOf(e)}:{code:`already-in-stack`,title:this.titleOf(e)}),!1;let i=this.visiblePage,a=[];this._stack.push(e);let o=this._beginSwitch(i,e,!1,n,a);return this._emitChange(t,i,!1,[],a,o),!0}_popFromStack(e,t){let n=this.visiblePage;if(e===n)return;let r=this._stack.indexOf(e),i=this._stack.slice(r+1).reverse();this._stack.length=r+1;let a=[],o=this._beginSwitch(n,e,!0,t,a);for(let e of i)e!==n&&this._registry.get(e)?.removeOnPop===!0&&this._unregister(e)&&a.push(e);this._emitChange(`pop`,n,!0,i,a,o)}_beginSwitch(e,t,n,r,i){if(this._pendingRemoval!==null&&this._pendingRemoval!==e){let e=this._resolvePendingRemoval();e!==null&&i.push(e)}let a=null;return n&&e!==null&&this._registry.get(e)?.removeOnPop===!0&&!this._stack.includes(e)&&(a=e,this._pendingRemoval=e),{animate:r&&e!==null,tagNotify:e!==null&&this.tagOf(e)!==null||t!==null&&this.tagOf(t)!==null,removeAfterTransition:a}}_resolvePendingRemoval(){let e=this._pendingRemoval;if(e===null)return null;if(this._pendingRemoval=null,this._stack.includes(e)){let t=this._registry.get(e);return t!==void 0&&(t.removeOnPop=!0),null}return this._unregister(e)?e:null}_unregister(e){let t=this._registry.get(e);return t===void 0?!1:(t.tag!==null&&this._tags.get(t.tag)===e&&this._tags.delete(t.tag),this._registry.delete(e),!0)}};function clampSidebarSelection(e,t){return!Number.isInteger(e)||e<0||e>=t?-1:e}function adjustSidebarSelection(e,t,n,r,i,a){if(t===0&&n>0)return clampSidebarSelection(0,n);let o=e>>>0,s=r>>>0;return s<=o&&s+i>o?-1:s<=o?clampSidebarSelection(o+a-i>>>0,n):e}function flattenSidebarItems(e,t){let n=[],r=[],i=0;return e.forEach((e,a)=>{r.push(i),e.items.forEach((e,r)=>{let o=i+r;t&&!t(e,o)||n.push({index:o,sectionIndex:a,sectionItemIndex:r,item:e,titleVisible:stringIsNotEmpty(e.title),subtitleVisible:stringIsNotEmpty(e.subtitle),iconVisible:stringIsNotEmpty(e.iconName)})}),i+=e.items.length}),{items:n,sectionFirstIndex:r}}function deriveSidebarHeaders(e,t){let n=[],r=null;for(let i of t){if(r===i.sectionIndex)continue;let t=r===null;r=i.sectionIndex;let a=e[i.sectionIndex]?.title??``;t&&a.length===0||n.push({sectionIndex:i.sectionIndex,kind:a.length>0?`title`:`separator`,title:a,first:t})}return n}var SidebarState=class{constructor(){this._mode=`sidebar`,this._sections=[],this._filter=null,this._selected=-1,this._items=[],this._sectionFirstIndex=[],this._visibleItems=[],this._headers=[],this._listeners=new Set}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}_emit(e,t){let n={selected:this._selected,previous:e,item:this.selectedItem,interactive:t};for(let e of[...this._listeners])e(n)}_applySelected(e,t){if(e===this._selected)return!1;let n=this._selected;return this._selected=e,this._emit(n,t),!0}_invalidate(){let e=flattenSidebarItems(this._sections),t=this._filter;this._items=e.items,this._sectionFirstIndex=e.sectionFirstIndex,this._visibleItems=t?this._items.filter(e=>t(e.item,e.index)):this._items,this._headers=deriveSidebarHeaders(this._sections,this._visibleItems)}get mode(){return this._mode}setMode(e){return e===this._mode?!1:(this._mode=e,!0)}get selectionVisible(){return this._mode===`sidebar`}get sections(){return this._sections}setSections(e){let t=this.count;this._sections=[...e],this._invalidate();let n=adjustSidebarSelection(adjustSidebarSelection(this._selected,t,0,0,t,0),0,this.count,0,0,this.count);this._applySelected(n,!1)}insertSection(e,t){let n=this.count,r=this._sections.length,i=Number.isInteger(t)&&t>=0&&t<r?t:r;this._sections.splice(i,0,e),this._invalidate();let a=this._sectionFirstIndex[i]??0,o=adjustSidebarSelection(this._selected,n,this.count,a,0,e.items.length);return this._applySelected(o,!1),i}removeSectionAt(e){let t=this.sectionAt(e);if(!t)return!1;let n=this.count,r=this._sectionFirstIndex[e]??0,i=t.items.length;return this._sections.splice(e,1),this._invalidate(),this._applySelected(adjustSidebarSelection(this._selected,n,this.count,r,i,0),!1),!0}removeAllSections(){let e=this.count;this._sections=[],this._invalidate(),this._applySelected(adjustSidebarSelection(this._selected,e,0,0,e,0),!1)}refresh(){this._invalidate()}sectionAt(e){if(!(!Number.isInteger(e)||e<0))return this._sections[e]}sectionFirstIndex(e){return this._sectionFirstIndex[e]??0}get count(){return this._items.length}get items(){return this._items}itemAt(e){if(!(!Number.isInteger(e)||e<0))return this._items[e]?.item}get filter(){return this._filter}setFilter(e){e!==this._filter&&(this._filter=e,this._invalidate())}get visibleItems(){return this._visibleItems}get headers(){return this._headers}get isEmpty(){return this._visibleItems.length===0}get selected(){return this._selected}get selectedItem(){return this.itemAt(this._selected)}setSelected(e){return this._applySelected(clampSidebarSelection(e,this.count),!1)}activate(e){let t=this._visibleItems.find(t=>t.index===e);return!t||t.item.visible===!1||t.item.enabled===!1?{index:e,activated:!1,selectionChanged:!1}:{index:e,activated:!0,selectionChanged:this._applySelected(clampSidebarSelection(e,this.count),!0)}}};const Tn=1200,En=Math.PI*.35,Dn=Math.PI*.015,On=Math.PI*.9,kn=Math.PI*.9,An=Math.PI*.7,jn=Math.PI*1.1,Mn=Math.PI*1.35,z=kn+jn+Mn-An;53*Math.PI*2/z;const Nn=jn-An/2;function normalizeSpinnerAngle(e){let t=e;for(;t<0;)t+=Math.PI*2;for(;t>Math.PI*2;)t-=Math.PI*2;return t}function spinnerArcStart(e){let t=e%z,n=t>jn?1:easeInOutSine(t/jn);return adwLerp(Dn,On,n)-t*On/z}function spinnerArcEnd(e){let t=e%z,n=jn-An,r;return r=t<n?0:t>z-kn?1:easeInOutSine((t-n)/Mn),adwLerp(0,On-Dn,r)-t*On/z}function spinnerArc(e){let t=e,n=normalizeSpinnerAngle(t+spinnerArcStart(t)+En),r=normalizeSpinnerAngle(t+spinnerArcEnd(t)+En),i=n-r;for(;i<=0;)i+=Math.PI*2;return{start:n,end:r,length:i}}function spinnerProgressAt(e){let t=Tn*53;return(e%t+t)%t/Tn*Math.PI*2}const Pn={shift:`shift`,shft:`shift`,control:`control`,ctrl:`control`,ctl:`control`,alt:`alt`,mod1:`alt`,meta:`meta`,super:`super`,hyper:`hyper`,primary:`primary`},Fn=[`hyper`,`super`,`control`,`alt`,`shift`,`meta`],In={hyper:{default:`Hyper`,apple:`Hyper`},super:{default:`Super`,apple:`Super`},control:{default:`Ctrl`,apple:`⌃`},alt:{default:`Alt`,apple:`⌥`},shift:{default:`Shift`,apple:`⇧`},meta:{default:`Meta`,apple:`⌘`}},Ln={Shift:`shift`,Control:`control`,Alt:`alt`,Meta:`meta`,Super:`super`,Hyper:`hyper`},Rn={exclam:`!`,quotedbl:`"`,numbersign:`#`,dollar:`$`,percent:`%`,ampersand:`&`,apostrophe:`'`,parenleft:`(`,parenright:`)`,asterisk:`*`,plus:`+`,comma:`,`,minus:`-`,period:`.`,slash:`/`,colon:`:`,semicolon:`;`,less:`<`,equal:`=`,greater:`>`,question:`?`,at:`@`,bracketleft:`[`,backslash:`\\`,bracketright:`]`,asciicircum:`^`,underscore:`_`,grave:"`",braceleft:`{`,bar:`|`,braceright:`}`,asciitilde:`~`},zn={Left:{default:`←`},Up:{default:`↑`},Right:{default:`→`},Down:{default:`↓`},space:{default:`␣`},Return:{default:`⏎`},Page_Up:{default:`Page_Up`},Page_Down:{default:`Page_Down`},Escape:{apple:`⎋`},Tab:{apple:`⇥`},BackSpace:{apple:`⌫`},Delete:{apple:`⌦`}};function parseAccelerator(e,t=`default`){let n=new Set,r=e;for(;r.startsWith(`<`);){let e=r.indexOf(`>`);if(e===-1)return null;let i=r.slice(1,e).toLowerCase();if(r=r.slice(e+1),i===`release`)continue;let a=Pn[i];if(!a)return null;n.add(a===`primary`?t===`apple`?`meta`:`control`:a)}return r.length===0?null:{modifiers:n,key:r}}function keycapForKey(e,t){let n=/^([A-Za-z]+)_([LR])$/.exec(e);if(n&&Ln[n[1]]){let e=Ln[n[1]];return{label:In[e][t],sideMarker:n[2]}}let r=zn[e];if(r){let e=t===`apple`?r.apple??r.default:r.default;if(e)return{label:e}}let i=/^KP_(.+)$/.exec(e);if(i){let e=printableFor(i[1]);if(e)return{label:`KP ${e.toUpperCase()}`}}let a=printableFor(e);return a?{label:a===`\\`?`Backslash`:a.toUpperCase()}:{label:e.length===1?e.toUpperCase():e}}function printableFor(e){if(e.length===1){let t=e.codePointAt(0)??0;return t>32&&t<127?e:null}return Rn[e]??null}function shortcutKeycaps(e,t=`default`){let n=parseAccelerator(e,t);if(!n)return null;let r=[];for(let e of Fn)n.modifiers.has(e)&&r.push({label:In[e][t]});return r.push(keycapForKey(n.key,t)),r}function accessibleFor(e){return e.map(e=>e.sideMarker?`${e.label} ${e.sideMarker}`:e.label).join(`+`)}function parseShortcutLabel(e,t={}){let{disabledText:n=``,direction:r=`ltr`,platform:i=`default`}=t;if(e.length===0)return{nodes:[{kind:`disabled`,text:n}],accessibleLabel:n,error:null};let a=[],o=``,s=null,combination=e=>{for(let t of e.split(`&`)){let e=shortcutKeycaps(t,i);if(!e)return s=t,!1;a.push({kind:`keys`,keys:e}),o+=accessibleFor(e)}return!0},sequence=e=>{let t=r===`rtl`?`←`:`→`,n=e.split(`+`);for(let[e,r]of n.entries())if(e>0&&(a.push({kind:`separator`,text:t}),o+=t),!combination(r))return!1;return!0},range=e=>{let t=e.indexOf(`...`);return t===-1?sequence(e):sequence(e.slice(0,t))?(a.push({kind:`separator`,text:`⋯`}),o+=`…`,sequence(e.slice(t+3))):!1};for(let[t,n]of e.split(` `).entries())if(t>0&&(a.push({kind:`separator`,text:`/`}),o+=` `),!range(n))break;return{nodes:a,accessibleLabel:o,error:s}}const Bn=[`px`,`pt`,`sp`];function adwLengthToPx(e,t,n=96){switch(e){case`pt`:return t*n/72;case`sp`:return t*n/96;default:return t}}function normalizeLengthUnit(e,t){return Bn.includes(e)?e:t}function isSidebarAtVisualStart(e,t=`ltr`){return e===`start`==(t!==`rtl`)}function fractionOf(e){return e.sidebarWidthFraction??.25}function resolveSidebarBounds(e,t=0,n={}){let r=e.sidebarWidthUnit??`sp`,i=e.dpi??96,a=n.ceil?Math.ceil:Math.trunc,o=adwLengthToPx(r,e.minSidebarWidth??180,i),s=adwLengthToPx(r,e.maxSidebarWidth??280,i),c=a(Math.max(t,o));return{min:c,max:a(Math.max(c,s))}}function resolveOverlaySidebarWidth(e){let t=resolveSidebarBounds(e,e.sidebarChildMin??0,{ceil:!0});if(e.collapsed)return glibClamp(e.totalWidth,t.min,t.max);let n=glibClamp(Math.trunc(e.totalWidth*fractionOf(e)),t.min,t.max);return Math.min(n,e.totalWidth-(e.contentMin??0))}function layoutOverlaySplitView(e){let{totalWidth:t,showProgress:n,collapsed:r}=e,i=e.sidebarWidth,a=isSidebarAtVisualStart(e.sidebarPosition??`start`,e.direction??`ltr`),o=i,s=Math.trunc(i*n),c=s>i,l={shieldVisible:r&&n>0,sidebarPainted:n>0,shadowProgress:1-Math.min(n,+!!r),shadowSide:a?`left`:`right`};return r?(c&&(o=s),{sidebar:{x:a?c?0:s-i:t-s,width:o},content:{x:0,width:t},...l}):(c&&(o=s,s=i),a?{sidebar:{x:s-i,width:o},content:{x:s,width:t-s},...l}:{sidebar:{x:t-(c?o:s),width:o},content:{x:0,width:t-s},...l})}function tagsConflict(e,t){return e==null||t==null?!1:e===t}function resolveNavigationStack(e){let{hasSidebar:t,hasContent:n,showContent:r}=e,i=e.sidebarPosition===`end`;if(e.changingPage&&t&&n)return r?i?{stack:[`content`],transition:`pop`,page:`sidebar`}:{stack:[`sidebar`,`content`],transition:`push`,page:`content`}:i?{stack:[`content`,`sidebar`],transition:`push`,page:`sidebar`}:{stack:[`sidebar`],transition:`pop`,page:`content`};let a=[];return i?(n&&a.push(`content`),t&&(!r||!n)&&a.push(`sidebar`)):(t&&a.push(`sidebar`),n&&(r||!t)&&a.push(`content`)),{stack:a,transition:`replace`,page:null}}function resolveNavigationAction(e){if(e.action===`pop`)return e.showContent&&e.hasSidebar&&e.hasContent?{kind:`set-show-content`,showContent:!1}:{kind:`delegate`};let{tag:t}=e;return e.contentTag!==null&&e.contentTag!==void 0&&t===e.contentTag?e.showContent&&e.collapsed?{kind:`already-in-stack`,tag:t}:{kind:`set-show-content`,showContent:!0}:e.sidebarTag!==null&&e.sidebarTag!==void 0&&t===e.sidebarTag?{kind:`already-in-stack`,tag:t}:{kind:`delegate`}}const B={alreadyInStack:e=>`Page with the tag '${e}' is already in the navigation stack`,notFound:e=>`No page with the tag '${e}' found in AdwNavigationSplitView`,sidebarCollision:e=>`Trying to add sidebar with the tag '${e}' to AdwNavigationSplitView, but content already has the same tag`,contentCollision:e=>`Trying to add content with the tag '${e}' to AdwNavigationSplitView, but sidebar already has the same tag`,sidebarTagCollision:e=>`Trying to set the sidebar's tag to '${e}', but the content already has the same tag`,contentTagCollision:e=>`Trying to set the content's tag to '${e}', but the sidebar already has the same tag`};var NavigationSplitViewState=class{constructor(e={}){this._sidebar=null,this._content=null,this._sidebarTag=null,this._contentTag=null,this._listeners=new Set,this._sidebarPosition=e.sidebarPosition??`start`,this._collapsed=e.collapsed??!1,this._showContent=e.showContent??!1,this._handlers={onCritical:e.onCritical,onDelegate:e.onDelegate}}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}_emit(e,t,n=!1){let r={property:e,interactive:n,plan:t};for(let e of[...this._listeners])e(r)}_critical(e){this._handlers.onCritical?.(e)}_plan(e=!1){return resolveNavigationStack({hasSidebar:this._sidebar!==null,hasContent:this._content!==null,sidebarPosition:this._sidebarPosition,showContent:this._showContent,changingPage:e})}get collapsed(){return this._collapsed}get showContent(){return this._showContent}get sidebarPosition(){return this._sidebarPosition}get sidebar(){return this._sidebar}get content(){return this._content}get sidebarTag(){return this._sidebarTag}get contentTag(){return this._contentTag}get stack(){return this._plan()}get visiblePane(){let{stack:e}=this._plan();return e[e.length-1]??null}setSidebar(e){if(e===this._sidebar)return!1;let t=e?.tag??null;return tagsConflict(t,this._contentTag)?(this._critical(B.sidebarCollision(t)),!1):(this._sidebar=e,this._sidebarTag=t,this._emit(`sidebar`,this._plan()),!0)}setContent(e){if(e===this._content)return!1;let t=e?.tag??null;return tagsConflict(this._sidebarTag,t)?(this._critical(B.contentCollision(t)),!1):(this._content=e,this._contentTag=t,this._emit(`content`,this._plan()),!0)}setTag(e,t){return e===`sidebar`?(this._sidebarTag=t,tagsConflict(this._sidebarTag,this._contentTag)?(this._critical(B.sidebarTagCollision(t)),this._sidebarTag=null,!1):!0):(this._contentTag=t,tagsConflict(this._sidebarTag,this._contentTag)?(this._critical(B.contentTagCollision(t)),this._contentTag=null,!1):!0)}setSidebarPosition(e){return e===this._sidebarPosition?!1:(this._sidebarPosition=e,this._emit(`sidebar-position`,this._plan()),!0)}setCollapsed(e){let t=!!e;return t===this._collapsed?!1:(this._collapsed=t,this._emit(`collapsed`,this._plan()),!0)}setShowContent(e,t=!1){let n=!!e;if(n===this._showContent)return!1;this._showContent=n;let r=this._collapsed&&this._sidebar!==null&&this._content!==null;return this._emit(`show-content`,this._plan(r),t),!0}push(e){return this._runAction(resolveNavigationAction({action:`push`,tag:e,sidebarTag:this._sidebarTag,contentTag:this._contentTag,showContent:this._showContent,collapsed:this._collapsed}),`push`,e)}pop(){return this._runAction(resolveNavigationAction({action:`pop`,hasSidebar:this._sidebar!==null,hasContent:this._content!==null,showContent:this._showContent}),`pop`)}_runAction(e,t,n){switch(e.kind){case`set-show-content`:return this.setShowContent(e.showContent,!0),e;case`already-in-stack`:return this._critical(B.alreadyInStack(e.tag)),e;default:return this._handlers.onDelegate?.(t,n)||t===`pop`?e:(this._critical(B.notFound(n??``)),{kind:`not-found`,tag:n??``})}}};const Vn={animate(e){return e.onValue(e.to),e.onDone(),{cancel:()=>{}}}};var OverlaySplitViewState=class{constructor(e={}){this._swipeActive=!1,this._animation=null,this._listeners=new Set,this._showSidebar=e.showSidebar??!0,this._collapsed=e.collapsed??!1,this._pinSidebar=e.pinSidebar??!1,this._sidebarPosition=e.sidebarPosition??`start`,this._enableShowGesture=e.enableShowGesture??!0,this._enableHideGesture=e.enableHideGesture??!0,this._showProgress=+!!this._showSidebar,this._animator=e.animator??Vn}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}_emit(e,t=!1){let n={property:e,showSidebar:this._showSidebar,collapsed:this._collapsed,showProgress:this._showProgress,shieldVisible:this.shieldVisible,interactive:t};for(let e of[...this._listeners])e(n)}get showSidebar(){return this._showSidebar}get collapsed(){return this._collapsed}get pinSidebar(){return this._pinSidebar}get sidebarPosition(){return this._sidebarPosition}get enableShowGesture(){return this._enableShowGesture}get enableHideGesture(){return this._enableHideGesture}get showProgress(){return this._showProgress}get shieldVisible(){return this._collapsed&&this._showProgress>0}get sidebarPainted(){return this._showProgress>0}get sidebarFocusable(){return!this._collapsed||this._showSidebar}get contentFocusable(){return!this._collapsed||!this._showSidebar}setShowSidebar(e,t={}){let n=!!e;if(n===this._showSidebar)return!1;this._showSidebar=n;let r=+!!n,i=t.animate??!0;return i||(this._cancelAnimation(),this._showProgress=r),this._emit(`show-sidebar`,t.interactive??!1),i&&!this._swipeActive&&this._startAnimation(r,t.velocity??0),!0}setCollapsed(e){let t=!!e;return t===this._collapsed?!1:(this._collapsed=t,this._pinSidebar||this.setShowSidebar(!t,{animate:!1}),this._emit(`collapsed`),!0)}setPinSidebar(e){let t=!!e;return t===this._pinSidebar?!1:(this._pinSidebar=t,this._emit(`pin-sidebar`),!0)}setSidebarPosition(e){return e===this._sidebarPosition?!1:(this._sidebarPosition=e,this._emit(`sidebar-position`),!0)}setEnableShowGesture(e){let t=!!e;return t===this._enableShowGesture?!1:(this._enableShowGesture=t,!0)}setEnableHideGesture(e){let t=!!e;return t===this._enableHideGesture?!1:(this._enableHideGesture=t,!0)}setShowProgress(e){this._showProgress=e,this._emit(`show-progress`)}escape(){return this._showProgress<2**-52||!this._collapsed?!1:(this.setShowSidebar(!1,{interactive:!0}),!0)}dismissShield(){return this.setShowSidebar(!1,{interactive:!0})}get swipeActive(){return this._swipeActive}beginSwipe(){this._cancelAnimation(),this._swipeActive=!0}endSwipe(e,t=0){if(!this._swipeActive)return{kind:`animate`,to:this._showProgress};this._swipeActive=!1;let n=resolveSwipeRelease({to:e,showSidebar:this._showSidebar});return n.kind===`animate`?this._startAnimation(n.to,t):this.setShowSidebar(n.showSidebar,{velocity:t,interactive:!0}),n}get snapPoints(){return resolveSwipeSnapPoints({showProgress:this._showProgress,enableShowGesture:this._enableShowGesture,enableHideGesture:this._enableHideGesture,swipeActive:this._swipeActive})}_cancelAnimation(){this._animation?.cancel(),this._animation=null}_startAnimation(e,t){this._cancelAnimation();let n=!1,r=this._animator.animate({from:this._showProgress,to:e,velocity:t,clamp:e<.5,onValue:e=>this.setShowProgress(e),onDone:()=>{n=!0,this._animation=null}});n||(this._animation=r)}};function resolveSwipeSnapPoints(e){let t=e.showProgress>0||e.enableShowGesture||e.swipeActive,n=e.showProgress<1||e.enableHideGesture||e.swipeActive;return t&&n?[0,1]:[+!!t]}function resolveSwipeStart(e){let t=Math.abs(e.showProgress-1)<2**-52||e.showProgress>1,n=Math.abs(e.showProgress)<2**-52||e.showProgress<0;return!(t&&!e.collapsed&&e.direction===`forward`||n&&!e.enableShowGesture||t&&!e.enableHideGesture)}function resolveSwipeRelease(e){return e.to>0===e.showSidebar?{kind:`animate`,to:e.to}:{kind:`set-show-sidebar`,showSidebar:e.to>0}}function swipeCancelProgress(e){let t=e<0?-Math.round(-e):Math.round(e);return t===0?0:t}function resolveSwipeArea(e){if(!e.isDrag)return{x:0,y:0,width:0,height:0};let t=Math.max(Math.trunc(e.sidebarWidth*e.showProgress),32);return{x:isSidebarAtVisualStart(e.sidebarPosition??`start`,e.direction??`ltr`)?0:e.totalWidth-t,y:0,width:t,height:e.totalHeight}}const Hn={none:`open-menu-symbolic`,down:`pan-down-symbolic`,up:`pan-up-symbolic`,left:`pan-start-symbolic`,right:`pan-end-symbolic`,none:`pan-down-symbolic`},Un=[`none`,`up`,`down`,`left`,`right`],Wn=[`child`,`label`,`icon-name`],Gn={set:Object.freeze([`menu-model`,`popover`]),clear:Object.freeze([`popover`,`menu-model`])};function splitButtonStyleClasses(e,t){let n=[];return t!==null&&t.length>0&&n.push(`image-button`),e!==null&&e.length>0&&n.push(`text-button`),n}function resolveDropdownTooltip(e){return typeof e==`string`&&e.length>0?{text:e,markup:!0}:{text:`More Options`,markup:!1}}function splitButtonArrowIcon(e){return Hn[e]??Hn.down}function splitButtonPopupDirection(e){return e===`none`||!Un.includes(e)?`down`:e}const Kn=splitButtonPopupDirection;function isSplitButtonDirection(e){return typeof e==`string`&&Un.includes(e)}function splitButtonRootState(e,t){return{active:e.active||t.active||e.keyboardActivating||t.keyboardActivating,checked:e.checked||t.checked}}const menuKey=e=>e===null?``:JSON.stringify(e);function internalContent(e){return Object.freeze({adwInternalContent:e})}function derivedPopover(){return Object.freeze({adwDerivedPopover:!0})}var SplitButtonState=class{constructor(){this._mode=`empty`,this._label=null,this._iconName=null,this._child=null,this._useUnderline=!1,this._menuModel=null,this._popover=null,this._direction=`down`,this._dropdownTooltip=``,this._open=!1,this._listeners=new Set}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}_emit(e,t){let n={mode:this._mode,label:this._label,iconName:this.iconName,child:this._child,styleClasses:this.styleClasses,dropdownEnabled:this.dropdownEnabled,open:this._open,notified:e,interactive:t};for(let e of[...this._listeners])e(n)}_contentNotify(e){let t={child:this._child!==null,label:this._label!==null,"icon-name":this.iconName!==null},n=[e];for(let r of Wn)r!==e&&t[r]&&n.push(r);return n}get mode(){return this._mode}get label(){return this._label}setLabel(e){if(typeof e!=`string`||e===this._label)return!1;let t=this._contentNotify(`label`);return this._child=this._mode===`label`?this._child:internalContent(`label`),this._mode=`label`,this._label=e,this._iconName=null,this._emit(t,!1),!0}get iconName(){return gtkButtonIconNameReadback(this._iconName)}setIconName(e){if(typeof e!=`string`||e===this.iconName)return!1;let t=this._contentNotify(`icon-name`);return this._child=this._mode===`icon`?this._child:internalContent(`icon`),this._mode=`icon`,this._iconName=e,this._label=null,this._emit(t,!1),!0}get child(){return this._child}setChild(e){let t=e??null;if(t===this._child)return!1;let n=this._contentNotify(`child`);return this._mode=t===null?`empty`:`child`,this._child=t,this._label=null,this._iconName=null,this._emit(n,!1),!0}get styleClasses(){return splitButtonStyleClasses(this._label,this.iconName)}get useUnderline(){return this._useUnderline}setUseUnderline(e){let t=!!e;return t===this._useUnderline?!1:(this._useUnderline=t,this._emit([`use-underline`],!1),!0)}get menuModel(){return this._menuModel}setMenuModel(e){let t=normalizeMenuModel(e),n=t.length>0?t:null;if(menuKey(n)===menuKey(this._menuModel))return!1;let r=n===null?null:derivedPopover();return this._menuModel=n,this._popover=r,this.dropdownEnabled||(this._open=!1),this._emit(Gn[n===null?`clear`:`set`],!1),!0}get popover(){return this._popover}setPopover(e){let t=e??null;return t===this._popover?!1:(this._menuModel=null,this._popover=t,this.dropdownEnabled||(this._open=!1),this._emit(Gn[t===null?`clear`:`set`],!1),!0)}get dropdownEnabled(){return this._menuModel!==null||this._popover!==null}get direction(){return this._direction}setDirection(e){return!isSplitButtonDirection(e)||e===this._direction?!1:(this._direction=e,this._emit([`direction`],!1),!0)}get arrowIcon(){return splitButtonArrowIcon(this._direction)}get dropdownTooltip(){return this._dropdownTooltip}setDropdownTooltip(e){return typeof e!=`string`||e===this._dropdownTooltip?!1:(this._dropdownTooltip=e,this._emit([`dropdown-tooltip`],!1),!0)}get open(){return this._open}_setOpen(e,t){return e&&!this.dropdownEnabled||e===this._open?!1:(this._open=e,this._emit([],t),!0)}openMenu(){return this._setOpen(!0,!1)}closeMenu(){return this._setOpen(!1,!1)}toggleMenu(){return this._setOpen(!this._open,!0)}activateMenuItem(e){if(this._menuModel===null)return null;let t=menuItemAt(this._menuModel,e);return t===null?null:(this._setOpen(!1,!0),t)}};function menuAssignments(e,t){let n=[],r=e.props?.[`menu-model`];if(r!==void 0){let i=typeof r==`string`?t?.[r]:void 0;if(i===void 0)throw Error(`${e.tag} menu-model: ${JSON.stringify(r)} names no menu: the file declares [${Object.keys(t??{}).join(`, `)}] (ADR 0097 § 1).`);n.push([`menu-model`,normalizeMenuModel(i)])}for(let[t,r]of Object.entries(e.menuModels??{}))n.push([t,normalizeMenuModel(r)]);return n}const qn=[`narrow`,`wide`],Jn=[`labels`,`icons`,`both`];function isViewSwitcherPolicy(e){return e===`narrow`||e===`wide`}function isInlineViewSwitcherDisplayMode(e){return e===`labels`||e===`icons`||e===`both`}function createViewSwitcherPage(e){return{name:e.name,title:e.title??null,iconName:e.iconName??null,visible:e.visible??!0,useUnderline:e.useUnderline??!1,badgeNumber:normalizeBadgeNumber(e.badgeNumber),needsAttention:e.needsAttention??!1,startsSection:e.startsSection??!1,sectionTitle:e.sectionTitle??null}}function viewSwitcherPageFromStackPage(e){return createViewSwitcherPage({name:e.name,title:e.title,iconName:e.icon.length>0?e.icon:null,visible:e.visible,badgeNumber:e.badgeNumber,needsAttention:e.needsAttention,useUnderline:e.useUnderline,startsSection:e.startsSection,sectionTitle:e.sectionTitle})}function viewSwitcherPagesFromStack(e){return e.map(e=>viewSwitcherPageFromStackPage(e))}function viewSwitcherSidebarSections(e){let t=[];for(let n of e)t.length===0||n.startsSection===!0?t.push({title:n.sectionTitle??``,pages:[n]}):t[t.length-1].pages.push(n);return t}function isViewSwitcherButtonVisible(e){return e.visible&&(isPresent(e.title)||isPresent(e.iconName))}function viewSwitcherIconName(e){return isPresent(e)&&e.length>0?e:`image-missing`}function viewSwitcherLabel(e){return isPresent(e.title)?e.useUnderline?stripMnemonic(e.title):e.title:``}function viewSwitcherBadgeLabel(e){let t=normalizeBadgeNumber(e);return t>999?`999+`:t===0?``:String(t)}const Yn={attentionRequested:`Attention requested.`,badgeOverflow:`Has a badge: more than 999.`,badge:e=>`Has a badge: ${e}.`};function viewSwitcherIndicatorDescription(e,t,n=Yn){let r=normalizeBadgeNumber(t),i=e?n.attentionRequested:``,a=``;return r>999?a=n.badgeOverflow:r>0&&(a=n.badge(r)),i&&a?`${a} ${i}`:i||a}function inlineToggleTooltip(e,t){return t===`icons`?viewSwitcherLabel(e):``}function shouldRevealViewSwitcherBar(e,t){if(!e)return!1;let n=0;for(let e of t)if(e.visible&&(n++,n>1))return!0;return!1}function viewSwitcherButtonOrientation(e){return e===`wide`?`horizontal`:`vertical`}function buildViewSwitcherButtons(e,t,n,r=Yn){let i=viewSwitcherButtonOrientation(n);return e.map((e,n)=>({pageIndex:n,name:e.name,label:viewSwitcherLabel(e),iconName:viewSwitcherIconName(e.iconName),visible:isViewSwitcherButtonVisible(e),selected:n===t,orientation:i,badgeLabel:viewSwitcherBadgeLabel(e.badgeNumber),needsAttention:e.needsAttention,description:viewSwitcherIndicatorDescription(e.needsAttention,e.badgeNumber,r)}))}function buildInlineToggles(e,t,n=Yn){let r=t!==`labels`,i=t!==`icons`,a=[];return e.forEach((e,o)=>{e.visible&&a.push({toggleIndex:a.length,pageIndex:o,name:e.name,label:viewSwitcherLabel(e),iconName:viewSwitcherIconName(e.iconName),showIcon:r,showLabel:i,tooltip:inlineToggleTooltip(e,t),badgeLabel:viewSwitcherBadgeLabel(e.badgeNumber),needsAttention:e.needsAttention,description:viewSwitcherIndicatorDescription(e.needsAttention,e.badgeNumber,n)})}),a}function toggleIndexForPage(e,t){if(!Number.isInteger(t)||t<0||t>=e.length||!e[t].visible)return-1;let n=0;for(let r=0;r<t;r++)e[r].visible&&n++;return n}var ViewSwitcherDragSwitch=class{constructor(e){this._timers=new Map,this._scheduler=e.scheduler,this._onSwitch=e.onSwitch,this._delay=e.delay??500}enter(e,t){if(!Number.isInteger(e)||e<0||e===t||this._timers.has(e))return!1;let n=this._scheduler.schedule(()=>{this._timers.delete(e),this._onSwitch(e)},this._delay);return this._timers.set(e,n),!0}leave(e){let t=this._timers.get(e);t!==void 0&&(this._timers.delete(e),this._scheduler.cancel(t))}cancel(){for(let e of this._timers.values())this._scheduler.cancel(e);this._timers.clear()}get pending(){return[...this._timers.keys()].sort((e,t)=>e-t)}},ViewSwitcherState=class{constructor(e={}){this._pages=[],this._pagesView=null,this._stack=new ViewStackState,this._listeners=new Set,this._drag=e.scheduler?new ViewSwitcherDragSwitch({scheduler:e.scheduler,delay:e.dragSwitchDelay,onSwitch:e=>{this.setSelected(e)}}):null,this._subscribeStack()}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}get pages(){return this._pagesView??=Object.freeze(this._pages.slice()),this._pagesView}setPages(e){let t=this.selected,n=t>=0?this.selectedName:null;this._pages=e.map(e=>createViewSwitcherPage(e)),this._pagesView=null;let r=new ViewStackState;for(let e of this._pages)r.addPage({name:e.name,title:e.title,visible:e.visible});if(n!==null){let e=r.indexOfName(n);e>=0&&r.setVisibleIndex(e,!1)}this._stack=r,this._subscribeStack(),this._drag?.cancel(),(this.selected!==t||this.selectedName!==(n??``))&&this._emit(!1)}get selected(){return this._stack.visibleIndex}get selectedName(){return this._stack.visibleName}get selectedPage(){return this._pages[this.selected]}get count(){return this._pages.length}setSelected(e,t=!0){return this._stack.setVisibleIndex(e,t)}selectName(e,t=!0){return this._stack.setVisibleName(e,t)}setPageVisible(e,t){let n=this._pages.findIndex(t=>t.name===e);if(n<0)return!1;let r=this._pages[n],i=!!t;return r.visible===i?!1:(this._pages[n]={...r,visible:i},this._pagesView=null,this._stack.setPageVisible(e,i))}dragEnter(e){this._drag?.enter(e,this.selected)}dragLeave(e){this._drag?.leave(e)}cancelDrag(){this._drag?.cancel()}get pendingDragSwitches(){return this._drag?.pending??[]}get diagnostics(){return this._stack.diagnostics}_subscribeStack(){this._stack.subscribe(e=>this._emit(e.interactive))}_emit(e){let t=this.selectedPage,n={selected:this.selected,name:t?.name??``,title:t?viewSwitcherLabel(t):``,interactive:e};for(let e of[...this._listeners])e(n)}},ViewSwitcherBarState=class{constructor(){this._reveal=!1,this._revealed=!1,this._pages=[],this._listeners=new Set}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}get reveal(){return this._reveal}get revealed(){return this._revealed}setReveal(e){let t=!!e;return t===this._reveal?!1:(this._reveal=t,this._refresh(),!0)}setPages(e){return this._pages=e,this._refresh()}_refresh(){let e=shouldRevealViewSwitcherBar(this._reveal,this._pages);if(e===this._revealed)return!1;this._revealed=e;let t={reveal:this._reveal,revealed:this._revealed};for(let e of[...this._listeners])e(t);return!0}};function isPresent(e){return e!=null}function normalizeBadgeNumber(e){return typeof e!=`number`||!Number.isFinite(e)?0:Math.max(0,Math.trunc(e))}const Xn=new Map([[`µ`,`μ`],[`ß`,`ss`],[`ʼn`,`ʼn`],[`ſ`,`s`],[`ǰ`,`ǰ`],[`ͅ`,`ι`],[`ΐ`,`ΐ`],[`ΰ`,`ΰ`],[`ς`,`σ`],[`ϐ`,`β`],[`ϑ`,`θ`],[`ϕ`,`φ`],[`ϖ`,`π`],[`ϰ`,`κ`],[`ϱ`,`ρ`],[`ϵ`,`ε`],[`և`,`եւ`],[`ᲀ`,`в`],[`ᲁ`,`д`],[`ᲂ`,`о`],[`ᲃ`,`с`],[`ᲄ`,`т`],[`ᲅ`,`т`],[`ᲆ`,`ъ`],[`ᲇ`,`ѣ`],[`ᲈ`,`ꙋ`],[`ẖ`,`ẖ`],[`ẗ`,`ẗ`],[`ẘ`,`ẘ`],[`ẙ`,`ẙ`],[`ẚ`,`aʾ`],[`ẛ`,`ṡ`],[`ὐ`,`ὐ`],[`ὒ`,`ὒ`],[`ὔ`,`ὔ`],[`ὖ`,`ὖ`],[`ᾀ`,`ἀι`],[`ᾁ`,`ἁι`],[`ᾂ`,`ἂι`],[`ᾃ`,`ἃι`],[`ᾄ`,`ἄι`],[`ᾅ`,`ἅι`],[`ᾆ`,`ἆι`],[`ᾇ`,`ἇι`],[`ᾐ`,`ἠι`],[`ᾑ`,`ἡι`],[`ᾒ`,`ἢι`],[`ᾓ`,`ἣι`],[`ᾔ`,`ἤι`],[`ᾕ`,`ἥι`],[`ᾖ`,`ἦι`],[`ᾗ`,`ἧι`],[`ᾠ`,`ὠι`],[`ᾡ`,`ὡι`],[`ᾢ`,`ὢι`],[`ᾣ`,`ὣι`],[`ᾤ`,`ὤι`],[`ᾥ`,`ὥι`],[`ᾦ`,`ὦι`],[`ᾧ`,`ὧι`],[`ᾲ`,`ὰι`],[`ᾳ`,`αι`],[`ᾴ`,`άι`],[`ᾶ`,`ᾶ`],[`ᾷ`,`ᾶι`],[`ι`,`ι`],[`ῂ`,`ὴι`],[`ῃ`,`ηι`],[`ῄ`,`ήι`],[`ῆ`,`ῆ`],[`ῇ`,`ῆι`],[`ῒ`,`ῒ`],[`ΐ`,`ΐ`],[`ῖ`,`ῖ`],[`ῗ`,`ῗ`],[`ῢ`,`ῢ`],[`ΰ`,`ΰ`],[`ῤ`,`ῤ`],[`ῦ`,`ῦ`],[`ῧ`,`ῧ`],[`ῲ`,`ὼι`],[`ῳ`,`ωι`],[`ῴ`,`ώι`],[`ῶ`,`ῶ`],[`ῷ`,`ῶι`],[`ff`,`ff`],[`fi`,`fi`],[`fl`,`fl`],[`ffi`,`ffi`],[`ffl`,`ffl`],[`ſt`,`st`],[`st`,`st`],[`ﬓ`,`մն`],[`ﬔ`,`մե`],[`ﬕ`,`մի`],[`ﬖ`,`վն`],[`ﬗ`,`մխ`]]);function foldCherokee(e){if(e>=43888&&e<=43967)return String.fromCodePoint(e-43888+5024);if(e>=5112&&e<=5117)return String.fromCodePoint(e-8)}const defaultCaseFolder=e=>{let t=``;for(let n of e.toLowerCase()){let e=n.codePointAt(0);if(e<181){t+=n;continue}t+=Xn.get(n)??foldCherokee(e)??n}return t};function makeComparable(e,t={},n=defaultCaseFolder){let r=n(e??``);return(t.useMarkup??!0)&&(r=stripMarkup(r)??r),(t.allowUnderline??!0)&&(t.useUnderline??!1)&&(r=stripMnemonic(r)),r}function displayedLabelText(e,t){let n=e??``;return t?stripMarkup(n)??n:n}function derivePreferencesGroupHeader(e){let t=e.useMarkup??!0,n=stringIsNotEmpty(displayedLabelText(e.title,t)),r=stringIsNotEmpty(displayedLabelText(e.description,t)),i=e.hasHeaderSuffix??!1;return{titleVisible:n,descriptionVisible:r,headerVisible:n||r||i,singleLine:!r&&(i||n),listboxVisible:(e.rowCount??0)>0}}function countVisiblePages(e){let t=0;for(let n of e)n.visible!==!1&&(t+=1);return t}function collectSearchRows(e){let t=[];for(let n of e)if(n.visible!==!1){for(let e of n.groups)if(e.visible!==!1)for(let r of e.rows)r.visible!==!1&&r.title!==``&&t.push({page:n,group:e,row:r})}return t}function rowMatchesQuery(e,t,n=defaultCaseFolder){let r=n(t??``),i={useMarkup:e.useMarkup,useUnderline:e.useUnderline};return makeComparable(e.title,{...i,allowUnderline:!0},n).includes(r)?!0:e.isActionRow?makeComparable(e.subtitle,{...i,allowUnderline:!1},n).includes(r):!1}function createSearchRowSubtitle(e){let t=e.groupTitle??null;t===``&&(t=null);let n=null;return e.pageTitle!==void 0&&e.pageTitle!==null&&(n=e.pageUseUnderline?stripMnemonic(e.pageTitle):e.pageTitle,(e.rowUseMarkup??!0)&&(n=escapeMarkup(n)),n===``&&(n=null)),t===null?n:e.nVisiblePages<=1?t:`${n??e.untitledPageLabel??`Untitled page`} → ${t}`}function searchPreferences(e,t,n={}){let r=n.fold??defaultCaseFolder,i=countVisiblePages(e),a=[];for(let{page:o,group:s,row:c}of collectSearchRows(e))rowMatchesQuery(c,t,r)&&a.push({title:c.title,subtitle:createSearchRowSubtitle({groupTitle:s.title,pageTitle:o.title??``,pageUseUnderline:o.useUnderline,rowUseMarkup:c.useMarkup,nVisiblePages:i,untitledPageLabel:n.untitledPageLabel}),useMarkup:c.useMarkup??!0,useUnderline:c.useUnderline??!1,page:o,group:s,row:c});return a}function scrollMaxValue(e){return e.upper-e.pageSize}function isScrolledFromStart(e){return e.value>e.lower}function isScrolledFromEnd(e){return e.value<scrollMaxValue(e)}const Zn=[`undershoot-top`,`undershoot-bottom`,`undershoot-start`,`undershoot-end`];function scrollUndershootClasses(e){let t=[],{vertical:n,horizontal:r}=e;return n&&(isScrolledFromStart(n)&&t.push(`undershoot-top`),isScrolledFromEnd(n)&&t.push(`undershoot-bottom`)),r&&(isScrolledFromStart(r)&&t.push(`undershoot-start`),isScrolledFromEnd(r)&&t.push(`undershoot-end`)),t}function overshootDistance(e,t){let n=scrollMaxValue(t);return e<t.lower?e-t.lower:e>n?e-n:0}function accumulateOvershoot(e,t,n){let r=n.lower-100,i=scrollMaxValue(n)+100;return Math.min(Math.max(e+t,r),i)}var PopoverState=class{constructor(){this._open=!1,this._listeners=new Set}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}_emit(e){let t={open:this._open,interactive:e};for(let e of[...this._listeners])e(t)}_setOpen(e,t){return e===this._open?!1:(this._open=e,this._emit(t),!0)}get open(){return this._open}popup(){return this._setOpen(!0,!1)}popdown(){return this._setOpen(!1,!1)}toggle(){return this._setOpen(!this._open,!0)}dismiss(){return this._setOpen(!1,!0)}};function resolvePopoverKey(e,t){if(e===`Escape`)return{action:`close`,index:-1};let n=Number.isFinite(t.itemCount)?Math.max(0,Math.trunc(t.itemCount)):0;if(n===0)return{action:`none`,index:-1};let r=t.currentIndex,i=Number.isFinite(r)&&r>=0&&r<n?Math.trunc(r):-1,a=t.hasSearch===!0&&i<0;switch(e){case`ArrowDown`:return{action:`focus`,index:i<0?0:(i+1)%n};case`ArrowUp`:return{action:`focus`,index:i<0?n-1:(i-1+n)%n};case`Home`:return a?{action:`none`,index:-1}:{action:`focus`,index:0};case`End`:return a?{action:`none`,index:-1}:{action:`focus`,index:n-1};case`Enter`:case` `:return i<0?{action:`none`,index:-1}:{action:`activate`,index:i};default:return{action:`none`,index:-1}}}const Qn=[`none`,`fill`,`spread`],$n=[`minimum`,`natural`],er=[`start-to-end`,`end-to-start`];function normalizeWrapBoxSpacing(e){let t=typeof e==`number`?e:Number.parseFloat(String(e??``));return!Number.isFinite(t)||t<0?0:t}function normalizeWrapBoxAlign(e){let t=typeof e==`number`?e:Number.parseFloat(String(e??``));return Number.isFinite(t)?Math.min(1,Math.max(0,t)):0}function normalizeWrapBoxJustify(e){return Qn.includes(e)?e:`none`}function normalizeWrapPolicy(e){return $n.includes(e)?e:`natural`}function normalizeNaturalLineLength(e){let t=typeof e==`number`?e:Number.parseFloat(String(e??``));return!Number.isFinite(t)||t<0?-1:Math.trunc(t)}function normalizeWrapBoxLengthUnit(e){return normalizeLengthUnit(e,`px`)}function normalizeWrapBoxPackDirection(e){return er.includes(e)?e:`start-to-end`}function wrapBoxLengthToPx(e,t,n=96){return e<0?-1:adwLengthToPx(t,e,n)}function resolveWrapBoxLine(e){let t=e.lastLine&&!e.justifyLastLine?`none`:e.justify;if(t===`none`)return{justify:`none`,growChildren:!1,growGaps:!1,align:e.align};let n=t===`spread`&&e.childrenInLine>1;return{justify:t,growChildren:!n,growGaps:n,align:0}}function wrapPolicyFlexShrink(e){return+(e===`minimum`)}function resolveWrapBoxChildOrder(e){let{children:t,child:n,op:r}=e,i=e.sibling??null;if(i!==null&&i===n)return null;let a=t.indexOf(n);if(r===`insert-after`&&a!==-1||r===`reorder-after`&&a===-1)return null;let o=a===-1?[...t]:t.filter((e,t)=>t!==a);if(i===null)return[n,...o];let s=o.indexOf(i);return s===-1?null:[...o.slice(0,s+1),n,...o.slice(s+1)]}var WindowMemberState=class{constructor(e,t={}){this._active=!1,this._focus=null,this._notify=e,this._maximized=t.maximized??!1}get active(){return this._active}get maximized(){return this._maximized}get focus(){return this._focus}reportActive(e){return this._active===e?!1:(this._active=e,this._notify(`is-active`),!0)}reportMaximized(e){return this._maximized===e?!1:(this._maximized=e,this._notify(`maximized`),!0)}reportFocus(e){return this._focus===e?!1:(this._focus=e,this._notify(`focus-widget`),!0)}};function stepDefaultSize(e,t,n){if(!Number.isInteger(t)||!Number.isInteger(n)||t<-1||n<-1)return null;let r=[];return n!==e[1]&&r.push(`default-height`),t!==e[0]&&r.push(`default-width`),{width:t,height:n,changed:r}}var CloseRequestState=class{constructor(){this._emitting=!1}get emitting(){return this._emitting}close(e){if(!e.realized||this._emitting)return`ignored`;let t;this._emitting=!0;try{e.emit()?t=`handled`:e.hideOnClose?(e.hide(),t=`hidden`):t=`destroyed`}finally{this._emitting=!1}return t===`destroyed`&&e.destroy(),t}};const tr=`--accent-bg-color`,nr=`--accent-color`;function isAdwaitaDark(e){return e.closest(`.theme-dark`)?!0:e.closest(`.theme-light`)?!1:globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1}const rr=new WeakSet;function hasAppChosenAccent(e){return rr.has(e)}function writeAdwaitaAccent(e,t,n){t.style.setProperty(tr,adwaitaAccentBgColor(e)),t.style.setProperty(nr,adwaitaAccentColor(e,n))}function applyAdwaitaAccent(e,t={}){let n=t.target??document.documentElement;rr.add(n),writeAdwaitaAccent(e,n,t.dark??isAdwaitaDark(n))}function clearAdwaitaAccent(e=document.documentElement){rr.delete(e),e.style.removeProperty(tr),e.style.removeProperty(nr)}let V={},ir=!1,ar=null,or=!1;function readSystemAccent(){if(typeof CSS>`u`||!CSS.supports(`color`,`AccentColor`))return null;let e=document.createElement(`span`);e.style.color=`AccentColor`,e.style.display=`none`,document.documentElement.append(e);let t=getComputedStyle(e).color;e.remove();let n=parseAdwRgb(t);return n?{accent:nearestAccent(n),accentRgb:formatAdwRgb(n)}:null}function resolve(){if(V.accent&&V.accent!==Pe)return{accent:V.accent,source:`handoff`};let e=V.accentRgb?parseAdwRgb(V.accentRgb):null;if(e)return{accent:nearestAccent(e),source:`handoff`};if(V.accent===Pe){let e=readSystemAccent();if(e)return{accent:e.accent,source:`system`}}return null}function syncScheme(e){let t=V.colorScheme,n=t===`dark`?`theme-dark`:t===`light`?`theme-light`:null;n!==ar&&(ar&&e.classList.remove(ar),ar=null,n&&!e.classList.contains(`theme-dark`)&&!e.classList.contains(`theme-light`)&&(e.classList.add(n),ar=n))}function sync(){let e=document.documentElement;if(syncScheme(e),hasAppChosenAccent(e))return;let t=resolve();t?(writeAdwaitaAccent(t.accent,e,isAdwaitaDark(e)),ir=!0):ir&&=(clearAdwaitaAccent(e),!1)}const isHandoffMeta=e=>e.nodeName===`META`&&e.getAttribute(`name`)?.startsWith(`adw-`)===!0;function touchesHandoffMeta(e){return e.type===`attributes`?isHandoffMeta(e.target)||e.attributeName===`name`&&e.oldValue?.startsWith(`adw-`)===!0:[...e.addedNodes,...e.removedNodes].some(isHandoffMeta)}function readMetaHandoff(){V=appearanceFromMeta(e=>document.head.querySelector(`meta[name="${e}"]`)?.getAttribute(`content`)??null)}function followDesktopAppearance(){or||typeof document>`u`||(or=!0,readMetaHandoff(),sync(),new MutationObserver(e=>{e.some(touchesHandoffMeta)&&(readMetaHandoff(),sync())}).observe(document.head,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`content`,`name`],attributeOldValue:!0}),globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).addEventListener(`change`,sync),globalThis.addEventListener(`focus`,()=>{V.accent===Pe&&sync()}))}function observeAdaptiveSize(e,t){let n=new ResizeObserver(e=>{let n=e[e.length-1];if(!n)return;let r=n.borderBoxSize?.[0];t(r?{width:r.inlineSize,height:r.blockSize}:{width:n.contentRect.width,height:n.contentRect.height})});return n.observe(e),()=>n.disconnect()}function addBreakpoints(e,t){return observeAdaptiveSize(e,e=>{for(let n of t)n.evaluate(e)})}function bindBreakpointSetter(e,t,n,r=!1){return t?addBreakpoints(e,[new AdwBreakpoint(t,{onApply:()=>n(!0),onUnapply:()=>n(!1)},r)]):()=>{}}const sr=`adw-scroll-shaded`,cr=`--adw-overshoot`,lr=[`overshoot-top`,`overshoot-bottom`],ur=new Set([`auto`,`scroll`,`overlay`]);function adjustmentsOf(e){let t=getComputedStyle(e);return{vertical:ur.has(t.overflowY)?{value:e.scrollTop,lower:0,upper:e.scrollHeight,pageSize:e.clientHeight}:void 0,horizontal:ur.has(t.overflowX)?{value:e.scrollLeft,lower:0,upper:e.scrollWidth,pageSize:e.clientWidth}:void 0}}function isScroller(e){let t=getComputedStyle(e);return ur.has(t.overflowY)||ur.has(t.overflowX)}function wheelDeltaPx(e,t){return e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*t:e.deltaY}var AdwScrollShading=class{_root;_mutations=null;_resize=null;_unclamped=new WeakMap;_settleTimers=new WeakMap;_shaded=new Set;_pendingScan=0;_undershootEdges={top:!0,bottom:!0};_onOvershoot;constructor(e,t={}){this._root=e,this._onOvershoot=t.onOvershoot??null}setUndershootEdges(e){if(!(e.top===this._undershootEdges.top&&e.bottom===this._undershootEdges.bottom)){this._undershootEdges={...e};for(let e of this._shaded)this._update(e)}}connect(){this._mutations||(this._root.addEventListener(`scroll`,this._onScroll,{capture:!0,passive:!0}),this._root.addEventListener(`wheel`,this._onWheel,{capture:!0,passive:!0}),this._mutations=new MutationObserver(()=>this._scheduleRefresh()),this._mutations.observe(this._root,{childList:!0,subtree:!0}),this._resize=new ResizeObserver(()=>this._scheduleRefresh()),this._resize.observe(this._root),this.refresh())}disconnect(){this._root.removeEventListener(`scroll`,this._onScroll,{capture:!0}),this._root.removeEventListener(`wheel`,this._onWheel,{capture:!0}),this._mutations?.disconnect(),this._mutations=null,this._resize?.disconnect(),this._resize=null,this._pendingScan&&cancelAnimationFrame(this._pendingScan),this._pendingScan=0;for(let e of this._shaded)this._clear(e);this._shaded.clear()}_scheduleRefresh(){this._pendingScan||=requestAnimationFrame(()=>{this._pendingScan=0,this.refresh()})}refresh(){let e=new Set;isScroller(this._root)&&e.add(this._root);for(let t of this._root.querySelectorAll(`*`))isScroller(t)&&e.add(t);for(let t of this._shaded)e.has(t)||this._clear(t);this._shaded=e;for(let t of e)this._update(t)}_clear(e){e.classList.remove(sr,...Zn,...lr),e.style.removeProperty(cr)}_update(e){e.classList.add(sr);let t=scrollUndershootClasses(adjustmentsOf(e));for(let n of Zn){let r=(n!==`undershoot-top`||this._undershootEdges.top)&&(n!==`undershoot-bottom`||this._undershootEdges.bottom);e.classList.toggle(n,r&&t.includes(n))}}_onScroll=e=>{let t=e.target;t instanceof HTMLElement&&this._shaded.has(t)&&this._update(t)};_onWheel=e=>{let t=e.target instanceof HTMLElement?this._scrollerFor(e.target):null;if(!t)return;let{vertical:n}=adjustmentsOf(t);if(!n)return;let r=this._unclamped.get(t)??n.value,i=accumulateOvershoot(overshootDistance(r,n)===0?n.value:r,wheelDeltaPx(e,n.pageSize),n);this._unclamped.set(t,i),this._applyOvershoot(t,overshootDistance(i,n)),clearTimeout(this._settleTimers.get(t)),this._settleTimers.set(t,setTimeout(()=>{this._unclamped.set(t,t.scrollTop),this._applyOvershoot(t,0)},50))};_applyOvershoot(e,t){e.classList.toggle(`overshoot-top`,t<0),e.classList.toggle(`overshoot-bottom`,t>0),t===0?e.style.removeProperty(cr):e.style.setProperty(cr,`${Math.abs(t)}px`),this._onOvershoot?.(t)}_scrollerFor(e){for(let t=e;t;t=t.parentElement){if(this._shaded.has(t))return t;if(t===this._root)break}return null}};function walk(e,t,n){n(e,t),(e.children??[]).forEach((e,r)=>walk(e,`${t} > ${e.tag}[${r}]`,n))}function authoredNodes(e,t=e.tag){let n=[];return walk(e,t,(e,t)=>n.push({node:e,path:t})),n}function constructUsesOf(e){let t=[];return[{tree:e,address:e.tag},...(e.siblings??[]).map((t,n)=>({tree:t,address:`${e.tag} > sibling[${n}] ${t.tag}`}))].forEach(({tree:e,address:n},r)=>{r>0&&t.push({kind:`sibling-object`,path:n}),collectUses(e,n,t)}),t}function treeNodesOf(e){return[...authoredNodes(e,e.tag),...(e.siblings??[]).flatMap((t,n)=>authoredNodes(t,`${e.tag} > sibling[${n}] ${t.tag}`))]}function collectUses(e,t,n){for(let{node:r,path:i}of authoredNodes(e,t))r.layout!==void 0&&n.push({kind:`layout`,path:i}),r.accessibility!==void 0&&n.push({kind:`accessibility`,path:i}),r.extensions?.strings!==void 0&&n.push({kind:`strings`,path:i}),r.extensions?.responses!==void 0&&n.push({kind:`responses`,path:i}),r.page!==void 0&&n.push({kind:`page`,path:i}),r.extern===!0&&n.push({kind:`extern`,path:i}),r.signals?.forEach(()=>n.push({kind:`signal`,path:i})),Object.keys(r.bindings??{}).forEach(()=>n.push({kind:`bind`,path:i})),r.breakpoints?.forEach(()=>n.push({kind:`breakpoint`,path:i}))}var UnsupportedConstructError=class extends Error{constructor(e,t){let n=t.map(e=>` ${e.kind} at ${e.path} — ${e.reason}`).join(`
|
|
16
|
+
`);super(`this tree cannot be rendered by ${e}: ${t.length} construct(s) it refuses.\n${n}`),this.name=`UnsupportedConstructError`,this.renderer=e,this.refused=t}};function assertTreeConstructs(e,t,n,r){let i=[];for(let r of constructUsesOf(n)){let n=t[r.kind];if(n===void 0)throw Error(`${e}'s capabilities declare no row for the construct '${r.kind}'.`);n!==`implemented`&&i.push({...r,reason:n.refused})}if(r!==void 0&&t.accessibility===`implemented`)for(let{node:e,path:t}of treeNodesOf(n))for(let n of Object.keys(e.accessibility??{}))r.includes(n)||i.push({kind:`accessibility`,path:t,reason:`'${n}' has no accessibility door here; only ${r.join(`, `)} are written`});if(i.length>0)throw new UnsupportedConstructError(e,i)}const hostTagOf=e=>{if(!/^(?:Adw|Gtk)[A-Z]\w*$/.test(e))throw Error(`hostTagOf: ${e} is not a GIR class name`);let t=[];for(let n=0;n<e.length;n++){let r=e.charAt(n);if(r>=`A`&&r<=`Z`&&n>0){let r=e.charAt(n-1),i=e.charAt(n+1);(!(r>=`A`&&r<=`Z`)||i>=`a`&&i<=`z`)&&t.push(`-`)}t.push(r.toLowerCase())}return t.join(``)},attributeOf=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),propertyOf=e=>e.replace(/[-_]([a-z0-9])/g,(e,t)=>t.toUpperCase()),dr={"margin-start":`margin-inline-start`,"margin-end":`margin-inline-end`,"margin-top":`margin-top`,"margin-bottom":`margin-bottom`},fr=[`hexpand`,`vexpand`],pr={"width-request":`min-width`,"height-request":`min-height`};function widgetLengthStyle(e,t){let n=dr[e];if(n!==void 0)return[n,`${Number(t)}px`];let r=pr[e];if(r!==void 0)return[r,Number(t)<0?null:`${Number(t)}px`]}const mr=new Map([[`adw-toggle-group`,new Set([`sensitive`])],[`adw-toggle`,new Set([`enabled`])],[`adw-alert-response`,new Set([`enabled`])],[`adw-sidebar-item`,new Set([`enabled`,`visible`])],[`gtk-editable-label`,new Set([`editable`])],[`adw-entry-row`,new Set([`editable`,`show-apply-button`])],[`gtk-text`,new Set([`editable`])],[`gtk-text-view`,new Set([`editable`])],[`adw-navigation-page`,new Set([`can-pop`])],[`gtk-action-bar`,new Set([`revealed`])],[`adw-password-entry-row`,new Set([`revealed`])]]);function isValueBasedBooleanAttr(e,t){let n=mr.get(e);return n!==void 0&&n.has(t)}const hr={layout:`implemented`,accessibility:`implemented`,strings:`implemented`,responses:`implemented`,page:`implemented`,extern:`implemented`,signal:`implemented`,bind:`implemented`,breakpoint:`implemented`,"sibling-object":`implemented`};function dispatchedSignalsOf(e){let t=[];for(let n=e.constructor;typeof n==`function`;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,`signals`)?.value;e!==void 0&&t.unshift(e)}return Object.assign({},...t)}const H=new WeakMap,gr=new Set,_r=new WeakMap;let U=null;function isMapped(e){return e.isConnected&&e.checkVisibility()}function depthOf(e){let t=0;for(let n=e.parentElement;n!==null;n=n.parentElement)t++;return t}function recheck(){let e=[];for(let t of gr){let n=t.deref();if(n===void 0){gr.delete(t);continue}let r=H.get(n);isMapped(n)!==r.mapped&&e.push(n)}if(e.length===0)return;let deepestFirst=e=>e.map(e=>[e,depthOf(e)]).sort((e,t)=>t[1]-e[1]),t=deepestFirst(e.filter(e=>H.get(e).mapped)),n=deepestFirst(e.filter(e=>!H.get(e).mapped));for(let[e]of[...t,...n]){let t=H.get(e);t.mapped=!t.mapped,e.dispatchEvent(new CustomEvent(t.mapped?`map`:`unmap`))}}function observe(){U===null&&(U=new MutationObserver(recheck),U.observe(document,{childList:!0,subtree:!0,attributes:!0}),document.addEventListener(`toggle`,recheck,!0))}function unobserve(){U===null||gr.size>0||(U.disconnect(),U=null,document.removeEventListener(`toggle`,recheck,!0))}function watchMapping(e){let t=H.get(e);if(t===void 0||t.listeners===0){t={mapped:isMapped(e),listeners:0},H.set(e,t);let n=new WeakRef(e);_r.set(e,n),gr.add(n),observe()}t.listeners++;let n=!0;return()=>{if(!n)return;n=!1;let t=H.get(e);--t.listeners>0||(gr.delete(_r.get(e)),_r.delete(e),unobserve())}}const vr=new WeakSet,yr=new WeakMap,br=new WeakSet;let xr=0;function hasElementApi(e){return br.has(e)}function eventOf(e,t){let n=dispatchedSignalsOf(e),r=n[t]??(t.startsWith(`notify::`)?n[`notify::${attributeOf(t.slice(8))}`]:void 0);if(r===void 0)throw Error(`<${e.localName}> declares no signal '${t}'. It dispatches: ${Object.keys(n).join(`, `)||`none`}.`);return r}function inheritedDescriptor(e,t){for(let n=Object.getPrototypeOf(e);n!==null;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(e!==void 0)return e}}function notifyElement(e,t){let n=propertyOf(t);e.dispatchEvent(new CustomEvent(eventOf(e,`notify::${t}`),{bubbles:!0,detail:{[n]:e[n]}}))}function ensureNotifying(e,t){let n=propertyOf(t),r=yr.get(e)??new Set;if(r.has(n)||(r.add(n),yr.set(e,r),Object.getOwnPropertyDescriptor(e,n)!==void 0))return;let i=inheritedDescriptor(e,n);if(i?.get===void 0||i.set===void 0)return;let{get:a,set:o}=i,s=eventOf(e,`notify::${t}`);Object.defineProperty(e,n,{configurable:!0,enumerable:!1,get(){return a.call(this)},set(e){let n=a.call(this),r=!1,mark=e=>{e.target===this&&(r=!0)};this.addEventListener(s,mark);try{o.call(this,e)}finally{this.removeEventListener(s,mark)}!r&&a.call(this)!==n&¬ifyElement(this,t)}})}function signalOwner(e,t,n){for(let r=e instanceof Element?e:null;r!==null;r=r.parentElement)if(dispatchedSignalsOf(r)[t]===n)return r;return null}function listenElement(e,t,n){let r=eventOf(e,t),i=t.startsWith(`notify::`);i&&ensureNotifying(e,t.slice(8));let listener=a=>{i&&a.target!==e||!i&&!vr.has(a)&&signalOwner(a.target,t,r)!==e||n(e,...vr.has(a)?a.detail:[])===!0&&a.cancelable&&(a.preventDefault(),a.stopImmediatePropagation())};e.addEventListener(r,listener);let a=t===`map`||t===`unmap`?watchMapping(e):void 0;return()=>{e.removeEventListener(r,listener),a?.()}}function dispatchElement(e,t,n){let r=eventOf(e,t),i=new CustomEvent(r,{detail:n,bubbles:r.startsWith(`notify::`)});vr.add(i),e.dispatchEvent(i)}function installSensitive(e){if(`sensitive`in e)return;let t=e.constructor.observedAttributes??[],n=`disabled`in e||t.includes(`disabled`);Object.defineProperty(e,"sensitive",{configurable:!0,enumerable:!1,get:()=>n?!e.hasAttribute(`disabled`):e.getAttribute(`aria-disabled`)!==`true`,set:t=>{n?e.toggleAttribute(`disabled`,!t):t?e.removeAttribute(`aria-disabled`):e.setAttribute(`aria-disabled`,`true`)}})}const Sr=new WeakSet,Cr=new WeakSet;function hasInstalledVisible(e){if(Sr.has(e))return!0;let t=inheritedDescriptor(e,`visible`)?.get;return t!==void 0&&Cr.has(t)}function installVisible(e){if(`visible`in e)return;Sr.add(e);let define=(t,n)=>Object.defineProperty(e,t,{configurable:!0,enumerable:!1,...n}),set=t=>{let n=!e.hidden;e.toggleAttribute(`hidden`,!t),!e.hidden!==n&&`notify::visible`in dispatchedSignalsOf(e)&¬ifyElement(e,`visible`)};define(`visible`,{get:()=>!e.hidden,set}),`get_visible`in e||define(`get_visible`,{value:()=>!e.hidden,writable:!0}),`set_visible`in e||define(`set_visible`,{value:set,writable:!0})}function installElementApi(e){let t=e.connect;if(typeof t==`function`&&!wr.has(t))return;br.add(e);let n=new Map,define=(t,n)=>Object.defineProperty(e,t,{value:n,configurable:!0,writable:!0,enumerable:!1});define(`connect`,(t,r)=>{let i=listenElement(e,t,r),a=++xr;return n.set(a,i),a}),define(`disconnect`,t=>{let r=n.get(t);if(r===void 0)throw Error(`No handler with id ${t} is connected to <${e.localName}>`);n.delete(t),r()}),define(`emit`,(t,...n)=>dispatchElement(e,t,n)),define(`notify`,t=>notifyElement(e,t)),define(`get_property`,t=>(eventOf(e,`notify::${t}`),e[propertyOf(t)])),define(`set_property`,(t,n)=>{eventOf(e,`notify::${t}`);let r=propertyOf(t),i=inheritedDescriptor(e,r);if(i!==void 0&&i.get!==void 0&&i.set===void 0)throw Error(`Property '${t}' of <${e.localName}> is read-only`);e[r]=n}),define(`add_css_class`,t=>e.classList.add(t)),define(`remove_css_class`,t=>e.classList.remove(t)),define(`has_css_class`,t=>e.classList.contains(t))}const wr=new WeakSet;function markLazyElementApi(e){for(let t of[`connect`,`disconnect`,`emit`,`notify`])wr.add(e[t])}const Tr=new Set([`connect`,`disconnect`,`emit`,`notify`,`get_property`,`set_property`]);function endpointOf(e){return hasElementApi(e)?new Proxy(e,{get(e,t){if(typeof t!=`string`||Tr.has(t))return Reflect.get(e,t,e);let n=Reflect.get(e,propertyOf(t),e);return typeof n==`function`?n.bind(e):n},set(e,t,n){return Reflect.set(e,typeof t==`string`?propertyOf(t):t,n,e)}}):e}const Er=new WeakMap;function isContent(e){return e instanceof Element?!0:e.nodeType===Node.TEXT_NODE&&(e.textContent??``).trim()!==``}function bindSlottedChildren(e,t,n){let r=new Map,i=[],a=null;for(let e of t){let t=e.claims;e.name!==void 0&&r.set(e.name,e),t!==void 0&&i.push([t,e]),e.name===void 0&&t===void 0&&(a=e)}let o=new Set,s=null,slotFor=e=>{if(o.has(e))return null;let t=e instanceof Element?e.getAttribute(`slot`)??``:``;if(t!==``)return r.get(t)??null;for(let[t,n]of i)if(t(e))return n;return a},route=t=>{let n=slotFor(t);return n===null?null:`into`in n?(n.into.appendChild(t),n):(n.consume(t),t.parentNode===e&&e.removeChild(t),n)},c={slots:t,slotFor,install(...t){let r=[];for(let t of Array.from(e.childNodes)){if(route(t)!==null||t.parentNode!==e||!isContent(t))continue;r.push(t);let n=t instanceof Element?t.getAttribute(`slot`)??``:``;console.warn(`'${n}' is not a valid child type of '${e.localName}'`)}o=new Set(t),e.replaceChildren(...t,...r),s?.disconnect(),s=new MutationObserver(t=>{for(let r of t)if(r.target===e)for(let e of r.addedNodes){let t=route(e);t!==null&&n?.(e,t)}}),s.observe(e,{childList:!0})}};return Er.set(e,c),c}const Dr=new Map;function registerTemplateClass(e,t){let n=Dr.get(e);if(n!==void 0&&n!==t)throw Error(`the template class '${e}' is already registered as <${n}>.`);Dr.set(e,t)}function isTemplateTag(e){for(let t of Dr.values())if(t===e)return!0;return!1}function templateTagFor(e){let t=Dr.get(e);if(t===void 0)throw Error(`the tree uses the class '$${e}', which no registerTemplateClass() call registered: adwaita-web cannot build a class it does not know.`);if(customElements.get(t)===void 0)throw Error(`the class '$${e}' is registered as <${t}>, which nothing has defined in the custom element registry, so the element would stay an empty unknown tag.`);return t}function booleanAttribute$2(e,t){return e===null?t:e!==`false`}__name(booleanAttribute$2,`booleanAttribute`);function writeBooleanAttribute$1(e,t,n){n?e.setAttribute(t,`true`):e.setAttribute(t,`false`)}__name(writeBooleanAttribute$1,`writeBooleanAttribute`);function isWritable(e,t){for(let n=e;n!==null;n=Object.getPrototypeOf(n)){let e=Object.getOwnPropertyDescriptor(n,t);if(e!==void 0)return e.set!==void 0||e.writable===!0}return!1}function buildSiblings(e,t){let n=new Map;for(let r of e.siblings??[]){if(r.id===void 0)throw Error(`the sibling \`${r.tag}\` has no id, so nothing could ever ask for it: give it one in the .blp.`);n.set(r.id,buildNode$1(r,t))}return n}function newRecord(e,t,n){return{placed:[],extended:[],ids:new Map,binds:[],breakpointHosts:[],disposers:[],...e===void 0?{}:{scope:e},...t===void 0?{}:{observeSize:t},...n===void 0?{}:{template:n,connects:[]}}}function bindBreakpoints(e,t,n){let r=createBreakpointDriver((t.breakpoints??[]).map(t=>{if(parseBreakpointCondition(t.condition)===null)throw Error(`<${e.localName}> \`condition ("${t.condition}")\` is not an Adwaita breakpoint condition.`);return{condition:t.condition,setters:t.setters.map(t=>{let r=n.ids.get(t.object);if(r===void 0)throw Error(`<${e.localName}> breakpoint setter \`${t.object}.${t.property}\` names no object: nothing in this tree has the id '${t.object}'.`);return{object:r,property:t.property,value:t.value}})}}),{read(e,t){let n=propertyOf(t),r=e[n];return typeof r==`boolean`&&isWritable(e,n)?{member:r}:{attribute:e.getAttribute(attributeOf(t))}},write(e,t,n){let r=propertyOf(t);if(typeof n==`object`&&n&&`member`in n)e[r]=n.member;else if(typeof n==`object`&&n&&`attribute`in n){let r=n.attribute;r===null?e.removeAttribute(attributeOf(t)):e.setAttribute(attributeOf(t),r)}else typeof n==`boolean`&&isWritable(e,r)?e[r]=n:writeProp(e,t,n)}});n.disposers.push((n.observeSize??observeAdaptiveSize)(e,e=>r.evaluate(e)))}function bindProperty(e,t){if(t.template!==void 0)return bindThroughEngine(e,t.template,t);let{el:n,property:r,source:i,sourceProperty:a,flags:o}=e,s=`<${n.localName}> \`${r}: bind ${i}.${a}\``,c=t.ids.get(i);if(c===void 0)throw Error(`${s} names no object: nothing in this tree has the id '${i}'.`);if(o.length>0)throw Error(`${s} carries ${o.join(`, `)}: adwaita-web binds the plain form only until each flag is verified against GObject.`);let l=`notify::${a}`,u=dispatchedSignalsOf(c),d=u[l];if(d===void 0)throw Error(`${s}: <${c.localName}> dispatches no '${l}', so the target would follow the source once and never again. It dispatches: ${Object.keys(u).join(`, `)||`none`}.`);let f=propertyOf(r),p=propertyOf(a);if(!isWritable(n,f))throw Error(`${s}: <${n.localName}> has no writable property '${f}'.`);let follow=()=>{n[f]=c[p]};follow(),c.addEventListener(d,follow)}function bindThroughEngine(e,t,n){let{el:r,property:i,source:a,sourceProperty:o,flags:s}=e,c=`<${r.localName}> \`${i}: bind ${a}.${o}\``,l=a===`template`?t.instance:n.ids.get(a);if(l===void 0)throw Error(`${c} names no object: nothing in this tree has the id '${a}'.`);let u=[`bidirectional`,`inverted`,`no-sync-create`],d=s.filter(e=>!u.includes(e));if(d.length>0)throw Error(`${c} carries ${d.join(`, `)}, which is not a bind flag.`);if(hasElementApi(r)&&!isWritable(r,propertyOf(i)))throw Error(`${c}: <${r.localName}> has no writable property '${propertyOf(i)}'.`);let f=[];s.includes(`bidirectional`)&&f.push(`bidirectional`),s.includes(`inverted`)&&f.push(`invert-boolean`),s.includes(`no-sync-create`)||f.push(`sync-create`),t.bind(endpointOf(l),o,endpointOf(r),i,f)}function writeProp(e,t,n){let r=attributeOf(t),i=propertyOf(t),a=fr.find(e=>e===r);a!==void 0&&typeof n==`boolean`?e.setAttribute(a,n?``:`false`):r===`visible`&&typeof n==`boolean`&&hasInstalledVisible(e)||isTemplateTag(e.localName)&&i in e?e[i]=n:typeof n==`boolean`&&isValueBasedBooleanAttr(e.localName,r)?writeBooleanAttribute$1(e,r,n):n===!1&&isWritable(e,i)?e[i]=!1:typeof n==`boolean`?e.toggleAttribute(r,n):e.setAttribute(r,String(n));let o=widgetLengthStyle(r,n);o!==void 0&&(o[1]===null?e.style.removeProperty(o[0]):e.style.setProperty(o[0],o[1]))}function buildNode$1(e,t){let n=document.createElement(e.extern===!0?templateTagFor(e.tag):hostTagOf(e.tag));if(t.template!==void 0&&installElementApi(n),installVisible(n),e.id!==void 0){if(t.ids.has(e.id))throw Error(`Two nodes of this tree carry the id '${e.id}'; GtkBuilder refuses a duplicate id.`);n.id=e.id,t.ids.set(e.id,n)}collectNode(n,e,t),writeLook(n,e,t.menus),bindSignals(n,e,t),e.extensions!==void 0&&t.extended.push({el:n,node:e});for(let r of buildChildren(n,e,t))n.append(r);return n}__name(buildNode$1,`buildNode`);function collectNode(e,t,n){for(let[r,i]of Object.entries(t.bindings??{}))r===`sensitive`&&installSensitive(e),n.binds.push({el:e,property:r,source:i.source,sourceProperty:i.property,flags:i.flags??[]});t.breakpoints!==void 0&&n.breakpointHosts.push({el:e,node:t})}function writeLook(e,t,n){for(let[n,r]of Object.entries(t.props??{}))n!==`menu-model`&&writeProp(e,n,r);for(let[r,i]of menuAssignments(t,n))e[propertyOf(r)]=i;t.styleClasses!==void 0&&t.styleClasses.length>0&&e.classList.add(...t.styleClasses),writeExtensions(e,t),writeAccessibility(e,t)}const Or={label:`aria-label`,description:`aria-description`};function writeAccessibility(e,t){for(let[n,r]of Object.entries(t.accessibility??{}))e.setAttribute(Or[n],String(r.value))}const kr={row:{property:`gridRow`,span:!1},column:{property:`gridColumn`,span:!1},"row-span":{property:`gridRow`,span:!0},"column-span":{property:`gridColumn`,span:!0}};function writeGridCell(e,t,n){let r=n.layout??{};if(e.localName!==`gtk-grid`)throw Error(`layout (${Object.keys(r).join(`, `)}) on \`${n.tag}\` under \`${e.localName}\`: this renderer's only layout manager is the grid, so the placement would be dropped.`);let i={row:0,column:0,"row-span":1,"column-span":1};for(let[e,t]of Object.entries(r)){if(kr[e]===void 0)throw Error(`layout \`${e}\` on \`${n.tag}\` reaches nothing: a grid child takes ${Object.keys(kr).join(`, `)}.`);if(typeof t!=`number`||!Number.isInteger(t))throw Error(`layout \`${e}: ${String(t)}\` on \`${n.tag}\` is not a whole number.`);i[e]=t}t.style.gridRow=`${i.row+1} / span ${i[`row-span`]}`,t.style.gridColumn=`${i.column+1} / span ${i[`column-span`]}`}function buildChildren(e,t,n){let r=[];for(let i of t.children??[]){let t=buildNode$1(i,n);i.layout!==void 0&&writeGridCell(e,t,i),i.page!==void 0&&writePage(e,t,i),i.slot!==void 0&&(t.setAttribute(`slot`,i.slot),n.placed.push({parent:e,child:t,slot:i.slot})),r.push(t)}return r}function buildTemplateTree(e,t,n){assertTreeConstructs(`adwaita-web`,hr,e,Object.keys(Or));let r=newRecord(void 0,void 0,t);r.menus=e.menus,e.id!==void 0&&r.ids.set(e.id,n),collectNode(n,e,r),bindSignals(n,e,r);let i=buildChildren(n,e,r);buildSiblings(e,r);for(let e of r.connects??[])e();for(let e of r.binds)bindProperty(e,r);for(let e of r.breakpointHosts)bindBreakpoints(e.el,e.node,r);return{children:i,objects:Object.fromEntries(r.ids),finish:()=>writeLook(n,e,e.menus)}}function bindSignals(e,t,n){let r=dispatchedSignalsOf(e);for(let i of t.signals??[]){let t=i.detail===void 0?i.name:`${i.name}::${i.detail}`,a=r[t];if(a===void 0)throw Error(`<${e.localName}> declares no signal '${t}', so the handler '${i.handler}' would never run. It dispatches: ${Object.keys(r).join(`, `)||`none`}.`);if(n.template!==void 0){if(i.flags?.includes(`after`)===!0)throw Error(`the handler '${i.handler}' for '${t}' uses after, which is not in the GObject subset.`);let r=n.template;n.connects.push(()=>{let a=i.object===void 0?void 0:i.object===`template`?r.instance:n.ids.get(i.object);if(i.object!==void 0&&a===void 0)throw Error(`the handler '${i.handler}' for '${t}' names the object '${i.object}', which nothing in this tree has.`);e.connect(t,r.handler(i.handler,{object:a,flags:i.flags}))});continue}if(i.object!==void 0||(i.flags?.length??0)>0)throw Error(`the handler '${i.handler}' for '${t}' uses ${i.object===void 0?``:`an object `}${(i.flags??[]).join(`, `)}: adwaita-web binds plain handlers only until each of those is verified against GTK.`);let o=n.scope?.[i.handler];if(typeof o!=`function`)throw Error(`the tree binds the handler '${i.handler}' for '${t}', and the scope ${n.scope===void 0?"was not given (pass `scope`)":`has no such function`}.`);e.addEventListener(a,e=>o.call(n.scope,e))}}function writeExtensions(e,t){let n=t.extensions?.strings;n!==void 0&&e.setAttribute(`strings`,JSON.stringify(n.map(e=>e.value)));for(let n of t.extensions?.responses??[]){let t=document.createElement(`adw-alert-response`);t.id=n.id,n.appearance!==void 0&&t.setAttribute(`appearance`,n.appearance),n.enabled===!1&&t.setAttribute(`enabled`,`false`),t.textContent=n.label,e.append(t)}}function writePage(e,t,n){let{page:r}=n;if(e.localName===`gtk-notebook`)r?.label!==void 0&&t.setAttribute(`tab-label`,r.label);else if(e.localName===`gtk-stack`)r?.name!==void 0&&t.setAttribute(`name`,r.name),r?.label!==void 0&&t.setAttribute(`title`,r.label);else throw Error(`adwaita-web's shared-tree builder: <${n.tag}> has a page, and <${e.localName}> has no pages.`)}const Ar=new Map;function modifierState(e){return!!e.shiftKey|(e.ctrlKey?4:0)|(e.altKey?8:0)|(e.metaKey?67108864:0)}const jr={setStyles(e){if(typeof document>`u`)return;let t=new Set(e.map(e=>e.owner));for(let[e,n]of Ar)t.has(e)||(n.remove(),Ar.delete(e));for(let{owner:t,css:n,priority:r}of e){let e=Ar.get(t);e||(e=document.createElement(`style`),Ar.set(t,e)),e.dataset.gtkPriority=String(r),e.textContent!==n&&(e.textContent=n),document.head.append(e)}},openUri(e){typeof globalThis>`u`||globalThis.open(e,`_blank`,`noopener`)},fontName(){if(typeof document>`u`||!document.body)return null;let e=getComputedStyle(document.body),t=e.fontFamily.split(`,`)[0]?.trim().replace(/^["']|["']$/g,``),n=Number.parseFloat(e.fontSize);return!t||!Number.isFinite(n)?null:`${t} ${Math.round(n*.75*10)/10}`},listenKeys(e,t){let n=e;n.hasAttribute(`tabindex`)||n.setAttribute(`tabindex`,`-1`);let listen=e=>n=>{let r=n;t({key:r.key,keycode:r.keyCode,state:modifierState(r),pressed:e})&&r.preventDefault()},r=listen(!0),i=listen(!1);return n.addEventListener(`keydown`,r),n.addEventListener(`keyup`,i),()=>{n.removeEventListener(`keydown`,r),n.removeEventListener(`keyup`,i)}}},W=createGtkPlatform(jr);W.CssProvider,W.StyleContext,W.Settings;const Mr=W.IconTheme;W.EventControllerKey,W.show_uri;const Nr=new Set;function onIconThemeChanged(e){return Nr.add(e),()=>{Nr.delete(e)}}function hasSymbolic(e){return e===``?!1:getComputedStyle(document.documentElement).getPropertyValue(`--icon-${e}`).trim()!==``}function lookupIcon(e,t={}){if(e==null||e===``)return null;let n=resourceIcon(e,t);if(n!==null)return n;let r=normalizeIconName(e);return r===``?{kind:`missing`}:{kind:`symbolic`,name:r}}const Pr=Mr.get_for_display(null),Fr=new Map;Pr.connect(`changed`,()=>{for(let e of Fr.values())e!==null&&URL.revokeObjectURL(e);Fr.clear();for(let e of Nr)e()});const Ir={".svg":`image/svg+xml`,".png":`image/png`};function resourceUrl(e){let t=Fr.get(e);if(t!==void 0)return t;let n=null,r=Ir[e.slice(e.lastIndexOf(`.`))];if(r===void 0)console.warn(`Gtk.IconTheme: ${e} is not an SVG or a PNG, which is all a browser draws (ADR 0116 § 4).`);else try{let t=resources_lookup_data(e,0).get_data();n=URL.createObjectURL(new Blob([t],{type:r}))}catch(t){console.warn(`Gtk.IconTheme: ${e} cannot be drawn: ${t.message}`)}return Fr.set(e,n),n}function resourceIcon(e,t){let n=lookupResourceIcon(Pr,{names:iconLookupNames(e,t.direction??null),get size(){return t.size??16},scale:t.scale??1,themeHas:e=>hasSymbolic(normalizeIconName(e))});return n===null?null:n.kind===`theme`?{kind:`symbolic`,name:normalizeIconName(n.name)}:{kind:`resource`,name:n.name,path:n.path,url:resourceUrl(n.path),symbolic:n.symbolic}}let G=null;function interceptCopy(e,t){if(!e)return t(),!1;let n=G,r={data:e,wrote:!1};G=r;try{t()}finally{G=n}return r.wrote}const Lr={writeText(e){if(G){G.data.setData(`text/plain`,e),G.wrote=!0;return}return typeof navigator>`u`||!navigator.clipboard?Promise.reject(Error(`navigator.clipboard is not available here`)):navigator.clipboard.writeText(e)}},Rr={name:`adwaita-web`,requiresWindow:!1,start(e){return new Promise(t=>{let go=()=>{e(),t()};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,go,{once:!0}):go()})},detach(e){e.remove()},exit(){},iconTheme:()=>Mr.get_for_display(null),guardUnload(e){e?globalThis.addEventListener(`beforeunload`,confirmUnload):globalThis.removeEventListener(`beforeunload`,confirmUnload)}};function confirmUnload(e){e.preventDefault(),e.returnValue=``}function parentOfElement(e){if(!(e instanceof Element))return null;let t=e.anchor;return t instanceof Element?t:e.parentElement}function activateWidgetAction(e,t,n=null){return activateWidgetAction$1(e,t,parentOfElement,n)}function menuActionsOfElement(e,t){return menuActionsFor(t,e,parentOfElement)}function activateElementMenuItem(e,t){return activateMenuItem(t,e,parentOfElement)}var GioApplication=class extends GioApplicationBase{static host=Rr};withGtkApplication(GioApplication);const zr=new WeakMap;function followAccelerators(e,t){zr.get(e)?.(),zr.delete(e),t!==null&&zr.set(e,jr.listenKeys(e,t=>dispatchAccelerator(e,t,parentOfElement)))}function defineWindowApplication(e){defineWindowApplicationMembers(e,followAccelerators)}const Br={b:{element:`b`},i:{element:`i`},u:{element:`u`},s:{element:`s`},tt:{element:`span`,style:{"font-family":`monospace`}},big:{element:`span`,style:{"font-size":`larger`}},small:{element:`span`,style:{"font-size":`smaller`}},sub:{element:`sub`,style:{"font-size":`calc(1em / 1.2)`}},sup:{element:`sup`,style:{"font-size":`calc(1em / 1.2)`}},markup:{element:`span`,style:{display:`contents`}},span:{element:`span`}},Vr={weight:`font-weight`,style:`font-style`,underline:`text-decoration-line`,strikethrough:`text-decoration-line`,font_family:`font-family`,size:`font-size`},Hr={font_weight:`weight`,font_style:`style`,face:`font_family`,font_size:`size`},Ur={weight:{ultralight:`100`,light:`300`,normal:`400`,medium:`500`,semibold:`600`,bold:`bold`,ultrabold:`700`,heavy:`900`},style:{normal:`normal`,oblique:`oblique`,italic:`italic`}};function buildNode(e,t){if(e.kind===`text`)return t.createTextNode(e.text);let n=Br[e.tag];if(n===void 0)return null;let r=t.createElement(n.element);if(n.style!==void 0)for(let[e,t]of Object.entries(n.style))r.style.setProperty(e,t);e.tag===`span`&&applySpanAttributes(r,e.attributes);for(let n of e.children){let e=buildNode(n,t);e!==null&&r.append(e)}return r}function applySpanAttributes(e,t){let n=[];for(let[r,i]of Object.entries(t)){let t=Hr[r]??r,a=Vr[t];if(a===void 0)continue;if(t===`underline`){i!==`none`&&n.push(`underline`);continue}if(t===`strikethrough`){i!==`false`&&i!==`none`&&n.push(`line-through`);continue}if(t===`font_family`){let t=sanitizeFontFamily(i);t!==null&&e.style.setProperty(a,t);continue}if(t===`size`){let t=sanitizeFontSize(i);t!==null&&e.style.setProperty(a,t);continue}if(t===`weight`&&/^[0-9]{1,4}$/.test(i)&&+i>=1&&+i<=1e3){e.style.setProperty(a,i);continue}let o=Ur[t]?.[i];o!==void 0&&e.style.setProperty(a,o)}n.length>0&&e.style.setProperty(`text-decoration-line`,n.join(` `))}const Wr=new Set([`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`,`ui-serif`,`ui-sans-serif`,`ui-monospace`,`ui-rounded`]);function sanitizeFontFamily(e){let t=[];for(let n of e.split(`,`)){let e=n.trim();if(e!==``){if(!Wr.has(e.toLowerCase())&&!/^["']?[A-Za-z0-9 _-]+["']?$/.test(e))return null;t.push(e)}}return t.length>0?t.join(`, `):null}function sanitizeFontSize(e){let t=e.trim(),n={"xx-small":`xx-small`,"x-small":`x-small`,small:`small`,medium:`medium`,large:`large`,"x-large":`x-large`,"xx-large":`xx-large`,smaller:`smaller`,larger:`larger`}[t];return n===void 0?/^[0-9]+$/.test(t)?`${t/1024}pt`:/^[0-9]+(\.[0-9]+)?pt$/.test(t)||/^[0-9]+(\.[0-9]+)?%$/.test(t)?t:null:n}function renderPangoMarkup(e,t){let n=parsePangoMarkup(t);if(n===null){e.textContent=t;return}let r=e.ownerDocument??document;e.replaceChildren(...n.map(e=>buildNode(e,r)).filter(e=>e!==null))}function widgetChild(e,t,n){for(let r=e[t];r!==null;r=r[n])if(isWidgetNode(r))return r;return null}var WidgetElement=class extends HTMLElement{static signals={map:`map`,unmap:`unmap`};get visible(){return!this.hidden}set visible(e){let t=!this.hidden;this.toggleAttribute(`hidden`,!e),!this.hidden!==t&&`notify::visible`in dispatchedSignalsOf(this)&¬ifyElement(this,`visible`)}get_visible(){return this.visible}set_visible(e){this.visible=e}get_first_child(){return widgetChild(this,`firstElementChild`,`nextElementSibling`)}get_last_child(){return widgetChild(this,`lastElementChild`,`previousElementSibling`)}get_next_sibling(){return widgetChild(this,`nextElementSibling`,`nextElementSibling`)}get_prev_sibling(){return widgetChild(this,`previousElementSibling`,`previousElementSibling`)}get_parent(){return widgetChild(this,`parentElement`,`parentElement`)}get_width(){return this.offsetWidth}get_height(){return this.offsetHeight}connect(e,t){return installElementApi(this),this.connect(e,t)}disconnect(e){installElementApi(this),this.disconnect(e)}emit(e,...t){installElementApi(this),this.emit(e,...t)}notify(e){installElementApi(this),this.notify(e)}get_mapped(){return isMapped(this)}};markLazyElementApi(WidgetElement.prototype),Cr.add(Object.getOwnPropertyDescriptor(WidgetElement.prototype,`visible`).get);var TooltipElement=class extends WidgetElement{get tooltip_text(){return this.getAttribute(`tooltip-text`)}set tooltip_text(e){e==null?this.removeAttribute(`tooltip-text`):this.setAttribute(`tooltip-text`,e)}get tooltipText(){return this.tooltip_text}set tooltipText(e){this.tooltip_text=e}get_tooltip_text(){return this.tooltip_text}set_tooltip_text(e){this.tooltip_text=e}};function cssUrl(e){return`url("${e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}")`}const Gr=`adw-icon--`;var GtkImage=class extends WidgetElement{static get observedAttributes(){return[`icon-name`,`size`]}get iconName(){return this.getAttribute(`icon-name`)??``}set iconName(e){e===null?this.removeAttribute(`icon-name`):this.setAttribute(`icon-name`,e)}get resolvedIconName(){return normalizeIconName(this.getAttribute(`icon-name`))}get size(){let e=Number.parseFloat(this.getAttribute(`size`)??``);return Number.isFinite(e)&&e>0?e:null}set size(e){e===null?this.removeAttribute(`size`):this.setAttribute(`size`,String(e))}_unsubscribe=null;connectedCallback(){this._unsubscribe??=onIconThemeChanged(()=>this._render()),this._render()}disconnectedCallback(){this._unsubscribe?.(),this._unsubscribe=null}attributeChangedCallback(){this._render()}_request(){let measure=()=>{if(this.size!==null)return this.size;let e=this.isConnected?Number.parseFloat(getComputedStyle(this).width):NaN;return Number.isFinite(e)&&e>0?Math.round(e):16};return{get size(){return measure()},scale:Math.max(1,Math.round(globalThis.devicePixelRatio??1)),direction:this.matches(`:dir(rtl)`)?`rtl`:`ltr`}}_render(){this.classList.add(`adw-icon`);let e=[...this.classList].filter(e=>e.startsWith(Gr));this.classList.remove(...e);let t=lookupIcon(this.getAttribute(`icon-name`),this._request()),n=t?.kind===`resource`&&t.url===null?{kind:`missing`}:t,r=n?.kind===`resource`&&!n.symbolic?n.url:null,i=n?.kind===`resource`&&n.symbolic?n.url:null;this.classList.toggle(`adw-icon-color`,r!==null),r===null?this.style.removeProperty(`background-image`):this.style.backgroundImage=cssUrl(r),i===null?(this.style.removeProperty(`mask-image`),this.style.removeProperty(`-webkit-mask-image`),this.style.removeProperty(`background-color`)):(this.style.setProperty(`mask-image`,cssUrl(i)),this.style.setProperty(`-webkit-mask-image`,cssUrl(i)),this.style.backgroundColor=`currentColor`),n?.kind===`symbolic`?this.classList.add(`${Gr}${n.name}`):n?.kind===`missing`&&this.classList.add(`${Gr}image-missing`),this.setAttribute(`aria-hidden`,`true`);let a=this.size;if(a===null)this.style.removeProperty(`width`),this.style.removeProperty(`height`),this.style.removeProperty(`mask-size`),this.style.removeProperty(`-webkit-mask-size`);else{let e=`${a}px`;this.style.width=e,this.style.height=e,this.style.setProperty(`mask-size`,e),this.style.setProperty(`-webkit-mask-size`,e)}}};function createGtkImage(e,...t){let n=document.createElement(`gtk-image`);return e!==null&&n.setAttribute(`icon-name`,e),t.length>0&&n.classList.add(...t),n}customElements.define(`gtk-image`,GtkImage);const Kr={schedule:(e,t)=>setTimeout(e,t),cancel:e=>clearTimeout(e)};var AdwToastOverlay=class extends WidgetElement{_toasts;_initialized=!1;_queue;_scheduler=Kr;_currentEl=null;constructor(){super(),this._queue=new ToastOverlayQueue({scheduler:{schedule:(e,t)=>this._scheduler.schedule(e,t),cancel:e=>this._scheduler.cancel(e)},onShow:e=>this._mountToast(e),onHide:()=>this._unmountToast(this._queue.pending>0)})}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=document.createElement(`div`);e.className=`adw-toast-overlay-content`,this._toasts=document.createElement(`div`),this._toasts.className=`adw-toast-overlay-toasts`,bindSlottedChildren(this,[{name:`child`,into:e},{into:e}]).install(e,this._toasts)}get scheduler(){return this._scheduler}set scheduler(e){this._scheduler=e}get currentToast(){return this._queue.current}get pendingToasts(){return this._queue.pending}add_toast(e){this._toasts||this.connectedCallback(),this._queue.add_toast(e)}dismiss_all(){this._queue.dismiss_all()}_mountToast(e){let t=document.createElement(`div`);t.className=`adw-toast`;let n=document.createElement(`div`);n.className=`adw-toast-content-wrapper`;let r=document.createElement(`span`);if(r.className=`adw-toast-title`,e.use_markup?renderPangoMarkup(r,e.title):r.textContent=e.title,n.appendChild(r),t.appendChild(n),e.button_label){let n=document.createElement(`button`);n.type=`button`,n.className=`adw-toast-action-button`,n.textContent=e.button_label,n.addEventListener(`click`,()=>{e.emit(`button-clicked`),e.action_name&&activateWidgetAction(this,e.action_name),e.dismiss()}),t.appendChild(n)}let i=document.createElement(`button`);i.type=`button`,i.className=`adw-toast-close-button`,i.setAttribute(`aria-label`,`Close`),i.appendChild(createGtkImage(`window-close`)),i.addEventListener(`click`,()=>e.dismiss()),t.appendChild(i),this._toasts.appendChild(t),this._currentEl=t,requestAnimationFrame(()=>{t.classList.add(`visible`)})}_unmountToast(e){let t=this._currentEl;if(this._currentEl=null,t){if(e){t.remove();return}t.classList.remove(`visible`),t.classList.add(`hiding`),t.addEventListener(`transitionend`,()=>t.remove(),{once:!0}),this._scheduler.schedule(()=>{t.parentNode&&t.remove()},300)}}};customElements.define(`adw-toast-overlay`,AdwToastOverlay);const qr=[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`,`);var AdwModalSurface=class{_init;_previouslyFocused=null;constructor(e){this._init=e,e.surface.setAttribute(`role`,e.role),e.surface.setAttribute(`aria-modal`,`true`),e.surface.hasAttribute(`tabindex`)||(e.surface.tabIndex=-1),e.host.addEventListener(`keydown`,e=>this._onKeyDown(e))}focusables(){return Array.from(this._init.surface.querySelectorAll(qr)).filter(e=>!e.hasAttribute(`disabled`)&&!e.hidden&&e.getClientRects().length>0)}present(){let e=document.activeElement;this._previouslyFocused=e instanceof HTMLElement&&e!==this._init.host?e:null;let t=this.focusables(),n=this._init.initialFocus?.(t);((n&&t.includes(n)?n:void 0)??t[0]??this._init.surface).focus()}dismiss(){let e=this._previouslyFocused;this._previouslyFocused=null,e&&e.isConnected&&e.focus()}_onKeyDown(e){if(!this._init.isOpen())return;if(e.key===`Escape`){e.stopPropagation(),this._init.onEscape();return}if(e.key!==`Tab`)return;e.stopPropagation();let t=this.focusables();if(t.length===0){e.preventDefault(),this._init.surface.focus();return}let n=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&(i===n||i===this._init.surface||i===this._init.host)?(e.preventDefault(),r.focus()):!e.shiftKey&&(i===r||i===this._init.host)&&(e.preventDefault(),n.focus())}};function rowLabel(e){return stripMnemonic(C[e])}var AdwAboutDialog=class extends WidgetElement{_initialized=!1;_scrimEl;_sheetEl;_modal;_navView;_scrollEl;_mainToolbarEl;_developers=[];_designers=[];_artists=[];_documenters=[];_licenseState={...ye};_reflecting=!1;_creditSections=[];_acknowledgementSections=[];_legalSections=[];_links=[];_releaseNotesSegments=[];_toastOverlay;static get observedAttributes(){return[`application-name`,`application-icon`,`developer-name`,`version`,`comments`,`website`,`support-url`,`issue-url`,`copyright`,`license`,`license-type`,`license-url`,`translator-credits`,`release-notes`,`release-notes-version`,`debug-info`,`open`]}static new_from_appdata(e,t){refuseNewFromAppdata()}get applicationName(){return this.getAttribute(`application-name`)??``}set applicationName(e){this.setAttribute(`application-name`,e)}get applicationIcon(){return this.getAttribute(`application-icon`)??``}set applicationIcon(e){this.setAttribute(`application-icon`,e)}get developerName(){return this.getAttribute(`developer-name`)??``}set developerName(e){this.setAttribute(`developer-name`,e)}get version(){return this.getAttribute(`version`)??``}set version(e){this.setAttribute(`version`,e)}get comments(){return this.getAttribute(`comments`)??``}set comments(e){this.setAttribute(`comments`,e)}get website(){return this.getAttribute(`website`)??``}set website(e){this.setAttribute(`website`,e)}get supportUrl(){return this.getAttribute(`support-url`)??``}set supportUrl(e){this.setAttribute(`support-url`,e)}get issueUrl(){return this.getAttribute(`issue-url`)??``}set issueUrl(e){this.setAttribute(`issue-url`,e)}get copyright(){return this.getAttribute(`copyright`)??``}set copyright(e){this.setAttribute(`copyright`,e)}get license(){return this._licenseState.license}set license(e){this.setAttribute(`license`,e)}get licenseType(){return this._licenseState.licenseType}set licenseType(e){this.setAttribute(`license-type`,String(e))}get translatorCredits(){return this.getAttribute(`translator-credits`)??``}set translatorCredits(e){this.setAttribute(`translator-credits`,e)}get licenseUrl(){return this.getAttribute(`license-url`)??``}set licenseUrl(e){this.setAttribute(`license-url`,e)}get releaseNotes(){return this.getAttribute(`release-notes`)??``}set releaseNotes(e){this.setAttribute(`release-notes`,e)}get releaseNotesVersion(){return this.getAttribute(`release-notes-version`)??``}set releaseNotesVersion(e){this.setAttribute(`release-notes-version`,e)}get debugInfo(){return this.getAttribute(`debug-info`)??``}set debugInfo(e){this.setAttribute(`debug-info`,e)}add_link(e,t){this._links.push({title:e,url:t}),this._initialized&&this._render()}add_credit_section(e,t){this._creditSections.push({title:e,people:[...t]}),this._initialized&&this._render()}add_acknowledgement_section(e,t){this._acknowledgementSections.push({title:e,people:[...t]}),this._initialized&&this._render()}add_legal_section(e,t,n,r){isLicenseType(n)&&(this._legalSections.push({title:e,copyright:t,licenseType:n,license:r}),this._initialized&&this._render())}get open(){return this.hasAttribute(`open`)}set open(e){e?this.setAttribute(`open`,``):this.removeAttribute(`open`)}get developers(){return this._developers}set developers(e){this._developers=[...e],this._initialized&&this._render()}get designers(){return this._designers}set designers(e){this._designers=[...e],this._initialized&&this._render()}get artists(){return this._artists}set artists(e){this._artists=[...e],this._initialized&&this._render()}get documenters(){return this._documenters}set documenters(e){this._documenters=[...e],this._initialized&&this._render()}present(){this.open=!0}close(){this.open=!1}connectedCallback(){this._initialized||(this._initialized=!0,this._scrimEl=document.createElement(`div`),this._scrimEl.className=`adw-about-dialog-scrim`,this._scrimEl.addEventListener(`click`,()=>this.close()),this._sheetEl=document.createElement(`div`),this._sheetEl.className=`adw-about-dialog-sheet`,this._sheetEl.setAttribute(`aria-label`,C.dialogTitle),this._toastOverlay=document.createElement(`adw-toast-overlay`),this._sheetEl.appendChild(this._toastOverlay),this.replaceChildren(this._scrimEl,this._sheetEl),this._modal=new AdwModalSurface({host:this,surface:this._sheetEl,role:`dialog`,isOpen:()=>this.open,onEscape:()=>this.close()}),this._render())}attributeChangedCallback(e,t,n){if(t!==n){if(e===`license`||e===`license-type`){this._reflecting||this._applyLicenseAttribute(e,n),this._initialized&&!this._reflecting&&this._render();return}if((e===`release-notes`||e===`release-notes-version`)&&(this._releaseNotesSegments=releaseNotesBuffer({releaseNotes:this.releaseNotes,releaseNotesVersion:this.releaseNotesVersion,version:this.version},C).segments),this._initialized){if(e===`open`){this._syncOpen(),this.dispatchEvent(new CustomEvent(`notify::open`,{bubbles:!0,detail:{open:this.open}})),this.open||this.dispatchEvent(new CustomEvent(`closed`,{bubbles:!0}));return}this._render()}}}_applyLicenseAttribute(e,t){let n=e===`license`?setLicense(this._licenseState,t??``):setLicenseType(this._licenseState,this._parseLicenseType(t));this._licenseState=n.state,this._reflectLicense();for(let e of n.notify)this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{license:this._licenseState.license,licenseType:this._licenseState.licenseType}}))}_parseLicenseType(e){return e===null?S.UNKNOWN:/^-?\d+$/.test(e.trim())?Number(e):licenseTypeForNick(e.trim())??-1}_reflectLicense(){let{license:e,licenseType:t}=this._licenseState;this._reflecting=!0;try{e.length===0?this.removeAttribute(`license`):this.getAttribute(`license`)!==e&&this.setAttribute(`license`,e);let n=this.getAttribute(`license-type`);t===S.UNKNOWN?n!==null&&this.removeAttribute(`license-type`):(n===null||this._parseLicenseType(n)!==t)&&this.setAttribute(`license-type`,String(t))}finally{this._reflecting=!1}}_syncOpen(){this.classList.toggle(`open`,this.open),this.open?(this._navView.replace?.([`main`]),this._scrollEl.scrollTop=0,this._updateHeaderTitle(),this._modal.present()):this._modal.dismiss()}_creditsSections(){return creditsSections({developers:this._developers,designers:this._designers,artists:this._artists,documenters:this._documenters,translatorCredits:this.translatorCredits,creditSections:this._creditSections})}_legalInput(){return{copyright:this.copyright,licenseType:this._licenseState.licenseType,license:this._licenseState.license,legalSections:this._legalSections}}_render(){let e=this._creditsSections(),t=acknowledgementSections(this._acknowledgementSections),n=aboutDialogVisibility({applicationIcon:this.applicationIcon,applicationName:this.applicationName,developerName:this.developerName,version:this.version,comments:this.comments,website:this.website,supportUrl:this.supportUrl,issueUrl:this.issueUrl,debugInfo:this.debugInfo,releaseNotes:this.releaseNotes,hasCustomLinks:this._links.length>0,hasCredits:e.length>0,hasLegal:legalVisible(this._legalInput()),hasAcknowledgements:t.length>0});this._navView?.remove(),this._navView=document.createElement(`adw-navigation-view`),this._navView.append(this._buildMainPage(n)),n.whatsNewRow&&this._navView.append(this._buildWhatsNewPage()),n.detailsRow&&this._navView.append(this._buildDetailsPage(n)),n.troubleshootingRow&&this._navView.append(this._buildTroubleshootingPage(),this._buildDebugInfoPage()),n.creditsRow&&this._navView.append(this._buildCreditsPage(e)),n.legalRow&&this._navView.append(this._buildLegalPage()),n.acknowledgementsRow&&this._navView.append(this._buildAcknowledgementsPage(t)),(this._toastOverlay.querySelector(`:scope > .adw-toast-overlay-content`)??this._toastOverlay).appendChild(this._navView),this.classList.toggle(`open`,this.open)}_buildPage(e,t,n,r=t){let i=document.createElement(`adw-navigation-page`);i.setAttribute(`title`,t),i.setAttribute(`tag`,e);let a=document.createElement(`adw-header-bar`);if(a.setAttribute(`title`,r),n){let e=document.createElement(`button`);e.type=`button`,e.className=`adw-button flat circular adw-about-dialog-close`,e.setAttribute(`aria-label`,`Close`),e.addEventListener(`click`,()=>this.close());let endApply=()=>{let t=a.endSection??null;t&&t.appendChild(e)};queueMicrotask(endApply)}let o=document.createElement(`div`);o.className=`adw-about-dialog-scroll`;let s=document.createElement(`div`);s.className=`adw-about-dialog-clamp`;let c=document.createElement(`div`);c.className=`adw-about-dialog-page-body`,s.appendChild(c),o.appendChild(s);let l=document.createElement(`div`);return l.className=`adw-about-dialog-toolbar-view`,l.append(a,o),i.appendChild(l),e===`main`&&(this._scrollEl=o,this._mainToolbarEl=l,l.classList.add(`main-page`),o.addEventListener(`scroll`,()=>this._updateHeaderTitle())),{page:i,body:c,header:a}}_buildMainPage(e){let{page:t,body:n}=this._buildPage(`main`,C.dialogTitle,!0,this.applicationName);if(e.appIcon&&n.appendChild(createGtkImage(this.applicationIcon,`adw-about-dialog-icon`)),e.appName){let e=document.createElement(`span`);e.className=`adw-about-dialog-name`,e.textContent=this.applicationName,n.appendChild(e)}if(e.developerName){let e=document.createElement(`span`);e.className=`adw-about-dialog-developer`,e.textContent=this.developerName,n.appendChild(e)}if(e.version){let e=document.createElement(`span`);e.className=`adw-about-dialog-version`,e.textContent=this.version,n.appendChild(e)}let r=[];e.whatsNewRow&&r.push(this._buildNavRow(rowLabel(`whatsNewRow`),`whatsnew`)),e.detailsRow&&r.push(this._buildNavRow(rowLabel(`detailsRow`),`details`)),e.websiteRow&&r.push(this._buildLinkRow(rowLabel(`websiteRow`),this.website));let i=[];e.supportRow&&i.push(this._buildLinkRow(rowLabel(`supportRow`),this.supportUrl)),e.issueRow&&i.push(this._buildLinkRow(rowLabel(`issueRow`),this.issueUrl)),e.troubleshootingRow&&i.push(this._buildNavRow(rowLabel(`troubleshootingRow`),`troubleshooting`));let a=[];return e.creditsRow&&a.push(this._buildNavRow(rowLabel(`creditsRow`),`credits`)),e.legalRow&&a.push(this._buildNavRow(rowLabel(`legalRow`),`legal`)),e.acknowledgementsRow&&a.push(this._buildNavRow(rowLabel(`acknowledgementsRow`),`acknowledgements`)),e.detailsGroup&&n.appendChild(this._buildGroup(`details`,r)),e.supportGroup&&n.appendChild(this._buildGroup(`support`,i)),e.creditsLegalGroup&&n.appendChild(this._buildGroup(`credits-legal`,a)),t}_buildGroup(e,t,n){let r=document.createElement(`adw-preferences-group`);e!==null&&r.setAttribute(`data-group`,e),n!==void 0&&r.setAttribute(`title`,n);for(let e of t)r.appendChild(e);let i=document.createElement(`div`);return i.className=`adw-about-dialog-rows`,i.appendChild(r),i}_buildNavRow(e,t){let n=document.createElement(`adw-action-row`);n.setAttribute(`title`,e),n.setAttribute(`activatable`,``);let r=createGtkImage(`go-next`,`adw-about-dialog-chevron`);return r.setAttribute(`slot`,`suffix`),n.appendChild(r),n.addEventListener(`activated`,()=>{this._navView.push?.(t)}),n}_activateLink(e){let t=new CustomEvent(`activate-link`,{bubbles:!0,cancelable:!0,detail:{uri:e}});this.dispatchEvent(t)&&globalThis.open(e,`_blank`,`noopener,noreferrer`)}_buildDetailsPage(e){let{page:t,body:n}=this._buildPage(`details`,C.detailsPage,!1);if(e.commentsLabel){let e=document.createElement(`p`);e.className=`adw-about-dialog-comments`,e.textContent=this.comments,n.appendChild(e)}if(e.linksGroup){let t=[];e.detailsWebsiteRow&&t.push(this._buildLinkRow(rowLabel(`websiteRow`),this.website));for(let e of this._links)t.push(this._buildLinkRow(stripMnemonic(e.title),e.url));n.appendChild(this._buildGroup(`links`,t))}return t}_buildWhatsNewPage(){let{page:e,body:t}=this._buildPage(`whatsnew`,C.whatsNewPage,!1),n=document.createElement(`div`);n.className=`adw-about-dialog-release-notes`;for(let e of this._releaseNotesSegments){let t=document.createElement(`span`);e.tag!==null&&(t.dataset.tag=e.tag),t.textContent=e.text,n.appendChild(t)}return t.appendChild(n),e}_buildTroubleshootingPage(){let{page:e,body:t}=this._buildPage(`troubleshooting`,C.troubleshootingPage,!1),n=document.createElement(`p`);return n.className=`adw-about-dialog-comments`,n.textContent=C.troubleshootingIntro,t.append(n,this._buildGroup(null,[this._buildNavRow(rowLabel(`debugInfoRow`),`debuginfo`)])),e}_buildDebugInfoPage(){let{page:e,body:t}=this._buildPage(`debuginfo`,C.debugInfoPage,!1),n=document.createElement(`pre`);n.className=`adw-about-dialog-debug-info`,n.textContent=this.debugInfo;let r=document.createElement(`button`);return r.type=`button`,r.className=`adw-button pill adw-about-dialog-copy`,r.textContent=rowLabel(`copyText`),r.addEventListener(`click`,()=>this._copyProperty(this.debugInfo)),t.append(n,r),e}_copyProperty(e){e.length!==0&&(Promise.resolve(Lr.writeText(e)).catch(()=>void 0),this._toastOverlay.add_toast(new Toast({title:C.copiedToast})))}_buildLinkRow(e,t){let n=document.createElement(`adw-action-row`);return n.setAttribute(`title`,e),this._makeLinkRow(n,t),n}_makeLinkRow(e,t){e.setAttribute(`activatable`,``),e.setAttribute(`role`,`link`),e.classList.add(`link`,`adw-about-dialog-link-row`);let n=linkRowTooltip(t);n!==null&&e.setAttribute(`tooltip-text`,n);let r=createGtkImage(linkRowIconName(t),`adw-about-dialog-link-icon`);r.setAttribute(`slot`,`suffix`),r.setAttribute(`aria-hidden`,`true`),e.appendChild(r),e.addEventListener(`activated`,()=>this._activateLink(t))}_buildCreditsPage(e){return this._buildCreditGroupsPage(`credits`,C.creditsPage,e)}_buildAcknowledgementsPage(e){return this._buildCreditGroupsPage(`acknowledgements`,C.acknowledgementsPage,e)}_buildCreditGroupsPage(e,t,n){let{page:r,body:i}=this._buildPage(e,t,!1);for(let e of n){let t=e.people.map(e=>this._buildCreditRow(e));i.appendChild(this._buildGroup(null,t,e.title??void 0))}return r}_buildCreditRow(e){let t=document.createElement(`adw-action-row`);if(t.setAttribute(`title`,e.name),e.link!==null){let n=e.uri??``;this._makeLinkRow(t,n)}return t}_buildLegalPage(){let{page:e,body:t}=this._buildPage(`legal`,C.legalPage,!1),n=this._legalInput(),r=legalSections(n),i=legalSectionVisible(n.copyright,n.licenseType,n.license);for(let[e,a]of r.entries()){if(a.title!==null){let e=document.createElement(`p`);e.className=`adw-about-dialog-legal-title`,e.textContent=a.title,t.appendChild(e)}let r=document.createElement(`p`);r.className=`adw-about-dialog-license`,e===0&&i&&this.licenseUrl&&n.licenseType===S.CUSTOM?(this._renderLegalLabel(r,this.copyright),this.copyright.length>0&&r.append(`
|
|
17
17
|
|
|
18
|
-
`),r.append(this._buildLicenseUrlLink())):this._renderLegalLabel(r,a.markup),a.markup.length>0&&t.appendChild(r)}return e}_buildLicenseUrlLink(){let e=this.licenseUrl,t=document.createElement(`a`);return t.href=e,t.rel=`noopener noreferrer`,t.textContent=this.license,t.addEventListener(`click`,t=>{t.preventDefault(),this._activateLink(e)}),t}_renderLegalLabel(e,t){e.replaceChildren();let n=/<a\s+href="([^\x22]*)">([\s\S]*?)<\/a>/g,r=0,text=t=>{if(t.length===0)return;let n=document.createElement(`span`);renderPangoMarkup(n,t),e.appendChild(n)};for(let i of t.matchAll(n)){text(t.slice(r,i.index)),r=i.index+i[0].length;let n=i[1].replace(/&/g,`&`),a=document.createElement(`a`);renderPangoMarkup(a,i[2]),/^(https?:|mailto:)/i.test(n)&&(a.href=n,a.rel=`noopener noreferrer`,a.addEventListener(`click`,e=>{e.preventDefault(),this._activateLink(n)})),e.appendChild(a)}text(t.slice(r))}_updateHeaderTitle(){!this._scrollEl||!this._mainToolbarEl||this._mainToolbarEl.classList.toggle(`scrolled`,this._scrollEl.scrollTop>0)}};customElements.define(`adw-about-dialog`,AdwAboutDialog);function bindEmptySections(...e){let derive=()=>{for(let t of e)t.hidden=t.childElementCount===0},t=new MutationObserver(derive);for(let n of e)t.observe(n,{childList:!0});derive()}function applyRowTooltip(e,t){let n=e.getAttribute(`tooltip-text`)??``;for(let e of t)n?(e.getAttribute(`title`)!==n&&e.setAttribute(`title`,n),e.hasAttribute(Jr)||e.setAttribute(Jr,``)):(e.removeAttribute(`title`),e.removeAttribute(Jr))}const Jr=`data-row-tooltip`;function attachRowActivation(e){let{row:t,activatable:n}=e,r=e.activate??(()=>t.click());t.addEventListener(`keydown`,e=>{e.target===t&&n()&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),r()))});let sync=()=>{n()?t.tabIndex=0:t.removeAttribute(`tabindex`)};return sync(),{sync}}function applyRowLineClamp(e){let{titleEl:t,subtitleEl:n,textContainerEl:r,getTitleLines:i,getSubtitleLines:a}=e,o=i(),s=a(),c=o>0,l=s>0,u=c||l;r.classList.toggle(`adw-row-clamp`,u),c?t.style.setProperty(`--adw-row-title-lines`,String(o)):t.style.removeProperty(`--adw-row-title-lines`),l?n.style.setProperty(`--adw-row-subtitle-lines`,String(s)):n.style.removeProperty(`--adw-row-subtitle-lines`),u?r.style.setProperty(`--adw-row-ellipsize-overflow`,`ellipsis`):r.style.removeProperty(`--adw-row-ellipsize-overflow`)}function parseRowLinesAttribute(e){if(e===null||e===``)return 0;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:0}const Yr=[`disabled`,`aria-disabled`];function isSensitive(e){return e.disabled===!0?!1:e.getAttribute(`aria-disabled`)!==`true`}var AdwActionRow=class extends TooltipElement{static signals={activated:`activated`};_titleEl;_subtitleEl;_suffixEl;_prefixEl;_textEl;_state=new ActionRowState;_sensitivityObserver=null;_initialized=!1;_activation;static get observedAttributes(){return[`title`,`subtitle`,`activatable`,`tooltip-text`,`title-lines`,`subtitle-lines`]}get suffixSection(){return this._suffixEl}get prefixSection(){return this._prefixEl}get activatableWidget(){return this._state.activatableWidget}set activatableWidget(e){this._state.setActivatableWidget(e,e?isSensitive(e):!0)&&(this._observeSensitivity(e),this._syncActivatable())}get activatable(){return this._state.activatable}constructor(){super(),installElementApi(this)}connectedCallback(){if(this._initialized){this._observeSensitivity(this._state.activatableWidget);return}this._initialized=!0,this._prefixEl=document.createElement(`div`),this._prefixEl.className=`adw-action-row-prefix`;let e=document.createElement(`div`);e.className=`adw-row-text`,this._textEl=e,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-row-title`,this._subtitleEl=document.createElement(`span`),this._subtitleEl.className=`adw-row-subtitle`,e.append(this._titleEl,this._subtitleEl),this._suffixEl=document.createElement(`div`),this._suffixEl.className=`adw-action-row-suffix`,bindSlottedChildren(this,[{name:`prefix`,into:this._prefixEl},{name:`suffix`,into:this._suffixEl}]).install(this._prefixEl,e,this._suffixEl),bindEmptySections(this._prefixEl,this._suffixEl),this._adoptAttributes(),this._render(),this.addEventListener(`click`,e=>this._onClick(e)),this._activation=attachRowActivation({row:this,activatable:()=>this._state.activatable})}_adoptAttributes(){this._state.setTitle(this.getAttribute(`title`)),this._state.setSubtitle(this.getAttribute(`subtitle`)),this._state.setActivatable(this.hasAttribute(`activatable`)),this._applyLineClamping()}disconnectedCallback(){this._sensitivityObserver?.disconnect(),this._sensitivityObserver=null}attributeChangedCallback(){this._initialized&&(this._adoptAttributes(),this._render())}_onClick(e){if(!this._state.activatable)return;let t=this._state.activate();t&&e.target instanceof Node&&t.contains(e.target)||(t?.click(),this.dispatchEvent(new CustomEvent(`activated`,{bubbles:!0})))}_observeSensitivity(e){if(this._sensitivityObserver?.disconnect(),!e){this._sensitivityObserver=null;return}this._sensitivityObserver??=new MutationObserver(()=>{let e=this._state.activatableWidget;e&&this._state.setActivatableWidgetSensitive(isSensitive(e))&&this._syncActivatable()}),this._sensitivityObserver.observe(e,{attributeFilter:Yr})}_syncActivatable(){this.toggleAttribute(`activatable`,this._state.activatable),this._initialized&&this._render()}_render(){let{title:e,titleVisible:t,subtitle:n,subtitleVisible:r}=this._state.state;this._titleEl.textContent=e,this._titleEl.hidden=!t,this._subtitleEl.textContent=n,this._subtitleEl.hidden=!r,this.classList.toggle(`activatable`,this._state.activatable),applyRowTooltip(this,[this._prefixEl,this._textEl,this._suffixEl]),this._activation?.sync()}_applyLineClamping(){applyRowLineClamp({titleEl:this._titleEl,subtitleEl:this._subtitleEl,textContainerEl:this._titleEl.parentElement,getTitleLines:()=>parseRowLinesAttribute(this.getAttribute(`title-lines`)),getSubtitleLines:()=>parseRowLinesAttribute(this.getAttribute(`subtitle-lines`))})}};customElements.define(`adw-action-row`,AdwActionRow);var AdwAlertResponse=class extends WidgetElement{static get observedAttributes(){return[`id`,`appearance`,`enabled`]}},AdwAlertDialog=class extends WidgetElement{static signals={response:`response`,...Object.fromEntries([`heading`,`body`,`heading-use-markup`,`body-use-markup`,`close-response`,`default-response`,`prefer-wide-layout`].map(e=>[`notify::${e}`,`notify::${e}`]))};_initialized=!1;_attachedByPresent=!1;_scrimEl;_dialogEl;_headingEl;_bodyEl;_childEl;_responseAreaEl;_modal;_model=new AdwAlertResponses;_buttons=new Map;_blockCloseResponse=!1;constructor(e){super(),installElementApi(this);for(let[t,n]of Object.entries(e??{})){if(n===void 0)continue;let e=propertyOf(t);if(!(e in this))throw Error(`No property ${t} on <adw-alert-dialog>`);this[e]=n}}static get observedAttributes(){return[`heading`,`body`,`heading-use-markup`,`body-use-markup`,`close-response`,`default-response`,`open`,`prefer-wide-layout`]}get heading(){return this.getAttribute(`heading`)??``}set heading(e){this.setAttribute(`heading`,e)}get body(){return this.getAttribute(`body`)??``}set body(e){this.setAttribute(`body`,e)}get open(){return this.hasAttribute(`open`)}set open(e){e?this.setAttribute(`open`,``):this.removeAttribute(`open`)}get headingUseMarkup(){return this.hasAttribute(`heading-use-markup`)}set headingUseMarkup(e){e?this.setAttribute(`heading-use-markup`,``):this.removeAttribute(`heading-use-markup`)}get bodyUseMarkup(){return this.hasAttribute(`body-use-markup`)}set bodyUseMarkup(e){e?this.setAttribute(`body-use-markup`,``):this.removeAttribute(`body-use-markup`)}get preferWideLayout(){return this.hasAttribute(`prefer-wide-layout`)}set preferWideLayout(e){e?this.setAttribute(`prefer-wide-layout`,``):this.removeAttribute(`prefer-wide-layout`)}get defaultResponse(){return this._model.defaultResponse}set defaultResponse(e){this.set_default_response(e)}get closeResponse(){return this._model.closeResponse}set closeResponse(e){this.set_close_response(e)}connectedCallback(){if(this._initialized)return;this._initialized=!0,this._scrimEl=document.createElement(`div`),this._scrimEl.className=`adw-alert-dialog-scrim`,this._scrimEl.addEventListener(`click`,()=>this._dismiss()),this._dialogEl=document.createElement(`div`),this._dialogEl.className=`adw-alert-dialog-box`,this._dialogEl.addEventListener(`click`,e=>e.stopPropagation()),this._modal=new AdwModalSurface({host:this,surface:this._dialogEl,role:`alertdialog`,isOpen:()=>this.open,onEscape:()=>this._dismiss(),initialFocus:e=>this._initialFocusTarget(e)});let e=document.createElement(`div`);e.className=`adw-alert-dialog-message`,this._headingEl=document.createElement(`h2`),this._headingEl.className=`adw-alert-dialog-heading`,this._bodyEl=document.createElement(`p`),this._bodyEl.className=`adw-alert-dialog-body`,this._childEl=document.createElement(`div`),this._childEl.className=`adw-alert-dialog-child`,e.append(this._headingEl,this._bodyEl,this._childEl),this._responseAreaEl=document.createElement(`div`),this._responseAreaEl.className=`adw-alert-dialog-responses`,this._responseAreaEl.append(...this._buttons.values()),this._dialogEl.append(e,this._responseAreaEl),bindSlottedChildren(this,[{claims:e=>e instanceof Element&&e.localName===`adw-alert-response`,consume:e=>this._adoptResponse(e)},{name:`extra-child`,into:this._childEl},{into:this._childEl}]).install(this._scrimEl,this._dialogEl),bindEmptySections(this._childEl),this._model.heading=this.heading,this._model.body=this.body;let t=this.getAttribute(`close-response`);t!==null&&(this._model.closeResponse=t);let n=this.getAttribute(`default-response`);n!==null&&(this._model.defaultResponse=n),this._render()}_adoptResponse(e){let t=e.getAttribute(`id`);if(!t)return;let n=e.getAttribute(`appearance`)??`default`;this.add_response(t,(e.textContent??``).trim()),n!=="default"&&this.set_response_appearance(t,n),booleanAttribute$2(e.getAttribute(`enabled`),!0)||this.set_response_enabled(t,!1)}attributeChangedCallback(e,t,n){this._initialized&&t!==n&&(this._render(),e===`heading`?(this._model.heading=this.heading,this.dispatchEvent(new CustomEvent(`notify::heading`,{bubbles:!0,detail:{heading:this.heading}}))):e===`body`?(this._model.body=this.body,this.dispatchEvent(new CustomEvent(`notify::body`,{bubbles:!0,detail:{body:this.body}}))):e===`close-response`?n!==null&&this.set_close_response(n):e===`default-response`?this.set_default_response(n):e===`open`&&(this.dispatchEvent(new CustomEvent(`notify::open`,{bubbles:!0,detail:{open:this.open}})),this.open?this._modal.present():(this._modal.dismiss(),this._attachedByPresent&&(this._attachedByPresent=!1,this.remove()))))}present(e){this.isConnected||(document.body.appendChild(this),this._attachedByPresent=!0),this.open=!0}add_response(e,t){if(this._model.hasResponse(e)){console.warn(`[adw-alert-dialog] Trying to add a response with id '${e}', but such a response already exists`);return}let n=document.createElement(`button`);n.type=`button`,n.className=`adw-button adw-alert-dialog-response`,n.textContent=t,n.addEventListener(`click`,()=>this._activateResponse(e)),this._model.addResponse(e,t),this._buttons.set(e,n),this._responseAreaEl&&this._responseAreaEl.appendChild(n),this._render()}remove_response(e){if(!this._model.hasResponse(e)){console.warn(`[adw-alert-dialog] Trying to remove a response with id '${e}', but such a response does not exist`);return}this._buttons.get(e)?.remove(),this._buttons.delete(e);let t=this._model.responses.filter(t=>t.id!==e),n=new AdwAlertResponses(this._model.heading,this._model.body);for(let e of t)n.addResponse(e.id,e.label,{appearance:e.appearance,enabled:e.enabled});n.closeResponse=this._model.closeResponse,n.defaultResponse=this._model.defaultResponse===e?null:this._model.defaultResponse,this._model=n,this._render()}has_response(e){return this._model.hasResponse(e)}get_response_label(e){return this._model.responses.find(t=>t.id===e)?.label??null}set_response_label(e,t){let n=this._buttons.get(e);n&&(this._model.addResponse(e,t),n.textContent=t)}get_response_appearance(e){return this._model.hasResponse(e)?this._model.getResponseAppearance(e):null}set_response_appearance(e,t){let n=this._buttons.get(e);n&&(this._model.setResponseAppearance(e,t),n.classList.toggle(`suggested-action`,t===`suggested`),n.classList.toggle(`destructive-action`,t===`destructive`))}get_response_enabled(e){return this._model.hasResponse(e)?this._model.getResponseEnabled(e):!1}set_response_enabled(e,t){let n=this._buttons.get(e);n&&(this._model.setResponseEnabled(e,t),n.disabled=!t)}get_default_response(){return this._model.defaultResponse}set_default_response(e){this._model.defaultResponse=e,this._render()}get_close_response(){return this._model.closeResponse}set_close_response(e){this._model.closeResponse=e}get_heading(){return this.heading}set_heading(e){this.heading=e}get_body(){return this.body}set_body(e){this.body=e}_activateResponse(e){this._model.getResponseEnabled(e)&&(this._blockCloseResponse=!0,this.open=!1,this._blockCloseResponse=!1,this._emitResponse(this._model.resolveById(e)))}_dismiss(){this.open&&(this.open=!1,!this._blockCloseResponse&&this._emitResponse(this._model.resolveById(null)))}_emitResponse(e){dispatchElement(this,`response`,[e])}_initialFocusTarget(e){return e.find(e=>this._childEl.contains(e))??this._defaultResponseButton()}_defaultResponseButton(){let e=this._model.defaultResponse,t=this._model.responses.find(e=>e.enabled)?.id;return(e!==null&&this._model.getResponseEnabled(e)?this._buttons.get(e):void 0)??(t?this._buttons.get(t):void 0)}_render(){if(!this._initialized)return;this.classList.toggle(`open`,this.open);let e=this.heading;this.headingUseMarkup?renderPangoMarkup(this._headingEl,e):this._headingEl.textContent=e,this._headingEl.hidden=e.length===0;let t=this.body;this.bodyUseMarkup?renderPangoMarkup(this._bodyEl,t):this._bodyEl.textContent=t,this._bodyEl.hidden=t.length===0;let n=this.preferWideLayout&&this._model.responses.length<=2;this._responseAreaEl.classList.toggle(`horizontal`,n);let r=this._model.defaultResponse;for(let e of this._model.responses){let t=e.id===r&&e.appearance==="default";this._buttons.get(e.id)?.classList.toggle(`default-response`,t)}}};customElements.define(`adw-alert-response`,AdwAlertResponse),customElements.define(`adw-alert-dialog`,AdwAlertDialog);function requested(e,t,n){let r=Number.parseFloat(e.getAttribute(t)??``);return Number.isFinite(r)&&r>=0?r:n}function fillsContainingBlock(e){return[`maximized`,`fullscreened`].some(t=>e.hasAttribute(t)&&e.getAttribute(t)!==`false`)}var AdwWindowFeatures=class{_host;_contentEl=null;_breakpoints=[];_disposeBreakpoints=null;_openDialogs=[];constructor(e){this._host=e}get contentArea(){return this._contentEl}get content(){return this._contentEl?.firstElementChild??null}set content(e){e&&this._contentEl?.appendChild(e)}get breakpoints(){return this._breakpoints}get currentBreakpoint(){return this._breakpoints.find(e=>e.applied)??null}get dialogs(){return this._openDialogs=this._openDialogs.filter(e=>e.isConnected),this._openDialogs}get visibleDialog(){let e=this.dialogs;return e.length>0?e[e.length-1]:null}adopt(e){this._contentEl===null&&(this._contentEl=e,e.classList.add(`adw-window-content`),this._host.addEventListener(`notify::open`,e=>{let t=e.target;t!==this._host&&(t.hasAttribute(`open`)?this._openDialogs.includes(t)||this._openDialogs.push(t):this._openDialogs=this._openDialogs.filter(e=>e!==t))}))}addBreakpoint(e){let t=this._host,n=new AdwBreakpoint(e,{onApply:()=>t.dataset.breakpoint=e,onUnapply:()=>{t.dataset.breakpoint===e&&delete t.dataset.breakpoint}});return this._breakpoints.push(n),this.bind(),n}bind(){this._disposeBreakpoints?.(),this._disposeBreakpoints=null,this._contentEl!==null&&this._breakpoints.length>0&&(this._disposeBreakpoints=addBreakpoints(this._host,this._breakpoints))}release(){this._disposeBreakpoints?.(),this._disposeBreakpoints=null}applySizeRequest(){let e=this._host;e.style.minWidth=`${requested(e,`width-request`,360)}px`,e.style.minHeight=`${requested(e,`height-request`,200)}px`;let t=fillsContainingBlock(e),n=t?null:e.getAttribute(`default-width`)??e.getAttribute(`width`),r=t?null:e.getAttribute(`default-height`)??e.getAttribute(`height`);n?e.style.width=`${n}px`:e.style.removeProperty(`width`),r?e.style.height=`${r}px`:e.style.removeProperty(`height`)}};const Xr={minimize:{className:`minimize`,icon:`window-minimize-symbolic`,label:`Minimize`,action:`minimize`},maximize:{className:`maximize`,icon:`window-maximize-symbolic`,label:`Maximize`,action:`toggle-maximized`},close:{className:`close`,icon:`window-close-symbolic`,label:`Close`,action:`close`}},Zr=[`decoration-layout`,`deletable`,`icon-name`,`maximized`,`modal`,`resizable`,`transient-for`];var GtkWindowControls=class extends WidgetElement{_initialized=!1;_empty=!0;_window=null;_windowObserver=null;static get observedAttributes(){return[`decoration-layout`,`side`,`use-native-controls`]}get side(){return this.getAttribute(`side`)===`end`?`end`:`start`}set side(e){this._write(`side`,e)}get useNativeControls(){return this.hasAttribute(`use-native-controls`)}get empty(){return this._empty}_write(e,t){this.getAttribute(e)!==t&&this.setAttribute(e,t)}connectedCallback(){if(this._initialized){this._followWindow();return}this._initialized=!0,this.setAttribute(`role`,`group`),this._followWindow()}disconnectedCallback(){this._windowObserver?.disconnect(),this._windowObserver=null,this._window=null}attributeChangedCallback(e){this._initialized&&(this._render(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:this._property(e)}})))}_property(e){return e===`side`?this.side:this.hasAttribute(e)}_followWindow(){this._windowObserver?.disconnect(),this._applyEmptyClass(),this._window=this.closest(`gtk-window, adw-window`),this._window!==null&&(this._windowObserver??=new MutationObserver(()=>this._render()),this._windowObserver.observe(this._window,{attributes:!0,attributeFilter:Zr})),this._render()}_isSovereign(e){return!e.hasAttribute(`modal`)&&!e.hasAttribute(`transient-for`)}_windowFlag(e,t){return e.getAttribute(t)!==`false`}_layoutHalf(){let e=this.getAttribute(`decoration-layout`)??this._window?.getAttribute(`decoration-layout`)??`:minimize,maximize,close`;if(e===``)return null;let t=e.indexOf(`:`);return t===-1?e:this.side===`start`?e.slice(0,t):e.slice(t+1)}_render(){this.classList.toggle(`start`,this.side===`start`),this.classList.toggle(`end`,this.side===`end`),this.replaceChildren(),this._applyEmptyClass();let e=this._window;if(e===null){this._setEmpty(!0);return}let t=this._isSovereign(e),n=this._layoutHalf();if(n===null){this._setEmpty(!0);return}let r=!0;for(let i of n.split(`,`)){let n=this._buttonFor(i,e,t);n!==null&&(this.appendChild(n),r=!1)}this._setEmpty(r)}_applyEmptyClass(){this.classList.toggle(`empty`,this._empty)}_buttonFor(e,t,n){if(e===`icon`)return n?this._windowIcon(t):null;if(e===`minimize`)return n?this._controlButton(Xr.minimize):null;if(e===`maximize`){if(!n||!this._windowFlag(t,`resizable`))return null;let e=t.hasAttribute(`maximized`)&&t.getAttribute(`maximized`)!==`false`;return this._controlButton(e?{...Xr.maximize,icon:`window-restore-symbolic`,label:`Restore`}:Xr.maximize)}return e===`close`&&this._windowFlag(t,`deletable`)?this._controlButton(Xr.close):null}_windowIcon(e){let t=e.getAttribute(`icon-name`);return t===null||t===``?null:createGtkImage(t,`icon`)}_controlButton(e){let t=document.createElement(`button`);return t.className=`adw-window-controls-button ${e.className}`,t.setAttribute(`aria-label`,e.label),t.title=e.label,t.appendChild(createGtkImage(e.icon)),t.addEventListener(`click`,()=>this.dispatchEvent(new CustomEvent(`window-action`,{bubbles:!0,detail:{action:e.action}}))),t}_setEmpty(e){e!==this._empty&&(this._empty=e,this._applyEmptyClass(),this.dispatchEvent(new CustomEvent(`notify::empty`,{bubbles:!0,detail:{empty:e}})))}};customElements.define(`gtk-window-controls`,GtkWindowControls);var GtkWindow=class extends WidgetElement{_initialized=!1;_titlebar;_content;_startControls=null;_endControls=null;_titleLabel=null;_titlebarObserver=null;_members=new WindowMemberState(e=>this._notifyMember(e));_closing=new CloseRequestState;_syncActive=()=>void this._members.reportActive(this._documentIsActive());_onFocusIn=e=>{e.target instanceof Element&&this._members.reportFocus(e.target)};_onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&this.contains(t)||t===null&&!document.hasFocus()||this._members.reportFocus(null)};static signals={"close-request":`close-request`,...Object.fromEntries([`application`,`decorated`,`default-height`,`default-width`,`deletable`,`focus-widget`,`fullscreened`,`hide-on-close`,`icon-name`,`is-active`,`maximized`,`modal`,`resizable`,`title`,`transient-for`].map(e=>[`notify::${e}`,`notify::${e}`]))};constructor(){super(),installElementApi(this);let e=this.emit;Object.defineProperty(this,"emit",{configurable:!0,writable:!0,value:(t,...n)=>{if(t===`close-request`)throw Error(`<gtk-window>.emit('close-request') is not supported; call close()`);e(t,...n)}})}static get observedAttributes(){return[`decorated`,`default-width`,`default-height`,`deletable`,`fullscreened`,`hide-on-close`,`icon-name`,`maximized`,`modal`,`resizable`,`title`,`transient-for`,`hidden`]}get title(){return this.getAttribute(`title`)??``}set title(e){this._write(`title`,e)}get decorated(){return this._onByDefault(`decorated`)}set decorated(e){this._write(`decorated`,String(e))}get maximized(){return this._offByDefault(`maximized`)}set maximized(e){this._write(`maximized`,String(e))}get fullscreened(){return this._offByDefault(`fullscreened`)}set fullscreened(e){this._write(`fullscreened`,String(e))}get resizable(){return this._onByDefault(`resizable`)}set resizable(e){this._write(`resizable`,String(e))}get deletable(){return this._onByDefault(`deletable`)}set deletable(e){this._write(`deletable`,String(e))}get hide_on_close(){return this._offByDefault(`hide-on-close`)}set hide_on_close(e){this._offByDefault(`hide-on-close`)!==e&&this._write(`hide-on-close`,String(e))}get_hide_on_close(){return this.hide_on_close}set_hide_on_close(e){this.hide_on_close=e}_write(e,t){t===null?this.removeAttribute(e):this.getAttribute(e)!==t&&this.setAttribute(e,t)}_onByDefault(e){return this.getAttribute(e)!==`false`}_offByDefault(e){return this.hasAttribute(e)&&this.getAttribute(e)!==`false`}connectedCallback(){if(this._initialized){this._watchActivity(),this._watchTitlebar(),this._render();return}this._initialized=!0,this._watchActivity(),this._titlebar=document.createElement(`div`),this._titlebar.className=`adw-gtk-window-titlebar`,this._content=document.createElement(`div`),this._content.className=`adw-gtk-window-content`,bindSlottedChildren(this,[...this.hasTitlebar()?[{name:`titlebar`,into:this._titlebar},{name:`child`,into:this._content}]:[],...this.extraSlots(),{into:this._content}]).install(...this.strips()),this.addEventListener(`window-action`,e=>this._onWindowAction(e)),this._watchTitlebar(),this._render()}disconnectedCallback(){this._titlebarObserver?.disconnect(),this._titlebarObserver=null,globalThis.removeEventListener(`focus`,this._syncActive),globalThis.removeEventListener(`blur`,this._syncActive),document.removeEventListener(`visibilitychange`,this._syncActive),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this._members.reportActive(!1),this._members.reportFocus(null)}_watchActivity(){globalThis.addEventListener(`focus`,this._syncActive),globalThis.addEventListener(`blur`,this._syncActive),document.addEventListener(`visibilitychange`,this._syncActive),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),this._syncActive()}_documentIsActive(){return this.isConnected&&!this.hidden&&document.visibilityState!==`hidden`&&document.hasFocus()}_notifyMember(e){let t=e===`is-active`?this._members.active:e===`focus-widget`?this._members.focus:this.maximized;this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:t}}))}_watchTitlebar(){this._titlebarObserver?.disconnect(),this._titlebarObserver=new MutationObserver(()=>this._render()),this._titlebarObserver.observe(this._titlebar,{childList:!0})}strips(){return[this._titlebar,this._content]}hasTitlebar(){return!0}extraSlots(){return[]}attributeChangedCallback(e){if(e===`hidden`){this._syncActive();return}this._initialized&&this._render(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:this._property(e)}}))}_property(e){if(e===`default-width`||e===`default-height`){let t=Number.parseFloat(this.getAttribute(e)??``);return Number.isFinite(t)?t:null}return e===`title`||e===`icon-name`||e===`transient-for`?this.getAttribute(e):e===`decorated`||e===`resizable`||e===`deletable`?this._onByDefault(e):this._offByDefault(e)}_render(){this._titlebar.hidden=!this.decorated,this.classList.toggle(`maximized`,this.decorated&&this.maximized),this.classList.toggle(`fullscreen`,this.decorated&&this._offByDefault(`fullscreened`)),this.renderFrameSize();let e=this.getAttribute(`title`);e===null?this.removeAttribute(`aria-label`):this.setAttribute(`aria-label`,e),this._renderTitlebar()}renderFrameSize(){let e=fillsContainingBlock(this),t=Number.parseFloat(this.getAttribute(`default-width`)??``),n=Number.parseFloat(this.getAttribute(`default-height`)??``);for(let[r,i]of[[`width`,t],[`height`,n]])!e&&Number.isFinite(i)&&i>0?this.style.setProperty(r,`${i}px`):this.style.removeProperty(r)}_renderTitlebar(){if([...this._titlebar.children].some(e=>e!==this._startControls&&e!==this._endControls&&e!==this._titleLabel)){for(let e of[this._startControls,this._endControls,this._titleLabel])e?.remove();this._startControls=null,this._endControls=null,this._titleLabel=null;return}if(!this.decorated||!this.hasTitlebar())return;this._startControls===null&&(this._startControls=document.createElement(`gtk-window-controls`),this._startControls.setAttribute(`side`,`start`),this._endControls=document.createElement(`gtk-window-controls`),this._endControls.setAttribute(`side`,`end`),this._titleLabel=document.createElement(`span`),this._titleLabel.className=`adw-gtk-window-title`,this._titlebar.append(this._startControls,this._titleLabel,this._endControls));let e=this.getAttribute(`title`);e===null?this._titleLabel?.removeAttribute(`title`):this._titleLabel?.setAttribute(`title`,e??``)}_onWindowAction(e){let t=e.detail?.action;if(t===`toggle-maximized`){this._write(`maximized`,String(!this._offByDefault(`maximized`)));return}t===`close`&&this.close()}close(){let e=this._closing.close({realized:this.isConnected,hideOnClose:this.hide_on_close,emit:()=>{let e=new CustomEvent(`close-request`,{bubbles:!0,cancelable:!0});return this.dispatchEvent(e),e.defaultPrevented},hide:()=>void(this.hidden=!0),destroy:()=>this.remove()});return e===`hidden`||e===`destroyed`}present(){this.hidden=!1}get isActive(){return this._members.active}get is_active(){return this._members.active}get focusWidget(){return this.get_focus()}get focus_widget(){return this.get_focus()}set focus_widget(e){this.set_focus(e)}get_focus(){let e=document.activeElement;return e!==null&&e!==this&&this.contains(e)?e:null}set_focus(e){if(e===null){let e=this.get_focus();(e instanceof HTMLElement||e instanceof SVGElement)&&e.blur(),this._members.reportFocus(null);return}if(e===this||!this.contains(e))throw Error(`<gtk-window>.set_focus: the widget is not inside this window`);(e instanceof HTMLElement||e instanceof SVGElement)&&e.focus(),this._members.reportFocus(this.get_focus())}get_default_size(){let read=e=>{let t=Number.parseInt(this.getAttribute(e)??``,10);return Number.isFinite(t)?t:0};return[read(`default-width`),read(`default-height`)]}set_default_size(e,t){let n=stepDefaultSize(this.get_default_size(),e,t);if(n!==null)for(let e of n.changed)this._write(e,String(e===`default-width`?n.width:n.height))}is_maximized(){return this.maximized}maximize(){this._write(`maximized`,`true`)}unmaximize(){this._write(`maximized`,`false`)}is_fullscreen(){return this.fullscreened}fullscreen(){this._write(`fullscreened`,`true`)}unfullscreen(){this._write(`fullscreened`,`false`)}};customElements.define(`gtk-window`,GtkWindow),defineWindowApplication(GtkWindow.prototype);var GtkApplicationWindow=class extends GtkWindow{_menubar=null;_menubarObserver=null;static signals={...GtkWindow.signals,"notify::show-menubar":`notify::show-menubar`};static get observedAttributes(){return[...GtkWindow.observedAttributes,`show-menubar`]}get showMenubar(){return this.getAttribute(`show-menubar`)===`true`}set showMenubar(e){this._write(`show-menubar`,String(e))}menubarSection(){if(this._menubar===null){let e=document.createElement(`div`);e.className=`adw-gtk-application-window-menubar`,this._menubar=e}return this._menubar}strips(){return[this._titlebar,this.menubarSection(),this._content]}extraSlots(){return[{name:`menubar`,into:this.menubarSection()}]}connectedCallback(){super.connectedCallback(),this._followMenubar()}disconnectedCallback(){this._menubarObserver?.disconnect(),this._menubarObserver=null}attributeChangedCallback(e){super.attributeChangedCallback(e),e===`show-menubar`&&this._renderMenubar()}_followMenubar(){this._menubarObserver?.disconnect(),this._menubarObserver=new MutationObserver(()=>this._renderMenubar()),this._menubarObserver.observe(this.menubarSection(),{childList:!0}),this._renderMenubar()}_renderMenubar(){let e=this.menubarSection();e.hidden=!this.showMenubar||e.childElementCount===0}};customElements.define(`gtk-application-window`,GtkApplicationWindow),installActionMap(GtkApplicationWindow.prototype);var AdwApplicationWindow=class extends GtkApplicationWindow{_features=new AdwWindowFeatures(this);_model=[];_menubarEl=null;static get observedAttributes(){return[...GtkApplicationWindow.observedAttributes,`width`,`height`,`width-request`,`height-request`,`menu-model`]}get contentArea(){return this._content}get content(){return this._features.content}set content(e){this._features.content=e}get breakpoints(){return this._features.breakpoints}get currentBreakpoint(){return this._features.currentBreakpoint}get dialogs(){return this._features.dialogs}get visibleDialog(){return this._features.visibleDialog}addBreakpoint(e){return this._features.addBreakpoint(e)}get showMenubar(){return this.hasAttribute(`show-menubar`)}set showMenubar(e){e?this.setAttribute(`show-menubar`,``):this.removeAttribute(`show-menubar`)}get menuModel(){return this._model}set menuModel(e){this._model=normalizeMenuModel(e),this._renderMenubar()}get menubar(){return this._menubarEl}connectedCallback(){super.connectedCallback(),this._features.adopt(this._content),this._features.bind()}disconnectedCallback(){this._features.release(),super.disconnectedCallback()}attributeChangedCallback(e){if(e===`width`||e===`height`||e===`width-request`||e===`height-request`){this.renderFrameSize();return}super.attributeChangedCallback(e),e===`menu-model`&&(this._model=parseMenuModel(this.getAttribute(`menu-model`)),this._renderMenubar())}hasTitlebar(){return!1}strips(){return[this._content]}extraSlots(){return[{name:`content`,into:this._content}]}renderFrameSize(){this._features.applySizeRequest()}_followMenubar(){this._menubarEl===null&&(this._menubarEl=document.createElement(`div`),this._menubarEl.className=`adw-application-window-menubar`,this._content.prepend(this._menubarEl)),this._renderMenubar()}menubarSection(){return this._menubarEl??super.menubarSection()}_renderMenubar(){let e=this._menubarEl;if(e!==null){e.replaceChildren(),e.hidden=!this.showMenubar||this._model.length===0;for(let t of flattenMenu(this._model)){let n=t.node;if(n.kind===`submenu`){let t=document.createElement(`gtk-menu-button`);t.setAttribute(`menu-title`,n.label),t.menuModel=n.items,e.appendChild(t);continue}let r=document.createElement(`gtk-button`);r.setAttribute(`label`,n.label??``),r.setAttribute(`flat`,``),r.addEventListener(`click`,()=>{this.dispatchEvent(new CustomEvent(`menu-item-activated`,{bubbles:!0,detail:{id:n.id??n.label,label:n.label,path:[...t.path]}}))}),e.appendChild(r)}}}};customElements.define(`adw-application-window`,AdwApplicationWindow);var AdwAvatar=class extends WidgetElement{_textEl;_iconEl;_imageEl;_initialized=!1;static get observedAttributes(){return[`text`,`size`,`show-initials`,`icon`,`custom-image`]}connectedCallback(){this._initialized||(this._initialized=!0,this._textEl=document.createElement(`span`),this._textEl.className=`adw-avatar-text`,this._iconEl=createGtkImage(null,`adw-avatar-icon`),this._imageEl=document.createElement(`img`),this._imageEl.className=`adw-avatar-custom-image`,this._imageEl.alt=``,this.replaceChildren(this._textEl,this._iconEl,this._imageEl),this._render())}attributeChangedCallback(){this._initialized&&this._render()}_render(){let e=parseFloat(this.getAttribute(`size`)||`48`);this.style.width=`${e}px`,this.style.height=`${e}px`;let t=this.getAttribute(`text`)??``,n=this.getAttribute(`custom-image`)??``,r=avatarMode({hasCustomImage:n.length>0,showInitials:this.hasAttribute(`show-initials`),text:t});if(this._imageEl.hidden=r!==`image`,r===`image`)this._imageEl.getAttribute(`src`)!==n&&(this._imageEl.src=n),this.style.backgroundImage=``,this.style.color=``,this._textEl.hidden=!0,this._iconEl.hidden=!0;else if(r===`initials`){let{fg:n,start:r,stop:i}=avatarColor(t);this.style.backgroundImage=`linear-gradient(${r}, ${i})`,this.style.color=n,this._textEl.textContent=avatarInitials(t),this._textEl.hidden=!1,this._iconEl.hidden=!0,this._applyFontSize(e)}else this.style.backgroundImage=``,this.style.color=``,this._textEl.hidden=!0,this._iconEl.iconName=this.getAttribute(`icon`)??`avatar-default`,this._iconEl.size=avatarIconSize(e),this._iconEl.hidden=!1}_applyFontSize(e){let t=avatarMaxFontSize(e);this._textEl.style.fontSize=`${t}px`;let{width:n,height:r}=this._textEl.getBoundingClientRect();this._textEl.style.fontSize=`${avatarFontSize(e,{width:n,height:r})}px`}};customElements.define(`adw-avatar`,AdwAvatar);var AdwBanner=class extends WidgetElement{_titleEl;_button;_initialized=!1;static get observedAttributes(){return[`title`,`button-label`,`revealed`,`use-markup`,`button-style`]}connectedCallback(){this._initialized||(this._initialized=!0,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-banner-title`,this._button=document.createElement(`button`),this._button.className=`adw-banner-button`,this._button.addEventListener(`click`,()=>{this.dispatchEvent(new CustomEvent(`button-clicked`,{bubbles:!0}))}),this.replaceChildren(this._titleEl,this._button),this._render())}attributeChangedCallback(){this._initialized&&this._render()}_render(){let e=this.getAttribute(`title`)??``;this.hasAttribute(`use-markup`)?renderPangoMarkup(this._titleEl,e):this._titleEl.textContent=e;let t=this.getAttribute(`button-label`)??``;this._button.textContent=bannerButtonText(t),this._button.hidden=!bannerButtonVisible(t);let n=bannerButtonStyleClasses(parseBannerButtonStyle(this.getAttribute(`button-style`)));for(let e of ft)this._button.classList.toggle(e,n.includes(e));this.classList.toggle(`revealed`,this.hasAttribute(`revealed`))}};customElements.define(`adw-banner`,AdwBanner);var AdwBin=class extends WidgetElement{_observer=null;get child(){return this.lastElementChild}set child(e){this.setChild(e)}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}]),this._enforceSingleChild(),this._observer??=new MutationObserver(()=>this._enforceSingleChild()),this._observer.observe(this,{childList:!0})}disconnectedCallback(){this._observer?.disconnect()}_enforceSingleChild(){let e=this.lastElementChild;if(e!==null)for(let t of Array.from(this.children)){if(t===e)break;t.remove()}}setChild(e){if(e!==null&&e.parentElement!==null&&e.parentElement!==this)throw Error(`AdwBin.setChild: the child already has a parent.`);if(e===this.child)return;let t=this.child;e===null?t?.remove():this.replaceChildren(e),this.dispatchEvent(new CustomEvent(`notify::child`,{bubbles:!0,detail:{child:e}}))}};customElements.define(`adw-bin`,AdwBin);var AdwBottomSheetContent=class extends WidgetElement{},AdwBottomSheetSheet=class extends WidgetElement{},AdwBottomSheetBottomBar=class extends WidgetElement{},AdwBottomSheet=class extends WidgetElement{static signals={"notify::open":`notify::open`};_initialized=!1;_contentEl;_dimmingEl;_sheetEl;_sheetBodyEl;_bottomBarEl;_dragHandleEl;_pendingBottomBar=null;_state=new BottomSheetPresentation;_reflecting=!1;static get observedAttributes(){return[`open`,`modal`,`can-close`,`can-open`,`reveal-bottom-bar`,`show-drag-handle`]}get open(){return this._state.open}set open(e){this._setOpen(!!e)}get modal(){return this._state.modal}set modal(e){this._setBoolAttr(`modal`,e)}get_modal(){return this.modal}set_modal(e){this.modal=e}get canClose(){return this._state.canClose}set canClose(e){this._setBoolAttr(`can-close`,e)}get canOpen(){return this._state.canOpen}set canOpen(e){this._setBoolAttr(`can-open`,e)}get revealBottomBar(){return this._state.revealBottomBar}set revealBottomBar(e){this._setBoolAttr(`reveal-bottom-bar`,e)}get showDragHandle(){return this._boolAttr(`show-drag-handle`,!0)}set showDragHandle(e){this._setBoolAttr(`show-drag-handle`,e)}get bottomBar(){return this._initialized?this._bottomBarEl.firstChild:this._pendingBottomBar}setBottomBar(e){if(this._state.setHasBottomBar(e!==null),!this._initialized){this._pendingBottomBar=e;return}e?this._bottomBarEl.replaceChildren(e):this._bottomBarEl.replaceChildren(),this._render()}requestOpen(e){return this._state.requestOpen(e)}requestClose(e){let t=this._state.requestClose(e);return t===`close-attempt`?this.dispatchEvent(new CustomEvent(`close-attempt`,{bubbles:!0})):t===`delegate`&&this.dispatchEvent(new CustomEvent(`sheet.close`,{bubbles:!0})),t}constructor(){super(),installElementApi(this)}connectedCallback(){if(this._initialized)return;this._initialized=!0,this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-bottom-sheet-content`,this._dimmingEl=document.createElement(`div`),this._dimmingEl.className=`adw-bottom-sheet-dimming`,this._dimmingEl.addEventListener(`click`,()=>this.requestClose(`dimming`)),this._sheetEl=document.createElement(`div`),this._sheetEl.className=`adw-bottom-sheet-sheet`,this._dragHandleEl=document.createElement(`div`),this._dragHandleEl.className=`adw-bottom-sheet-drag-handle`,this._dragHandleEl.setAttribute(`aria-hidden`,`true`),this._sheetBodyEl=document.createElement(`div`),this._sheetBodyEl.className=`adw-bottom-sheet-sheet-body`,this._bottomBarEl=document.createElement(`button`),this._bottomBarEl.type=`button`,this._bottomBarEl.className=`adw-bottom-sheet-bottom-bar`,this._bottomBarEl.addEventListener(`click`,()=>this.requestOpen(`bottom-bar`)),this._sheetEl.append(this._bottomBarEl,this._dragHandleEl,this._sheetBodyEl);let layer=(e,t)=>({claims:t=>t instanceof Element&&t.localName===e,consume:e=>{for(let n of Array.from(e.childNodes))t.appendChild(n)}});bindSlottedChildren(this,[{name:`sheet`,into:this._sheetBodyEl},{name:`bottom-bar`,into:this._bottomBarEl},{name:`content`,into:this._contentEl},layer(`adw-bottom-sheet-sheet`,this._sheetBodyEl),layer(`adw-bottom-sheet-bottom-bar`,this._bottomBarEl),layer(`adw-bottom-sheet-content`,this._contentEl),{into:this._contentEl}],(e,t)=>{!(`into`in t)||t.into!==this._bottomBarEl||(this._state.setHasBottomBar(!0),this._render())}).install(this._contentEl,this._dimmingEl,this._sheetEl),this._pendingBottomBar&&this._bottomBarEl.replaceChildren(this._pendingBottomBar),this._pendingBottomBar=null,this.addEventListener(`keydown`,e=>{e.key===`Escape`&&(!this.open&&!this._sheetEl.contains(e.target)||(e.stopPropagation(),this.requestClose(`escape`)))}),this._state.setCanClose(this._boolAttr(`can-close`,!0)),this._state.setCanOpen(this._boolAttr(`can-open`,!0)),this._state.setRevealBottomBar(this._boolAttr(`reveal-bottom-bar`,!0)),this._state.setHasBottomBar(this._bottomBarEl.childNodes.length>0),this._state.setOpen(this._boolAttr(`open`,!1)),this._state.subscribe(e=>{this._render(),this.dispatchEvent(new CustomEvent(`notify::open`,{bubbles:!0,detail:{open:e}}))}),this._render()}attributeChangedCallback(e,t,n){if(!this._reflecting&&t!==n){if(e===`open`){this._state.setOpen(this._boolAttr(`open`,!1));return}e===`modal`&&this._state.setModal(this._boolAttr(`modal`,!0)),e===`can-close`&&this._state.setCanClose(this._boolAttr(`can-close`,!0)),e===`can-open`&&this._state.setCanOpen(this._boolAttr(`can-open`,!0)),e===`reveal-bottom-bar`&&this._state.setRevealBottomBar(this._boolAttr(`reveal-bottom-bar`,!0)),this._initialized&&this._render()}}_setOpen(e){this._state.setOpen(e)&&(this._initialized||this._reflectOpen(e))}_render(){let e=this._state.open,t=this._state.chrome,n=t.layer===`bottom-bar`;this._reflectOpen(e),this.classList.toggle(`open`,e),this.classList.toggle(`modal`,this._state.modal),this.classList.toggle(`has-drag-handle`,this.showDragHandle),this.classList.toggle(`showing-bottom-bar`,n&&t.surfaceVisible),this._dimmingEl.classList.toggle(`visible`,t.dimmed),this._bottomBarEl.hidden=!n,this._bottomBarEl.classList.toggle(`inert`,t.bottomBarInert),this._sheetBodyEl.hidden=n,this._dragHandleEl.hidden=!this.showDragHandle||n}_reflectOpen(e){this._reflecting=!0,e?this.setAttribute(`open`,``):this.removeAttribute(`open`),this._reflecting=!1}_boolAttr(e,t){let n=this.getAttribute(e);return n===null?t:n!==`false`}_setBoolAttr(e,t){t?this.setAttribute(e,``):this.setAttribute(e,`false`)}};customElements.define(`adw-bottom-sheet-content`,AdwBottomSheetContent),customElements.define(`adw-bottom-sheet-sheet`,AdwBottomSheetSheet),customElements.define(`adw-bottom-sheet-bottom-bar`,AdwBottomSheetBottomBar),customElements.define(`adw-bottom-sheet`,AdwBottomSheet);function parseBreakpoints(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return console.error("<adw-breakpoint-bin>: `breakpoints` is not JSON; no breakpoint is applied."),[]}return Array.isArray(t)?t.flatMap(e=>{if(typeof e!=`object`||!e)return[];let{condition:t,setters:n}=e;return typeof t==`string`?[{condition:t,setters:Array.isArray(n)?n:[]}]:[]}):[]}var AdwBreakpointBin=class extends WidgetElement{_state=new BreakpointBinState;_dispose;_applied=null;_pendingSync=!1;_originals=new Map;static get observedAttributes(){return[`breakpoints`]}get currentBreakpoint(){return this._state.current}get currentBreakpointAttribute(){let e=this._state.current;return e===null?null:String(e)}get child(){return this.firstElementChild}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}]),this.setAttribute(`role`,`group`),this.style.display=`block`,this._syncSizing(),this._pendingSync=!0,this._observe()}disconnectedCallback(){this._dispose?.(),this._dispose=void 0}attributeChangedCallback(e){e!==`breakpoints`||!this.isConnected||(this._originals.clear(),this._syncBreakpoints())}_syncBreakpoints(){this._pendingSync=!1;let e=parseBreakpoints(this.getAttribute(`breakpoints`));this._state=new BreakpointBinState;for(let t of e){let e=[];for(let n of t.setters){if(typeof n?.target!=`string`||typeof n.property!=`string`)continue;let t=this.querySelector(n.target);if(t===null)continue;let r=`${n.target}\u0000${n.property}\u0000${n.value}`;this._originals.has(r)||this._originals.set(r,t.getAttribute(n.property)),e.push({object:t,property:n.property,value:n.value,originalValue:this._originals.get(r)??null})}this._state.add({condition:t.condition,setters:e})}this._state.inherit(this._applied),this._state.setHasChild(this.child!==null),this._write(this._state.current),this._syncSizing()}_observe(){this._dispose?.(),this._dispose=observeAdaptiveSize(this,e=>{this._pendingSync&&this._syncBreakpoints(),this._state.setHasChild(this.child!==null);let t=this._state.evaluate(e);t!==null&&(this._emit(t.from,`breakpoint-unapply`),this._perform(t.writes),this._write(t.to),this._emit(t.to,`breakpoint-apply`),this.dispatchEvent(new CustomEvent(`notify::current-breakpoint`,{bubbles:!0,detail:{currentBreakpoint:this.currentBreakpointAttribute}})))})}_perform(e){for(let t of e)t.value===null?t.object.removeAttribute(t.property):t.object.setAttribute(t.property,String(t.value))}_write(e){this._applied=e}_emit(e,t){e!==null&&this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:{index:e}}))}_syncSizing(){let e=this._state.length>0;this.style.minWidth=e?`0px`:``,this.style.minHeight=e?`0px`:``,e&&(this.style.overflow=`hidden`)}};customElements.define(`adw-breakpoint-bin`,AdwBreakpointBin);var AdwButtonContent=class extends WidgetElement{_boxEl;_iconEl;_labelEl;_initialized=!1;_styledHost=null;static get observedAttributes(){return[`icon-name`,`label`,`use-underline`,`can-shrink`]}connectedCallback(){this._initialized||(this._initialized=!0,this._boxEl=document.createElement(`div`),this._boxEl.className=`adw-button-content-box`,this._iconEl=createGtkImage(null),this._labelEl=document.createElement(`span`),this._labelEl.className=`adw-button-content-label`,this._boxEl.append(this._iconEl,this._labelEl),this.replaceChildren(this._boxEl),this._render()),this._root()}disconnectedCallback(){this._unroot()}attributeChangedCallback(e){this._initialized&&(this._render(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0})))}_hostButton(){let e=this.parentElement?.closest(`button, .adw-button`)??null;if(!e)return null;let t=e.parentElement;return t?.matches(`adw-split-button, .adw-split-button`)?t:e}_root(){let e=this._hostButton();e!==this._styledHost&&(this._unroot(),e&&(e.classList.add(gt),this._styledHost=e))}_unroot(){this._styledHost?.classList.remove(gt),this._styledHost=null}_render(){this._iconEl.iconName=buttonContentIconName(this.getAttribute(`icon-name`)??``),this._iconEl.hidden=!1;let e=this.getAttribute(`label`)??``;this._labelEl.textContent=buttonContentLabelText(e,this.hasAttribute(`use-underline`)),this._labelEl.hidden=e.length===0,this.classList.toggle(`can-shrink`,this.hasAttribute(`can-shrink`))}};customElements.define(`adw-button-content`,AdwButtonContent);var AdwButtonRow=class extends TooltipElement{_contentsEl;_startIconEl;_endIconEl;_titleEl;_state=new ButtonRowState;_initialized=!1;static get observedAttributes(){return[`title`,`start-icon-name`,`end-icon-name`,`tooltip-text`]}connectedCallback(){this._initialized||(this._contentsEl=document.createElement(`div`),this._contentsEl.className=`adw-button-row-contents`,this._startIconEl=createGtkImage(null,`start`),this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-button-row-title`,this._endIconEl=createGtkImage(null,`end`),this._contentsEl.append(this._startIconEl,this._titleEl,this._endIconEl),this.replaceChildren(this._contentsEl),this._initialized=!0,this._render(),this.addEventListener(`click`,()=>{this.dispatchEvent(new CustomEvent(`activated`,{bubbles:!0}))}),attachRowActivation({row:this,activatable:()=>!0}))}attributeChangedCallback(){this._initialized&&this._render()}_render(){this._state.setTitle(this.getAttribute(`title`)),this._state.setStartIconName(this.getAttribute(`start-icon-name`)),this._state.setEndIconName(this.getAttribute(`end-icon-name`));let e=this._state.state;this._titleEl.textContent=e.title,this._titleEl.hidden=!e.titleVisible,this._paintIcon(this._startIconEl,e.startIconName,e.startIconVisible),this._paintIcon(this._endIconEl,e.endIconName,e.endIconVisible),this.classList.toggle(`activatable`,!0),applyRowTooltip(this,[this._contentsEl])}_paintIcon(e,t,n){e.iconName=n?t:null,e.hidden=!n}};customElements.define(`adw-button-row`,AdwButtonRow);function attachSwipeDrag(e){let t=new SwipeTracker({points:e.points,allowLongSwipes:e.allowLongSwipes,cancelProgress:e.cancelProgress}),n=null,r=0,i=0,a=0,o=0,s=0,c=`none`,l=null,u=!1,axisOffset=(t,n)=>e.orientation===`vertical`?n:t,progressOffset=(e,t)=>-axisOffset(e,t),release=()=>{let r=n;n=null,c=`none`,t.reset(),globalThis.removeEventListener(`pointermove`,onMove,!0),globalThis.removeEventListener(`pointerup`,onFinish,!0),globalThis.removeEventListener(`pointercancel`,onCancel,!0),globalThis.removeEventListener(`lostpointercapture`,onLostCapture,!0),r!==null&&e.host.hasPointerCapture(r)&&e.host.releasePointerCapture(r),l!==null&&(e.host.style.scrollSnapType=l.scrollSnapType,e.host.style.scrollBehavior=l.scrollBehavior,e.host.style.userSelect=l.userSelect,l=null)},claimAllowed=t=>{let n=e.points();if(n.length===0)return!1;let a=n[0],c=n[n.length-1];if(Math.abs(a-c)<2**-52)return!1;let l=e.progress(),u=t<0&&(Math.abs(l-a)<2**-52||l<a),d=t>0&&(Math.abs(l-c)<2**-52||l>c);return u||d?!1:e.claimable===void 0?!0:e.claimable({x:r,y:i})||e.claimable({x:o,y:s})},claim=()=>{c=`scrolling`,n!==null&&e.host.setPointerCapture(n),l={scrollSnapType:e.host.style.scrollSnapType,scrollBehavior:e.host.style.scrollBehavior,userSelect:e.host.style.userSelect},e.host.style.scrollSnapType=`none`,e.host.style.scrollBehavior=`auto`,e.host.style.userSelect=`none`},arm=()=>{globalThis.addEventListener(`pointermove`,onMove,!0),globalThis.addEventListener(`pointerup`,onFinish,!0),globalThis.addEventListener(`pointercancel`,onCancel,!0),globalThis.addEventListener(`lostpointercapture`,onLostCapture,!0)};e.host.addEventListener(`pointerdown`,t=>{if(u=!1,n!==null){if(t.pointerId!==n)return;release()}t.pointerType!==`mouse`||t.button!==0||e.enabled()&&t.target?.closest(`select, textarea, input[type="range"], [contenteditable=""], [contenteditable="true"]`)===null&&(n=t.pointerId,r=t.clientX,i=t.clientY,o=t.clientX,s=t.clientY,a=0,c=`pending`,arm())});function onMove(l){if(n!==l.pointerId)return;o=l.clientX,s=l.clientY;let u=l.clientX-r,d=l.clientY-i,f=progressOffset(u,d),p=f-a;a=f;let m=Math.trunc(l.timeStamp);if(t.record(p,m),!(l.buttons&1)){release();return}if(c===`pending`){if(Math.abs(d)>Math.abs(u)!=(e.orientation===`vertical`)){release();return}if(Math.hypot(u,d)<16)return;if(!claimAllowed(f)){release();return}t.prepare(e.progress()),claim(),a=f;return}c===`scrolling`&&(l.preventDefault(),e.onUpdate(t.advance(p,e.pitch())))}function finish(r,i){if(n!==r.pointerId)return;if(c!==`scrolling`){release();return}i&&t.cancel();let{to:a,velocity:o}=t.end(Math.trunc(r.timeStamp));release(),u=!0,e.onEnd(a,o)}function onFinish(e){finish(e,!1)}function onCancel(e){finish(e,!0)}function onLostCapture(e){finish(e,!1)}return e.host.addEventListener(`click`,e=>{u&&(u=!1,e.stopPropagation(),e.preventDefault())},{capture:!0}),{get dragging(){return c===`scrolling`}}}function wheelSource(e){if(e.deltaMode!==0)return`mouse`;let t=Math.abs(e.deltaY),n=Math.abs(e.deltaX);if(n>0&&t>0)return`touchpad`;let r=Math.max(n,t);return!Number.isInteger(r)||r<40?`touchpad`:`mouse`}var AdwCarousel=class extends WidgetElement{_state=new CarouselState({animateScroll:!0,onScrollTo:e=>this._performScroll(e)});_trackEl;_slots=new Map;_nextPageId=0;_scrollRaf=0;_initialized=!1;_pendingPosition=null;_pendingLayout;_layoutObserver;_pendingInteractive=null;_scrollTargetId=null;_drag;_pendingScrollPage=null;static get observedAttributes(){return[`allow-scroll-wheel`,`allow-mouse-drag`,`allow-long-swipes`,`interactive`,`spacing`,`position`]}constructor(){super(),this._state.subscribe(e=>this._onStateChange(e)),this._state.onPageChanged(e=>{this.dispatchEvent(new CustomEvent(`page-changed`,{bubbles:!0,detail:{index:e}}))})}get nPages(){return this._state.nPages}get position(){return this._state.position}set position(e){this._scrollToPosition(e)}get currentPage(){return this._state.pageAt(this._state.position)}get allowMouseDrag(){return this._state.allowMouseDrag}set allowMouseDrag(e){this.setAttribute(`allow-mouse-drag`,e?`true`:`false`)}get allowScrollWheel(){return this._state.allowScrollWheel}set allowScrollWheel(e){this.setAttribute(`allow-scroll-wheel`,e?`true`:`false`)}get allowLongSwipes(){return this._state.allowLongSwipes}set allowLongSwipes(e){this.toggleAttribute(`allow-long-swipes`,e)}get interactive(){return this._state.interactive}set interactive(e){this.setAttribute(`interactive`,e?`true`:`false`)}get spacing(){return this._state.spacing}set spacing(e){this.setAttribute(`spacing`,String(e))}connectedCallback(){this._initialized||this._build(),this._observeLayout()}_build(){this._initialized=!0,this._trackEl=document.createElement(`div`),this._trackEl.className=`adw-carousel-track`,this._trackEl.style.setProperty(`scroll-behavior`,`smooth`),this._applyAttribute(`allow-scroll-wheel`,this.getAttribute(`allow-scroll-wheel`)),this._applyAttribute(`allow-mouse-drag`,this.getAttribute(`allow-mouse-drag`)),this._applyAttribute(`allow-long-swipes`,this.getAttribute(`allow-long-swipes`)),this._applyAttribute(`interactive`,this.getAttribute(`interactive`)),this._applyAttribute(`spacing`,this.getAttribute(`spacing`));let e=Array.from(this.children).filter(e=>e instanceof HTMLElement);this.replaceChildren(this._trackEl);for(let t of e)this._insert(t,-1);this._trackEl.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._trackEl.addEventListener(`wheel`,this._onWheel,{passive:!1}),this._drag=attachSwipeDrag({host:this._trackEl,orientation:`horizontal`,enabled:()=>this._state.interactive&&this._state.allowMouseDrag,pitch:()=>this._distance(),points:()=>this._state.snapPoints,progress:()=>this._state.position,allowLongSwipes:()=>this._state.allowLongSwipes,cancelProgress:()=>{let e=this._state.snapPoints;return e[carouselClosestSnapPoint(this._state.position,e)]??this._state.position},onUpdate:e=>{let t=this._distance();t>0&&(this._trackEl.scrollLeft=e*t)},onEnd:e=>{let t=this._distance();t>0&&this._trackEl.scrollTo({left:e*t})}}),this._applyAttribute(`position`,this.getAttribute(`position`));let t=this._pendingScrollPage;this._pendingScrollPage=null;let n=t?this._idOf(t):null;n!==null&&this._positionWhenMeasurable(this._state.indexOf(n))}attributeChangedCallback(e,t,n){this._initialized&&this._applyAttribute(e,n)}disconnectedCallback(){this._cancelPendingPosition(),this._layoutObserver?.disconnect(),this._layoutObserver=void 0}_observeLayout(){this._layoutObserver||(this._layoutObserver=new ResizeObserver(()=>{this._allocatePages()&&this._applyScrollFromModel()}),this._layoutObserver.observe(this._trackEl,{box:`border-box`}))}_applyAttribute(e,t){switch(e){case`allow-scroll-wheel`:this._state.setAllowScrollWheel(t!==`false`);return;case`allow-mouse-drag`:this._state.setAllowMouseDrag(t!==`false`);return;case`allow-long-swipes`:this._state.setAllowLongSwipes(t!==null&&t!==`false`),this._applySnapStop();return;case`interactive`:this._state.setInteractive(t!==`false`);return;case`spacing`:{let e=t===null?0:Number.parseFloat(t);Number.isFinite(e)&&this._state.setSpacing(Math.max(0,e)),this._trackEl.style.columnGap=`${this._state.spacing}px`;return}case`position`:t!==null&&this._positionWhenMeasurable(Number.parseFloat(t))}}_positionWhenMeasurable(e){if(Number.isFinite(e)){if(this._trackEl.clientWidth>0){this._cancelPendingPosition(),this._scrollInstantly(e);return}this._pendingPosition=e,!this._pendingLayout&&(this._pendingLayout=new ResizeObserver(()=>{if(this._trackEl.clientWidth<=0)return;let e=this._pendingPosition;this._cancelPendingPosition(),e!==null&&this._scrollInstantly(e)}),this._pendingLayout.observe(this._trackEl))}}_scrollInstantly(e){let t=this._trackEl.style.getPropertyValue(`scroll-behavior`);this._trackEl.style.setProperty(`scroll-behavior`,`auto`);try{this._scrollToPosition(e)}finally{t?this._trackEl.style.setProperty(`scroll-behavior`,t):this._trackEl.style.removeProperty(`scroll-behavior`)}}_cancelPendingPosition(){this._pendingLayout?.disconnect(),this._pendingLayout=void 0,this._pendingPosition=null}_scrollToPosition(e){if(!Number.isFinite(e))return;let t=this._state.pageAt(e);t>=0&&this.scrollToPage(t)}insertPage(e,t=-1){return this._initialized?this._insert(e,t):(this.appendChild(e),!0)}appendPage(e){return this.insertPage(e,-1)}prependPage(e){return this.insertPage(e,0)}removePage(e){let t=this._idOf(e);return t===null||!this._state.removePage(t)?!1:(this._state.skipReveal(t),this._syncTrack(),!0)}reorderPage(e,t){let n=this._idOf(e);return n===null||!this._state.reorderPage(n,t)?!1:(this._syncTrack(),!0)}scrollToPage(e){this._state.scrollTo(e)}navigate(e){return this._state.navigate(e)}scroll_to(e,t){if(!this._initialized){e.parentElement===this&&(this._pendingScrollPage=e);return}let n=this._idOf(e);n!==null&&this._state.scrollTo(this._state.indexOf(n),{animate:t})}get_nth_page(e){if(!this._initialized){let t=this.children[e];return Number.isInteger(e)&&t instanceof HTMLElement?t:null}if(!Number.isInteger(e)||e<0||e>=this._state.nPages)return null;let t=this._state.ids[e],n=t===void 0?null:this._slots.get(t)?.firstElementChild;return n instanceof HTMLElement?n:null}get_n_pages(){return this._initialized?this._state.nPages:this.children.length}get_position(){return this._state.position}_insert(e,t){let n=`page-${this._nextPageId++}`;if(!this._state.insertPage(n,t))return!1;let r=document.createElement(`div`);return r.className=`adw-carousel-page`,r.appendChild(e),this._slots.set(n,r),this._state.skipReveal(n),this._syncTrack(),!0}_idOf(e){for(let[t,n]of this._slots)if(n.contains(e))return t;return null}_syncTrack(){let e=this._state.ids,t=new Set(e);for(let[e,n]of this._slots)t.has(e)||(n.remove(),this._slots.delete(e));e.forEach((e,t)=>{let n=this._slots.get(e);n&&this._trackEl.children[t]!==n&&this._trackEl.insertBefore(n,this._trackEl.children[t]??null)}),this._applySnapStop(),this._allocatePages(),this._applyScrollFromModel()}_allocatePages(){let e=[...this._slots.values()];if(e.length===0)return!1;let t=e[0].getBoundingClientRect().width;this._trackEl.style.removeProperty(`padding-inline`);for(let t of e)t.style.removeProperty(`flex-basis`);let n=this._trackEl.clientWidth;if(!(n>0))return!1;let{pageSize:r,leadingInset:i}=carouselPageAllocation(n,e.map(e=>({natural:e.firstElementChild?.getBoundingClientRect().width??0})));if(!(r>0))return!1;for(let t of e)t.style.flexBasis=`${r}px`;return i>0&&(this._trackEl.style.paddingInline=`${i}px`),Math.round(r)!==Math.round(t)}_applyScrollFromModel(){let e=this._distance();e>0&&this._trackEl.scrollTo({left:this._restorePosition()*e,behavior:`instant`})}_restorePosition(){if(this._scrollTargetId===null)return this._state.position;let e=this._state.ids.indexOf(this._scrollTargetId);return e<0?this._state.position:this._state.snapPointOf(e)??this._state.position}_applySnapStop(){let e=this._state.allowLongSwipes?`normal`:`always`;for(let t of this._slots.values())t.style.setProperty(`scroll-snap-stop`,e)}_distance(){let e=this._trackEl?.firstElementChild;return e?this._state.pageDistance(e.getBoundingClientRect().width):0}_performScroll(e){if(!this._trackEl)return;let t=this._distance();if(t>0){if(!e.animate){this._pendingInteractive=null,this._scrollTargetId=null,this._trackEl.scrollTo({left:e.index*t,behavior:`instant`});return}this._pendingInteractive=e.interactive,this._scrollTargetId=this._state.ids[e.index]??null,this._trackEl.scrollTo({left:e.index*t})}}_onScroll=()=>{this._scrollRaf||=requestAnimationFrame(()=>{this._scrollRaf=0,this._updatePositionFromScroll()})};_onWheel=e=>{if(this._drag?.dragging===!0){e.preventDefault();return}this._state.handleWheel({deltaX:e.deltaX,deltaY:e.deltaY,source:wheelSource(e)})!==0&&e.preventDefault()};_updatePositionFromScroll(){let e=this._distance();if(!(e>0))return;let t=this._trackEl.scrollLeft/e;this._state.setPosition(t,this._pendingInteractive??!0)&&this._state.settleIfArrived()&&(this._pendingInteractive=null,this._scrollTargetId=null)}_onStateChange(e){if(e.reason===`n-pages`){this.dispatchEvent(new CustomEvent(`notify::n-pages`,{bubbles:!0,detail:{nPages:e.nPages}}));return}e.reason===`position`&&this.dispatchEvent(new CustomEvent(`notify::position`,{bubbles:!0,detail:{position:e.position,page:e.page,interactive:e.interactive}}))}},AdwCarouselIndicator=class extends WidgetElement{_carousel=null;_initialized=!1;static get observedAttributes(){return[`for`,`carousel`]}get carousel(){return this._carousel}set carousel(e){e!==this._carousel&&(this._detach(),this._carousel=e,this._attach())}connectedCallback(){this._initialized=!0,this._carousel||this._resolveForAttr(),this._attach(),this._render()}disconnectedCallback(){this._detach()}attributeChangedCallback(e){(e===`for`||e===`carousel`)&&this._initialized&&(this._detach(),this._carousel=null,this._resolveForAttr(),this._attach(),this._render())}_resolveForAttr(){let e=this.getAttribute(`carousel`)??this.getAttribute(`for`);if(!e)return;let t=this.getRootNode().getElementById?.(e)??document.getElementById(e);t instanceof AdwCarousel&&(this._carousel=t)}_attach(){!this._carousel||!this._initialized||(this._carousel.addEventListener(`notify::position`,this._onChange),this._carousel.addEventListener(`notify::n-pages`,this._onChange),this._render())}_detach(){this._carousel&&(this._carousel.removeEventListener(`notify::position`,this._onChange),this._carousel.removeEventListener(`notify::n-pages`,this._onChange))}_onChange=()=>{this._render()};nPages(){return this._carousel?.nPages??0}position(){return this._carousel?.position??0}currentPage(){return this._carousel?.currentPage??-1}goTo(e){this._carousel?.scrollToPage(e)}},AdwCarouselIndicatorDots=class extends AdwCarouselIndicator{_render(){renderIndicator(this,`adw-carousel-dot`,this.nPages(),this.position(),this.currentPage(),e=>this.goTo(e))}},AdwCarouselIndicatorLines=class extends AdwCarouselIndicator{_render(){renderIndicator(this,`adw-carousel-line`,this.nPages(),this.position(),this.currentPage(),e=>this.goTo(e))}};function renderIndicator(e,t,n,r,i,a){if(e.childElementCount!==n){let r=[];for(let e=0;e<n;e++){let n=document.createElement(`button`);n.type=`button`,n.className=t,n.setAttribute(`aria-label`,`Page ${e+1}`),n.addEventListener(`click`,()=>a(e)),r.push(n)}e.replaceChildren(...r)}Array.from(e.children).forEach((e,t)=>{let n=Math.max(0,1-Math.abs(r-t)),a=e;a.style.setProperty(`--adw-carousel-progress`,n.toFixed(3)),a.classList.toggle(`active`,t===i),a.setAttribute(`aria-current`,t===i?`true`:`false`)})}customElements.define(`adw-carousel`,AdwCarousel),customElements.define(`adw-carousel-indicator-dots`,AdwCarouselIndicatorDots),customElements.define(`adw-carousel-indicator-lines`,AdwCarouselIndicatorLines);var AdwClamp=class extends WidgetElement{_resize=null;_mutations=null;static get observedAttributes(){return[`maximum-size`,`tightening-threshold`]}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}]),this._resize=new ResizeObserver(()=>this._allocate()),this._resize.observe(this),this._mutations=new MutationObserver(()=>this._allocate()),this._mutations.observe(this,{childList:!0}),this._allocate()}disconnectedCallback(){this._resize?.disconnect(),this._resize=null,this._mutations?.disconnect(),this._mutations=null}attributeChangedCallback(){this._allocate()}_allocate(){let e={maximumSize:normalizeClampSize(this.getAttribute(`maximum-size`),xt.maximumSize),tighteningThreshold:normalizeClampSize(this.getAttribute(`tightening-threshold`),xt.tighteningThreshold),childMin:0,childNat:0},t=this.clientWidth,n=Array.from(this.children);if(t<=0){for(let e of n){e.style.maxWidth=``,e.style.marginInline=``;for(let t of St)e.classList.remove(t)}return}let{childSize:r,sizeClass:i}=clampAllocate(t,e);for(let e of n){e.style.maxWidth=`${r}px`,e.style.marginInline=`auto`;for(let t of St)e.classList.toggle(t,t===i)}}};customElements.define(`adw-clamp`,AdwClamp);const Qr={automatic:`auto`,always:`scroll`,never:`hidden`};var AdwClampScrollable=class extends WidgetElement{_resize=null;_mutations=null;static get observedAttributes(){return[`maximum-size`,`tightening-threshold`,`unit`,`orientation`,`hscroll-policy`,`vscroll-policy`]}get maximumSize(){return normalizeClampSize(this.getAttribute(`maximum-size`),xt.maximumSize)}set maximumSize(e){this.setAttribute(`maximum-size`,String(e))}get tighteningThreshold(){return normalizeClampSize(this.getAttribute(`tightening-threshold`),xt.tighteningThreshold)}set tighteningThreshold(e){this.setAttribute(`tightening-threshold`,String(e))}get unit(){return normalizeLengthUnit(this.getAttribute(`unit`),`sp`)}set unit(e){this.setAttribute(`unit`,e)}get orientation(){return normalizeBoxOrientation(this.getAttribute(`orientation`))}set orientation(e){this.setAttribute(`orientation`,e)}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}]),this._resize=new ResizeObserver(()=>this._allocate()),this._resize.observe(this),this._mutations=new MutationObserver(()=>this._allocate()),this._mutations.observe(this,{childList:!0}),this._applyOverflow(),this._allocate()}disconnectedCallback(){this._resize?.disconnect(),this._resize=null,this._mutations?.disconnect(),this._mutations=null}attributeChangedCallback(){this._applyOverflow(),this._allocate()}_applyOverflow(){let e=this.getAttribute(`hscroll-policy`),t=this.getAttribute(`vscroll-policy`);this.style.overflowX=e===null?`auto`:Qr[e]??`auto`,this.style.overflowY=t===null?`auto`:Qr[t]??`auto`}_allocate(){let e=this.orientation===`vertical`,t=this.unit,n=e?this.clientHeight:this.clientWidth,r={maximumSize:adwLengthToPx(t,this.maximumSize),tighteningThreshold:adwLengthToPx(t,this.tighteningThreshold),childMin:0,childNat:0};for(let t of Array.from(this.children)){if(n<=0){t.style.maxWidth=``,t.style.maxHeight=``,t.style.marginInline=``,t.style.marginBlock=``;for(let e of St)t.classList.remove(e);continue}let{childSize:i,sizeClass:a}=clampAllocate(n,r);e?(t.style.maxWidth=``,t.style.maxHeight=`${i}px`,t.style.marginInline=``,t.style.marginBlock=`auto`):(t.style.maxWidth=`${i}px`,t.style.maxHeight=``,t.style.marginInline=`auto`,t.style.marginBlock=``);for(let e of St)t.classList.toggle(e,e===a)}}};customElements.define(`adw-clamp-scrollable`,AdwClampScrollable);function stringListSlot(e){return{name:`model`,consume:t=>e(parseListModel(t instanceof Element?t.getAttribute(`strings`):null))}}var AdwComboRow=class extends TooltipElement{_select;_valueEl;_textEl;_titleEl;_subtitleEl;_state=new ComboState;_authored=Mt.new(null);_initialized=!1;static get observedAttributes(){return[`title`,`subtitle`,`model`,`selected`,`tooltip-text`,`title-lines`,`subtitle-lines`]}get model(){return this._state.model}set model(e){this._state.setModel(readModelWrite(e,this._authored))}get options(){return this._state.options}set_model(e){this.model=e}get_model(){return this.model}get selected(){return this._initialized?this._state.selectedIndex:parseInt(this.getAttribute(`selected`)||`0`,10)}set selected(e){this.setAttribute(`selected`,String(e))}get_selected(){return this.selected}set_selected(e){this.selected=e}get selectedValue(){return this._state.selectedValue}set selectedValue(e){let t=this._state.options.findIndex(t=>t.value===e);t>=0&&(this.selected=t)}get selectedItem(){return this._state.selectedItem}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=document.createElement(`div`);e.className=`adw-row-text`,this._textEl=e,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-row-title`,this._subtitleEl=document.createElement(`span`),this._subtitleEl.className=`adw-row-subtitle`,e.append(this._titleEl,this._subtitleEl),this._valueEl=document.createElement(`span`),this._valueEl.className=`adw-row-value`,this._select=document.createElement(`select`),bindSlottedChildren(this,[stringListSlot(e=>{this._authored.reconcile(e),this._state.setModel(this._authored)})]).install(e,this._valueEl,this._select);let t=this.getAttribute(`model`);this._state.model===null&&t!==null&&(this._authored.reconcile(parseListModel(t)),this._state.setModel(this._authored)),this._state.setSelectedIndex(parseInt(this.getAttribute(`selected`)||`0`,10)),this._state.subscribeItems(e=>this._applyItemsChanged(e)),this._state.subscribe(e=>{this._valueEl.textContent=e.label,this._select.selectedIndex!==e.selected&&(this._select.selectedIndex=e.selected),this._syncChooser(),e.interactive&&(this.setAttribute(`selected`,String(e.selected)),this.dispatchEvent(new CustomEvent(`notify::selected`,{bubbles:!0,detail:{selected:e.selected}})))}),this._select.addEventListener(`change`,()=>{this._state.select(this._select.selectedIndex)}),this._renderOptions(),this._renderText()}attributeChangedCallback(e,t,n){this._initialized&&(e===`model`?this.model=n:e===`selected`?this._state.setSelectedIndex(parseInt(n||`0`,10)):this._renderText())}_createOption(e){let t=document.createElement(`option`);return t.value=e.value,t.textContent=e.label,t}_applyItemsChanged(e){if(!this._initialized)return;for(let t=0;t<e.removed;t++)this._select.remove(e.position);let t=this._select.options[e.position]??null,n=this._state.options;for(let r=0;r<e.added;r++){let i=n[e.position+r];i&&this._select.insertBefore(this._createOption(i),t)}}_renderOptions(){this._initialized&&(this._select.replaceChildren(...this._state.options.map(e=>this._createOption(e))),this._select.selectedIndex=this._state.selectedIndex,this._valueEl.textContent=this._state.selectedLabel,this._syncChooser())}_syncChooser(){let e=this._state.presentsChooser;this.dataset.presentsChooser=e?`true`:`false`,this._select.disabled=!e}_renderText(){let e=deriveRowLabels({title:this.getAttribute(`title`),subtitle:this.getAttribute(`subtitle`)});this._titleEl.textContent=e.title,this._titleEl.hidden=!e.titleVisible,this._subtitleEl.textContent=e.subtitle,this._subtitleEl.hidden=!e.subtitleVisible,applyRowTooltip(this,[this._textEl,this._valueEl,this._select]),this._applyLineClamping()}_applyLineClamping(){applyRowLineClamp({titleEl:this._titleEl,subtitleEl:this._subtitleEl,textContainerEl:this._titleEl.parentElement,getTitleLines:()=>parseRowLinesAttribute(this.getAttribute(`title-lines`)),getSubtitleLines:()=>parseRowLinesAttribute(this.getAttribute(`subtitle-lines`))})}};customElements.define(`adw-combo-row`,AdwComboRow);const $r=[`auto`,`floating`,`bottom-sheet`];var AdwDialog=class extends WidgetElement{_initialized=!1;_scrimEl;_boxEl;_headerEl;_titleEl;_closeBtn;_contentEl;_modal;static get observedAttributes(){return[`title`,`open`,`can-close`,`content-width`,`content-height`,`presentation-mode`,`show-header`]}get open(){return this.hasAttribute(`open`)}set open(e){e?this.setAttribute(`open`,``):this.removeAttribute(`open`)}get title(){return this.getAttribute(`title`)??``}set title(e){this.setAttribute(`title`,e)}get canClose(){let e=this.getAttribute(`can-close`);return e===null?!0:e!==`false`}set canClose(e){e?this.setAttribute(`can-close`,``):this.setAttribute(`can-close`,`false`)}get contentWidth(){let e=Number.parseInt(this.getAttribute(`content-width`)??``,10);return Number.isNaN(e)?360:e}set contentWidth(e){this.setAttribute(`content-width`,String(e))}get contentHeight(){let e=Number.parseInt(this.getAttribute(`content-height`)??``,10);return Number.isNaN(e)?0:e}set contentHeight(e){e>0?this.setAttribute(`content-height`,String(e)):this.removeAttribute(`content-height`)}get presentationMode(){let e=this.getAttribute(`presentation-mode`);return e&&$r.includes(e)?e:`auto`}set presentationMode(e){this.setAttribute(`presentation-mode`,e)}get contentArea(){return this._contentEl}present(e){this.isConnected||(e??document.body).appendChild(this),this.open=!0}close(){this._attemptClose()}forceClose(){this.open&&=!1}connectedCallback(){if(this._initialized)return;this._initialized=!0,this.classList.add(`adw-dialog`),this._scrimEl=document.createElement(`div`),this._scrimEl.className=`adw-dialog-scrim`,this._scrimEl.addEventListener(`click`,()=>this._attemptClose()),this._boxEl=document.createElement(`div`),this._boxEl.className=`adw-dialog-box`,this._boxEl.addEventListener(`click`,e=>e.stopPropagation()),this._modal=new AdwModalSurface({host:this,surface:this._boxEl,role:`dialog`,isOpen:()=>this.open,onEscape:()=>this._attemptClose()}),this._headerEl=document.createElement(`div`),this._headerEl.className=`adw-dialog-header`;let e=document.createElement(`div`);e.className=`adw-dialog-header-side`,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-dialog-title`;let t=document.createElement(`div`);t.className=`adw-dialog-header-side adw-dialog-header-side--end`,this._closeBtn=document.createElement(`button`),this._closeBtn.type=`button`,this._closeBtn.className=`adw-dialog-close`,this._closeBtn.setAttribute(`aria-label`,`Close`),this._closeBtn.addEventListener(`click`,()=>this._attemptClose()),t.appendChild(this._closeBtn),this._headerEl.append(e,this._titleEl,t),this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-dialog-content`,this._boxEl.append(this._headerEl,this._contentEl),this._scrimEl.appendChild(this._boxEl),bindSlottedChildren(this,[{name:`child`,into:this._contentEl},{into:this._contentEl}]).install(this._scrimEl),this._render()}attributeChangedCallback(e,t,n){this._initialized&&t!==n&&(this._render(),e===`open`&&(this.dispatchEvent(new CustomEvent(`notify::open`,{bubbles:!0,detail:{open:this.open}})),this.open?this._modal.present():this._onClosed()))}_attemptClose(){if(this.open){if(!this.canClose){this.dispatchEvent(new CustomEvent(`close-attempt`,{bubbles:!0}));return}this.open=!1}}_onClosed(){this.dispatchEvent(new CustomEvent(`closed`,{bubbles:!0})),this._modal.dismiss()}decorateHeader(e){}_render(){this.classList.toggle(`open`,this.open);let e=this.title;this._titleEl.textContent=e;let t=e.length>0||this.hasAttribute(`show-header`);this._headerEl.hidden=!t,this.dataset.presentation=this.presentationMode,this._boxEl.style.setProperty(`--adw-dialog-content-width`,`${this.contentWidth}px`);let n=this.contentHeight;n>0?this._boxEl.style.setProperty(`--adw-dialog-content-height`,`${n}px`):this._boxEl.style.removeProperty(`--adw-dialog-content-height`);let r=!this.canClose;this._closeBtn.disabled=r,this._closeBtn.classList.toggle(`locked`,r),this.decorateHeader(this._headerEl)}};customElements.define(`adw-dialog`,AdwDialog);function setPartVisible(e,t){e.hidden=!t,e.style.display=t?``:`none`}var AdwEntryRow=class extends TooltipElement{_state=new EntryRowState;_input;_emptyTitle;_title;_area;_editIcon;_indicator;_applyButton;_prefixes;_suffixes;_initialized=!1;_slots;_lastText=``;_lastLength=0;static get observedAttributes(){return[`title`,`text`,`editable`,`max-length`,`show-apply-button`,`activates-default`,`tooltip-text`]}get _classPrefix(){return`adw-entry-row`}get text(){return this._state.text}set text(e){this._state.setText(e??``)}get textLength(){return this._state.textLength}get maxLength(){return this._state.maxLength}set maxLength(e){this._state.setMaxLength(e)}get editable(){return this._state.editable}set editable(e){this._state.setEditable(e)}get showApplyButton(){return this._state.showApplyButton}set showApplyButton(e){this._state.setShowApplyButton(e)}get activatesDefault(){return this._state.activatesDefault}set activatesDefault(e){this._state.setActivatesDefault(e)}get editing(){return this._state.editing}connectedCallback(){this._initialized||(this._initialized=!0,this._build(),this._state.setMaxLength(Number.parseInt(this.getAttribute(`max-length`)??``,10)),this._state.setEditable(this.getAttribute(`editable`)!==`false`),this._state.setShowApplyButton(booleanAttribute$2(this.getAttribute(`show-apply-button`),!1)),this._state.setActivatesDefault(booleanAttribute$2(this.getAttribute(`activates-default`),!1)),this.hasAttribute(`text`)&&this._state.setText(this.getAttribute(`text`)??``),this._renderTitle(),this._onConnected(),this._slots.install(this._prefixes,this._area,this._indicator,this._applyButton,this._editIcon,this._suffixes),this._lastText=this._state.text,this._lastLength=this._state.textLength,this._render(this._state.state),applyRowTooltip(this,this._tooltipParts()),this._state.subscribe(e=>this._onStateChanged(e)))}attributeChangedCallback(e,t,n){if(this._initialized)switch(e){case`title`:this._renderTitle();break;case`text`:this._state.setText(n??``);break;case`editable`:this._state.setEditable(n!==`false`);break;case`max-length`:this._state.setMaxLength(Number.parseInt(n??``,10));break;case`show-apply-button`:this._state.setShowApplyButton(booleanAttribute$2(n,!1));break;case`activates-default`:this._state.setActivatesDefault(booleanAttribute$2(n,!1));break;case`tooltip-text`:applyRowTooltip(this,this._tooltipParts());break}}_tooltipParts(){return[this._prefixes,this._area,this._suffixes]}addSuffix(e){this._suffixes.append(e),setPartVisible(this._suffixes,!0)}addPrefix(e){this._prefixes.prepend(e),setPartVisible(this._prefixes,!0)}setShowIndicator(e){this._state.setShowIndicator(e)}setIndicatorIconName(e){this._indicator.dataset.iconName=e}setIndicatorTooltip(e){this._indicator.title=e,this._indicator.setAttribute(`aria-label`,e)}apply(){this._state.apply(),this.dispatchEvent(new CustomEvent(`apply`,{bubbles:!0}))}grabFocusWithoutSelecting(){return this._input.focus(),this._state.editing}_onConnected(){}_build(){let e=this._classPrefix;this._prefixes=document.createElement(`div`),this._prefixes.className=`${e}-prefixes`,this._suffixes=document.createElement(`div`),this._suffixes.className=`${e}-suffixes`,this._emptyTitle=document.createElement(`span`),this._emptyTitle.className=`adw-row-title ${e}-empty-title`,this._title=document.createElement(`span`),this._title.className=`adw-row-title ${e}-title`,this._input=document.createElement(`input`),this._input.className=`${e}-input`,this._input.type=`text`,this._input.addEventListener(`input`,()=>{this._state.setText(this._input.value),this._input.value!==this._state.text&&(this._input.value=this._state.text)}),this._input.addEventListener(`focus`,()=>this._state.setEditing(!0)),this._input.addEventListener(`blur`,()=>this._state.setEditing(!1)),this._input.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._activate())}),this._area=document.createElement(`div`),this._area.className=`${e}-text`,this._area.append(this._emptyTitle,this._title,this._input),this._indicator=document.createElement(`span`),this._indicator.className=`${e}-indicator`,this._indicator.setAttribute(`role`,`img`),this._indicator.textContent=`⇪`,this._applyButton=document.createElement(`button`),this._applyButton.type=`button`,this._applyButton.className=`adw-button suggested-action circular icon-only ${e}-apply`,this._applyButton.dataset.iconName=`adw-entry-apply-symbolic`,this._applyButton.title=Lt,this._applyButton.setAttribute(`aria-label`,Lt),this._applyButton.textContent=`✓`,this._applyButton.addEventListener(`click`,()=>this.apply()),this._editIcon=createGtkImage(`document-edit`,`adw-row-edit`,`${e}-edit`),this._editIcon.dataset.iconName=`adw-entry-edit-symbolic`,this._slots=bindSlottedChildren(this,[{name:`prefix`,consume:e=>this.addPrefix(e)},{name:`suffix`,claims:e=>e instanceof Element,consume:e=>this.addSuffix(e)}]),setPartVisible(this._prefixes,!1),setPartVisible(this._suffixes,!1),this.addEventListener(`click`,e=>this._maybeFocus(e))}_maybeFocus(e){let t=e.target;(t===this||t===this._area||t===this._emptyTitle||t===this._title||t===this._editIcon||t===this._indicator||t===this._prefixes||t===this._suffixes)&&this._input.focus()}_activate(){let e=this._state.activate();if(e.signal===`apply`){this.dispatchEvent(new CustomEvent(`apply`,{bubbles:!0}));return}e.activateDefault&&this.closest(`form`)?.requestSubmit(),this.dispatchEvent(new CustomEvent(`entry-activated`,{bubbles:!0}))}_renderTitle(){let e=this.getAttribute(`title`)??``;this._emptyTitle.textContent=e,this._title.textContent=e}_render(e){this._input.value!==e.text&&(this._input.value=e.text),this._input.readOnly=!e.editable,this.classList.toggle(`focused`,e.editing),this.classList.toggle(`empty`,e.empty),setPartVisible(this._emptyTitle,e.emptyTarget===0),setPartVisible(this._title,e.emptyTarget===1),setPartVisible(this._editIcon,e.editIconVisible),this._editIcon.classList.toggle(`disabled`,!e.editIconSensitive),this._editIcon.setAttribute(`aria-disabled`,String(!e.editIconSensitive)),setPartVisible(this._indicator,e.indicatorVisible),setPartVisible(this._applyButton,e.applyButtonVisible),this.setAttribute(`text-length`,String(e.textLength))}_onStateChanged(e){if(this._render(e),e.text!==this._lastText){this._lastText=e.text;let t={text:e.text};this.dispatchEvent(new CustomEvent(`changed`,{bubbles:!0,detail:t})),this.dispatchEvent(new CustomEvent(`notify::text`,{bubbles:!0,detail:t}))}e.textLength!==this._lastLength&&(this._lastLength=e.textLength,this.dispatchEvent(new CustomEvent(`notify::text-length`,{bubbles:!0,detail:{textLength:e.textLength}})))}};customElements.define(`adw-entry-row`,AdwEntryRow);var GtkSwitch=class extends WidgetElement{static signals={"notify::active":`notify::active`,"notify::state":`notify::state`};_input;_slider;_initialized=!1;static get observedAttributes(){return[`active`,`state`,`disabled`,`unfocusable`]}get unfocusable(){return this.hasAttribute(`unfocusable`)}set unfocusable(e){this.toggleAttribute(`unfocusable`,!!e)}get active(){return this.hasAttribute(`active`)}set active(e){this.toggleAttribute(`active`,!!e),this.state=this.active}get state(){return this.hasAttribute(`state`)}set state(e){this.toggleAttribute(`state`,!!e)}get disabled(){return this.hasAttribute(`disabled`)}set disabled(e){this.toggleAttribute(`disabled`,!!e)}connectedCallback(){if(this._initialized){this._render();return}this._initialized=!0,this.classList.add(`adw-switch`),this._input=document.createElement(`input`),this._input.type=`checkbox`,this._slider=document.createElement(`span`),this._slider.className=`adw-switch-slider`,this.replaceChildren(this._input,this._slider),this.active&&(this.state=!0),this._input.addEventListener(`change`,()=>{this.active=this._input.checked}),this.addEventListener(`click`,e=>{this.disabled||e.target!==this._input&&(this.active=!this.active)}),this._render()}attributeChangedCallback(e){this._initialized&&(this._render(),e===`active`?this.dispatchEvent(new CustomEvent(`notify::active`,{bubbles:!0,detail:{active:this.active}})):e===`state`&&this.dispatchEvent(new CustomEvent(`notify::state`,{bubbles:!0,detail:{state:this.state}})))}_render(){let e=this.disabled;this._input.checked=this.active,this._input.disabled=e,this.unfocusable?this._input.tabIndex=-1:this._input.removeAttribute(`tabindex`),this.classList.toggle(`checked`,this.state),this.classList.toggle(`disabled`,e)}};customElements.define(`gtk-switch`,GtkSwitch);var AdwExpanderRow=class extends TooltipElement{_headerEl;_titleEl;_subtitleEl;_enableSwitch;_chevronEl;_contentEl;_prefixEl;_suffixEl;_state=new ExpanderState;_initialized=!1;_reflectingEnable=!1;constructor(){super(),this._state.subscribe(e=>{this._reflectExpanded(e),this._initialized&&this._render()})}static get observedAttributes(){return[`title`,`subtitle`,`expanded`,`enable-expansion`,`show-enable-switch`,`tooltip-text`,`title-lines`,`subtitle-lines`]}get expanded(){return this._state.expanded}set expanded(e){this._state.setExpanded(e)}get enableExpansion(){return this._state.enableExpansion}set enableExpansion(e){this.setAttribute(`enable-expansion`,e?`true`:`false`)}get contentSection(){return this._contentEl}get suffixSection(){return this._suffixEl}get prefixSection(){return this._prefixEl}connectedCallback(){if(this._initialized)return;this._initialized=!0,this._headerEl=document.createElement(`div`),this._headerEl.className=`adw-expander-row-header`;let e=document.createElement(`div`);e.className=`adw-row-text`,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-row-title`,this._subtitleEl=document.createElement(`span`),this._subtitleEl.className=`adw-row-subtitle`,e.append(this._titleEl,this._subtitleEl),this._enableSwitch=document.createElement(`gtk-switch`),this._enableSwitch.classList.add(`adw-expander-row-enable-switch`),this._enableSwitch.active=this._state.enableExpansion,this._chevronEl=createGtkImage(`go-down`,`adw-expander-row-chevron`),this._prefixEl=document.createElement(`div`),this._prefixEl.className=`adw-expander-row-prefix`,this._suffixEl=document.createElement(`div`),this._suffixEl.className=`adw-expander-row-suffix`,this._headerEl.append(this._prefixEl,e,this._suffixEl,this._enableSwitch,this._chevronEl),this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-expander-row-content`,bindSlottedChildren(this,[{name:`prefix`,into:this._prefixEl},{name:`suffix`,into:this._suffixEl},{into:this._contentEl}]).install(this._headerEl,this._contentEl),bindEmptySections(this._prefixEl,this._suffixEl),this._headerEl.addEventListener(`click`,e=>{this._enableSwitch.contains(e.target)||this._state.toggle()&&this.dispatchEvent(new CustomEvent(`notify::expanded`,{bubbles:!0,detail:{expanded:this.expanded}}))}),attachRowActivation({row:this._headerEl,activatable:()=>!0}),this._enableSwitch.addEventListener(`notify::active`,e=>{if(e.stopPropagation(),this._reflectingEnable)return;let t=this._enableSwitch.active,n=this._state.setEnableExpansion(t);this.setAttribute(`enable-expansion`,t?`true`:`false`);for(let e of n)this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:e===`expanded`?{expanded:this.expanded}:{enableExpansion:t}}))}),this._state.setExpanded(this.hasAttribute(`expanded`)),this._reflectExpanded(this._state.expanded),this._render()}attributeChangedCallback(e){e===`enable-expansion`&&this._state.setEnableExpansion(this._enableAttribute()),this._initialized&&(e===`expanded`&&(this._state.setExpanded(this.hasAttribute(`expanded`)),this._reflectExpanded(this._state.expanded)),this._render())}_enableAttribute(){return this.getAttribute(`enable-expansion`)!==`false`}_reflectExpanded(e){this.hasAttribute(`expanded`)!==e&&(e?this.setAttribute(`expanded`,``):this.removeAttribute(`expanded`))}_render(){let e=deriveRowLabels({title:this.getAttribute(`title`),subtitle:this.getAttribute(`subtitle`)});this._titleEl.textContent=e.title,this._titleEl.hidden=!e.titleVisible,this._subtitleEl.textContent=e.subtitle,this._subtitleEl.hidden=!e.subtitleVisible;let t=this.hasAttribute(`show-enable-switch`);this._enableSwitch.hidden=!t,this._reflectingEnable=!0,this._enableSwitch.active=this._state.enableExpansion,this._reflectingEnable=!1,this.classList.toggle(`expanded`,this.expanded),this._headerEl.setAttribute(`aria-expanded`,String(this.expanded)),this._contentEl.classList.toggle(`expanded`,this.expanded),applyRowTooltip(this,[this._headerEl]),this._applyLineClamping()}_applyLineClamping(){applyRowLineClamp({titleEl:this._titleEl,subtitleEl:this._subtitleEl,textContainerEl:this._titleEl.parentElement,getTitleLines:()=>parseRowLinesAttribute(this.getAttribute(`title-lines`)),getSubtitleLines:()=>parseRowLinesAttribute(this.getAttribute(`subtitle-lines`))})}};customElements.define(`adw-expander-row`,AdwExpanderRow);var AdwWindowTitle=class extends WidgetElement{_titleEl;_subtitleEl;_state=new WindowTitleState;_initialized=!1;static get observedAttributes(){return[`title`,`subtitle`]}connectedCallback(){this._initialized||(this._initialized=!0,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-window-title-title`,this._subtitleEl=document.createElement(`span`),this._subtitleEl.className=`adw-window-title-subtitle`,this.replaceChildren(this._titleEl,this._subtitleEl),this._state.setTitle(this.getAttribute(`title`)),this._state.setSubtitle(this.getAttribute(`subtitle`)),this._render())}attributeChangedCallback(e,t,n){this._initialized&&(e===`title`?this._state.setTitle(n):this._state.setSubtitle(n))&&(this._render(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:e===`title`?this._state.title:this._state.subtitle}})))}_render(){let{title:e,titleVisible:t,subtitle:n,subtitleVisible:r}=this._state.state;this._titleEl.textContent=e,this._titleEl.hidden=!t,this._subtitleEl.textContent=n,this._subtitleEl.hidden=!r}};customElements.define(`adw-window-title`,AdwWindowTitle);var AdwHeaderBar=class extends WidgetElement{_initialized=!1;_startEl=null;_centerEl=null;_endEl=null;_titleEl=null;_page=null;_window=null;_pageObserver=null;static get observedAttributes(){return[`title`,`subtitle`]}get startSection(){return this._startEl}get centerSection(){return this._centerEl}get endSection(){return this._endEl}connectedCallback(){if(this._initialized){this._followPage(),this._renderTitle();return}this._initialized=!0,this._startEl=document.createElement(`div`),this._startEl.className=`adw-header-bar-start`,this._centerEl=document.createElement(`div`),this._centerEl.className=`adw-header-bar-center`,this._endEl=document.createElement(`div`),this._endEl.className=`adw-header-bar-end`,bindSlottedChildren(this,[{name:`start`,into:this._startEl},{name:`center`,into:this._centerEl},{name:`title-widget`,into:this._centerEl},{name:`end`,into:this._endEl},{into:this._startEl}],(e,t)=>{`into`in t&&t.into===this._centerEl&&this._dropDerivedTitle()}).install(this._startEl,this._centerEl,this._endEl),this._centerEl.childElementCount===0&&(this._titleEl=document.createElement(`adw-window-title`),this._titleEl.className=`adw-header-bar-title`,this._centerEl.appendChild(this._titleEl)),this._followPage(),this._renderTitle()}disconnectedCallback(){this._pageObserver?.disconnect(),this._pageObserver=null,this._page=null,this._window=null}_followPage(){this._page=this.closest(`adw-navigation-page`),this._window=this.closest(`adw-window, adw-application-window`),this._pageObserver??=new MutationObserver(()=>this._renderTitle());for(let e of[this._page,this._window])e!==null&&this._pageObserver.observe(e,{attributes:!0,attributeFilter:[`title`]})}attributeChangedCallback(){this._initialized&&this._renderTitle()}_dropDerivedTitle(){this._titleEl?.remove(),this._titleEl=null}_renderTitle(){if(this._titleEl)for(let e of[`title`,`subtitle`]){let t=this.getAttribute(e)??(e===`title`?this._page?.getAttribute(`title`)??this._window?.getAttribute(`title`)??null:null);t===null?this._titleEl.removeAttribute(e):this._titleEl.setAttribute(e,t)}}};customElements.define(`adw-header-bar`,AdwHeaderBar);const ei={schedule(e,t){return setTimeout(e,t)},cancel(e){clearTimeout(e)}};function createSwitcherIcon(e,t){return createGtkImage(viewSwitcherIconName(e),t)}function applySwitcherIcon(e,t){e.iconName=viewSwitcherIconName(t)}function readSwitcherPage(e){let t=Number.parseInt(e.getAttribute(`badge-number`)??``,10);return{name:e.getAttribute(`name`)??``,title:e.getAttribute(`title`),iconName:e.getAttribute(`icon-name`),visible:!e.hasAttribute(`hidden`),useUnderline:e.hasAttribute(`use-underline`),badgeNumber:Number.isNaN(t)?0:t,needsAttention:e.hasAttribute(`needs-attention`)}}function applyIndicator(e,t,n){e.textContent=t,e.classList.toggle(`needs-attention`,n&&t.length===0),e.hidden=t.length===0&&!n}function applyDescription(e,t){t?e.setAttribute(`aria-description`,t):e.removeAttribute(`aria-description`)}const ti={horizontal:{previous:`ArrowLeft`,next:`ArrowRight`},vertical:{previous:`ArrowUp`,next:`ArrowDown`}},adjacentStep=(e,t,n)=>{let r=t+n;return r<0||r>=e.length?null:r};function attachRovingFocus(e){let keysOf=e=>ti[typeof e==`function`?e():e];e.host.addEventListener(`keydown`,t=>{let{previous:n,next:r}=keysOf(e.orientation),i=e.crossAxis===void 0?null:keysOf(e.crossAxis.orientation);if(t.altKey||t.ctrlKey||t.metaKey)return;let a=e.items(),o=a.findIndex(e=>e===t.target||e.contains(t.target));if(o<0)return;let s=e.step??adjacentStep,c;if(t.key===n)c=s(a,o,-1);else if(t.key===r)c=s(a,o,1);else if(i!==null&&t.key===i.previous)c=e.crossAxis.step(a,o,-1);else if(i!==null&&t.key===i.next)c=e.crossAxis.step(a,o,1);else if(t.key===`Home`)c=0;else if(t.key===`End`)c=a.length-1;else return;t.preventDefault();let l=c===null?void 0:a[c];l===void 0||l===a[o]||(e.select(l),l.focus())})}var AdwViewStackPage=class extends WidgetElement{static get observedAttributes(){return[`name`,`title`,`icon-name`,`badge-number`,`needs-attention`,`use-underline`]}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}])}},AdwInlineViewSwitcher=class extends WidgetElement{scheduler=ei;_stateInstance=null;get _state(){return this._stateInstance||(this._stateInstance=new ViewSwitcherState({scheduler:this.scheduler}),this._stateInstance.subscribe(e=>this._onStateChange(e))),this._stateInstance}_groupEl;_pagesEl;_panels=[];_toggles=[];_displayMode=`labels`;_initialized=!1;_declared=[];_pageObserver;static get observedAttributes(){return[`active`,`display-mode`,`flat`,`round`,`osd`]}constructor(){super()}get active(){return this._state.selected}set active(e){this._state.setSelected(e),this._reflectActive()}get activeToggle(){return toggleIndexForPage(this._state.pages,this._state.selected)}get displayMode(){return this._displayMode}set displayMode(e){this.setAttribute(`display-mode`,e)}get visibleChildName(){return this._state.selectedName}set visibleChildName(e){this._state.selectName(e)}get pages(){return this._state.pages}setPageVisible(e,t){let n=this._state.setPageVisible(e,t);return this._rebuildToggles(),n}connectedCallback(){if(this._initialized){this._watchPages();return}let e=Array.from(this.querySelectorAll(`:scope > adw-view-stack-page`)),t=this.getAttribute(`active`);if(this._groupEl=document.createElement(`div`),this._groupEl.className=`adw-inline-view-switcher-group`,this._groupEl.setAttribute(`role`,`tablist`),attachRovingFocus({host:this,orientation:`horizontal`,items:()=>this._toggles,select:e=>{this._state.setSelected(Number(e.dataset.pageIndex))}}),this._pagesEl=document.createElement(`div`),this._pagesEl.className=`adw-inline-view-switcher-pages`,this._panels=e.map(e=>{let t=document.createElement(`div`);t.className=`adw-inline-view-switcher-page`,t.setAttribute(`role`,`tabpanel`),t.dataset.name=e.getAttribute(`name`)??``;for(let n of Array.from(e.childNodes))t.appendChild(n);return this._pagesEl.appendChild(t),t}),this.replaceChildren(this._groupEl,this._pagesEl),this._displayMode=this._readDisplayModeAttr(),this._initialized=!0,this._declared=e,this._watchPages(),this._state.setPages(e.map(e=>readSwitcherPage(e))),t!==null){let e=Number.parseInt(t,10);Number.isNaN(e)||this._state.setSelected(e,!1)}this._rebuildToggles()}disconnectedCallback(){this._state.cancelDrag(),this._pageObserver?.disconnect(),this._pageObserver=void 0}refreshPages(){this._initialized&&(this._state.setPages(this._declared.map(e=>readSwitcherPage(e))),this._rebuildToggles())}_watchPages(){this._pageObserver?.disconnect(),this._pageObserver=new MutationObserver(()=>this.refreshPages());for(let e of this._declared)this._pageObserver.observe(e,{attributes:!0})}attributeChangedCallback(e){if(this._initialized){if(e===`active`){let e=this.getAttribute(`active`),t=e===null?NaN:Number.parseInt(e,10);Number.isNaN(t)||this._state.setSelected(t),this._reflectActive();return}if(e===`display-mode`){let e=this._readDisplayModeAttr();if(e===this._displayMode)return;this._displayMode=e,this._rebuildToggles(),this.dispatchEvent(new CustomEvent(`notify::display-mode`,{bubbles:!0,detail:{displayMode:e}}));return}this._applyStyleClasses()}}_readDisplayModeAttr(){let e=this.getAttribute(`display-mode`);return e===null?`labels`:isInlineViewSwitcherDisplayMode(e)?e:this._displayMode}_rebuildToggles(){if(!this._initialized)return;let e=buildInlineToggles(this._state.pages,this._displayMode);this._groupEl.replaceChildren(),this._toggles=e.map(e=>{let t=document.createElement(`button`);if(t.type=`button`,t.className=`adw-inline-view-switcher-toggle`,t.setAttribute(`role`,`tab`),t.dataset.pageIndex=String(e.pageIndex),t.dataset.toggleIndex=String(e.toggleIndex),e.showIcon&&t.appendChild(createSwitcherIcon(e.iconName,`adw-inline-view-switcher-icon`)),e.showLabel){let n=document.createElement(`span`);n.className=`adw-inline-view-switcher-label`,n.textContent=e.label,t.appendChild(n)}let n=document.createElement(`span`);return n.className=`adw-inline-view-switcher-indicator`,n.setAttribute(`aria-hidden`,`true`),applyIndicator(n,e.badgeLabel,e.needsAttention),t.appendChild(n),e.tooltip&&(t.title=e.tooltip),e.showLabel||t.setAttribute(`aria-label`,e.tooltip||e.iconName),applyDescription(t,e.description),t.addEventListener(`click`,()=>{this._state.setSelected(e.pageIndex)}),t.addEventListener(`dragenter`,n=>{t.contains(n.relatedTarget)||this._state.dragEnter(e.pageIndex)}),t.addEventListener(`dragleave`,n=>{t.contains(n.relatedTarget)||this._state.dragLeave(e.pageIndex)}),this._groupEl.appendChild(t),t}),this._render()}_onStateChange(e){this._render(),this.dispatchEvent(new CustomEvent(`notify::active`,{bubbles:!0,detail:{active:e.selected,name:e.name,toggleIndex:this.activeToggle,interactive:e.interactive}}))}_render(){if(!this._initialized)return;this._applyStyleClasses();let e=this.activeToggle;this._toggles.forEach((t,n)=>{let r=n===e&&e!==-1;t.classList.toggle(`active`,r),t.setAttribute(`aria-selected`,String(r)),t.tabIndex=r?0:-1});let t=this._state.selected;this._panels.forEach((e,n)=>{let r=n===t;e.classList.toggle(`active-view`,r),e.hidden=!r}),this._reflectActive()}_applyStyleClasses(){for(let e of[`flat`,`round`,`osd`]){let t=this.hasAttribute(e);this.classList.toggle(e,t),this._groupEl?.classList.toggle(e,t)}for(let e of Jn)this._groupEl.classList.toggle(e,e===this._displayMode)}_reflectActive(){let e=String(this._state.selected);this.getAttribute(`active`)!==e&&this.setAttribute(`active`,e)}};customElements.define(`adw-view-stack-page`,AdwViewStackPage),customElements.define(`adw-inline-view-switcher`,AdwInlineViewSwitcher);var AdwMultiLayoutView=class extends WidgetElement{_layouts=[];_children=new Map;_slots=new Map;_current=null;_acceptingSlots=!1;_observer=null;static get observedAttributes(){return[`layout-name`]}get layoutName(){return this._current?.name??null}set layoutName(e){e!==null&&this.setAttribute(`layout-name`,e)}get layout(){return this._current?.content??null}connectedCallback(){this.setAttribute(`role`,`group`),this.style.display=`block`,this._observer?.disconnect(),this._observer=new MutationObserver(()=>this._rebuild()),this._observer.observe(this,{childList:!0}),this._rebuild()}disconnectedCallback(){this._observer?.disconnect(),this._observer=null}attributeChangedCallback(e){!this.isConnected||e!==`layout-name`||this._setLayoutByName(this.getAttribute(`layout-name`))}getChild(e){return this._children.get(e)??null}getLayoutByName(e){return this._layouts.find(t=>t.name===e)?.content??null}registerSlot(e,t){if(this._acceptingSlots&&this._slots.get(e)!==t){if(this._slots.has(e)){console.warn(`Duplicate slot ID in AdwLayout ${this.layoutName}: ${e}`);return}this._slots.set(e,t)}}_rebuild(){if(this.isConnected){this._observer?.disconnect();try{this._readAuthoredTree()}finally{this.isConnected&&this._observer?.observe(this,{childList:!0})}}}_readAuthoredTree(){let e=[];for(let t of Array.from(this.children)){let n=t.getAttribute(`name`);if(n!==null){e.push({name:n,content:t});continue}let r=t.getAttribute(`slot`);r===null||r===``||(this._children.has(r)&&console.warn(`While adding child: duplicate slot ${r} in AdwMultiLayoutView; kept the first`),this._children.set(r,t))}this._layouts=e;let t=this.getAttribute(`layout-name`);t===null?this._setLayout(e[0]??null):this._setLayoutByName(t)}_setLayout(e){if(e===this._current){e!==null&&this._mount(e);return}this._current=e,e===null?this._destroy():this._mount(e),this.dispatchEvent(new CustomEvent(`notify::layout`,{bubbles:!0,detail:{layout:this.layoutName}})),this.dispatchEvent(new CustomEvent(`notify::layout-name`,{bubbles:!0,detail:{layoutName:this.layoutName}}))}_setLayoutByName(e){if(e===null)return;let t=this._layouts.find(t=>t.name===e);if(t===void 0){console.error(`Layout name '${e}' not found in AdwMultiLayoutView`);return}this._setLayout(t)}_destroy(){this._slots.clear(),this.replaceChildren()}_mount(e){for(this._destroy(),this._acceptingSlots=!0,this.appendChild(e.content);;){let t=this._slots.size;for(let t of e.content.querySelectorAll(`adw-layout-slot`)){let e=t.getAttribute(`id`);e!==null&&e!==``&&!this._slots.has(e)&&this.registerSlot(e,t)}for(let[e,t]of this._children)this._parent(e,t);if(this._slots.size===t)break}this._acceptingSlots=!1}_parent(e,t){let n=this._slots.get(e);n!==void 0&&t.parentElement!==n&&(this._mirrorVisible(n,t),n.appendChild(t))}_mirrorVisible(e,t){let apply=()=>{e.toggleAttribute(`hidden`,t.hidden===!0)};apply(),new MutationObserver(apply).observe(t,{attributes:!0,attributeFilter:[`hidden`]})}};customElements.define(`adw-multi-layout-view`,AdwMultiLayoutView);var AdwLayoutSlot=class extends WidgetElement{_registered=!1;static get observedAttributes(){return[`id`]}get slotId(){return this.getAttribute(`id`)}connectedCallback(){this.setAttribute(`role`,`group`),this.style.display=`contents`,this._register()}disconnectedCallback(){this._registered=!1}attributeChangedCallback(e){!this.isConnected||e!==`id`||(this._registered&&console.warn("<adw-layout-slot>: `id` is construct-only upstream; re-registering the slot."),this._register())}_register(){let e=this.slotId;if(e===null||e===``){console.error("<adw-layout-slot> created without an `id` — libadwaita refuses this with g_error.");return}let t=this.closest(`adw-multi-layout-view`);t instanceof AdwMultiLayoutView&&t.registerSlot(e,this),this._registered=!0}};customElements.define(`adw-layout-slot`,AdwLayoutSlot);function readPageProps(e){return{tag:e.tag,title:e.title,canPop:e.canPop}}var AdwNavigationPage=class extends WidgetElement{_syncing=!1;static get observedAttributes(){return[`title`,`tag`,`can-pop`,`no-back-button`]}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}])}get title(){return this.getAttribute(`title`)??``}set title(e){this.setAttribute(`title`,e)}get tag(){return this.getAttribute(`tag`)}set tag(e){e===null?this.removeAttribute(`tag`):this.setAttribute(`tag`,e)}get canPop(){return this.getAttribute(`can-pop`)!==`false`}set canPop(e){this.setAttribute(`can-pop`,e?`true`:`false`)}attributeChangedCallback(e,t){if(this._syncing)return;let n=this.closest(`adw-navigation-view`);n instanceof AdwNavigationView&&n.syncPageProperty(this,e,t)}revertAttribute(e,t){this._syncing=!0,t===null?this.removeAttribute(e):this.setAttribute(e,t),this._syncing=!1}},AdwNavigationView=class extends WidgetElement{static signals={pushed:`pushed`,popped:`popped`,replaced:`replaced`,"notify::visible-page":`notify::visible-page`};_pagesEl;_backButtons=new WeakMap;_initialized=!1;_diagnose=e=>{console.warn(`[adw-navigation-view] ${describeNavigationDiagnostic(e)}`)};_state=new NavigationViewState({onDiagnostic:this._diagnose});static get observedAttributes(){return[`animate-transitions`,`pop-on-escape`]}get animateTransitions(){return this.getAttribute(`animate-transitions`)!==`false`}set animateTransitions(e){this.setAttribute(`animate-transitions`,e?`true`:`false`)}get popOnEscape(){return this.getAttribute(`pop-on-escape`)!==`false`}set popOnEscape(e){this.setAttribute(`pop-on-escape`,e?`true`:`false`)}get visiblePage(){return this._state.visiblePage}get visiblePageTag(){return this._state.visiblePageTag}get_visible_page_tag(){return this.visiblePageTag}get depth(){return this._state.depth}get navigationStack(){return this._state.stack}get pages(){return this._state.pages}get canGoBack(){return this._state.canGoBack()}get backButtonTooltip(){return this._state.backButtonTooltip()}constructor(){super(),installElementApi(this)}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=Array.from(this.querySelectorAll(`:scope > adw-navigation-page`));this._pagesEl=document.createElement(`div`),this._pagesEl.className=`adw-navigation-view-pages`;for(let t of e)t.classList.add(`adw-navigation-page`),this._pagesEl.appendChild(t);this.replaceChildren(this._pagesEl),this._state.subscribe(e=>this._onChange(e)),this._state.setAnimateTransitions(this.animateTransitions),this._state.setPopOnEscape(this.popOnEscape),this.addEventListener(`keydown`,this._onKeyDown);for(let t of e)this._state.add(t,readPageProps(t));for(let t of e)this._state.isRegistered(t)||this._detach(t);this._syncClasses(),this._render()}attributeChangedCallback(e){if(this._initialized){if(e===`pop-on-escape`){this._state.setPopOnEscape(this.popOnEscape);return}this._state.setAnimateTransitions(this.animateTransitions),this._syncClasses()}}syncPageProperty(e,t,n){this._state.isRegistered(e)&&(t===`tag`?(this._state.setTag(e,e.tag),this._state.tagOf(e)!==e.tag&&e.revertAttribute(`tag`,n)):t===`title`?this._state.setTitle(e,e.title):t===`can-pop`&&this._state.setCanPop(e,e.canPop),this._render())}addPage(e){let t=this._state.add(e,readPageProps(e));return this._render(),t}removePage(e){let t=this._state.remove(e);return t&&!this._state.isRegistered(e)&&this._detach(e),this._render(),t}push(e){if(typeof e==`string`)return this.pushByTag(e);let t=this._state.push(e,readPageProps(e));return this._render(),t}push_by_tag(e){return this.pushByTag(e)}pushByTag(e){let t=this._state.pushByTag(e);return this._render(),t}pop(){let e=this._state.pop();return this._render(),e}popToPage(e){let t=this._state.popToPage(e);return this._render(),t}popToTag(e){let t=this._state.popToTag(e);return this._render(),t}replace(e){let t=e.map(e=>{if(typeof e!=`string`)return e??null;let t=this._state.findPage(e);return t===null&&this._diagnose({code:`tag-not-found`,tag:e}),t});this._state.replace(t,readPageProps),this._render()}replaceWithTags(e){this._state.replaceWithTags(e),this._render()}findPage(e){return this._state.findPage(e)}getPreviousPage(e){return this._state.getPreviousPage(e)}_onChange(e){for(let t of e.removed)this._detach(t);for(let e of this._state.finishTransition())this._detach(e);if(this._render(),e.reason===`add`||e.reason===`push`)this._dispatch(`pushed`,e.visiblePage);else if(e.reason===`pop`)for(let t of e.popped)this._dispatch(`popped`,t);else this._dispatch(`replaced`,null);e.previousVisiblePage!==e.visiblePage&&this._dispatch(`notify::visible-page`,e.visiblePage)}_dispatch(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:{page:t,tag:t?.tag??null}}))}_onKeyDown=e=>{if(e.defaultPrevented)return;let t;if(e.key===`Escape`)t=this._state.popFromEscape();else if(e.altKey&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)){let n=getComputedStyle(this).direction===`rtl`?`ArrowRight`:`ArrowLeft`;if(e.key!==n)return;t=this._state.popFromShortcut()}else return;t===`stop`&&(e.preventDefault(),e.stopPropagation())};_syncClasses(){this.classList.toggle(`animated`,this.animateTransitions)}_render(){let e=this._state.visiblePage;for(let t of this._state.pages){this._attach(t);let n=t===e;t.classList.toggle(`visible-page`,n),t.hidden=!n,n||this._removeBackButton(t)}e&&this._syncBackButton(e)}_attach(e){e.parentNode!==this._pagesEl&&(e.classList.add(`adw-navigation-page`),this._pagesEl.appendChild(e))}_detach(e){this._removeBackButton(e),e.classList.remove(`visible-page`),e.parentNode===this._pagesEl&&this._pagesEl.removeChild(e)}_syncBackButton(e){if(!this._state.canGoBack()||e.hasAttribute(`no-back-button`)){this._removeBackButton(e);return}let t=this._state.backButtonTooltip()??wn,n=this._backButtons.get(e);if(n){n.setAttribute(`tooltip`,t);return}let r=e.querySelector(`adw-header-bar`);if(!r)return;let i=r.startSection??null;if(!i)return;let a=document.createElement(`gtk-button`);a.classList.add(`adw-navigation-back-button`),a.setAttribute(`icon`,`go-previous`),a.setAttribute(`flat`,``),a.setAttribute(`tooltip`,t),a.addEventListener(`click`,()=>this.pop()),i.insertBefore(a,i.firstChild),this._backButtons.set(e,a)}_removeBackButton(e){let t=this._backButtons.get(e);t&&(t.parentNode&&t.parentNode.removeChild(t),this._backButtons.delete(e))}};customElements.define(`adw-navigation-view`,AdwNavigationView),customElements.define(`adw-navigation-page`,AdwNavigationPage);var AdwNavigationSplitView=class extends WidgetElement{_sidebarEl;_contentEl;_initialized=!1;_disposeBreakpoint;_breakpointApplied=!1;_state=new NavigationSplitViewState;_reflecting=!1;static get observedAttributes(){return[`collapsed`,`show-content`,`sidebar-position`,`min-sidebar-width`,`max-sidebar-width`,`breakpoint`]}get collapsed(){return this._initialized?this._state.collapsed:this.hasAttribute(`collapsed`)}set collapsed(e){this.toggleAttribute(`collapsed`,e)}get showContent(){return this._initialized?this._state.showContent:this.hasAttribute(`show-content`)}set showContent(e){this.toggleAttribute(`show-content`,e)}get sidebarPosition(){return this.getAttribute(`sidebar-position`)===`end`?`end`:`start`}set sidebarPosition(e){this.setAttribute(`sidebar-position`,e)}get sidebarTag(){return this._state.sidebarTag}get contentTag(){return this._state.contentTag}push(e){return this._state.push(e)}pop(){return this._state.pop()}connectedCallback(){this._buildOnce(),this._reflectShowContent(),this._syncWidth(),this._syncClasses(),this._syncBreakpoint()}_buildOnce(){this._initialized||(this._initialized=!0,this._sidebarEl=document.createElement(`div`),this._sidebarEl.className=`adw-nsv-sidebar`,this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-nsv-content`,bindSlottedChildren(this,[{name:`sidebar`,into:this._sidebarEl},{name:`content`,into:this._contentEl}],(e,t)=>this._mountPane(t.name===`sidebar`?`sidebar`:`content`)).install(this._sidebarEl,this._contentEl),this._state=new NavigationSplitViewState({sidebarPosition:this.sidebarPosition,collapsed:this.hasAttribute(`collapsed`),showContent:this.hasAttribute(`show-content`),onCritical:e=>console.error(e),onDelegate:(e,t)=>{let n={tag:t,handled:!1};return this.dispatchEvent(new CustomEvent(`navigation-${e}`,{bubbles:!0,detail:n})),n.handled}}),this._mountPane(`sidebar`),this._mountPane(`content`),this._state.subscribe(()=>{this._reflectShowContent(),this._syncClasses()}))}_mountPane(e){let t=e===`sidebar`?this._sidebarEl:this._contentEl,n=Array.from(t.children),r=n.length>0?{tag:this._tagOf(n)}:null;e===`sidebar`?this._state.setSidebar(r):this._state.setContent(r)}_tagOf(e){for(let t of e){let e=t.getAttribute(`tag`);if(e!==null)return e}return null}_reflectShowContent(){if(this._reflecting)return;let e=this._state.showContent;if(this.hasAttribute(`show-content`)!==e){this._reflecting=!0;try{this.toggleAttribute(`show-content`,e)}finally{this._reflecting=!1}}}disconnectedCallback(){this._disposeBreakpoint?.(),this._disposeBreakpoint=void 0}attributeChangedCallback(e){if(this._initialized){if(e===`breakpoint`){this._syncBreakpoint();return}if(e===`min-sidebar-width`||e===`max-sidebar-width`){this._syncWidth();return}e===`collapsed`&&this._state.setCollapsed(this.hasAttribute(`collapsed`)),e===`show-content`&&this._state.setShowContent(this.hasAttribute(`show-content`)),e===`sidebar-position`&&this._state.setSidebarPosition(this.sidebarPosition),this._syncClasses(),this._syncWidth()}}_syncWidth(){if(this.collapsed){this._sidebarEl.style.minWidth=``,this._sidebarEl.style.maxWidth=``;return}let e=resolveSidebarBounds({minSidebarWidth:this._widthAttr(`min-sidebar-width`,180),maxSidebarWidth:this._widthAttr(`max-sidebar-width`,280)},0,{ceil:!0});this._sidebarEl.style.minWidth=`${e.min}px`,this._sidebarEl.style.maxWidth=`${e.max}px`}_widthAttr(e,t){let n=this.getAttribute(e);if(n===null)return t;let r=parseFloat(n);return Number.isFinite(r)?r:t}get _direction(){return getComputedStyle(this).direction===`rtl`?`rtl`:`ltr`}_syncClasses(){let e=this._state;this.classList.toggle(`collapsed`,e.collapsed),this.classList.toggle(`show-content`,e.showContent),this.classList.toggle(`sidebar-end`,e.sidebarPosition===`end`),this.classList.toggle(`sidebar-at-visual-start`,isSidebarAtVisualStart(e.sidebarPosition,this._direction)),this._sidebarEl?.classList.toggle(`sidebar-pane`,!e.collapsed),this._contentEl?.classList.toggle(`content-pane`,!e.collapsed);let{stack:t}=e.stack,n=t[t.length-1]??null;this._sidebarEl&&(this._sidebarEl.dataset.paneVisible=String(!e.collapsed||n===`sidebar`)),this._contentEl&&(this._contentEl.dataset.paneVisible=String(!e.collapsed||n===`content`))}_syncBreakpoint(){this._disposeBreakpoint?.(),this._disposeBreakpoint=bindBreakpointSetter(this,this.getAttribute(`breakpoint`),e=>{this._breakpointApplied=e,this.collapsed=e},this._breakpointApplied)}};customElements.define(`adw-navigation-split-view`,AdwNavigationSplitView);const ni={animate(e){let t=0,n=!1,r=performance.now(),step=i=>{if(n)return;let a=Math.min((i-r)/250,1),o=1-(1-a)*(1-a);if(e.onValue(e.from+(e.to-e.from)*o),a<1){t=requestAnimationFrame(step);return}e.onValue(e.to),e.onDone()};return t=requestAnimationFrame(step),{cancel(){n=!0,t&&cancelAnimationFrame(t)}}}};function readTriStateAttr(e,t,n){let r=e.getAttribute(t);return r===null?n:r!==`false`&&r!==`0`}var AdwOverlaySplitView=class extends WidgetElement{static signals={"notify::show-sidebar":`notify::show-sidebar`};_initialized=!1;_sidebarEl;_contentEl;_backdropEl;_disposeBreakpoint;_breakpointApplied=!1;_state=new OverlaySplitViewState;_notifiedShowSidebar=null;_reflecting=!1;_measuredWidth=0;_resizeObserver;_swipePointer=null;_swipeOrigin={x:0,progress:0};static get observedAttributes(){return[`show-sidebar`,`collapsed`,`pin-sidebar`,`sidebar-position`,`min-sidebar-width`,`max-sidebar-width`,`sidebar-width-fraction`,`enable-show-gesture`,`enable-hide-gesture`,`breakpoint`]}get showSidebar(){return this._state.showSidebar}set showSidebar(e){this.setAttribute(`show-sidebar`,e?``:`false`)}get show_sidebar(){return this.showSidebar}set show_sidebar(e){this.showSidebar=e}get_show_sidebar(){return this.showSidebar}set_show_sidebar(e){this.showSidebar=e}get collapsed(){return this._state.collapsed}set collapsed(e){e?this.setAttribute(`collapsed`,``):this.removeAttribute(`collapsed`)}get minSidebarWidth(){return parseFloat(this.getAttribute(`min-sidebar-width`)||`180`)}get maxSidebarWidth(){return parseFloat(this.getAttribute(`max-sidebar-width`)||`280`)}get sidebarWidthFraction(){return parseFloat(this.getAttribute(`sidebar-width-fraction`)||`0.25`)}connectedCallback(){this._buildOnce(),this._bindToDocument(),this._reflectShowSidebar(),this._syncClasses(),this._syncSidebarWidth(),this._syncBreakpoint()}_buildOnce(){this._initialized||(this._initialized=!0,this._sidebarEl=document.createElement(`div`),this._sidebarEl.className=`adw-osv-sidebar`,this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-osv-content`,this._backdropEl=document.createElement(`div`),this._backdropEl.className=`adw-osv-backdrop`,this._backdropEl.addEventListener(`click`,()=>this.hideSidebar()),bindSlottedChildren(this,[{name:`sidebar`,into:this._sidebarEl},{name:`content`,into:this._contentEl},{into:this._contentEl}]).install(this._sidebarEl,this._contentEl,this._backdropEl),this._state=new OverlaySplitViewState({collapsed:this.hasAttribute(`collapsed`),showSidebar:readTriStateAttr(this,`show-sidebar`,!0),pinSidebar:this.hasAttribute(`pin-sidebar`),sidebarPosition:this.getAttribute(`sidebar-position`)===`end`?`end`:`start`,enableShowGesture:readTriStateAttr(this,`enable-show-gesture`,!0),enableHideGesture:readTriStateAttr(this,`enable-hide-gesture`,!0),animator:ni}),this._state.subscribe(()=>{this._reflectShowSidebar(),this._syncClasses()}),this.addEventListener(`keydown`,this._onKeyDown),this._bindSwipe())}_bindToDocument(){this._resizeObserver?.disconnect(),this._resizeObserver=new ResizeObserver(e=>{let t=e[e.length-1];if(!t)return;let n=t.borderBoxSize?.[0];this._measuredWidth=n?n.inlineSize:t.contentRect.width,this._syncSidebarWidth(),this._syncClasses()}),this._resizeObserver.observe(this),this._measuredWidth=this.offsetWidth}disconnectedCallback(){this._disposeBreakpoint?.(),this._disposeBreakpoint=void 0,this._resizeObserver?.disconnect(),this._resizeObserver=void 0}_onKeyDown=e=>{e.key!==`Escape`||e.defaultPrevented||this._state.escape()&&e.preventDefault()};attributeChangedCallback(e,t,n){if(this._initialized){if(e===`breakpoint`){this._syncBreakpoint();return}this._readAttribute(e),(e===`min-sidebar-width`||e===`max-sidebar-width`||e===`sidebar-width-fraction`||e===`collapsed`)&&this._syncSidebarWidth(),this._syncClasses()}}_readAttribute(e){let t=this._state;if(e===`pin-sidebar`&&t.setPinSidebar(this.hasAttribute(`pin-sidebar`)),e===`sidebar-position`){let e=this.getAttribute(`sidebar-position`);t.setSidebarPosition(e===`end`?`end`:`start`)}e===`show-sidebar`&&t.setShowSidebar(readTriStateAttr(this,`show-sidebar`,!0)),e===`enable-show-gesture`&&t.setEnableShowGesture(readTriStateAttr(this,`enable-show-gesture`,!0)),e===`enable-hide-gesture`&&t.setEnableHideGesture(readTriStateAttr(this,`enable-hide-gesture`,!0)),e===`collapsed`&&t.setCollapsed(this.hasAttribute(`collapsed`)),this._reflectShowSidebar()}_reflectShowSidebar(){if(this._reflecting)return;let e=this._state.showSidebar?``:`false`;if(this.getAttribute(`show-sidebar`)!==e){this._reflecting=!0;try{this.setAttribute(`show-sidebar`,e)}finally{this._reflecting=!1}}this._notifyShowSidebar()}_notifyShowSidebar(){let e=this._state.showSidebar,t=this._notifiedShowSidebar;this._notifiedShowSidebar=e,!(t===null||t===e)&&this.dispatchEvent(new CustomEvent(`notify::show-sidebar`,{bubbles:!0,detail:{showSidebar:e}}))}_syncBreakpoint(){this._disposeBreakpoint?.(),this._disposeBreakpoint=bindBreakpointSetter(this,this.getAttribute(`breakpoint`),e=>{this._breakpointApplied=e,this.collapsed=e},this._breakpointApplied)}openSidebar(){this.showSidebar=!0,this.dispatchEvent(new CustomEvent(`sidebar-toggled`,{detail:{isVisible:!0}}))}hideSidebar(){this.showSidebar=!1,this.dispatchEvent(new CustomEvent(`sidebar-toggled`,{detail:{isVisible:!1}}))}toggleSidebar(){this.showSidebar=!this.showSidebar,this.dispatchEvent(new CustomEvent(`sidebar-toggled`,{detail:{isVisible:this.showSidebar}}))}get _direction(){return getComputedStyle(this).direction===`rtl`?`rtl`:`ltr`}get _widthSpec(){return{minSidebarWidth:this.minSidebarWidth,maxSidebarWidth:this.maxSidebarWidth,sidebarWidthFraction:this.sidebarWidthFraction}}get _sidebarWidth(){return resolveOverlaySidebarWidth({...this._widthSpec,totalWidth:this._measuredWidth,collapsed:this._state.collapsed})}_syncClasses(){let e=this._state;this.classList.toggle(`collapsed`,e.collapsed),this.classList.toggle(`show-sidebar`,e.showSidebar);let t=isSidebarAtVisualStart(e.sidebarPosition,this._direction);this.classList.toggle(`sidebar-start`,e.sidebarPosition===`start`),this.classList.toggle(`sidebar-end`,e.sidebarPosition===`end`),this.classList.toggle(`sidebar-at-visual-start`,t),this._sidebarEl?.classList.toggle(`sidebar-pane`,!e.collapsed),this._sidebarEl?.classList.toggle(`overlay-pane`,e.collapsed),this._contentEl?.classList.toggle(`content-pane`,!e.collapsed),this._backdropEl&&(this._backdropEl.hidden=!e.shieldVisible),this._sidebarEl?.setAttribute(`aria-hidden`,String(!e.sidebarFocusable)),this._contentEl?.setAttribute(`aria-hidden`,String(!e.contentFocusable)),this._syncGeometry()}_syncGeometry(){let e=this._sidebarEl;if(!e)return;if(this._measuredWidth<=0){for(let t of[`left`,`marginLeft`,`marginRight`,`width`,`minWidth`,`maxWidth`,`opacity`,`pointerEvents`])e.style[t]=``;this._backdropEl&&(this._backdropEl.style.opacity=``);return}let t=this._state,n=this._sidebarWidth,r=layoutOverlaySplitView({totalWidth:this._measuredWidth,sidebarWidth:n,showProgress:t.showProgress,collapsed:t.collapsed,sidebarPosition:t.sidebarPosition,direction:this._direction}),i=isSidebarAtVisualStart(t.sidebarPosition,this._direction);if(e.style.width=`${r.sidebar.width}px`,t.collapsed)e.style.marginLeft=``,e.style.marginRight=``,e.style.insetInlineStart=``,e.style.left=`${r.sidebar.x}px`;else{e.style.left=``;let r=n-Math.trunc(n*Math.min(t.showProgress,1));e.style.marginLeft=i?`${-r}px`:``,e.style.marginRight=i?``:`${-r}px`}e.style.opacity=t.showProgress<=0?`0`:`1`,e.style.pointerEvents=t.sidebarPainted?``:`none`,this._backdropEl&&(this._backdropEl.style.opacity=String(1-r.shadowProgress))}_syncSidebarWidth(){if(!this._sidebarEl)return;let e=resolveSidebarBounds(this._widthSpec,0,{ceil:!0});this._sidebarEl.style.minWidth=`${e.min}px`,this._sidebarEl.style.maxWidth=`${e.max}px`,this._syncGeometry()}_bindSwipe(){this.addEventListener(`pointerdown`,e=>{if(this._swipePointer!==null||e.button!==0)return;let t=this._state,n=this.getBoundingClientRect(),r=resolveSwipeArea({isDrag:!0,sidebarWidth:this._sidebarWidth,showProgress:t.showProgress,totalWidth:n.width,totalHeight:n.height,sidebarPosition:t.sidebarPosition,direction:this._direction}),i=e.clientX-n.left,a=e.clientY-n.top;i<r.x||i>r.x+r.width||a<r.y||a>r.y+r.height||(this._swipePointer=e.pointerId,this._swipeOrigin={x:e.clientX,progress:t.showProgress})}),this.addEventListener(`pointermove`,e=>{if(e.pointerId!==this._swipePointer)return;let t=this._state,n=this._sidebarWidth||1,r=isSidebarAtVisualStart(t.sidebarPosition,this._direction),i=(e.clientX-this._swipeOrigin.x)/n*(r?1:-1);if(!t.swipeActive){if(!resolveSwipeStart({showProgress:t.showProgress,collapsed:t.collapsed,direction:i>=0?`forward`:`back`,enableShowGesture:t.enableShowGesture,enableHideGesture:t.enableHideGesture})){this._swipePointer=null;return}t.beginSwipe();try{this.setPointerCapture(e.pointerId)}catch{}}t.setShowProgress(this._swipeOrigin.progress+i)});let release=(e,t)=>{if(e.pointerId!==this._swipePointer)return;this._swipePointer=null;let n=this._state;if(!n.swipeActive)return;this.hasPointerCapture(e.pointerId)&&this.releasePointerCapture(e.pointerId);let r=resolveSwipeSnapPoints({showProgress:n.showProgress,enableShowGesture:n.enableShowGesture,enableHideGesture:n.enableHideGesture,swipeActive:!0}),i=t?swipeCancelProgress(n.showProgress):r.reduce((e,t)=>Math.abs(t-n.showProgress)<Math.abs(e-n.showProgress)?t:e);n.endSwipe(i)};this.addEventListener(`pointerup`,e=>release(e,!1)),this.addEventListener(`pointercancel`,e=>release(e,!0))}};customElements.define(`adw-overlay-split-view`,AdwOverlaySplitView);var AdwPasswordEntryRow=class extends AdwEntryRow{_password=new PasswordEntryRowState(this._state);_toggle;_toggleIcon;static get observedAttributes(){return[...AdwEntryRow.observedAttributes,`revealed`]}get _classPrefix(){return`adw-password-entry-row`}get revealed(){return this._password.revealed}set revealed(e){this._password.setRevealed(e)}get capsLockOn(){return this._password.capsLockOn}setCapsLockOn(e){this._password.setCapsLockOn(e)}_onConnected(){this._input.type=`password`,this._input.autocomplete=`off`,this._toggle=document.createElement(`button`),this._toggle.type=`button`,this._toggle.className=`adw-button flat circular icon-only ${this._classPrefix}-toggle`,this._toggleIcon=createGtkImage(null),this._toggle.append(this._toggleIcon),this._toggle.addEventListener(`click`,()=>this._password.togglePeek()),this.addSuffix(this._toggle);let readCapsLock=e=>this._password.setCapsLockOn(e.getModifierState(`CapsLock`));this._input.addEventListener(`keydown`,readCapsLock),this._input.addEventListener(`keyup`,readCapsLock);let e=this._password.state;this.setIndicatorIconName(e.indicatorIconName),this.setIndicatorTooltip(e.indicatorTooltip),this.hasAttribute(`revealed`)&&this._password.setRevealed(this.getAttribute(`revealed`)!==`false`),this._renderPassword(this._password.state),this._password.subscribe(e=>{this._renderPassword(e),this.dispatchEvent(new CustomEvent(`notify::revealed`,{bubbles:!0,detail:{revealed:e.revealed}}))})}attributeChangedCallback(e,t,n){if(e!==`revealed`){super.attributeChangedCallback(e,t,n);return}this._initialized&&this._password.setRevealed(n!==null&&n!==`false`)}_renderPassword(e){this._input.type=e.revealed?`text`:`password`,this._toggleIcon.dataset.iconName=e.peekIconName,this._toggleIcon.iconName=e.peekIconName,this._toggle.title=e.peekLabel,this._toggle.setAttribute(`aria-label`,e.peekLabel),this._toggle.setAttribute(`aria-pressed`,String(e.revealed)),e.revealed?this.setAttribute(`revealed`,``):this.removeAttribute(`revealed`)}};customElements.define(`adw-password-entry-row`,AdwPasswordEntryRow);const ri=new Set([`adw-action-row`,`adw-switch-row`,`adw-combo-row`,`adw-spin-row`]),ii=new Set([...ri,`adw-entry-row`,`adw-password-entry-row`,`adw-expander-row`,`adw-button-row`]);function isVisible(e){return!(e instanceof HTMLElement&&e.hidden)}function groupRows(e){let t=e.querySelector(`:scope > .adw-preferences-group-listbox`);return Array.from((t??e).children).filter(e=>ii.has(e.tagName.toLowerCase()))}function describeRow(e){let t=e.getAttribute(`subtitle`);return{title:e.getAttribute(`title`)??``,subtitle:t,visible:isVisible(e),isActionRow:ri.has(e.tagName.toLowerCase()),useMarkup:!1,useUnderline:!1,ref:e}}function describeGroup(e){return{title:e.getAttribute(`title`)??``,visible:isVisible(e),rows:groupRows(e).map(describeRow),ref:e}}function describePreferencesPages(e){return Array.from(e.querySelectorAll(`adw-preferences-page`)).map(e=>({name:e.getAttribute(`name`),title:e.getAttribute(`title`)??``,iconName:e.getAttribute(`icon-name`),useUnderline:e.hasAttribute(`use-underline`),visible:isVisible(e),description:e.getAttribute(`description`)??``,groups:Array.from(e.querySelectorAll(`adw-preferences-group`)).map(describeGroup),ref:e}))}function searchPreferencesDom(e,t,n){return searchPreferences(describePreferencesPages(e),t,n)}var AdwPreferencesPage=class extends WidgetElement{static get observedAttributes(){return[`title`,`icon-name`,`name`,`use-underline`,`open`]}get name(){return this.getAttribute(`name`)??``}set name(e){this.setAttribute(`name`,e)}get iconName(){return this.getAttribute(`icon-name`)??``}set iconName(e){this.setAttribute(`icon-name`,e)}get useUnderline(){return this.hasAttribute(`use-underline`)}set useUnderline(e){this.toggleAttribute(`use-underline`,e)}get groups(){return Array.from(this.querySelectorAll(`adw-preferences-group`))}},AdwPreferencesDialog=class extends WidgetElement{_initialized=!1;_scrimEl;_dialogEl;_titleEl;_bodyEl;_pagesEl;_closeBtn;_modal;static get observedAttributes(){return[`title`,`open`,`can-close`,`content-width`]}get open(){return this.hasAttribute(`open`)}set open(e){e?this.setAttribute(`open`,``):this.removeAttribute(`open`)}get canClose(){let e=this.getAttribute(`can-close`);return e===null?!0:e!==`false`}set canClose(e){e?this.setAttribute(`can-close`,``):this.setAttribute(`can-close`,`false`)}get contentWidth(){let e=Number.parseInt(this.getAttribute(`content-width`)??``,10);return Number.isNaN(e)?640:e}set contentWidth(e){this.setAttribute(`content-width`,String(e))}present(e){this.isConnected||(e??document.body).appendChild(this),this.open=!0}close(){this._attemptClose()}forceClose(){this.open&&=!1}add(e){this._pagesEl.appendChild(e)}removePage(e){return e.parentNode===this._pagesEl?(this._pagesEl.removeChild(e),!0):!1}get pages(){return Array.from(this._pagesEl.querySelectorAll(`adw-preferences-page`))}search(e,t){return searchPreferencesDom(this._pagesEl,e,t)}connectedCallback(){if(this._initialized)return;this._initialized=!0,this._scrimEl=document.createElement(`div`),this._scrimEl.className=`adw-preferences-dialog-scrim`,this._scrimEl.addEventListener(`click`,()=>this._attemptClose()),this._dialogEl=document.createElement(`div`),this._dialogEl.className=`adw-preferences-dialog-box`,this._dialogEl.addEventListener(`click`,e=>e.stopPropagation());let e=document.createElement(`div`);e.className=`adw-preferences-dialog-header`;let t=document.createElement(`div`);t.className=`adw-preferences-dialog-header-side`,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-preferences-dialog-title`;let n=document.createElement(`div`);n.className=`adw-preferences-dialog-header-side adw-preferences-dialog-header-side--end`,this._closeBtn=document.createElement(`button`),this._closeBtn.type=`button`,this._closeBtn.className=`adw-preferences-dialog-close`,this._closeBtn.setAttribute(`aria-label`,`Close`),this._closeBtn.addEventListener(`click`,()=>this._attemptClose()),n.appendChild(this._closeBtn),e.append(t,this._titleEl,n),this._bodyEl=document.createElement(`div`),this._bodyEl.className=`adw-preferences-dialog-body`,this._pagesEl=document.createElement(`div`),this._pagesEl.className=`adw-preferences-dialog-pages`,this._bodyEl.appendChild(this._pagesEl),this._dialogEl.append(e,this._bodyEl),bindSlottedChildren(this,[{into:this._pagesEl}]).install(this._scrimEl,this._dialogEl),this._modal=new AdwModalSurface({host:this,surface:this._dialogEl,role:`dialog`,isOpen:()=>this.open,onEscape:()=>this._attemptClose()}),this._render()}attributeChangedCallback(e,t,n){this._initialized&&t!==n&&(this._render(),e===`open`&&(this.dispatchEvent(new CustomEvent(`notify::open`,{bubbles:!0,detail:{open:this.open}})),this.open?this._modal.present():(this.dispatchEvent(new CustomEvent(`closed`,{bubbles:!0})),this._modal.dismiss())))}_attemptClose(){if(this.open){if(!this.canClose){this.dispatchEvent(new CustomEvent(`close-attempt`,{bubbles:!0}));return}this.open=!1}}_render(){this.classList.toggle(`open`,this.open);let e=this.getAttribute(`title`)??``;this._titleEl.textContent=e,this._dialogEl.style.setProperty(`--adw-dialog-content-width`,`${this.contentWidth}px`);let t=!this.canClose;this._closeBtn.disabled=t,this._closeBtn.classList.toggle(`locked`,t)}};customElements.define(`adw-preferences-page`,AdwPreferencesPage),customElements.define(`adw-preferences-dialog`,AdwPreferencesDialog);function isHeaderSuffix(e){return e instanceof Element&&e.getAttribute(`slot`)===`header-suffix`}var AdwPreferencesGroup=class extends WidgetElement{_headerEl;_titleEl;_descriptionEl;_suffixEl;_listboxEl;_initialized=!1;_observer=null;static get observedAttributes(){return[`title`,`description`]}get description(){return this.getAttribute(`description`)??``}set description(e){e?this.setAttribute(`description`,e):this.removeAttribute(`description`)}addRow(e){isHeaderSuffix(e)?this._suffixEl.appendChild(e):this._listboxEl.appendChild(e),this._renderHeader()}removeRow(e){let t=e.parentNode;return t!==this._listboxEl&&t!==this._suffixEl?!1:(t.removeChild(e),this._renderHeader(),!0)}connectedCallback(){if(this._initialized){this._observeBoxes();return}this._initialized=!0,this._headerEl=document.createElement(`div`),this._headerEl.className=`adw-preferences-group-header`;let e=document.createElement(`div`);e.className=`adw-preferences-group-labels`,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-preferences-group-title`,this._descriptionEl=document.createElement(`span`),this._descriptionEl.className=`adw-preferences-group-description`,e.append(this._titleEl,this._descriptionEl),this._suffixEl=document.createElement(`div`),this._suffixEl.className=`adw-preferences-group-suffix`,this._headerEl.append(e,this._suffixEl),this._listboxEl=document.createElement(`div`),this._listboxEl.className=`adw-preferences-group-listbox`,bindSlottedChildren(this,[{name:`header-suffix`,into:this._suffixEl},{into:this._listboxEl}],()=>this._renderHeader()).install(this._headerEl,this._listboxEl),this.setAttribute(`role`,`group`),this._observeBoxes()}disconnectedCallback(){this._observer?.disconnect(),this._observer=null}attributeChangedCallback(){this._initialized&&this._renderHeader()}_observeBoxes(){this._observer||(this._observer=new MutationObserver(()=>this._renderHeader()),this._observer.observe(this._listboxEl,{childList:!0}),this._observer.observe(this._suffixEl,{childList:!0}),this._renderHeader())}_renderHeader(){let e=this.getAttribute(`title`)??``,t=this.getAttribute(`description`)??``;this._titleEl.textContent=e,this._descriptionEl.textContent=t;let n=derivePreferencesGroupHeader({title:e,description:t,hasHeaderSuffix:this._suffixEl.childElementCount>0,rowCount:this._listboxEl.childElementCount,useMarkup:!1});this._titleEl.hidden=!n.titleVisible,this._descriptionEl.hidden=!n.descriptionVisible,this._headerEl.hidden=!n.headerVisible,this._headerEl.classList.toggle(`single-line`,n.singleLine),this._listboxEl.hidden=!n.listboxVisible}};customElements.define(`adw-preferences-group`,AdwPreferencesGroup);var AdwPreferencesRow=class extends TooltipElement{_titleEl;_contentEl;_initialized=!1;static get observedAttributes(){return[`title`,`title-selectable`,`use-markup`,`use-underline`,`tooltip-text`]}get title(){return this.getAttribute(`title`)??``}set title(e){e===``?this.removeAttribute(`title`):this.setAttribute(`title`,e)}get titleSelectable(){return this.hasAttribute(`title-selectable`)}set titleSelectable(e){this.toggleAttribute(`title-selectable`,e)}get useMarkup(){return this.hasAttribute(`use-markup`)}set useMarkup(e){this.toggleAttribute(`use-markup`,e)}get useUnderline(){return this.hasAttribute(`use-underline`)}set useUnderline(e){this.toggleAttribute(`use-underline`,e)}get child(){return this._contentEl?.firstElementChild??null}set child(e){this._contentEl?.replaceChildren(...e===null?[]:[e])}connectedCallback(){this._initialized||(this._initialized=!0,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-row-title`,this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-preferences-row-content`,bindSlottedChildren(this,[{name:`child`,into:this._contentEl}]).install(this._titleEl,this._contentEl),bindEmptySections(this._contentEl),this.hasAttribute(`role`)||this.setAttribute(`role`,`listitem`),this._render())}attributeChangedCallback(e,t,n){this._initialized&&(this._render(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:n}})))}_render(){let e=labelDisplayText(this.title,this.useMarkup,this.useUnderline);this._titleEl.textContent=e,this._titleEl.hidden=!stringIsNotEmpty(e),this._titleEl.style.userSelect=this.titleSelectable?`text`:``,applyRowTooltip(this,[this._titleEl,this._contentEl])}};customElements.define(`adw-preferences-row`,AdwPreferencesRow);var AdwShortcutLabel=class extends WidgetElement{_initialized=!1;static get observedAttributes(){return[`accelerator`,`disabled-text`]}connectedCallback(){this._initialized||(this._initialized=!0,this.hasAttribute(`role`)||this.setAttribute(`role`,`img`)),this._render()}attributeChangedCallback(e){this._initialized&&(this._render(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0})))}get accelerator(){return this.getAttribute(`accelerator`)??``}set accelerator(e){this.setAttribute(`accelerator`,e)}get disabledText(){return this.getAttribute(`disabled-text`)??``}set disabledText(e){this.setAttribute(`disabled-text`,e)}_render(){let{nodes:e,accessibleLabel:t,error:n}=parseShortcutLabel(this.accelerator,{disabledText:this.disabledText,direction:this._direction()});this.replaceChildren(...e.map(e=>this._nodeElement(e))),this.setAttribute(`aria-label`,t),n&&console.warn(`adw-shortcut-label: failed to parse ${n}, part of accelerator '${this.accelerator}'`)}_direction(){let e=this.isConnected?getComputedStyle(this).direction:``;return e===`rtl`||e===`ltr`?e:this.closest(`[dir="rtl"]`)?`rtl`:`ltr`}_nodeElement(e){if(e.kind===`separator`||e.kind===`disabled`){let t=document.createElement(`span`);return t.className=e.kind===`disabled`?`dimmed adw-shortcut-label-disabled`:`dimmed`,t.textContent=e.text,t}let t=document.createElement(`span`);t.className=`adw-shortcut-label-keys`,t.setAttribute(`dir`,`ltr`);for(let n of e.keys){let e=document.createElement(`span`);if(e.className=`keycap`,e.textContent=n.label,n.sideMarker){let t=document.createElement(`sub`);t.className=`adw-shortcut-label-side`,t.textContent=n.sideMarker,e.append(t)}t.append(e)}return t}};customElements.define(`adw-shortcut-label`,AdwShortcutLabel);var AdwShortcutsDialog=class extends AdwDialog{get sections(){return[...this.contentArea.children].filter(e=>e.localName===`adw-shortcuts-section`)}connectedCallback(){super.connectedCallback(),this.classList.add(`adw-shortcuts-dialog`)}};customElements.define(`adw-shortcuts-dialog`,AdwShortcutsDialog);const ai=new WeakMap,oi=new WeakMap;var AdwSidebarItem=class extends WidgetElement{static get observedAttributes(){return[`title`,`subtitle`,`icon-name`,`disabled`,`hidden`,`enabled`,`visible`,`needs-attention`,`badge-number`]}get enabled(){let e=this.getAttribute(`enabled`);return e===null?!this.hasAttribute(`disabled`):booleanAttribute$2(e,!0)}set enabled(e){this.setAttribute(`enabled`,e?`true`:`false`),this.toggleAttribute(`disabled`,!e)}get visible(){let e=this.getAttribute(`visible`);return e===null?!this.hasAttribute(`hidden`):booleanAttribute$2(e,!0)}set visible(e){this.setAttribute(`visible`,e?`true`:`false`),this.toggleAttribute(`hidden`,!e)}attributeChangedCallback(e,t,n){let r=ai.get(this);if(!r)return;let i=n??``;e===`title`?r.spec.title=i:e===`subtitle`?r.spec.subtitle=i:e===`icon-name`?r.spec.iconName=i:e===`disabled`?r.spec.enabled=n===null:e===`enabled`?r.spec.enabled=booleanAttribute$2(n,!0):e===`hidden`?r.spec.visible=n===null:e===`visible`?r.spec.visible=booleanAttribute$2(n,!0):e===`needs-attention`?r.spec.needsAttention=n===null:e===`badge-number`&&(r.spec.badgeNumber=Number.parseInt(i,10)||0),r.sidebar.refresh()}},AdwSidebarSection=class extends WidgetElement{static get observedAttributes(){return[`title`]}attributeChangedCallback(e,t,n){let r=oi.get(this);r&&(r.spec.title=n??``,r.sidebar.refresh())}},AdwSidebar=class extends WidgetElement{_state=new SidebarState;_listEl;_rows=[];_initialized=!1;_reflecting=!1;static get observedAttributes(){return[`mode`,`selected`]}get selected(){return this._state.selected}set selected(e){this.setAttribute(`selected`,String(e))}get selectedItem(){return this._state.selectedItem}get mode(){return this._state.mode}set mode(e){this.setAttribute(`mode`,e)}get sections(){return this._state.sections}set sections(e){this._state.setSections(e),this._rebuild()}get filter(){return this._state.filter}set filter(e){this._state.setFilter(e),this._rebuild()}connectedCallback(){this._initialized||(this._initialized=!0,this._listEl=document.createElement(`div`),this._listEl.className=`adw-sidebar-list`,this._listEl.setAttribute(`role`,`listbox`),attachRovingFocus({host:this,orientation:`vertical`,items:()=>this._rows.filter(e=>!e.el.hidden&&!e.el.disabled).map(e=>e.el),select:e=>{let t=this._rows.find(t=>t.el===e);t!==void 0&&this._state.setSelected(t.index)}}),this._state.setSections(this._readDeclaredSections()),this._state.setMode(this._readModeAttr()),this.hasAttribute(`selected`)&&this._state.setSelected(this._readSelectedAttr()),this._state.subscribe(e=>this._onSelectionChanged(e)),this.replaceChildren(this._listEl),this._applyMode(),this._rebuild(),this._reflectSelected())}attributeChangedCallback(e){if(!(!this._initialized||this._reflecting)){if(e===`selected`){this._state.setSelected(this._readSelectedAttr()),this._reflectSelected();return}e===`mode`&&this._state.setMode(this._readModeAttr())&&(this._applyMode(),this._applySelection())}}refresh(){this._initialized&&(this._state.refresh(),this._rebuild())}_readDeclaredSections(){let e=[];for(let t of Array.from(this.querySelectorAll(`adw-sidebar-section`))){let n=[];for(let e of Array.from(t.querySelectorAll(`adw-sidebar-item`))){let t={title:e.getAttribute(`title`)??``,subtitle:e.getAttribute(`subtitle`)??``,iconName:e.getAttribute(`icon-name`)??``,enabled:e.enabled,visible:e.visible,badgeNumber:Number.parseInt(e.getAttribute(`badge-number`)??`0`,10)||0,needsAttention:e.hasAttribute(`needs-attention`)};ai.set(e,{sidebar:this,spec:t}),n.push(t)}let r={title:t.getAttribute(`title`)??``,items:n};oi.set(t,{sidebar:this,spec:r}),e.push(r)}return e}_readModeAttr(){return this.getAttribute(`mode`)===`page`?`page`:`sidebar`}_readSelectedAttr(){return Number.parseFloat(this.getAttribute(`selected`)??``)}_reflectSelected(){this._reflecting=!0,this.setAttribute(`selected`,String(this._state.selected)),this._reflecting=!1}_onSelectionChanged(e){this._reflectSelected(),this._applySelection(),this.dispatchEvent(new CustomEvent(`notify::selected`,{bubbles:!0,detail:{selected:e.selected,previous:e.previous,interactive:e.interactive}}))}_activate(e){this._state.activate(e).activated&&this.dispatchEvent(new CustomEvent(`activated`,{bubbles:!0,detail:{index:e}}))}_rebuild(){let e=new Map;for(let t of this._state.headers)e.set(t.sectionIndex,t);let t=[];for(let e of this._state.visibleItems){let n=t[t.length-1];n&&n.sectionIndex===e.sectionIndex?n.items.push(e):t.push({sectionIndex:e.sectionIndex,items:[e]})}this._rows=[];let n=[];for(let r of t){let t=e.get(r.sectionIndex);t&&n.push(this._createHeader(t));let i=document.createElement(`div`);i.className=`adw-sidebar-section`;for(let e of r.items){let t=this._createRow(e);i.appendChild(t),this._rows.push({el:t,index:e.index})}n.push(i)}this._listEl.replaceChildren(...n),this.classList.toggle(`empty`,this._state.isEmpty),this._applySelection()}_createHeader(e){let t=document.createElement(`div`);if(t.className=`adw-sidebar-section-header`,e.kind===`title`){t.classList.add(`has-title`);let n=document.createElement(`span`);n.className=`adw-sidebar-section-heading`,n.textContent=e.title,t.appendChild(n)}else t.classList.add(`separator`);return e.first&&t.classList.add(`first`),t}_createRow(e){let t=e.item,n=document.createElement(`button`);n.type=`button`,n.className=`adw-sidebar-item`,n.setAttribute(`role`,`option`),n.hidden=t.visible===!1,n.disabled=t.enabled===!1;let r=createGtkImage(t.iconName??null,`adw-sidebar-item-icon`);r.hidden=!e.iconVisible,n.appendChild(r);let i=document.createElement(`span`);i.className=`adw-sidebar-item-text`;let a=document.createElement(`span`);a.className=`adw-sidebar-item-title`,a.textContent=t.title,a.hidden=!e.titleVisible,i.appendChild(a);let o=document.createElement(`span`);return o.className=`adw-sidebar-item-subtitle`,o.textContent=t.subtitle??``,o.hidden=!e.subtitleVisible,i.appendChild(o),n.appendChild(i),n.appendChild(this._createIndicator(t)),n.appendChild(createGtkImage(`go-next`,`adw-sidebar-item-arrow`)),n.addEventListener(`click`,()=>this._activate(e.index)),n}_createIndicator(e){let t=e.badgeNumber??0,n=e.needsAttention===!0,r=document.createElement(`span`);if(r.className=`indicator`,r.hidden=!n&&t===0,r.classList.toggle(`dot`,t===0),r.classList.toggle(`needs-attention`,n),t>0){let e=document.createElement(`span`);e.className=`numeric`,e.textContent=viewSwitcherBadgeLabel(t),r.appendChild(e)}return r}_applyMode(){let e=this._state.mode===`page`;this.classList.toggle(`page`,e),this.classList.toggle(`mode-sidebar`,!e)}_applySelection(){let e=this._state.selected,t=this._state.selectionVisible;this._rows.forEach((n,r)=>{let i=n.index===e;n.el.classList.toggle(`selected`,i&&t),n.el.setAttribute(`aria-selected`,String(i)),n.el.tabIndex=i||e===-1&&r===0?0:-1})}};customElements.define(`adw-sidebar-item`,AdwSidebarItem),customElements.define(`adw-sidebar-section`,AdwSidebarSection),customElements.define(`adw-sidebar`,AdwSidebar);const si=[`value`,`lower`,`upper`,`stepIncrement`,`pageIncrement`,`pageSize`];function authoredAdjustment(e){let t={};if(!(e instanceof Element))return t;for(let n of si){let r=e.getAttribute(attributeOf(n)),i=r===null?NaN:Number.parseFloat(r);Number.isFinite(i)&&(t[n]=i)}return t}var AdwSpinRow=class extends TooltipElement{_input;_textEl;_controlEl;_titleEl;_subtitleEl;_state=new SpinState;_initialized=!1;static get observedAttributes(){return[`title`,`subtitle`,`value`,`adjustment`,`tooltip-text`,`title-lines`,`subtitle-lines`]}get value(){return this._state.value}set value(e){this._state.setValue(this._roundToStep(e)),this._syncValue()}get adjustment(){return this._state.adjustment}set adjustment(e){this._state.configure(typeof e==`string`?parseAdjustment(e):e)}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=normalizeAdjustment(parseAdjustment(this.getAttribute(`adjustment`)));this._state.configure(e);let t=document.createElement(`div`);t.className=`adw-row-text`,this._textEl=t,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-row-title`,this._subtitleEl=document.createElement(`span`),this._subtitleEl.className=`adw-row-subtitle`,t.append(this._titleEl,this._subtitleEl);let n=document.createElement(`div`);n.className=`adw-spin-control`,this._controlEl=n;let r=document.createElement(`button`);r.className=`adw-spin-dec`,r.textContent=`−`,r.addEventListener(`click`,()=>this._adjust(-this._state.adjustment.stepIncrement));let i=document.createElement(`input`);i.type=`text`,i.value=this._formatValue(this._state.value),i.addEventListener(`change`,()=>{let e=parseFloat(i.value);Number.isNaN(e)?i.value=this._formatValue(this._state.value):(this.value=e,this._emitChange())});let a=document.createElement(`button`);a.className=`adw-spin-inc`,a.textContent=`+`,a.addEventListener(`click`,()=>this._adjust(this._state.adjustment.stepIncrement)),n.append(r,i,a),bindSlottedChildren(this,[{name:`adjustment`,consume:e=>this._state.configure(normalizeAdjustment(authoredAdjustment(e)))}]).install(t,n);let o=this.getAttribute(`value`);this._state.setValue(this._roundToStep(o===null?this._state.value:Number.parseFloat(o))),i.value=this._formatValue(this._state.value),this._input=i,this._state.subscribe(()=>this._syncValue()),this._renderText()}attributeChangedCallback(e,t,n){if(this._initialized){if(e===`title`||e===`subtitle`||e===`tooltip-text`||e===`title-lines`||e===`subtitle-lines`){this._renderText();return}if(e===`adjustment`){this._state.configure(parseAdjustment(n));return}this._state.setValue(this._roundToStep(Number.parseFloat(n||`0`)))}}_renderText(){let e=deriveRowLabels({title:this.getAttribute(`title`),subtitle:this.getAttribute(`subtitle`)});this._titleEl.textContent=e.title,this._titleEl.hidden=!e.titleVisible,this._subtitleEl.textContent=e.subtitle,this._subtitleEl.hidden=!e.subtitleVisible,applyRowTooltip(this,[this._textEl,this._controlEl]),this._applyLineClamping()}_applyLineClamping(){applyRowLineClamp({titleEl:this._titleEl,subtitleEl:this._subtitleEl,textContainerEl:this._titleEl.parentElement,getTitleLines:()=>parseRowLinesAttribute(this.getAttribute(`title-lines`)),getSubtitleLines:()=>parseRowLinesAttribute(this.getAttribute(`subtitle-lines`))})}_adjust(e){this.value=this._state.value+e,this._emitChange()}_emitChange(){this.dispatchEvent(new CustomEvent(`notify::value`,{bubbles:!0,detail:{value:this._state.value}}))}_syncValue(){this._input&&(this._input.value=this._formatValue(this._state.value)),this.setAttribute(`value`,String(this._state.value))}_roundToStep(e){if(!Number.isFinite(e))return e;let t=this._countDecimals(this._state.adjustment.stepIncrement);return t>0?parseFloat(e.toFixed(t)):e}_countDecimals(e){let t=String(e),n=t.indexOf(`.`);return n===-1?0:t.length-n-1}_formatValue(e){let t=this._countDecimals(this._state.adjustment.stepIncrement);return t>0?e.toFixed(t):String(e)}};customElements.define(`adw-spin-row`,AdwSpinRow);const ci=`http://www.w3.org/2000/svg`,li=new Set;let ui=0;function tick(e){for(let t of li)t.drawAt(e);ui=li.size>0?requestAnimationFrame(tick):0}function startTicking(){ui===0&&li.size>0&&(ui=requestAnimationFrame(tick))}var AdwSpinner=class extends WidgetElement{static get observedAttributes(){return[`size`]}_svg=null;_track=null;_arc=null;_circumference=0;_radius=0;_origin=null;connectedCallback(){this._build(),li.add(this),this._origin=null,startTicking()}disconnectedCallback(){li.delete(this)}attributeChangedCallback(){this._sync()}drawAt(e){this._origin===null&&(this._origin=e),this._paint(spinnerProgressAt(e-this._origin))}_build(){if(this._svg)return;let e=document.createElementNS(ci,`svg`);e.setAttribute(`fill`,`none`),e.setAttribute(`aria-hidden`,`true`);let t=document.createElementNS(ci,`circle`);t.setAttribute(`stroke`,`currentColor`),t.setAttribute(`stroke-opacity`,`0.15`);let n=document.createElementNS(ci,`circle`);n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-linecap`,`round`),e.append(t,n),this._svg=e,this._track=t,this._arc=n,this.replaceChildren(e),this.setAttribute(`role`,`progressbar`),this.setAttribute(`aria-busy`,`true`),this._sync()}_sync(){let e=this._svg,t=this._track,n=this._arc;if(!e||!t||!n)return;let r=resolveSpinnerSize(this.getAttribute(`size`)),{diameter:i,lineWidth:a}=spinnerGeometry(r,r);this.style.width=`${r}px`,this.style.height=`${r}px`,e.setAttribute(`width`,String(i)),e.setAttribute(`height`,String(i)),e.setAttribute(`viewBox`,`0 0 ${i} ${i}`);let o=(i-a)/2;this._radius=o,this._circumference=2*Math.PI*o;for(let e of[t,n])e.setAttribute(`cx`,String(i/2)),e.setAttribute(`cy`,String(i/2)),e.setAttribute(`r`,String(o)),e.setAttribute(`stroke-width`,String(a));this._paint(this._origin===null?Nn:this._lastProgress)}_lastProgress=Nn;_paint(e){let t=this._arc;if(!t||this._radius<=0)return;this._lastProgress=e;let{end:n,length:r}=spinnerArc(e),i=r*this._radius;t.setAttribute(`stroke-dasharray`,`${i} ${Math.max(this._circumference-i,0)}`),t.setAttribute(`stroke-dashoffset`,String(-n*this._radius))}};customElements.define(`adw-spinner`,AdwSpinner);var PopoverMenuView=class{surface;prefix;onActivate;_model=[];_actions=null;_title=``;_page=[];_openers=new Set;_backRow=null;_key=`[]`;_rows=[];constructor(e,t,n){this.surface=e,this.prefix=t,this.onActivate=n,this.surface.addEventListener(`keydown`,e=>this._onKeyDown(e))}_onKeyDown(e){let t=document.activeElement;if(!(t===null||!this.surface.contains(t))){if(e.key===`ArrowRight`&&this._openers.has(t)){e.preventDefault(),t.click();return}e.key===`ArrowLeft`&&t===this._backRow&&(e.preventDefault(),t.click())}}get rows(){return this._rows}get page(){return this._page}showPage(e){this._page=[...e]}get focusableRows(){return this._rows.filter(e=>!e.hidden&&!e.disabled)}focusPage(e){let t=this.focusableRows;(t[e]??t[0])?.focus()}setMenuModel(e){let t=JSON.stringify(e);t!==this._key&&(this._key=t,this._page=[]),this._model=e}setActions(e){this._actions=e}setTitle(e){this._title=e}reset(){this._page=[]}currentItems(){if(this._page.length===0)return this._model;let e=menuNodeAt(this._model,this._page);return e!==null&&e.kind!==`item`?e.items:this._model}render(){this.surface.replaceChildren(),this._rows=[],this._openers=new Set,this._backRow=null;let e=menuNodeAt(this._model,this._page);this._page.length>0&&e!==null&&e.kind===`submenu`?this.surface.appendChild(this.backRow(e.label)):this._title.length>0&&this.surface.appendChild(this.heading(this._title,`${this.prefix}-title`));let t=``;for(let e of flattenMenu(this.currentItems(),this._page)){e.separated&&this.surface.appendChild(this.separator());let n=e.path.slice(0,-1),r=n.join(`.`);if(r!==t){t=r;let e=this.sectionHeading(n);e!==null&&this.surface.appendChild(this.heading(e,`adw-popover-section-title`))}e.node.kind===`submenu`?this.surface.appendChild(this.submenuRow(e.node.label,e.node.icon,e.path)):this.surface.appendChild(this.itemRow(e.node,e.path))}}sectionHeading(e){if(e.length<=this._page.length)return null;let t=menuNodeAt(this._model,e);return t!==null&&t.kind===`section`&&t.label!==void 0?t.label:null}heading(e,t){let n=document.createElement(`div`);return n.className=`adw-popover-title ${t}`,n.textContent=e,n}separator(){let e=document.createElement(`div`);return e.className=`adw-popover-separator`,e.setAttribute(`role`,`separator`),e}baseRow(e){let t=document.createElement(`button`);return t.type=`button`,t.className=`adw-popover-item ${e}`,t.tabIndex=-1,this._rows.push(t),t}backRow(e){let t=this.baseRow(`${this.prefix}-item adw-popover-back`);t.setAttribute(`role`,`menuitem`),t.appendChild(createGtkImage(`go-previous`,`${this.prefix}-item-icon`));let n=document.createElement(`span`);return n.className=`${this.prefix}-item-label`,n.textContent=e.length>0?menuLabelText(e):`Back`,t.appendChild(n),t.addEventListener(`click`,()=>{this._page=this._page.slice(0,-1),this.render(),this.focusPage(0)}),this._backRow=t,t}submenuRow(e,t,n){let r=this.baseRow(`${this.prefix}-item`);r.setAttribute(`role`,`menuitem`),r.setAttribute(`aria-haspopup`,`menu`),t!==void 0&&t.length>0&&r.appendChild(createGtkImage(t,`${this.prefix}-item-icon`));let i=document.createElement(`span`);return i.className=`${this.prefix}-item-label`,i.textContent=menuLabelText(e),r.appendChild(i),r.appendChild(createGtkImage(`go-next`,`adw-popover-item-arrow`)),r.addEventListener(`click`,()=>{this._page=[...n],this.render(),this.focusPage(1)}),this._openers.add(r),r}itemRow(e,t){let n=resolveMenuItemState(e,this._actions??void 0),r=this.baseRow(`${this.prefix}-item`);if(r.hidden=!n.visible,r.disabled=!n.sensitive,n.sensitive||r.setAttribute(`aria-disabled`,`true`),n.role===`normal`)r.setAttribute(`role`,`menuitem`);else{r.setAttribute(`role`,n.role===`check`?`menuitemcheckbox`:`menuitemradio`),r.setAttribute(`aria-checked`,String(n.toggled));let e=document.createElement(`span`);e.className=`adw-popover-item-check ${n.role===`radio`?`radio`:``}`.trim(),r.appendChild(e)}e.icon!==void 0&&e.icon.length>0&&r.appendChild(createGtkImage(e.icon,`${this.prefix}-item-icon`));let i=document.createElement(`span`);if(i.className=`${this.prefix}-item-label`,i.textContent=menuLabelText(e.label),r.appendChild(i),e.accel!==void 0&&e.accel.length>0){let t=document.createElement(`span`);t.className=`adw-popover-item-accel`,t.textContent=e.accel,r.appendChild(t)}return r.addEventListener(`click`,()=>{n.sensitive&&this.onActivate(t)}),r}};const di=[`bottom`,`top`,`start`,`end`],fi=[`start`,`end`],pi=[`menu`,`listbox`],mi=[...pi,`dialog`];var GtkPopover=class extends WidgetElement{_state=new PopoverState;_anchor=null;_initialized=!1;_reflecting=!1;_onDocumentPointerDown=e=>{if(!this.autohide)return;let t=e.target;this.contains(t)||this.anchor?.contains(t)!==!0&&this._state.dismiss()};_onDocumentKeyDown=e=>{e.key===`Escape`&&this.autohide&&(e.stopPropagation(),this._state.dismiss(),this.anchor?.focus())};static get observedAttributes(){return[`open`,`position`,`align`,`role`,`menu`,`autohide`]}get open(){return this._state.open}set open(e){e?this._state.popup():this._state.popdown()}get autohide(){return this.getAttribute(`autohide`)!==`false`}set autohide(e){this.setAttribute(`autohide`,String(e))}get anchor(){return this._anchor??this.parentElement}set anchor(e){this._anchor=e}get position(){let e=this.getAttribute(`position`);return di.includes(e)?e:`bottom`}set position(e){this.setAttribute(`position`,e)}get align(){let e=this.getAttribute(`align`);return fi.includes(e)?e:`start`}set align(e){this.setAttribute(`align`,e)}get popoverRole(){let e=this.getAttribute(`role`);return mi.includes(e)?e:`menu`}get items(){return[...this.querySelectorAll(`.adw-popover-item`)].filter(e=>!e.hidden&&!e.disabled)}popup(){this._state.popup()}popdown(){this._state.popdown()}subscribe(e){return this._state.subscribe(t=>e(t.open))}connectedCallback(){this._buildOnce(),this._state.open&&this._bindDocument()}takesChild(){return!0}_buildOnce(){this._initialized||(this._initialized=!0,this.takesChild()&&bindSlottedChildren(this,[{name:`child`,into:this}]),this.classList.add(`adw-popover`),this.hasAttribute(`role`)||this.setAttribute(`role`,`menu`),this.addEventListener(`keydown`,e=>this._onKeyDown(e)),this._state.subscribe(e=>this._onStateChange(e.open)),this.hasAttribute(`open`)&&this._state.popup(),this._render())}disconnectedCallback(){this._unbindDocument()}attributeChangedCallback(e,t,n){if(this._initialized){if(e===`open`){if(this._reflecting)return;n===null?this._state.popdown():this._state.popup();return}if(e===`role`&&n===null){this.setAttribute(`role`,`menu`);return}this._render()}}_onStateChange(e){e?this._bindDocument():this._unbindDocument(),this._reflecting=!0,e?this.setAttribute(`open`,``):this.removeAttribute(`open`),this._reflecting=!1,this._render(),this.dispatchEvent(new CustomEvent(`notify::open`,{bubbles:!0,detail:{open:e}}))}_bindDocument(){document.addEventListener(`pointerdown`,this._onDocumentPointerDown),document.addEventListener(`keydown`,this._onDocumentKeyDown,!0)}_unbindDocument(){document.removeEventListener(`pointerdown`,this._onDocumentPointerDown),document.removeEventListener(`keydown`,this._onDocumentKeyDown,!0)}_render(){this.hidden=!this._state.open,this.dataset.position=this.position,this.dataset.align=this.align}_onKeyDown(e){if(!this._state.open||!pi.includes(this.popoverRole))return;let t=this.items,n=document.activeElement,r=n===null?-1:t.indexOf(n),i=this.querySelector(`input, textarea`)!==null,{action:a,index:o}=resolvePopoverKey(e.key,{itemCount:t.length,currentIndex:r,hasSearch:i});if(a===`focus`){e.preventDefault(),t[o]?.focus();return}a===`activate`&&(e.preventDefault(),t[o]?.click(),this.dispatchEvent(new CustomEvent(`popover-item-activated`,{bubbles:!0,detail:{index:o}})))}};customElements.define(`gtk-popover`,GtkPopover);const hi={flat:`flat`,suggested:`suggested-action`,destructive:`destructive-action`},gi={"open-menu-symbolic":`open-menu`,"pan-down-symbolic":`go-down`,"pan-up-symbolic":`go-down`,"pan-start-symbolic":`go-previous`,"pan-end-symbolic":`go-next`},_i={down:`bottom`,up:`top`,left:`start`,right:`end`};var AdwSplitButton=class extends WidgetElement{_state=new SplitButtonState;_actionEl;_dropdownEl;_arrowEl;_menuEl;_menuView;_actions=null;_inlineLabel=``;_openReflected=!1;_initialized=!1;static get observedAttributes(){return[`label`,`icon-name`,`use-underline`,`tooltip`,`dropdown-tooltip`,`direction`,`menu-model`,`disabled`,`flat`,`suggested`,`destructive`]}get active(){return this._state.open}get dropdownEnabled(){return this._state.dropdownEnabled}get label(){return this._state.label}set label(e){this.setAttribute(`label`,e??``),this.removeAttribute(`icon-name`)}get iconName(){return this._state.iconName}set iconName(e){this.setAttribute(`icon-name`,e??``),this.removeAttribute(`label`)}get menuModel(){return this._state.menuModel??[]}set menuModel(e){this._state.setMenuModel(this._acceptMenu(e)),this._initialized&&this._render()}_acceptMenu(e,t=!0){let n=normalizeMenuModel(e);if(t)return assertMenuRenderable(n,k),n;let r=menuRefusals(n,k);if(r.length===0)return n;console.error(`${k.name} cannot render this menu, so it has none:`);for(let e of r)console.error(` [${e.path.join(`.`)}] ${e.message}`);return[]}get actions(){return this._actions}set actions(e){this._actions=e??null,this._menuView?.setActions(this._actions),this._initialized&&this._render()}get dropdownTooltip(){return this._state.dropdownTooltip}set dropdownTooltip(e){this.setAttribute(`dropdown-tooltip`,e??``)}get direction(){return this._state.direction}set direction(e){this.setAttribute(`direction`,e)}get useUnderline(){return this._state.useUnderline}set useUnderline(e){e?this.setAttribute(`use-underline`,``):this.removeAttribute(`use-underline`)}popup(){this._state.openMenu()}popdown(){this._state.closeMenu()}connectedCallback(){this._initialized||(this._initialized=!0,this._inlineLabel=(this.textContent??``).trim(),this.classList.add(`adw-split-button`),this._actionEl=document.createElement(`button`),this._actionEl.type=`button`,this._actionEl.className=`adw-split-button-action`,this._dropdownEl=document.createElement(`button`),this._dropdownEl.type=`button`,this._dropdownEl.className=`adw-split-button-dropdown`,this._dropdownEl.setAttribute(`aria-haspopup`,`menu`),this._arrowEl=createGtkImage(null),this._dropdownEl.appendChild(this._arrowEl),this._menuEl=document.createElement(`gtk-popover`),this._menuEl.classList.add(`adw-split-button-menu`),this._menuEl.setAttribute(`role`,`menu`),this._menuEl.setAttribute(`menu`,``),this._menuEl.setAttribute(`align`,`end`),this.replaceChildren(this._actionEl,this._dropdownEl,this._menuEl),this._menuEl.anchor=this._dropdownEl,this._menuEl.subscribe(e=>{e||(this._state.closeMenu(),this._menuView.reset())}),this._menuView=new PopoverMenuView(this._menuEl,`adw-split-button-menu`,e=>{let t=this._state.activateMenuItem(e);t!==null&&(activateElementMenuItem(this,t),this.dispatchEvent(new CustomEvent(`menu-activated`,{bubbles:!0,detail:{label:t.label,action:t.action,id:t.id??t.label,path:[...e]}})))}),this._menuView.setActions(this._actions),this._actionEl.addEventListener(`click`,()=>{this.hasAttribute(`disabled`)||this.dispatchEvent(new CustomEvent(`clicked`,{bubbles:!0}))}),this._dropdownEl.addEventListener(`click`,()=>{this.hasAttribute(`disabled`)||this._state.toggleMenu()}),this._syncStateFromAttributes(),this._state.subscribe(e=>this._onStateChange(e)),this._render())}attributeChangedCallback(e,t,n){if(this._initialized){switch(e){case`label`:case`icon-name`:this._applyContentAttribute(e,n);break;case`use-underline`:this._state.setUseUnderline(n!==null);break;case`direction`:this._state.setDirection(isSplitButtonDirection(n)?n:`down`);break;case`dropdown-tooltip`:this._state.setDropdownTooltip(n??``);break;case`menu-model`:this._state.setMenuModel(this._acceptMenu(parseMenuModel(n),!1));break;default:break}this._render()}}_syncStateFromAttributes(){let e=this.getAttribute(`label`)??(this._inlineLabel.length>0?this._inlineLabel:null),t=this.getAttribute(`icon-name`);e!==null&&this._state.setLabel(e),t!==null&&this._state.setIconName(t),this._state.setUseUnderline(this.hasAttribute(`use-underline`));let n=this.getAttribute(`direction`);isSplitButtonDirection(n)&&this._state.setDirection(n),this._state.setDropdownTooltip(this.getAttribute(`dropdown-tooltip`)??``),this._state.menuModel===null&&this._state.setMenuModel(this._acceptMenu(parseMenuModel(this.getAttribute(`menu-model`)),!1))}_applyContentAttribute(e,t){if(t!==null){e===`label`?this._state.setLabel(t):this._state.setIconName(t);return}let n=this.getAttribute(e===`label`?`icon-name`:`label`);n===null?this._state.setChild(null):e===`label`?this._state.setIconName(n):this._state.setLabel(n)}_onStateChange(e){for(let t of e.notified)this.dispatchEvent(new CustomEvent(`notify::${t}`,{bubbles:!0}));let t=e.open&&!this._openReflected;e.open!==this._openReflected&&(this._openReflected=e.open,this.dispatchEvent(new CustomEvent(`notify::active`,{bubbles:!0,detail:{active:e.open}}))),this._render(),t&&this._menuView.focusableRows[0]?.focus()}_render(){let e=this.hasAttribute(`disabled`);this.classList.toggle(`disabled`,e),this._actionEl.disabled=e,this._dropdownEl.disabled=e||!this._state.dropdownEnabled,this.classList.remove(`flat`,`suggested-action`,`destructive-action`);for(let[e,t]of Object.entries(hi))this.hasAttribute(e)&&this.classList.add(t);this._renderContent(),this._renderDropdown(),this._renderMenu()}_renderContent(){let{mode:e,label:t,iconName:n,styleClasses:r}=this._state;this.classList.toggle(`image-button`,r.includes(`image-button`)),this.classList.toggle(`text-button`,r.includes(`text-button`)),this._actionEl.replaceChildren(),this._actionEl.classList.toggle(`icon-only`,e===`icon`),e===`icon`&&n!==null?this._actionEl.appendChild(createGtkImage(n)):e===`label`&&t!==null&&this._actionEl.appendChild(document.createTextNode(t));let i=this.getAttribute(`tooltip`);this._actionEl.title=i??``,e===`icon`?this._actionEl.setAttribute(`aria-label`,i??(n||`Action`)):this._actionEl.removeAttribute(`aria-label`)}_renderDropdown(){let{direction:e,open:t}=this._state,n=splitButtonArrowIcon(e);this._arrowEl.iconName=gi[n],this._arrowEl.style.transform=n===`pan-up-symbolic`?`rotate(180deg)`:``,this._menuEl.position=_i[splitButtonPopupDirection(e)];let{text:r}=resolveDropdownTooltip(this._state.dropdownTooltip);this._dropdownEl.title=r,this._dropdownEl.setAttribute(`aria-label`,r),this._dropdownEl.setAttribute(`aria-expanded`,String(t));let{checked:i}=splitButtonRootState({active:!1,checked:!1,keyboardActivating:!1},{active:!1,checked:t,keyboardActivating:!1});this.classList.toggle(`checked`,i),this.classList.toggle(`active`,t)}_renderMenu(){this._menuEl.open=this._state.open;let e=this._state.menuModel??[];this._menuView.setMenuModel(e),this._menuView.setActions(this._actions??menuActionsOfElement(this,e)),this._menuView.render()}};customElements.define(`adw-split-button`,AdwSplitButton);var AdwStatusPage=class extends WidgetElement{_iconEl;_titleEl;_descEl;_childEl;_initialized=!1;static get observedAttributes(){return[`icon`,`icon-name`,`title`,`description`,`compact`]}connectedCallback(){this._initialized||(this._initialized=!0,this._iconEl=createGtkImage(null,`adw-status-page-icon`),this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-status-page-title`,this._descEl=document.createElement(`span`),this._descEl.className=`adw-status-page-description`,this._childEl=document.createElement(`div`),this._childEl.className=`adw-status-page-child`,bindSlottedChildren(this,[{name:`child`,into:this._childEl},{into:this._childEl}]).install(this._iconEl,this._titleEl,this._descEl,this._childEl),bindEmptySections(this._childEl),this._render())}attributeChangedCallback(){this._initialized&&this._render()}_render(){this.hasAttribute(`compact`)&&this.classList.add(`compact`);let e=this.getAttribute(`icon`)??this.getAttribute(`icon-name`);this._iconEl.iconName=e,this._iconEl.hidden=!stringIsNotEmpty(e);let t=this.getAttribute(`title`)??``;this._titleEl.textContent=t,this._titleEl.hidden=!stringIsNotEmpty(t);let n=this.getAttribute(`description`)??``;this._descEl.textContent=n,this._descEl.hidden=!stringIsNotEmpty(n)}};customElements.define(`adw-status-page`,AdwStatusPage);var AdwSwitchRow=class extends TooltipElement{static signals={"notify::active":`notify::active`};_switchEl;_prefixEl;_textEl;_titleEl;_subtitleEl;_state=new SwitchRowState;_initialized=!1;static get observedAttributes(){return[`title`,`subtitle`,`active`,`tooltip-text`,`title-lines`,`subtitle-lines`]}get prefixSection(){return this._prefixEl}get active(){return this._initialized?this._state.active:this.hasAttribute(`active`)}set active(e){this.toggleAttribute(`active`,!!e)}get_active(){return this.active}set_active(e){this.active=e}constructor(){super(),installElementApi(this)}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=document.createElement(`div`);e.className=`adw-row-text`,this._textEl=e,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-row-title`,this._subtitleEl=document.createElement(`span`),this._subtitleEl.className=`adw-row-subtitle`,e.append(this._titleEl,this._subtitleEl),this._prefixEl=document.createElement(`div`),this._prefixEl.className=`adw-switch-row-prefix`,this._switchEl=document.createElement(`gtk-switch`),this._switchEl.unfocusable=!0,bindSlottedChildren(this,[{name:`prefix`,into:this._prefixEl}]).install(this._prefixEl,e,this._switchEl),bindEmptySections(this._prefixEl),this._state.setActive(this.hasAttribute(`active`)),this._switchEl.active=this._state.active,this.setAttribute(`role`,`switch`),this.setAttribute(`aria-checked`,String(this._state.active)),this._switchEl.addEventListener(`notify::active`,e=>{e.stopPropagation(),this._apply(this._state.setActive(this._switchEl.active))}),this.addEventListener(`click`,e=>{e.target instanceof Node&&this._switchEl.contains(e.target)||this._apply(this._state.activate())}),attachRowActivation({row:this,activatable:()=>!0}),this._renderText()}attributeChangedCallback(e){this._initialized&&(e===`active`?this._apply(this._state.setActive(this.hasAttribute(`active`))):this._renderText())}_apply(e){e&&(this._switchEl.active=this._state.active,this.toggleAttribute(`active`,this._state.active),this.setAttribute(`aria-checked`,String(this._state.active)),this.dispatchEvent(new CustomEvent(`notify::active`,{bubbles:!0,detail:{active:this._state.active}})))}_renderText(){let{title:e,titleVisible:t,subtitle:n,subtitleVisible:r}=deriveRowLabels({title:this.getAttribute(`title`),subtitle:this.getAttribute(`subtitle`)});this._titleEl.textContent=e,this._titleEl.hidden=!t,this._subtitleEl.textContent=n,this._subtitleEl.hidden=!r,applyRowTooltip(this,[this._prefixEl,this._textEl]),this._applyLineClamping()}_applyLineClamping(){applyRowLineClamp({titleEl:this._titleEl,subtitleEl:this._subtitleEl,textContainerEl:this._titleEl.parentElement,getTitleLines:()=>parseRowLinesAttribute(this.getAttribute(`title-lines`)),getSubtitleLines:()=>parseRowLinesAttribute(this.getAttribute(`subtitle-lines`))})}};customElements.define(`adw-switch-row`,AdwSwitchRow);const createTabChip=e=>{let t=document.createElement(`button`);t.type=`button`,t.className=`adw-tab`,t.setAttribute(`role`,`tab`);let n=createGtkImage(null,`adw-tab-icon`),r=document.createElement(`adw-spinner`);r.className=`adw-tab-spinner`,r.setAttribute(`size`,`16`),r.hidden=!0;let i=document.createElement(`span`);i.className=`adw-tab-title`;let a=createGtkImage(null,`adw-tab-indicator`),o=document.createElement(`button`);return o.type=`button`,o.className=`adw-tab-close`,o.setAttribute(`aria-label`,`Close tab`),o.addEventListener(`click`,t=>{t.stopPropagation(),e.onClose()}),t.append(n,r,i,a,o),t.addEventListener(`click`,()=>e.onSelect()),t.addEventListener(`pointerenter`,()=>e.onHover(!0)),t.addEventListener(`pointerleave`,()=>e.onHover(!1)),{el:t,icon:n,spinner:r,label:i,indicator:a,close:o}},refreshTabChip=(e,t,n)=>{e.label.textContent=t.title,e.el.title=tabTooltip(t),e.el.classList.toggle(`pinned`,t.pinned),e.el.classList.toggle(`needs-attention`,t.needsAttention),e.el.classList.toggle(`closing`,t.closing);let r=tabIconState(t,n);e.icon.iconName=r.icon,e.icon.hidden=!r.iconVisible||r.spinner,e.spinner.hidden=!(r.spinner&&r.iconVisible),e.indicator.iconName=t.indicatorIcon,e.indicator.hidden=!r.indicatorVisible},chipPosition=(e,t)=>t.getBoundingClientRect().left-e.getBoundingClientRect().left+e.scrollLeft,refreshTabChipClose=(e,t,n,r)=>{let i=e.scrollLeft,a=chipPosition(e,t.el),o=a>=i&&a+t.el.offsetWidth<=i+e.clientWidth;t.close.hidden=!tabCloseVisible({hovering:r.hovering,fullyVisible:o,selected:r.selected,dragging:!1,pinned:n.pinned})},scrollChipIntoBar=(e,t)=>{let n=e.clientWidth,r=t.offsetWidth;if(n<=0||r<=0)return;let i=e.scrollLeft,a=chipPosition(e,t),o=Math.min(r,n-r)/2;a-5<i?e.scrollLeft=a-o:a+r+5>i+n&&(e.scrollLeft=a+r+o-n)},vi=[`page-attached`,`page-detached`,`page-reordered`,`page-updated`,`page-pinned`,`notify::selected-page`];var AdwTabBar=class extends WidgetElement{_boxEl;_startEl;_endEl;_indicatorEl;_chips=new Map;_hovered=new Set;_view=null;_initialized=!1;_preferredAction=null;_dropTypes=[];_dropActions=[];_dropArmed=!1;static get observedAttributes(){return[`view`,`autohide`,`expand-tabs`,`inverted`,`extra-drag-preload`]}get view(){return this._view}set view(e){this.setView(e===null?null:typeof e==`string`?this._resolveView(e):e)}get startActionWidget(){return this._startEl?.firstElementChild??null}set startActionWidget(e){this.startActionWidget!==e&&(this._startEl.replaceChildren(...e===null?[]:[e]),this.dispatchEvent(new CustomEvent(`notify::start-action-widget`,{bubbles:!0,detail:{widget:e}})))}get endActionWidget(){return this._endEl?.firstElementChild??null}set endActionWidget(e){this.endActionWidget!==e&&(this._endEl.replaceChildren(...e===null?[]:[e]),this.dispatchEvent(new CustomEvent(`notify::end-action-widget`,{bubbles:!0,detail:{widget:e}})))}get autohide(){return this.hasAttribute(`autohide`)}set autohide(e){e?this.setAttribute(`autohide`,``):this.removeAttribute(`autohide`)}get expandTabs(){return this.hasAttribute(`expand-tabs`)}set expandTabs(e){e?this.setAttribute(`expand-tabs`,``):this.removeAttribute(`expand-tabs`)}get inverted(){return this.hasAttribute(`inverted`)}set inverted(e){e?this.setAttribute(`inverted`,``):this.removeAttribute(`inverted`)}get extraDragPreload(){return this.hasAttribute(`extra-drag-preload`)}set extraDragPreload(e){e?this.setAttribute(`extra-drag-preload`,``):this.removeAttribute(`extra-drag-preload`)}get tabsRevealed(){return tabsRevealed({autohide:this.autohide,nPages:this._view?.nPages??0,nPinnedPages:this._view?.nPinnedPages??0,isTransferringPage:!1})}get isOverflowing(){return this._initialized?this.scrollWidth>this.clientWidth:!1}get extraDragPreferredAction(){return this._preferredAction}setView(e){this._view!==e&&(this._unbindView(),this._view=e,this._bindView(),this._syncChips(),this._applyRevealed(),this.dispatchEvent(new CustomEvent(`notify::view`,{bubbles:!0,detail:{view:e}})))}connectedCallback(){if(this._initialized){this._bindView(),this._syncChips();return}this._initialized=!0,this.classList.add(`adw-tab-bar`),this.setAttribute(`role`,`tablist`),this._startEl=document.createElement(`div`),this._startEl.className=`adw-tab-bar-start-action`,this._boxEl=document.createElement(`div`),this._boxEl.className=`adw-tab-box`,this._indicatorEl=document.createElement(`div`),this._indicatorEl.className=`adw-tab-box-overflow`,this._indicatorEl.hidden=!0,this._boxEl.appendChild(this._indicatorEl),this._endEl=document.createElement(`div`),this._endEl.className=`adw-tab-bar-end-action`,bindSlottedChildren(this,[{name:`start-action-widget`,into:this._startEl},{name:`end-action-widget`,into:this._endEl}]).install(this._startEl,this._boxEl,this._endEl);let e=this.getAttribute(`view`);this.setView(e===null?null:this._resolveView(e)),this._bindView(),this._syncChips(),this._applyRevealed(),this.addEventListener(`keydown`,e=>this._onKeyDown(e)),this.addEventListener(`dragover`,this._onDragOver),this.addEventListener(`drop`,this._onDrop)}disconnectedCallback(){this._unbindView()}attributeChangedCallback(e,t,n){if(this._initialized){switch(e){case`view`:this.setView(n===null?null:this._resolveView(n));return;case`autohide`:this._applyRevealed();break;case`expand-tabs`:case`inverted`:case`extra-drag-preload`:break}(n!==null||e===`view`)&&this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:n}}))}}setupExtraDropTarget(e,t=[`copy`,`move`]){this._dropTypes=e,this._dropActions=t}_resolveView(e){return document.getElementById(e)??null}_bindView(){this._unbindView();for(let e of vi)this._view?.addEventListener(e,this._onViewChange)}_unbindView(){for(let e of vi)this._view?.removeEventListener(e,this._onViewChange)}_onViewChange=()=>{this._syncChips(),this._applyRevealed()};_syncChips(){let e=this._view?.pages??[],t=new Set;e.forEach((e,n)=>{t.add(e.id);let r=this._chips.get(e.id);if(r===void 0){let t=createTabChip({onSelect:()=>this._view?.setSelectedPage(e.id),onClose:()=>this._view?.closePage(e.id),onHover:t=>{t?this._hovered.add(e.id):this._hovered.delete(e.id),this._refreshOne(e.id)}});t.el.dataset.pageId=e.id,t.close.tabIndex=-1,this._chips.set(e.id,t),this._boxEl.insertBefore(t.el,this._boxEl.children[n]??null)}else this._boxEl.children[n]!==r.el&&this._boxEl.insertBefore(r.el,this._boxEl.children[n]??null);this._refreshOne(e.id)});for(let[e,n]of this._chips)t.has(e)||(n.el.remove(),this._chips.delete(e),this._hovered.delete(e));this._applyActiveState(),this._boxEl.classList.toggle(`single-tab`,e.length<=1),this._applyOverflow()}_refreshOne(e){let t=this._view?.pages.find(t=>t.id===e),n=this._chips.get(e);t===void 0||n===void 0||(refreshTabChip(n,t,this._view?.getAttribute(`default-icon`)),refreshTabChipClose(this,n,t,{hovering:this._hovered.has(e),selected:this._view?.selectedId===e}))}_applyActiveState(){let e=this._view?.selectedId??null;for(let[t,n]of this._chips){let r=t===e;n.el.classList.toggle(`active`,r),n.el.setAttribute(`aria-selected`,String(r)),n.el.tabIndex=r?0:-1;let i=this._view?.pages.find(e=>e.id===t);i!==void 0&&refreshTabChipClose(this,n,i,{hovering:this._hovered.has(t),selected:r})}if(e===null)return;let t=this._chips.get(e);t!==void 0&&scrollChipIntoBar(this,t.el)}_applyRevealed(){this.hidden=!this.tabsRevealed}_applyOverflow(){this._indicatorEl.hidden=!this.isOverflowing}_onKeyDown(e){let t=this._view;if(t===null)return;let n=!1;if(e.ctrlKey&&e.key===`Tab`)n=e.shiftKey?t.cyclePreviousPage():t.cycleNextPage();else if(e.ctrlKey&&(e.key===`PageUp`||e.key===`PageDown`))n=e.key===`PageUp`?t.selectPreviousPage():t.selectNextPage();else if(e.ctrlKey&&(e.key===`Home`||e.key===`End`))n=e.key===`Home`?t.selectFirstPage():t.selectLastPage();else if(e.altKey&&/^[0-9]$/.test(e.key)){let r=Number.parseInt(e.key,10);n=t.selectNthPage(r===0?9:r-1)}else e.key===`ArrowLeft`||e.key===`ArrowRight`?n=e.key===`ArrowLeft`?t.selectPreviousPage():t.selectNextPage():(e.key===`Home`||e.key===`End`)&&(n=e.key===`Home`?t.selectFirstPage():t.selectLastPage());if(!n)return;e.preventDefault();let r=t.selectedId;r!==null&&this._chips.get(r)?.el.focus({preventScroll:!0})}_onDragOver=e=>{this._dropTypes.length===0||e.dataTransfer===null||[...this._dropTypes].find(t=>e.dataTransfer?.types.includes(t))!==void 0&&(e.preventDefault(),e.dataTransfer.dropEffect!==`none`&&(e.dataTransfer.dropEffect=this._dropEffects(e)),this._armHoverValue())};_onDrop=e=>{if(this._dropTypes.length===0||e.dataTransfer===null)return;let t=[...this._dropTypes].find(t=>e.dataTransfer?.types.includes(t));if(t===void 0)return;e.preventDefault();let n=this._dropEffects(e),r=this.dispatchEvent(new CustomEvent(`extra-drag-drop`,{bubbles:!0,cancelable:!0,detail:{action:n,data:e.dataTransfer.getData(t)}}));e.dataTransfer.dropEffect=r?n:`none`};_dropEffects(e){let t=this._preferredAction;return t!==null&&this._dropActions.includes(t)?t:this._dropActions[0]??`copy`}_armHoverValue(){if(this._dropArmed)return;this._dropArmed=!0;let e=new CustomEvent(`extra-drag-value`,{bubbles:!0,cancelable:!0,detail:{action:null}});this.dispatchEvent(e);let t=e.detail.action;t!==this._preferredAction&&(this._preferredAction=t,this.dispatchEvent(new CustomEvent(`notify::extra-drag-preferred-action`,{bubbles:!0,detail:{action:t}})))}};customElements.define(`adw-tab-bar`,AdwTabBar);const yi=[`page-attached`,`page-detached`,`page-updated`,`notify::selected-page`];var AdwTabButton=class extends WidgetElement{_button;_binEl;_labelEl;_indicatorEl;_view=null;_initialized=!1;static get observedAttributes(){return[`view`]}get view(){return this._view}set view(e){this.setView(e===null?null:typeof e==`string`?this._resolveView(e):e)}setView(e){this._view!==e&&(this._unbindView(),this._view=e,this._bindView(),this._render(),this.dispatchEvent(new CustomEvent(`notify::view`,{bubbles:!0,detail:{view:e}})))}connectedCallback(){if(this._initialized){this._bindView(),this._render();return}this._initialized=!0,this._button=document.createElement(`button`),this._button.type=`button`,this._button.className=`adw-button image-button`,this._button.title=`View Open Tabs`,this._binEl=document.createElement(`span`),this._binEl.className=`adw-tab-button-indicatorbin`;let e=document.createElement(`span`);e.className=`adw-tab-button-plate`,this._labelEl=document.createElement(`span`),this._labelEl.className=`adw-tab-button-label numeric`,this._indicatorEl=document.createElement(`span`),this._indicatorEl.className=`adw-tab-button-indicator`,this._binEl.append(e,this._labelEl),this._button.append(this._binEl,this._indicatorEl),this.replaceChildren(this._button),this.setAttribute(`role`,`button`);let t=this.getAttribute(`view`);this.setView(t===null?null:this._resolveView(t)),this._bindView(),this._render()}disconnectedCallback(){this._unbindView()}attributeChangedCallback(e,t,n){!this._initialized||e!==`view`||this.setView(n===null?null:this._resolveView(n))}_resolveView(e){return document.getElementById(e)??null}_onViewChange=()=>this._render();_bindView(){this._unbindView();for(let e of yi)this._view?.addEventListener(e,this._onViewChange)}_unbindView(){for(let e of yi)this._view?.removeEventListener(e,this._onViewChange)}_render(){let e=this._view,t=e?.nPages??0,n=t<100;this._labelEl.textContent=n?String(t):``,this._labelEl.hidden=!n,this._labelEl.classList.toggle(`small`,t>=10),this._binEl.classList.toggle(`overflow`,!n);let r=e?.selectedId??null,i=e?.pages.some(e=>e.needsAttention&&e.id!==r)??!1;this._indicatorEl.classList.toggle(`needs-attention`,i),this._indicatorEl.hidden=!i,this._button.setAttribute(`aria-label`,`View Open Tabs (${t})`)}};customElements.define(`adw-tab-button`,AdwTabButton);var AdwTabOverview=class extends WidgetElement{_childEl;_overviewEl;_headerEl;_startButtonsEl;_endButtonsEl;_titleEl;_searchBtn;_searchEntry;_searchClamp;_searchBar;_menuBtn;_gridEl;_pinnedGridEl;_emptyState;_searchEmptyState;_newTabBtn;_thumbs=new Map;_view=null;_model=[];_searchActive=!1;_initialized=!1;_appliedOpen=!1;_reflecting=!1;static get observedAttributes(){return[`view`,`open`,`inverted`,`enable-search`,`enable-new-tab`,`secondary-menu`,`show-start-title-buttons`,`show-end-title-buttons`,`extra-drag-preload`]}get view(){return this._view}set view(e){this.setView(e===null?null:typeof e==`string`?this._resolveView(e):e)}setView(e){this._view!==e&&(this._unbindView(),this._view=e,this._bindView(),this._initialized&&this._syncAll(),this.dispatchEvent(new CustomEvent(`notify::view`,{bubbles:!0,detail:{view:e}})))}get child(){return this._childEl.firstElementChild}get open(){return this.hasAttribute(`open`)}set open(e){this.setOpen(e)}get inverted(){return this.hasAttribute(`inverted`)}set inverted(e){this.toggleAttribute(`inverted`,e)}get enableSearch(){return this.getAttribute(`enable-search`)!==`false`}set enableSearch(e){this.setAttribute(`enable-search`,String(e))}get searchActive(){return this._searchActive}get enableNewTab(){return this.hasAttribute(`enable-new-tab`)}set enableNewTab(e){this.toggleAttribute(`enable-new-tab`,e)}get secondaryMenu(){return this._model}set secondaryMenu(e){let t=normalizeMenuModel(e);assertMenuRenderable(t,k),this._model=t,this._applyMenu()}get showStartTitleButtons(){return this.getAttribute(`show-start-title-buttons`)!==`false`}set showStartTitleButtons(e){this.setAttribute(`show-start-title-buttons`,String(e))}get showEndTitleButtons(){return this.getAttribute(`show-end-title-buttons`)!==`false`}set showEndTitleButtons(e){this.setAttribute(`show-end-title-buttons`,String(e))}get extraDragPreload(){return this.hasAttribute(`extra-drag-preload`)}set extraDragPreload(e){this.toggleAttribute(`extra-drag-preload`,e)}get extraDragPreferredAction(){return 0}activateOverviewOpen(){return this.open||this._view===null?!1:(this.setOpen(!0),!0)}activateOverviewClose(){return!this.open||this._view===null||this._view.nPages===0?!1:(this.setOpen(!1),!0)}connectedCallback(){if(this._initialized){this._bindView(),this._syncAll();return}this._initialized=!0,this._childEl=document.createElement(`div`),this._childEl.className=`adw-tab-overview-child`,this._overviewEl=document.createElement(`div`),this._overviewEl.className=`overview adw-tab-overview-toolbar`,this._headerEl=document.createElement(`div`),this._headerEl.className=`adw-header-bar overview-header-bar`,this._startButtonsEl=document.createElement(`div`),this._startButtonsEl.className=`overview-title-buttons start`,this._endButtonsEl=document.createElement(`div`),this._endButtonsEl.className=`overview-title-buttons end`,this._searchBtn=document.createElement(`button`),this._searchBtn.type=`button`,this._searchBtn.className=`adw-button image-button search-button`,this._searchBtn.title=`Search Tabs`,this._searchBtn.appendChild(createGtkImage(`system-search`,`search-button-icon`)),this._titleEl=document.createElement(`div`),this._titleEl.className=`adw-window-title numeric overview-title`,this._menuBtn=document.createElement(`gtk-menu-button`),this._menuBtn.setAttribute(`icon-name`,`view-more`),this._menuBtn.className=`secondary-menu-button`,this._menuBtn.hidden=!0,this._headerEl.append(this._startButtonsEl,this._searchBtn,this._titleEl,this._endButtonsEl,this._menuBtn),this._searchBar=document.createElement(`div`),this._searchBar.className=`adw-search-bar overview-search-bar`,this._searchClamp=document.createElement(`div`),this._searchClamp.className=`adw-clamp overview-search-clamp`,this._searchEntry=document.createElement(`input`),this._searchEntry.type=`search`,this._searchEntry.className=`adw-entry overview-search-entry`,this._searchEntry.placeholder=`Search tabs`,this._searchEntry.setAttribute(`aria-label`,`Search tabs`),this._searchClamp.appendChild(this._searchEntry),this._searchBar.appendChild(this._searchClamp);let e=document.createElement(`div`);e.className=`adw-tab-overview-content`;let t=document.createElement(`div`);t.className=`adw-tab-overview-scroll`,this._pinnedGridEl=this._createGrid(`adw-tab-grid pinned-grid`,`Pinned tabs`),this._gridEl=this._createGrid(`adw-tab-grid`,`Open tabs`),t.append(this._pinnedGridEl,this._gridEl),this._emptyState=document.createElement(`adw-status-page`),this._emptyState.className=`overview-empty-state`,this._emptyState.setAttribute(`icon`,`view-grid`),this._emptyState.setAttribute(`title`,`No Open Tabs`),this._emptyState.hidden=!0,this._searchEmptyState=document.createElement(`adw-status-page`),this._searchEmptyState.className=`overview-search-empty-state`,this._searchEmptyState.setAttribute(`icon`,`system-search`),this._searchEmptyState.setAttribute(`title`,`No Tabs Found`),this._searchEmptyState.setAttribute(`description`,`Try a different search`),this._searchEmptyState.hidden=!0,this._newTabBtn=document.createElement(`button`),this._newTabBtn.type=`button`,this._newTabBtn.className=`adw-button pill suggested-action new-tab-button`,this._newTabBtn.append(createGtkImage(`list-add`,`new-tab-button-icon`),document.createTextNode(`New Tab`)),e.append(t,this._emptyState,this._searchEmptyState,this._newTabBtn),this._overviewEl.append(this._headerEl,this._searchBar,e);let n=Array.from(this.children);this.replaceChildren(this._childEl,this._overviewEl);for(let e of n)this._childEl.appendChild(e);this._searchEntry.addEventListener(`input`,()=>this._onSearchChanged()),this._searchEntry.addEventListener(`keydown`,e=>this._onSearchKeyDown(e)),this._searchBtn.addEventListener(`click`,()=>this._toggleSearchMode()),this._newTabBtn.addEventListener(`click`,()=>this._requestCreateTab()),this.addEventListener(`keydown`,e=>this._onKeyDown(e));let r=this.getAttribute(`view`);this.setView(r===null?this._findView():this._resolveView(r)),r!==null&&this.removeAttribute(`view`);let i=this.getAttribute(`secondary-menu`);i!==null&&(this.secondaryMenu=JSON.parse(i),this.removeAttribute(`secondary-menu`)),this._applyOpen(),this._syncAll()}disconnectedCallback(){this._unbindView()}attributeChangedCallback(e,t,n){if(this._initialized)switch(e){case`view`:this.setView(n===null?this._findView():this._resolveView(n));return;case`open`:this._reflecting||this._applyOpen();return;case`secondary-menu`:if(n===null)return;try{this.secondaryMenu=JSON.parse(n)}catch(e){console.error(`<adw-tab-overview secondary-menu> is not valid JSON: ${String(e)}`)}return;case`enable-new-tab`:this._applyNewTabButton();return;case`inverted`:this._syncGrids();return;case`enable-search`:case`show-start-title-buttons`:case`show-end-title-buttons`:this._applyHeaderBar();return}}_resolveView(e){return document.getElementById(e)??this._findView()}_findView(){return this.querySelector(`adw-tab-view`)}_bindView(){this._unbindView();for(let e of xi)this._view?.addEventListener(e,this._onViewChange)}_unbindView(){for(let e of xi)this._view?.removeEventListener(e,this._onViewChange)}_onViewChange=()=>{this._syncAll()};_syncAll(){this._applyTitle(),this._syncGrids(),this._applyEmptyStates(),this._applyNewTabButton(),this._applyHeaderBar()}_applyTitle(){let e=this._view;this._titleEl.textContent=e===null?``:e.nPages===1?`1 Tab`:`${e.nPages} Tabs`}_syncGrids(){let e=this._view,t=this._searchActive?this._searchEntry.value:``,n=new Set,r=[],i=[];if(e!==null)for(let a of e.pages){if(!tabSearchMatches(a,t)){this._thumbs.get(a.id)?.root.remove(),this._thumbs.delete(a.id);continue}n.add(a.id);let e=this._thumbFor(a.id);this._refreshThumb(e,a),(a.pinned?r:i).push(e.root)}for(let[e,t]of this._thumbs)n.has(e)||(t.root.remove(),this._thumbs.delete(e));this._pinnedGridEl.replaceChildren(...r),this._gridEl.replaceChildren(...i),this._pinnedGridEl.hidden=r.length===0}_applyEmptyStates(){let e=this._pinnedGridEl.childElementCount===0&&this._gridEl.childElementCount===0;this._emptyState.hidden=!(e&&!this._searchActive),this._searchEmptyState.hidden=!(e&&this._searchActive)}_applyNewTabButton(){this._newTabBtn.hidden=!(this.enableNewTab&&!this._searchActive)}_applyHeaderBar(){let e=this._model.length>0;this._headerEl.hidden=!(this.enableSearch||e||this.showStartTitleButtons||this.showEndTitleButtons),this._startButtonsEl.hidden=!this.showStartTitleButtons,this._endButtonsEl.hidden=!this.showEndTitleButtons,this._searchBtn.hidden=!this.enableSearch,this._searchBar.hidden=!this.enableSearch||!this._searchMode,this._menuBtn.hidden=!e}_applyMenu(){let e=this._menuBtn;this._model.length>0&&(e.menuModel=this._model),this._applyHeaderBar()}_applyOpen(){let e=this.open;this._overviewEl.hidden=!e,this._childEl.classList.toggle(`background`,e),this._childEl.inert=e,e!==this._appliedOpen&&(this._appliedOpen=e,this._reflecting=!0,e?this.hasAttribute(`open`)||this.setAttribute(`open`,``):this.hasAttribute(`open`)&&(this._searchMode=!1,this._setSearchActive(!1),this._searchEntry.value=``,this.removeAttribute(`open`)),this._reflecting=!1,this.dispatchEvent(new CustomEvent(`notify::open`,{bubbles:!0,detail:{open:e}})))}setOpen(e){this.open!==e&&(this._reflecting=!0,this.toggleAttribute(`open`,e),this._reflecting=!1,this._applyOpen(),e&&this._syncAll())}_searchMode=!1;_toggleSearchMode(){this._searchMode=!this._searchMode,this._searchBar.hidden=!this.enableSearch||!this._searchMode,this._searchMode?this._searchEntry.focus():this._stopSearch()}_onSearchChanged(){this._setSearchActive(this._searchEntry.value!==``),this._syncGrids(),this._applyEmptyStates(),this._applyNewTabButton()}_stopSearch(){this._searchEntry.value=``,this._setSearchActive(!1),this._syncGrids(),this._applyEmptyStates(),this._applyNewTabButton()}_setSearchActive(e){e!==this._searchActive&&(this._searchActive=e,this.dispatchEvent(new CustomEvent(`notify::search-active`,{bubbles:!0,detail:{searchActive:e}})))}_onSearchKeyDown(e){if(e.key===`Escape`){this._stopSearch(),this._searchMode=!1,this._searchBar.hidden=!this.enableSearch||!this._searchMode;return}e.key===`Enter`&&this._searchActive&&(this._focusFirstRow(this._pinnedGridEl)||this._focusFirstRow(this._gridEl))&&e.preventDefault()}_onKeyDown(e){if(!this.open)return;let t=e.target;if(t instanceof Node&&!this._onGridKey(e,t)&&!(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)){if(e.key===`ArrowDown`){if(this._searchBar.contains(t)||this._searchBtn.contains(t)){(this._focusFirstRow(this._pinnedGridEl)||this._focusFirstRow(this._gridEl))&&e.preventDefault();return}if(this._menuBtn.contains(t)){(this._focusLastRow(this._pinnedGridEl)||this._focusLastRow(this._gridEl))&&e.preventDefault();return}if(this._newTabBtn.contains(t))return;(this._gridEl.contains(t)||this._pinnedGridEl.contains(t))&&this._newTabBtn.hidden===!1&&(e.preventDefault(),this._newTabBtn.focus());return}this._newTabBtn.contains(t)&&(this._focusLastRow(this._gridEl)||this._focusLastRow(this._pinnedGridEl))&&e.preventDefault()}}_onGridKey(e,t){if(e.altKey||e.ctrlKey||e.metaKey)return!1;let n=[this._pinnedGridEl,this._gridEl].find(e=>e.contains(t));if(n===void 0)return!1;let r=[...n.children].filter(e=>e instanceof HTMLElement),i=r.findIndex(e=>e.contains(t));if(i<0||t instanceof Element&&t.closest(`button`)!==null)return!1;let a=this._view;if(a===null)return!1;if(e.key===`Enter`||e.key===` `){let t=r[i].dataset.pageId;return t===void 0?!1:(e.preventDefault(),a.setSelectedPage(t),this.setOpen(!1),!0)}let o=gridColumns(r.map(e=>e.getBoundingClientRect().top)),s=gridNavigate(e.key,i,r.length,o);if(s===null){let t=[`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key);return t&&e.preventDefault(),t}let c=r[s].dataset.pageId;return c===void 0?!1:(e.preventDefault(),a.setSelectedPage(c),r[s].focus(),!0)}_focusFirstRow(e){let t=e.querySelector(`.adw-tab-thumbnail`);return t===null?!1:(t.focus(),!0)}_focusLastRow(e){let t=e.querySelectorAll(`.adw-tab-thumbnail`),n=t[t.length-1];return n===void 0?!1:(n.focus(),!0)}_requestCreateTab(){let e=this._view;if(e===null)return;let t={page:null};if(this.dispatchEvent(new CustomEvent(`create-tab`,{bubbles:!0,detail:t})),t.page===null){console.error("<adw-tab-overview>: the create-tab handler must not leave `detail.page` unset.");return}e.setSelectedPage(t.page.id),this.setOpen(!1),t.page.content?.focus?.()}_createGrid(e,t){let n=document.createElement(`div`);return n.className=e,n.setAttribute(`role`,`grid`),n.setAttribute(`aria-label`,t),n}_thumbFor(e){let t=this._thumbs.get(e);if(t!==void 0)return t;let n=document.createElement(`div`);n.className=`adw-tab-thumbnail`,n.dataset.pageId=e,n.setAttribute(`role`,`gridcell`),n.tabIndex=-1;let r=document.createElement(`div`);r.className=`contents`;let i=document.createElement(`div`);i.className=`thumbnail`;let a=document.createElement(`div`);a.className=`card`;let o=document.createElement(`div`);o.className=`picture`;let s=document.createElement(`span`);s.className=`picture-portrait`,o.appendChild(s);let c=document.createElement(`button`);c.type=`button`,c.className=`tab-close-button adw-button image-button`,c.title=`Close Tab`,c.setAttribute(`aria-label`,`Close Tab`),c.tabIndex=-1,c.appendChild(createGtkImage(`window-close`,`tab-close-icon`));let l=document.createElement(`button`);l.type=`button`,l.className=`tab-unpin-icon`,l.tabIndex=-1,l.title=`Unpin Tab`,l.setAttribute(`aria-label`,`Unpin Tab`),l.dataset.iconName=`adw-tab-unpin-symbolic`;let u=document.createElement(`button`);u.type=`button`,u.className=`tab-indicator adw-button image-button`,u.tabIndex=-1;let d=createGtkImage(null,`tab-indicator-icon`);u.appendChild(d),a.append(o,c,l,u);let f=document.createElement(`div`);f.className=`needs-attention`;let p=document.createElement(`div`);p.className=`gizmo`,f.appendChild(p),i.append(a,f);let m=document.createElement(`div`);m.className=`icon-title-box`;let g=createGtkImage(null,`tab-icon`),_=document.createElement(`span`);_.className=`tab-label`,m.append(g,_),r.append(i,m),n.appendChild(r),n.addEventListener(`click`,()=>{let t=this._view;t!==null&&(t.setSelectedPage(e),this.setOpen(!1))}),n.addEventListener(`auxclick`,t=>{t.button===1&&(t.preventDefault(),this._view?.closePage(e))}),c.addEventListener(`click`,t=>{t.stopPropagation(),this._view?.closePage(e)}),l.addEventListener(`click`,t=>{t.stopPropagation(),this._view?.setPagePinned(e,!1)}),u.addEventListener(`click`,t=>{t.stopPropagation(),this._view?.dispatchEvent(new CustomEvent(`indicator-activated`,{bubbles:!0,detail:{id:e}}))});let ee={root:n,label:_,icon:g,spinner:null,picture:o,portrait:s,closeBtn:c,unpinIcon:l,indicatorBtn:u,indicatorIcon:d,attention:f};return this._thumbs.set(e,ee),ee}_refreshThumb(e,t){if(e.root.title=tabTooltip(t),e.root.setAttribute(`aria-label`,tabTooltip(t)),e.icon.hidden=t.icon===null&&!t.loading,e.root.classList.toggle(`loading`,t.loading),t.loading&&e.spinner===null){let t=document.createElement(`adw-spinner`);t.className=`tab-spinner`,t.setAttribute(`size`,String(bi)),e.icon.replaceWith(t),e.spinner=t}else!t.loading&&e.spinner!==null&&(e.spinner.replaceWith(e.icon),e.spinner=null);e.indicatorBtn.hidden=t.indicatorIcon===null,e.indicatorIcon.iconName=t.indicatorIcon,e.attention.hidden=!t.needsAttention,e.root.classList.toggle(`inverted`,this.inverted),e.closeBtn.hidden=t.pinned,e.unpinIcon.hidden=!t.pinned,e.label.textContent=t.title,e.portrait.textContent=t.title;let n=this._view?.selectedId===t.id;e.root.classList.toggle(`selected`,n),e.root.setAttribute(`aria-selected`,String(n))}};const bi=`16`,xi=[`page-attached`,`page-detached`,`page-reordered`,`page-pinned`,`page-updated`,`notify::selected-page`];customElements.define(`adw-tab-overview`,AdwTabOverview);const Si=[`title`,`tooltip`,`icon`,`indicator-icon`,`keyword`,`loading`,`needs-attention`,`pinned`];var AdwTabPage=class extends WidgetElement{static get observedAttributes(){return Si}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}])}attributeChangedCallback(e,t,n){let r=this.closest(`adw-tab-view`);r instanceof AdwTabView&&r.syncDeclaredPage(this,e,n)}},AdwTabView=class extends WidgetElement{_state=new TabViewState({onClosePage:e=>this._requestClose(e)});_barEl;_tabBoxEl;_pagesEl;_tabs=new Map;_chips=new Map;_panels=new Map;_hovered=new Set;_initialized=!1;_generatedIds=0;_reflecting=!1;static get observedAttributes(){return[`selected-page`,`autohide`,`expand-tabs`,`no-close`]}constructor(){super(),this._barEl=document.createElement(`div`),this._barEl.className=`adw-tab-bar`,this._barEl.setAttribute(`role`,`tablist`),this._tabBoxEl=document.createElement(`div`),this._tabBoxEl.className=`adw-tab-box`,this._barEl.appendChild(this._tabBoxEl),this._pagesEl=document.createElement(`div`),this._pagesEl.className=`adw-tab-view-pages`,this._state.subscribePages(e=>this._onPagesChange(e)),this._state.subscribe(e=>this._onSelectionChange(e))}get selectedPage(){return this._state.selectedPage}set selectedPage(e){this._state.setSelectedPage(e)}get autohide(){return this.hasAttribute(`autohide`)}set autohide(e){e?this.setAttribute(`autohide`,``):this.removeAttribute(`autohide`)}get expandTabs(){return this.hasAttribute(`expand-tabs`)}set expandTabs(e){e?this.setAttribute(`expand-tabs`,``):this.removeAttribute(`expand-tabs`)}get noClose(){return this.hasAttribute(`no-close`)}set noClose(e){e?this.setAttribute(`no-close`,``):this.removeAttribute(`no-close`)}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=this.getAttribute(`selected-page`),t=Array.from(this.children);this.replaceChildren(this._barEl,this._pagesEl);for(let e of t)e.localName===`adw-tab-page`?this._adoptDeclaredPage(e):this.appendPage({id:this._nextId(),content:e});e!==null&&this._applySelectedAttribute(e),this._applyBarVisibility(),this._reflectSelected(),this.addEventListener(`keydown`,e=>this._onKeyDown(e))}attributeChangedCallback(e,t,n){if(this._initialized){if(e===`selected-page`){if(this._reflecting)return;let e=this.getAttribute(`selected-page`);e!==null&&this._applySelectedAttribute(e);return}this._applyBarVisibility()}}syncDeclaredPage(e,t,n){let r=e.dataset.pageId;if(r!==void 0)switch(t){case`title`:this._state.setPageTitle(r,n);return;case`tooltip`:this._state.setPageTooltip(r,n);return;case`icon`:this._state.setPageIcon(r,n);return;case`indicator-icon`:this._state.setPageIndicatorIcon(r,n);return;case`keyword`:this._state.setPageKeyword(r,n);return;case`loading`:this._state.setPageLoading(r,n!==null);return;case`needs-attention`:this._state.setPageNeedsAttention(r,n!==null);return;case`pinned`:this._state.setPagePinned(r,n!==null);return}}get pages(){return this._state.pages}get nPages(){return this._state.nPages}get nPinnedPages(){return this._state.nPinnedPages}get selectedId(){return this._state.selectedId}get selectedIndex(){return this._state.selectedIndex}get selectedContent(){return this._state.selectedPage?.content??null}isClosing(e){return this._state.isClosing(e)}setSelectedPage(e){return this._state.setSelectedPage(e)}selectNthPage(e){return this._state.selectNthPage(e)}selectPreviousPage(){return this._state.selectPreviousPage()}selectNextPage(){return this._state.selectNextPage()}selectFirstPage(){return this._state.selectFirstPage()}selectLastPage(){return this._state.selectLastPage()}cycleNextPage(){return this._state.cycleNextPage()}cyclePreviousPage(){return this._state.cyclePreviousPage()}addPage(e,t=null){return this._state.addPage(this._withPanel(e),t)}insertPage(e,t){return this._state.insertPage(this._withPanel(e),t)}prependPage(e){return this._state.prependPage(this._withPanel(e))}appendPage(e){return this._state.appendPage(this._withPanel(e))}insertPinnedPage(e,t){return this._state.insertPinnedPage(this._withPanel(e),t)}prependPinnedPage(e){return this._state.prependPinnedPage(this._withPanel(e))}appendPinnedPage(e){return this._state.appendPinnedPage(this._withPanel(e))}setPagePinned(e,t){return this._state.setPagePinned(e,t)}closePage(e){return this._state.closePage(e)}closePageFinish(e,t){return this._state.closePageFinish(e,t)}closeOtherPages(e){this._state.closeOtherPages(e)}closePagesBefore(e){this._state.closePagesBefore(e)}closePagesAfter(e){this._state.closePagesAfter(e)}detachPage(e){return this._state.detachPage(e)}reorderPage(e,t){return this._state.reorderPage(e,t)}reorderBackward(e){return this._state.reorderBackward(e)}reorderForward(e){return this._state.reorderForward(e)}reorderFirst(e){return this._state.reorderFirst(e)}reorderLast(e){return this._state.reorderLast(e)}setPageTitle(e,t){return this._state.setPageTitle(e,t)}setPageTooltip(e,t){return this._state.setPageTooltip(e,t)}setPageKeyword(e,t){return this._state.setPageKeyword(e,t)}setPageIcon(e,t){return this._state.setPageIcon(e,t)}setPageIndicatorIcon(e,t){return this._state.setPageIndicatorIcon(e,t)}setPageLoading(e,t){return this._state.setPageLoading(e,t)}setPageNeedsAttention(e,t){return this._state.setPageNeedsAttention(e,t)}get diagnostics(){return this._state.diagnostics}_adoptDeclaredPage(e){let t={id:e.getAttribute(`page-id`)??this._nextId(),title:e.getAttribute(`title`),tooltip:e.getAttribute(`tooltip`),icon:e.getAttribute(`icon`),indicatorIcon:e.getAttribute(`indicator-icon`),loading:e.hasAttribute(`loading`),needsAttention:e.hasAttribute(`needs-attention`),content:e};e.hasAttribute(`pinned`)?this.appendPinnedPage(t):this.appendPage(t)}_withPanel(e){let t=e.content??document.createElement(`adw-tab-page`);return t.classList.add(`adw-tab-page`),t.setAttribute(`role`,`tabpanel`),t.dataset.pageId=e.id,{...e,content:t}}_nextId(){return this._generatedIds+=1,`tab-${this._generatedIds}`}_onPagesChange(e){switch(e.kind){case`attached`:{let t=this._state.getPage(e.id);t&&this._insertTab(t,e.position);break}case`detached`:this._tabs.get(e.id)?.remove(),this._tabs.delete(e.id),this._chips.delete(e.id),this._hovered.delete(e.id),this._panels.get(e.id)?.remove(),this._panels.delete(e.id);break;case`reordered`:case`pinned`:this._moveTab(e.id,e.position),this._refreshTab(e.id);break;case`updated`:this._refreshTab(e.id);break}this._applyBarVisibility(),this._applyActiveState(),this.dispatchEvent(new CustomEvent(`page-${e.kind}`,{bubbles:!0,detail:{id:e.id,position:e.position,previousPosition:e.previousPosition}}))}_insertTab(e,t){let n=createTabChip({onSelect:()=>this._state.setSelectedPage(e.id),onClose:()=>this._state.closePage(e.id),onHover:t=>{t?this._hovered.add(e.id):this._hovered.delete(e.id),this._refreshCloseVisibility(e.id)}});n.el.dataset.pageId=e.id,n.close.tabIndex=-1,this._tabBoxEl.insertBefore(n.el,this._tabBoxEl.children[t]??null),this._tabs.set(e.id,n.el),this._chips.set(e.id,n);let r=e.content;r&&(this._panels.set(e.id,r),this._pagesEl.insertBefore(r,this._pagesEl.children[t]??null)),this._refreshTab(e.id)}_moveTab(e,t){let n=this._tabs.get(e);n&&(n.remove(),this._tabBoxEl.insertBefore(n,this._tabBoxEl.children[t]??null));let r=this._panels.get(e);r&&(r.remove(),this._pagesEl.insertBefore(r,this._pagesEl.children[t]??null))}_refreshTab(e){let t=this._state.getPage(e),n=this._tabs.get(e);!t||!n||(refreshTabChip(this._chips.get(e),t,this.getAttribute(`default-icon`)),this._refreshCloseVisibility(e))}_refreshCloseVisibility(e){let t=this._state.getPage(e),n=this._chips.get(e);!t||!n||refreshTabChipClose(this._barEl,n,t,{hovering:this._hovered.has(e),selected:this._state.selectedId===e})}_onSelectionChange(e){this._applyActiveState(),this._scrollSelectedTabIntoBar(),this._reflectSelected(),this.dispatchEvent(new CustomEvent(`notify::selected-page`,{bubbles:!0,detail:{selected:e.selectedIndex,selectedId:e.selectedId,previousId:e.previousId,interactive:e.interactive}}))}_applyActiveState(){let e=this._state.selectedId;for(let t of this._state.pages){let n=t.id===e,r=this._tabs.get(t.id);r&&(r.classList.toggle(`active`,n),r.setAttribute(`aria-selected`,String(n)),r.tabIndex=n?0:-1);let i=t.content;i&&(i.classList.toggle(`active-page`,n),i.hidden=!n),this._refreshCloseVisibility(t.id)}}_scrollSelectedTabIntoBar(){let e=this._state.selectedId,t=e===null?void 0:this._tabs.get(e);t&&scrollChipIntoBar(this._barEl,t)}_applyBarVisibility(){let e=tabsRevealed({autohide:this.autohide,nPages:this._state.nPages,nPinnedPages:this._state.nPinnedPages,isTransferringPage:!1});this._barEl.hidden=!e,this._barEl.classList.toggle(`single-tab`,this._state.nPages<=1)}_reflectSelected(){this._reflecting=!0;let e=this._state.selectedId;e===null?this.removeAttribute(`selected-page`):this.getAttribute(`selected-page`)!==e&&this.setAttribute(`selected-page`,e),this._reflecting=!1}_applySelectedAttribute(e){this._state.setSelectedPage(e)}_onKeyDown(e){let t=e.target instanceof Node&&this._barEl.contains(e.target),n=!1;if(e.ctrlKey&&e.key===`Tab`)n=e.shiftKey?this._state.cyclePreviousPage():this._state.cycleNextPage();else if(e.ctrlKey&&e.shiftKey&&(e.key===`PageUp`||e.key===`PageDown`)){let t=this._state.selectedId;t!==null&&(n=e.key===`PageUp`?this._state.reorderBackward(t):this._state.reorderForward(t))}else if(e.ctrlKey&&e.shiftKey&&(e.key===`Home`||e.key===`End`)){let t=this._state.selectedId;t!==null&&(n=e.key===`Home`?this._state.reorderFirst(t):this._state.reorderLast(t))}else if(e.ctrlKey&&(e.key===`PageUp`||e.key===`PageDown`))n=e.key===`PageUp`?this._state.selectPreviousPage():this._state.selectNextPage();else if(e.ctrlKey&&(e.key===`Home`||e.key===`End`))n=e.key===`Home`?this._state.selectFirstPage():this._state.selectLastPage();else if(e.altKey&&/^[0-9]$/.test(e.key)){let t=Number.parseInt(e.key,10);n=this._state.selectNthPage(t===0?9:t-1)}else t&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)?n=e.key===`ArrowLeft`?this._state.selectPreviousPage():this._state.selectNextPage():t&&(e.key===`Home`||e.key===`End`)&&(n=e.key===`Home`?this._state.selectFirstPage():this._state.selectLastPage());if(n&&(e.preventDefault(),t)){let e=this._state.selectedId;e!==null&&this._tabs.get(e)?.focus({preventScroll:!0})}}_requestClose(e){return this.dispatchEvent(new CustomEvent(`close-page`,{bubbles:!0,cancelable:!0,detail:{index:this._state.getPagePosition(e.id),id:e.id}}))?!e.pinned:`defer`}};customElements.define(`adw-tab-view`,AdwTabView),customElements.define(`adw-tab-page`,AdwTabPage);var AdwToggle=class extends WidgetElement{static get observedAttributes(){return[`label`,`icon-name`,`tooltip`,`enabled`]}attributeChangedCallback(e,t,n){e===`enabled`&&t!==n&&this.dispatchEvent(new CustomEvent(`toggle-enabled-changed`,{bubbles:!0,composed:!0,detail:{enabled:n!==`false`}}))}},AdwToggleGroup=class extends WidgetElement{_innerEl;_buttons=[];_state=new ToggleGroupState;_initialized=!1;_stateAttr=`aria-checked`;_names=[];_enabled=[];_toggles=[];static get observedAttributes(){return[`active`,`active-name`,`flat`,`round`,`sensitive`]}get sensitive(){return booleanAttribute$2(this.getAttribute(`sensitive`),!0)}set sensitive(e){this.setAttribute(`sensitive`,e?`true`:`false`)}isToggleEnabled(e){return this._enabled[e]??!1}get active(){return this._state.selected}set active(e){this.setAttribute(`active`,String(e))}get activeName(){return this._names[this._state.selected]??null}set activeName(e){e===null?this.removeAttribute(`active-name`):this.setAttribute(`active-name`,e)}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=Array.from(this.querySelectorAll(`adw-toggle`)),t=keptToggles(e.map(e=>({el:e,name:e.getAttribute(`name`)}))).map(e=>e.el);t.length<e.length&&console.warn(`[adw-toggle-group] a toggle name already exists; the later toggle is not added`);let n=this.getAttribute(`role`)?.trim()||null;n===null&&this.setAttribute(`role`,`radiogroup`);let r=n===`tablist`,i=r?`tab`:`radio`;this._stateAttr=r?`aria-selected`:`aria-checked`,this._innerEl=document.createElement(`div`),this._innerEl.className=`adw-toggle-group-inner`,this._innerEl.setAttribute(`role`,`none`),this._toggles=t,this._buttons=t.map((e,t)=>{let n=document.createElement(`button`);n.type=`button`,n.className=`adw-toggle`,n.setAttribute(`role`,i),this._enabled[t]=booleanAttribute$2(e.getAttribute(`enabled`),!0);let r=e.getAttribute(`label`)??``,a=e.getAttribute(`icon-name`)??``,o=e.getAttribute(`tooltip`)??``;return a&&n.appendChild(createGtkImage(a)),r&&n.appendChild(document.createTextNode(r)),n.title=o,!r&&o?n.setAttribute(`aria-label`,o):a&&!r&&n.setAttribute(`aria-label`,a),n.addEventListener(`click`,()=>this._selectIndex(t)),n}),this._innerEl.append(...this._buttons),this.replaceChildren(this._innerEl);for(let e=0;e<this._toggles.length;e++)this._toggles[e].addEventListener(`toggle-enabled-changed`,t=>{let{enabled:n}=t.detail;this._enabled[e]!==n&&(this._enabled[e]=n,this._render())});this._state.setLabels(t.map(e=>e.getAttribute(`label`)||e.getAttribute(`icon-name`)||``)),this._names=t.map(e=>e.getAttribute(`name`)),this._state.subscribe(()=>this._render()),this._state.setSelected(this._readActiveAttr()),this._applyActiveName(),this._render(),attachRovingFocus({host:this,orientation:`horizontal`,items:()=>this._buttons.filter(e=>!e.disabled),select:e=>this._selectIndex(this._buttons.findIndex(t=>t===e))})}attributeChangedCallback(e){if(this._initialized){if(e===`active`){this._state.setSelected(this._readActiveAttr());return}if(e===`active-name`){this._applyActiveName();return}this._render()}}_applyActiveName(){let e=this.getAttribute(`active-name`);if(e===null)return;let t=toggleIndexOfName(this._names,e);t!==-1&&this._state.setSelected(t)}_readActiveAttr(){let e=Number.parseInt(this.getAttribute(`active`)??`0`,10);if(Number.isNaN(e))return 0;let t=Math.max(0,this._state.count-1);return Math.min(Math.max(e,0),t)}_selectIndex(e){this._enabled[e]&&this._state.setSelected(e)&&(this.setAttribute(`active`,String(e)),this.dispatchEvent(new CustomEvent(`notify::active`,{bubbles:!0,detail:{active:e}})))}_render(){this.classList.toggle(`flat`,this.hasAttribute(`flat`)),this.classList.toggle(`round`,this.hasAttribute(`round`));let e=this._state.selected,t=this.sensitive;this.toggleAttribute(`disabled`,!t),this._buttons.forEach((n,r)=>{let i=r===e;n.classList.toggle(`active`,i),n.setAttribute(this._stateAttr,String(i)),n.disabled=!t||!this._enabled[r],n.tabIndex=i?0:-1}),this._enabled[e]||this._activateFirstEnabled()}_activateFirstEnabled(){let e=this._enabled.findIndex(e=>e);e!==-1&&(this._state.setSelected(e),this.setAttribute(`active`,String(e)),this.dispatchEvent(new CustomEvent(`notify::active`,{bubbles:!0,detail:{active:e}})))}};customElements.define(`adw-toggle`,AdwToggle),customElements.define(`adw-toggle-group`,AdwToggleGroup);var AdwToolbarView=class extends WidgetElement{_topEl;_contentEl;_bottomEl;_initialized=!1;_resize=null;_shading=null;static get observedAttributes(){return[`top-bar-style`,`bottom-bar-style`,`extend-content-to-top-edge`,`extend-content-to-bottom-edge`]}get topBar(){return this._topEl}get contentArea(){return this._contentEl}get bottomBar(){return this._bottomEl}connectedCallback(){this._initialized||(this._initialized=!0,this._topEl=document.createElement(`div`),this._topEl.className=`adw-toolbar-view-top`,this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-toolbar-view-content`,this._bottomEl=document.createElement(`div`),this._bottomEl.className=`adw-toolbar-view-bottom`,bindSlottedChildren(this,[{name:`top`,into:this._topEl},{name:`bottom`,into:this._bottomEl},{name:`content`,into:this._contentEl},{into:this._contentEl}]).install(this._topEl,this._contentEl,this._bottomEl),bindEmptySections(this._topEl,this._bottomEl)),this._shading=new AdwScrollShading(this._contentEl),this._shading.connect(),this._resize=new ResizeObserver(()=>this._syncClasses()),this._resize.observe(this._topEl),this._resize.observe(this._bottomEl),this._syncClasses()}disconnectedCallback(){this._resize?.disconnect(),this._resize=null,this._shading?.disconnect(),this._shading=null}attributeChangedCallback(){this._initialized&&this._syncClasses()}_syncClasses(){let{view:e,topBar:t,bottomBar:n}=toolbarViewClasses({topBarStyle:parseToolbarStyle(this.getAttribute(`top-bar-style`)),bottomBarStyle:parseToolbarStyle(this.getAttribute(`bottom-bar-style`)),extendContentToTopEdge:this.hasAttribute(`extend-content-to-top-edge`),extendContentToBottomEdge:this.hasAttribute(`extend-content-to-bottom-edge`),topBarHeight:this._topEl.offsetHeight,bottomBarHeight:this._bottomEl.offsetHeight});for(let t of wt)this.classList.toggle(t,e.includes(t));for(let e of Tt)this._topEl.classList.toggle(e,t.includes(e)),this._bottomEl.classList.toggle(e,n.includes(e));this._shading?.setUndershootEdges({top:e.includes(`undershoot-top`),bottom:e.includes(`undershoot-bottom`)})}};customElements.define(`adw-toolbar-view`,AdwToolbarView);var AdwViewStack=class extends WidgetElement{static signals={"notify::visible-child":`notify::visible-child`,"notify::visible-child-name":`notify::visible-child-name`};_state=new ViewStackState;_initialized=!1;static get observedAttributes(){return[`visible-child-name`]}constructor(){super(),this._state.subscribe(e=>this._onStateChange(e)),new MutationObserver(e=>this._onChildrenRemoved(e)).observe(this,{childList:!0})}get pages(){return this._state.pages}get visibleChildIndex(){return this._state.visibleIndex}selectNthPage(e){return this._state.setVisibleIndex(e)}get visibleChildName(){return this._state.visibleName}set visibleChildName(e){this._state.setVisibleName(e)}get visibleChild(){return this._state.visiblePage?.content??null}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=this.getAttribute(`visible-child-name`);for(let e of Array.from(this.querySelectorAll(`:scope > adw-view-stack-page`))){let t=e.getAttribute(`name`)??``,n=document.createElement(`div`);n.className=`adw-view-stack-child`,n.dataset.name=t;for(let t of Array.from(e.childNodes))n.appendChild(t);this._state.addPage({name:t,title:e.getAttribute(`title`),icon:e.getAttribute(`icon-name`),content:n,visible:!e.hasAttribute(`hidden`),badgeNumber:e.hasAttribute(`badge-number`)?Number.parseInt(e.getAttribute(`badge-number`)??`0`,10):0,needsAttention:e.hasAttribute(`needs-attention`),useUnderline:e.hasAttribute(`use-underline`),startsSection:e.hasAttribute(`starts-section`),sectionTitle:e.getAttribute(`section-title`)}),this.replaceChild(n,e)}e!==null&&this._state.setVisibleName(e,!1),this._applyVisibility(),this._reflectName(),this._emitItemsChanged()}attributeChangedCallback(e,t,n){this._initialized&&e===`visible-child-name`&&n!==null&&n!==this._state.visibleName&&this._state.setVisibleName(n)}add(e,t,n,r){e.classList.add(`adw-view-stack-child`),e.dataset.name=t;let i=this._state.addPage({name:t,title:n,icon:r,content:e});return this.appendChild(e),this._applyVisibility(),this._reflectName(),this._emitItemsChanged(),i}addTitled(e,t,n){return this.add(e,t,n)}add_titled(e,t,n){return this.add(e,t,n)}add_named(e,t){return this.add(e,t??``)}add_titled_with_icon(e,t,n,r){return this.add(e,t,n,r)}remove(e){if(e===void 0){super.remove();return}let t=this._state.pages.find(t=>t.content===e);t&&this.removePage(t.name)}get_visible_child_name(){return this._state.visibleIndex<0?null:this._state.visibleName}set_visible_child_name(e){this._state.setVisibleName(e)}get_visible_child(){return this.visibleChild}set_visible_child(e){let t=this._state.pages.findIndex(t=>t.content===e);t!==-1&&this._state.setVisibleIndex(t)}removePage(e){let t=this._state.pages[this._state.indexOfName(e)]?.content;return this._state.removePage(e)?(t?.remove(),t&&clearPageMarks(t),this._applyVisibility(),this._reflectName(),this._emitItemsChanged(),!0):!1}setPageVisible(e,t){let n=this._state.setPageVisible(e,t);return this._applyVisibility(),this._emitItemsChanged(),n}_emitItemsChanged(){this.dispatchEvent(new CustomEvent(`items-changed`,{bubbles:!0,detail:{count:this.pages.length}}))}_onStateChange(e){this._applyVisibility(),this._reflectName(),this.dispatchEvent(new CustomEvent(`notify::visible-child`,{bubbles:!0,detail:{index:e.index,name:e.name,title:e.title,interactive:e.interactive}})),this.dispatchEvent(new CustomEvent(`notify::visible-child-name`,{bubbles:!0,detail:{"visible-child-name":e.name}}))}_onChildrenRemoved(e){let t=!1;for(let n of e)for(let e of n.removedNodes){if(!(e instanceof HTMLElement)||e.parentElement===this)continue;let n=this._state.pages.find(t=>t.content===e);n!==void 0&&(this._state.removePage(n.name),clearPageMarks(e),t=!0)}t&&(this._applyVisibility(),this._reflectName(),this._emitItemsChanged())}_applyVisibility(){let e=this._state.visibleIndex;this._state.pages.forEach((t,n)=>{let r=t.content;if(!r)return;let i=n===e;r.classList.toggle(`active-view`,i),r.hidden=!i})}_reflectName(){if(this._state.visibleIndex<0){this.removeAttribute(`visible-child-name`);return}let e=this._state.visibleName;this.getAttribute(`visible-child-name`)!==e&&this.setAttribute(`visible-child-name`,e)}};customElements.define(`adw-view-stack`,AdwViewStack);function clearPageMarks(e){e.classList.remove(`adw-view-stack-child`,`active-view`),delete e.dataset.name,e.hidden=!1}var AdwViewSwitcherPage=class extends WidgetElement{},AdwViewSwitcher=class extends WidgetElement{scheduler=ei;_stateInstance=null;get _state(){return this._stateInstance||(this._stateInstance=new ViewSwitcherState({scheduler:this.scheduler}),this._stateInstance.subscribe(e=>this._onStateChange(e))),this._stateInstance}_barEl;_contentEl;_nodes=[];_declared=[];_pageObserver;_policy=`narrow`;_initialized=!1;static get observedAttributes(){return[`policy`,`active`]}constructor(){super()}get policy(){return this._policy}set policy(e){this.setAttribute(`policy`,e)}get active(){return this._state.selected}set active(e){this._state.setSelected(e),this._reflectActive()}get visibleChildName(){return this._state.selectedName}set visibleChildName(e){this._state.selectName(e)}get pages(){return this._state.pages}setPageVisible(e,t){let n=this._state.setPageVisible(e,t);return this._render(),n}connectedCallback(){if(this._initialized){this._watchPages();return}let e=Array.from(this.querySelectorAll(`:scope > adw-view-switcher-page`)),t=this.getAttribute(`active`);if(this._barEl=document.createElement(`div`),this._barEl.className=`adw-view-switcher-bar`,this._barEl.setAttribute(`role`,`tablist`),attachRovingFocus({host:this,orientation:`horizontal`,items:()=>this._nodes.map(e=>e.button).filter(e=>!e.hidden),select:e=>{this._state.setSelected(Number(e.dataset.pageIndex))}}),this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-view-switcher-content`,this._declared=e,this._watchPages(),this._nodes=e.map((e,t)=>this._buildPage(e,t)),this._barEl.append(...this._nodes.map(e=>e.button)),this._contentEl.append(...this._nodes.map(e=>e.body)),this.replaceChildren(this._barEl,this._contentEl),this._policy=this._readPolicyAttr(),this._initialized=!0,this._state.setPages(e.map(e=>readSwitcherPage(e))),t!==null){let e=Number.parseInt(t,10);Number.isNaN(e)||this._state.setSelected(e,!1)}this._render()}disconnectedCallback(){this._state.cancelDrag(),this._pageObserver?.disconnect(),this._pageObserver=void 0}refreshPages(){this._initialized&&(this._state.setPages(this._declared.map(e=>readSwitcherPage(e))),this._render())}_watchPages(){this._pageObserver?.disconnect(),this._pageObserver=new MutationObserver(()=>this.refreshPages());for(let e of this._declared)this._pageObserver.observe(e,{attributes:!0})}attributeChangedCallback(e){if(this._initialized){if(e===`policy`){let e=this._readPolicyAttr();if(e===this._policy)return;this._policy=e,this._render(),this.dispatchEvent(new CustomEvent(`notify::policy`,{bubbles:!0,detail:{policy:e}}));return}if(e===`active`){let e=this.getAttribute(`active`),t=e===null?NaN:Number.parseInt(e,10);Number.isNaN(t)||this._state.setSelected(t),this._reflectActive()}}}_buildPage(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=`adw-view-switcher-button`,n.setAttribute(`role`,`tab`),n.dataset.pageIndex=String(t);let r=createGtkImage(null,`adw-view-switcher-icon`),i=document.createElement(`span`);i.className=`adw-view-switcher-label`;let a=document.createElement(`span`);a.className=`adw-view-switcher-indicator`,a.setAttribute(`aria-hidden`,`true`),n.append(r,i,a),n.addEventListener(`click`,()=>{this._state.setSelected(t)}),n.addEventListener(`dragenter`,e=>{n.contains(e.relatedTarget)||this._state.dragEnter(t)}),n.addEventListener(`dragleave`,e=>{n.contains(e.relatedTarget)||this._state.dragLeave(t)});let o=document.createElement(`div`);o.className=`adw-view-switcher-page`,o.dataset.name=e.getAttribute(`name`)??``;for(let t of Array.from(e.childNodes))o.appendChild(t);return{button:n,icon:r,label:i,indicator:a,body:o}}_readPolicyAttr(){let e=this.getAttribute(`policy`);return e===null?`narrow`:isViewSwitcherPolicy(e)?e:this._policy}_onStateChange(e){this._render(),this.dispatchEvent(new CustomEvent(`notify::visible-child`,{bubbles:!0,detail:{index:e.selected,name:e.name,title:e.title,interactive:e.interactive}}))}_render(){if(this._initialized){for(let e of qn)this.classList.toggle(e,e===this._policy);buildViewSwitcherButtons(this._state.pages,this._state.selected,this._policy).forEach((e,t)=>{let n=this._nodes[t];n&&(n.button.hidden=!e.visible,n.button.classList.toggle(`active`,e.selected),n.button.setAttribute(`aria-selected`,String(e.selected)),n.button.tabIndex=e.selected?0:-1,applySwitcherIcon(n.icon,e.iconName),n.label.textContent=e.label,n.label.hidden=e.label.length===0,applyIndicator(n.indicator,e.badgeLabel,e.needsAttention),applyDescription(n.button,e.description),e.label?n.button.removeAttribute(`aria-label`):n.button.setAttribute(`aria-label`,e.iconName),n.body.classList.toggle(`active-view`,e.selected),n.body.hidden=!e.selected)}),this._reflectActive()}}_reflectActive(){let e=String(this._state.selected);this.getAttribute(`active`)!==e&&this.setAttribute(`active`,e)}};customElements.define(`adw-view-switcher-page`,AdwViewSwitcherPage),customElements.define(`adw-view-switcher`,AdwViewSwitcher);var AdwViewSwitcherSidebar=class extends WidgetElement{_sidebar;_placeholderEl;_prefixEl;_suffixEl;_stack=null;_filter=null;_initialized=!1;static get observedAttributes(){return[`stack`,`mode`]}get stack(){return this._stack}set stack(e){this.setStack(e===null?null:typeof e==`string`?this._resolveStack(e):e)}setStack(e){e!==null&&this._stack!==e&&(this._unbindStack(),this._stack=e,this._bindStack(),this._populate(),this._syncSelection(),this.dispatchEvent(new CustomEvent(`notify::stack`,{bubbles:!0,detail:{stack:e}})))}get mode(){return this.getAttribute(`mode`)===`page`?`page`:`sidebar`}set mode(e){this.setAttribute(`mode`,e)}get filter(){return this._filter}set filter(e){this._filter=e,this._initialized&&(this._sidebar.filter=e,this._applyEmptyState())}get placeholder(){return this._placeholderEl.firstElementChild}set placeholder(e){e===null?this._placeholderEl.replaceChildren():this._placeholderEl.replaceChildren(e),this._applyEmptyState()}get prefixWidget(){return this._prefixEl.firstElementChild}set prefixWidget(e){e===null?this._prefixEl.replaceChildren():this._prefixEl.replaceChildren(e)}get suffixWidget(){return this._suffixEl.firstElementChild}set suffixWidget(e){e===null?this._suffixEl.replaceChildren():this._suffixEl.replaceChildren(e)}connectedCallback(){if(this._initialized){this._bindStack(),this._populate();return}this._initialized=!0,this._prefixEl=document.createElement(`div`),this._prefixEl.className=`view-switcher-sidebar-prefix`,this._suffixEl=document.createElement(`div`),this._suffixEl.className=`view-switcher-sidebar-suffix`,this._placeholderEl=document.createElement(`div`),this._placeholderEl.className=`view-switcher-sidebar-placeholder`,this._placeholderEl.hidden=!0,this._sidebar=document.createElement(`adw-sidebar`),this._sidebar.addEventListener(`activated`,this._onSidebarActivated);let e=document.createElement(`div`);e.className=`view-switcher-sidebar-box`,e.append(this._sidebar,this._placeholderEl),bindSlottedChildren(this,[{name:`placeholder`,into:this._placeholderEl},{name:`prefix`,into:this._prefixEl},{name:`suffix`,into:this._suffixEl}]).install(this._prefixEl,e,this._suffixEl),this._applyMode();let t=this.getAttribute(`stack`);this.setStack(t===null?this._findStack():this._resolveStack(t)),this._applyEmptyState()}disconnectedCallback(){this._unbindStack()}attributeChangedCallback(e,t,n){this._initialized&&(e===`stack`?this.setStack(n===null?this._findStack():this._resolveStack(n)):e===`mode`&&this._applyMode())}_resolveStack(e){return document.getElementById(e)??this._findStack()}_findStack(){return this.parentElement?.querySelector(`adw-view-stack`)??null}_bindStack(){this._unbindStack();for(let e of Ci)this._stack?.addEventListener(e,this._onStackChange)}_unbindStack(){for(let e of Ci)this._stack?.removeEventListener(e,this._onStackChange)}_onStackChange=()=>{this._populate(),this._syncSelection()};_onSidebarActivated=e=>{e.stopPropagation();let t=e.detail.index,n=this._stack;n!==null&&(n.selectNthPage(t),this.dispatchEvent(new CustomEvent(`activated`,{bubbles:!0,detail:{index:t}})))};_populate(){let e=this._stack;if(e===null){this._sidebar.sections=[],this._applyEmptyState();return}let t=viewSwitcherPagesFromStack(e.pages);this._sidebar.sections=viewSwitcherSidebarSections(t).map(e=>this._toSectionSpec(e)),this._applyEmptyState()}_toSectionSpec(e){let t=e.pages.map(e=>({title:e.title??``,iconName:e.iconName??``,visible:e.visible,badgeNumber:e.badgeNumber,needsAttention:e.needsAttention}));return{title:e.title,items:t}}_syncSelection(){let e=this._stack;if(e===null)return;let t=e.visibleChildIndex;t<0||this._sidebar.selected!==t&&(this._sidebar.selected=t)}_applyMode(){let e=this.mode===`page`;this.classList.toggle(`page`,e),this._sidebar.mode=this.mode}_applyEmptyState(){let e=this._sidebar.classList.contains(`empty`);this._placeholderEl.hidden=!e,this.classList.toggle(`empty`,e)}};const Ci=[`items-changed`,`notify::visible-child`];customElements.define(`adw-view-switcher-sidebar`,AdwViewSwitcherSidebar);var AdwViewSwitcherBar=class extends WidgetElement{_barState=new ViewSwitcherBarState;_barEl;_nodes=[];_stack=null;_initialized=!1;_onStackNotify=()=>this._rebuild();static get observedAttributes(){return[`stack`,`reveal`,`revealed`]}constructor(){super(),this._barState.subscribe(()=>this._applyRevealed())}get stack(){return this._stack}set stack(e){this.setStack(this._resolveStack(e))}get reveal(){return this._barState.reveal}set reveal(e){e?this.setAttribute(`reveal`,``):(this.removeAttribute(`reveal`),this.removeAttribute(`revealed`))}get revealed(){return this._barState.revealed}connectedCallback(){this._initialized||(this._initialized=!0,this._barEl=document.createElement(`div`),this._barEl.className=`adw-view-switcher-bar-box`,this._barEl.setAttribute(`role`,`tablist`),this.replaceChildren(this._barEl),attachRovingFocus({host:this,orientation:`horizontal`,items:()=>this._nodes.map(e=>e.button).filter(e=>!e.hidden),select:e=>{let t=this._stack;if(!t)return;let n=Number(e.dataset.pageIndex);t.visibleChildIndex!==n&&t.selectNthPage(n)}})),this._barState.setReveal(this._readReveal());let e=this.getAttribute(`stack`);if(e&&!this._stack){this.setStack(this._resolveStack(e));return}this._bindStack(),this._rebuild()}disconnectedCallback(){this._unbindStack()}attributeChangedCallback(e,t,n){if(this._initialized){if(e===`reveal`||e===`revealed`){this._barState.setReveal(this._readReveal());return}e===`stack`&&this.setStack(this._resolveStack(n))}}set_stack(e){this.setStack(e)}get_stack(){return this._stack}setStack(e){this._unbindStack(),this._stack=e,this._bindStack(),this._rebuild()}refresh(){this._rebuild()}_readReveal(){return this.hasAttribute(`reveal`)||this.hasAttribute(`revealed`)}_bindStack(){this._stack?.addEventListener(`notify::visible-child`,this._onStackNotify),this._stack?.addEventListener(`items-changed`,this._onStackNotify)}_unbindStack(){this._stack?.removeEventListener(`notify::visible-child`,this._onStackNotify),this._stack?.removeEventListener(`items-changed`,this._onStackNotify)}_resolveStack(e){return e===null?null:typeof e==`string`?document.getElementById(e)??null:e}_rebuild(){if(!this._initialized)return;let e=this._stack?.pages??[];this._barState.setPages(e);let t=buildViewSwitcherButtons(viewSwitcherPagesFromStack(e),this._stack?.visibleChildIndex??-1,`narrow`);t.length!==this._nodes.length&&(this._barEl.replaceChildren(),this._nodes=t.map(e=>this._buildButton(e.pageIndex)),this._barEl.append(...this._nodes.map(e=>e.button))),t.forEach((e,t)=>{let n=this._nodes[t];n&&(n.button.hidden=!e.visible,n.button.classList.toggle(`active`,e.selected),n.button.setAttribute(`aria-selected`,String(e.selected)),n.button.tabIndex=e.selected?0:-1,applySwitcherIcon(n.icon,e.iconName),n.label.textContent=e.label,n.label.hidden=e.label.length===0,applyIndicator(n.indicator,e.badgeLabel,e.needsAttention),applyDescription(n.button,e.description),e.label?n.button.removeAttribute(`aria-label`):n.button.setAttribute(`aria-label`,e.iconName))}),this._applyRevealed()}_buildButton(e){let t=document.createElement(`button`);t.type=`button`,t.className=`adw-view-switcher-bar-button`,t.setAttribute(`role`,`tab`),t.dataset.pageIndex=String(e);let n=createGtkImage(null,`adw-view-switcher-bar-icon`),r=document.createElement(`span`);r.className=`adw-view-switcher-bar-label`;let i=document.createElement(`span`);return i.className=`adw-view-switcher-bar-indicator`,i.setAttribute(`aria-hidden`,`true`),t.append(n,r,i),t.addEventListener(`click`,()=>{this._stack?.selectNthPage(e)}),{button:t,icon:n,label:r,indicator:i}}_applyRevealed(){this.hidden=!this._barState.revealed}};customElements.define(`adw-view-switcher-bar`,AdwViewSwitcherBar);var AdwWindow=class extends GtkWindow{_features=new AdwWindowFeatures(this);static get observedAttributes(){return[...GtkWindow.observedAttributes,`width`,`height`,`width-request`,`height-request`]}get contentArea(){return this._content}get content(){return this._features.content}set content(e){this._features.content=e}get breakpoints(){return this._features.breakpoints}get currentBreakpoint(){return this._features.currentBreakpoint}get dialogs(){return this._features.dialogs}get visibleDialog(){return this._features.visibleDialog}addBreakpoint(e){return this._features.addBreakpoint(e)}connectedCallback(){super.connectedCallback(),this._features.adopt(this._content),this._features.bind()}disconnectedCallback(){this._features.release(),super.disconnectedCallback()}attributeChangedCallback(e){if(e===`width`||e===`height`||e===`width-request`||e===`height-request`){this.renderFrameSize();return}super.attributeChangedCallback(e)}hasTitlebar(){return!1}strips(){return[this._content]}extraSlots(){return[{name:`content`,into:this._content}]}renderFrameSize(){this._features.applySizeRequest()}};customElements.define(`adw-window`,AdwWindow);const wi=[`child-spacing`,`child-spacing-unit`,`pack-direction`,`align`,`justify`,`justify-last-line`,`line-spacing`,`line-spacing-unit`,`line-homogeneous`,`natural-line-length`,`natural-line-length-unit`,`wrap-reverse`,`wrap-policy`,`orientation`];function alignToJustifyContent(e){return e<.25?`flex-start`:e<.75?`center`:`flex-end`}var AdwWrapBox=class extends WidgetElement{_initialized=!1;static get observedAttributes(){return[...wi]}get childSpacing(){return normalizeWrapBoxSpacing(this.getAttribute(`child-spacing`))}set childSpacing(e){this.setAttribute(`child-spacing`,String(e))}get childSpacingUnit(){return normalizeWrapBoxLengthUnit(this.getAttribute(`child-spacing-unit`))}set childSpacingUnit(e){this.setAttribute(`child-spacing-unit`,e)}get lineSpacing(){return normalizeWrapBoxSpacing(this.getAttribute(`line-spacing`))}set lineSpacing(e){this.setAttribute(`line-spacing`,String(e))}get lineSpacingUnit(){return normalizeWrapBoxLengthUnit(this.getAttribute(`line-spacing-unit`))}set lineSpacingUnit(e){this.setAttribute(`line-spacing-unit`,e)}get align(){return normalizeWrapBoxAlign(this.getAttribute(`align`))}set align(e){this.setAttribute(`align`,String(e))}get justify(){return normalizeWrapBoxJustify(this.getAttribute(`justify`))}set justify(e){this.setAttribute(`justify`,e)}get justifyLastLine(){return this.hasAttribute(`justify-last-line`)}set justifyLastLine(e){this.toggleAttribute(`justify-last-line`,!!e)}get wrapPolicy(){return normalizeWrapPolicy(this.getAttribute(`wrap-policy`))}set wrapPolicy(e){this.setAttribute(`wrap-policy`,e)}get packDirection(){return normalizeWrapBoxPackDirection(this.getAttribute(`pack-direction`))}set packDirection(e){this.setAttribute(`pack-direction`,e)}get wrapReverse(){return this.hasAttribute(`wrap-reverse`)}set wrapReverse(e){this.toggleAttribute(`wrap-reverse`,!!e)}get lineHomogeneous(){return this.hasAttribute(`line-homogeneous`)}set lineHomogeneous(e){this.toggleAttribute(`line-homogeneous`,!!e)}get naturalLineLength(){return normalizeNaturalLineLength(this.getAttribute(`natural-line-length`))}set naturalLineLength(e){this.setAttribute(`natural-line-length`,String(e))}get naturalLineLengthUnit(){return normalizeWrapBoxLengthUnit(this.getAttribute(`natural-line-length-unit`))}set naturalLineLengthUnit(e){this.setAttribute(`natural-line-length-unit`,e)}get orientation(){return this.getAttribute(`orientation`)===`vertical`?`vertical`:`horizontal`}set orientation(e){this.setAttribute(`orientation`,e)}get _children(){return[...this.children]}insertChildAfter(e,t=null){return this._applyOrder(`insert-after`,e,t)}reorderChildAfter(e,t=null){return this._applyOrder(`reorder-after`,e,t)}removeAll(){for(let e of this._children)this.removeChild(e)}_applyOrder(e,t,n){let r=resolveWrapBoxChildOrder({children:this._children,child:t,sibling:n,op:e});if(r===null)return!1;let i=r.indexOf(t);return this.insertBefore(t,r[i+1]??null),!0}connectedCallback(){this._initialized||(this._initialized=!0,this._sync())}attributeChangedCallback(e,t,n){if(!this._initialized)return;this._sync();let r=this._normalized(e,n);r!==this._normalized(e,t)&&this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:r}}))}_normalized(e,t){switch(e){case`child-spacing`:case`line-spacing`:return normalizeWrapBoxSpacing(t);case`child-spacing-unit`:case`line-spacing-unit`:case`natural-line-length-unit`:return normalizeWrapBoxLengthUnit(t);case`align`:return normalizeWrapBoxAlign(t);case`justify`:return normalizeWrapBoxJustify(t);case`wrap-policy`:return normalizeWrapPolicy(t);case`pack-direction`:return normalizeWrapBoxPackDirection(t);case`natural-line-length`:return normalizeNaturalLineLength(t);case`orientation`:return t===`vertical`?`vertical`:`horizontal`;default:return t!==null}}_sync(){let e=this.style,t=this.orientation===`vertical`,n=t?`column`:`row`;e.flexDirection=this.packDirection===`end-to-start`?`${n}-reverse`:n,e.flexWrap=this.wrapReverse?`wrap-reverse`:`wrap`;let r=`${wrapBoxLengthToPx(this.childSpacing,this.childSpacingUnit)}px`,i=`${wrapBoxLengthToPx(this.lineSpacing,this.lineSpacingUnit)}px`;t?(e.rowGap=r,e.columnGap=i):(e.columnGap=r,e.rowGap=i),e.setProperty(`--adw-wrap-box-child-spacing`,r);let a=this.justify,o=this.justifyLastLine,s=this.align,c=resolveWrapBoxLine({justify:a,justifyLastLine:o,align:s,lastLine:!1,childrenInLine:2}),l=resolveWrapBoxLine({justify:a,justifyLastLine:o,align:s,lastLine:!0,childrenInLine:2});this.dataset.lineJustify=c.justify,this.dataset.lastLineJustify=l.justify,e.justifyContent=c.growGaps?`space-between`:alignToJustifyContent(c.align),e.alignContent=this.lineHomogeneous?`stretch`:`flex-start`,e.setProperty(`--adw-wrap-box-child-shrink`,String(wrapPolicyFlexShrink(this.wrapPolicy)));let u=wrapBoxLengthToPx(this.naturalLineLength,this.naturalLineLengthUnit),d=u===-1?``:`${u}px`;e.maxWidth=t?``:d,e.maxHeight=t?d:``}};customElements.define(`adw-wrap-box`,AdwWrapBox);const Ti={dark:()=>typeof document<`u`&&isAdwaitaDark(document.documentElement),subscribe(e){if(typeof document>`u`)return()=>{};let t=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`),n=globalThis.matchMedia?.(`(prefers-contrast: more)`);t?.addEventListener(`change`,e),n?.addEventListener(`change`,e);let r=new MutationObserver(e);return r.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>{t?.removeEventListener(`change`,e),n?.removeEventListener(`change`,e),r.disconnect()}},highContrast:()=>globalThis.matchMedia?.(`(prefers-contrast: more)`).matches===!0,supportsColorSchemes(){let matches=e=>globalThis.matchMedia?.(e).matches===!0;return matches(`(prefers-color-scheme: dark)`)||matches(`(prefers-color-scheme: light)`)}};Ti.force=e=>{if(typeof document>`u`)return;let t=document.documentElement;t.classList.remove(`theme-dark`,`theme-light`),e!==null&&t.classList.add(e?`theme-dark`:`theme-light`)},Object.freeze({ALWAYS:0,AUTOMATIC:1,NEVER:2,EXTERNAL:3}),Object.freeze({NONE:0,LTR:1,RTL:2}),Object.freeze({WIDGET:1,TEXT:2,LEFT:3,RIGHT:4,TOP:5,BOTTOM:6}),Object.freeze({WORD:0,LINE:1});const Ei={main:`About`,credits:`Credits`,license:`License`,system:`System`},Di=[`credits`,`license`,`system`],Oi=[`unknown`,`custom`,`gpl-2-0`,`gpl-3-0`,`lgpl-2-1`,`lgpl-3-0`,`bsd`,`mit-x11`,`artistic`,`gpl-2-0-only`,`gpl-3-0-only`,`lgpl-2-1-only`,`lgpl-3-0-only`,`agpl-3-0`,`agpl-3-0-only`,`bsd-3`,`apache-2-0`,`mpl-2-0`,`0bsd`];var GtkAboutDialog=class extends AdwDialog{_built=!1;_logo=``;_switcherEl;_stackEl;_pages=new Map;_populated=new Set;_authors=[];_documenters=[];_artists=[];_creditSections=[];static get observedAttributes(){return[...AdwDialog.observedAttributes,`program-name`,`version`,`copyright`,`comments`,`license`,`license-type`,`system-information`,`website`,`website-label`,`translator-credits`,`logo-icon-name`,`wrap-license`]}get programName(){return this.getAttribute(`program-name`)??``}set programName(e){this.setAttribute(`program-name`,e)}get version(){return this.getAttribute(`version`)??``}set version(e){this.setAttribute(`version`,e)}get copyright(){return this.getAttribute(`copyright`)??``}set copyright(e){this.setAttribute(`copyright`,e)}get comments(){return this.getAttribute(`comments`)??``}set comments(e){this.setAttribute(`comments`,e)}get license(){return this.getAttribute(`license`)??``}set license(e){this.setAttribute(`license`,e),this.setAttribute(`license-type`,`custom`)}get licenseType(){let e=this.getAttribute(`license-type`);return e!==null&&Oi.includes(e)?e:`unknown`}set licenseType(e){Oi.includes(e)?this.setAttribute(`license-type`,e):this.removeAttribute(`license-type`)}get systemInformation(){return this.getAttribute(`system-information`)??``}set systemInformation(e){this.setAttribute(`system-information`,e)}get website(){return this.getAttribute(`website`)??``}set website(e){this.setAttribute(`website`,e)}get websiteLabel(){return this.getAttribute(`website-label`)??``}set websiteLabel(e){this.setAttribute(`website-label`,e)}get translatorCredits(){return this.getAttribute(`translator-credits`)??``}set translatorCredits(e){this.setAttribute(`translator-credits`,e)}get logoIconName(){return this.getAttribute(`logo-icon-name`)??``}set logoIconName(e){this.setAttribute(`logo-icon-name`,e)}get wrapLicense(){return this.hasAttribute(`wrap-license`)}set wrapLicense(e){this.toggleAttribute(`wrap-license`,e)}get logo(){return this._logo}set logo(e){this._logo=e,this._built&&this._renderLogo()}get authors(){return[...this._authors]}set authors(e){this._authors=[...e],this._creditsChanged()}get documenters(){return[...this._documenters]}set documenters(e){this._documenters=[...e],this._creditsChanged()}get artists(){return[...this._artists]}set artists(e){this._artists=[...e],this._creditsChanged()}addCreditSection(e,t){this._creditSections.push({name:e,people:[...t]}),this._creditsChanged()}_creditsChanged(){this._populated.delete(`credits`),this._built&&this._renderAbout()}connectedCallback(){if(this._built){super.connectedCallback();return}this._switcherEl=document.createElement(`div`),this._switcherEl.className=`adw-gtk-about-dialog-switcher`,this._switcherEl.setAttribute(`role`,`tablist`),this._switcherEl.setAttribute(`aria-label`,`Pages`),super.connectedCallback(),this._stackEl=document.createElement(`div`),this._stackEl.className=`adw-gtk-about-dialog-stack`,this._stackEl.dataset.transitionType=`crossfade`,this.setAttribute(`title`,`About ${this.programName||document.title}`);let e=[...this.contentArea.childNodes];this.contentArea.replaceChildren(this._build());for(let t of e)this.contentArea.appendChild(t);this._renderAbout(),this._built=!0}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),this._built&&t!==n&&((e===`license`||e===`license-type`||e===`website`)&&this._populated.delete(`license`),e===`system-information`&&this._populated.delete(`system`),(e===`website`||e===`website-label`||e===`license`||e===`license-type`)&&(this._renderMain(),this._populateLicense()),e===`wrap-license`&&this._populateLicense(),e===`system-information`&&this._populateSystem(),this._renderAbout())}decorateHeader(e){let t=e.querySelector(`.adw-dialog-title`);t===null?e.prepend(this._switcherEl):t.replaceWith(this._switcherEl),this._renderSwitcher()}get visiblePage(){return this._stackEl.dataset.visible??`main`}showPage(e){this._populatePage(e);for(let[t,n]of this._pages)n.hidden=t!==e;this._stackEl.dataset.visible=e,this._renderSwitcher()}_build(){let e=document.createElement(`div`);e.className=`adw-gtk-about-dialog-box`;let t=document.createElement(`div`);t.className=`adw-gtk-about-dialog-head`;let n=document.createElement(`div`);n.className=`adw-gtk-about-dialog-logo-slot`,t.appendChild(n),this._renderLogo();let r=document.createElement(`div`);r.className=`adw-gtk-about-dialog-name`,r.textContent=this.programName||document.title,t.appendChild(r);for(let e of[`main`,...Di]){let t=document.createElement(`div`);t.className=`adw-gtk-about-dialog-page`,t.dataset.page=e,t.hidden=e!==`main`,this._pages.set(e,t),this._stackEl.appendChild(t)}return this._renderMain(),t.appendChild(this._stackEl),e.appendChild(t),e}_renderAbout(){this.setAttribute(`title`,`About ${this.programName||document.title}`);for(let e of Di){let t=this._pages.get(e);if(t===void 0)continue;let n=this._pageVisible(e);t.hidden!==!n&&(t.hidden=!n,n||this._populated.delete(e))}this._pages.get(this._stackEl.dataset.visible??`main`)?.hidden!==!1&&(this._stackEl.dataset.visible=`main`,this._pages.get(`main`).hidden=!1),this._renderMain(),this._renderSwitcher()}_pageVisible(e){return e===`credits`?this._creditsPeople().length>0:e===`license`?this.licenseType===`custom`&&this.license.length>0:this.systemInformation.length>0}_creditsPeople(){let e=[];this._authors.length>0&&e.push({title:`Created by`,people:this._authors}),this._documenters.length>0&&e.push({title:`Documented by`,people:this._documenters});let t=translatorCreditsPeople(this.translatorCredits);t.length>0&&e.push({title:`Translated by`,people:t}),this._artists.length>0&&e.push({title:`Design by`,people:this._artists});for(let t of this._creditSections)e.push({title:t.name,people:t.people});return e}_visiblePages(){return Di.filter(e=>this._pages.get(e)?.hidden===!1)}_renderSwitcher(){if(this._switcherEl===void 0)return;let e=this._visiblePages();this._switcherEl.hidden=e.length===0,this._switcherEl.replaceChildren(...e.map(e=>{let t=document.createElement(`button`);return t.type=`button`,t.className=`adw-gtk-about-dialog-switcher-item`,t.setAttribute(`role`,`tab`),t.textContent=Ei[e],t.classList.toggle(`checked`,this._stackEl.dataset.visible===e),t.setAttribute(`aria-selected`,String(this._stackEl.dataset.visible===e)),t.addEventListener(`click`,()=>this.showPage(e)),t}))}_renderLogo(){let e=this.contentArea.querySelector(`.adw-gtk-about-dialog-logo-slot`);if(e!==null){if(this.logoIconName.length>0){e.replaceChildren(createGtkImage(this.logoIconName,`adw-gtk-about-dialog-logo`));return}if(this._logo.length>0){let t=document.createElement(`img`);t.className=`adw-gtk-about-dialog-logo`,t.src=this._logo,t.alt=``,e.replaceChildren(t);return}e.replaceChildren()}}_renderMain(){let e=this._pages.get(`main`);if(e===void 0)return;let t=[],label=(e,t)=>{let n=document.createElement(`div`);return n.className=t,n.textContent=e,n};this.version.length>0&&t.push(label(this.version,`adw-gtk-about-dialog-version`)),this.comments.length>0&&t.push(label(this.comments,`adw-gtk-about-dialog-comments`)),this.website.length>0?t.push(this.websiteLabel.length>0?this._link(this.websiteLabel,this.website,`adw-gtk-about-dialog-website`):this._link(`Website`,this.website,`adw-gtk-about-dialog-website`)):this.websiteLabel.length>0&&t.push(label(this.websiteLabel,`adw-gtk-about-dialog-website`)),this.copyright.length>0&&t.push(label(this.copyright,`adw-gtk-about-dialog-copyright`));let n=this._licenseMarkup();n!==null&&t.push(n),e.replaceChildren(...t)}_licenseMarkup(){let e=this.licenseType,t=Oi.indexOf(e),n=t>=0?t:S.UNKNOWN,r=document.createElement(`div`);if(r.className=`adw-gtk-about-dialog-license`,n!==S.CUSTOM&&n!==S.UNKNOWN){let e=ve[n],t=e.url??this.website;return r.append(document.createTextNode(`This program comes with absolutely no warranty.
|
|
18
|
+
`),r.append(this._buildLicenseUrlLink())):this._renderLegalLabel(r,a.markup),a.markup.length>0&&t.appendChild(r)}return e}_buildLicenseUrlLink(){let e=this.licenseUrl,t=document.createElement(`a`);return t.href=e,t.rel=`noopener noreferrer`,t.textContent=this.license,t.addEventListener(`click`,t=>{t.preventDefault(),this._activateLink(e)}),t}_renderLegalLabel(e,t){e.replaceChildren();let n=/<a\s+href="([^\x22]*)">([\s\S]*?)<\/a>/g,r=0,text=t=>{if(t.length===0)return;let n=document.createElement(`span`);renderPangoMarkup(n,t),e.appendChild(n)};for(let i of t.matchAll(n)){text(t.slice(r,i.index)),r=i.index+i[0].length;let n=i[1].replace(/&/g,`&`),a=document.createElement(`a`);renderPangoMarkup(a,i[2]),/^(https?:|mailto:)/i.test(n)&&(a.href=n,a.rel=`noopener noreferrer`,a.addEventListener(`click`,e=>{e.preventDefault(),this._activateLink(n)})),e.appendChild(a)}text(t.slice(r))}_updateHeaderTitle(){!this._scrollEl||!this._mainToolbarEl||this._mainToolbarEl.classList.toggle(`scrolled`,this._scrollEl.scrollTop>0)}};customElements.define(`adw-about-dialog`,AdwAboutDialog);function bindEmptySections(...e){let derive=()=>{for(let t of e)t.hidden=t.childElementCount===0},t=new MutationObserver(derive);for(let n of e)t.observe(n,{childList:!0});derive()}function applyRowTooltip(e,t){let n=e.getAttribute(`tooltip-text`)??``;for(let e of t)n?(e.getAttribute(`title`)!==n&&e.setAttribute(`title`,n),e.hasAttribute(Jr)||e.setAttribute(Jr,``)):(e.removeAttribute(`title`),e.removeAttribute(Jr))}const Jr=`data-row-tooltip`;function attachRowActivation(e){let{row:t,activatable:n}=e,r=e.activate??(()=>t.click());t.addEventListener(`keydown`,e=>{e.target===t&&n()&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),r()))});let sync=()=>{n()?t.tabIndex=0:t.removeAttribute(`tabindex`)};return sync(),{sync}}function applyRowLineClamp(e){let{titleEl:t,subtitleEl:n,textContainerEl:r,getTitleLines:i,getSubtitleLines:a}=e,o=i(),s=a(),c=o>0,l=s>0,u=c||l;r.classList.toggle(`adw-row-clamp`,u),c?t.style.setProperty(`--adw-row-title-lines`,String(o)):t.style.removeProperty(`--adw-row-title-lines`),l?n.style.setProperty(`--adw-row-subtitle-lines`,String(s)):n.style.removeProperty(`--adw-row-subtitle-lines`),u?r.style.setProperty(`--adw-row-ellipsize-overflow`,`ellipsis`):r.style.removeProperty(`--adw-row-ellipsize-overflow`)}function parseRowLinesAttribute(e){if(e===null||e===``)return 0;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:0}const Yr=[`disabled`,`aria-disabled`];function isSensitive(e){return e.disabled===!0?!1:e.getAttribute(`aria-disabled`)!==`true`}var AdwActionRow=class extends TooltipElement{static signals={activated:`activated`};_titleEl;_subtitleEl;_suffixEl;_prefixEl;_textEl;_state=new ActionRowState;_sensitivityObserver=null;_initialized=!1;_activation;static get observedAttributes(){return[`title`,`subtitle`,`activatable`,`tooltip-text`,`title-lines`,`subtitle-lines`]}get suffixSection(){return this._suffixEl}get prefixSection(){return this._prefixEl}get activatableWidget(){return this._state.activatableWidget}set activatableWidget(e){this._state.setActivatableWidget(e,e?isSensitive(e):!0)&&(this._observeSensitivity(e),this._syncActivatable())}get activatable(){return this._state.activatable}constructor(){super(),installElementApi(this)}connectedCallback(){if(this._initialized){this._observeSensitivity(this._state.activatableWidget);return}this._initialized=!0,this._prefixEl=document.createElement(`div`),this._prefixEl.className=`adw-action-row-prefix`;let e=document.createElement(`div`);e.className=`adw-row-text`,this._textEl=e,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-row-title`,this._subtitleEl=document.createElement(`span`),this._subtitleEl.className=`adw-row-subtitle`,e.append(this._titleEl,this._subtitleEl),this._suffixEl=document.createElement(`div`),this._suffixEl.className=`adw-action-row-suffix`,bindSlottedChildren(this,[{name:`prefix`,into:this._prefixEl},{name:`suffix`,into:this._suffixEl}]).install(this._prefixEl,e,this._suffixEl),bindEmptySections(this._prefixEl,this._suffixEl),this._adoptAttributes(),this._render(),this.addEventListener(`click`,e=>this._onClick(e)),this._activation=attachRowActivation({row:this,activatable:()=>this._state.activatable})}_adoptAttributes(){this._state.setTitle(this.getAttribute(`title`)),this._state.setSubtitle(this.getAttribute(`subtitle`)),this._state.setActivatable(this.hasAttribute(`activatable`)),this._applyLineClamping()}disconnectedCallback(){this._sensitivityObserver?.disconnect(),this._sensitivityObserver=null}attributeChangedCallback(){this._initialized&&(this._adoptAttributes(),this._render())}_onClick(e){if(!this._state.activatable)return;let t=this._state.activate();t&&e.target instanceof Node&&t.contains(e.target)||(t?.click(),this.dispatchEvent(new CustomEvent(`activated`,{bubbles:!0})))}_observeSensitivity(e){if(this._sensitivityObserver?.disconnect(),!e){this._sensitivityObserver=null;return}this._sensitivityObserver??=new MutationObserver(()=>{let e=this._state.activatableWidget;e&&this._state.setActivatableWidgetSensitive(isSensitive(e))&&this._syncActivatable()}),this._sensitivityObserver.observe(e,{attributeFilter:Yr})}_syncActivatable(){this.toggleAttribute(`activatable`,this._state.activatable),this._initialized&&this._render()}_render(){let{title:e,titleVisible:t,subtitle:n,subtitleVisible:r}=this._state.state;this._titleEl.textContent=e,this._titleEl.hidden=!t,this._subtitleEl.textContent=n,this._subtitleEl.hidden=!r,this.classList.toggle(`activatable`,this._state.activatable),applyRowTooltip(this,[this._prefixEl,this._textEl,this._suffixEl]),this._activation?.sync()}_applyLineClamping(){applyRowLineClamp({titleEl:this._titleEl,subtitleEl:this._subtitleEl,textContainerEl:this._titleEl.parentElement,getTitleLines:()=>parseRowLinesAttribute(this.getAttribute(`title-lines`)),getSubtitleLines:()=>parseRowLinesAttribute(this.getAttribute(`subtitle-lines`))})}};customElements.define(`adw-action-row`,AdwActionRow);var AdwAlertResponse=class extends WidgetElement{static get observedAttributes(){return[`id`,`appearance`,`enabled`]}},AdwAlertDialog=class extends WidgetElement{static signals={response:`response`,...Object.fromEntries([`heading`,`body`,`heading-use-markup`,`body-use-markup`,`close-response`,`default-response`,`prefer-wide-layout`].map(e=>[`notify::${e}`,`notify::${e}`]))};_initialized=!1;_attachedByPresent=!1;_scrimEl;_dialogEl;_headingEl;_bodyEl;_childEl;_responseAreaEl;_modal;_model=new AdwAlertResponses;_buttons=new Map;_blockCloseResponse=!1;constructor(e){super(),installElementApi(this);for(let[t,n]of Object.entries(e??{})){if(n===void 0)continue;let e=propertyOf(t);if(!(e in this))throw Error(`No property ${t} on <adw-alert-dialog>`);this[e]=n}}static get observedAttributes(){return[`heading`,`body`,`heading-use-markup`,`body-use-markup`,`close-response`,`default-response`,`open`,`prefer-wide-layout`]}get heading(){return this.getAttribute(`heading`)??``}set heading(e){this.setAttribute(`heading`,e)}get body(){return this.getAttribute(`body`)??``}set body(e){this.setAttribute(`body`,e)}get open(){return this.hasAttribute(`open`)}set open(e){e?this.setAttribute(`open`,``):this.removeAttribute(`open`)}get headingUseMarkup(){return this.hasAttribute(`heading-use-markup`)}set headingUseMarkup(e){e?this.setAttribute(`heading-use-markup`,``):this.removeAttribute(`heading-use-markup`)}get bodyUseMarkup(){return this.hasAttribute(`body-use-markup`)}set bodyUseMarkup(e){e?this.setAttribute(`body-use-markup`,``):this.removeAttribute(`body-use-markup`)}get preferWideLayout(){return this.hasAttribute(`prefer-wide-layout`)}set preferWideLayout(e){e?this.setAttribute(`prefer-wide-layout`,``):this.removeAttribute(`prefer-wide-layout`)}get defaultResponse(){return this._model.defaultResponse}set defaultResponse(e){this.set_default_response(e)}get closeResponse(){return this._model.closeResponse}set closeResponse(e){this.set_close_response(e)}connectedCallback(){if(this._initialized)return;this._initialized=!0,this._scrimEl=document.createElement(`div`),this._scrimEl.className=`adw-alert-dialog-scrim`,this._scrimEl.addEventListener(`click`,()=>this._dismiss()),this._dialogEl=document.createElement(`div`),this._dialogEl.className=`adw-alert-dialog-box`,this._dialogEl.addEventListener(`click`,e=>e.stopPropagation()),this._modal=new AdwModalSurface({host:this,surface:this._dialogEl,role:`alertdialog`,isOpen:()=>this.open,onEscape:()=>this._dismiss(),initialFocus:e=>this._initialFocusTarget(e)});let e=document.createElement(`div`);e.className=`adw-alert-dialog-message`,this._headingEl=document.createElement(`h2`),this._headingEl.className=`adw-alert-dialog-heading`,this._bodyEl=document.createElement(`p`),this._bodyEl.className=`adw-alert-dialog-body`,this._childEl=document.createElement(`div`),this._childEl.className=`adw-alert-dialog-child`,e.append(this._headingEl,this._bodyEl,this._childEl),this._responseAreaEl=document.createElement(`div`),this._responseAreaEl.className=`adw-alert-dialog-responses`,this._responseAreaEl.append(...this._buttons.values()),this._dialogEl.append(e,this._responseAreaEl),bindSlottedChildren(this,[{claims:e=>e instanceof Element&&e.localName===`adw-alert-response`,consume:e=>this._adoptResponse(e)},{name:`extra-child`,into:this._childEl},{into:this._childEl}]).install(this._scrimEl,this._dialogEl),bindEmptySections(this._childEl),this._model.heading=this.heading,this._model.body=this.body;let t=this.getAttribute(`close-response`);t!==null&&(this._model.closeResponse=t);let n=this.getAttribute(`default-response`);n!==null&&(this._model.defaultResponse=n),this._render()}_adoptResponse(e){let t=e.getAttribute(`id`);if(!t)return;let n=e.getAttribute(`appearance`)??`default`;this.add_response(t,(e.textContent??``).trim()),n!=="default"&&this.set_response_appearance(t,n),booleanAttribute$2(e.getAttribute(`enabled`),!0)||this.set_response_enabled(t,!1)}attributeChangedCallback(e,t,n){this._initialized&&t!==n&&(this._render(),e===`heading`?(this._model.heading=this.heading,this.dispatchEvent(new CustomEvent(`notify::heading`,{bubbles:!0,detail:{heading:this.heading}}))):e===`body`?(this._model.body=this.body,this.dispatchEvent(new CustomEvent(`notify::body`,{bubbles:!0,detail:{body:this.body}}))):e===`close-response`?n!==null&&this.set_close_response(n):e===`default-response`?this.set_default_response(n):e===`open`&&(this.dispatchEvent(new CustomEvent(`notify::open`,{bubbles:!0,detail:{open:this.open}})),this.open?this._modal.present():(this._modal.dismiss(),this._attachedByPresent&&(this._attachedByPresent=!1,this.remove()))))}present(e){this.isConnected||(document.body.appendChild(this),this._attachedByPresent=!0),this.open=!0}add_response(e,t){if(this._model.hasResponse(e)){console.warn(`[adw-alert-dialog] Trying to add a response with id '${e}', but such a response already exists`);return}let n=document.createElement(`button`);n.type=`button`,n.className=`adw-button adw-alert-dialog-response`,n.textContent=t,n.addEventListener(`click`,()=>this._activateResponse(e)),this._model.addResponse(e,t),this._buttons.set(e,n),this._responseAreaEl&&this._responseAreaEl.appendChild(n),this._render()}remove_response(e){if(!this._model.hasResponse(e)){console.warn(`[adw-alert-dialog] Trying to remove a response with id '${e}', but such a response does not exist`);return}this._buttons.get(e)?.remove(),this._buttons.delete(e);let t=this._model.responses.filter(t=>t.id!==e),n=new AdwAlertResponses(this._model.heading,this._model.body);for(let e of t)n.addResponse(e.id,e.label,{appearance:e.appearance,enabled:e.enabled});n.closeResponse=this._model.closeResponse,n.defaultResponse=this._model.defaultResponse===e?null:this._model.defaultResponse,this._model=n,this._render()}has_response(e){return this._model.hasResponse(e)}get_response_label(e){return this._model.responses.find(t=>t.id===e)?.label??null}set_response_label(e,t){let n=this._buttons.get(e);n&&(this._model.addResponse(e,t),n.textContent=t)}get_response_appearance(e){return this._model.hasResponse(e)?this._model.getResponseAppearance(e):null}set_response_appearance(e,t){let n=this._buttons.get(e);n&&(this._model.setResponseAppearance(e,t),n.classList.toggle(`suggested-action`,t===`suggested`),n.classList.toggle(`destructive-action`,t===`destructive`))}get_response_enabled(e){return this._model.hasResponse(e)?this._model.getResponseEnabled(e):!1}set_response_enabled(e,t){let n=this._buttons.get(e);n&&(this._model.setResponseEnabled(e,t),n.disabled=!t)}get_default_response(){return this._model.defaultResponse}set_default_response(e){this._model.defaultResponse=e,this._render()}get_close_response(){return this._model.closeResponse}set_close_response(e){this._model.closeResponse=e}get_heading(){return this.heading}set_heading(e){this.heading=e}get_body(){return this.body}set_body(e){this.body=e}_activateResponse(e){this._model.getResponseEnabled(e)&&(this._blockCloseResponse=!0,this.open=!1,this._blockCloseResponse=!1,this._emitResponse(this._model.resolveById(e)))}_dismiss(){this.open&&(this.open=!1,!this._blockCloseResponse&&this._emitResponse(this._model.resolveById(null)))}_emitResponse(e){dispatchElement(this,`response`,[e])}_initialFocusTarget(e){return e.find(e=>this._childEl.contains(e))??this._defaultResponseButton()}_defaultResponseButton(){let e=this._model.defaultResponse,t=this._model.responses.find(e=>e.enabled)?.id;return(e!==null&&this._model.getResponseEnabled(e)?this._buttons.get(e):void 0)??(t?this._buttons.get(t):void 0)}_render(){if(!this._initialized)return;this.classList.toggle(`open`,this.open);let e=this.heading;this.headingUseMarkup?renderPangoMarkup(this._headingEl,e):this._headingEl.textContent=e,this._headingEl.hidden=e.length===0;let t=this.body;this.bodyUseMarkup?renderPangoMarkup(this._bodyEl,t):this._bodyEl.textContent=t,this._bodyEl.hidden=t.length===0;let n=this.preferWideLayout&&this._model.responses.length<=2;this._responseAreaEl.classList.toggle(`horizontal`,n);let r=this._model.defaultResponse;for(let e of this._model.responses){let t=e.id===r&&e.appearance==="default";this._buttons.get(e.id)?.classList.toggle(`default-response`,t)}}};customElements.define(`adw-alert-response`,AdwAlertResponse),customElements.define(`adw-alert-dialog`,AdwAlertDialog);function requested(e,t,n){let r=Number.parseFloat(e.getAttribute(t)??``);return Number.isFinite(r)&&r>=0?r:n}function fillsContainingBlock(e){return[`maximized`,`fullscreened`].some(t=>e.hasAttribute(t)&&e.getAttribute(t)!==`false`)}var AdwWindowFeatures=class{_host;_contentEl=null;_breakpoints=[];_disposeBreakpoints=null;_openDialogs=[];constructor(e){this._host=e}get contentArea(){return this._contentEl}get content(){return this._contentEl?.firstElementChild??null}set content(e){e&&this._contentEl?.appendChild(e)}get breakpoints(){return this._breakpoints}get currentBreakpoint(){return this._breakpoints.find(e=>e.applied)??null}get dialogs(){return this._openDialogs=this._openDialogs.filter(e=>e.isConnected),this._openDialogs}get visibleDialog(){let e=this.dialogs;return e.length>0?e[e.length-1]:null}adopt(e){this._contentEl===null&&(this._contentEl=e,e.classList.add(`adw-window-content`),this._host.addEventListener(`notify::open`,e=>{let t=e.target;t!==this._host&&(t.hasAttribute(`open`)?this._openDialogs.includes(t)||this._openDialogs.push(t):this._openDialogs=this._openDialogs.filter(e=>e!==t))}))}addBreakpoint(e){let t=this._host,n=new AdwBreakpoint(e,{onApply:()=>t.dataset.breakpoint=e,onUnapply:()=>{t.dataset.breakpoint===e&&delete t.dataset.breakpoint}});return this._breakpoints.push(n),this.bind(),n}bind(){this._disposeBreakpoints?.(),this._disposeBreakpoints=null,this._contentEl!==null&&this._breakpoints.length>0&&(this._disposeBreakpoints=addBreakpoints(this._host,this._breakpoints))}release(){this._disposeBreakpoints?.(),this._disposeBreakpoints=null}applySizeRequest(){let e=this._host;e.style.minWidth=`${requested(e,`width-request`,360)}px`,e.style.minHeight=`${requested(e,`height-request`,200)}px`;let t=fillsContainingBlock(e),n=t?null:e.getAttribute(`default-width`)??e.getAttribute(`width`),r=t?null:e.getAttribute(`default-height`)??e.getAttribute(`height`);n?e.style.width=`${n}px`:e.style.removeProperty(`width`),r?e.style.height=`${r}px`:e.style.removeProperty(`height`)}};const Xr={minimize:{className:`minimize`,icon:`window-minimize-symbolic`,label:`Minimize`,action:`minimize`},maximize:{className:`maximize`,icon:`window-maximize-symbolic`,label:`Maximize`,action:`toggle-maximized`},close:{className:`close`,icon:`window-close-symbolic`,label:`Close`,action:`close`}},Zr=[`decoration-layout`,`deletable`,`icon-name`,`maximized`,`modal`,`resizable`,`transient-for`];var GtkWindowControls=class extends WidgetElement{_initialized=!1;_empty=!0;_window=null;_windowObserver=null;static get observedAttributes(){return[`decoration-layout`,`side`,`use-native-controls`]}get side(){return this.getAttribute(`side`)===`end`?`end`:`start`}set side(e){this._write(`side`,e)}get useNativeControls(){return this.hasAttribute(`use-native-controls`)}get empty(){return this._empty}_write(e,t){this.getAttribute(e)!==t&&this.setAttribute(e,t)}connectedCallback(){if(this._initialized){this._followWindow();return}this._initialized=!0,this.setAttribute(`role`,`group`),this._followWindow()}disconnectedCallback(){this._windowObserver?.disconnect(),this._windowObserver=null,this._window=null}attributeChangedCallback(e){this._initialized&&(this._render(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:this._property(e)}})))}_property(e){return e===`side`?this.side:this.hasAttribute(e)}_followWindow(){this._windowObserver?.disconnect(),this._applyEmptyClass(),this._window=this.closest(`gtk-window, adw-window`),this._window!==null&&(this._windowObserver??=new MutationObserver(()=>this._render()),this._windowObserver.observe(this._window,{attributes:!0,attributeFilter:Zr})),this._render()}_isSovereign(e){return!e.hasAttribute(`modal`)&&!e.hasAttribute(`transient-for`)}_windowFlag(e,t){return e.getAttribute(t)!==`false`}_layoutHalf(){let e=this.getAttribute(`decoration-layout`)??this._window?.getAttribute(`decoration-layout`)??`:minimize,maximize,close`;if(e===``)return null;let t=e.indexOf(`:`);return t===-1?e:this.side===`start`?e.slice(0,t):e.slice(t+1)}_render(){this.classList.toggle(`start`,this.side===`start`),this.classList.toggle(`end`,this.side===`end`),this.replaceChildren(),this._applyEmptyClass();let e=this._window;if(e===null){this._setEmpty(!0);return}let t=this._isSovereign(e),n=this._layoutHalf();if(n===null){this._setEmpty(!0);return}let r=!0;for(let i of n.split(`,`)){let n=this._buttonFor(i,e,t);n!==null&&(this.appendChild(n),r=!1)}this._setEmpty(r)}_applyEmptyClass(){this.classList.toggle(`empty`,this._empty)}_buttonFor(e,t,n){if(e===`icon`)return n?this._windowIcon(t):null;if(e===`minimize`)return n?this._controlButton(Xr.minimize):null;if(e===`maximize`){if(!n||!this._windowFlag(t,`resizable`))return null;let e=t.hasAttribute(`maximized`)&&t.getAttribute(`maximized`)!==`false`;return this._controlButton(e?{...Xr.maximize,icon:`window-restore-symbolic`,label:`Restore`}:Xr.maximize)}return e===`close`&&this._windowFlag(t,`deletable`)?this._controlButton(Xr.close):null}_windowIcon(e){let t=e.getAttribute(`icon-name`);return t===null||t===``?null:createGtkImage(t,`icon`)}_controlButton(e){let t=document.createElement(`button`);return t.className=`adw-window-controls-button ${e.className}`,t.setAttribute(`aria-label`,e.label),t.title=e.label,t.appendChild(createGtkImage(e.icon)),t.addEventListener(`click`,()=>this.dispatchEvent(new CustomEvent(`window-action`,{bubbles:!0,detail:{action:e.action}}))),t}_setEmpty(e){e!==this._empty&&(this._empty=e,this._applyEmptyClass(),this.dispatchEvent(new CustomEvent(`notify::empty`,{bubbles:!0,detail:{empty:e}})))}};customElements.define(`gtk-window-controls`,GtkWindowControls);var GtkWindow=class extends WidgetElement{_initialized=!1;_titlebar;_content;_startControls=null;_endControls=null;_titleLabel=null;_titlebarObserver=null;_members=new WindowMemberState(e=>this._notifyMember(e));_closing=new CloseRequestState;_syncActive=()=>void this._members.reportActive(this._documentIsActive());_onFocusIn=e=>{e.target instanceof Element&&this._members.reportFocus(e.target)};_onFocusOut=e=>{let t=e.relatedTarget;t instanceof Node&&this.contains(t)||t===null&&!document.hasFocus()||this._members.reportFocus(null)};static signals={"close-request":`close-request`,...Object.fromEntries([`application`,`decorated`,`default-height`,`default-width`,`deletable`,`focus-widget`,`fullscreened`,`hide-on-close`,`icon-name`,`is-active`,`maximized`,`modal`,`resizable`,`title`,`transient-for`].map(e=>[`notify::${e}`,`notify::${e}`]))};constructor(){super(),installElementApi(this);let e=this.emit;Object.defineProperty(this,"emit",{configurable:!0,writable:!0,value:(t,...n)=>{if(t===`close-request`)throw Error(`<gtk-window>.emit('close-request') is not supported; call close()`);e(t,...n)}})}static get observedAttributes(){return[`decorated`,`default-width`,`default-height`,`deletable`,`fullscreened`,`hide-on-close`,`icon-name`,`maximized`,`modal`,`resizable`,`title`,`transient-for`,`hidden`]}get title(){return this.getAttribute(`title`)??``}set title(e){this._write(`title`,e)}get decorated(){return this._onByDefault(`decorated`)}set decorated(e){this._write(`decorated`,String(e))}get maximized(){return this._offByDefault(`maximized`)}set maximized(e){this._write(`maximized`,String(e))}get fullscreened(){return this._offByDefault(`fullscreened`)}set fullscreened(e){this._write(`fullscreened`,String(e))}get resizable(){return this._onByDefault(`resizable`)}set resizable(e){this._write(`resizable`,String(e))}get deletable(){return this._onByDefault(`deletable`)}set deletable(e){this._write(`deletable`,String(e))}get hide_on_close(){return this._offByDefault(`hide-on-close`)}set hide_on_close(e){this._offByDefault(`hide-on-close`)!==e&&this._write(`hide-on-close`,String(e))}get_hide_on_close(){return this.hide_on_close}set_hide_on_close(e){this.hide_on_close=e}_write(e,t){t===null?this.removeAttribute(e):this.getAttribute(e)!==t&&this.setAttribute(e,t)}_onByDefault(e){return this.getAttribute(e)!==`false`}_offByDefault(e){return this.hasAttribute(e)&&this.getAttribute(e)!==`false`}connectedCallback(){if(this._initialized){this._watchActivity(),this._watchTitlebar(),this._render();return}this._initialized=!0,this._watchActivity(),this._titlebar=document.createElement(`div`),this._titlebar.className=`adw-gtk-window-titlebar`,this._content=document.createElement(`div`),this._content.className=`adw-gtk-window-content`,bindSlottedChildren(this,[...this.hasTitlebar()?[{name:`titlebar`,into:this._titlebar},{name:`child`,into:this._content}]:[],...this.extraSlots(),{into:this._content}]).install(...this.strips()),this.addEventListener(`window-action`,e=>this._onWindowAction(e)),this._watchTitlebar(),this._render()}disconnectedCallback(){this._titlebarObserver?.disconnect(),this._titlebarObserver=null,globalThis.removeEventListener(`focus`,this._syncActive),globalThis.removeEventListener(`blur`,this._syncActive),document.removeEventListener(`visibilitychange`,this._syncActive),this.removeEventListener(`focusin`,this._onFocusIn),this.removeEventListener(`focusout`,this._onFocusOut),this._members.reportActive(!1),this._members.reportFocus(null)}_watchActivity(){globalThis.addEventListener(`focus`,this._syncActive),globalThis.addEventListener(`blur`,this._syncActive),document.addEventListener(`visibilitychange`,this._syncActive),this.addEventListener(`focusin`,this._onFocusIn),this.addEventListener(`focusout`,this._onFocusOut),this._syncActive()}_documentIsActive(){return this.isConnected&&!this.hidden&&document.visibilityState!==`hidden`&&document.hasFocus()}_notifyMember(e){let t=e===`is-active`?this._members.active:e===`focus-widget`?this._members.focus:this.maximized;this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:t}}))}_watchTitlebar(){this._titlebarObserver?.disconnect(),this._titlebarObserver=new MutationObserver(()=>this._render()),this._titlebarObserver.observe(this._titlebar,{childList:!0})}strips(){return[this._titlebar,this._content]}hasTitlebar(){return!0}extraSlots(){return[]}attributeChangedCallback(e){if(e===`hidden`){this._syncActive();return}this._initialized&&this._render(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:this._property(e)}}))}_property(e){if(e===`default-width`||e===`default-height`){let t=Number.parseFloat(this.getAttribute(e)??``);return Number.isFinite(t)?t:null}return e===`title`||e===`icon-name`||e===`transient-for`?this.getAttribute(e):e===`decorated`||e===`resizable`||e===`deletable`?this._onByDefault(e):this._offByDefault(e)}_render(){this._titlebar.hidden=!this.decorated,this.classList.toggle(`maximized`,this.decorated&&this.maximized),this.classList.toggle(`fullscreen`,this.decorated&&this._offByDefault(`fullscreened`)),this.renderFrameSize();let e=this.getAttribute(`title`);e===null?this.removeAttribute(`aria-label`):this.setAttribute(`aria-label`,e),this._renderTitlebar()}renderFrameSize(){let e=fillsContainingBlock(this),t=Number.parseFloat(this.getAttribute(`default-width`)??``),n=Number.parseFloat(this.getAttribute(`default-height`)??``);for(let[r,i]of[[`width`,t],[`height`,n]])!e&&Number.isFinite(i)&&i>0?this.style.setProperty(r,`${i}px`):this.style.removeProperty(r)}_renderTitlebar(){if([...this._titlebar.children].some(e=>e!==this._startControls&&e!==this._endControls&&e!==this._titleLabel)){for(let e of[this._startControls,this._endControls,this._titleLabel])e?.remove();this._startControls=null,this._endControls=null,this._titleLabel=null;return}if(!this.decorated||!this.hasTitlebar())return;this._startControls===null&&(this._startControls=document.createElement(`gtk-window-controls`),this._startControls.setAttribute(`side`,`start`),this._endControls=document.createElement(`gtk-window-controls`),this._endControls.setAttribute(`side`,`end`),this._titleLabel=document.createElement(`span`),this._titleLabel.className=`adw-gtk-window-title`,this._titlebar.append(this._startControls,this._titleLabel,this._endControls));let e=this.getAttribute(`title`);e===null?this._titleLabel?.removeAttribute(`title`):this._titleLabel?.setAttribute(`title`,e??``)}_onWindowAction(e){let t=e.detail?.action;if(t===`toggle-maximized`){this._write(`maximized`,String(!this._offByDefault(`maximized`)));return}t===`close`&&this.close()}close(){let e=this._closing.close({realized:this.isConnected,hideOnClose:this.hide_on_close,emit:()=>{let e=new CustomEvent(`close-request`,{bubbles:!0,cancelable:!0});return this.dispatchEvent(e),e.defaultPrevented},hide:()=>void(this.hidden=!0),destroy:()=>this.remove()});return e===`hidden`||e===`destroyed`}present(){this.hidden=!1}get isActive(){return this._members.active}get is_active(){return this._members.active}get focusWidget(){return this.get_focus()}get focus_widget(){return this.get_focus()}set focus_widget(e){this.set_focus(e)}get_focus(){let e=document.activeElement;return e!==null&&e!==this&&this.contains(e)?e:null}set_focus(e){if(e===null){let e=this.get_focus();(e instanceof HTMLElement||e instanceof SVGElement)&&e.blur(),this._members.reportFocus(null);return}if(e===this||!this.contains(e))throw Error(`<gtk-window>.set_focus: the widget is not inside this window`);(e instanceof HTMLElement||e instanceof SVGElement)&&e.focus(),this._members.reportFocus(this.get_focus())}get_default_size(){let read=e=>{let t=Number.parseInt(this.getAttribute(e)??``,10);return Number.isFinite(t)?t:0};return[read(`default-width`),read(`default-height`)]}set_default_size(e,t){let n=stepDefaultSize(this.get_default_size(),e,t);if(n!==null)for(let e of n.changed)this._write(e,String(e===`default-width`?n.width:n.height))}is_maximized(){return this.maximized}maximize(){this._write(`maximized`,`true`)}unmaximize(){this._write(`maximized`,`false`)}is_fullscreen(){return this.fullscreened}fullscreen(){this._write(`fullscreened`,`true`)}unfullscreen(){this._write(`fullscreened`,`false`)}};customElements.define(`gtk-window`,GtkWindow),defineWindowApplication(GtkWindow.prototype);var GtkApplicationWindow=class extends GtkWindow{_menubar=null;_menubarObserver=null;static signals={...GtkWindow.signals,"notify::show-menubar":`notify::show-menubar`};static get observedAttributes(){return[...GtkWindow.observedAttributes,`show-menubar`]}get showMenubar(){return this.getAttribute(`show-menubar`)===`true`}set showMenubar(e){this._write(`show-menubar`,String(e))}menubarSection(){if(this._menubar===null){let e=document.createElement(`div`);e.className=`adw-gtk-application-window-menubar`,this._menubar=e}return this._menubar}strips(){return[this._titlebar,this.menubarSection(),this._content]}extraSlots(){return[{name:`menubar`,into:this.menubarSection()}]}connectedCallback(){super.connectedCallback(),this._followMenubar()}disconnectedCallback(){this._menubarObserver?.disconnect(),this._menubarObserver=null}attributeChangedCallback(e){super.attributeChangedCallback(e),e===`show-menubar`&&this._renderMenubar()}_followMenubar(){this._menubarObserver?.disconnect(),this._menubarObserver=new MutationObserver(()=>this._renderMenubar()),this._menubarObserver.observe(this.menubarSection(),{childList:!0}),this._renderMenubar()}_renderMenubar(){let e=this.menubarSection();e.hidden=!this.showMenubar||e.childElementCount===0}};customElements.define(`gtk-application-window`,GtkApplicationWindow),installActionMap(GtkApplicationWindow.prototype);var AdwApplicationWindow=class extends GtkApplicationWindow{_features=new AdwWindowFeatures(this);_model=[];_menubarEl=null;static get observedAttributes(){return[...GtkApplicationWindow.observedAttributes,`width`,`height`,`width-request`,`height-request`,`menu-model`]}get contentArea(){return this._content}get content(){return this._features.content}set content(e){this._features.content=e}get breakpoints(){return this._features.breakpoints}get currentBreakpoint(){return this._features.currentBreakpoint}get dialogs(){return this._features.dialogs}get visibleDialog(){return this._features.visibleDialog}addBreakpoint(e){return this._features.addBreakpoint(e)}get showMenubar(){return this.hasAttribute(`show-menubar`)}set showMenubar(e){e?this.setAttribute(`show-menubar`,``):this.removeAttribute(`show-menubar`)}get menuModel(){return this._model}set menuModel(e){this._model=normalizeMenuModel(e),this._renderMenubar()}get menubar(){return this._menubarEl}connectedCallback(){super.connectedCallback(),this._features.adopt(this._content),this._features.bind()}disconnectedCallback(){this._features.release(),super.disconnectedCallback()}attributeChangedCallback(e){if(e===`width`||e===`height`||e===`width-request`||e===`height-request`){this.renderFrameSize();return}super.attributeChangedCallback(e),e===`menu-model`&&(this._model=parseMenuModel(this.getAttribute(`menu-model`)),this._renderMenubar())}hasTitlebar(){return!1}strips(){return[this._content]}extraSlots(){return[{name:`content`,into:this._content}]}renderFrameSize(){this._features.applySizeRequest()}_followMenubar(){this._menubarEl===null&&(this._menubarEl=document.createElement(`div`),this._menubarEl.className=`adw-application-window-menubar`,this._content.prepend(this._menubarEl)),this._renderMenubar()}menubarSection(){return this._menubarEl??super.menubarSection()}_renderMenubar(){let e=this._menubarEl;if(e!==null){e.replaceChildren(),e.hidden=!this.showMenubar||this._model.length===0;for(let t of flattenMenu(this._model)){let n=t.node;if(n.kind===`submenu`){let t=document.createElement(`gtk-menu-button`);t.setAttribute(`menu-title`,n.label),t.menuModel=n.items,e.appendChild(t);continue}let r=document.createElement(`gtk-button`);r.setAttribute(`label`,n.label??``),r.setAttribute(`flat`,``),r.addEventListener(`click`,()=>{this.dispatchEvent(new CustomEvent(`menu-item-activated`,{bubbles:!0,detail:{id:n.id??n.label,label:n.label,path:[...t.path]}}))}),e.appendChild(r)}}}};customElements.define(`adw-application-window`,AdwApplicationWindow);var AdwAvatar=class extends WidgetElement{_textEl;_iconEl;_imageEl;_initialized=!1;static get observedAttributes(){return[`text`,`size`,`show-initials`,`icon`,`custom-image`]}connectedCallback(){this._initialized||(this._initialized=!0,this._textEl=document.createElement(`span`),this._textEl.className=`adw-avatar-text`,this._iconEl=createGtkImage(null,`adw-avatar-icon`),this._imageEl=document.createElement(`img`),this._imageEl.className=`adw-avatar-custom-image`,this._imageEl.alt=``,this.replaceChildren(this._textEl,this._iconEl,this._imageEl),this._render())}attributeChangedCallback(){this._initialized&&this._render()}_render(){let e=parseFloat(this.getAttribute(`size`)||`48`);this.style.width=`${e}px`,this.style.height=`${e}px`;let t=this.getAttribute(`text`)??``,n=this.getAttribute(`custom-image`)??``,r=avatarMode({hasCustomImage:n.length>0,showInitials:this.hasAttribute(`show-initials`),text:t});if(this._imageEl.hidden=r!==`image`,r===`image`)this._imageEl.getAttribute(`src`)!==n&&(this._imageEl.src=n),this.style.backgroundImage=``,this.style.color=``,this._textEl.hidden=!0,this._iconEl.hidden=!0;else if(r===`initials`){let{fg:n,start:r,stop:i}=avatarColor(t);this.style.backgroundImage=`linear-gradient(${r}, ${i})`,this.style.color=n,this._textEl.textContent=avatarInitials(t),this._textEl.hidden=!1,this._iconEl.hidden=!0,this._applyFontSize(e)}else this.style.backgroundImage=``,this.style.color=``,this._textEl.hidden=!0,this._iconEl.iconName=this.getAttribute(`icon`)??`avatar-default`,this._iconEl.size=avatarIconSize(e),this._iconEl.hidden=!1}_applyFontSize(e){let t=avatarMaxFontSize(e);this._textEl.style.fontSize=`${t}px`;let{width:n,height:r}=this._textEl.getBoundingClientRect();this._textEl.style.fontSize=`${avatarFontSize(e,{width:n,height:r})}px`}};customElements.define(`adw-avatar`,AdwAvatar);var AdwBanner=class extends WidgetElement{_titleEl;_button;_initialized=!1;static get observedAttributes(){return[`title`,`button-label`,`revealed`,`use-markup`,`button-style`]}connectedCallback(){this._initialized||(this._initialized=!0,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-banner-title`,this._button=document.createElement(`button`),this._button.className=`adw-banner-button`,this._button.addEventListener(`click`,()=>{this.dispatchEvent(new CustomEvent(`button-clicked`,{bubbles:!0}))}),this.replaceChildren(this._titleEl,this._button),this._render())}attributeChangedCallback(){this._initialized&&this._render()}_render(){let e=this.getAttribute(`title`)??``;this.hasAttribute(`use-markup`)?renderPangoMarkup(this._titleEl,e):this._titleEl.textContent=e;let t=this.getAttribute(`button-label`)??``;this._button.textContent=bannerButtonText(t),this._button.hidden=!bannerButtonVisible(t);let n=bannerButtonStyleClasses(parseBannerButtonStyle(this.getAttribute(`button-style`)));for(let e of ft)this._button.classList.toggle(e,n.includes(e));this.classList.toggle(`revealed`,this.hasAttribute(`revealed`))}};customElements.define(`adw-banner`,AdwBanner);var AdwBin=class extends WidgetElement{_observer=null;get child(){return this.lastElementChild}set child(e){this.setChild(e)}get_child(){return this.child}set_child(e){this.setChild(e)}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}]),this._enforceSingleChild(),this._observer??=new MutationObserver(()=>this._enforceSingleChild()),this._observer.observe(this,{childList:!0})}disconnectedCallback(){this._observer?.disconnect()}_enforceSingleChild(){let e=this.lastElementChild;if(e!==null)for(let t of Array.from(this.children)){if(t===e)break;t.remove()}}setChild(e){if(e!==null&&e.parentElement!==null&&e.parentElement!==this)throw Error(`AdwBin.setChild: the child already has a parent.`);if(e===this.child)return;let t=this.child;e===null?t?.remove():this.replaceChildren(e),this.dispatchEvent(new CustomEvent(`notify::child`,{bubbles:!0,detail:{child:e}}))}};customElements.define(`adw-bin`,AdwBin);var AdwBottomSheetContent=class extends WidgetElement{},AdwBottomSheetSheet=class extends WidgetElement{},AdwBottomSheetBottomBar=class extends WidgetElement{},AdwBottomSheet=class extends WidgetElement{static signals={"notify::open":`notify::open`};_initialized=!1;_contentEl;_dimmingEl;_sheetEl;_sheetBodyEl;_bottomBarEl;_dragHandleEl;_pendingBottomBar=null;_state=new BottomSheetPresentation;_reflecting=!1;static get observedAttributes(){return[`open`,`modal`,`can-close`,`can-open`,`reveal-bottom-bar`,`show-drag-handle`]}get open(){return this._state.open}set open(e){this._setOpen(!!e)}get modal(){return this._state.modal}set modal(e){this._setBoolAttr(`modal`,e)}get_modal(){return this.modal}set_modal(e){this.modal=e}get canClose(){return this._state.canClose}set canClose(e){this._setBoolAttr(`can-close`,e)}get canOpen(){return this._state.canOpen}set canOpen(e){this._setBoolAttr(`can-open`,e)}get revealBottomBar(){return this._state.revealBottomBar}set revealBottomBar(e){this._setBoolAttr(`reveal-bottom-bar`,e)}get showDragHandle(){return this._boolAttr(`show-drag-handle`,!0)}set showDragHandle(e){this._setBoolAttr(`show-drag-handle`,e)}get bottomBar(){return this._initialized?this._bottomBarEl.firstChild:this._pendingBottomBar}setBottomBar(e){if(this._state.setHasBottomBar(e!==null),!this._initialized){this._pendingBottomBar=e;return}e?this._bottomBarEl.replaceChildren(e):this._bottomBarEl.replaceChildren(),this._render()}requestOpen(e){return this._state.requestOpen(e)}requestClose(e){let t=this._state.requestClose(e);return t===`close-attempt`?this.dispatchEvent(new CustomEvent(`close-attempt`,{bubbles:!0})):t===`delegate`&&this.dispatchEvent(new CustomEvent(`sheet.close`,{bubbles:!0})),t}constructor(){super(),installElementApi(this)}connectedCallback(){if(this._initialized)return;this._initialized=!0,this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-bottom-sheet-content`,this._dimmingEl=document.createElement(`div`),this._dimmingEl.className=`adw-bottom-sheet-dimming`,this._dimmingEl.addEventListener(`click`,()=>this.requestClose(`dimming`)),this._sheetEl=document.createElement(`div`),this._sheetEl.className=`adw-bottom-sheet-sheet`,this._dragHandleEl=document.createElement(`div`),this._dragHandleEl.className=`adw-bottom-sheet-drag-handle`,this._dragHandleEl.setAttribute(`aria-hidden`,`true`),this._sheetBodyEl=document.createElement(`div`),this._sheetBodyEl.className=`adw-bottom-sheet-sheet-body`,this._bottomBarEl=document.createElement(`button`),this._bottomBarEl.type=`button`,this._bottomBarEl.className=`adw-bottom-sheet-bottom-bar`,this._bottomBarEl.addEventListener(`click`,()=>this.requestOpen(`bottom-bar`)),this._sheetEl.append(this._bottomBarEl,this._dragHandleEl,this._sheetBodyEl);let layer=(e,t)=>({claims:t=>t instanceof Element&&t.localName===e,consume:e=>{for(let n of Array.from(e.childNodes))t.appendChild(n)}});bindSlottedChildren(this,[{name:`sheet`,into:this._sheetBodyEl},{name:`bottom-bar`,into:this._bottomBarEl},{name:`content`,into:this._contentEl},layer(`adw-bottom-sheet-sheet`,this._sheetBodyEl),layer(`adw-bottom-sheet-bottom-bar`,this._bottomBarEl),layer(`adw-bottom-sheet-content`,this._contentEl),{into:this._contentEl}],(e,t)=>{!(`into`in t)||t.into!==this._bottomBarEl||(this._state.setHasBottomBar(!0),this._render())}).install(this._contentEl,this._dimmingEl,this._sheetEl),this._pendingBottomBar&&this._bottomBarEl.replaceChildren(this._pendingBottomBar),this._pendingBottomBar=null,this.addEventListener(`keydown`,e=>{e.key===`Escape`&&(!this.open&&!this._sheetEl.contains(e.target)||(e.stopPropagation(),this.requestClose(`escape`)))}),this._state.setCanClose(this._boolAttr(`can-close`,!0)),this._state.setCanOpen(this._boolAttr(`can-open`,!0)),this._state.setRevealBottomBar(this._boolAttr(`reveal-bottom-bar`,!0)),this._state.setHasBottomBar(this._bottomBarEl.childNodes.length>0),this._state.setOpen(this._boolAttr(`open`,!1)),this._state.subscribe(e=>{this._render(),this.dispatchEvent(new CustomEvent(`notify::open`,{bubbles:!0,detail:{open:e}}))}),this._render()}attributeChangedCallback(e,t,n){if(!this._reflecting&&t!==n){if(e===`open`){this._state.setOpen(this._boolAttr(`open`,!1));return}e===`modal`&&this._state.setModal(this._boolAttr(`modal`,!0)),e===`can-close`&&this._state.setCanClose(this._boolAttr(`can-close`,!0)),e===`can-open`&&this._state.setCanOpen(this._boolAttr(`can-open`,!0)),e===`reveal-bottom-bar`&&this._state.setRevealBottomBar(this._boolAttr(`reveal-bottom-bar`,!0)),this._initialized&&this._render()}}_setOpen(e){this._state.setOpen(e)&&(this._initialized||this._reflectOpen(e))}_render(){let e=this._state.open,t=this._state.chrome,n=t.layer===`bottom-bar`;this._reflectOpen(e),this.classList.toggle(`open`,e),this.classList.toggle(`modal`,this._state.modal),this.classList.toggle(`has-drag-handle`,this.showDragHandle),this.classList.toggle(`showing-bottom-bar`,n&&t.surfaceVisible),this._dimmingEl.classList.toggle(`visible`,t.dimmed),this._bottomBarEl.hidden=!n,this._bottomBarEl.classList.toggle(`inert`,t.bottomBarInert),this._sheetBodyEl.hidden=n,this._dragHandleEl.hidden=!this.showDragHandle||n}_reflectOpen(e){this._reflecting=!0,e?this.setAttribute(`open`,``):this.removeAttribute(`open`),this._reflecting=!1}_boolAttr(e,t){let n=this.getAttribute(e);return n===null?t:n!==`false`}_setBoolAttr(e,t){t?this.setAttribute(e,``):this.setAttribute(e,`false`)}};customElements.define(`adw-bottom-sheet-content`,AdwBottomSheetContent),customElements.define(`adw-bottom-sheet-sheet`,AdwBottomSheetSheet),customElements.define(`adw-bottom-sheet-bottom-bar`,AdwBottomSheetBottomBar),customElements.define(`adw-bottom-sheet`,AdwBottomSheet);function parseBreakpoints(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return console.error("<adw-breakpoint-bin>: `breakpoints` is not JSON; no breakpoint is applied."),[]}return Array.isArray(t)?t.flatMap(e=>{if(typeof e!=`object`||!e)return[];let{condition:t,setters:n}=e;return typeof t==`string`?[{condition:t,setters:Array.isArray(n)?n:[]}]:[]}):[]}var AdwBreakpointBin=class extends WidgetElement{_state=new BreakpointBinState;_dispose;_applied=null;_pendingSync=!1;_originals=new Map;static get observedAttributes(){return[`breakpoints`]}get currentBreakpoint(){return this._state.current}get currentBreakpointAttribute(){let e=this._state.current;return e===null?null:String(e)}get child(){return this.firstElementChild}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}]),this.setAttribute(`role`,`group`),this.style.display=`block`,this._syncSizing(),this._pendingSync=!0,this._observe()}disconnectedCallback(){this._dispose?.(),this._dispose=void 0}attributeChangedCallback(e){e!==`breakpoints`||!this.isConnected||(this._originals.clear(),this._syncBreakpoints())}_syncBreakpoints(){this._pendingSync=!1;let e=parseBreakpoints(this.getAttribute(`breakpoints`));this._state=new BreakpointBinState;for(let t of e){let e=[];for(let n of t.setters){if(typeof n?.target!=`string`||typeof n.property!=`string`)continue;let t=this.querySelector(n.target);if(t===null)continue;let r=`${n.target}\u0000${n.property}\u0000${n.value}`;this._originals.has(r)||this._originals.set(r,t.getAttribute(n.property)),e.push({object:t,property:n.property,value:n.value,originalValue:this._originals.get(r)??null})}this._state.add({condition:t.condition,setters:e})}this._state.inherit(this._applied),this._state.setHasChild(this.child!==null),this._write(this._state.current),this._syncSizing()}_observe(){this._dispose?.(),this._dispose=observeAdaptiveSize(this,e=>{this._pendingSync&&this._syncBreakpoints(),this._state.setHasChild(this.child!==null);let t=this._state.evaluate(e);t!==null&&(this._emit(t.from,`breakpoint-unapply`),this._perform(t.writes),this._write(t.to),this._emit(t.to,`breakpoint-apply`),this.dispatchEvent(new CustomEvent(`notify::current-breakpoint`,{bubbles:!0,detail:{currentBreakpoint:this.currentBreakpointAttribute}})))})}_perform(e){for(let t of e)t.value===null?t.object.removeAttribute(t.property):t.object.setAttribute(t.property,String(t.value))}_write(e){this._applied=e}_emit(e,t){e!==null&&this.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:{index:e}}))}_syncSizing(){let e=this._state.length>0;this.style.minWidth=e?`0px`:``,this.style.minHeight=e?`0px`:``,e&&(this.style.overflow=`hidden`)}};customElements.define(`adw-breakpoint-bin`,AdwBreakpointBin);var AdwButtonContent=class extends WidgetElement{_boxEl;_iconEl;_labelEl;_initialized=!1;_styledHost=null;static get observedAttributes(){return[`icon-name`,`label`,`use-underline`,`can-shrink`]}connectedCallback(){this._initialized||(this._initialized=!0,this._boxEl=document.createElement(`div`),this._boxEl.className=`adw-button-content-box`,this._iconEl=createGtkImage(null),this._labelEl=document.createElement(`span`),this._labelEl.className=`adw-button-content-label`,this._boxEl.append(this._iconEl,this._labelEl),this.replaceChildren(this._boxEl),this._render()),this._root()}disconnectedCallback(){this._unroot()}attributeChangedCallback(e){this._initialized&&(this._render(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0})))}_hostButton(){let e=this.parentElement?.closest(`button, .adw-button`)??null;if(!e)return null;let t=e.parentElement;return t?.matches(`adw-split-button, .adw-split-button`)?t:e}_root(){let e=this._hostButton();e!==this._styledHost&&(this._unroot(),e&&(e.classList.add(gt),this._styledHost=e))}_unroot(){this._styledHost?.classList.remove(gt),this._styledHost=null}_render(){this._iconEl.iconName=buttonContentIconName(this.getAttribute(`icon-name`)??``),this._iconEl.hidden=!1;let e=this.getAttribute(`label`)??``;this._labelEl.textContent=buttonContentLabelText(e,this.hasAttribute(`use-underline`)),this._labelEl.hidden=e.length===0,this.classList.toggle(`can-shrink`,this.hasAttribute(`can-shrink`))}};customElements.define(`adw-button-content`,AdwButtonContent);var AdwButtonRow=class extends TooltipElement{_contentsEl;_startIconEl;_endIconEl;_titleEl;_state=new ButtonRowState;_initialized=!1;static get observedAttributes(){return[`title`,`start-icon-name`,`end-icon-name`,`tooltip-text`]}connectedCallback(){this._initialized||(this._contentsEl=document.createElement(`div`),this._contentsEl.className=`adw-button-row-contents`,this._startIconEl=createGtkImage(null,`start`),this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-button-row-title`,this._endIconEl=createGtkImage(null,`end`),this._contentsEl.append(this._startIconEl,this._titleEl,this._endIconEl),this.replaceChildren(this._contentsEl),this._initialized=!0,this._render(),this.addEventListener(`click`,()=>{this.dispatchEvent(new CustomEvent(`activated`,{bubbles:!0}))}),attachRowActivation({row:this,activatable:()=>!0}))}attributeChangedCallback(){this._initialized&&this._render()}_render(){this._state.setTitle(this.getAttribute(`title`)),this._state.setStartIconName(this.getAttribute(`start-icon-name`)),this._state.setEndIconName(this.getAttribute(`end-icon-name`));let e=this._state.state;this._titleEl.textContent=e.title,this._titleEl.hidden=!e.titleVisible,this._paintIcon(this._startIconEl,e.startIconName,e.startIconVisible),this._paintIcon(this._endIconEl,e.endIconName,e.endIconVisible),this.classList.toggle(`activatable`,!0),applyRowTooltip(this,[this._contentsEl])}_paintIcon(e,t,n){e.iconName=n?t:null,e.hidden=!n}};customElements.define(`adw-button-row`,AdwButtonRow);function attachSwipeDrag(e){let t=new SwipeTracker({points:e.points,allowLongSwipes:e.allowLongSwipes,cancelProgress:e.cancelProgress}),n=null,r=0,i=0,a=0,o=0,s=0,c=`none`,l=null,u=!1,axisOffset=(t,n)=>e.orientation===`vertical`?n:t,progressOffset=(e,t)=>-axisOffset(e,t),release=()=>{let r=n;n=null,c=`none`,t.reset(),globalThis.removeEventListener(`pointermove`,onMove,!0),globalThis.removeEventListener(`pointerup`,onFinish,!0),globalThis.removeEventListener(`pointercancel`,onCancel,!0),globalThis.removeEventListener(`lostpointercapture`,onLostCapture,!0),r!==null&&e.host.hasPointerCapture(r)&&e.host.releasePointerCapture(r),l!==null&&(e.host.style.scrollSnapType=l.scrollSnapType,e.host.style.scrollBehavior=l.scrollBehavior,e.host.style.userSelect=l.userSelect,l=null)},claimAllowed=t=>{let n=e.points();if(n.length===0)return!1;let a=n[0],c=n[n.length-1];if(Math.abs(a-c)<2**-52)return!1;let l=e.progress(),u=t<0&&(Math.abs(l-a)<2**-52||l<a),d=t>0&&(Math.abs(l-c)<2**-52||l>c);return u||d?!1:e.claimable===void 0?!0:e.claimable({x:r,y:i})||e.claimable({x:o,y:s})},claim=()=>{c=`scrolling`,n!==null&&e.host.setPointerCapture(n),l={scrollSnapType:e.host.style.scrollSnapType,scrollBehavior:e.host.style.scrollBehavior,userSelect:e.host.style.userSelect},e.host.style.scrollSnapType=`none`,e.host.style.scrollBehavior=`auto`,e.host.style.userSelect=`none`},arm=()=>{globalThis.addEventListener(`pointermove`,onMove,!0),globalThis.addEventListener(`pointerup`,onFinish,!0),globalThis.addEventListener(`pointercancel`,onCancel,!0),globalThis.addEventListener(`lostpointercapture`,onLostCapture,!0)};e.host.addEventListener(`pointerdown`,t=>{if(u=!1,n!==null){if(t.pointerId!==n)return;release()}t.pointerType!==`mouse`||t.button!==0||e.enabled()&&t.target?.closest(`select, textarea, input[type="range"], [contenteditable=""], [contenteditable="true"]`)===null&&(n=t.pointerId,r=t.clientX,i=t.clientY,o=t.clientX,s=t.clientY,a=0,c=`pending`,arm())});function onMove(l){if(n!==l.pointerId)return;o=l.clientX,s=l.clientY;let u=l.clientX-r,d=l.clientY-i,f=progressOffset(u,d),p=f-a;a=f;let m=Math.trunc(l.timeStamp);if(t.record(p,m),!(l.buttons&1)){release();return}if(c===`pending`){if(Math.abs(d)>Math.abs(u)!=(e.orientation===`vertical`)){release();return}if(Math.hypot(u,d)<16)return;if(!claimAllowed(f)){release();return}t.prepare(e.progress()),claim(),a=f;return}c===`scrolling`&&(l.preventDefault(),e.onUpdate(t.advance(p,e.pitch())))}function finish(r,i){if(n!==r.pointerId)return;if(c!==`scrolling`){release();return}i&&t.cancel();let{to:a,velocity:o}=t.end(Math.trunc(r.timeStamp));release(),u=!0,e.onEnd(a,o)}function onFinish(e){finish(e,!1)}function onCancel(e){finish(e,!0)}function onLostCapture(e){finish(e,!1)}return e.host.addEventListener(`click`,e=>{u&&(u=!1,e.stopPropagation(),e.preventDefault())},{capture:!0}),{get dragging(){return c===`scrolling`}}}function wheelSource(e){if(e.deltaMode!==0)return`mouse`;let t=Math.abs(e.deltaY),n=Math.abs(e.deltaX);if(n>0&&t>0)return`touchpad`;let r=Math.max(n,t);return!Number.isInteger(r)||r<40?`touchpad`:`mouse`}var AdwCarousel=class extends WidgetElement{_state=new CarouselState({animateScroll:!0,onScrollTo:e=>this._performScroll(e)});_trackEl;_slots=new Map;_nextPageId=0;_scrollRaf=0;_initialized=!1;_pendingPosition=null;_pendingLayout;_layoutObserver;_pendingInteractive=null;_scrollTargetId=null;_drag;_pendingScrollPage=null;static get observedAttributes(){return[`allow-scroll-wheel`,`allow-mouse-drag`,`allow-long-swipes`,`interactive`,`spacing`,`position`]}constructor(){super(),this._state.subscribe(e=>this._onStateChange(e)),this._state.onPageChanged(e=>{this.dispatchEvent(new CustomEvent(`page-changed`,{bubbles:!0,detail:{index:e}}))})}get nPages(){return this._state.nPages}get position(){return this._state.position}set position(e){this._scrollToPosition(e)}get currentPage(){return this._state.pageAt(this._state.position)}get allowMouseDrag(){return this._state.allowMouseDrag}set allowMouseDrag(e){this.setAttribute(`allow-mouse-drag`,e?`true`:`false`)}get allowScrollWheel(){return this._state.allowScrollWheel}set allowScrollWheel(e){this.setAttribute(`allow-scroll-wheel`,e?`true`:`false`)}get allowLongSwipes(){return this._state.allowLongSwipes}set allowLongSwipes(e){this.toggleAttribute(`allow-long-swipes`,e)}get interactive(){return this._state.interactive}set interactive(e){this.setAttribute(`interactive`,e?`true`:`false`)}get spacing(){return this._state.spacing}set spacing(e){this.setAttribute(`spacing`,String(e))}connectedCallback(){this._initialized||this._build(),this._observeLayout()}_build(){this._initialized=!0,this._trackEl=document.createElement(`div`),this._trackEl.className=`adw-carousel-track`,this._trackEl.style.setProperty(`scroll-behavior`,`smooth`),this._applyAttribute(`allow-scroll-wheel`,this.getAttribute(`allow-scroll-wheel`)),this._applyAttribute(`allow-mouse-drag`,this.getAttribute(`allow-mouse-drag`)),this._applyAttribute(`allow-long-swipes`,this.getAttribute(`allow-long-swipes`)),this._applyAttribute(`interactive`,this.getAttribute(`interactive`)),this._applyAttribute(`spacing`,this.getAttribute(`spacing`));let e=Array.from(this.children).filter(e=>e instanceof HTMLElement);this.replaceChildren(this._trackEl);for(let t of e)this._insert(t,-1);this._trackEl.addEventListener(`scroll`,this._onScroll,{passive:!0}),this._trackEl.addEventListener(`wheel`,this._onWheel,{passive:!1}),this._drag=attachSwipeDrag({host:this._trackEl,orientation:`horizontal`,enabled:()=>this._state.interactive&&this._state.allowMouseDrag,pitch:()=>this._distance(),points:()=>this._state.snapPoints,progress:()=>this._state.position,allowLongSwipes:()=>this._state.allowLongSwipes,cancelProgress:()=>{let e=this._state.snapPoints;return e[carouselClosestSnapPoint(this._state.position,e)]??this._state.position},onUpdate:e=>{let t=this._distance();t>0&&(this._trackEl.scrollLeft=e*t)},onEnd:e=>{let t=this._distance();t>0&&this._trackEl.scrollTo({left:e*t})}}),this._applyAttribute(`position`,this.getAttribute(`position`));let t=this._pendingScrollPage;this._pendingScrollPage=null;let n=t?this._idOf(t):null;n!==null&&this._positionWhenMeasurable(this._state.indexOf(n))}attributeChangedCallback(e,t,n){this._initialized&&this._applyAttribute(e,n)}disconnectedCallback(){this._cancelPendingPosition(),this._layoutObserver?.disconnect(),this._layoutObserver=void 0}_observeLayout(){this._layoutObserver||(this._layoutObserver=new ResizeObserver(()=>{this._allocatePages()&&this._applyScrollFromModel()}),this._layoutObserver.observe(this._trackEl,{box:`border-box`}))}_applyAttribute(e,t){switch(e){case`allow-scroll-wheel`:this._state.setAllowScrollWheel(t!==`false`);return;case`allow-mouse-drag`:this._state.setAllowMouseDrag(t!==`false`);return;case`allow-long-swipes`:this._state.setAllowLongSwipes(t!==null&&t!==`false`),this._applySnapStop();return;case`interactive`:this._state.setInteractive(t!==`false`);return;case`spacing`:{let e=t===null?0:Number.parseFloat(t);Number.isFinite(e)&&this._state.setSpacing(Math.max(0,e)),this._trackEl.style.columnGap=`${this._state.spacing}px`;return}case`position`:t!==null&&this._positionWhenMeasurable(Number.parseFloat(t))}}_positionWhenMeasurable(e){if(Number.isFinite(e)){if(this._trackEl.clientWidth>0){this._cancelPendingPosition(),this._scrollInstantly(e);return}this._pendingPosition=e,!this._pendingLayout&&(this._pendingLayout=new ResizeObserver(()=>{if(this._trackEl.clientWidth<=0)return;let e=this._pendingPosition;this._cancelPendingPosition(),e!==null&&this._scrollInstantly(e)}),this._pendingLayout.observe(this._trackEl))}}_scrollInstantly(e){let t=this._trackEl.style.getPropertyValue(`scroll-behavior`);this._trackEl.style.setProperty(`scroll-behavior`,`auto`);try{this._scrollToPosition(e)}finally{t?this._trackEl.style.setProperty(`scroll-behavior`,t):this._trackEl.style.removeProperty(`scroll-behavior`)}}_cancelPendingPosition(){this._pendingLayout?.disconnect(),this._pendingLayout=void 0,this._pendingPosition=null}_scrollToPosition(e){if(!Number.isFinite(e))return;let t=this._state.pageAt(e);t>=0&&this.scrollToPage(t)}insertPage(e,t=-1){return this._initialized?this._insert(e,t):(this.appendChild(e),!0)}appendPage(e){return this.insertPage(e,-1)}prependPage(e){return this.insertPage(e,0)}removePage(e){let t=this._idOf(e);return t===null||!this._state.removePage(t)?!1:(this._state.skipReveal(t),this._syncTrack(),!0)}reorderPage(e,t){let n=this._idOf(e);return n===null||!this._state.reorderPage(n,t)?!1:(this._syncTrack(),!0)}scrollToPage(e){this._state.scrollTo(e)}navigate(e){return this._state.navigate(e)}scroll_to(e,t){if(!this._initialized){e.parentElement===this&&(this._pendingScrollPage=e);return}let n=this._idOf(e);n!==null&&this._state.scrollTo(this._state.indexOf(n),{animate:t})}get_nth_page(e){if(!this._initialized){let t=this.children[e];return Number.isInteger(e)&&t instanceof HTMLElement?t:null}if(!Number.isInteger(e)||e<0||e>=this._state.nPages)return null;let t=this._state.ids[e],n=t===void 0?null:this._slots.get(t)?.firstElementChild;return n instanceof HTMLElement?n:null}get_n_pages(){return this._initialized?this._state.nPages:this.children.length}get_position(){return this._state.position}_insert(e,t){let n=`page-${this._nextPageId++}`;if(!this._state.insertPage(n,t))return!1;let r=document.createElement(`div`);return r.className=`adw-carousel-page`,r.appendChild(e),this._slots.set(n,r),this._state.skipReveal(n),this._syncTrack(),!0}_idOf(e){for(let[t,n]of this._slots)if(n.contains(e))return t;return null}_syncTrack(){let e=this._state.ids,t=new Set(e);for(let[e,n]of this._slots)t.has(e)||(n.remove(),this._slots.delete(e));e.forEach((e,t)=>{let n=this._slots.get(e);n&&this._trackEl.children[t]!==n&&this._trackEl.insertBefore(n,this._trackEl.children[t]??null)}),this._applySnapStop(),this._allocatePages(),this._applyScrollFromModel()}_allocatePages(){let e=[...this._slots.values()];if(e.length===0)return!1;let t=e[0].getBoundingClientRect().width;this._trackEl.style.removeProperty(`padding-inline`);for(let t of e)t.style.removeProperty(`flex-basis`);let n=this._trackEl.clientWidth;if(!(n>0))return!1;let{pageSize:r,leadingInset:i}=carouselPageAllocation(n,e.map(e=>({natural:e.firstElementChild?.getBoundingClientRect().width??0})));if(!(r>0))return!1;for(let t of e)t.style.flexBasis=`${r}px`;return i>0&&(this._trackEl.style.paddingInline=`${i}px`),Math.round(r)!==Math.round(t)}_applyScrollFromModel(){let e=this._distance();e>0&&this._trackEl.scrollTo({left:this._restorePosition()*e,behavior:`instant`})}_restorePosition(){if(this._scrollTargetId===null)return this._state.position;let e=this._state.ids.indexOf(this._scrollTargetId);return e<0?this._state.position:this._state.snapPointOf(e)??this._state.position}_applySnapStop(){let e=this._state.allowLongSwipes?`normal`:`always`;for(let t of this._slots.values())t.style.setProperty(`scroll-snap-stop`,e)}_distance(){let e=this._trackEl?.firstElementChild;return e?this._state.pageDistance(e.getBoundingClientRect().width):0}_performScroll(e){if(!this._trackEl)return;let t=this._distance();if(t>0){if(!e.animate){this._pendingInteractive=null,this._scrollTargetId=null,this._trackEl.scrollTo({left:e.index*t,behavior:`instant`});return}this._pendingInteractive=e.interactive,this._scrollTargetId=this._state.ids[e.index]??null,this._trackEl.scrollTo({left:e.index*t})}}_onScroll=()=>{this._scrollRaf||=requestAnimationFrame(()=>{this._scrollRaf=0,this._updatePositionFromScroll()})};_onWheel=e=>{if(this._drag?.dragging===!0){e.preventDefault();return}this._state.handleWheel({deltaX:e.deltaX,deltaY:e.deltaY,source:wheelSource(e)})!==0&&e.preventDefault()};_updatePositionFromScroll(){let e=this._distance();if(!(e>0))return;let t=this._trackEl.scrollLeft/e;this._state.setPosition(t,this._pendingInteractive??!0)&&this._state.settleIfArrived()&&(this._pendingInteractive=null,this._scrollTargetId=null)}_onStateChange(e){if(e.reason===`n-pages`){this.dispatchEvent(new CustomEvent(`notify::n-pages`,{bubbles:!0,detail:{nPages:e.nPages}}));return}e.reason===`position`&&this.dispatchEvent(new CustomEvent(`notify::position`,{bubbles:!0,detail:{position:e.position,page:e.page,interactive:e.interactive}}))}},AdwCarouselIndicator=class extends WidgetElement{_carousel=null;_initialized=!1;static get observedAttributes(){return[`for`,`carousel`]}get carousel(){return this._carousel}set carousel(e){e!==this._carousel&&(this._detach(),this._carousel=e,this._attach())}connectedCallback(){this._initialized=!0,this._carousel||this._resolveForAttr(),this._attach(),this._render()}disconnectedCallback(){this._detach()}attributeChangedCallback(e){(e===`for`||e===`carousel`)&&this._initialized&&(this._detach(),this._carousel=null,this._resolveForAttr(),this._attach(),this._render())}_resolveForAttr(){let e=this.getAttribute(`carousel`)??this.getAttribute(`for`);if(!e)return;let t=this.getRootNode().getElementById?.(e)??document.getElementById(e);t instanceof AdwCarousel&&(this._carousel=t)}_attach(){!this._carousel||!this._initialized||(this._carousel.addEventListener(`notify::position`,this._onChange),this._carousel.addEventListener(`notify::n-pages`,this._onChange),this._render())}_detach(){this._carousel&&(this._carousel.removeEventListener(`notify::position`,this._onChange),this._carousel.removeEventListener(`notify::n-pages`,this._onChange))}_onChange=()=>{this._render()};nPages(){return this._carousel?.nPages??0}position(){return this._carousel?.position??0}currentPage(){return this._carousel?.currentPage??-1}goTo(e){this._carousel?.scrollToPage(e)}},AdwCarouselIndicatorDots=class extends AdwCarouselIndicator{_render(){renderIndicator(this,`adw-carousel-dot`,this.nPages(),this.position(),this.currentPage(),e=>this.goTo(e))}},AdwCarouselIndicatorLines=class extends AdwCarouselIndicator{_render(){renderIndicator(this,`adw-carousel-line`,this.nPages(),this.position(),this.currentPage(),e=>this.goTo(e))}};function renderIndicator(e,t,n,r,i,a){if(e.childElementCount!==n){let r=[];for(let e=0;e<n;e++){let n=document.createElement(`button`);n.type=`button`,n.className=t,n.setAttribute(`aria-label`,`Page ${e+1}`),n.addEventListener(`click`,()=>a(e)),r.push(n)}e.replaceChildren(...r)}Array.from(e.children).forEach((e,t)=>{let n=Math.max(0,1-Math.abs(r-t)),a=e;a.style.setProperty(`--adw-carousel-progress`,n.toFixed(3)),a.classList.toggle(`active`,t===i),a.setAttribute(`aria-current`,t===i?`true`:`false`)})}customElements.define(`adw-carousel`,AdwCarousel),customElements.define(`adw-carousel-indicator-dots`,AdwCarouselIndicatorDots),customElements.define(`adw-carousel-indicator-lines`,AdwCarouselIndicatorLines);var AdwClamp=class extends WidgetElement{_resize=null;_mutations=null;static get observedAttributes(){return[`maximum-size`,`tightening-threshold`]}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}]),this._resize=new ResizeObserver(()=>this._allocate()),this._resize.observe(this),this._mutations=new MutationObserver(()=>this._allocate()),this._mutations.observe(this,{childList:!0}),this._allocate()}disconnectedCallback(){this._resize?.disconnect(),this._resize=null,this._mutations?.disconnect(),this._mutations=null}attributeChangedCallback(){this._allocate()}_allocate(){let e={maximumSize:normalizeClampSize(this.getAttribute(`maximum-size`),xt.maximumSize),tighteningThreshold:normalizeClampSize(this.getAttribute(`tightening-threshold`),xt.tighteningThreshold),childMin:0,childNat:0},t=this.clientWidth,n=Array.from(this.children);if(t<=0){for(let e of n){e.style.maxWidth=``,e.style.marginInline=``;for(let t of St)e.classList.remove(t)}return}let{childSize:r,sizeClass:i}=clampAllocate(t,e);for(let e of n){e.style.maxWidth=`${r}px`,e.style.marginInline=`auto`;for(let t of St)e.classList.toggle(t,t===i)}}};customElements.define(`adw-clamp`,AdwClamp);const Qr={automatic:`auto`,always:`scroll`,never:`hidden`};var AdwClampScrollable=class extends WidgetElement{_resize=null;_mutations=null;static get observedAttributes(){return[`maximum-size`,`tightening-threshold`,`unit`,`orientation`,`hscroll-policy`,`vscroll-policy`]}get maximumSize(){return normalizeClampSize(this.getAttribute(`maximum-size`),xt.maximumSize)}set maximumSize(e){this.setAttribute(`maximum-size`,String(e))}get tighteningThreshold(){return normalizeClampSize(this.getAttribute(`tightening-threshold`),xt.tighteningThreshold)}set tighteningThreshold(e){this.setAttribute(`tightening-threshold`,String(e))}get unit(){return normalizeLengthUnit(this.getAttribute(`unit`),`sp`)}set unit(e){this.setAttribute(`unit`,e)}get orientation(){return normalizeBoxOrientation(this.getAttribute(`orientation`))}set orientation(e){this.setAttribute(`orientation`,e)}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}]),this._resize=new ResizeObserver(()=>this._allocate()),this._resize.observe(this),this._mutations=new MutationObserver(()=>this._allocate()),this._mutations.observe(this,{childList:!0}),this._applyOverflow(),this._allocate()}disconnectedCallback(){this._resize?.disconnect(),this._resize=null,this._mutations?.disconnect(),this._mutations=null}attributeChangedCallback(){this._applyOverflow(),this._allocate()}_applyOverflow(){let e=this.getAttribute(`hscroll-policy`),t=this.getAttribute(`vscroll-policy`);this.style.overflowX=e===null?`auto`:Qr[e]??`auto`,this.style.overflowY=t===null?`auto`:Qr[t]??`auto`}_allocate(){let e=this.orientation===`vertical`,t=this.unit,n=e?this.clientHeight:this.clientWidth,r={maximumSize:adwLengthToPx(t,this.maximumSize),tighteningThreshold:adwLengthToPx(t,this.tighteningThreshold),childMin:0,childNat:0};for(let t of Array.from(this.children)){if(n<=0){t.style.maxWidth=``,t.style.maxHeight=``,t.style.marginInline=``,t.style.marginBlock=``;for(let e of St)t.classList.remove(e);continue}let{childSize:i,sizeClass:a}=clampAllocate(n,r);e?(t.style.maxWidth=``,t.style.maxHeight=`${i}px`,t.style.marginInline=``,t.style.marginBlock=`auto`):(t.style.maxWidth=`${i}px`,t.style.maxHeight=``,t.style.marginInline=`auto`,t.style.marginBlock=``);for(let e of St)t.classList.toggle(e,e===a)}}};customElements.define(`adw-clamp-scrollable`,AdwClampScrollable);function stringListSlot(e){return{name:`model`,consume:t=>e(parseListModel(t instanceof Element?t.getAttribute(`strings`):null))}}var AdwComboRow=class extends TooltipElement{_select;_valueEl;_textEl;_titleEl;_subtitleEl;_state=new ComboState;_authored=Mt.new(null);_initialized=!1;static get observedAttributes(){return[`title`,`subtitle`,`model`,`selected`,`tooltip-text`,`title-lines`,`subtitle-lines`]}get model(){return this._state.model}set model(e){this._state.setModel(readModelWrite(e,this._authored))}get options(){return this._state.options}set_model(e){this.model=e}get_model(){return this.model}get selected(){return this._initialized?this._state.selectedIndex:parseInt(this.getAttribute(`selected`)||`0`,10)}set selected(e){this.setAttribute(`selected`,String(e))}get_selected(){return this.selected}set_selected(e){this.selected=e}get selectedValue(){return this._state.selectedValue}set selectedValue(e){let t=this._state.options.findIndex(t=>t.value===e);t>=0&&(this.selected=t)}get selectedItem(){return this._state.selectedItem}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=document.createElement(`div`);e.className=`adw-row-text`,this._textEl=e,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-row-title`,this._subtitleEl=document.createElement(`span`),this._subtitleEl.className=`adw-row-subtitle`,e.append(this._titleEl,this._subtitleEl),this._valueEl=document.createElement(`span`),this._valueEl.className=`adw-row-value`,this._select=document.createElement(`select`),bindSlottedChildren(this,[stringListSlot(e=>{this._authored.reconcile(e),this._state.setModel(this._authored)})]).install(e,this._valueEl,this._select);let t=this.getAttribute(`model`);this._state.model===null&&t!==null&&(this._authored.reconcile(parseListModel(t)),this._state.setModel(this._authored)),this._state.setSelectedIndex(parseInt(this.getAttribute(`selected`)||`0`,10)),this._state.subscribeItems(e=>this._applyItemsChanged(e)),this._state.subscribe(e=>{this._valueEl.textContent=e.label,this._select.selectedIndex!==e.selected&&(this._select.selectedIndex=e.selected),this._syncChooser(),e.interactive&&(this.setAttribute(`selected`,String(e.selected)),this.dispatchEvent(new CustomEvent(`notify::selected`,{bubbles:!0,detail:{selected:e.selected}})))}),this._select.addEventListener(`change`,()=>{this._state.select(this._select.selectedIndex)}),this._renderOptions(),this._renderText()}attributeChangedCallback(e,t,n){this._initialized&&(e===`model`?this.model=n:e===`selected`?this._state.setSelectedIndex(parseInt(n||`0`,10)):this._renderText())}_createOption(e){let t=document.createElement(`option`);return t.value=e.value,t.textContent=e.label,t}_applyItemsChanged(e){if(!this._initialized)return;for(let t=0;t<e.removed;t++)this._select.remove(e.position);let t=this._select.options[e.position]??null,n=this._state.options;for(let r=0;r<e.added;r++){let i=n[e.position+r];i&&this._select.insertBefore(this._createOption(i),t)}}_renderOptions(){this._initialized&&(this._select.replaceChildren(...this._state.options.map(e=>this._createOption(e))),this._select.selectedIndex=this._state.selectedIndex,this._valueEl.textContent=this._state.selectedLabel,this._syncChooser())}_syncChooser(){let e=this._state.presentsChooser;this.dataset.presentsChooser=e?`true`:`false`,this._select.disabled=!e}_renderText(){let e=deriveRowLabels({title:this.getAttribute(`title`),subtitle:this.getAttribute(`subtitle`)});this._titleEl.textContent=e.title,this._titleEl.hidden=!e.titleVisible,this._subtitleEl.textContent=e.subtitle,this._subtitleEl.hidden=!e.subtitleVisible,applyRowTooltip(this,[this._textEl,this._valueEl,this._select]),this._applyLineClamping()}_applyLineClamping(){applyRowLineClamp({titleEl:this._titleEl,subtitleEl:this._subtitleEl,textContainerEl:this._titleEl.parentElement,getTitleLines:()=>parseRowLinesAttribute(this.getAttribute(`title-lines`)),getSubtitleLines:()=>parseRowLinesAttribute(this.getAttribute(`subtitle-lines`))})}};customElements.define(`adw-combo-row`,AdwComboRow);const $r=[`auto`,`floating`,`bottom-sheet`];var AdwDialog=class extends WidgetElement{_initialized=!1;_scrimEl;_boxEl;_headerEl;_titleEl;_closeBtn;_contentEl;_modal;static get observedAttributes(){return[`title`,`open`,`can-close`,`content-width`,`content-height`,`presentation-mode`,`show-header`]}get open(){return this.hasAttribute(`open`)}set open(e){e?this.setAttribute(`open`,``):this.removeAttribute(`open`)}get title(){return this.getAttribute(`title`)??``}set title(e){this.setAttribute(`title`,e)}get canClose(){let e=this.getAttribute(`can-close`);return e===null?!0:e!==`false`}set canClose(e){e?this.setAttribute(`can-close`,``):this.setAttribute(`can-close`,`false`)}get contentWidth(){let e=Number.parseInt(this.getAttribute(`content-width`)??``,10);return Number.isNaN(e)?360:e}set contentWidth(e){this.setAttribute(`content-width`,String(e))}get contentHeight(){let e=Number.parseInt(this.getAttribute(`content-height`)??``,10);return Number.isNaN(e)?0:e}set contentHeight(e){e>0?this.setAttribute(`content-height`,String(e)):this.removeAttribute(`content-height`)}get presentationMode(){let e=this.getAttribute(`presentation-mode`);return e&&$r.includes(e)?e:`auto`}set presentationMode(e){this.setAttribute(`presentation-mode`,e)}get contentArea(){return this._contentEl}present(e){this.isConnected||(e??document.body).appendChild(this),this.open=!0}close(){this._attemptClose()}forceClose(){this.open&&=!1}connectedCallback(){if(this._initialized)return;this._initialized=!0,this.classList.add(`adw-dialog`),this._scrimEl=document.createElement(`div`),this._scrimEl.className=`adw-dialog-scrim`,this._scrimEl.addEventListener(`click`,()=>this._attemptClose()),this._boxEl=document.createElement(`div`),this._boxEl.className=`adw-dialog-box`,this._boxEl.addEventListener(`click`,e=>e.stopPropagation()),this._modal=new AdwModalSurface({host:this,surface:this._boxEl,role:`dialog`,isOpen:()=>this.open,onEscape:()=>this._attemptClose()}),this._headerEl=document.createElement(`div`),this._headerEl.className=`adw-dialog-header`;let e=document.createElement(`div`);e.className=`adw-dialog-header-side`,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-dialog-title`;let t=document.createElement(`div`);t.className=`adw-dialog-header-side adw-dialog-header-side--end`,this._closeBtn=document.createElement(`button`),this._closeBtn.type=`button`,this._closeBtn.className=`adw-dialog-close`,this._closeBtn.setAttribute(`aria-label`,`Close`),this._closeBtn.addEventListener(`click`,()=>this._attemptClose()),t.appendChild(this._closeBtn),this._headerEl.append(e,this._titleEl,t),this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-dialog-content`,this._boxEl.append(this._headerEl,this._contentEl),this._scrimEl.appendChild(this._boxEl),bindSlottedChildren(this,[{name:`child`,into:this._contentEl},{into:this._contentEl}]).install(this._scrimEl),this._render()}attributeChangedCallback(e,t,n){this._initialized&&t!==n&&(this._render(),e===`open`&&(this.dispatchEvent(new CustomEvent(`notify::open`,{bubbles:!0,detail:{open:this.open}})),this.open?this._modal.present():this._onClosed()))}_attemptClose(){if(this.open){if(!this.canClose){this.dispatchEvent(new CustomEvent(`close-attempt`,{bubbles:!0}));return}this.open=!1}}_onClosed(){this.dispatchEvent(new CustomEvent(`closed`,{bubbles:!0})),this._modal.dismiss()}decorateHeader(e){}_render(){this.classList.toggle(`open`,this.open);let e=this.title;this._titleEl.textContent=e;let t=e.length>0||this.hasAttribute(`show-header`);this._headerEl.hidden=!t,this.dataset.presentation=this.presentationMode,this._boxEl.style.setProperty(`--adw-dialog-content-width`,`${this.contentWidth}px`);let n=this.contentHeight;n>0?this._boxEl.style.setProperty(`--adw-dialog-content-height`,`${n}px`):this._boxEl.style.removeProperty(`--adw-dialog-content-height`);let r=!this.canClose;this._closeBtn.disabled=r,this._closeBtn.classList.toggle(`locked`,r),this.decorateHeader(this._headerEl)}};customElements.define(`adw-dialog`,AdwDialog);function setPartVisible(e,t){e.hidden=!t,e.style.display=t?``:`none`}var AdwEntryRow=class extends TooltipElement{_state=new EntryRowState;_input;_emptyTitle;_title;_area;_editIcon;_indicator;_applyButton;_prefixes;_suffixes;_initialized=!1;_slots;_lastText=``;_lastLength=0;static get observedAttributes(){return[`title`,`text`,`editable`,`max-length`,`show-apply-button`,`activates-default`,`tooltip-text`]}get _classPrefix(){return`adw-entry-row`}get text(){return this._state.text}set text(e){this._state.setText(e??``)}get textLength(){return this._state.textLength}get maxLength(){return this._state.maxLength}set maxLength(e){this._state.setMaxLength(e)}get editable(){return this._state.editable}set editable(e){this._state.setEditable(e)}get showApplyButton(){return this._state.showApplyButton}set showApplyButton(e){this._state.setShowApplyButton(e)}get activatesDefault(){return this._state.activatesDefault}set activatesDefault(e){this._state.setActivatesDefault(e)}get editing(){return this._state.editing}connectedCallback(){this._initialized||(this._initialized=!0,this._build(),this._state.setMaxLength(Number.parseInt(this.getAttribute(`max-length`)??``,10)),this._state.setEditable(this.getAttribute(`editable`)!==`false`),this._state.setShowApplyButton(booleanAttribute$2(this.getAttribute(`show-apply-button`),!1)),this._state.setActivatesDefault(booleanAttribute$2(this.getAttribute(`activates-default`),!1)),this.hasAttribute(`text`)&&this._state.setText(this.getAttribute(`text`)??``),this._renderTitle(),this._onConnected(),this._slots.install(this._prefixes,this._area,this._indicator,this._applyButton,this._editIcon,this._suffixes),this._lastText=this._state.text,this._lastLength=this._state.textLength,this._render(this._state.state),applyRowTooltip(this,this._tooltipParts()),this._state.subscribe(e=>this._onStateChanged(e)))}attributeChangedCallback(e,t,n){if(this._initialized)switch(e){case`title`:this._renderTitle();break;case`text`:this._state.setText(n??``);break;case`editable`:this._state.setEditable(n!==`false`);break;case`max-length`:this._state.setMaxLength(Number.parseInt(n??``,10));break;case`show-apply-button`:this._state.setShowApplyButton(booleanAttribute$2(n,!1));break;case`activates-default`:this._state.setActivatesDefault(booleanAttribute$2(n,!1));break;case`tooltip-text`:applyRowTooltip(this,this._tooltipParts());break}}_tooltipParts(){return[this._prefixes,this._area,this._suffixes]}addSuffix(e){this._suffixes.append(e),setPartVisible(this._suffixes,!0)}addPrefix(e){this._prefixes.prepend(e),setPartVisible(this._prefixes,!0)}setShowIndicator(e){this._state.setShowIndicator(e)}setIndicatorIconName(e){this._indicator.dataset.iconName=e}setIndicatorTooltip(e){this._indicator.title=e,this._indicator.setAttribute(`aria-label`,e)}apply(){this._state.apply(),this.dispatchEvent(new CustomEvent(`apply`,{bubbles:!0}))}grabFocusWithoutSelecting(){return this._input.focus(),this._state.editing}_onConnected(){}_build(){let e=this._classPrefix;this._prefixes=document.createElement(`div`),this._prefixes.className=`${e}-prefixes`,this._suffixes=document.createElement(`div`),this._suffixes.className=`${e}-suffixes`,this._emptyTitle=document.createElement(`span`),this._emptyTitle.className=`adw-row-title ${e}-empty-title`,this._title=document.createElement(`span`),this._title.className=`adw-row-title ${e}-title`,this._input=document.createElement(`input`),this._input.className=`${e}-input`,this._input.type=`text`,this._input.addEventListener(`input`,()=>{this._state.setText(this._input.value),this._input.value!==this._state.text&&(this._input.value=this._state.text)}),this._input.addEventListener(`focus`,()=>this._state.setEditing(!0)),this._input.addEventListener(`blur`,()=>this._state.setEditing(!1)),this._input.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._activate())}),this._area=document.createElement(`div`),this._area.className=`${e}-text`,this._area.append(this._emptyTitle,this._title,this._input),this._indicator=document.createElement(`span`),this._indicator.className=`${e}-indicator`,this._indicator.setAttribute(`role`,`img`),this._indicator.textContent=`⇪`,this._applyButton=document.createElement(`button`),this._applyButton.type=`button`,this._applyButton.className=`adw-button suggested-action circular icon-only ${e}-apply`,this._applyButton.dataset.iconName=`adw-entry-apply-symbolic`,this._applyButton.title=Lt,this._applyButton.setAttribute(`aria-label`,Lt),this._applyButton.textContent=`✓`,this._applyButton.addEventListener(`click`,()=>this.apply()),this._editIcon=createGtkImage(`document-edit`,`adw-row-edit`,`${e}-edit`),this._editIcon.dataset.iconName=`adw-entry-edit-symbolic`,this._slots=bindSlottedChildren(this,[{name:`prefix`,consume:e=>this.addPrefix(e)},{name:`suffix`,claims:e=>e instanceof Element,consume:e=>this.addSuffix(e)}]),setPartVisible(this._prefixes,!1),setPartVisible(this._suffixes,!1),this.addEventListener(`click`,e=>this._maybeFocus(e))}_maybeFocus(e){let t=e.target;(t===this||t===this._area||t===this._emptyTitle||t===this._title||t===this._editIcon||t===this._indicator||t===this._prefixes||t===this._suffixes)&&this._input.focus()}_activate(){let e=this._state.activate();if(e.signal===`apply`){this.dispatchEvent(new CustomEvent(`apply`,{bubbles:!0}));return}e.activateDefault&&this.closest(`form`)?.requestSubmit(),this.dispatchEvent(new CustomEvent(`entry-activated`,{bubbles:!0}))}_renderTitle(){let e=this.getAttribute(`title`)??``;this._emptyTitle.textContent=e,this._title.textContent=e}_render(e){this._input.value!==e.text&&(this._input.value=e.text),this._input.readOnly=!e.editable,this.classList.toggle(`focused`,e.editing),this.classList.toggle(`empty`,e.empty),setPartVisible(this._emptyTitle,e.emptyTarget===0),setPartVisible(this._title,e.emptyTarget===1),setPartVisible(this._editIcon,e.editIconVisible),this._editIcon.classList.toggle(`disabled`,!e.editIconSensitive),this._editIcon.setAttribute(`aria-disabled`,String(!e.editIconSensitive)),setPartVisible(this._indicator,e.indicatorVisible),setPartVisible(this._applyButton,e.applyButtonVisible),this.setAttribute(`text-length`,String(e.textLength))}_onStateChanged(e){if(this._render(e),e.text!==this._lastText){this._lastText=e.text;let t={text:e.text};this.dispatchEvent(new CustomEvent(`changed`,{bubbles:!0,detail:t})),this.dispatchEvent(new CustomEvent(`notify::text`,{bubbles:!0,detail:t}))}e.textLength!==this._lastLength&&(this._lastLength=e.textLength,this.dispatchEvent(new CustomEvent(`notify::text-length`,{bubbles:!0,detail:{textLength:e.textLength}})))}};customElements.define(`adw-entry-row`,AdwEntryRow);var GtkSwitch=class extends WidgetElement{static signals={"notify::active":`notify::active`,"notify::state":`notify::state`};_input;_slider;_initialized=!1;static get observedAttributes(){return[`active`,`state`,`disabled`,`unfocusable`]}get unfocusable(){return this.hasAttribute(`unfocusable`)}set unfocusable(e){this.toggleAttribute(`unfocusable`,!!e)}get active(){return this.hasAttribute(`active`)}set active(e){this.toggleAttribute(`active`,!!e),this.state=this.active}get state(){return this.hasAttribute(`state`)}set state(e){this.toggleAttribute(`state`,!!e)}get disabled(){return this.hasAttribute(`disabled`)}set disabled(e){this.toggleAttribute(`disabled`,!!e)}connectedCallback(){if(this._initialized){this._render();return}this._initialized=!0,this.classList.add(`adw-switch`),this._input=document.createElement(`input`),this._input.type=`checkbox`,this._slider=document.createElement(`span`),this._slider.className=`adw-switch-slider`,this.replaceChildren(this._input,this._slider),this.active&&(this.state=!0),this._input.addEventListener(`change`,()=>{this.active=this._input.checked}),this.addEventListener(`click`,e=>{this.disabled||e.target!==this._input&&(this.active=!this.active)}),this._render()}attributeChangedCallback(e){this._initialized&&(this._render(),e===`active`?this.dispatchEvent(new CustomEvent(`notify::active`,{bubbles:!0,detail:{active:this.active}})):e===`state`&&this.dispatchEvent(new CustomEvent(`notify::state`,{bubbles:!0,detail:{state:this.state}})))}_render(){let e=this.disabled;this._input.checked=this.active,this._input.disabled=e,this.unfocusable?this._input.tabIndex=-1:this._input.removeAttribute(`tabindex`),this.classList.toggle(`checked`,this.state),this.classList.toggle(`disabled`,e)}};customElements.define(`gtk-switch`,GtkSwitch);var AdwExpanderRow=class extends TooltipElement{_headerEl;_titleEl;_subtitleEl;_enableSwitch;_chevronEl;_contentEl;_prefixEl;_suffixEl;_state=new ExpanderState;_initialized=!1;_reflectingEnable=!1;constructor(){super(),this._state.subscribe(e=>{this._reflectExpanded(e),this._initialized&&this._render()})}static get observedAttributes(){return[`title`,`subtitle`,`expanded`,`enable-expansion`,`show-enable-switch`,`tooltip-text`,`title-lines`,`subtitle-lines`]}get expanded(){return this._state.expanded}set expanded(e){this._state.setExpanded(e)}get enableExpansion(){return this._state.enableExpansion}set enableExpansion(e){this.setAttribute(`enable-expansion`,e?`true`:`false`)}get contentSection(){return this._contentEl}get suffixSection(){return this._suffixEl}get prefixSection(){return this._prefixEl}connectedCallback(){if(this._initialized)return;this._initialized=!0,this._headerEl=document.createElement(`div`),this._headerEl.className=`adw-expander-row-header`;let e=document.createElement(`div`);e.className=`adw-row-text`,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-row-title`,this._subtitleEl=document.createElement(`span`),this._subtitleEl.className=`adw-row-subtitle`,e.append(this._titleEl,this._subtitleEl),this._enableSwitch=document.createElement(`gtk-switch`),this._enableSwitch.classList.add(`adw-expander-row-enable-switch`),this._enableSwitch.active=this._state.enableExpansion,this._chevronEl=createGtkImage(`go-down`,`adw-expander-row-chevron`),this._prefixEl=document.createElement(`div`),this._prefixEl.className=`adw-expander-row-prefix`,this._suffixEl=document.createElement(`div`),this._suffixEl.className=`adw-expander-row-suffix`,this._headerEl.append(this._prefixEl,e,this._suffixEl,this._enableSwitch,this._chevronEl),this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-expander-row-content`,bindSlottedChildren(this,[{name:`prefix`,into:this._prefixEl},{name:`suffix`,into:this._suffixEl},{into:this._contentEl}]).install(this._headerEl,this._contentEl),bindEmptySections(this._prefixEl,this._suffixEl),this._headerEl.addEventListener(`click`,e=>{this._enableSwitch.contains(e.target)||this._state.toggle()&&this.dispatchEvent(new CustomEvent(`notify::expanded`,{bubbles:!0,detail:{expanded:this.expanded}}))}),attachRowActivation({row:this._headerEl,activatable:()=>!0}),this._enableSwitch.addEventListener(`notify::active`,e=>{if(e.stopPropagation(),this._reflectingEnable)return;let t=this._enableSwitch.active,n=this._state.setEnableExpansion(t);this.setAttribute(`enable-expansion`,t?`true`:`false`);for(let e of n)this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:e===`expanded`?{expanded:this.expanded}:{enableExpansion:t}}))}),this._state.setExpanded(this.hasAttribute(`expanded`)),this._reflectExpanded(this._state.expanded),this._render()}attributeChangedCallback(e){e===`enable-expansion`&&this._state.setEnableExpansion(this._enableAttribute()),this._initialized&&(e===`expanded`&&(this._state.setExpanded(this.hasAttribute(`expanded`)),this._reflectExpanded(this._state.expanded)),this._render())}_enableAttribute(){return this.getAttribute(`enable-expansion`)!==`false`}_reflectExpanded(e){this.hasAttribute(`expanded`)!==e&&(e?this.setAttribute(`expanded`,``):this.removeAttribute(`expanded`))}_render(){let e=deriveRowLabels({title:this.getAttribute(`title`),subtitle:this.getAttribute(`subtitle`)});this._titleEl.textContent=e.title,this._titleEl.hidden=!e.titleVisible,this._subtitleEl.textContent=e.subtitle,this._subtitleEl.hidden=!e.subtitleVisible;let t=this.hasAttribute(`show-enable-switch`);this._enableSwitch.hidden=!t,this._reflectingEnable=!0,this._enableSwitch.active=this._state.enableExpansion,this._reflectingEnable=!1,this.classList.toggle(`expanded`,this.expanded),this._headerEl.setAttribute(`aria-expanded`,String(this.expanded)),this._contentEl.classList.toggle(`expanded`,this.expanded),applyRowTooltip(this,[this._headerEl]),this._applyLineClamping()}_applyLineClamping(){applyRowLineClamp({titleEl:this._titleEl,subtitleEl:this._subtitleEl,textContainerEl:this._titleEl.parentElement,getTitleLines:()=>parseRowLinesAttribute(this.getAttribute(`title-lines`)),getSubtitleLines:()=>parseRowLinesAttribute(this.getAttribute(`subtitle-lines`))})}};customElements.define(`adw-expander-row`,AdwExpanderRow);var AdwWindowTitle=class extends WidgetElement{_titleEl;_subtitleEl;_state=new WindowTitleState;_initialized=!1;static get observedAttributes(){return[`title`,`subtitle`]}connectedCallback(){this._initialized||(this._initialized=!0,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-window-title-title`,this._subtitleEl=document.createElement(`span`),this._subtitleEl.className=`adw-window-title-subtitle`,this.replaceChildren(this._titleEl,this._subtitleEl),this._state.setTitle(this.getAttribute(`title`)),this._state.setSubtitle(this.getAttribute(`subtitle`)),this._render())}attributeChangedCallback(e,t,n){this._initialized&&(e===`title`?this._state.setTitle(n):this._state.setSubtitle(n))&&(this._render(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:e===`title`?this._state.title:this._state.subtitle}})))}_render(){let{title:e,titleVisible:t,subtitle:n,subtitleVisible:r}=this._state.state;this._titleEl.textContent=e,this._titleEl.hidden=!t,this._subtitleEl.textContent=n,this._subtitleEl.hidden=!r}};customElements.define(`adw-window-title`,AdwWindowTitle);var AdwHeaderBar=class extends WidgetElement{_initialized=!1;_startEl=null;_centerEl=null;_endEl=null;_titleEl=null;_page=null;_window=null;_pageObserver=null;static get observedAttributes(){return[`title`,`subtitle`]}get startSection(){return this._startEl}get centerSection(){return this._centerEl}get endSection(){return this._endEl}connectedCallback(){if(this._initialized){this._followPage(),this._renderTitle();return}this._initialized=!0,this._startEl=document.createElement(`div`),this._startEl.className=`adw-header-bar-start`,this._centerEl=document.createElement(`div`),this._centerEl.className=`adw-header-bar-center`,this._endEl=document.createElement(`div`),this._endEl.className=`adw-header-bar-end`,bindSlottedChildren(this,[{name:`start`,into:this._startEl},{name:`center`,into:this._centerEl},{name:`title-widget`,into:this._centerEl},{name:`end`,into:this._endEl},{into:this._startEl}],(e,t)=>{`into`in t&&t.into===this._centerEl&&this._dropDerivedTitle()}).install(this._startEl,this._centerEl,this._endEl),this._centerEl.childElementCount===0&&(this._titleEl=document.createElement(`adw-window-title`),this._titleEl.className=`adw-header-bar-title`,this._centerEl.appendChild(this._titleEl)),this._followPage(),this._renderTitle()}disconnectedCallback(){this._pageObserver?.disconnect(),this._pageObserver=null,this._page=null,this._window=null}_followPage(){this._page=this.closest(`adw-navigation-page`),this._window=this.closest(`adw-window, adw-application-window`),this._pageObserver??=new MutationObserver(()=>this._renderTitle());for(let e of[this._page,this._window])e!==null&&this._pageObserver.observe(e,{attributes:!0,attributeFilter:[`title`]})}attributeChangedCallback(){this._initialized&&this._renderTitle()}_dropDerivedTitle(){this._titleEl?.remove(),this._titleEl=null}_renderTitle(){if(this._titleEl)for(let e of[`title`,`subtitle`]){let t=this.getAttribute(e)??(e===`title`?this._page?.getAttribute(`title`)??this._window?.getAttribute(`title`)??null:null);t===null?this._titleEl.removeAttribute(e):this._titleEl.setAttribute(e,t)}}};customElements.define(`adw-header-bar`,AdwHeaderBar);const ei={schedule(e,t){return setTimeout(e,t)},cancel(e){clearTimeout(e)}};function createSwitcherIcon(e,t){return createGtkImage(viewSwitcherIconName(e),t)}function applySwitcherIcon(e,t){e.iconName=viewSwitcherIconName(t)}function readSwitcherPage(e){let t=Number.parseInt(e.getAttribute(`badge-number`)??``,10);return{name:e.getAttribute(`name`)??``,title:e.getAttribute(`title`),iconName:e.getAttribute(`icon-name`),visible:!e.hasAttribute(`hidden`),useUnderline:e.hasAttribute(`use-underline`),badgeNumber:Number.isNaN(t)?0:t,needsAttention:e.hasAttribute(`needs-attention`)}}function applyIndicator(e,t,n){e.textContent=t,e.classList.toggle(`needs-attention`,n&&t.length===0),e.hidden=t.length===0&&!n}function applyDescription(e,t){t?e.setAttribute(`aria-description`,t):e.removeAttribute(`aria-description`)}const ti={horizontal:{previous:`ArrowLeft`,next:`ArrowRight`},vertical:{previous:`ArrowUp`,next:`ArrowDown`}},adjacentStep=(e,t,n)=>{let r=t+n;return r<0||r>=e.length?null:r};function attachRovingFocus(e){let keysOf=e=>ti[typeof e==`function`?e():e];e.host.addEventListener(`keydown`,t=>{let{previous:n,next:r}=keysOf(e.orientation),i=e.crossAxis===void 0?null:keysOf(e.crossAxis.orientation);if(t.altKey||t.ctrlKey||t.metaKey)return;let a=e.items(),o=a.findIndex(e=>e===t.target||e.contains(t.target));if(o<0)return;let s=e.step??adjacentStep,c;if(t.key===n)c=s(a,o,-1);else if(t.key===r)c=s(a,o,1);else if(i!==null&&t.key===i.previous)c=e.crossAxis.step(a,o,-1);else if(i!==null&&t.key===i.next)c=e.crossAxis.step(a,o,1);else if(t.key===`Home`)c=0;else if(t.key===`End`)c=a.length-1;else return;t.preventDefault();let l=c===null?void 0:a[c];l===void 0||l===a[o]||(e.select(l),l.focus())})}var AdwViewStackPage=class extends WidgetElement{static get observedAttributes(){return[`name`,`title`,`icon-name`,`badge-number`,`needs-attention`,`use-underline`]}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}])}},AdwInlineViewSwitcher=class extends WidgetElement{scheduler=ei;_stateInstance=null;get _state(){return this._stateInstance||(this._stateInstance=new ViewSwitcherState({scheduler:this.scheduler}),this._stateInstance.subscribe(e=>this._onStateChange(e))),this._stateInstance}_groupEl;_pagesEl;_panels=[];_toggles=[];_displayMode=`labels`;_initialized=!1;_declared=[];_pageObserver;static get observedAttributes(){return[`active`,`display-mode`,`flat`,`round`,`osd`]}constructor(){super()}get active(){return this._state.selected}set active(e){this._state.setSelected(e),this._reflectActive()}get activeToggle(){return toggleIndexForPage(this._state.pages,this._state.selected)}get displayMode(){return this._displayMode}set displayMode(e){this.setAttribute(`display-mode`,e)}get visibleChildName(){return this._state.selectedName}set visibleChildName(e){this._state.selectName(e)}get pages(){return this._state.pages}setPageVisible(e,t){let n=this._state.setPageVisible(e,t);return this._rebuildToggles(),n}connectedCallback(){if(this._initialized){this._watchPages();return}let e=Array.from(this.querySelectorAll(`:scope > adw-view-stack-page`)),t=this.getAttribute(`active`);if(this._groupEl=document.createElement(`div`),this._groupEl.className=`adw-inline-view-switcher-group`,this._groupEl.setAttribute(`role`,`tablist`),attachRovingFocus({host:this,orientation:`horizontal`,items:()=>this._toggles,select:e=>{this._state.setSelected(Number(e.dataset.pageIndex))}}),this._pagesEl=document.createElement(`div`),this._pagesEl.className=`adw-inline-view-switcher-pages`,this._panels=e.map(e=>{let t=document.createElement(`div`);t.className=`adw-inline-view-switcher-page`,t.setAttribute(`role`,`tabpanel`),t.dataset.name=e.getAttribute(`name`)??``;for(let n of Array.from(e.childNodes))t.appendChild(n);return this._pagesEl.appendChild(t),t}),this.replaceChildren(this._groupEl,this._pagesEl),this._displayMode=this._readDisplayModeAttr(),this._initialized=!0,this._declared=e,this._watchPages(),this._state.setPages(e.map(e=>readSwitcherPage(e))),t!==null){let e=Number.parseInt(t,10);Number.isNaN(e)||this._state.setSelected(e,!1)}this._rebuildToggles()}disconnectedCallback(){this._state.cancelDrag(),this._pageObserver?.disconnect(),this._pageObserver=void 0}refreshPages(){this._initialized&&(this._state.setPages(this._declared.map(e=>readSwitcherPage(e))),this._rebuildToggles())}_watchPages(){this._pageObserver?.disconnect(),this._pageObserver=new MutationObserver(()=>this.refreshPages());for(let e of this._declared)this._pageObserver.observe(e,{attributes:!0})}attributeChangedCallback(e){if(this._initialized){if(e===`active`){let e=this.getAttribute(`active`),t=e===null?NaN:Number.parseInt(e,10);Number.isNaN(t)||this._state.setSelected(t),this._reflectActive();return}if(e===`display-mode`){let e=this._readDisplayModeAttr();if(e===this._displayMode)return;this._displayMode=e,this._rebuildToggles(),this.dispatchEvent(new CustomEvent(`notify::display-mode`,{bubbles:!0,detail:{displayMode:e}}));return}this._applyStyleClasses()}}_readDisplayModeAttr(){let e=this.getAttribute(`display-mode`);return e===null?`labels`:isInlineViewSwitcherDisplayMode(e)?e:this._displayMode}_rebuildToggles(){if(!this._initialized)return;let e=buildInlineToggles(this._state.pages,this._displayMode);this._groupEl.replaceChildren(),this._toggles=e.map(e=>{let t=document.createElement(`button`);if(t.type=`button`,t.className=`adw-inline-view-switcher-toggle`,t.setAttribute(`role`,`tab`),t.dataset.pageIndex=String(e.pageIndex),t.dataset.toggleIndex=String(e.toggleIndex),e.showIcon&&t.appendChild(createSwitcherIcon(e.iconName,`adw-inline-view-switcher-icon`)),e.showLabel){let n=document.createElement(`span`);n.className=`adw-inline-view-switcher-label`,n.textContent=e.label,t.appendChild(n)}let n=document.createElement(`span`);return n.className=`adw-inline-view-switcher-indicator`,n.setAttribute(`aria-hidden`,`true`),applyIndicator(n,e.badgeLabel,e.needsAttention),t.appendChild(n),e.tooltip&&(t.title=e.tooltip),e.showLabel||t.setAttribute(`aria-label`,e.tooltip||e.iconName),applyDescription(t,e.description),t.addEventListener(`click`,()=>{this._state.setSelected(e.pageIndex)}),t.addEventListener(`dragenter`,n=>{t.contains(n.relatedTarget)||this._state.dragEnter(e.pageIndex)}),t.addEventListener(`dragleave`,n=>{t.contains(n.relatedTarget)||this._state.dragLeave(e.pageIndex)}),this._groupEl.appendChild(t),t}),this._render()}_onStateChange(e){this._render(),this.dispatchEvent(new CustomEvent(`notify::active`,{bubbles:!0,detail:{active:e.selected,name:e.name,toggleIndex:this.activeToggle,interactive:e.interactive}}))}_render(){if(!this._initialized)return;this._applyStyleClasses();let e=this.activeToggle;this._toggles.forEach((t,n)=>{let r=n===e&&e!==-1;t.classList.toggle(`active`,r),t.setAttribute(`aria-selected`,String(r)),t.tabIndex=r?0:-1});let t=this._state.selected;this._panels.forEach((e,n)=>{let r=n===t;e.classList.toggle(`active-view`,r),e.hidden=!r}),this._reflectActive()}_applyStyleClasses(){for(let e of[`flat`,`round`,`osd`]){let t=this.hasAttribute(e);this.classList.toggle(e,t),this._groupEl?.classList.toggle(e,t)}for(let e of Jn)this._groupEl.classList.toggle(e,e===this._displayMode)}_reflectActive(){let e=String(this._state.selected);this.getAttribute(`active`)!==e&&this.setAttribute(`active`,e)}};customElements.define(`adw-view-stack-page`,AdwViewStackPage),customElements.define(`adw-inline-view-switcher`,AdwInlineViewSwitcher);var AdwMultiLayoutView=class extends WidgetElement{_layouts=[];_children=new Map;_slots=new Map;_current=null;_acceptingSlots=!1;_observer=null;static get observedAttributes(){return[`layout-name`]}get layoutName(){return this._current?.name??null}set layoutName(e){e!==null&&this.setAttribute(`layout-name`,e)}get layout(){return this._current?.content??null}connectedCallback(){this.setAttribute(`role`,`group`),this.style.display=`block`,this._observer?.disconnect(),this._observer=new MutationObserver(()=>this._rebuild()),this._observer.observe(this,{childList:!0}),this._rebuild()}disconnectedCallback(){this._observer?.disconnect(),this._observer=null}attributeChangedCallback(e){!this.isConnected||e!==`layout-name`||this._setLayoutByName(this.getAttribute(`layout-name`))}getChild(e){return this._children.get(e)??null}getLayoutByName(e){return this._layouts.find(t=>t.name===e)?.content??null}registerSlot(e,t){if(this._acceptingSlots&&this._slots.get(e)!==t){if(this._slots.has(e)){console.warn(`Duplicate slot ID in AdwLayout ${this.layoutName}: ${e}`);return}this._slots.set(e,t)}}_rebuild(){if(this.isConnected){this._observer?.disconnect();try{this._readAuthoredTree()}finally{this.isConnected&&this._observer?.observe(this,{childList:!0})}}}_readAuthoredTree(){let e=[];for(let t of Array.from(this.children)){let n=t.getAttribute(`name`);if(n!==null){e.push({name:n,content:t});continue}let r=t.getAttribute(`slot`);r===null||r===``||(this._children.has(r)&&console.warn(`While adding child: duplicate slot ${r} in AdwMultiLayoutView; kept the first`),this._children.set(r,t))}this._layouts=e;let t=this.getAttribute(`layout-name`);t===null?this._setLayout(e[0]??null):this._setLayoutByName(t)}_setLayout(e){if(e===this._current){e!==null&&this._mount(e);return}this._current=e,e===null?this._destroy():this._mount(e),this.dispatchEvent(new CustomEvent(`notify::layout`,{bubbles:!0,detail:{layout:this.layoutName}})),this.dispatchEvent(new CustomEvent(`notify::layout-name`,{bubbles:!0,detail:{layoutName:this.layoutName}}))}_setLayoutByName(e){if(e===null)return;let t=this._layouts.find(t=>t.name===e);if(t===void 0){console.error(`Layout name '${e}' not found in AdwMultiLayoutView`);return}this._setLayout(t)}_destroy(){this._slots.clear(),this.replaceChildren()}_mount(e){for(this._destroy(),this._acceptingSlots=!0,this.appendChild(e.content);;){let t=this._slots.size;for(let t of e.content.querySelectorAll(`adw-layout-slot`)){let e=t.getAttribute(`id`);e!==null&&e!==``&&!this._slots.has(e)&&this.registerSlot(e,t)}for(let[e,t]of this._children)this._parent(e,t);if(this._slots.size===t)break}this._acceptingSlots=!1}_parent(e,t){let n=this._slots.get(e);n!==void 0&&t.parentElement!==n&&(this._mirrorVisible(n,t),n.appendChild(t))}_mirrorVisible(e,t){let apply=()=>{e.toggleAttribute(`hidden`,t.hidden===!0)};apply(),new MutationObserver(apply).observe(t,{attributes:!0,attributeFilter:[`hidden`]})}};customElements.define(`adw-multi-layout-view`,AdwMultiLayoutView);var AdwLayoutSlot=class extends WidgetElement{_registered=!1;static get observedAttributes(){return[`id`]}get slotId(){return this.getAttribute(`id`)}connectedCallback(){this.setAttribute(`role`,`group`),this.style.display=`contents`,this._register()}disconnectedCallback(){this._registered=!1}attributeChangedCallback(e){!this.isConnected||e!==`id`||(this._registered&&console.warn("<adw-layout-slot>: `id` is construct-only upstream; re-registering the slot."),this._register())}_register(){let e=this.slotId;if(e===null||e===``){console.error("<adw-layout-slot> created without an `id` — libadwaita refuses this with g_error.");return}let t=this.closest(`adw-multi-layout-view`);t instanceof AdwMultiLayoutView&&t.registerSlot(e,this),this._registered=!0}};customElements.define(`adw-layout-slot`,AdwLayoutSlot);function readPageProps(e){return{tag:e.tag,title:e.title,canPop:e.canPop}}var AdwNavigationPage=class extends WidgetElement{_syncing=!1;static get observedAttributes(){return[`title`,`tag`,`can-pop`,`no-back-button`]}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}])}get title(){return this.getAttribute(`title`)??``}set title(e){this.setAttribute(`title`,e)}get tag(){return this.getAttribute(`tag`)}set tag(e){e===null?this.removeAttribute(`tag`):this.setAttribute(`tag`,e)}get canPop(){return this.getAttribute(`can-pop`)!==`false`}set canPop(e){this.setAttribute(`can-pop`,e?`true`:`false`)}attributeChangedCallback(e,t){if(this._syncing)return;let n=this.closest(`adw-navigation-view`);n instanceof AdwNavigationView&&n.syncPageProperty(this,e,t)}revertAttribute(e,t){this._syncing=!0,t===null?this.removeAttribute(e):this.setAttribute(e,t),this._syncing=!1}},AdwNavigationView=class extends WidgetElement{static signals={pushed:`pushed`,popped:`popped`,replaced:`replaced`,"notify::visible-page":`notify::visible-page`};_pagesEl;_backButtons=new WeakMap;_initialized=!1;_diagnose=e=>{console.warn(`[adw-navigation-view] ${describeNavigationDiagnostic(e)}`)};_state=new NavigationViewState({onDiagnostic:this._diagnose});static get observedAttributes(){return[`animate-transitions`,`pop-on-escape`]}get animateTransitions(){return this.getAttribute(`animate-transitions`)!==`false`}set animateTransitions(e){this.setAttribute(`animate-transitions`,e?`true`:`false`)}get popOnEscape(){return this.getAttribute(`pop-on-escape`)!==`false`}set popOnEscape(e){this.setAttribute(`pop-on-escape`,e?`true`:`false`)}get visiblePage(){return this._state.visiblePage}get visiblePageTag(){return this._state.visiblePageTag}get_visible_page_tag(){return this.visiblePageTag}get depth(){return this._state.depth}get navigationStack(){return this._state.stack}get pages(){return this._state.pages}get canGoBack(){return this._state.canGoBack()}get backButtonTooltip(){return this._state.backButtonTooltip()}constructor(){super(),installElementApi(this)}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=Array.from(this.querySelectorAll(`:scope > adw-navigation-page`));this._pagesEl=document.createElement(`div`),this._pagesEl.className=`adw-navigation-view-pages`;for(let t of e)t.classList.add(`adw-navigation-page`),this._pagesEl.appendChild(t);this.replaceChildren(this._pagesEl),this._state.subscribe(e=>this._onChange(e)),this._state.setAnimateTransitions(this.animateTransitions),this._state.setPopOnEscape(this.popOnEscape),this.addEventListener(`keydown`,this._onKeyDown);for(let t of e)this._state.add(t,readPageProps(t));for(let t of e)this._state.isRegistered(t)||this._detach(t);this._syncClasses(),this._render()}attributeChangedCallback(e){if(this._initialized){if(e===`pop-on-escape`){this._state.setPopOnEscape(this.popOnEscape);return}this._state.setAnimateTransitions(this.animateTransitions),this._syncClasses()}}syncPageProperty(e,t,n){this._state.isRegistered(e)&&(t===`tag`?(this._state.setTag(e,e.tag),this._state.tagOf(e)!==e.tag&&e.revertAttribute(`tag`,n)):t===`title`?this._state.setTitle(e,e.title):t===`can-pop`&&this._state.setCanPop(e,e.canPop),this._render())}addPage(e){let t=this._state.add(e,readPageProps(e));return this._render(),t}removePage(e){let t=this._state.remove(e);return t&&!this._state.isRegistered(e)&&this._detach(e),this._render(),t}push(e){if(typeof e==`string`)return this.pushByTag(e);let t=this._state.push(e,readPageProps(e));return this._render(),t}push_by_tag(e){return this.pushByTag(e)}pushByTag(e){let t=this._state.pushByTag(e);return this._render(),t}pop(){let e=this._state.pop();return this._render(),e}popToPage(e){let t=this._state.popToPage(e);return this._render(),t}popToTag(e){let t=this._state.popToTag(e);return this._render(),t}replace(e){let t=e.map(e=>{if(typeof e!=`string`)return e??null;let t=this._state.findPage(e);return t===null&&this._diagnose({code:`tag-not-found`,tag:e}),t});this._state.replace(t,readPageProps),this._render()}replaceWithTags(e){this._state.replaceWithTags(e),this._render()}findPage(e){return this._state.findPage(e)}getPreviousPage(e){return this._state.getPreviousPage(e)}_onChange(e){for(let t of e.removed)this._detach(t);for(let e of this._state.finishTransition())this._detach(e);if(this._render(),e.reason===`add`||e.reason===`push`)this._dispatch(`pushed`,e.visiblePage);else if(e.reason===`pop`)for(let t of e.popped)this._dispatch(`popped`,t);else this._dispatch(`replaced`,null);e.previousVisiblePage!==e.visiblePage&&this._dispatch(`notify::visible-page`,e.visiblePage)}_dispatch(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:{page:t,tag:t?.tag??null}}))}_onKeyDown=e=>{if(e.defaultPrevented)return;let t;if(e.key===`Escape`)t=this._state.popFromEscape();else if(e.altKey&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)){let n=getComputedStyle(this).direction===`rtl`?`ArrowRight`:`ArrowLeft`;if(e.key!==n)return;t=this._state.popFromShortcut()}else return;t===`stop`&&(e.preventDefault(),e.stopPropagation())};_syncClasses(){this.classList.toggle(`animated`,this.animateTransitions)}_render(){let e=this._state.visiblePage;for(let t of this._state.pages){this._attach(t);let n=t===e;t.classList.toggle(`visible-page`,n),t.hidden=!n,n||this._removeBackButton(t)}e&&this._syncBackButton(e)}_attach(e){e.parentNode!==this._pagesEl&&(e.classList.add(`adw-navigation-page`),this._pagesEl.appendChild(e))}_detach(e){this._removeBackButton(e),e.classList.remove(`visible-page`),e.parentNode===this._pagesEl&&this._pagesEl.removeChild(e)}_syncBackButton(e){if(!this._state.canGoBack()||e.hasAttribute(`no-back-button`)){this._removeBackButton(e);return}let t=this._state.backButtonTooltip()??wn,n=this._backButtons.get(e);if(n){n.setAttribute(`tooltip`,t);return}let r=e.querySelector(`adw-header-bar`);if(!r)return;let i=r.startSection??null;if(!i)return;let a=document.createElement(`gtk-button`);a.classList.add(`adw-navigation-back-button`),a.setAttribute(`icon`,`go-previous`),a.setAttribute(`flat`,``),a.setAttribute(`tooltip`,t),a.addEventListener(`click`,()=>this.pop()),i.insertBefore(a,i.firstChild),this._backButtons.set(e,a)}_removeBackButton(e){let t=this._backButtons.get(e);t&&(t.parentNode&&t.parentNode.removeChild(t),this._backButtons.delete(e))}};customElements.define(`adw-navigation-view`,AdwNavigationView),customElements.define(`adw-navigation-page`,AdwNavigationPage);var AdwNavigationSplitView=class extends WidgetElement{_sidebarEl;_contentEl;_initialized=!1;_disposeBreakpoint;_breakpointApplied=!1;_state=new NavigationSplitViewState;_reflecting=!1;static get observedAttributes(){return[`collapsed`,`show-content`,`sidebar-position`,`min-sidebar-width`,`max-sidebar-width`,`breakpoint`]}get collapsed(){return this._initialized?this._state.collapsed:this.hasAttribute(`collapsed`)}set collapsed(e){this.toggleAttribute(`collapsed`,e)}get showContent(){return this._initialized?this._state.showContent:this.hasAttribute(`show-content`)}set showContent(e){this.toggleAttribute(`show-content`,e)}get sidebarPosition(){return this.getAttribute(`sidebar-position`)===`end`?`end`:`start`}set sidebarPosition(e){this.setAttribute(`sidebar-position`,e)}get sidebarTag(){return this._state.sidebarTag}get contentTag(){return this._state.contentTag}push(e){return this._state.push(e)}pop(){return this._state.pop()}connectedCallback(){this._buildOnce(),this._reflectShowContent(),this._syncWidth(),this._syncClasses(),this._syncBreakpoint()}_buildOnce(){this._initialized||(this._initialized=!0,this._sidebarEl=document.createElement(`div`),this._sidebarEl.className=`adw-nsv-sidebar`,this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-nsv-content`,bindSlottedChildren(this,[{name:`sidebar`,into:this._sidebarEl},{name:`content`,into:this._contentEl}],(e,t)=>this._mountPane(t.name===`sidebar`?`sidebar`:`content`)).install(this._sidebarEl,this._contentEl),this._state=new NavigationSplitViewState({sidebarPosition:this.sidebarPosition,collapsed:this.hasAttribute(`collapsed`),showContent:this.hasAttribute(`show-content`),onCritical:e=>console.error(e),onDelegate:(e,t)=>{let n={tag:t,handled:!1};return this.dispatchEvent(new CustomEvent(`navigation-${e}`,{bubbles:!0,detail:n})),n.handled}}),this._mountPane(`sidebar`),this._mountPane(`content`),this._state.subscribe(()=>{this._reflectShowContent(),this._syncClasses()}))}_mountPane(e){let t=e===`sidebar`?this._sidebarEl:this._contentEl,n=Array.from(t.children),r=n.length>0?{tag:this._tagOf(n)}:null;e===`sidebar`?this._state.setSidebar(r):this._state.setContent(r)}_tagOf(e){for(let t of e){let e=t.getAttribute(`tag`);if(e!==null)return e}return null}_reflectShowContent(){if(this._reflecting)return;let e=this._state.showContent;if(this.hasAttribute(`show-content`)!==e){this._reflecting=!0;try{this.toggleAttribute(`show-content`,e)}finally{this._reflecting=!1}}}disconnectedCallback(){this._disposeBreakpoint?.(),this._disposeBreakpoint=void 0}attributeChangedCallback(e){if(this._initialized){if(e===`breakpoint`){this._syncBreakpoint();return}if(e===`min-sidebar-width`||e===`max-sidebar-width`){this._syncWidth();return}e===`collapsed`&&this._state.setCollapsed(this.hasAttribute(`collapsed`)),e===`show-content`&&this._state.setShowContent(this.hasAttribute(`show-content`)),e===`sidebar-position`&&this._state.setSidebarPosition(this.sidebarPosition),this._syncClasses(),this._syncWidth()}}_syncWidth(){if(this.collapsed){this._sidebarEl.style.minWidth=``,this._sidebarEl.style.maxWidth=``;return}let e=resolveSidebarBounds({minSidebarWidth:this._widthAttr(`min-sidebar-width`,180),maxSidebarWidth:this._widthAttr(`max-sidebar-width`,280)},0,{ceil:!0});this._sidebarEl.style.minWidth=`${e.min}px`,this._sidebarEl.style.maxWidth=`${e.max}px`}_widthAttr(e,t){let n=this.getAttribute(e);if(n===null)return t;let r=parseFloat(n);return Number.isFinite(r)?r:t}get _direction(){return getComputedStyle(this).direction===`rtl`?`rtl`:`ltr`}_syncClasses(){let e=this._state;this.classList.toggle(`collapsed`,e.collapsed),this.classList.toggle(`show-content`,e.showContent),this.classList.toggle(`sidebar-end`,e.sidebarPosition===`end`),this.classList.toggle(`sidebar-at-visual-start`,isSidebarAtVisualStart(e.sidebarPosition,this._direction)),this._sidebarEl?.classList.toggle(`sidebar-pane`,!e.collapsed),this._contentEl?.classList.toggle(`content-pane`,!e.collapsed);let{stack:t}=e.stack,n=t[t.length-1]??null;this._sidebarEl&&(this._sidebarEl.dataset.paneVisible=String(!e.collapsed||n===`sidebar`)),this._contentEl&&(this._contentEl.dataset.paneVisible=String(!e.collapsed||n===`content`))}_syncBreakpoint(){this._disposeBreakpoint?.(),this._disposeBreakpoint=bindBreakpointSetter(this,this.getAttribute(`breakpoint`),e=>{this._breakpointApplied=e,this.collapsed=e},this._breakpointApplied)}};customElements.define(`adw-navigation-split-view`,AdwNavigationSplitView);const ni={animate(e){let t=0,n=!1,r=performance.now(),step=i=>{if(n)return;let a=Math.min((i-r)/250,1),o=1-(1-a)*(1-a);if(e.onValue(e.from+(e.to-e.from)*o),a<1){t=requestAnimationFrame(step);return}e.onValue(e.to),e.onDone()};return t=requestAnimationFrame(step),{cancel(){n=!0,t&&cancelAnimationFrame(t)}}}};function readTriStateAttr(e,t,n){let r=e.getAttribute(t);return r===null?n:r!==`false`&&r!==`0`}var AdwOverlaySplitView=class extends WidgetElement{static signals={"notify::show-sidebar":`notify::show-sidebar`};_initialized=!1;_sidebarEl;_contentEl;_backdropEl;_disposeBreakpoint;_breakpointApplied=!1;_state=new OverlaySplitViewState;_notifiedShowSidebar=null;_reflecting=!1;_measuredWidth=0;_resizeObserver;_swipePointer=null;_swipeOrigin={x:0,progress:0};static get observedAttributes(){return[`show-sidebar`,`collapsed`,`pin-sidebar`,`sidebar-position`,`min-sidebar-width`,`max-sidebar-width`,`sidebar-width-fraction`,`enable-show-gesture`,`enable-hide-gesture`,`breakpoint`]}get showSidebar(){return this._state.showSidebar}set showSidebar(e){this.setAttribute(`show-sidebar`,e?``:`false`)}get show_sidebar(){return this.showSidebar}set show_sidebar(e){this.showSidebar=e}get_show_sidebar(){return this.showSidebar}set_show_sidebar(e){this.showSidebar=e}get collapsed(){return this._state.collapsed}set collapsed(e){e?this.setAttribute(`collapsed`,``):this.removeAttribute(`collapsed`)}get minSidebarWidth(){return parseFloat(this.getAttribute(`min-sidebar-width`)||`180`)}get maxSidebarWidth(){return parseFloat(this.getAttribute(`max-sidebar-width`)||`280`)}get sidebarWidthFraction(){return parseFloat(this.getAttribute(`sidebar-width-fraction`)||`0.25`)}connectedCallback(){this._buildOnce(),this._bindToDocument(),this._reflectShowSidebar(),this._syncClasses(),this._syncSidebarWidth(),this._syncBreakpoint()}_buildOnce(){this._initialized||(this._initialized=!0,this._sidebarEl=document.createElement(`div`),this._sidebarEl.className=`adw-osv-sidebar`,this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-osv-content`,this._backdropEl=document.createElement(`div`),this._backdropEl.className=`adw-osv-backdrop`,this._backdropEl.addEventListener(`click`,()=>this.hideSidebar()),bindSlottedChildren(this,[{name:`sidebar`,into:this._sidebarEl},{name:`content`,into:this._contentEl},{into:this._contentEl}]).install(this._sidebarEl,this._contentEl,this._backdropEl),this._state=new OverlaySplitViewState({collapsed:this.hasAttribute(`collapsed`),showSidebar:readTriStateAttr(this,`show-sidebar`,!0),pinSidebar:this.hasAttribute(`pin-sidebar`),sidebarPosition:this.getAttribute(`sidebar-position`)===`end`?`end`:`start`,enableShowGesture:readTriStateAttr(this,`enable-show-gesture`,!0),enableHideGesture:readTriStateAttr(this,`enable-hide-gesture`,!0),animator:ni}),this._state.subscribe(()=>{this._reflectShowSidebar(),this._syncClasses()}),this.addEventListener(`keydown`,this._onKeyDown),this._bindSwipe())}_bindToDocument(){this._resizeObserver?.disconnect(),this._resizeObserver=new ResizeObserver(e=>{let t=e[e.length-1];if(!t)return;let n=t.borderBoxSize?.[0];this._measuredWidth=n?n.inlineSize:t.contentRect.width,this._syncSidebarWidth(),this._syncClasses()}),this._resizeObserver.observe(this),this._measuredWidth=this.offsetWidth}disconnectedCallback(){this._disposeBreakpoint?.(),this._disposeBreakpoint=void 0,this._resizeObserver?.disconnect(),this._resizeObserver=void 0}_onKeyDown=e=>{e.key!==`Escape`||e.defaultPrevented||this._state.escape()&&e.preventDefault()};attributeChangedCallback(e,t,n){if(this._initialized){if(e===`breakpoint`){this._syncBreakpoint();return}this._readAttribute(e),(e===`min-sidebar-width`||e===`max-sidebar-width`||e===`sidebar-width-fraction`||e===`collapsed`)&&this._syncSidebarWidth(),this._syncClasses()}}_readAttribute(e){let t=this._state;if(e===`pin-sidebar`&&t.setPinSidebar(this.hasAttribute(`pin-sidebar`)),e===`sidebar-position`){let e=this.getAttribute(`sidebar-position`);t.setSidebarPosition(e===`end`?`end`:`start`)}e===`show-sidebar`&&t.setShowSidebar(readTriStateAttr(this,`show-sidebar`,!0)),e===`enable-show-gesture`&&t.setEnableShowGesture(readTriStateAttr(this,`enable-show-gesture`,!0)),e===`enable-hide-gesture`&&t.setEnableHideGesture(readTriStateAttr(this,`enable-hide-gesture`,!0)),e===`collapsed`&&t.setCollapsed(this.hasAttribute(`collapsed`)),this._reflectShowSidebar()}_reflectShowSidebar(){if(this._reflecting)return;let e=this._state.showSidebar?``:`false`;if(this.getAttribute(`show-sidebar`)!==e){this._reflecting=!0;try{this.setAttribute(`show-sidebar`,e)}finally{this._reflecting=!1}}this._notifyShowSidebar()}_notifyShowSidebar(){let e=this._state.showSidebar,t=this._notifiedShowSidebar;this._notifiedShowSidebar=e,!(t===null||t===e)&&this.dispatchEvent(new CustomEvent(`notify::show-sidebar`,{bubbles:!0,detail:{showSidebar:e}}))}_syncBreakpoint(){this._disposeBreakpoint?.(),this._disposeBreakpoint=bindBreakpointSetter(this,this.getAttribute(`breakpoint`),e=>{this._breakpointApplied=e,this.collapsed=e},this._breakpointApplied)}openSidebar(){this.showSidebar=!0,this.dispatchEvent(new CustomEvent(`sidebar-toggled`,{detail:{isVisible:!0}}))}hideSidebar(){this.showSidebar=!1,this.dispatchEvent(new CustomEvent(`sidebar-toggled`,{detail:{isVisible:!1}}))}toggleSidebar(){this.showSidebar=!this.showSidebar,this.dispatchEvent(new CustomEvent(`sidebar-toggled`,{detail:{isVisible:this.showSidebar}}))}get _direction(){return getComputedStyle(this).direction===`rtl`?`rtl`:`ltr`}get _widthSpec(){return{minSidebarWidth:this.minSidebarWidth,maxSidebarWidth:this.maxSidebarWidth,sidebarWidthFraction:this.sidebarWidthFraction}}get _sidebarWidth(){return resolveOverlaySidebarWidth({...this._widthSpec,totalWidth:this._measuredWidth,collapsed:this._state.collapsed})}_syncClasses(){let e=this._state;this.classList.toggle(`collapsed`,e.collapsed),this.classList.toggle(`show-sidebar`,e.showSidebar);let t=isSidebarAtVisualStart(e.sidebarPosition,this._direction);this.classList.toggle(`sidebar-start`,e.sidebarPosition===`start`),this.classList.toggle(`sidebar-end`,e.sidebarPosition===`end`),this.classList.toggle(`sidebar-at-visual-start`,t),this._sidebarEl?.classList.toggle(`sidebar-pane`,!e.collapsed),this._sidebarEl?.classList.toggle(`overlay-pane`,e.collapsed),this._contentEl?.classList.toggle(`content-pane`,!e.collapsed),this._backdropEl&&(this._backdropEl.hidden=!e.shieldVisible),this._sidebarEl?.setAttribute(`aria-hidden`,String(!e.sidebarFocusable)),this._contentEl?.setAttribute(`aria-hidden`,String(!e.contentFocusable)),this._syncGeometry()}_syncGeometry(){let e=this._sidebarEl;if(!e)return;if(this._measuredWidth<=0){for(let t of[`left`,`marginLeft`,`marginRight`,`width`,`minWidth`,`maxWidth`,`opacity`,`pointerEvents`])e.style[t]=``;this._backdropEl&&(this._backdropEl.style.opacity=``);return}let t=this._state,n=this._sidebarWidth,r=layoutOverlaySplitView({totalWidth:this._measuredWidth,sidebarWidth:n,showProgress:t.showProgress,collapsed:t.collapsed,sidebarPosition:t.sidebarPosition,direction:this._direction}),i=isSidebarAtVisualStart(t.sidebarPosition,this._direction);if(e.style.width=`${r.sidebar.width}px`,t.collapsed)e.style.marginLeft=``,e.style.marginRight=``,e.style.insetInlineStart=``,e.style.left=`${r.sidebar.x}px`;else{e.style.left=``;let r=n-Math.trunc(n*Math.min(t.showProgress,1));e.style.marginLeft=i?`${-r}px`:``,e.style.marginRight=i?``:`${-r}px`}e.style.opacity=t.showProgress<=0?`0`:`1`,e.style.pointerEvents=t.sidebarPainted?``:`none`,this._backdropEl&&(this._backdropEl.style.opacity=String(1-r.shadowProgress))}_syncSidebarWidth(){if(!this._sidebarEl)return;let e=resolveSidebarBounds(this._widthSpec,0,{ceil:!0});this._sidebarEl.style.minWidth=`${e.min}px`,this._sidebarEl.style.maxWidth=`${e.max}px`,this._syncGeometry()}_bindSwipe(){this.addEventListener(`pointerdown`,e=>{if(this._swipePointer!==null||e.button!==0)return;let t=this._state,n=this.getBoundingClientRect(),r=resolveSwipeArea({isDrag:!0,sidebarWidth:this._sidebarWidth,showProgress:t.showProgress,totalWidth:n.width,totalHeight:n.height,sidebarPosition:t.sidebarPosition,direction:this._direction}),i=e.clientX-n.left,a=e.clientY-n.top;i<r.x||i>r.x+r.width||a<r.y||a>r.y+r.height||(this._swipePointer=e.pointerId,this._swipeOrigin={x:e.clientX,progress:t.showProgress})}),this.addEventListener(`pointermove`,e=>{if(e.pointerId!==this._swipePointer)return;let t=this._state,n=this._sidebarWidth||1,r=isSidebarAtVisualStart(t.sidebarPosition,this._direction),i=(e.clientX-this._swipeOrigin.x)/n*(r?1:-1);if(!t.swipeActive){if(!resolveSwipeStart({showProgress:t.showProgress,collapsed:t.collapsed,direction:i>=0?`forward`:`back`,enableShowGesture:t.enableShowGesture,enableHideGesture:t.enableHideGesture})){this._swipePointer=null;return}t.beginSwipe();try{this.setPointerCapture(e.pointerId)}catch{}}t.setShowProgress(this._swipeOrigin.progress+i)});let release=(e,t)=>{if(e.pointerId!==this._swipePointer)return;this._swipePointer=null;let n=this._state;if(!n.swipeActive)return;this.hasPointerCapture(e.pointerId)&&this.releasePointerCapture(e.pointerId);let r=resolveSwipeSnapPoints({showProgress:n.showProgress,enableShowGesture:n.enableShowGesture,enableHideGesture:n.enableHideGesture,swipeActive:!0}),i=t?swipeCancelProgress(n.showProgress):r.reduce((e,t)=>Math.abs(t-n.showProgress)<Math.abs(e-n.showProgress)?t:e);n.endSwipe(i)};this.addEventListener(`pointerup`,e=>release(e,!1)),this.addEventListener(`pointercancel`,e=>release(e,!0))}};customElements.define(`adw-overlay-split-view`,AdwOverlaySplitView);var AdwPasswordEntryRow=class extends AdwEntryRow{_password=new PasswordEntryRowState(this._state);_toggle;_toggleIcon;static get observedAttributes(){return[...AdwEntryRow.observedAttributes,`revealed`]}get _classPrefix(){return`adw-password-entry-row`}get revealed(){return this._password.revealed}set revealed(e){this._password.setRevealed(e)}get capsLockOn(){return this._password.capsLockOn}setCapsLockOn(e){this._password.setCapsLockOn(e)}_onConnected(){this._input.type=`password`,this._input.autocomplete=`off`,this._toggle=document.createElement(`button`),this._toggle.type=`button`,this._toggle.className=`adw-button flat circular icon-only ${this._classPrefix}-toggle`,this._toggleIcon=createGtkImage(null),this._toggle.append(this._toggleIcon),this._toggle.addEventListener(`click`,()=>this._password.togglePeek()),this.addSuffix(this._toggle);let readCapsLock=e=>this._password.setCapsLockOn(e.getModifierState(`CapsLock`));this._input.addEventListener(`keydown`,readCapsLock),this._input.addEventListener(`keyup`,readCapsLock);let e=this._password.state;this.setIndicatorIconName(e.indicatorIconName),this.setIndicatorTooltip(e.indicatorTooltip),this.hasAttribute(`revealed`)&&this._password.setRevealed(this.getAttribute(`revealed`)!==`false`),this._renderPassword(this._password.state),this._password.subscribe(e=>{this._renderPassword(e),this.dispatchEvent(new CustomEvent(`notify::revealed`,{bubbles:!0,detail:{revealed:e.revealed}}))})}attributeChangedCallback(e,t,n){if(e!==`revealed`){super.attributeChangedCallback(e,t,n);return}this._initialized&&this._password.setRevealed(n!==null&&n!==`false`)}_renderPassword(e){this._input.type=e.revealed?`text`:`password`,this._toggleIcon.dataset.iconName=e.peekIconName,this._toggleIcon.iconName=e.peekIconName,this._toggle.title=e.peekLabel,this._toggle.setAttribute(`aria-label`,e.peekLabel),this._toggle.setAttribute(`aria-pressed`,String(e.revealed)),e.revealed?this.setAttribute(`revealed`,``):this.removeAttribute(`revealed`)}};customElements.define(`adw-password-entry-row`,AdwPasswordEntryRow);const ri=new Set([`adw-action-row`,`adw-switch-row`,`adw-combo-row`,`adw-spin-row`]),ii=new Set([...ri,`adw-entry-row`,`adw-password-entry-row`,`adw-expander-row`,`adw-button-row`]);function isVisible(e){return!(e instanceof HTMLElement&&e.hidden)}function groupRows(e){let t=e.querySelector(`:scope > .adw-preferences-group-listbox`);return Array.from((t??e).children).filter(e=>ii.has(e.tagName.toLowerCase()))}function describeRow(e){let t=e.getAttribute(`subtitle`);return{title:e.getAttribute(`title`)??``,subtitle:t,visible:isVisible(e),isActionRow:ri.has(e.tagName.toLowerCase()),useMarkup:!1,useUnderline:!1,ref:e}}function describeGroup(e){return{title:e.getAttribute(`title`)??``,visible:isVisible(e),rows:groupRows(e).map(describeRow),ref:e}}function describePreferencesPages(e){return Array.from(e.querySelectorAll(`adw-preferences-page`)).map(e=>({name:e.getAttribute(`name`),title:e.getAttribute(`title`)??``,iconName:e.getAttribute(`icon-name`),useUnderline:e.hasAttribute(`use-underline`),visible:isVisible(e),description:e.getAttribute(`description`)??``,groups:Array.from(e.querySelectorAll(`adw-preferences-group`)).map(describeGroup),ref:e}))}function searchPreferencesDom(e,t,n){return searchPreferences(describePreferencesPages(e),t,n)}var AdwPreferencesPage=class extends WidgetElement{static get observedAttributes(){return[`title`,`icon-name`,`name`,`use-underline`,`open`]}get name(){return this.getAttribute(`name`)??``}set name(e){this.setAttribute(`name`,e)}get iconName(){return this.getAttribute(`icon-name`)??``}set iconName(e){this.setAttribute(`icon-name`,e)}get useUnderline(){return this.hasAttribute(`use-underline`)}set useUnderline(e){this.toggleAttribute(`use-underline`,e)}get groups(){return Array.from(this.querySelectorAll(`adw-preferences-group`))}},AdwPreferencesDialog=class extends WidgetElement{_initialized=!1;_scrimEl;_dialogEl;_titleEl;_bodyEl;_pagesEl;_closeBtn;_modal;static get observedAttributes(){return[`title`,`open`,`can-close`,`content-width`]}get open(){return this.hasAttribute(`open`)}set open(e){e?this.setAttribute(`open`,``):this.removeAttribute(`open`)}get canClose(){let e=this.getAttribute(`can-close`);return e===null?!0:e!==`false`}set canClose(e){e?this.setAttribute(`can-close`,``):this.setAttribute(`can-close`,`false`)}get contentWidth(){let e=Number.parseInt(this.getAttribute(`content-width`)??``,10);return Number.isNaN(e)?640:e}set contentWidth(e){this.setAttribute(`content-width`,String(e))}present(e){this.isConnected||(e??document.body).appendChild(this),this.open=!0}close(){this._attemptClose()}forceClose(){this.open&&=!1}add(e){this._pagesEl.appendChild(e)}removePage(e){return e.parentNode===this._pagesEl?(this._pagesEl.removeChild(e),!0):!1}get pages(){return Array.from(this._pagesEl.querySelectorAll(`adw-preferences-page`))}search(e,t){return searchPreferencesDom(this._pagesEl,e,t)}connectedCallback(){if(this._initialized)return;this._initialized=!0,this._scrimEl=document.createElement(`div`),this._scrimEl.className=`adw-preferences-dialog-scrim`,this._scrimEl.addEventListener(`click`,()=>this._attemptClose()),this._dialogEl=document.createElement(`div`),this._dialogEl.className=`adw-preferences-dialog-box`,this._dialogEl.addEventListener(`click`,e=>e.stopPropagation());let e=document.createElement(`div`);e.className=`adw-preferences-dialog-header`;let t=document.createElement(`div`);t.className=`adw-preferences-dialog-header-side`,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-preferences-dialog-title`;let n=document.createElement(`div`);n.className=`adw-preferences-dialog-header-side adw-preferences-dialog-header-side--end`,this._closeBtn=document.createElement(`button`),this._closeBtn.type=`button`,this._closeBtn.className=`adw-preferences-dialog-close`,this._closeBtn.setAttribute(`aria-label`,`Close`),this._closeBtn.addEventListener(`click`,()=>this._attemptClose()),n.appendChild(this._closeBtn),e.append(t,this._titleEl,n),this._bodyEl=document.createElement(`div`),this._bodyEl.className=`adw-preferences-dialog-body`,this._pagesEl=document.createElement(`div`),this._pagesEl.className=`adw-preferences-dialog-pages`,this._bodyEl.appendChild(this._pagesEl),this._dialogEl.append(e,this._bodyEl),bindSlottedChildren(this,[{into:this._pagesEl}]).install(this._scrimEl,this._dialogEl),this._modal=new AdwModalSurface({host:this,surface:this._dialogEl,role:`dialog`,isOpen:()=>this.open,onEscape:()=>this._attemptClose()}),this._render()}attributeChangedCallback(e,t,n){this._initialized&&t!==n&&(this._render(),e===`open`&&(this.dispatchEvent(new CustomEvent(`notify::open`,{bubbles:!0,detail:{open:this.open}})),this.open?this._modal.present():(this.dispatchEvent(new CustomEvent(`closed`,{bubbles:!0})),this._modal.dismiss())))}_attemptClose(){if(this.open){if(!this.canClose){this.dispatchEvent(new CustomEvent(`close-attempt`,{bubbles:!0}));return}this.open=!1}}_render(){this.classList.toggle(`open`,this.open);let e=this.getAttribute(`title`)??``;this._titleEl.textContent=e,this._dialogEl.style.setProperty(`--adw-dialog-content-width`,`${this.contentWidth}px`);let t=!this.canClose;this._closeBtn.disabled=t,this._closeBtn.classList.toggle(`locked`,t)}};customElements.define(`adw-preferences-page`,AdwPreferencesPage),customElements.define(`adw-preferences-dialog`,AdwPreferencesDialog);function isHeaderSuffix(e){return e instanceof Element&&e.getAttribute(`slot`)===`header-suffix`}var AdwPreferencesGroup=class extends WidgetElement{_headerEl;_titleEl;_descriptionEl;_suffixEl;_listboxEl;_initialized=!1;_observer=null;static get observedAttributes(){return[`title`,`description`]}get description(){return this.getAttribute(`description`)??``}set description(e){e?this.setAttribute(`description`,e):this.removeAttribute(`description`)}addRow(e){isHeaderSuffix(e)?this._suffixEl.appendChild(e):this._listboxEl.appendChild(e),this._renderHeader()}removeRow(e){let t=e.parentNode;return t!==this._listboxEl&&t!==this._suffixEl?!1:(t.removeChild(e),this._renderHeader(),!0)}connectedCallback(){if(this._initialized){this._observeBoxes();return}this._initialized=!0,this._headerEl=document.createElement(`div`),this._headerEl.className=`adw-preferences-group-header`;let e=document.createElement(`div`);e.className=`adw-preferences-group-labels`,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-preferences-group-title`,this._descriptionEl=document.createElement(`span`),this._descriptionEl.className=`adw-preferences-group-description`,e.append(this._titleEl,this._descriptionEl),this._suffixEl=document.createElement(`div`),this._suffixEl.className=`adw-preferences-group-suffix`,this._headerEl.append(e,this._suffixEl),this._listboxEl=document.createElement(`div`),this._listboxEl.className=`adw-preferences-group-listbox`,bindSlottedChildren(this,[{name:`header-suffix`,into:this._suffixEl},{into:this._listboxEl}],()=>this._renderHeader()).install(this._headerEl,this._listboxEl),this.setAttribute(`role`,`group`),this._observeBoxes()}disconnectedCallback(){this._observer?.disconnect(),this._observer=null}attributeChangedCallback(){this._initialized&&this._renderHeader()}_observeBoxes(){this._observer||(this._observer=new MutationObserver(()=>this._renderHeader()),this._observer.observe(this._listboxEl,{childList:!0}),this._observer.observe(this._suffixEl,{childList:!0}),this._renderHeader())}_renderHeader(){let e=this.getAttribute(`title`)??``,t=this.getAttribute(`description`)??``;this._titleEl.textContent=e,this._descriptionEl.textContent=t;let n=derivePreferencesGroupHeader({title:e,description:t,hasHeaderSuffix:this._suffixEl.childElementCount>0,rowCount:this._listboxEl.childElementCount,useMarkup:!1});this._titleEl.hidden=!n.titleVisible,this._descriptionEl.hidden=!n.descriptionVisible,this._headerEl.hidden=!n.headerVisible,this._headerEl.classList.toggle(`single-line`,n.singleLine),this._listboxEl.hidden=!n.listboxVisible}};customElements.define(`adw-preferences-group`,AdwPreferencesGroup);var AdwPreferencesRow=class extends TooltipElement{_titleEl;_contentEl;_initialized=!1;static get observedAttributes(){return[`title`,`title-selectable`,`use-markup`,`use-underline`,`tooltip-text`]}get title(){return this.getAttribute(`title`)??``}set title(e){e===``?this.removeAttribute(`title`):this.setAttribute(`title`,e)}get titleSelectable(){return this.hasAttribute(`title-selectable`)}set titleSelectable(e){this.toggleAttribute(`title-selectable`,e)}get useMarkup(){return this.hasAttribute(`use-markup`)}set useMarkup(e){this.toggleAttribute(`use-markup`,e)}get useUnderline(){return this.hasAttribute(`use-underline`)}set useUnderline(e){this.toggleAttribute(`use-underline`,e)}get child(){return this._contentEl?.firstElementChild??null}set child(e){this._contentEl?.replaceChildren(...e===null?[]:[e])}connectedCallback(){this._initialized||(this._initialized=!0,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-row-title`,this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-preferences-row-content`,bindSlottedChildren(this,[{name:`child`,into:this._contentEl}]).install(this._titleEl,this._contentEl),bindEmptySections(this._contentEl),this.hasAttribute(`role`)||this.setAttribute(`role`,`listitem`),this._render())}attributeChangedCallback(e,t,n){this._initialized&&(this._render(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:n}})))}_render(){let e=labelDisplayText(this.title,this.useMarkup,this.useUnderline);this._titleEl.textContent=e,this._titleEl.hidden=!stringIsNotEmpty(e),this._titleEl.style.userSelect=this.titleSelectable?`text`:``,applyRowTooltip(this,[this._titleEl,this._contentEl])}};customElements.define(`adw-preferences-row`,AdwPreferencesRow);var AdwShortcutLabel=class extends WidgetElement{_initialized=!1;static get observedAttributes(){return[`accelerator`,`disabled-text`]}connectedCallback(){this._initialized||(this._initialized=!0,this.hasAttribute(`role`)||this.setAttribute(`role`,`img`)),this._render()}attributeChangedCallback(e){this._initialized&&(this._render(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0})))}get accelerator(){return this.getAttribute(`accelerator`)??``}set accelerator(e){this.setAttribute(`accelerator`,e)}get disabledText(){return this.getAttribute(`disabled-text`)??``}set disabledText(e){this.setAttribute(`disabled-text`,e)}_render(){let{nodes:e,accessibleLabel:t,error:n}=parseShortcutLabel(this.accelerator,{disabledText:this.disabledText,direction:this._direction()});this.replaceChildren(...e.map(e=>this._nodeElement(e))),this.setAttribute(`aria-label`,t),n&&console.warn(`adw-shortcut-label: failed to parse ${n}, part of accelerator '${this.accelerator}'`)}_direction(){let e=this.isConnected?getComputedStyle(this).direction:``;return e===`rtl`||e===`ltr`?e:this.closest(`[dir="rtl"]`)?`rtl`:`ltr`}_nodeElement(e){if(e.kind===`separator`||e.kind===`disabled`){let t=document.createElement(`span`);return t.className=e.kind===`disabled`?`dimmed adw-shortcut-label-disabled`:`dimmed`,t.textContent=e.text,t}let t=document.createElement(`span`);t.className=`adw-shortcut-label-keys`,t.setAttribute(`dir`,`ltr`);for(let n of e.keys){let e=document.createElement(`span`);if(e.className=`keycap`,e.textContent=n.label,n.sideMarker){let t=document.createElement(`sub`);t.className=`adw-shortcut-label-side`,t.textContent=n.sideMarker,e.append(t)}t.append(e)}return t}};customElements.define(`adw-shortcut-label`,AdwShortcutLabel);var AdwShortcutsDialog=class extends AdwDialog{get sections(){return[...this.contentArea.children].filter(e=>e.localName===`adw-shortcuts-section`)}connectedCallback(){super.connectedCallback(),this.classList.add(`adw-shortcuts-dialog`)}};customElements.define(`adw-shortcuts-dialog`,AdwShortcutsDialog);const ai=new WeakMap,oi=new WeakMap;var AdwSidebarItem=class extends WidgetElement{static get observedAttributes(){return[`title`,`subtitle`,`icon-name`,`disabled`,`hidden`,`enabled`,`visible`,`needs-attention`,`badge-number`]}get enabled(){let e=this.getAttribute(`enabled`);return e===null?!this.hasAttribute(`disabled`):booleanAttribute$2(e,!0)}set enabled(e){this.setAttribute(`enabled`,e?`true`:`false`),this.toggleAttribute(`disabled`,!e)}get visible(){let e=this.getAttribute(`visible`);return e===null?!this.hasAttribute(`hidden`):booleanAttribute$2(e,!0)}set visible(e){this.setAttribute(`visible`,e?`true`:`false`),this.toggleAttribute(`hidden`,!e)}attributeChangedCallback(e,t,n){let r=ai.get(this);if(!r)return;let i=n??``;e===`title`?r.spec.title=i:e===`subtitle`?r.spec.subtitle=i:e===`icon-name`?r.spec.iconName=i:e===`disabled`?r.spec.enabled=n===null:e===`enabled`?r.spec.enabled=booleanAttribute$2(n,!0):e===`hidden`?r.spec.visible=n===null:e===`visible`?r.spec.visible=booleanAttribute$2(n,!0):e===`needs-attention`?r.spec.needsAttention=n===null:e===`badge-number`&&(r.spec.badgeNumber=Number.parseInt(i,10)||0),r.sidebar.refresh()}},AdwSidebarSection=class extends WidgetElement{static get observedAttributes(){return[`title`]}attributeChangedCallback(e,t,n){let r=oi.get(this);r&&(r.spec.title=n??``,r.sidebar.refresh())}},AdwSidebar=class extends WidgetElement{_state=new SidebarState;_listEl;_rows=[];_initialized=!1;_reflecting=!1;static get observedAttributes(){return[`mode`,`selected`]}get selected(){return this._state.selected}set selected(e){this.setAttribute(`selected`,String(e))}get selectedItem(){return this._state.selectedItem}get mode(){return this._state.mode}set mode(e){this.setAttribute(`mode`,e)}get sections(){return this._state.sections}set sections(e){this._state.setSections(e),this._rebuild()}get filter(){return this._state.filter}set filter(e){this._state.setFilter(e),this._rebuild()}connectedCallback(){this._initialized||(this._initialized=!0,this._listEl=document.createElement(`div`),this._listEl.className=`adw-sidebar-list`,this._listEl.setAttribute(`role`,`listbox`),attachRovingFocus({host:this,orientation:`vertical`,items:()=>this._rows.filter(e=>!e.el.hidden&&!e.el.disabled).map(e=>e.el),select:e=>{let t=this._rows.find(t=>t.el===e);t!==void 0&&this._state.setSelected(t.index)}}),this._state.setSections(this._readDeclaredSections()),this._state.setMode(this._readModeAttr()),this.hasAttribute(`selected`)&&this._state.setSelected(this._readSelectedAttr()),this._state.subscribe(e=>this._onSelectionChanged(e)),this.replaceChildren(this._listEl),this._applyMode(),this._rebuild(),this._reflectSelected())}attributeChangedCallback(e){if(!(!this._initialized||this._reflecting)){if(e===`selected`){this._state.setSelected(this._readSelectedAttr()),this._reflectSelected();return}e===`mode`&&this._state.setMode(this._readModeAttr())&&(this._applyMode(),this._applySelection())}}refresh(){this._initialized&&(this._state.refresh(),this._rebuild())}_readDeclaredSections(){let e=[];for(let t of Array.from(this.querySelectorAll(`adw-sidebar-section`))){let n=[];for(let e of Array.from(t.querySelectorAll(`adw-sidebar-item`))){let t={title:e.getAttribute(`title`)??``,subtitle:e.getAttribute(`subtitle`)??``,iconName:e.getAttribute(`icon-name`)??``,enabled:e.enabled,visible:e.visible,badgeNumber:Number.parseInt(e.getAttribute(`badge-number`)??`0`,10)||0,needsAttention:e.hasAttribute(`needs-attention`)};ai.set(e,{sidebar:this,spec:t}),n.push(t)}let r={title:t.getAttribute(`title`)??``,items:n};oi.set(t,{sidebar:this,spec:r}),e.push(r)}return e}_readModeAttr(){return this.getAttribute(`mode`)===`page`?`page`:`sidebar`}_readSelectedAttr(){return Number.parseFloat(this.getAttribute(`selected`)??``)}_reflectSelected(){this._reflecting=!0,this.setAttribute(`selected`,String(this._state.selected)),this._reflecting=!1}_onSelectionChanged(e){this._reflectSelected(),this._applySelection(),this.dispatchEvent(new CustomEvent(`notify::selected`,{bubbles:!0,detail:{selected:e.selected,previous:e.previous,interactive:e.interactive}}))}_activate(e){this._state.activate(e).activated&&this.dispatchEvent(new CustomEvent(`activated`,{bubbles:!0,detail:{index:e}}))}_rebuild(){let e=new Map;for(let t of this._state.headers)e.set(t.sectionIndex,t);let t=[];for(let e of this._state.visibleItems){let n=t[t.length-1];n&&n.sectionIndex===e.sectionIndex?n.items.push(e):t.push({sectionIndex:e.sectionIndex,items:[e]})}this._rows=[];let n=[];for(let r of t){let t=e.get(r.sectionIndex);t&&n.push(this._createHeader(t));let i=document.createElement(`div`);i.className=`adw-sidebar-section`;for(let e of r.items){let t=this._createRow(e);i.appendChild(t),this._rows.push({el:t,index:e.index})}n.push(i)}this._listEl.replaceChildren(...n),this.classList.toggle(`empty`,this._state.isEmpty),this._applySelection()}_createHeader(e){let t=document.createElement(`div`);if(t.className=`adw-sidebar-section-header`,e.kind===`title`){t.classList.add(`has-title`);let n=document.createElement(`span`);n.className=`adw-sidebar-section-heading`,n.textContent=e.title,t.appendChild(n)}else t.classList.add(`separator`);return e.first&&t.classList.add(`first`),t}_createRow(e){let t=e.item,n=document.createElement(`button`);n.type=`button`,n.className=`adw-sidebar-item`,n.setAttribute(`role`,`option`),n.hidden=t.visible===!1,n.disabled=t.enabled===!1;let r=createGtkImage(t.iconName??null,`adw-sidebar-item-icon`);r.hidden=!e.iconVisible,n.appendChild(r);let i=document.createElement(`span`);i.className=`adw-sidebar-item-text`;let a=document.createElement(`span`);a.className=`adw-sidebar-item-title`,a.textContent=t.title,a.hidden=!e.titleVisible,i.appendChild(a);let o=document.createElement(`span`);return o.className=`adw-sidebar-item-subtitle`,o.textContent=t.subtitle??``,o.hidden=!e.subtitleVisible,i.appendChild(o),n.appendChild(i),n.appendChild(this._createIndicator(t)),n.appendChild(createGtkImage(`go-next`,`adw-sidebar-item-arrow`)),n.addEventListener(`click`,()=>this._activate(e.index)),n}_createIndicator(e){let t=e.badgeNumber??0,n=e.needsAttention===!0,r=document.createElement(`span`);if(r.className=`indicator`,r.hidden=!n&&t===0,r.classList.toggle(`dot`,t===0),r.classList.toggle(`needs-attention`,n),t>0){let e=document.createElement(`span`);e.className=`numeric`,e.textContent=viewSwitcherBadgeLabel(t),r.appendChild(e)}return r}_applyMode(){let e=this._state.mode===`page`;this.classList.toggle(`page`,e),this.classList.toggle(`mode-sidebar`,!e)}_applySelection(){let e=this._state.selected,t=this._state.selectionVisible;this._rows.forEach((n,r)=>{let i=n.index===e;n.el.classList.toggle(`selected`,i&&t),n.el.setAttribute(`aria-selected`,String(i)),n.el.tabIndex=i||e===-1&&r===0?0:-1})}};customElements.define(`adw-sidebar-item`,AdwSidebarItem),customElements.define(`adw-sidebar-section`,AdwSidebarSection),customElements.define(`adw-sidebar`,AdwSidebar);const si=[`value`,`lower`,`upper`,`stepIncrement`,`pageIncrement`,`pageSize`];function authoredAdjustment(e){let t={};if(!(e instanceof Element))return t;for(let n of si){let r=e.getAttribute(attributeOf(n)),i=r===null?NaN:Number.parseFloat(r);Number.isFinite(i)&&(t[n]=i)}return t}var AdwSpinRow=class extends TooltipElement{_input;_textEl;_controlEl;_titleEl;_subtitleEl;_state=new SpinState;_initialized=!1;static get observedAttributes(){return[`title`,`subtitle`,`value`,`adjustment`,`tooltip-text`,`title-lines`,`subtitle-lines`]}get value(){return this._state.value}set value(e){this._state.setValue(this._roundToStep(e)),this._syncValue()}get adjustment(){return this._state.adjustment}set adjustment(e){this._state.configure(typeof e==`string`?parseAdjustment(e):e)}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=normalizeAdjustment(parseAdjustment(this.getAttribute(`adjustment`)));this._state.configure(e);let t=document.createElement(`div`);t.className=`adw-row-text`,this._textEl=t,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-row-title`,this._subtitleEl=document.createElement(`span`),this._subtitleEl.className=`adw-row-subtitle`,t.append(this._titleEl,this._subtitleEl);let n=document.createElement(`div`);n.className=`adw-spin-control`,this._controlEl=n;let r=document.createElement(`button`);r.className=`adw-spin-dec`,r.textContent=`−`,r.addEventListener(`click`,()=>this._adjust(-this._state.adjustment.stepIncrement));let i=document.createElement(`input`);i.type=`text`,i.value=this._formatValue(this._state.value),i.addEventListener(`change`,()=>{let e=parseFloat(i.value);Number.isNaN(e)?i.value=this._formatValue(this._state.value):(this.value=e,this._emitChange())});let a=document.createElement(`button`);a.className=`adw-spin-inc`,a.textContent=`+`,a.addEventListener(`click`,()=>this._adjust(this._state.adjustment.stepIncrement)),n.append(r,i,a),bindSlottedChildren(this,[{name:`adjustment`,consume:e=>this._state.configure(normalizeAdjustment(authoredAdjustment(e)))}]).install(t,n);let o=this.getAttribute(`value`);this._state.setValue(this._roundToStep(o===null?this._state.value:Number.parseFloat(o))),i.value=this._formatValue(this._state.value),this._input=i,this._state.subscribe(()=>this._syncValue()),this._renderText()}attributeChangedCallback(e,t,n){if(this._initialized){if(e===`title`||e===`subtitle`||e===`tooltip-text`||e===`title-lines`||e===`subtitle-lines`){this._renderText();return}if(e===`adjustment`){this._state.configure(parseAdjustment(n));return}this._state.setValue(this._roundToStep(Number.parseFloat(n||`0`)))}}_renderText(){let e=deriveRowLabels({title:this.getAttribute(`title`),subtitle:this.getAttribute(`subtitle`)});this._titleEl.textContent=e.title,this._titleEl.hidden=!e.titleVisible,this._subtitleEl.textContent=e.subtitle,this._subtitleEl.hidden=!e.subtitleVisible,applyRowTooltip(this,[this._textEl,this._controlEl]),this._applyLineClamping()}_applyLineClamping(){applyRowLineClamp({titleEl:this._titleEl,subtitleEl:this._subtitleEl,textContainerEl:this._titleEl.parentElement,getTitleLines:()=>parseRowLinesAttribute(this.getAttribute(`title-lines`)),getSubtitleLines:()=>parseRowLinesAttribute(this.getAttribute(`subtitle-lines`))})}_adjust(e){this.value=this._state.value+e,this._emitChange()}_emitChange(){this.dispatchEvent(new CustomEvent(`notify::value`,{bubbles:!0,detail:{value:this._state.value}}))}_syncValue(){this._input&&(this._input.value=this._formatValue(this._state.value)),this.setAttribute(`value`,String(this._state.value))}_roundToStep(e){if(!Number.isFinite(e))return e;let t=this._countDecimals(this._state.adjustment.stepIncrement);return t>0?parseFloat(e.toFixed(t)):e}_countDecimals(e){let t=String(e),n=t.indexOf(`.`);return n===-1?0:t.length-n-1}_formatValue(e){let t=this._countDecimals(this._state.adjustment.stepIncrement);return t>0?e.toFixed(t):String(e)}};customElements.define(`adw-spin-row`,AdwSpinRow);const ci=`http://www.w3.org/2000/svg`,li=new Set;let ui=0;function tick(e){for(let t of li)t.drawAt(e);ui=li.size>0?requestAnimationFrame(tick):0}function startTicking(){ui===0&&li.size>0&&(ui=requestAnimationFrame(tick))}var AdwSpinner=class extends WidgetElement{static get observedAttributes(){return[`size`]}_svg=null;_track=null;_arc=null;_circumference=0;_radius=0;_origin=null;connectedCallback(){this._build(),li.add(this),this._origin=null,startTicking()}disconnectedCallback(){li.delete(this)}attributeChangedCallback(){this._sync()}drawAt(e){this._origin===null&&(this._origin=e),this._paint(spinnerProgressAt(e-this._origin))}_build(){if(this._svg)return;let e=document.createElementNS(ci,`svg`);e.setAttribute(`fill`,`none`),e.setAttribute(`aria-hidden`,`true`);let t=document.createElementNS(ci,`circle`);t.setAttribute(`stroke`,`currentColor`),t.setAttribute(`stroke-opacity`,`0.15`);let n=document.createElementNS(ci,`circle`);n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-linecap`,`round`),e.append(t,n),this._svg=e,this._track=t,this._arc=n,this.replaceChildren(e),this.setAttribute(`role`,`progressbar`),this.setAttribute(`aria-busy`,`true`),this._sync()}_sync(){let e=this._svg,t=this._track,n=this._arc;if(!e||!t||!n)return;let r=resolveSpinnerSize(this.getAttribute(`size`)),{diameter:i,lineWidth:a}=spinnerGeometry(r,r);this.style.width=`${r}px`,this.style.height=`${r}px`,e.setAttribute(`width`,String(i)),e.setAttribute(`height`,String(i)),e.setAttribute(`viewBox`,`0 0 ${i} ${i}`);let o=(i-a)/2;this._radius=o,this._circumference=2*Math.PI*o;for(let e of[t,n])e.setAttribute(`cx`,String(i/2)),e.setAttribute(`cy`,String(i/2)),e.setAttribute(`r`,String(o)),e.setAttribute(`stroke-width`,String(a));this._paint(this._origin===null?Nn:this._lastProgress)}_lastProgress=Nn;_paint(e){let t=this._arc;if(!t||this._radius<=0)return;this._lastProgress=e;let{end:n,length:r}=spinnerArc(e),i=r*this._radius;t.setAttribute(`stroke-dasharray`,`${i} ${Math.max(this._circumference-i,0)}`),t.setAttribute(`stroke-dashoffset`,String(-n*this._radius))}};customElements.define(`adw-spinner`,AdwSpinner);var PopoverMenuView=class{surface;prefix;onActivate;_model=[];_actions=null;_title=``;_page=[];_openers=new Set;_backRow=null;_key=`[]`;_rows=[];constructor(e,t,n){this.surface=e,this.prefix=t,this.onActivate=n,this.surface.addEventListener(`keydown`,e=>this._onKeyDown(e))}_onKeyDown(e){let t=document.activeElement;if(!(t===null||!this.surface.contains(t))){if(e.key===`ArrowRight`&&this._openers.has(t)){e.preventDefault(),t.click();return}e.key===`ArrowLeft`&&t===this._backRow&&(e.preventDefault(),t.click())}}get rows(){return this._rows}get page(){return this._page}showPage(e){this._page=[...e]}get focusableRows(){return this._rows.filter(e=>!e.hidden&&!e.disabled)}focusPage(e){let t=this.focusableRows;(t[e]??t[0])?.focus()}setMenuModel(e){let t=JSON.stringify(e);t!==this._key&&(this._key=t,this._page=[]),this._model=e}setActions(e){this._actions=e}setTitle(e){this._title=e}reset(){this._page=[]}currentItems(){if(this._page.length===0)return this._model;let e=menuNodeAt(this._model,this._page);return e!==null&&e.kind!==`item`?e.items:this._model}render(){this.surface.replaceChildren(),this._rows=[],this._openers=new Set,this._backRow=null;let e=menuNodeAt(this._model,this._page);this._page.length>0&&e!==null&&e.kind===`submenu`?this.surface.appendChild(this.backRow(e.label)):this._title.length>0&&this.surface.appendChild(this.heading(this._title,`${this.prefix}-title`));let t=``;for(let e of flattenMenu(this.currentItems(),this._page)){e.separated&&this.surface.appendChild(this.separator());let n=e.path.slice(0,-1),r=n.join(`.`);if(r!==t){t=r;let e=this.sectionHeading(n);e!==null&&this.surface.appendChild(this.heading(e,`adw-popover-section-title`))}e.node.kind===`submenu`?this.surface.appendChild(this.submenuRow(e.node.label,e.node.icon,e.path)):this.surface.appendChild(this.itemRow(e.node,e.path))}}sectionHeading(e){if(e.length<=this._page.length)return null;let t=menuNodeAt(this._model,e);return t!==null&&t.kind===`section`&&t.label!==void 0?t.label:null}heading(e,t){let n=document.createElement(`div`);return n.className=`adw-popover-title ${t}`,n.textContent=e,n}separator(){let e=document.createElement(`div`);return e.className=`adw-popover-separator`,e.setAttribute(`role`,`separator`),e}baseRow(e){let t=document.createElement(`button`);return t.type=`button`,t.className=`adw-popover-item ${e}`,t.tabIndex=-1,this._rows.push(t),t}backRow(e){let t=this.baseRow(`${this.prefix}-item adw-popover-back`);t.setAttribute(`role`,`menuitem`),t.appendChild(createGtkImage(`go-previous`,`${this.prefix}-item-icon`));let n=document.createElement(`span`);return n.className=`${this.prefix}-item-label`,n.textContent=e.length>0?menuLabelText(e):`Back`,t.appendChild(n),t.addEventListener(`click`,()=>{this._page=this._page.slice(0,-1),this.render(),this.focusPage(0)}),this._backRow=t,t}submenuRow(e,t,n){let r=this.baseRow(`${this.prefix}-item`);r.setAttribute(`role`,`menuitem`),r.setAttribute(`aria-haspopup`,`menu`),t!==void 0&&t.length>0&&r.appendChild(createGtkImage(t,`${this.prefix}-item-icon`));let i=document.createElement(`span`);return i.className=`${this.prefix}-item-label`,i.textContent=menuLabelText(e),r.appendChild(i),r.appendChild(createGtkImage(`go-next`,`adw-popover-item-arrow`)),r.addEventListener(`click`,()=>{this._page=[...n],this.render(),this.focusPage(1)}),this._openers.add(r),r}itemRow(e,t){let n=resolveMenuItemState(e,this._actions??void 0),r=this.baseRow(`${this.prefix}-item`);if(r.hidden=!n.visible,r.disabled=!n.sensitive,n.sensitive||r.setAttribute(`aria-disabled`,`true`),n.role===`normal`)r.setAttribute(`role`,`menuitem`);else{r.setAttribute(`role`,n.role===`check`?`menuitemcheckbox`:`menuitemradio`),r.setAttribute(`aria-checked`,String(n.toggled));let e=document.createElement(`span`);e.className=`adw-popover-item-check ${n.role===`radio`?`radio`:``}`.trim(),r.appendChild(e)}e.icon!==void 0&&e.icon.length>0&&r.appendChild(createGtkImage(e.icon,`${this.prefix}-item-icon`));let i=document.createElement(`span`);if(i.className=`${this.prefix}-item-label`,i.textContent=menuLabelText(e.label),r.appendChild(i),e.accel!==void 0&&e.accel.length>0){let t=document.createElement(`span`);t.className=`adw-popover-item-accel`,t.textContent=e.accel,r.appendChild(t)}return r.addEventListener(`click`,()=>{n.sensitive&&this.onActivate(t)}),r}};const di=[`bottom`,`top`,`start`,`end`],fi=[`start`,`end`],pi=[`menu`,`listbox`],mi=[...pi,`dialog`];var GtkPopover=class extends WidgetElement{_state=new PopoverState;_anchor=null;_initialized=!1;_reflecting=!1;_onDocumentPointerDown=e=>{if(!this.autohide)return;let t=e.target;this.contains(t)||this.anchor?.contains(t)!==!0&&this._state.dismiss()};_onDocumentKeyDown=e=>{e.key===`Escape`&&this.autohide&&(e.stopPropagation(),this._state.dismiss(),this.anchor?.focus())};static get observedAttributes(){return[`open`,`position`,`align`,`role`,`menu`,`autohide`]}get open(){return this._state.open}set open(e){e?this._state.popup():this._state.popdown()}get autohide(){return this.getAttribute(`autohide`)!==`false`}set autohide(e){this.setAttribute(`autohide`,String(e))}get anchor(){return this._anchor??this.parentElement}set anchor(e){this._anchor=e}get position(){let e=this.getAttribute(`position`);return di.includes(e)?e:`bottom`}set position(e){this.setAttribute(`position`,e)}get align(){let e=this.getAttribute(`align`);return fi.includes(e)?e:`start`}set align(e){this.setAttribute(`align`,e)}get popoverRole(){let e=this.getAttribute(`role`);return mi.includes(e)?e:`menu`}get items(){return[...this.querySelectorAll(`.adw-popover-item`)].filter(e=>!e.hidden&&!e.disabled)}popup(){this._state.popup()}popdown(){this._state.popdown()}subscribe(e){return this._state.subscribe(t=>e(t.open))}connectedCallback(){this._buildOnce(),this._state.open&&this._bindDocument()}takesChild(){return!0}_buildOnce(){this._initialized||(this._initialized=!0,this.takesChild()&&bindSlottedChildren(this,[{name:`child`,into:this}]),this.classList.add(`adw-popover`),this.hasAttribute(`role`)||this.setAttribute(`role`,`menu`),this.addEventListener(`keydown`,e=>this._onKeyDown(e)),this._state.subscribe(e=>this._onStateChange(e.open)),this.hasAttribute(`open`)&&this._state.popup(),this._render())}disconnectedCallback(){this._unbindDocument()}attributeChangedCallback(e,t,n){if(this._initialized){if(e===`open`){if(this._reflecting)return;n===null?this._state.popdown():this._state.popup();return}if(e===`role`&&n===null){this.setAttribute(`role`,`menu`);return}this._render()}}_onStateChange(e){e?this._bindDocument():this._unbindDocument(),this._reflecting=!0,e?this.setAttribute(`open`,``):this.removeAttribute(`open`),this._reflecting=!1,this._render(),this.dispatchEvent(new CustomEvent(`notify::open`,{bubbles:!0,detail:{open:e}}))}_bindDocument(){document.addEventListener(`pointerdown`,this._onDocumentPointerDown),document.addEventListener(`keydown`,this._onDocumentKeyDown,!0)}_unbindDocument(){document.removeEventListener(`pointerdown`,this._onDocumentPointerDown),document.removeEventListener(`keydown`,this._onDocumentKeyDown,!0)}_render(){this.hidden=!this._state.open,this.dataset.position=this.position,this.dataset.align=this.align}_onKeyDown(e){if(!this._state.open||!pi.includes(this.popoverRole))return;let t=this.items,n=document.activeElement,r=n===null?-1:t.indexOf(n),i=this.querySelector(`input, textarea`)!==null,{action:a,index:o}=resolvePopoverKey(e.key,{itemCount:t.length,currentIndex:r,hasSearch:i});if(a===`focus`){e.preventDefault(),t[o]?.focus();return}a===`activate`&&(e.preventDefault(),t[o]?.click(),this.dispatchEvent(new CustomEvent(`popover-item-activated`,{bubbles:!0,detail:{index:o}})))}};customElements.define(`gtk-popover`,GtkPopover);const hi={flat:`flat`,suggested:`suggested-action`,destructive:`destructive-action`},gi={"open-menu-symbolic":`open-menu`,"pan-down-symbolic":`go-down`,"pan-up-symbolic":`go-down`,"pan-start-symbolic":`go-previous`,"pan-end-symbolic":`go-next`},_i={down:`bottom`,up:`top`,left:`start`,right:`end`};var AdwSplitButton=class extends WidgetElement{_state=new SplitButtonState;_actionEl;_dropdownEl;_arrowEl;_menuEl;_menuView;_actions=null;_inlineLabel=``;_openReflected=!1;_initialized=!1;static get observedAttributes(){return[`label`,`icon-name`,`use-underline`,`tooltip`,`dropdown-tooltip`,`direction`,`menu-model`,`disabled`,`flat`,`suggested`,`destructive`]}get active(){return this._state.open}get dropdownEnabled(){return this._state.dropdownEnabled}get label(){return this._state.label}set label(e){this.setAttribute(`label`,e??``),this.removeAttribute(`icon-name`)}get iconName(){return this._state.iconName}set iconName(e){this.setAttribute(`icon-name`,e??``),this.removeAttribute(`label`)}get menuModel(){return this._state.menuModel??[]}set menuModel(e){this._state.setMenuModel(this._acceptMenu(e)),this._initialized&&this._render()}_acceptMenu(e,t=!0){let n=normalizeMenuModel(e);if(t)return assertMenuRenderable(n,k),n;let r=menuRefusals(n,k);if(r.length===0)return n;console.error(`${k.name} cannot render this menu, so it has none:`);for(let e of r)console.error(` [${e.path.join(`.`)}] ${e.message}`);return[]}get actions(){return this._actions}set actions(e){this._actions=e??null,this._menuView?.setActions(this._actions),this._initialized&&this._render()}get dropdownTooltip(){return this._state.dropdownTooltip}set dropdownTooltip(e){this.setAttribute(`dropdown-tooltip`,e??``)}get direction(){return this._state.direction}set direction(e){this.setAttribute(`direction`,e)}get useUnderline(){return this._state.useUnderline}set useUnderline(e){e?this.setAttribute(`use-underline`,``):this.removeAttribute(`use-underline`)}popup(){this._state.openMenu()}popdown(){this._state.closeMenu()}connectedCallback(){this._initialized||(this._initialized=!0,this._inlineLabel=(this.textContent??``).trim(),this.classList.add(`adw-split-button`),this._actionEl=document.createElement(`button`),this._actionEl.type=`button`,this._actionEl.className=`adw-split-button-action`,this._dropdownEl=document.createElement(`button`),this._dropdownEl.type=`button`,this._dropdownEl.className=`adw-split-button-dropdown`,this._dropdownEl.setAttribute(`aria-haspopup`,`menu`),this._arrowEl=createGtkImage(null),this._dropdownEl.appendChild(this._arrowEl),this._menuEl=document.createElement(`gtk-popover`),this._menuEl.classList.add(`adw-split-button-menu`),this._menuEl.setAttribute(`role`,`menu`),this._menuEl.setAttribute(`menu`,``),this._menuEl.setAttribute(`align`,`end`),this.replaceChildren(this._actionEl,this._dropdownEl,this._menuEl),this._menuEl.anchor=this._dropdownEl,this._menuEl.subscribe(e=>{e||(this._state.closeMenu(),this._menuView.reset())}),this._menuView=new PopoverMenuView(this._menuEl,`adw-split-button-menu`,e=>{let t=this._state.activateMenuItem(e);t!==null&&(activateElementMenuItem(this,t),this.dispatchEvent(new CustomEvent(`menu-activated`,{bubbles:!0,detail:{label:t.label,action:t.action,id:t.id??t.label,path:[...e]}})))}),this._menuView.setActions(this._actions),this._actionEl.addEventListener(`click`,()=>{this.hasAttribute(`disabled`)||this.dispatchEvent(new CustomEvent(`clicked`,{bubbles:!0}))}),this._dropdownEl.addEventListener(`click`,()=>{this.hasAttribute(`disabled`)||this._state.toggleMenu()}),this._syncStateFromAttributes(),this._state.subscribe(e=>this._onStateChange(e)),this._render())}attributeChangedCallback(e,t,n){if(this._initialized){switch(e){case`label`:case`icon-name`:this._applyContentAttribute(e,n);break;case`use-underline`:this._state.setUseUnderline(n!==null);break;case`direction`:this._state.setDirection(isSplitButtonDirection(n)?n:`down`);break;case`dropdown-tooltip`:this._state.setDropdownTooltip(n??``);break;case`menu-model`:this._state.setMenuModel(this._acceptMenu(parseMenuModel(n),!1));break;default:break}this._render()}}_syncStateFromAttributes(){let e=this.getAttribute(`label`)??(this._inlineLabel.length>0?this._inlineLabel:null),t=this.getAttribute(`icon-name`);e!==null&&this._state.setLabel(e),t!==null&&this._state.setIconName(t),this._state.setUseUnderline(this.hasAttribute(`use-underline`));let n=this.getAttribute(`direction`);isSplitButtonDirection(n)&&this._state.setDirection(n),this._state.setDropdownTooltip(this.getAttribute(`dropdown-tooltip`)??``),this._state.menuModel===null&&this._state.setMenuModel(this._acceptMenu(parseMenuModel(this.getAttribute(`menu-model`)),!1))}_applyContentAttribute(e,t){if(t!==null){e===`label`?this._state.setLabel(t):this._state.setIconName(t);return}let n=this.getAttribute(e===`label`?`icon-name`:`label`);n===null?this._state.setChild(null):e===`label`?this._state.setIconName(n):this._state.setLabel(n)}_onStateChange(e){for(let t of e.notified)this.dispatchEvent(new CustomEvent(`notify::${t}`,{bubbles:!0}));let t=e.open&&!this._openReflected;e.open!==this._openReflected&&(this._openReflected=e.open,this.dispatchEvent(new CustomEvent(`notify::active`,{bubbles:!0,detail:{active:e.open}}))),this._render(),t&&this._menuView.focusableRows[0]?.focus()}_render(){let e=this.hasAttribute(`disabled`);this.classList.toggle(`disabled`,e),this._actionEl.disabled=e,this._dropdownEl.disabled=e||!this._state.dropdownEnabled,this.classList.remove(`flat`,`suggested-action`,`destructive-action`);for(let[e,t]of Object.entries(hi))this.hasAttribute(e)&&this.classList.add(t);this._renderContent(),this._renderDropdown(),this._renderMenu()}_renderContent(){let{mode:e,label:t,iconName:n,styleClasses:r}=this._state;this.classList.toggle(`image-button`,r.includes(`image-button`)),this.classList.toggle(`text-button`,r.includes(`text-button`)),this._actionEl.replaceChildren(),this._actionEl.classList.toggle(`icon-only`,e===`icon`),e===`icon`&&n!==null?this._actionEl.appendChild(createGtkImage(n)):e===`label`&&t!==null&&this._actionEl.appendChild(document.createTextNode(t));let i=this.getAttribute(`tooltip`);this._actionEl.title=i??``,e===`icon`?this._actionEl.setAttribute(`aria-label`,i??(n||`Action`)):this._actionEl.removeAttribute(`aria-label`)}_renderDropdown(){let{direction:e,open:t}=this._state,n=splitButtonArrowIcon(e);this._arrowEl.iconName=gi[n],this._arrowEl.style.transform=n===`pan-up-symbolic`?`rotate(180deg)`:``,this._menuEl.position=_i[splitButtonPopupDirection(e)];let{text:r}=resolveDropdownTooltip(this._state.dropdownTooltip);this._dropdownEl.title=r,this._dropdownEl.setAttribute(`aria-label`,r),this._dropdownEl.setAttribute(`aria-expanded`,String(t));let{checked:i}=splitButtonRootState({active:!1,checked:!1,keyboardActivating:!1},{active:!1,checked:t,keyboardActivating:!1});this.classList.toggle(`checked`,i),this.classList.toggle(`active`,t)}_renderMenu(){this._menuEl.open=this._state.open;let e=this._state.menuModel??[];this._menuView.setMenuModel(e),this._menuView.setActions(this._actions??menuActionsOfElement(this,e)),this._menuView.render()}};customElements.define(`adw-split-button`,AdwSplitButton);var AdwStatusPage=class extends WidgetElement{_iconEl;_titleEl;_descEl;_childEl;_initialized=!1;static get observedAttributes(){return[`icon`,`icon-name`,`title`,`description`,`compact`]}connectedCallback(){this._initialized||(this._initialized=!0,this._iconEl=createGtkImage(null,`adw-status-page-icon`),this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-status-page-title`,this._descEl=document.createElement(`span`),this._descEl.className=`adw-status-page-description`,this._childEl=document.createElement(`div`),this._childEl.className=`adw-status-page-child`,bindSlottedChildren(this,[{name:`child`,into:this._childEl},{into:this._childEl}]).install(this._iconEl,this._titleEl,this._descEl,this._childEl),bindEmptySections(this._childEl),this._render())}attributeChangedCallback(){this._initialized&&this._render()}_render(){this.hasAttribute(`compact`)&&this.classList.add(`compact`);let e=this.getAttribute(`icon`)??this.getAttribute(`icon-name`);this._iconEl.iconName=e,this._iconEl.hidden=!stringIsNotEmpty(e);let t=this.getAttribute(`title`)??``;this._titleEl.textContent=t,this._titleEl.hidden=!stringIsNotEmpty(t);let n=this.getAttribute(`description`)??``;this._descEl.textContent=n,this._descEl.hidden=!stringIsNotEmpty(n)}};customElements.define(`adw-status-page`,AdwStatusPage);var AdwSwitchRow=class extends TooltipElement{static signals={"notify::active":`notify::active`};_switchEl;_prefixEl;_textEl;_titleEl;_subtitleEl;_state=new SwitchRowState;_initialized=!1;static get observedAttributes(){return[`title`,`subtitle`,`active`,`tooltip-text`,`title-lines`,`subtitle-lines`]}get prefixSection(){return this._prefixEl}get active(){return this._initialized?this._state.active:this.hasAttribute(`active`)}set active(e){this.toggleAttribute(`active`,!!e)}get_active(){return this.active}set_active(e){this.active=e}constructor(){super(),installElementApi(this)}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=document.createElement(`div`);e.className=`adw-row-text`,this._textEl=e,this._titleEl=document.createElement(`span`),this._titleEl.className=`adw-row-title`,this._subtitleEl=document.createElement(`span`),this._subtitleEl.className=`adw-row-subtitle`,e.append(this._titleEl,this._subtitleEl),this._prefixEl=document.createElement(`div`),this._prefixEl.className=`adw-switch-row-prefix`,this._switchEl=document.createElement(`gtk-switch`),this._switchEl.unfocusable=!0,bindSlottedChildren(this,[{name:`prefix`,into:this._prefixEl}]).install(this._prefixEl,e,this._switchEl),bindEmptySections(this._prefixEl),this._state.setActive(this.hasAttribute(`active`)),this._switchEl.active=this._state.active,this.setAttribute(`role`,`switch`),this.setAttribute(`aria-checked`,String(this._state.active)),this._switchEl.addEventListener(`notify::active`,e=>{e.stopPropagation(),this._apply(this._state.setActive(this._switchEl.active))}),this.addEventListener(`click`,e=>{e.target instanceof Node&&this._switchEl.contains(e.target)||this._apply(this._state.activate())}),attachRowActivation({row:this,activatable:()=>!0}),this._renderText()}attributeChangedCallback(e){this._initialized&&(e===`active`?this._apply(this._state.setActive(this.hasAttribute(`active`))):this._renderText())}_apply(e){e&&(this._switchEl.active=this._state.active,this.toggleAttribute(`active`,this._state.active),this.setAttribute(`aria-checked`,String(this._state.active)),this.dispatchEvent(new CustomEvent(`notify::active`,{bubbles:!0,detail:{active:this._state.active}})))}_renderText(){let{title:e,titleVisible:t,subtitle:n,subtitleVisible:r}=deriveRowLabels({title:this.getAttribute(`title`),subtitle:this.getAttribute(`subtitle`)});this._titleEl.textContent=e,this._titleEl.hidden=!t,this._subtitleEl.textContent=n,this._subtitleEl.hidden=!r,applyRowTooltip(this,[this._prefixEl,this._textEl]),this._applyLineClamping()}_applyLineClamping(){applyRowLineClamp({titleEl:this._titleEl,subtitleEl:this._subtitleEl,textContainerEl:this._titleEl.parentElement,getTitleLines:()=>parseRowLinesAttribute(this.getAttribute(`title-lines`)),getSubtitleLines:()=>parseRowLinesAttribute(this.getAttribute(`subtitle-lines`))})}};customElements.define(`adw-switch-row`,AdwSwitchRow);const createTabChip=e=>{let t=document.createElement(`button`);t.type=`button`,t.className=`adw-tab`,t.setAttribute(`role`,`tab`);let n=createGtkImage(null,`adw-tab-icon`),r=document.createElement(`adw-spinner`);r.className=`adw-tab-spinner`,r.setAttribute(`size`,`16`),r.hidden=!0;let i=document.createElement(`span`);i.className=`adw-tab-title`;let a=createGtkImage(null,`adw-tab-indicator`),o=document.createElement(`button`);return o.type=`button`,o.className=`adw-tab-close`,o.setAttribute(`aria-label`,`Close tab`),o.addEventListener(`click`,t=>{t.stopPropagation(),e.onClose()}),t.append(n,r,i,a,o),t.addEventListener(`click`,()=>e.onSelect()),t.addEventListener(`pointerenter`,()=>e.onHover(!0)),t.addEventListener(`pointerleave`,()=>e.onHover(!1)),{el:t,icon:n,spinner:r,label:i,indicator:a,close:o}},refreshTabChip=(e,t,n)=>{e.label.textContent=t.title,e.el.title=tabTooltip(t),e.el.classList.toggle(`pinned`,t.pinned),e.el.classList.toggle(`needs-attention`,t.needsAttention),e.el.classList.toggle(`closing`,t.closing);let r=tabIconState(t,n);e.icon.iconName=r.icon,e.icon.hidden=!r.iconVisible||r.spinner,e.spinner.hidden=!(r.spinner&&r.iconVisible),e.indicator.iconName=t.indicatorIcon,e.indicator.hidden=!r.indicatorVisible},chipPosition=(e,t)=>t.getBoundingClientRect().left-e.getBoundingClientRect().left+e.scrollLeft,refreshTabChipClose=(e,t,n,r)=>{let i=e.scrollLeft,a=chipPosition(e,t.el),o=a>=i&&a+t.el.offsetWidth<=i+e.clientWidth;t.close.hidden=!tabCloseVisible({hovering:r.hovering,fullyVisible:o,selected:r.selected,dragging:!1,pinned:n.pinned})},scrollChipIntoBar=(e,t)=>{let n=e.clientWidth,r=t.offsetWidth;if(n<=0||r<=0)return;let i=e.scrollLeft,a=chipPosition(e,t),o=Math.min(r,n-r)/2;a-5<i?e.scrollLeft=a-o:a+r+5>i+n&&(e.scrollLeft=a+r+o-n)},vi=[`page-attached`,`page-detached`,`page-reordered`,`page-updated`,`page-pinned`,`notify::selected-page`];var AdwTabBar=class extends WidgetElement{_boxEl;_startEl;_endEl;_indicatorEl;_chips=new Map;_hovered=new Set;_view=null;_initialized=!1;_preferredAction=null;_dropTypes=[];_dropActions=[];_dropArmed=!1;static get observedAttributes(){return[`view`,`autohide`,`expand-tabs`,`inverted`,`extra-drag-preload`]}get view(){return this._view}set view(e){this.setView(e===null?null:typeof e==`string`?this._resolveView(e):e)}get startActionWidget(){return this._startEl?.firstElementChild??null}set startActionWidget(e){this.startActionWidget!==e&&(this._startEl.replaceChildren(...e===null?[]:[e]),this.dispatchEvent(new CustomEvent(`notify::start-action-widget`,{bubbles:!0,detail:{widget:e}})))}get endActionWidget(){return this._endEl?.firstElementChild??null}set endActionWidget(e){this.endActionWidget!==e&&(this._endEl.replaceChildren(...e===null?[]:[e]),this.dispatchEvent(new CustomEvent(`notify::end-action-widget`,{bubbles:!0,detail:{widget:e}})))}get autohide(){return this.hasAttribute(`autohide`)}set autohide(e){e?this.setAttribute(`autohide`,``):this.removeAttribute(`autohide`)}get expandTabs(){return this.hasAttribute(`expand-tabs`)}set expandTabs(e){e?this.setAttribute(`expand-tabs`,``):this.removeAttribute(`expand-tabs`)}get inverted(){return this.hasAttribute(`inverted`)}set inverted(e){e?this.setAttribute(`inverted`,``):this.removeAttribute(`inverted`)}get extraDragPreload(){return this.hasAttribute(`extra-drag-preload`)}set extraDragPreload(e){e?this.setAttribute(`extra-drag-preload`,``):this.removeAttribute(`extra-drag-preload`)}get tabsRevealed(){return tabsRevealed({autohide:this.autohide,nPages:this._view?.nPages??0,nPinnedPages:this._view?.nPinnedPages??0,isTransferringPage:!1})}get isOverflowing(){return this._initialized?this.scrollWidth>this.clientWidth:!1}get extraDragPreferredAction(){return this._preferredAction}setView(e){this._view!==e&&(this._unbindView(),this._view=e,this._bindView(),this._syncChips(),this._applyRevealed(),this.dispatchEvent(new CustomEvent(`notify::view`,{bubbles:!0,detail:{view:e}})))}connectedCallback(){if(this._initialized){this._bindView(),this._syncChips();return}this._initialized=!0,this.classList.add(`adw-tab-bar`),this.setAttribute(`role`,`tablist`),this._startEl=document.createElement(`div`),this._startEl.className=`adw-tab-bar-start-action`,this._boxEl=document.createElement(`div`),this._boxEl.className=`adw-tab-box`,this._indicatorEl=document.createElement(`div`),this._indicatorEl.className=`adw-tab-box-overflow`,this._indicatorEl.hidden=!0,this._boxEl.appendChild(this._indicatorEl),this._endEl=document.createElement(`div`),this._endEl.className=`adw-tab-bar-end-action`,bindSlottedChildren(this,[{name:`start-action-widget`,into:this._startEl},{name:`end-action-widget`,into:this._endEl}]).install(this._startEl,this._boxEl,this._endEl);let e=this.getAttribute(`view`);this.setView(e===null?null:this._resolveView(e)),this._bindView(),this._syncChips(),this._applyRevealed(),this.addEventListener(`keydown`,e=>this._onKeyDown(e)),this.addEventListener(`dragover`,this._onDragOver),this.addEventListener(`drop`,this._onDrop)}disconnectedCallback(){this._unbindView()}attributeChangedCallback(e,t,n){if(this._initialized){switch(e){case`view`:this.setView(n===null?null:this._resolveView(n));return;case`autohide`:this._applyRevealed();break;case`expand-tabs`:case`inverted`:case`extra-drag-preload`:break}(n!==null||e===`view`)&&this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:n}}))}}setupExtraDropTarget(e,t=[`copy`,`move`]){this._dropTypes=e,this._dropActions=t}_resolveView(e){return document.getElementById(e)??null}_bindView(){this._unbindView();for(let e of vi)this._view?.addEventListener(e,this._onViewChange)}_unbindView(){for(let e of vi)this._view?.removeEventListener(e,this._onViewChange)}_onViewChange=()=>{this._syncChips(),this._applyRevealed()};_syncChips(){let e=this._view?.pages??[],t=new Set;e.forEach((e,n)=>{t.add(e.id);let r=this._chips.get(e.id);if(r===void 0){let t=createTabChip({onSelect:()=>this._view?.setSelectedPage(e.id),onClose:()=>this._view?.closePage(e.id),onHover:t=>{t?this._hovered.add(e.id):this._hovered.delete(e.id),this._refreshOne(e.id)}});t.el.dataset.pageId=e.id,t.close.tabIndex=-1,this._chips.set(e.id,t),this._boxEl.insertBefore(t.el,this._boxEl.children[n]??null)}else this._boxEl.children[n]!==r.el&&this._boxEl.insertBefore(r.el,this._boxEl.children[n]??null);this._refreshOne(e.id)});for(let[e,n]of this._chips)t.has(e)||(n.el.remove(),this._chips.delete(e),this._hovered.delete(e));this._applyActiveState(),this._boxEl.classList.toggle(`single-tab`,e.length<=1),this._applyOverflow()}_refreshOne(e){let t=this._view?.pages.find(t=>t.id===e),n=this._chips.get(e);t===void 0||n===void 0||(refreshTabChip(n,t,this._view?.getAttribute(`default-icon`)),refreshTabChipClose(this,n,t,{hovering:this._hovered.has(e),selected:this._view?.selectedId===e}))}_applyActiveState(){let e=this._view?.selectedId??null;for(let[t,n]of this._chips){let r=t===e;n.el.classList.toggle(`active`,r),n.el.setAttribute(`aria-selected`,String(r)),n.el.tabIndex=r?0:-1;let i=this._view?.pages.find(e=>e.id===t);i!==void 0&&refreshTabChipClose(this,n,i,{hovering:this._hovered.has(t),selected:r})}if(e===null)return;let t=this._chips.get(e);t!==void 0&&scrollChipIntoBar(this,t.el)}_applyRevealed(){this.hidden=!this.tabsRevealed}_applyOverflow(){this._indicatorEl.hidden=!this.isOverflowing}_onKeyDown(e){let t=this._view;if(t===null)return;let n=!1;if(e.ctrlKey&&e.key===`Tab`)n=e.shiftKey?t.cyclePreviousPage():t.cycleNextPage();else if(e.ctrlKey&&(e.key===`PageUp`||e.key===`PageDown`))n=e.key===`PageUp`?t.selectPreviousPage():t.selectNextPage();else if(e.ctrlKey&&(e.key===`Home`||e.key===`End`))n=e.key===`Home`?t.selectFirstPage():t.selectLastPage();else if(e.altKey&&/^[0-9]$/.test(e.key)){let r=Number.parseInt(e.key,10);n=t.selectNthPage(r===0?9:r-1)}else e.key===`ArrowLeft`||e.key===`ArrowRight`?n=e.key===`ArrowLeft`?t.selectPreviousPage():t.selectNextPage():(e.key===`Home`||e.key===`End`)&&(n=e.key===`Home`?t.selectFirstPage():t.selectLastPage());if(!n)return;e.preventDefault();let r=t.selectedId;r!==null&&this._chips.get(r)?.el.focus({preventScroll:!0})}_onDragOver=e=>{this._dropTypes.length===0||e.dataTransfer===null||[...this._dropTypes].find(t=>e.dataTransfer?.types.includes(t))!==void 0&&(e.preventDefault(),e.dataTransfer.dropEffect!==`none`&&(e.dataTransfer.dropEffect=this._dropEffects(e)),this._armHoverValue())};_onDrop=e=>{if(this._dropTypes.length===0||e.dataTransfer===null)return;let t=[...this._dropTypes].find(t=>e.dataTransfer?.types.includes(t));if(t===void 0)return;e.preventDefault();let n=this._dropEffects(e),r=this.dispatchEvent(new CustomEvent(`extra-drag-drop`,{bubbles:!0,cancelable:!0,detail:{action:n,data:e.dataTransfer.getData(t)}}));e.dataTransfer.dropEffect=r?n:`none`};_dropEffects(e){let t=this._preferredAction;return t!==null&&this._dropActions.includes(t)?t:this._dropActions[0]??`copy`}_armHoverValue(){if(this._dropArmed)return;this._dropArmed=!0;let e=new CustomEvent(`extra-drag-value`,{bubbles:!0,cancelable:!0,detail:{action:null}});this.dispatchEvent(e);let t=e.detail.action;t!==this._preferredAction&&(this._preferredAction=t,this.dispatchEvent(new CustomEvent(`notify::extra-drag-preferred-action`,{bubbles:!0,detail:{action:t}})))}};customElements.define(`adw-tab-bar`,AdwTabBar);const yi=[`page-attached`,`page-detached`,`page-updated`,`notify::selected-page`];var AdwTabButton=class extends WidgetElement{_button;_binEl;_labelEl;_indicatorEl;_view=null;_initialized=!1;static get observedAttributes(){return[`view`]}get view(){return this._view}set view(e){this.setView(e===null?null:typeof e==`string`?this._resolveView(e):e)}setView(e){this._view!==e&&(this._unbindView(),this._view=e,this._bindView(),this._render(),this.dispatchEvent(new CustomEvent(`notify::view`,{bubbles:!0,detail:{view:e}})))}connectedCallback(){if(this._initialized){this._bindView(),this._render();return}this._initialized=!0,this._button=document.createElement(`button`),this._button.type=`button`,this._button.className=`adw-button image-button`,this._button.title=`View Open Tabs`,this._binEl=document.createElement(`span`),this._binEl.className=`adw-tab-button-indicatorbin`;let e=document.createElement(`span`);e.className=`adw-tab-button-plate`,this._labelEl=document.createElement(`span`),this._labelEl.className=`adw-tab-button-label numeric`,this._indicatorEl=document.createElement(`span`),this._indicatorEl.className=`adw-tab-button-indicator`,this._binEl.append(e,this._labelEl),this._button.append(this._binEl,this._indicatorEl),this.replaceChildren(this._button),this.setAttribute(`role`,`button`);let t=this.getAttribute(`view`);this.setView(t===null?null:this._resolveView(t)),this._bindView(),this._render()}disconnectedCallback(){this._unbindView()}attributeChangedCallback(e,t,n){!this._initialized||e!==`view`||this.setView(n===null?null:this._resolveView(n))}_resolveView(e){return document.getElementById(e)??null}_onViewChange=()=>this._render();_bindView(){this._unbindView();for(let e of yi)this._view?.addEventListener(e,this._onViewChange)}_unbindView(){for(let e of yi)this._view?.removeEventListener(e,this._onViewChange)}_render(){let e=this._view,t=e?.nPages??0,n=t<100;this._labelEl.textContent=n?String(t):``,this._labelEl.hidden=!n,this._labelEl.classList.toggle(`small`,t>=10),this._binEl.classList.toggle(`overflow`,!n);let r=e?.selectedId??null,i=e?.pages.some(e=>e.needsAttention&&e.id!==r)??!1;this._indicatorEl.classList.toggle(`needs-attention`,i),this._indicatorEl.hidden=!i,this._button.setAttribute(`aria-label`,`View Open Tabs (${t})`)}};customElements.define(`adw-tab-button`,AdwTabButton);var AdwTabOverview=class extends WidgetElement{_childEl;_overviewEl;_headerEl;_startButtonsEl;_endButtonsEl;_titleEl;_searchBtn;_searchEntry;_searchClamp;_searchBar;_menuBtn;_gridEl;_pinnedGridEl;_emptyState;_searchEmptyState;_newTabBtn;_thumbs=new Map;_view=null;_model=[];_searchActive=!1;_initialized=!1;_appliedOpen=!1;_reflecting=!1;static get observedAttributes(){return[`view`,`open`,`inverted`,`enable-search`,`enable-new-tab`,`secondary-menu`,`show-start-title-buttons`,`show-end-title-buttons`,`extra-drag-preload`]}get view(){return this._view}set view(e){this.setView(e===null?null:typeof e==`string`?this._resolveView(e):e)}setView(e){this._view!==e&&(this._unbindView(),this._view=e,this._bindView(),this._initialized&&this._syncAll(),this.dispatchEvent(new CustomEvent(`notify::view`,{bubbles:!0,detail:{view:e}})))}get child(){return this._childEl.firstElementChild}get open(){return this.hasAttribute(`open`)}set open(e){this.setOpen(e)}get inverted(){return this.hasAttribute(`inverted`)}set inverted(e){this.toggleAttribute(`inverted`,e)}get enableSearch(){return this.getAttribute(`enable-search`)!==`false`}set enableSearch(e){this.setAttribute(`enable-search`,String(e))}get searchActive(){return this._searchActive}get enableNewTab(){return this.hasAttribute(`enable-new-tab`)}set enableNewTab(e){this.toggleAttribute(`enable-new-tab`,e)}get secondaryMenu(){return this._model}set secondaryMenu(e){let t=normalizeMenuModel(e);assertMenuRenderable(t,k),this._model=t,this._applyMenu()}get showStartTitleButtons(){return this.getAttribute(`show-start-title-buttons`)!==`false`}set showStartTitleButtons(e){this.setAttribute(`show-start-title-buttons`,String(e))}get showEndTitleButtons(){return this.getAttribute(`show-end-title-buttons`)!==`false`}set showEndTitleButtons(e){this.setAttribute(`show-end-title-buttons`,String(e))}get extraDragPreload(){return this.hasAttribute(`extra-drag-preload`)}set extraDragPreload(e){this.toggleAttribute(`extra-drag-preload`,e)}get extraDragPreferredAction(){return 0}activateOverviewOpen(){return this.open||this._view===null?!1:(this.setOpen(!0),!0)}activateOverviewClose(){return!this.open||this._view===null||this._view.nPages===0?!1:(this.setOpen(!1),!0)}connectedCallback(){if(this._initialized){this._bindView(),this._syncAll();return}this._initialized=!0,this._childEl=document.createElement(`div`),this._childEl.className=`adw-tab-overview-child`,this._overviewEl=document.createElement(`div`),this._overviewEl.className=`overview adw-tab-overview-toolbar`,this._headerEl=document.createElement(`div`),this._headerEl.className=`adw-header-bar overview-header-bar`,this._startButtonsEl=document.createElement(`div`),this._startButtonsEl.className=`overview-title-buttons start`,this._endButtonsEl=document.createElement(`div`),this._endButtonsEl.className=`overview-title-buttons end`,this._searchBtn=document.createElement(`button`),this._searchBtn.type=`button`,this._searchBtn.className=`adw-button image-button search-button`,this._searchBtn.title=`Search Tabs`,this._searchBtn.appendChild(createGtkImage(`system-search`,`search-button-icon`)),this._titleEl=document.createElement(`div`),this._titleEl.className=`adw-window-title numeric overview-title`,this._menuBtn=document.createElement(`gtk-menu-button`),this._menuBtn.setAttribute(`icon-name`,`view-more`),this._menuBtn.className=`secondary-menu-button`,this._menuBtn.hidden=!0,this._headerEl.append(this._startButtonsEl,this._searchBtn,this._titleEl,this._endButtonsEl,this._menuBtn),this._searchBar=document.createElement(`div`),this._searchBar.className=`adw-search-bar overview-search-bar`,this._searchClamp=document.createElement(`div`),this._searchClamp.className=`adw-clamp overview-search-clamp`,this._searchEntry=document.createElement(`input`),this._searchEntry.type=`search`,this._searchEntry.className=`adw-entry overview-search-entry`,this._searchEntry.placeholder=`Search tabs`,this._searchEntry.setAttribute(`aria-label`,`Search tabs`),this._searchClamp.appendChild(this._searchEntry),this._searchBar.appendChild(this._searchClamp);let e=document.createElement(`div`);e.className=`adw-tab-overview-content`;let t=document.createElement(`div`);t.className=`adw-tab-overview-scroll`,this._pinnedGridEl=this._createGrid(`adw-tab-grid pinned-grid`,`Pinned tabs`),this._gridEl=this._createGrid(`adw-tab-grid`,`Open tabs`),t.append(this._pinnedGridEl,this._gridEl),this._emptyState=document.createElement(`adw-status-page`),this._emptyState.className=`overview-empty-state`,this._emptyState.setAttribute(`icon`,`view-grid`),this._emptyState.setAttribute(`title`,`No Open Tabs`),this._emptyState.hidden=!0,this._searchEmptyState=document.createElement(`adw-status-page`),this._searchEmptyState.className=`overview-search-empty-state`,this._searchEmptyState.setAttribute(`icon`,`system-search`),this._searchEmptyState.setAttribute(`title`,`No Tabs Found`),this._searchEmptyState.setAttribute(`description`,`Try a different search`),this._searchEmptyState.hidden=!0,this._newTabBtn=document.createElement(`button`),this._newTabBtn.type=`button`,this._newTabBtn.className=`adw-button pill suggested-action new-tab-button`,this._newTabBtn.append(createGtkImage(`list-add`,`new-tab-button-icon`),document.createTextNode(`New Tab`)),e.append(t,this._emptyState,this._searchEmptyState,this._newTabBtn),this._overviewEl.append(this._headerEl,this._searchBar,e);let n=Array.from(this.children);this.replaceChildren(this._childEl,this._overviewEl);for(let e of n)this._childEl.appendChild(e);this._searchEntry.addEventListener(`input`,()=>this._onSearchChanged()),this._searchEntry.addEventListener(`keydown`,e=>this._onSearchKeyDown(e)),this._searchBtn.addEventListener(`click`,()=>this._toggleSearchMode()),this._newTabBtn.addEventListener(`click`,()=>this._requestCreateTab()),this.addEventListener(`keydown`,e=>this._onKeyDown(e));let r=this.getAttribute(`view`);this.setView(r===null?this._findView():this._resolveView(r)),r!==null&&this.removeAttribute(`view`);let i=this.getAttribute(`secondary-menu`);i!==null&&(this.secondaryMenu=JSON.parse(i),this.removeAttribute(`secondary-menu`)),this._applyOpen(),this._syncAll()}disconnectedCallback(){this._unbindView()}attributeChangedCallback(e,t,n){if(this._initialized)switch(e){case`view`:this.setView(n===null?this._findView():this._resolveView(n));return;case`open`:this._reflecting||this._applyOpen();return;case`secondary-menu`:if(n===null)return;try{this.secondaryMenu=JSON.parse(n)}catch(e){console.error(`<adw-tab-overview secondary-menu> is not valid JSON: ${String(e)}`)}return;case`enable-new-tab`:this._applyNewTabButton();return;case`inverted`:this._syncGrids();return;case`enable-search`:case`show-start-title-buttons`:case`show-end-title-buttons`:this._applyHeaderBar();return}}_resolveView(e){return document.getElementById(e)??this._findView()}_findView(){return this.querySelector(`adw-tab-view`)}_bindView(){this._unbindView();for(let e of xi)this._view?.addEventListener(e,this._onViewChange)}_unbindView(){for(let e of xi)this._view?.removeEventListener(e,this._onViewChange)}_onViewChange=()=>{this._syncAll()};_syncAll(){this._applyTitle(),this._syncGrids(),this._applyEmptyStates(),this._applyNewTabButton(),this._applyHeaderBar()}_applyTitle(){let e=this._view;this._titleEl.textContent=e===null?``:e.nPages===1?`1 Tab`:`${e.nPages} Tabs`}_syncGrids(){let e=this._view,t=this._searchActive?this._searchEntry.value:``,n=new Set,r=[],i=[];if(e!==null)for(let a of e.pages){if(!tabSearchMatches(a,t)){this._thumbs.get(a.id)?.root.remove(),this._thumbs.delete(a.id);continue}n.add(a.id);let e=this._thumbFor(a.id);this._refreshThumb(e,a),(a.pinned?r:i).push(e.root)}for(let[e,t]of this._thumbs)n.has(e)||(t.root.remove(),this._thumbs.delete(e));this._pinnedGridEl.replaceChildren(...r),this._gridEl.replaceChildren(...i),this._pinnedGridEl.hidden=r.length===0}_applyEmptyStates(){let e=this._pinnedGridEl.childElementCount===0&&this._gridEl.childElementCount===0;this._emptyState.hidden=!(e&&!this._searchActive),this._searchEmptyState.hidden=!(e&&this._searchActive)}_applyNewTabButton(){this._newTabBtn.hidden=!(this.enableNewTab&&!this._searchActive)}_applyHeaderBar(){let e=this._model.length>0;this._headerEl.hidden=!(this.enableSearch||e||this.showStartTitleButtons||this.showEndTitleButtons),this._startButtonsEl.hidden=!this.showStartTitleButtons,this._endButtonsEl.hidden=!this.showEndTitleButtons,this._searchBtn.hidden=!this.enableSearch,this._searchBar.hidden=!this.enableSearch||!this._searchMode,this._menuBtn.hidden=!e}_applyMenu(){let e=this._menuBtn;this._model.length>0&&(e.menuModel=this._model),this._applyHeaderBar()}_applyOpen(){let e=this.open;this._overviewEl.hidden=!e,this._childEl.classList.toggle(`background`,e),this._childEl.inert=e,e!==this._appliedOpen&&(this._appliedOpen=e,this._reflecting=!0,e?this.hasAttribute(`open`)||this.setAttribute(`open`,``):this.hasAttribute(`open`)&&(this._searchMode=!1,this._setSearchActive(!1),this._searchEntry.value=``,this.removeAttribute(`open`)),this._reflecting=!1,this.dispatchEvent(new CustomEvent(`notify::open`,{bubbles:!0,detail:{open:e}})))}setOpen(e){this.open!==e&&(this._reflecting=!0,this.toggleAttribute(`open`,e),this._reflecting=!1,this._applyOpen(),e&&this._syncAll())}_searchMode=!1;_toggleSearchMode(){this._searchMode=!this._searchMode,this._searchBar.hidden=!this.enableSearch||!this._searchMode,this._searchMode?this._searchEntry.focus():this._stopSearch()}_onSearchChanged(){this._setSearchActive(this._searchEntry.value!==``),this._syncGrids(),this._applyEmptyStates(),this._applyNewTabButton()}_stopSearch(){this._searchEntry.value=``,this._setSearchActive(!1),this._syncGrids(),this._applyEmptyStates(),this._applyNewTabButton()}_setSearchActive(e){e!==this._searchActive&&(this._searchActive=e,this.dispatchEvent(new CustomEvent(`notify::search-active`,{bubbles:!0,detail:{searchActive:e}})))}_onSearchKeyDown(e){if(e.key===`Escape`){this._stopSearch(),this._searchMode=!1,this._searchBar.hidden=!this.enableSearch||!this._searchMode;return}e.key===`Enter`&&this._searchActive&&(this._focusFirstRow(this._pinnedGridEl)||this._focusFirstRow(this._gridEl))&&e.preventDefault()}_onKeyDown(e){if(!this.open)return;let t=e.target;if(t instanceof Node&&!this._onGridKey(e,t)&&!(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)){if(e.key===`ArrowDown`){if(this._searchBar.contains(t)||this._searchBtn.contains(t)){(this._focusFirstRow(this._pinnedGridEl)||this._focusFirstRow(this._gridEl))&&e.preventDefault();return}if(this._menuBtn.contains(t)){(this._focusLastRow(this._pinnedGridEl)||this._focusLastRow(this._gridEl))&&e.preventDefault();return}if(this._newTabBtn.contains(t))return;(this._gridEl.contains(t)||this._pinnedGridEl.contains(t))&&this._newTabBtn.hidden===!1&&(e.preventDefault(),this._newTabBtn.focus());return}this._newTabBtn.contains(t)&&(this._focusLastRow(this._gridEl)||this._focusLastRow(this._pinnedGridEl))&&e.preventDefault()}}_onGridKey(e,t){if(e.altKey||e.ctrlKey||e.metaKey)return!1;let n=[this._pinnedGridEl,this._gridEl].find(e=>e.contains(t));if(n===void 0)return!1;let r=[...n.children].filter(e=>e instanceof HTMLElement),i=r.findIndex(e=>e.contains(t));if(i<0||t instanceof Element&&t.closest(`button`)!==null)return!1;let a=this._view;if(a===null)return!1;if(e.key===`Enter`||e.key===` `){let t=r[i].dataset.pageId;return t===void 0?!1:(e.preventDefault(),a.setSelectedPage(t),this.setOpen(!1),!0)}let o=gridColumns(r.map(e=>e.getBoundingClientRect().top)),s=gridNavigate(e.key,i,r.length,o);if(s===null){let t=[`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key);return t&&e.preventDefault(),t}let c=r[s].dataset.pageId;return c===void 0?!1:(e.preventDefault(),a.setSelectedPage(c),r[s].focus(),!0)}_focusFirstRow(e){let t=e.querySelector(`.adw-tab-thumbnail`);return t===null?!1:(t.focus(),!0)}_focusLastRow(e){let t=e.querySelectorAll(`.adw-tab-thumbnail`),n=t[t.length-1];return n===void 0?!1:(n.focus(),!0)}_requestCreateTab(){let e=this._view;if(e===null)return;let t={page:null};if(this.dispatchEvent(new CustomEvent(`create-tab`,{bubbles:!0,detail:t})),t.page===null){console.error("<adw-tab-overview>: the create-tab handler must not leave `detail.page` unset.");return}e.setSelectedPage(t.page.id),this.setOpen(!1),t.page.content?.focus?.()}_createGrid(e,t){let n=document.createElement(`div`);return n.className=e,n.setAttribute(`role`,`grid`),n.setAttribute(`aria-label`,t),n}_thumbFor(e){let t=this._thumbs.get(e);if(t!==void 0)return t;let n=document.createElement(`div`);n.className=`adw-tab-thumbnail`,n.dataset.pageId=e,n.setAttribute(`role`,`gridcell`),n.tabIndex=-1;let r=document.createElement(`div`);r.className=`contents`;let i=document.createElement(`div`);i.className=`thumbnail`;let a=document.createElement(`div`);a.className=`card`;let o=document.createElement(`div`);o.className=`picture`;let s=document.createElement(`span`);s.className=`picture-portrait`,o.appendChild(s);let c=document.createElement(`button`);c.type=`button`,c.className=`tab-close-button adw-button image-button`,c.title=`Close Tab`,c.setAttribute(`aria-label`,`Close Tab`),c.tabIndex=-1,c.appendChild(createGtkImage(`window-close`,`tab-close-icon`));let l=document.createElement(`button`);l.type=`button`,l.className=`tab-unpin-icon`,l.tabIndex=-1,l.title=`Unpin Tab`,l.setAttribute(`aria-label`,`Unpin Tab`),l.dataset.iconName=`adw-tab-unpin-symbolic`;let u=document.createElement(`button`);u.type=`button`,u.className=`tab-indicator adw-button image-button`,u.tabIndex=-1;let d=createGtkImage(null,`tab-indicator-icon`);u.appendChild(d),a.append(o,c,l,u);let f=document.createElement(`div`);f.className=`needs-attention`;let p=document.createElement(`div`);p.className=`gizmo`,f.appendChild(p),i.append(a,f);let m=document.createElement(`div`);m.className=`icon-title-box`;let g=createGtkImage(null,`tab-icon`),_=document.createElement(`span`);_.className=`tab-label`,m.append(g,_),r.append(i,m),n.appendChild(r),n.addEventListener(`click`,()=>{let t=this._view;t!==null&&(t.setSelectedPage(e),this.setOpen(!1))}),n.addEventListener(`auxclick`,t=>{t.button===1&&(t.preventDefault(),this._view?.closePage(e))}),c.addEventListener(`click`,t=>{t.stopPropagation(),this._view?.closePage(e)}),l.addEventListener(`click`,t=>{t.stopPropagation(),this._view?.setPagePinned(e,!1)}),u.addEventListener(`click`,t=>{t.stopPropagation(),this._view?.dispatchEvent(new CustomEvent(`indicator-activated`,{bubbles:!0,detail:{id:e}}))});let ee={root:n,label:_,icon:g,spinner:null,picture:o,portrait:s,closeBtn:c,unpinIcon:l,indicatorBtn:u,indicatorIcon:d,attention:f};return this._thumbs.set(e,ee),ee}_refreshThumb(e,t){if(e.root.title=tabTooltip(t),e.root.setAttribute(`aria-label`,tabTooltip(t)),e.icon.hidden=t.icon===null&&!t.loading,e.root.classList.toggle(`loading`,t.loading),t.loading&&e.spinner===null){let t=document.createElement(`adw-spinner`);t.className=`tab-spinner`,t.setAttribute(`size`,String(bi)),e.icon.replaceWith(t),e.spinner=t}else!t.loading&&e.spinner!==null&&(e.spinner.replaceWith(e.icon),e.spinner=null);e.indicatorBtn.hidden=t.indicatorIcon===null,e.indicatorIcon.iconName=t.indicatorIcon,e.attention.hidden=!t.needsAttention,e.root.classList.toggle(`inverted`,this.inverted),e.closeBtn.hidden=t.pinned,e.unpinIcon.hidden=!t.pinned,e.label.textContent=t.title,e.portrait.textContent=t.title;let n=this._view?.selectedId===t.id;e.root.classList.toggle(`selected`,n),e.root.setAttribute(`aria-selected`,String(n))}};const bi=`16`,xi=[`page-attached`,`page-detached`,`page-reordered`,`page-pinned`,`page-updated`,`notify::selected-page`];customElements.define(`adw-tab-overview`,AdwTabOverview);const Si=[`title`,`tooltip`,`icon`,`indicator-icon`,`keyword`,`loading`,`needs-attention`,`pinned`];var AdwTabPage=class extends WidgetElement{static get observedAttributes(){return Si}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}])}attributeChangedCallback(e,t,n){let r=this.closest(`adw-tab-view`);r instanceof AdwTabView&&r.syncDeclaredPage(this,e,n)}},AdwTabView=class extends WidgetElement{_state=new TabViewState({onClosePage:e=>this._requestClose(e)});_barEl;_tabBoxEl;_pagesEl;_tabs=new Map;_chips=new Map;_panels=new Map;_hovered=new Set;_initialized=!1;_generatedIds=0;_reflecting=!1;static get observedAttributes(){return[`selected-page`,`autohide`,`expand-tabs`,`no-close`]}constructor(){super(),this._barEl=document.createElement(`div`),this._barEl.className=`adw-tab-bar`,this._barEl.setAttribute(`role`,`tablist`),this._tabBoxEl=document.createElement(`div`),this._tabBoxEl.className=`adw-tab-box`,this._barEl.appendChild(this._tabBoxEl),this._pagesEl=document.createElement(`div`),this._pagesEl.className=`adw-tab-view-pages`,this._state.subscribePages(e=>this._onPagesChange(e)),this._state.subscribe(e=>this._onSelectionChange(e))}get selectedPage(){return this._state.selectedPage}set selectedPage(e){this._state.setSelectedPage(e)}get autohide(){return this.hasAttribute(`autohide`)}set autohide(e){e?this.setAttribute(`autohide`,``):this.removeAttribute(`autohide`)}get expandTabs(){return this.hasAttribute(`expand-tabs`)}set expandTabs(e){e?this.setAttribute(`expand-tabs`,``):this.removeAttribute(`expand-tabs`)}get noClose(){return this.hasAttribute(`no-close`)}set noClose(e){e?this.setAttribute(`no-close`,``):this.removeAttribute(`no-close`)}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=this.getAttribute(`selected-page`),t=Array.from(this.children);this.replaceChildren(this._barEl,this._pagesEl);for(let e of t)e.localName===`adw-tab-page`?this._adoptDeclaredPage(e):this.appendPage({id:this._nextId(),content:e});e!==null&&this._applySelectedAttribute(e),this._applyBarVisibility(),this._reflectSelected(),this.addEventListener(`keydown`,e=>this._onKeyDown(e))}attributeChangedCallback(e,t,n){if(this._initialized){if(e===`selected-page`){if(this._reflecting)return;let e=this.getAttribute(`selected-page`);e!==null&&this._applySelectedAttribute(e);return}this._applyBarVisibility()}}syncDeclaredPage(e,t,n){let r=e.dataset.pageId;if(r!==void 0)switch(t){case`title`:this._state.setPageTitle(r,n);return;case`tooltip`:this._state.setPageTooltip(r,n);return;case`icon`:this._state.setPageIcon(r,n);return;case`indicator-icon`:this._state.setPageIndicatorIcon(r,n);return;case`keyword`:this._state.setPageKeyword(r,n);return;case`loading`:this._state.setPageLoading(r,n!==null);return;case`needs-attention`:this._state.setPageNeedsAttention(r,n!==null);return;case`pinned`:this._state.setPagePinned(r,n!==null);return}}get pages(){return this._state.pages}get nPages(){return this._state.nPages}get nPinnedPages(){return this._state.nPinnedPages}get selectedId(){return this._state.selectedId}get selectedIndex(){return this._state.selectedIndex}get selectedContent(){return this._state.selectedPage?.content??null}isClosing(e){return this._state.isClosing(e)}setSelectedPage(e){return this._state.setSelectedPage(e)}selectNthPage(e){return this._state.selectNthPage(e)}selectPreviousPage(){return this._state.selectPreviousPage()}selectNextPage(){return this._state.selectNextPage()}selectFirstPage(){return this._state.selectFirstPage()}selectLastPage(){return this._state.selectLastPage()}cycleNextPage(){return this._state.cycleNextPage()}cyclePreviousPage(){return this._state.cyclePreviousPage()}addPage(e,t=null){return this._state.addPage(this._withPanel(e),t)}insertPage(e,t){return this._state.insertPage(this._withPanel(e),t)}prependPage(e){return this._state.prependPage(this._withPanel(e))}appendPage(e){return this._state.appendPage(this._withPanel(e))}insertPinnedPage(e,t){return this._state.insertPinnedPage(this._withPanel(e),t)}prependPinnedPage(e){return this._state.prependPinnedPage(this._withPanel(e))}appendPinnedPage(e){return this._state.appendPinnedPage(this._withPanel(e))}setPagePinned(e,t){return this._state.setPagePinned(e,t)}closePage(e){return this._state.closePage(e)}closePageFinish(e,t){return this._state.closePageFinish(e,t)}closeOtherPages(e){this._state.closeOtherPages(e)}closePagesBefore(e){this._state.closePagesBefore(e)}closePagesAfter(e){this._state.closePagesAfter(e)}detachPage(e){return this._state.detachPage(e)}reorderPage(e,t){return this._state.reorderPage(e,t)}reorderBackward(e){return this._state.reorderBackward(e)}reorderForward(e){return this._state.reorderForward(e)}reorderFirst(e){return this._state.reorderFirst(e)}reorderLast(e){return this._state.reorderLast(e)}setPageTitle(e,t){return this._state.setPageTitle(e,t)}setPageTooltip(e,t){return this._state.setPageTooltip(e,t)}setPageKeyword(e,t){return this._state.setPageKeyword(e,t)}setPageIcon(e,t){return this._state.setPageIcon(e,t)}setPageIndicatorIcon(e,t){return this._state.setPageIndicatorIcon(e,t)}setPageLoading(e,t){return this._state.setPageLoading(e,t)}setPageNeedsAttention(e,t){return this._state.setPageNeedsAttention(e,t)}get diagnostics(){return this._state.diagnostics}_adoptDeclaredPage(e){let t={id:e.getAttribute(`page-id`)??this._nextId(),title:e.getAttribute(`title`),tooltip:e.getAttribute(`tooltip`),icon:e.getAttribute(`icon`),indicatorIcon:e.getAttribute(`indicator-icon`),loading:e.hasAttribute(`loading`),needsAttention:e.hasAttribute(`needs-attention`),content:e};e.hasAttribute(`pinned`)?this.appendPinnedPage(t):this.appendPage(t)}_withPanel(e){let t=e.content??document.createElement(`adw-tab-page`);return t.classList.add(`adw-tab-page`),t.setAttribute(`role`,`tabpanel`),t.dataset.pageId=e.id,{...e,content:t}}_nextId(){return this._generatedIds+=1,`tab-${this._generatedIds}`}_onPagesChange(e){switch(e.kind){case`attached`:{let t=this._state.getPage(e.id);t&&this._insertTab(t,e.position);break}case`detached`:this._tabs.get(e.id)?.remove(),this._tabs.delete(e.id),this._chips.delete(e.id),this._hovered.delete(e.id),this._panels.get(e.id)?.remove(),this._panels.delete(e.id);break;case`reordered`:case`pinned`:this._moveTab(e.id,e.position),this._refreshTab(e.id);break;case`updated`:this._refreshTab(e.id);break}this._applyBarVisibility(),this._applyActiveState(),this.dispatchEvent(new CustomEvent(`page-${e.kind}`,{bubbles:!0,detail:{id:e.id,position:e.position,previousPosition:e.previousPosition}}))}_insertTab(e,t){let n=createTabChip({onSelect:()=>this._state.setSelectedPage(e.id),onClose:()=>this._state.closePage(e.id),onHover:t=>{t?this._hovered.add(e.id):this._hovered.delete(e.id),this._refreshCloseVisibility(e.id)}});n.el.dataset.pageId=e.id,n.close.tabIndex=-1,this._tabBoxEl.insertBefore(n.el,this._tabBoxEl.children[t]??null),this._tabs.set(e.id,n.el),this._chips.set(e.id,n);let r=e.content;r&&(this._panels.set(e.id,r),this._pagesEl.insertBefore(r,this._pagesEl.children[t]??null)),this._refreshTab(e.id)}_moveTab(e,t){let n=this._tabs.get(e);n&&(n.remove(),this._tabBoxEl.insertBefore(n,this._tabBoxEl.children[t]??null));let r=this._panels.get(e);r&&(r.remove(),this._pagesEl.insertBefore(r,this._pagesEl.children[t]??null))}_refreshTab(e){let t=this._state.getPage(e),n=this._tabs.get(e);!t||!n||(refreshTabChip(this._chips.get(e),t,this.getAttribute(`default-icon`)),this._refreshCloseVisibility(e))}_refreshCloseVisibility(e){let t=this._state.getPage(e),n=this._chips.get(e);!t||!n||refreshTabChipClose(this._barEl,n,t,{hovering:this._hovered.has(e),selected:this._state.selectedId===e})}_onSelectionChange(e){this._applyActiveState(),this._scrollSelectedTabIntoBar(),this._reflectSelected(),this.dispatchEvent(new CustomEvent(`notify::selected-page`,{bubbles:!0,detail:{selected:e.selectedIndex,selectedId:e.selectedId,previousId:e.previousId,interactive:e.interactive}}))}_applyActiveState(){let e=this._state.selectedId;for(let t of this._state.pages){let n=t.id===e,r=this._tabs.get(t.id);r&&(r.classList.toggle(`active`,n),r.setAttribute(`aria-selected`,String(n)),r.tabIndex=n?0:-1);let i=t.content;i&&(i.classList.toggle(`active-page`,n),i.hidden=!n),this._refreshCloseVisibility(t.id)}}_scrollSelectedTabIntoBar(){let e=this._state.selectedId,t=e===null?void 0:this._tabs.get(e);t&&scrollChipIntoBar(this._barEl,t)}_applyBarVisibility(){let e=tabsRevealed({autohide:this.autohide,nPages:this._state.nPages,nPinnedPages:this._state.nPinnedPages,isTransferringPage:!1});this._barEl.hidden=!e,this._barEl.classList.toggle(`single-tab`,this._state.nPages<=1)}_reflectSelected(){this._reflecting=!0;let e=this._state.selectedId;e===null?this.removeAttribute(`selected-page`):this.getAttribute(`selected-page`)!==e&&this.setAttribute(`selected-page`,e),this._reflecting=!1}_applySelectedAttribute(e){this._state.setSelectedPage(e)}_onKeyDown(e){let t=e.target instanceof Node&&this._barEl.contains(e.target),n=!1;if(e.ctrlKey&&e.key===`Tab`)n=e.shiftKey?this._state.cyclePreviousPage():this._state.cycleNextPage();else if(e.ctrlKey&&e.shiftKey&&(e.key===`PageUp`||e.key===`PageDown`)){let t=this._state.selectedId;t!==null&&(n=e.key===`PageUp`?this._state.reorderBackward(t):this._state.reorderForward(t))}else if(e.ctrlKey&&e.shiftKey&&(e.key===`Home`||e.key===`End`)){let t=this._state.selectedId;t!==null&&(n=e.key===`Home`?this._state.reorderFirst(t):this._state.reorderLast(t))}else if(e.ctrlKey&&(e.key===`PageUp`||e.key===`PageDown`))n=e.key===`PageUp`?this._state.selectPreviousPage():this._state.selectNextPage();else if(e.ctrlKey&&(e.key===`Home`||e.key===`End`))n=e.key===`Home`?this._state.selectFirstPage():this._state.selectLastPage();else if(e.altKey&&/^[0-9]$/.test(e.key)){let t=Number.parseInt(e.key,10);n=this._state.selectNthPage(t===0?9:t-1)}else t&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)?n=e.key===`ArrowLeft`?this._state.selectPreviousPage():this._state.selectNextPage():t&&(e.key===`Home`||e.key===`End`)&&(n=e.key===`Home`?this._state.selectFirstPage():this._state.selectLastPage());if(n&&(e.preventDefault(),t)){let e=this._state.selectedId;e!==null&&this._tabs.get(e)?.focus({preventScroll:!0})}}_requestClose(e){return this.dispatchEvent(new CustomEvent(`close-page`,{bubbles:!0,cancelable:!0,detail:{index:this._state.getPagePosition(e.id),id:e.id}}))?!e.pinned:`defer`}};customElements.define(`adw-tab-view`,AdwTabView),customElements.define(`adw-tab-page`,AdwTabPage);var AdwToggle=class extends WidgetElement{static get observedAttributes(){return[`label`,`icon-name`,`tooltip`,`enabled`]}attributeChangedCallback(e,t,n){e===`enabled`&&t!==n&&this.dispatchEvent(new CustomEvent(`toggle-enabled-changed`,{bubbles:!0,composed:!0,detail:{enabled:n!==`false`}}))}},AdwToggleGroup=class extends WidgetElement{_innerEl;_buttons=[];_state=new ToggleGroupState;_initialized=!1;_stateAttr=`aria-checked`;_names=[];_enabled=[];_toggles=[];static get observedAttributes(){return[`active`,`active-name`,`flat`,`round`,`sensitive`]}get sensitive(){return booleanAttribute$2(this.getAttribute(`sensitive`),!0)}set sensitive(e){this.setAttribute(`sensitive`,e?`true`:`false`)}isToggleEnabled(e){return this._enabled[e]??!1}get active(){return this._state.selected}set active(e){this.setAttribute(`active`,String(e))}get activeName(){return this._names[this._state.selected]??null}set activeName(e){e===null?this.removeAttribute(`active-name`):this.setAttribute(`active-name`,e)}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=Array.from(this.querySelectorAll(`adw-toggle`)),t=keptToggles(e.map(e=>({el:e,name:e.getAttribute(`name`)}))).map(e=>e.el);t.length<e.length&&console.warn(`[adw-toggle-group] a toggle name already exists; the later toggle is not added`);let n=this.getAttribute(`role`)?.trim()||null;n===null&&this.setAttribute(`role`,`radiogroup`);let r=n===`tablist`,i=r?`tab`:`radio`;this._stateAttr=r?`aria-selected`:`aria-checked`,this._innerEl=document.createElement(`div`),this._innerEl.className=`adw-toggle-group-inner`,this._innerEl.setAttribute(`role`,`none`),this._toggles=t,this._buttons=t.map((e,t)=>{let n=document.createElement(`button`);n.type=`button`,n.className=`adw-toggle`,n.setAttribute(`role`,i),this._enabled[t]=booleanAttribute$2(e.getAttribute(`enabled`),!0);let r=e.getAttribute(`label`)??``,a=e.getAttribute(`icon-name`)??``,o=e.getAttribute(`tooltip`)??``;return a&&n.appendChild(createGtkImage(a)),r&&n.appendChild(document.createTextNode(r)),n.title=o,!r&&o?n.setAttribute(`aria-label`,o):a&&!r&&n.setAttribute(`aria-label`,a),n.addEventListener(`click`,()=>this._selectIndex(t)),n}),this._innerEl.append(...this._buttons),this.replaceChildren(this._innerEl);for(let e=0;e<this._toggles.length;e++)this._toggles[e].addEventListener(`toggle-enabled-changed`,t=>{let{enabled:n}=t.detail;this._enabled[e]!==n&&(this._enabled[e]=n,this._render())});this._state.setLabels(t.map(e=>e.getAttribute(`label`)||e.getAttribute(`icon-name`)||``)),this._names=t.map(e=>e.getAttribute(`name`)),this._state.subscribe(()=>this._render()),this._state.setSelected(this._readActiveAttr()),this._applyActiveName(),this._render(),attachRovingFocus({host:this,orientation:`horizontal`,items:()=>this._buttons.filter(e=>!e.disabled),select:e=>this._selectIndex(this._buttons.findIndex(t=>t===e))})}attributeChangedCallback(e){if(this._initialized){if(e===`active`){this._state.setSelected(this._readActiveAttr());return}if(e===`active-name`){this._applyActiveName();return}this._render()}}_applyActiveName(){let e=this.getAttribute(`active-name`);if(e===null)return;let t=toggleIndexOfName(this._names,e);t!==-1&&this._state.setSelected(t)}_readActiveAttr(){let e=Number.parseInt(this.getAttribute(`active`)??`0`,10);if(Number.isNaN(e))return 0;let t=Math.max(0,this._state.count-1);return Math.min(Math.max(e,0),t)}_selectIndex(e){this._enabled[e]&&this._state.setSelected(e)&&(this.setAttribute(`active`,String(e)),this.dispatchEvent(new CustomEvent(`notify::active`,{bubbles:!0,detail:{active:e}})))}_render(){this.classList.toggle(`flat`,this.hasAttribute(`flat`)),this.classList.toggle(`round`,this.hasAttribute(`round`));let e=this._state.selected,t=this.sensitive;this.toggleAttribute(`disabled`,!t),this._buttons.forEach((n,r)=>{let i=r===e;n.classList.toggle(`active`,i),n.setAttribute(this._stateAttr,String(i)),n.disabled=!t||!this._enabled[r],n.tabIndex=i?0:-1}),this._enabled[e]||this._activateFirstEnabled()}_activateFirstEnabled(){let e=this._enabled.findIndex(e=>e);e!==-1&&(this._state.setSelected(e),this.setAttribute(`active`,String(e)),this.dispatchEvent(new CustomEvent(`notify::active`,{bubbles:!0,detail:{active:e}})))}};customElements.define(`adw-toggle`,AdwToggle),customElements.define(`adw-toggle-group`,AdwToggleGroup);var AdwToolbarView=class extends WidgetElement{_topEl;_contentEl;_bottomEl;_initialized=!1;_resize=null;_shading=null;static get observedAttributes(){return[`top-bar-style`,`bottom-bar-style`,`extend-content-to-top-edge`,`extend-content-to-bottom-edge`]}get topBar(){return this._topEl}get contentArea(){return this._contentEl}get bottomBar(){return this._bottomEl}connectedCallback(){this._initialized||(this._initialized=!0,this._topEl=document.createElement(`div`),this._topEl.className=`adw-toolbar-view-top`,this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-toolbar-view-content`,this._bottomEl=document.createElement(`div`),this._bottomEl.className=`adw-toolbar-view-bottom`,bindSlottedChildren(this,[{name:`top`,into:this._topEl},{name:`bottom`,into:this._bottomEl},{name:`content`,into:this._contentEl},{into:this._contentEl}]).install(this._topEl,this._contentEl,this._bottomEl),bindEmptySections(this._topEl,this._bottomEl)),this._shading=new AdwScrollShading(this._contentEl),this._shading.connect(),this._resize=new ResizeObserver(()=>this._syncClasses()),this._resize.observe(this._topEl),this._resize.observe(this._bottomEl),this._syncClasses()}disconnectedCallback(){this._resize?.disconnect(),this._resize=null,this._shading?.disconnect(),this._shading=null}attributeChangedCallback(){this._initialized&&this._syncClasses()}_syncClasses(){let{view:e,topBar:t,bottomBar:n}=toolbarViewClasses({topBarStyle:parseToolbarStyle(this.getAttribute(`top-bar-style`)),bottomBarStyle:parseToolbarStyle(this.getAttribute(`bottom-bar-style`)),extendContentToTopEdge:this.hasAttribute(`extend-content-to-top-edge`),extendContentToBottomEdge:this.hasAttribute(`extend-content-to-bottom-edge`),topBarHeight:this._topEl.offsetHeight,bottomBarHeight:this._bottomEl.offsetHeight});for(let t of wt)this.classList.toggle(t,e.includes(t));for(let e of Tt)this._topEl.classList.toggle(e,t.includes(e)),this._bottomEl.classList.toggle(e,n.includes(e));this._shading?.setUndershootEdges({top:e.includes(`undershoot-top`),bottom:e.includes(`undershoot-bottom`)})}};customElements.define(`adw-toolbar-view`,AdwToolbarView);var AdwViewStack=class extends WidgetElement{static signals={"notify::visible-child":`notify::visible-child`,"notify::visible-child-name":`notify::visible-child-name`};_state=new ViewStackState;_initialized=!1;static get observedAttributes(){return[`visible-child-name`]}constructor(){super(),this._state.subscribe(e=>this._onStateChange(e)),new MutationObserver(e=>this._onChildrenRemoved(e)).observe(this,{childList:!0})}get pages(){return this._state.pages}get visibleChildIndex(){return this._state.visibleIndex}selectNthPage(e){return this._state.setVisibleIndex(e)}get visibleChildName(){return this._state.visibleName}set visibleChildName(e){this._state.setVisibleName(e)}get visibleChild(){return this._state.visiblePage?.content??null}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=this.getAttribute(`visible-child-name`);for(let e of Array.from(this.querySelectorAll(`:scope > adw-view-stack-page`))){let t=e.getAttribute(`name`)??``,n=document.createElement(`div`);n.className=`adw-view-stack-child`,n.dataset.name=t;for(let t of Array.from(e.childNodes))n.appendChild(t);this._state.addPage({name:t,title:e.getAttribute(`title`),icon:e.getAttribute(`icon-name`),content:n,visible:!e.hasAttribute(`hidden`),badgeNumber:e.hasAttribute(`badge-number`)?Number.parseInt(e.getAttribute(`badge-number`)??`0`,10):0,needsAttention:e.hasAttribute(`needs-attention`),useUnderline:e.hasAttribute(`use-underline`),startsSection:e.hasAttribute(`starts-section`),sectionTitle:e.getAttribute(`section-title`)}),this.replaceChild(n,e)}e!==null&&this._state.setVisibleName(e,!1),this._applyVisibility(),this._reflectName(),this._emitItemsChanged()}attributeChangedCallback(e,t,n){this._initialized&&e===`visible-child-name`&&n!==null&&n!==this._state.visibleName&&this._state.setVisibleName(n)}add(e,t,n,r){e.classList.add(`adw-view-stack-child`),e.dataset.name=t;let i=this._state.addPage({name:t,title:n,icon:r,content:e});return this.appendChild(e),this._applyVisibility(),this._reflectName(),this._emitItemsChanged(),i}addTitled(e,t,n){return this.add(e,t,n)}add_titled(e,t,n){return this.add(e,t,n)}add_named(e,t){return this.add(e,t??``)}add_titled_with_icon(e,t,n,r){return this.add(e,t,n,r)}remove(e){if(e===void 0){super.remove();return}let t=this._state.pages.find(t=>t.content===e);t&&this.removePage(t.name)}get_visible_child_name(){return this._state.visibleIndex<0?null:this._state.visibleName}set_visible_child_name(e){this._state.setVisibleName(e)}get_visible_child(){return this.visibleChild}set_visible_child(e){let t=this._state.pages.findIndex(t=>t.content===e);t!==-1&&this._state.setVisibleIndex(t)}removePage(e){let t=this._state.pages[this._state.indexOfName(e)]?.content;return this._state.removePage(e)?(t?.remove(),t&&clearPageMarks(t),this._applyVisibility(),this._reflectName(),this._emitItemsChanged(),!0):!1}setPageVisible(e,t){let n=this._state.setPageVisible(e,t);return this._applyVisibility(),this._emitItemsChanged(),n}_emitItemsChanged(){this.dispatchEvent(new CustomEvent(`items-changed`,{bubbles:!0,detail:{count:this.pages.length}}))}_onStateChange(e){this._applyVisibility(),this._reflectName(),this.dispatchEvent(new CustomEvent(`notify::visible-child`,{bubbles:!0,detail:{index:e.index,name:e.name,title:e.title,interactive:e.interactive}})),this.dispatchEvent(new CustomEvent(`notify::visible-child-name`,{bubbles:!0,detail:{"visible-child-name":e.name}}))}_onChildrenRemoved(e){let t=!1;for(let n of e)for(let e of n.removedNodes){if(!(e instanceof HTMLElement)||e.parentElement===this)continue;let n=this._state.pages.find(t=>t.content===e);n!==void 0&&(this._state.removePage(n.name),clearPageMarks(e),t=!0)}t&&(this._applyVisibility(),this._reflectName(),this._emitItemsChanged())}_applyVisibility(){let e=this._state.visibleIndex;this._state.pages.forEach((t,n)=>{let r=t.content;if(!r)return;let i=n===e;r.classList.toggle(`active-view`,i),r.hidden=!i})}_reflectName(){if(this._state.visibleIndex<0){this.removeAttribute(`visible-child-name`);return}let e=this._state.visibleName;this.getAttribute(`visible-child-name`)!==e&&this.setAttribute(`visible-child-name`,e)}};customElements.define(`adw-view-stack`,AdwViewStack);function clearPageMarks(e){e.classList.remove(`adw-view-stack-child`,`active-view`),delete e.dataset.name,e.hidden=!1}var AdwViewSwitcherPage=class extends WidgetElement{},AdwViewSwitcher=class extends WidgetElement{scheduler=ei;_stateInstance=null;get _state(){return this._stateInstance||(this._stateInstance=new ViewSwitcherState({scheduler:this.scheduler}),this._stateInstance.subscribe(e=>this._onStateChange(e))),this._stateInstance}_barEl;_contentEl;_nodes=[];_declared=[];_pageObserver;_policy=`narrow`;_initialized=!1;static get observedAttributes(){return[`policy`,`active`]}constructor(){super()}get policy(){return this._policy}set policy(e){this.setAttribute(`policy`,e)}get active(){return this._state.selected}set active(e){this._state.setSelected(e),this._reflectActive()}get visibleChildName(){return this._state.selectedName}set visibleChildName(e){this._state.selectName(e)}get pages(){return this._state.pages}setPageVisible(e,t){let n=this._state.setPageVisible(e,t);return this._render(),n}connectedCallback(){if(this._initialized){this._watchPages();return}let e=Array.from(this.querySelectorAll(`:scope > adw-view-switcher-page`)),t=this.getAttribute(`active`);if(this._barEl=document.createElement(`div`),this._barEl.className=`adw-view-switcher-bar`,this._barEl.setAttribute(`role`,`tablist`),attachRovingFocus({host:this,orientation:`horizontal`,items:()=>this._nodes.map(e=>e.button).filter(e=>!e.hidden),select:e=>{this._state.setSelected(Number(e.dataset.pageIndex))}}),this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-view-switcher-content`,this._declared=e,this._watchPages(),this._nodes=e.map((e,t)=>this._buildPage(e,t)),this._barEl.append(...this._nodes.map(e=>e.button)),this._contentEl.append(...this._nodes.map(e=>e.body)),this.replaceChildren(this._barEl,this._contentEl),this._policy=this._readPolicyAttr(),this._initialized=!0,this._state.setPages(e.map(e=>readSwitcherPage(e))),t!==null){let e=Number.parseInt(t,10);Number.isNaN(e)||this._state.setSelected(e,!1)}this._render()}disconnectedCallback(){this._state.cancelDrag(),this._pageObserver?.disconnect(),this._pageObserver=void 0}refreshPages(){this._initialized&&(this._state.setPages(this._declared.map(e=>readSwitcherPage(e))),this._render())}_watchPages(){this._pageObserver?.disconnect(),this._pageObserver=new MutationObserver(()=>this.refreshPages());for(let e of this._declared)this._pageObserver.observe(e,{attributes:!0})}attributeChangedCallback(e){if(this._initialized){if(e===`policy`){let e=this._readPolicyAttr();if(e===this._policy)return;this._policy=e,this._render(),this.dispatchEvent(new CustomEvent(`notify::policy`,{bubbles:!0,detail:{policy:e}}));return}if(e===`active`){let e=this.getAttribute(`active`),t=e===null?NaN:Number.parseInt(e,10);Number.isNaN(t)||this._state.setSelected(t),this._reflectActive()}}}_buildPage(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=`adw-view-switcher-button`,n.setAttribute(`role`,`tab`),n.dataset.pageIndex=String(t);let r=createGtkImage(null,`adw-view-switcher-icon`),i=document.createElement(`span`);i.className=`adw-view-switcher-label`;let a=document.createElement(`span`);a.className=`adw-view-switcher-indicator`,a.setAttribute(`aria-hidden`,`true`),n.append(r,i,a),n.addEventListener(`click`,()=>{this._state.setSelected(t)}),n.addEventListener(`dragenter`,e=>{n.contains(e.relatedTarget)||this._state.dragEnter(t)}),n.addEventListener(`dragleave`,e=>{n.contains(e.relatedTarget)||this._state.dragLeave(t)});let o=document.createElement(`div`);o.className=`adw-view-switcher-page`,o.dataset.name=e.getAttribute(`name`)??``;for(let t of Array.from(e.childNodes))o.appendChild(t);return{button:n,icon:r,label:i,indicator:a,body:o}}_readPolicyAttr(){let e=this.getAttribute(`policy`);return e===null?`narrow`:isViewSwitcherPolicy(e)?e:this._policy}_onStateChange(e){this._render(),this.dispatchEvent(new CustomEvent(`notify::visible-child`,{bubbles:!0,detail:{index:e.selected,name:e.name,title:e.title,interactive:e.interactive}}))}_render(){if(this._initialized){for(let e of qn)this.classList.toggle(e,e===this._policy);buildViewSwitcherButtons(this._state.pages,this._state.selected,this._policy).forEach((e,t)=>{let n=this._nodes[t];n&&(n.button.hidden=!e.visible,n.button.classList.toggle(`active`,e.selected),n.button.setAttribute(`aria-selected`,String(e.selected)),n.button.tabIndex=e.selected?0:-1,applySwitcherIcon(n.icon,e.iconName),n.label.textContent=e.label,n.label.hidden=e.label.length===0,applyIndicator(n.indicator,e.badgeLabel,e.needsAttention),applyDescription(n.button,e.description),e.label?n.button.removeAttribute(`aria-label`):n.button.setAttribute(`aria-label`,e.iconName),n.body.classList.toggle(`active-view`,e.selected),n.body.hidden=!e.selected)}),this._reflectActive()}}_reflectActive(){let e=String(this._state.selected);this.getAttribute(`active`)!==e&&this.setAttribute(`active`,e)}};customElements.define(`adw-view-switcher-page`,AdwViewSwitcherPage),customElements.define(`adw-view-switcher`,AdwViewSwitcher);var AdwViewSwitcherSidebar=class extends WidgetElement{_sidebar;_placeholderEl;_prefixEl;_suffixEl;_stack=null;_filter=null;_initialized=!1;static get observedAttributes(){return[`stack`,`mode`]}get stack(){return this._stack}set stack(e){this.setStack(e===null?null:typeof e==`string`?this._resolveStack(e):e)}setStack(e){e!==null&&this._stack!==e&&(this._unbindStack(),this._stack=e,this._bindStack(),this._populate(),this._syncSelection(),this.dispatchEvent(new CustomEvent(`notify::stack`,{bubbles:!0,detail:{stack:e}})))}get mode(){return this.getAttribute(`mode`)===`page`?`page`:`sidebar`}set mode(e){this.setAttribute(`mode`,e)}get filter(){return this._filter}set filter(e){this._filter=e,this._initialized&&(this._sidebar.filter=e,this._applyEmptyState())}get placeholder(){return this._placeholderEl.firstElementChild}set placeholder(e){e===null?this._placeholderEl.replaceChildren():this._placeholderEl.replaceChildren(e),this._applyEmptyState()}get prefixWidget(){return this._prefixEl.firstElementChild}set prefixWidget(e){e===null?this._prefixEl.replaceChildren():this._prefixEl.replaceChildren(e)}get suffixWidget(){return this._suffixEl.firstElementChild}set suffixWidget(e){e===null?this._suffixEl.replaceChildren():this._suffixEl.replaceChildren(e)}connectedCallback(){if(this._initialized){this._bindStack(),this._populate();return}this._initialized=!0,this._prefixEl=document.createElement(`div`),this._prefixEl.className=`view-switcher-sidebar-prefix`,this._suffixEl=document.createElement(`div`),this._suffixEl.className=`view-switcher-sidebar-suffix`,this._placeholderEl=document.createElement(`div`),this._placeholderEl.className=`view-switcher-sidebar-placeholder`,this._placeholderEl.hidden=!0,this._sidebar=document.createElement(`adw-sidebar`),this._sidebar.addEventListener(`activated`,this._onSidebarActivated);let e=document.createElement(`div`);e.className=`view-switcher-sidebar-box`,e.append(this._sidebar,this._placeholderEl),bindSlottedChildren(this,[{name:`placeholder`,into:this._placeholderEl},{name:`prefix`,into:this._prefixEl},{name:`suffix`,into:this._suffixEl}]).install(this._prefixEl,e,this._suffixEl),this._applyMode();let t=this.getAttribute(`stack`);this.setStack(t===null?this._findStack():this._resolveStack(t)),this._applyEmptyState()}disconnectedCallback(){this._unbindStack()}attributeChangedCallback(e,t,n){this._initialized&&(e===`stack`?this.setStack(n===null?this._findStack():this._resolveStack(n)):e===`mode`&&this._applyMode())}_resolveStack(e){return document.getElementById(e)??this._findStack()}_findStack(){return this.parentElement?.querySelector(`adw-view-stack`)??null}_bindStack(){this._unbindStack();for(let e of Ci)this._stack?.addEventListener(e,this._onStackChange)}_unbindStack(){for(let e of Ci)this._stack?.removeEventListener(e,this._onStackChange)}_onStackChange=()=>{this._populate(),this._syncSelection()};_onSidebarActivated=e=>{e.stopPropagation();let t=e.detail.index,n=this._stack;n!==null&&(n.selectNthPage(t),this.dispatchEvent(new CustomEvent(`activated`,{bubbles:!0,detail:{index:t}})))};_populate(){let e=this._stack;if(e===null){this._sidebar.sections=[],this._applyEmptyState();return}let t=viewSwitcherPagesFromStack(e.pages);this._sidebar.sections=viewSwitcherSidebarSections(t).map(e=>this._toSectionSpec(e)),this._applyEmptyState()}_toSectionSpec(e){let t=e.pages.map(e=>({title:e.title??``,iconName:e.iconName??``,visible:e.visible,badgeNumber:e.badgeNumber,needsAttention:e.needsAttention}));return{title:e.title,items:t}}_syncSelection(){let e=this._stack;if(e===null)return;let t=e.visibleChildIndex;t<0||this._sidebar.selected!==t&&(this._sidebar.selected=t)}_applyMode(){let e=this.mode===`page`;this.classList.toggle(`page`,e),this._sidebar.mode=this.mode}_applyEmptyState(){let e=this._sidebar.classList.contains(`empty`);this._placeholderEl.hidden=!e,this.classList.toggle(`empty`,e)}};const Ci=[`items-changed`,`notify::visible-child`];customElements.define(`adw-view-switcher-sidebar`,AdwViewSwitcherSidebar);var AdwViewSwitcherBar=class extends WidgetElement{_barState=new ViewSwitcherBarState;_barEl;_nodes=[];_stack=null;_initialized=!1;_onStackNotify=()=>this._rebuild();static get observedAttributes(){return[`stack`,`reveal`,`revealed`]}constructor(){super(),this._barState.subscribe(()=>this._applyRevealed())}get stack(){return this._stack}set stack(e){this.setStack(this._resolveStack(e))}get reveal(){return this._barState.reveal}set reveal(e){e?this.setAttribute(`reveal`,``):(this.removeAttribute(`reveal`),this.removeAttribute(`revealed`))}get revealed(){return this._barState.revealed}connectedCallback(){this._initialized||(this._initialized=!0,this._barEl=document.createElement(`div`),this._barEl.className=`adw-view-switcher-bar-box`,this._barEl.setAttribute(`role`,`tablist`),this.replaceChildren(this._barEl),attachRovingFocus({host:this,orientation:`horizontal`,items:()=>this._nodes.map(e=>e.button).filter(e=>!e.hidden),select:e=>{let t=this._stack;if(!t)return;let n=Number(e.dataset.pageIndex);t.visibleChildIndex!==n&&t.selectNthPage(n)}})),this._barState.setReveal(this._readReveal());let e=this.getAttribute(`stack`);if(e&&!this._stack){this.setStack(this._resolveStack(e));return}this._bindStack(),this._rebuild()}disconnectedCallback(){this._unbindStack()}attributeChangedCallback(e,t,n){if(this._initialized){if(e===`reveal`||e===`revealed`){this._barState.setReveal(this._readReveal());return}e===`stack`&&this.setStack(this._resolveStack(n))}}set_stack(e){this.setStack(e)}get_stack(){return this._stack}setStack(e){this._unbindStack(),this._stack=e,this._bindStack(),this._rebuild()}refresh(){this._rebuild()}_readReveal(){return this.hasAttribute(`reveal`)||this.hasAttribute(`revealed`)}_bindStack(){this._stack?.addEventListener(`notify::visible-child`,this._onStackNotify),this._stack?.addEventListener(`items-changed`,this._onStackNotify)}_unbindStack(){this._stack?.removeEventListener(`notify::visible-child`,this._onStackNotify),this._stack?.removeEventListener(`items-changed`,this._onStackNotify)}_resolveStack(e){return e===null?null:typeof e==`string`?document.getElementById(e)??null:e}_rebuild(){if(!this._initialized)return;let e=this._stack?.pages??[];this._barState.setPages(e);let t=buildViewSwitcherButtons(viewSwitcherPagesFromStack(e),this._stack?.visibleChildIndex??-1,`narrow`);t.length!==this._nodes.length&&(this._barEl.replaceChildren(),this._nodes=t.map(e=>this._buildButton(e.pageIndex)),this._barEl.append(...this._nodes.map(e=>e.button))),t.forEach((e,t)=>{let n=this._nodes[t];n&&(n.button.hidden=!e.visible,n.button.classList.toggle(`active`,e.selected),n.button.setAttribute(`aria-selected`,String(e.selected)),n.button.tabIndex=e.selected?0:-1,applySwitcherIcon(n.icon,e.iconName),n.label.textContent=e.label,n.label.hidden=e.label.length===0,applyIndicator(n.indicator,e.badgeLabel,e.needsAttention),applyDescription(n.button,e.description),e.label?n.button.removeAttribute(`aria-label`):n.button.setAttribute(`aria-label`,e.iconName))}),this._applyRevealed()}_buildButton(e){let t=document.createElement(`button`);t.type=`button`,t.className=`adw-view-switcher-bar-button`,t.setAttribute(`role`,`tab`),t.dataset.pageIndex=String(e);let n=createGtkImage(null,`adw-view-switcher-bar-icon`),r=document.createElement(`span`);r.className=`adw-view-switcher-bar-label`;let i=document.createElement(`span`);return i.className=`adw-view-switcher-bar-indicator`,i.setAttribute(`aria-hidden`,`true`),t.append(n,r,i),t.addEventListener(`click`,()=>{this._stack?.selectNthPage(e)}),{button:t,icon:n,label:r,indicator:i}}_applyRevealed(){this.hidden=!this._barState.revealed}};customElements.define(`adw-view-switcher-bar`,AdwViewSwitcherBar);var AdwWindow=class extends GtkWindow{_features=new AdwWindowFeatures(this);static get observedAttributes(){return[...GtkWindow.observedAttributes,`width`,`height`,`width-request`,`height-request`]}get contentArea(){return this._content}get content(){return this._features.content}set content(e){this._features.content=e}get breakpoints(){return this._features.breakpoints}get currentBreakpoint(){return this._features.currentBreakpoint}get dialogs(){return this._features.dialogs}get visibleDialog(){return this._features.visibleDialog}addBreakpoint(e){return this._features.addBreakpoint(e)}connectedCallback(){super.connectedCallback(),this._features.adopt(this._content),this._features.bind()}disconnectedCallback(){this._features.release(),super.disconnectedCallback()}attributeChangedCallback(e){if(e===`width`||e===`height`||e===`width-request`||e===`height-request`){this.renderFrameSize();return}super.attributeChangedCallback(e)}hasTitlebar(){return!1}strips(){return[this._content]}extraSlots(){return[{name:`content`,into:this._content}]}renderFrameSize(){this._features.applySizeRequest()}};customElements.define(`adw-window`,AdwWindow);const wi=[`child-spacing`,`child-spacing-unit`,`pack-direction`,`align`,`justify`,`justify-last-line`,`line-spacing`,`line-spacing-unit`,`line-homogeneous`,`natural-line-length`,`natural-line-length-unit`,`wrap-reverse`,`wrap-policy`,`orientation`];function alignToJustifyContent(e){return e<.25?`flex-start`:e<.75?`center`:`flex-end`}var AdwWrapBox=class extends WidgetElement{_initialized=!1;static get observedAttributes(){return[...wi]}get childSpacing(){return normalizeWrapBoxSpacing(this.getAttribute(`child-spacing`))}set childSpacing(e){this.setAttribute(`child-spacing`,String(e))}get childSpacingUnit(){return normalizeWrapBoxLengthUnit(this.getAttribute(`child-spacing-unit`))}set childSpacingUnit(e){this.setAttribute(`child-spacing-unit`,e)}get lineSpacing(){return normalizeWrapBoxSpacing(this.getAttribute(`line-spacing`))}set lineSpacing(e){this.setAttribute(`line-spacing`,String(e))}get lineSpacingUnit(){return normalizeWrapBoxLengthUnit(this.getAttribute(`line-spacing-unit`))}set lineSpacingUnit(e){this.setAttribute(`line-spacing-unit`,e)}get align(){return normalizeWrapBoxAlign(this.getAttribute(`align`))}set align(e){this.setAttribute(`align`,String(e))}get justify(){return normalizeWrapBoxJustify(this.getAttribute(`justify`))}set justify(e){this.setAttribute(`justify`,e)}get justifyLastLine(){return this.hasAttribute(`justify-last-line`)}set justifyLastLine(e){this.toggleAttribute(`justify-last-line`,!!e)}get wrapPolicy(){return normalizeWrapPolicy(this.getAttribute(`wrap-policy`))}set wrapPolicy(e){this.setAttribute(`wrap-policy`,e)}get packDirection(){return normalizeWrapBoxPackDirection(this.getAttribute(`pack-direction`))}set packDirection(e){this.setAttribute(`pack-direction`,e)}get wrapReverse(){return this.hasAttribute(`wrap-reverse`)}set wrapReverse(e){this.toggleAttribute(`wrap-reverse`,!!e)}get lineHomogeneous(){return this.hasAttribute(`line-homogeneous`)}set lineHomogeneous(e){this.toggleAttribute(`line-homogeneous`,!!e)}get naturalLineLength(){return normalizeNaturalLineLength(this.getAttribute(`natural-line-length`))}set naturalLineLength(e){this.setAttribute(`natural-line-length`,String(e))}get naturalLineLengthUnit(){return normalizeWrapBoxLengthUnit(this.getAttribute(`natural-line-length-unit`))}set naturalLineLengthUnit(e){this.setAttribute(`natural-line-length-unit`,e)}get orientation(){return this.getAttribute(`orientation`)===`vertical`?`vertical`:`horizontal`}set orientation(e){this.setAttribute(`orientation`,e)}get _children(){return[...this.children]}insertChildAfter(e,t=null){return this._applyOrder(`insert-after`,e,t)}reorderChildAfter(e,t=null){return this._applyOrder(`reorder-after`,e,t)}removeAll(){for(let e of this._children)this.removeChild(e)}_applyOrder(e,t,n){let r=resolveWrapBoxChildOrder({children:this._children,child:t,sibling:n,op:e});if(r===null)return!1;let i=r.indexOf(t);return this.insertBefore(t,r[i+1]??null),!0}connectedCallback(){this._initialized||(this._initialized=!0,this._sync())}attributeChangedCallback(e,t,n){if(!this._initialized)return;this._sync();let r=this._normalized(e,n);r!==this._normalized(e,t)&&this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:r}}))}_normalized(e,t){switch(e){case`child-spacing`:case`line-spacing`:return normalizeWrapBoxSpacing(t);case`child-spacing-unit`:case`line-spacing-unit`:case`natural-line-length-unit`:return normalizeWrapBoxLengthUnit(t);case`align`:return normalizeWrapBoxAlign(t);case`justify`:return normalizeWrapBoxJustify(t);case`wrap-policy`:return normalizeWrapPolicy(t);case`pack-direction`:return normalizeWrapBoxPackDirection(t);case`natural-line-length`:return normalizeNaturalLineLength(t);case`orientation`:return t===`vertical`?`vertical`:`horizontal`;default:return t!==null}}_sync(){let e=this.style,t=this.orientation===`vertical`,n=t?`column`:`row`;e.flexDirection=this.packDirection===`end-to-start`?`${n}-reverse`:n,e.flexWrap=this.wrapReverse?`wrap-reverse`:`wrap`;let r=`${wrapBoxLengthToPx(this.childSpacing,this.childSpacingUnit)}px`,i=`${wrapBoxLengthToPx(this.lineSpacing,this.lineSpacingUnit)}px`;t?(e.rowGap=r,e.columnGap=i):(e.columnGap=r,e.rowGap=i),e.setProperty(`--adw-wrap-box-child-spacing`,r);let a=this.justify,o=this.justifyLastLine,s=this.align,c=resolveWrapBoxLine({justify:a,justifyLastLine:o,align:s,lastLine:!1,childrenInLine:2}),l=resolveWrapBoxLine({justify:a,justifyLastLine:o,align:s,lastLine:!0,childrenInLine:2});this.dataset.lineJustify=c.justify,this.dataset.lastLineJustify=l.justify,e.justifyContent=c.growGaps?`space-between`:alignToJustifyContent(c.align),e.alignContent=this.lineHomogeneous?`stretch`:`flex-start`,e.setProperty(`--adw-wrap-box-child-shrink`,String(wrapPolicyFlexShrink(this.wrapPolicy)));let u=wrapBoxLengthToPx(this.naturalLineLength,this.naturalLineLengthUnit),d=u===-1?``:`${u}px`;e.maxWidth=t?``:d,e.maxHeight=t?d:``}};customElements.define(`adw-wrap-box`,AdwWrapBox);const Ti={dark:()=>typeof document<`u`&&isAdwaitaDark(document.documentElement),subscribe(e){if(typeof document>`u`)return()=>{};let t=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`),n=globalThis.matchMedia?.(`(prefers-contrast: more)`);t?.addEventListener(`change`,e),n?.addEventListener(`change`,e);let r=new MutationObserver(e);return r.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>{t?.removeEventListener(`change`,e),n?.removeEventListener(`change`,e),r.disconnect()}},highContrast:()=>globalThis.matchMedia?.(`(prefers-contrast: more)`).matches===!0,supportsColorSchemes(){let matches=e=>globalThis.matchMedia?.(e).matches===!0;return matches(`(prefers-color-scheme: dark)`)||matches(`(prefers-color-scheme: light)`)}};Ti.force=e=>{if(typeof document>`u`)return;let t=document.documentElement;t.classList.remove(`theme-dark`,`theme-light`),e!==null&&t.classList.add(e?`theme-dark`:`theme-light`)},Object.freeze({ALWAYS:0,AUTOMATIC:1,NEVER:2,EXTERNAL:3}),Object.freeze({NONE:0,LTR:1,RTL:2}),Object.freeze({WIDGET:1,TEXT:2,LEFT:3,RIGHT:4,TOP:5,BOTTOM:6}),Object.freeze({WORD:0,LINE:1});const Ei={main:`About`,credits:`Credits`,license:`License`,system:`System`},Di=[`credits`,`license`,`system`],Oi=[`unknown`,`custom`,`gpl-2-0`,`gpl-3-0`,`lgpl-2-1`,`lgpl-3-0`,`bsd`,`mit-x11`,`artistic`,`gpl-2-0-only`,`gpl-3-0-only`,`lgpl-2-1-only`,`lgpl-3-0-only`,`agpl-3-0`,`agpl-3-0-only`,`bsd-3`,`apache-2-0`,`mpl-2-0`,`0bsd`];var GtkAboutDialog=class extends AdwDialog{_built=!1;_logo=``;_switcherEl;_stackEl;_pages=new Map;_populated=new Set;_authors=[];_documenters=[];_artists=[];_creditSections=[];static get observedAttributes(){return[...AdwDialog.observedAttributes,`program-name`,`version`,`copyright`,`comments`,`license`,`license-type`,`system-information`,`website`,`website-label`,`translator-credits`,`logo-icon-name`,`wrap-license`]}get programName(){return this.getAttribute(`program-name`)??``}set programName(e){this.setAttribute(`program-name`,e)}get version(){return this.getAttribute(`version`)??``}set version(e){this.setAttribute(`version`,e)}get copyright(){return this.getAttribute(`copyright`)??``}set copyright(e){this.setAttribute(`copyright`,e)}get comments(){return this.getAttribute(`comments`)??``}set comments(e){this.setAttribute(`comments`,e)}get license(){return this.getAttribute(`license`)??``}set license(e){this.setAttribute(`license`,e),this.setAttribute(`license-type`,`custom`)}get licenseType(){let e=this.getAttribute(`license-type`);return e!==null&&Oi.includes(e)?e:`unknown`}set licenseType(e){Oi.includes(e)?this.setAttribute(`license-type`,e):this.removeAttribute(`license-type`)}get systemInformation(){return this.getAttribute(`system-information`)??``}set systemInformation(e){this.setAttribute(`system-information`,e)}get website(){return this.getAttribute(`website`)??``}set website(e){this.setAttribute(`website`,e)}get websiteLabel(){return this.getAttribute(`website-label`)??``}set websiteLabel(e){this.setAttribute(`website-label`,e)}get translatorCredits(){return this.getAttribute(`translator-credits`)??``}set translatorCredits(e){this.setAttribute(`translator-credits`,e)}get logoIconName(){return this.getAttribute(`logo-icon-name`)??``}set logoIconName(e){this.setAttribute(`logo-icon-name`,e)}get wrapLicense(){return this.hasAttribute(`wrap-license`)}set wrapLicense(e){this.toggleAttribute(`wrap-license`,e)}get logo(){return this._logo}set logo(e){this._logo=e,this._built&&this._renderLogo()}get authors(){return[...this._authors]}set authors(e){this._authors=[...e],this._creditsChanged()}get documenters(){return[...this._documenters]}set documenters(e){this._documenters=[...e],this._creditsChanged()}get artists(){return[...this._artists]}set artists(e){this._artists=[...e],this._creditsChanged()}addCreditSection(e,t){this._creditSections.push({name:e,people:[...t]}),this._creditsChanged()}_creditsChanged(){this._populated.delete(`credits`),this._built&&this._renderAbout()}connectedCallback(){if(this._built){super.connectedCallback();return}this._switcherEl=document.createElement(`div`),this._switcherEl.className=`adw-gtk-about-dialog-switcher`,this._switcherEl.setAttribute(`role`,`tablist`),this._switcherEl.setAttribute(`aria-label`,`Pages`),super.connectedCallback(),this._stackEl=document.createElement(`div`),this._stackEl.className=`adw-gtk-about-dialog-stack`,this._stackEl.dataset.transitionType=`crossfade`,this.setAttribute(`title`,`About ${this.programName||document.title}`);let e=[...this.contentArea.childNodes];this.contentArea.replaceChildren(this._build());for(let t of e)this.contentArea.appendChild(t);this._renderAbout(),this._built=!0}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),this._built&&t!==n&&((e===`license`||e===`license-type`||e===`website`)&&this._populated.delete(`license`),e===`system-information`&&this._populated.delete(`system`),(e===`website`||e===`website-label`||e===`license`||e===`license-type`)&&(this._renderMain(),this._populateLicense()),e===`wrap-license`&&this._populateLicense(),e===`system-information`&&this._populateSystem(),this._renderAbout())}decorateHeader(e){let t=e.querySelector(`.adw-dialog-title`);t===null?e.prepend(this._switcherEl):t.replaceWith(this._switcherEl),this._renderSwitcher()}get visiblePage(){return this._stackEl.dataset.visible??`main`}showPage(e){this._populatePage(e);for(let[t,n]of this._pages)n.hidden=t!==e;this._stackEl.dataset.visible=e,this._renderSwitcher()}_build(){let e=document.createElement(`div`);e.className=`adw-gtk-about-dialog-box`;let t=document.createElement(`div`);t.className=`adw-gtk-about-dialog-head`;let n=document.createElement(`div`);n.className=`adw-gtk-about-dialog-logo-slot`,t.appendChild(n),this._renderLogo();let r=document.createElement(`div`);r.className=`adw-gtk-about-dialog-name`,r.textContent=this.programName||document.title,t.appendChild(r);for(let e of[`main`,...Di]){let t=document.createElement(`div`);t.className=`adw-gtk-about-dialog-page`,t.dataset.page=e,t.hidden=e!==`main`,this._pages.set(e,t),this._stackEl.appendChild(t)}return this._renderMain(),t.appendChild(this._stackEl),e.appendChild(t),e}_renderAbout(){this.setAttribute(`title`,`About ${this.programName||document.title}`);for(let e of Di){let t=this._pages.get(e);if(t===void 0)continue;let n=this._pageVisible(e);t.hidden!==!n&&(t.hidden=!n,n||this._populated.delete(e))}this._pages.get(this._stackEl.dataset.visible??`main`)?.hidden!==!1&&(this._stackEl.dataset.visible=`main`,this._pages.get(`main`).hidden=!1),this._renderMain(),this._renderSwitcher()}_pageVisible(e){return e===`credits`?this._creditsPeople().length>0:e===`license`?this.licenseType===`custom`&&this.license.length>0:this.systemInformation.length>0}_creditsPeople(){let e=[];this._authors.length>0&&e.push({title:`Created by`,people:this._authors}),this._documenters.length>0&&e.push({title:`Documented by`,people:this._documenters});let t=translatorCreditsPeople(this.translatorCredits);t.length>0&&e.push({title:`Translated by`,people:t}),this._artists.length>0&&e.push({title:`Design by`,people:this._artists});for(let t of this._creditSections)e.push({title:t.name,people:t.people});return e}_visiblePages(){return Di.filter(e=>this._pages.get(e)?.hidden===!1)}_renderSwitcher(){if(this._switcherEl===void 0)return;let e=this._visiblePages();this._switcherEl.hidden=e.length===0,this._switcherEl.replaceChildren(...e.map(e=>{let t=document.createElement(`button`);return t.type=`button`,t.className=`adw-gtk-about-dialog-switcher-item`,t.setAttribute(`role`,`tab`),t.textContent=Ei[e],t.classList.toggle(`checked`,this._stackEl.dataset.visible===e),t.setAttribute(`aria-selected`,String(this._stackEl.dataset.visible===e)),t.addEventListener(`click`,()=>this.showPage(e)),t}))}_renderLogo(){let e=this.contentArea.querySelector(`.adw-gtk-about-dialog-logo-slot`);if(e!==null){if(this.logoIconName.length>0){e.replaceChildren(createGtkImage(this.logoIconName,`adw-gtk-about-dialog-logo`));return}if(this._logo.length>0){let t=document.createElement(`img`);t.className=`adw-gtk-about-dialog-logo`,t.src=this._logo,t.alt=``,e.replaceChildren(t);return}e.replaceChildren()}}_renderMain(){let e=this._pages.get(`main`);if(e===void 0)return;let t=[],label=(e,t)=>{let n=document.createElement(`div`);return n.className=t,n.textContent=e,n};this.version.length>0&&t.push(label(this.version,`adw-gtk-about-dialog-version`)),this.comments.length>0&&t.push(label(this.comments,`adw-gtk-about-dialog-comments`)),this.website.length>0?t.push(this.websiteLabel.length>0?this._link(this.websiteLabel,this.website,`adw-gtk-about-dialog-website`):this._link(`Website`,this.website,`adw-gtk-about-dialog-website`)):this.websiteLabel.length>0&&t.push(label(this.websiteLabel,`adw-gtk-about-dialog-website`)),this.copyright.length>0&&t.push(label(this.copyright,`adw-gtk-about-dialog-copyright`));let n=this._licenseMarkup();n!==null&&t.push(n),e.replaceChildren(...t)}_licenseMarkup(){let e=this.licenseType,t=Oi.indexOf(e),n=t>=0?t:S.UNKNOWN,r=document.createElement(`div`);if(r.className=`adw-gtk-about-dialog-license`,n!==S.CUSTOM&&n!==S.UNKNOWN){let e=ve[n],t=e.url??this.website;return r.append(document.createTextNode(`This program comes with absolutely no warranty.
|
|
19
19
|
See the `),this._link(e.name??``,t,`adw-gtk-about-dialog-license-link`),document.createTextNode(` for details.`)),r}return n===S.UNKNOWN||this.license.length===0?null:(this._fillWithLinks(r,this.license),r)}_populateLicense(){let e=this._pages.get(`license`);if(e===void 0)return;let t=document.createElement(`div`);t.className=`adw-gtk-about-dialog-text-view`,this.wrapLicense&&t.classList.add(`wrap`);let n=this._licenseMarkup();if(n!==null){let e=document.createElement(`div`);e.className=`adw-gtk-about-dialog-text`,e.replaceChildren(...[...n.childNodes].map(e=>e.cloneNode(!0))),t.appendChild(e)}e.replaceChildren(this._frame(t))}_populateSystem(){let e=this._pages.get(`system`);if(e===void 0)return;let t=document.createElement(`div`);t.className=`adw-gtk-about-dialog-text-view`;let n=document.createElement(`div`);n.className=`adw-gtk-about-dialog-text`,this._fillWithLinks(n,this.systemInformation),t.appendChild(n),e.replaceChildren(this._frame(t))}_populateCredits(){let e=this._pages.get(`credits`);if(e===void 0)return;let t=document.createElement(`div`);t.className=`adw-gtk-about-dialog-credits-grid`,t.setAttribute(`role`,`group`),t.setAttribute(`aria-label`,Ei.credits);for(let e of this._creditsPeople()){let n=document.createElement(`div`);n.className=`adw-gtk-about-dialog-credits-heading`,n.textContent=e.title,t.appendChild(n);for(let n of e.people){let e=parseCreditPerson(n),r=document.createElement(`div`);r.className=`adw-gtk-about-dialog-credits-person`,e.link===null?r.textContent=e.name:r.appendChild(this._link(e.name,e.uri??``,`adw-gtk-about-dialog-credits-link`)),t.appendChild(r)}t.appendChild(document.createElement(`div`))}e.replaceChildren(this._frame(t))}_populatePage(e){this._populated.has(e)||(this._populated.add(e),e===`credits`?this._populateCredits():e===`license`?this._populateLicense():e===`system`&&this._populateSystem())}_frame(e){let t=document.createElement(`div`);t.className=`adw-gtk-about-dialog-scrolled`;let n=document.createElement(`div`);return n.className=`adw-view`,n.appendChild(e),t.appendChild(n),t}_link(e,t,n){let r=document.createElement(`a`);return r.className=n,r.href=t,r.rel=`noopener noreferrer`,r.textContent=e,r.addEventListener(`click`,e=>{e.preventDefault(),this._activateLink(t)}),r}_fillWithLinks(e,t){for(let n of splitLinks(t)){if(n.uri===null){e.appendChild(document.createTextNode(n.text));continue}let t=document.createElement(`a`);t.href=n.uri,t.rel=`noopener noreferrer`,t.textContent=n.text,t.addEventListener(`click`,e=>{e.preventDefault(),this._activateLink(n.uri)}),e.appendChild(t)}}_activateLink(e){let t=new CustomEvent(`activate-link`,{bubbles:!0,cancelable:!0,detail:{uri:e}});this.dispatchEvent(t)&&globalThis.open(e,`_blank`,`noopener,noreferrer`)}};function splitLinks(e){let t=[],n=e;for(;n.length>0;){let e=n.indexOf(`<`),r=e<0?-1:n.indexOf(`>`,e),i=n.indexOf(`http://`),a=n.indexOf(`https://`),o=i;(i<0||a>=0&&a<i)&&(o=a);let s=-1;if(o>=0&&(s=`
|
|
20
20
|
>`.split(``).reduce((e,t)=>{if(e>=0)return e;let r=n.indexOf(t,o);return r<0?-1:r},-1),s<0&&(s=n.length)),o>=0&&(e<0||r<0||o<=e+1)&&(e=o,r=s),e<0||r<0){t.push({text:n,uri:null});break}e>0&&t.push({text:n.slice(0,e),uri:null});let c=n[e]===`<`,l=c?n.slice(e+1,r):n.slice(e,r);t.push({text:l,uri:c?`mailto:${l}`:l}),n=n.slice(r+ +!!c)}return t}customElements.define(`gtk-about-dialog`,GtkAboutDialog);var GtkActionBar=class extends WidgetElement{_initialized=!1;_startEl=null;_centerEl=null;_endEl=null;static get observedAttributes(){return[`revealed`]}get revealed(){return this.getAttribute(`revealed`)!==`false`}set revealed(e){this.setAttribute(`revealed`,e?`true`:`false`)}get startSection(){return this._startEl}get centerSection(){return this._centerEl}get endSection(){return this._endEl}connectedCallback(){if(this._initialized)return;this._initialized=!0,this._startEl=document.createElement(`div`),this._startEl.className=`adw-action-bar-start`,this._centerEl=document.createElement(`div`),this._centerEl.className=`adw-action-bar-center`,this._endEl=document.createElement(`div`),this._endEl.className=`adw-action-bar-end`;let e=this._endEl;bindSlottedChildren(this,[{name:`start`,into:this._startEl},{name:`center`,into:this._centerEl},{name:`end`,consume:t=>e.prepend(t)},{into:this._startEl}]).install(this._startEl,this._centerEl,this._endEl),this._renderRevealed()}attributeChangedCallback(){this._initialized&&this._renderRevealed()}_renderRevealed(){this.hidden=!this.revealed}};customElements.define(`gtk-action-bar`,GtkActionBar);function normalizeAlign(e){let t=Number.parseFloat(e??``);return Number.isFinite(t)?glibClamp(t,0,1):.5}function normalizeRatio(e){let t=Number.parseFloat(e??``);return Number.isFinite(t)?glibClamp(t,1e-4,1e4):1}var GtkAspectFrame=class extends WidgetElement{static get observedAttributes(){return[`ratio`,`xalign`,`yalign`,`obey-child`]}get ratio(){return normalizeRatio(this.getAttribute(`ratio`))}set ratio(e){this.setAttribute(`ratio`,String(e))}get xalign(){return normalizeAlign(this.getAttribute(`xalign`))}set xalign(e){this.setAttribute(`xalign`,String(e))}get yalign(){return normalizeAlign(this.getAttribute(`yalign`))}set yalign(e){this.setAttribute(`yalign`,String(e))}get obeyChild(){let e=this.getAttribute(`obey-child`);return e===null||e!==`false`&&e!==`0`}set obeyChild(e){e?this.setAttribute(`obey-child`,`true`):this.setAttribute(`obey-child`,`false`)}get child(){return this.firstElementChild??null}set child(e){this.firstElementChild!==null&&this.firstElementChild.remove(),e!==null&&this.append(e),this._sync()}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}]),this.setAttribute(`role`,`generic`),this._sync()}attributeChangedCallback(e,t,n){if(this._sync(),!this.isConnected)return;let r=this._normalized(e,n);r!==this._normalized(e,t)&&this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:r}}))}_normalized(e,t){return e===`ratio`?normalizeRatio(t):e===`xalign`||e===`yalign`?normalizeAlign(t):t!==null&&t!==`false`&&t!==`0`}_sync(){let e=this.child;if(e===null)return;let t=e.style;this.obeyChild?t.removeProperty(`aspect-ratio`):t.aspectRatio=String(this.ratio),t.flex=`1 1 auto`,t.maxWidth=`100%`,t.maxHeight=`100%`,this.style.justifyContent=labelYalignAlignItems(this.xalign),this.style.alignItems=labelYalignAlignItems(this.yalign)}};customElements.define(`gtk-aspect-frame`,GtkAspectFrame);const K={},ki=new Map([[`gtk-box`,{}],[`gtk-stack`,{}],[`gtk-overlay`,{skip:`.adw-overlay-layer`}],[`gtk-scrolled-window`,{skip:`gtk-scrollbar`}],[`gtk-viewport`,{}],[`adw-bin`,K],[`adw-bottom-sheet`,K],[`adw-breakpoint-bin`,K],[`adw-clamp`,K],[`adw-clamp-scrollable`,K],[`adw-layout-slot`,K],[`adw-multi-layout-view`,K],[`adw-navigation-view`,K],[`adw-overlay-split-view`,K],[`adw-status-page`,K],[`adw-toast-overlay`,K],[`adw-toolbar-view`,K],[`adw-view-stack`,K],[`adw-header-bar`,{horizontalOnly:!0}]]),Ai={horizontal:`hexpand`,vertical:`vexpand`};function vfuncOf(e){let t=ki.get(e.localName);if(t!==void 0)return t;if(typeof customElements.getName==`function`)for(let t=Object.getPrototypeOf(e);t&&t!==HTMLElement.prototype;){let e=customElements.getName(t.constructor),n=e===null?void 0:ki.get(e);if(n!==void 0)return n;t=Object.getPrototypeOf(t)}}function isWidget(e){return e.localName.includes(`-`)||e.hasAttribute(`hexpand`)||e.hasAttribute(`vexpand`)}function isStackPage(e){return e.classList.contains(`adw-view-stack-child`)&&e.parentElement?.localName===`adw-view-stack`}function explicitExpand(e,t){let n=e.getAttribute(Ai[t]);return n===null?void 0:n!==`false`}function computeExpand(e,t){if(e.hasAttribute(`hidden`)&&!isStackPage(e))return!1;let n=explicitExpand(e,t);if(n!==void 0)return n;let r=vfuncOf(e);return r===void 0||r.horizontalOnly&&t===`vertical`?!1:anyChildExpands(e,t,r.skip)}function anyChildExpands(e,t,n){for(let r of e.children)if(!(n!==void 0&&r.matches(n))){if(isWidget(r)){if(computeExpand(r,t))return!0}else if(anyChildExpands(r,t,void 0))return!0}return!1}const ji=[`orientation`,`spacing`,`homogeneous`],Mi={horizontal:`data-computed-hexpand`,vertical:`data-computed-vexpand`};var GtkBox=class extends WidgetElement{_expandObserver=null;static get observedAttributes(){return[...ji]}get orientation(){return normalizeBoxOrientation(this.getAttribute(`orientation`))}set orientation(e){this.setAttribute(`orientation`,e)}get spacing(){return normalizeBoxSpacing(this.getAttribute(`spacing`))}set spacing(e){this.setAttribute(`spacing`,String(e))}get homogeneous(){return this.hasAttribute(`homogeneous`)}set homogeneous(e){this.toggleAttribute(`homogeneous`,!!e)}remove(e){if(e===void 0){super.remove();return}if(e.parentNode!==this){console.warn(`Gtk.Box: trying to remove a widget that is not a child of this box`);return}this.removeChild(e)}insert_child_after(e,t=null){return this._applyOrder(`insert-after`,e,t)}reorder_child_after(e,t=null){return this._applyOrder(`reorder-after`,e,t)}_applyOrder(e,t,n){let r=resolveWrapBoxChildOrder({children:[...this.children],child:t,sibling:n,op:e});return r===null?!1:(this.insertBefore(t,r[r.indexOf(t)+1]??null),!0)}connectedCallback(){this._sync(),this._syncComputedExpand(),!this._expandObserver&&(this._expandObserver=new MutationObserver(e=>{e.some(affectsExpand)&&this._syncComputedExpand()}),this._expandObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`hexpand`,`vexpand`,`hidden`]}))}disconnectedCallback(){this._expandObserver?.disconnect(),this._expandObserver=null}attributeChangedCallback(e,t,n){this._sync();let r=this._normalized(e,n);r!==this._normalized(e,t)&&this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:r}}))}_normalized(e,t){return e===`orientation`?normalizeBoxOrientation(t):e===`spacing`?normalizeBoxSpacing(t):t!==null}_sync(){this.style.flexDirection=this.orientation===`vertical`?`column`:`row`,this.style.gap=`${this.spacing}px`}_syncComputedExpand(){for(let e of this.children)for(let t of[`horizontal`,`vertical`]){let n=explicitExpand(e,t)===void 0&&computeExpand(e,t);e.toggleAttribute(Mi[t],n)}}};function affectsExpand(e){if(e.type!==`childList`)return!0;let isElement=e=>e.nodeType===Node.ELEMENT_NODE;return[...e.addedNodes].some(isElement)||[...e.removedNodes].some(isElement)}customElements.define(`gtk-box`,GtkBox);const Ni=[`aria-label`,`aria-description`];function forwardAccessibleName(e,t){for(let n of Ni){let r=e.getAttribute(n);r===null?t.removeAttribute(n):t.setAttribute(n,r)}return e.hasAttribute(`aria-label`)}const Pi=[`flat`,`suggested`,`destructive`,`circular`,`pill`];var GtkButton=class extends TooltipElement{static signals={clicked:`click`};_button;_label=``;_initialized=!1;_child=null;static get observedAttributes(){return[`icon`,`icon-name`,`label`,`tooltip`,`tooltip-text`,`disabled`,`flat`,`suggested`,`destructive`,`circular`,`pill`,`class`,...Ni]}get icon_name(){return this.getAttribute(`icon-name`)}set icon_name(e){this.reflect(`icon-name`,e)}get iconName(){return this.icon_name}set iconName(e){this.icon_name=e}reflect(e,t){t==null?this.removeAttribute(e):this.setAttribute(e,t)}get button(){return this._button}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=Array.from(this.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.textContent??``).join(``);this._label=(this.getAttribute(`label`)??e).trim(),this._button=document.createElement(`button`),bindSlottedChildren(this,[{name:`child`,claims:e=>e instanceof Element,consume:e=>{this._child=e,this._render()}}]).install(this._button),this._render()}attributeChangedCallback(){this._initialized&&this._render()}_render(){let e=this._button;e.className=`adw-button`;let t=[...Pi.filter(e=>this.hasAttribute(e)),...this.classList];e.classList.add(...buttonStyleClasses(t));let n=this._child,r=n?null:this.getAttribute(`icon`)??this.getAttribute(`icon-name`),i=n?``:(this.getAttribute(`label`)??this._label).trim();r&&!i&&e.classList.add(`icon-only`),i&&!r&&e.classList.add(`text-button`),n?e.replaceChildren(n):e.replaceChildren(),r&&e.appendChild(createGtkImage(r)),i&&e.appendChild(document.createTextNode(i));let a=this.getAttribute(`tooltip`)??this.getAttribute(`tooltip-text`);e.title=a??``,!forwardAccessibleName(this,e)&&r&&!i&&e.setAttribute(`aria-label`,a??r),e.disabled=this.hasAttribute(`disabled`),this.decorate(e)}decorate(e){}};customElements.define(`gtk-button`,GtkButton);const Fi=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],Ii=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],q=[{step:`previous-month`,icon:`go-previous`,tooltip:`Previous Month`},{step:`next-month`,icon:`go-next`,tooltip:`Next Month`},{step:`previous-year`,icon:`go-up`,tooltip:`Previous Year`},{step:`next-year`,icon:`go-down`,tooltip:`Next Year`}];var GtkCalendar=class extends WidgetElement{_headerEl;_monthEl;_yearEl;_arrowEls={};_gridEl;_dayNameEls=[];_weekNumberEls=[];_cellEls=[];_marked=calendarClearMarks();_date;_focus=-1;_initialized=!1;static get observedAttributes(){return[`date`,`year`,`month`,`day`,`show-heading`,`show-day-names`,`show-week-numbers`,`week-start`]}get date(){return toIsoDate(this._date)}set date(e){this.setAttribute(`date`,e)}get year(){return this._date.year}set year(e){this.setAttribute(`year`,String(e))}get month(){return this._date.month-1}set month(e){this.setAttribute(`month`,String(e))}get day(){return this._date.day}set day(e){this.setAttribute(`day`,String(e))}get showHeading(){return this.getAttribute(`show-heading`)!==`false`}set showHeading(e){this.setAttribute(`show-heading`,String(!!e))}get showDayNames(){return this.getAttribute(`show-day-names`)!==`false`}set showDayNames(e){this.setAttribute(`show-day-names`,String(!!e))}get showWeekNumbers(){return this.hasAttribute(`show-week-numbers`)}set showWeekNumbers(e){this.toggleAttribute(`show-week-numbers`,!!e)}get weekStart(){let e=this.getAttribute(`week-start`);if(e!==null){let t=Number.parseInt(e,10);if(Number.isFinite(t)&&t>=0&&t<=6)return t}return localeWeekStart()}set weekStart(e){this.setAttribute(`week-start`,String(e))}get markedDays(){return this._marked.flatMap((e,t)=>e?[t+1]:[])}constructor(){super(),this._date=today()}connectedCallback(){this._initialized||(this._initialized=!0,this._buildHeader(),this._buildGrid(),this.replaceChildren(this._headerEl,this._gridEl),this.addEventListener(`keydown`,e=>this._onKeyDown(e)),this._adoptAttributes(),this._render())}attributeChangedCallback(e){if(!this._initialized)return;let t=this._adoptAttributes(e);this._render(),(e===`date`||e===`year`||e===`month`||e===`day`)&&this._emitDaySelected(t)}markDay(e){let t=calendarMarkDay(this._marked,e,!0);t!==this._marked&&(this._marked=t,this._paintStates(),this.dispatchEvent(new CustomEvent(`notify::marked-days`,{bubbles:!0,detail:{markedDays:this.markedDays}})))}unmarkDay(e){let t=calendarMarkDay(this._marked,e,!1);t!==this._marked&&(this._marked=t,this._paintStates(),this.dispatchEvent(new CustomEvent(`notify::marked-days`,{bubbles:!0,detail:{markedDays:this.markedDays}})))}dayIsMarked(e){return calendarDayIsMarked(this._marked,e)}clearMarks(){this._marked=calendarClearMarks(),this._paintStates(),this.dispatchEvent(new CustomEvent(`notify::marked-days`,{bubbles:!0,detail:{markedDays:[]}}))}get cells(){return calendarDays(this._date.year,this._date.month,this.weekStart)}get selectedDate(){return{...this._date}}_buildHeader(){this._headerEl=document.createElement(`div`),this._headerEl.className=`adw-calendar-header`;let e={previousMonth:{icon:q[0].icon,tooltip:q[0].tooltip},nextMonth:{icon:q[1].icon,tooltip:q[1].tooltip},previousYear:{icon:q[2].icon,tooltip:q[2].tooltip},nextYear:{icon:q[3].icon,tooltip:q[3].tooltip}},button=(t,n,r)=>{let i=document.createElement(`button`);return i.type=`button`,i.className=`adw-calendar-nav-button flat`,i.title=e[t].tooltip,i.setAttribute(`aria-label`,e[t].tooltip),n&&i.classList.add(`expand`),i.style.justifySelf=r,i.addEventListener(`click`,()=>this._onArrow(t)),i.appendChild(createGtkImage(e[t].icon,`adw-calendar-nav-icon`)),this._arrowEls[t]=i,i};this._monthEl=document.createElement(`span`),this._monthEl.className=`adw-calendar-month`,this._yearEl=document.createElement(`span`),this._yearEl.className=`adw-calendar-year`,this._headerEl.append(button(`previousMonth`,!1,`start`),this._monthEl,button(`nextMonth`,!0,`start`),button(`previousYear`,!1,`center`),this._yearEl,button(`nextYear`,!1,`end`)),this._monthEl.style.flex=`1`,this._yearEl.style.paddingInline=`6px`}_buildGrid(){this._gridEl=document.createElement(`div`),this._gridEl.className=`adw-calendar-grid`;for(let e=0;e<7;e++){let e=document.createElement(`span`);e.className=`adw-calendar-day-name`,this._dayNameEls.push(e),this._gridEl.appendChild(e)}let e=document.createElement(`span`);e.className=`adw-calendar-week-spacer`,e.setAttribute(`aria-hidden`,`true`),this._gridEl.appendChild(e);for(let e=0;e<6;e++){let e=document.createElement(`span`);e.className=`adw-calendar-week-number`,this._weekNumberEls.push(e),this._gridEl.appendChild(e);for(let e=0;e<7;e++){let e=document.createElement(`button`);e.type=`button`,e.className=`adw-calendar-cell day-number`,e.addEventListener(`click`,()=>this._onCellClick(Number(e.dataset.index??`0`))),this._cellEls.push(e),this._gridEl.appendChild(e)}}}_adoptAttributes(e){let t=this.getAttribute(`date`);if(t!==null&&!(e===`year`||e===`month`||e===`day`)){let e=parseIsoDate(t);if(e!==null){let t=calendarSelectDay(this._date,e,!1);return this._date=t.date,t}}let n={year:integer(this.getAttribute(`year`),this._date.year),month:integer(this.getAttribute(`month`),this._date.month-1)+1,day:integer(this.getAttribute(`day`),this._date.day)},r=calendarSelectDay(this._date,n,!1);return this._date=r.date,r}_render(){this._monthEl.textContent=Ii[this._date.month-1],this._yearEl.textContent=String(this._date.year);let e=calendarDays(this._date.year,this._date.month,this.weekStart);e.forEach((e,t)=>{let n=this._cellEls[t];n.dataset.index=String(t),n.textContent=String(e.date.day),n.setAttribute(`aria-label`,`${Ii[e.date.month-1]} ${e.date.day}, ${e.date.year}`),n.classList.toggle(`other-month`,e.month!==`current`)}),this._paintWeekNumbers(e),this._paintStates(),this._paintArrows(),this._paintDayNames(),this._paintVisibility()}_paintWeekNumbers(e){for(let t=0;t<6;t++){let n=e[t*7+6];this._weekNumberEls[t].textContent=String(calendarWeekNumber(n.date))}}_paintStates(){let e=calendarDays(this._date.year,this._date.month,this.weekStart),t=today(),n=t.year===this._date.year&&t.month===this._date.month?t.day:-1;e.forEach((e,t)=>{let r=this._cellEls[t],i=e.month===`current`&&e.date.day===this._date.day,a=e.month===`previous`&&this._date.year===1&&this._date.month===1||e.month===`next`&&this._date.year===9999&&this._date.month===12;r.classList.toggle(`selected`,i),r.classList.toggle(`marked`,e.month===`current`&&calendarDayIsMarked(this._marked,e.date.day)),r.classList.toggle(`today`,e.date.day===n&&e.month===`current`),r.classList.toggle(`focused`,t===this._focus),r.disabled=a,a?r.textContent=``:r.textContent=String(e.date.day)})}_paintArrows(){let e=calendarNavigationButtons(this._date);for(let t of[`previousMonth`,`nextMonth`,`previousYear`,`nextYear`])this._arrowEls[t].disabled=!e[t]}_paintDayNames(){for(let e=0;e<7;e++)this._dayNameEls[e].textContent=Fi[(e+this.weekStart)%7]}_paintVisibility(){this._headerEl.hidden=!this.showHeading;for(let e of this._dayNameEls)e.hidden=!this.showDayNames;for(let e of this._weekNumberEls)e.hidden=!this.showWeekNumbers}_onArrow(e){let t=q.find(t=>arrowNameOf(t.step)===e)?.step;t===void 0||this._arrowEls[e].disabled||this._navigate(t)}_navigate(e){let t=this._date;if(this._date=calendarSelectDay(t,calendarStep(t,e),!1).date,this._focus>=0){let e=this.cells,t=e[this._focus],n=e.findIndex(e=>e.month===t?.month&&e.date.day===t.date.day);this._focus=n>=0?n:-1}this._render(),this.dispatchEvent(new CustomEvent(`notify::date`,{bubbles:!0,detail:{date:this.date}})),this.dispatchEvent(new CustomEvent({"previous-month":`prev-month`,"next-month":`next-month`,"previous-year":`prev-year`,"next-year":`next-year`}[e],{bubbles:!0}))}_emitDaySelected(e){let notify=(e,t)=>this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:t}}));e.dayChanged&&(this.dispatchEvent(new CustomEvent(`day-selected`,{bubbles:!0})),notify(`day`,this._date.day)),e.monthChanged&¬ify(`month`,this._date.month-1),e.yearChanged&¬ify(`year`,this._date.year),notify(`date`,this.date)}_onCellClick(e){let t=this.cells[e];t!==void 0&&(this._focus=e,t.month===`previous`?this._navigate(`previous-month`):t.month===`next`&&this._navigate(`next-month`),this._selectDate(t.date,!0))}_selectDate(e,t){let n=calendarSelectDay(this._date,e,t);if(!n.dayChanged&&!n.monthChanged&&!n.yearChanged){this._render();return}this._date=n.date;let r=this.cells.findIndex(e=>e.month===`current`&&e.date.day===this._date.day);r>=0&&(this._focus=r),this._render(),this._emitDaySelected(n)}_onKeyDown(e){let t={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,1],ArrowDown:[0,-1]};if(e.ctrlKey){let t={ArrowLeft:`previous-month`,ArrowRight:`next-month`,ArrowUp:`previous-year`,ArrowDown:`next-year`}[e.key];if(t===void 0||(e.preventDefault(),!calendarNavigationButtons(this._date)[arrowNameOf(t)]))return;this._navigate(t);return}if(e.altKey||e.metaKey)return;if(e.key===` `){if(this._focus<0)return;e.preventDefault();let t=this.cells[this._focus];if(t===void 0)return;t.month===`previous`?this._navigate(`previous-month`):t.month===`next`&&this._navigate(`next-month`),this._selectDate(t.date,!0);return}let n=t[e.key];n!==void 0&&(e.preventDefault(),this._moveFocus(n[0],n[1]))}_moveFocus(e,t){if(this.cells.length===0)return;let n=this._focus<0?-1:Math.trunc(this._focus/7),r=this._focus<0?-1:this._focus%7;t===1?(n>0&&n--,n<0&&(n=5),r<0&&(r=6)):t===-1?(n<5&&n++,r<0&&(r=0)):e===-1?(r>0?r--:n>0&&(r=6,n--),r<0&&(r=6),n<0&&(n=5)):(r<6?r++:n<5&&(r=0,n++),r<0&&(r=0),n<0&&(n=0));let i=n*7+r;this._cellEls[i]?.disabled!==!0&&(this._focus=i,this._paintStates(),this._cellEls[i]?.focus())}};function arrowNameOf(e){switch(e){case`previous-month`:return`previousMonth`;case`next-month`:return`nextMonth`;case`previous-year`:return`previousYear`;default:return`nextYear`}}function localeWeekStart(){let e=globalThis.navigator?.language;if(typeof e!=`string`)return calendarWeekStart(0,0);let t=Intl.Locale;if(t===void 0)return calendarWeekStart(0,0);let n=new t(e).getWeekInfo?.();return n===void 0?calendarWeekStart(0,0):calendarWeekStart(n.firstDay%7,n.firstDay===7?0:1)}function today(){let e=new Date;return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}}function toIsoDate(e){return`${String(e.year).padStart(4,`0`)}-${String(e.month).padStart(2,`0`)}-${String(e.day).padStart(2,`0`)}`}function parseIsoDate(e){let t=/^(-?\d{1,6})-(\d{1,2})-(\d{1,2})$/.exec(e.trim());if(t===null)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]);return r<1||r>12||i<1||i>31||n<1||n>9999?null:{year:n,month:r,day:i}}function integer(e,t){let n=Number.parseInt(e??``,10);return Number.isFinite(n)?n:t}customElements.define(`gtk-calendar`,GtkCalendar);const Li={top:0,center:.5,bottom:1};var GtkCenterBox=class extends WidgetElement{static get observedAttributes(){return[`baseline-position`,`shrink-center-last`]}get baselinePosition(){let e=this.getAttribute(`baseline-position`);return e!==null&&e in Li?e:`center`}set baselinePosition(e){this.setAttribute(`baseline-position`,e)}get shrinkCenterLast(){let e=this.getAttribute(`shrink-center-last`);return e===null||e!==`false`&&e!==`0`}set shrinkCenterLast(e){e?this.removeAttribute(`shrink-center-last`):this.setAttribute(`shrink-center-last`,`false`)}get startWidget(){return this.querySelector(`[slot="start-widget"]`)}set startWidget(e){this._assign(`start-widget`,e)}get centerWidget(){return this.querySelector(`[slot="center-widget"]`)}set centerWidget(e){this._assign(`center-widget`,e)}get endWidget(){return this.querySelector(`[slot="end-widget"]`)}set endWidget(e){this._assign(`end-widget`,e)}connectedCallback(){bindSlottedChildren(this,[{name:`start-widget`,into:this},{name:`center-widget`,into:this},{name:`end-widget`,into:this}]),this.setAttribute(`role`,`generic`),this._sync()}attributeChangedCallback(e,t,n){if(this._sync(),!this.isConnected)return;let r=this._normalized(e,n);r!==this._normalized(e,t)&&this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:r}}))}_normalized(e,t){return e===`shrink-center-last`?t===null||t!==`false`&&t!==`0`:t!==null&&t in Li?t:`center`}_assign(e,t){let n=this.querySelector(`[slot="${e}"]`);n!==null&&(n.removeAttribute(`slot`),n.remove()),t!==null&&(t.setAttribute(`slot`,e),this.append(t)),this._sync()}_sync(){let e=this.shrinkCenterLast;for(let t of this.children){let n=t.getAttribute(`slot`),r=n===`center-widget`?!e:n===`start-widget`||n===`end-widget`?e:!1;t.style.flexShrink=String(r?100:1)}this.hasAttribute(`baseline-position`)?this.style.alignItems=labelYalignAlignItems(Li[this.baselinePosition]):this.style.removeProperty(`align-items`)}};customElements.define(`gtk-center-box`,GtkCenterBox);const Ri=new RadioGroupState;var AdwCheckBase=class extends WidgetElement{_input;_indicator;_label;_initialized=!1;get checked(){return this.hasAttribute(`checked`)}set checked(e){this.toggleAttribute(`checked`,!!e)}get active(){return this.checked}set active(e){this.checked=e}get indeterminate(){return this.hasAttribute(`indeterminate`)}set indeterminate(e){this.toggleAttribute(`indeterminate`,!!e)}get disabled(){return this.hasAttribute(`disabled`)}set disabled(e){this.toggleAttribute(`disabled`,!!e)}get label(){return this.getAttribute(`label`)??this._label?.textContent??``}set label(e){this.setAttribute(`label`,e)}connectedCallback(){if(this._initialized){this.onConnected();return}this._initialized=!0;let e=[...this.childNodes];this._input=document.createElement(`input`),this._input.type=this.inputType,this._input.className=`adw-check-input`,this._indicator=document.createElement(`span`),this._indicator.className=`adw-check-indicator`,this._label=document.createElement(`span`),this._label.className=`adw-check-label`;let t=this.getAttribute(`label`);t===null?this._label.append(...e):this._label.textContent=t,this.replaceChildren(this._input,this._indicator,this._label),this._input.addEventListener(`change`,()=>this.activate()),this.addEventListener(`click`,e=>{this.disabled||e.target!==this._input&&this.activate()}),this.onConnected(),this.render()}disconnectedCallback(){this.onDisconnected()}attributeChangedCallback(e){this._initialized&&(e===`label`&&(this._label.textContent=this.getAttribute(`label`)??``),this.render(),e===`active`&&(this.checked=this.hasAttribute(`active`)),e===`checked`&&(this.dispatchEvent(new CustomEvent(`notify::checked`,{bubbles:!0,detail:{checked:this.checked}})),this.dispatchEvent(new CustomEvent(`toggled`,{bubbles:!0})),this.dispatchEvent(new CustomEvent(`notify::active`,{bubbles:!0,detail:{active:this.checked}}))))}onConnected(){}onDisconnected(){}render(){let e=resolveCheckState(this.checked,this.indeterminate);this._input.checked=e===`checked`,this._input.indeterminate=e===`indeterminate`,this._input.setAttribute(`aria-checked`,e===`indeterminate`?`mixed`:String(e===`checked`)),this._input.disabled=this.disabled,this._label.hidden=this._label.childNodes.length===0,forwardAccessibleName(this,this._input)}},zi=class GtkCheckButton extends AdwCheckBase{static signals={toggled:`toggled`,"notify::active":`notify::active`};static get observedAttributes(){return[`checked`,`active`,`indeterminate`,`disabled`,`label`,`group`,...Ni]}get inputType(){return`checkbox`}set group(e){if(typeof e==`string`){this.setAttribute(`group`,e);return}this.set_group(e)}set_group(e){setCheckGroup(this,e),this.render(),e?.render()}get_active(){return this.checked}set_active(e){this.checked=e}attributeChangedCallback(e){if(e===`checked`&&this.checked)for(let e of checkGroupNeighbours(this))e.checked=!1;e===`group`&&this.isConnected&&this._resolveGroup(),super.attributeChangedCallback(e)}onConnected(){this._resolveGroup()}_resolveGroup(){let e=this.getAttribute(`group`);if(e===null)return;let t=this.getRootNode().getElementById?.(e)??document.getElementById(e);if(!(t instanceof GtkCheckButton))throw Error(`gtk-check-button group="${e}" names no gtk-check-button in this document`);this.set_group(t)}render(){if(this._input===void 0)return;super.render();let e=isRadioCheck(this);this.toggleAttribute(`radio`,e),e?this._input.setAttribute(`role`,`radio`):this._input.removeAttribute(`role`)}activate(){if(!checkActivationFlips(this,this.checked)){this.render();return}this.indeterminate=!1,this.checked=!this.checked}},AdwRadio=class extends AdwCheckBase{_unsubscribe=null;static get observedAttributes(){return[`checked`,`indeterminate`,`disabled`,`label`,`name`,`value`,...Ni]}get inputType(){return`radio`}get name(){return this.getAttribute(`name`)??``}set name(e){this.setAttribute(`name`,e)}get value(){return this.getAttribute(`value`)??this.label.trim()}set value(e){this.setAttribute(`value`,e)}activate(){if(this.indeterminate=!1,this.name===``){this.checked=!0;return}Ri.select(this.name,this.value)}onConnected(){this._input.name=this.name,this.name!==``&&(this._unsubscribe??=Ri.subscribe(e=>{e.name===this.name&&(this.checked=e.selected===this.value)}),this.checked&&Ri.select(this.name,this.value))}onDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}render(){super.render(),this._input.name=this.name}};customElements.define(`gtk-check-button`,zi),customElements.define(`adw-radio`,AdwRadio);const Bi={red:.75,green:.25,blue:.25,alpha:1};var GtkColorDialogButton=class extends WidgetElement{_buttonEl;_swatchEl;_inputEl;_dialog=null;_rgba={...Bi};_pending=!1;_initialized=!1;static get observedAttributes(){return[`rgba`,`dialog`,`disabled`]}get rgba(){return{...this._rgba}}set rgba(e){let t=typeof e==`string`?parseCssColor(e):e;t===null||rgbaEqual(t,this._rgba)||(this._rgba=t,this._renderSwatch(),this.dispatchEvent(new CustomEvent(`notify::rgba`,{bubbles:!0,detail:{rgba:this.rgba}})))}get dialog(){return this._dialog}set dialog(e){this._dialog!==e&&(this._dialog=e,e?.title!=null&&(this._inputEl.title=e.title),this._renderSensitivity(),this.dispatchEvent(new CustomEvent(`notify::dialog`,{bubbles:!0,detail:{dialog:e}})))}connectedCallback(){if(this._initialized)return;this._initialized=!0,this.setAttribute(`role`,`group`),this._swatchEl=document.createElement(`span`),this._swatchEl.className=`color-button-swatch`,this._buttonEl=document.createElement(`button`),this._buttonEl.type=`button`,this._buttonEl.className=`adw-button color icon-only`,this._buttonEl.setAttribute(`aria-haspopup`,`dialog`),this._buttonEl.appendChild(this._swatchEl),this._inputEl=document.createElement(`input`),this._inputEl.type=`color`,this._inputEl.className=`color-button-input`,this._inputEl.tabIndex=-1,this._inputEl.setAttribute(`aria-hidden`,`true`),this.replaceChildren(this._buttonEl,this._inputEl),this._buttonEl.addEventListener(`click`,()=>this.activate()),this._inputEl.addEventListener(`change`,()=>{this._pending=!1;let e=parseCssColor(this._inputEl.value);e!==null&&(this.rgba={...e,alpha:this._rgba.alpha}),this._renderSensitivity()}),this.hasAttribute(`dialog`)&&(this.dialog={});let e=this.getAttribute(`rgba`);e!==null&&(this.rgba=e),this._renderSwatch(),this._renderSensitivity()}attributeChangedCallback(e){if(this._initialized){if(e===`rgba`){let e=this.getAttribute(`rgba`);e!==null&&(this.rgba=e);return}if(e===`dialog`){this.dialog=this.hasAttribute(`dialog`)?this._dialog??{}:null;return}this._renderSensitivity()}}activate(){this.dispatchEvent(new CustomEvent(`activate`,{bubbles:!0})),this._choose()}_choose(){this._dialog===null||this._pending||(this._pending=!0,this._renderSensitivity(),this._inputEl.value=formatHex(this._rgba),this._inputEl.click())}_renderSensitivity(){let e=this._dialog!==null&&!this.hasAttribute(`disabled`);this._buttonEl.disabled=!e,this._buttonEl.classList.toggle(`disabled`,!e)}_renderSwatch(){this._swatchEl.style.backgroundColor=formatCssColor(this._rgba),this._swatchEl.dataset.translucent=String(this._rgba.alpha<1);let e=describeColor(this._rgba);this._swatchEl.setAttribute(`aria-label`,e),this._buttonEl.setAttribute(`aria-label`,e)}};customElements.define(`gtk-color-dialog-button`,GtkColorDialogButton);function rgbaEqual(e,t){return e.red===t.red&&e.green===t.green&&e.blue===t.blue&&e.alpha===t.alpha}function scaleRound(e,t){return Math.min(t,Math.max(0,Math.floor(e*t+.5)))}function describeColor(e){let t=[`Red ${scaleRound(e.red,100)}%`,`Green ${scaleRound(e.green,100)}%`,`Blue ${scaleRound(e.blue,100)}%`];return e.alpha<1&&t.push(`Alpha ${scaleRound(e.alpha,100)}%`),t.join(`, `)}function formatHex(e){let channel=e=>Math.round(Math.min(1,Math.max(0,e))*255).toString(16).padStart(2,`0`);return`#${channel(e.red)}${channel(e.green)}${channel(e.blue)}`}function formatCssColor(e){let t=formatHex(e);return e.alpha<1?`${t}${Math.round(e.alpha*255).toString(16).padStart(2,`0`)}`:t}const Vi=/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i;function parseCssColor(e){let t=document.createElement(`span`);t.style.color=``,t.style.color=e.trim();let n=t.style.color;if(n===``)return null;let r=Vi.exec(n);if(r===null)return null;let i=r[4];return{red:Number(r[1])/255,green:Number(r[2])/255,blue:Number(r[3])/255,alpha:i===void 0?1:i.endsWith(`%`)?Number.parseFloat(i)/100:Number(i)}}const Hi=`adw-list-item-label`,defaultListItemFactory=e=>{let t=document.createElement(`span`);return t.className=Hi,t.textContent=e.item.label,t};function attachRubberBand(e){let t=null,n=null,r=null,stop=()=>{t?.remove(),t=null,n=null,r!==null&&e.host.hasPointerCapture(r)&&e.host.releasePointerCapture(r),r=null};e.host.addEventListener(`pointerdown`,i=>{if(i.button!==0||!e.enabled())return;let a=i.target;a!==null&&e.rows().some(e=>e===a||e.contains(a))||(n={x:i.clientX,y:i.clientY},r=i.pointerId,e.host.setPointerCapture(i.pointerId),t=document.createElement(`div`),t.className=`adw-rubberband`,t.setAttribute(`aria-hidden`,`true`),e.surface.appendChild(t))}),e.host.addEventListener(`pointermove`,r=>{if(n===null||t===null)return;let i=e.surface.getBoundingClientRect(),a=Math.min(n.x,r.clientX),o=Math.min(n.y,r.clientY),s=Math.abs(r.clientX-n.x),c=Math.abs(r.clientY-n.y);t.style.left=`${a-i.left}px`,t.style.top=`${o-i.top}px`,t.style.width=`${s}px`,t.style.height=`${c}px`;let l=[];e.rows().forEach((e,t)=>{let n=e.getBoundingClientRect();n.right>=a&&n.left<=a+s&&n.bottom>=o&&n.top<=o+c&&l.push(t)}),e.selectPositions(l)});for(let t of[`pointerup`,`pointercancel`,`lostpointercapture`])e.host.addEventListener(t,stop)}const Ui=new Set([`all`,`item`,`cell`]);function normalizeListTabBehavior$1(e){return e!=null&&Ui.has(e)?e:`all`}__name(normalizeListTabBehavior$1,`normalizeListTabBehavior`);var GtkListView=class extends WidgetElement{_listEl;_rows=[];_state=new ListViewState;_factory=defaultListItemFactory;_initialized=!1;static get observedAttributes(){return[`model`,`selection-mode`,`show-separators`,`single-click-activate`,`enable-rubberband`,`tab-behavior`,`orientation`]}get model(){return this._state.model}set model(e){this._state.setModel(normalizeComboOptions(e))}get factory(){return this._factory}set factory(e){this._factory=typeof e==`function`?e:defaultListItemFactory,this._renderRows()}get selected(){return this._state.selection}set selected(e){let t=typeof e==`number`?[e]:e??[];this._state.setSelection(t)}get selectionMode(){return normalizeListSelectionMode(this.getAttribute(`selection-mode`))}set selectionMode(e){this.setAttribute(`selection-mode`,e)}get showSeparators(){return this.hasAttribute(`show-separators`)}set showSeparators(e){this.toggleAttribute(`show-separators`,!!e)}get singleClickActivate(){return this.hasAttribute(`single-click-activate`)}set singleClickActivate(e){this.toggleAttribute(`single-click-activate`,!!e)}get enableRubberband(){return this.hasAttribute(`enable-rubberband`)}set enableRubberband(e){this.toggleAttribute(`enable-rubberband`,!!e)}get tabBehavior(){return normalizeListTabBehavior$1(this.getAttribute(`tab-behavior`))}set tabBehavior(e){this.setAttribute(`tab-behavior`,e)}get orientation(){return this.getAttribute(`orientation`)===`horizontal`?`horizontal`:`vertical`}set orientation(e){this.setAttribute(`orientation`,e)}connectedCallback(){this._initialized||(this._initialized=!0,this.classList.add(this._viewClass,`view`),this._listEl=document.createElement(`div`),this._listEl.className=`adw-list-view-rows`,this.appendChild(this._listEl),bindSlottedChildren(this,[stringListSlot(e=>this._state.setModel(e))]).install(this._listEl),this._state.count===0&&this._state.setModel(parseListModel(this.getAttribute(`model`))),this._state.setSelectionMode(this.selectionMode),this._state.subscribeItems(e=>this._applyItemsChanged(e)),this._state.subscribeSelection(()=>this._onSelectionChanged()),attachRovingFocus({host:this,orientation:()=>this.orientation,items:()=>this._rows,select:e=>this._selectRow(e,{})}),attachRubberBand({host:this,surface:this._listEl,enabled:()=>this.enableRubberband&&this._state.selectionMode===`multiple`,rows:()=>this._rows,selectPositions:e=>this._state.setSelection(e,!0)}),this._applyAttributes(),this._renderRows())}attributeChangedCallback(e){if(this._initialized){if(e===`model`){this._state.setModel(parseListModel(this.getAttribute(`model`)));return}e===`selection-mode`&&this._state.setSelectionMode(this.selectionMode),this._applyAttributes(),(e===`selection-mode`||e===`tab-behavior`)&&this._renderRows()}}_applyAttributes(){let e=this.orientation;this.classList.toggle(`separators`,this.showSeparators),this.classList.toggle(`horizontal`,e===`horizontal`);let t=this._state.selectionMode!==`none`;this.setAttribute(`role`,t?`listbox`:`list`),this._state.selectionMode===`multiple`?this.setAttribute(`aria-multiselectable`,`true`):this.removeAttribute(`aria-multiselectable`)}get _viewClass(){return`adw-list-view`}get _rowClass(){return`adw-list-view-row`}_renderRows(){if(this._initialized){this._listEl.replaceChildren(),this._rows=[];for(let e=0;e<this._state.count;e++){let t=this._createRow(e);t!==null&&(this._listEl.appendChild(t),this._rows.push(t))}this._syncSelectedStates()}}_createRow(e){let t=this._state.itemContext(e);if(t===null)return null;let n=document.createElement(`div`);return n.className=`${this._rowClass} activatable`,n.setAttribute(`role`,this._state.selectionMode===`none`?`listitem`:`option`),n.tabIndex=this.tabBehavior===`all`?0:-1,n.appendChild(this._factory(t)),n.addEventListener(`click`,e=>{this._selectRow(n,{modify:e.ctrlKey||e.metaKey,extend:e.shiftKey}),this.singleClickActivate&&this._activateRow(n)}),n.addEventListener(`dblclick`,()=>{this.singleClickActivate||this._activateRow(n)}),n.addEventListener(`pointerenter`,()=>{this.singleClickActivate&&this._selectRow(n,{})}),n.addEventListener(`keydown`,e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),e.key===` `?this._selectRow(n,{modify:e.ctrlKey,extend:e.shiftKey}):this._activateRow(n))}),n}_selectRow(e,t){let n=this._rows.indexOf(e);n<0||this._state.selectItem(n,t)}_activateRow(e){let t=this._rows.indexOf(e);t<0||this.dispatchEvent(new CustomEvent(`activate`,{bubbles:!0,detail:{position:t}}))}_onSelectionChanged(){this._syncSelectedStates(),this.dispatchEvent(new CustomEvent(`notify::selected`,{bubbles:!0,detail:{selected:this._state.selection}}))}_syncSelectedStates(){let e=new Set(this._state.selection),t=this.tabBehavior!==`all`,n=e.size>0?Math.min(...e):0;this._rows.forEach((r,i)=>{let a=e.has(i);r.classList.toggle(`selected`,a),this._state.selectionMode===`none`?r.removeAttribute(`aria-selected`):r.setAttribute(`aria-selected`,String(a)),t&&(r.tabIndex=i===n?0:-1)})}_applyItemsChanged(e){if(!this._initialized)return;for(let t of this._rows.splice(e.position,e.removed))t.remove();let t=this._rows[e.position]??null,n=[];for(let r=0;r<e.added;r++){let i=this._createRow(e.position+r);i!==null&&(this._listEl.insertBefore(i,t),n.push(i))}this._rows.splice(e.position,0,...n),this._syncSelectedStates()}};customElements.define(`gtk-list-view`,GtkListView);var GtkColumnView=class extends GtkListView{_headerEl;_columns=[];_factories={};_sorter=null;_dragged=null;static get observedAttributes(){return[`model`,`columns`,`selection-mode`,`single-click-activate`,`enable-rubberband`,`tab-behavior`,`show-row-separators`,`show-column-separators`,`reorderable`]}get columns(){return this._columns.map(e=>({...e}))}set columns(e){this._columns=normalizeColumnViewColumns(e),this._renderHeader(),this._renderRows()}get columnFactories(){return this._factories}set columnFactories(e){this._factories=e??{},this._renderRows()}get sorter(){return this._sorter===null?null:{...this._sorter}}set sorter(e){this._applySorter(e)}get showRowSeparators(){return this.hasAttribute(`show-row-separators`)}set showRowSeparators(e){this.toggleAttribute(`show-row-separators`,!!e)}get showColumnSeparators(){return this.hasAttribute(`show-column-separators`)}set showColumnSeparators(e){this.toggleAttribute(`show-column-separators`,!!e)}get reorderable(){return this.hasAttribute(`reorderable`)}set reorderable(e){this.toggleAttribute(`reorderable`,!!e)}connectedCallback(){let e=this._headerEl===void 0;e&&(this._columns=parseColumnViewColumns(this.getAttribute(`columns`)),this._headerEl=document.createElement(`div`),this._headerEl.className=`adw-column-view-header`,this._headerEl.setAttribute(`role`,`row`)),super.connectedCallback(),e&&this.insertBefore(this._headerEl,this.firstChild),this._renderHeader(),this._renderRows()}attributeChangedCallback(e){if(e===`columns`){this._columns=parseColumnViewColumns(this.getAttribute(`columns`)),this._renderHeader(),this._renderRows();return}super.attributeChangedCallback(e)}_applyAttributes(){super._applyAttributes(),this.classList.toggle(`separators`,this.showRowSeparators),this.classList.toggle(`column-separators`,this.showColumnSeparators),this.setAttribute(`role`,`grid`),this.removeAttribute(`aria-multiselectable`),this.classList.remove(`horizontal`),this._headerEl!==void 0&&this._applyTracks(this._headerEl)}get _viewClass(){return`adw-column-view`}get _rowClass(){return`adw-column-view-row`}_createRow(e){let t=super._createRow(e);if(t===null)return null;t.setAttribute(`role`,`row`),t.replaceChildren();let n=this._state.itemContext(e);if(n!==null)for(let e of this._columns)e.visible!==!1&&t.appendChild(this._createCell(e,n));return this._applyTracks(t),t}_createCell(e,t){let n=document.createElement(`div`);n.className=`adw-column-view-cell`,n.setAttribute(`role`,`gridcell`);let r=this._factories[e.id??e.key];if(r!==void 0)n.appendChild(r(t));else{let r=document.createElement(`span`);r.className=Hi,r.textContent=listItemField(t.item,e.key),n.appendChild(r)}return n}_renderHeader(){if(this._headerEl!==void 0){this._headerEl.replaceChildren();for(let e of this._columns)e.visible!==!1&&this._headerEl.appendChild(this._createHeaderCell(e));this._applyTracks(this._headerEl)}}_createHeaderCell(e){let t=e.id??e.key,n=document.createElement(`button`);n.type=`button`,n.className=`adw-column-view-header-cell`,n.setAttribute(`role`,`columnheader`),n.dataset.columnId=t;let r=document.createElement(`span`);if(r.className=`adw-column-view-header-title`,r.textContent=e.title??e.key,n.appendChild(r),e.sortable===!0){let r=this._sorter!==null&&this._sorter.column===t,i=createGtkImage(`go-down`,`adw-column-view-sort-indicator`);i.classList.toggle(`ascending`,r&&!this._sorter.descending),i.classList.toggle(`descending`,r&&this._sorter.descending),i.hidden=!r,n.appendChild(i),n.setAttribute(`aria-sort`,r?this._sorter.descending?`descending`:`ascending`:`none`),n.addEventListener(`click`,()=>this._applySorter(columnViewSort(this._sorter,e)))}else n.disabled=!0;return this.reorderable&&this._makeDraggable(n,t),n}_makeDraggable(e,t){e.draggable=!0,e.addEventListener(`dragstart`,e=>{this._dragged=t,e.dataTransfer?.setData(`text/plain`,t)}),e.addEventListener(`dragover`,e=>e.preventDefault()),e.addEventListener(`drop`,e=>{e.preventDefault();let n=this._columns.findIndex(e=>(e.id??e.key)===this._dragged),r=this._columns.findIndex(e=>(e.id??e.key)===t);if(this._dragged=null,n<0||r<0||n===r)return;let i=this._columns.splice(n,1);this._columns.splice(r,0,...i),this._renderHeader(),this._renderRows()})}_applySorter(e){let t=e===null&&this._sorter===null||e!==null&&this._sorter!==null&&e.column===this._sorter.column&&e.descending===this._sorter.descending;this._sorter=e===null?null:{...e},!t&&(this._renderHeader(),this.dispatchEvent(new CustomEvent(`notify::sorter`,{bubbles:!0,detail:{sorter:this.sorter}})))}_applyTracks(e){e.style.gridTemplateColumns=dataGridTrackTemplate(columnViewTracks(this._columns))}};customElements.define(`gtk-column-view`,GtkColumnView);var GtkDropDown=class extends WidgetElement{static signals={"notify::selected":`notify::selected`,"notify::selected-item":`notify::selected-item`};_buttonEl;_labelEl;_popoverEl;_listEl;_searchEl=null;_itemButtons=[];_state=new ComboState;_authored=Mt.new(null);_initialized=!1;_typeAheadBuffer=``;_typeAheadTimer=null;static get observedAttributes(){return[`model`,`selected`,`enable-search`,`disabled`]}get model(){return this._state.model}set model(e){this._state.setModel(readModelWrite(e,this._authored))}get options(){return this._state.options}set_model(e){this.model=e}get_model(){return this.model}get selected(){return this._state.selectedIndex}set selected(e){this._selectIndex(e)}get_selected(){return this.selected}set_selected(e){this.selected=e}get selectedValue(){return this._state.selectedValue}set selectedValue(e){let t=this._state.options.findIndex(t=>t.value===e);t>=0&&this._selectIndex(t)}get selectedItem(){return this._state.selectedItem}get_selected_item(){return this.selectedItem}get enableSearch(){return this.hasAttribute(`enable-search`)}set enableSearch(e){e?this.setAttribute(`enable-search`,``):this.removeAttribute(`enable-search`)}get active(){return this._popoverEl?.open??!1}connectedCallback(){if(this._initialized)return;this._initialized=!0,this.classList.add(`adw-drop-down`),this._buttonEl=document.createElement(`button`),this._buttonEl.type=`button`,this._buttonEl.className=`adw-drop-down-button`,this._buttonEl.setAttribute(`aria-haspopup`,`listbox`),this._buttonEl.setAttribute(`aria-expanded`,`false`),this._labelEl=document.createElement(`span`),this._labelEl.className=`adw-drop-down-label`,this._buttonEl.append(this._labelEl,createGtkImage(`go-down`,`adw-drop-down-arrow`)),this._buttonEl.addEventListener(`click`,()=>{this.hasAttribute(`disabled`)||!this._popoverEl.open&&this._state.count===0||(this._popoverEl.open=!this._popoverEl.open)}),this._buttonEl.addEventListener(`keydown`,e=>this._onButtonKeyDown(e)),this._popoverEl=document.createElement(`gtk-popover`),this._popoverEl.classList.add(`adw-drop-down-popover`),this._popoverEl.setAttribute(`role`,`listbox`),this._popoverEl.setAttribute(`menu`,``),this._listEl=document.createElement(`div`),this._listEl.className=`adw-drop-down-list`,this._popoverEl.appendChild(this._listEl),bindSlottedChildren(this,[stringListSlot(e=>{this._authored.reconcile(e),this._state.setModel(this._authored)})]).install(this._buttonEl,this._popoverEl);let e=this.getAttribute(`model`);this._state.model===null&&e!==null&&(this._authored.reconcile(parseListModel(e)),this._state.setModel(this._authored));let t=Number.parseInt(this.getAttribute(`selected`)??``,10);this._state.hasIndex(t)&&this._state.setSelectedIndex(t),this._state.subscribeItems(e=>this._applyItemsChanged(e)),this._state.subscribe(()=>{this._updateLabel(),this._updateSelectedStates()}),this._popoverEl.anchor=this._buttonEl,this._popoverEl.subscribe(e=>this._onPopoverToggled(e)),this._popoverEl.addEventListener(`keydown`,e=>this._onPopoverTypeAhead(e)),this._renderAll()}attributeChangedCallback(e,t,n){if(!(!this._initialized||!this._buttonEl))if(e===`model`)this.model=n;else if(e===`selected`){let e=Number.parseInt(n??``,10);Number.isNaN(e)||this._selectIndex(e,{fromAttr:!0})}else e===`enable-search`?this._renderPopover():e===`disabled`&&(this._buttonEl.disabled=this.hasAttribute(`disabled`),this.hasAttribute(`disabled`)&&this._popoverEl.popdown())}_selectIndex(e,t={}){if(!this._state.hasIndex(e))return;let n=t.fromUser?this._state.select(e):this._state.setSelectedIndex(e);if(this._updateLabel(),this._updateSelectedStates(),!t.fromAttr&&this.getAttribute(`selected`)!==String(e)&&this.setAttribute(`selected`,String(e)),n){let n=this._state.selectedItem;this.dispatchEvent(new CustomEvent(`notify::selected`,{bubbles:!0,detail:{selected:e}})),this.dispatchEvent(new CustomEvent(`notify::selected-item`,{bubbles:!0,detail:{"selected-item":n??null}})),t.fromUser&&this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{index:e,value:this._state.selectedValue,label:this._state.selectedLabel}}))}}_onPopoverToggled(e){if(this.classList.toggle(`active`,e),this._buttonEl.setAttribute(`aria-expanded`,String(e)),e)if(this._filter(``),this._searchEl)this._searchEl.value=``,this._searchEl.focus();else{let e=this._visibleItems();(e[this._state.selectedIndex]??e[0])?.focus()}}_onButtonKeyDown(e){this.hasAttribute(`disabled`)||(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`||e.key===` `?(e.preventDefault(),this._state.count>0&&this._popoverEl.popup()):e.key.length===1&&!this._popoverEl.open&&this._typeAhead(e.key))}_onPopoverTypeAhead(e){this._searchEl||e.key.length===1&&this._typeAhead(e.key)}_typeAhead(e){this._typeAheadBuffer+=e.toLowerCase(),this._typeAheadTimer&&clearTimeout(this._typeAheadTimer),this._typeAheadTimer=setTimeout(()=>this._typeAheadBuffer=``,800);let t=this._state.options.findIndex(e=>e.label.toLowerCase().startsWith(this._typeAheadBuffer));t<0||(this._popoverEl.open?this._itemButtons[t]?.focus():this._selectIndex(t,{fromUser:!0}))}_filter(e){let t=e.trim().toLowerCase(),n=this._state.options;this._itemButtons.forEach((e,r)=>{e.hidden=!(t.length===0||(n[r]?.label.toLowerCase().includes(t)??!1))})}_visibleItems(){return this._itemButtons.filter(e=>!e.hidden)}_renderAll(){this._buttonEl.disabled=this.hasAttribute(`disabled`),this.classList.toggle(`disabled`,this.hasAttribute(`disabled`)),this._renderPopover(),this._updateLabel()}_updateLabel(){this._labelEl&&(this._labelEl.textContent=this._state.selectedLabel)}_updateSelectedStates(){this._itemButtons.forEach((e,t)=>{let n=t===this._state.selectedIndex;e.classList.toggle(`selected`,n),e.setAttribute(`aria-selected`,String(n))})}_renderPopover(){if(this._listEl.replaceChildren(),this._itemButtons=[],this._searchEl=null,this.enableSearch)this._searchEl=document.createElement(`input`),this._searchEl.type=`text`,this._searchEl.className=`adw-drop-down-search adw-entry`,this._searchEl.placeholder=`Search…`,this._searchEl.setAttribute(`aria-label`,`Search`),this._searchEl.addEventListener(`input`,()=>this._filter(this._searchEl?.value??``)),this._popoverEl.insertBefore(this._searchEl,this._listEl);else{let e=this._popoverEl.querySelector(`.adw-drop-down-search`);e&&e.remove()}for(let e of this._state.options){let t=this._createItem(e);this._listEl.appendChild(t),this._itemButtons.push(t)}this._updateSelectedStates(),this._state.count===0&&this._popoverEl.popdown()}_createItem(e){let t=document.createElement(`button`);t.type=`button`,t.className=`adw-popover-item adw-drop-down-item`,t.setAttribute(`role`,`option`),t.tabIndex=-1;let n=document.createElement(`span`);n.className=`adw-drop-down-item-label`,n.textContent=e.label;let r=document.createElement(`span`);return r.className=`adw-drop-down-item-check`,r.setAttribute(`aria-hidden`,`true`),t.append(n,r),t.addEventListener(`click`,()=>{let e=this._itemButtons.indexOf(t);e<0||(this._selectIndex(e,{fromUser:!0}),this._popoverEl.popdown(),this._buttonEl.focus())}),t}_applyItemsChanged(e){if(!this._initialized)return;for(let t of this._itemButtons.splice(e.position,e.removed))t.remove();let t=this._itemButtons[e.position]??null,n=[],r=this._state.options;for(let i=0;i<e.added;i++){let a=r[e.position+i];if(!a)continue;let o=this._createItem(a);this._listEl.insertBefore(o,t),n.push(o)}this._itemButtons.splice(e.position,0,...n),this._updateSelectedStates(),this._updateLabel(),this._state.count===0&&this._popoverEl.popdown()}};customElements.define(`gtk-drop-down`,GtkDropDown);const Wi=2147483647;function intAttribute(e,t){let n=Number.parseInt(e.getAttribute(t)??``,10);return Number.isFinite(n)?n:0}var GtkDrawingArea=class extends WidgetElement{_canvas;_context=null;_initialized=!1;_drawFunc=null;_width=-1;_height=-1;_scale=1;_resize=null;_frame=null;static get observedAttributes(){return[`content-width`,`content-height`]}get contentWidth(){return intAttribute(this,`content-width`)}set contentWidth(e){this._write(`content-width`,String(glibClamp(Math.trunc(e)||0,0,Wi)))}get contentHeight(){return intAttribute(this,`content-height`)}set contentHeight(e){this._write(`content-height`,String(glibClamp(Math.trunc(e)||0,0,Wi)))}_write(e,t){this.getAttribute(e)!==t&&this.setAttribute(e,t)}get drawFunc(){return this._drawFunc}set drawFunc(e){this.setDrawFunc(e)}setDrawFunc(e){this._drawFunc=e,this.queueDraw()}queueDraw(){!this._initialized||this._frame!==null||(this._frame=requestAnimationFrame(()=>{this._frame=null,this._draw()}))}connectedCallback(){if(this._initialized){this._observe();return}this._initialized=!0,this._canvas=document.createElement(`canvas`),this._canvas.className=`adw-drawing-area-canvas`,this._context=this._canvas.getContext(`2d`),this.replaceChildren(this._canvas),this._publishSize(),this._observe()}disconnectedCallback(){this._resize?.disconnect(),this._resize=null,this._frame!==null&&cancelAnimationFrame(this._frame),this._frame=null}attributeChangedCallback(e){this._initialized&&((e===`content-width`||e===`content-height`)&&this._publishSize(),this._notify(e),(e===`content-width`||e===`content-height`)&&this.queueDraw())}_publishSize(){let e=[[`--adw-drawing-width`,this.contentWidth],[`--adw-drawing-height`,this.contentHeight]];for(let[t,n]of e)n>0?this.style.setProperty(t,`${n}px`):this.style.removeProperty(t)}_observe(){this._resize||(this._resize=new ResizeObserver(e=>{for(let t of e){let e=t.borderBoxSize?.[0];this._allocated(e?e.inlineSize:t.contentRect.width,e?e.blockSize:t.contentRect.height)}}),this._resize.observe(this))}_allocated(e,t){let n=e!==this._width||t!==this._height;this._width=e,this._height=t,n&&this.dispatchEvent(new CustomEvent(`resize`,{bubbles:!0,detail:{width:e,height:t}})),this._draw()}_draw(){if(!this._canvas||this._width<0)return;let e=this._width,t=this._height,n=this._devicePixelRatio(),r=Math.round(e*n),i=Math.round(t*n);this._canvas.width!==r&&(this._canvas.width=r),this._canvas.height!==i&&(this._canvas.height=i),this._scale=n;let a=this._context;a&&(a.setTransform(n,0,0,n,0,0),a.clearRect(0,0,e,t),this._drawFunc&&this._drawFunc(this,a,e,t))}_devicePixelRatio(){return typeof globalThis>`u`?1:globalThis.devicePixelRatio||1}_notify(e){let t=e===`content-width`?this.contentWidth:this.contentHeight;this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:t}}))}get allocation(){return{width:this._width,height:this._height}}get pixelScale(){return this._scale}};customElements.define(`gtk-drawing-area`,GtkDrawingArea);const Gi=new WeakMap;var Ki=class GtkDragIcon extends WidgetElement{_pointerX=0;_pointerY=0;_dragging=!1;_onDragOver=null;_onDragEnd=null;_transfer=null;static get observedAttributes(){return[]}static getForDrag(e){let t=e.dataTransfer,n=t===null?void 0:Gi.get(t);if(n!==void 0)return n;let r=document.querySelector(`gtk-drag-icon`),i=r instanceof GtkDragIcon&&!r.dragging?r:null,a=i??document.createElement(`gtk-drag-icon`);return i===null&&document.body.appendChild(a),t!==null&&Gi.set(t,a),a.beginDrag(e),a}static createWidgetForValue(e){if(typeof e==`string`){let t=document.createElement(`gtk-label`);return t.setAttribute(`label`,e),t}if(e===null)return null;let t=document.createElement(`div`);t.className=`adw-drag-icon-swatch`;let n=e.alpha??1;return t.style.backgroundColor=`rgba(${Math.round(e.red*255)}, ${Math.round(e.green*255)}, ${Math.round(e.blue*255)}, ${n})`,t}get child(){return this.firstElementChild}set child(e){this.child!==e&&(this.replaceChildren(),e!==null&&this.appendChild(e),this.dispatchEvent(new CustomEvent(`notify::child`,{bubbles:!0,detail:{child:e}})))}setChild(e){this.child=e,e!==null&&this._render()}connectedCallback(){this.style.pointerEvents=`none`,bindSlottedChildren(this,[{name:`child`,into:this}]),this._dragging&&this._observe()}disconnectedCallback(){this._unobserve()}beginDrag(e){let t=e.dataTransfer;if(t!==null)try{let e=document.createElement(`canvas`);e.width=1,e.height=1,t.setDragImage(e,0,0)}catch{}this._pointerX=e.clientX,this._pointerY=e.clientY,this._transfer=t,this._dragging=!0,this._observe(),this._render()}endDrag(){this._dragging=!1,this._transfer=null,this._unobserve(),this.hidden=!0}get dragging(){return this._dragging}_observe(){this._onDragOver===null&&(this._onDragOver=e=>{this._pointerX=e.clientX,this._pointerY=e.clientY,this._render()},this._onDragEnd=e=>{(e.dataTransfer===null||e.dataTransfer===this._transfer)&&this.endDrag()},document.addEventListener(`dragover`,this._onDragOver),document.addEventListener(`dragend`,this._onDragEnd))}_unobserve(){this._onDragOver!==null&&document.removeEventListener(`dragover`,this._onDragOver),this._onDragEnd!==null&&document.removeEventListener(`dragend`,this._onDragEnd),this._onDragOver=null,this._onDragEnd=null}_render(){this.hidden=!this._dragging,this._dragging&&(this.style.left=`0px`,this.style.top=`0px`,this.style.transform=`translate3d(${Math.round(this._pointerX)}px, ${Math.round(this._pointerY)}px, 0)`)}};customElements.define(`gtk-drag-icon`,Ki);var GtkEditableLabel=class extends WidgetElement{_label;_entry;_initialized=!1;_grace=null;static get observedAttributes(){return[`text`,`editable`,`editing`]}get text(){return this.getAttribute(`text`)??``}set text(e){this.setAttribute(`text`,e??``)}get editable(){let e=this.getAttribute(`editable`);return e===null?!0:e!==`false`}set editable(e){e?this.removeAttribute(`editable`):this.setAttribute(`editable`,`false`)}get editing(){return this.hasAttribute(`editing`)}set editing(e){this.toggleAttribute(`editing`,!!e)}startEditing(){this.editable&&(this.editing=!0)}stopEditing(e=!1){this.editing&&=(e&&this.setAttribute(`text`,this._entry.value),!1)}get entry(){return this._entry}connectedCallback(){this._initialized||(this._initialized=!0,this._label=document.createElement(`span`),this._label.className=`adw-editable-label-label`,this._label.addEventListener(`click`,()=>this.startEditing()),this._entry=document.createElement(`input`),this._entry.className=`adw-editable-label-entry`,this._entry.type=`text`,this._entry.tabIndex=-1,this._entry.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),this.stopEditing(!0)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.stopEditing(!1))}),this.replaceChildren(this._label,this._entry),this.addEventListener(`keydown`,e=>{this.editing||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),this.startEditing())}),this.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t instanceof Node&&this.contains(t)||(this._grace!==null&&clearTimeout(this._grace),this._grace=setTimeout(()=>{this._grace=null,this.editing&&this.stopEditing(!0)},100))}),this._render())}disconnectedCallback(){this._grace!==null&&clearTimeout(this._grace),this._grace=null}attributeChangedCallback(e,t,n){if(this._initialized)switch(e){case`text`:this.editing||this._render();break;case`editable`:n===`false`&&this.stopEditing(!1);break;case`editing`:this._render(),this.editing?this._entry.focus():this.focus(),this.dispatchEvent(new CustomEvent(`notify::editing`,{bubbles:!0,detail:{editing:this.editing}}));break}}_render(){let e=this.editing;this.classList.toggle(`editing`,e),this._label.hidden=e,this._entry.hidden=!e,this._label.textContent=this.text,this._entry.value=this.text,e?this.removeAttribute(`tabindex`):this.setAttribute(`tabindex`,`0`)}};customElements.define(`gtk-editable-label`,GtkEditableLabel);function row(e,t,n=``){return{text:e,name:t,keywords:n===``?[]:n.split(` `)}}const qi=[`🏻`,`🏼`,`🏽`,`🏾`,`🏿`];function hasVariations(e){return[...e.text].some(e=>qi.includes(e))}const Ji=[row(`😀`,`grinning face`,`smile happy joy grin`),row(`😃`,`grinning face with big eyes`,`smile happy joy`),row(`😄`,`grinning face with smiling eyes`,`smile happy joy`),row(`😁`,`beaming face with smiling eyes`,`smile happy`),row(`😂`,`face with tears of joy`,`laugh joy cry`),row(`🤣`,`rolling on the floor laughing`,`laugh rofl joy`),row(`🙂`,`slightly smiling face`,`smile`),row(`😉`,`winking face`,`wink joke flirt`),row(`😊`,`smiling face with smiling eyes`,`blush happy`),row(`😇`,`smiling face with halo`,`angel innocent`),row(`🥰`,`smiling face with hearts`,`love affection`),row(`😍`,`smiling face with heart-eyes`,`love crush`),row(`😘`,`face blowing a kiss`,`kiss love`),row(`😗`,`kissing face`,`kiss love`),row(`☺️`,`smiling face`,`smile happy`),row(`😋`,`face savoring food`,`yum delicious tasty`),row(`😛`,`face with tongue`,`tongue silly`),row(`🤪`,`zany face`,`crazy goofy wild`),row(`😟`,`worried face`,`worried sad`),row(`🙁`,`slightly frowning face`,`sad frown`),row(`☹️`,`frowning face`,`sad frown`),row(`😮`,`face with open mouth`,`surprised wow`),row(`😲`,`astonished face`,`surprised wow`),row(`😳`,`flushed face`,`blush embarrassed`),row(`🥺`,`pleading face`,`please puppy`),row(`😦`,`frowning face with open mouth`,`frown disappointed`),row(`😨`,`fearful face`,`fear scared`),row(`😰`,`anxious face with sweat`,`nervous anxious`),row(`😢`,`crying face`,`cry sad tear`),row(`😭`,`loudly crying face`,`cry sad sob`),row(`😶`,`face without mouth`,`silent speechless`),row(`😏`,`smirking face`,`smirk`),row(`😒`,`unamused face`,`meh unhappy`),row(`🙄`,`face with rolling eyes`,`eyeroll annoyed`),row(`😬`,`grimacing face`,`grimace awkward`),row(`🤥`,`lying face`,`liar pinocchio`),row(`😎`,`smiling face with sunglasses`,`cool sunglasses`),row(`🤓`,`nerd face`,`nerd geek glasses`),row(`🧐`,`face with monocle`,`fancy monocle`),row(`🧑`,`person`,`adult human`),row(`👨`,`man`,`adult male`),row(`👩`,`woman`,`adult female`),row(`👧`,`girl`,`child female`),row(`👦`,`boy`,`child male`),row(`👶`,`baby`,`child infant`),row(`👶🏻`,`child: light skin tone`,`child skin tone`),row(`🧑💻`,`technologist`,`coder computer`),row(`👷`,`construction worker`,`builder work`),row(`🕵️`,`detective`,`spy sleuth`),row(`🤴`,`prince`,`crown royal`),row(`👸`,`princess`,`crown royal`),row(`👰`,`person with veil`,`bride wedding`),row(`🤵`,`person in tuxedo`,`formal groom`),row(`🎅`,`Santa Claus`,`christmas santa`),row(`🤶`,`Mrs. Claus`,`christmas santa`),row(`🦸`,`superhero`,`hero power`),row(`🦹`,`supervillain`,`villain power`),row(`🧙`,`mage`,`wizard magic`),row(`🧚`,`fairy`,`magic wings`),row(`🧛`,`vampire`,`dracula horror`),row(`🧜`,`merperson`,`mermaid merman`),row(`🧝`,`elf`,`fantasy pointy`),row(`🧟`,`zombie`,`undead horror`),row(`💆`,`person getting massage`,`spa head`),row(`💇`,`person getting haircut`,`barber salon`),row(`🚶`,`person walking`,`walk pedestrian`),row(`🏃`,`person running`,`run marathon`),row(`💃`,`woman dancing`,`dance ballet`),row(`👪`,`family`,`parents child`),row(`🧑🤝🧑`,`people holding hands`,`family couple`)],Yi=[row(`👋`,`waving hand`,`wave hello goodbye`),row(`✋️`,`raised hand`,`stop highfive`),row(`👍`,`thumbs up`,`like yes approve`),row(`👎`,`thumbs down`,`dislike no`),row(`👌`,`OK hand`,`ok perfect`),row(`👏`,`clapping hands`,`applause praise`),row(`👐`,`open hands`,`hug open`),row(`🙌`,`raising hands`,`celebrate praise`),row(`🙏`,`folded hands`,`pray thanks`),row(`🤝`,`handshake`,`deal agreement`),row(`🤘`,`sign of the horns`,`rock metal`),row(`👈`,`backhand index pointing left`,`point direction`),row(`👉`,`backhand index pointing right`,`point direction`),row(`☝️`,`index pointing up`,`point one`),row(`✍️`,`writing hand`,`write pen`),row(`🤞`,`crossed fingers`,`luck hope`),row(`💪`,`flexed biceps`,`muscle strong`),row(`🧠`,`brain`,`mind smart`),row(`👀`,`eyes`,`look see watch`),row(`🧣`,`ear`,`hear listen`),row(`👃`,`nose`,`smell`),row(`🦰`,`red hair`,`ginger hair`),row(`🛀`,`bathing`,`bath shower`),row(`🛍`,`shower`,`bath clean`),row(`🦽`,`probing cane`,`blind accessibility`),row(`🦼`,`motorized wheelchair`,`accessibility`),row(`🦯`,`person with white cane`,`blind accessibility`),row(`🏋️`,`weight lifting`,`gym sport`),row(`👫`,`woman and man holding hands`,`couple family`),row(`👬`,`men holding hands`,`couple`),row(`👭`,`women holding hands`,`couple`),row(`💏`,`kiss`,`love couple`),row(`💑`,`couple with heart`,`love wedding`),row(`👮`,`police officer`,`cop law`),row(`👷`,`person with skullcap`,`worker`),row(`🥷`,`ninja`,`martialarts`),row(`🧗`,`person climbing`,`sport`),row(`🤸`,`person cartwheeling`,`gymnastics`),row(`🤼`,`people wrestling`,`sport wrestle`),row(`👯`,`people with bunny ears`,`costume`),row(`🧕`,`woman with headscarf`,`hijab clothing`),row(`👞`,`man’s shoe`,`clothing`),row(`👕`,`t-shirt`,`clothing shirt`),row(`👖`,`jeans`,`clothing trousers`),row(`👔`,`necktie`,`clothing formal`),row(`👗`,`dress`,`clothing`),row(`👘`,`kimono`,`clothing`),row(`🥻`,`sari`,`clothing`),row(`👙`,`bikini`,`clothing swimsuit`),row(`👚`,`woman’s clothes`,`clothing dress`),row(`🩱`,`one-piece swimsuit`,`clothing swimsuit`),row(`👑`,`woman’s hat`,`clothing`),row(`👒`,`glasses`,`clothing eyewear`),row(`🎩`,`top hat`,`clothing`),row(`🎓`,`graduation cap`,`clothing education`),row(`🧢`,`billed cap`,`clothing hat`),row(`👜`,`running shoe`,`clothing sneaker`),row(`👡`,`woman’s heel`,`clothing shoe`),row(`🛠️`,`hammer and wrench`,`tool repair`)],Xi=[row(`🐒`,`monkey`,`animal primate`),row(`🦍`,`gorilla`,`animal ape`),row(`🐕`,`dog`,`animal pet`),row(`🐶`,`dog face`,`animal pet`),row(`🐩`,`poodle`,`dog animal`),row(`🐺`,`wolf`,`animal`),row(`🦊`,`fox`,`animal`),row(`🐱`,`cat face`,`animal pet`),row(`🦁`,`lion`,`animal cat`),row(`🐯`,`tiger face`,`animal cat`),row(`🐅`,`tiger`,`animal`),row(`🐆`,`leopard`,`animal cat`),row(`🐴`,`horse face`,`animal`),row(`🦄`,`unicorn`,`animal fantasy`),row(`ᾬ`,`unicorn face`,`animal fantasy`),row(`🦓`,`zebra`,`animal`),row(`🦌`,`deer`,`animal`),row(`🐮`,`cow face`,`animal`),row(`🐷`,`pig face`,`animal`),row(`🐪`,`camel`,`animal desert`),row(`🦒`,`giraffe`,`animal`),row(`🐘`,`elephant`,`animal`),row(`🦛`,`rhinoceros`,`animal`),row(`🐰`,`rabbit face`,`animal pet`),row(`🐻`,`bear`,`animal`),row(`🐨`,`koala`,`animal`),row(`🐼`,`panda`,`animal`),row(`🦥`,`sloth`,`animal`),row(`🦦`,`otter`,`animal`),row(`🦘`,`kangaroo`,`animal`),row(`🐔`,`chicken`,`bird animal`),row(`🐧`,`penguin`,`bird animal`),row(`🦆`,`duck`,`bird animal`),row(`🦉`,`owl`,`bird animal`),row(`🐸`,`frog`,`animal`),row(`🐢`,`turtle`,`animal reptile`),row(`🐍`,`snake`,`animal reptile`),row(`🐳`,`dragon face`,`animal fantasy`),row(`🦖`,`T-Rex`,`animal dinosaur`),row(`🐬`,`dolphin`,`animal sea`),row(`🦈`,`shark`,`animal sea`),row(`🐙`,`octopus`,`animal sea`),row(`🐛`,`bug`,`animal insect`),row(`🦋`,`butterfly`,`animal insect`),row(`🕷️`,`spider`,`animal insect`),row(`🌸`,`cherry blossom`,`flower spring`),row(`🌺`,`hibiscus`,`flower`),row(`🌻`,`sunflower`,`flower sun`),row(`🌷`,`tulip`,`flower`),row(`🌱`,`seedling`,`plant nature`),row(`🌲`,`evergreen tree`,`plant nature`),row(`🌳`,`deciduous tree`,`plant nature`),row(`🌴`,`palm tree`,`plant nature`),row(`🌵`,`cactus`,`plant`),row(`🍀`,`four leaf clover`,`plant luck`),row(`🍁`,`maple leaf`,`plant autumn`),row(`🍂`,`fallen leaf`,`plant autumn`),row(`🍃`,`leaf fluttering in wind`,`plant wind`)],Zi=[row(`🍇`,`grapes`,`fruit`),row(`🍈`,`melon`,`fruit`),row(`🍉`,`watermelon`,`fruit`),row(`🍊`,`tangerine`,`fruit citrus`),row(`🍋`,`lemon`,`fruit citrus`),row(`🍌`,`banana`,`fruit`),row(`🍍`,`pineapple`,`fruit`),row(`🍎`,`red apple`,`fruit`),row(`🍐`,`pear`,`fruit`),row(`🍑`,`peach`,`fruit`),row(`🍒`,`cherries`,`fruit`),row(`🍓`,`strawberry`,`fruit`),row(`🥝`,`kiwi fruit`,`fruit`),row(`🍏`,`tomato`,`fruit vegetable`),row(`🥐`,`croissant`,`food bread`),row(`🥖`,`flatbread`,`food bread`),row(`🥨`,`pretzel`,`food`),row(`🥯`,`bagel`,`food bread`),row(`🥞`,`pancakes`,`food breakfast`),row(`🧀`,`cheese wedge`,`food dairy`),row(`🍖`,`meat on bone`,`food`),row(`🍗`,`poultry leg`,`food chicken`),row(`🥩`,`cut of meat`,`food`),row(`🥓`,`bacon`,`food`),row(`🍔`,`hamburger`,`food`),row(`🍟`,`french fries`,`food`),row(`🍕`,`pizza`,`food`),row(`🌭`,`hot dog`,`food`),row(`🥪`,`sandwich`,`food lunch`),row(`🌮`,`taco`,`food`),row(`🌯`,`burrito`,`food`),row(`🥗`,`green salad`,`food vegetable`),row(`🍿`,`popcorn`,`food snack`),row(`🍣`,`sushi`,`food japanese`),row(`🍤`,`fish cake with swirl`,`food`),row(`🍥`,`soft ice cream`,`food dessert`),row(`🍦`,`soft serve`,`food dessert`),row(`🍨`,`ice cream`,`food dessert`),row(`🎂`,`birthday cake`,`food dessert`),row(`🧁`,`cupcake`,`food dessert`),row(`🥧`,`pie`,`food dessert`),row(`🍫`,`chocolate bar`,`food dessert`),row(`🍬`,`candy`,`food sweet`),row(`🍭`,`lollipop`,`food sweet`),row(`☕`,`hot beverage`,`drink coffee tea`),row(`🫖`,`teapot`,`drink tea`),row(`🍶`,`teacup without handle`,`drink tea`),row(`🍷`,`wine glass`,`drink`),row(`🍸`,`cocktail glass`,`drink`),row(`🍺`,`beer mug`,`drink`),row(`🥂`,`clinking glasses`,`drink cheers`),row(`🥢`,`chopsticks`,`food utensil`),row(`🍴`,`fork and knife`,`food utensil`),row(`🥄`,`spoon`,`food utensil`)],Qi=[row(`🌍`,`globe showing Europe-Africa`,`world earth`),row(`🌎`,`globe showing Americas`,`world earth`),row(`🌏`,`globe showing Asia-Australia`,`world earth`),row(`🗺️`,`world map`,`map`),row(`⛰️`,`mountain`,`travel nature`),row(`🌋`,`volcano`,`travel nature`),row(`🏕️`,`camping`,`travel nature`),row(`🏖️`,`beach with umbrella`,`travel sea`),row(`🏜`,`desert`,`travel nature`),row(`🏝️`,`desert island`,`travel sea`),row(`🏞️`,`national park`,`travel nature`),row(`🏟️`,`stadium`,`travel sport`),row(`🏛️`,`classical building`,`travel`),row(`🏗️`,`buildings`,`travel`),row(`🏠`,`house`,`home building`),row(`🏡`,`house with garden`,`home`),row(`🏢`,`office building`,`work`),row(`🏤`,`post office`,`building`),row(`🏥`,`hospital`,`building health`),row(`🏨`,`hotel`,`travel building`),row(`🏪`,`convenience store`,`building shop`),row(`🏫`,`school`,`building education`),row(`🏯`,`castle`,`building`),row(`⛪`,`church`,`building religion`),row(`⛩️`,`shinto torii gate`,`japan`),row(`🛑`,`fountain`,`building`),row(`🗼️`,`tower`,`building`),row(`🗽`,`Statue of Liberty`,`travel usa`),row(`🗛️`,`Mount Rushmore`,`travel usa`),row(`🧲`,`carousel horse`,`travel fair`),row(`🚀`,`rocket`,`travel space`),row(`🛸`,`flying saucer`,`travel space`),row(`🛎️`,`bellhop bell`,`travel hotel`),row(`🧳`,`luggage`,`travel`),row(`🧭`,`compass`,`travel navigate`),row(`⌛️`,`hourglass done`,`time`),row(`⏰`,`alarm clock`,`time`),row(`🚂`,`locomotive`,`travel train`),row(`🚆`,`train`,`travel`),row(`🚇`,`metro`,`travel subway`),row(`🚉`,`station`,`travel`),row(`🚌`,`bus`,`travel`),row(`🚑`,`ambulance`,`emergency`),row(`🚓`,`police car`,`emergency`),row(`🚕`,`taxi`,`travel`),row(`🚗`,`automobile`,`travel car`),row(`🚙`,`sport utility vehicle`,`car`),row(`🚲`,`bicycle`,`vehicle`),row(`🛴`,`kick scooter`,`vehicle`),row(`⛺`,`tent`,`travel camping`)],$i=[row(`🎃`,`jack-o-lantern`,`halloween pumpkin`),row(`🎄`,`Christmas tree`,`christmas`),row(`🎆`,`fireworks`,`celebration`),row(`✨`,`sparkles`,`celebration magic`),row(`🎈`,`balloon`,`party`),row(`🎉`,`party popper`,`party celebration`),row(`🎊`,`confetti ball`,`party`),row(`🎁`,`wrapped gift`,`present birthday`),row(`🎗️`,`reminder ribbon`,`awareness`),row(`🎫`,`ticket`,`event`),row(`🏆`,`trophy`,`award win`),row(`🥇`,`1st place medal`,`award win`),row(`🎾`,`tennis`,`sport`),row(`🏈`,`American football`,`sport`),row(`🏑`,`field hockey`,`sport`),row(`🏒`,`ice hockey`,`sport`),row(`🎳`,`bowling`,`sport`),row(`🏐`,`volleyball`,`sport`),row(`🥎`,`lacrosse`,`sport`),row(`⚽`,`soccer ball`,`sport football`),row(`⚾`,`baseball`,`sport`),row(`🏊`,`swimming`,`sport`),row(`🎿`,`skis`,`sport winter`),row(`⛷️`,`skier`,`sport winter`),row(`🛹`,`skateboard`,`sport`),row(`🎽`,`running shirt`,`sport`),row(`🎯`,`bullseye`,`sport game target`),row(`🎱`,`pool 8 ball`,`game`),row(`🎲`,`game die`,`game dice`),row(`🃏`,`joker`,`game cards`),row(`🕹️`,`joystick`,`game`),row(`🎮`,`video game`,`game`),row(`🧩`,`puzzle piece`,`game`),row(`🧸`,`teddy bear`,`toy`),row(`🪅`,`pinata`,`toy party`),row(`🪆`,`nesting dolls`,`toy`),row(`🎭`,`performing arts`,`theatre`),row(`🎼`,`musical score`,`music`),row(`🎤`,`microphone`,`music sing`),row(`🎧`,`headphones`,`music listen`),row(`🎸`,`guitar`,`music`),row(`🥁`,`drum`,`music`),row(`🎨`,`artist palette`,`art paint`),row(`🖌️`,`paintbrush`,`art paint`),row(`🧵`,`thread`,`sew`),row(`🪡`,`sewing needle`,`sew`)],ea=[row(`🧱`,`brick`,`object build`),row(`🪑`,`shovel`,`object tool`),row(`🪩`,`mirror ball`,`object`),row(`🧯`,`fire extinguisher`,`object safety`),row(`🛠️`,`hammer and wrench`,`tool`),row(`⚒️`,`hammer and pick`,`tool`),row(`🔧`,`wrench`,`tool`),row(`🪛`,`screwdriver`,`tool`),row(`⚙️`,`gear`,`tool cog`),row(`🗜️`,`clamp`,`tool`),row(`🔒`,`locked with key`,`object security`),row(`🔓`,`unlocked`,`object security`),row(`🔑`,`key`,`object`),row(`🗝️`,`old key`,`object`),row(`🔨`,`hammer`,`tool`),row(`🔫`,`water pistol`,`object toy`),row(`🪓`,`carpentry saw`,`tool`),row(`💡`,`light bulb`,`object idea`),row(`🔦`,`flashlight`,`object`),row(`🔬`,`microscope`,`object lab`),row(`🔭`,`telescope`,`object`),row(`💻`,`laptop`,`object computer`),row(`🖥️`,`desktop computer`,`object computer`),row(`🖨️`,`printer`,`object office`),row(`⌨️`,`keyboard`,`object computer`),row(`🖱️`,`computer mouse`,`object computer`),row(`💾`,`floppy disk`,`object`),row(`📚`,`books`,`object reading`),row(`📓`,`notebook`,`object writing`),row(`📊`,`bar chart`,`object data`),row(`📋`,`clipboard`,`object office`),row(`📌`,`pushpin`,`object office`),row(`📎`,`paperclip`,`object office`),row(`📏`,`straight ruler`,`object office`),row(`✂️`,`scissors`,`object office`),row(`🗑️`,`card file box`,`object office`),row(`🗒️`,`file cabinet`,`object office`),row(`🗓️`,`wastebasket`,`object office`),row(`🧼`,`window`,`object house`),row(``,`elevator`,`object building`),row(`🛝`,`radio`,`object`),row(`🛞`,`video camera`,`object record`),row(`⚯`,`white flag`,`object surrender`)],ta=[row(`🔠`,`input latin letters`,`symbol text`),row(`🔡`,`lowercase`,`symbol text`),row(`🔢`,`uppercase`,`symbol text`),row(`🅰️`,`A button`,`symbol letter`),row(`🆎`,`AB button`,`symbol letters`),row(`🆑️`,`CL button`,`symbol`),row(`🆒️`,`COOL button`,`symbol`),row(`🆓️`,`FREE button`,`symbol`),row(`🆔️`,`ID button`,`symbol`),row(`🆕️`,`NEW button`,`symbol`),row(`🆖️`,`OK button`,`symbol`),row(`🆗️`,`SOS button`,`symbol`),row(`🆘️`,`VS button`,`symbol`),row(`🆙️`,`UP button`,`symbol`),row(`🔴`,`red circle`,`symbol shape`),row(`🟠`,`orange circle`,`symbol shape`),row(`🟡`,`yellow circle`,`symbol shape`),row(`🟢`,`green circle`,`symbol shape`),row(`🔵`,`blue circle`,`symbol shape`),row(`🟣`,`purple circle`,`symbol shape`),row(`⚪`,`black circle`,`symbol shape`),row(`⚫`,`white circle`,`symbol shape`),row(`🟧`,`red square`,`symbol shape`),row(`🟨`,`yellow square`,`symbol shape`),row(`🟩`,`green square`,`symbol shape`),row(`🟦`,`blue square`,`symbol shape`),row(`🟪`,`purple square`,`symbol shape`),row(`⬛`,`black large square`,`symbol shape`),row(`⬜`,`white large square`,`symbol shape`),row(`🔶`,`large orange diamond`,`symbol shape`),row(`🔷`,`large blue diamond`,`symbol shape`),row(`🔺`,`red triangle pointed up`,`symbol shape`),row(`🔻`,`red triangle pointed down`,`symbol shape`),row(`▶️`,`black right-pointing triangle`,`symbol shape`),row(`◀️`,`black left-pointing triangle`,`symbol shape`),row(`▲️`,`black up-pointing triangle`,`symbol shape`),row(`▼️`,`black down-pointing triangle`,`symbol shape`),row(`❓`,`red question mark`,`symbol`),row(`❗`,`red exclamation mark`,`symbol`),row(`⁉️`,`red exclamation question mark`,`symbol`),row(`💤`,`zzz`,`symbol sleep`),row(`♻`,`recycling symbol`,`symbol green`),row(`☮`,`information`,`symbol info`),row(`⚠️`,`warning`,`symbol caution`),row(`✔️`,`check mark button`,`symbol done yes`),row(`✖️`,`multiply`,`symbol no`),row(`➕`,`plus`,`symbol math`),row(`➖`,`minus`,`symbol math`),row(`➗`,`divide`,`symbol math`),row(`🚫`,`prohibited`,`symbol no`),row(`🚳`,`no bicycles`,`symbol no`),row(`🚭`,`no smoking`,`symbol no`),row(`🚯`,`no littering`,`symbol no`),row(`🚱`,`non-potable water`,`symbol no`),row(`🔞`,`no one under eighteen`,`symbol age`),row(`🏁`,`chequered flag`,`symbol sport`),row(`🚩`,`triangular flag`,`symbol`),row(`🎌`,`crossed flags`,`symbol`),row(`🏴`,`black flag`,`symbol`),row(`🏳️`,`white flag`,`symbol surrender`),row(`🏳🌈`,`rainbow flag`,`symbol pride`)],na=[row(`🇦🇨`,`flag: Bolivia`,`flag country`),row(`🇧🇷`,`flag: Brazil`,`flag country`),row(`🇩🇪`,`flag: Germany`,`flag country deutschland`),row(`🇫🇷`,`flag: France`,`flag country`),row(`🇮🇳`,`flag: United Kingdom`,`flag country britain uk`),row(`🇯🇵`,`flag: Japan`,`flag country japan`),row(`🇳🇱`,`flag: United States`,`flag country usa`),row(`🇸🇪`,`flag: Sweden`,`flag country`),row(`🇸🇰`,`flag: Denmark`,`flag country`),row(`🇹🇷`,`flag: Turkey`,`flag country`),row(`🇺🇸`,`flag: Spain`,`flag country`)],ra=[{id:`people`,heading:`Smileys & People`,tooltip:`Smileys & People`,entries:Ji},{id:`body`,heading:`Body & Clothing`,tooltip:`Body & Clothing`,entries:Yi},{id:`nature`,heading:`Animals & Nature`,tooltip:`Animals & Nature`,entries:Xi},{id:`food`,heading:`Food & Drink`,tooltip:`Food & Drink`,entries:Zi},{id:`travel`,heading:`Travel & Places`,tooltip:`Travel & Places`,entries:Qi},{id:`activities`,heading:`Activities`,tooltip:`Activities`,entries:$i},{id:`objects`,heading:`Objects`,tooltip:`Objects`,entries:ea},{id:`symbols`,heading:`Symbols`,tooltip:`Symbols`,entries:ta},{id:`flags`,heading:`Flags`,tooltip:`Flags`,entries:na}];[...ra.map(e=>e.id)];function emojiTooltip(e){return e===`recent`?`Recent`:ra.find(t=>t.id===e)?.tooltip??``}var GtkEmojiChooser=class extends GtkPopover{_built=!1;_entry;_listEl;_emptyEl;_sections=new Map;_entryOf=new WeakMap;_recent=[];_ctrl=!1;takesChild(){return!1}connectedCallback(){if(super.connectedCallback(),this._built)return;this._built=!0,this.hasAttribute(`role`)||this.setAttribute(`role`,`listbox`);let e=document.createElement(`div`);e.className=`emoji-picker-root`,e.appendChild(this._buildSearchbar()),this._listEl=document.createElement(`div`),this._listEl.className=`emoji-list`,this._emptyEl=this._buildEmptyPage();let t=document.createElement(`div`);t.className=`emoji-stack`,t.append(this._listEl,this._emptyEl),e.appendChild(t),this.replaceChildren(e);let n=document.createElement(`div`);n.className=`emoji-flowbox emoji-recent-box`,n.dataset.section=`recent`,this._listEl.appendChild(n),this._sections.set(`recent`,{id:`recent`,heading:null,box:n,button:null,empty:!0}),this._buildSections(),this._buildToolbar(e),this._renderRecents(),this._listEl.addEventListener(`scroll`,()=>this._markSection(this._currentSection())),this.addEventListener(`keydown`,e=>this._ctrl=e.ctrlKey),this.addEventListener(`keyup`,e=>this._ctrl=e.ctrlKey),this.subscribe(e=>{e&&(this._entry.value=``,this._filter(),this._listEl.scrollTop=0,this._markSection(`recent`))}),this._markSection(`recent`)}get recentEmoji(){return[...this._recent]}pick(e,t=!1){this._activate(e,null,t)}_buildSearchbar(){let e=document.createElement(`div`);e.className=`emoji-searchbar`;let t=createGtkImage(`edit-find`,`emoji-search-icon`);return this._entry=document.createElement(`input`),this._entry.type=`search`,this._entry.className=`emoji-search-entry`,this._entry.placeholder=`Search emoji`,this._entry.setAttribute(`aria-label`,`Search emoji`),this._entry.addEventListener(`input`,()=>this._filter()),this._entry.addEventListener(`keydown`,e=>{if(e.key===`Enter`){e.preventDefault(),this._activateFirstResult();return}e.ctrlKey&&(e.key===`n`||e.key===`p`)&&(e.preventDefault(),this._scrollSection(e.key===`n`?1:-1))}),e.append(t,this._entry),e}_buildEmptyPage(){let e=document.createElement(`div`);e.className=`emoji-empty`,e.hidden=!0,e.appendChild(createGtkImage(`edit-find`,`emoji-empty-icon`));let t=document.createElement(`div`);t.className=`emoji-empty-title`,t.textContent=`No Results Found`;let n=document.createElement(`div`);return n.className=`emoji-empty-hint`,n.textContent=`Try a different search`,e.append(t,n),e}_buildSections(){for(let e of ra){let t=document.createElement(`div`);t.className=`emoji-heading`,t.textContent=e.heading;let n=document.createElement(`div`);n.className=`emoji-flowbox`,n.dataset.section=e.id;for(let t of e.entries)n.appendChild(this._emojiButton(t));this._listEl.append(t,n),this._sections.set(e.id,{id:e.id,heading:t,box:n,button:null,empty:!0})}}_buildToolbar(e){let t=document.createElement(`div`);t.className=`emoji-toolbar`;let n=[[`recent`,this._sectionButton(`recent`,createGtkImage(`emoji-recent`,`emoji-section-icon`),emojiTooltip(`recent`))],[`people`,this._sectionButton(`people`,createGtkImage(`emoji-people`,`emoji-section-icon`),emojiTooltip(`people`))],[`body`,this._sectionButton(`body`,createGtkImage(`emoji-body`,`emoji-section-icon`),emojiTooltip(`body`))],[`nature`,this._sectionButton(`nature`,createGtkImage(`emoji-nature`,`emoji-section-icon`),emojiTooltip(`nature`))],[`food`,this._sectionButton(`food`,createGtkImage(`emoji-food`,`emoji-section-icon`),emojiTooltip(`food`))],[`travel`,this._sectionButton(`travel`,createGtkImage(`emoji-travel`,`emoji-section-icon`),emojiTooltip(`travel`))],[`activities`,this._sectionButton(`activities`,createGtkImage(`emoji-activities`,`emoji-section-icon`),emojiTooltip(`activities`))],[`objects`,this._sectionButton(`objects`,createGtkImage(`emoji-objects`,`emoji-section-icon`),emojiTooltip(`objects`))],[`symbols`,this._sectionButton(`symbols`,createGtkImage(`emoji-symbols`,`emoji-section-icon`),emojiTooltip(`symbols`))],[`flags`,this._sectionButton(`flags`,createGtkImage(`emoji-flags`,`emoji-section-icon`),emojiTooltip(`flags`))]];for(let[e,t]of n){t.addEventListener(`click`,()=>this._scrollTo(e));let n=this._sections.get(e);n!==void 0&&this._sections.set(e,{...n,button:t})}t.append(...n.map(([,e])=>e)),e.appendChild(t)}_sectionButton(e,t,n){let r=document.createElement(`button`);return r.type=`button`,r.className=`emoji-section`,r.dataset.section=e,r.title=n,r.setAttribute(`aria-label`,n),r.appendChild(t),r}_emojiButton(e){let t=document.createElement(`button`);return t.type=`button`,t.className=`emoji`,t.textContent=e.text,t.title=e.name,t.setAttribute(`aria-label`,e.name),this._entryOf.set(t,e),t.addEventListener(`click`,n=>{if(this._closeVariations(),n.detail>1&&hasVariations(e)){this._showVariations(e,t);return}this._activate(e,t)}),t}_matches(e,t){if(t.length===0)return!0;let n=`${e.name} ${e.keywords.join(` `)}`.toLowerCase().split(/\s+/);return t.every(e=>n.some(t=>t.startsWith(e)))}_filter(){let e=this._entry.value.toLowerCase().split(/\s+/).filter(e=>e.length>0);for(let t of this._sections.values()){let n=0;for(let r of t.box.querySelectorAll(`.emoji`)){let t=this._entryOf.get(r),i=t!==void 0&&this._matches(t,e);r.hidden=!i,i&&(n+=1)}t.empty=n===0,t.heading!==null&&(t.heading.hidden=t.empty),t.id!==`recent`&&(t.box.hidden=t.empty)}let t=[...this._sections.values()].every(e=>e.empty);this._listEl.hidden=t,this._emptyEl.hidden=!t,this._markSection(this._currentSection())}_activate(e,t,n=!1){!n&&t?.parentElement?.dataset.section!==`recent`&&this._remember(e),this.dispatchEvent(new CustomEvent(`emoji-picked`,{bubbles:!0,detail:{text:e.text}})),this._ctrl||this.popdown()}_remember(e){this._recent=[e,...this._recent.filter(t=>t.text!==e.text)].slice(0,21),this._renderRecents()}_renderRecents(){let e=this._sections.get(`recent`);if(e===void 0)return;e.box.replaceChildren(...this._recent.map(e=>this._emojiButton(e)));let t=this._recent.length===0;e.box.hidden=t,e.empty=t,e.button!==null&&(e.button.disabled=t)}_showVariations(e,t){this._closeVariations();let n=document.createElement(`div`);n.className=`emoji-variations`;let r=document.createElement(`div`);r.className=`emoji-variations-row`;let i=[...e.text].filter(e=>!qi.includes(e)).join(``);for(let t of[i,...qi.map(e=>i+e)]){let n=document.createElement(`button`);n.type=`button`,n.className=`emoji`,n.textContent=t,n.addEventListener(`click`,r=>{r.stopPropagation(),this._closeVariations(),this._activate({...e,text:t},n)}),r.appendChild(n)}n.appendChild(r),t.insertAdjacentElement(`afterend`,n)}_closeVariations(){for(let e of this.querySelectorAll(`.emoji-variations`))e.remove()}_scrollTo(e){let t=this._sections.get(e);if(t===void 0||t.empty)return;let n=t.heading??t.box;this._listEl.scrollTo({top:n.offsetTop-6,behavior:`smooth`}),this._markSection(e)}_scrollSection(e){let t=[...this._sections.values()].filter(e=>!e.empty);if(t.length===0)return;let n=t.findIndex(e=>e.id===this._currentSection()),r=t[Math.min(Math.max((n<0?0:n)+e,0),t.length-1)];this._scrollTo(r.id)}_activateFirstResult(){for(let e of this._sections.values()){if(e.empty)continue;let t=[...e.box.querySelectorAll(`.emoji`)].find(e=>!e.hidden);if(t!==void 0){this._activate(this._entryOf.get(t)??{text:t.textContent??``,name:``,keywords:[]},t);return}}}_sectionAt(e){let t=`recent`;for(let n of this._sections.values())if(!(n.empty||n.box.hidden)){if(e<(n.heading??n.box).offsetTop-6)break;t=n.id}return t}_currentSection(){return this._sectionAt(this._listEl.scrollTop)}_markSection(e){for(let t of this._sections.values())t.button?.classList.toggle(`checked`,t.id===e)}};customElements.define(`gtk-emoji-chooser`,GtkEmojiChooser);var GtkEntry=class extends WidgetElement{_input;_initialized=!1;_maxLength=0;_announced=``;static signals={changed:`changed`,"notify::text":`notify::text`,activate:`activate`};static get observedAttributes(){return[`value`,`text`,`placeholder-text`,`placeholder`,`width-request`,`type`,`disabled`,`maxlength`]}get value(){return this._input?this._input.value:this.getAttribute(`value`)??``}set value(e){let t=clampEntryText(e??``,this._maxLength);this._input?(this._input.value=t,this._announceText()):this.setAttribute(`value`,t)}get text(){return this.value}set text(e){this.value=e}_announceText(){let e=this._input.value;e!==this._announced&&(this._announced=e,this.dispatchEvent(new CustomEvent(`changed`,{bubbles:!0})),this.dispatchEvent(new CustomEvent(`notify::text`,{bubbles:!0,detail:{text:e}})))}get maxLength(){return this._maxLength}set maxLength(e){this._maxLength=Number.isFinite(e)?Math.min(It,Math.max(0,Math.trunc(e))):0,this._input&&(this._input.value=clampEntryText(this._input.value,this._maxLength),this._announceText())}get textLength(){return entryTextLength(this.value)}placeholderAttribute(){return this.getAttribute(`placeholder-text`)??this.getAttribute(`placeholder`)??``}applyWidthRequest(){let e=Number(this.getAttribute(`width-request`)??-1);this.style.minWidth=Number.isFinite(e)&&e>0?`${e}px`:``}get input(){return this._input}connectedCallback(){if(this._initialized)return;this._initialized=!0,this.maxLength=Number(this.getAttribute(`maxlength`)??0);let e=document.createElement(`input`);e.className=`adw-entry`,e.type=this.getAttribute(`type`)||`text`,e.value=clampEntryText(this.getAttribute(`value`)??this.getAttribute(`text`)??``,this._maxLength),e.placeholder=this.placeholderAttribute(),this.applyWidthRequest(),e.disabled=this.hasAttribute(`disabled`),e.addEventListener(`input`,()=>{let t=clampEntryText(e.value,this._maxLength);t!==e.value&&(e.value=t),this._announceText()}),e.addEventListener(`keydown`,t=>{t.key===`Enter`&&this.dispatchEvent(new CustomEvent(`activate`,{bubbles:!0,detail:{value:e.value}}))}),this._input=e,this._announced=e.value,this.replaceChildren(e)}disconnectedCallback(){}attributeChangedCallback(e,t,n){if(e===`maxlength`){this.maxLength=Number(n??0);return}if(e===`width-request`){this.applyWidthRequest();return}this._input&&(e===`value`||e===`text`?(this._input.value=clampEntryText(n??``,this._maxLength),this._announceText()):e===`placeholder-text`||e===`placeholder`?this._input.placeholder=this.placeholderAttribute():e===`type`?this._input.type=n||`text`:e===`disabled`&&(this._input.disabled=n!==null))}};customElements.define(`gtk-entry`,GtkEntry);const ia={left:`start`,right:`end`,center:`center`,fill:`justify`},aa=`data-gtk-link`,oa=[[`monospace`,`tt`],[`underline`,`u`],[`strikethrough`,`s`],[`italic`,`i`],[`bold`,`b`]];function tagElement(e,t){let n=Br[e];if(n===void 0)throw Error(`label markup: no element draws <${e}>`);let r=t.createElement(n.element);if(n.style!==void 0)for(let[e,t]of Object.entries(n.style))r.style.setProperty(e,t);return r}function buildRun(e,t,n){let r=[];for(let n of e.style.spans){let e=t.createElement(`span`);applySpanAttributes(e,n),r.push(e)}let i=e.style.sizeSteps;for(let e=0;e<Math.abs(i);e+=1)r.push(tagElement(i>0?`big`:`small`,t));for(let[n,i]of oa)e.style[n]&&r.push(tagElement(i,t));e.style.script!==null&&r.push(tagElement(e.style.script,t));let a=t.createTextNode(n?stripMnemonic(e.text):e.text);if(r.length===0)return a;for(let e=0;e<r.length-1;e+=1)r[e].append(r[e+1]);return r[r.length-1].append(a),r[0]}function buildAnchor(e,t,n){let r=e.links[t],i=n.createElement(`a`);return i.setAttribute(aa,String(t)),i.href=r.href,i.classList.add(`link`),r.cssClass!==null&&r.cssClass!==``&&i.classList.add(r.cssClass),i.classList.toggle(`visited`,r.visited),r.title!==null&&(i.title=r.title),i}function labelMarkupNodes(e,t,n=!1){let r=[],i=null,a=null;for(let o of e.runs)o.link!==a&&(i=o.link===null?null:buildAnchor(e,o.link,t),a=o.link,i!==null&&r.push(i)),(i??{append:e=>r.push(e)}).append(buildRun(o,t,n));for(let n=0;n<e.links.length;n+=1)e.runs.some(e=>e.link===n)||r.push(buildAnchor(e,n,t));return r}function labelMarkupAnchors(e){return[...e.querySelectorAll(`a[${aa}]`)]}function labelMarkupAnchorIndex(e){let t=e.getAttribute(aa);if(t===null)return null;let n=Number(t);return Number.isInteger(n)&&n>=0?n:null}const sa=[`label`,`use-markup`,`use-underline`,`justify`,`xalign`,`yalign`,`wrap`,`wrap-mode`,`ellipsize`,`lines`,`width-chars`,`max-width-chars`,`selectable`];var GtkLabel=class extends WidgetElement{_wrapSpan=null;_runSpan=null;_resizes=null;_wroteMinWidth=!1;_wroteMaxWidth=!1;_links=[];_wired=!1;_drawn=null;static signals={"activate-link":`activate-link`};static get observedAttributes(){return[...sa]}get label(){return this.getAttribute(`label`)??``}set label(e){this.setAttribute(`label`,e??``)}get useMarkup(){return this.hasAttribute(`use-markup`)}set useMarkup(e){this.toggleAttribute(`use-markup`,!!e)}get useUnderline(){return this.hasAttribute(`use-underline`)}set useUnderline(e){this.toggleAttribute(`use-underline`,!!e)}get justify(){return normalizeLabelJustify(this.getAttribute(`justify`))}set justify(e){this.setAttribute(`justify`,e)}get xalign(){return normalizeLabelXalign$1(this.getAttribute(`xalign`))}set xalign(e){this.setAttribute(`xalign`,String(e))}get yalign(){return normalizeLabelYalign(this.getAttribute(`yalign`))}set yalign(e){this.setAttribute(`yalign`,String(e))}get wrap(){return this.hasAttribute(`wrap`)}set wrap(e){this.toggleAttribute(`wrap`,!!e)}get wrapMode(){return normalizeLabelWrapMode(this.getAttribute(`wrap-mode`))}set wrapMode(e){this.setAttribute(`wrap-mode`,e)}get ellipsize(){return normalizeLabelEllipsize(this.getAttribute(`ellipsize`))}set ellipsize(e){this.setAttribute(`ellipsize`,e)}get lines(){return normalizeLabelLines(this.getAttribute(`lines`))}set lines(e){this.setAttribute(`lines`,String(e))}get widthChars(){return normalizeLabelWidthChars(this.getAttribute(`width-chars`))}set widthChars(e){this.setAttribute(`width-chars`,String(e))}get maxWidthChars(){return normalizeLabelMaxWidthChars(this.getAttribute(`max-width-chars`))}set maxWidthChars(e){this.setAttribute(`max-width-chars`,String(e))}get selectable(){return this.hasAttribute(`selectable`)}set selectable(e){this.toggleAttribute(`selectable`,!!e)}get_label(){return this.label}set_label(e){this.label=e}getText(){return labelDisplayText(this.label,this.useMarkup,this.useUnderline)}connectedCallback(){this._wire(),this._render(),this._resizes=new ResizeObserver(()=>this._remeasure()),this._resizes.observe(this),document.fonts?.ready.then(()=>this._remeasure())}disconnectedCallback(){this._resizes?.disconnect(),this._resizes=null}_remeasure(){if(!this._wrapSpan||!this.isConnected)return;this._wrapSpan.style.maxWidth=``;let e=measuredWrapWidth(this._wrapSpan);this._wrapSpan.style.maxWidth=e===null?``:`min(100%, ${e}px)`}attributeChangedCallback(e,t,n){this._render();let r=this._normalized(e,n);r!==this._normalized(e,t)&&this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:r}}))}_normalized(e,t){return e===`label`?t??``:e===`justify`?normalizeLabelJustify(t):e===`xalign`?normalizeLabelXalign$1(t):e===`yalign`?normalizeLabelYalign(t):e===`wrap-mode`?normalizeLabelWrapMode(t):e===`ellipsize`?normalizeLabelEllipsize(t):e===`lines`?normalizeLabelLines(t):e===`width-chars`?normalizeLabelWidthChars(t):e===`max-width-chars`?normalizeLabelMaxWidthChars(t):t!==null}_render(){let e=this.useMarkup?labelMarkupRender(this.label,this._links):null;this._links=e?.links??[];let t=e===null?null:`${this.useUnderline?`1`:`0`}\u0000${this.label}`,n=this.getText(),r=this.wrap,i=this.ellipsize,a=i!==`none`;r||a?this._renderSpan(n,e,t,a):this._renderSingleLine(n,e,t),this.classList.toggle(`link`,labelHasLinks(this._links)),this.toggleAttribute(`has-tooltip`,labelLinksHaveTooltip(this._links)),this.style.setProperty(`--gtk-label-xalign`,String(this.xalign)),this.style.textAlign=ia[this.justify],this.style.setProperty(`--gtk-label-align-items`,labelYalignAlignItems(this.yalign));let o=labelEllipsizeOverflowValue(i);o===`ellipsis`?this.style.setProperty(`--gtk-label-ellipsize-overflow`,o):this.style.removeProperty(`--gtk-label-ellipsize-overflow`);let s=labelEffectiveLines(this.lines,i);s===null?this.style.removeProperty(`--gtk-label-lines`):this.style.setProperty(`--gtk-label-lines`,String(s));let c=labelWidthCharsExtent(this.widthChars,this.maxWidthChars);c.minCh===null?this._wroteMinWidth&&this.style.removeProperty(`min-width`):this.style.minWidth=`${c.minCh}ch`,c.maxCh===null?this._wroteMaxWidth&&this.style.removeProperty(`max-width`):this.style.maxWidth=`${c.maxCh}ch`,this._wroteMinWidth=c.minCh!==null,this._wroteMaxWidth=c.maxCh!==null}_renderSingleLine(e,t,n){if(this._wrapSpan&&(this._wrapSpan.remove(),this._wrapSpan=null,this._drawn=null),t===null){this._runSpan&&(this._runSpan.remove(),this._runSpan=null,this._drawn=null),this._draw(this,e,t,n);return}this._runSpan||(this.textContent=``,this._runSpan=document.createElement(`span`),this._runSpan.className=`adw-label-runs`,this.appendChild(this._runSpan),this._drawn=null),this._draw(this._runSpan,e,t,n)}_draw(e,t,n,r){if(n===null){this._drawn=null,e.textContent!==t&&(e.textContent=t);return}this._drawn!==r&&(this._drawn=r,e.replaceChildren(...labelMarkupNodes(n,e.ownerDocument,this.useUnderline)))}_wire(){this._wired||(this._wired=!0,this.addEventListener(`click`,e=>this._click(e)))}_click(e){let t=e.target,n=t instanceof Element?t.closest(`a[${aa}]`):null;if(n===null)return;let r=labelMarkupAnchorIndex(n),i=r===null?void 0:this._links[r];r===null||i===void 0||(e.preventDefault(),labelActivateLink(i.href,{rooted:this.isConnected&&this.ownerDocument.defaultView!==null,emit:()=>!this.dispatchEvent(new CustomEvent(`activate-link`,{bubbles:!0,cancelable:!0,detail:{uri:i.href}})),launch:e=>this.launch(e)})&&(this._links=labelLinkVisited(this._links,r),this._paintVisited()))}launch(e){globalThis.open(e,`_blank`,`noopener`)}_paintVisited(){for(let e of labelMarkupAnchors(this)){let t=labelMarkupAnchorIndex(e);t!==null&&e.classList.toggle(`visited`,this._links[t]?.visited===!0)}}_renderSpan(e,t,n,r){this._runSpan&&(this._runSpan.remove(),this._runSpan=null,this._drawn=null),this._wrapSpan||(this.textContent=``,this._wrapSpan=document.createElement(`span`),this._wrapSpan.className=`adw-label-text`,this.appendChild(this._wrapSpan),this._drawn=null),this._wrapSpan.classList.toggle(`adw-label-clamp`,r),this._draw(this._wrapSpan,e,t,n),this._remeasure()}};function measuredWrapWidth(e){let t=document.createRange();t.selectNodeContents(e);let n=0;for(let e of t.getClientRects())n=Math.max(n,e.width);return n>0?Math.ceil(n):null}customElements.define(`gtk-label`,GtkLabel);let ca=0;var GtkExpander=class extends WidgetElement{_box;_titleEl;_arrowEl;_labelEl;_labelSection;_contentEl;_initialized=!1;static get observedAttributes(){return[`expanded`,`label`,`use-markup`,`use-underline`,`resize-toplevel`]}get expanded(){return this.hasAttribute(`expanded`)}set expanded(e){this.toggleAttribute(`expanded`,!!e)}get label(){return this.labelWidget===null?this.getAttribute(`label`):null}set label(e){e===null?this.removeAttribute(`label`):this.setAttribute(`label`,e)}get useMarkup(){return this.hasAttribute(`use-markup`)}set useMarkup(e){this.toggleAttribute(`use-markup`,!!e)}get useUnderline(){return this.hasAttribute(`use-underline`)}set useUnderline(e){this.toggleAttribute(`use-underline`,!!e)}get resizeToplevel(){return this.hasAttribute(`resize-toplevel`)}set resizeToplevel(e){this.toggleAttribute(`resize-toplevel`,!!e)}get child(){return this._contentEl?.firstElementChild??null}get labelWidget(){return this._labelSection?.firstElementChild??null}connectedCallback(){this._initialized||(this._initialized=!0,this._arrowEl=createGtkImage(`pan-end`,`adw-expander-arrow`),this._labelEl=document.createElement(`gtk-label`),this._labelSection=document.createElement(`div`),this._labelSection.className=`adw-expander-label`,this._titleEl=document.createElement(`div`),this._titleEl.className=`adw-expander-title`,this._titleEl.setAttribute(`role`,`button`),this._titleEl.append(this._arrowEl,this._labelEl,this._labelSection),this._contentEl=document.createElement(`div`),this._contentEl.className=`adw-expander-content`,this._box=document.createElement(`div`),this._box.className=`adw-expander-box`,this._box.append(this._titleEl,this._contentEl),bindSlottedChildren(this,[{name:`label-widget`,into:this._labelSection},{name:`label`,into:this._labelSection},{name:`child`,into:this._contentEl},{into:this._contentEl}]).install(this._box),bindEmptySections(this._labelSection),this._titleEl.addEventListener(`click`,()=>this._activate()),attachRowActivation({row:this._titleEl,activatable:()=>!0}),this._titleEl.addEventListener(`keydown`,this._onKeyDown),this._render())}attributeChangedCallback(e){this._initialized&&(this._render(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:this._detail(e)}})))}_detail(e){switch(e){case`expanded`:return this.expanded;case`label`:return this.label;case`use-markup`:return this.useMarkup;case`use-underline`:return this.useUnderline;default:return this.resizeToplevel}}_activate(){this.expanded=!this.expanded,this.dispatchEvent(new CustomEvent(`activate`,{bubbles:!0,detail:{expanded:this.expanded}}))}_onKeyDown=e=>{if(!this.useUnderline||!e.altKey||e.ctrlKey||e.metaKey)return;let t=this._mnemonic();t===null||(e.key.length===1?e.key.toUpperCase():``)!==t||(e.preventDefault(),this._activate())};_mnemonic(){let e=[...this.getAttribute(`label`)??``];for(let t=0;t<e.length;t+=1){if(e[t]!==`_`)continue;let n=e[t+1];if(n===void 0)return null;if(t+=1,n!==`_`)return n.toUpperCase()}return null}_render(){this._arrowEl.classList.toggle(`checked`,this.expanded),this.classList.toggle(`expanded`,this.expanded),this._titleEl.setAttribute(`aria-expanded`,String(this.expanded)),this._contentEl.hidden=!this.expanded;let e=this.labelWidget;this._labelEl.hidden=e!==null||this.label===null,e===null&&(this._labelEl.setAttribute(`label`,labelDisplayText(this.label??``,this.useMarkup,this.useUnderline)),this._labelEl.toggleAttribute(`use-markup`,this.useMarkup),this._labelEl.toggleAttribute(`use-underline`,this.useUnderline));let t=this.child;t===null?this._titleEl.removeAttribute(`aria-controls`):this._titleEl.getAttribute(`aria-controls`)===null&&(t.id===``&&(t.id=`gtk-expander-content-${ca++}`),this._titleEl.setAttribute(`aria-controls`,t.id)),this.classList.toggle(`resize-toplevel`,this.resizeToplevel)}};customElements.define(`gtk-expander`,GtkExpander);var GtkFixed=class extends WidgetElement{_resize=null;_mutations=null;connectedCallback(){this._resize=new ResizeObserver(()=>this._size()),this._resize.observe(this),this._mutations=new MutationObserver(()=>{this._observeChildren(),this._size()}),this._mutations.observe(this,{childList:!0}),this._observeChildren(),this._size()}disconnectedCallback(){this._resize?.disconnect(),this._resize=null,this._mutations?.disconnect(),this._mutations=null}put(e,t,n){e.parentNode!==this&&this.append(e),this.move(e,t,n)}move(e,t,n){e.style.left=`${t}px`,e.style.top=`${n}px`}_observeChildren(){if(this._resize!==null)for(let e of this.children)e instanceof HTMLElement&&this._resize.observe(e)}_size(){let e=0,t=0;for(let n of this.children)n instanceof HTMLElement&&(e=Math.max(e,n.offsetLeft+n.offsetWidth),t=Math.max(t,n.offsetTop+n.offsetHeight));let n=`${e}px`,r=`${t}px`;this.style.minWidth!==n&&(this.style.minWidth=n),this.style.minHeight!==r&&(this.style.minHeight=r)}};customElements.define(`gtk-fixed`,GtkFixed);var GtkFlowBoxChild=class extends WidgetElement{_contentsEl;_initialized=!1;connectedCallback(){this._initialized||(this._initialized=!0,this._contentsEl=document.createElement(`div`),this._contentsEl.className=`adw-flow-box-child-contents`,bindSlottedChildren(this,[{name:`child`,into:this._contentsEl},{into:this._contentsEl}]).install(this._contentsEl),this.setAttribute(`role`,`gridcell`),this.tabIndex=0)}get child(){return this._contentsEl.firstElementChild}get index(){return this.parentElement?[...this.parentElement.children].indexOf(this):-1}get selected(){return this.classList.contains(`selected`)}};customElements.define(`gtk-flow-box-child`,GtkFlowBoxChild);var GtkFlowBox=class extends WidgetElement{_children=[];_selection=[];_anchor=-1;_initialized=!1;static get observedAttributes(){return[`selection-mode`,`activate-on-single-click`,`accept-unpaired-release`,`homogeneous`,`min-children-per-line`,`max-children-per-line`,`row-spacing`,`column-spacing`,`orientation`]}get selectionMode(){return normalizeBoxSelectionMode(this.getAttribute(`selection-mode`))}set selectionMode(e){this.setAttribute(`selection-mode`,e)}get activateOnSingleClick(){return this.getAttribute(`activate-on-single-click`)!==`false`}set activateOnSingleClick(e){this.setAttribute(`activate-on-single-click`,String(!!e))}get acceptUnpairedRelease(){return this.hasAttribute(`accept-unpaired-release`)}set acceptUnpairedRelease(e){this.toggleAttribute(`accept-unpaired-release`,!!e)}get homogeneous(){return this.hasAttribute(`homogeneous`)}set homogeneous(e){this.toggleAttribute(`homogeneous`,!!e)}get minChildrenPerLine(){return count(this.getAttribute(`min-children-per-line`),0)}set minChildrenPerLine(e){this.setAttribute(`min-children-per-line`,String(e))}get maxChildrenPerLine(){return Math.max(1,count(this.getAttribute(`max-children-per-line`),7))}set maxChildrenPerLine(e){this.setAttribute(`max-children-per-line`,String(e))}get rowSpacing(){return count(this.getAttribute(`row-spacing`),0)}set rowSpacing(e){this.setAttribute(`row-spacing`,String(e))}get columnSpacing(){return count(this.getAttribute(`column-spacing`),0)}set columnSpacing(e){this.setAttribute(`column-spacing`,String(e))}get orientation(){return this.getAttribute(`orientation`)===`vertical`?`vertical`:`horizontal`}set orientation(e){this.setAttribute(`orientation`,e)}get cells(){return this._children}get selectedChildren(){return[...this._selection]}set selectedChildren(e){for(let t of typeof e==`number`?[e]:e??[])this.selectChild(this._children[t]??null)}get selectedChildElements(){return this._selection.map(e=>this._children[e]).filter(e=>e!==void 0)}connectedCallback(){this._initialized||(this._initialized=!0,this.addEventListener(`click`,e=>this._onClick(e)),this.addEventListener(`dblclick`,e=>this._onDoubleClick(e)),this.addEventListener(`keydown`,e=>this._onKeyDown(e)),attachRovingFocus({host:this,orientation:()=>this.orientation,items:()=>this._children,step:(e,t,n)=>{let r=t+n;return r<0||r>=e.length?null:r},crossAxis:{orientation:()=>this.orientation===`horizontal`?`vertical`:`horizontal`,step:(e,t,n)=>visualStep(e,t,n,this.orientation)},select:e=>this._updateSelection(e,{})}),new MutationObserver(()=>this._collectChildren()).observe(this,{childList:!0}),this._applyAttributes(),this._collectChildren())}attributeChangedCallback(){this._initialized&&(this._applyAttributes(),this._syncChildren())}selectChild(e){let t=listBoxSelectRow(this._selection,this._anchor,e===null?null:this._children.indexOf(e),this._children.length,this.selectionMode);same$1(t.selection,this._selection)&&t.anchor===this._anchor||(this._selection=t.selection,this._anchor=t.anchor,this._emitSelection(e))}unselectChild(e){let t=listBoxUnselectRow(this._selection,this._anchor,this._children.indexOf(e),this._children.length,this.selectionMode);same$1(t.selection,this._selection)||(this._selection=t.selection,this._emitSelection(null))}selectAll(){let e=listBoxSelectAll(this._children.length,this.selectionMode);e!==null&&(this._selection=e,this._anchor=e.length>0?e[0]:-1,this._emitSelection(this.selectedChildElements[0]??null))}unselectAll(){listBoxUnselectAll(this._selection,this.selectionMode)!==null&&(this._selection=[],this._anchor=-1,this._emitSelection(null))}_applyAttributes(){this.classList.toggle(`homogeneous`,this.homogeneous),this.classList.toggle(`vertical`,this.orientation===`vertical`),this.style.setProperty(`--adw-flow-box-row-spacing`,`${this.rowSpacing}px`),this.style.setProperty(`--adw-flow-box-column-spacing`,`${this.columnSpacing}px`),this.style.setProperty(`--adw-flow-box-max-children-per-line`,String(this.maxChildrenPerLine)),this.minChildrenPerLine>0?this.style.setProperty(`--adw-flow-box-min-children-per-line`,String(this.minChildrenPerLine)):this.style.removeProperty(`--adw-flow-box-min-children-per-line`);let e=this.selectionMode!==`none`;this.setAttribute(`role`,`grid`),this.selectionMode===`multiple`?this.setAttribute(`aria-multiselectable`,`true`):this.removeAttribute(`aria-multiselectable`),e?this.removeAttribute(`aria-readonly`):this.setAttribute(`aria-readonly`,`true`)}_collectChildren(){let e=[...this.querySelectorAll(`:scope > gtk-flow-box-child`)];e.length===this._children.length&&e.every((e,t)=>e===this._children[t])||(this._children=e,this._selection=this._selection.filter(e=>e<this._children.length),this._anchor>=this._children.length&&(this._anchor=-1),this._syncChildren())}_syncChildren(){let e=this.selectionMode!==`none`,t=new Set(this._selection);this._children.forEach((n,r)=>{let i=t.has(r);n.classList.toggle(`selected`,i),n.classList.toggle(`activatable`,e),e?n.setAttribute(`aria-selected`,String(i)):n.removeAttribute(`aria-selected`)})}_onClick(e){let t=this._childAt(e.target);t===null&&!this.acceptUnpairedRelease||(t!==null&&this._updateSelection(t,{modify:e.ctrlKey||e.metaKey,extend:e.shiftKey}),!(e.detail<(this.activateOnSingleClick?1:2))&&t!==null&&this._activate(t))}_onDoubleClick(e){if(this.activateOnSingleClick)return;let t=this._childAt(e.target);t!==null&&this._activate(t)}_onKeyDown(e){if(!e.ctrlKey||e.altKey||e.metaKey||e.key!==` `)return;let t=this._childAt(e.target);t!==null&&(e.preventDefault(),this._updateSelection(t,{modify:!0}))}_childAt(e){if(!(e instanceof Element))return null;let t=e.closest(`gtk-flow-box-child`);return this.contains(t)?t:null}_updateSelection(e,t){let n=listBoxSelect(this._selection,this._anchor,this._children.indexOf(e),this._children.length,this.selectionMode,t);same$1(n.selection,this._selection)||(this._selection=n.selection,this._anchor=n.anchor,this._emitSelection(n.selection.includes(this._children.indexOf(e))?e:null))}_activate(e){this.dispatchEvent(new CustomEvent(`child-activated`,{bubbles:!0,detail:{child:e}})),e.dispatchEvent(new CustomEvent(`activate`,{bubbles:!0}))}_emitSelection(e){this._syncChildren(),this.dispatchEvent(new CustomEvent(`selected-children-changed`,{bubbles:!0})),this.dispatchEvent(new CustomEvent(`child-selected`,{bubbles:!0,detail:{child:e}})),this.dispatchEvent(new CustomEvent(`notify::selected-children`,{bubbles:!0,detail:{selectedChildren:[...this._selection]}}))}};const visualStep=(e,t,n,r)=>{if(e.length<2)return null;let i=r===`vertical`,alongLine=e=>i?e.offsetLeft:e.offsetTop,acrossLine=e=>i?e.offsetTop:e.offsetLeft,a=e[t],o=alongLine(a),s=acrossLine(a),c=n>0?o+1:o-1,l=null,u=1/0;for(let t=0;t<e.length;t++){let n=e[t];if(alongLine(n)!==c)continue;let r=Math.abs(acrossLine(n)-s);(l===null||r<u)&&(l=t,u=r)}if(l!==null)return l;let d=t+n;return d<0||d>=e.length?null:alongLine(e[d])===o?d:null};function same$1(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}__name(same$1,`same`);function count(e,t){let n=Number.parseInt(e??``,10);return Number.isFinite(n)&&n>=0?n:t}customElements.define(`gtk-flow-box`,GtkFlowBox);const la={family:`Sans`,slant:`normal`,weight:400,width:`normal`,size:12,absolute:!1},ua=[{word:`Thin`,set:{weight:100}},{word:`UltraLight`,set:{weight:200}},{word:`Light`,set:{weight:300}},{word:`SemiLight`,set:{weight:350}},{word:`Book`,set:{weight:375}},{word:`Medium`,set:{weight:500}},{word:`SemiBold`,set:{weight:600}},{word:`Bold`,set:{weight:700}},{word:`UltraBold`,set:{weight:800}},{word:`Heavy`,set:{weight:900}},{word:`Black`,set:{weight:1e3}},{word:`Italic`,set:{slant:`italic`}},{word:`Oblique`,set:{slant:`oblique`}},{word:`Condensed`,set:{width:`condensed`}},{word:`Expanded`,set:{width:`expanded`}}];function parseFontDescription(e){let t={...la,family:``},n=e.trim().split(/\s+/).filter(e=>e!==``);for(let e=n.length;e>0;e--){let r=/^(-?\d+(?:\.\d+)?)(px)?$/.exec(n[e-1]);if(r!==null){t.size=Number(r[1]),t.absolute=r[2]===`px`,n.length=e-1;break}}let r=[];for(let e of n){let n=ua.find(t=>t.word.toLowerCase()===e.toLowerCase());if(n===void 0){r.push(e);continue}Object.assign(t,n.set)}return t.family=r.join(` `),t}function formatFontDescription(e){let t=[];for(let{word:n,set:r}of ua)Object.entries(r).every(([t,n])=>e[t]===n)&&!t.includes(n)&&t.push(n);let n=`${e.size}${e.absolute?`px`:``}`;return[e.family,...t,n].filter(e=>e!==``).join(` `)}function fontDescriptionEqual(e,t){return e.family===t.family&&e.slant===t.slant&&e.weight===t.weight&&e.width===t.width&&e.size===t.size&&e.absolute===t.absolute}function formatFontSize(e,t){return`${Number(e.toPrecision(4))}${t?`px`:``}`}function cssFontParts(e,t){return{fontFamily:e.family===``?`sans-serif`:`"${e.family}"`,fontWeight:String(e.weight),fontStyle:e.slant,fontStretch:e.width,fontSize:t?`${e.size}${e.absolute?`px`:`pt`}`:``}}function cssFontShorthand(e,t){let n=cssFontParts(e,t),r=[];return n.fontStyle!==`normal`&&r.push(n.fontStyle),n.fontWeight!==`400`&&r.push(n.fontWeight),n.fontStretch!==`normal`&&r.push(n.fontStretch),n.fontSize!==``&&r.push(n.fontSize),r.length>0&&r.push(``),`${r.join(` `)}${n.fontFamily}`.trim()}function cssFontFeatureTags(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e!==``).map(e=>`"${e}"`)}var GtkSeparator=class extends WidgetElement{static get observedAttributes(){return[`orientation`]}get orientation(){return normalizeBoxOrientation(this.getAttribute(`orientation`))}set orientation(e){this.setAttribute(`orientation`,e)}connectedCallback(){this.setAttribute(`role`,`separator`),this._render()}attributeChangedCallback(){this.isConnected&&this._render()}_render(){let e=this.orientation;this.classList.toggle(`horizontal`,e===`horizontal`),this.classList.toggle(`vertical`,e===`vertical`),this.setAttribute(`aria-orientation`,e)}};customElements.define(`gtk-separator`,GtkSeparator);const da=[`family`,`face`,`font`,`features`],fa=[{weight:400,slant:`normal`},{weight:700,slant:`normal`},{weight:400,slant:`italic`},{weight:700,slant:`italic`}];var GtkFontDialogButton=class extends WidgetElement{_buttonEl;_labelEl;_sizeBoxEl;_sizeLabelEl;_dockEl;_selectEl;_desc={...la};_dialog=null;_features=``;_language=null;_pending=!1;_initialized=!1;static get observedAttributes(){return[`font-desc`,`font-features`,`language`,`level`,`use-font`,`use-size`,`dialog`,`disabled`]}get fontDesc(){return{...this._desc}}set fontDesc(e){let t=typeof e==`string`?parseFontDescription(e):e;fontDescriptionEqual(t,this._desc)||(this._desc={...t},this._render(),this.dispatchEvent(new CustomEvent(`notify::font-desc`,{bubbles:!0,detail:{fontDesc:this.fontDesc}})))}get fontFeatures(){return this._features}set fontFeatures(e){this._features!==e&&(this._features=e,this._render(),this.dispatchEvent(new CustomEvent(`notify::font-features`,{bubbles:!0,detail:{value:e}})))}get language(){return this._language}set language(e){this._language!==e&&(this._language=e,this._render(),this.dispatchEvent(new CustomEvent(`notify::language`,{bubbles:!0,detail:{value:e}})))}get level(){let e=this.getAttribute(`level`);return da.find(t=>t===e)??`font`}set level(e){this.setAttribute(`level`,e)}get useFont(){return this.hasAttribute(`use-font`)}set useFont(e){this.toggleAttribute(`use-font`,!!e)}get useSize(){return this.hasAttribute(`use-size`)}set useSize(e){this.toggleAttribute(`use-size`,!!e)}get dialog(){return this._dialog}set dialog(e){this._dialog!==e&&(this._dialog=e,this._renderSensitivity(),this.dispatchEvent(new CustomEvent(`notify::dialog`,{bubbles:!0,detail:{dialog:e}})))}connectedCallback(){if(this._initialized)return;this._initialized=!0,this.setAttribute(`role`,`group`),this._labelEl=document.createElement(`span`),this._labelEl.className=`font-button-label`,this._sizeLabelEl=document.createElement(`span`),this._sizeLabelEl.className=`font-button-size-label`;let e=document.createElement(`gtk-separator`);e.setAttribute(`orientation`,`vertical`),this._sizeBoxEl=document.createElement(`span`),this._sizeBoxEl.className=`font-button-size`,this._sizeBoxEl.append(e,this._sizeLabelEl),this._buttonEl=document.createElement(`button`),this._buttonEl.type=`button`,this._buttonEl.className=`adw-button font`,this._buttonEl.setAttribute(`aria-haspopup`,`dialog`),this._buttonEl.append(this._labelEl,this._sizeBoxEl),this._selectEl=document.createElement(`select`),this._selectEl.className=`font-button-chooser`,this._selectEl.addEventListener(`change`,()=>this._choose()),this._dockEl=document.createElement(`gtk-popover`),this._dockEl.classList.add(`font-button-popover`),this._dockEl.replaceChildren(this._selectEl),this._dockEl.anchor=this._buttonEl,this.replaceChildren(this._buttonEl,this._dockEl),this._buttonEl.addEventListener(`click`,()=>this.activate()),this._dockEl.subscribe(e=>{e||(this._pending=!1),this._renderSensitivity()}),this.hasAttribute(`dialog`)&&(this.dialog={});for(let e of[`font-desc`,`font-features`,`language`]){let t=this.getAttribute(e);t!==null&&(e===`font-desc`?this.fontDesc=t:e===`font-features`?this.fontFeatures=t:this.language=t)}this._render()}attributeChangedCallback(e){if(this._initialized)switch(e){case`font-desc`:{let e=this.getAttribute(`font-desc`);e!==null&&(this.fontDesc=e);return}case`font-features`:this.fontFeatures=this.getAttribute(`font-features`)??``;return;case`language`:this.language=this.getAttribute(`language`);return;case`dialog`:this.dialog=this.hasAttribute(`dialog`)?this._dialog??{}:null;return;case`disabled`:this._renderSensitivity();return;default:this._render()}}activate(){this.dispatchEvent(new CustomEvent(`activate`,{bubbles:!0})),this._openChooser()}_openChooser(){this._dialog===null||this._pending||(this._pending=!0,this._renderSensitivity(),this._selectEl.replaceChildren(...this._options()),this._dockEl.popup())}_options(){let e=new Set;for(let t of document.fonts)t.family&&e.add(t.family);this._desc.family!==``&&e.add(this._desc.family);let t=[],n=new Set,add=e=>{let r=formatFontDescription(e);if(n.has(r))return;n.add(r);let i=document.createElement(`option`);i.value=r,i.textContent=r,t.push(i)};add(this._desc);for(let t of[...e].sort())for(let{weight:e,slant:n}of fa){let r={...this._desc,family:t,weight:e,slant:n};document.fonts.check(cssFontShorthand(r,!0))&&add(r)}return t}_choose(){let e=parseFontDescription(this._selectEl.value),t=this.level;t===`family`?this.fontDesc={...la,family:e.family}:t===`face`?this.fontDesc={...e,size:this._desc.size,absolute:this._desc.absolute}:this.fontDesc=e,this._pending=!1,this._dockEl.popdown(),this._renderSensitivity()}_renderSensitivity(){let e=this._dialog!==null&&!this.hasAttribute(`disabled`);this._buttonEl.disabled=!e,this._buttonEl.classList.toggle(`disabled`,!e)}_render(){if(!this._initialized)return;let e=this.level,t=this._faceName(),n=[this._desc.family===``?`None`:this._desc.family];e!==`family`&&t!==``&&n.push(t),this._labelEl.textContent=n.join(` `),this._sizeBoxEl.hidden=e===`family`||e===`face`,this._sizeBoxEl.hidden||(this._sizeLabelEl.textContent=formatFontSize(this._desc.size,this._desc.absolute));let r=this._labelEl.style;if(this.useFont){let e=cssFontParts(this._desc,this.useSize);r.fontFamily=e.fontFamily,r.fontWeight=e.fontWeight,r.fontStyle=e.fontStyle,r.fontStretch=e.fontStretch,r.fontSize=e.fontSize,r.fontFeatureSettings=``;for(let e of cssFontFeatureTags(this._features))if(r.fontFeatureSettings=e,r.fontFeatureSettings!==``)break;this._labelEl.lang=this._language??this._dialog?.language??``}else r.fontFamily=``,r.fontWeight=``,r.fontStyle=``,r.fontStretch=``,r.fontSize=``,r.fontFeatureSettings=``,this._labelEl.lang=``;this._renderSensitivity()}_faceName(){let e=cssFontShorthand(this._desc,!0);if(this._desc.family===``||!document.fonts.check(e))return``;let t=[];return this._desc.slant===`italic`?t.push(`Italic`):this._desc.slant===`oblique`&&t.push(`Oblique`),this._desc.weight!==400&&t.push(this._desc.weight>=700?`Bold`:`Light`),this._desc.width===`condensed`?t.push(`Condensed`):this._desc.width===`expanded`&&t.push(`Expanded`),t.join(` `)}};customElements.define(`gtk-font-dialog-button`,GtkFontDialogButton);function normalizeLabelXalign(e){let t=Number.parseFloat(e??``);return Number.isFinite(t)?glibClamp(t,0,1):0}var GtkFrame=class extends WidgetElement{_mutations=null;static get observedAttributes(){return[`label`,`label-xalign`]}_labelEl=null;_writingLabel=!1;get label(){return this.getAttribute(`label`)}set label(e){e===null?this.removeAttribute(`label`):this.setAttribute(`label`,e)}get labelXalign(){return normalizeLabelXalign(this.getAttribute(`label-xalign`))}set labelXalign(e){this.setAttribute(`label-xalign`,String(e))}get labelWidget(){let e=this.querySelector(`[slot="label-widget"]`);return e===null?this._labelEl?.parentNode===this?this._labelEl:null:e}set labelWidget(e){let t=this.querySelector(`[slot="label-widget"]`);t!==null&&(t.removeAttribute(`slot`),t.remove()),e!==null&&(e.setAttribute(`slot`,`label-widget`),this.prepend(e),this._sync())}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this},{name:`label-widget`,into:this}]),this._mutations=new MutationObserver(()=>this._sync()),this._mutations.observe(this,{childList:!0}),this.setAttribute(`role`,`group`),this._sync()}disconnectedCallback(){this._mutations?.disconnect(),this._mutations=null}attributeChangedCallback(e,t,n){if(this._sync(),!this.isConnected)return;let r=e===`label-xalign`?String(normalizeLabelXalign(n)):n;r!==(e===`label-xalign`?String(normalizeLabelXalign(t)):t)&&this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:r}}))}_sync(){let e=this.querySelector(`[slot="label-widget"]`),t=this.getAttribute(`label`);e===null&&t!==null?(this._labelEl===null&&(this._labelEl=document.createElement(`gtk-label`),this._labelEl.addEventListener(`notify::label`,e=>{this._writingLabel&&e.stopPropagation()})),this._writingLabel=!0,this._labelEl.setAttribute(`label`,t),this._writingLabel=!1,this._labelEl.parentNode!==this&&this.prepend(this._labelEl)):this._labelEl?.parentNode===this&&this._labelEl.remove();let n=this.labelWidget;n!==null&&(n.classList.add(`adw-frame-label`),n.style.alignSelf=labelYalignAlignItems(this.labelXalign))}};customElements.define(`gtk-frame`,GtkFrame);const pa=[`gl`,`gles`];function parseApis(e){let t=e.getAttribute(`allowed-apis`);if(t===null)return[...pa];let n=t.split(/[\s,|]+/).filter(e=>pa.includes(e));return pa.filter(e=>n.includes(e))}function booleanAttribute$1(e,t,n){let r=e.getAttribute(t);return r===null?n:r!==`false`&&r!==`0`}__name(booleanAttribute$1,`booleanAttribute`);var GtkGLArea=class extends WidgetElement{_canvas;_messageEl=null;_initialized=!1;_context=null;_error=null;_needsResize=!1;_allowedApis=[...pa];_needsRender=!0;_haveBuffers=!1;_width=0;_height=0;_scale=1;_resize=null;_frame=null;static get observedAttributes(){return[`auto-render`,`has-depth-buffer`,`has-stencil-buffer`,`allowed-apis`]}get autoRender(){return booleanAttribute$1(this,`auto-render`,!0)}set autoRender(e){this.autoRender!==!!e&&this._write(`auto-render`,String(!!e))}get hasDepthBuffer(){return booleanAttribute$1(this,`has-depth-buffer`,!1)}set hasDepthBuffer(e){this.hasDepthBuffer!==!!e&&this._write(`has-depth-buffer`,String(!!e))}get hasStencilBuffer(){return booleanAttribute$1(this,`has-stencil-buffer`,!1)}set hasStencilBuffer(e){this.hasStencilBuffer!==!!e&&this._write(`has-stencil-buffer`,String(!!e))}get allowedApis(){return[...this._allowedApis]}set allowedApis(e){if(this._context!==null){this._write(`allowed-apis`,this._allowedApis.join(` `));return}this._allowedApis=pa.filter(t=>e.includes(t)),this._write(`allowed-apis`,this._allowedApis.join(` `))}_write(e,t){this.getAttribute(e)!==t&&this.setAttribute(e,t)}get api(){return this._context===null?`gl`:`gles`}get context(){return this._context}get error(){return this._error}setError(e){let t=e===null?null:typeof e==`string`?e:e.message;this._error!==t&&(this._error=t,this._renderMessage(),this._queueDraw())}makeCurrent(){return this._context}queueRender(){this._needsRender=!0,this._queueDraw()}connectedCallback(){if(this._initialized){this._observe();return}this._initialized=!0,this.hasAttribute(`allowed-apis`)&&(this._allowedApis=parseApis(this)),this._canvas=document.createElement(`canvas`),this._canvas.className=`adw-gl-area-canvas`,this.replaceChildren(this._canvas),this._observe()}disconnectedCallback(){this._resize?.disconnect(),this._resize=null,this._frame!==null&&cancelAnimationFrame(this._frame),this._frame=null}_queueDraw(){!this._initialized||this._frame!==null||(this._frame=requestAnimationFrame(()=>{this._frame=null,this._draw()}))}attributeChangedCallback(e){if(this._initialized){switch(e){case`auto-render`:this.autoRender&&this._queueDraw();break;case`has-depth-buffer`:case`has-stencil-buffer`:this._haveBuffers=!1;break;case`allowed-apis`:if(this._context!==null){this._write(`allowed-apis`,this._allowedApis.join(` `));return}this._allowedApis=parseApis(this);break;default:break}this._notify(e)}}_notify(e){let t=e===`allowed-apis`?this.allowedApis.join(` `):e===`auto-render`?this.autoRender:e===`has-depth-buffer`?this.hasDepthBuffer:this.hasStencilBuffer;this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:t}}))}_observe(){this._resize||(this._resize=new ResizeObserver(e=>{for(let t of e){let e=t.borderBoxSize?.[0],n=e?e.inlineSize:t.contentRect.width,r=e?e.blockSize:t.contentRect.height;n===this._width&&r===this._height||(this._width=n,this._height=r,this._needsResize=!0,this._queueDraw())}}),this._resize.observe(this))}_draw(){if(!this._canvas)return;let e=typeof globalThis>`u`?1:globalThis.devicePixelRatio||1;this._scale=e;let t=Math.round(this._width*e),n=Math.round(this._height*e);if(t===0||n===0)return;if(this._error!==null){this._renderMessage();return}let r=this._context??this._createContext();r!==null&&(this.makeCurrent(),this.attachBuffers(r),this.hasDepthBuffer?r.enable?.(r.DEPTH_TEST):r.disable?.(r.DEPTH_TEST),(this._needsRender||this.autoRender)&&(this._needsResize&&(this._needsResize=!1,this.dispatchEvent(new CustomEvent(`resize`,{bubbles:!0,detail:{width:t,height:n}}))),this.dispatchEvent(new CustomEvent(`render`,{bubbles:!0,detail:{context:r}}))),this._needsRender=!1)}attachBuffers(e=this._context){e!==null&&(this.hasStencilBuffer?e.enable?.(e.STENCIL_TEST):e.disable?.(e.STENCIL_TEST),this._haveBuffers=!0)}_createContext(){let e=this.allowedApis;if(e.length===0)return null;let t={context:null};if(this.dispatchEvent(new CustomEvent(`create-context`,{bubbles:!0,detail:t})),t.context!==null)return this._context=t.context,this._context;let n={preserveDrawingBuffer:!0,depth:this.hasDepthBuffer,stencil:this.hasStencilBuffer},r=e.includes(`gles`)?[`webgl2`,`webgl`]:[`webgl`];for(let e of r){let t=this._canvas.getContext(e,n);if(t!==null)return this._context=t,t}return null}_renderMessage(){if(this._error===null){this._messageEl?.remove(),this._messageEl=null;return}this._messageEl||(this._messageEl=document.createElement(`div`),this._messageEl.className=`adw-gl-area-error`,this.append(this._messageEl)),this._messageEl.textContent=this._error}get viewport(){return{width:Math.round(this._width*this._scale),height:Math.round(this._height*this._scale)}}get pixelScale(){return this._scale}};customElements.define(`gtk-gl-area`,GtkGLArea);function booleanAttribute(e,t,n){let r=e.getAttribute(t);return r===null?n:r!==`false`&&r!==`0`}var GtkGraphicsOffload=class extends WidgetElement{_childEl;_initialized=!1;static get observedAttributes(){return[`enabled`,`black-background`]}get child(){return this._childEl?.firstElementChild??null}get enabled(){return this.getAttribute(`enabled`)===`disabled`?`disabled`:`enabled`}set enabled(e){this.enabled!==e&&this.setAttribute(`enabled`,e)}get blackBackground(){return booleanAttribute(this,`black-background`,!1)}set blackBackground(e){this.blackBackground!==!!e&&this.setAttribute(`black-background`,String(!!e))}connectedCallback(){this._initialized||(this._initialized=!0,this._childEl=document.createElement(`div`),this._childEl.className=`adw-graphics-offload-child`,bindSlottedChildren(this,[{name:`child`,into:this._childEl},{into:this._childEl}]).install(this._childEl),this.replaceChildren(this._childEl),this._render())}attributeChangedCallback(e){this._initialized&&((e===`enabled`||e===`black-background`)&&this._render(),this._notify(e))}_render(){let e=this.enabled!==`disabled`;this.style.willChange=e?`transform`:``,this.style.backgroundColor=this.blackBackground?`#000000`:``}_notify(e){let t=e===`enabled`?this.enabled:this.blackBackground;this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:t}}))}};customElements.define(`gtk-graphics-offload`,GtkGraphicsOffload);var GtkGrid=class extends WidgetElement{static get observedAttributes(){return[`column-spacing`,`row-spacing`,`column-homogeneous`,`row-homogeneous`,`orientation`]}get columnSpacing(){return normalizeBoxSpacing(this.getAttribute(`column-spacing`))}set columnSpacing(e){this.setAttribute(`column-spacing`,String(e))}get rowSpacing(){return normalizeBoxSpacing(this.getAttribute(`row-spacing`))}set rowSpacing(e){this.setAttribute(`row-spacing`,String(e))}get columnHomogeneous(){return this.hasAttribute(`column-homogeneous`)}set columnHomogeneous(e){this.toggleAttribute(`column-homogeneous`,!!e)}get rowHomogeneous(){return this.hasAttribute(`row-homogeneous`)}set rowHomogeneous(e){this.toggleAttribute(`row-homogeneous`,!!e)}get orientation(){return normalizeBoxOrientation(this.getAttribute(`orientation`))}set orientation(e){this.setAttribute(`orientation`,e)}connectedCallback(){this.setAttribute(`role`,`generic`),this._sync()}attributeChangedCallback(e,t,n){if(this._sync(),!this.isConnected)return;let r=this._normalized(e,n);r!==this._normalized(e,t)&&this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:r}}))}_normalized(e,t){return e===`column-spacing`||e===`row-spacing`?normalizeBoxSpacing(t):e===`orientation`?normalizeBoxOrientation(t):t!==null}_sync(){this.style.rowGap=`${this.rowSpacing}px`,this.style.columnGap=`${this.columnSpacing}px`,this.style.gridAutoRows=this.rowHomogeneous?`1fr`:``,this.style.gridAutoColumns=this.columnHomogeneous?`1fr`:``,this.style.gridAutoFlow=this.orientation===`vertical`?`row`:`column`}};customElements.define(`gtk-grid`,GtkGrid);function cssPixels(e,t){let n=Number.parseFloat(e);return Number.isFinite(n)?n:t}var GtkGridView=class extends GtkListView{_observer=null;static get observedAttributes(){return[`model`,`selection-mode`,`single-click-activate`,`enable-rubberband`,`tab-behavior`,`orientation`,`min-columns`,`max-columns`]}get minColumns(){return this._columnBound(`min-columns`,1)}set minColumns(e){this.setAttribute(`min-columns`,String(e))}get maxColumns(){return this._columnBound(`max-columns`,7)}set maxColumns(e){this.setAttribute(`max-columns`,String(e))}connectedCallback(){super.connectedCallback(),this._observer===null&&(this._observer=new ResizeObserver(()=>this._applyColumns()),this._observer.observe(this),this._applyColumns())}disconnectedCallback(){this._observer?.disconnect(),this._observer=null}attributeChangedCallback(e){super.attributeChangedCallback(e),this._applyColumns()}get _viewClass(){return`adw-grid-view`}get _rowClass(){return`adw-grid-view-child`}_renderRows(){super._renderRows(),this._applyColumns()}_columnBound(e,t){let n=Number.parseInt(this.getAttribute(e)??``,10);return Number.isFinite(n)&&n>=1?n:t}_applyColumns(){let e=this._rows[0];if(e===void 0)return;let t=cssPixels(globalThis.getComputedStyle(e).minWidth,120),n=cssPixels(globalThis.getComputedStyle(this._listEl).columnGap,6),r=gridViewColumns(Math.round(this.getBoundingClientRect().width),t,n,this.minColumns,this.maxColumns);this._listEl.style.gridTemplateColumns=`repeat(${r}, 1fr)`}};customElements.define(`gtk-grid-view`,GtkGridView);var GtkHeaderBar=class extends WidgetElement{_initialized=!1;_handle;_box;_startBox;_endBox;_startControls=null;_endControls=null;_titleLabel=null;_centre=null;_centreObserver=null;static get observedAttributes(){return[`decoration-layout`,`show-title-buttons`]}get decorationLayout(){return this.getAttribute(`decoration-layout`)}set decorationLayout(e){e===null?this.removeAttribute(`decoration-layout`):this._write(`decoration-layout`,e)}get showTitleButtons(){return this.getAttribute(`show-title-buttons`)!==`false`}set showTitleButtons(e){this._write(`show-title-buttons`,String(e))}get titleWidget(){return this._centre}_write(e,t){this.getAttribute(e)!==t&&this.setAttribute(e,t)}connectedCallback(){if(this._initialized){this._followCentre();return}this._initialized=!0,this.setAttribute(`role`,`group`),this._startBox=document.createElement(`div`),this._startBox.className=`adw-gtk-header-bar-start`,this._endBox=document.createElement(`div`),this._endBox.className=`adw-gtk-header-bar-end`,this._box=document.createElement(`div`),this._box.className=`adw-gtk-header-bar-box`,this._box.append(this._startBox,this._endBox),this._handle=document.createElement(`div`),this._handle.className=`adw-gtk-header-bar-handle`,this._handle.appendChild(this._box),this._renderTitleButtons(),bindSlottedChildren(this,[{name:`start`,into:this._startBox},{name:`title`,into:this._box},{name:`title-widget`,into:this._box},{name:`end`,consume:e=>this._endBox.prepend(e)},{into:this._startBox}]).install(this._handle),this._followCentre()}disconnectedCallback(){this._centreObserver?.disconnect(),this._centreObserver=null}attributeChangedCallback(e){this._initialized&&(e===`show-title-buttons`?this._renderTitleButtons():this._bindDecorationLayout(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:this._property(e)}})))}_property(e){return e===`show-title-buttons`?this.showTitleButtons:this.decorationLayout}_renderTitleButtons(){if(!this.showTitleButtons){this._startControls?.remove(),this._endControls?.remove(),this._startControls=null,this._endControls=null;return}this._startControls===null&&(this._startControls=document.createElement(`gtk-window-controls`),this._startControls.setAttribute(`side`,`start`),this._startBox.prepend(this._startControls),this._endControls=document.createElement(`gtk-window-controls`),this._endControls.setAttribute(`side`,`end`),this._endBox.appendChild(this._endControls)),this._bindDecorationLayout()}_bindDecorationLayout(){for(let e of[this._startControls,this._endControls]){if(e===null)continue;let t=this.decorationLayout;t===null?e.removeAttribute(`decoration-layout`):e.setAttribute(`decoration-layout`,t)}}_followCentre(){this._centreObserver?.disconnect(),this._centreObserver=new MutationObserver(()=>this._syncCentre()),this._centreObserver.observe(this._box,{childList:!0});let e=this.closest(`gtk-window, adw-window`);e!==null&&this._centreObserver.observe(e,{attributes:!0,attributeFilter:[`title`]}),this._syncCentre()}_centreChild(){for(let e of this._box.children)if(!(e===this._startBox||e===this._endBox||e===this._titleLabel)&&e instanceof HTMLElement)return e;return null}_syncCentre(){this._centre=this._centreChild(),this._centre===null?this._titleLabel===null?this._constructTitleLabel():this._updateTitle():this._dropTitleLabel()}_constructTitleLabel(){let e=document.createElement(`gtk-label`);e.className=`title adw-gtk-header-bar-title`,this._titleLabel=e,this._box.appendChild(e),this._updateTitle()}_dropTitleLabel(){this._titleLabel?.remove(),this._titleLabel=null}_updateTitle(){let e=this._titleLabel;if(e===null)return;let t=this.closest(`gtk-window, adw-window`)?.getAttribute(`title`)??document.title;t===``?e.removeAttribute(`label`):e.setAttribute(`label`,t)}};customElements.define(`gtk-header-bar`,GtkHeaderBar);var GtkLinkButton=class extends GtkButton{_wired=!1;static get observedAttributes(){return[...GtkButton.observedAttributes,`uri`,`visited`]}get uri(){return this.getAttribute(`uri`)??``}set uri(e){this.setAttribute(`uri`,e)}get visited(){return this.hasAttribute(`visited`)}set visited(e){this.toggleAttribute(`visited`,!!e)}connectedCallback(){super.connectedCallback(),!this._wired&&(this._wired=!0,this.button.addEventListener(`click`,()=>this._activateLink()))}attributeChangedCallback(e){e===`uri`&&this.isConnected&&(this.visited=!1),super.attributeChangedCallback(),e===`visited`&&this.isConnected&&this.dispatchEvent(new CustomEvent(`notify::visited`,{bubbles:!0,detail:{visited:this.visited}}))}_activateLink(){let e=new CustomEvent(`activate-link`,{bubbles:!0,cancelable:!0});if(this.dispatchEvent(e),e.defaultPrevented)return;let{uri:t}=this;t!==``&&(this.launch(t),this.visited=!0)}launch(e){globalThis.open(e,`_blank`,`noopener`)}decorate(e){e.classList.add(`link`),e.classList.toggle(`visited`,this.visited);let t=(this.getAttribute(`label`)??``).trim();(this.getAttribute(`tooltip`)??this.getAttribute(`tooltip-text`))===null&&t!==``&&this.uri!==``&&this.uri!==t&&(e.title=this.uri)}};customElements.define(`gtk-link-button`,GtkLinkButton);const ma=[`clip`,`ellipsize-start`,`ellipsize-middle`,`ellipsize-end`];function normalizeInscriptionOverflow(e){return ma.includes(e)?e:`clip`}function normalizeInscriptionWrapMode(e){return bn.includes(e)?e:`word-char`}function normalizeAlignment(e,t){let n=typeof e==`number`?e:Number.parseFloat(String(e??``));return Number.isFinite(n)?Math.min(1,Math.max(0,n)):t}function normalizeCount(e){let t=typeof e==`number`?e:Number.parseInt(String(e??``),10);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):0}var GtkInscription=class extends WidgetElement{_initialized=!1;static get observedAttributes(){return[`markup`,`min-chars`,`min-lines`,`nat-chars`,`nat-lines`,`text`,`text-overflow`,`wrap-mode`,`xalign`,`yalign`]}get text(){return this.getAttribute(`text`)??``}set text(e){this._write(`text`,e)}get markup(){return this.getAttribute(`markup`)??``}set markup(e){this._write(`markup`,e)}get minChars(){let e=this.getAttribute(`min-chars`);return e===null?3:normalizeCount(e)}set minChars(e){this._write(`min-chars`,String(e))}get natChars(){return normalizeCount(this.getAttribute(`nat-chars`))}set natChars(e){this._write(`nat-chars`,String(e))}get minLines(){let e=this.getAttribute(`min-lines`);return e===null?1:normalizeCount(e)}set minLines(e){this._write(`min-lines`,String(e))}get natLines(){return normalizeCount(this.getAttribute(`nat-lines`))}set natLines(e){this._write(`nat-lines`,String(e))}get textOverflow(){return normalizeInscriptionOverflow(this.getAttribute(`text-overflow`))}set textOverflow(e){this._write(`text-overflow`,e)}get wrapMode(){return normalizeInscriptionWrapMode(this.getAttribute(`wrap-mode`))}set wrapMode(e){this._write(`wrap-mode`,e)}get xalign(){return normalizeAlignment(this.getAttribute(`xalign`),0)}set xalign(e){this._write(`xalign`,String(e))}get yalign(){return normalizeAlignment(this.getAttribute(`yalign`),.5)}set yalign(e){this._write(`yalign`,String(e))}_write(e,t){this.getAttribute(e)!==t&&this.setAttribute(e,t)}connectedCallback(){if(this._initialized){this._render();return}this._initialized=!0,this._render()}attributeChangedCallback(e){this._initialized&&(this._render(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:this._property(e)}})))}_property(e){switch(e){case`text`:return this.text;case`markup`:return this.markup;case`min-chars`:return this.minChars;case`nat-chars`:return this.natChars;case`min-lines`:return this.minLines;case`nat-lines`:return this.natLines;case`text-overflow`:return this.textOverflow;case`wrap-mode`:return this.wrapMode;case`xalign`:return this.xalign;default:return this.yalign}}_render(){let e=this.text,t=this.markup;this.textContent=e||!t?e:labelDisplayText(t,!0,!1);let n=this.minChars,r=this.natChars;if(n===0&&r===0)this.style.setProperty(`--gtk-inscription-min-ch`,`auto`),this.style.setProperty(`--gtk-inscription-width`,`auto`);else{let{minCh:e,maxCh:t}=labelWidthCharsExtent(n,r);this.style.setProperty(`--gtk-inscription-min-ch`,`${e}ch`),this.style.setProperty(`--gtk-inscription-width`,`${t}ch`)}let i=this.minLines,a=this.natLines;this.style.setProperty(`--gtk-inscription-min-lh`,i===0&&a===0?`auto`:`${i}lh`),this.style.setProperty(`--gtk-inscription-height`,i===0&&a===0?`auto`:`${Math.max(i,a)}lh`),this.style.setProperty(`--gtk-inscription-xalign`,String(this.xalign)),this.style.setProperty(`--gtk-inscription-align-items`,labelYalignAlignItems(this.yalign));let o=this.textOverflow;this.style.setProperty(`--gtk-inscription-text-overflow`,labelEllipsizeOverflowValue(o===`clip`?`none`:`end`)),this.classList.toggle(`clip`,o===`clip`),this.classList.toggle(`ellipsized`,o!==`clip`)}};customElements.define(`gtk-inscription`,GtkInscription);const ha=[[`low`,.25],[`high`,.75],[`full`,1]];function levelClassFor(e,t){for(let n=0;n<e.length;n++){let[r,i]=e[n];if(t>i)continue;let a=n===0?null:e[n-1][1];if(a===null||a<t)return r}return null}function numberAttribute(e,t,n){let r=Number.parseFloat(e.getAttribute(t)??``);return Number.isFinite(r)?r:n}var GtkLevelBar=class extends WidgetElement{_trough;_initialized=!1;_offsets=ha.map(e=>[...e]);static get observedAttributes(){return[`value`,`min-value`,`max-value`,`mode`,`inverted`,`orientation`,`disabled`]}get value(){return numberAttribute(this,`value`,0)}set value(e){this._write(`value`,String(e))}get minValue(){return numberAttribute(this,`min-value`,0)}set minValue(e){this._write(`min-value`,String(e))}get maxValue(){return numberAttribute(this,`max-value`,1)}set maxValue(e){this._write(`max-value`,String(e))}get mode(){return this.getAttribute(`mode`)===`discrete`?`discrete`:`continuous`}set mode(e){this._write(`mode`,e)}get inverted(){return this.hasAttribute(`inverted`)}set inverted(e){this.toggleAttribute(`inverted`,!!e)}get orientation(){return normalizeBoxOrientation(this.getAttribute(`orientation`))}set orientation(e){this._write(`orientation`,e)}_write(e,t){this.getAttribute(e)!==t&&this.setAttribute(e,t)}get disabled(){return this.hasAttribute(`disabled`)}set disabled(e){this.toggleAttribute(`disabled`,!!e)}addOffsetValue(e,t){if(t<this.minValue||t>this.maxValue)return;let n=this._offsets.findIndex(([t])=>t===e);n!==-1&&this._offsets[n][1]===t||(n!==-1&&this._offsets.splice(n,1),this._offsets.push([e,t]),this._offsets.sort((e,t)=>e[1]-t[1]),this._render(),this.dispatchEvent(new CustomEvent(`offset-changed`,{bubbles:!0,detail:{name:e}})))}removeOffsetValue(e){let t=this._offsets.findIndex(([t])=>t===e);t!==-1&&(this._offsets.splice(t,1),this._render())}offsetValue(e){return this._offsets.find(([t])=>t===e)?.[1]??null}connectedCallback(){if(this._initialized){this._render();return}this._initialized=!0,this._trough=document.createElement(`span`),this._trough.className=`adw-level-bar-trough`,this.replaceChildren(this._trough),this.setAttribute(`role`,`meter`),this._render()}attributeChangedCallback(e){if(!(!this._initialized||e===`disabled`)){if(e===`min-value`&&this.value<this.minValue){this._write(`value`,String(this.minValue)),this._notify(e);return}if(e===`max-value`&&(this._clampOffsets(),this.value>this.maxValue)){this._write(`value`,String(this.maxValue)),this._notify(e);return}this._render(),this._notify(e)}}_notify(e){this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:this._property(e)}}))}_clampOffsets(){for(let e=0;e<this._offsets.length;e++){let[t,n]=this._offsets[e];n<this.minValue?this._offsets[e]=[t,this.minValue]:n>this.maxValue&&(this._offsets[e]=[t,this.maxValue])}}_property(e){switch(e){case`value`:return this.value;case`min-value`:return this.minValue;case`max-value`:return this.maxValue;case`mode`:return this.mode;case`inverted`:return this.inverted;default:return this.orientation}}_render(){if(!this._trough)return;let e=this.mode===`discrete`,t=this.orientation===`vertical`;this.classList.toggle(`continuous`,!e),this.classList.toggle(`discrete`,e),this.classList.toggle(`vertical`,t),this.classList.toggle(`horizontal`,!t);let n=this.minValue,r=this.maxValue,i=this.value,a=e?Math.max(1,Math.round(r)-Math.round(n)):1,o=levelClassFor(this._offsets,i);if(this._trough.replaceChildren(),e){let e=Math.min(a,Math.max(0,Math.round(i)-Math.round(n)));for(let t=0;t<a;t++){let n=this.inverted?t>=a-e:t<e;this._trough.append(this._block(n?`filled`:`empty`,n?o:null))}}else{let e=this._block(`empty`,null),t=this._block(`filled`,o);t.style.setProperty(`--level-fraction`,String(r>n?(i-n)/(r-n):0)),t.hidden=i===0,this._trough.append(e,t)}this.setAttribute(`aria-valuemin`,String(n)),this.setAttribute(`aria-valuemax`,String(r)),this.setAttribute(`aria-valuenow`,String(i))}_block(e,t){let n=document.createElement(`span`);return n.className=`adw-level-bar-block ${e}`,e===`filled`&&t&&n.classList.add(t),n}};customElements.define(`gtk-level-bar`,GtkLevelBar);var GtkListBoxRow=class extends WidgetElement{_contentsEl;_activation;_initialized=!1;static get observedAttributes(){return[`activatable`,`selectable`]}get activatable(){return this.getAttribute(`activatable`)!==`false`}set activatable(e){this.setAttribute(`activatable`,String(!!e))}get selectable(){return this.getAttribute(`selectable`)!==`false`}set selectable(e){this.setAttribute(`selectable`,String(!!e))}get index(){return this.parentElement?[...this.parentElement.children].indexOf(this):-1}get selected(){return this.classList.contains(`selected`)}get child(){return this._contentsEl.firstElementChild}connectedCallback(){this._initialized||(this._initialized=!0,this._contentsEl=document.createElement(`div`),this._contentsEl.className=`adw-list-box-row-contents`,bindSlottedChildren(this,[{name:`child`,into:this._contentsEl},{into:this._contentsEl}]).install(this._contentsEl),this.setAttribute(`role`,`listitem`),this._claimed?this._syncActivation():this.syncClasses(!0))}claim(){this._claimed=!0}release(){this._claimed=!1,this.syncClasses(!1)}_canSelect=!0;_claimed=!1;attributeChangedCallback(){this._initialized&&this.syncClasses(this._canSelect)}syncClasses(e){this._canSelect=e,this.classList.toggle(`activatable`,this.activatable||this.selectable&&e),this._syncActivation()}_syncActivation(){this._activation??=attachRowActivation({row:this,activatable:()=>this.classList.contains(`activatable`),activate:()=>this.dispatchEvent(new CustomEvent(`activate`,{bubbles:!0}))}),this._claimed||this._activation.sync()}};customElements.define(`gtk-list-box-row`,GtkListBoxRow);const ga=new Set([`all`,`item`,`cell`]);function normalizeListTabBehavior(e){return e!=null&&ga.has(e)?e:`all`}var GtkListBox=class extends WidgetElement{_rows=[];_selection=[];_anchor=-1;_initialized=!1;static get observedAttributes(){return[`selection-mode`,`activate-on-single-click`,`accept-unpaired-release`,`show-separators`,`tab-behavior`]}get selectionMode(){return normalizeBoxSelectionMode(this.getAttribute(`selection-mode`))}set selectionMode(e){this.setAttribute(`selection-mode`,e)}get activateOnSingleClick(){return this.getAttribute(`activate-on-single-click`)!==`false`}set activateOnSingleClick(e){this.setAttribute(`activate-on-single-click`,String(!!e))}get acceptUnpairedRelease(){return this.hasAttribute(`accept-unpaired-release`)}set acceptUnpairedRelease(e){this.toggleAttribute(`accept-unpaired-release`,!!e)}get showSeparators(){return this.hasAttribute(`show-separators`)}set showSeparators(e){this.toggleAttribute(`show-separators`,!!e)}get tabBehavior(){return normalizeListTabBehavior(this.getAttribute(`tab-behavior`))}set tabBehavior(e){this.setAttribute(`tab-behavior`,e)}get rows(){return this._rows}get selectedRows(){return[...this._selection]}set selectedRows(e){for(let t of typeof e==`number`?[e]:e??[])this.selectRow(this._rows[t]??null)}get selectedRowElements(){return this._selection.map(e=>this._rows[e]).filter(e=>e!==void 0)}connectedCallback(){this._initialized||(this._initialized=!0,this.addEventListener(`click`,e=>this._onClick(e)),this.addEventListener(`dblclick`,e=>this._onDoubleClick(e)),this.addEventListener(`keydown`,e=>this._onKeyDown(e)),attachRovingFocus({host:this,orientation:`vertical`,items:()=>this._rows,select:e=>this._updateSelection(e,{})}),new MutationObserver(()=>this._collectRows()).observe(this,{childList:!0}),this._applyAttributes(),this._collectRows())}attributeChangedCallback(e){this._initialized&&(this._applyAttributes(),e===`selection-mode`&&this._syncRows(),e===`tab-behavior`&&this._syncTabIndexes())}selectRow(e){let t=e===null?null:this._rows.indexOf(e),n=listBoxSelectRow(this._selection,this._anchor,t,this._rows.length,this.selectionMode,e===null||e.selectable);same(n.selection,this._selection)&&n.anchor===this._anchor||(this._selection=n.selection,this._anchor=n.anchor,this._emitSelection(e))}unselectRow(e){let t=listBoxUnselectRow(this._selection,this._anchor,this._rows.indexOf(e),this._rows.length,this.selectionMode);same(t.selection,this._selection)||(this._selection=t.selection,this._emitSelection(null))}selectAll(){let e=listBoxSelectAll(this._rows.length,this.selectionMode);e!==null&&(this._selection=e,this._anchor=e.length>0?e[0]:-1,this._emitSelection(this.selectedRowElements[0]??null))}unselectAll(){listBoxUnselectAll(this._selection,this.selectionMode)!==null&&(this._selection=[],this._anchor=-1,this._emitSelection(null))}_applyAttributes(){this.classList.toggle(`separators`,this.showSeparators);let e=this.selectionMode!==`none`;this.setAttribute(`role`,e?`listbox`:`list`),this.selectionMode===`multiple`?this.setAttribute(`aria-multiselectable`,`true`):this.removeAttribute(`aria-multiselectable`)}_collectRows(){let e=[...this.querySelectorAll(`:scope > gtk-list-box-row`)];if(!(e.length===this._rows.length&&e.every((e,t)=>e===this._rows[t]))){for(let t of this._rows)e.includes(t)||t.release();for(let t of e)t.claim();this._rows=e,this._selection=this._selection.filter(e=>e<this._rows.length),this._anchor>=this._rows.length&&(this._anchor=-1),this._syncRows()}}_syncRows(){let e=this.selectionMode!==`none`,t=new Set(this._selection);this._rows.forEach((n,r)=>{n.syncClasses(e),n.selectable&&e?n.setAttribute(`aria-selected`,String(t.has(r))):n.removeAttribute(`aria-selected`)}),this._syncTabIndexes()}_syncTabIndexes(){let e=this.tabBehavior!==`all`,t=this._selection.length>0?this._selection[0]:0;this._rows.forEach((n,r)=>{n.tabIndex=e?r===t?0:-1:n.classList.contains(`activatable`)?0:-1})}_onClick(e){let t=this._rowAt(e.target);t===null&&!this.acceptUnpairedRelease||(t!==null&&this._updateSelection(t,{modify:e.ctrlKey||e.metaKey,extend:e.shiftKey}),!(e.detail<(this.activateOnSingleClick?1:2))&&t!==null&&this._activate(t))}_onDoubleClick(e){if(this.activateOnSingleClick)return;let t=this._rowAt(e.target);t!==null&&this._activate(t)}_onKeyDown(e){if(!e.ctrlKey||e.altKey||e.metaKey||e.key!==` `)return;let t=this._rowAt(e.target);t!==null&&(e.preventDefault(),this._updateSelection(t,{modify:!0}))}_rowAt(e){if(!(e instanceof Element))return null;let t=e.closest(`gtk-list-box-row`);return this.contains(t)?t:null}_updateSelection(e,t){let n=listBoxSelect(this._selection,this._anchor,this._rows.indexOf(e),this._rows.length,this.selectionMode,t,e.selectable);same(n.selection,this._selection)||(this._selection=n.selection,this._anchor=n.anchor,this._emitSelection(n.selection.includes(this._rows.indexOf(e))?e:null))}_activate(e){e.activatable&&(this.dispatchEvent(new CustomEvent(`row-activated`,{bubbles:!0,detail:{row:e}})),e.dispatchEvent(new CustomEvent(`activate`,{bubbles:!0})))}_emitSelection(e){this._syncRows(),this.dispatchEvent(new CustomEvent(`selected-rows-changed`,{bubbles:!0})),this.dispatchEvent(new CustomEvent(`row-selected`,{bubbles:!0,detail:{row:e}})),this.dispatchEvent(new CustomEvent(`notify::selected-rows`,{bubbles:!0,detail:{selectedRows:[...this._selection]}}))}};function same(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}customElements.define(`gtk-list-box`,GtkListBox);function volumeIconFor(e){let t=Math.min(1,Math.max(0,Number.isFinite(e)?e:1));return t===0?`audio-volume-muted-symbolic`:t===1?`audio-volume-high-symbolic`:Math.trunc((t-0)/.5)+2===2?`audio-volume-low-symbolic`:`audio-volume-medium-symbolic`}function mediaTimeToString(e,t=!1,n=!1){let r=Math.trunc(e);t&&r++;let i=r%60;r-=i;let a=r%3600/60;r-=a*60;let o=r/3600;return o>0||n?t?`-${o}:${String(a).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`:`${o}:${String(a).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`:t?`-${a}:${String(i).padStart(2,`0`)}`:`${a}:${String(i).padStart(2,`0`)}`}var GtkMediaControls=class extends WidgetElement{_initialized=!1;_playButton;_timeLabel;_seekScale;_durationLabel;_volumeButton;_volumeIcon;_volumePopover;_volumeScale;_media=null;_seeking=!1;_volume=1;connectedCallback(){if(this._initialized){this._adoptMedia();return}this._initialized=!0;let e=document.createElement(`div`);e.className=`adw-media-controls-box`,this._playButton=document.createElement(`button`),this._playButton.className=`adw-media-controls-button adw-flat`,this._playButton.type=`button`,this._playButton.title=`Play`,this._playButton.setAttribute(`aria-label`,`Play`),this._playButton.addEventListener(`click`,()=>this._togglePlay());let t=document.createElement(`div`);t.className=`adw-media-controls-time-box`,this._timeLabel=document.createElement(`span`),this._timeLabel.className=`adw-media-controls-time-label`,this._seekScale=document.createElement(`input`),this._seekScale.className=`adw-media-controls-seek-scale`,this._seekScale.type=`range`,this._seekScale.min=`0`,this._seekScale.max=`10`,this._seekScale.step=`1`,this._seekScale.value=`0`,this._seekScale.setAttribute(`aria-label`,`Position`),this._seekScale.addEventListener(`input`,()=>this._onSeekInput()),this._durationLabel=document.createElement(`span`),this._durationLabel.className=`adw-media-controls-duration-label`,t.append(this._timeLabel,this._seekScale,this._durationLabel),this._volumeButton=document.createElement(`button`),this._volumeButton.className=`adw-media-controls-button adw-media-controls-volume-button adw-flat`,this._volumeButton.type=`button`,this._volumeButton.setAttribute(`aria-label`,`Volume`),this._volumeButton.addEventListener(`click`,()=>this._toggleVolumePopover()),this._volumeIcon=document.createElement(`span`),this._volumeIcon.className=`adw-media-controls-volume-icon`,this._volumePopover=document.createElement(`gtk-popover`),this._volumePopover.className=`adw-media-controls-volume-popover`,this._volumeScale=document.createElement(`input`),this._volumeScale.className=`adw-media-controls-volume-scale`,this._volumeScale.type=`range`,this._volumeScale.min=`0`,this._volumeScale.max=`1`,this._volumeScale.step=`0.1`,this._volumeScale.value=`1`,this._volumeScale.setAttribute(`aria-label`,`Volume`),this._volumeScale.addEventListener(`input`,()=>this._onVolumeInput()),this._volumePopover.append(this._volumeScale),this._volumePopover.addEventListener(`click`,e=>e.stopPropagation()),this._volumeButton.append(this._volumeIcon,this._volumePopover),e.append(this._playButton,t,this._volumeButton),this.replaceChildren(e),this._renderVolume(),this._adoptMedia()}get media(){return this._media}get timestamp(){return this._media?.currentTime??0}get duration(){let e=this._media?.duration??0;return Number.isFinite(e)?e:0}get volume(){return this._volume}set volume(e){this._setVolume(e)}get sensitive(){return this._media!=null}_togglePlay(){let e=this._media??null;e!==null&&(e.paused?e.play().catch(()=>{}):e.pause())}_onSeekInput(){this._seeking=!0,this._media&&(this._media.currentTime=Number.parseFloat(this._seekScale.value)),this._seeking=!1,this._updateTimestamp()}_onVolumeInput(){this._setVolume(Number.parseFloat(this._volumeScale.value))}_setVolume(e){let t=Math.min(1,Math.max(0,Number.isFinite(e)?e:1));this._volume=t,this._media&&(this._media.volume=t),this._renderVolume()}_renderVolume(){this._volumeScale&&(this._volumeScale.value=String(this._volume));let e=document.createElement(`gtk-image`);e.setAttribute(`icon-name`,volumeIconFor(this._volume)),this._volumeIcon?.replaceChildren(e)}_toggleVolumePopover(){this._volumePopover&&(this._volumePopover.hidden=!this._volumePopover.hidden)}_adoptMedia(){let e=this.getAttribute(`for`),t=e?this.ownerDocument.getElementById(e):null,n=(t instanceof HTMLVideoElement?t:null)??this.closest(`gtk-video`)?.querySelector(`video`)??null;if(n===this._media){this._render();return}if(this._media&&this._detachMedia(),this._media=n,n){this._mediaListeners=[[`timeupdate`,()=>this._updateTimestamp()],[`durationchange`,()=>this._updateDuration()],[`play`,()=>this._updatePlaying(!0)],[`pause`,()=>this._updatePlaying(!1)],[`seeked`,()=>this._updateTimestamp()]];for(let[e,t]of this._mediaListeners)n.addEventListener(e,t);this._setVolume(n.volume)}this._render()}_mediaListeners=[];_detachMedia(){if(this._media)for(let[e,t]of this._mediaListeners)this._media.removeEventListener(e,t);this._mediaListeners=[]}_updateTimestamp(){if(!this._initialized)return;let e=this.timestamp,t=this.duration;!this._seeking&&t>0&&(this._seekScale.value=String(e)),this._timeLabel.textContent=mediaTimeToString(e),this._durationLabel.textContent=mediaTimeToString(t>e?t-e:0,!0),this._durationLabel.hidden=t<=0}_updateDuration(){this._initialized&&(this._seekScale.max=String(this.duration>0?this.duration:10),this._updateTimestamp())}_updatePlaying(e){if(!this._initialized)return;let t=document.createElement(`gtk-image`);t.setAttribute(`icon-name`,e?`media-playback-pause-symbolic`:`media-playback-start-symbolic`),this._playButton.replaceChildren(t),this._playButton.title=e?`Pause`:`Play`,this._playButton.setAttribute(`aria-label`,e?`Pause`:`Play`)}_render(){if(!this._initialized)return;let e=this._media??null,t=e!==null;this.classList.toggle(`insensitive`,!t),this._playButton.disabled=!t,this._seekScale.disabled=!t,this._volumeButton.disabled=!t,this._volumeScale.disabled=!t,this._updateDuration(),this._updateTimestamp(),this._updatePlaying(t&&!e.paused)}};customElements.define(`gtk-media-controls`,GtkMediaControls);const _a={down:`bottom`,up:`top`,left:`start`,right:`end`};var GtkMenuButton=class extends WidgetElement{_buttonEl;_popoverEl;_model=[];_actions=null;_menuTitle=``;_initialized=!1;_menuView;static get observedAttributes(){return[`icon-name`,`menu-title`,`menu-model`,`disabled`,`flat`,`circular`,`direction`]}get active(){return this._popoverEl?.open??!1}get menuModel(){return this._model}set menuModel(e){this._model=this._acceptMenu(e),this._initialized&&this._renderMenu()}get menu_model(){return this.menuModel}set menu_model(e){this.menuModel=e}get_menu_model(){return this.menuModel}set_menu_model(e){this.menuModel=e}_acceptMenu(e,t=!0){let n=normalizeMenuModel(e);if(t)return assertMenuRenderable(n,k),n;let r=menuRefusals(n,k);if(r.length===0)return n;console.error(`${k.name} cannot render this menu, so it has none:`);for(let e of r)console.error(` [${e.path.join(`.`)}] ${e.message}`);return[]}get actions(){return this._actions}set actions(e){this._actions=e??null,this._menuView?.setActions(this._actions),this._initialized&&this._renderMenu()}get menuTitle(){return this.getAttribute(`menu-title`)??this._menuTitle}set menuTitle(e){this._menuTitle=e??``,this.setAttribute(`menu-title`,this._menuTitle)}get direction(){let e=this.getAttribute(`direction`);return isSplitButtonDirection(e)?e:`down`}set direction(e){this.setAttribute(`direction`,e)}connectedCallback(){this._initialized||(this._initialized=!0,this.classList.add(`adw-menu-button`),this._buttonEl=document.createElement(`button`),this._buttonEl.type=`button`,this._buttonEl.className=`adw-menu-button-button`,this._buttonEl.setAttribute(`aria-haspopup`,`menu`),this._buttonEl.setAttribute(`aria-expanded`,`false`),this._popoverEl=document.createElement(`gtk-popover`),this._popoverEl.classList.add(`adw-menu-button-popover`),this._popoverEl.setAttribute(`role`,`menu`),this._popoverEl.setAttribute(`menu`,``),this._popoverEl.setAttribute(`align`,`end`),this.replaceChildren(this._buttonEl,this._popoverEl),this._popoverEl.anchor=this._buttonEl,this._popoverEl.subscribe(e=>this._onPopoverToggled(e)),this._menuView=new PopoverMenuView(this._popoverEl,`adw-menu-button`,e=>{let t=menuItemAt(this._model,e);t!==null&&(this._popoverEl.popdown(),this._buttonEl.focus(),activateElementMenuItem(this,t),this.dispatchEvent(new CustomEvent(`menu-item-activated`,{bubbles:!0,detail:{id:t.id??t.label,label:t.label,path:[...e]}})))}),this._menuView.setActions(this._actions),this._buttonEl.addEventListener(`click`,()=>{this.hasAttribute(`disabled`)||!this._popoverEl.open&&this._model.length===0||(this._popoverEl.open=!this._popoverEl.open)}),this._model.length===0&&(this._model=this._parseMenuAttr()),!this.hasAttribute(`flat`)&&!this.hasAttribute(`circular`)&&this.setAttribute(`flat`,``),this._render())}attributeChangedCallback(e){if(!(!this._initialized||!this._buttonEl)){if(e===`menu-model`){this._model=this._parseMenuAttr(),this._renderMenu();return}this._render()}}_parseMenuAttr(){return this._acceptMenu(parseMenuModel(this.getAttribute(`menu-model`)),!1)}_onPopoverToggled(e){this.classList.toggle(`active`,e),this._buttonEl.setAttribute(`aria-expanded`,String(e)),e?(this._refreshActions(),this._menuView.focusableRows[0]?.focus()):this._menuView.reset()}_render(){let e=this.hasAttribute(`disabled`);this.classList.toggle(`disabled`,e),this._buttonEl.disabled=e,e&&this._popoverEl.popdown(),this.classList.toggle(`flat`,this.hasAttribute(`flat`)),this.classList.toggle(`circular`,this.hasAttribute(`circular`)),this._popoverEl.position=_a[Kn(this.direction)],this._buttonEl.replaceChildren(),this._buttonEl.appendChild(createGtkImage(this.getAttribute(`icon-name`)??`open-menu`,`adw-menu-button-icon`)),this._buttonEl.setAttribute(`aria-label`,this.getAttribute(`menu-title`)||`Menu`),this._renderMenu()}_refreshActions(){this._menuView.setActions(this._actions??menuActionsOfElement(this,this._model)),this._menuView.render()}_renderMenu(){this._menuView.setMenuModel(this._model),this._menuView.setTitle(this.getAttribute(`menu-title`)??this._menuTitle),this._menuView.render(),this._model.length===0&&this._popoverEl.popdown()}};customElements.define(`gtk-menu-button`,GtkMenuButton);const va=[`top`,`bottom`,`left`,`right`],ya=[`tab-label`,`menu-label`,`tab-fill`,`tab-expand`,`reorderable`,`detachable`];var GtkNotebook=class extends WidgetElement{_current=null;_initialized=!1;_initializedChildren=new WeakSet;_header;_tabs;_observer=null;_tabNodes=[];_menu=null;static get observedAttributes(){return[`page`,`tab-pos`,`show-tabs`,`show-border`,`scrollable`,`enable-popup`,`group-name`]}get page(){return this._current?this._pages().indexOf(this._current):-1}set page(e){this.setCurrentPage(e)}get tabPos(){let e=this.getAttribute(`tab-pos`);return e!==null&&va.includes(e)?e:`top`}set tabPos(e){this._write(`tab-pos`,e)}get showTabs(){return this._flag(`show-tabs`,!0)}set showTabs(e){this._write(`show-tabs`,e?``:`false`)}get showBorder(){return this._flag(`show-border`,!0)}set showBorder(e){this._write(`show-border`,e?``:`false`)}get scrollable(){return this._flag(`scrollable`,!1)}set scrollable(e){this._write(`scrollable`,e?``:`false`)}get enablePopup(){return this._flag(`enable-popup`,!1)}set enablePopup(e){this._write(`enable-popup`,e?``:`false`)}get groupName(){return this.getAttribute(`group-name`)}set groupName(e){this._write(`group-name`,e)}get currentPage(){return this._current}get nPages(){return this._pages().length}getNthPage(e){let t=this._pages();return t[e<0?t.length-1:e]??null}pageNum(e){return this._pages().indexOf(e)}getPage(e){return this._pages().includes(e)?this._page(e):null}setPage(e){let t=this._pages().indexOf(e);return t===-1?!1:this.setCurrentPage(t)}nextPage(){return this._searchPage(1)}prevPage(){return this._searchPage(-1)}setCurrentPage(e){let t=this._pages(),n=t[e<0?t.length-1:e];return n?this._switchTo(n):!1}appendPage(e,t){return this.insertPage(e,-1,t)}insertPage(e,t,n){let r=t<0?this._pages().length:t;return n!=null&&e.setAttribute(`tab-label`,n),this._initChild(e),this.insertBefore(e,this._pages()[r]??null),this.dispatchEvent(new CustomEvent(`page-added`,{bubbles:!0,detail:{position:r,nPages:this._pages().length}})),this._current||this._switchTo(e),this._render(),r}removePage(e){let t=this._pages().indexOf(e);return t===-1?!1:(e===this._current&&(this._current=null),e.remove(),this.dispatchEvent(new CustomEvent(`page-removed`,{bubbles:!0,detail:{position:t,nPages:this._pages().length}})),this._current||this._takeOver(t),this._render(),!0)}refresh(){this._render()}connectedCallback(){if(this._initialized)this._observer=new MutationObserver(e=>this._onMutations(e));else{this._initialized=!0,this._header=document.createElement(`div`),this._header.className=`adw-notebook-header`,this._tabs=document.createElement(`div`),this._tabs.className=`adw-notebook-tabs`,this._tabs.setAttribute(`role`,`tablist`),this._header.appendChild(this._tabs);for(let e of this._pages())this._initChild(e)}this._header.parentNode!==this&&this.prepend(this._header),this._observer?.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...ya,`hidden`]}),this._current||this._switchTo(this._firstVisible()),this.addEventListener(`contextmenu`,this._onContextMenu),this._render()}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this.removeEventListener(`contextmenu`,this._onContextMenu),this._closeMenu()}attributeChangedCallback(e){if(this._initialized){if(e===`page`){let t=this.getAttribute(e);t!==null&&this.setCurrentPage(Number.parseInt(t,10));return}this._render(),this._notify(e)}}_switchTo(e){let t=this._pages().indexOf(e);if(t===-1||!this._page(e).visible||this._current===e)return!1;let n=new CustomEvent(`switch-page`,{bubbles:!0,cancelable:!0,detail:{page:t,child:e}});return this.dispatchEvent(n),n.defaultPrevented?!1:(this._current=e,this._render(),this._notify(`page`),!0)}_notify(e){this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:this._property(e)}}))}_property(e){switch(e){case`page`:return this.page;case`tab-pos`:return this.tabPos;case`show-tabs`:return this.showTabs;case`show-border`:return this.showBorder;case`scrollable`:return this.scrollable;case`enable-popup`:return this.enablePopup;default:return this.groupName}}_write(e,t){t===null?this.removeAttribute(e):this.getAttribute(e)!==t&&this.setAttribute(e,t)}_flag(e,t){let n=this.getAttribute(e);return n===null?t:n!==`false`}_pages(){return Array.from(this.children).filter(e=>e!==this._header)}_page(e){return{tabLabel:e.getAttribute(`tab-label`),menuLabel:e.getAttribute(`menu-label`),tabFill:e.getAttribute(`tab-fill`)!==`false`,tabExpand:e.hasAttribute(`tab-expand`),reorderable:e.hasAttribute(`reorderable`),detachable:e.hasAttribute(`detachable`),visible:!e.hasAttribute(`hidden`),child:e}}_initChild(e){this._initializedChildren.has(e)||(this._initializedChildren.add(e),e.classList.add(`adw-notebook-page`))}_firstVisible(){return this._pages().find(e=>this._page(e).visible)??null}_searchPage(e){let t=this._pages(),n=this._current?t.indexOf(this._current):-1;for(let r=n+e;r>=0&&r<t.length;r+=e)if(this._switchTo(t[r]))return!0;return!1}_takeOver(e){let t=this._pages();for(let n of[...t.slice(e),...t.slice(0,e)])if(this._switchTo(n))return!0;return!1}_onMutations(e){let t=new Set(this._pages()),n=e.filter(e=>e.target===this||t.has(e.target));if(n.length===0)return;let r=0,i=0,a=[];for(let e of n){if(e.type===`childList`){for(let t of Array.from(e.removedNodes))t===this._current&&(this._current=null),i+=1;for(let t of Array.from(e.addedNodes))!(t instanceof HTMLElement)||t===this._header||(this._initChild(t),r+=1);continue}let t=e.attributeName;if(t===`hidden`){(!this._current||!this._page(this._current).visible)&&this._switchTo(this._firstVisible());continue}t&&ya.includes(t)&&a.push(e.target)}(r>0||i>0)&&this.dispatchEvent(new CustomEvent(`items-changed`,{bubbles:!0,detail:{added:r,removed:i}}));for(let e of a)this.dispatchEvent(new CustomEvent(`page-updated`,{bubbles:!0,detail:{child:e}}));this._render()}_effectiveTabPos(){let e=this.tabPos;return this.getAttribute(`dir`)===`rtl`?e===`left`?`right`:e===`right`?`left`:e:e}_render(){if(!this._initialized)return;let e=this._pages();e.length!==this._tabNodes.length&&(this._tabs.replaceChildren(),this._tabNodes=e.map(()=>this._buildTab()),this._tabs.append(...this._tabNodes));let t=this._current?e.indexOf(this._current):-1,n=0;e.forEach((e,r)=>{let i=this._tabNodes[r];if(!i)return;let a=this._page(e),o=r===t;a.visible&&(n+=1);let s=a.tabLabel??`Page ${n}`;i.textContent!==s&&(i.textContent=s),i.classList.toggle(`active`,o),i.classList.toggle(`expand`,a.tabExpand),i.classList.toggle(`fill`,a.tabFill),i.classList.toggle(`reorderable`,a.reorderable);let c=!a.visible;i.hidden!==c&&(i.hidden=c),i.setAttribute(`aria-selected`,String(o)),e.classList.toggle(`visible-page`,o),o?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,`true`)});let r=!this.showTabs;this._header.hidden!==r&&(this._header.hidden=r);let i=this._effectiveTabPos();this.getAttribute(`data-tab-pos`)!==i&&this.setAttribute(`data-tab-pos`,i),this.classList.toggle(`frame`,this.showBorder)}_buildTab(){let e=document.createElement(`button`);return e.type=`button`,e.className=`adw-notebook-tab`,e.setAttribute(`role`,`tab`),e.addEventListener(`click`,()=>{let t=this._tabNodes.findIndex(t=>t===e);if(t===-1)return;let n=this._pages()[t];n&&this._switchTo(n)}),e}_onContextMenu=e=>{if(!this.enablePopup)return;e.preventDefault(),this._closeMenu();let t=document.createElement(`div`);t.className=`adw-notebook-menu`,t.setAttribute(`role`,`listbox`);let n=0;for(let e of this._pages()){let r=this._page(e);r.visible&&(n+=1);let i=document.createElement(`button`);i.type=`button`,i.className=`adw-notebook-menu-item`,i.setAttribute(`role`,`option`),i.textContent=r.menuLabel??r.tabLabel??`Page ${n}`,i.hidden=!r.visible,i.setAttribute(`aria-selected`,String(e===this._current)),i.addEventListener(`click`,()=>{this._switchTo(e),this._closeMenu()}),t.appendChild(i)}this.appendChild(t),this._menu=t};_closeMenu(){this._menu?.remove(),this._menu=null}};customElements.define(`gtk-notebook`,GtkNotebook);const ba=[`left`,`right`,`top`,`bottom`];var GtkOverlay=class extends WidgetElement{_childEl;_layerEl;_initialized=!1;_resize=null;_mutations=null;static get observedAttributes(){return[]}get child(){return this._childEl?.firstElementChild??null}get overlayLayer(){return this._layerEl}connectedCallback(){if(this._initialized){this._observe();return}this._initialized=!0,this._childEl=document.createElement(`div`),this._childEl.className=`adw-overlay-child`,this._layerEl=document.createElement(`div`),this._layerEl.className=`adw-overlay-layer`,bindSlottedChildren(this,[{name:`child`,into:this._childEl},{into:this._childEl},{name:`overlay`,into:this._layerEl}]).install(this._childEl,this._layerEl),this._observe()}disconnectedCallback(){this._resize?.disconnect(),this._resize=null,this._mutations?.disconnect(),this._mutations=null}_observe(){this._resize||(this._resize=new ResizeObserver(()=>this._syncEdgeClasses()),this._resize.observe(this._layerEl),this._mutations=new MutationObserver(()=>this._syncEdgeClasses()),this._mutations.observe(this._layerEl,{childList:!0,attributes:!0,subtree:!0}),this._syncEdgeClasses())}_syncEdgeClasses(){let e=this.matches(`:dir(rtl)`);for(let t of this._layerEl.children){let n=t.getAttribute(`halign`),r=t.getAttribute(`valign`),i={left:e?n===`end`:n===`start`,right:e?n===`start`:n===`end`,top:r===`start`,bottom:r===`end`};for(let e of ba)t.classList.toggle(e,i[e])}}};customElements.define(`gtk-overlay`,GtkOverlay);const J=25.4,Y=[{name:`na_letter`,displayName:`US Letter`,width:8.5*J,height:11*J},{name:`na_legal`,displayName:`US Legal`,width:8.5*J,height:14*J},{name:`iso_a4`,displayName:`A4`,width:210,height:297},{name:`iso_a5`,displayName:`A5`,width:148,height:210},{name:`roc_16k`,displayName:`ROC 16k`,width:7.75*J,height:10.75*J},{name:`iso_b5`,displayName:`B5`,width:176,height:250},{name:`jis_b5`,displayName:`JB5`,width:182,height:257},{name:`na_number-10`,displayName:`#10 Envelope`,width:4.125*J,height:9.5*J},{name:`iso_dl`,displayName:`DL Envelope`,width:110,height:220},{name:`jpn_chou3`,displayName:`Choukei 3 Envelope`,width:120,height:235},{name:`na_ledger`,displayName:`Tabloid`,width:11*J,height:17*J},{name:`iso_a3`,displayName:`A3`,width:297,height:420}],xa=new Set([`na_letter`,`na_legal`,`iso_a4`]);function doubleToString(e,t){let n=t===`inch`?e.toFixed(2):e.toFixed(1);return n.includes(`.`)&&(n=n.replace(/0+$/,``),n.endsWith(`.`)&&(n=n.slice(0,-1))),n}function defaultMargins(e){return{top:.25*J,bottom:(xa.has(e.name)?.56:.25)*J,left:.25*J,right:.25*J}}function defaultPageSetup(){let e=Y.find(e=>e.name===`iso_a4`);return{paperSize:e.name,orientation:`portrait`,margins:defaultMargins(e)}}function paperSizeByName(e){return Y.find(t=>t.name===e)??null}function paperSizeOf(e){return paperSizeByName(e.paperSize)??Y[2]}function pageSetupEquals(e,t){return e.paperSize===t.paperSize&&e.margins.top===t.margins.top&&e.margins.bottom===t.margins.bottom&&e.margins.left===t.margins.left&&e.margins.right===t.margins.right}function orientedSize(e,t=`mm`){let n=paperSizeOf(e),r=e.orientation===`landscape`||e.orientation===`reverse-landscape`,i=r?n.height:n.width,a=r?n.width:n.height;return t===`mm`?{width:i,height:a}:{width:i/J,height:a/J}}function unitLabel(e){return e===`mm`?`mm`:`inch`}function paperSizeLabel(e,t=`mm`){let{width:n,height:r}=orientedSize(e,t);return`${doubleToString(n,t)} × ${doubleToString(r,t)} ${unitLabel(t)}`}function paperMarginsTooltip(e,t=`mm`){let inUnit=e=>t===`mm`?e:e/J,shown=e=>`${doubleToString(inUnit(e),t)} ${unitLabel(t)}`,{margins:n}=e;return[`Margins:`,` Left: ${shown(n.left)}`,` Right: ${shown(n.right)}`,` Top: ${shown(n.top)}`,` Bottom: ${shown(n.bottom)}`].join(`
|
|
21
21
|
`)}const Sa={name:`Any Printer`,location:`For portable documents`},Ca=[[`portrait`,`Portrait`],[`reverse-portrait`,`Reverse portrait`],[`landscape`,`Landscape`],[`reverse-landscape`,`Reverse landscape`]];var GtkPageSetupUnixDialog=class extends AdwDialog{_built=!1;static get observedAttributes(){return[...AdwDialog.observedAttributes]}_printerEl;_paperEl;_sizeLabelEl;_radios=new Map;_printers=[];_setups=[];_lastSetup=null;_printSettings=null;_unit=`mm`;get unit(){return this._unit}set unit(e){this._unit=e,this._built&&this._renderSetup()}get printers(){return this._printers.map(e=>({...e}))}set printers(e){this._printers=e.map(e=>({...e})),this._built&&this._renderSetup()}get pageSetup(){return{...this._current(),orientation:this._orientation()}}set pageSetup(e){let t=this._setups.findIndex(t=>pageSetupEquals(t,e));t<0&&this._setups.push(e),this._built&&this._renderSetup();let n=t<0?this._setups.length-1:t;this._paperEl.selected!==n&&(this._paperEl.selected=n),this._setOrientation(e.orientation),this._built&&this._renderSetup()}get printSettings(){return this._printSettings}set printSettings(e){this._printSettings=e;let t=e?.[`format-for-printer`];if(t===void 0)return;let n=this._printerRows().findIndex(e=>e.name===t);n>=0&&(this._printerEl.selected=n)}connectedCallback(){if(this._built){super.connectedCallback();return}super.connectedCallback(),this.hasAttribute(`title`)||this.setAttribute(`title`,`Page Setup`),this._fillPaperSizes();let e=[...this.contentArea.childNodes];this.contentArea.replaceChildren(this._build());for(let t of e)this.contentArea.appendChild(t);this._renderSetup();let t=this._setups.findIndex(e=>e.paperSize===defaultPageSetup().paperSize);t>=0&&this._paperEl.selected!==t&&(this._paperEl.selected=t,this._renderSetup()),this._built=!0}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),!(!this._built||t===n)&&e!==`title`&&this._renderSetup()}_build(){let e=document.createElement(`div`);e.className=`adw-page-setup-grid`,this._printerEl=this._dropDown(`printer`,`_Format for:`),this._printerEl.addEventListener(`notify::selected`,()=>this._printerChanged()),e.append(this._label(`_Format for:`),this._printerEl),this._paperEl=this._dropDown(`paper`,`_Paper size:`),this._paperEl.addEventListener(`notify::selected`,()=>this._paperChanged()),e.append(this._label(`_Paper size:`),this._paperEl),this._sizeLabelEl=document.createElement(`div`),this._sizeLabelEl.className=`adw-page-setup-size-label`,this._sizeLabelEl.setAttribute(`aria-live`,`polite`),e.append(this._sizeLabelEl),e.append(this._label(`_Orientation:`));for(let[t,n]of Ca){let r=document.createElement(`adw-radio`);r.className=`adw-page-setup-orientation`,r.setAttribute(`label`,n),r.setAttribute(`name`,`adw-page-setup-orientation`),r.setAttribute(`value`,t),r.addEventListener(`notify::checked`,()=>this._orientationChanged()),this._radios.set(t,r),e.appendChild(r)}return e.appendChild(this._actions()),e}_dropDown(e,t){let n=document.createElement(`gtk-drop-down`);return n.className=`adw-page-setup-${e}`,n.setAttribute(`aria-label`,t.replace(`_`,``)),n}_label(e){let t=document.createElement(`div`);return t.className=`adw-page-setup-label`,t.textContent=e.replace(`_`,``),t}_actions(){let e=document.createElement(`div`);e.className=`adw-page-setup-actions`;let t=document.createElement(`button`);t.type=`button`,t.className=`adw-page-setup-cancel`,t.textContent=`Cancel`,t.addEventListener(`click`,()=>this._respond(-6));let n=document.createElement(`button`);return n.type=`button`,n.className=`adw-page-setup-apply suggested-action`,n.textContent=`Apply`,n.addEventListener(`click`,()=>this._respond(-5)),e.append(t,n),e}_respond(e){this.dispatchEvent(new CustomEvent(`response`,{bubbles:!0,detail:{responseId:e}})),this.close()}_printerRows(){return[Sa,...this._printers]}_fillPaperSizes(){this._setups=Y.map(e=>({paperSize:e.name,orientation:`portrait`,margins:defaultMargins(e)}))}_current(){return this._setups[this._paperEl.selected]??defaultPageSetup()}_orientation(){for(let[e,t]of this._radios)if(t.checked)return e;return`portrait`}_setOrientation(e){let t=this._radios.get(e);t!==void 0&&(t.checked=!0)}_renderSetup(){let e=this._printerRows();this._printerEl.setAttribute(`model`,JSON.stringify(e.map(e=>e.name))),this._printerEl.selected>=e.length&&(this._printerEl.selected=0);let t=[...this._setups.map(e=>paperSizeOf(e).displayName),`Manage Custom Sizes…`];this._paperEl.setAttribute(`model`,JSON.stringify(t)),this._paperEl.selected>=t.length&&(this._paperEl.selected=0);let n=this._current();this._sizeLabelEl.textContent=paperSizeLabel(n,this._unit),this._sizeLabelEl.title=paperMarginsTooltip(n,this._unit)}_printerChanged(){let e=this._printerRows()[this._printerEl.selected];(e===void 0||e.name===Sa.name)&&this._fillPaperSizes(),this._renderSetup(),this._printSettings!==null&&(this._printSettings={"format-for-printer":e?.name})}_paperChanged(){let e=this._paperEl.selected;if(e>=this._setups.length){let e=this._lastSetup??defaultPageSetup();this._setups.push(e),this._paperEl.selected=this._setups.length-1,this._renderSetup();return}this._lastSetup=this._setups[e]??null,this._renderSetup()}_orientationChanged(){this._built&&(this._setups[this._paperEl.selected]={...this._current(),orientation:this._orientation()},this._renderSetup())}};customElements.define(`gtk-page-setup-unix-dialog`,GtkPageSetupUnixDialog);function computePanedPosition(e){let{allocation:t,startRequest:n,endRequest:r,resizeStart:i,resizeEnd:a,shrinkStart:o,shrinkEnd:s}=e,c=o?0:n,l=t;s||(l=Math.max(1,l-r)),l=Math.max(c,l);let u;return u=e.positionSet?e.lastAllocation>0?i&&!a?e.startChildSize+t-e.lastAllocation:!i&&a?e.startChildSize:t*(e.startChildSize/e.lastAllocation)+.5:e.startChildSize:i&&!a?Math.max(0,t-r):!i&&a?n:n+r===0?t*.5+.5:t*(n/(n+r))+.5,u=Math.trunc(u),{min:c,max:l,position:glibClamp(u,c,l)}}var GtkPaned=class extends WidgetElement{_startEl;_handleEl;_endEl;_initialized=!1;_position=-1;_positionSet=!1;_minPosition=0;_maxPosition=2**53-1;_lastAllocation=0;_dragPos=0;_dragging=!1;_resize=null;static get observedAttributes(){return[`orientation`,`position`,`position-set`,`resize-start-child`,`resize-end-child`,`shrink-start-child`,`shrink-end-child`,`wide-handle`]}get orientation(){return normalizeBoxOrientation(this.getAttribute(`orientation`))}set orientation(e){this.setAttribute(`orientation`,e)}get position(){return this._position}set position(e){this.setPosition(e)}get positionSet(){return this._positionSet}get minPosition(){return this._minPosition}get maxPosition(){return this._maxPosition}get wideHandle(){return this.hasAttribute(`wide-handle`)}set wideHandle(e){this.toggleAttribute(`wide-handle`,!!e)}get startChild(){return this._startEl?.firstElementChild??null}get endChild(){return this._endEl?.firstElementChild??null}connectedCallback(){if(this._initialized){this._observe();return}this._initialized=!0,this.setAttribute(`role`,`group`),this._startEl=document.createElement(`div`),this._startEl.className=`adw-paned-child`,this._handleEl=document.createElement(`div`),this._handleEl.className=`adw-paned-handle separator`,this._handleEl.setAttribute(`role`,`separator`),this._handleEl.tabIndex=0,this._endEl=document.createElement(`div`),this._endEl.className=`adw-paned-child`,bindSlottedChildren(this,[{into:this._startEl},{name:`start`,into:this._startEl},{name:`end`,into:this._endEl},{name:`start-child`,into:this._startEl},{name:`end-child`,into:this._endEl}],()=>this._observe()).install(this._startEl,this._handleEl,this._endEl),this._handleEl.addEventListener(`pointerdown`,this._onPointerDown),this._handleEl.addEventListener(`keydown`,this._onKeyDown);let e=Number.parseFloat(this.getAttribute(`position`)??``);Number.isFinite(e)&&this.setPosition(e),this._observe(),this._layout()}disconnectedCallback(){this._dragging=!1,this._resize?.disconnect(),this._resize=null}attributeChangedCallback(e){if(this._initialized){if(e===`position`){let e=Number.parseFloat(this.getAttribute(`position`)??``);Number.isFinite(e)&&this.setPosition(e);return}e!==`position-set`&&(this._layout(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:this._property(e)}})))}}_property(e){switch(e){case`orientation`:return this.orientation;case`resize-start-child`:return this.getAttribute(`resize-start-child`)!==`false`;case`resize-end-child`:return this.getAttribute(`resize-end-child`)!==`false`;case`shrink-start-child`:return this.getAttribute(`shrink-start-child`)!==`false`;case`shrink-end-child`:return this.getAttribute(`shrink-end-child`)!==`false`;case`wide-handle`:return this.wideHandle;default:return this.getAttribute(e)}}_observe(){this._resize||(this._resize=new ResizeObserver(()=>this._layout()),this._resize.observe(this));for(let e of[this._startEl,this._endEl]){let t=e.firstElementChild;t&&this._resize.observe(t)}}setPosition(e){if(Number.isFinite(e)){if(e<0){this._positionSet&&(this._positionSet=!1,this._notify(`position-set`,{positionSet:!1})),this._position=-1,this._layout();return}this._positionSet||(this._positionSet=!0,this._notify(`position-set`,{positionSet:!0})),this._position!==e&&(this._position=e,this._notify(`position`,{position:e}),this._layout())}}_layout(){if(!this._startEl)return;let e=this.orientation===`horizontal`,t=this._handleEl.getBoundingClientRect(),n=e?t.width:t.height,r=Math.max(1,(e?this.clientWidth:this.clientHeight)-n),i=computePanedPosition({allocation:r,startRequest:this._sizeRequest(this._startEl,e),endRequest:this._sizeRequest(this._endEl,e),resizeStart:this.getAttribute(`resize-start-child`)!==`false`,resizeEnd:this.getAttribute(`resize-end-child`)!==`false`,shrinkStart:this.getAttribute(`shrink-start-child`)!==`false`,shrinkEnd:this.getAttribute(`shrink-end-child`)!==`false`,positionSet:this._positionSet,startChildSize:this._position<0?0:this._position,lastAllocation:this._lastAllocation}),a=Math.floor(i.position);a!==this._position&&(this._position=a,this._notify(`position`,{position:a})),i.min!==this._minPosition&&(this._minPosition=i.min,this._notify(`min-position`,{minPosition:i.min})),i.max!==this._maxPosition&&(this._maxPosition=i.max,this._notify(`max-position`,{maxPosition:i.max})),this._lastAllocation=r,this._startEl.style.flexBasis=`${Math.max(1,a)}px`,this._startEl.style.flexGrow=`0`,this._endEl.style.flexGrow=this.getAttribute(`resize-end-child`)===`false`?`0`:`1`,this._applyMinimum(this._startEl,`shrink-start-child`,e),this._applyMinimum(this._endEl,`shrink-end-child`,e);let o=a!==0,s=a!==r;this._startEl.hidden=!o,this._endEl.hidden=!s,this._handleEl.hidden=!o||!s,this.classList.toggle(`horizontal`,e),this.classList.toggle(`vertical`,!e),this._handleEl.classList.toggle(`wide`,this.wideHandle),this._handleEl.setAttribute(`aria-orientation`,this.orientation),this._handleEl.setAttribute(`aria-valuemin`,`0`),this._handleEl.setAttribute(`aria-valuemax`,String(e?this.clientWidth:this.clientHeight)),this._handleEl.setAttribute(`aria-valuenow`,String(a))}_sizeRequest(e,t){let n=e.style.flexGrow,r=e.style.flexShrink,i=e.style.flexBasis;e.style.flex=`none`;let a=t?e.offsetWidth:e.offsetHeight;return e.style.flexGrow=n,e.style.flexShrink=r,e.style.flexBasis=i,a}_applyMinimum(e,t,n){let r=this.getAttribute(t)!==`false`;e.style.minWidth=n&&r?`0`:``,e.style.minHeight=n?``:r?`0`:``}_notify(e,t){this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:t}))}get _isRtl(){return this.orientation===`horizontal`&&this.matches(`:dir(rtl)`)}_onPointerDown=e=>{if(e.button!==0||this._handleEl.hidden)return;this._dragging=!0,this._handleEl.setPointerCapture(e.pointerId);let t=this.orientation===`horizontal`,n=this._handleEl.getBoundingClientRect(),r=t?e.clientX:e.clientY,i=t?n.left:n.top;this._dragPos=r-i-(this.wideHandle?0:6),this._handleEl.addEventListener(`pointermove`,this._onPointerMove),this._handleEl.addEventListener(`pointerup`,this._onPointerUp),this._handleEl.addEventListener(`pointercancel`,this._onPointerUp)};_onPointerMove=e=>{if(!this._dragging)return;let t=this.orientation===`horizontal`,n=(t?e.clientX:e.clientY)-this._dragPos,r=t?this._handleEl.offsetWidth:this._handleEl.offsetHeight,i=this._isRtl?(t?this.clientWidth:this.clientHeight)-n-r:n;this.setPosition(glibClamp(Math.round(i),this._minPosition,this._maxPosition))};_onPointerUp=e=>{this._dragging&&(this._dragging=!1,this._handleEl.hasPointerCapture(e.pointerId)&&this._handleEl.releasePointerCapture(e.pointerId),this._handleEl.removeEventListener(`pointermove`,this._onPointerMove),this._handleEl.removeEventListener(`pointerup`,this._onPointerUp),this._handleEl.removeEventListener(`pointercancel`,this._onPointerUp))};_onKeyDown=e=>{if(e.altKey||e.metaKey||e.shiftKey)return;if(e.key===`Escape`){this.dispatchEvent(new CustomEvent(`cancel-position`,{bubbles:!0,detail:{}}));return}if(e.key===`Enter`||e.key===` `){this.dispatchEvent(new CustomEvent(`accept-position`,{bubbles:!0,detail:{}}));return}let t=0,n=null;switch(e.key){case`ArrowLeft`:t=e.ctrlKey?-75:-1;break;case`ArrowRight`:t=e.ctrlKey?75:1;break;case`ArrowUp`:t=e.ctrlKey?-75:-1;break;case`ArrowDown`:t=e.ctrlKey?75:1;break;case`PageUp`:t=-75;break;case`PageDown`:t=75;break;case`Home`:n=`start`;break;case`End`:n=`end`;break;default:return}e.preventDefault();let r;n===`start`?r=this._minPosition:n===`end`?r=this._maxPosition:(this._isRtl&&(t=-t),r=this._position+t),this.setPosition(glibClamp(r,this._minPosition,this._maxPosition))}};customElements.define(`gtk-paned`,GtkPaned);var GtkPasswordEntry=class extends GtkEntry{_entry=new EntryRowState;_password=new PasswordEntryRowState(this._entry);_toggle;_peekIcon;_capsLock;static get observedAttributes(){return[...GtkEntry.observedAttributes,`show-peek-icon`]}get revealed(){return this._password.revealed}set revealed(e){this._password.setRevealed(e)}get capsLockOn(){return this._password.capsLockOn}setCapsLockOn(e){this._password.setCapsLockOn(e)}connectedCallback(){super.connectedCallback(),this._input.type=`password`,this._input.autocomplete=`new-password`,this._capsLock=document.createElement(`span`),this._capsLock.className=`adw-password-entry-caps-lock`,this._capsLock.textContent=`⇪`,this._capsLock.setAttribute(`role`,`alert`),this._toggle=document.createElement(`button`),this._toggle.type=`button`,this._toggle.className=`adw-button flat circular icon-only adw-password-entry-peek`,this._peekIcon=createGtkImage(null,`adw-password-entry-peek-icon`),this._toggle.append(this._peekIcon),this._toggle.addEventListener(`click`,()=>this._password.togglePeek()),this._toggle.addEventListener(`mousedown`,e=>e.preventDefault());let readCapsLock=e=>this._password.setCapsLockOn(e.getModifierState(`CapsLock`));this._input.addEventListener(`keydown`,readCapsLock),this._input.addEventListener(`keyup`,readCapsLock),this._input.addEventListener(`focus`,()=>{this._entry.setEditing(!0),this._passwordChanged()}),this._input.addEventListener(`blur`,()=>{this._entry.setEditing(!1),this._passwordChanged()}),this.replaceChildren(this._capsLock,this._input,this._toggle),this._toggle.hidden=!this.hasAttribute(`show-peek-icon`),this._applyPassword(this._password.state),this._password.subscribe(e=>{this._applyPassword(e),this.dispatchEvent(new CustomEvent(`notify::revealed`,{bubbles:!0,detail:{revealed:e.revealed}}))})}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),e===`show-peek-icon`&&this._toggle&&(this._toggle.hidden=n===null)}_passwordChanged(){this._applyPassword(this._password.state)}_applyPassword(e){this._input.type=e.revealed?`text`:`password`,this._peekIcon.dataset.iconName=e.peekIconName,this._peekIcon.iconName=e.peekIconName,this._toggle.title=e.peekLabel,this._toggle.setAttribute(`aria-label`,e.peekLabel),this._toggle.setAttribute(`aria-pressed`,String(e.revealed)),e.revealed?this.setAttribute(`revealed`,``):this.removeAttribute(`revealed`),this._capsLock.dataset.iconName=e.indicatorIconName,this._capsLock.title=e.indicatorTooltip,this._capsLock.setAttribute(`aria-label`,e.indicatorTooltip),this._capsLock.hidden=!this._entry.state.indicatorVisible}};customElements.define(`gtk-password-entry`,GtkPasswordEntry);const wa=[`fill`,`contain`,`cover`,`scale-down`];function normalizePictureContentFit(e){return wa.includes(e)?e:`contain`}var GtkPicture=class extends WidgetElement{_initialized=!1;static get observedAttributes(){return[`alternative-text`,`can-shrink`,`content-fit`,`isolate-contents`,`keep-aspect-ratio`]}get alternativeText(){return this.getAttribute(`alternative-text`)??``}set alternativeText(e){this._write(`alternative-text`,e)}get canShrink(){return!this.hasAttribute(`can-shrink`)||this.getAttribute(`can-shrink`)!==`false`}set canShrink(e){this._toggle(`can-shrink`,e,!0)}get contentFit(){return normalizePictureContentFit(this.getAttribute(`content-fit`))}set contentFit(e){this._write(`content-fit`,e)}get isolateContents(){return!this.hasAttribute(`isolate-contents`)||this.getAttribute(`isolate-contents`)!==`false`}set isolateContents(e){this._toggle(`isolate-contents`,e,!0)}get keepAspectRatio(){return this.contentFit!==`fill`}set keepAspectRatio(e){this.contentFit=e?`contain`:`fill`}_write(e,t){this.getAttribute(e)!==t&&this.setAttribute(e,t)}_toggle(e,t,n){let r=t?``:`false`;if(n){t?this.removeAttribute(e):this._write(e,r);return}this._write(e,r)}connectedCallback(){if(this._initialized){this._render();return}this._initialized=!0,this.setAttribute(`role`,`img`),this._render()}attributeChangedCallback(e,t,n){this._initialized&&(this._render(),e===`content-fit`&&(t===`fill`||n===`fill`)&&this.dispatchEvent(new CustomEvent(`notify::keep-aspect-ratio`,{bubbles:!0,detail:{"keep-aspect-ratio":this.keepAspectRatio}})),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:this._property(e)}})))}_property(e){switch(e){case`alternative-text`:return this.alternativeText;case`can-shrink`:return this.canShrink;case`isolate-contents`:return this.isolateContents;case`keep-aspect-ratio`:return this.keepAspectRatio;default:return this.contentFit}}_render(){this.style.setProperty(`--gtk-picture-content-fit`,this.contentFit),this.classList.toggle(`can-shrink`,this.canShrink),this.classList.toggle(`isolated`,this.isolateContents),this.alternativeText?this.setAttribute(`aria-label`,this.alternativeText):this.removeAttribute(`aria-label`)}};customElements.define(`gtk-picture`,GtkPicture);const Ta=`main`;var GtkPopoverMenu=class extends GtkPopover{_model=[];_actions=null;_menuView;_menuInitialized=!1;static get observedAttributes(){return[...GtkPopover.observedAttributes,`menu-model`,`menu-title`,`visible-submenu`]}get menuModel(){return this._model}set menuModel(e){this._model=normalizeMenuModel(e),assertMenuRenderable(this._model,k),this._menuInitialized&&this._renderMenu()}get actions(){return this._actions}set actions(e){this._actions=e??null,this._menuView?.setActions(this._actions),this._menuInitialized&&this._renderMenu()}get menuTitle(){return this.getAttribute(`menu-title`)??``}set menuTitle(e){this.setAttribute(`menu-title`,e??``)}get visibleSubmenu(){let e=this._openPageLabel();return e===null?Ta:e}set visibleSubmenu(e){this.openSubmenu(e)}takesChild(){return!1}connectedCallback(){super.connectedCallback(),!this._menuInitialized&&(this._menuInitialized=!0,this.classList.add(`adw-popover-menu`),this.setAttribute(`role`,`menu`),this.setAttribute(`menu`,``),this._menuView=new PopoverMenuView(this,`adw-popover-menu`,e=>this._activate(e)),this._menuView.setActions(this._actions),this._model.length===0&&(this._model=this._parseMenuAttr()),this._renderMenu(),this.subscribe(e=>{e?(this._menuView.setActions(this._actions??menuActionsOfElement(this,this._model)),this._menuView.render(),this._menuView.focusableRows[0]?.focus()):this._menuView.reset()}))}attributeChangedCallback(e,t,n){if(super.attributeChangedCallback(e,t,n),this._menuInitialized){if(e===`menu-model`){this._model=this._parseMenuAttr(),this._renderMenu();return}if(e===`menu-title`){this._menuView.setTitle(this.menuTitle),this._menuView.render();return}e===`visible-submenu`&&this._navigate(n??Ta)}}openSubmenu(e){this._navigate(e)}_navigate(e){let t=this.visibleSubmenu;if(!this._showPage(e))return;let n=this.visibleSubmenu;this._reflectSubmenu(),n!==t&&this.dispatchEvent(new CustomEvent(`notify::visible-submenu`,{bubbles:!0,detail:{visibleSubmenu:n}}))}_showPage(e){if(e===Ta||e.length===0)this._menuView.reset();else{let t=this._findSubmenu(e);if(t===null)return!1;this._menuView.setMenuModel(this._model),this._menuView.showPage(t)}return this._menuView.render(),!0}closeSubmenus(){this.openSubmenu(Ta)}_openPageLabel(){let e=this._menuView.page;if(e.length===0)return null;let t=menuNodeAt(this._model,e);return t!==null&&t.kind!==`item`?t.label:null}_findSubmenu(e){let walk=(t,n)=>{for(let[r,i]of t.entries()){if(i.kind===`item`)continue;let t=[...n,r];if(i.label===e)return t;let a=walk(i.items,t);if(a!==null)return a}return null};return walk(this._model,[])}_reflectSubmenu(){let e=this.visibleSubmenu;this.getAttribute(`visible-submenu`)!==e&&this.setAttribute(`visible-submenu`,e)}_activate(e){let t=menuItemAt(this._model,e);this.popdown(),this.anchor?.focus(),t!==null&&(activateElementMenuItem(this,t),this.dispatchEvent(new CustomEvent(`menu-item-activated`,{bubbles:!0,detail:{id:t.id??t.label,label:t.label,path:[...e]}})))}_renderMenu(){this._menuView.setMenuModel(this._model),this._menuView.setTitle(this.menuTitle),this._menuView.render(),this._model.length===0&&this.popdown()}_parseMenuAttr(){let e=normalizeMenuModel(parseMenuModel(this.getAttribute(`menu-model`))),t=menuRefusals(e,k);if(t.length===0)return e;console.error(`${k.name} cannot render this menu, so it has none:`);for(let e of t)console.error(` [${e.path.join(`.`)}] ${e.message}`);return[]}};customElements.define(`gtk-popover-menu`,GtkPopoverMenu);var GtkPopoverBin=class extends WidgetElement{_model=[];_popover=null;_actions=null;_initialized=!1;_longPressTimer=null;static get observedAttributes(){return[`menu-model`,`handle-input`]}get menuModel(){return this._model}set menuModel(e){this._model=normalizeMenuModel(e),assertMenuRenderable(this._model,k),this._adoptPopover(this._buildPopover()),this._notifyModel()}get popoverElement(){return this._popover}set popoverElement(e){this._model=[],this._adoptPopover(e),this._notifyModel()}get handleInput(){return this.hasAttribute(`handle-input`)}set handleInput(e){this.toggleAttribute(`handle-input`,!!e)}get actions(){return this._actions}set actions(e){this._actions=e??null,this._popover!==null&&(this._popover.actions=this._actions)}connectedCallback(){this._initialized||(this._initialized=!0,this.classList.add(`adw-popover-bin`),bindSlottedChildren(this,[{name:`child`,into:this}]),this.addEventListener(`contextmenu`,e=>this._onContextMenu(e)),this.addEventListener(`keydown`,e=>this._onKeyDown(e)),this._wireGestures(),this._model.length===0&&(this._model=this._parseMenuAttr()),this._model.length>0&&this._adoptPopover(this._buildPopover()))}disconnectedCallback(){this._cancelLongPress()}attributeChangedCallback(e){if(this._initialized){if(e===`handle-input`){this.handleInput||this._cancelLongPress();return}e===`menu-model`&&(this._model=this._parseMenuAttr(),this._adoptPopover(this._model.length>0?this._buildPopover():null),this._notifyModel())}}popup(){this.dispatchEvent(new CustomEvent(`menu.popup`,{bubbles:!0}));let e=this._popover;e!==null&&(e.open=!0)}popdown(){this._popover?.popdown()}get childElement(){let e=this.firstElementChild;return e===null||e===this._popover?null:e}_wireGestures(){this.addEventListener(`pointerdown`,e=>{!this.handleInput||this._popover===null||(this._cancelLongPress(),e.pointerType===`touch`&&(this._longPressTimer=setTimeout(()=>{this._longPressTimer=null,this._popupAt(e)},500)))}),this.addEventListener(`pointerup`,()=>this._cancelLongPress()),this.addEventListener(`pointercancel`,()=>this._cancelLongPress())}_cancelLongPress(){this._longPressTimer!==null&&(clearTimeout(this._longPressTimer),this._longPressTimer=null)}_onContextMenu(e){!this.handleInput||this._popover===null||(e.preventDefault(),this._popupAt(e))}_popupAt(e){let t=this._popover;t!==null&&(t.open=!0)}_onKeyDown(e){e.key!==`ContextMenu`&&e.key!==`F10`||e.shiftKey||this._popover!==null&&(e.preventDefault(),this.popup())}_buildPopover(){if(this._model.length===0)return null;let e=document.createElement(`gtk-popover-menu`);return e.setAttribute(`position`,`bottom`),e.setAttribute(`align`,`start`),e.menuModel=this._model,e.actions=this._actions,e.anchor=this,e}_adoptPopover(e){let t=this._popover;t!==null&&t!==e&&(t.popdown(),t.remove()),this._popover=e;let n=this.childElement;if(e===null){n?.classList.remove(`has-open-popup`);return}e.subscribe(e=>{n?.classList.toggle(`has-open-popup`,e)}),this.appendChild(e)}_notifyModel(){this.dispatchEvent(new CustomEvent(`notify::menu-model`,{bubbles:!0,detail:{menuModel:this._model,popover:this._popover}}))}_parseMenuAttr(){let e=normalizeMenuModel(parseMenuModel(this.getAttribute(`menu-model`))),t=menuRefusals(e,k);if(t.length===0)return e;console.error(`${k.name} cannot render this menu, so it has none:`);for(let e of t)console.error(` [${e.path.join(`.`)}] ${e.message}`);return[]}};customElements.define(`gtk-popover-bin`,GtkPopoverBin);var GtkPopoverMenuBar=class extends WidgetElement{_model=[];_actions=null;_items=[];_active=null;_initialized=!1;static get observedAttributes(){return[`menu-model`]}get menuModel(){return this._model}set menuModel(e){this._model=normalizeMenuModel(e),assertMenuRenderable(this._model,k),this._initialized&&this._rebuild()}get actions(){return this._actions}set actions(e){this._actions=e??null,this._initialized&&this._rebuild()}get activeItem(){return this._active?.button??null}connectedCallback(){this._initialized||(this._initialized=!0,this.classList.add(`adw-popover-menu-bar`),this.setAttribute(`role`,`menubar`),this.addEventListener(`keydown`,e=>this._onKeyDown(e)),this.addEventListener(`pointerleave`,()=>{this._active!==null&&!this._active.popover.open&&this._setActive(null,!1)}),this._model.length===0&&(this._model=this._parseMenuAttr()),this._rebuild())}attributeChangedCallback(e){!this._initialized||e!==`menu-model`||(this._model=this._parseMenuAttr(),this._rebuild())}selectFirst(){this._setActive(this._items[0]??null,!0)}popup(){this.selectFirst()}_setActive(e,t){let n=e!==this._active,r=this._active!==null&&this._active.popover.open;r&&n&&this._active?.popover.popdown(),n&&(this._active?.button.classList.remove(`selected`),this._active=e,e?.button.classList.add(`selected`)),this._active!==null&&(t||r&&n?this._active.popover.open=!0:n&&this.matches(`:focus-within`)&&this._active.button.focus())}_onKeyDown(e){this._active?.popover.open!==!0&&(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),this._move(e.key===`ArrowRight`?1:-1)))}_move(e){let t=this._items.length;if(t===0)return;let n=(this._active===null?-1:this._items.indexOf(this._active))+e;n<0&&(n=t-1),n>=t&&(n=0),this._setActive(this._items[n],!1)}_rebuild(){this._items=[],this._active=null;let e=[];this._model.forEach((t,n)=>{t.kind===`submenu`&&e.push(this._buildItem(t,[n]))}),this._items=e,this.replaceChildren(...e.map(e=>e.root))}_focusFirstRow(e){e.querySelector(`.adw-popover-item:not([hidden]):not([disabled])`)?.focus()}_buildItem(e,t){let n=document.createElement(`div`);n.className=`adw-popover-menu-bar-item`,n.setAttribute(`role`,`none`);let r=document.createElement(`button`);r.type=`button`,r.className=`adw-popover-menu-bar-button`,r.setAttribute(`role`,`menuitem`),r.setAttribute(`aria-haspopup`,`menu`),r.setAttribute(`aria-expanded`,`false`);let i=document.createElement(`span`);i.className=`adw-popover-menu-bar-label`,i.textContent=menuLabelText(e.label),r.appendChild(i);let a=document.createElement(`gtk-popover-menu`);a.setAttribute(`position`,`bottom`),a.setAttribute(`align`,`start`),a.menuModel=e.items,a.actions=this._actions,a.anchor=r,r.setAttribute(`aria-controls`,`popover`);let o={node:e,path:t,root:n,button:r,popover:a};return a.subscribe(e=>{if(r.setAttribute(`aria-expanded`,String(e)),e){for(let e of this._items)e.root.classList.toggle(`active`,e===o);this._focusFirstRow(a)}else o.root.classList.remove(`active`),this._active===o&&(this._active=null)}),a.addEventListener(`menu-item-activated`,e=>{e.stopPropagation();let n=e.detail;this._activate(o,[...t,...n.path])}),r.addEventListener(`click`,()=>this._setActive(o,!0)),n.addEventListener(`pointerenter`,()=>this._setActive(o,!1)),n.append(r,a),o}_activate(e,t){let n=menuItemAt(this._model,t);e.popover.popdown(),e.button.focus(),n!==null&&this.dispatchEvent(new CustomEvent(`menu-item-activated`,{bubbles:!0,detail:{id:n.id??n.label,label:n.label,path:[...t]}}))}_parseMenuAttr(){let e=normalizeMenuModel(parseMenuModel(this.getAttribute(`menu-model`))),t=menuRefusals(e,k);if(t.length>0){console.error(`${k.name} cannot render this menu, so it has none:`);for(let e of t)console.error(` [${e.path.join(`.`)}] ${e.message}`);return[]}for(let[t,n]of e.entries())n.kind!==`submenu`&&console.warn(`Don't know how to handle this item: top-level entry ${t} is a ${n.kind}.`);return e}};customElements.define(`gtk-popover-menu-bar`,GtkPopoverMenuBar);const Ea=[`collate`,`copies`,`generate-pdf`,`generate-ps`,`number-up`,`number-up-layout`,`page-set`,`preview`,`reverse`,`scale`],Da=[`General`,`Page Setup`,`Job`,`Image Quality`,`Color`,`Finishing`,`Advanced`],Oa=[`All sheets`,`Even sheets`,`Odd sheets`],ka=[`portrait`,`landscape`,`reverse-portrait`,`reverse-landscape`],Aa={copies:`1`,collate:`0`,reverse:`0`,"page-set":`0`,scale:`100`,orientation:`portrait`};var GtkPrintUnixDialog=class extends AdwDialog{_built=!1;_printers=[];_selected=null;_settings={...Aa};_pageSetup=defaultPageSetup();_printerListEl;_switcherEl;_panelEl;_tabPages=new Map;_tab=`General`;_currentPage=-1;_supportSelection=!1;_hasSelection=!1;_manual=new Set;_range=`all`;_printAt=`now`;_printButton;_previewButton;_conflictsEl;_capabilityControls=new Map;_collateCheck;_reverseCheck;_copiesInput;_paperDrop;_orientationDrop;_pageRangeInput;_selectionRadio;_currentPageRadio;_rangeRadios=new Map;_atInput=null;static get observedAttributes(){return[...AdwDialog.observedAttributes,`current-page`,`embed-page-setup`,`has-selection`,`manual-capabilities`,`support-selection`]}get currentPage(){return this._currentPage}set currentPage(e){this._currentPage=e,this._built&&this._renderPrint()}get embedPageSetup(){return this.hasAttribute(`embed-page-setup`)}set embedPageSetup(e){this.toggleAttribute(`embed-page-setup`,e),this._built&&this._renderPrint()}get hasSelection(){return this._hasSelection}set hasSelection(e){this._hasSelection=e,this._built&&this._renderPrint()}get supportSelection(){return this.hasAttribute(`support-selection`)}set supportSelection(e){this.toggleAttribute(`support-selection`,e),this._built&&this._renderPrint()}get manualCapabilities(){return[...this._manual]}set manualCapabilities(e){this._manual=new Set(e.filter(e=>Ea.includes(e))),this._built&&this._renderPrint()}get selectedPrinter(){return this._selected===null?null:{...this._selected}}get pageSetup(){return{...this._pageSetup}}set pageSetup(e){this._pageSetup=e,this._built&&this._renderPrint()}get printSettings(){return{...this._settings}}set printSettings(e){this._settings={...Aa,...e},this._built&&this._renderPrint()}get range(){return this._range}set range(e){if(this._range=e,!this._built)return;let t=this._rangeRadios.get(e);t!==void 0&&(t.checked=!0),this._renderPrint()}get printers(){return this._printers.map(e=>({...e}))}set printers(e){this._printers=e.map(e=>({...e})),this._selected=null,this._built&&this._renderPrint()}connectedCallback(){if(this._built){super.connectedCallback();return}this._switcherEl=document.createElement(`div`),this._switcherEl.className=`adw-print-switcher`,this._switcherEl.setAttribute(`role`,`tablist`),super.connectedCallback(),this.hasAttribute(`title`)||this.setAttribute(`title`,`Print`),this._readManual();let e=[...this.contentArea.childNodes];this.contentArea.replaceChildren(this._build());for(let t of e)this.contentArea.appendChild(t);this._renderPrint(),this._built=!0}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),!(!this._built||t===n)&&e!==`title`&&(e===`manual-capabilities`&&this._readManual(),this._renderPrint())}_readManual(){this._manual=new Set((this.getAttribute(`manual-capabilities`)??``).split(`|`).map(e=>e.trim()).filter(e=>Ea.includes(e)))}decorateHeader(e){let t=e.querySelector(`.adw-dialog-title`);t===null?e.prepend(this._switcherEl):t.replaceWith(this._switcherEl)}_build(){let e=document.createElement(`div`);return e.className=`adw-print-root`,this._panelEl=document.createElement(`div`),this._panelEl.className=`adw-print-panel`,this._panelEl.setAttribute(`role`,`tabpanel`),e.append(this._panelEl,this._buildConflicts(),this._buildActions()),this._renderPanel(),e}_renderPanel(){for(let e of Da){let t=this._tabPages.get(e);t===void 0&&(t=document.createElement(`div`),t.className=`adw-print-page`,t.setAttribute(`role`,`tabpanel`),t.dataset.tab=e,t.appendChild(this._buildTab(e)),this._tabPages.set(e,t),this._panelEl.appendChild(t)),t.hidden=e!==this._tab}}_buildTab(e){switch(e){case`General`:return this._buildGeneral();case`Page Setup`:return this._buildPageSetup();case`Job`:return this._buildJob();case`Image Quality`:case`Color`:case`Finishing`:return this._buildOptionsPage(e);case`Advanced`:return this._buildOptionsPage(e)}}_buildGeneral(){let e=document.createElement(`div`);e.className=`adw-print-columns`,this._printerListEl=document.createElement(`div`),this._printerListEl.className=`adw-print-printer-list`,this._printerListEl.setAttribute(`role`,`radiogroup`),this._printerListEl.setAttribute(`aria-label`,`Printer`),e.appendChild(this._frame(this._printerListEl));let t=document.createElement(`div`);t.className=`adw-print-column`;let n=this._group(`Range`),r=n.body;for(let[e,t]of[[`all`,`All Pages`],[`current`,`Current Page`],[`selection`,`Selection`]]){let n=this._radio(t,`adw-print-range-${e}`);n.addEventListener(`notify::checked`,()=>{n.checked&&(this._range=e,(e===`current`||e===`selection`)&&this._renderPrint())}),e===`current`&&(this._currentPageRadio=n),e===`selection`&&(this._selectionRadio=n),this._rangeRadios.set(e,n),r.appendChild(n)}let i=this._radio(`Pages:`,`adw-print-range-pages`);i.addEventListener(`notify::checked`,()=>{i.checked&&(this._range=`pages`,this._pageRangeInput.focus())}),this._pageRangeInput=document.createElement(`input`),this._pageRangeInput.type=`text`,this._pageRangeInput.className=`adw-print-page-range-entry`,this._pageRangeInput.title=`Specify one or more page ranges, e.g. 1–3, 7, 11`,this._pageRangeInput.setAttribute(`aria-label`,`Pages`),this._pageRangeInput.addEventListener(`focus`,()=>{this._range=`pages`,i.checked=!0}),this._rangeRadios.set(`pages`,i);let a=document.createElement(`div`);a.className=`adw-print-grid-row`,a.append(i,this._pageRangeInput),r.appendChild(a),t.appendChild(n.group);let o=this._group(`Copies`),s=o.body,c=document.createElement(`div`);c.className=`adw-print-grid-row`;let l=document.createElement(`div`);l.className=`adw-print-label`,l.textContent=`Copies:`,this._copiesInput=document.createElement(`input`),this._copiesInput.type=`number`,this._copiesInput.min=`1`,this._copiesInput.className=`adw-print-copies`,this._copiesInput.value=this._settings.copies??`1`,this._copiesInput.setAttribute(`aria-label`,`Copies`),this._copiesInput.addEventListener(`input`,()=>{this._settings={...this._settings,copies:this._copiesInput.value},this._renderPrint()}),c.append(l,this._copiesInput),s.appendChild(c),this._collateCheck=this._check(`Collate`,`adw-print-collate`),this._reverseCheck=this._check(`Reverse`,`adw-print-reverse`);for(let e of[this._collateCheck,this._reverseCheck])e.addEventListener(`notify::checked`,()=>this._renderPrint());s.append(this._collateCheck,this._reverseCheck);let u=this._buildCollatePreview(),d=document.createElement(`div`);return d.className=`adw-print-grid-row`,d.appendChild(u),s.appendChild(d),t.appendChild(o.group),e.appendChild(t),e}_buildCollatePreview(){let e=document.createElement(`div`);return e.className=`adw-print-collate-preview`,e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,`A visualization of the effect of the collate and reverse options on the page ordering`),e.dataset.columnA=`2`,e.dataset.columnB=`1`,e}_buildPageSetup(){let e=document.createElement(`div`);e.className=`adw-print-columns`;let t=document.createElement(`div`);t.className=`adw-print-column`;let n=this._group(`Layout`),r=n.body;r.appendChild(this._labelledRow(`Two-sided:`,this._dropDown(Oa,`Two-sided`)));let i=document.createElement(`input`);i.type=`number`,i.min=`10`,i.max=`400`,i.className=`adw-print-scale`,i.value=this._settings.scale??`100`,i.setAttribute(`aria-label`,`Scale in percent`),i.addEventListener(`input`,()=>{this._settings={...this._settings,scale:i.value},this._renderPrint()}),this._capabilityControls.set(`scale`,i);let a=document.createElement(`div`);a.className=`adw-print-grid-row`;let o=document.createElement(`div`);o.className=`adw-print-label`,o.textContent=`Scale:`;let s=document.createElement(`span`);s.className=`adw-print-label`,s.textContent=`%`,a.append(o,i,s),r.appendChild(a),t.appendChild(n.group);let c=this._group(`Paper`),l=c.body,u=Y.map(e=>e.displayName);return this._paperDrop=this._dropDown(u,`Paper size`),this._orientationDrop=this._dropDown(ka.map(e=>e[0].toUpperCase()+e.slice(1)),`Orientation`),l.appendChild(this._labelledRow(`Paper size:`,this._paperDrop)),l.appendChild(this._labelledRow(`Orientation:`,this._orientationDrop)),t.appendChild(c.group),this._paperDrop.addEventListener(`notify::selected`,()=>{this.embedPageSetup&&this._paperChanged(this._paperDrop.selected)}),this._orientationDrop.addEventListener(`notify::selected`,()=>{if(!this.embedPageSetup)return;let e=ka[this._orientationDrop.selected]??`portrait`;this._pageSetup={...this._pageSetup,orientation:e},this._settings={...this._settings,orientation:e},this._renderPrint()}),e.append(t,this._buildSheetPreview()),e}_buildSheetPreview(){let e=document.createElement(`div`);e.className=`adw-print-sheet-preview`,e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,`Page layout preview`);let t=document.createElement(`div`);t.className=`adw-print-paper`;let n=paperSizeOf(this._pageSetup),r=this._pageSetup.orientation===`landscape`||this._pageSetup.orientation===`reverse-landscape`;t.style.aspectRatio=r?`${n.height} / ${n.width}`:`${n.width} / ${n.height}`;let i=document.createElement(`div`);i.className=`adw-print-number-up`,i.dataset.cells=`1`,t.appendChild(i),e.appendChild(t);let a=document.createElement(`div`);return a.className=`adw-print-sheet-caption`,a.textContent=`${orientedSize(this._pageSetup).width.toFixed(1)} mm × ${orientedSize(this._pageSetup).height.toFixed(1)} mm`,e.appendChild(a),e}_buildJob(){let e=document.createElement(`div`);e.className=`adw-print-column`;let t=this._group(`Job Details`);t.body.appendChild(this._optionsGrid(`Job Details`));let n=this._group(`Print Document`),r=n.body;for(let[e,t]of[[`now`,`Now`],[`at`,`At:`],[`hold`,`On hold`]]){let n=this._radio(t,`adw-print-at`);if(n.addEventListener(`notify::checked`,()=>{n.checked&&(this._printAt=e,this._atInput!==null&&(this._atInput.disabled=e!==`at`),e===`at`&&this._atInput?.focus())}),r.appendChild(n),e===`at`){this._atInput=document.createElement(`input`),this._atInput.type=`text`,this._atInput.className=`adw-print-at-entry`,this._atInput.setAttribute(`aria-label`,`Print at`),this._atInput.disabled=!0,this._atInput.addEventListener(`input`,()=>{this._settings={...this._settings,"print-at":this._atInput.value}});let e=document.createElement(`div`);e.className=`adw-print-grid-row`,e.appendChild(this._atInput),r.appendChild(e)}}let i=this._group(`Add Cover Page`);return i.body.appendChild(this._optionsGrid(`Cover Page`)),e.append(t.group,n.group,i.group),e}_buildOptionsPage(e){let t=document.createElement(`div`);t.className=`adw-print-column`;let n=this._optionsGrid(e);if(e===`Advanced`){let e=document.createElement(`div`);return e.className=`adw-print-advanced`,e.appendChild(n),t.appendChild(e),t}return t.appendChild(n),t}_optionsGrid(e){let t=document.createElement(`div`);return t.className=`adw-print-options-grid`,t.setAttribute(`role`,`group`),t.setAttribute(`aria-label`,e),t.dataset.empty=`true`,t}_buildConflicts(){return this._conflictsEl=document.createElement(`div`),this._conflictsEl.className=`adw-print-conflicts`,this._conflictsEl.hidden=!0,this._conflictsEl.append(createGtkImage(`dialog-warning`,`adw-print-conflicts-icon`),(()=>{let e=document.createElement(`span`);return e.className=`adw-print-conflicts-label`,e.textContent=`Some of the settings in the dialog conflict`,e})()),this._conflictsEl}_buildActions(){let e=document.createElement(`div`);e.className=`adw-print-actions`,this._previewButton=document.createElement(`button`),this._previewButton.type=`button`,this._previewButton.className=`adw-print-preview`,this._previewButton.textContent=`Preview`,this._previewButton.addEventListener(`click`,()=>this._respond(-10));let t=document.createElement(`button`);return t.type=`button`,t.className=`adw-print-cancel`,t.textContent=`Cancel`,t.addEventListener(`click`,()=>this._respond(-6)),this._printButton=document.createElement(`button`),this._printButton.type=`button`,this._printButton.className=`adw-print-print suggested-action`,this._printButton.textContent=`Print`,this._printButton.addEventListener(`click`,()=>this._respond(-5)),e.append(this._previewButton,t,this._printButton),e}_respond(e){this.dispatchEvent(new CustomEvent(`response`,{bubbles:!0,detail:{responseId:e}})),e!==-5&&this.close()}_group(e){let t=document.createElement(`div`);t.className=`adw-print-group`;let n=document.createElement(`div`);n.className=`adw-print-group-title`,n.textContent=e;let r=document.createElement(`div`);return r.className=`adw-print-group-body`,t.append(n,r),{group:t,body:r}}_labelledRow(e,t,n){let r=document.createElement(`div`);r.className=`adw-print-grid-row`;let i=document.createElement(`div`);return i.className=`adw-print-label`,i.textContent=e,r.append(i,t),n!==void 0&&this._capabilityControls.set(n,t),r}_dropDown(e,t){let n=document.createElement(`gtk-drop-down`);return n.className=`adw-print-dropdown`,n.setAttribute(`model`,JSON.stringify([...e])),n.setAttribute(`aria-label`,t),n}_radio(e,t){let n=document.createElement(`adw-radio`);return n.className=t,n.setAttribute(`label`,e),n.setAttribute(`name`,t),n.setAttribute(`value`,e),n}_check(e,t){let n=document.createElement(`gtk-check-button`);return n.className=t,n.setAttribute(`label`,e),n.setAttribute(`name`,t),n}_frame(e){let t=document.createElement(`div`);return t.className=`adw-print-frame`,t.appendChild(e),t}_printerChanged(e){this._selected=e,e!==null&&(this._settings={...this._settings,"format-for-printer":e.name}),this._renderPrint()}_paperChanged(e){let t=Y[e];t!==void 0&&(this._pageSetup={...this._pageSetup,paperSize:t.name,margins:defaultMargins(t)},this._renderPrint())}_capabilities(){let e=new Set(this._manual);for(let t of this._selected?.capabilities??[])e.add(t);return e}_renderPrint(){let e=this._capabilities();this._switcherEl.replaceChildren(...Da.map(e=>{let t=document.createElement(`button`);return t.type=`button`,t.className=`adw-print-switcher-item`,t.setAttribute(`role`,`tab`),t.textContent=e,t.classList.toggle(`checked`,e===this._tab),t.setAttribute(`aria-selected`,String(e===this._tab)),t.addEventListener(`click`,()=>{this._tab=e,this._renderPanel(),this._renderPrint()}),t})),this._printerListEl.replaceChildren(...this._printers.map(e=>{let t=document.createElement(`button`);t.type=`button`,t.className=`adw-print-printer-row`,t.setAttribute(`role`,`radio`),t.setAttribute(`aria-checked`,String(e===this._selected)),t.classList.toggle(`checked`,e===this._selected),t.appendChild(e.iconName===void 0?createGtkImage(`printer`,`adw-print-printer-icon`):createGtkImage(e.iconName,`adw-print-printer-icon`));let n=document.createElement(`span`);n.className=`adw-print-printer-text`;let r=document.createElement(`span`);if(r.className=`adw-print-printer-name`,r.textContent=e.name,n.appendChild(r),e.location!==void 0){let t=document.createElement(`span`);t.className=`adw-print-printer-location`,t.textContent=e.location,n.appendChild(t)}return t.appendChild(n),t.addEventListener(`click`,()=>this._printerChanged(e)),t})),this._selectionRadio.hidden=!this.supportSelection,this._selectionRadio.classList.toggle(`insensitive`,!this.supportSelection||!this._hasSelection),this._selectionRadio.setAttribute(`aria-disabled`,String(!this.supportSelection||!this._hasSelection)),this._currentPageRadio.classList.toggle(`insensitive`,this._currentPage===-1),this._currentPageRadio.setAttribute(`aria-disabled`,String(this._currentPage===-1));for(let[t,n]of this._capabilityControls)n.toggleAttribute(`disabled`,!e.has(t));let t=Number.parseInt(this._copiesInput.value,10),n=this._copiesInput.value!==``&&Number.isFinite(t)&&t>1;this._collateCheck.toggleAttribute(`disabled`,!n||!e.has(`collate`)),this._reverseCheck.toggleAttribute(`disabled`,!e.has(`reverse`)),this._copiesInput.toggleAttribute(`disabled`,!e.has(`copies`)),this._paperDrop.toggleAttribute(`disabled`,!this.embedPageSetup),this._orientationDrop.toggleAttribute(`disabled`,!this.embedPageSetup);let r=this._collateCheck.checked,i=this._reverseCheck.checked,a=this.contentArea.querySelector(`.adw-print-collate-preview`);a!==null&&(a.dataset.columnA=String(r?i?1:2:i?2:1),a.dataset.columnB=String(r?i?2:1:i?1:2),a.dataset.secondColumn=String(n));let o=this._selected!==null&&(this._selected.acceptsJobs??!0);this._printButton.toggleAttribute(`disabled`,!o),this._previewButton.hidden=!e.has(`preview`);let s=this.contentArea.querySelector(`.adw-print-paper`);if(s!==null){let e=paperSizeOf(this._pageSetup),t=this._pageSetup.orientation===`reverse-portrait`;s.style.aspectRatio=`${this._pageSetup.orientation===`landscape`||t?`${e.height} / ${e.width}`:`${e.width} / ${e.height}`}`}let c=this.contentArea.querySelector(`.adw-print-number-up`);c!==null&&(c.dataset.cells=`1`),this._conflictsEl.hidden=!0}};customElements.define(`gtk-print-unix-dialog`,GtkPrintUnixDialog);var GtkProgressBar=class extends WidgetElement{_trough;_progress;_text;_initialized=!1;static get observedAttributes(){return[`fraction`,`pulsing`,`show-text`,`text`,`inverted`,`osd`,`disabled`]}get fraction(){let e=Number.parseFloat(this.getAttribute(`fraction`)??``);return Number.isFinite(e)?glibClamp(e,0,1):0}set fraction(e){this.setAttribute(`fraction`,String(e))}get pulsing(){return this.hasAttribute(`pulsing`)}set pulsing(e){this.toggleAttribute(`pulsing`,!!e)}get showText(){return this.hasAttribute(`show-text`)}set showText(e){this.toggleAttribute(`show-text`,!!e)}get text(){let e=this.getAttribute(`text`);return e===null?`${Math.round(this.fraction*100)}%`:e}set text(e){this.setAttribute(`text`,e)}get inverted(){return this.hasAttribute(`inverted`)}set inverted(e){this.toggleAttribute(`inverted`,!!e)}get osd(){return this.hasAttribute(`osd`)}set osd(e){this.toggleAttribute(`osd`,!!e)}get disabled(){return this.hasAttribute(`disabled`)}set disabled(e){this.toggleAttribute(`disabled`,!!e)}pulse(){this.pulsing=!0}connectedCallback(){this._initialized||(this._initialized=!0,this._trough=document.createElement(`span`),this._trough.className=`adw-progress-bar-trough`,this._progress=document.createElement(`span`),this._progress.className=`adw-progress-bar-progress`,this._trough.appendChild(this._progress),this._text=document.createElement(`span`),this._text.className=`adw-progress-bar-text`,this.replaceChildren(this._trough,this._text),this.setAttribute(`role`,`progressbar`),this.setAttribute(`aria-valuemin`,`0`),this.setAttribute(`aria-valuemax`,`1`),this._render())}attributeChangedCallback(){this._initialized&&this._render()}_render(){let e=this.fraction,t=this.pulsing,n=!t&&e===0;this._trough.classList.toggle(`empty`,n),this._progress.style.width=t||n?``:`${e*100}%`,this._text.textContent=this.text,this._text.hidden=!this.showText,t?this.removeAttribute(`aria-valuenow`):this.setAttribute(`aria-valuenow`,String(e))}};customElements.define(`gtk-progress-bar`,GtkProgressBar);const ja=[`none`,`crossfade`,`slide-right`,`slide-left`,`slide-up`,`slide-down`,`swing-right`,`swing-left`,`swing-up`,`swing-down`,`fade-slide-right`,`fade-slide-left`,`fade-slide-up`,`fade-slide-down`],Ma=new Set([`slide-right`,`slide-left`,`fade-slide-right`,`fade-slide-left`]),Na=new Set([`slide-up`,`slide-down`,`fade-slide-up`,`fade-slide-down`]),Pa=new Set([`swing-right`,`swing-left`]),Fa=new Set([`swing-up`,`swing-down`]),Ia=new Set([`crossfade`,`fade-slide-right`,`fade-slide-left`,`fade-slide-up`,`fade-slide-down`]),La={"slide-left":`slide-right`,"slide-right":`slide-left`,"swing-left":`swing-right`,"swing-right":`swing-left`,"fade-slide-left":`fade-slide-right`,"fade-slide-right":`fade-slide-left`};var GtkRevealer=class extends WidgetElement{_clipEl;_initialized=!1;_position=0;_target=0;_frame=0;_startedAt=0;_naturalWidth=0;_naturalHeight=0;_resize=null;static get observedAttributes(){return[`reveal-child`,`transition-type`,`transition-duration`]}get revealChild(){return this.hasAttribute(`reveal-child`)}set revealChild(e){this.toggleAttribute(`reveal-child`,!!e)}get childRevealed(){return this._position===this._target?this.revealChild:!this.revealChild}get transitionType(){let e=this.getAttribute(`transition-type`);return ja.includes(e)?e:`slide-down`}set transitionType(e){this.setAttribute(`transition-type`,e)}get transitionDuration(){let e=Number.parseFloat(this.getAttribute(`transition-duration`)??``);return Number.isFinite(e)&&e>=0?e:250}set transitionDuration(e){this.setAttribute(`transition-duration`,String(e))}get child(){return this._clipEl?.firstElementChild??null}connectedCallback(){if(this._initialized){this._observeChild(),this._render();return}this._initialized=!0,this.setAttribute(`role`,`group`),this._clipEl=document.createElement(`div`),this._clipEl.className=`adw-revealer-clip`,bindSlottedChildren(this,[{name:`child`,into:this._clipEl},{into:this._clipEl}],()=>this._observeChild()).install(this._clipEl),this._observeChild(),this._animate(this.revealChild),this._render()}disconnectedCallback(){this._finish(),this._resize?.disconnect(),this._resize=null}attributeChangedCallback(e,t,n){if(!this._initialized)return;if(e===`reveal-child`){if(!this._animate(n!==null))return;this.dispatchEvent(new CustomEvent(`notify::reveal-child`,{bubbles:!0,detail:{revealChild:this.revealChild}}));return}this._render();let r=e===`transition-duration`?{transitionDuration:this.transitionDuration}:{transitionType:this.transitionType};this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:r}))}_observeChild(){this._resize?.disconnect(),this._resize=new ResizeObserver(e=>{for(let t of e){let e=t.borderBoxSize?.[0];this._naturalWidth=e?e.inlineSize:t.contentRect.width,this._naturalHeight=e?e.blockSize:t.contentRect.height}this._render()}),this._resize.observe(this._clipEl);let e=this._clipEl.firstElementChild;e&&this._resize.observe(e)}_animate(e){let t=+!!e;if(this._target===t)return!1;this._target=t;let n=this.effectiveTransition,r=globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1;if(this.transitionDuration===0||n===`none`||r||!this.isConnected)return this._finish(),this._setPosition(t),!0;let i=this._position;return this._startedAt=performance.now(),this._frame===0&&(this._frame=requestAnimationFrame(()=>this._tick(i))),!0}_tick(e){this._frame=0;let t=this.transitionDuration,n=performance.now()-this._startedAt,r=t<=0?1:Math.min(1,n/t),i=easeOutCubic(r);this._setPosition(e+i*(this._target-e)),r<1&&(this._frame=requestAnimationFrame(()=>this._tick(e)))}_finish(){this._frame!==0&&(cancelAnimationFrame(this._frame),this._frame=0)}get effectiveTransition(){let e=this.transitionType;return this.matches(`:dir(rtl)`)?La[e]??e:e}_scale(e){let t=this.effectiveTransition,n=e===`horizontal`?Ma:Na,r=e===`horizontal`?Pa:Fa;return n.has(t)?this._position:r.has(t)?Math.sin(Math.PI*this._position/2):1}_setPosition(e){this._position=e,this._render(),this._position===this._target&&this.dispatchEvent(new CustomEvent(`notify::child-revealed`,{bubbles:!0,detail:{childRevealed:this.childRevealed}}))}_render(){let e=this._clipEl.firstElementChild;e&&this._naturalHeight===0&&(this._naturalWidth=e.offsetWidth,this._naturalHeight=e.offsetHeight);let t=this._position,n=this._scale(`horizontal`),r=this._scale(`vertical`),i=this.effectiveTransition;if(this._clipEl.style.width=n<1?`${Math.ceil(this._naturalWidth*n)}px`:``,this._clipEl.style.height=r<1?`${Math.ceil(this._naturalHeight*r)}px`:``,e){let a=this._naturalWidth,o=this._naturalHeight,s=a*n,c=o*r,l=2*Math.max(s,c),u=90*(1-t),d=``;switch(i){case`slide-right`:case`fade-slide-right`:d=`translateX(${s-a}px)`;break;case`slide-down`:case`fade-slide-down`:d=`translateY(${c-o}px)`;break;case`swing-right`:d=`translate(0, ${c/2}px) perspective(${l}px) rotateY(${u}deg) translate(0, ${-o/2}px)`;break;case`swing-left`:d=`translate(${s}px, ${c/2}px) perspective(${l}px) rotateY(${-u}deg) translate(${-a}px, ${-o/2}px)`;break;case`swing-down`:d=`translate(${s/2}px, 0) perspective(${l}px) rotateX(${-u}deg) translate(${-a/2}px, 0)`;break;case`swing-up`:d=`translate(${s/2}px, ${c}px) perspective(${l}px) rotateX(${u}deg) translate(${-a/2}px, ${-o}px)`;break;default:break}e.style.transform=d,e.style.transformOrigin=d===``?``:`0 0`,e.style.opacity=Ia.has(i)?String(t):``}this.classList.toggle(`revealed`,t>0)}};customElements.define(`gtk-revealer`,GtkRevealer);const Ra=[`left`,`right`,`top`,`bottom`];function seededRange(e,t){let n=normalizeAdjustment(parseAdjustment(e));if(t===null)return n;let r=Number.parseFloat(t);return Number.isFinite(r)?{...n,value:r}:n}function formatScaleValue(e,t){let n=e.toFixed(t);return n.startsWith(`-`)&&Number.parseFloat(n)===0?n.slice(1):n}var GtkScale=class extends WidgetElement{_range=new SpinState;_trough;_highlight;_fill;_slider;_value;_initialized=!1;_pointerId=null;static get observedAttributes(){return[`adjustment`,`digits`,`disabled`,`draw-value`,`fill-level`,`has-origin`,`inverted`,`orientation`,`restrict-to-fill-level`,`round-digits`,`show-fill-level`,`value`,`value-pos`]}get orientation(){return normalizeBoxOrientation(this.getAttribute(`orientation`))}set orientation(e){this.setAttribute(`orientation`,e)}get adjustment(){return this._range.adjustment}set adjustment(e){this._range.configure(typeof e==`string`?parseAdjustment(e):e),this._render()}get value(){return this._range.value}set value(e){this._setValue(e,!1)}get inverted(){return this.hasAttribute(`inverted`)}set inverted(e){this.toggleAttribute(`inverted`,!!e)}get drawValue(){return this.hasAttribute(`draw-value`)}set drawValue(e){this.toggleAttribute(`draw-value`,!!e)}get valuePos(){let e=this.getAttribute(`value-pos`);return Ra.includes(e)?e:`top`}set valuePos(e){this.setAttribute(`value-pos`,e)}get hasOrigin(){return!this.hasAttribute(`has-origin`)||this.getAttribute(`has-origin`)!==`false`}set hasOrigin(e){this.toggleAttribute(`has-origin`,!!e)}get digits(){let e=Number.parseInt(this.getAttribute(`digits`)??``,10);return Number.isFinite(e)?Math.max(0,e):1}set digits(e){this.setAttribute(`digits`,String(e))}get fillLevel(){let e=Number.parseFloat(this.getAttribute(`fill-level`)??``);return Number.isFinite(e)?e:0}set fillLevel(e){this.setAttribute(`fill-level`,String(e))}get showFillLevel(){return this.hasAttribute(`show-fill-level`)}set showFillLevel(e){this.toggleAttribute(`show-fill-level`,!!e)}get restrictToFillLevel(){return this.hasAttribute(`restrict-to-fill-level`)}set restrictToFillLevel(e){this.toggleAttribute(`restrict-to-fill-level`,!!e)}get slider(){return this._slider}connectedCallback(){this._initialized||(this._initialized=!0,this._range.configure(seededRange(this.getAttribute(`adjustment`),this.getAttribute(`value`))),this._trough=document.createElement(`span`),this._trough.className=`adw-scale-trough`,this._highlight=document.createElement(`span`),this._highlight.className=`adw-scale-highlight`,this._fill=document.createElement(`span`),this._fill.className=`adw-scale-fill`,this._slider=document.createElement(`span`),this._slider.className=`adw-scale-slider`,this._trough.append(this._fill,this._highlight,this._slider),this._value=document.createElement(`span`),this._value.className=`adw-scale-value`,this.replaceChildren(this._trough,this._value),this.setAttribute(`role`,`slider`),this.hasAttribute(`tabindex`)||this.setAttribute(`tabindex`,`0`),this._trough.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),this._value.addEventListener(`pointerdown`,e=>this._onPointerDown(e)),this.addEventListener(`keydown`,e=>this._onKeyDown(e)),this.addEventListener(`pointermove`,e=>this._onPointerMove(e)),this.addEventListener(`pointerup`,e=>this._onPointerUp(e)),this.addEventListener(`pointercancel`,e=>this._onPointerUp(e)),this._range.subscribe(e=>{this._render(),this.dispatchEvent(new CustomEvent(`value-changed`,{bubbles:!0,detail:{value:e.value}}))}),this._range.subscribeChanged(()=>this._render()),this._render())}attributeChangedCallback(e){if(this._initialized){if(e===`adjustment`){this._range.configure(parseAdjustment(this.getAttribute(`adjustment`)));return}if(e===`value`){this._range.setValue(Number.parseFloat(this.getAttribute(`value`)??`0`));return}this._render()}}_setValue(e,t){let n=e;this.restrictToFillLevel&&(n=Math.min(n,Math.max(this.adjustment.lower,this.fillLevel)));let r=Number.parseInt(this.getAttribute(`round-digits`)??``,10);if(Number.isFinite(r)&&r!==-1){let e=10**r;n=Math.floor(n*e+.5)/e}return t?this._range.setValueInteractive(n):this._range.setValue(n)}_valueAtCoord(e){let t=this.adjustment,n=this.orientation===`horizontal`?this._trough.clientWidth:this._trough.clientHeight,r=n===0?1:glibClamp(e/n,0,1);return this._shouldInvert()&&(r=1-r),t.lower+r*(t.upper-t.lower-t.pageSize)}_shouldInvert(){let e=this.closest(`[dir="rtl"]`)!==null;return this.orientation===`horizontal`?this.inverted?!e:e:this.inverted}_onPointerDown(e){if(this.hasAttribute(`disabled`)||e.button!==0)return;let t=this._trough.getBoundingClientRect(),n=this.orientation===`horizontal`?e.clientX-t.left:e.clientY-t.top;this._pointerId=e.pointerId,this.focus(),this._setValue(this._valueAtCoord(n),!0);try{this.setPointerCapture(e.pointerId)}catch{}e.preventDefault()}_onPointerMove(e){if(this._pointerId!==e.pointerId)return;let t=this._trough.getBoundingClientRect(),n=this.orientation===`horizontal`?e.clientX-t.left:e.clientY-t.top;this._setValue(this._valueAtCoord(n),!0)}_onPointerUp(e){this._pointerId===e.pointerId&&(this._pointerId=null,this.hasPointerCapture(e.pointerId)&&this.releasePointerCapture(e.pointerId))}_onKeyDown(e){if(this.hasAttribute(`disabled`))return;let t=this.adjustment,n=e.ctrlKey,r=null;switch(e.key){case`ArrowLeft`:r=this.value-(n?t.pageIncrement:t.stepIncrement);break;case`ArrowRight`:r=this.value+(n?t.pageIncrement:t.stepIncrement);break;case`ArrowDown`:r=this.value-(n?t.pageIncrement:t.stepIncrement);break;case`ArrowUp`:r=this.value+(n?t.pageIncrement:t.stepIncrement);break;case`PageUp`:r=this.value+t.pageIncrement;break;case`PageDown`:r=this.value-t.pageIncrement;break;case`Home`:r=t.lower;break;case`End`:r=t.upper-t.pageSize;break;case`+`:case`=`:r=this.value+(n?t.pageIncrement:t.stepIncrement);break;case`-`:r=this.value-(n?t.pageIncrement:t.stepIncrement);break;default:return}e.preventDefault(),this._setValue(r,!0)}_render(){if(!this._trough)return;let e=this.orientation,t=this.adjustment,n=t.upper-t.lower-t.pageSize,r=n===0?0:(t.value-t.lower)/n,i=glibClamp(this._shouldInvert()?1-r:r,0,1);this.classList.toggle(`horizontal`,e===`horizontal`),this.classList.toggle(`vertical`,e===`vertical`),this.setAttribute(`aria-orientation`,e),e===`horizontal`?this._slider.style.left=`${i*100}%`:this._slider.style.bottom=`${i*100}%`,this._slider.style.top=``,this._slider.style.right=``;let a=this.hasOrigin;this._highlight.hidden=!a,a&&(e===`horizontal`?(this._highlight.style.right=``,this._highlight.style.width=`${i*100}%`):(this._highlight.style.width=``,this._highlight.style.height=`${i*100}%`));let o=this.showFillLevel;if(this._fill.hidden=!o,o){let r=glibClamp((this.fillLevel-t.lower)/(n||1),0,1);e===`horizontal`?this._fill.style.width=`${r*100}%`:this._fill.style.height=`${r*100}%`}this._value.textContent=formatScaleValue(t.value,this.digits),this._value.hidden=!this.drawValue;let s=this.valuePos;this._value.classList.toggle(`left`,s===`left`),this._value.classList.toggle(`right`,s===`right`),this._value.classList.toggle(`top`,s===`top`),this._value.classList.toggle(`bottom`,s===`bottom`),this.classList.toggle(`value-top`,s===`top`),this.classList.toggle(`value-right`,s===`right`),this.classList.toggle(`value-bottom`,s===`bottom`),this.classList.toggle(`value-left`,s===`left`),this.setAttribute(`aria-valuemin`,String(t.lower)),this.setAttribute(`aria-valuemax`,String(t.upper-t.pageSize)),this.setAttribute(`aria-valuenow`,String(t.value)),this.setAttribute(`aria-valuetext`,this._value.textContent??``),this.hasAttribute(`disabled`)?this.setAttribute(`aria-disabled`,`true`):this.removeAttribute(`aria-disabled`)}};customElements.define(`gtk-scale`,GtkScale);const za={lower:0,upper:100,stepIncrement:2,pageIncrement:20,pageSize:0};var GtkScaleButton=class extends WidgetElement{_state=new SpinState;_buttonEl;_glyph;_dockEl;_rangeEl;_minusEl;_plusEl;_icons=[];_initialized=!1;_syncing=!1;static get observedAttributes(){return[`value`,`icons`,`adjustment`,`has-frame`,`orientation`]}get value(){return this._state.value}set value(e){this._applyValue(e)}get active(){return this._buttonEl?.classList.contains(`checked`)??!1}get icons(){return[...this._icons]}set icons(e){this.setAttribute(`icons`,JSON.stringify(e))}get hasFrame(){return this.hasAttribute(`has-frame`)}set hasFrame(e){this.toggleAttribute(`has-frame`,!!e)}get orientation(){return this.getAttribute(`orientation`)===`horizontal`?`horizontal`:`vertical`}set orientation(e){this.setAttribute(`orientation`,e)}connectedCallback(){if(this._initialized)return;this._initialized=!0,this.setAttribute(`role`,`group`),this._glyph=createGtkImage(`image-missing`,`scale-button-glyph`),this._buttonEl=document.createElement(`button`),this._buttonEl.type=`button`,this._buttonEl.className=`adw-button scale-button-icon flat`,this._buttonEl.setAttribute(`aria-expanded`,`false`),this._buttonEl.appendChild(this._glyph),this._minusEl=this._stepButton(`list-remove-symbolic`,`Decrease`),this._plusEl=this._stepButton(`list-add-symbolic`,`Increase`),this._rangeEl=document.createElement(`input`),this._rangeEl.type=`range`,this._rangeEl.className=`scale-button-range`,this._rangeEl.addEventListener(`input`,()=>{this._syncing||this._applyValue(Number(this._rangeEl.value))});let e=document.createElement(`div`);e.className=`scale-button-box`,e.append(this._minusEl,this._rangeEl,this._plusEl),this._dockEl=document.createElement(`gtk-popover`),this._dockEl.classList.add(`scale-popup`),this._dockEl.replaceChildren(e),this._dockEl.anchor=this._buttonEl,this.replaceChildren(this._buttonEl,this._dockEl),this._buttonEl.addEventListener(`click`,()=>this._toggleDock()),this._minusEl.addEventListener(`click`,()=>this._step(-1)),this._plusEl.addEventListener(`click`,()=>this._step(1)),this._dockEl.subscribe(e=>this._renderDock(e)),this.addEventListener(`wheel`,e=>{e.deltaY!==0&&(e.preventDefault(),this._applyValue(this._state.value-Math.sign(e.deltaY)*this._state.adjustment.stepIncrement))},{passive:!1}),this.addEventListener(`keydown`,e=>this._onKeyDown(e)),this._icons=parseIcons(this.getAttribute(`icons`)),this._syncAdjustment(),this._render()}attributeChangedCallback(e){if(this._initialized){if(e===`adjustment`){this._syncAdjustment();return}if(e===`icons`){this._icons=parseIcons(this.getAttribute(`icons`)),this._render(),this.dispatchEvent(new CustomEvent(`notify::icons`,{bubbles:!0}));return}if(e===`value`){let e=this.getAttribute(`value`);if(e===null||e.trim()===``)return;let t=Number(e);Number.isFinite(t)&&this._applyValue(t);return}this._render()}}_applyValue(e){let t=this._state.setValue(e);if(this._render(),!t)return;let n=this._state.value;this.setAttribute(`value`,String(n)),this.dispatchEvent(new CustomEvent(`value-changed`,{bubbles:!0,detail:{value:n}})),this.dispatchEvent(new CustomEvent(`notify::value`,{bubbles:!0,detail:{value:n}}))}_syncAdjustment(){let e=parseAdjustment(this.getAttribute(`adjustment`)),t={...za,...e},n=this.getAttribute(`value`),r=n===null||n.trim()===``?NaN:Number(n);t.value=Number.isFinite(r)?r:this._state.value,this._state.configure(t),this._render(),this.dispatchEvent(new CustomEvent(`notify::adjustment`,{bubbles:!0}))}_render(){if(!this._initialized)return;let e=this._state.value,[t,n]=adjustmentRange(this._state.adjustment),r=selectIcon(this._icons,e,t,n);this._glyph.getAttribute(`icon-name`)!==r&&this._glyph.setAttribute(`icon-name`,r),this._buttonEl.setAttribute(`aria-label`,r),this._syncing=!0,this._rangeEl.min=String(t),this._rangeEl.max=String(n),this._rangeEl.step=String(this._state.adjustment.stepIncrement),this._rangeEl.value=String(e),this._rangeEl.setAttribute(`aria-valuemin`,String(t)),this._rangeEl.setAttribute(`aria-valuemax`,String(n)),this._rangeEl.setAttribute(`aria-valuenow`,String(e)),this._syncing=!1,this._minusEl.disabled=!(t<e),this._plusEl.disabled=!(e<n),this._buttonEl.classList.toggle(`flat`,!this.hasFrame),this.classList.toggle(`horizontal`,this.orientation===`horizontal`),this.classList.toggle(`vertical`,this.orientation===`vertical`)}_stepButton(e,t){let n=document.createElement(`button`);return n.type=`button`,n.className=`adw-button scale-button-step flat`,n.setAttribute(`aria-label`,t),n.appendChild(createGtkImage(e)),n}_toggleDock(){this.active?this._dock(`popdown`):this._dock(`popup`)}_dock(e){let t=e===`popup`;this.active!==t&&(this._buttonEl.classList.toggle(`checked`,t),this._buttonEl.setAttribute(`aria-expanded`,String(t)),t?(this._dockEl.popup(),this._rangeEl.focus()):(this._dockEl.popdown(),this._buttonEl.focus()),this.dispatchEvent(new CustomEvent(e,{bubbles:!0})),this.dispatchEvent(new CustomEvent(`notify::active`,{bubbles:!0,detail:{active:t}})))}_renderDock(e){this._dock(e?`popup`:`popdown`)}_step(e){this._applyValue(this._state.value+e*this._state.adjustment.pageIncrement)}_onKeyDown(e){if(e.key===`Escape`){if(!this.active)return;e.preventDefault(),this._dock(`popdown`);return}e.target===this._buttonEl&&(e.key!==` `&&e.key!==`Enter`&&e.key!==`Return`||(e.preventDefault(),this._toggleDock()))}};customElements.define(`gtk-scale-button`,GtkScaleButton);function selectIcon(e,t,n,r){let i=e[0];if(i===void 0||i===``)return`image-missing`;if(e.length===1)return i;if(e.length===2)return t<(r-n)/2+n?i:e[1]??i;if(t===n)return i;if(t===r)return e[1]??i;let a=(r-n)/(e.length-2);return e[Math.floor((t-n)/a)+2]??i}function parseIcons(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}var GtkSearchBar=class extends WidgetElement{_box;_center;_close;_initialized=!1;_capture=null;_onCapturedKey=e=>this._captureKey(e);_onInput=()=>this._revealFromTyping();static get observedAttributes(){return[`search-mode-enabled`,`show-close-button`]}get searchModeEnabled(){return this.hasAttribute(`search-mode-enabled`)}set searchModeEnabled(e){this.toggleAttribute(`search-mode-enabled`,!!e)}get showCloseButton(){return this.hasAttribute(`show-close-button`)}set showCloseButton(e){this.toggleAttribute(`show-close-button`,!!e)}get keyCaptureWidget(){return this._capture}set keyCaptureWidget(e){this._capture!==e&&(this._capture?.removeEventListener(`keydown`,this._onCapturedKey,!0),this._capture=e,this._capture?.addEventListener(`keydown`,this._onCapturedKey,!0))}get entry(){return this.querySelector(`input, textarea`)}connectedCallback(){this._initialized||(this._initialized=!0,this.setAttribute(`role`,`search`),this._center=document.createElement(`div`),this._center.className=`adw-search-bar-center`,this._close=document.createElement(`button`),this._close.className=`adw-search-bar-close`,this._close.type=`button`,this._close.setAttribute(`aria-label`,`Close search`),this._close.addEventListener(`click`,()=>this.searchModeEnabled=!1),this._box=document.createElement(`div`),this._box.className=`adw-search-bar-box`,this._box.append(this._center,this._close),bindSlottedChildren(this,[{name:`child`,into:this._center},{into:this._center}]).install(this._box),this.addEventListener(`input`,this._onInput),this.addEventListener(`keydown`,e=>{e.key===`Escape`&&(this.searchModeEnabled=!1)}),this._render())}disconnectedCallback(){this.keyCaptureWidget=null}attributeChangedCallback(e,t,n){if(this._initialized){if(e===`search-mode-enabled`){this._applyReveal(),this.dispatchEvent(new CustomEvent(`notify::search-mode-enabled`,{bubbles:!0,detail:{searchModeEnabled:this.searchModeEnabled}}));return}e===`show-close-button`&&(this._render(),this.dispatchEvent(new CustomEvent(`notify::show-close-button`,{bubbles:!0,detail:{showCloseButton:this.showCloseButton}})))}}_render(){let e=this.searchModeEnabled;this.classList.toggle(`revealed`,e),this._box.inert=!e,this._close.hidden=!this.showCloseButton}_applyReveal(){this._render();let e=this.entry;e!==null&&(this.searchModeEnabled?e.focus():e.value=``)}_revealFromTyping(){this.searchModeEnabled||(this.searchModeEnabled=!0,this.entry?.focus())}_captureKey(e){if(e.defaultPrevented||e.ctrlKey||e.altKey||e.metaKey||e.key.length!==1)return;let t=this.entry;if(this.searchModeEnabled=!0,t===null)return;e.preventDefault(),t.focus();let n=t.selectionStart??t.value.length,r=t.selectionEnd??n;t.setRangeText(e.key,n,r,`end`)}};customElements.define(`gtk-search-bar`,GtkSearchBar);var GtkSearchEntry=class extends GtkEntry{_searchIcon;_clear;_clearIcon;_timeout=null;static get observedAttributes(){return[...GtkEntry.observedAttributes,`search-delay`]}get searchDelay(){let e=Number.parseInt(this.getAttribute(`search-delay`)??``,10);return Number.isFinite(e)&&e>=0?e:150}set searchDelay(e){this.setAttribute(`search-delay`,String(e))}get _empty(){return this._input?this._input.value===``:this.getAttribute(`value`)===``}connectedCallback(){super.connectedCallback(),this._searchIcon=createGtkImage(`system-search-symbolic`,`adw-search-entry-icon`),this._clear=document.createElement(`button`),this._clear.type=`button`,this._clear.className=`adw-button flat circular icon-only adw-search-entry-clear`,this._clearIcon=createGtkImage(`edit-clear-symbolic`,`adw-search-entry-clear-icon`),this._clear.append(this._clearIcon),this._clear.title=`Clear Entry`,this._clear.setAttribute(`aria-label`,`Clear Entry`),this._clear.addEventListener(`click`,()=>{this._input.value=``,this._onChanged(),this._input.focus()}),this._clear.addEventListener(`mousedown`,e=>e.preventDefault()),this.replaceChildren(this._searchIcon,this._input,this._clear),this.setAttribute(`role`,`searchbox`),this._input.addEventListener(`input`,()=>this._onChanged()),this._input.addEventListener(`keydown`,e=>this._onKeyDown(e)),this._render()}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),e===`search-delay`&&this._clear&&this._cancel()}disconnectedCallback(){this._cancel(),super.disconnectedCallback()}_onChanged(){if(this._cancel(),this._empty){this._render(),this.dispatchEvent(new CustomEvent(`search-changed`,{bubbles:!0,detail:{value:``}}));return}this._render();let e=this.searchDelay;this._timeout=globalThis.setTimeout(()=>{this._timeout=null,this.dispatchEvent(new CustomEvent(`search-changed`,{bubbles:!0,detail:{value:this._input.value}}))},e)}_cancel(){this._timeout!==null&&(clearTimeout(this._timeout),this._timeout=null)}_onKeyDown(e){switch(e.key){case`Escape`:e.preventDefault(),this.dispatchEvent(new CustomEvent(`stop-search`,{bubbles:!0}));break;case`g`:if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault(),this.dispatchEvent(new CustomEvent(e.shiftKey?`previous-match`:`next-match`,{bubbles:!0}));break;default:return}}_render(){this._clear&&(this._clear.hidden=this._empty)}};customElements.define(`gtk-search-entry`,GtkSearchEntry);const Ba=[`always`,`never`,`automatic`,`external`],Va=[`always`,`automatic`,`never`,`external`],Ha=[`top-left`,`top-right`,`bottom-left`,`bottom-right`];function normalizePolicy(e){return Ba.find(t=>t===e)??`automatic`}function normalizeCorner(e){return Ha.find(t=>t===e)??`top-left`}function sizeRequest(e){if(e===null)return null;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>=0?t:null}const Ua=[{key:`hadjustment`,bar:`horizontal`,policy:`hscrollbar-policy`,natural:`propagate-natural-width`,cssSize:`width`,end:`left`,farEnd:`right`},{key:`vadjustment`,bar:`vertical`,policy:`vscrollbar-policy`,natural:`propagate-natural-height`,cssSize:`height`,end:`top`,farEnd:`bottom`}];function resolveScrollKey(e){switch(e.key){case`ArrowLeft`:return e.ctrlKey?{scroll:`step-backward`,horizontal:!0}:null;case`ArrowRight`:return e.ctrlKey?{scroll:`step-forward`,horizontal:!0}:null;case`ArrowUp`:return e.ctrlKey?{scroll:`step-backward`,horizontal:!1}:null;case`ArrowDown`:return e.ctrlKey?{scroll:`step-forward`,horizontal:!1}:null;case`PageUp`:return{scroll:`page-backward`,horizontal:e.ctrlKey};case`PageDown`:return{scroll:`page-forward`,horizontal:e.ctrlKey};case`Home`:return{scroll:`start`,horizontal:e.ctrlKey};case`End`:return{scroll:`end`,horizontal:e.ctrlKey};default:return null}}var GtkScrolledWindow=class extends WidgetElement{_viewport;_bars=null;_wroteSizes=new Set;_shading=null;_observer=null;_hoverable=null;_fadeTimer=null;_built=!1;_standIn={};_heard=new WeakSet;_pushing=!1;_adopted={};static get observedAttributes(){return[`hscrollbar-policy`,`vscrollbar-policy`,`window-placement`,`has-frame`,`min-content-width`,`min-content-height`,`max-content-width`,`max-content-height`,`overlay-scrolling`,`propagate-natural-width`,`propagate-natural-height`]}get hscrollbarPolicy(){return normalizePolicy(this.getAttribute(`hscrollbar-policy`))}set hscrollbarPolicy(e){this.setAttribute(`hscrollbar-policy`,e)}get vscrollbarPolicy(){return normalizePolicy(this.getAttribute(`vscrollbar-policy`))}set vscrollbarPolicy(e){this.setAttribute(`vscrollbar-policy`,e)}get_policy(){return[Va.indexOf(this.hscrollbarPolicy),Va.indexOf(this.vscrollbarPolicy)]}set_policy(e,t){let nick=(e,t)=>{let n=Number.isInteger(e)?Va[e]:void 0;if(n===void 0)throw TypeError(`${e} is not a valid value for enum argument ${t}`);return n},n=nick(e,`hscrollbar_policy`),r=nick(t,`vscrollbar_policy`);this.hscrollbarPolicy=n,this.vscrollbarPolicy=r}get hadjustment(){return this._adjustmentOf(`hadjustment`)}get vadjustment(){return this._adjustmentOf(`vadjustment`)}get_hadjustment(){return this.hadjustment}get_vadjustment(){return this.vadjustment}set_hadjustment(e){this._adopt(`hadjustment`,e)}set_vadjustment(e){this._adopt(`vadjustment`,e)}_adjustmentOf(e){let t=this._adopted[e];if(t!==void 0)return t;let n=this._standIn[e];return n===void 0&&(n=this._standIn[e]=new GtkAdjustment,this._listen(e,n),this._push(e)),n}_adopt(e,t){this._adopted[e]=t,this._listen(e,t),this._push(e)}_listen(e,t){!(t instanceof GtkAdjustment)||this._heard.has(t)||(this._heard.add(t),t.connect(`value-changed`,()=>{this._pushing||this._adjustmentOf(e)!==t||!this._viewport||this._viewport.scrollAxis(e===`hadjustment`?`horizontal`:`vertical`,t.value)}))}_push(e){let t=this._viewport,n=this._adopted[e]??this._standIn[e];if(!t?.isConnected||!(n instanceof GtkAdjustment))return;let r=t[e];this._pushing=!0;try{n.configure(r.value,r.lower,r.upper,r.stepIncrement,r.pageIncrement,r.pageSize)}finally{this._pushing=!1}}get windowPlacement(){return normalizeCorner(this.getAttribute(`window-placement`))}set windowPlacement(e){this.setAttribute(`window-placement`,e)}get hasFrame(){return this.hasAttribute(`has-frame`)}set hasFrame(e){this.toggleAttribute(`has-frame`,!!e)}get overlayScrolling(){return this.getAttribute(`overlay-scrolling`)!==`false`}set overlayScrolling(e){this.toggleAttribute(`overlay-scrolling`,!!e)}get minContentWidth(){return sizeRequest(this.getAttribute(`min-content-width`))}set minContentWidth(e){this._writeSizeRequest(`min-content-width`,e)}get minContentHeight(){return sizeRequest(this.getAttribute(`min-content-height`))}set minContentHeight(e){this._writeSizeRequest(`min-content-height`,e)}get maxContentWidth(){return sizeRequest(this.getAttribute(`max-content-width`))}set maxContentWidth(e){this._writeSizeRequest(`max-content-width`,e)}get maxContentHeight(){return sizeRequest(this.getAttribute(`max-content-height`))}set maxContentHeight(e){this._writeSizeRequest(`max-content-height`,e)}get propagateNaturalWidth(){return this.hasAttribute(`propagate-natural-width`)}set propagateNaturalWidth(e){this.toggleAttribute(`propagate-natural-width`,!!e)}get propagateNaturalHeight(){return this.hasAttribute(`propagate-natural-height`)}set propagateNaturalHeight(e){this.toggleAttribute(`propagate-natural-height`,!!e)}hscrollbar(){return this._bars?.horizontal??null}vscrollbar(){return this._bars?.vertical??null}get child(){return this._built?this._viewport.firstElementChild:this.firstElementChild}set child(e){this.set_child(e)}get_child(){return this.child}set_child(e){let t=this.child;e!==t&&(this._built?this._viewport.replaceChildren(...e===null?[]:[e]):(t?.remove(),e!==null&&this.appendChild(e)),this.dispatchEvent(new CustomEvent(`notify::child`,{bubbles:!0,detail:{child:e}})))}get viewport(){return this._viewport}connectedCallback(){if(!this._built){this._built=!0,this._viewport=document.createElement(`gtk-viewport`);let e=document.createElement(`gtk-scrollbar`),t=document.createElement(`gtk-scrollbar`);e.setAttribute(`orientation`,`horizontal`),t.setAttribute(`orientation`,`vertical`),this._bars={horizontal:e,vertical:t},bindSlottedChildren(this,[{name:`child`,into:this._viewport},{into:this._viewport}]).install(this._viewport,t,e),this.setAttribute(`role`,`generic`),this._viewport.addEventListener(`value-changed`,this._onViewportValue);for(let n of[e,t])n.addEventListener(`value-changed`,this._onBarValue),n.addEventListener(`pointerenter`,this._onIndicatorOver),n.addEventListener(`pointerleave`,this._onIndicatorOut);this._observer=new ResizeObserver(()=>this._sync()),this._observer.observe(this._viewport),this._shading=new AdwScrollShading(this,{onOvershoot:e=>this._edgeOvershot(e)}),this._shading.connect()}this._releaseHoverable(),this._hoverable=matchMedia(`(hover: hover)`),this._hoverable.addEventListener(`change`,this._onHoverableChange),this.addEventListener(`keydown`,this._onKeyDown),this._sync()}disconnectedCallback(){this.removeEventListener(`keydown`,this._onKeyDown),this._releaseHoverable()}attributeChangedCallback(e,t,n){!this._built||!this.isConnected||(this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:this._normalized(e,n)}})),this._sync())}_normalized(e,t){switch(e){case`hscrollbar-policy`:return normalizePolicy(t);case`vscrollbar-policy`:return normalizePolicy(t);case`window-placement`:return normalizeCorner(t);case`overlay-scrolling`:return t!==`false`;case`has-frame`:return t!==null;case`propagate-natural-width`:case`propagate-natural-height`:return t!==null;default:return sizeRequest(t)}}_writeSizeRequest(e,t){t===null?this.removeAttribute(e):this.setAttribute(e,String(Math.max(0,Math.trunc(t))))}get _useIndicators(){return this.overlayScrolling&&(this._hoverable?.matches??!0)}_sync(){let e=this._bars;if(e===null||!this._viewport.isConnected||!e.vertical.isConnected)return;this._push(`hadjustment`),this._push(`vadjustment`);let t=this.windowPlacement,n=this._useIndicators;this.classList.toggle(`frame`,this.hasFrame),this.classList.toggle(t,!0);for(let e of Ha)e!==t&&this.classList.toggle(e,!1);this.classList.toggle(`overlay-scrolling`,n),this._writeSize(`min-width`,`min-content-width`),this._writeSize(`min-height`,`min-content-height`),this._writeSize(`max-width`,`max-content-width`),this._writeSize(`max-height`,`max-content-height`);for(let t of Ua){let r=e[t.bar],i=normalizePolicy(this.getAttribute(t.policy)),a=this._adjustment(t.key);r.hidden=!(i===`always`||i===`automatic`&&a.upper-a.lower>a.pageSize),r.classList.toggle(`overlay-indicator`,n),r.adjustment=a,this._viewport.style[t.cssSize]=this.hasAttribute(t.natural)?`max-content`:i===`never`?`min-content`:``}n||this._clearFade()}_writeSize(e,t){let n=sizeRequest(this.getAttribute(t));n===null?this._wroteSizes.has(e)&&this.style.removeProperty(e):this.style.setProperty(e,`${n}px`),n===null?this._wroteSizes.delete(e):this._wroteSizes.add(e)}_adjustment(e){return this._viewport[e]}_mayScroll(e){let t=this._bars;if(t===null)return null;let n=e?t.horizontal:t.vertical;return n.hidden?normalizePolicy(this.getAttribute(e?`hscrollbar-policy`:`vscrollbar-policy`))===`external`?n:null:n}_onViewportValue=e=>{let t=this._bars;if(t===null)return;let n=e.detail;this._push(`hadjustment`),this._push(`vadjustment`);for(let e of Ua){let r=n[e.key];t[e.bar].adjustment=r;let i=r.upper-r.pageSize;r.value<=r.lower?this._edgeReached(e.end):r.value>=i&&this._edgeReached(e.farEnd)}this._fadeIn()};_onBarValue=e=>{let t=e.currentTarget,n=e.detail.adjustment;t.hidden||this._viewport.scrollAxis(t.getAttribute(`orientation`)===`vertical`?`vertical`:`horizontal`,n.value)};_edgeReached(e){this.dispatchEvent(new CustomEvent(`edge-reached`,{bubbles:!0,detail:{pos:e}}))}_edgeOvershot(e){e!==0&&this.dispatchEvent(new CustomEvent(`edge-overshot`,{bubbles:!0,detail:{pos:e<0?`top`:`bottom`}}))}_onKeyDown=e=>{if(e.key===`Tab`&&e.ctrlKey){let t=e.shiftKey?`backward`:`forward`;this.dispatchEvent(new CustomEvent(`move-focus-out`,{bubbles:!0,detail:{directionType:t}}));return}let t=resolveScrollKey(e);if(t===null)return;let n=this._mayScroll(t.horizontal);n!==null&&(e.preventDefault(),n.scrollBy(t.scroll),this.dispatchEvent(new CustomEvent(`scroll-child`,{bubbles:!0,detail:{scroll:t.scroll,horizontal:t.horizontal}})))};_fadeIn(){let e=this._bars;if(!(e===null||!this._useIndicators)){for(let t of[e.horizontal,e.vertical])t.style.setProperty(`--adw-indicator-opacity`,`1`);this._fadeTimer!==null&&clearTimeout(this._fadeTimer),this._fadeTimer=setTimeout(()=>this._fadeOut(),2e3)}}_fadeOut(){this._fadeTimer=null;let e=this._bars;if(!(e===null||!this._useIndicators))for(let t of[e.horizontal,e.vertical])t.classList.contains(`hovering`)||t.style.setProperty(`--adw-indicator-opacity`,`0`)}_clearFade(){this._fadeTimer!==null&&clearTimeout(this._fadeTimer),this._fadeTimer=null;let e=this._bars;if(e!==null)for(let t of[e.horizontal,e.vertical])t.style.removeProperty(`--adw-indicator-opacity`)}_onIndicatorOver=e=>{e.currentTarget.classList.add(`hovering`),this._fadeIn()};_onIndicatorOut=e=>{e.currentTarget.classList.remove(`hovering`)};_onHoverableChange=()=>{this._sync()};_releaseHoverable(){this._hoverable?.removeEventListener(`change`,this._onHoverableChange),this._hoverable=null}};customElements.define(`gtk-scrolled-window`,GtkScrolledWindow);const Wa=Object.freeze({value:0,lower:0,upper:0,stepIncrement:0,pageIncrement:0,pageSize:0});var GtkScrollbar=class extends WidgetElement{_trough;_slider;_observer=null;_built=!1;_adjustment=null;_grabPosition=0;_grabDelta=0;_zoom=!1;_dragging=!1;static get observedAttributes(){return[`orientation`,`adjustment`]}get orientation(){return normalizeBoxOrientation(this.getAttribute(`orientation`))}set orientation(e){this.setAttribute(`orientation`,e)}get adjustment(){return this._adjustment??Wa}set adjustment(e){let t=e==null?null:typeof e==`string`?parseAdjustment(e):e;this._adjustment=t===null?null:normalizeAdjustment(t,this._adjustment??void 0),this._built&&(this._render(),this._notify(`adjustment`,{adjustment:this.adjustment}))}get value(){return this.adjustment.value}set value(e){let t=this._adjustment;if(t===null)return;let n=clampAdjustmentValue(t,e);n!==t.value&&(this._adjustment={...t,value:n},this._render(),this.dispatchEvent(new CustomEvent(`value-changed`,{bubbles:!0,detail:{adjustment:this._adjustment}})))}scrollBy(e){if(typeof e!=`string`)return;let t=this.adjustment;switch(e){case`step-forward`:this.value=t.value+t.stepIncrement;break;case`step-backward`:this.value=t.value-t.stepIncrement;break;case`page-forward`:this.value=t.value+t.pageIncrement;break;case`page-backward`:this.value=t.value-t.pageIncrement;break;case`start`:this.value=t.lower;break;case`end`:this.value=t.upper;break}}scrollByWheel(e,t){let n=t===1?48:100,r=n===0?0:e/n;this.scrollBy(r>=0?`page-forward`:`page-backward`)}get _troughLength(){return this.orientation===`vertical`?this._trough.clientHeight:this._trough.clientWidth}connectedCallback(){this._built||(this._built=!0,this._trough=document.createElement(`div`),this._trough.className=`adw-scrollbar-trough`,this._slider=document.createElement(`div`),this._slider.className=`adw-scrollbar-slider`,this._trough.appendChild(this._slider),this.replaceChildren(this._trough),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`keydown`,this._onKeyDown),this.addEventListener(`wheel`,this._onWheel,{passive:!0}),this.tabIndex=0,this._observer=new ResizeObserver(()=>this._render()),this._observer.observe(this._trough),this.setAttribute(`role`,`scrollbar`)),this.hasAttribute(`adjustment`)&&(this.adjustment=this.getAttribute(`adjustment`)),this._render()}attributeChangedCallback(e,t,n){if(!(!this._built||!this.isConnected)){if(e===`adjustment`){this.adjustment=n;return}this._notify(`orientation`,{orientation:this.orientation}),this._render()}}_notify(e,t){this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:t}))}_onPointerDown=e=>{if(!this.hasAttribute(`tabindex`))return;this.focus();let t=this._coordinate(e),n=e.target===this._slider;this._grabPosition=this._sliderPosition(),this._grabDelta=t-this._grabPosition,this._setZoom(n&&e.shiftKey),this._dragging=n,this._capture(e.pointerId),this.addEventListener(`pointermove`,this._onPointerMove),this.addEventListener(`pointerup`,this._onPointerEnd),this.addEventListener(`pointercancel`,this._onPointerEnd),!n&&(e.button===0&&!e.shiftKey?this.value=this._coordinateValue(t+this._sliderSize()/2):(e.button===1||e.button===0&&e.shiftKey)&&this.scrollBy(this._coordinateValue(t)>this.value?`page-forward`:`page-backward`))};_onPointerMove=e=>{if(!this._dragging)return;this._setZoom(e.shiftKey);let t=this._coordinate(e),n=this._zoom?this._zoomFactor():1;this.value=this._coordinateValue(this._grabPosition+n*(t-(this._grabDelta+this._grabPosition)))};_onPointerEnd=e=>{this._endDrag(e.pointerId)};_endDrag(e){this._dragging=!1,this._setZoom(!1),e!==void 0&&this.hasPointerCapture(e)&&this.releasePointerCapture(e),this.removeEventListener(`pointermove`,this._onPointerMove),this.removeEventListener(`pointerup`,this._onPointerEnd),this.removeEventListener(`pointercancel`,this._onPointerEnd)}_capture(e){try{this.setPointerCapture(e)}catch{}}_onKeyDown=e=>{let t=resolveRangeKey(e,this.orientation===`vertical`);t!==null&&(e.preventDefault(),this.scrollBy(t))};_onWheel=e=>{e.target!==this&&e.target!==this._trough||this.scrollByWheel(e.deltaY,e.deltaMode)};_setZoom(e){this._zoom!==e&&(this._zoom=e,this.classList.toggle(`fine-tune`,e))}_zoomFactor(){let e=this.adjustment,t=e.upper-e.lower-e.pageSize,n=t<=0?1:Math.min(1,this._troughLength/t);return n===1?.25:n}_render(){if(!this._built)return;let e=this.adjustment,t=this.orientation===`vertical`;this.classList.toggle(`vertical`,t),this.classList.toggle(`horizontal`,!t),this.setAttribute(`aria-orientation`,this.orientation),this.removeAttribute(`aria-disabled`),this.removeAttribute(`disabled`);let n=this._troughLength,r=e.upper-e.lower,i=r-e.pageSize;if(r===0)this._slider.style.removeProperty(`--adw-scrollbar-size`);else{let t=Math.min(n,n*(e.pageSize/r));this._slider.style.setProperty(`--adw-scrollbar-size`,`${t}px`)}let a=this._sliderSize(),o=Math.max(0,n-a),s=i===0?0:o*((e.value-e.lower)/i);this.setAttribute(`aria-valuemin`,String(e.lower)),this.setAttribute(`aria-valuemax`,String(e.upper-e.pageSize)),this.setAttribute(`aria-valuenow`,String(e.value)),this._slider.style.setProperty(`--adw-scrollbar-position`,`${s}px`)}_sliderPosition(){return Number.parseFloat(this._slider.style.getPropertyValue(`--adw-scrollbar-position`))||0}_sliderSize(){return Number.parseFloat(this._slider.style.getPropertyValue(`--adw-scrollbar-size`))||0}_coordinateValue(e){let t=this.adjustment,n=Math.max(1,this._troughLength-this._sliderSize()),r=Math.min(1,Math.max(0,e/n));return t.lower+r*(t.upper-t.pageSize-t.lower)}_coordinate(e){let t=this._trough.getBoundingClientRect();return this.orientation===`vertical`?e.clientY-t.top:e.clientX-t.left}};function resolveRangeKey(e,t){switch(e.key){case`ArrowRight`:return t?null:`step-forward`;case`ArrowLeft`:return t?null:`step-backward`;case`ArrowDown`:return t?`step-forward`:null;case`ArrowUp`:return t?`step-backward`:null;case`PageDown`:return`page-forward`;case`PageUp`:return`page-backward`;case`Home`:return`start`;case`End`:return`end`;default:return null}}customElements.define(`gtk-scrollbar`,GtkScrollbar);const Ga=1e-10,Ka=[`always`,`if-valid`];var GtkSpinButton=class extends WidgetElement{_range=new SpinState;_input;_down;_up;_initialized=!1;_edited=!1;_vertical=null;_initialTimer=null;_repeatTimer=null;_timerCalls=0;_timerStep=0;static get observedAttributes(){return[`adjustment`,`climb-rate`,`digits`,`disabled`,`numeric`,`orientation`,`snap-to-ticks`,`update-policy`,`value`,`wrap`]}get adjustment(){return this._range.adjustment}set adjustment(e){this._range.configure(typeof e==`string`?parseAdjustment(e):e),this._render()}get value(){return this._range.value}set value(e){this._range.setValue(e),this._render()}get digits(){let e=Number.parseInt(this.getAttribute(`digits`)??``,10);return Number.isFinite(e)?Math.max(0,e):0}set digits(e){this.setAttribute(`digits`,String(e))}get numeric(){return this.hasAttribute(`numeric`)}set numeric(e){this.toggleAttribute(`numeric`,!!e)}get snapToTicks(){return this.hasAttribute(`snap-to-ticks`)}set snapToTicks(e){this.toggleAttribute(`snap-to-ticks`,!!e)}get wrap(){return this.hasAttribute(`wrap`)}set wrap(e){this.toggleAttribute(`wrap`,!!e)}get updatePolicy(){let e=this.getAttribute(`update-policy`);return Ka.includes(e)?e:`always`}set updatePolicy(e){this.setAttribute(`update-policy`,e)}get climbRate(){let e=Number.parseFloat(this.getAttribute(`climb-rate`)??``);return Number.isFinite(e)&&e>0?e:0}set climbRate(e){this.setAttribute(`climb-rate`,String(e))}get text(){return this._input}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=normalizeAdjustment(parseAdjustment(this.getAttribute(`adjustment`))),t=this.getAttribute(`value`),n=t===null?NaN:Number.parseFloat(t);this._range.configure(Number.isFinite(n)?{...e,value:n}:e),this._input=document.createElement(`input`),this._input.className=`adw-spin-button-text`,this._input.type=`text`,this._input.inputMode=`decimal`,this._input.autocomplete=`off`,this._input.spellcheck=!1,this._down=document.createElement(`button`),this._down.type=`button`,this._down.className=`adw-button image-button down`,this._down.append(createGtkImage(`value-decrease-symbolic`)),this._down.setAttribute(`aria-label`,`Decrease`),this._up=document.createElement(`button`),this._up.type=`button`,this._up.className=`adw-button image-button up`,this._up.append(createGtkImage(`value-increase-symbolic`)),this._up.setAttribute(`aria-label`,`Increase`),this._down.addEventListener(`click`,()=>this._spin(-this._range.adjustment.stepIncrement)),this._up.addEventListener(`click`,()=>this._spin(this._range.adjustment.stepIncrement)),this._hold(this._down,-1),this._hold(this._up,1),this._input.addEventListener(`input`,()=>{this._edited=!0,this.numeric&&this._rejectNonNumeric()}),this._input.addEventListener(`change`,()=>this._update()),this._input.addEventListener(`keydown`,e=>this._onKeyDown(e)),this.setAttribute(`role`,`spinbutton`),this.replaceChildren(this._input,this._down,this._up),this._range.subscribe(e=>{this._render(),this.dispatchEvent(new CustomEvent(`value-changed`,{bubbles:!0,detail:{value:e.value}}))}),this._range.subscribeChanged(()=>this._render()),this._render()}attributeChangedCallback(e){if(this._initialized){if(e===`adjustment`){this._range.configure(parseAdjustment(this.getAttribute(`adjustment`)));return}if(e===`value`){this._range.setValue(Number.parseFloat(this.getAttribute(`value`)??`0`));return}this._render()}}_spin(e){let t=this.adjustment,n=t.value+e,r=!1;e>0?this.wrap?Math.abs(t.value-t.upper)<Ga?(n=t.lower,r=!0):n>t.upper&&(n=t.upper):n=Math.min(n,t.upper):e<0&&(this.wrap?Math.abs(t.value-t.lower)<Ga?(n=t.upper,r=!0):n<t.lower&&(n=t.lower):n=Math.max(n,t.lower)),Math.abs(n-t.value)>Ga&&this._range.setValueInteractive(n),r&&this.dispatchEvent(new CustomEvent(`wrapped`,{bubbles:!0}))}_update(){let e=this.adjustment,t=Number.parseFloat(this._input.value),n=this._input.value.trim()!==``&&Number.isNaN(t);if(this.updatePolicy===`always`){let r=glibClamp(n||!Number.isFinite(t)?e.value:t,e.lower,e.upper-e.pageSize);this._commit(this.snapToTicks?snapAdjustmentValue(e,r):r);return}if(n||!Number.isFinite(t)||t<e.lower||t>e.upper){this._render(),this.dispatchEvent(new CustomEvent(`value-changed`,{bubbles:!0,detail:{value:this._range.value}}));return}this._commit(this.snapToTicks?snapAdjustmentValue(e,t):t)}_commit(e){this._range.setValue(e),this._edited=!1,this._render()}_rejectNonNumeric(){let e=this.digits,t=!1,n=!1,r=``;for(let i of this._input.value){if(i===`-`||i===`+`){if(t||r!==``)return this._resetText();t=!0,r+=i;continue}if(i===`.`){if(!e||n)return this._resetText();n=!0,r+=i;continue}if(i<`0`||i>`9`)return this._resetText();r+=i}r!==this._input.value&&(this._input.value=r)}_resetText(){this._input.value=this._formatted()}_hold(e,t){let begin=e=>{e.button!==0||this.hasAttribute(`disabled`)||(this._timerStep=this._range.adjustment.stepIncrement,this._timerCalls=0,this._spin(t*this._timerStep),this._initialTimer=globalThis.setTimeout(()=>{this._initialTimer=null,this._spin(t*this._timerStep),this._repeatTimer=globalThis.setInterval(()=>this._tick(t),50)},500))},end=()=>this._stopHold();e.addEventListener(`pointerdown`,begin),e.addEventListener(`pointerup`,end),e.addEventListener(`pointerleave`,end),e.addEventListener(`pointercancel`,end)}_tick(e){this._spin(e*this._timerStep);let t=this._range.adjustment;this.climbRate>0&&this._timerStep<t.pageIncrement&&(this._timerCalls<5?this._timerCalls+=1:(this._timerCalls=0,this._timerStep+=this.climbRate))}_stopHold(){this._initialTimer!==null&&(clearTimeout(this._initialTimer),this._initialTimer=null),this._repeatTimer!==null&&(clearInterval(this._repeatTimer),this._repeatTimer=null),this._timerCalls=0,this._timerStep=0}_onKeyDown(e){let t=this._range.adjustment,n=t.stepIncrement,r=t.pageIncrement,i=null;switch(e.key){case`ArrowUp`:i=n;break;case`ArrowDown`:i=-n;break;case`PageUp`:i=r;break;case`PageDown`:i=-r;break;case`Enter`:{let e=this._edited;this._update(),e||this.dispatchEvent(new CustomEvent(`activate`,{bubbles:!0}));return}default:return}e.preventDefault(),this._spin(i)}_formatted(){return formatScaleValue(this._range.value,this.digits)}_render(){if(!this._input)return;let e=this.adjustment,t=this.getAttribute(`orientation`)===`vertical`;this.classList.toggle(`vertical`,t),this.classList.toggle(`horizontal`,!t),t!==this._vertical&&(this._vertical=t,t?this.replaceChildren(this._up,this._input,this._down):this.replaceChildren(this._input,this._down,this._up)),this._input.disabled=this.hasAttribute(`disabled`),this._input.size=10,document.activeElement!==this._input&&this._input.value!==this._formatted()&&(this._input.value=this._formatted()),this._up.disabled=!this.wrap&&e.upper-e.value<=Ga,this._down.disabled=!this.wrap&&e.value-e.lower<=Ga,this.setAttribute(`aria-valuemin`,String(e.lower)),this.setAttribute(`aria-valuemax`,String(e.upper-e.pageSize)),this.setAttribute(`aria-valuenow`,String(e.value)),this.hasAttribute(`disabled`)?this.setAttribute(`aria-disabled`,`true`):this.removeAttribute(`aria-disabled`)}};customElements.define(`gtk-spin-button`,GtkSpinButton);const qa=`http://www.w3.org/2000/svg`;var GtkSpinner=class extends WidgetElement{_initialized=!1;static get observedAttributes(){return[`spinning`,`disabled`]}get spinning(){return this.hasAttribute(`spinning`)}set spinning(e){this.toggleAttribute(`spinning`,!!e)}start(){this.spinning=!0,this.setAttribute(`aria-busy`,`true`)}stop(){this.spinning=!1,this.setAttribute(`aria-busy`,`false`)}connectedCallback(){if(this._initialized){this._render();return}this._initialized=!0;let e=document.createElementNS(qa,`svg`);e.setAttribute(`viewBox`,`0 0 16 16`),e.setAttribute(`class`,`adw-spinner-ring`);let t=document.createElementNS(qa,`circle`);t.setAttribute(`cx`,`8`),t.setAttribute(`cy`,`8`),t.setAttribute(`r`,`7`),t.setAttribute(`class`,`adw-spinner-track`);let n=document.createElementNS(qa,`path`);n.setAttribute(`d`,`M 1 8 A 7 7 0 0 1 8 1`),n.setAttribute(`class`,`adw-spinner-arc`),e.append(t,n),this.replaceChildren(e),this.setAttribute(`role`,`progressbar`),this._render()}attributeChangedCallback(e){this._initialized&&(this._render(),e===`spinning`&&this.dispatchEvent(new CustomEvent(`notify::spinning`,{bubbles:!0,detail:{spinning:this.spinning}})))}_render(){this.classList.toggle(`checked`,this.spinning)}};customElements.define(`gtk-spinner`,GtkSpinner);const Ja=[`name`,`title`,`icon-name`,`needs-attention`,`use-underline`];var GtkStackPage=class extends WidgetElement{static get observedAttributes(){return[...Ja]}get name(){return this.getAttribute(`name`)??``}set name(e){e===null?this.removeAttribute(`name`):this.setAttribute(`name`,e)}get iconName(){return this.getAttribute(`icon-name`)}set iconName(e){e===null?this.removeAttribute(`icon-name`):this.setAttribute(`icon-name`,e)}get needsAttention(){return this.hasAttribute(`needs-attention`)}set needsAttention(e){this.toggleAttribute(`needs-attention`,!!e)}get useUnderline(){return this.hasAttribute(`use-underline`)}set useUnderline(e){this.toggleAttribute(`use-underline`,!!e)}get visible(){return!this.hasAttribute(`hidden`)}set visible(e){this.toggleAttribute(`hidden`,!e)}get child(){return pageChildOf(this)}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}])}};function pageChildOf(e){let t=Array.from(e.children),n=t.filter(e=>e.getAttribute(`slot`)===`child`),r=n.length>0?n:t;if(r.length>1)throw Error(`<gtk-stack-page name="${e.getAttribute(`name`)??``}"> holds ${r.length} children, and a GtkStackPage has one \`child\`.`);return r[0]??null}customElements.define(`gtk-stack-page`,GtkStackPage);const Ya=[`none`,`crossfade`,`slide-right`,`slide-left`,`slide-up`,`slide-down`,`slide-left-right`,`slide-up-down`,`over-up`,`over-down`,`over-left`,`over-right`,`under-up`,`under-down`,`under-left`,`under-right`,`over-up-down`,`over-down-up`,`over-left-right`,`over-right-left`,`rotate-left`,`rotate-right`,`rotate-left-right`],Xa=new Set([`slide-left-right`,`slide-up-down`,`over-up-down`,`over-down-up`,`over-left-right`,`over-right-left`,`rotate-left-right`]),Za={"slide-left":`slide-right`,"slide-right":`slide-left`,"rotate-left":`rotate-right`,"rotate-right":`rotate-left`,"over-left":`over-right`,"over-right":`over-left`,"under-left":`under-right`,"under-right":`under-left`};function simpleTransitionType(e,t){switch(t){case`slide-left-right`:return e?`slide-right`:`slide-left`;case`rotate-left-right`:return e?`rotate-right`:`rotate-left`;case`slide-up-down`:return e?`slide-down`:`slide-up`;case`over-up-down`:return e?`under-down`:`over-up`;case`over-down-up`:return e?`under-up`:`over-down`;case`over-left-right`:return e?`under-right`:`over-left`;case`over-right-left`:return e?`under-left`:`over-right`;default:return t}}const Qa=[`name`,`title`,`icon-name`,`use-underline`,`needs-attention`];var GtkStack=class extends WidgetElement{static signals={"notify::visible-child":`notify::visible-child`,"notify::visible-child-name":`notify::visible-child-name`};_visible=null;_lastVisible=null;_initialized=!1;_initializedChildren=new WeakSet;_observer=null;_timer=null;_running=!1;static get observedAttributes(){return[`visible-child-name`,`transition-type`,`transition-duration`,`hhomogeneous`,`vhomogeneous`,`interpolate-size`]}get visibleChildName(){return this.getAttribute(`visible-child-name`)}set visibleChildName(e){this._write(`visible-child-name`,e)}get visibleChild(){return this._visible}set visibleChild(e){this.setVisibleChild(e)}get transitionType(){let e=this.getAttribute(`transition-type`);return e!==null&&Ya.includes(e)?e:`none`}set transitionType(e){this._write(`transition-type`,e)}get transitionDuration(){return this._duration()}set transitionDuration(e){this._write(`transition-duration`,String(e))}get hhomogeneous(){return this._flag(`hhomogeneous`,!0)}set hhomogeneous(e){this._write(`hhomogeneous`,e?``:`false`)}get vhomogeneous(){return this._flag(`vhomogeneous`,!0)}set vhomogeneous(e){this._write(`vhomogeneous`,e?``:`false`)}get interpolateSize(){return this.hasAttribute(`interpolate-size`)}set interpolateSize(e){this.toggleAttribute(`interpolate-size`,!!e)}get transitionRunning(){return this.hasAttribute(`transition-running`)}get pages(){return this._children().map(e=>this._page(e))}getChildByName(e){return this._children().find(t=>this._page(t).name===e)??null}getPage(e){return this._children().includes(e)?this._page(e):null}isSelected(e){return this._visible===e}addTitled(e,t,n){return t!==null&&e.setAttribute(`name`,t),n!=null&&e.setAttribute(`title`,n),this.addChild(e)}addNamed(e,t){return this.addTitled(e,t)}addChild(e){return this.appendChild(e),this._initChild(e),this._initialized&&!this._visible&&!e.hasAttribute(`hidden`)&&this._show(e),e}removePage(e){e.remove()}remove(e){if(e===void 0){super.remove();return}this.removePage(e)}add_titled(e,t,n){return this.addTitled(e,t,n)}add_named(e,t){return this.addNamed(e,t)}get_visible_child_name(){return this.visibleChildName}set_visible_child_name(e){this.setVisibleChildName(e)}get_visible_child(){return this.visibleChild}set_visible_child(e){this.setVisibleChild(e)}setVisibleChild(e,t){return e?this._children().includes(e)?this._show(e,t):!1:this._show(this._firstVisible(),t)}setVisibleChildName(e){if(e===null)return!1;let t=this._children().find(t=>this._page(t).name===e);return t?this._show(t):!1}connectedCallback(){if(this._initialized){this._render();return}this._initialized=!0,this.setAttribute(`role`,`group`);for(let e of this._children())this._initChild(this._adopt(e));this._observer=new MutationObserver(e=>this._onChildMutations(e)),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...Qa,`hidden`]}),this._visible||this._show(this._firstVisible()),this._render()}disconnectedCallback(){this._observer?.disconnect(),this._observer=null,this._timer!==null&&clearTimeout(this._timer),this._timer=null,this._initialized=!1}attributeChangedCallback(e){if(this._initialized){if(e===`visible-child-name`){this.setVisibleChildName(this.getAttribute(`visible-child-name`));return}this._render(),this._notify(e)}}_property(e){switch(e){case`transition-type`:return this.transitionType;case`transition-duration`:return this.transitionDuration;case`hhomogeneous`:return this.hhomogeneous;case`vhomogeneous`:return this.vhomogeneous;case`interpolate-size`:return this.interpolateSize;default:return this.visibleChildName}}_notify(e){this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:this._property(e)}}))}_write(e,t){t===null?this.removeAttribute(e):this.getAttribute(e)!==t&&this.setAttribute(e,t)}_flag(e,t){let n=this.getAttribute(e);return n===null?t:n!==`false`}_duration(){let e=this.getAttribute(`transition-duration`);if(e===null)return 200;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:0}_children(){return Array.from(this.children)}_page(e){return{name:e.getAttribute(`name`)??``,title:e.getAttribute(`title`),iconName:e.getAttribute(`icon-name`),useUnderline:e.hasAttribute(`use-underline`),needsAttention:e.hasAttribute(`needs-attention`),visible:!e.hasAttribute(`hidden`),child:e}}_firstVisible(){return this._children().find(e=>this._page(e).visible)??null}_adopt(e){if(e.localName!==`gtk-stack-page`)return e;let t=pageChildOf(e);if(t===null)throw Error(`<gtk-stack-page name="${e.getAttribute(`name`)??``}"> has no child, so the stack would hold a page with nothing to show.`);for(let n of Ja){let r=e.getAttribute(n);r!==null&&t.setAttribute(n,r)}return e.hasAttribute(`hidden`)&&t.setAttribute(`hidden`,``),t.removeAttribute(`slot`),this.replaceChild(t,e),t}_initChild(e){this._initializedChildren.has(e)||(this._initializedChildren.add(e),e.classList.add(`adw-stack-page`))}_isPage(e){return e.parentNode===this}_onChildMutations(e){let t=0,n=0,r=-1,i=!1;for(let a of e){if(a.type===`childList`){if(a.target!==this)continue;for(let e of Array.from(a.removedNodes))e instanceof HTMLElement&&e.localName===`gtk-stack-page`||(e===this._visible&&(this._visible=null),e===this._lastVisible&&(this._lastVisible=null),n+=1);for(let e of Array.from(a.addedNodes))if(e instanceof HTMLElement){if(e.localName===`gtk-stack-page`){e.parentElement===this&&this._adopt(e);continue}this._initChild(e),t+=1,r===-1&&(r=this._children().indexOf(e))}continue}let e=a.attributeName;if(!(!e||!this._isPage(a.target))){if(e===`hidden`){(!this._visible||!this._page(this._visible).visible)&&this._show(this._firstVisible());continue}Qa.includes(e)&&(i=!0)}}if((n>0||t>0)&&this.dispatchEvent(new CustomEvent(`items-changed`,{bubbles:!0,detail:{position:r===-1?this._children().length:r,removed:n,added:t}})),i){for(let t of e){if(t.type!==`attributes`||!this._isPage(t.target))continue;let e=t.target;this.dispatchEvent(new CustomEvent(`page-updated`,{bubbles:!0,detail:{child:e}})),e===this._visible&&t.attributeName===`name`&&(this._write(`visible-child-name`,this._nameOrNull(this._page(e).name)),this.dispatchEvent(new CustomEvent(`notify::visible-child-name`,{bubbles:!0,detail:{"visible-child-name":this.visibleChildName}})))}this._render()}}_nameOrNull(e){return e===``?null:e}_show(e,t){if(!e)return!1;let n=this._page(e);if(!n.visible||this._visible===e)return!1;let r=this._visible;if(this._visible=e,this._write(`visible-child-name`,this._nameOrNull(n.name)),this._lastVisible=r,this._render(),this.dispatchEvent(new CustomEvent(`notify::visible-child`,{bubbles:!0,detail:{"visible-child":e}})),this.dispatchEvent(new CustomEvent(`notify::visible-child-name`,{bubbles:!0,detail:{"visible-child-name":this.visibleChildName}})),r){let t=Math.min(this._children().indexOf(r),this._children().indexOf(e));this.dispatchEvent(new CustomEvent(`selection-changed`,{bubbles:!0,detail:{position:t,nItems:2}}))}else this.dispatchEvent(new CustomEvent(`selection-changed`,{bubbles:!0,detail:{position:this._children().indexOf(e),nItems:1}}));return this._startTransition(r,t??this.transitionType),!0}_startTransition(e,t){this._timer!==null&&(clearTimeout(this._timer),this._timer=null);let n=this._effectiveType(t);if(Xa.has(n)&&!e?n=`none`:Xa.has(n)&&e&&(n=simpleTransitionType(this._newChildFirst(e),n)),n===`none`||!e||this._duration()===0){this._running=!1,this.removeAttribute(`transition-running`),this.classList.remove(`transitioning`),this._lastVisible=null,this._render();return}this.dataset.transitionType=n,this._running=!0,this.setAttribute(`transition-running`,``),this.classList.add(`transitioning`),this._render(),this.dispatchEvent(new CustomEvent(`transition-start`,{bubbles:!0,detail:{duration:this._duration()}})),this._timer=setTimeout(()=>{this._timer=null,this._running=!1,this.removeAttribute(`transition-running`),this.classList.remove(`transitioning`),delete this.dataset.transitionType,this._lastVisible=null,this._render(),this.dispatchEvent(new CustomEvent(`transition-end`,{bubbles:!0}))},this._duration())}_newChildFirst(e){let t=this._children();return t.indexOf(this._visible)<t.indexOf(e)}_effectiveType(e){let t=e;return t!==`none`&&(this._reducedMotion()?t=this.hhomogeneous&&this.vhomogeneous?`crossfade`:`none`:this.getAttribute(`dir`)===`rtl`&&(t=Za[t]??t)),t}_reducedMotion(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}_render(){if(this._initialized){for(let e of this._children()){let t=e===this._visible;e.classList.toggle(`visible-page`,t),e.classList.toggle(`transitioning-in`,t&&this._running),e.classList.toggle(`transitioning-out`,!t&&e===this._lastVisible&&this._running),t?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,`true`)}this.style.setProperty(`--stack-transition-duration`,`${this._duration()}ms`)}}};customElements.define(`gtk-stack`,GtkStack);var GtkStackSidebar=class extends WidgetElement{_stack=null;_list;_initialized=!1;_rows=[];_onStackChange=()=>this._rebuild();static get observedAttributes(){return[`stack`]}get stack(){return this._stack}set stack(e){this.setStack(typeof e==`string`?this._resolve(e):e)}refresh(){this._rebuild()}connectedCallback(){if(this._initialized){this._bindStack(),this._rebuild();return}this._initialized=!0,this._list=document.createElement(`div`),this._list.className=`adw-stack-sidebar-list navigation-sidebar`,this._list.setAttribute(`role`,`listbox`),this._list.setAttribute(`aria-label`,`Sidebar`),this.replaceChildren(this._list),this.classList.add(`sidebar`);let e=this.getAttribute(`stack`);if(e){this.setStack(this._resolve(e));return}this._rebuild()}disconnectedCallback(){this._unbindStack()}attributeChangedCallback(e,t,n){!this._initialized||e!==`stack`||this.setStack(n===null?null:this._resolve(n))}setStack(e){e!==this._stack&&(this._unbindStack(),this._stack=e,this._bindStack(),this._rebuild(),this.dispatchEvent(new CustomEvent(`notify::stack`,{bubbles:!0,detail:{stack:this._stack}})))}_resolve(e){return e?document.getElementById(e)??null:null}_bindStack(){this._stack?.addEventListener(`items-changed`,this._onStackChange),this._stack?.addEventListener(`selection-changed`,this._onStackChange),this._stack?.addEventListener(`page-updated`,this._onStackChange)}_unbindStack(){this._stack?.removeEventListener(`items-changed`,this._onStackChange),this._stack?.removeEventListener(`selection-changed`,this._onStackChange),this._stack?.removeEventListener(`page-updated`,this._onStackChange)}_pages(){return this._stack?.pages??[]}_visible(e){return e.visible&&e.title!==null}_selectedIndex(){let e=this._pages(),t=this._stack?.visibleChildName??null;return t===null?-1:e.findIndex(e=>e.name===t)}_rebuild(){if(!this._initialized)return;let e=this._pages();e.length!==this._rows.length&&(this._list.replaceChildren(),this._rows=e.map(()=>this._buildRow()),this._list.append(...this._rows));let t=this._selectedIndex();e.forEach((e,n)=>{let r=this._rows[n];if(!r)return;let i=r.querySelector(`.adw-stack-sidebar-title`);i&&(i.textContent=e.title??``),r.hidden=!this._visible(e),r.classList.toggle(`needs-attention`,e.needsAttention),r.classList.toggle(`selected`,n===t),r.setAttribute(`aria-selected`,String(n===t))})}_buildRow(){let e=document.createElement(`button`);e.type=`button`,e.className=`adw-stack-sidebar-row`,e.setAttribute(`role`,`link`);let t=document.createElement(`span`);return t.className=`adw-stack-sidebar-title`,e.appendChild(t),e.addEventListener(`click`,()=>this._onRowActivated(e)),e}_onRowActivated(e){let t=this._rows.findIndex(t=>t===e);if(t===-1)return;let n=this._pages()[t];n&&(this._stack?.isSelected(n.child)||this._stack?.setVisibleChild(n.child))}};customElements.define(`gtk-stack-sidebar`,GtkStackSidebar);var GtkStackSwitcher=class extends WidgetElement{_stack=null;_initialized=!1;_nodes=[];_onStackChange=()=>this._rebuild();static get observedAttributes(){return[`stack`,`orientation`]}get stack(){return this._stack}set stack(e){this.setStack(typeof e==`string`?this._resolve(e):e)}get orientation(){return normalizeBoxOrientation(this.getAttribute(`orientation`))}set orientation(e){this.getAttribute(`orientation`)!==e&&this.setAttribute(`orientation`,e)}refresh(){this._rebuild()}connectedCallback(){if(this._initialized){this._bindStack(),this._rebuild();return}this._initialized=!0,this.setAttribute(`role`,`tablist`),this.classList.add(`linked`);let e=this.getAttribute(`stack`);if(e){this.setStack(this._resolve(e));return}this._rebuild()}disconnectedCallback(){this._unbindStack()}attributeChangedCallback(e,t,n){if(this._initialized){if(e===`orientation`){this._render(),this.dispatchEvent(new CustomEvent(`notify::orientation`,{bubbles:!0,detail:{orientation:this.orientation}}));return}this.setStack(n===null?null:this._resolve(n))}}setStack(e){e!==this._stack&&(this._unbindStack(),this._stack=e,this._bindStack(),this._rebuild(),this.dispatchEvent(new CustomEvent(`notify::stack`,{bubbles:!0,detail:{stack:this._stack}})))}_resolve(e){return e?document.getElementById(e)??null:null}_bindStack(){this._stack?.addEventListener(`items-changed`,this._onStackChange),this._stack?.addEventListener(`selection-changed`,this._onStackChange),this._stack?.addEventListener(`page-updated`,this._onStackChange)}_unbindStack(){this._stack?.removeEventListener(`items-changed`,this._onStackChange),this._stack?.removeEventListener(`selection-changed`,this._onStackChange),this._stack?.removeEventListener(`page-updated`,this._onStackChange)}_visible(e){return e.visible&&(e.title!==null||e.iconName!==null)}_pages(){return this._stack?.pages??[]}_selectedIndex(){let e=this._pages(),t=this._stack?.visibleChildName??null;return t===null?-1:e.findIndex(e=>e.name===t)}_rebuild(){if(!this._initialized)return;let e=this._pages();e.length!==this._nodes.length&&(this.replaceChildren(),this._nodes=e.map(()=>this._buildButton()),this.append(...this._nodes.map(e=>e.button)));let t=this._selectedIndex();e.forEach((e,n)=>{let r=this._nodes[n];if(!r)return;r.button.hidden=!this._visible(e),r.button.classList.toggle(`active`,n===t),r.button.setAttribute(`aria-selected`,String(n===t)),r.button.classList.toggle(`needs-attention`,e.needsAttention);let i=e.iconName!==null,a=e.title!==null;r.icon.hidden=!i,r.label.hidden=!a,r.label.textContent=e.title??``,r.button.dataset.buttonMode=i?a?`both`:`icon`:`text`,i?(r.icon.setAttribute(`icon-name`,e.iconName),this.title=e.title??``):(r.icon.removeAttribute(`icon-name`),this.removeAttribute(`title`))}),this._render()}_buildButton(){let e=document.createElement(`button`);e.type=`button`,e.className=`adw-stack-switcher-button`,e.setAttribute(`role`,`tab`);let t=document.createElement(`span`);t.className=`adw-stack-switcher-icon`,t.setAttribute(`aria-hidden`,`true`);let n=document.createElement(`span`);return n.className=`adw-stack-switcher-title`,e.append(t,n),e.addEventListener(`click`,()=>this._onToggled(e)),{button:e,label:n,icon:t}}_onToggled(e){let t=this._nodes.findIndex(t=>t.button===e);if(t===-1)return;let n=this._pages()[t];n&&(this._stack?.isSelected(n.child)||this._stack?.setVisibleChild(n.child))}_render(){this.setAttribute(`aria-orientation`,this.orientation)}};customElements.define(`gtk-stack-switcher`,GtkStackSwitcher);var GtkText=class extends WidgetElement{_input;_initialized=!1;_maxLength=0;static get observedAttributes(){return[`text`,`editable`,`placeholder-text`,`max-length`,`visibility`,`propagate-text-width`]}get text(){return this._input?this._input.value:this.getAttribute(`text`)??``}set text(e){let t=clampEntryText(e??``,this._maxLength);this._input?this._input.value=t:this.setAttribute(`text`,t),this._resizeToText()}get editable(){return readBooleanAttribute(this,`editable`,!0)}set editable(e){writeBooleanAttribute(this,`editable`,e,!0)}get placeholderText(){return this.getAttribute(`placeholder-text`)??``}set placeholderText(e){this.setAttribute(`placeholder-text`,e??``)}get maxLength(){return this._maxLength}set maxLength(e){this._maxLength=Number.isFinite(e)?Math.min(It,Math.max(0,Math.trunc(e))):0,this._input&&(this._input.value=clampEntryText(this._input.value,this._maxLength))}get visibility(){return readBooleanAttribute(this,`visibility`,!0)}set visibility(e){writeBooleanAttribute(this,`visibility`,e,!0)}get propagateTextWidth(){return readBooleanAttribute(this,`propagate-text-width`,!1)}set propagateTextWidth(e){writeBooleanAttribute(this,`propagate-text-width`,e,!1)}get textLength(){return entryTextLength(this.text)}get input(){return this._input}connectedCallback(){if(this._initialized)return;this._initialized=!0,this._maxLength=Number(this.getAttribute(`max-length`)??0);let e=document.createElement(`input`);e.className=`adw-text`,e.type=this.visibility?`text`:`password`,e.value=clampEntryText(this.getAttribute(`text`)??``,this._maxLength),e.placeholder=this.placeholderText,e.readOnly=!this.editable,e.addEventListener(`input`,()=>{let t=clampEntryText(e.value,this._maxLength);t!==e.value&&(e.value=t),this._resizeToText()}),e.addEventListener(`keydown`,t=>{t.key===`Enter`&&this.dispatchEvent(new CustomEvent(`activate`,{bubbles:!0,detail:{text:e.value}}))}),this._input=e,this.replaceChildren(e),this._render()}attributeChangedCallback(e,t,n){if(!this._initialized){e===`max-length`&&(this._maxLength=Number(n??0));return}e===`text`?this._input.value=clampEntryText(n??``,this._maxLength):e===`placeholder-text`?this._input.placeholder=n??``:e===`max-length`?(this._maxLength=Number(n??0),this._input.value=clampEntryText(this._input.value,this._maxLength)):e===`editable`?this._input.readOnly=!this.editable:e===`visibility`&&(this._input.type=this.visibility?`text`:`password`),this._resizeToText(),this._reflectReadOnly()}_render(){this._resizeToText(),this._reflectReadOnly()}_reflectReadOnly(){this.classList.toggle(`read-only`,!this.editable)}_resizeToText(){let e=this.propagateTextWidth;this.classList.toggle(`propagate-text-width`,e),this._input&&e&&(this._input.size=Math.max(1,entryTextLength(this._input.value)))}};function readBooleanAttribute(e,t,n){let r=e.getAttribute(t);return r===null?n:r!==`false`}function writeBooleanAttribute(e,t,n,r){n===r?e.removeAttribute(t):e.setAttribute(t,n?`true`:`false`)}customElements.define(`gtk-text`,GtkText);const $a=[`none`,`char`,`word`,`word-char`];function normalizeWrapMode(e){return $a.includes(e??``)?e:`none`}const eo={none:`pre`,word:`pre-wrap`,"word-char":`pre-wrap`,char:`pre-wrap`};var GtkTextView=class extends WidgetElement{_area;_initialized=!1;static get observedAttributes(){return[`text`,`editable`,`wrap-mode`,`justification`,`monospace`,`accepts-tab`,`cursor-visible`,`top-margin`,`bottom-margin`,`left-margin`,`right-margin`]}get text(){return this._area?this._area.value:this.getAttribute(`text`)??this._seedText()}set text(e){this._area?this._area.value=e??``:this.setAttribute(`text`,e??``)}get editable(){return this._bool(`editable`,!0)}set editable(e){this._setBool(`editable`,e,!0)}get wrapMode(){return normalizeWrapMode(this.getAttribute(`wrap-mode`))}set wrapMode(e){this.setAttribute(`wrap-mode`,e)}get justification(){return normalizeLabelJustify(this.getAttribute(`justification`))}set justification(e){this.setAttribute(`justification`,e)}get monospace(){return this._bool(`monospace`,!1)}set monospace(e){this._setBool(`monospace`,e,!1)}get acceptsTab(){return this._bool(`accepts-tab`,!0)}set acceptsTab(e){this._setBool(`accepts-tab`,e,!0)}get cursorVisible(){return this._bool(`cursor-visible`,!0)}set cursorVisible(e){this._setBool(`cursor-visible`,e,!0)}get topMargin(){return this._margin(`top-margin`)}set topMargin(e){this.setAttribute(`top-margin`,String(e))}get bottomMargin(){return this._margin(`bottom-margin`)}set bottomMargin(e){this.setAttribute(`bottom-margin`,String(e))}get leftMargin(){return this._margin(`left-margin`)}set leftMargin(e){this.setAttribute(`left-margin`,String(e))}get rightMargin(){return this._margin(`right-margin`)}set rightMargin(e){this.setAttribute(`right-margin`,String(e))}get buffer(){return{cursor_position:this._area?this._area.selectionEnd??this._area.value.length:this.text.length,insert_at_cursor:(e,t=-1)=>{let n=t<0?e:e.slice(0,t),r=this._area;if(!r){this.text+=n;return}let i=r.selectionEnd??r.value.length;r.setRangeText(n,i,i,`end`),this._emitChanged()},set_text:(e,t=-1)=>{this.text=t<0?e:e.slice(0,t),this._area&&this._emitChanged()},get_text:()=>this.text}}get_buffer(){return this.buffer}get textarea(){return this._area}connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=document.createElement(`textarea`);e.className=`adw-text-view`,e.value=this.getAttribute(`text`)??this._seedText(),e.spellcheck=!1,e.addEventListener(`input`,()=>this._emitChanged()),e.addEventListener(`keydown`,t=>{if(t.key!==`Tab`||!this.acceptsTab)return;t.preventDefault();let n=e.selectionStart??e.value.length,r=e.selectionEnd??n;e.setRangeText(` `,n,r,`end`),this._emitChanged()}),this._area=e,this.replaceChildren(e),this._render()}attributeChangedCallback(e,t,n){this._initialized&&(e===`text`?this._area.value=n??``:e===`editable`&&(this._area.readOnly=!this.editable),this._render())}_render(){let e=this.wrapMode,t=this._area;t.style.whiteSpace=eo[e],t.style.wordBreak=e===`char`?`break-all`:`normal`,t.style.overflowWrap=e===`word-char`?`anywhere`:`normal`,t.style.textAlign=ia[this.justification],t.style.caretColor=this.cursorVisible?``:`transparent`,this.classList.toggle(`monospace`,this.monospace),t.style.setProperty(`--adw-text-view-margin-top`,`${this.topMargin}px`),t.style.setProperty(`--adw-text-view-margin-end`,`${this.rightMargin}px`),t.style.setProperty(`--adw-text-view-margin-bottom`,`${this.bottomMargin}px`),t.style.setProperty(`--adw-text-view-margin-start`,`${this.leftMargin}px`)}_seedText(){return this.textContent}_emitChanged(){this.dispatchEvent(new CustomEvent(`changed`,{bubbles:!0,detail:{text:this._area.value}}))}_bool(e,t){let n=this.getAttribute(e);return n===null?t:n!==`false`}_setBool(e,t,n){t===n?this.removeAttribute(e):this.setAttribute(e,t?`true`:`false`)}_margin(e){let t=Number.parseInt(this.getAttribute(e)??``,10);return Number.isFinite(t)?Math.max(0,t):0}};customElements.define(`gtk-text-view`,GtkTextView);var GtkToggleButton=class extends GtkButton{static signals={...GtkButton.signals,toggled:`toggled`,"notify::active":`notify::active`};_wired=!1;_groupNext=null;_groupPrev=null;_reflectingGroup=!1;static get observedAttributes(){return[...GtkButton.observedAttributes,`active`,`group`]}get active(){return this.hasAttribute(`active`)}set active(e){let t=!!e;this.active!==t&&(t&&this._grouped&&this._clearGroup(),this.toggleAttribute(`active`,t))}set group(e){this._reflectingGroup=!0,e===null||e.id===``?this.removeAttribute(`group`):this.setAttribute(`group`,e.id),this._reflectingGroup=!1,this._setGroup(e)}get _grouped(){return this._groupNext!==null||this._groupPrev!==null}connectedCallback(){super.connectedCallback(),!this._wired&&(this._wired=!0,this.button.addEventListener(`click`,()=>{this.active&&this._grouped||(this.active=!this.active)}),this.hasAttribute(`group`)&&this._setGroup(resolveGroupTarget(this.getAttribute(`group`),this)))}attributeChangedCallback(e){e===`group`&&!this._reflectingGroup&&this.isConnected&&this._setGroup(resolveGroupTarget(this.getAttribute(`group`),this)),super.attributeChangedCallback(),!(e!==`active`||!this.isConnected)&&(this.active&&this._grouped&&this._clearGroup(),this.dispatchEvent(new CustomEvent(`toggled`,{bubbles:!0})),this.dispatchEvent(new CustomEvent(`notify::active`,{bubbles:!0,detail:{active:this.active}})))}_setGroup(e){if(e===this){console.error(`<gtk-toggle-button> cannot be its own group; the group is unchanged.`);return}if(e===null)this._groupPrev&&(this._groupPrev._groupNext=this._groupNext),this._groupNext&&(this._groupNext._groupPrev=this._groupPrev),this._groupNext=null,this._groupPrev=null;else{if(this._groupNext===e)return;if(this._groupPrev=null,e._groupPrev){let t=e._groupPrev;t._groupNext=this,this._groupPrev=t}e._groupPrev=this,this._groupNext=e}this.dispatchEvent(new CustomEvent(`notify::group`,{bubbles:!0}))}_clearGroup(){let e=this._groupFirst();for(let t=e;t!==null;t=t._groupNext)t!==this&&(t.active=!1)}_groupFirst(e=0){let t=this._groupPrev;return t===null||e>1024?this:t._groupFirst(e+1)}decorate(e){e.classList.toggle(`checked`,this.active),e.setAttribute(`aria-pressed`,String(this.active))}};customElements.define(`gtk-toggle-button`,GtkToggleButton);function resolveGroupTarget(e,t){if(e===null||e===``)return null;let n=document.getElementById(e);return n===null?(console.error(`<gtk-toggle-button group="${e}"> names no element; the group is unchanged.`),null):(n instanceof GtkToggleButton||customElements.upgrade(n),!(n instanceof GtkToggleButton)||n===t?(console.error(`<gtk-toggle-button group="${e}"> names no other toggle button; the group is unchanged.`),null):n)}var GtkTreeExpander=class extends WidgetElement{_ornaments=[];_expandTimer=null;_initialized=!1;static get observedAttributes(){return[`hide-expander`,`indent-for-depth`,`indent-for-icon`,`depth`,`expandable`,`expanded`]}get hideExpander(){return this.hasAttribute(`hide-expander`)}set hideExpander(e){this.toggleAttribute(`hide-expander`,!!e)}get indentForDepth(){return this.getAttribute(`indent-for-depth`)!==`false`}set indentForDepth(e){this.setAttribute(`indent-for-depth`,String(!!e))}get indentForIcon(){return this.getAttribute(`indent-for-icon`)!==`false`}set indentForIcon(e){this.setAttribute(`indent-for-icon`,String(!!e))}get depth(){let e=Number.parseInt(this.getAttribute(`depth`)??``,10);return Number.isFinite(e)&&e>0?e:0}set depth(e){this.setAttribute(`depth`,String(e))}get expandable(){return this.hasAttribute(`expandable`)}set expandable(e){this.toggleAttribute(`expandable`,!!e)}get expanded(){return this.hasAttribute(`expanded`)}set expanded(e){this.toggleAttribute(`expanded`,!!e)}get layout(){return treeExpanderLayout({depth:this.depth,expandable:this.expandable,expanded:this.expanded},{hideExpander:this.hideExpander,indentForDepth:this.indentForDepth,indentForIcon:this.indentForIcon})}connectedCallback(){this._initialized||(this._initialized=!0,this.hasAttribute(`tabindex`)||(this.tabIndex=0),this._wire()),bindSlottedChildren(this,[{name:`child`,into:this}]),this.setAttribute(`role`,`button`),this._render()}_wire(){this.addEventListener(`keydown`,e=>{let t=treeExpanderAction(e.key,{ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,rtl:globalThis.getComputedStyle(this).direction===`rtl`});t!==`none`&&(e.preventDefault(),this.expanded=treeExpanderExpanded(this.expanded,t))}),this.addEventListener(`dragenter`,()=>{this.expanded||this._expandTimer!==null||(this._expandTimer=setTimeout(()=>{this._expandTimer=null,this.expanded=!0},500))});for(let e of[`dragleave`,`drop`])this.addEventListener(e,()=>this._cancelExpandTimer())}disconnectedCallback(){this._cancelExpandTimer()}attributeChangedCallback(e){this._initialized&&(this._render(),e===`expanded`&&this.dispatchEvent(new CustomEvent(`notify::expanded`,{bubbles:!0,detail:{expanded:this.expanded}})))}_cancelExpandTimer(){this._expandTimer!==null&&(clearTimeout(this._expandTimer),this._expandTimer=null)}_render(){for(let e of this._ornaments)e.remove();this._ornaments=[];let e=this.layout,t=this.firstChild;for(let n=0;n<e.indents;n++){let e=document.createElement(`span`);e.className=`adw-tree-expander-indent`,e.setAttribute(`aria-hidden`,`true`),this.insertBefore(e,t),this._ornaments.push(e)}if(e.expander===`none`)this.removeAttribute(`aria-expanded`);else{let n=createGtkImage(`go-next`,`adw-tree-expander-icon`);n.classList.toggle(`expanded`,e.expander===`expanded`),n.addEventListener(`click`,e=>{e.stopPropagation(),this.expanded=!this.expanded}),this.insertBefore(n,t),this._ornaments.push(n),this.setAttribute(`aria-expanded`,String(e.expander===`expanded`))}this.setAttribute(`aria-level`,String(e.level))}};customElements.define(`gtk-tree-expander`,GtkTreeExpander);var GtkVideo=class extends WidgetElement{_initialized=!1;_overlayIcon;_controlsRevealer;_media=null;mediaListeners=[];_hideTimer=null;_hasStream=!1;_error=null;_ended=!1;_playing=!1;static get observedAttributes(){return[`autoplay`,`graphics-offload`,`loop`]}get autoplay(){return this.hasAttribute(`autoplay`)}set autoplay(e){this._write(`autoplay`,!!e),this._syncMedia()}get loop(){return this.hasAttribute(`loop`)}set loop(e){this._write(`loop`,!!e),this._syncMedia()}get graphicsOffload(){return this.hasAttribute(`graphics-offload`)}set graphicsOffload(e){this._write(`graphics-offload`,!!e)}get media(){return this._media}get playing(){return this._playing}get timestamp(){return this._media?.currentTime??0}get duration(){let e=this._media?.duration??0;return Number.isFinite(e)?e:0}get controlsRevealed(){return this._controlsRevealer?.classList.contains(`revealed`)??!1}_write(e,t){this.toggleAttribute(e,t)}connectedCallback(){if(this._initialized){this._adoptMedia();return}this._initialized=!0,this._overlayIcon=document.createElement(`button`),this._overlayIcon.className=`adw-video-overlay-icon osd circular`,this._overlayIcon.type=`button`,this._overlayIcon.setAttribute(`aria-label`,`Play`),this._overlayIcon.title=`Play`,this._overlayIcon.addEventListener(`click`,()=>this._overlayClicked()),this._controlsRevealer=document.createElement(`div`),this._controlsRevealer.className=`adw-video-controls-revealer`,this._wrap(),this._adoptMedia(),this.addEventListener(`pointermove`,this._onPointerMove)}_wrap(){let e=this.querySelector(`:scope > video`),t=[...this.children].filter(t=>t!==e),n=document.createElement(`div`);n.className=`adw-video-surface`,this.replaceChildren(n),e&&n.appendChild(e),n.append(this._overlayIcon),this._controlsRevealer.append(...t),n.append(this._controlsRevealer)}_adoptMedia(){let e=this.querySelector(`:scope > .adw-video-surface > video`)??null;if(e===this._media){this._syncMedia(),this._updateOverlayIcon();return}if(this._media&&this._detachMedia(this._media),this._media=e,this._hasStream=e!==null,e){let onPlay=()=>this._updatePlaying(!0),onPause=()=>this._updatePlaying(!1),onEnded=()=>{this._ended=!0,this._updateOverlayIcon()},onError=()=>{this._error=e.error?.message??`Playback failed`,this._updateOverlayIcon()},onMetadata=()=>{this._ended=!1,this._error=null,this._updateOverlayIcon()},onPrepared=()=>{this.autoplay&&e.play().catch(()=>{})};this.mediaListeners=[[`play`,onPlay],[`pause`,onPause],[`ended`,onEnded],[`error`,onError],[`loadedmetadata`,onMetadata],[`loadeddata`,onPrepared]];for(let[t,n]of this.mediaListeners)e.addEventListener(t,n)}this._syncMedia(),this._updateOverlayIcon()}_detachMedia(e){for(let[t,n]of this.mediaListeners)e.removeEventListener(t,n);this.mediaListeners=[]}_syncMedia(){this._media&&(this._media.loop=this.loop,this._media.autoplay=!1,this.classList.toggle(`graphics-offload`,this.graphicsOffload))}_overlayClicked(){let e=this._media??null;e!==null&&(e.paused?e.play().catch(()=>{}):e.pause())}revealControls(){this._controlsRevealer&&(this._controlsRevealer.classList.add(`revealed`),this._hideTimer!==null&&clearTimeout(this._hideTimer),this._hideTimer=setTimeout(()=>this._hideControls(),3e3))}_hideControls(){this._hideTimer=null,this._controlsRevealer?.classList.remove(`revealed`)}_onPointerMove=()=>{this.revealControls()};attributeChangedCallback(e){this._initialized&&(e===`graphics-offload`&&this._syncMedia(),this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:this._property(e)}})))}_property(e){switch(e){case`autoplay`:return this.autoplay;case`loop`:return this.loop;default:return this.graphicsOffload}}_updatePlaying(e){this._playing=e,this._overlayIcon&&(this._overlayIcon.hidden=e),this.classList.toggle(`playing`,e),this.dispatchEvent(new CustomEvent(`notify::playing`,{bubbles:!0,detail:{playing:e}}))}_updateOverlayIcon(){if(!this._overlayIcon)return;let e,t=null;this._hasStream?this._error===null?e=this._ended?`media-playlist-repeat-symbolic`:`media-playback-start-symbolic`:(e=`dialog-error-symbolic`,t=this._error):e=`media-eject-symbolic`;let n=document.createElement(`gtk-image`);n.setAttribute(`icon-name`,e),this._overlayIcon.replaceChildren(n),t?this._overlayIcon.title=t:this._overlayIcon.title=``,this._overlayIcon.classList.toggle(`error`,this._error!==null)}disconnectedCallback(){this._hideTimer!==null&&clearTimeout(this._hideTimer),this._hideTimer=null}};customElements.define(`gtk-video`,GtkVideo);const to=[`horizontal`,`vertical`];function axisAdjustment(e,t){let n=t===`vertical`,r=n?e.clientHeight:e.clientWidth,i=n?e.scrollHeight:e.scrollWidth;return normalizeAdjustment({value:n?e.scrollTop:e.scrollLeft,lower:0,upper:Math.max(i,r),stepIncrement:r*.1,pageIncrement:r*.9,pageSize:r})}var GtkViewport=class extends WidgetElement{_observer=null;_watch=null;static get observedAttributes(){return[`scroll-to-focus`]}get hadjustment(){return axisAdjustment(this,`horizontal`)}get vadjustment(){return axisAdjustment(this,`vertical`)}get scrollToFocus(){return this.getAttribute(`scroll-to-focus`)!==`false`}set scrollToFocus(e){this.setAttribute(`scroll-to-focus`,e?`true`:`false`)}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}]),this.setAttribute(`role`,`generic`),this.addEventListener(`scroll`,this._announce,{passive:!0}),this._observe(),this._bindFocus()}disconnectedCallback(){this.removeEventListener(`scroll`,this._announce),this.removeEventListener(`focusin`,this._onFocusIn)}_observe(){if(this._observer===null){this._observer=new ResizeObserver(()=>this._announce()),this._observer.observe(this);for(let e of this.children)this._observer.observe(e);this._watch=new MutationObserver(()=>{for(let e of this.children)this._observer?.observe(e);this._announce()}),this._watch.observe(this,{childList:!0})}}attributeChangedCallback(e){this.dispatchEvent(new CustomEvent(`notify::${e}`,{bubbles:!0,detail:{[e]:this.scrollToFocus}})),this.isConnected&&this._bindFocus()}scrollAxis(e,t){let n=axisAdjustment(this,e),r=clampAdjustmentValue(n,t);r!==n.value&&(e===`vertical`?this.scrollTop=r:this.scrollLeft=r,this._announce())}scrollTo(e,t){if(!(e instanceof Element)&&e!==null){Element.prototype.scrollTo.call(this,e,t);return}let n=e;if(n!==null&&n!==this&&typeof n.scrollIntoView==`function`){n.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}),this._announce();return}for(let e of to){let t=axisAdjustment(this,e),n=clampAdjustmentValue(t,t.value);n!==t.value&&(e===`vertical`?this.scrollTop=n:this.scrollLeft=n)}this._announce()}get adjustments(){return{hadjustment:this.hadjustment,vadjustment:this.vadjustment}}_announce=()=>{this.dispatchEvent(new CustomEvent(`value-changed`,{bubbles:!0,detail:this.adjustments}))};_bindFocus(){this.removeEventListener(`focusin`,this._onFocusIn),this.scrollToFocus&&this.addEventListener(`focusin`,this._onFocusIn)}_onFocusIn=e=>{let t=e.target;!(t instanceof Element)||t===this||this.scrollTo(t)}};customElements.define(`gtk-viewport`,GtkViewport);const no={"double-click":{attribute:`double-click-action`,fallback:`toggle-maximize`},"middle-click":{attribute:`middle-click-action`,fallback:`none`},"right-click":{attribute:`right-click-action`,fallback:`menu`}},ro={"toggle-maximize":`window.toggle-maximized`,lower:`window.lower`,minimize:`window.minimize`,menu:`window.menu`},io=new Set([`none`,`toggle-maximize`,`lower`,`minimize`,`menu`]);function gestureOf(e,t){switch(e){case 0:return t>1?`double-click`:null;case 1:return`middle-click`;case 2:return`right-click`;default:return null}}var GtkWindowHandle=class extends WidgetElement{_drag=null;static get observedAttributes(){return[`double-click-action`,`middle-click-action`,`right-click-action`]}actionFor(e){let{attribute:t,fallback:n}=no[e],r=this.getAttribute(t);return r===null?n:r.startsWith(`toggle-maximize`)?`toggle-maximize`:io.has(r)?r:`none`}connectedCallback(){bindSlottedChildren(this,[{name:`child`,into:this}]),this.setAttribute(`role`,`generic`),this.addEventListener(`click`,this._onClick),this.addEventListener(`pointerdown`,this._onPointerDown),this.addEventListener(`pointermove`,this._onPointerMove)}disconnectedCallback(){this.removeEventListener(`click`,this._onClick),this.removeEventListener(`pointerdown`,this._onPointerDown),this.removeEventListener(`pointermove`,this._onPointerMove),this._drag=null}_perform(e,t,n){let r=this.actionFor(e),i=r===`none`?null:ro[r],a={action:r,gesture:e,windowAction:i,x:t,y:n};this.dispatchEvent(new CustomEvent(`titlebar-action`,{bubbles:!0,detail:a})),i!==null&&this.dispatchEvent(new CustomEvent(i,{bubbles:!0,detail:a}))}_onClick=e=>{this._drag=null;let t=gestureOf(e.button,e.detail);t!==null&&this._perform(t,e.clientX,e.clientY)};_onPointerDown=e=>{e.detail>1||(this._drag={pointerId:e.pointerId,x:e.clientX,y:e.clientY})};_onPointerMove=e=>{let t=this._drag;t===null||t.pointerId!==e.pointerId||Math.abs(e.clientX-t.x)+Math.abs(e.clientY-t.y)<=1||(this._drag=null,this.dispatchEvent(new CustomEvent(`window-move`,{bubbles:!0,detail:{x:e.clientX,y:e.clientY}})))}};customElements.define(`gtk-window-handle`,GtkWindowHandle);function extensionsOf(e){return[...e.patterns,...e.suffixes].map(e=>`.${e}`)}function filePickerOptions(e,t){let n=[];for(let t of e.filters){if(t.acceptAll)continue;let e={};for(let n of t.mimeTypes)e[n]=[];let r=extensionsOf(t);r.length>0&&(e[t.mimeTypes[0]??`application/octet-stream`]=r),n.push({description:t.name??``,accept:e})}let r={};return n.length>0&&(r.types=n,r.excludeAcceptAllOption=!e.filters.some(e=>e.acceptAll)),t===`save`&&e.initialName!==null&&(r.suggestedName=e.initialName),r}function inputAccept(e){if(!e||e.acceptAll)return null;let t=[...extensionsOf(e),...e.mimeTypes];return t.length>0?t.join(`,`):null}function writeInWorker(e,t){let n=URL.createObjectURL(new Blob([`onmessage = async (event) => {
|