@stimulus-plumbers/controllers 0.3.2 → 0.4.0

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.
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@hotwired/stimulus`)):typeof define==`function`&&define.amd?define([`exports`,`@hotwired/stimulus`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.StimulusPlumbersControllers={},e.Stimulus))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=[`a[href]`,`area[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`,`audio[controls]`,`video[controls]`,`[contenteditable]:not([contenteditable="false"])`].join(`,`);function r(e){return Array.from(e.querySelectorAll(n)).filter(e=>i(e))}function i(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}function a(e){let t=r(e);return t.length>0?(t[0].focus(),!0):!1}var o=class{constructor(e,t={}){this.container=e,this.previouslyFocused=null,this.options=t,this.isActive=!1}activate(){this.isActive||(this.previouslyFocused=document.activeElement,this.isActive=!0,this.options.initialFocus?this.options.initialFocus.focus():a(this.container),this.container.addEventListener(`keydown`,this.handleKeyDown))}deactivate(){if(!this.isActive)return;this.isActive=!1,this.container.removeEventListener(`keydown`,this.handleKeyDown);let e=this.options.returnFocus||this.previouslyFocused;e&&i(e)&&e.focus()}handleKeyDown=e=>{if(e.key===`Escape`&&this.options.escapeDeactivates){e.preventDefault(),this.deactivate();return}if(e.key!==`Tab`)return;let t=r(this.container);if(t.length===0)return;let n=t[0],i=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),n.focus())}},s=class{constructor(){this.savedElement=null}save(){this.savedElement=document.activeElement}restore(){this.savedElement&&i(this.savedElement)&&(this.savedElement.focus(),this.savedElement=null)}};function c(e,t){return e.key===t}function l(e){return e.key===`Enter`||e.key===` `}function u(e){return[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`].includes(e.key)}function d(e){e.preventDefault(),e.stopPropagation()}var f=class{constructor(e,t=0){this.items=e,this.currentIndex=t,this.updateTabIndex()}handleKeyDown(e){let t;switch(e.key){case`ArrowDown`:case`ArrowRight`:e.preventDefault(),t=(this.currentIndex+1)%this.items.length;break;case`ArrowUp`:case`ArrowLeft`:e.preventDefault(),t=this.currentIndex===0?this.items.length-1:this.currentIndex-1;break;case`Home`:e.preventDefault(),t=0;break;case`End`:e.preventDefault(),t=this.items.length-1;break;default:return}this.setCurrentIndex(t)}setCurrentIndex(e){e>=0&&e<this.items.length&&(this.currentIndex=e,this.updateTabIndex(),this.items[e].focus())}updateTabIndex(){this.items.forEach((e,t)=>{e.tabIndex=t===this.currentIndex?0:-1})}updateItems(e){this.items=e,this.currentIndex=Math.min(this.currentIndex,e.length-1),this.updateTabIndex()}},p=(e,t,n)=>{let r=document.querySelector(`[data-live-region="${e}"]`);return r||(r=document.createElement(`div`),r.className=`sr-only`,r.dataset.liveRegion=e,r.setAttribute(`aria-live`,e),r.setAttribute(`aria-atomic`,t.toString()),r.setAttribute(`aria-relevant`,n),document.body.appendChild(r)),r};function m(e,t={}){let{politeness:n=`polite`,atomic:r=!0,relevant:i=`additions text`}=t,a=p(n,r,i);a.textContent=``,setTimeout(()=>{a.textContent=e},100)}var h=(e=`a11y`)=>`${e}-${Math.random().toString(36).substr(2,9)}`,ee=(e,t=`element`)=>e.id||=h(t),g=(e,t,n)=>{e.setAttribute(t,n.toString())},te=(e,t)=>g(e,`aria-expanded`,t),_=(e,t)=>g(e,`aria-pressed`,t),ne=(e,t)=>g(e,`aria-checked`,t);function re(e,t){g(e,`aria-disabled`,t),t?e.setAttribute(`tabindex`,`-1`):e.removeAttribute(`tabindex`)}var v={menu:`menu`,listbox:`listbox`,tree:`tree`,grid:`grid`,dialog:`dialog`},y=(e,t,n)=>{Object.entries(t).forEach(([t,r])=>{e.setAttribute(t,r),n[t]=r})},b=(e,t,n)=>n||!e.hasAttribute(t);function x({trigger:e,target:t,role:n=null,override:r=!1}){let i={trigger:{},target:{}};if(!e||!t)return i;let a={},o={};if(n&&b(t,`role`,r)&&(o.role=n),t.id&&(b(e,`aria-controls`,r)&&(a[`aria-controls`]=t.id),n===`tooltip`&&b(e,`aria-describedby`,r)&&(a[`aria-describedby`]=t.id)),n&&b(e,`aria-haspopup`,r)){let e=v[n]||`true`;e&&(a[`aria-haspopup`]=e)}return y(t,o,i.target),y(e,a,i.trigger),i}var S=(e,t)=>{t.forEach(t=>{e.hasAttribute(t)&&e.removeAttribute(t)})};function ie({trigger:e,target:t,attributes:n=null}){!e||!t||(S(e,n||[`aria-controls`,`aria-haspopup`,`aria-describedby`]),(!n||n.includes(`role`))&&S(t,[`role`]))}var C=class{constructor(){this._abortController=null,this._timer=null}schedule(e,t){clearTimeout(this._timer),this._timer=setTimeout(e,t)}async request(e,t={}){this._abortController?.abort(),this._abortController=new AbortController;let n=await fetch(e,{...t,signal:this._abortController.signal});if(!n.ok)throw Error(`${n.status}`);return n}cancel(){clearTimeout(this._timer),this._abortController?.abort()}};function w(e,t){let n=0;for(let r=0;r<t.length&&n<e.length;r++)t[r]===e[n]&&n++;return n===e.length}function ae(e,t){return t.includes(e)}function oe(e,t){return t.startsWith(e)}function se(e){return e===`contains`?ae:e===`prefix`?oe:w}function ce(e,t){return t===`textContent`?e.textContent?.trim().toLowerCase()??``:(e.getAttribute(t)??``).toLowerCase()}function T(e,t,n={}){let{strategy:r=`fuzzy`,matcher:i,fields:a=[`textContent`]}=n,o=typeof i==`function`?i:se(r),s=t.toLowerCase(),c=0;return e.querySelectorAll(`[role="option"]`).forEach(e=>{let t=a.some(t=>o(s,ce(e,t)));e.hidden=!t,t&&c++}),c}var E={get top(){return`bottom`},get bottom(){return`top`},get left(){return`right`},get right(){return`left`}};function D({x:e,y:t,width:n,height:r}){return{x:e,y:t,width:n,height:r,left:e,right:e+n,top:t,bottom:t+r}}function O(){return D({x:0,y:0,width:window.innerWidth||document.documentElement.clientWidth,height:window.innerHeight||document.documentElement.clientHeight})}function le(e){if(!(e instanceof HTMLElement))return!1;let t=O(),n=e.getBoundingClientRect(),r=n.top<=t.height&&n.top+n.height>0,i=n.left<=t.width&&n.left+n.width>0;return r&&i}var k={get visibleOnly(){return!0},hiddenClass:null},ue={element:null,visible:null,dispatch:!0,prefix:``},A=class{constructor(e,t={}){this.controller=e;let{element:n,visible:r,dispatch:i,prefix:a}=Object.assign({},ue,t);this.element=n||e.element,this.visibleOnly=typeof r==`boolean`?r:k.visibleOnly,this.visibleCallback=typeof r==`string`?r:null,this.notify=!!i,this.prefix=typeof a==`string`&&a?a:e.identifier}get visible(){return this.element instanceof HTMLElement?this.visibleOnly?le(this.element)&&this.isVisible(this.element):!0:!1}isVisible(e){if(this.visibleCallback){let t=this.findCallback(this.visibleCallback);if(typeof t==`function`)return t(e)}return e instanceof HTMLElement?!e.hasAttribute(`hidden`):!1}dispatch(e,{target:t=null,prefix:n=null,detail:r=null}={}){if(this.notify)return this.controller.dispatch(e,{target:t||this.element,prefix:n||this.prefix,detail:r})}findCallback(e){if(typeof e!=`string`)return;let t=this,n=e.split(`.`).reduce((e,t)=>e&&e[t],t.controller);if(typeof n==`function`)return n.bind(t.controller);let r=e.split(`.`).reduce((e,t)=>e&&e[t],t);if(typeof r==`function`)return r.bind(t)}async awaitCallback(e,...t){if(typeof e==`string`&&(e=this.findCallback(e)),typeof e==`function`){let n=e(...t);return n instanceof Promise?await n:n}}},de={normalize(e){return typeof e==`string`?e:``},validate(){return!0}};function fe(e){let t=0,n=!1;for(let r=e.length-1;r>=0;r--){let i=parseInt(e[r],10);n&&(i*=2,i>9&&(i-=9)),t+=i,n=!n}return t%10==0}var pe=/\D/g,me=/^\d{13,19}$/,he=/(.{4})(?=.)/g,ge={normalize(e){return typeof e==`string`?e.replace(pe,``):``},validate(e){return typeof e!=`string`||!me.test(e)?!1:fe(e)},format(e){return typeof e==`string`?e.replace(he,`$1 `):``}},j={1:10},M=/\D/g,_e=/^\+\d{7,15}$/,ve={normalize(e){if(typeof e!=`string`)return``;let t=e.trimStart().startsWith(`+`),n=e.replace(M,``);return t?`+${n}`:n},validate(e){if(typeof e!=`string`)return!1;if(_e.test(e))return!0;let t=e.replace(M,``);return Object.values(j).includes(t.length)},format(e){if(typeof e!=`string`)return``;let t=e.replace(M,``);for(let[e,n]of Object.entries(j)){if(t.length===n)return`(${t.slice(0,3)}) ${t.slice(3,6)}-${t.slice(6)}`;let r=n+e.length;if(t.length===r&&t.startsWith(e)){let n=t.slice(e.length);return`+${e} (${n.slice(0,3)}) ${n.slice(3,6)}-${n.slice(6)}`}}return e}},N=/[^\d.,-]/g,P=/^-?\d+(\.\d+)?$/,F={normalize(e){if(typeof e!=`string`)return``;let t=e.replace(N,``);if(!t)return``;let n=t.lastIndexOf(`,`),r=t.lastIndexOf(`.`);return n>-1&&r>-1?n>r?t.replace(/\./g,``).replace(`,`,`.`):t.replace(/,/g,``):n>-1?t.slice(n+1).length<=2?t.replace(`,`,`.`):t.replace(/,/g,``):t},validate(e){return typeof e==`string`?P.test(e):!1},format(e,t={}){if(typeof e!=`string`)return``;let n=parseFloat(e);if(isNaN(n))return e;let r=t.locale||`en-US`,i=t.currency||`USD`,a=t.fractionDigits===void 0?{}:{minimumFractionDigits:t.fractionDigits,maximumFractionDigits:t.fractionDigits};try{return new Intl.NumberFormat(r,{style:`currency`,currency:i,...a}).format(n)}catch{return e}}},I=/^\d{4}-\d{2}-\d{2}$/,ye=/^(\d{1,4})[/\-.](\d{1,2})[/\-.](\d{1,4})$/,be=/\D/g,L={normalize(e){if(typeof e!=`string`)return``;let t=e.trim();if(I.test(t))return t;let n=t.match(ye);if(n){let[,e,t,r]=n;if(e.length===4)return`${e}-${t.padStart(2,`0`)}-${r.padStart(2,`0`)}`;if(r.length===4)return`${r}-${e.padStart(2,`0`)}-${t.padStart(2,`0`)}`}let r=t.replace(be,``);if(r.length===8){let e=parseInt(r.slice(0,4),10);return e>=1e3&&e<=9999?`${r.slice(0,4)}-${r.slice(4,6)}-${r.slice(6,8)}`:`${r.slice(4,8)}-${r.slice(0,2)}-${r.slice(2,4)}`}return t},validate(e){if(typeof e!=`string`)return!1;let t=L.normalize(e);if(!I.test(t))return!1;let n=new Date(`${t}T00:00:00Z`);return!isNaN(n.getTime())&&n.toISOString().startsWith(t)},format(e,t={}){if(typeof e!=`string`)return``;let n=new Date(`${e}T00:00:00Z`);if(isNaN(n.getTime()))return e;let r=t.locale||`en-US`;try{return new Intl.DateTimeFormat(r,{year:t.year||`numeric`,month:t.month||`2-digit`,day:t.day||`2-digit`,timeZone:t.timeZone||`UTC`}).format(n)}catch{return e}}},xe=/^([01]?\d|2[0-3]):([0-5]\d)$/,R={normalize(e){if(typeof e!=`string`)return``;let t=e.trim();if(xe.test(t)){let[e,n]=t.split(`:`);return`${String(parseInt(e,10)).padStart(2,`0`)}:${n}`}let n=t.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);if(n){let e=parseInt(n[1],10),t=n[2];return e=n[3].toUpperCase()===`AM`?e===12?0:e:e===12?12:e+12,e>23||parseInt(t,10)>59?``:`${String(e).padStart(2,`0`)}:${t}`}return``},validate(e){return R.normalize(e)!==``},format(e,t={}){if(typeof e!=`string`)return``;let n=e.match(/^(\d{2}):(\d{2})$/);if(!n)return e;let r=parseInt(n[1],10),i=n[2];if(t.format===`h24`)return`${String(r).padStart(2,`0`)}:${i}`;let a=r<12?`AM`:`PM`;return`${r%12||12}:${i} ${a}`}},z={PLAIN:`plain`,CREDIT_CARD:`creditCard`,PHONE:`phone`,CURRENCY:`currency`,DATE:`date`,TIME:`time`},B=new Map([[z.PLAIN,de],[z.CREDIT_CARD,ge],[z.PHONE,ve],[z.CURRENCY,F],[z.DATE,L],[z.TIME,R]]),V={type:z.PLAIN,options:{}},H=class extends A{static register(e,t){B.set(e,t)}constructor(e,t={}){super(e,t),this.type=t.type??V.type,this.options=t.options??V.options,this.enhance()}enhance(){let e=this,t=B.get(e.type)??B.get(z.PLAIN),n={normalize:n=>t.normalize?.(n,e.options)??(typeof n==`string`?n:``),validate:n=>t.validate?.(n,e.options)??!0,format:n=>t.format?.(n,e.options)??(typeof n==`string`?n:``),mask:n=>t.mask?.(n,e.options)??null,maskable:()=>typeof t.mask==`function`};Object.defineProperty(this.controller,`formatter`,{get(){return n},configurable:!0})}},U=(e,t)=>new H(e,t);function W(e){return e instanceof Date&&!isNaN(e)}function G(...e){if(e.length===0)throw`Missing values to parse as date`;if(e.length===1){let t=new Date(e[0]);if(e[0]&&W(t))return t}else{let t=new Date(...e);if(W(t))return t}}var K=7,q={locales:[`default`],today:``,day:null,month:null,year:null,since:null,till:null,disabledDates:[],disabledWeekdays:[],disabledDays:[],disabledMonths:[],disabledYears:[],firstDayOfWeek:0,onNavigated:`navigated`},Se=class extends A{constructor(e,t={}){super(e,t);let n=Object.assign({},q,t),{onNavigated:r,since:i,till:a,firstDayOfWeek:o}=n;this.onNavigated=r,this.since=G(i),this.till=G(a),this.firstDayOfWeek=0<=o&&o<7?o:q.firstDayOfWeek;let{disabledDates:s,disabledWeekdays:c,disabledDays:l,disabledMonths:u,disabledYears:d}=n;this.disabledDates=Array.isArray(s)?s:[],this.disabledWeekdays=Array.isArray(c)?c:[],this.disabledDays=Array.isArray(l)?l:[],this.disabledMonths=Array.isArray(u)?u:[],this.disabledYears=Array.isArray(d)?d:[];let{today:f,day:p,month:m,year:h}=n;this.now=G(f)||new Date,typeof h==`number`&&typeof m==`number`&&typeof p==`number`?this.current=G(h,m,p):this.current=this.now,this.build(),this.enhance()}build(){this.daysOfWeek=this.buildDaysOfWeek(),this.daysOfMonth=this.buildDaysOfMonth(),this.monthsOfYear=this.buildMonthsOfYear()}buildDaysOfWeek(){let e=new Intl.DateTimeFormat(this.localesValue,{weekday:`long`}),t=new Intl.DateTimeFormat(this.localesValue,{weekday:`short`}),n=new Date(`2024-10-06`),r=[];for(let i=this.firstDayOfWeek,a=i+7;i<a;i++){let a=new Date(n);a.setDate(n.getDate()+i),r.push({date:a,value:a.getDay(),long:e.format(a),short:t.format(a)})}return r}buildDaysOfMonth(){let e=this.month,t=this.year,n=[],r=e=>({current:this.month===e.getMonth()&&this.year===e.getFullYear(),date:e,value:e.getDate(),month:e.getMonth(),year:e.getFullYear(),iso:e.toISOString()}),i=new Date(t,e).getDay(),a=this.firstDayOfWeek-i;for(let i=a>0?a-7:a;i<0;i++){let a=new Date(t,e,i+1);n.push(r(a))}let o=new Date(t,e+1,0).getDate();for(let i=1;i<=o;i++){let a=new Date(t,e,i);n.push(r(a))}let s=n.length%K,c=s===0?0:K-s;for(let i=1;i<=c;i++){let a=new Date(t,e+1,i);n.push(r(a))}return n}buildMonthsOfYear(){let e=new Intl.DateTimeFormat(this.localesValue,{month:`long`}),t=new Intl.DateTimeFormat(this.localesValue,{month:`short`}),n=new Intl.DateTimeFormat(this.localesValue,{month:`numeric`}),r=[];for(let i=0;i<12;i++){let a=new Date(this.year,i);r.push({date:a,value:a.getMonth(),long:e.format(a),short:t.format(a),numeric:n.format(a)})}return r}get today(){return this.now}set today(e){if(!W(e))return;let t=this.month?this.month:e.getMonth(),n=this.year?this.year:e.getFullYear(),r=t==e.getMonth()&&n==e.getFullYear(),i=this.hasDayValue?this.day:r?e.getDate():1;this.now=new Date(n,t,i).toISOString()}get current(){return typeof this.year==`number`&&typeof this.month==`number`&&typeof this.day==`number`?G(this.year,this.month,this.day):null}set current(e){W(e)&&(this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear())}navigate=async e=>{if(!W(e))return;let t=this.current,n=e.toISOString(),r=t.toISOString();this.dispatch(`navigate`,{detail:{from:r,to:n}}),this.current=e,this.build(),await this.awaitCallback(this.onNavigated,{from:r,to:n}),this.dispatch(`navigated`,{detail:{from:r,to:n}})};step=async(e,t)=>{if(t===0)return;let n=this.current;switch(e){case`year`:n.setFullYear(n.getFullYear()+t);break;case`month`:n.setMonth(n.getMonth()+t);break;case`day`:n.setDate(n.getDate()+t);break;default:return}await this.navigate(n)};isDisabled=e=>{if(!W(e))return!1;if(this.disabledDates.length){let t=e.getTime();for(let e of this.disabledDates)if(t===new Date(e).getTime())return!0}if(this.disabledWeekdays.length){let t=e.getDay(),n=this.daysOfWeek,r=n.findIndex(e=>e.value===t);if(r>=0){let e=n[r];for(let t of this.disabledWeekdays)if(e.value==t||e.short===t||e.long===t)return!0}}if(this.disabledDays.length){let t=e.getDate();for(let e of this.disabledDays)if(t==e)return!0}if(this.disabledMonths.length){let t=e.getMonth(),n=this.monthsOfYear,r=n.findIndex(e=>e.value===t);if(r>=0){let e=n[r];for(let t of this.disabledMonths)if(e.value==t||e.short===t||e.long===t)return!0}}if(this.disabledYears.length){let t=e.getFullYear();for(let e of this.disabledYears)if(t==e)return!0}return!1};isWithinRange=e=>{if(!W(e))return!1;let t=!0;return this.since&&(t&&=e>=this.since),this.till&&(t&&=e<=this.till),t};enhance(){let e=this;Object.assign(this.controller,{get calendar(){return{get today(){return e.today},get current(){return e.current},get day(){return e.day},get month(){return e.month},get year(){return e.year},get since(){return e.since},get till(){return e.till},get firstDayOfWeek(){return e.firstDayOfWeek},get disabledDates(){return e.disabledDates},get disabledWeekdays(){return e.disabledWeekdays},get disabledDays(){return e.disabledDays},get disabledMonths(){return e.disabledMonths},get disabledYears(){return e.disabledYears},get daysOfWeek(){return e.daysOfWeek},get daysOfMonth(){return e.daysOfMonth},get monthsOfYear(){return e.monthsOfYear},navigate:async t=>await e.navigate(t),step:async(t,n)=>await e.step(t,n),isDisabled:t=>e.isDisabled(t),isWithinRange:t=>e.isWithinRange(t)}}})}},Ce=(e,t)=>new Se(e,t),J={content:null,url:``,reload:`never`,stale:3600,onLoad:`canLoad`,onLoaded:`contentLoaded`},we=class extends A{constructor(e,t={}){super(e,t);let n=Object.assign({},J,t),{content:r,url:i,reload:a,stale:o}=n;this.content=r,this.url=i,this.reload=typeof a==`string`?a:J.reload,this.stale=typeof o==`number`?o:J.stale;let{onLoad:s,onLoaded:c}=n;this.onLoad=s,this.onLoaded=c,this._requestor=new C,this.enhance()}get reloadable(){switch(this.reload){case`never`:return!1;case`always`:return!0;default:{let e=G(this.loadedAt);return e&&new Date-e>this.stale*1e3}}}contentLoadable=({url:e})=>!!e;contentLoader=async()=>``;remoteContentLoader=async e=>(await this._requestor.request(e)).text();load=async()=>{if(this.loadedAt&&!this.reloadable)return;let e=this.findCallback(this.onLoad),t=await this.awaitCallback(e||this.contentLoadable,{url:this.url});if(this.dispatch(`load`,{detail:{url:this.url}}),!t)return;this.dispatch(`loading`,{detail:{url:this.url}});let n=this.url?await this.remoteContentLoader(this.url):await this.contentLoader();n&&(await this.awaitCallback(this.onLoaded,{url:this.url,content:n}),this.loadedAt=new Date().getTime(),this.dispatch(`loaded`,{detail:{url:this.url,content:n}}))};enhance(){let e=this;Object.assign(this.controller,{load:e.load.bind(e)})}},Te=(e,t)=>new we(e,t),Y=class extends A{observe(e){this._handler=e,this.events.forEach(t=>window.addEventListener(t,e,!0))}unobserve(){this._handler&&this.events.forEach(e=>window.removeEventListener(e,this._handler,!0))}enhance(){let e=this,t=this.controller.disconnect?.bind(this.controller)||(()=>{});this.controller.disconnect=()=>{e.unobserve(),t()}}},Ee={trigger:null,events:[`click`],onDismissed:`dismissed`},De=class extends Y{constructor(e,t={}){super(e,t);let{trigger:n,events:r,onDismissed:i}=Object.assign({},Ee,t);this.onDismissed=i,this.trigger=n||this.element,this.events=r,this.enhance(),this.observe(this.dismiss)}dismiss=async e=>{let{target:t}=e;t instanceof HTMLElement&&(this.element.contains(t)||this.visible&&(this.dispatch(`dismiss`),await this.awaitCallback(this.onDismissed,{target:this.trigger}),this.dispatch(`dismissed`)))}},X=(e,t)=>new De(e,t),Oe={anchor:null,events:[`click`],placement:`bottom`,alignment:`start`,onFlipped:`flipped`,ariaRole:null,respectMotion:!0},ke=class extends Y{constructor(e,t={}){super(e,t);let{anchor:n,events:r,placement:i,alignment:a,onFlipped:o,ariaRole:s,respectMotion:c}=Object.assign({},Oe,t);this.anchor=n,this.events=r,this.placement=i,this.alignment=a,this.onFlipped=o,this.ariaRole=s,this.respectMotion=c,this.prefersReducedMotion=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,this.anchor&&this.element&&x({trigger:this.anchor,target:this.element,role:this.ariaRole}),this.enhance(),this.observe(this.flip)}flip=async()=>{if(!this.visible)return;this.dispatch(`flip`),window.getComputedStyle(this.element).position!=`absolute`&&(this.element.style.position=`absolute`);let e=this.flippedRect(this.anchor.getBoundingClientRect(),this.element.getBoundingClientRect());this.element.style.transition=this.respectMotion&&this.prefersReducedMotion?`none`:``;for(let[t,n]of Object.entries(e))this.element.style[t]=n;await this.awaitCallback(this.onFlipped,{target:this.element,placement:e}),this.dispatch(`flipped`,{detail:{placement:e}})};flippedRect(e,t){let n=this.quadrumRect(e,O()),r=[this.placement,E[this.placement]],i={};for(;!Object.keys(i).length&&r.length>0;){let a=r.shift();if(!this.biggerRectThan(n[a],t))continue;let o=this.quadrumPlacement(e,a,t),s=this.quadrumAlignment(e,a,o);i.top=`${s.top+window.scrollY}px`,i.left=`${s.left+window.scrollX}px`}return Object.keys(i).length||(i.top=``,i.left=``),i}quadrumRect(e,t){return{left:D({x:t.x,y:t.y,width:e.x-t.x,height:t.height}),right:D({x:e.x+e.width,y:t.y,width:t.width-(e.x+e.width),height:t.height}),top:D({x:t.x,y:t.y,width:t.width,height:e.y-t.y}),bottom:D({x:t.x,y:e.y+e.height,width:t.width,height:t.height-(e.y+e.height)})}}quadrumPlacement(e,t,n){switch(t){case`top`:return D({x:n.x,y:e.y-n.height,width:n.width,height:n.height});case`bottom`:return D({x:n.x,y:e.y+e.height,width:n.width,height:n.height});case`left`:return D({x:e.x-n.width,y:n.y,width:n.width,height:n.height});case`right`:return D({x:e.x+e.width,y:n.y,width:n.width,height:n.height});default:throw`Unable place at the quadrum, ${t}`}}quadrumAlignment(e,t,n){switch(t){case`top`:case`bottom`:{let t=e.x;return this.alignment===`center`?t=e.x+e.width/2-n.width/2:this.alignment===`end`&&(t=e.x+e.width-n.width),D({x:t,y:n.y,width:n.width,height:n.height})}case`left`:case`right`:{let t=e.y;return this.alignment===`center`?t=e.y+e.height/2-n.height/2:this.alignment===`end`&&(t=e.y+e.height-n.height),D({x:n.x,y:t,width:n.width,height:n.height})}default:throw`Unable align at the quadrum, ${t}`}}biggerRectThan(e,t){return e.height>=t.height&&e.width>=t.width}enhance(){super.enhance(),this.controller.flip=this.flip}},Ae=(e,t)=>new ke(e,t),je={events:[`resize`],boundaries:[`top`,`left`,`right`],onShifted:`shifted`,respectMotion:!0},Me=class extends Y{constructor(e,t={}){super(e,t);let{onShifted:n,events:r,boundaries:i,respectMotion:a}=Object.assign({},je,t);this.onShifted=n,this.events=r,this.boundaries=i,this.respectMotion=a,this.prefersReducedMotion=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,this.enhance(),this.observe(this.shift)}shift=async()=>{if(!this.visible)return;this.dispatch(`shift`);let e=this.overflowRect(this.element.getBoundingClientRect(),this.elementTranslations(this.element)),t=e.left||e.right||0,n=e.top||e.bottom||0;this.element.style.transition=this.respectMotion&&this.prefersReducedMotion?`none`:``,this.element.style.transform=`translate(${t}px, ${n}px)`,await this.awaitCallback(this.onShifted,e),this.dispatch(`shifted`,{detail:e})};overflowRect(e,t){let n={},r=O(),i=D({x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height});for(let e of this.boundaries){let t=this.directionDistance(i,e,r),a=E[e];t<0?i[a]+t>=r[a]&&!n[a]&&(n[e]=t):n[e]=``}return n}directionDistance(e,t,n){switch(t){case`top`:case`left`:return e[t]-n[t];case`bottom`:case`right`:return n[t]-e[t];default:throw`Invalid direction to calcuate distance, ${t}`}}elementTranslations(e){let t=window.getComputedStyle(e),n=t.transform||t.webkitTransform||t.mozTransform;if(n===`none`||n===void 0)return{x:0,y:0};let r=n.includes(`3d`)?`3d`:`2d`,i=n.match(/matrix.*\((.+)\)/)[1].split(`, `);return r===`2d`?{x:Number(i[4]),y:Number(i[5])}:{x:0,y:0}}enhance(){super.enhance(),this.controller.shift=this.shift}},Ne=(e,t)=>new Me(e,t),Z={visibility:`visibility`,onShown:`shown`,onHidden:`hidden`},Pe=class extends A{constructor(e,t={}){let{visibility:n,onShown:r,onHidden:i,activator:a}=Object.assign({},Z,t),o=typeof n==`string`?n:Z.namespace,s=typeof t.visible==`string`?t.visible:`isVisible`;(typeof t.visible!=`boolean`||t.visible)&&(t.visible=`${o}.${s}`),super(e,t),this.visibility=o,this.visibilityResolver=s,this.onShown=r,this.onHidden=i,this.activator=a instanceof HTMLElement?a:null,this.enhance(),this.element instanceof HTMLElement&&this.activate(this.isVisible(this.element))}isVisible(e){if(!(e instanceof HTMLElement))return!1;let t=k.hiddenClass;return t?!e.classList.contains(t):!e.hasAttribute(`hidden`)}toggle(e,t){if(!(e instanceof HTMLElement))return;let n=k.hiddenClass;n?t?e.classList.remove(n):e.classList.add(n):t?e.removeAttribute(`hidden`):e.setAttribute(`hidden`,!0)}activate(e){this.activator&&this.activator.setAttribute(`aria-expanded`,e?`true`:`false`)}async show(){!(this.element instanceof HTMLElement)||this.isVisible(this.element)||(this.dispatch(`show`),this.toggle(this.element,!0),this.activate(!0),await this.awaitCallback(this.onShown,{target:this.element}),this.dispatch(`shown`))}async hide(){!(this.element instanceof HTMLElement)||!this.isVisible(this.element)||(this.dispatch(`hide`),this.toggle(this.element,!1),this.activate(!1),await this.awaitCallback(this.onHidden,{target:this.element}),this.dispatch(`hidden`))}enhance(){let e=this,t={show:e.show.bind(e),hide:e.hide.bind(e)};Object.defineProperty(t,`visible`,{get(){return e.isVisible(e.element)}}),Object.defineProperty(t,this.visibilityResolver,{value:e.isVisible.bind(e)}),Object.defineProperty(this.controller,this.visibility,{get(){return t}})}},Q=(e,t)=>new Pe(e,t),Fe=class extends t.Controller{static targets=[`daysOfWeek`,`daysOfMonth`];static classes=[`dayOfWeek`,`dayOfMonth`,`week`];static values={locales:{type:Array,default:[`default`]},weekdayFormat:{type:String,default:`short`},dayFormat:{type:String,default:`numeric`},daysOfOtherMonth:{type:Boolean,default:!1}};initialize(){Ce(this)}connect(){this.draw()}navigated(){this.draw()}draw(){this.drawDaysOfWeek(),this.drawDaysOfMonth()}createDayElement(e,{selectable:t=!1,disabled:n=!1}={}){let r=document.createElement(t?`button`:`div`);return r.tabIndex=-1,e?r.textContent=e:r.setAttribute(`aria-hidden`,`true`),n&&(r instanceof HTMLButtonElement?r.disabled=!0:r.setAttribute(`aria-disabled`,`true`)),r}drawDaysOfWeek(){if(!this.hasDaysOfWeekTarget)return;let e=new Intl.DateTimeFormat(this.localesValue,{weekday:this.weekdayFormatValue}),t=[];for(let n of this.calendar.daysOfWeek){let r=this.createDayElement(e.format(n.date));r.setAttribute(`role`,`columnheader`),r.title=n.long,this.hasDayOfWeekClass&&r.classList.add(...this.dayOfWeekClasses),t.push(r)}let n=document.createElement(`div`);n.setAttribute(`role`,`row`),this.hasWeekClass&&n.classList.add(...this.weekClasses),n.replaceChildren(...t),this.daysOfWeekTarget.replaceChildren(n)}drawDaysOfMonth(){if(!this.hasDaysOfMonthTarget)return;let e=this.calendar.today,t=new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),n=[];for(let e of this.calendar.daysOfMonth){let r=!e.current||this.calendar.isDisabled(e.date)||!this.calendar.isWithinRange(e.date),i=e.current||this.daysOfOtherMonthValue?e.value:``,a=this.createDayElement(i,{selectable:e.current,disabled:r});t===e.date.getTime()&&a.setAttribute(`aria-current`,`date`),this.hasDayOfMonthClass&&a.classList.add(...this.dayOfMonthClasses);let o=document.createElement(`time`);o.dateTime=e.iso,a.appendChild(o),n.push(a)}let r=[];for(let e=0;e<n.length;e+=7){let t=document.createElement(`div`);t.setAttribute(`role`,`row`),this.hasWeekClass&&t.classList.add(...this.weekClasses);for(let r of n.slice(e,e+7))r.setAttribute(`role`,`gridcell`),t.appendChild(r);r.push(t)}this.daysOfMonthTarget.replaceChildren(...r)}},Ie=class extends t.Controller{onSelect(e){if(!(e.target instanceof HTMLElement))return;e.preventDefault();let t=e.target instanceof HTMLTimeElement?e.target.parentElement:e.target;if(t.disabled||t.getAttribute(`aria-disabled`)===`true`)return;this.dispatch(`selecting`,{target:t});let n=e.target instanceof HTMLTimeElement?e.target:e.target.querySelector(`time`);if(!n)return console.error(`unable to locate time element within ${t}`);let r=G(n.dateTime);if(!r)return console.error(`unable to parse ${n.dateTime} found within the time element`);this.select(r.toISOString())}select(e){let t=G(e);t&&this.dispatch(`selected`,{detail:{epoch:t.getTime(),iso:e}})}},Le=class extends t.Controller{static targets=[`source`];static values={type:{type:String,default:`text/plain`}};onPaste(e){let t=e.clipboardData?.getData(this.typeValue)??``,n=Array.from(e.clipboardData?.types??[]);e.preventDefault(),this.dispatch(`pasted`,{detail:{text:t,types:n},bubbles:!0})}async copy(e){let t=e.params?.text??(this.hasSourceTarget?this.sourceTarget.value??this.sourceTarget.textContent??``:``);try{await navigator.clipboard.writeText(t),this.dispatch(`copied`,{detail:{text:t},bubbles:!0})}catch(e){this.dispatch(`copy-failed`,{detail:{error:e},bubbles:!0})}}},Re=class extends t.Controller{static targets=[`previous`,`next`,`day`,`month`,`year`];static outlets=[`calendar-month`];static values={date:String,locales:{type:Array,default:[`default`]},dayFormat:{type:String,default:`numeric`},monthFormat:{type:String,default:`long`},yearFormat:{type:String,default:`numeric`}};initialize(){this.previous=this.previous.bind(this),this.next=this.next.bind(this)}async calendarMonthOutletConnected(){if(this.dateValue){let e=G(this.dateValue);e&&await this.calendarMonthOutlet.calendar.navigate(e)}this.draw()}onSelect(e){this.dateValue=e.detail.iso,this.draw(),this.dispatch(`selected`,{detail:{value:e.detail.iso},bubbles:!0})}previousTargetConnected(e){e.addEventListener(`click`,this.previous)}previousTargetDisconnected(e){e.removeEventListener(`click`,this.previous)}async previous(){await this.calendarMonthOutlet.calendar.step(`month`,-1),this.draw()}nextTargetConnected(e){e.addEventListener(`click`,this.next)}nextTargetDisconnected(e){e.removeEventListener(`click`,this.next)}async next(){await this.calendarMonthOutlet.calendar.step(`month`,1),this.draw()}draw(){this.drawDay(),this.drawMonth(),this.drawYear()}drawDay(){if(!this.hasDayTarget||!this.hasCalendarMonthOutlet)return;let{year:e,month:t,day:n}=this.calendarMonthOutlet.calendar;this.dayTarget.textContent=new Intl.DateTimeFormat(this.localesValue,{day:this.dayFormatValue}).format(new Date(e,t,n))}drawMonth(){if(!this.hasMonthTarget||!this.hasCalendarMonthOutlet)return;let{year:e,month:t}=this.calendarMonthOutlet.calendar;this.monthTarget.textContent=new Intl.DateTimeFormat(this.localesValue,{month:this.monthFormatValue}).format(new Date(e,t))}drawYear(){if(!this.hasYearTarget||!this.hasCalendarMonthOutlet)return;let{year:e}=this.calendarMonthOutlet.calendar;this.yearTarget.textContent=new Intl.DateTimeFormat(this.localesValue,{year:this.yearFormatValue}).format(new Date(e,0))}},ze=class extends t.Controller{static targets=[`listbox`,`loading`,`empty`];static values={url:{type:String,default:``},field:{type:String,default:`q`},delay:{type:Number,default:300}};initialize(){this._requestor=new C}onSelect(e){let t=e.target.closest(`[role="option"]`);!t||t.getAttribute(`aria-disabled`)===`true`||this.select(t.dataset.value??``)}select(e){let t=this.listboxTarget.querySelectorAll(`[role="option"]`);t.forEach(e=>e.setAttribute(`aria-selected`,`false`));let n=[...t].find(t=>t.dataset.value===e);n&&n.setAttribute(`aria-selected`,`true`),this.dispatch(`selected`,{detail:{value:e},bubbles:!0})}onNavigate(e){if([`ArrowUp`,`ArrowDown`,`Enter`,` `].includes(e.key)){if(e.preventDefault(),e.key===`Enter`||e.key===` `){this.listboxTarget.querySelector(`[aria-selected="true"]`)?.click();return}this.step(e.key===`ArrowDown`?1:-1)}}step(e){let t=[...this.listboxTarget.querySelectorAll(`[role="option"]:not([aria-disabled="true"]):not([hidden])`)];if(!t.length)return;let n=this.listboxTarget.querySelector(`[aria-selected="true"]`),r=t.indexOf(n),i=e>0?t[Math.min(r+1,t.length-1)]:t[Math.max(r-1,0)];!i||i===n||(t.forEach(e=>e.setAttribute(`aria-selected`,`false`)),i.setAttribute(`aria-selected`,`true`),i.scrollIntoView({block:`nearest`}))}filter(e){if(this.urlValue){let t=new URL(this.urlValue,window.location.href);t.searchParams.set(this.fieldValue,e),this.setLoading(!0),this._requestor.schedule(()=>this._requestor.request(t).then(e=>e.text()).then(e=>{this.listboxTarget.innerHTML=e,this.setEmpty(this.listboxTarget.querySelectorAll(`[role="option"]`).length===0)}).catch(e=>{e.name!==`AbortError`&&console.error(`[combobox-dropdown] fetch failed`,e)}).finally(()=>this.setLoading(!1)),this.delayValue)}else{let t=T(this.listboxTarget,e);this.setEmpty(t===0)}}showAll(){this.listboxTarget.querySelectorAll(`[role="option"]`).forEach(e=>e.hidden=!1),this.setEmpty(!1)}setLoading(e){this.hasLoadingTarget&&(this.loadingTarget.hidden=!e)}setEmpty(e){this.hasEmptyTarget&&(this.emptyTarget.hidden=!e)}disconnect(){this._requestor.cancel()}},$=class extends t.Controller{static targets=[`hour`,`minute`,`period`];connect(){this.select(this.toH24())}onSelect(e){let t=e.target.closest(`[role="option"]`);t&&(t.closest(`[role="listbox"]`).querySelectorAll(`[role="option"]`).forEach(e=>e.setAttribute(`aria-selected`,`false`)),t.setAttribute(`aria-selected`,`true`),this.select(this.toH24()))}select(e){e&&this.dispatch(`selected`,{detail:{value:e},bubbles:!0})}onNavigate(e){[`ArrowUp`,`ArrowDown`].includes(e.key)&&(e.preventDefault(),this.step(e.currentTarget,e.key===`ArrowDown`?1:-1))}step(e,t){let n=[...e.querySelectorAll(`[role="option"]`)],r=e.querySelector(`[aria-selected="true"]`),i=n.indexOf(r),a=t>0?n[Math.min(i+1,n.length-1)]:n[Math.max(i-1,0)];!a||a===r||(n.forEach(e=>e.setAttribute(`aria-selected`,`false`)),a.setAttribute(`aria-selected`,`true`),a.scrollIntoView({block:`nearest`}),this.select(this.toH24()))}toH24(){let e=this.selectedValue(this.hourTarget),t=this.selectedValue(this.minuteTarget);if(!e||!t)return null;if(!this.hasPeriodTarget)return`${e}:${t}`;let n=this.selectedValue(this.periodTarget),r=parseInt(e,10);return r=n===`AM`?r===12?0:r:r===12?12:r+12,`${String(r).padStart(2,`0`)}:${t}`}selectedValue(e){return e?.querySelector(`[aria-selected="true"]`)?.dataset.value??null}},Be=class extends t.Controller{static targets=[`trigger`];connect(){X(this,{trigger:this.hasTriggerTarget?this.triggerTarget:null})}},Ve=class extends t.Controller{static targets=[`anchor`,`reference`];static values={placement:{type:String,default:`bottom`},alignment:{type:String,default:`start`},role:{type:String,default:`tooltip`}};connect(){if(!this.hasReferenceTarget){console.error(`FlipperController requires a reference target. Add data-flipper-target="reference" to your element.`);return}if(!this.hasAnchorTarget){console.error(`FlipperController requires an anchor target. Add data-flipper-target="anchor" to your element.`);return}Ae(this,{element:this.referenceTarget,anchor:this.anchorTarget,placement:this.placementValue,alignment:this.alignmentValue,ariaRole:this.roleValue})}},He=class extends t.Controller{static targets=[`trigger`,`popover`,`value`];static values={value:String,minLength:{type:Number,default:1}};static outlets=[`combobox-dropdown`];connect(){X(this),this.hasPopoverTarget&&Q(this,{element:this.popoverTarget,activator:this.hasTriggerTarget?this.triggerTarget:null})}async dismissed(){await this.close()}async open(){this.hasPopoverTarget&&await this.visibility.show()}async close(){this.hasPopoverTarget&&await this.visibility.hide()}async toggle(){this.visibility?.visible?await this.close():await this.open()}async shown(){this.hasPopoverTarget&&a(this.popoverTarget)}async hidden(){this.hasTriggerTarget&&this.triggerTarget.focus()}async onSelect(e){e.detail?.value!==void 0&&(this.valueValue=e.detail.value),await this.close()}onInput(e){if(e.target!==this.triggerTarget)return;let t=e.target.value.trim();if(t.length<this.minLengthValue){this.hasComboboxDropdownOutlet&&this.comboboxDropdownOutlet.showAll();return}this.hasComboboxDropdownOutlet&&this.comboboxDropdownOutlet.filter(t)}valueValueChanged(e){this.hasValueTarget&&(this.valueTarget.value=e),this.dispatch(`changed`,{detail:{value:e}})}},Ue=class extends t.Controller{static targets=[`input`,`toggle`];static values={type:{type:String,default:`plain`},options:{type:Object,default:{}},revealed:{type:Boolean,default:!1}};connect(){U(this,{type:this.typeValue,options:this.optionsValue}),this.format(this.readValue()),this.drawToggle()}typeValueChanged(){this.formatter&&(U(this,{type:this.typeValue,options:this.optionsValue}),this.format(this.readValue()),this.drawToggle())}optionsValueChanged(){this.formatter&&(U(this,{type:this.typeValue,options:this.optionsValue}),this.format(this.readValue()))}revealedValueChanged(){this.formatter&&(this.format(this.readValue()),this.drawToggle())}onChange(e){this.format(e?.detail?.value??``)}format(e){this.formatter&&this.onFormatting(e)}toggle(){!this.formatter.maskable()&&this.typeValue!==`password`||(this.revealedValue=!this.revealedValue)}onPaste(e){let t=e.detail?.text??``;if(!this.formatter||!t)return;let n=this.formatter.normalize(t);this.formatter.validate(n)&&this.format(n)}drawToggle(){if(!this.hasToggleTarget)return;let e=this.formatter?.maskable()||this.typeValue===`password`;this.toggleTarget.hidden=!e,e&&_(this.toggleTarget,this.revealedValue)}readValue(){return this.hasInputTarget?this.inputTarget instanceof HTMLInputElement?this.inputTarget.value:this.inputTarget.textContent:``}onFormatting(e){if(!this.formatter)return;if(this.typeValue===`password`){this.hasInputTarget&&(this.inputTarget.type=this.revealedValue?`text`:`password`);return}let t=this.formatter.normalize(e),n=this.revealedValue||!this.formatter.maskable()?this.formatter.format(t):this.formatter.mask(t);this.hasInputTarget&&(this.inputTarget instanceof HTMLInputElement?this.inputTarget.value=n:this.inputTarget.textContent=n),this.dispatch(`formatted`,{detail:{value:n}})}},We=class extends t.Controller{static targets=[`input`,`clear`];initialize(){this.onInput=this.draw.bind(this),this.onEscape=this.handleEscape.bind(this)}connect(){this.draw()}inputTargetConnected(e){e.addEventListener(`input`,this.onInput),e.addEventListener(`keydown`,this.onEscape)}inputTargetDisconnected(e){e.removeEventListener(`input`,this.onInput),e.removeEventListener(`keydown`,this.onEscape)}clear(){this.hasInputTarget&&(this.inputTarget.value=``,this.draw(),this.inputTarget.focus(),this.inputTarget.dispatchEvent(new Event(`input`,{bubbles:!0})))}draw(){!this.hasInputTarget||!this.hasClearTarget||(this.clearTarget.hidden=this.inputTarget.value.length===0)}handleEscape(e){e.key===`Escape`&&this.inputTarget.value!==``&&(e.preventDefault(),this.clear())}},Ge=class extends t.Controller{static targets=[`modal`,`overlay`];initialize(){this.onCancel=this.close.bind(this)}connect(){this.hasModalTarget||console.error(`ModalController requires a modal target. Add data-modal-target="modal" to your element.`)}modalTargetConnected(e){this.isNativeDialog=e instanceof HTMLDialogElement,this.isNativeDialog?(e.addEventListener(`cancel`,this.onCancel),e.addEventListener(`click`,this.onBackdropClick)):(this.focusTrap=new o(e,{escapeDeactivates:!0}),X(this,{element:e}))}modalTargetDisconnected(e){this.isNativeDialog&&(e.removeEventListener(`cancel`,this.onCancel),e.removeEventListener(`click`,this.onBackdropClick))}dismissed=()=>{this.close()};open(e){if(e&&e.preventDefault(),this.hasModalTarget){if(this.isNativeDialog)this.previouslyFocused=document.activeElement,this.modalTarget.showModal();else{let e=this.hasOverlayTarget?this.overlayTarget:this.modalTarget;e.hidden=!1,document.body.style.overflow=`hidden`,this.focusTrap&&this.focusTrap.activate()}m(`Modal opened`)}}close(e){if(e&&e.preventDefault(),this.hasModalTarget){if(this.isNativeDialog)this.modalTarget.close(),this.previouslyFocused&&this.previouslyFocused.isConnected&&setTimeout(()=>{this.previouslyFocused.focus()},0);else{let e=this.hasOverlayTarget?this.overlayTarget:this.modalTarget;e.hidden=!0,document.body.style.overflow=``,this.focusTrap&&this.focusTrap.deactivate()}m(`Modal closed`)}}onBackdropClick=e=>{let t=this.modalTarget.getBoundingClientRect();(e.clientY<t.top||e.clientY>t.bottom||e.clientX<t.left||e.clientX>t.right)&&this.close()}},Ke=class extends t.Controller{static targets=[`content`];connect(){Ne(this,{element:this.hasContentTarget?this.contentTarget:null})}},qe=class extends t.Controller{static targets=[`content`,`template`,`loader`,`activator`];static classes=[`hidden`];static values={url:String,loadedAt:String,reload:{type:String,default:`never`},staleAfter:{type:Number,default:3600}};connect(){Te(this,{element:this.hasContentTarget?this.contentTarget:null,url:this.hasUrlValue?this.urlValue:null}),this.hasContentTarget&&Q(this,{element:this.contentTarget,activator:this.hasActivatorTarget?this.activatorTarget:null}),this.hasLoaderTarget&&Q(this,{element:this.loaderTarget,visibility:`contentLoaderVisibility`})}async show(){await this.visibility.show()}async hide(){await this.visibility.hide()}async shown(){await this.load()}canLoad(){return this.hasContentTarget&&this.contentTarget.tagName.toLowerCase()===`turbo-frame`?(this.hasUrlValue&&this.contentTarget.setAttribute(`src`,this.urlValue),!1):!0}async contentLoading(){this.hasLoaderTarget&&await this.contentLoaderVisibility.show()}async contentLoaded({content:e}){this.hasContentTarget&&this.contentTarget.replaceChildren(this.getContentNode(e)),this.hasLoaderTarget&&await this.contentLoaderVisibility.hide()}getContentNode(e){if(typeof e==`string`){let t=document.createElement(`template`);return t.innerHTML=e,document.importNode(t.content,!0)}return document.importNode(e,!0)}contentLoader(){if(this.hasTemplateTarget)return this.templateTarget instanceof HTMLTemplateElement?this.templateTarget.content:this.templateTarget.innerHTML}};e.ARIA_HASPOPUP_VALUES=v,e.CalendarMonthController=Fe,e.CalendarMonthObserverController=Ie,e.ClipboardController=Le,e.ComboboxDateController=Re,e.ComboboxDropdownController=ze,e.ComboboxTimeController=$,e.DismisserController=Be,e.FOCUSABLE_SELECTOR=n,e.FORMATTER_TYPES=z,e.FlipperController=Ve,e.FocusRestoration=s,e.FocusTrap=o,e.Formatter=H,e.InputComboboxController=He,e.InputFormatController=Ue,e.InputSearchController=We,e.ModalController=Ge,e.PannerController=Ke,e.PopoverController=qe,e.Requestor=C,e.RovingTabIndex=f,e.announce=m,e.connectTriggerToTarget=x,e.disconnectTriggerFromTarget=ie,e.ensureId=ee,e.filterOptions=T,e.focusFirst=a,e.fuzzyMatcher=w,e.generateId=h,e.getFocusableElements=r,e.isActivationKey=l,e.isArrowKey=u,e.isKey=c,e.isVisible=i,e.preventDefault=d,e.setAriaState=g,e.setChecked=ne,e.setDisabled=re,e.setExpanded=te,e.setPressed=_});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@hotwired/stimulus`)):typeof define==`function`&&define.amd?define([`exports`,`@hotwired/stimulus`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.StimulusPlumbersControllers={},e.Stimulus))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=[`a[href]`,`area[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`,`audio[controls]`,`video[controls]`,`[contenteditable]:not([contenteditable="false"])`].join(`,`);function r(e){return Array.from(e.querySelectorAll(n)).filter(e=>i(e))}function i(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}function a(e){let t=r(e);return t.length>0?(t[0].focus(),!0):!1}var o=class{constructor(e,t={}){this.container=e,this.previouslyFocused=null,this.options=t,this.isActive=!1}activate(){this.isActive||(this.previouslyFocused=document.activeElement,this.isActive=!0,this.options.initialFocus?this.options.initialFocus.focus():a(this.container),this.container.addEventListener(`keydown`,this.handleKeyDown))}deactivate(){if(!this.isActive)return;this.isActive=!1,this.container.removeEventListener(`keydown`,this.handleKeyDown);let e=this.options.returnFocus||this.previouslyFocused;e&&i(e)&&e.focus()}handleKeyDown=e=>{if(e.key===`Escape`&&this.options.escapeDeactivates){e.preventDefault(),this.deactivate();return}if(e.key!==`Tab`)return;let t=r(this.container);if(t.length===0)return;let n=t[0],i=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),n.focus())}},s=class{constructor(){this.savedElement=null}save(){this.savedElement=document.activeElement}restore(){this.savedElement&&i(this.savedElement)&&(this.savedElement.focus(),this.savedElement=null)}};function c(e,t){return e.key===t}function l(e){return e.key===`Enter`||e.key===` `}function u(e){return[`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`].includes(e.key)}function d(e){e.preventDefault(),e.stopPropagation()}var f=class{constructor(e,t=0){this.items=e,this.currentIndex=t,this.updateTabIndex()}handleKeyDown(e){let t;switch(e.key){case`ArrowDown`:case`ArrowRight`:e.preventDefault(),t=(this.currentIndex+1)%this.items.length;break;case`ArrowUp`:case`ArrowLeft`:e.preventDefault(),t=this.currentIndex===0?this.items.length-1:this.currentIndex-1;break;case`Home`:e.preventDefault(),t=0;break;case`End`:e.preventDefault(),t=this.items.length-1;break;default:return}this.setCurrentIndex(t)}setCurrentIndex(e){e>=0&&e<this.items.length&&(this.currentIndex=e,this.updateTabIndex(),this.items[e].focus())}updateTabIndex(){this.items.forEach((e,t)=>{e.tabIndex=t===this.currentIndex?0:-1})}updateItems(e){this.items=e,this.currentIndex=Math.min(this.currentIndex,e.length-1),this.updateTabIndex()}},p=(e,t,n)=>{let r=document.querySelector(`[data-live-region="${e}"]`);return r||(r=document.createElement(`div`),r.className=`sr-only`,r.dataset.liveRegion=e,r.setAttribute(`aria-live`,e),r.setAttribute(`aria-atomic`,t.toString()),r.setAttribute(`aria-relevant`,n),document.body.appendChild(r)),r};function m(e,t={}){let{politeness:n=`polite`,atomic:r=!0,relevant:i=`additions text`}=t,a=p(n,r,i);a.textContent=``,setTimeout(()=>{a.textContent=e},100)}var h=(e=`a11y`)=>`${e}-${Math.random().toString(36).substr(2,9)}`,ee=(e,t=`element`)=>e.id||=h(t),g=(e,t,n)=>{e.setAttribute(t,n.toString())},te=(e,t)=>g(e,`aria-expanded`,t),_=(e,t)=>g(e,`aria-pressed`,t),ne=(e,t)=>g(e,`aria-checked`,t);function re(e,t){g(e,`aria-disabled`,t),t?e.setAttribute(`tabindex`,`-1`):e.removeAttribute(`tabindex`)}var v={menu:`menu`,listbox:`listbox`,tree:`tree`,grid:`grid`,dialog:`dialog`},y=(e,t,n)=>{Object.entries(t).forEach(([t,r])=>{e.setAttribute(t,r),n[t]=r})},b=(e,t,n)=>n||!e.hasAttribute(t);function x({trigger:e,target:t,role:n=null,override:r=!1}){let i={trigger:{},target:{}};if(!e||!t)return i;let a={},o={};if(n&&b(t,`role`,r)&&(o.role=n),t.id&&(b(e,`aria-controls`,r)&&(a[`aria-controls`]=t.id),n===`tooltip`&&b(e,`aria-describedby`,r)&&(a[`aria-describedby`]=t.id)),n&&b(e,`aria-haspopup`,r)){let e=v[n]||`true`;e&&(a[`aria-haspopup`]=e)}return y(t,o,i.target),y(e,a,i.trigger),i}var S=(e,t)=>{t.forEach(t=>{e.hasAttribute(t)&&e.removeAttribute(t)})};function ie({trigger:e,target:t,attributes:n=null}){!e||!t||(S(e,n||[`aria-controls`,`aria-haspopup`,`aria-describedby`]),(!n||n.includes(`role`))&&S(t,[`role`]))}var C=class{constructor(){this._abortController=null,this._timer=null}schedule(e,t){clearTimeout(this._timer),this._timer=setTimeout(e,t)}async request(e,t={}){this._abortController?.abort(),this._abortController=new AbortController;let n=await fetch(e,{...t,signal:this._abortController.signal});if(!n.ok)throw Error(`${n.status}`);return n}cancel(){clearTimeout(this._timer),this._abortController?.abort()}};function w(e,t){let n=0;for(let r=0;r<t.length&&n<e.length;r++)t[r]===e[n]&&n++;return n===e.length}function ae(e,t){return t.includes(e)}function oe(e,t){return t.startsWith(e)}function se(e){return e===`contains`?ae:e===`prefix`?oe:w}function ce(e,t){return t===`textContent`?e.textContent?.trim().toLowerCase()??``:(e.getAttribute(t)??``).toLowerCase()}function T(e,t,n={}){let{strategy:r=`fuzzy`,matcher:i,fields:a=[`textContent`]}=n,o=typeof i==`function`?i:se(r),s=t.toLowerCase(),c=0;return e.querySelectorAll(`[role="option"]`).forEach(e=>{let t=a.some(t=>o(s,ce(e,t)));e.hidden=!t,t&&c++}),c}var E={get top(){return`bottom`},get bottom(){return`top`},get left(){return`right`},get right(){return`left`}};function D({x:e,y:t,width:n,height:r}){return{x:e,y:t,width:n,height:r,left:e,right:e+n,top:t,bottom:t+r}}function O(){return D({x:0,y:0,width:window.innerWidth||document.documentElement.clientWidth,height:window.innerHeight||document.documentElement.clientHeight})}function le(e){if(!(e instanceof HTMLElement))return!1;let t=O(),n=e.getBoundingClientRect(),r=n.top<=t.height&&n.top+n.height>0,i=n.left<=t.width&&n.left+n.width>0;return r&&i}var k={get visibleOnly(){return!0},hiddenClass:null},ue={element:null,visible:null,dispatch:!0,prefix:``},A=class{constructor(e,t={}){this.controller=e;let{element:n,visible:r,dispatch:i,prefix:a}=Object.assign({},ue,t);this.element=n||e.element,this.visibleOnly=typeof r==`boolean`?r:k.visibleOnly,this.visibleCallback=typeof r==`string`?r:null,this.notify=!!i,this.prefix=typeof a==`string`&&a?a:e.identifier}get visible(){return this.element instanceof HTMLElement?this.visibleOnly?le(this.element)&&this.isVisible(this.element):!0:!1}isVisible(e){if(this.visibleCallback){let t=this.findCallback(this.visibleCallback);if(typeof t==`function`)return t(e)}return e instanceof HTMLElement?!e.hasAttribute(`hidden`):!1}dispatch(e,{target:t=null,prefix:n=null,detail:r=null}={}){if(this.notify)return this.controller.dispatch(e,{target:t||this.element,prefix:n||this.prefix,detail:r})}findCallback(e){if(typeof e!=`string`)return;let t=this,n=e.split(`.`).reduce((e,t)=>e&&e[t],t.controller);if(typeof n==`function`)return n.bind(t.controller);let r=e.split(`.`).reduce((e,t)=>e&&e[t],t);if(typeof r==`function`)return r.bind(t)}async awaitCallback(e,...t){if(typeof e==`string`&&(e=this.findCallback(e)),typeof e==`function`){let n=e(...t);return n instanceof Promise?await n:n}}},de={normalize(e){return typeof e==`string`?e:``},validate(){return!0}};function fe(e){let t=0,n=!1;for(let r=e.length-1;r>=0;r--){let i=parseInt(e[r],10);n&&(i*=2,i>9&&(i-=9)),t+=i,n=!n}return t%10==0}var pe=/\D/g,me=/^\d{13,19}$/,he=/(.{4})(?=.)/g,ge={normalize(e){return typeof e==`string`?e.replace(pe,``):``},validate(e){return typeof e!=`string`||!me.test(e)?!1:fe(e)},format(e){return typeof e==`string`?e.replace(he,`$1 `):``}},j={1:10},M=/\D/g,_e=/^\+\d{7,15}$/,ve={normalize(e){if(typeof e!=`string`)return``;let t=e.trimStart().startsWith(`+`),n=e.replace(M,``);return t?`+${n}`:n},validate(e){if(typeof e!=`string`)return!1;if(_e.test(e))return!0;let t=e.replace(M,``);return Object.values(j).includes(t.length)},format(e){if(typeof e!=`string`)return``;let t=e.replace(M,``);for(let[e,n]of Object.entries(j)){if(t.length===n)return`(${t.slice(0,3)}) ${t.slice(3,6)}-${t.slice(6)}`;let r=n+e.length;if(t.length===r&&t.startsWith(e)){let n=t.slice(e.length);return`+${e} (${n.slice(0,3)}) ${n.slice(3,6)}-${n.slice(6)}`}}return e}},ye=/[^\d.,-]/g,N=/^-?\d+(\.\d+)?$/,P={normalize(e){if(typeof e!=`string`)return``;let t=e.replace(ye,``);if(!t)return``;let n=t.lastIndexOf(`,`),r=t.lastIndexOf(`.`);return n>-1&&r>-1?n>r?t.replace(/\./g,``).replace(`,`,`.`):t.replace(/,/g,``):n>-1?t.slice(n+1).length<=2?t.replace(`,`,`.`):t.replace(/,/g,``):t},validate(e){return typeof e==`string`?N.test(e):!1},format(e,t={}){if(typeof e!=`string`)return``;let n=parseFloat(e);if(isNaN(n))return e;let r=t.locale||`en-US`,i=t.currency||`USD`,a=t.fractionDigits===void 0?{}:{minimumFractionDigits:t.fractionDigits,maximumFractionDigits:t.fractionDigits};try{return new Intl.NumberFormat(r,{style:`currency`,currency:i,...a}).format(n)}catch{return e}}},F=/^\d{4}-\d{2}-\d{2}$/,be=/^(\d{1,4})[/\-.](\d{1,2})[/\-.](\d{1,4})$/,xe=/\D/g,I={normalize(e){if(typeof e!=`string`)return``;let t=e.trim();if(F.test(t))return t;let n=t.match(be);if(n){let[,e,t,r]=n;if(e.length===4)return`${e}-${t.padStart(2,`0`)}-${r.padStart(2,`0`)}`;if(r.length===4)return`${r}-${e.padStart(2,`0`)}-${t.padStart(2,`0`)}`}let r=t.replace(xe,``);if(r.length===8){let e=parseInt(r.slice(0,4),10);return e>=1e3&&e<=9999?`${r.slice(0,4)}-${r.slice(4,6)}-${r.slice(6,8)}`:`${r.slice(4,8)}-${r.slice(0,2)}-${r.slice(2,4)}`}return t},validate(e){if(typeof e!=`string`)return!1;let t=I.normalize(e);if(!F.test(t))return!1;let n=new Date(`${t}T00:00:00Z`);return!isNaN(n.getTime())&&n.toISOString().startsWith(t)},format(e,t={}){if(typeof e!=`string`)return``;let n=new Date(`${e}T00:00:00Z`);if(isNaN(n.getTime()))return e;let r=t.locale||`en-US`;try{return new Intl.DateTimeFormat(r,{year:t.year||`numeric`,month:t.month||`2-digit`,day:t.day||`2-digit`,timeZone:t.timeZone||`UTC`}).format(n)}catch{return e}}},Se=/^([01]?\d|2[0-3]):([0-5]\d)$/,L={normalize(e){if(typeof e!=`string`)return``;let t=e.trim();if(Se.test(t)){let[e,n]=t.split(`:`);return`${String(parseInt(e,10)).padStart(2,`0`)}:${n}`}let n=t.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);if(n){let e=parseInt(n[1],10),t=n[2];return e=n[3].toUpperCase()===`AM`?e===12?0:e:e===12?12:e+12,e>23||parseInt(t,10)>59?``:`${String(e).padStart(2,`0`)}:${t}`}return``},validate(e){return L.normalize(e)!==``},format(e,t={}){if(typeof e!=`string`)return``;let n=e.match(/^(\d{2}):(\d{2})$/);if(!n)return e;let r=parseInt(n[1],10),i=n[2];if(t.format===`h24`)return`${String(r).padStart(2,`0`)}:${i}`;let a=r<12?`AM`:`PM`;return`${r%12||12}:${i} ${a}`}},R={PLAIN:`plain`,CREDIT_CARD:`creditCard`,PHONE:`phone`,CURRENCY:`currency`,DATE:`date`,TIME:`time`},z=new Map([[R.PLAIN,de],[R.CREDIT_CARD,ge],[R.PHONE,ve],[R.CURRENCY,P],[R.DATE,I],[R.TIME,L]]),B={type:R.PLAIN,options:{}},V=class extends A{static register(e,t){z.set(e,t)}constructor(e,t={}){super(e,t),this.type=t.type??B.type,this.options=t.options??B.options,this.enhance()}enhance(){let e=this,t=z.get(e.type)??z.get(R.PLAIN),n={normalize:n=>t.normalize?.(n,e.options)??(typeof n==`string`?n:``),validate:n=>t.validate?.(n,e.options)??!0,format:n=>t.format?.(n,e.options)??(typeof n==`string`?n:``),mask:n=>t.mask?.(n,e.options)??null,maskable:()=>typeof t.mask==`function`};Object.defineProperty(this.controller,`formatter`,{get(){return n},configurable:!0})}},H=(e,t)=>new V(e,t),Ce=/^\d{4}-\d{2}-\d{2}$/;function U(e){return e instanceof Date&&!isNaN(e)}function W(...e){if(e.length===0)throw`Missing values to parse as date`;if(e.length===1){let t=e[0];if(!t)return;if(typeof t==`string`&&Ce.test(t)){let[e,n,r]=t.split(`-`).map(Number),i=new Date(e,n-1,r);if(U(i))return i}else{let e=new Date(t);if(U(e))return e}}else{let t=new Date(...e);if(U(t))return t}}var G=7,K={locales:[`default`],today:``,day:null,month:null,year:null,since:null,till:null,disabledDates:[],disabledWeekdays:[],disabledDays:[],disabledMonths:[],disabledYears:[],firstDayOfWeek:0,onNavigated:`navigated`},we=class extends A{constructor(e,t={}){super(e,t);let n=Object.assign({},K,t),{onNavigated:r,since:i,till:a,firstDayOfWeek:o}=n;this.onNavigated=r,this.since=W(i),this.till=W(a),this.firstDayOfWeek=0<=o&&o<7?o:K.firstDayOfWeek;let{disabledDates:s,disabledWeekdays:c,disabledDays:l,disabledMonths:u,disabledYears:d}=n;this.disabledDates=Array.isArray(s)?s:[],this.disabledWeekdays=Array.isArray(c)?c:[],this.disabledDays=Array.isArray(l)?l:[],this.disabledMonths=Array.isArray(u)?u:[],this.disabledYears=Array.isArray(d)?d:[];let{today:f,day:p,month:m,year:h}=n;this.now=W(f)||new Date,typeof h==`number`&&typeof m==`number`&&typeof p==`number`?this.current=W(h,m,p):this.current=this.now,this.build(),this.enhance()}build(){this.daysOfWeek=this.buildDaysOfWeek(),this.daysOfMonth=this.buildDaysOfMonth(),this.monthsOfYear=this.buildMonthsOfYear(),this.yearsOfDecade=this.buildYearsOfDecade()}buildDaysOfWeek(){let e=new Intl.DateTimeFormat(this.localesValue,{weekday:`long`}),t=new Intl.DateTimeFormat(this.localesValue,{weekday:`short`}),n=new Date(`2024-10-06`),r=[];for(let i=this.firstDayOfWeek,a=i+7;i<a;i++){let a=new Date(n);a.setDate(n.getDate()+i),r.push({date:a,value:a.getDay(),long:e.format(a),short:t.format(a)})}return r}buildDaysOfMonth(){let e=this.month,t=this.year,n=[],r=e=>({current:this.month===e.getMonth()&&this.year===e.getFullYear(),date:e,value:e.getDate(),month:e.getMonth(),year:e.getFullYear(),iso:e.toISOString()}),i=new Date(t,e).getDay(),a=this.firstDayOfWeek-i;for(let i=a>0?a-7:a;i<0;i++){let a=new Date(t,e,i+1);n.push(r(a))}let o=new Date(t,e+1,0).getDate();for(let i=1;i<=o;i++){let a=new Date(t,e,i);n.push(r(a))}let s=n.length%G,c=s===0?0:G-s;for(let i=1;i<=c;i++){let a=new Date(t,e+1,i);n.push(r(a))}return n}buildMonthsOfYear(){let e=new Intl.DateTimeFormat(this.localesValue,{month:`long`}),t=new Intl.DateTimeFormat(this.localesValue,{month:`short`}),n=new Intl.DateTimeFormat(this.localesValue,{month:`numeric`}),r=[];for(let i=0;i<12;i++){let a=new Date(this.year,i);r.push({date:a,value:a.getMonth(),long:e.format(a),short:t.format(a),numeric:n.format(a)})}return r}buildYearsOfDecade(){let e=Math.floor(this.year/10)*10,t=[];for(let n=e-1;n<=e+10;n++)t.push({value:n,current:n===this.year,outside:n<e||n>e+9});return t}get today(){return this.now}set today(e){if(!U(e))return;let t=this.month??e.getMonth(),n=this.year??e.getFullYear(),r=t==e.getMonth()&&n==e.getFullYear()?e.getDate():1;this.now=new Date(n,t,r)}get current(){return typeof this.year==`number`&&typeof this.month==`number`&&typeof this.day==`number`?W(this.year,this.month,this.day):null}set current(e){U(e)&&(this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear())}navigate=async e=>{if(!U(e))return;let t=this.current,n=e.toISOString(),r=t.toISOString();this.dispatch(`navigate`,{detail:{from:r,to:n}}),this.current=e,this.build(),await this.awaitCallback(this.onNavigated,{from:r,to:n}),this.dispatch(`navigated`,{detail:{from:r,to:n}})};step=async(e,t)=>{if(t===0)return;let n=this.current;switch(e){case`year`:n.setFullYear(n.getFullYear()+t);break;case`month`:n.setMonth(n.getMonth()+t);break;case`day`:n.setDate(n.getDate()+t);break;default:return}await this.navigate(n)};isDisabled=e=>{if(!U(e))return!1;if(this.disabledDates.length){let t=e.getTime();for(let e of this.disabledDates)if(t===new Date(e).getTime())return!0}if(this.disabledWeekdays.length){let t=e.getDay(),n=this.daysOfWeek,r=n.findIndex(e=>e.value===t);if(r>=0){let e=n[r];for(let t of this.disabledWeekdays)if(e.value==t||e.short===t||e.long===t)return!0}}if(this.disabledDays.length){let t=e.getDate();for(let e of this.disabledDays)if(t==e)return!0}if(this.disabledMonths.length){let t=e.getMonth(),n=this.monthsOfYear,r=n.findIndex(e=>e.value===t);if(r>=0){let e=n[r];for(let t of this.disabledMonths)if(e.value==t||e.short===t||e.long===t)return!0}}if(this.disabledYears.length){let t=e.getFullYear();for(let e of this.disabledYears)if(t==e)return!0}return!1};isWithinRange=e=>{if(!U(e))return!1;let t=!0;return this.since&&(t&&=e>=this.since),this.till&&(t&&=e<=this.till),t};enhance(){let e=this;Object.assign(this.controller,{get calendar(){return{get today(){return e.today},get current(){return e.current},get day(){return e.day},get month(){return e.month},get year(){return e.year},get since(){return e.since},get till(){return e.till},get firstDayOfWeek(){return e.firstDayOfWeek},get disabledDates(){return e.disabledDates},get disabledWeekdays(){return e.disabledWeekdays},get disabledDays(){return e.disabledDays},get disabledMonths(){return e.disabledMonths},get disabledYears(){return e.disabledYears},get daysOfWeek(){return e.daysOfWeek},get daysOfMonth(){return e.daysOfMonth},get monthsOfYear(){return e.monthsOfYear},get yearsOfDecade(){return e.yearsOfDecade},navigate:async t=>await e.navigate(t),step:async(t,n)=>await e.step(t,n),isDisabled:t=>e.isDisabled(t),isWithinRange:t=>e.isWithinRange(t)}}})}},Te=(e,t)=>new we(e,t),q={content:null,url:``,reload:`never`,stale:3600,onLoad:`canLoad`,onLoaded:`contentLoaded`},Ee=class extends A{constructor(e,t={}){super(e,t);let n=Object.assign({},q,t),{content:r,url:i,reload:a,stale:o}=n;this.content=r,this.url=i,this.reload=typeof a==`string`?a:q.reload,this.stale=typeof o==`number`?o:q.stale;let{onLoad:s,onLoaded:c}=n;this.onLoad=s,this.onLoaded=c,this._requestor=new C,this.enhance()}get reloadable(){switch(this.reload){case`never`:return!1;case`always`:return!0;default:{let e=W(this.loadedAt);return e&&new Date-e>this.stale*1e3}}}contentLoadable=({url:e})=>!!e;contentLoader=async()=>``;remoteContentLoader=async e=>(await this._requestor.request(e)).text();load=async()=>{if(this.loadedAt&&!this.reloadable)return;let e=this.findCallback(this.onLoad),t=await this.awaitCallback(e||this.contentLoadable,{url:this.url});if(this.dispatch(`load`,{detail:{url:this.url}}),!t)return;this.dispatch(`loading`,{detail:{url:this.url}});let n=this.url?await this.remoteContentLoader(this.url):await this.contentLoader();n&&(await this.awaitCallback(this.onLoaded,{url:this.url,content:n}),this.loadedAt=new Date().getTime(),this.dispatch(`loaded`,{detail:{url:this.url,content:n}}))};enhance(){let e=this;Object.assign(this.controller,{load:e.load.bind(e)})}},De=(e,t)=>new Ee(e,t),J=class extends A{observe(e){this._handler=e,this.events.forEach(t=>window.addEventListener(t,e,!0))}unobserve(){this._handler&&this.events.forEach(e=>window.removeEventListener(e,this._handler,!0))}enhance(){let e=this,t=this.controller.disconnect?.bind(this.controller)||(()=>{});this.controller.disconnect=()=>{e.unobserve(),t()}}},Oe={trigger:null,events:[`click`],onDismissed:`dismissed`},ke=class extends J{constructor(e,t={}){super(e,t);let{trigger:n,events:r,onDismissed:i}=Object.assign({},Oe,t);this.onDismissed=i,this.trigger=n||this.element,this.events=r,this.enhance(),this.observe(this.dismiss)}dismiss=async e=>{let{target:t}=e;t instanceof HTMLElement&&(this.element.contains(t)||this.visible&&(this.dispatch(`dismiss`),await this.awaitCallback(this.onDismissed,{target:this.trigger}),this.dispatch(`dismissed`)))}},Y=(e,t)=>new ke(e,t),Ae={anchor:null,events:[`click`],placement:`bottom`,alignment:`start`,onFlipped:`flipped`,ariaRole:null,respectMotion:!0},je=class extends J{constructor(e,t={}){super(e,t);let{anchor:n,events:r,placement:i,alignment:a,onFlipped:o,ariaRole:s,respectMotion:c}=Object.assign({},Ae,t);this.anchor=n,this.events=r,this.placement=i,this.alignment=a,this.onFlipped=o,this.ariaRole=s,this.respectMotion=c,this.prefersReducedMotion=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,this.anchor&&this.element&&x({trigger:this.anchor,target:this.element,role:this.ariaRole}),this.enhance(),this.observe(this.flip)}flip=async()=>{if(!this.visible)return;this.dispatch(`flip`),window.getComputedStyle(this.element).position!=`absolute`&&(this.element.style.position=`absolute`);let e=this.flippedRect(this.anchor.getBoundingClientRect(),this.element.getBoundingClientRect());this.element.style.transition=this.respectMotion&&this.prefersReducedMotion?`none`:``;for(let[t,n]of Object.entries(e))this.element.style[t]=n;await this.awaitCallback(this.onFlipped,{target:this.element,placement:e}),this.dispatch(`flipped`,{detail:{placement:e}})};flippedRect(e,t){let n=this.quadrumRect(e,O()),r=[this.placement,E[this.placement]],i={};for(;!Object.keys(i).length&&r.length>0;){let a=r.shift();if(!this.biggerRectThan(n[a],t))continue;let o=this.quadrumPlacement(e,a,t),s=this.quadrumAlignment(e,a,o);i.top=`${s.top+window.scrollY}px`,i.left=`${s.left+window.scrollX}px`}return Object.keys(i).length||(i.top=``,i.left=``),i}quadrumRect(e,t){return{left:D({x:t.x,y:t.y,width:e.x-t.x,height:t.height}),right:D({x:e.x+e.width,y:t.y,width:t.width-(e.x+e.width),height:t.height}),top:D({x:t.x,y:t.y,width:t.width,height:e.y-t.y}),bottom:D({x:t.x,y:e.y+e.height,width:t.width,height:t.height-(e.y+e.height)})}}quadrumPlacement(e,t,n){switch(t){case`top`:return D({x:n.x,y:e.y-n.height,width:n.width,height:n.height});case`bottom`:return D({x:n.x,y:e.y+e.height,width:n.width,height:n.height});case`left`:return D({x:e.x-n.width,y:n.y,width:n.width,height:n.height});case`right`:return D({x:e.x+e.width,y:n.y,width:n.width,height:n.height});default:throw`Unable place at the quadrum, ${t}`}}quadrumAlignment(e,t,n){switch(t){case`top`:case`bottom`:{let t=e.x;return this.alignment===`center`?t=e.x+e.width/2-n.width/2:this.alignment===`end`&&(t=e.x+e.width-n.width),D({x:t,y:n.y,width:n.width,height:n.height})}case`left`:case`right`:{let t=e.y;return this.alignment===`center`?t=e.y+e.height/2-n.height/2:this.alignment===`end`&&(t=e.y+e.height-n.height),D({x:n.x,y:t,width:n.width,height:n.height})}default:throw`Unable align at the quadrum, ${t}`}}biggerRectThan(e,t){return e.height>=t.height&&e.width>=t.width}enhance(){super.enhance(),this.controller.flip=this.flip}},Me=(e,t)=>new je(e,t),Ne={events:[`resize`],boundaries:[`top`,`left`,`right`],onShifted:`shifted`,respectMotion:!0},Pe=class extends J{constructor(e,t={}){super(e,t);let{onShifted:n,events:r,boundaries:i,respectMotion:a}=Object.assign({},Ne,t);this.onShifted=n,this.events=r,this.boundaries=i,this.respectMotion=a,this.prefersReducedMotion=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,this.enhance(),this.observe(this.shift)}shift=async()=>{if(!this.visible)return;this.dispatch(`shift`);let e=this.overflowRect(this.element.getBoundingClientRect(),this.elementTranslations(this.element)),t=e.left||e.right||0,n=e.top||e.bottom||0;this.element.style.transition=this.respectMotion&&this.prefersReducedMotion?`none`:``,this.element.style.transform=`translate(${t}px, ${n}px)`,await this.awaitCallback(this.onShifted,e),this.dispatch(`shifted`,{detail:e})};overflowRect(e,t){let n={},r=O(),i=D({x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height});for(let e of this.boundaries){let t=this.directionDistance(i,e,r),a=E[e];t<0?i[a]+t>=r[a]&&!n[a]&&(n[e]=t):n[e]=``}return n}directionDistance(e,t,n){switch(t){case`top`:case`left`:return e[t]-n[t];case`bottom`:case`right`:return n[t]-e[t];default:throw`Invalid direction to calcuate distance, ${t}`}}elementTranslations(e){let t=window.getComputedStyle(e),n=t.transform||t.webkitTransform||t.mozTransform;if(n===`none`||n===void 0)return{x:0,y:0};let r=n.includes(`3d`)?`3d`:`2d`,i=n.match(/matrix.*\((.+)\)/)[1].split(`, `);return r===`2d`?{x:Number(i[4]),y:Number(i[5])}:{x:0,y:0}}enhance(){super.enhance(),this.controller.shift=this.shift}},Fe=(e,t)=>new Pe(e,t),X={visibility:`visibility`,onShown:`shown`,onHidden:`hidden`},Ie=class extends A{constructor(e,t={}){let{visibility:n,onShown:r,onHidden:i,activator:a}=Object.assign({},X,t),o=typeof n==`string`?n:X.namespace,s=typeof t.visible==`string`?t.visible:`isVisible`;(typeof t.visible!=`boolean`||t.visible)&&(t.visible=`${o}.${s}`),super(e,t),this.visibility=o,this.visibilityResolver=s,this.onShown=r,this.onHidden=i,this.activator=a instanceof HTMLElement?a:null,this.enhance(),this.element instanceof HTMLElement&&this.activate(this.isVisible(this.element))}isVisible(e){if(!(e instanceof HTMLElement))return!1;let t=k.hiddenClass;return t?!e.classList.contains(t):!e.hasAttribute(`hidden`)}toggle(e,t){if(!(e instanceof HTMLElement))return;let n=k.hiddenClass;n?t?e.classList.remove(n):e.classList.add(n):t?e.removeAttribute(`hidden`):e.setAttribute(`hidden`,!0)}activate(e){this.activator&&this.activator.setAttribute(`aria-expanded`,e?`true`:`false`)}async show(){!(this.element instanceof HTMLElement)||this.isVisible(this.element)||(this.dispatch(`show`),this.toggle(this.element,!0),this.activate(!0),await this.awaitCallback(this.onShown,{target:this.element}),this.dispatch(`shown`))}async hide(){!(this.element instanceof HTMLElement)||!this.isVisible(this.element)||(this.dispatch(`hide`),this.toggle(this.element,!1),this.activate(!1),await this.awaitCallback(this.onHidden,{target:this.element}),this.dispatch(`hidden`))}enhance(){let e=this,t={show:e.show.bind(e),hide:e.hide.bind(e)};Object.defineProperty(t,`visible`,{get(){return e.isVisible(e.element)}}),Object.defineProperty(t,this.visibilityResolver,{value:e.isVisible.bind(e)}),Object.defineProperty(this.controller,this.visibility,{get(){return t}})}},Z=(e,t)=>new Ie(e,t),Le=class extends t.Controller{static targets=[`daysOfWeek`,`daysOfMonth`];static classes=[`dayOfWeek`,`dayOfMonth`,`row`];static values={locales:{type:Array,default:[`default`]},weekdayFormat:{type:String,default:`short`},dayFormat:{type:String,default:`numeric`},daysOfOtherMonth:{type:Boolean,default:!1},today:{type:String,default:``},selected:{type:String,default:``}};initialize(){Te(this,{today:this.todayValue})}connect(){this.draw()}navigated(){this.draw()}selectedValueChanged(){if(!this.hasDaysOfMonthTarget||(this.daysOfMonthTarget.querySelectorAll(`[aria-selected]`).forEach(e=>{e.setAttribute(`aria-selected`,`false`)}),!this.selectedValue))return;let e=W(this.selectedValue);if(!e)return;let t=this.daysOfMonthTarget.querySelector(`time[datetime="${e.toISOString()}"]`);t&&t.closest(`[aria-selected]`).setAttribute(`aria-selected`,`true`)}onSelect(e){let t=e.detail?.iso;t&&(this.selectedValue=t)}draw(){this.drawDaysOfWeek(),this.drawDaysOfMonth(),this.selectedValueChanged()}createDayElement(e,{selectable:t=!1,disabled:n=!1}={}){let r=document.createElement(t?`button`:`div`);return r.tabIndex=-1,e?r.textContent=e:r.setAttribute(`aria-hidden`,`true`),n&&(r instanceof HTMLButtonElement?r.disabled=!0:r.setAttribute(`aria-disabled`,`true`)),r}drawDaysOfWeek(){if(!this.hasDaysOfWeekTarget)return;let e=new Intl.DateTimeFormat(this.localesValue,{weekday:this.weekdayFormatValue}),t=[];for(let n of this.calendar.daysOfWeek){let r=this.createDayElement(e.format(n.date));r.setAttribute(`role`,`columnheader`),r.title=n.long,this.hasDayOfWeekClass&&r.classList.add(...this.dayOfWeekClasses),t.push(r)}let n=document.createElement(`div`);n.setAttribute(`role`,`row`),this.hasRowClass&&n.classList.add(...this.rowClasses),n.replaceChildren(...t),this.daysOfWeekTarget.replaceChildren(n)}drawDaysOfMonth(){if(!this.hasDaysOfMonthTarget)return;let e=this.calendar.today,t=new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),n=[];for(let e of this.calendar.daysOfMonth){let r=!e.current||this.calendar.isDisabled(e.date)||!this.calendar.isWithinRange(e.date),i=e.current||this.daysOfOtherMonthValue?e.value:``,a=this.createDayElement(i,{selectable:e.current,disabled:r});t===e.date.getTime()&&a.setAttribute(`aria-current`,`date`),(e.current||this.daysOfOtherMonthValue)&&a.setAttribute(`aria-selected`,``),this.hasDayOfMonthClass&&a.classList.add(...this.dayOfMonthClasses);let o=document.createElement(`time`);o.dateTime=e.iso,a.appendChild(o),n.push(a)}let r=[];for(let e=0;e<n.length;e+=7){let t=document.createElement(`div`);t.setAttribute(`role`,`row`),this.hasRowClass&&t.classList.add(...this.rowClasses);for(let r of n.slice(e,e+7))r.setAttribute(`role`,`gridcell`),t.appendChild(r);r.push(t)}this.daysOfMonthTarget.replaceChildren(...r)}},Re=class extends t.Controller{onSelect(e){if(!(e.target instanceof HTMLElement))return;e.preventDefault();let t=e.target instanceof HTMLTimeElement?e.target.parentElement:e.target;if(t.disabled||t.getAttribute(`aria-disabled`)===`true`)return;this.dispatch(`selecting`,{target:t});let n=e.target instanceof HTMLTimeElement?e.target:e.target.querySelector(`time`);if(!n)return console.error(`unable to locate time element within ${t}`);let r=W(n.dateTime);if(!r)return console.error(`unable to parse ${n.dateTime} found within the time element`);this.select(r.toISOString())}select(e){let t=W(e);t&&this.dispatch(`selected`,{detail:{epoch:t.getTime(),iso:e}})}},ze=class extends t.Controller{static targets=[`source`];static values={contentType:{type:String,default:`text/plain`}};onPaste(e){let t=e.clipboardData?.getData(this.contentTypeValue)??``,n=Array.from(e.clipboardData?.types??[]);e.preventDefault(),this.dispatch(`pasted`,{detail:{text:t,types:n},bubbles:!0})}async copy(e){let t=e.params?.text??(this.hasSourceTarget?this.sourceTarget.value??this.sourceTarget.textContent??``:``);try{await navigator.clipboard.writeText(t),this.dispatch(`copied`,{detail:{text:t},bubbles:!0})}catch(e){this.dispatch(`copy-failed`,{detail:{error:e},bubbles:!0})}}},Q=[`month`,`year`,`decade`],Be=class extends t.Controller{static targets=[`previous`,`next`,`day`,`month`,`year`,`viewTitle`,`monthView`,`yearView`,`decadeView`];static outlets=[`calendar-month`];static values={date:String,view:{type:String,default:`month`},locales:{type:Array,default:[`default`]},dayFormat:{type:String,default:`numeric`},monthFormat:{type:String,default:`long`},yearFormat:{type:String,default:`numeric`}};initialize(){this.previous=this.previous.bind(this),this.next=this.next.bind(this),this.selectMonth=this.selectMonth.bind(this),this.selectYear=this.selectYear.bind(this)}async calendarMonthOutletConnected(){if(this.dateValue){let e=W(this.dateValue);e&&await this.calendarMonthOutlet.calendar.navigate(e)}this.draw()}onSelect(e){this.dateValue=e.detail.iso,this.draw(),this.dispatch(`selected`,{detail:{value:e.detail.iso},bubbles:!0})}zoomOut(){let e=Q.indexOf(this.viewValue);e<Q.length-1&&(this.viewValue=Q[e+1],this.draw())}async selectMonth(e){let t=e.target.closest(`button[data-month]`);if(!t)return;let n=parseInt(t.dataset.month,10)-1,{year:r}=this.calendarMonthOutlet.calendar;await this.calendarMonthOutlet.calendar.navigate(new Date(r,n,1)),this.viewValue=`month`,this.draw()}async selectYear(e){let t=e.target.closest(`button[data-year]`);if(!t||t.getAttribute(`aria-disabled`)===`true`)return;let n=parseInt(t.dataset.year,10),{month:r}=this.calendarMonthOutlet.calendar;await this.calendarMonthOutlet.calendar.navigate(new Date(n,r,1)),this.viewValue=`year`,this.draw()}previousTargetConnected(e){e.addEventListener(`click`,this.previous)}previousTargetDisconnected(e){e.removeEventListener(`click`,this.previous)}async previous(){await this.calendarMonthOutlet.calendar.step(...this.stepArgs(-1)),this.draw()}nextTargetConnected(e){e.addEventListener(`click`,this.next)}nextTargetDisconnected(e){e.removeEventListener(`click`,this.next)}async next(){await this.calendarMonthOutlet.calendar.step(...this.stepArgs(1)),this.draw()}yearViewTargetConnected(e){e.addEventListener(`click`,this.selectMonth)}yearViewTargetDisconnected(e){e.removeEventListener(`click`,this.selectMonth)}decadeViewTargetConnected(e){e.addEventListener(`click`,this.selectYear)}decadeViewTargetDisconnected(e){e.removeEventListener(`click`,this.selectYear)}draw(){this.drawDay(),this.drawMonth(),this.drawYear(),this.drawViewTitle(),this.drawYearView(),this.drawDecadeView(),this.drawView()}drawDay(){if(!this.hasDayTarget||!this.hasCalendarMonthOutlet)return;let{year:e,month:t,day:n}=this.calendarMonthOutlet.calendar;this.dayTarget.textContent=new Intl.DateTimeFormat(this.localesValue,{day:this.dayFormatValue}).format(new Date(e,t,n))}drawMonth(){if(!this.hasMonthTarget||!this.hasCalendarMonthOutlet)return;let{year:e,month:t}=this.calendarMonthOutlet.calendar;this.monthTarget.textContent=new Intl.DateTimeFormat(this.localesValue,{month:this.monthFormatValue}).format(new Date(e,t))}drawYear(){if(!this.hasYearTarget||!this.hasCalendarMonthOutlet)return;let{year:e}=this.calendarMonthOutlet.calendar;this.yearTarget.textContent=new Intl.DateTimeFormat(this.localesValue,{year:this.yearFormatValue}).format(new Date(e,0))}drawViewTitle(){if(!this.hasViewTitleTarget||!this.hasCalendarMonthOutlet)return;let{year:e,month:t}=this.calendarMonthOutlet.calendar;this.viewTitleTarget.textContent=this.viewTitleLabel(e,t)}drawYearView(){if(!this.hasYearViewTarget||!this.hasCalendarMonthOutlet)return;let{year:e,month:t,monthsOfYear:n}=this.calendarMonthOutlet.calendar,r=this.calendarMonthOutlet.calendar.today,i=[];for(let a of n){let n=document.createElement(`button`);n.type=`button`,n.textContent=a.short,n.dataset.month=a.value+1,n.setAttribute(`role`,`gridcell`),n.setAttribute(`aria-selected`,a.value===t?`true`:`false`),a.value===r.getMonth()&&e===r.getFullYear()&&n.setAttribute(`aria-current`,`month`),i.push(n)}this.yearViewTarget.replaceChildren(...i)}drawDecadeView(){if(!this.hasDecadeViewTarget||!this.hasCalendarMonthOutlet)return;let{year:e,yearsOfDecade:t}=this.calendarMonthOutlet.calendar,n=this.calendarMonthOutlet.calendar.today.getFullYear(),r=[];for(let i of t){let t=document.createElement(`button`);t.type=`button`,t.textContent=i.value,t.dataset.year=i.value,t.setAttribute(`role`,`gridcell`),t.setAttribute(`aria-selected`,i.value===e?`true`:`false`),i.value===n&&t.setAttribute(`aria-current`,`year`),i.outside&&t.setAttribute(`aria-disabled`,`true`),r.push(t)}this.decadeViewTarget.replaceChildren(...r)}viewTitleLabel(e,t){if(this.viewValue===`year`)return String(e);if(this.viewValue===`decade`){let t=Math.floor(e/10)*10;return`${t}–${t+9}`}return new Intl.DateTimeFormat(this.localesValue,{month:`long`,year:`numeric`}).format(new Date(e,t))}stepArgs(e){return this.viewValue===`year`?[`year`,e]:this.viewValue===`decade`?[`year`,e*10]:[`month`,e]}drawView(){if(this.hasMonthViewTarget&&(this.monthViewTarget.hidden=this.viewValue!==`month`),this.hasYearViewTarget&&(this.yearViewTarget.hidden=this.viewValue!==`year`),this.hasDecadeViewTarget&&(this.decadeViewTarget.hidden=this.viewValue!==`decade`),this.hasCalendarMonthOutlet){let e=this.calendarMonthOutlet,t=this.viewValue===`month`;e.hasDaysOfWeekTarget&&(e.daysOfWeekTarget.hidden=!t),e.hasDaysOfMonthTarget&&(e.daysOfMonthTarget.hidden=!t)}}},Ve=class extends t.Controller{static targets=[`listbox`,`loading`,`empty`];static values={url:{type:String,default:``},field:{type:String,default:`q`},delay:{type:Number,default:300}};initialize(){this._requestor=new C}onSelect(e){let t=e.target.closest(`[role="option"]`);!t||t.getAttribute(`aria-disabled`)===`true`||this.select(t.dataset.value??``)}select(e){let t=this.listboxTarget.querySelectorAll(`[role="option"]`);t.forEach(e=>e.setAttribute(`aria-selected`,`false`));let n=[...t].find(t=>t.dataset.value===e);n&&n.setAttribute(`aria-selected`,`true`),this.dispatch(`selected`,{detail:{value:e},bubbles:!0})}onNavigate(e){if([`ArrowUp`,`ArrowDown`,`Enter`,` `].includes(e.key)){if(e.preventDefault(),e.key===`Enter`||e.key===` `){this.listboxTarget.querySelector(`[aria-selected="true"]`)?.click();return}this.step(e.key===`ArrowDown`?1:-1)}}step(e){let t=[...this.listboxTarget.querySelectorAll(`[role="option"]:not([aria-disabled="true"]):not([hidden])`)];if(!t.length)return;let n=this.listboxTarget.querySelector(`[aria-selected="true"]`),r=t.indexOf(n),i=e>0?t[Math.min(r+1,t.length-1)]:t[Math.max(r-1,0)];!i||i===n||(t.forEach(e=>e.setAttribute(`aria-selected`,`false`)),i.setAttribute(`aria-selected`,`true`),i.scrollIntoView({block:`nearest`}))}filter(e){if(this.urlValue){let t=new URL(this.urlValue,window.location.href);t.searchParams.set(this.fieldValue,e),this.setLoading(!0),this._requestor.schedule(()=>this._requestor.request(t).then(e=>e.text()).then(e=>{this.listboxTarget.innerHTML=e,this.setEmpty(this.listboxTarget.querySelectorAll(`[role="option"]`).length===0)}).catch(e=>{e.name!==`AbortError`&&console.error(`[combobox-dropdown] fetch failed`,e)}).finally(()=>this.setLoading(!1)),this.delayValue)}else{let t=T(this.listboxTarget,e);this.setEmpty(t===0)}}showAll(){this.listboxTarget.querySelectorAll(`[role="option"]`).forEach(e=>e.hidden=!1),this.setEmpty(!1)}setLoading(e){this.hasLoadingTarget&&(this.loadingTarget.hidden=!e)}setEmpty(e){this.hasEmptyTarget&&(this.emptyTarget.hidden=!e)}disconnect(){this._requestor.cancel()}},$=class extends t.Controller{static targets=[`hour`,`minute`,`period`];connect(){this.select(this.toH24())}onSelect(e){let t=e.target.closest(`[role="option"]`);t&&(t.closest(`[role="listbox"]`).querySelectorAll(`[role="option"]`).forEach(e=>e.setAttribute(`aria-selected`,`false`)),t.setAttribute(`aria-selected`,`true`),this.select(this.toH24()))}select(e){e&&this.dispatch(`selected`,{detail:{value:e},bubbles:!0})}onNavigate(e){[`ArrowUp`,`ArrowDown`].includes(e.key)&&(e.preventDefault(),this.step(e.currentTarget,e.key===`ArrowDown`?1:-1))}step(e,t){let n=[...e.querySelectorAll(`[role="option"]`)],r=e.querySelector(`[aria-selected="true"]`),i=n.indexOf(r),a=t>0?n[Math.min(i+1,n.length-1)]:n[Math.max(i-1,0)];!a||a===r||(n.forEach(e=>e.setAttribute(`aria-selected`,`false`)),a.setAttribute(`aria-selected`,`true`),a.scrollIntoView({block:`nearest`}),this.select(this.toH24()))}toH24(){let e=this.selectedValue(this.hourTarget),t=this.selectedValue(this.minuteTarget);if(!e||!t)return null;if(!this.hasPeriodTarget)return`${e}:${t}`;let n=this.selectedValue(this.periodTarget),r=parseInt(e,10);return r=n===`AM`?r===12?0:r:r===12?12:r+12,`${String(r).padStart(2,`0`)}:${t}`}selectedValue(e){return e?.querySelector(`[aria-selected="true"]`)?.dataset.value??null}},He=class extends t.Controller{static targets=[`trigger`];connect(){Y(this,{trigger:this.hasTriggerTarget?this.triggerTarget:null})}},Ue=class extends t.Controller{static targets=[`anchor`,`reference`];static values={placement:{type:String,default:`bottom`},alignment:{type:String,default:`start`},role:{type:String,default:`tooltip`}};connect(){if(!this.hasReferenceTarget){console.error(`FlipperController requires a reference target. Add data-flipper-target="reference" to your element.`);return}if(!this.hasAnchorTarget){console.error(`FlipperController requires an anchor target. Add data-flipper-target="anchor" to your element.`);return}Me(this,{element:this.referenceTarget,anchor:this.anchorTarget,placement:this.placementValue,alignment:this.alignmentValue,ariaRole:this.roleValue})}},We=class extends t.Controller{static targets=[`trigger`,`input`];static values={value:String,minLength:{type:Number,default:1}};static outlets=[`combobox-dropdown`];onSelect(e){e.detail?.value!==void 0&&(this.valueValue=e.detail.value)}onInput(e){if(e.target!==this.triggerTarget)return;let t=e.target.value.trim();if(t.length<this.minLengthValue){this.hasComboboxDropdownOutlet&&this.comboboxDropdownOutlet.showAll();return}this.hasComboboxDropdownOutlet&&this.comboboxDropdownOutlet.filter(t)}valueValueChanged(e){this.hasInputTarget&&(this.inputTarget.value=e),this.dispatch(`changed`,{detail:{value:e}})}},Ge=class extends t.Controller{static targets=[`input`,`toggle`];static values={format:{type:String,default:`plain`},options:{type:Object,default:{}},revealed:{type:Boolean,default:!1}};connect(){H(this,{type:this.formatValue,options:this.optionsValue}),this.format(this.readValue()),this.drawToggle()}formatValueChanged(){this.formatter&&(H(this,{type:this.formatValue,options:this.optionsValue}),this.format(this.readValue()),this.drawToggle())}optionsValueChanged(){this.formatter&&(H(this,{type:this.formatValue,options:this.optionsValue}),this.format(this.readValue()))}revealedValueChanged(){this.formatter&&(this.format(this.readValue()),this.drawToggle())}onChange(e){this.format(e?.detail?.value??``)}format(e){this.formatter&&this.onFormatting(e)}toggle(){!this.formatter.maskable()&&this.formatValue!==`password`||(this.revealedValue=!this.revealedValue)}onPaste(e){let t=e.detail?.text??``;if(!this.formatter||!t)return;let n=this.formatter.normalize(t);this.formatter.validate(n)&&this.format(n)}drawToggle(){if(!this.hasToggleTarget)return;let e=this.formatter?.maskable()||this.formatValue===`password`;this.toggleTarget.hidden=!e,e&&_(this.toggleTarget,this.revealedValue)}readValue(){return this.hasInputTarget?this.inputTarget instanceof HTMLInputElement?this.inputTarget.value:this.inputTarget.textContent:``}onFormatting(e){if(!this.formatter)return;if(this.formatValue===`password`){this.hasInputTarget&&(this.inputTarget.type=this.revealedValue?`text`:`password`);return}let t=this.formatter.normalize(e),n=this.revealedValue||!this.formatter.maskable()?this.formatter.format(t):this.formatter.mask(t);this.hasInputTarget&&(this.inputTarget instanceof HTMLInputElement?this.inputTarget.value=n:this.inputTarget.textContent=n),this.dispatch(`formatted`,{detail:{value:n}})}},Ke=class extends t.Controller{static targets=[`input`,`clear`];initialize(){this.onInput=this.draw.bind(this),this.onEscape=this.handleEscape.bind(this)}connect(){this.draw()}inputTargetConnected(e){e.addEventListener(`input`,this.onInput),e.addEventListener(`keydown`,this.onEscape)}inputTargetDisconnected(e){e.removeEventListener(`input`,this.onInput),e.removeEventListener(`keydown`,this.onEscape)}clear(){this.hasInputTarget&&(this.inputTarget.value=``,this.draw(),this.inputTarget.focus(),this.inputTarget.dispatchEvent(new Event(`input`,{bubbles:!0})))}draw(){!this.hasInputTarget||!this.hasClearTarget||(this.clearTarget.hidden=this.inputTarget.value.length===0)}handleEscape(e){e.key===`Escape`&&this.inputTarget.value!==``&&(e.preventDefault(),this.clear())}},qe=class extends t.Controller{static targets=[`modal`,`overlay`];initialize(){this.onCancel=this.close.bind(this)}connect(){this.hasModalTarget||console.error(`ModalController requires a modal target. Add data-modal-target="modal" to your element.`)}modalTargetConnected(e){this.isNativeDialog=e instanceof HTMLDialogElement,this.isNativeDialog?(e.addEventListener(`cancel`,this.onCancel),e.addEventListener(`click`,this.onBackdropClick)):(this.focusTrap=new o(e,{escapeDeactivates:!0}),Y(this,{element:e}))}modalTargetDisconnected(e){this.isNativeDialog&&(e.removeEventListener(`cancel`,this.onCancel),e.removeEventListener(`click`,this.onBackdropClick))}dismissed=()=>{this.close()};open(e){if(e&&e.preventDefault(),this.hasModalTarget){if(this.isNativeDialog)this.previouslyFocused=document.activeElement,this.modalTarget.showModal();else{let e=this.hasOverlayTarget?this.overlayTarget:this.modalTarget;e.hidden=!1,document.body.style.overflow=`hidden`,this.focusTrap&&this.focusTrap.activate()}m(`Modal opened`)}}close(e){if(e&&e.preventDefault(),this.hasModalTarget){if(this.isNativeDialog)this.modalTarget.close(),this.previouslyFocused&&this.previouslyFocused.isConnected&&setTimeout(()=>{this.previouslyFocused.focus()},0);else{let e=this.hasOverlayTarget?this.overlayTarget:this.modalTarget;e.hidden=!0,document.body.style.overflow=``,this.focusTrap&&this.focusTrap.deactivate()}m(`Modal closed`)}}onBackdropClick=e=>{let t=this.modalTarget.getBoundingClientRect();(e.clientY<t.top||e.clientY>t.bottom||e.clientX<t.left||e.clientX>t.right)&&this.close()}},Je=class extends t.Controller{static targets=[`content`];connect(){Fe(this,{element:this.hasContentTarget?this.contentTarget:null})}},Ye=class extends t.Controller{static targets=[`trigger`,`panel`,`template`,`loader`];static classes=[`hidden`];static values={url:String,loadedAt:String,reload:{type:String,default:`never`},staleAfter:{type:Number,default:3600},closeOnSelect:{type:Boolean,default:!0}};connect(){De(this,{element:this.hasPanelTarget?this.panelTarget:null,url:this.hasUrlValue?this.urlValue:null}),this.hasPanelTarget&&(Z(this,{element:this.panelTarget,activator:this.hasTriggerTarget?this.triggerTarget:null}),Y(this)),this.hasLoaderTarget&&Z(this,{element:this.loaderTarget,visibility:`contentLoaderVisibility`})}async dismissed(){await this.close()}async open(){this.hasPanelTarget&&await this.visibility.show()}async close(){this.hasPanelTarget&&await this.visibility.hide()}async toggle(){this.visibility?.visible?await this.close():await this.open()}async closeOnSelect(){this.closeOnSelectValue&&await this.close()}async shown(){await this.load(),this.hasPanelTarget&&a(this.panelTarget)}async hidden(){this.hasTriggerTarget&&this.triggerTarget.focus()}canLoad(){return this.hasPanelTarget&&this.panelTarget.tagName.toLowerCase()===`turbo-frame`?(this.hasUrlValue&&this.panelTarget.setAttribute(`src`,this.urlValue),!1):!0}async contentLoading(){this.hasLoaderTarget&&await this.contentLoaderVisibility.show()}async contentLoaded({content:e}){this.hasPanelTarget&&this.panelTarget.replaceChildren(this.getContentNode(e)),this.hasLoaderTarget&&await this.contentLoaderVisibility.hide()}getContentNode(e){if(typeof e==`string`){let t=document.createElement(`template`);return t.innerHTML=e,document.importNode(t.content,!0)}return document.importNode(e,!0)}contentLoader(){if(this.hasTemplateTarget)return this.templateTarget instanceof HTMLTemplateElement?this.templateTarget.content:this.templateTarget.innerHTML}};e.ARIA_HASPOPUP_VALUES=v,e.CalendarMonthController=Le,e.CalendarObserverController=Re,e.ClipboardController=ze,e.ComboboxDateController=Be,e.ComboboxDropdownController=Ve,e.ComboboxTimeController=$,e.DismisserController=He,e.FOCUSABLE_SELECTOR=n,e.FORMATTER_TYPES=R,e.FlipperController=Ue,e.FocusRestoration=s,e.FocusTrap=o,e.Formatter=V,e.InputClearableController=Ke,e.InputComboboxController=We,e.InputFormatterController=Ge,e.ModalController=qe,e.PannerController=Je,e.PopoverController=Ye,e.Requestor=C,e.RovingTabIndex=f,e.announce=m,e.connectTriggerToTarget=x,e.disconnectTriggerFromTarget=ie,e.ensureId=ee,e.filterOptions=T,e.focusFirst=a,e.fuzzyMatcher=w,e.generateId=h,e.getFocusableElements=r,e.isActivationKey=l,e.isArrowKey=u,e.isKey=c,e.isVisible=i,e.preventDefault=d,e.setAriaState=g,e.setChecked=ne,e.setDisabled=re,e.setExpanded=te,e.setPressed=_});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stimulus-plumbers/controllers",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "Stimulus controllers following WCAG standards",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -11,7 +11,8 @@
11
11
  ],
12
12
  "scripts": {
13
13
  "dev": "vite",
14
- "build": "vite build",
14
+ "build": "vite build && npm run build:manifest",
15
+ "build:manifest": "node scripts/build-controllers-manifest.mjs",
15
16
  "preview": "vite preview",
16
17
  "test": "vitest run",
17
18
  "test:ui": "vitest --ui",
@@ -40,10 +41,8 @@
40
41
  "devDependencies": {
41
42
  "@eslint/js": "^10.0.1",
42
43
  "@hotwired/stimulus": "^3.2.2",
43
- "@testing-library/dom": "^10.4.0",
44
44
  "@vitest/coverage-v8": "^4.0.18",
45
45
  "@vitest/ui": "^4.1.4",
46
- "axe-core": "^4.10.2",
47
46
  "eslint": "^10.2.0",
48
47
  "globals": "^17.4.0",
49
48
  "jsdom": "^29.0.0",
@@ -1,18 +1,21 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
2
  import { initCalendar } from '../plumbers';
3
+ import { tryParseDate } from '../plumbers/plumber/date';
3
4
 
4
5
  export default class extends Controller {
5
6
  static targets = ['daysOfWeek', 'daysOfMonth'];
6
- static classes = ['dayOfWeek', 'dayOfMonth', 'week'];
7
+ static classes = ['dayOfWeek', 'dayOfMonth', 'row'];
7
8
  static values = {
8
9
  locales: { type: Array, default: ['default'] },
9
10
  weekdayFormat: { type: String, default: 'short' },
10
11
  dayFormat: { type: String, default: 'numeric' },
11
12
  daysOfOtherMonth: { type: Boolean, default: false },
13
+ today: { type: String, default: '' },
14
+ selected: { type: String, default: '' },
12
15
  };
13
16
 
14
17
  initialize() {
15
- initCalendar(this);
18
+ initCalendar(this, { today: this.todayValue });
16
19
  }
17
20
 
18
21
  connect() {
@@ -23,9 +26,31 @@ export default class extends Controller {
23
26
  this.draw();
24
27
  }
25
28
 
29
+ selectedValueChanged() {
30
+ if (!this.hasDaysOfMonthTarget) return;
31
+
32
+ this.daysOfMonthTarget.querySelectorAll('[aria-selected]').forEach((el) => {
33
+ el.setAttribute('aria-selected', 'false');
34
+ });
35
+
36
+ if (!this.selectedValue) return;
37
+
38
+ const parsed = tryParseDate(this.selectedValue);
39
+ if (!parsed) return;
40
+
41
+ const time = this.daysOfMonthTarget.querySelector(`time[datetime="${parsed.toISOString()}"]`);
42
+ if (time) time.closest('[aria-selected]').setAttribute('aria-selected', 'true');
43
+ }
44
+
45
+ onSelect(event) {
46
+ const iso = event.detail?.iso;
47
+ if (iso) this.selectedValue = iso;
48
+ }
49
+
26
50
  draw() {
27
51
  this.drawDaysOfWeek();
28
52
  this.drawDaysOfMonth();
53
+ this.selectedValueChanged();
29
54
  }
30
55
 
31
56
  createDayElement(day, { selectable = false, disabled = false } = {}) {
@@ -56,7 +81,7 @@ export default class extends Controller {
56
81
  }
57
82
  const row = document.createElement('div');
58
83
  row.setAttribute('role', 'row');
59
- if (this.hasWeekClass) row.classList.add(...this.weekClasses);
84
+ if (this.hasRowClass) row.classList.add(...this.rowClasses);
60
85
  row.replaceChildren(...daysOfWeek);
61
86
  this.daysOfWeekTarget.replaceChildren(row);
62
87
  }
@@ -77,6 +102,7 @@ export default class extends Controller {
77
102
  });
78
103
 
79
104
  if (today === date.date.getTime()) dayElement.setAttribute('aria-current', 'date');
105
+ if (date.current || this.daysOfOtherMonthValue) dayElement.setAttribute('aria-selected', '');
80
106
  if (this.hasDayOfMonthClass) dayElement.classList.add(...this.dayOfMonthClasses);
81
107
 
82
108
  const time = document.createElement('time');
@@ -90,7 +116,7 @@ export default class extends Controller {
90
116
  for (let i = 0; i < daysOfMonth.length; i += 7) {
91
117
  const row = document.createElement('div');
92
118
  row.setAttribute('role', 'row');
93
- if (this.hasWeekClass) row.classList.add(...this.weekClasses);
119
+ if (this.hasRowClass) row.classList.add(...this.rowClasses);
94
120
  for (const day of daysOfMonth.slice(i, i + 7)) {
95
121
  day.setAttribute('role', 'gridcell');
96
122
  row.appendChild(day);
@@ -3,11 +3,11 @@ import { Controller } from '@hotwired/stimulus';
3
3
  export default class extends Controller {
4
4
  static targets = ['source'];
5
5
  static values = {
6
- type: { type: String, default: 'text/plain' },
6
+ contentType: { type: String, default: 'text/plain' },
7
7
  };
8
8
 
9
9
  onPaste(event) {
10
- const text = event.clipboardData?.getData(this.typeValue) ?? '';
10
+ const text = event.clipboardData?.getData(this.contentTypeValue) ?? '';
11
11
  const types = Array.from(event.clipboardData?.types ?? []);
12
12
  event.preventDefault();
13
13
  this.dispatch('pasted', { detail: { text, types }, bubbles: true });
@@ -1,11 +1,14 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
2
  import { tryParseDate } from '../plumbers/plumber/date';
3
3
 
4
+ const VIEWS = ['month', 'year', 'decade'];
5
+
4
6
  export default class extends Controller {
5
- static targets = ['previous', 'next', 'day', 'month', 'year'];
7
+ static targets = ['previous', 'next', 'day', 'month', 'year', 'viewTitle', 'monthView', 'yearView', 'decadeView'];
6
8
  static outlets = ['calendar-month'];
7
9
  static values = {
8
10
  date: String,
11
+ view: { type: String, default: 'month' },
9
12
  locales: { type: Array, default: ['default'] },
10
13
  dayFormat: { type: String, default: 'numeric' },
11
14
  monthFormat: { type: String, default: 'long' },
@@ -15,6 +18,8 @@ export default class extends Controller {
15
18
  initialize() {
16
19
  this.previous = this.previous.bind(this);
17
20
  this.next = this.next.bind(this);
21
+ this.selectMonth = this.selectMonth.bind(this);
22
+ this.selectYear = this.selectYear.bind(this);
18
23
  }
19
24
 
20
25
  async calendarMonthOutletConnected() {
@@ -31,34 +36,84 @@ export default class extends Controller {
31
36
  this.dispatch('selected', { detail: { value: event.detail.iso }, bubbles: true });
32
37
  }
33
38
 
39
+ zoomOut() {
40
+ const idx = VIEWS.indexOf(this.viewValue);
41
+ if (idx < VIEWS.length - 1) {
42
+ this.viewValue = VIEWS[idx + 1];
43
+ this.draw();
44
+ }
45
+ }
46
+
47
+ async selectMonth(event) {
48
+ const btn = event.target.closest('button[data-month]');
49
+ if (!btn) return;
50
+ const month = parseInt(btn.dataset.month, 10) - 1; // data-month is 1-indexed
51
+ const { year } = this.calendarMonthOutlet.calendar;
52
+ await this.calendarMonthOutlet.calendar.navigate(new Date(year, month, 1));
53
+ this.viewValue = 'month';
54
+ this.draw();
55
+ }
56
+
57
+ async selectYear(event) {
58
+ const btn = event.target.closest('button[data-year]');
59
+ if (!btn || btn.getAttribute('aria-disabled') === 'true') return;
60
+ const year = parseInt(btn.dataset.year, 10);
61
+ const { month } = this.calendarMonthOutlet.calendar;
62
+ await this.calendarMonthOutlet.calendar.navigate(new Date(year, month, 1));
63
+ this.viewValue = 'year';
64
+ this.draw();
65
+ }
66
+
34
67
  previousTargetConnected(target) {
35
68
  target.addEventListener('click', this.previous);
36
69
  }
70
+
37
71
  previousTargetDisconnected(target) {
38
72
  target.removeEventListener('click', this.previous);
39
73
  }
40
74
 
41
75
  async previous() {
42
- await this.calendarMonthOutlet.calendar.step('month', -1);
76
+ await this.calendarMonthOutlet.calendar.step(...this.stepArgs(-1));
43
77
  this.draw();
44
78
  }
45
79
 
46
80
  nextTargetConnected(target) {
47
81
  target.addEventListener('click', this.next);
48
82
  }
83
+
49
84
  nextTargetDisconnected(target) {
50
85
  target.removeEventListener('click', this.next);
51
86
  }
52
87
 
53
88
  async next() {
54
- await this.calendarMonthOutlet.calendar.step('month', 1);
89
+ await this.calendarMonthOutlet.calendar.step(...this.stepArgs(1));
55
90
  this.draw();
56
91
  }
57
92
 
93
+ yearViewTargetConnected(target) {
94
+ target.addEventListener('click', this.selectMonth);
95
+ }
96
+
97
+ yearViewTargetDisconnected(target) {
98
+ target.removeEventListener('click', this.selectMonth);
99
+ }
100
+
101
+ decadeViewTargetConnected(target) {
102
+ target.addEventListener('click', this.selectYear);
103
+ }
104
+
105
+ decadeViewTargetDisconnected(target) {
106
+ target.removeEventListener('click', this.selectYear);
107
+ }
108
+
58
109
  draw() {
59
110
  this.drawDay();
60
111
  this.drawMonth();
61
112
  this.drawYear();
113
+ this.drawViewTitle();
114
+ this.drawYearView();
115
+ this.drawDecadeView();
116
+ this.drawView();
62
117
  }
63
118
 
64
119
  drawDay() {
@@ -84,4 +139,83 @@ export default class extends Controller {
84
139
  new Date(year, 0)
85
140
  );
86
141
  }
142
+
143
+ drawViewTitle() {
144
+ if (!this.hasViewTitleTarget || !this.hasCalendarMonthOutlet) return;
145
+ const { year, month } = this.calendarMonthOutlet.calendar;
146
+ this.viewTitleTarget.textContent = this.viewTitleLabel(year, month);
147
+ }
148
+
149
+ drawYearView() {
150
+ if (!this.hasYearViewTarget || !this.hasCalendarMonthOutlet) return;
151
+
152
+ const { year, month, monthsOfYear } = this.calendarMonthOutlet.calendar;
153
+ const today = this.calendarMonthOutlet.calendar.today;
154
+ const cells = [];
155
+
156
+ for (const m of monthsOfYear) {
157
+ const btn = document.createElement('button');
158
+ btn.type = 'button';
159
+ btn.textContent = m.short;
160
+ btn.dataset.month = m.value + 1; // 1-indexed to match SSR convention
161
+ btn.setAttribute('role', 'gridcell');
162
+ btn.setAttribute('aria-selected', m.value === month ? 'true' : 'false');
163
+ if (m.value === today.getMonth() && year === today.getFullYear()) {
164
+ btn.setAttribute('aria-current', 'month');
165
+ }
166
+ cells.push(btn);
167
+ }
168
+
169
+ this.yearViewTarget.replaceChildren(...cells);
170
+ }
171
+
172
+ drawDecadeView() {
173
+ if (!this.hasDecadeViewTarget || !this.hasCalendarMonthOutlet) return;
174
+
175
+ const { year, yearsOfDecade } = this.calendarMonthOutlet.calendar;
176
+ const todayYear = this.calendarMonthOutlet.calendar.today.getFullYear();
177
+ const cells = [];
178
+
179
+ for (const y of yearsOfDecade) {
180
+ const btn = document.createElement('button');
181
+ btn.type = 'button';
182
+ btn.textContent = y.value;
183
+ btn.dataset.year = y.value;
184
+ btn.setAttribute('role', 'gridcell');
185
+ btn.setAttribute('aria-selected', y.value === year ? 'true' : 'false');
186
+ if (y.value === todayYear) btn.setAttribute('aria-current', 'year');
187
+ if (y.outside) btn.setAttribute('aria-disabled', 'true');
188
+ cells.push(btn);
189
+ }
190
+
191
+ this.decadeViewTarget.replaceChildren(...cells);
192
+ }
193
+
194
+ viewTitleLabel(year, month) {
195
+ if (this.viewValue === 'year') return String(year);
196
+ if (this.viewValue === 'decade') {
197
+ const start = Math.floor(year / 10) * 10;
198
+ return `${start}–${start + 9}`;
199
+ }
200
+ return new Intl.DateTimeFormat(this.localesValue, { month: 'long', year: 'numeric' }).format(new Date(year, month));
201
+ }
202
+
203
+ stepArgs(direction) {
204
+ if (this.viewValue === 'year') return ['year', direction];
205
+ if (this.viewValue === 'decade') return ['year', direction * 10];
206
+ return ['month', direction];
207
+ }
208
+
209
+ drawView() {
210
+ if (this.hasMonthViewTarget) this.monthViewTarget.hidden = this.viewValue !== 'month';
211
+ if (this.hasYearViewTarget) this.yearViewTarget.hidden = this.viewValue !== 'year';
212
+ if (this.hasDecadeViewTarget) this.decadeViewTarget.hidden = this.viewValue !== 'decade';
213
+
214
+ if (this.hasCalendarMonthOutlet) {
215
+ const outlet = this.calendarMonthOutlet;
216
+ const monthView = this.viewValue === 'month';
217
+ if (outlet.hasDaysOfWeekTarget) outlet.daysOfWeekTarget.hidden = !monthView;
218
+ if (outlet.hasDaysOfMonthTarget) outlet.daysOfMonthTarget.hidden = !monthView;
219
+ }
220
+ }
87
221
  }
@@ -1,55 +1,16 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
- import { focusFirst } from '../accessibility/focus';
3
- import { attachDismisser, attachVisibility } from '../plumbers';
4
2
 
5
3
  export default class extends Controller {
6
- static targets = ['trigger', 'popover', 'value'];
4
+ static targets = ['trigger', 'input'];
7
5
  static values = {
8
6
  value: String,
9
7
  minLength: { type: Number, default: 1 },
10
8
  };
11
9
  static outlets = ['combobox-dropdown'];
12
10
 
13
- connect() {
14
- attachDismisser(this);
15
- if (this.hasPopoverTarget) {
16
- attachVisibility(this, {
17
- element: this.popoverTarget,
18
- activator: this.hasTriggerTarget ? this.triggerTarget : null,
19
- });
20
- }
21
- }
22
-
23
- async dismissed() {
24
- await this.close();
25
- }
26
-
27
- async open() {
28
- if (!this.hasPopoverTarget) return;
29
- await this.visibility.show();
30
- }
31
-
32
- async close() {
33
- if (!this.hasPopoverTarget) return;
34
- await this.visibility.hide();
35
- }
36
-
37
- async toggle() {
38
- this.visibility?.visible ? await this.close() : await this.open();
39
- }
40
-
41
- async shown() {
42
- if (this.hasPopoverTarget) focusFirst(this.popoverTarget);
43
- }
44
-
45
- async hidden() {
46
- if (this.hasTriggerTarget) this.triggerTarget.focus();
47
- }
48
-
49
- // Receives combobox-*:selected events from sub-controllers
50
- async onSelect(event) {
11
+ // Commits the value only; popover#closeOnSelect handles dismissal.
12
+ onSelect(event) {
51
13
  if (event.detail?.value !== undefined) this.valueValue = event.detail.value;
52
- await this.close();
53
14
  }
54
15
 
55
16
  onInput(event) {
@@ -63,7 +24,7 @@ export default class extends Controller {
63
24
  }
64
25
 
65
26
  valueValueChanged(newVal) {
66
- if (this.hasValueTarget) this.valueTarget.value = newVal;
27
+ if (this.hasInputTarget) this.inputTarget.value = newVal;
67
28
  this.dispatch('changed', { detail: { value: newVal } });
68
29
  }
69
30
  }