Socket
Socket
Sign inDemoInstall

@primer/view-components

Package Overview
Dependencies
Maintainers
8
Versions
5358
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@primer/view-components - npm Package Compare versions

Comparing version 0.0.40 to 0.0.41

app/components/primer/local_time.d.ts

2

app/assets/javascripts/primer_view_components.js

@@ -1,2 +0,2 @@

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),o=n.indexOf(e);if(o===n.length-1&&1===t||0===o&&-1===t)return this.clearSelection(),void this.input.focus();let r=1===t?0:n.length-1;if(e&&o>=0){const e=o+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"),s(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 s(t,e){(function(t,e){const n=t.scrollTop,i=n+t.clientHeight,s=e.offsetTop,o=s+e.clientHeight;return s>=n&&o<=i})(t,e)||(t.scrollTop=e.offsetTop)}class o extends CustomEvent{constructor(t,e){super(t,e),this.relatedTarget=e.relatedTarget}}const r=new WeakMap;function a(t,e){const n=new XMLHttpRequest;return n.open("GET",e,!0),n.setRequestHeader("Accept","text/fragment+html"),function(t,e){const n=r.get(t);n&&n.abort();r.set(t,e);const i=()=>r.delete(t),s=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 s.then(i,i),s}(t,n)}class c{constructor(t,n,i){this.container=t,this.input=n,this.results=i,this.combobox=new e(n,i),this.results.hidden=!0,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.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)}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)}onKeydown(t){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.container.value=n}onResultsMouseDown(){this.interactingWithList=!0}onInputChange(){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++}`}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")),a(this.input,n.toString()).then((t=>{this.results.innerHTML=t,this.identifyOptions();const e=!!this.results.querySelector('[role="option"]');this.container.open=e,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)}}const u=new WeakMap;class l extends HTMLElement{constructor(){super()}connectedCallback(){const t=this.getAttribute("for");if(!t)return;const e=this.querySelector("input"),n=document.getElementById(t);e instanceof HTMLInputElement&&n&&(u.set(this,new c(this,e,n)),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 o("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 m(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 o=n.getElementById(e);o&&(s=o,s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement?h(s.value):s instanceof HTMLAnchorElement&&s.hasAttribute("href")?h(s.href):d(s)).then(i)}var s}function f(t){const e=t.currentTarget;e instanceof HTMLElement&&m(e)}function p(t){if(" "===t.key||"Enter"===t.key){const e=t.currentTarget;e instanceof HTMLElement&&(t.preventDefault(),m(e))}}function g(t){t.currentTarget.addEventListener("keydown",p)}function b(t){t.currentTarget.removeEventListener("keydown",p)}window.customElements.get("auto-complete")||(window.AutocompleteElement=l,window.customElements.define("auto-complete",l));class w extends HTMLElement{constructor(){super(),this.addEventListener("click",f),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)}}function v(t){""===t.style.display||"block"===t.style.display?t.style.display="none":t.style.display="block"}function y(t){const[e,n]=t.querySelectorAll(".octicon");e&&n&&(v(e),v(n))}window.customElements.get("clipboard-copy")||(window.ClipboardCopyElement=w,window.customElements.define("clipboard-copy",w)),document.addEventListener("clipboard-copy",(function({target:t}){t instanceof HTMLElement&&(y(t),setTimeout(y,2e3,t))}));class E extends HTMLElement{constructor(){super(),this.addEventListener("keydown",(t=>{const e=t.target;if(!(e instanceof HTMLElement))return;if("tab"!==e.getAttribute("role")&&!e.closest('[role="tablist"]'))return;const n=Array.from(this.querySelectorAll('[role="tablist"] [role="tab"]')),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=Array.from(this.querySelectorAll('[role="tablist"] [role="tab"]'));if(!(t.target instanceof Element))return;const n=t.target.closest('[role="tab"]');if(!n||!n.closest('[role="tablist"]'))return;A(this,e.indexOf(n))}))}connectedCallback(){for(const t of this.querySelectorAll('[role="tablist"] [role="tab"]'))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=t.querySelectorAll('[role="tablist"] [role="tab"]'),i=t.querySelectorAll('[role="tabpanel"]'),s=n[e],o=i[e];if(!!t.dispatchEvent(new CustomEvent("tab-container-change",{bubbles:!0,cancelable:!0,detail:{relatedTarget:o}}))){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");s.setAttribute("aria-selected","true"),s.setAttribute("tabindex","0"),s.focus(),o.hidden=!1,t.dispatchEvent(new CustomEvent("tab-container-changed",{bubbles:!0,detail:{relatedTarget:o}}))}}window.customElements.get("tab-container")||(window.TabContainerElement=E,window.customElements.define("tab-container",E));const M=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],T=["January","February","March","April","May","June","July","August","September","October","November","December"];function x(t){return"0".concat(t).slice(-2)}function L(t,e){const n=t.getDay(),i=t.getDate(),s=t.getMonth(),o=t.getFullYear(),r=t.getHours(),a=t.getMinutes(),c=t.getSeconds();return e.replace(/%([%aAbBcdeHIlmMpPSwyYZz])/g,(function(e){let u;switch(e[1]){case"%":return"%";case"a":return M[n].slice(0,3);case"A":return M[n];case"b":return T[s].slice(0,3);case"B":return T[s];case"c":return t.toString();case"d":return x(i);case"e":return String(i);case"H":return x(r);case"I":return x(L(t,"%l"));case"l":return String(0===r||12===r?12:(r+12)%12);case"m":return x(s+1);case"M":return x(a);case"p":return r>11?"PM":"AM";case"P":return r>11?"pm":"am";case"S":return x(c);case"w":return String(n);case"y":return x(o%100);case"Y":return String(o);case"Z":return u=t.toString().match(/\((\w+)\)$/),u?u[1]:"";case"z":return u=t.toString().match(/\w([+-]\d\d\d\d) /),u?u[1]:""}return""}))}function k(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=k({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=k({day:"numeric",month:"short",year:"numeric"});function R(t){const e=t.closest("[lang]");return e instanceof HTMLElement&&e.lang?e.lang:"default"}const F=new WeakMap;class Y extends HTMLElement{static get observedAttributes(){return["datetime","day","format","lang","hour","minute","month","second","title","weekday","year"]}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)?F.delete(this):F.set(this,new Date(t))}const s=this.getFormattedTitle(),o=this.getAttribute("title");"title"===t||!s||o&&o!==i||this.setAttribute("title",s);const r=this.getFormattedDate();r&&(this.textContent=r)}get date(){return F.get(this)}getFormattedTitle(){const t=this.date;if(!t)return;const e=q();if(e)return e.format(t);try{return t.toLocaleString()}catch(e){if(e instanceof RangeError)return t.toString();throw e}}getFormattedDate(){}}const q=k({day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}),X=new WeakMap;class W extends Y{attributeChangedCallback(t,e,n){"hour"!==t&&"minute"!==t&&"second"!==t&&"time-zone-name"!==t||X.delete(this),super.attributeChangedCallback(t,e,n)}getFormattedDate(){const t=this.date;if(!t)return;const e=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 s=n[e][t.getAttribute(e)];i=i.replace(e,s||"")}return i=i.replace(/(\s,)|(,\s$)/,""),L(e,i).replace(/\s+/," ").trim()}(this,t)||"",n=function(t,e){const n={},i=t.getAttribute("hour");"numeric"!==i&&"2-digit"!==i||(n.hour=i);const s=t.getAttribute("minute");"numeric"!==s&&"2-digit"!==s||(n.minute=s);const o=t.getAttribute("second");"numeric"!==o&&"2-digit"!==o||(n.second=o);const r=t.getAttribute("time-zone-name");"short"!==r&&"long"!==r||(n.timeZoneName=r);if(0===Object.keys(n).length)return;let a=X.get(t);a||(a=k(n),X.set(t,a));const c=a();if(c)return c.format(e);return L(e,n.second?"%H:%M:%S":"%H:%M")}(this,t)||"";return"".concat(e," ").concat(n).trim()}}window.customElements.get("local-time")||(window.LocalTimeElement=W,window.customElements.define("local-time",W));class K{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 ".concat(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),s=Math.round(i/24);return t>=0&&s<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),s=Math.round(i/24);return t>=0&&s<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),s=Math.round(i/24),o=Math.round(s/30),r=Math.round(o/12);return t<0||e<10?O(this.locale,0,"second"):e<45?O(this.locale,-e,"second"):e<90||n<45?O(this.locale,-n,"minute"):n<90||i<24?O(this.locale,-i,"hour"):i<36||s<30?O(this.locale,-s,"day"):o<18?O(this.locale,-o,"month"):O(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),s=Math.round(i/24),o=Math.round(s/30),r=Math.round(o/12);return n<1?"1m":n<60?"".concat(n,"m"):i<24?"".concat(i,"h"):s<365?"".concat(s,"d"):"".concat(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),s=Math.round(i/24),o=Math.round(s/30),r=Math.round(o/12);return o>=18||o>=12?O(this.locale,r,"year"):s>=45||s>=30?O(this.locale,o,"month"):i>=36||i>=24?O(this.locale,s,"day"):n>=90||n>=45?O(this.locale,i,"hour"):e>=90||e>=45?O(this.locale,n,"minute"):O(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),s=Math.round(i/24),o=Math.round(s/30),r=Math.round(o/12);return s>=365?"".concat(r,"y"):i>=24?"".concat(s,"d"):n>=60?"".concat(i,"h"):n>1?"".concat(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"),L(this.date,t)}formatTime(){const t=U();return t?t.format(this.date):L(this.date,"%l:%M%P")}}function O(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 ".concat(e);case"day":return"today";case"hour":case"minute":return"in 0 ".concat(e,"s");case"second":return"now"}else if(1===t)switch(e){case"year":case"quarter":case"month":case"week":return"next ".concat(e);case"day":return"tomorrow";case"hour":case"minute":case"second":return"in 1 ".concat(e)}else if(-1===t)switch(e){case"year":case"quarter":case"month":case"week":return"last ".concat(e);case"day":return"yesterday";case"hour":case"minute":case"second":return"1 ".concat(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 ".concat(t," ").concat(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"".concat(-t," ").concat(e,"s ago")}throw new RangeError("Invalid unit argument for format() '".concat(e,"'"))}(e,n)}const U=k({hour:"numeric",minute:"2-digit"});class z extends Y{getFormattedDate(){const t=this.date;if(t)return new K(t,R(this)).toString()}connectedCallback(){P.push(this),B||($(),B=setInterval($,6e4)),super.connectedCallback()}disconnectedCallback(){const t=P.indexOf(this);-1!==t&&P.splice(t,1),P.length||B&&(clearInterval(B),B=null)}}const P=[];let B;function $(){let t,e,n;for(e=0,n=P.length;e<n;e++)t=P[e],t.textContent=t.getFormattedDate()||""}window.customElements.get("relative-time")||(window.RelativeTimeElement=z,window.customElements.define("relative-time",z));class N extends z{getFormattedDate(){const t=this.getAttribute("format"),e=this.date;if(e)return"micro"===t?new K(e,R(this)).microTimeAgo():new K(e,R(this)).timeAgo()}}window.customElements.get("time-ago")||(window.TimeAgoElement=N,window.customElements.define("time-ago",N));class Z extends z{getFormattedDate(){const t=this.getAttribute("format"),e=this.date;if(e)return"micro"===t?new K(e,R(this)).microTimeUntil():new K(e,R(this)).timeUntil()}}window.customElements.get("time-until")||(window.TimeUntilElement=Z,window.customElements.define("time-until",Z));const j=new WeakMap,J=new WeakMap,G=new WeakMap;function Q(t){const e=t.currentTarget;if(!(e instanceof ot))return;const{box:n,image:i}=G.get(e)||{};if(!n||!i)return;let s=0,o=0;if(t instanceof KeyboardEvent)"ArrowUp"===t.key?o=-1:"ArrowDown"===t.key?o=1:"ArrowLeft"===t.key?s=-1:"ArrowRight"===t.key&&(s=1);else if(J.has(e)&&t instanceof MouseEvent){const n=J.get(e);s=t.pageX-n.dragStartX,o=t.pageY-n.dragStartY}else if(J.has(e)&&t instanceof TouchEvent){const{pageX:n,pageY:i}=t.changedTouches[0],{dragStartX:r,dragStartY:a}=J.get(e);s=n-r,o=i-a}if(0!==s||0!==o){const t=Math.min(Math.max(0,n.offsetLeft+s),i.width-n.offsetWidth),r=Math.min(Math.max(0,n.offsetTop+o),i.height-n.offsetHeight);n.style.left=`${t}px`,n.style.top=`${r}px`,st(e,{x:t,y:r,width:n.offsetWidth,height:n.offsetHeight})}if(t instanceof MouseEvent)J.set(e,{dragStartX:t.pageX,dragStartY:t.pageY});else if(t instanceof TouchEvent){const{pageX:n,pageY:i}=t.changedTouches[0];J.set(e,{dragStartX:n,dragStartY:i})}}function V(t){const e=t.target;if(!(e instanceof HTMLElement))return;const n=_(e);if(!(n instanceof ot))return;const{box:i}=G.get(n)||{};if(!i)return;const s=n.getBoundingClientRect();let o,r,a;if(t instanceof KeyboardEvent){if("Escape"===t.key)return nt(n);if("-"===t.key&&(a=-10),"="===t.key&&(a=10),!a)return;o=i.offsetWidth+a,r=i.offsetHeight+a,j.set(n,{startX:i.offsetLeft,startY:i.offsetTop})}else if(t instanceof MouseEvent){const e=j.get(n);if(!e)return;o=t.pageX-e.startX-s.left-window.pageXOffset,r=t.pageY-e.startY-s.top-window.pageYOffset}else if(t instanceof TouchEvent){const e=j.get(n);if(!e)return;o=t.changedTouches[0].pageX-e.startX-s.left-window.pageXOffset,r=t.changedTouches[0].pageY-e.startY-s.top-window.pageYOffset}o&&r&&et(n,o,r,!(t instanceof KeyboardEvent))}function _(t){const e=t.getRootNode();return e instanceof ShadowRoot?e.host:t}function tt(t){const e=t.currentTarget;if(!(e instanceof HTMLElement))return;const n=_(e);if(!(n instanceof ot))return;const{box:i}=G.get(n)||{};if(!i)return;const s=t.target;if(s instanceof HTMLElement)if(s.hasAttribute("data-direction")){const e=s.getAttribute("data-direction")||"";n.addEventListener("mousemove",V),n.addEventListener("touchmove",V,{passive:!0}),["nw","se"].indexOf(e)>=0&&n.classList.add("nwse"),["ne","sw"].indexOf(e)>=0&&n.classList.add("nesw"),j.set(n,{startX:i.offsetLeft+(["se","ne"].indexOf(e)>=0?0:i.offsetWidth),startY:i.offsetTop+(["se","sw"].indexOf(e)>=0?0:i.offsetHeight)}),V(t)}else n.addEventListener("mousemove",Q),n.addEventListener("touchmove",Q,{passive:!0})}function et(t,e,n,i=!0){let s=Math.max(Math.abs(e),Math.abs(n),10);const o=j.get(t);if(!o)return;const{box:r,image:a}=G.get(t)||{};if(!r||!a)return;s=Math.min(s,n>0?a.height-o.startY:o.startY,e>0?a.width-o.startX:o.startX);const c=i?Math.round(Math.max(0,e>0?o.startX:o.startX-s)):r.offsetLeft,u=i?Math.round(Math.max(0,n>0?o.startY:o.startY-s)):r.offsetTop;r.style.left=`${c}px`,r.style.top=`${u}px`,r.style.width=`${s}px`,r.style.height=`${s}px`,st(t,{x:c,y:u,width:s,height:s})}function nt(t){const{image:e}=G.get(t)||{};if(!e)return;const n=Math.round(e.clientWidth>e.clientHeight?e.clientHeight:e.clientWidth);j.set(t,{startX:(e.clientWidth-n)/2,startY:(e.clientHeight-n)/2}),et(t,n,n)}function it(t){const e=t.currentTarget;e instanceof ot&&(J.delete(e),e.classList.remove("nwse","nesw"),e.removeEventListener("mousemove",V),e.removeEventListener("mousemove",Q),e.removeEventListener("touchmove",V),e.removeEventListener("touchmove",Q))}function st(t,e){const{image:n}=G.get(t)||{};if(!n)return;const i=n.naturalWidth/n.width;for(const n in e){const s=Math.round(e[n]*i);e[n]=s;const o=t.querySelector(`[data-image-crop-input='${n}']`);o instanceof HTMLInputElement&&(o.value=s.toString())}t.dispatchEvent(new CustomEvent("image-crop-change",{bubbles:!0,detail:e}))}class ot extends HTMLElement{connectedCallback(){if(G.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&&(G.set(this,{box:e,image:n}),n.addEventListener("load",(()=>{this.loaded=!0,nt(this)})),this.addEventListener("mouseleave",it),this.addEventListener("touchend",it),this.addEventListener("mouseup",it),e.addEventListener("mousedown",tt),e.addEventListener("touchstart",tt,{passive:!0}),this.addEventListener("keydown",Q),this.addEventListener("keydown",V),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}=G.get(this)||{};"src"===t&&(this.loaded=!1,i&&(i.src=n))}}window.customElements.get("image-crop")||(window.ImageCropElement=ot,window.customElements.define("image-crop",ot));
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),o=n.indexOf(e);if(o===n.length-1&&1===t||0===o&&-1===t)return this.clearSelection(),void this.input.focus();let r=1===t?0:n.length-1;if(e&&o>=0){const e=o+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"),s(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 s(t,e){(function(t,e){const n=t.scrollTop,i=n+t.clientHeight,s=e.offsetTop,o=s+e.clientHeight;return s>=n&&o<=i})(t,e)||(t.scrollTop=e.offsetTop)}class o extends CustomEvent{constructor(t,e){super(t,e),this.relatedTarget=e.relatedTarget}}const r=new WeakMap;function a(t,e){const n=new XMLHttpRequest;return n.open("GET",e,!0),n.setRequestHeader("Accept","text/fragment+html"),function(t,e){const n=r.get(t);n&&n.abort();r.set(t,e);const i=()=>r.delete(t),s=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 s.then(i,i),s}(t,n)}class c{constructor(t,n,i){this.container=t,this.input=n,this.results=i,this.combobox=new e(n,i),this.results.hidden=!0,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.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)}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)}onKeydown(t){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.container.value=n}onResultsMouseDown(){this.interactingWithList=!0}onInputChange(){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++}`}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")),a(this.input,n.toString()).then((t=>{this.results.innerHTML=t,this.identifyOptions();const e=!!this.results.querySelector('[role="option"]');this.container.open=e,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)}}const u=new WeakMap;class l extends HTMLElement{constructor(){super()}connectedCallback(){const t=this.getAttribute("for");if(!t)return;const e=this.querySelector("input"),n=document.getElementById(t);e instanceof HTMLInputElement&&n&&(u.set(this,new c(this,e,n)),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 o("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 m(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 o=n.getElementById(e);o&&(s=o,s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement?h(s.value):s instanceof HTMLAnchorElement&&s.hasAttribute("href")?h(s.href):d(s)).then(i)}var s}function f(t){const e=t.currentTarget;e instanceof HTMLElement&&m(e)}function p(t){if(" "===t.key||"Enter"===t.key){const e=t.currentTarget;e instanceof HTMLElement&&(t.preventDefault(),m(e))}}function g(t){t.currentTarget.addEventListener("keydown",p)}function b(t){t.currentTarget.removeEventListener("keydown",p)}window.customElements.get("auto-complete")||(window.AutocompleteElement=l,window.customElements.define("auto-complete",l));class w extends HTMLElement{constructor(){super(),this.addEventListener("click",f),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=w,window.customElements.define("clipboard-copy",w));function v(t){""===t.style.display||"block"===t.style.display?t.style.display="none":t.style.display="block"}function y(t){const[e,n]=t.querySelectorAll(".octicon");e&&n&&(v(e),v(n))}const E=new WeakMap;document.addEventListener("clipboard-copy",(function({target:t}){if(!(t instanceof HTMLElement))return;if(!t.hasAttribute("data-view-component"))return;const e=E.get(t);e?(clearTimeout(e),E.delete(t)):y(t),E.set(t,setTimeout(y,2e3,t))}));class A extends HTMLElement{constructor(){super(),this.addEventListener("keydown",(t=>{const e=t.target;if(!(e instanceof HTMLElement))return;if("tab"!==e.getAttribute("role")&&!e.closest('[role="tablist"]'))return;const n=Array.from(this.querySelectorAll('[role="tablist"] [role="tab"]')),i=n.indexOf(n.find((t=>t.matches('[aria-selected="true"]'))));if("ArrowRight"===t.code){let t=i+1;t>=n.length&&(t=0),M(this,t)}else if("ArrowLeft"===t.code){let t=i-1;t<0&&(t=n.length-1),M(this,t)}else"Home"===t.code?(M(this,0),t.preventDefault()):"End"===t.code&&(M(this,n.length-1),t.preventDefault())})),this.addEventListener("click",(t=>{const e=Array.from(this.querySelectorAll('[role="tablist"] [role="tab"]'));if(!(t.target instanceof Element))return;const n=t.target.closest('[role="tab"]');if(!n||!n.closest('[role="tablist"]'))return;M(this,e.indexOf(n))}))}connectedCallback(){for(const t of this.querySelectorAll('[role="tablist"] [role="tab"]'))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 M(t,e){const n=t.querySelectorAll('[role="tablist"] [role="tab"]'),i=t.querySelectorAll('[role="tabpanel"]'),s=n[e],o=i[e];if(!!t.dispatchEvent(new CustomEvent("tab-container-change",{bubbles:!0,cancelable:!0,detail:{relatedTarget:o}}))){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");s.setAttribute("aria-selected","true"),s.setAttribute("tabindex","0"),s.focus(),o.hidden=!1,t.dispatchEvent(new CustomEvent("tab-container-changed",{bubbles:!0,detail:{relatedTarget:o}}))}}window.customElements.get("tab-container")||(window.TabContainerElement=A,window.customElements.define("tab-container",A));const T=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],x=["January","February","March","April","May","June","July","August","September","October","November","December"];function L(t){return`0${t}`.slice(-2)}function k(t,e){const n=t.getDay(),i=t.getDate(),s=t.getMonth(),o=t.getFullYear(),r=t.getHours(),a=t.getMinutes(),c=t.getSeconds();return e.replace(/%([%aAbBcdeHIlmMpPSwyYZz])/g,(function(e){let u;switch(e[1]){case"%":return"%";case"a":return T[n].slice(0,3);case"A":return T[n];case"b":return x[s].slice(0,3);case"B":return x[s];case"c":return t.toString();case"d":return L(i);case"e":return String(i);case"H":return L(r);case"I":return L(k(t,"%l"));case"l":return String(0===r||12===r?12:(r+12)%12);case"m":return L(s+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(o%100);case"Y":return String(o);case"Z":return u=t.toString().match(/\((\w+)\)$/),u?u[1]:"";case"z":return u=t.toString().match(/\w([+-]\d\d\d\d) /),u?u[1]:""}return""}))}function C(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 S=null;const H=C({day:"numeric",month:"short"});function D(){if(null!==S)return S;const t=H();if(t){const e=t.format(new Date(0));return S=!!e.match(/^\d/),S}return!1}let $=null;const I=C({day:"numeric",month:"short",year:"numeric"});function R(t){const e=t.closest("[lang]");return e instanceof HTMLElement&&e.lang?e.lang:"default"}const F=new WeakMap;class Y 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)?F.delete(this):F.set(this,new Date(t))}const s=this.getFormattedTitle(),o=this.getAttribute("title");"title"===t||!s||o&&o!==i||this.setAttribute("title",s);const r=this.getFormattedDate();r&&(this.textContent=r)}get date(){return F.get(this)}getFormattedTitle(){const t=this.date;if(!t)return;const e=q();if(e)return e.format(t);try{return t.toLocaleString()}catch(e){if(e instanceof RangeError)return t.toString();throw e}}getFormattedDate(){}}const q=C({day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}),W=new WeakMap;class X extends Y{attributeChangedCallback(t,e,n){"hour"!==t&&"minute"!==t&&"second"!==t&&"time-zone-name"!==t||W.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=D()?"weekday day month year":"weekday month day, year";for(const e in n){const s=n[e][t.getAttribute(e)||""];i=i.replace(e,s||"")}return i=i.replace(/(\s,)|(,\s$)/,""),k(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 s=t.getAttribute("minute");"numeric"!==s&&"2-digit"!==s||(n.minute=s);const o=t.getAttribute("second");"numeric"!==o&&"2-digit"!==o||(n.second=o);const r=t.getAttribute("time-zone-name");"short"!==r&&"long"!==r||(n.timeZoneName=r);if(0===Object.keys(n).length)return;let a=W.get(t);a||(a=C(n),W.set(t,a));const c=a();if(c)return c.format(e);return k(e,n.second?"%H:%M:%S":"%H:%M")}(this,t)||""}`.trim()}}window.customElements.get("local-time")||(window.LocalTimeElement=X,window.customElements.define("local-time",X));class K{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),s=Math.round(i/24);return t>=0&&s<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),s=Math.round(i/24);return t>=0&&s<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),s=Math.round(i/24),o=Math.round(s/30),r=Math.round(o/12);return t<0||e<10?O(this.locale,0,"second"):e<45?O(this.locale,-e,"second"):e<90||n<45?O(this.locale,-n,"minute"):n<90||i<24?O(this.locale,-i,"hour"):i<36||s<30?O(this.locale,-s,"day"):o<18?O(this.locale,-o,"month"):O(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),s=Math.round(i/24),o=Math.round(s/30),r=Math.round(o/12);return n<1?"1m":n<60?`${n}m`:i<24?`${i}h`:s<365?`${s}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),s=Math.round(i/24),o=Math.round(s/30),r=Math.round(o/12);return o>=18||o>=12?O(this.locale,r,"year"):s>=45||s>=30?O(this.locale,o,"month"):i>=36||i>=24?O(this.locale,s,"day"):n>=90||n>=45?O(this.locale,i,"hour"):e>=90||e>=45?O(this.locale,n,"minute"):O(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),s=Math.round(i/24),o=Math.round(s/30),r=Math.round(o/12);return s>=365?`${r}y`:i>=24?`${s}d`:n>=60?`${i}h`:n>1?`${n}m`:"1m"}formatDate(){let t=D()?"%e %b":"%b %e";var e;return e=this.date,(new Date).getUTCFullYear()!==e.getUTCFullYear()&&(t+=function(){if(null!==$)return $;const t=I();if(t){const e=t.format(new Date(0));return $=!!e.match(/\d,/),$}return!0}()?", %Y":" %Y"),k(this.date,t)}formatTime(){const t=z();return t?t.format(this.date):k(this.date,"%l:%M%P")}}function O(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 z=C({hour:"numeric",minute:"2-digit"});class U extends Y{getFormattedDate(){const t=this.date;if(t)return new K(t,R(this)).toString()}connectedCallback(){P.push(this),B||(N(),B=window.setInterval(N,6e4)),super.connectedCallback()}disconnectedCallback(){const t=P.indexOf(this);-1!==t&&P.splice(t,1),P.length||B&&(clearInterval(B),B=null)}}const P=[];let B;function N(){let t,e,n;for(e=0,n=P.length;e<n;e++)t=P[e],t.textContent=t.getFormattedDate()||""}window.customElements.get("relative-time")||(window.RelativeTimeElement=U,window.customElements.define("relative-time",U));class Z extends U{getFormattedDate(){const t=this.getAttribute("format"),e=this.date;if(e)return"micro"===t?new K(e,R(this)).microTimeAgo():new K(e,R(this)).timeAgo()}}window.customElements.get("time-ago")||(window.TimeAgoElement=Z,window.customElements.define("time-ago",Z));class j extends U{getFormattedDate(){const t=this.getAttribute("format"),e=this.date;if(e)return"micro"===t?new K(e,R(this)).microTimeUntil():new K(e,R(this)).timeUntil()}}window.customElements.get("time-until")||(window.TimeUntilElement=j,window.customElements.define("time-until",j));const J=new WeakMap,G=new WeakMap,Q=new WeakMap;function V(t){const e=t.currentTarget;if(!(e instanceof rt))return;const{box:n,image:i}=Q.get(e)||{};if(!n||!i)return;let s=0,o=0;if(t instanceof KeyboardEvent)"ArrowUp"===t.key?o=-1:"ArrowDown"===t.key?o=1:"ArrowLeft"===t.key?s=-1:"ArrowRight"===t.key&&(s=1);else if(G.has(e)&&t instanceof MouseEvent){const n=G.get(e);s=t.pageX-n.dragStartX,o=t.pageY-n.dragStartY}else if(G.has(e)&&t instanceof TouchEvent){const{pageX:n,pageY:i}=t.changedTouches[0],{dragStartX:r,dragStartY:a}=G.get(e);s=n-r,o=i-a}if(0!==s||0!==o){const t=Math.min(Math.max(0,n.offsetLeft+s),i.width-n.offsetWidth),r=Math.min(Math.max(0,n.offsetTop+o),i.height-n.offsetHeight);n.style.left=`${t}px`,n.style.top=`${r}px`,ot(e,{x:t,y:r,width:n.offsetWidth,height:n.offsetHeight})}if(t instanceof MouseEvent)G.set(e,{dragStartX:t.pageX,dragStartY:t.pageY});else if(t instanceof TouchEvent){const{pageX:n,pageY:i}=t.changedTouches[0];G.set(e,{dragStartX:n,dragStartY:i})}}function _(t){const e=t.target;if(!(e instanceof HTMLElement))return;const n=tt(e);if(!(n instanceof rt))return;const{box:i}=Q.get(n)||{};if(!i)return;const s=n.getBoundingClientRect();let o,r,a;if(t instanceof KeyboardEvent){if("Escape"===t.key)return it(n);if("-"===t.key&&(a=-10),"="===t.key&&(a=10),!a)return;o=i.offsetWidth+a,r=i.offsetHeight+a,J.set(n,{startX:i.offsetLeft,startY:i.offsetTop})}else if(t instanceof MouseEvent){const e=J.get(n);if(!e)return;o=t.pageX-e.startX-s.left-window.pageXOffset,r=t.pageY-e.startY-s.top-window.pageYOffset}else if(t instanceof TouchEvent){const e=J.get(n);if(!e)return;o=t.changedTouches[0].pageX-e.startX-s.left-window.pageXOffset,r=t.changedTouches[0].pageY-e.startY-s.top-window.pageYOffset}o&&r&&nt(n,o,r,!(t instanceof KeyboardEvent))}function tt(t){const e=t.getRootNode();return e instanceof ShadowRoot?e.host:t}function et(t){const e=t.currentTarget;if(!(e instanceof HTMLElement))return;const n=tt(e);if(!(n instanceof rt))return;const{box:i}=Q.get(n)||{};if(!i)return;const s=t.target;if(s instanceof HTMLElement)if(s.hasAttribute("data-direction")){const e=s.getAttribute("data-direction")||"";n.addEventListener("mousemove",_),n.addEventListener("touchmove",_,{passive:!0}),["nw","se"].indexOf(e)>=0&&n.classList.add("nwse"),["ne","sw"].indexOf(e)>=0&&n.classList.add("nesw"),J.set(n,{startX:i.offsetLeft+(["se","ne"].indexOf(e)>=0?0:i.offsetWidth),startY:i.offsetTop+(["se","sw"].indexOf(e)>=0?0:i.offsetHeight)}),_(t)}else n.addEventListener("mousemove",V),n.addEventListener("touchmove",V,{passive:!0})}function nt(t,e,n,i=!0){let s=Math.max(Math.abs(e),Math.abs(n),10);const o=J.get(t);if(!o)return;const{box:r,image:a}=Q.get(t)||{};if(!r||!a)return;s=Math.min(s,n>0?a.height-o.startY:o.startY,e>0?a.width-o.startX:o.startX);const c=i?Math.round(Math.max(0,e>0?o.startX:o.startX-s)):r.offsetLeft,u=i?Math.round(Math.max(0,n>0?o.startY:o.startY-s)):r.offsetTop;r.style.left=`${c}px`,r.style.top=`${u}px`,r.style.width=`${s}px`,r.style.height=`${s}px`,ot(t,{x:c,y:u,width:s,height:s})}function it(t){const{image:e}=Q.get(t)||{};if(!e)return;const n=Math.round(e.clientWidth>e.clientHeight?e.clientHeight:e.clientWidth);J.set(t,{startX:(e.clientWidth-n)/2,startY:(e.clientHeight-n)/2}),nt(t,n,n)}function st(t){const e=t.currentTarget;e instanceof rt&&(G.delete(e),e.classList.remove("nwse","nesw"),e.removeEventListener("mousemove",_),e.removeEventListener("mousemove",V),e.removeEventListener("touchmove",_),e.removeEventListener("touchmove",V))}function ot(t,e){const{image:n}=Q.get(t)||{};if(!n)return;const i=n.naturalWidth/n.width;for(const n in e){const s=Math.round(e[n]*i);e[n]=s;const o=t.querySelector(`[data-image-crop-input='${n}']`);o instanceof HTMLInputElement&&(o.value=s.toString())}t.dispatchEvent(new CustomEvent("image-crop-change",{bubbles:!0,detail:e}))}class rt extends HTMLElement{connectedCallback(){if(Q.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&&(Q.set(this,{box:e,image:n}),n.addEventListener("load",(()=>{this.loaded=!0,it(this)})),this.addEventListener("mouseleave",st),this.addEventListener("touchend",st),this.addEventListener("mouseup",st),e.addEventListener("mousedown",et),e.addEventListener("touchstart",et,{passive:!0}),this.addEventListener("keydown",V),this.addEventListener("keydown",_),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}=Q.get(this)||{};"src"===t&&(this.loaded=!1,i&&(i.src=n))}}window.customElements.get("image-crop")||(window.ImageCropElement=rt,window.customElements.define("image-crop",rt));
//# sourceMappingURL=primer_view_components.js.map
import '@github/clipboard-copy-element';
const CLIPBOARD_COPY_TIMER_DURATION = 2000;
function toggleSVG(svg) {

@@ -18,7 +19,17 @@ if (svg.style.display === '' || svg.style.display === 'block') {

}
const clipboardCopyElementTimers = new WeakMap();
document.addEventListener('clipboard-copy', function ({ target }) {
if (!(target instanceof HTMLElement))
return;
toggleCopyButton(target);
setTimeout(toggleCopyButton, 2000, target);
if (!target.hasAttribute('data-view-component'))
return;
const currentTimeout = clipboardCopyElementTimers.get(target);
if (currentTimeout) {
clearTimeout(currentTimeout);
clipboardCopyElementTimers.delete(target);
}
else {
toggleCopyButton(target);
}
clipboardCopyElementTimers.set(target, setTimeout(toggleCopyButton, CLIPBOARD_COPY_TIMER_DURATION, target));
});

@@ -5,2 +5,3 @@ import './auto_complete/auto_complete';

import './time_ago_component';
import './local_time';
import './image_crop';

@@ -5,2 +5,3 @@ import './auto_complete/auto_complete';

import './time_ago_component';
import './local_time';
import './image_crop';

@@ -5,2 +5,64 @@ # CHANGELOG

## 0.0.41
### New
* Create `LocalTime` component.
*Kristján Oddsson*
* Create `Image` component.
*Manuel Puyol*
* Add `extra` slot to `TabNav`.
*Manuel Puyol*
* Do not raise error if Primer CSS class name is passed to component if `PRIMER_WARNINGS_DISABLED` is set.
*Joel Hawksley*
### Accessibility
* Accept `aria-current="true"` in tabbed components.
*Manuel Puyol*
### Changes
* Promote `Tooltip` component to beta.
*Manuel Puyol*
### Bug fixes
* Ensure that `ClipboardCopy` behaviors only target ViewComponents.
*Manuel Puyol*
* Ensure that the `rounded` attribute for `<image-crop>` is represented as a boolean attribute.
*Kristján Oddsson*
### Breaking changes
* Don't allow `OcticonComponent` height/width values under 16px
*Jon Rohan*
* Remove `:large` size option from `OcticonComponent` and change `:medium` to 24px
*Jon Rohan*
* Restrict `Label` tag to `span`, `div`, `a`, `summary`.
*Kate Higa*
### Misc
* Add a CI check for changes to the CHANGELOG file.
*Kristján Oddsson*
## 0.0.40

@@ -7,0 +69,0 @@

{
"name": "@primer/view-components",
"version": "0.0.40",
"version": "0.0.41",
"description": "ViewComponents for the Primer Design System",

@@ -36,3 +36,3 @@ "main": "app/assets/javascripts/primer_view_components.js",

"@github/tab-container-element": "^3.1.0",
"@github/time-elements": "^3.1.1"
"@github/time-elements": "^3.1.2"
},

@@ -39,0 +39,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc