@primer/view-components 0.0.0-pre.2715c38
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/LICENSE.txt +21 -0
- package/README.md +17 -0
- package/app/assets/javascripts/primer_view_components.js +2 -0
- package/app/assets/javascripts/primer_view_components.js.map +1 -0
- package/app/assets/styles/primer_view_components.css +1 -0
- package/app/assets/styles/primer_view_components.css.map +1 -0
- package/app/components/primer/alpha/modal-dialog-element.d.ts +18 -0
- package/app/components/primer/alpha/modal-dialog-element.js +142 -0
- package/app/components/primer/alpha/toggle-switch-element.d.ts +28 -0
- package/app/components/primer/alpha/toggle-switch-element.js +137 -0
- package/app/components/primer/alpha/tool-tip-element.d.ts +25 -0
- package/app/components/primer/alpha/tool-tip-element.js +366 -0
- package/app/components/primer/beta/auto_complete/auto_complete.d.ts +1 -0
- package/app/components/primer/beta/auto_complete/auto_complete.js +1 -0
- package/app/components/primer/clipboard_copy_component.d.ts +1 -0
- package/app/components/primer/clipboard_copy_component.js +43 -0
- package/app/components/primer/dropdown/menu.d.ts +1 -0
- package/app/components/primer/dropdown/menu.js +1 -0
- package/app/components/primer/dropdown.d.ts +1 -0
- package/app/components/primer/dropdown.js +1 -0
- package/app/components/primer/experimental/action-bar-menu-element.d.ts +31 -0
- package/app/components/primer/experimental/action-bar-menu-element.js +334 -0
- package/app/components/primer/experimental/action_bar.d.ts +14 -0
- package/app/components/primer/experimental/action_bar.js +139 -0
- package/app/components/primer/image_crop.d.ts +1 -0
- package/app/components/primer/image_crop.js +1 -0
- package/app/components/primer/local_time.d.ts +1 -0
- package/app/components/primer/local_time.js +1 -0
- package/app/components/primer/primer.d.ts +12 -0
- package/app/components/primer/primer.js +12 -0
- package/app/components/primer/tab_container_component.d.ts +1 -0
- package/app/components/primer/tab_container_component.js +1 -0
- package/app/components/primer/time_ago_component.d.ts +1 -0
- package/app/components/primer/time_ago_component.js +1 -0
- package/package.json +81 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 GitHub
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img width="300px" alt="Primer ViewComponents Logo" src="/static/assets/view-components.svg">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Primer ViewComponents</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">ViewComponents for the Primer Design System.</p>
|
|
8
|
+
|
|
9
|
+
_Note: This library is under active pre-1.0 development. Breaking changes are likely in patch releases._
|
|
10
|
+
|
|
11
|
+
## Documentation
|
|
12
|
+
|
|
13
|
+
Visit [https://primer.style/view-components/](https://primer.style/view-components/) to view documentation.
|
|
14
|
+
|
|
15
|
+
## License
|
|
16
|
+
|
|
17
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const t=!!navigator.userAgent.match(/Macintosh/);class e{constructor(e,n){this.input=e,this.list=n,this.isComposing=!1,n.id||(n.id=`combobox-${Math.random().toString().slice(2,6)}`),this.keyboardEventHandler=e=>function(e,n){if(e.shiftKey||e.metaKey||e.altKey)return;if(!t&&e.ctrlKey)return;if(n.isComposing)return;switch(e.key){case"Enter":case"Tab":(function(t,e){const n=e.querySelector('[aria-selected="true"]');return!!n&&("true"===n.getAttribute("aria-disabled")||n.click(),!0)})(n.input,n.list)&&e.preventDefault();break;case"Escape":n.clearSelection();break;case"ArrowDown":n.navigate(1),e.preventDefault();break;case"ArrowUp":n.navigate(-1),e.preventDefault();break;case"n":t&&e.ctrlKey&&(n.navigate(1),e.preventDefault());break;case"p":t&&e.ctrlKey&&(n.navigate(-1),e.preventDefault());break;default:if(e.ctrlKey)break;n.clearSelection()}}(e,this),this.compositionEventHandler=t=>function(t,e){e.isComposing="compositionstart"===t.type;if(!document.getElementById(e.input.getAttribute("aria-controls")||""))return;e.clearSelection()}(t,this),this.inputHandler=this.clearSelection.bind(this),e.setAttribute("role","combobox"),e.setAttribute("aria-controls",n.id),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("aria-haspopup","listbox")}destroy(){this.clearSelection(),this.stop(),this.input.removeAttribute("role"),this.input.removeAttribute("aria-controls"),this.input.removeAttribute("aria-expanded"),this.input.removeAttribute("aria-autocomplete"),this.input.removeAttribute("aria-haspopup")}start(){this.input.setAttribute("aria-expanded","true"),this.input.addEventListener("compositionstart",this.compositionEventHandler),this.input.addEventListener("compositionend",this.compositionEventHandler),this.input.addEventListener("input",this.inputHandler),this.input.addEventListener("keydown",this.keyboardEventHandler),this.list.addEventListener("click",n)}stop(){this.clearSelection(),this.input.setAttribute("aria-expanded","false"),this.input.removeEventListener("compositionstart",this.compositionEventHandler),this.input.removeEventListener("compositionend",this.compositionEventHandler),this.input.removeEventListener("input",this.inputHandler),this.input.removeEventListener("keydown",this.keyboardEventHandler),this.list.removeEventListener("click",n)}navigate(t=1){const e=Array.from(this.list.querySelectorAll('[aria-selected="true"]')).filter(i)[0],n=Array.from(this.list.querySelectorAll('[role="option"]')).filter(i),s=n.indexOf(e);if(s===n.length-1&&1===t||0===s&&-1===t)return this.clearSelection(),void this.input.focus();let r=1===t?0:n.length-1;if(e&&s>=0){const e=s+t;e>=0&&e<n.length&&(r=e)}const a=n[r];if(a)for(const t of n)a===t?(this.input.setAttribute("aria-activedescendant",a.id),a.setAttribute("aria-selected","true"),o(this.list,a)):t.setAttribute("aria-selected","false")}clearSelection(){this.input.removeAttribute("aria-activedescendant");for(const t of this.list.querySelectorAll('[aria-selected="true"]'))t.setAttribute("aria-selected","false")}}function n(t){if(!(t.target instanceof Element))return;const e=t.target.closest('[role="option"]');e&&"true"!==e.getAttribute("aria-disabled")&&function(t){t.dispatchEvent(new CustomEvent("combobox-commit",{bubbles:!0}))}(e)}function i(t){return!t.hidden&&!(t instanceof HTMLInputElement&&"hidden"===t.type)&&(t.offsetWidth>0||t.offsetHeight>0)}function o(t,e){(function(t,e){const n=t.scrollTop,i=n+t.clientHeight,o=e.offsetTop,s=o+e.clientHeight;return o>=n&&s<=i})(t,e)||(t.scrollTop=e.offsetTop)}const s=window.testScreenReaderDelay||100;class r{constructor(t,n,i,o=!1){var s;if(this.container=t,this.input=n,this.results=i,this.combobox=new e(n,i),this.feedback=document.getElementById(`${this.results.id}-feedback`),this.autoselectEnabled=o,this.clearButton=document.getElementById(`${this.input.id||this.input.name}-clear`),this.clientOptions=i.querySelectorAll("[role=option]"),this.feedback&&(this.feedback.setAttribute("aria-live","polite"),this.feedback.setAttribute("aria-atomic","true")),this.clearButton&&!this.clearButton.getAttribute("aria-label")){const t=document.querySelector(`label[for="${this.input.name}"]`);this.clearButton.setAttribute("aria-label","clear:"),this.clearButton.setAttribute("aria-labelledby",`${this.clearButton.id} ${(null==t?void 0:t.id)||""}`)}this.input.getAttribute("aria-expanded")||this.input.setAttribute("aria-expanded","false"),this.results.hidden=!0,this.results.setAttribute("aria-label","results"),this.input.setAttribute("autocomplete","off"),this.input.setAttribute("spellcheck","false"),this.interactingWithList=!1,this.onInputChange=function(t,e=0){let n;return function(...i){clearTimeout(n),n=window.setTimeout((()=>{clearTimeout(n),t(...i)}),e)}}(this.onInputChange.bind(this),300),this.onResultsMouseDown=this.onResultsMouseDown.bind(this),this.onInputBlur=this.onInputBlur.bind(this),this.onInputFocus=this.onInputFocus.bind(this),this.onKeydown=this.onKeydown.bind(this),this.onCommit=this.onCommit.bind(this),this.handleClear=this.handleClear.bind(this),this.input.addEventListener("keydown",this.onKeydown),this.input.addEventListener("focus",this.onInputFocus),this.input.addEventListener("blur",this.onInputBlur),this.input.addEventListener("input",this.onInputChange),this.results.addEventListener("mousedown",this.onResultsMouseDown),this.results.addEventListener("combobox-commit",this.onCommit),null===(s=this.clearButton)||void 0===s||s.addEventListener("click",this.handleClear)}destroy(){this.input.removeEventListener("keydown",this.onKeydown),this.input.removeEventListener("focus",this.onInputFocus),this.input.removeEventListener("blur",this.onInputBlur),this.input.removeEventListener("input",this.onInputChange),this.results.removeEventListener("mousedown",this.onResultsMouseDown),this.results.removeEventListener("combobox-commit",this.onCommit)}handleClear(t){t.preventDefault(),"true"===this.input.getAttribute("aria-expanded")&&(this.input.setAttribute("aria-expanded","false"),this.updateFeedbackForScreenReaders("Results hidden.")),this.input.value="",this.container.value="",this.input.focus(),this.input.dispatchEvent(new Event("change")),this.container.open=!1}onKeydown(t){if("Enter"===t.key&&this.container.open&&this.autoselectEnabled){const e=this.results.children[0];e&&(t.stopPropagation(),t.preventDefault(),this.onCommit({target:e}))}if("Escape"===t.key&&this.container.open)this.container.open=!1,t.stopPropagation(),t.preventDefault();else if(t.altKey&&"ArrowUp"===t.key&&this.container.open)this.container.open=!1,t.stopPropagation(),t.preventDefault();else if(t.altKey&&"ArrowDown"===t.key&&!this.container.open){if(!this.input.value.trim())return;this.container.open=!0,t.stopPropagation(),t.preventDefault()}}onInputFocus(){this.fetchResults()}onInputBlur(){this.interactingWithList?this.interactingWithList=!1:this.container.open=!1}onCommit({target:t}){const e=t;if(!(e instanceof HTMLElement))return;if(this.container.open=!1,e instanceof HTMLAnchorElement)return;const n=e.getAttribute("data-autocomplete-value")||e.textContent;this.updateFeedbackForScreenReaders(`${e.textContent||""} selected.`),this.container.value=n,n||this.updateFeedbackForScreenReaders("Results hidden.")}onResultsMouseDown(){this.interactingWithList=!0}onInputChange(){this.feedback&&this.feedback.textContent&&(this.feedback.textContent=""),this.container.removeAttribute("value"),this.fetchResults()}identifyOptions(){let t=0;for(const e of this.results.querySelectorAll('[role="option"]:not([id])'))e.id=`${this.results.id}-option-${t++}`}updateFeedbackForScreenReaders(t){setTimeout((()=>{this.feedback&&(this.feedback.textContent=t)}),s)}fetchResults(){const t=this.input.value.trim();if(!t)return void(this.container.open=!1);const e=this.container.src;if(!e)return;const n=new URL(e,window.location.href),i=new URLSearchParams(n.search.slice(1));i.append("q",t),n.search=i.toString(),this.container.dispatchEvent(new CustomEvent("loadstart")),this.container.fetchResult(this.input,n.toString()).then((t=>{this.results.innerHTML=t,this.identifyOptions();const e=this.results.querySelectorAll('[role="option"]'),n=!!e.length,i=e.length,[o]=e,s=null==o?void 0:o.textContent;this.autoselectEnabled&&s?this.updateFeedbackForScreenReaders(`${i} results. ${s} is the top result: Press Enter to activate.`):this.updateFeedbackForScreenReaders(`${i||"No"} results.`),this.container.open=n,this.container.dispatchEvent(new CustomEvent("load")),this.container.dispatchEvent(new CustomEvent("loadend"))})).catch((()=>{this.container.dispatchEvent(new CustomEvent("error")),this.container.dispatchEvent(new CustomEvent("loadend"))}))}open(){this.results.hidden&&(this.combobox.start(),this.results.hidden=!1)}close(){this.results.hidden||(this.combobox.stop(),this.results.hidden=!0)}}class a extends CustomEvent{constructor(t,e){super(t,e),this.relatedTarget=e.relatedTarget}}const c=new WeakMap;function l(t,e){const n=new XMLHttpRequest;return n.open("GET",e,!0),n.setRequestHeader("Accept","text/fragment+html"),function(t,e){const n=c.get(t);n&&n.abort();c.set(t,e);const i=()=>c.delete(t),o=function(t){return new Promise(((e,n)=>{t.onload=function(){t.status>=200&&t.status<300?e(t.responseText):n(new Error(t.responseText))},t.onerror=n,t.send()}))}(e);return o.then(i,i),o}(t,n)}const u=new WeakMap;class AutocompleteElement extends HTMLElement{constructor(){super(...arguments),this.fetchResult=l}connectedCallback(){const t=this.getAttribute("for");if(!t)return;const e=this.querySelector("input"),n=document.getElementById(t);if(!(e instanceof HTMLInputElement&&n))return;const i="true"===this.getAttribute("data-autoselect");u.set(this,new r(this,e,n,i)),n.setAttribute("role","listbox")}disconnectedCallback(){const t=u.get(this);t&&(t.destroy(),u.delete(this))}get src(){return this.getAttribute("src")||""}set src(t){this.setAttribute("src",t)}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t)}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.removeAttribute("open")}static get observedAttributes(){return["open","value"]}attributeChangedCallback(t,e,n){if(e===n)return;const i=u.get(this);if(i)switch(t){case"open":null===n?i.close():i.open();break;case"value":null!==n&&(i.input.value=n),this.dispatchEvent(new a("auto-complete-change",{bubbles:!0,relatedTarget:i.input}))}}}function d(t){if("clipboard"in navigator)return navigator.clipboard.writeText(t.textContent);const e=getSelection();if(null==e)return Promise.reject(new Error);e.removeAllRanges();const n=document.createRange();return n.selectNodeContents(t),e.addRange(n),document.execCommand("copy"),e.removeAllRanges(),Promise.resolve()}function h(t){if("clipboard"in navigator)return navigator.clipboard.writeText(t);const e=document.body;if(!e)return Promise.reject(new Error);const n=function(t){const e=document.createElement("pre");return e.style.width="1px",e.style.height="1px",e.style.position="fixed",e.style.top="5px",e.textContent=t,e}(t);return e.appendChild(n),d(n),e.removeChild(n),Promise.resolve()}function f(t){const e=t.getAttribute("for"),n=t.getAttribute("value");function i(){t.dispatchEvent(new CustomEvent("clipboard-copy",{bubbles:!0}))}if(n)h(n).then(i);else if(e){const n="getRootNode"in Element.prototype?t.getRootNode():t.ownerDocument;if(!(n instanceof Document||"ShadowRoot"in window&&n instanceof ShadowRoot))return;const s=n.getElementById(e);s&&(o=s,o instanceof HTMLInputElement||o instanceof HTMLTextAreaElement?h(o.value):o instanceof HTMLAnchorElement&&o.hasAttribute("href")?h(o.href):d(o)).then(i)}var o}function m(t){const e=t.currentTarget;e instanceof HTMLElement&&f(e)}function p(t){if(" "===t.key||"Enter"===t.key){const e=t.currentTarget;e instanceof HTMLElement&&(t.preventDefault(),f(e))}}function g(t){t.currentTarget.addEventListener("keydown",p)}function b(t){t.currentTarget.removeEventListener("keydown",p)}window.customElements.get("auto-complete")||(window.AutocompleteElement=AutocompleteElement,window.customElements.define("auto-complete",AutocompleteElement));class ClipboardCopyElement extends HTMLElement{constructor(){super(),this.addEventListener("click",m),this.addEventListener("focus",g),this.addEventListener("blur",b)}connectedCallback(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("role")||this.setAttribute("role","button")}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t)}}window.customElements.get("clipboard-copy")||(window.ClipboardCopyElement=ClipboardCopyElement,window.customElements.define("clipboard-copy",ClipboardCopyElement));function w(t){t.style.display="inline-block"}function v(t){t.style.display="none"}const y=new WeakMap;function E(t){return Array.from(t.querySelectorAll('[role="tablist"] [role="tab"]')).filter((e=>e instanceof HTMLElement&&e.closest(t.tagName)===t))}document.addEventListener("clipboard-copy",(function({target:t}){if(!(t instanceof HTMLElement))return;if(!t.hasAttribute("data-view-component"))return;const e=y.get(t);e?(clearTimeout(e),y.delete(t)):function(t){const[e,n]=t.querySelectorAll(".octicon");e&&n&&(v(e),w(n))}(t),y.set(t,setTimeout((()=>{!function(t){const[e,n]=t.querySelectorAll(".octicon");e&&n&&(w(e),v(n))}(t),y.delete(t)}),2e3))}));class TabContainerElement extends HTMLElement{constructor(){super(),this.addEventListener("keydown",(t=>{const e=t.target;if(!(e instanceof HTMLElement))return;if(e.closest(this.tagName)!==this)return;if("tab"!==e.getAttribute("role")&&!e.closest('[role="tablist"]'))return;const n=E(this),i=n.indexOf(n.find((t=>t.matches('[aria-selected="true"]'))));if("ArrowRight"===t.code){let t=i+1;t>=n.length&&(t=0),A(this,t)}else if("ArrowLeft"===t.code){let t=i-1;t<0&&(t=n.length-1),A(this,t)}else"Home"===t.code?(A(this,0),t.preventDefault()):"End"===t.code&&(A(this,n.length-1),t.preventDefault())})),this.addEventListener("click",(t=>{const e=E(this);if(!(t.target instanceof Element))return;if(t.target.closest(this.tagName)!==this)return;const n=t.target.closest('[role="tab"]');if(!(n instanceof HTMLElement&&n.closest('[role="tablist"]')))return;A(this,e.indexOf(n))}))}connectedCallback(){for(const t of E(this))t.hasAttribute("aria-selected")||t.setAttribute("aria-selected","false"),t.hasAttribute("tabindex")||("true"===t.getAttribute("aria-selected")?t.setAttribute("tabindex","0"):t.setAttribute("tabindex","-1"))}}function A(t,e){const n=E(t),i=Array.from(t.querySelectorAll('[role="tabpanel"]')).filter((e=>e.closest(t.tagName)===t)),o=n[e],s=i[e];if(!!t.dispatchEvent(new CustomEvent("tab-container-change",{bubbles:!0,cancelable:!0,detail:{relatedTarget:s}}))){for(const t of n)t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","-1");for(const t of i)t.hidden=!0,t.hasAttribute("tabindex")||t.hasAttribute("data-tab-container-no-tabstop")||t.setAttribute("tabindex","0");o.setAttribute("aria-selected","true"),o.setAttribute("tabindex","0"),o.focus(),s.hidden=!1,t.dispatchEvent(new CustomEvent("tab-container-changed",{bubbles:!0,detail:{relatedTarget:s}}))}}window.customElements.get("tab-container")||(window.TabContainerElement=TabContainerElement,window.customElements.define("tab-container",TabContainerElement));const T=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],k=["January","February","March","April","May","June","July","August","September","October","November","December"];function L(t){return`0${t}`.slice(-2)}function M(t,e){const n=t.getDay(),i=t.getDate(),o=t.getMonth(),s=t.getFullYear(),r=t.getHours(),a=t.getMinutes(),c=t.getSeconds();return e.replace(/%([%aAbBcdeHIlmMpPSwyYZz])/g,(function(e){let l;switch(e[1]){case"%":return"%";case"a":return T[n].slice(0,3);case"A":return T[n];case"b":return k[o].slice(0,3);case"B":return k[o];case"c":return t.toString();case"d":return L(i);case"e":return String(i);case"H":return L(r);case"I":return L(M(t,"%l"));case"l":return String(0===r||12===r?12:(r+12)%12);case"m":return L(o+1);case"M":return L(a);case"p":return r>11?"PM":"AM";case"P":return r>11?"pm":"am";case"S":return L(c);case"w":return String(n);case"y":return L(s%100);case"Y":return String(s);case"Z":return l=t.toString().match(/\((\w+)\)$/),l?l[1]:"";case"z":return l=t.toString().match(/\w([+-]\d\d\d\d) /),l?l[1]:""}return""}))}function x(t){let e;return function(){if(e)return e;if("Intl"in window)try{return e=new Intl.DateTimeFormat(void 0,t),e}catch(t){if(!(t instanceof RangeError))throw t}}}let C=null;const S=x({day:"numeric",month:"short"});function H(){if(null!==C)return C;const t=S();if(t){const e=t.format(new Date(0));return C=!!e.match(/^\d/),C}return!1}let D=null;const I=x({day:"numeric",month:"short",year:"numeric"});function F(t){const e=t.closest("[lang]");return e instanceof HTMLElement&&e.lang?e.lang:"default"}const O=new WeakMap;class ExtendedTimeElement extends HTMLElement{static get observedAttributes(){return["datetime","day","format","lang","hour","minute","month","second","title","weekday","year","time-zone-name"]}connectedCallback(){const t=this.getFormattedTitle();t&&!this.hasAttribute("title")&&this.setAttribute("title",t);const e=this.getFormattedDate();e&&(this.textContent=e)}attributeChangedCallback(t,e,n){const i=this.getFormattedTitle();if("datetime"===t){const t=Date.parse(n);isNaN(t)?O.delete(this):O.set(this,new Date(t))}const o=this.getFormattedTitle(),s=this.getAttribute("title");"title"===t||!o||s&&s!==i||this.setAttribute("title",o);const r=this.getFormattedDate();r&&(this.textContent=r)}get date(){return O.get(this)}getFormattedTitle(){const t=this.date;if(!t)return;const e=R();if(e)return e.format(t);try{return t.toLocaleString()}catch(e){if(e instanceof RangeError)return t.toString();throw e}}getFormattedDate(){}}const R=x({day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}),$=new WeakMap;class LocalTimeElement extends ExtendedTimeElement{attributeChangedCallback(t,e,n){"hour"!==t&&"minute"!==t&&"second"!==t&&"time-zone-name"!==t||$.delete(this),super.attributeChangedCallback(t,e,n)}getFormattedDate(){const t=this.date;if(!t)return;return`${function(t,e){const n={weekday:{short:"%a",long:"%A"},day:{numeric:"%e","2-digit":"%d"},month:{short:"%b",long:"%B"},year:{numeric:"%Y","2-digit":"%y"}};let i=H()?"weekday day month year":"weekday month day, year";for(const e in n){const o=n[e][t.getAttribute(e)||""];i=i.replace(e,o||"")}return i=i.replace(/(\s,)|(,\s$)/,""),M(e,i).replace(/\s+/," ").trim()}(this,t)||""} ${function(t,e){const n={},i=t.getAttribute("hour");"numeric"!==i&&"2-digit"!==i||(n.hour=i);const o=t.getAttribute("minute");"numeric"!==o&&"2-digit"!==o||(n.minute=o);const s=t.getAttribute("second");"numeric"!==s&&"2-digit"!==s||(n.second=s);const r=t.getAttribute("time-zone-name");"short"!==r&&"long"!==r||(n.timeZoneName=r);if(0===Object.keys(n).length)return;let a=$.get(t);a||(a=x(n),$.set(t,a));const c=a();if(c)return c.format(e);return M(e,n.second?"%H:%M:%S":"%H:%M")}(this,t)||""}`.trim()}}window.customElements.get("local-time")||(window.LocalTimeElement=LocalTimeElement,window.customElements.define("local-time",LocalTimeElement));class W{constructor(t,e){this.date=t,this.locale=e}toString(){const t=this.timeElapsed();if(t)return t;{const t=this.timeAhead();return t||`on ${this.formatDate()}`}}timeElapsed(){const t=(new Date).getTime()-this.date.getTime(),e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),o=Math.round(i/24);return t>=0&&o<30?this.timeAgoFromMs(t):null}timeAhead(){const t=this.date.getTime()-(new Date).getTime(),e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),o=Math.round(i/24);return t>=0&&o<30?this.timeUntil():null}timeAgo(){const t=(new Date).getTime()-this.date.getTime();return this.timeAgoFromMs(t)}timeAgoFromMs(t){const e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),o=Math.round(i/24),s=Math.round(o/30),r=Math.round(s/12);return t<0||e<10?P(this.locale,0,"second"):e<45?P(this.locale,-e,"second"):e<90||n<45?P(this.locale,-n,"minute"):n<90||i<24?P(this.locale,-i,"hour"):i<36||o<30?P(this.locale,-o,"day"):s<18?P(this.locale,-s,"month"):P(this.locale,-r,"year")}microTimeAgo(){const t=(new Date).getTime()-this.date.getTime(),e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),o=Math.round(i/24),s=Math.round(o/30),r=Math.round(s/12);return n<1?"1m":n<60?`${n}m`:i<24?`${i}h`:o<365?`${o}d`:`${r}y`}timeUntil(){const t=this.date.getTime()-(new Date).getTime();return this.timeUntilFromMs(t)}timeUntilFromMs(t){const e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),o=Math.round(i/24),s=Math.round(o/30),r=Math.round(s/12);return s>=18||s>=12?P(this.locale,r,"year"):o>=45||o>=30?P(this.locale,s,"month"):i>=36||i>=24?P(this.locale,o,"day"):n>=90||n>=45?P(this.locale,i,"hour"):e>=90||e>=45?P(this.locale,n,"minute"):P(this.locale,e>=10?e:0,"second")}microTimeUntil(){const t=this.date.getTime()-(new Date).getTime(),e=Math.round(t/1e3),n=Math.round(e/60),i=Math.round(n/60),o=Math.round(i/24),s=Math.round(o/30),r=Math.round(s/12);return o>=365?`${r}y`:i>=24?`${o}d`:n>=60?`${i}h`:n>1?`${n}m`:"1m"}formatDate(){let t=H()?"%e %b":"%b %e";var e;return e=this.date,(new Date).getUTCFullYear()!==e.getUTCFullYear()&&(t+=function(){if(null!==D)return D;const t=I();if(t){const e=t.format(new Date(0));return D=!!e.match(/\d,/),D}return!0}()?", %Y":" %Y"),M(this.date,t)}formatTime(){const t=N();return t?t.format(this.date):M(this.date,"%l:%M%P")}}function P(t,e,n){const i=function(t,e){if("Intl"in window&&"RelativeTimeFormat"in window.Intl)try{return new Intl.RelativeTimeFormat(t,e)}catch(t){if(!(t instanceof RangeError))throw t}}(t,{numeric:"auto"});return i?i.format(e,n):function(t,e){if(0===t)switch(e){case"year":case"quarter":case"month":case"week":return`this ${e}`;case"day":return"today";case"hour":case"minute":return`in 0 ${e}s`;case"second":return"now"}else if(1===t)switch(e){case"year":case"quarter":case"month":case"week":return`next ${e}`;case"day":return"tomorrow";case"hour":case"minute":case"second":return`in 1 ${e}`}else if(-1===t)switch(e){case"year":case"quarter":case"month":case"week":return`last ${e}`;case"day":return"yesterday";case"hour":case"minute":case"second":return`1 ${e} ago`}else if(t>1)switch(e){case"year":case"quarter":case"month":case"week":case"day":case"hour":case"minute":case"second":return`in ${t} ${e}s`}else if(t<-1)switch(e){case"year":case"quarter":case"month":case"week":case"day":case"hour":case"minute":case"second":return`${-t} ${e}s ago`}throw new RangeError(`Invalid unit argument for format() '${e}'`)}(e,n)}const N=x({hour:"numeric",minute:"2-digit"});class RelativeTimeElement extends ExtendedTimeElement{getFormattedDate(){const t=this.date;if(t)return new W(t,F(this)).toString()}connectedCallback(){q.push(this),B||(K(),B=window.setInterval(K,6e4)),super.connectedCallback()}disconnectedCallback(){const t=q.indexOf(this);-1!==t&&q.splice(t,1),q.length||B&&(clearInterval(B),B=null)}}const q=[];let B;function K(){let t,e,n;for(e=0,n=q.length;e<n;e++)t=q[e],t.textContent=t.getFormattedDate()||""}window.customElements.get("relative-time")||(window.RelativeTimeElement=RelativeTimeElement,window.customElements.define("relative-time",RelativeTimeElement));class TimeAgoElement extends RelativeTimeElement{getFormattedDate(){const t=this.getAttribute("format"),e=this.date;if(e)return"micro"===t?new W(e,F(this)).microTimeAgo():new W(e,F(this)).timeAgo()}}window.customElements.get("time-ago")||(window.TimeAgoElement=TimeAgoElement,window.customElements.define("time-ago",TimeAgoElement));class TimeUntilElement extends RelativeTimeElement{getFormattedDate(){const t=this.getAttribute("format"),e=this.date;if(e)return"micro"===t?new W(e,F(this)).microTimeUntil():new W(e,F(this)).timeUntil()}}window.customElements.get("time-until")||(window.TimeUntilElement=TimeUntilElement,window.customElements.define("time-until",TimeUntilElement));const U=new WeakMap,Y=new WeakMap,z=new WeakMap;function j(t){const e=t.currentTarget;if(!(e instanceof ImageCropElement))return;const{box:n,image:i}=z.get(e)||{};if(!n||!i)return;let o=0,s=0;if(t instanceof KeyboardEvent)"ArrowUp"===t.key?s=-1:"ArrowDown"===t.key?s=1:"ArrowLeft"===t.key?o=-1:"ArrowRight"===t.key&&(o=1);else if(Y.has(e)&&t instanceof MouseEvent){const n=Y.get(e);o=t.pageX-n.dragStartX,s=t.pageY-n.dragStartY}else if(Y.has(e)&&t instanceof TouchEvent){const{pageX:n,pageY:i}=t.changedTouches[0],{dragStartX:r,dragStartY:a}=Y.get(e);o=n-r,s=i-a}if(0!==o||0!==s){const t=Math.min(Math.max(0,n.offsetLeft+o),i.width-n.offsetWidth),r=Math.min(Math.max(0,n.offsetTop+s),i.height-n.offsetHeight);n.style.left=`${t}px`,n.style.top=`${r}px`,Q(e,{x:t,y:r,width:n.offsetWidth,height:n.offsetHeight})}if(t instanceof MouseEvent)Y.set(e,{dragStartX:t.pageX,dragStartY:t.pageY});else if(t instanceof TouchEvent){const{pageX:n,pageY:i}=t.changedTouches[0];Y.set(e,{dragStartX:n,dragStartY:i})}}function X(t){const e=t.target;if(!(e instanceof HTMLElement))return;const n=V(e);if(!(n instanceof ImageCropElement))return;const{box:i}=z.get(n)||{};if(!i)return;const o=n.getBoundingClientRect();let s,r,a;if(t instanceof KeyboardEvent){if("Escape"===t.key)return Z(n);if("-"===t.key&&(a=-10),"="===t.key&&(a=10),!a)return;s=i.offsetWidth+a,r=i.offsetHeight+a,U.set(n,{startX:i.offsetLeft,startY:i.offsetTop})}else if(t instanceof MouseEvent){const e=U.get(n);if(!e)return;s=t.pageX-e.startX-o.left-window.pageXOffset,r=t.pageY-e.startY-o.top-window.pageYOffset}else if(t instanceof TouchEvent){const e=U.get(n);if(!e)return;s=t.changedTouches[0].pageX-e.startX-o.left-window.pageXOffset,r=t.changedTouches[0].pageY-e.startY-o.top-window.pageYOffset}s&&r&&J(n,s,r,!(t instanceof KeyboardEvent))}function V(t){const e=t.getRootNode();return e instanceof ShadowRoot?e.host:t}function _(t){const e=t.currentTarget;if(!(e instanceof HTMLElement))return;const n=V(e);if(!(n instanceof ImageCropElement))return;const{box:i}=z.get(n)||{};if(!i)return;const o=t.target;if(o instanceof HTMLElement)if(o.hasAttribute("data-direction")){const e=o.getAttribute("data-direction")||"";n.addEventListener("mousemove",X),n.addEventListener("touchmove",X,{passive:!0}),["nw","se"].indexOf(e)>=0&&n.classList.add("nwse"),["ne","sw"].indexOf(e)>=0&&n.classList.add("nesw"),U.set(n,{startX:i.offsetLeft+(["se","ne"].indexOf(e)>=0?0:i.offsetWidth),startY:i.offsetTop+(["se","sw"].indexOf(e)>=0?0:i.offsetHeight)}),X(t)}else n.addEventListener("mousemove",j),n.addEventListener("touchmove",j,{passive:!0})}function J(t,e,n,i=!0){let o=Math.max(Math.abs(e),Math.abs(n),10);const s=U.get(t);if(!s)return;const{box:r,image:a}=z.get(t)||{};if(!r||!a)return;o=Math.min(o,n>0?a.height-s.startY:s.startY,e>0?a.width-s.startX:s.startX);const c=i?Math.round(Math.max(0,e>0?s.startX:s.startX-o)):r.offsetLeft,l=i?Math.round(Math.max(0,n>0?s.startY:s.startY-o)):r.offsetTop;r.style.left=`${c}px`,r.style.top=`${l}px`,r.style.width=`${o}px`,r.style.height=`${o}px`,Q(t,{x:c,y:l,width:o,height:o})}function Z(t){const{image:e}=z.get(t)||{};if(!e)return;const n=Math.round(e.clientWidth>e.clientHeight?e.clientHeight:e.clientWidth);U.set(t,{startX:(e.clientWidth-n)/2,startY:(e.clientHeight-n)/2}),J(t,n,n)}function G(t){const e=t.currentTarget;e instanceof ImageCropElement&&(Y.delete(e),e.classList.remove("nwse","nesw"),e.removeEventListener("mousemove",X),e.removeEventListener("mousemove",j),e.removeEventListener("touchmove",X),e.removeEventListener("touchmove",j))}function Q(t,e){const{image:n}=z.get(t)||{};if(!n)return;const i=n.naturalWidth/n.width;for(const n in e){const o=Math.round(e[n]*i);e[n]=o;const s=t.querySelector(`[data-image-crop-input='${n}']`);s instanceof HTMLInputElement&&(s.value=o.toString())}t.dispatchEvent(new CustomEvent("image-crop-change",{bubbles:!0,detail:e}))}class ImageCropElement extends HTMLElement{connectedCallback(){if(z.has(this))return;const t=this.attachShadow({mode:"open"});t.innerHTML='\n<style>\n :host { touch-action: none; display: block; }\n :host(.nesw) { cursor: nesw-resize; }\n :host(.nwse) { cursor: nwse-resize; }\n :host(.nesw) .crop-box, :host(.nwse) .crop-box { cursor: inherit; }\n :host([loaded]) .crop-image { display: block; }\n :host([loaded]) ::slotted([data-loading-slot]), .crop-image { display: none; }\n\n .crop-wrapper {\n position: relative;\n font-size: 0;\n }\n .crop-container {\n user-select: none;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n position: absolute;\n overflow: hidden;\n z-index: 1;\n top: 0;\n width: 100%;\n height: 100%;\n }\n\n :host([rounded]) .crop-box {\n border-radius: 50%;\n box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.3);\n }\n .crop-box {\n position: absolute;\n border: 1px dashed #fff;\n box-sizing: border-box;\n cursor: move;\n }\n\n :host([rounded]) .crop-outline {\n outline: none;\n }\n .crop-outline {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n outline: 4000px solid rgba(0, 0, 0, .3);\n }\n\n .handle { position: absolute; }\n :host([rounded]) .handle::before { border-radius: 50%; }\n .handle:before {\n position: absolute;\n display: block;\n padding: 4px;\n transform: translate(-50%, -50%);\n content: \' \';\n background: #fff;\n border: 1px solid #767676;\n }\n .ne { top: 0; right: 0; cursor: nesw-resize; }\n .nw { top: 0; left: 0; cursor: nwse-resize; }\n .se { bottom: 0; right: 0; cursor: nwse-resize; }\n .sw { bottom: 0; left: 0; cursor: nesw-resize; }\n</style>\n<slot></slot>\n<div class="crop-wrapper">\n <img width="100%" class="crop-image" alt="">\n <div class="crop-container">\n <div data-crop-box class="crop-box">\n <div class="crop-outline"></div>\n <div data-direction="nw" class="handle nw"></div>\n <div data-direction="ne" class="handle ne"></div>\n <div data-direction="sw" class="handle sw"></div>\n <div data-direction="se" class="handle se"></div>\n </div>\n </div>\n</div>\n';const e=t.querySelector("[data-crop-box]");if(!(e instanceof HTMLElement))return;const n=t.querySelector("img");n instanceof HTMLImageElement&&(z.set(this,{box:e,image:n}),n.addEventListener("load",(()=>{this.loaded=!0,Z(this)})),this.addEventListener("mouseleave",G),this.addEventListener("touchend",G),this.addEventListener("mouseup",G),e.addEventListener("mousedown",_),e.addEventListener("touchstart",_,{passive:!0}),this.addEventListener("keydown",j),this.addEventListener("keydown",X),this.src&&(n.src=this.src))}static get observedAttributes(){return["src"]}get src(){return this.getAttribute("src")}set src(t){t?this.setAttribute("src",t):this.removeAttribute("src")}get loaded(){return this.hasAttribute("loaded")}set loaded(t){t?this.setAttribute("loaded",""):this.removeAttribute("loaded")}attributeChangedCallback(t,e,n){const{image:i}=z.get(this)||{};"src"===t&&(this.loaded=!1,i&&(i.src=n))}}window.customElements.get("image-crop")||(window.ImageCropElement=ImageCropElement,window.customElements.define("image-crop",ImageCropElement));class DetailsMenuElement extends HTMLElement{get preload(){return this.hasAttribute("preload")}set preload(t){t?this.setAttribute("preload",""):this.removeAttribute("preload")}get src(){return this.getAttribute("src")||""}set src(t){this.setAttribute("src",t)}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","menu");const t=this.parentElement;if(!t)return;const e=t.querySelector("summary");e&&(e.setAttribute("aria-haspopup","menu"),e.hasAttribute("role")||e.setAttribute("role","button"));const n=[nt(t,"compositionstart",(t=>ht(this,t))),nt(t,"compositionend",(t=>ht(this,t))),nt(t,"click",(e=>ct(t,e))),nt(t,"change",(e=>ct(t,e))),nt(t,"keydown",(e=>function(t,e,n){if(!(n instanceof KeyboardEvent))return;if(t.querySelector("details[open]"))return;const i=tt.get(e);if(!i||i.isComposing)return;const o=n.target instanceof Element&&"SUMMARY"===n.target.tagName;switch(n.key){case"Escape":t.hasAttribute("open")&&(dt(t),n.preventDefault(),n.stopPropagation());break;case"ArrowDown":{o&&!t.hasAttribute("open")&&t.setAttribute("open","");const e=rt(t,!0);e&&e.focus(),n.preventDefault()}break;case"ArrowUp":{o&&!t.hasAttribute("open")&&t.setAttribute("open","");const e=rt(t,!1);e&&e.focus(),n.preventDefault()}break;case"n":if(at&&n.ctrlKey){const e=rt(t,!0);e&&e.focus(),n.preventDefault()}break;case"p":if(at&&n.ctrlKey){const e=rt(t,!1);e&&e.focus(),n.preventDefault()}break;case" ":case"Enter":{const e=document.activeElement;e instanceof HTMLElement&&ut(e)&&e.closest("details")===t&&(n.preventDefault(),n.stopPropagation(),e.click())}}}(t,this,e))),nt(t,"toggle",(()=>it(t,this)),{once:!0}),nt(t,"toggle",(()=>function(t){if(!t.hasAttribute("open"))return;for(const e of document.querySelectorAll("details[open] > details-menu")){const n=e.closest("details");n&&n!==t&&!n.contains(t)&&n.removeAttribute("open")}}(t))),this.preload?nt(t,"mouseover",(()=>it(t,this)),{once:!0}):et,...ot(t)];tt.set(this,{subscriptions:n,loaded:!1,isComposing:!1})}disconnectedCallback(){const t=tt.get(this);if(t){tt.delete(this);for(const e of t.subscriptions)e.unsubscribe()}}}const tt=new WeakMap,et={unsubscribe(){}};function nt(t,e,n,i=!1){return t.addEventListener(e,n,i),{unsubscribe:()=>{t.removeEventListener(e,n,i)}}}function it(t,e){const n=e.getAttribute("src");if(!n)return;const i=tt.get(e);if(!i)return;if(i.loaded)return;i.loaded=!0;const o=e.querySelector("include-fragment");o&&!o.hasAttribute("src")&&(o.addEventListener("loadend",(()=>st(t))),o.setAttribute("src",n))}function ot(t){let e=!1;return[nt(t,"mousedown",(()=>e=!0)),nt(t,"keydown",(()=>e=!1)),nt(t,"toggle",(()=>{t.hasAttribute("open")&&(st(t)||e||function(t){const e=document.activeElement;if(e&&ut(e)&&t.contains(e))return;const n=rt(t,!0);n&&n.focus()}(t))}))]}function st(t){if(!t.hasAttribute("open"))return!1;const e=t.querySelector("details-menu [autofocus]");return!!e&&(e.focus(),!0)}function rt(t,e){const n=Array.from(t.querySelectorAll('[role^="menuitem"]:not([hidden]):not([disabled]):not([aria-disabled="true"])')),i=document.activeElement,o=i instanceof HTMLElement?n.indexOf(i):-1,s=e?n[o+1]:n[o-1],r=e?n[0]:n[n.length-1];return s||r}const at=navigator.userAgent.match(/Macintosh/);function ct(t,e){const n=e.target;if(n instanceof Element&&n.closest("details")===t)if("click"===e.type){const e=n.closest('[role="menuitem"], [role="menuitemradio"]');if(!e)return;const i=e.querySelector("input");if("LABEL"===e.tagName&&n===i)return;"LABEL"===e.tagName&&i&&!i.checked||lt(e,t)}else if("change"===e.type){const e=n.closest('[role="menuitemradio"], [role="menuitemcheckbox"]');e&<(e,t)}}function lt(t,e){if(t.hasAttribute("disabled")||"true"===t.getAttribute("aria-disabled"))return;const n=t.closest("details-menu");if(!n)return;n.dispatchEvent(new CustomEvent("details-menu-select",{cancelable:!0,detail:{relatedTarget:t}}))&&(!function(t,e){const n=e.querySelector("[data-menu-button]");if(!n)return;const i=function(t){if(!t)return null;const e=t.hasAttribute("data-menu-button-text")?t:t.querySelector("[data-menu-button-text]");return e?e.getAttribute("data-menu-button-text")||e.textContent:null}(t);if(i)n.textContent=i;else{const e=function(t){if(!t)return null;const e=t.hasAttribute("data-menu-button-contents")?t:t.querySelector("[data-menu-button-contents]");return e?e.innerHTML:null}(t);e&&(n.innerHTML=e)}}(t,e),function(t,e){for(const n of e.querySelectorAll('[role="menuitemradio"], [role="menuitemcheckbox"]')){const e=n.querySelector('input[type="radio"], input[type="checkbox"]');let i=(n===t).toString();e instanceof HTMLInputElement&&(i=e.indeterminate?"mixed":e.checked.toString()),n.setAttribute("aria-checked",i)}}(t,e),"menuitemcheckbox"!==t.getAttribute("role")&&dt(e),n.dispatchEvent(new CustomEvent("details-menu-selected",{detail:{relatedTarget:t}})))}function ut(t){const e=t.getAttribute("role");return"menuitem"===e||"menuitemcheckbox"===e||"menuitemradio"===e}function dt(t){if(!t.hasAttribute("open"))return;t.removeAttribute("open");const e=t.querySelector("summary");e&&e.focus()}function ht(t,e){const n=tt.get(t);n&&(n.isComposing="compositionstart"===e.type)}function ft(t,e,n,i){var o,s=arguments.length,r=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(s<3?o(r):s>3?o(e,n,r):o(e,n))||r);return s>3&&r&&Object.defineProperty(e,n,r),r}function mt(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function pt(t,e,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(t,n):o?o.value=n:e.set(t,n),n}window.customElements.get("details-menu")||(window.DetailsMenuElement=DetailsMenuElement,window.customElements.define("details-menu",DetailsMenuElement));const gt=new WeakSet;function bt(t){yt(t),vt(t)}const wt=new WeakMap;function vt(t=document){if(wt.has(t))return wt.get(t);let e=!1;const n=new MutationObserver((t=>{for(const e of t)if("attributes"===e.type&&e.target instanceof Element)Tt(e.target);else if("childList"===e.type&&e.addedNodes.length)for(const t of e.addedNodes)t instanceof Element&&yt(t)}));n.observe(t,{childList:!0,subtree:!0,attributeFilter:["data-action"]});const i={get closed(){return e},unsubscribe(){e=!0,wt.delete(t),n.disconnect()}};return wt.set(t,i),i}function yt(t){for(const e of t.querySelectorAll("[data-action]"))Tt(e);t instanceof Element&&t.hasAttribute("data-action")&&Tt(t)}function Et(t){const e=t.currentTarget;for(const n of At(e))if(t.type===n.type){const i=e.closest(n.tag);gt.has(i)&&"function"==typeof i[n.method]&&i[n.method](t);const o=e.getRootNode();if(o instanceof ShadowRoot&>.has(o.host)&&o.host.matches(n.tag)){const e=o.host;"function"==typeof e[n.method]&&e[n.method](t)}}}function*At(t){for(const e of(t.getAttribute("data-action")||"").trim().split(/\s+/)){const t=e.lastIndexOf(":"),n=Math.max(0,e.lastIndexOf("#"))||e.length;yield{type:e.slice(0,t),tag:e.slice(t+1,n),method:e.slice(n+1)||"handleEvent"}||"handleEvent"}}function Tt(t){for(const e of At(t))t.addEventListener(e.type,Et)}const kt=t=>String("symbol"==typeof t?t.description:t).replace(/([A-Z]($|[a-z]))/g,"-$1").replace(/--/g,"-").replace(/^-|-$/,"").toLowerCase(),Lt=(t,e="property")=>{const n=kt(t);if(!n.includes("-"))throw new DOMException(`${e}: ${String(t)} is not a valid ${e} name`,"SyntaxError");return n};const Mt=new WeakSet;function xt(t,e){if(Mt.has(t))return;Mt.add(t);const n=Object.getPrototypeOf(t),i=n?.constructor?.attrPrefix??"data-";e||(e=Ht(n,"attr"));for(const n of e){const e=t[n],o=Lt(`${i}${n}`);let s={configurable:!0,get(){return this.getAttribute(o)||""},set(t){this.setAttribute(o,t||"")}};"number"==typeof e?s={configurable:!0,get(){return Number(this.getAttribute(o)||0)},set(t){this.setAttribute(o,t)}}:"boolean"==typeof e&&(s={configurable:!0,get(){return this.hasAttribute(o)},set(t){this.toggleAttribute(o,t)}}),Object.defineProperty(t,n,s),n in t&&!t.hasAttribute(o)&&s.set.call(t,e)}}const Ct=Symbol.for("catalyst");class St{constructor(t){const e=this,n=t.prototype.connectedCallback;t.prototype.connectedCallback=function(){e.connectedCallback(this,n)};const i=t.prototype.disconnectedCallback;t.prototype.disconnectedCallback=function(){e.disconnectedCallback(this,i)};const o=t.prototype.attributeChangedCallback;t.prototype.attributeChangedCallback=function(t,n,i){e.attributeChangedCallback(this,t,n,i,o)};let s=t.observedAttributes||[];Object.defineProperty(t,"observedAttributes",{configurable:!0,get(){return e.observedAttributes(this,s)},set(t){s=t}}),function(t){let e=t.observedAttributes||[];const n=t.attrPrefix??"data-",i=t=>Lt(`${n}${t}`);Object.defineProperty(t,"observedAttributes",{configurable:!0,get:()=>[...Ht(t.prototype,"attr")].map(i).concat(e),set(t){e=t}})}(t),function(t){const e=kt(t.name).replace(/-element$/,"");try{window.customElements.define(e,t),window[t.name]=customElements.get(e)}catch(t){if(!(t instanceof DOMException&&"NotSupportedError"===t.name))throw t}}(t)}observedAttributes(t,e){return e}connectedCallback(t,e){t.toggleAttribute("data-catalyst",!0),customElements.upgrade(t),function(t){for(const e of t.querySelectorAll("template[data-shadowroot]"))e.parentElement===t&&t.attachShadow({mode:"closed"===e.getAttribute("data-shadowroot")?"closed":"open"}).append(e.content.cloneNode(!0))}(t),xt(t),function(t){gt.add(t),t.shadowRoot&&bt(t.shadowRoot),yt(t),vt(t.ownerDocument)}(t),e?.call(t),t.shadowRoot&&bt(t.shadowRoot)}disconnectedCallback(t,e){e?.call(t)}attributeChangedCallback(t,e,n,i,o){xt(t),"data-catalyst"!==e&&o&&o.call(t,e,n,i)}}function Ht(t,e){if(!Object.prototype.hasOwnProperty.call(t,Ct)){const e=t[Ct],n=t[Ct]=new Map;if(e)for(const[t,i]of e)n.set(t,new Set(i))}const n=t[Ct];return n.has(e)||n.set(e,new Set),n.get(e)}function Dt(t,e){Ht(t,"target").add(e),Object.defineProperty(t,e,{configurable:!0,get(){return function(t,e){const n=t.tagName.toLowerCase();if(t.shadowRoot)for(const i of t.shadowRoot.querySelectorAll(`[data-target~="${n}.${e}"]`))if(!i.closest(n))return i;for(const i of t.querySelectorAll(`[data-target~="${n}.${e}"]`))if(i.closest(n)===t)return i}(this,e)}})}function It(t,e){Ht(t,"targets").add(e),Object.defineProperty(t,e,{configurable:!0,get(){return function(t,e){const n=t.tagName.toLowerCase(),i=[];if(t.shadowRoot)for(const o of t.shadowRoot.querySelectorAll(`[data-targets~="${n}.${e}"]`))o.closest(n)||i.push(o);for(const o of t.querySelectorAll(`[data-targets~="${n}.${e}"]`))o.closest(n)===t&&i.push(o);return i}(this,e)}})}function Ft(t){new St(t)}function Ot(t,e=0,{start:n=!1,middle:i=!1,once:o=!1}={}){return function(t,e=0,{start:n=!0,middle:i=!0,once:o=!1}={}){let s,r=0,a=!1;function c(...l){if(a)return;const u=Date.now()-r;r=Date.now(),n?(n=!1,t.apply(this,l),o&&c.cancel()):(i&&u<e||!i)&&(clearTimeout(s),s=setTimeout((()=>{r=Date.now(),t.apply(this,l),o&&c.cancel()}),i?e-u:e))}return c.cancel=()=>{clearTimeout(s),a=!0},c}(t,e,{start:n,middle:i,once:o})}new Promise((t=>{"loading"!==document.readyState?t():document.addEventListener("readystatechange",(()=>t()),{once:!0})})),new Promise((t=>{const e=new AbortController;e.signal.addEventListener("abort",(()=>t()));const n={once:!0,passive:!0,signal:e.signal},i=()=>e.abort();document.addEventListener("mousedown",i,n),document.addEventListener("touchstart",i,n),document.addEventListener("keydown",i,n),document.addEventListener("pointerdown",i,n)}));let Rt=class ToggleSwitchElement extends HTMLElement{get src(){const t=this.getAttribute("src");if(!t)return null;const e=this.ownerDocument.createElement("a");return e.href=t,e.href}get csrf(){const t=this.querySelector("[data-csrf]");return this.getAttribute("csrf")||t instanceof HTMLInputElement&&t.value||null}get csrfField(){return this.getAttribute("csrf-field")||"authenticity_token"}isRemote(){return null!=this.src}toggle(){this.isRemote()?(this.setLoadingState(),this.check()):this.performToggle()}turnOn(){this.isDisabled()||(this.switch.setAttribute("aria-checked","true"),this.classList.add("ToggleSwitch--checked"))}turnOff(){this.isDisabled()||(this.switch.setAttribute("aria-checked","false"),this.classList.remove("ToggleSwitch--checked"))}isOn(){return"true"===this.switch.getAttribute("aria-checked")}isOff(){return!this.isOn()}isDisabled(){return"true"===this.switch.getAttribute("aria-disabled")}disable(){this.switch.setAttribute("aria-disabled","true")}enable(){this.switch.setAttribute("aria-disabled","false")}performToggle(){this.isOn()?this.turnOff():this.turnOn()}setLoadingState(){this.disable(),this.errorIcon.setAttribute("hidden","hidden"),this.loadingSpinner.removeAttribute("hidden")}setSuccessState(){this.setFinishedState(!1)}setErrorState(){this.setFinishedState(!0)}setFinishedState(t){t&&this.errorIcon.removeAttribute("hidden"),this.loadingSpinner.setAttribute("hidden","hidden"),this.enable()}async check(){const t=new FormData;this.csrf&&t.append(this.csrfField,this.csrf),t.append("value",this.isOn()?"1":"0");try{if(!this.src)throw new Error("invalid src");(await fetch(this.src,{credentials:"same-origin",method:"POST",body:t})).ok?(this.setSuccessState(),this.performToggle()):this.setErrorState()}catch(t){this.setErrorState()}}};ft([Dt],Rt.prototype,"switch",void 0),ft([Dt],Rt.prototype,"loadingSpinner",void 0),ft([Dt],Rt.prototype,"errorIcon",void 0),ft([function(t=0,e={}){return(n,i,o)=>{if(!o||"function"!=typeof o.value)throw new Error("debounce can only decorate functions");const s=o.value;o.value=Ot(s,t,e),Object.defineProperty(n,i,o)}}(300)],Rt.prototype,"check",null),Rt=ft([Ft],Rt);const $t={"outside-top":["outside-bottom","outside-right","outside-left","outside-bottom"],"outside-bottom":["outside-top","outside-right","outside-left","outside-bottom"],"outside-left":["outside-right","outside-bottom","outside-top","outside-bottom"],"outside-right":["outside-left","outside-bottom","outside-top","outside-bottom"]},Wt={start:["end","center"],end:["start","center"],center:["end","start"]};function Pt(t,e,n={}){const i=function(t){let e=t.parentNode;for(;null!==e;){if(e instanceof HTMLElement&&"static"!==getComputedStyle(e).position)return e;e=e.parentNode}return document.body}(t),o=function(t){let e=t;for(;null!==e&&e!==document.body;){if("visible"!==getComputedStyle(e).overflow)break;e=e.parentNode}const n=e!==document.body&&e instanceof HTMLElement?e:document.body,i=n.getBoundingClientRect(),o=getComputedStyle(n),[s,r,a,c]=[o.borderTopWidth,o.borderLeftWidth,o.borderRightWidth,o.borderBottomWidth].map((t=>parseInt(t,10)||0));return{top:i.top+s,left:i.left+r,width:i.width-a-r,height:Math.max(i.height-s-c,n===document.body?window.innerHeight:-1/0)}}(i),s=getComputedStyle(i),r=i.getBoundingClientRect(),[a,c]=[s.borderTopWidth,s.borderLeftWidth].map((t=>parseInt(t,10)||0));return function(t,e,n,i,{side:o,align:s,allowOutOfBounds:r,anchorOffset:a,alignmentOffset:c}){const l={top:t.top-e.top,left:t.left-e.left,width:t.width,height:t.height};let u=Yt(n,i,o,s,a,c),d=o,h=s;if(u.top-=e.top,u.left-=e.left,!r){const r=$t[o];let f=0;if(r){let t=o;for(;f<r.length&&zt(t,u,l,n);){const o=r[f++];t=o,u=Yt(n,i,o,s,a,c),u.top-=e.top,u.left-=e.left,d=o}}const m=Wt[s];let p=0;if(m){let t=s;for(;p<m.length&&jt(t,u,l,n);){const o=m[p++];t=o,u=Yt(n,i,d,o,a,c),u.top-=e.top,u.left-=e.left,h=o}}u.top<l.top&&(u.top=l.top),u.left<l.left&&(u.left=l.left),u.left+n.width>t.width+l.left&&(u.left=t.width+l.left-n.width),r&&f<r.length&&u.top+n.height>t.height+l.top&&(u.top=t.height+l.top-n.height)}return Object.assign(Object.assign({},u),{anchorSide:d,anchorAlign:h})}(o,{top:r.top+a,left:r.left+c},t.getBoundingClientRect(),e instanceof Element?e.getBoundingClientRect():e,function(t={}){var e,n,i,o,s;const r=null!==(e=t.side)&&void 0!==e?e:Nt,a=null!==(n=t.align)&&void 0!==n?n:qt;return{side:r,align:a,anchorOffset:null!==(i=t.anchorOffset)&&void 0!==i?i:"inside-center"===r?0:Bt,alignmentOffset:null!==(o=t.alignmentOffset)&&void 0!==o?o:"center"!==a&&r.startsWith("inside")?Kt:0,allowOutOfBounds:null!==(s=t.allowOutOfBounds)&&void 0!==s?s:Ut}}(n))}const Nt="outside-bottom",qt="start",Bt=4,Kt=4,Ut=!1;function Yt(t,e,n,i,o,s){const r=e.left+e.width,a=e.top+e.height;let c=-1,l=-1;return"outside-top"===n?c=e.top-o-t.height:"outside-bottom"===n?c=a+o:"outside-left"===n?l=e.left-o-t.width:"outside-right"===n&&(l=r+o),"outside-top"!==n&&"outside-bottom"!==n||(l="start"===i?e.left+s:"center"===i?e.left-(t.width-e.width)/2+s:r-t.width-s),"outside-left"!==n&&"outside-right"!==n||(c="start"===i?e.top+s:"center"===i?e.top-(t.height-e.height)/2+s:a-t.height-s),"inside-top"===n?c=e.top+o:"inside-bottom"===n?c=a-o-t.height:"inside-left"===n?l=e.left+o:"inside-right"===n?l=r-o-t.width:"inside-center"===n&&(l=(r+e.left)/2-t.width/2+o),"inside-top"===n||"inside-bottom"===n?l="start"===i?e.left+s:"center"===i?e.left-(t.width-e.width)/2+s:r-t.width-s:"inside-left"!==n&&"inside-right"!==n&&"inside-center"!==n||(c="start"===i?e.top+s:"center"===i?e.top-(t.height-e.height)/2+s:a-t.height-s),{top:c,left:l}}function zt(t,e,n,i){return"outside-top"===t||"outside-bottom"===t?e.top<n.top||e.top+i.height>n.height+n.top:e.left<n.left||e.left+i.width>n.width+n.left}function jt(t,e,n,i){return"end"===t?e.left<n.left:"start"===t||"center"===t?e.left+i.width>n.left+n.width||e.left<n.left:void 0}function*Xt(t,e={}){var n,i;const o=null!==(n=e.strict)&&void 0!==n&&n,s=null!==(i=e.onlyTabbable)&&void 0!==i&&i?Jt:_t,r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:t=>t instanceof HTMLElement&&s(t,o)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let a=null;if(!e.reverse&&s(t,o)&&(yield t),e.reverse){let t=r.lastChild();for(;t;)a=t,t=r.lastChild()}else a=r.firstChild();for(;a instanceof HTMLElement;)yield a,a=e.reverse?r.previousNode():r.nextNode();e.reverse&&s(t,o)&&(yield t)}function Vt(t,e=!1){return Xt(t,{reverse:e,strict:!0,onlyTabbable:!0}).next().value}function _t(t,e=!1){const n=["BUTTON","INPUT","SELECT","TEXTAREA","OPTGROUP","OPTION","FIELDSET"].includes(t.tagName)&&t.disabled,i=t.hidden,o=t instanceof HTMLInputElement&&"hidden"===t.type,s=t.classList.contains("sentinel");if(n||i||o||s)return!1;if(e){const e=0===t.offsetWidth||0===t.offsetHeight,n=["hidden","collapse"].includes(getComputedStyle(t).visibility),i=0===t.getClientRects().length;if(e||n||i)return!1}return null!=t.getAttribute("tabindex")||!(t instanceof HTMLAnchorElement&&null==t.getAttribute("href"))&&-1!==t.tabIndex}function Jt(t,e=!1){return _t(t,e)&&"-1"!==t.getAttribute("tabindex")}let Zt=!1;function Gt(){}try{const t=Object.create({},{signal:{get(){Zt=!0}}});window.addEventListener("test",Gt,t),window.removeEventListener("test",Gt,t)}catch(t){}function Qt(){Zt||(!function(){if("undefined"==typeof window)return;const t=EventTarget.prototype.addEventListener;EventTarget.prototype.addEventListener=function(e,n,i){return"object"==typeof i&&"signal"in i&&i.signal instanceof AbortSignal&&t.call(i.signal,"abort",(()=>{this.removeEventListener(e,n,i)})),t.call(this,e,n,i)}}(),Zt=!0)}Qt();const te=[];let ee,ne;function ie(t,e,n){const i=new AbortController,o=null!=n?n:i.signal;t.setAttribute("data-focus-trap","active");const s=document.createElement("span");s.setAttribute("class","sentinel"),s.setAttribute("tabindex","0"),s.setAttribute("aria-hidden","true"),s.onfocus=()=>{const e=Vt(t,!0);null==e||e.focus()};const r=document.createElement("span");let a;function c(n){if(n instanceof HTMLElement&&document.contains(t)){if(t.contains(n))return void(a=n);if(a&&Jt(a)&&t.contains(a))return void a.focus();if(e&&t.contains(e))return void e.focus();{const e=Vt(t);return void(null==e||e.focus())}}}r.setAttribute("class","sentinel"),r.setAttribute("tabindex","0"),r.setAttribute("aria-hidden","true"),r.onfocus=()=>{const e=Vt(t);null==e||e.focus()},t.prepend(s),t.append(r);const l=function(t){const e=new AbortController;return t.addEventListener("abort",(()=>{e.abort()})),e}(o);if(ee){const t=ee;ee.container.setAttribute("data-focus-trap","suspended"),ee.controller.abort(),te.push(t)}l.signal.addEventListener("abort",(()=>{ee=void 0})),o.addEventListener("abort",(()=>{t.removeAttribute("data-focus-trap");const e=t.getElementsByClassName("sentinel");for(;e.length>0;)e[0].remove();const n=te.findIndex((e=>e.container===t));n>=0&&te.splice(n,1),function(){const t=te.pop();t&&ie(t.container,t.initialFocus,t.originalSignal)}()})),document.addEventListener("focus",(t=>{c(t.target)}),{signal:l.signal,capture:!0}),c(document.activeElement),ee={container:t,controller:l,initialFocus:e,originalSignal:o};const u=te.findIndex((e=>e.container===t));if(u>=0&&te.splice(u,1),!n)return i}function oe(){return void 0===ne&&(ne=/^mac/i.test(window.navigator.platform)),ne}let se=1e4;var re;Qt(),function(t){t[t.ArrowHorizontal=1]="ArrowHorizontal",t[t.ArrowVertical=2]="ArrowVertical",t[t.JK=4]="JK",t[t.HL=8]="HL",t[t.HomeAndEnd=16]="HomeAndEnd",t[t.PageUpDown=256]="PageUpDown",t[t.WS=32]="WS",t[t.AD=64]="AD",t[t.Tab=128]="Tab",t[t.ArrowAll=3]="ArrowAll",t[t.HJKL=12]="HJKL",t[t.WASD=96]="WASD",t[t.All=511]="All"}(re||(re={}));const ae={ArrowLeft:re.ArrowHorizontal,ArrowDown:re.ArrowVertical,ArrowUp:re.ArrowVertical,ArrowRight:re.ArrowHorizontal,h:re.HL,j:re.JK,k:re.JK,l:re.HL,a:re.AD,s:re.WS,w:re.WS,d:re.AD,Tab:re.Tab,Home:re.HomeAndEnd,End:re.HomeAndEnd,PageUp:re.PageUpDown,PageDown:re.PageUpDown},ce={ArrowLeft:"previous",ArrowDown:"next",ArrowUp:"previous",ArrowRight:"next",h:"previous",j:"next",k:"previous",l:"next",a:"previous",s:"next",w:"previous",d:"next",Tab:"next",Home:"start",End:"end",PageUp:"start",PageDown:"end"};function le(t){const e=ce[t.key];if("Tab"===t.key&&t.shiftKey)return"previous";const n=oe();if(n&&t.metaKey||!n&&t.ctrlKey){if("ArrowLeft"===t.key||"ArrowUp"===t.key)return"start";if("ArrowRight"===t.key||"ArrowDown"===t.key)return"end"}return e}function ue(t,e){var n,i,o,s;const r=[],a=new WeakMap,c=null!==(n=null==e?void 0:e.bindKeys)&&void 0!==n?n:((null==e?void 0:e.getNextFocusable)?re.ArrowAll:re.ArrowVertical)|re.HomeAndEnd,l=null!==(i=null==e?void 0:e.focusOutBehavior)&&void 0!==i?i:"stop",u=null!==(o=null==e?void 0:e.focusInStrategy)&&void 0!==o?o:"previous",d=null==e?void 0:e.activeDescendantControl,h=null==e?void 0:e.onActiveDescendantChanged;let f;function m(){return r[0]}function p(t,e=!1){const n=f;f=t,d?t&&document.activeElement===d?g(n,t,e):b():(n&&n!==t&&a.has(n)&&n.setAttribute("tabindex","-1"),null==t||t.setAttribute("tabindex","0"))}function g(e,n,i=!1){n.id||n.setAttribute("id","__primer_id_"+se++),e&&e!==n&&e.removeAttribute("data-is-active-descendant"),d&&(i||d.getAttribute("aria-activedescendant")!==n.id)&&(d.setAttribute("aria-activedescendant",n.id),t.setAttribute("data-has-active-descendant",n.id),n.setAttribute("data-is-active-descendant",i?"activated-directly":"activated-indirectly"),null==h||h(n,e,i))}function b(e=f){"first"===u&&(f=void 0),null==d||d.removeAttribute("aria-activedescendant"),t.removeAttribute("data-has-active-descendant"),null==e||e.removeAttribute("data-is-active-descendant"),null==h||h(void 0,e,!1)}function w(...t){const n=t.filter((t=>{var n,i;return null===(i=null===(n=null==e?void 0:e.focusableElementFilter)||void 0===n?void 0:n.call(e,t))||void 0===i||i}));if(0===n.length)return;const i=r.findIndex((t=>(t.compareDocumentPosition(n[0])&Node.DOCUMENT_POSITION_PRECEDING)>0));r.splice(-1===i?r.length:i,0,...n);for(const t of n)a.has(t)||a.set(t,t.getAttribute("tabindex")),t.setAttribute("tabindex","-1");f||p(m())}function v(...t){for(const e of t){const t=r.indexOf(e);t>=0&&r.splice(t,1);const n=a.get(e);if(void 0!==n&&(null===n?e.removeAttribute("tabindex"):e.setAttribute("tabindex",n),a.delete(e)),e===f){p(m())}}}w(...Xt(t)),p(m());new MutationObserver((t=>{for(const e of t)for(const t of e.removedNodes)t instanceof HTMLElement&&v(...Xt(t));for(const e of t)for(const t of e.addedNodes)t instanceof HTMLElement&&w(...Xt(t))})).observe(t,{subtree:!0,childList:!0});const y=new AbortController,E=null!==(s=null==e?void 0:e.abortSignal)&&void 0!==s?s:y.signal;let A;E.addEventListener("abort",(()=>{v(...r)})),t.addEventListener("mousedown",(t=>{t.target instanceof HTMLElement&&t.target!==document.activeElement&&(A=r.indexOf(t.target))}),{signal:E}),d?(t.addEventListener("focusin",(t=>{t.target instanceof HTMLElement&&r.includes(t.target)&&(d.focus(),p(t.target))})),t.addEventListener("mousemove",(({target:t})=>{if(!(t instanceof Node))return;const e=r.find((e=>e.contains(t)));e&&p(e)}),{signal:E,capture:!0}),d.addEventListener("focusin",(()=>{f?g(void 0,f):p(m())})),d.addEventListener("focusout",(()=>{b()}))):t.addEventListener("focusin",(e=>{if(e.target instanceof HTMLElement)if(void 0!==A)A>=0&&r[A]!==f&&p(r[A]),A=void 0;else if("previous"===u)p(e.target);else if("closest"===u||"first"===u){if(e.relatedTarget instanceof Element&&!t.contains(e.relatedTarget)){const t="previous"===k?r.length-1:0,e=r[t];return void(null==e||e.focus())}p(e.target)}else if("function"==typeof u)if(e.relatedTarget instanceof Element&&!t.contains(e.relatedTarget)){const t=u(e.relatedTarget);if((t?r.indexOf(t):-1)>=0&&t instanceof HTMLElement)return void t.focus();console.warn("Element requested is not a known focusable element.")}else p(e.target);k=void 0}),{signal:E});const T=null!=d?d:t;let k;return"closest"===u&&document.addEventListener("keydown",(t=>{"Tab"===t.key&&(k=le(t))}),{signal:E,capture:!0}),T.addEventListener("keydown",(n=>{var i;if(n.key in ce){const o=ae[n.key];if(!n.defaultPrevented&&(o&c)>0&&!function(t,e){const n=t.key,i=[...n].length,o=e instanceof HTMLInputElement&&"text"===e.type||e instanceof HTMLTextAreaElement;if(o&&(1===i||"Home"===n||"End"===n))return!0;if(e instanceof HTMLSelectElement){if(1===i)return!0;if("ArrowDown"===n&&oe()&&!t.metaKey)return!0;if("ArrowDown"===n&&!oe()&&t.altKey)return!0}if(e instanceof HTMLTextAreaElement&&("PageUp"===n||"PageDown"===n))return!0;if(o){const t=e,i=0===t.selectionStart&&0===t.selectionEnd,o=t.selectionStart===t.value.length&&t.selectionEnd===t.value.length;if("ArrowLeft"===n&&!i)return!0;if("ArrowRight"===n&&!o)return!0;if(t instanceof HTMLTextAreaElement){if("ArrowUp"===n&&!i)return!0;if("ArrowDown"===n&&!o)return!0}}return!1}(n,document.activeElement)){const o=le(n);let s;if((null==e?void 0:e.getNextFocusable)&&(s=e.getNextFocusable(o,null!==(i=document.activeElement)&&void 0!==i?i:void 0,n)),!s){const e=function(){if(!f)return 0;const e=r.indexOf(f);return-1!==e?e:f===t?-1:0}();let i=e;"previous"===o?i-=1:"start"===o?i=0:"next"===o?i+=1:i=r.length-1,i<0&&(i="wrap"===l&&"Tab"!==n.key?r.length-1:0),i>=r.length&&(i="wrap"===l&&"Tab"!==n.key?0:r.length-1),e!==i&&(s=r[i])}d?p(s||f,!0):s&&(k=o,s.focus()),("Tab"!==n.key||s)&&n.preventDefault()}}}),{signal:E}),y}function de(t,e){let n=t;const i=n.ownerDocument;if(!i)return;const o=i.documentElement;if(!o)return;const s=i.defaultView.HTMLElement;let r=0,a=0;const c=n.offsetHeight,l=n.offsetWidth;for(;n!==i.body&&n!==e;){if(r+=n.offsetTop||0,a+=n.offsetLeft||0,!(n.offsetParent instanceof s))return;n=n.offsetParent}let u,d,h;if(e&&e!==i&&e!==i.defaultView&&e!==i.documentElement&&e!==i.body){if(!(e instanceof s))return;h=e,u=e.scrollHeight,d=e.scrollWidth}else h=o,u=function(t,e){return Math.max(t.scrollHeight,e.scrollHeight,t.offsetHeight,e.offsetHeight,e.clientHeight)}(i.body,o),d=function(t,e){return Math.max(t.scrollWidth,e.scrollWidth,t.offsetWidth,e.offsetWidth,e.clientWidth)}(i.body,o);return{top:r,left:a,bottom:u-(r+c),right:d-(a+l),_container:h}}var he,fe,me,pe,ge,be,we;const ve=["tooltip-n","tooltip-s","tooltip-e","tooltip-w","tooltip-ne","tooltip-se","tooltip-nw","tooltip-sw"];class ToolTipElement extends HTMLElement{constructor(){super(...arguments),he.add(this),fe.set(this,void 0),me.set(this,"center"),pe.set(this,"outside-bottom"),ge.set(this,!1)}styles(){return'\n :host {\n position: absolute;\n z-index: 1000000;\n padding: .5em .75em;\n font: normal normal 11px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";\n -webkit-font-smoothing: subpixel-antialiased;\n color: var(--color-fg-on-emphasis);\n text-align: center;\n text-decoration: none;\n text-shadow: none;\n text-transform: none;\n letter-spacing: normal;\n word-wrap: break-word;\n white-space: pre;\n background: var(--color-neutral-emphasis-plus);\n border-radius: 6px;\n opacity: 0;\n max-width: 250px;\n word-wrap: break-word;\n white-space: normal;\n width: max-content;\n }\n\n :host:before{\n position: absolute;\n z-index: 1000001;\n color: var(--color-neutral-emphasis-plus);\n content: "";\n border: 6px solid transparent;\n opacity: 0\n }\n\n @keyframes tooltip-appear {\n from {\n opacity: 0\n }\n to {\n opacity: 1\n }\n }\n\n :host:after{\n position: absolute;\n display: block;\n right: 0;\n left: 0;\n height: 12px;\n content: ""\n }\n\n :host(.tooltip-open),\n :host(.tooltip-open):before {\n animation-name: tooltip-appear;\n animation-duration: .1s;\n animation-fill-mode: forwards;\n animation-timing-function: ease-in;\n animation-delay: .4s\n }\n\n :host(.tooltip-s):before,\n :host(.tooltip-n):before {\n right: 50%;\n margin-right: -6px;\n }\n\n :host(.tooltip-s):before,\n :host(.tooltip-se):before,\n :host(.tooltip-sw):before {\n bottom: 100%;\n border-bottom-color: var(--color-neutral-emphasis-plus)\n }\n\n :host(.tooltip-s):after,\n :host(.tooltip-se):after,\n :host(.tooltip-sw):after {\n bottom: 100%\n }\n\n :host(.tooltip-n):before,\n :host(.tooltip-ne):before,\n :host(.tooltip-nw):before {\n top: 100%;\n border-top-color: var(--color-neutral-emphasis-plus)\n }\n\n :host(.tooltip-n):after,\n :host(.tooltip-ne):after,\n :host(.tooltip-nw):after {\n top: 100%\n }\n\n :host(.tooltip-se):before,\n :host(.tooltip-ne):before {\n left: 0;\n margin-left: 6px;\n }\n\n :host(.tooltip-sw):before,\n :host(.tooltip-nw):before {\n right: 0;\n margin-right: 6px;\n }\n\n :host(.tooltip-w):before {\n top: 50%;\n bottom: 50%;\n left: 100%;\n margin-top: -6px;\n border-left-color: var(--color-neutral-emphasis-plus)\n }\n\n :host(.tooltip-e):before {\n top: 50%;\n right: 100%;\n bottom: 50%;\n margin-top: -6px;\n border-right-color: var(--color-neutral-emphasis-plus)\n }\n '}get htmlFor(){return this.getAttribute("for")||""}set htmlFor(t){this.setAttribute("for",t)}get type(){return"label"===this.getAttribute("data-type")?"label":"description"}set type(t){this.setAttribute("data-type",t)}get direction(){return this.getAttribute("data-direction")||"s"}set direction(t){this.setAttribute("data-direction",t)}get control(){return this.ownerDocument.getElementById(this.htmlFor)}set hiddenFromView(t){this.classList.toggle("sr-only",t),this.isConnected&&mt(this,he,"m",be).call(this)}get hiddenFromView(){return this.classList.contains("sr-only")}connectedCallback(){var t;if(!this.shadowRoot){this.attachShadow({mode:"open"}).innerHTML=`\n <style>\n ${this.styles()}\n </style>\n <slot></slot>\n `}if(this.hiddenFromView=!0,pt(this,ge,!0,"f"),this.id||(this.id=`tooltip-${Date.now()}-${(1e4*Math.random()).toFixed(0)}`),!this.control)return;this.setAttribute("role","tooltip"),null===(t=mt(this,fe,"f"))||void 0===t||t.abort(),pt(this,fe,new AbortController,"f");const{signal:e}=mt(this,fe,"f");this.addEventListener("mouseleave",this,{signal:e}),this.control.addEventListener("mouseenter",this,{signal:e}),this.control.addEventListener("mouseleave",this,{signal:e}),this.control.addEventListener("focus",this,{signal:e}),this.control.addEventListener("blur",this,{signal:e}),this.ownerDocument.addEventListener("keydown",this,{signal:e}),mt(this,he,"m",be).call(this)}disconnectedCallback(){var t;null===(t=mt(this,fe,"f"))||void 0===t||t.abort()}handleEvent(t){this.control&&("mouseenter"!==t.type&&"focus"!==t.type||!this.hiddenFromView?"blur"===t.type||"mouseleave"===t.type&&t.relatedTarget!==this.control&&t.relatedTarget!==this?this.hiddenFromView=!0:"keydown"!==t.type||"Escape"!==t.key||this.hiddenFromView||(this.hiddenFromView=!0):this.hiddenFromView=!1)}attributeChangedCallback(t){if("id"===t||"data-type"===t){if(!this.id||!this.control)return;if("label"===this.type){let t=this.control.getAttribute("aria-labelledby");t=t?`${t} ${this.id}`:this.id,this.control.setAttribute("aria-labelledby",t),this.setAttribute("aria-hidden","true")}else{let t=this.control.getAttribute("aria-describedby");t=t?`${t} ${this.id}`:this.id,this.control.setAttribute("aria-describedby",t)}}else if("data-direction"===t){this.classList.remove(...ve);const t=this.direction;"n"===t?(pt(this,me,"center","f"),pt(this,pe,"outside-top","f")):"ne"===t?(pt(this,me,"start","f"),pt(this,pe,"outside-top","f")):"e"===t?(pt(this,me,"center","f"),pt(this,pe,"outside-right","f")):"se"===t?(pt(this,me,"start","f"),pt(this,pe,"outside-bottom","f")):"s"===t?(pt(this,me,"center","f"),pt(this,pe,"outside-bottom","f")):"sw"===t?(pt(this,me,"end","f"),pt(this,pe,"outside-bottom","f")):"w"===t?(pt(this,me,"center","f"),pt(this,pe,"outside-left","f")):"nw"===t&&(pt(this,me,"end","f"),pt(this,pe,"outside-top","f"))}}}var ye,Ee,Ae,Te,ke,Le,Me,xe,Ce,Se,He,De,Ie,Fe,Oe,Re,$e,We,Pe,Ne,qe,Be;fe=new WeakMap,me=new WeakMap,pe=new WeakMap,ge=new WeakMap,he=new WeakSet,be=function(){if(this.hiddenFromView)this.classList.remove("tooltip-open",...ve);else{this.classList.add("tooltip-open");for(const t of this.ownerDocument.querySelectorAll(this.tagName))t!==this&&(t.hiddenFromView=!0);mt(this,he,"m",we).call(this)}},we=function(){if(!this.control)return;if(!mt(this,ge,"f")||this.hiddenFromView)return;this.style.left="0px";const t=Pt(this,this.control,{side:mt(this,pe,"f"),align:mt(this,me,"f"),anchorOffset:10}),e=t.anchorSide,n=t.anchorAlign;this.style.top=`${t.top}px`,this.style.left=`${t.left}px`;let i="s";i="outside-left"===e?"w":"outside-right"===e?"e":"outside-top"===e?"center"===n?"n":"start"===n?"ne":"nw":"center"===n?"s":"start"===n?"se":"sw",this.classList.add(`tooltip-${i}`)},ToolTipElement.observedAttributes=["data-type","data-direction","id"],window.customElements.get("tool-tip")||(window.ToolTipElement=ToolTipElement,window.customElements.define("tool-tip",ToolTipElement));class ActionBarMenuElement extends HTMLElement{constructor(){super(...arguments),ye.add(this),Ee.set(this,void 0),Ae.set(this,void 0),Te.set(this,void 0),ke.set(this,void 0)}get anchorAlign(){return this.getAttribute("data-anchor-align")||"start"}get anchorSide(){return this.getAttribute("data-anchor-side")||"outside-bottom"}get menu(){return this.querySelector('[role="menu"]')}get trigger(){return this.querySelector("button")}get overlay(){return this.querySelector(".Overlay")}get menuItems(){return this.menu?Array.from(this.menu.querySelectorAll('[role="menuitem"],[role="menuitemcheckbox"],[role="menuitemradio"]')):null}get open(){return this.hasAttribute("open")}set open(t){var e,n;const i=document.body.clientWidth,o=new ResizeObserver((t=>{for(const e of t)i!==e.contentRect.width&&this.open&&mt(this,ye,"m",Me).call(this)}));if(t){if(this.open)return;if(!this.trigger||!this.menu)return;this.setAttribute("open",""),this.trigger.setAttribute("aria-expanded","true"),null===(e=this.overlay)||void 0===e||e.removeAttribute("hidden"),this.menu.style.visibility="hidden",mt(this,ye,"m",Me).call(this),o.observe(document.body),this.menu.style.visibility="visible"}else{if(!this.open)return;this.removeAttribute("open"),null===(n=this.trigger)||void 0===n||n.setAttribute("aria-expanded","false"),this.overlay&&this.overlay.setAttribute("hidden","true"),o.unobserve(document.body),setTimeout((()=>{var t;document.activeElement===document.body&&(null===(t=this.trigger)||void 0===t||t.focus())}),1)}}connectedCallback(){this.trigger&&mt(this,ye,"m",Le).call(this)}disconnectedCallback(){mt(this,Ee,"f").abort()}show(){this.open=!0}hide(){this.open=!1}setFocusToMenuItem(t){if(this.menuItems)for(const e of this.menuItems)e===t?(e.tabIndex=0,t.focus()):e.tabIndex=-1}setFocusToPreviousMenuItem(t){if(!this.menuItems)return;let e=null,n=null;return t===mt(this,Te,"f")?e=mt(this,ke,"f"):(n=this.menuItems.indexOf(t),e=this.menuItems[n-1]),this.setFocusToMenuItem(e),e}setFocusToNextMenuItem(t){if(!this.menuItems)return;let e=null,n=null;return t===mt(this,ke,"f")?e=mt(this,Te,"f"):(n=this.menuItems.indexOf(t),e=this.menuItems[n+1]),this.setFocusToMenuItem(e),e}setFocusByFirstCharacter(t,e){if(!this.menuItems)return;let n=null,i=null;e.length>1||(e=e.toLowerCase(),n=this.menuItems.indexOf(t)+1,n>=this.menuItems.length&&(n=0),i=mt(this,Ae,"f").indexOf(e,n),-1===i&&(i=mt(this,Ae,"f").indexOf(e,0)),i>-1&&this.setFocusToMenuItem(this.menuItems[i]))}buttonKeydown(t){let e=!1;switch(t.key){case" ":case"Enter":case"ArrowDown":case"Down":this.show(),this.setFocusToMenuItem(mt(this,Te,"f")),e=!0;break;case"Esc":case"Escape":this.hide(),e=!0;break;case"Up":case"ArrowUp":this.show(),this.setFocusToMenuItem(mt(this,ke,"f")),e=!0}e&&(t.stopPropagation(),t.preventDefault())}buttonClick(t){this.open?this.hide():(this.show(),this.setFocusToMenuItem(mt(this,Te,"f"))),t.stopPropagation(),t.preventDefault()}menuItemKeydown(t){var e;const n=t.currentTarget,i=t.key;let o=!1;function s(t){return 1===t.length&&t.match(/\S/)}if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.shiftKey)s(i)&&(this.setFocusByFirstCharacter(n,i),o=!0),"Tab"===t.key&&(null===(e=this.trigger)||void 0===e||e.focus(),this.hide(),o=!0);else switch(i){case"Enter":this.hide();break;case"Esc":case"Escape":this.hide(),o=!0;break;case"Up":case"ArrowUp":this.setFocusToPreviousMenuItem(n),o=!0;break;case"ArrowDown":case"Down":this.setFocusToNextMenuItem(n),o=!0;break;case"Home":case"PageUp":this.setFocusToMenuItem(mt(this,Te,"f")),o=!0;break;case"End":case"PageDown":this.setFocusToMenuItem(mt(this,ke,"f")),o=!0;break;case"Tab":this.hide();break;default:s(i)&&(this.setFocusByFirstCharacter(n,i),o=!0)}o&&(t.stopPropagation(),t.preventDefault())}}menuItemClick(){this.hide()}menuItemMouseover(t){t.currentTarget.focus()}backgroundMousedown(t){this&&(this.contains(t.target)||this.open&&this.hide())}}Ee=new WeakMap,Ae=new WeakMap,Te=new WeakMap,ke=new WeakMap,ye=new WeakSet,Le=function(){pt(this,Ee,new AbortController,"f");const{signal:t}=mt(this,Ee,"f");if(this.trigger&&this.menu){if(this.trigger.addEventListener("keydown",this.buttonKeydown.bind(this),{signal:t}),this.trigger.addEventListener("click",this.buttonClick.bind(this),{signal:t}),pt(this,Ae,[],"f"),this.menuItems)for(const e of this.menuItems)e.textContent&&mt(this,Ae,"f").push(e.textContent.trim()[0].toLowerCase()),e.addEventListener("keydown",this.menuItemKeydown.bind(this),{signal:t}),e.addEventListener("click",this.menuItemClick.bind(this),{signal:t}),e.addEventListener("mouseover",this.menuItemMouseover.bind(this),{signal:t}),mt(this,Te,"f")||pt(this,Te,e,"f"),pt(this,ke,e,"f");window.addEventListener("mousedown",this.backgroundMousedown.bind(this),!0)}},Me=function(){if(!this.trigger||!this.menu)return;const t=this.querySelector("[data-menu-overlay]")||this.menu,e=this.trigger,{top:n,left:i}=Pt(t,e,{side:this.anchorSide,align:this.anchorAlign});t.style.top=`${n}px`,t.style.left=`${i}px`},window.customElements.get("action-bar-menu")||(window.ActionBarMenuElement=ActionBarMenuElement,window.customElements.define("action-bar-menu",ActionBarMenuElement));let Ke=class ActionBarElement extends HTMLElement{constructor(){super(...arguments),xe.add(this),Ce.set(this,void 0),Se.set(this,void 0),He.set(this,void 0),De.set(this,void 0),Ie.set(this,{bindKeys:re.ArrowHorizontal|re.HomeAndEnd})}connectedCallback(){var t,e,n;pt(this,Se,this.offsetWidth,"f"),pt(this,He,parseInt(null===(t=window.getComputedStyle(this))||void 0===t?void 0:t.columnGap,10)||0,"f");for(const t of this.items){const i=t.getBoundingClientRect().width,o=parseInt(null===(e=window.getComputedStyle(t))||void 0===e?void 0:e.marginLeft,10),s=parseInt(null===(n=window.getComputedStyle(t))||void 0===n?void 0:n.marginRight,10);t.setAttribute("data-offset-width",`${i+o+s}`)}for(pt(this,De,ue(this,mt(this,Ie,"f")),"f");mt(this,xe,"m",Fe).call(this)<0&&!this.items[0].hidden;)mt(this,xe,"m",Oe).call(this);pt(this,Ce,new ResizeObserver((t=>{for(const e of t)mt(this,Se,"f")!==e.contentRect.width&&mt(this,xe,"m",Oe).call(this)})),"f"),mt(this,Ce,"f").observe(this)}disconnectedCallback(){var t;null===(t=mt(this,De,"f"))||void 0===t||t.abort(),mt(this,Ce,"f").unobserve(this)}};var Ue,Ye,ze,je,Xe,Ve,_e;function Je(t){document.activeElement!==t&&(null==t||t.focus())}Ce=new WeakMap,Se=new WeakMap,He=new WeakMap,De=new WeakMap,Ie=new WeakMap,xe=new WeakSet,Fe=function(){const t=de(this.items[0],this);return t?t.left:this.clientWidth-this.moreMenu.clientWidth},Oe=function(){const t=mt(this,xe,"m",Fe).call(this);t<0?mt(this,xe,"m",$e).call(this):t>mt(this,He,"f")+mt(this,xe,"m",Re).call(this)&&mt(this,xe,"m",We).call(this)},Re=function(){const t=mt(this,xe,"m",Pe).call(this)[0]||this.items[0];return Number(t.getAttribute("data-offset-width")||"0")},$e=function(){var t;const e=mt(this,xe,"m",Ne).call(this),n=mt(this,xe,"m",qe).call(this);0!==e.length&&(e[e.length-1].hidden=!0,n[n.length-1].hidden=!1,this.moreMenu.hidden&&(this.moreMenu.hidden=!1),null===(t=mt(this,De,"f"))||void 0===t||t.abort(),pt(this,De,ue(this,mt(this,Ie,"f")),"f"))},We=function(){var t;const e=mt(this,xe,"m",Pe).call(this),n=mt(this,xe,"m",Be).call(this);0!==e.length&&(e[0].hidden=!1,n[0].hidden=!0,1===e.length&&(this.moreMenu.hidden=!0,this.moreMenu.open=!1),null===(t=mt(this,De,"f"))||void 0===t||t.abort(),pt(this,De,ue(this,mt(this,Ie,"f")),"f"))},Pe=function(){return this.items.filter((t=>t.hidden))},Ne=function(){return this.items.filter((t=>!t.hidden))},qe=function(){return this.menuItems.filter((t=>t.hidden))},Be=function(){return this.menuItems.filter((t=>!t.hidden))},ft([It],Ke.prototype,"items",void 0),ft([It],Ke.prototype,"menuItems",void 0),ft([Dt],Ke.prototype,"moreMenu",void 0),Ke=ft([Ft],Ke);class ModalDialogElement extends HTMLElement{constructor(){super(...arguments),Ue.add(this),Ye.set(this,new AbortController),ze.set(this,null),je.set(this,void 0),Xe.set(this,!0)}get open(){return this.hasAttribute("open")}set open(t){var e,n,i,o;if(t){if(this.open)return;this.setAttribute("open",""),null===(e=mt(this,Ue,"a",Ve))||void 0===e||e.classList.remove("Overlay--hidden"),document.body.style.overflow="hidden",mt(this,Ye,"f").signal.aborted&&pt(this,Ye,new AbortController,"f"),ie(this,void 0,mt(this,Ye,"f").signal)}else{if(!this.open)return;this.removeAttribute("open"),null===(n=mt(this,Ue,"a",Ve))||void 0===n||n.classList.add("Overlay--hidden"),document.body.style.overflow="initial",mt(this,Ye,"f").abort();const t=(null===(i=mt(this,je,"f"))||void 0===i?void 0:i.closest("details"))||(null===(o=mt(this,je,"f"))||void 0===o?void 0:o.closest("action-menu"));Je(t?Vt(t):mt(this,je,"f")),pt(this,je,void 0,"f")}}get showButtons(){return document.querySelectorAll(`button[data-show-dialog-id='${this.id}']`)}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog");const{signal:t}=pt(this,ze,new AbortController,"f");this.ownerDocument.addEventListener("click",(t=>{const e=t.target,n=e.closest(this.tagName)!==this,i=null==e?void 0:e.closest("button");if(!i)return void(n&&this.close());let o=i.getAttribute("data-close-dialog-id");o===this.id&&this.close(),o=i.getAttribute("data-submit-dialog-id"),o===this.id&&this.close(!0),o=i.getAttribute("data-show-dialog-id"),o===this.id&&(t.stopPropagation(),pt(this,je,i,"f"),this.show())}),{signal:t}),this.addEventListener("keydown",(t=>mt(this,Ue,"m",_e).call(this,t)))}disconnectedCallback(){var t;null===(t=mt(this,ze,"f"))||void 0===t||t.abort()}show(){this.open=!0}close(t=!1){if(!1===this.open)return;const e=new Event(t?"close":"cancel");this.dispatchEvent(e),this.open=!1}}Ye=new WeakMap,ze=new WeakMap,je=new WeakMap,Xe=new WeakMap,Ue=new WeakSet,Ve=function(){var t;return(null===(t=this.parentElement)||void 0===t?void 0:t.hasAttribute("data-modal-dialog-overlay"))?this.parentElement:null},_e=function(t){if(t instanceof KeyboardEvent&&!t.isComposing)switch(t.key){case"Escape":this.open&&(this.close(),t.preventDefault(),t.stopPropagation())}},window.customElements.get("modal-dialog")||(window.ModalDialogElement=ModalDialogElement,window.customElements.define("modal-dialog",ModalDialogElement));
|
|
2
|
+
//# sourceMappingURL=primer_view_components.js.map
|