@featherk/composables 0.8.2 → 0.9.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(X,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@vueuse/integrations/useFocusTrap")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/integrations/useFocusTrap"],t):(X=typeof globalThis<"u"?globalThis:X||self,t(X.FeatherKComposables={},X.Vue,X.useFocusTrap))})(this,(function(X,t,Te){"use strict";const Ie=(e,n)=>{const i=t.ref(null);let F=!1,I=null,$=null;const P=[],D=".k-table-row[data-grid-row-index] [tabindex]",E=()=>{const l=e?.value?.$el;return l?l.closest(".k-grid"):null},x=l=>{const g=E();if(!g)return!1;const u=l.closest(".k-grid-aria-root");if(u)return g.contains(u);const d=l.closest(".k-grid-header, .k-grid-content, .k-grid-content-locked");return d?g.contains(d):!1},A=l=>l.key==="Enter"||l.code==="Enter"||l.code==="NumpadEnter",L=()=>e?.value?.columns,b=l=>{const g=l.key||l.code;([" ","Spacebar","Space"].includes(g)||A(l))&&(l.preventDefault(),l.stopPropagation(),i.value=l.target,l.target.click())},y=l=>{if(!i.value)return;if(l.code==="Escape"){l.stopPropagation(),i.value&&i.value.focus();return}const g=Array.from(document.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item")),u=document.querySelector(".k-animation-container .k-popup .k-column-menu .k-filter-menu-container");if(u){if(l.code==="Tab"){const d=[".k-dropdownlist[tabindex='0']","input.k-input-inner:not([tabindex='-1']):not([disabled])","button:not([tabindex='-1']):not([disabled])",".k-checkbox"],k=n?.focusableMenuSelectors??d,m=Array.from(u.querySelectorAll(k.join(",")));if(m.length===0)return;const w=m.findIndex(j=>j===document.activeElement);let V;w===-1?V=0:l.shiftKey?V=(w-1+m.length)%m.length:V=(w+1)%m.length,l.preventDefault(),l.stopPropagation(),m[V]?.focus()}}else if(l.code==="ArrowUp"||l.code==="ArrowDown"){l.preventDefault(),l.stopPropagation();const d=g.findIndex(m=>m===document.activeElement);let k=d;l.code==="ArrowUp"?k=d>0?d-1:g.length-1:l.code==="ArrowDown"&&(k=d<g.length-1?d+1:0),g[k]?.focus();return}if(l.code==="Tab"){l.preventDefault(),l.stopPropagation();const d=i.value?.parentElement;(l.shiftKey?d?.previousElementSibling:d?.nextElementSibling)?.querySelector("button, [role='button'], .k-link")?.focus()}},M=()=>{I=new MutationObserver(l=>{l.forEach(g=>{g.addedNodes.forEach(u=>{if(u.nodeType===Node.ELEMENT_NODE){const d=u;if(d.classList.contains("k-animation-container")){const m=i.value;m&&(m.dataset.featherKSortable==="true"||t.nextTick(()=>{d.querySelectorAll(".k-columnmenu-item-wrapper").forEach(j=>{j.textContent?.toLowerCase().includes("sort")&&j.remove()})})),d.addEventListener("keydown",y),t.nextTick(()=>{const w=()=>{const V=Array.from(d.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"));if(V.length===1)V[0].focus(),V[0].click(),w.attempts=0;else if(V.length>1){w.attempts=0;return}else w.attempts===void 0&&(w.attempts=0),w.attempts++<3&&setTimeout(w,200)};w()})}d.querySelectorAll(".k-animation-container").forEach(m=>{m.addEventListener("keydown",y)})}}),g.removedNodes.forEach(u=>{if(u.nodeType===Node.ELEMENT_NODE){const d=u;d.classList.contains("k-animation-container")&&d.removeEventListener("keydown",y),d.querySelectorAll(".k-animation-container").forEach(m=>{m.removeEventListener("keydown",y)})}})})}),I.observe(document.body,{childList:!0,subtree:!0})},R=l=>{const g=l.tagName.toLowerCase();return!!(["input","textarea","select","button"].includes(g)||l.closest('.k-picker-wrap, .k-input-inner, .k-textbox, [role="combobox"]'))},f=l=>{if(!l.type||!l)return;const g=l.target;if(!g)return;const u=g.closest(".k-table-row[data-grid-row-index]");if(!x(g))return;const d=["ArrowLeft","ArrowRight"].includes(l.code);if(!(R(g)&&!(u&&d))){if(l.code==="Escape"){const k=document.activeElement?.closest(".k-table-row[data-grid-row-index]");if(k){l.preventDefault(),l.stopPropagation();try{Array.from(e?.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]")).forEach(w=>w.setAttribute("tabindex","-1"))}catch{}k.setAttribute("tabindex","0"),k.focus();return}}if(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter","NumpadEnter","Space"].includes(l.code)){if(g.classList.contains("k-grid-header-menu")&&g.classList.contains("k-grid-column-menu")){i.value=g;return}if(u){if(["ArrowDown","ArrowUp"].includes(l.code)){l.preventDefault(),l.stopPropagation();const k=(w,V)=>{let j=V==="next"?w.nextElementSibling:w.previousElementSibling;for(;j;){const a=j;try{if(a.classList.contains("k-table-row"))return a}catch{}j=V==="next"?j.nextElementSibling:j.previousElementSibling}return null},m=l.code==="ArrowDown"?k(u,"next"):k(u,"previous");m&&(u.setAttribute("tabindex","-1"),m.setAttribute("tabindex","0"),m.focus());return}if(["ArrowLeft","ArrowRight"].includes(l.code)){l.preventDefault(),l.stopPropagation();const k=u.querySelectorAll(D);if(k.length===0)return;let m=Array.from(k).findIndex(w=>w===document.activeElement);if(m===-1&&document.activeElement===u){k[0].focus();return}l.code==="ArrowRight"?m=m===k.length-1?0:m+1:l.code==="ArrowLeft"&&(m=m===0?k.length-1:m-1),k[m].focus();return}}}}},S=()=>{t.nextTick(()=>{const l=e.value.$el.closest(".k-grid");l&&l.classList.add("fk-grid")})},q=()=>{if(!$)try{const l=()=>{try{const d=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));if(!d||d.length===0||d.filter(w=>w.getAttribute("tabindex")==="0").length===1)return;const m=d.find(w=>w===document.activeElement||w.contains(document.activeElement));if(d.forEach(w=>w.setAttribute("tabindex","-1")),m){m.setAttribute("tabindex","0");return}d[0].setAttribute("tabindex","0")}catch(d){console.error("ensureSingleTabindex error:",d)}},g=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));g.length>0&&g.forEach((d,k)=>{d.setAttribute("tabindex",k===0?"0":"-1")});const u=e.value.$el.querySelector(".k-table-tbody");u&&($=new MutationObserver(()=>{l()}),$.observe(u,{childList:!0,subtree:!0}))}catch(l){console.error("Error setting up row navigation:",l)}},G=()=>{t.nextTick(()=>{const g=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");g&&g.forEach(u=>{u.setAttribute("role","button"),u.addEventListener("keydown",b)}),M(),J()})},W=()=>{const g=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");g&&g.forEach(u=>{u.removeEventListener("keydown",b)}),I&&(I.disconnect(),I=null),$&&($.disconnect(),$=null),P.forEach(u=>u()),P.length=0},J=()=>{document.querySelectorAll(".k-grid-header .k-table-thead th").forEach((u,d)=>{if(u.dataset.featherKHeaderBound==="true")return;const k=u.querySelector(".k-grid-header-menu.k-grid-column-menu");if(!k)return;const m=L();if(m&&m[d]){const h=m[d].field??"";u.setAttribute("data-feather-k-field",h),u.setAttribute("data-feather-k-filterable",m[d].filterable===!1?"false":"true"),u.setAttribute("data-feather-k-sortable",m[d].sortable===!1?"false":"true")}const w=u.dataset.featherKFilterable!=="false",V=u.dataset.featherKSortable!=="false";k.setAttribute("tabindex","-1"),w||V?u.style.cursor="pointer":u.style.cursor="default",w?(u.setAttribute("tabindex","0"),u.setAttribute("role","button"),u.setAttribute("aria-haspopup","menu")):(u.setAttribute("tabindex","0"),u.setAttribute("role","columnheader"),u.removeAttribute("aria-haspopup"));const j=h=>{h.target?.closest(".k-column-resizer")||(i.value=u,k.click())},a=h=>{if(w)i.value=u,h.preventDefault(),h.stopPropagation(),j(h);else if(V){i.value=u;const U=u.querySelector(".k-link");U&&U.click()}};u.addEventListener("click",a),P.push(()=>{u.removeEventListener("click",a)});const p=h=>{if((A(h)||h.code==="Space")&&(w||V)){if(h.preventDefault(),h.stopPropagation(),i.value=u,i.value.focus(),w)j(h);else if(V){const U=u.querySelector(".k-link");U&&U.click()}}};u.addEventListener("keydown",p,!0),P.push(()=>{u.removeEventListener("keydown",p,!0)}),u.dataset.featherKHeaderBound="true"});const g=document.querySelector(".k-grid-header .k-table-thead");if(g&&g.dataset.featherKHeaderBound!=="true"){const u=d=>{const k=d.target.closest("th");k&&(A(d)||d.code==="Space")&&k.dataset.featherKFilterable==="false"&&k.dataset.featherKSortable==="false"&&(d.preventDefault(),d.stopImmediatePropagation())};g.addEventListener("keydown",u,!0),P.push(()=>{g.removeEventListener("keydown",u,!0)}),g.dataset.featherKHeaderBound="true"}},Q=function(l,g){const u=l?.event?.event.target,d=L();if(!u||!d)return;const k=u.classList.contains("k-grid-header-menu"),m=u.classList.contains("k-columnmenu-item"),w=d.find(V=>V.field===l?.event?.field)?.sortable&&!0;if(!k){if(m&&!w){l?.event?.sort?.filter(j=>j.field!==l?.event?.field);return}typeof g=="function"&&t.nextTick(()=>{i.value&&i.value.focus(),g(l),t.nextTick(()=>{J()})})}},oe=()=>{if(!F)try{S(),q(),G(),F=!0}catch(l){console.error("initA11y failed:",l),W()}};return t.onBeforeUnmount(()=>{W()}),{activeFilterButton:i,handleGridKeyDown:f,handleSortChange:Q,initA11y:oe}},$e=e=>!!e&&typeof e=="object"&&"filters"in e&&Array.isArray(e.filters),Ce=e=>!!e&&typeof e=="object"&&"field"in e,we=(e,n)=>!e||typeof e!="object"?!1:$e(e)?e.filters.some(i=>we(i,n)):Ce(e)?e.field===n:!1,Pe=e=>n=>e.value?.filters&&e.value.filters.some(i=>we(i,n))?"active":"",Fe="Enter a valid ZIP code with exactly 5 or 9 digits.",De=e=>{const n=e.replace(/\D/g,"").slice(0,9);return n.length>5?`${n.slice(0,5)}-${n.slice(5)}`:n},Le=(e,n)=>e.slice(0,Math.max(0,n)).replace(/\D/g,"").length,Re=e=>e<=5?e:Math.min(e+1,10),qe=e=>{const n=t.ref(De(e.initialValue??"")),i=t.ref(!1),F=t.ref(e.errorMessage?.trim()||Fe),I=t.computed(()=>n.value.replace(/\D/g,"")),$=t.computed(()=>{const y=I.value.length;return y===5||y===9}),P=t.computed(()=>i.value&&!$.value),D=t.computed(()=>!i.value||$.value),E=t.computed(()=>i.value),x=(y,M)=>{const R=Re(M);t.nextTick(()=>{y.isConnected&&y.setSelectionRange(R,R)})};return{zipDisplay:n,submitted:i,errorMessage:F,wrapperClass:"fk-zip-textbox",zipRaw:I,isZipValid:$,showZipError:P,textBoxValid:D,textBoxValidate:E,handleZipInput:(...y)=>{const M=y[0],f=M?.event?.target,S=M?.value,q=Array.isArray(S)?S.join(""):String(S??""),G=f?.selectionStart!==void 0&&f.selectionStart!==null?Le(f.value,f.selectionStart):q.replace(/\D/g,"").length;n.value=De(q),f&&x(f,G)},submitAndValidate:y=>{i.value=!0;const M=$.value;return!M&&y?.focus&&t.nextTick(()=>{document.getElementById(e.id)?.focus()}),M},buildPayload:()=>({zip:I.value})}};function Ae(e,n){const i=t.ref(!1);t.watchEffect(()=>{e.value?.setAttribute("aria-invalid",String(!n.isValid()))});function F($){const P=e.value??$.currentTarget,D=$.relatedTarget;(!P||!P.contains(D))&&(i.value=!0)}function I(){i.value=!1}return{touched:i,onFocusout:F,reset:I}}function Ve(e,n){const i=t.ref(!1),F=t.ref(!1),I=t.computed(()=>t.toValue(n.submitted)||i.value),$=t.computed(()=>!I.value||n.isValid()),P=Ae(e,{isValid:()=>$.value});function D(b){return t.computed(()=>!I.value||t.toValue(b))}function E(b){return Object.fromEntries(Object.entries(b).map(([y,M])=>[y,D(M)]))}function x(b){const y=t.toValue(b);if(!y)return;y.querySelector('.k-invalid input, .k-invalid[tabindex="0"]')?.focus()}function A(b){if(F.value){F.value=!1;return}P.onFocusout(b),P.touched.value&&(i.value=!0)}function L(){i.value=!1,F.value=!0,P.reset()}return{touched:i,fieldsetValidate:I,onFocusout:A,reset:L,createFieldValidity:D,createFieldValidationsMap:E,focusFirstInvalidField:x}}function Oe(e){const n=t.ref(""),i=t.ref(void 0),F=t.ref(!!e.debug),I=t.ref(e.dateFormat??"mm/dd/yyyy"),$=t.computed(()=>!!e.required),P=t.ref(!1),D=["ArrowUp","ArrowDown"],E=["ArrowLeft","ArrowRight"],x=t.computed(()=>(n.value??"").replace(/\D/g,"")),A=a=>a<=2?"mm":a<=5?"dd":x.value.length<=10?"yyyy":"mm",L=t.computed(()=>{const a=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0";return parseInt(a).toString().padStart(2,"0")}),b=t.computed(()=>{const a=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0";return parseInt(a).toString().padStart(2,"0")}),y=t.computed(()=>{const a=n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0";return parseInt(a).toString().padStart(4,"0")}),M=a=>{if(x.value.length===0){e.onChange({value:null,event:a});return}if(x.value.length<8){e.onChange({value:null,event:a});return}if((n.value??"").length===10&&x.value.length===8){const[p,h,U]=n.value.split("/"),K=parseInt(p),N=parseInt(h),_=parseInt(U);if(G(_,K,N)){const ae=new Date(_,K-1,N);R(ae)?e.onChange({value:ae,event:a}):e.onChange({value:null,event:a})}else e.onChange({value:null,event:a})}},R=a=>{const p=e.min??void 0,h=e.max??void 0;return!(p&&a<p||h&&a>h)},f=t.computed(()=>{if((n.value??"").length===10&&x.value.length===8){const[a,p,h]=(n.value??"").split("/"),U=parseInt(a),K=parseInt(p),N=parseInt(h);if(G(N,U,K))return new Date(N,U-1,K)}return null}),S=t.computed(()=>(n.value??"").length===10&&x.value.length===8),q=(a,p)=>new Date(a,p,0).getDate(),G=(a,p,h)=>p>=1&&p<=12&&a>=1900&&h>=1&&h<=q(a,p),W=a=>{n.value=a.value;const p=a.event?.target;i.value=p?.selectionStart??0,M(a)},J=a=>{i.value=a.target.selectionStart??0},Q=(a,p,h)=>{const U=p?.selectionStart??i.value??0;i.value=U;let K=parseInt(L.value),N=parseInt(b.value),_=parseInt(y.value);if(!(x.value.length>=8)||!G(_,K,N)){const z=e.defaultValue??new Date;K=z.getMonth()+1,N=z.getDate(),_=z.getFullYear(),n.value=`${String(K).padStart(2,"0")}/${String(N).padStart(2,"0")}/${String(_)}`;const B=new Date(_,K-1,N);e.onChange({value:R(B)?B:null,event:h}),d({useRAF:!0});return}const o=A(U);if(o==="mm")K=a==="ArrowUp"?K<12?K+1:1:K>1?K-1:12;else if(o==="dd"){const z=new Date(_,K,0).getDate();N=a==="ArrowUp"?N<z?N+1:1:N>1?N-1:z}else o==="yyyy"&&(_=a==="ArrowUp"?_+1:Math.max(1,_-1));n.value=`${String(K).padStart(2,"0")}/${String(N).padStart(2,"0")}/${String(_)}`;const[s,C,O]=n.value.split("/"),H=new Date(parseInt(O),parseInt(s)-1,parseInt(C));H.toString()!=="Invalid Date"&&parseInt(O)>=1e3?e.onChange({value:R(H)?H:null,event:h}):e.onChange({value:null,event:h}),d({useRAF:!0})},oe=a=>{if(a.code==="Space"||a.key===" "){a.preventDefault(),a.stopPropagation(),e.onShowCalendar(a);return}if(a.key==="ArrowDown"&&a.altKey){a.preventDefault(),a.stopPropagation(),e.onShowCalendar(a);return}if(D.includes(a.key)){if(a.altKey)return;a.preventDefault(),a.stopPropagation();const p=a.target;Q(a.key,p,a);return}},l=a=>{a.preventDefault();const p=a.deltaY<0?"ArrowUp":"ArrowDown";Q(p,a.target,a)},g=a=>{const p=a.target;if(E.includes(a.key)){i.value=p?.selectionStart??0;return}if(D.includes(a.key)){if(a.altKey)return;i.value=p?.selectionStart??0}},u=a=>{P.value=!0,$.value&&!e.defaultValue&&e.externalValue&&e.externalValue.value===void 0&&x.value.length===0&&(e.externalValue.value="");const p=a.target;p&&(i.value=p.selectionStart??0)},d=a=>{const p=()=>{const h=document.getElementById(e.id);if(!h)return;const U=a?.pos??i.value??h.value.length;try{h.focus(),h.setSelectionRange(U,U)}catch{}};t.nextTick(()=>{if(a?.delay&&a.delay>0){setTimeout(p,a.delay);return}if(a?.useRAF){requestAnimationFrame(p);return}p()})};e.externalValue&&t.watch(e.externalValue,a=>{if(a){const p=new Date(a);if(p.toString()!=="Invalid Date"){const h=(p.getMonth()+1).toString().padStart(2,"0"),U=p.getDate().toString().padStart(2,"0"),K=p.getFullYear().toString();n.value=`${h}/${U}/${K}`,d({delay:50});return}}},{immediate:!0});const k=t.computed(()=>[["Date",`${L.value} / ${b.value} / ${y.value}`],["Digits only",x.value],["min",e.min?.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"})??null],["max",e.max?.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"})??null]]),m=t.computed(()=>{if(!$.value){if(!S.value)return!0;const p=f.value;return p?R(p):!1}if(!P.value)return!0;const a=f.value;return!S.value||!a?!1:R(a)}),w=t.computed(()=>{if(!$.value){if(!S.value)return;const p=f.value;return p?R(p)?"valid":"out-of-bounds":"invalid-date"}if(!P.value)return;if(x.value.length===0||!S.value)return"incomplete";const a=f.value;return a?R(a)?"valid":"out-of-bounds":"invalid-date"}),V=t.computed(()=>{const a=w.value;if(!a||a==="valid")return"";if(a==="incomplete")return"Required";if(a==="invalid-date")return`Must be in ${I.value} format.`;const p=e.min?e.min.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null,h=e.max?e.max.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null;if(a==="out-of-bounds"){if(p&&h)return`Must be between ${p} and ${h}.`;if(p)return`Must be on or after ${p}.`;if(h)return`Must be on or before ${h}.`}return""}),j=()=>{t.nextTick(()=>{const a=document.getElementById(e.id);if(!a){console.warn(`ID (#${e.id}) not found for styling.`);return}const p=a.closest(".k-datepicker");if(!p){console.warn(`.k-datepicker parent not found for #${e.id} styling.`);return}const h=p.parentElement;if(h){if(h.classList.contains("fk-datepicker"))return;h.classList.add("fk-datepicker")}else console.warn(`Parent of .k-datepicker not found for #${e.id} styling.`)})};return t.onMounted(()=>{j()}),{raw:n,cursorPos:i,debugEnabled:F,debugLines:k,placeholder:I,isValid:m,reason:t.readonly(w),validationMessage:V,digitsOnly:x,month:t.readonly(L),day:t.readonly(b),year:t.readonly(y),datePart:A,handleChange:W,handleKeyDown:oe,handleWheel:l,handleKeyUp:g,handleClick:J,handleBlur:u,initStyling:j}}function Ue(e){const n=t.ref(""),i=t.ref(void 0),F=t.ref(!!e.debug),I=t.ref(!1),$=1440*60*1e3,P=365*$,D=new Date,E=new Date(D.getTime()-P),x=new Date(D.getTime()+P);e.min=e.min??E,e.max=e.max??x;const A=t.computed(()=>(n.value??"").replace(/\D/g,"")),L=(r,c)=>new Date(r,c,0).getDate(),b=(r,c,v)=>c>=1&&c<=12&&r>=1e3&&v>=1&&v<=L(r,c),y=r=>Date.UTC(r.getFullYear(),r.getMonth(),r.getDate()),M=r=>{if(!r)return null;const c=e.min??new Date(Date.now()-90*$),v=e.max??new Date,T=y(r);return T<y(c)||T>y(v)?null:r},R=(r,c)=>e.allowReverse??!1?!0:r<=c,f=t.computed(()=>(n.value?.length??0)>=23&&A.value.length>=16),S=r=>{if((r??"").length<23||A.value.length<16)return{start:null,end:null};const c=r.substring(0,10),v=r.substring(13,23),[T,ee,te]=c.split("/").map(se=>parseInt(se||"0",10)),[ie,ce,de]=v.split("/").map(se=>parseInt(se||"0",10)),fe=new Date(te,T-1,ee),ye=new Date(de,ie-1,ce),Se=b(te,T,ee)&&fe.toString()!=="Invalid Date",be=b(de,ie,ce)&&ye.toString()!=="Invalid Date";return{start:Se?fe:null,end:be?ye:null}},q=e.externalValid??t.ref(!0),G=t.computed(()=>S(n.value)),W=t.computed(()=>{const r=M(G.value.start),c=M(G.value.end);return{start:r,end:c}}),J=t.computed(()=>{if(!f.value)return;const r=W.value.start,c=W.value.end;if(!r||!c)return;const v=Math.abs(y(c)-y(r));return Math.round(v/864e5+1)}),Q=t.computed(()=>{if(!f.value)return!1;const{start:r,end:c}=G.value;if(!r||!c||!W.value.start||!W.value.end)return!1;const v=W.value.start,T=W.value.end;return!(!R(v,T)||typeof e.maxSpanDays=="number"&&J.value!==void 0&&J.value>e.maxSpanDays)}),oe=t.computed(()=>{const{start:r,end:c}=G.value;if(!f.value)return"incomplete";if(!r||!c)return"invalid-date";if(!W.value.start||!W.value.end)return"out-of-bounds";const v=W.value.start,T=W.value.end;return R(v,T)?typeof e.maxSpanDays=="number"&&J.value!==void 0&&J.value>e.maxSpanDays?"span-exceeds-limit":"valid":"reversed-range"}),l=t.ref(void 0),g=t.computed(()=>{if(q.value!==!1)return"";const{min:r,max:c}=e,v=l.value;if(!v)return"";switch(v){case"incomplete":return"Required";case"invalid-date":return"One or both dates invalid.";case"reversed-range":return"End Date must be on or after Start Date.";case"out-of-bounds":return r&&c?`Dates must be between ${m(r)} and ${m(c)}.`:"Dates must be within the allowed range.";case"span-exceeds-limit":return typeof e.maxSpanDays=="number"?`Date range exceeds ${e.maxSpanDays} days.`:"Date range exceeds maximum allowed span.";default:return""}}),u=["ArrowUp","ArrowDown"],d=["ArrowLeft","ArrowRight"],k=(r,c)=>String(r).padStart(c,"0"),m=r=>`${k(r.getMonth()+1,2)}/${k(r.getDate(),2)}/${k(r.getFullYear(),4)}`,w=r=>r<=2?{side:"start",part:"mm"}:r<=5?{side:"start",part:(r<=3,"dd")}:r<=11?{side:"start",part:"yyyy"}:r<=15?{side:"end",part:"mm"}:r<=18?{side:"end",part:"dd"}:{side:"end",part:"yyyy"},V=(r,c,v)=>{const T=c?.selectionStart??i.value??0;i.value=T;const{start:ee,end:te}=S(n.value);if(!ee&&!te){const Y=new Date,le=m(Y);n.value=`${le} - ${le}`,e.onChange({value:{start:Y,end:Y},event:v}),t.nextTick(()=>{requestAnimationFrame(()=>{const ne=document.getElementById(e.id),re=i.value??0;ne&&(ne.focus(),ne.setSelectionRange(re,re))})});return}const ie=new Date,ce=w(T);let de=ee?new Date(ee):new Date(ie),fe=te?new Date(te):new Date(ie);const ye=(Y,le)=>{if(le==="mm"){const ne=Y.getMonth()+1,re=r==="ArrowUp"?ne<12?ne+1:1:ne>1?ne-1:12;Y.setMonth(re-1);const ge=L(Y.getFullYear(),re);Y.getDate()>ge&&Y.setDate(ge)}else if(le==="dd"){const ne=L(Y.getFullYear(),Y.getMonth()+1),re=Y.getDate(),ge=r==="ArrowUp"?re<ne?re+1:1:re>1?re-1:ne;Y.setDate(ge)}else if(le==="yyyy"){const ne=Y.getFullYear();Y.setFullYear(r==="ArrowUp"?ne+1:Math.max(1,ne-1));const re=L(Y.getFullYear(),Y.getMonth()+1);Y.getDate()>re&&Y.setDate(re)}};ce.side==="start"?ye(de,ce.part):ye(fe,ce.part);const Se=m(de),be=m(fe);n.value=`${Se} - ${be}`;const se=M(de),ke=M(fe);se&&ke&&R(se,ke)?e.onChange({value:{start:se,end:ke},event:v}):e.onChange({value:null,event:v}),t.nextTick(()=>{requestAnimationFrame(()=>{const Y=document.getElementById(e.id),le=i.value??0;Y&&(Y.focus(),Y.setSelectionRange(le,le))})})},j=r=>{const{start:c,end:v}=S(n.value);if(!c||!v){e.onChange({value:null,event:r});return}const T=M(c),ee=M(v);if(!T||!ee){e.onChange({value:null,event:r});return}if(!R(T,ee)){e.onChange({value:null,event:r});return}e.onChange({value:{start:T,end:ee},event:r})},a=r=>{const c=r.value??"",v=r.event;if(!c&&v&&v.type==="click"){ae(v);return}n.value=c;const T=v?.target;i.value=T?.selectionStart??0,j(r)},p=r=>{i.value=r.target.selectionStart??0},h=r=>{if(r.code==="Space"||r.key===" "){r.preventDefault(),r.stopPropagation(),e.onShowCalendar(r);return}if(r.key==="ArrowDown"&&r.altKey){r.preventDefault(),r.stopPropagation(),e.onShowCalendar(r);return}if(u.includes(r.key)){r.preventDefault(),r.stopPropagation();const c=r.target;V(r.key,c,r);return}},U=r=>{r.preventDefault();const c=r.deltaY<0?"ArrowUp":"ArrowDown";V(c,r.target,r)},K=r=>{if(d.includes(r.key)||u.includes(r.key)){const c=r.target;i.value=c?.selectionStart??0}},N=()=>{l.value=oe.value,(e.manageValid??!0)&&(q.value=Q.value)},_=r=>{N()},ae=r=>{console.log("Clear event:",r),n.value="",i.value=0,e.onChange({value:null,event:r}),N(),t.nextTick(()=>{const c=document.getElementById(e.id);c&&(c.focus(),c.setSelectionRange(0,0))})};e.externalValue&&t.watch(e.externalValue,r=>{const c=r?.start??null,v=r?.end??null;if(c&&v){if(n.value=`${m(c)} - ${m(v)}`,e.isOpen?.value&&I.value&&e.onRequestClose){const T=typeof e.closeDelay=="number"?e.closeDelay:e.closeDelay?.value??0;setTimeout(()=>{e.onRequestClose?.(),I.value=!1,N()},T)}return}},{immediate:!0});const o=t.computed(()=>n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0"),s=t.computed(()=>n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0"),C=t.computed(()=>n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0"),O=t.computed(()=>n.value&&n.value.substring(13,15).replace(/\D/g,"0")||"0"),H=t.computed(()=>n.value&&n.value.substring(16,18).replace(/\D/g,"0")||"0"),z=t.computed(()=>n.value&&n.value.substring(19,23).replace(/\D/g,"0")||"0"),B=t.computed(()=>{const{start:r,end:c}=S(n.value);return[{label:"Raw",value:n.value},{label:"Min Date",value:`${e.min?e.min.toDateString():"-"}`},{label:"Max Date",value:`${e.max?e.max.toDateString():"-"}`},{label:"Start",value:`${String(o.value).padStart(2,"0")} / ${String(s.value).padStart(2,"0")} / ${String(C.value).padStart(4,"0")}`},{label:"End",value:`${String(O.value).padStart(2,"0")} / ${String(H.value).padStart(2,"0")} / ${String(z.value).padStart(4,"0")}`},{label:"Digits only",value:A.value},{label:"Mask complete",value:`${f.value}`},{label:"Parsed",value:`${r?r.toDateString():"-"} | ${c?c.toDateString():"-"}`},{label:"Valid (managed)",value:`${q.value??"-"}`},{label:"Span (days)",value:`${J.value??"-"}`},{label:"Reason",value:`${oe.value??"-"}`},{label:"Cursor in",value:`${i.value??"-"} (${(()=>{const v=i.value??0,T=w(v);return`${T.side}.${T.part}`})()})`}]}),Z=()=>{t.nextTick(()=>{const r=document.getElementById(e.id);if(!r){console.warn(`#${e.id} not found for styling.`);return}const c=r.closest("div");if(!c){console.warn(`Parent div of #${e.id} not found for styling.`);return}c.classList.contains("fk-daterangepicker")||c.classList.add("fk-daterangepicker")})};t.onMounted(()=>{Z()});const me=()=>{t.nextTick(()=>{try{const r=Array.from(document.querySelectorAll(".k-animation-container"));if(!r.length)return;const v=[...r].reverse().find(te=>te.querySelector(".k-calendar"))?.querySelector(".k-calendar");if(!v)return;const T=v.querySelectorAll(".k-calendar-table");let ee=!1;T.forEach(te=>{te.tabIndex===0&&(ee?te.tabIndex=-1:ee=!0)})}catch(r){console.warn(r)}})};return e.isOpen&&t.watch(e.isOpen,r=>{r&&setTimeout(()=>me(),0)},{immediate:!1}),{raw:n,cursorPos:i,debugEnabled:F,debugLines:B,digitsOnly:A,valid:q,validComputed:t.readonly(Q),reason:t.readonly(oe),validationMessage:t.readonly(g),spanDays:t.readonly(J),month1:t.readonly(o),day1:t.readonly(s),year1:t.readonly(C),month2:t.readonly(O),day2:t.readonly(H),year2:t.readonly(z),handleChange:a,handleKeyDown:h,handleWheel:U,handleKeyUp:K,handleClick:p,handleBlur:_,handleClear:ae,onCalendarChange:()=>{I.value=!0},initStyling:Z}}function Be(e){const n=t.ref(""),i=t.ref(void 0),F=t.ref(!!e.debug),I=t.ref(e.timeFormat??"hh:mm AM"),$=t.computed(()=>!!e.required),P=t.ref(!1),D=["ArrowUp","ArrowDown"],E=["ArrowLeft","ArrowRight"],x=t.computed(()=>(n.value??"").replace(/\D/g,"")),A={H:/[0-9]/,h:/[0-9]/,M:/[0-9]/,m:/[0-9]/,A:/[AaPp]/,a:/[Mm]/},L=o=>o<=2?"hh":o<=5?"mm":"ampm",b=t.computed(()=>{const o=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0",s=parseInt(o);return Math.min(Math.max(s,0),23)}),y=t.computed(()=>{const o=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0",s=parseInt(o);return Math.min(Math.max(s,0),59)}),M=t.computed(()=>(n.value?.substring(6,8)||"AM").toUpperCase().startsWith("P")?"PM":"AM"),R=t.computed(()=>{const o=parseInt(n.value?.substring(0,2).replace(/\D/g,"0")||"0"),s=M.value;return o===12?s==="AM"?0:12:s==="PM"?o+12:o}),f=t.computed(()=>S.value?`${String(R.value).padStart(2,"0")}:${String(y.value).padStart(2,"0")}:00`:null),S=t.computed(()=>/^(\d{2}):(\d{2})\s([AP]M)$/i.test(n.value??"")),q=(o,s,C)=>{let O=o%12;return O===0&&(O=12),`${String(O).padStart(2,"0")}:${String(s).padStart(2,"0")} ${C}`},G=o=>{const s=o.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!s)return null;const C=parseInt(s[1]),O=parseInt(s[2]),H=s[3].toUpperCase();if(C<1||C>12||O<0||O>59)return null;let z=C%12;H==="PM"&&(z+=12);const B=new Date;return B.setSeconds(0,0),B.setHours(z),B.setMinutes(O),B},W=o=>{if(x.value.length===0){e.onChange({value:null,event:o});return}if(!S.value){e.onChange({value:null,event:o});return}const s=G(n.value);s&&Q(s)?e.onChange({value:s,event:o}):e.onChange({value:null,event:o})},J=o=>o.getHours()*60+o.getMinutes(),Q=o=>{const s=e.min??void 0,C=e.max??void 0,O=J(o);if(s){const H=J(s);if(O<H)return!1}if(C){const H=J(C);if(O>H)return!1}return!0},oe=o=>{const s=o.getHours(),C=s>=12?"PM":"AM";n.value=q(s,o.getMinutes(),C)},l=(o,s)=>{e.onChange({value:o,event:s})},g=()=>{t.nextTick(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const o=document.getElementById(e.id);if(o){o.focus();const s=(o.value??"").length;o.setSelectionRange(s,s)}})})})},u=o=>{const s=o?.event?.target;return s?s.closest(".k-time-now")?"now":s.closest(".k-time-accept")?"set":null:null},d=(o,s)=>{o&&Q(o)?l(o,s):l(null,s)},k=(...o)=>{const s=o[0];if(!s)return;const C=u(s);if(C==="now"){const H=new Date;oe(H),d(H,s),g();return}if(s?.value instanceof Date){const H=new Date(s.value);oe(H),d(H,s),C==="set"&&g();return}if(s?.value===null){n.value="",l(null,s);return}n.value=s.value;const O=s.event?.target;i.value=O?.selectionStart??0;try{const H=i.value??0;if(L(H)==="ampm"&&(n.value??"").length>=8){const z=n.value.charAt(6);/[Aa]/.test(z)?(n.value=`${n.value.slice(0,6)}AM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const B=document.getElementById(e.id);B&&(B.focus(),B.setSelectionRange(8,8))})})):/[Pp]/.test(z)&&(n.value=`${n.value.slice(0,6)}PM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const B=document.getElementById(e.id);B&&(B.focus(),B.setSelectionRange(8,8))})}))}}catch{}W(s)},m=o=>{i.value=o.target.selectionStart??0},w=(o,s,C)=>{const O=s?.selectionStart??i.value??0;i.value=O;const H=L(O),z=(n.value??"").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!z){if((n.value??"").length===0||x.value.length===0){const c=new Date,v=c.getHours(),T=v>=12?"PM":"AM";n.value=q(v,c.getMinutes(),T);const ee=G(n.value);d(ee,C),t.nextTick(()=>{requestAnimationFrame(()=>{const te=document.getElementById(e.id),ie=i.value??0;te&&(te.focus(),te.setSelectionRange(ie,ie))})})}return}let B=parseInt(z[1]),Z=parseInt(z[2]),me=z[3].toUpperCase();if(H==="hh")o==="ArrowUp"?B=B<12?B+1:1:B=B>1?B-1:12;else if(H==="mm"){const c=e.minuteStepRef?.value??e.minuteStep??1;if(c===1)o==="ArrowUp"?Z=Z<59?Z+1:0:Z=Z>0?Z-1:59;else if(o==="ArrowUp"){const v=Z%c;let T=v===0?Z+c:Z+(c-v);T>=60&&(T=0),Z=T}else{const v=Z%c;let T=v===0?Z-c:Z-v;T<0&&(T=60-c),Z=T}}else H==="ampm"&&(me=me==="AM"?"PM":"AM");n.value=`${String(B).padStart(2,"0")}:${String(Z).padStart(2,"0")} ${me}`;const r=G(n.value);d(r,C),t.nextTick(()=>{requestAnimationFrame(()=>{const c=document.getElementById(e.id),v=i.value??0;c&&(c.focus(),c.setSelectionRange(v,v))})})},V=o=>{if(o.code==="Space"||o.key===" "){o.preventDefault(),o.stopPropagation(),e.onShowPicker(o);return}if(o.key==="ArrowDown"&&o.altKey){o.preventDefault(),o.stopPropagation(),e.onShowPicker(o);return}if(D.includes(o.key)){if(o.altKey)return;o.preventDefault(),o.stopPropagation();const s=o.target;w(o.key,s,o);return}},j=o=>{o.preventDefault();const s=o.deltaY<0?"ArrowUp":"ArrowDown";w(s,o.target,o)},a=o=>{const s=o.target;if(E.includes(o.key)){i.value=s?.selectionStart??0;return}if(D.includes(o.key)){if(o.altKey)return;i.value=s?.selectionStart??0}},p=o=>{P.value=!0,$.value&&e.externalValue&&e.externalValue.value===void 0&&x.value.length===0&&(e.externalValue.value="");const s=o.target;s&&(i.value=s.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,o=>{if(o){const s=new Date(o);if(s.toString()!=="Invalid Date"){const C=s.getHours(),O=C>=12?"PM":"AM";n.value=q(C,s.getMinutes(),O);return}}},{immediate:!0});const h=t.computed(()=>[["Time",n.value||"--:-- --"],["Hour (12h)",b.value],["Hour (24h)",R.value],["Minute",y.value],["Period",M.value],["Time (24h)",f.value??"--:--:--"],["Digits only",x.value],["Parsed Date",U.value?.toLocaleDateString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["min",e.min?.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["max",e.max?.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["valid",K.value],["reason",N.value],["validationMessage",_.value]]),U=t.computed(()=>G(n.value)??null),K=t.computed(()=>{if(!$.value){if(!S.value)return!0;const s=U.value;return s?Q(s):!1}if(!P.value)return!0;const o=U.value;return!S.value||!o?!1:Q(o)}),N=t.computed(()=>{if(!$.value){if(!S.value)return;const s=U.value;return s?Q(s)?"valid":"out-of-bounds":"invalid-time"}if(!P.value)return;if(x.value.length===0||!S.value)return"incomplete";const o=U.value;return o?Q(o)?"valid":"out-of-bounds":"invalid-time"}),_=t.computed(()=>{const o=N.value;if(!o||o==="valid")return"";if(o==="incomplete")return"Required";if(o==="invalid-time")return`Must be in ${I.value} format.`;const s={hour:"2-digit",minute:"2-digit"},C=e.min?e.min.toLocaleTimeString("en-US",s):null,O=e.max?e.max.toLocaleTimeString("en-US",s):null;if(o==="out-of-bounds"){if(C&&O)return`Must be between ${C} and ${O}.`;if(C)return`Must be ${C} or later.`;if(O)return`Must be ${O} or earlier.`}return""}),ae=()=>{t.nextTick(()=>{const o=document.getElementById(e.id);if(!o){console.warn(`#${e.id} not found for styling.`);return}const s=o.closest(".k-timepicker");if(!s){console.warn(`.k-timepicker parent of #${e.id} not found for styling.`);return}const C=s.parentElement;if(!C){console.warn(`Parent of .k-timepicker not found for #${e.id} styling.`);return}C.classList.contains("fk-timepicker")||C.classList.add("fk-timepicker")})};return t.onMounted(()=>{ae()}),{raw:n,rules:A,debugEnabled:F,debugLines:h,placeholder:I,isValid:K,reason:t.readonly(N),validationMessage:_,isComplete:S,inRangeTime:Q,cursorPos:i,hour:t.readonly(b),hour24:t.readonly(R),minute:t.readonly(y),period:t.readonly(M),time24:t.readonly(f),parsedRawTime:t.readonly(U),handleChange:k,handleKeyDown:V,handleKeyUp:a,handleClick:m,handleWheel:j,handleBlur:p,initStyling:ae}}function Ke(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}const xe=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Ne=Object.prototype.toString,He=e=>Ne.call(e)==="[object Object]",ue=()=>{},Ye=je();function je(){var e,n;return xe&&((e=window?.navigator)==null?void 0:e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((n=window?.navigator)==null?void 0:n.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function he(e){return Array.isArray(e)?e:[e]}function Ge(e,n,i){return t.watch(e,n,{...i,immediate:!0})}const Ee=xe?window:void 0;function pe(e){var n;const i=t.toValue(e);return(n=i?.$el)!=null?n:i}function ve(...e){const n=[],i=()=>{n.forEach(D=>D()),n.length=0},F=(D,E,x,A)=>(D.addEventListener(E,x,A),()=>D.removeEventListener(E,x,A)),I=t.computed(()=>{const D=he(t.toValue(e[0])).filter(E=>E!=null);return D.every(E=>typeof E!="string")?D:void 0}),$=Ge(()=>{var D,E;return[(E=(D=I.value)==null?void 0:D.map(x=>pe(x)))!=null?E:[Ee].filter(x=>x!=null),he(t.toValue(I.value?e[1]:e[0])),he(t.unref(I.value?e[2]:e[1])),t.toValue(I.value?e[3]:e[2])]},([D,E,x,A])=>{if(i(),!D?.length||!E?.length||!x?.length)return;const L=He(A)?{...A}:A;n.push(...D.flatMap(b=>E.flatMap(y=>x.map(M=>F(b,y,M,L)))))},{flush:"post"}),P=()=>{$(),i()};return Ke(i),P}let Me=!1;function We(e,n,i={}){const{window:F=Ee,ignore:I=[],capture:$=!0,detectIframe:P=!1,controls:D=!1}=i;if(!F)return D?{stop:ue,cancel:ue,trigger:ue}:ue;if(Ye&&!Me){Me=!0;const f={passive:!0};Array.from(F.document.body.children).forEach(S=>S.addEventListener("click",ue,f)),F.document.documentElement.addEventListener("click",ue,f)}let E=!0;const x=f=>t.toValue(I).some(S=>{if(typeof S=="string")return Array.from(F.document.querySelectorAll(S)).some(q=>q===f.target||f.composedPath().includes(q));{const q=pe(S);return q&&(f.target===q||f.composedPath().includes(q))}});function A(f){const S=t.toValue(f);return S&&S.$.subTree.shapeFlag===16}function L(f,S){const q=t.toValue(f),G=q.$.subTree&&q.$.subTree.children;return G==null||!Array.isArray(G)?!1:G.some(W=>W.el===S.target||S.composedPath().includes(W.el))}const b=f=>{const S=pe(e);if(f.target!=null&&!(!(S instanceof Element)&&A(e)&&L(e,f))&&!(!S||S===f.target||f.composedPath().includes(S))){if("detail"in f&&f.detail===0&&(E=!x(f)),!E){E=!0;return}n(f)}};let y=!1;const M=[ve(F,"click",f=>{y||(y=!0,setTimeout(()=>{y=!1},0),b(f))},{passive:!0,capture:$}),ve(F,"pointerdown",f=>{const S=pe(e);E=!x(f)&&!!(S&&!f.composedPath().includes(S))},{passive:!0}),P&&ve(F,"blur",f=>{setTimeout(()=>{var S;const q=pe(e);((S=F.document.activeElement)==null?void 0:S.tagName)==="IFRAME"&&!q?.contains(F.document.activeElement)&&n(f)},0)},{passive:!0})].filter(Boolean),R=()=>M.forEach(f=>f());return D?{stop:R,cancel:()=>{E=!1},trigger:f=>{E=!0,b(f),E=!1}}:R}function ze(e){const n=t.shallowRef(null),i=[".k-animation-container .k-popup",".k-popup",".k-timepicker-popup",".k-menu-popup"],F=Array.isArray(e.popupSelector)?e.popupSelector:[e.popupSelector??i].flat(),I=A=>A?typeof e.initialFocus=="string"?A.querySelector(e.initialFocus)??A:typeof e.initialFocus=="function"?e.initialFocus(A)??A:A.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??A:null,{activate:$,deactivate:P}=Te.useFocusTrap(n,{escapeDeactivates:!1,clickOutsideDeactivates:!1,fallbackFocus:()=>n.value,initialFocus:()=>I(n.value),...e.focusTrapOptions??{}});let D=null,E=t.ref(null);const x=()=>{if(e.resolvePopupEl)return e.resolvePopupEl();const A=(b,y)=>{const M=Array.from(b.querySelectorAll(y));if(!M.length)return null;const R=M.filter(f=>f.offsetParent!==null||f.getClientRects().length>0);return R[R.length-1]??M[M.length-1]??null},L=e.triggerEl?.value?.closest?.(".k-animation-container")??document.body;for(const b of F){const y=A(L,b);if(y)return y}for(const b of F){const y=A(document,b);if(y)return y}return null};return We(n,A=>{E.value="outside",e.isOpen.value&&e.onRequestClose?.("outside",A)}),t.watch(()=>e.isOpen.value,A=>{A?(E.value=null,t.nextTick(()=>{const L=x();L&&(n.value=L,setTimeout(()=>$(),0),D||(D=b=>{b.key==="Escape"&&(E.value="escape",e.isOpen.value&&e.onRequestClose?.("escape",b))},document.addEventListener("keydown",D,!0)))})):(P(),D&&(document.removeEventListener("keydown",D,!0),D=null),n.value=null,E.value==="outside"&&t.nextTick(()=>{const L=()=>{const b=e.triggerEl?.value,y=b?.querySelector("input"),M=document.activeElement;M&&(M===y||b&&b.contains(M))&&(y??b)?.blur?.()};requestAnimationFrame(()=>setTimeout(L,0))}),e.returnFocusToTrigger!==!1&&E.value==="escape"&&e.triggerEl?.value&&(console.log("Returning focus to trigger element:",e.triggerEl.value),t.nextTick(()=>{const L=()=>{const b=e.triggerEl?.value;if(!b)return;(b.querySelector("input")??b)?.focus?.()};requestAnimationFrame(()=>setTimeout(L,0))})))}),{popupRef:n,activate:$,deactivate:P,lastCloseReason:t.readonly(E),setPopupEl:A=>n.value=A}}X.useFieldsetTouchTracker=Ae,X.useFieldsetValidationKit=Ve,X.useGridA11y=Ie,X.useGridActiveFilter=Pe,X.useMaskedDateInput=Oe,X.useMaskedDateRangeInput=Ue,X.useMaskedTimeInput=Be,X.usePopupTrap=ze,X.useZipTextBox=qe,Object.defineProperty(X,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(_,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@vueuse/integrations/useFocusTrap")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/integrations/useFocusTrap"],t):(_=typeof globalThis<"u"?globalThis:_||self,t(_.FeatherKComposables={},_.Vue,_.useFocusTrap))})(this,(function(_,t,Ve){"use strict";const $e=(e,n)=>{const l=t.ref(null);let V=!1,I=null,T=null;const k=[],w=".k-table-row[data-grid-row-index] [tabindex]",x=()=>{const i=e?.value?.$el;return i?i.closest(".k-grid"):null},M=i=>{const g=x();if(!g)return!1;const u=i.closest(".k-grid-aria-root");if(u)return g.contains(u);const d=i.closest(".k-grid-header, .k-grid-content, .k-grid-content-locked");return d?g.contains(d):!1},E=i=>i.key==="Enter"||i.code==="Enter"||i.code==="NumpadEnter",F=()=>e?.value?.columns,b=i=>{const g=i.key||i.code;([" ","Spacebar","Space"].includes(g)||E(i))&&(i.preventDefault(),i.stopPropagation(),l.value=i.target,i.target.click())},y=i=>{if(!l.value)return;if(i.code==="Escape"){i.stopPropagation(),l.value&&l.value.focus();return}const g=Array.from(document.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item")),u=document.querySelector(".k-animation-container .k-popup .k-column-menu .k-filter-menu-container");if(u){if(i.code==="Tab"){const d=[".k-dropdownlist[tabindex='0']","input.k-input-inner:not([tabindex='-1']):not([disabled])","button:not([tabindex='-1']):not([disabled])",".k-checkbox"],A=n?.focusableMenuSelectors??d,m=Array.from(u.querySelectorAll(A.join(",")));if(m.length===0)return;const D=m.findIndex(Z=>Z===document.activeElement);let q;D===-1?q=0:i.shiftKey?q=(D-1+m.length)%m.length:q=(D+1)%m.length,i.preventDefault(),i.stopPropagation(),m[q]?.focus()}}else if(i.code==="ArrowUp"||i.code==="ArrowDown"){i.preventDefault(),i.stopPropagation();const d=g.findIndex(m=>m===document.activeElement);let A=d;i.code==="ArrowUp"?A=d>0?d-1:g.length-1:i.code==="ArrowDown"&&(A=d<g.length-1?d+1:0),g[A]?.focus();return}if(i.code==="Tab"){i.preventDefault(),i.stopPropagation();const d=l.value?.parentElement;(i.shiftKey?d?.previousElementSibling:d?.nextElementSibling)?.querySelector("button, [role='button'], .k-link")?.focus()}},C=()=>{I=new MutationObserver(i=>{i.forEach(g=>{g.addedNodes.forEach(u=>{if(u.nodeType===Node.ELEMENT_NODE){const d=u;if(d.classList.contains("k-animation-container")){const m=l.value;m&&(m.dataset.featherKSortable==="true"||t.nextTick(()=>{d.querySelectorAll(".k-columnmenu-item-wrapper").forEach(Z=>{Z.textContent?.toLowerCase().includes("sort")&&Z.remove()})})),d.addEventListener("keydown",y),t.nextTick(()=>{const D=()=>{const q=Array.from(d.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"));if(q.length===1)q[0].focus(),q[0].click(),D.attempts=0;else if(q.length>1){D.attempts=0;return}else D.attempts===void 0&&(D.attempts=0),D.attempts++<3&&setTimeout(D,200)};D()})}d.querySelectorAll(".k-animation-container").forEach(m=>{m.addEventListener("keydown",y)})}}),g.removedNodes.forEach(u=>{if(u.nodeType===Node.ELEMENT_NODE){const d=u;d.classList.contains("k-animation-container")&&d.removeEventListener("keydown",y),d.querySelectorAll(".k-animation-container").forEach(m=>{m.removeEventListener("keydown",y)})}})})}),I.observe(document.body,{childList:!0,subtree:!0})},R=i=>{const g=i.tagName.toLowerCase();return!!(["input","textarea","select","button"].includes(g)||i.closest('.k-picker-wrap, .k-input-inner, .k-textbox, [role="combobox"]'))},f=i=>{if(!i.type||!i)return;const g=i.target;if(!g)return;const u=g.closest(".k-table-row[data-grid-row-index]");if(!M(g))return;const d=["ArrowLeft","ArrowRight"].includes(i.code);if(!(R(g)&&!(u&&d))){if(i.code==="Escape"){const A=document.activeElement?.closest(".k-table-row[data-grid-row-index]");if(A){i.preventDefault(),i.stopPropagation();try{Array.from(e?.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]")).forEach(D=>D.setAttribute("tabindex","-1"))}catch{}A.setAttribute("tabindex","0"),A.focus();return}}if(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter","NumpadEnter","Space"].includes(i.code)){if(g.classList.contains("k-grid-header-menu")&&g.classList.contains("k-grid-column-menu")){l.value=g;return}if(u){if(["ArrowDown","ArrowUp"].includes(i.code)){i.preventDefault(),i.stopPropagation();const A=(D,q)=>{let Z=q==="next"?D.nextElementSibling:D.previousElementSibling;for(;Z;){const o=Z;try{if(o.classList.contains("k-table-row"))return o}catch{}Z=q==="next"?Z.nextElementSibling:Z.previousElementSibling}return null},m=i.code==="ArrowDown"?A(u,"next"):A(u,"previous");m&&(u.setAttribute("tabindex","-1"),m.setAttribute("tabindex","0"),m.focus());return}if(["ArrowLeft","ArrowRight"].includes(i.code)){i.preventDefault(),i.stopPropagation();const A=u.querySelectorAll(w);if(A.length===0)return;let m=Array.from(A).findIndex(D=>D===document.activeElement);if(m===-1&&document.activeElement===u){A[0].focus();return}i.code==="ArrowRight"?m=m===A.length-1?0:m+1:i.code==="ArrowLeft"&&(m=m===0?A.length-1:m-1),A[m].focus();return}}}}},v=()=>{t.nextTick(()=>{const i=e.value?.$el;if(!i||typeof i.closest!="function")return;const g=i.closest(".k-grid");g&&g.classList.add("fk-grid")})},L=()=>{if(!T)try{const i=()=>{try{const d=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));if(!d||d.length===0||d.filter(D=>D.getAttribute("tabindex")==="0").length===1)return;const m=d.find(D=>D===document.activeElement||D.contains(document.activeElement));if(d.forEach(D=>D.setAttribute("tabindex","-1")),m){m.setAttribute("tabindex","0");return}d[0].setAttribute("tabindex","0")}catch(d){console.error("ensureSingleTabindex error:",d)}},g=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));g.length>0&&g.forEach((d,A)=>{d.setAttribute("tabindex",A===0?"0":"-1")});const u=e.value.$el.querySelector(".k-table-tbody");u&&(T=new MutationObserver(()=>{i()}),T.observe(u,{childList:!0,subtree:!0}))}catch(i){console.error("Error setting up row navigation:",i)}},H=()=>{t.nextTick(()=>{const g=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");g&&g.forEach(u=>{u.setAttribute("role","button"),u.addEventListener("keydown",b)}),C(),J()})},Y=()=>{const g=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");g&&g.forEach(u=>{u.removeEventListener("keydown",b)}),I&&(I.disconnect(),I=null),T&&(T.disconnect(),T=null),k.forEach(u=>u()),k.length=0},J=()=>{document.querySelectorAll(".k-grid-header .k-table-thead th").forEach((u,d)=>{if(u.dataset.featherKHeaderBound==="true")return;const A=u.querySelector(".k-grid-header-menu.k-grid-column-menu");if(!A)return;const m=F();if(m&&m[d]){const h=m[d].field??"";u.setAttribute("data-feather-k-field",h),u.setAttribute("data-feather-k-filterable",m[d].filterable===!1?"false":"true"),u.setAttribute("data-feather-k-sortable",m[d].sortable===!1?"false":"true")}const D=u.dataset.featherKFilterable!=="false",q=u.dataset.featherKSortable!=="false";A.setAttribute("tabindex","-1"),D||q?u.style.cursor="pointer":u.style.cursor="default",D?(u.setAttribute("tabindex","0"),u.setAttribute("role","button"),u.setAttribute("aria-haspopup","menu")):(u.setAttribute("tabindex","0"),u.setAttribute("role","columnheader"),u.removeAttribute("aria-haspopup"));const Z=h=>{h.target?.closest(".k-column-resizer")||(l.value=u,A.click())},o=h=>{if(D)l.value=u,h.preventDefault(),h.stopPropagation(),Z(h);else if(q){l.value=u;const U=u.querySelector(".k-link");U&&U.click()}};u.addEventListener("click",o),k.push(()=>{u.removeEventListener("click",o)});const p=h=>{if((E(h)||h.code==="Space")&&(D||q)){if(h.preventDefault(),h.stopPropagation(),l.value=u,l.value.focus(),D)Z(h);else if(q){const U=u.querySelector(".k-link");U&&U.click()}}};u.addEventListener("keydown",p,!0),k.push(()=>{u.removeEventListener("keydown",p,!0)}),u.dataset.featherKHeaderBound="true"});const g=document.querySelector(".k-grid-header .k-table-thead");if(g&&g.dataset.featherKHeaderBound!=="true"){const u=d=>{const A=d.target.closest("th");A&&(E(d)||d.code==="Space")&&A.dataset.featherKFilterable==="false"&&A.dataset.featherKSortable==="false"&&(d.preventDefault(),d.stopImmediatePropagation())};g.addEventListener("keydown",u,!0),k.push(()=>{g.removeEventListener("keydown",u,!0)}),g.dataset.featherKHeaderBound="true"}},X=function(i,g){const u=i?.event?.event.target,d=F();if(!u||!d)return;const A=u.classList.contains("k-grid-header-menu"),m=u.classList.contains("k-columnmenu-item"),D=d.find(q=>q.field===i?.event?.field)?.sortable&&!0;if(!A){if(m&&!D){i?.event?.sort?.filter(Z=>Z.field!==i?.event?.field);return}typeof g=="function"&&t.nextTick(()=>{l.value&&l.value.focus(),g(i),t.nextTick(()=>{J()})})}},re=()=>{if(!V)try{v(),L(),H(),V=!0}catch(i){console.error("initA11y failed:",i),Y()}};return t.onBeforeUnmount(()=>{Y()}),{activeFilterButton:l,handleGridKeyDown:f,handleSortChange:X,initA11y:re}},Fe=e=>!!e&&typeof e=="object"&&"filters"in e&&Array.isArray(e.filters),Pe=e=>!!e&&typeof e=="object"&&"field"in e,Ae=(e,n)=>!e||typeof e!="object"?!1:Fe(e)?e.filters.some(l=>Ae(l,n)):Pe(e)?e.field===n:!1,Re=e=>n=>e.value?.filters&&e.value.filters.some(l=>Ae(l,n))?"active":"",Le="Enter a valid ZIP code with exactly 5 or 9 digits.",De=e=>{const n=e.replace(/\D/g,"").slice(0,9);return n.length>5?`${n.slice(0,5)}-${n.slice(5)}`:n},qe=(e,n)=>e.slice(0,Math.max(0,n)).replace(/\D/g,"").length,Oe=e=>e<=5?e:Math.min(e+1,10),xe=e=>{const n=t.ref(De(e.initialValue??"")),l=t.ref(!1),V=t.ref(e.errorMessage?.trim()||Le),I=t.computed(()=>n.value.replace(/\D/g,"")),T=t.computed(()=>{const y=I.value.length;return y===5||y===9}),k=t.computed(()=>l.value&&!T.value),w=t.computed(()=>!l.value||T.value),x=t.computed(()=>l.value),M=(y,C)=>{const R=Oe(C);t.nextTick(()=>{y.isConnected&&y.setSelectionRange(R,R)})};return{zipDisplay:n,submitted:l,errorMessage:V,wrapperClass:"fk-zip-textbox",zipRaw:I,isZipValid:T,showZipError:k,textBoxValid:w,textBoxValidate:x,handleZipInput:(...y)=>{const C=y[0],f=C?.event?.target,v=C?.value,L=Array.isArray(v)?v.join(""):String(v??""),H=f?.selectionStart!==void 0&&f.selectionStart!==null?qe(f.value,f.selectionStart):L.replace(/\D/g,"").length;n.value=De(L),f&&M(f,H)},submitAndValidate:y=>{l.value=!0;const C=T.value;return!C&&y?.focus&&t.nextTick(()=>{document.getElementById(e.id)?.focus()}),C},buildPayload:()=>({zip:I.value})}};function Ee(e,n){const l=t.ref(!1);t.watchEffect(()=>{e.value?.setAttribute("aria-invalid",String(!n.isValid()))});function V(T){const k=e.value??T.currentTarget,w=T.relatedTarget;(!k||!k.contains(w))&&(l.value=!0)}function I(){l.value=!1}return{touched:l,onFocusout:V,reset:I}}function Me(e,n){const l=t.ref(!1),V=t.ref(!1),I=t.computed(()=>t.toValue(n.submitted)||l.value),T=t.computed(()=>!I.value||n.isValid()),k=Ee(e,{isValid:()=>T.value});function w(b){return t.computed(()=>!I.value||t.toValue(b))}function x(b){return Object.fromEntries(Object.entries(b).map(([y,C])=>[y,w(C)]))}function M(b){const y=t.toValue(b);if(!y)return;y.querySelector('.k-invalid input, .k-invalid[tabindex="0"]')?.focus()}function E(b){if(V.value){V.value=!1;return}k.onFocusout(b),k.touched.value&&(l.value=!0)}function F(){l.value=!1,V.value=!0,k.reset()}return{touched:l,fieldsetValidate:I,onFocusout:E,reset:F,createFieldValidity:w,createFieldValidationsMap:x,focusFirstInvalidField:M}}const Ue=[{label:"Alabama",value:"AL"},{label:"Alaska",value:"AK"},{label:"Arizona",value:"AZ"},{label:"Arkansas",value:"AR"},{label:"California",value:"CA"},{label:"Colorado",value:"CO"},{label:"Connecticut",value:"CT"},{label:"Delaware",value:"DE"},{label:"Florida",value:"FL"},{label:"Georgia",value:"GA"},{label:"Hawaii",value:"HI"},{label:"Idaho",value:"ID"},{label:"Illinois",value:"IL"},{label:"Indiana",value:"IN"},{label:"Iowa",value:"IA"},{label:"Kansas",value:"KS"},{label:"Kentucky",value:"KY"},{label:"Louisiana",value:"LA"},{label:"Maine",value:"ME"},{label:"Maryland",value:"MD"},{label:"Massachusetts",value:"MA"},{label:"Michigan",value:"MI"},{label:"Minnesota",value:"MN"},{label:"Mississippi",value:"MS"},{label:"Missouri",value:"MO"},{label:"Montana",value:"MT"},{label:"Nebraska",value:"NE"},{label:"Nevada",value:"NV"},{label:"New Hampshire",value:"NH"},{label:"New Jersey",value:"NJ"},{label:"New Mexico",value:"NM"},{label:"New York",value:"NY"},{label:"North Carolina",value:"NC"},{label:"North Dakota",value:"ND"},{label:"Ohio",value:"OH"},{label:"Oklahoma",value:"OK"},{label:"Oregon",value:"OR"},{label:"Pennsylvania",value:"PA"},{label:"Rhode Island",value:"RI"},{label:"South Carolina",value:"SC"},{label:"South Dakota",value:"SD"},{label:"Tennessee",value:"TN"},{label:"Texas",value:"TX"},{label:"Utah",value:"UT"},{label:"Vermont",value:"VT"},{label:"Virginia",value:"VA"},{label:"Washington",value:"WA"},{label:"West Virginia",value:"WV"},{label:"Wisconsin",value:"WI"},{label:"Wyoming",value:"WY"}];function ve(e){if(e&&typeof e=="object"&&"value"in e){const n=e.value;return typeof n=="string"?n:String(n??"")}return""}function Ke(){const e=t.reactive({address1:"",address2:"",city:"",state:null,zip:""});return{formData:e,onAddress1Input:(...k)=>{e.address1=ve(k[0])},onAddress2Input:(...k)=>{e.address2=ve(k[0])},onCityInput:(...k)=>{e.city=ve(k[0])},onStateChange:k=>{k.value===null&&e.state!==null||(e.state=k.value)},resetFormData:()=>{e.address1="",e.address2="",e.city="",e.state=null,e.zip=""}}}function Ne(e){const n=xe({id:"zip"}),{zipDisplay:l,zipRaw:V,isZipValid:I,wrapperClass:T,handleZipInput:k}=n;return t.watch(V,x=>{e.zip=x}),{zipDisplay:l,isZipValid:I,zipWrapperClass:T,onZipInput:k,resetZip:()=>{l.value="",e.zip=""}}}function Be(e){const n=t.computed(()=>e.formData.address1.trim()!==""),l=t.computed(()=>e.formData.city.trim()!==""),V=t.computed(()=>!!e.formData.state),I=t.computed(()=>t.toValue(e.isZipValid)),T=t.computed(()=>n.value&&l.value&&V.value&&I.value);return{strictAddress1Valid:n,strictCityValid:l,strictStateValid:V,strictZipValid:I,strictAddressValid:T}}function ze(e){if(!e)return;e.querySelector('.k-invalid input, .k-invalid[tabindex="0"]')?.focus()}function He(e){const n=t.ref(!1),{formData:l,onAddress1Input:V,onAddress2Input:I,onCityInput:T,onStateChange:k,resetFormData:w}=Ke(),{zipDisplay:x,isZipValid:M,zipWrapperClass:E,onZipInput:F,resetZip:b}=Ne(l),{strictAddress1Valid:y,strictCityValid:C,strictStateValid:R,strictZipValid:f,strictAddressValid:v}=Be({formData:l,isZipValid:M}),L=Me(e.fieldsetRef,{submitted:n,isValid:()=>v.value}),{touched:H,fieldsetValidate:Y,onFocusout:J,reset:X}=L,re=L.createFieldValidationsMap({address1:y,city:C,state:R,zip:f,address:v}),{address1:i,city:g,state:u,zip:d,address:A}=re,m={value:null,label:"Select state"},D=Ue.map(({label:p,value:h})=>({label:p,value:h})),q=t.computed(()=>({address1:l.address1.trim(),address2:l.address2.trim(),city:l.city.trim(),state:(l.state??"").trim().toUpperCase(),zip:l.zip.replace(/\D/g,"")}));return{formData:l,submitted:n,touched:H,addressValidate:Y,address1Valid:i,cityValid:g,stateValid:u,zipValid:d,addressValid:A,stateDefaultItem:m,stateOptions:D,zipDisplay:x,zipWrapperClass:E,onAddress1Input:V,onAddress2Input:I,onCityInput:T,onStateChange:k,onZipInput:F,onFieldsetFocusout:J,normalizedPayload:q,submit:async()=>(n.value=!0,v.value?{isValid:!0,payload:q.value}:(await t.nextTick(),ze(e.formRef.value),{isValid:!1,payload:null})),reset:()=>{n.value=!1,X(),w(),b()}}}function Ze(e){const n=t.ref(""),l=t.ref(void 0),V=t.ref(!!e.debug),I=t.ref(e.dateFormat??"mm/dd/yyyy"),T=t.computed(()=>!!e.required),k=t.ref(!1),w=["ArrowUp","ArrowDown"],x=["ArrowLeft","ArrowRight"],M=t.computed(()=>(n.value??"").replace(/\D/g,"")),E=o=>o<=2?"mm":o<=5?"dd":M.value.length<=10?"yyyy":"mm",F=t.computed(()=>{const o=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(2,"0")}),b=t.computed(()=>{const o=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(2,"0")}),y=t.computed(()=>{const o=n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(4,"0")}),C=o=>{if(M.value.length===0){e.onChange({value:null,event:o});return}if(M.value.length<8){e.onChange({value:null,event:o});return}if((n.value??"").length===10&&M.value.length===8){const[p,h,U]=n.value.split("/"),N=parseInt(p),B=parseInt(h),Q=parseInt(U);if(H(Q,N,B)){const oe=new Date(Q,N-1,B);R(oe)?e.onChange({value:oe,event:o}):e.onChange({value:null,event:o})}else e.onChange({value:null,event:o})}},R=o=>{const p=e.min??void 0,h=e.max??void 0;return!(p&&o<p||h&&o>h)},f=t.computed(()=>{if((n.value??"").length===10&&M.value.length===8){const[o,p,h]=(n.value??"").split("/"),U=parseInt(o),N=parseInt(p),B=parseInt(h);if(H(B,U,N))return new Date(B,U-1,N)}return null}),v=t.computed(()=>(n.value??"").length===10&&M.value.length===8),L=(o,p)=>new Date(o,p,0).getDate(),H=(o,p,h)=>p>=1&&p<=12&&o>=1900&&h>=1&&h<=L(o,p),Y=o=>{n.value=o.value;const p=o.event?.target;l.value=p?.selectionStart??0,C(o)},J=o=>{l.value=o.target.selectionStart??0},X=(o,p,h)=>{const U=p?.selectionStart??l.value??0;l.value=U;let N=parseInt(F.value),B=parseInt(b.value),Q=parseInt(y.value);if(!(M.value.length>=8)||!H(Q,N,B)){const j=e.defaultValue??new Date;N=j.getMonth()+1,B=j.getDate(),Q=j.getFullYear(),n.value=`${String(N).padStart(2,"0")}/${String(B).padStart(2,"0")}/${String(Q)}`;const K=new Date(Q,N-1,B);e.onChange({value:R(K)?K:null,event:h}),d({useRAF:!0});return}const r=E(U);if(r==="mm")N=o==="ArrowUp"?N<12?N+1:1:N>1?N-1:12;else if(r==="dd"){const j=new Date(Q,N,0).getDate();B=o==="ArrowUp"?B<j?B+1:1:B>1?B-1:j}else r==="yyyy"&&(Q=o==="ArrowUp"?Q+1:Math.max(1,Q-1));n.value=`${String(N).padStart(2,"0")}/${String(B).padStart(2,"0")}/${String(Q)}`;const[s,P,O]=n.value.split("/"),z=new Date(parseInt(O),parseInt(s)-1,parseInt(P));z.toString()!=="Invalid Date"&&parseInt(O)>=1e3?e.onChange({value:R(z)?z:null,event:h}):e.onChange({value:null,event:h}),d({useRAF:!0})},re=o=>{if(o.code==="Space"||o.key===" "){o.preventDefault(),o.stopPropagation(),e.onShowCalendar(o);return}if(o.key==="ArrowDown"&&o.altKey){o.preventDefault(),o.stopPropagation(),e.onShowCalendar(o);return}if(w.includes(o.key)){if(o.altKey)return;o.preventDefault(),o.stopPropagation();const p=o.target;X(o.key,p,o);return}},i=o=>{o.preventDefault();const p=o.deltaY<0?"ArrowUp":"ArrowDown";X(p,o.target,o)},g=o=>{const p=o.target;if(x.includes(o.key)){l.value=p?.selectionStart??0;return}if(w.includes(o.key)){if(o.altKey)return;l.value=p?.selectionStart??0}},u=o=>{k.value=!0,T.value&&!e.defaultValue&&e.externalValue&&e.externalValue.value===void 0&&M.value.length===0&&(e.externalValue.value="");const p=o.target;p&&(l.value=p.selectionStart??0)},d=o=>{const p=()=>{const h=document.getElementById(e.id);if(!h)return;const U=o?.pos??l.value??h.value.length;try{h.focus(),h.setSelectionRange(U,U)}catch{}};t.nextTick(()=>{if(o?.delay&&o.delay>0){setTimeout(p,o.delay);return}if(o?.useRAF){requestAnimationFrame(p);return}p()})};e.externalValue&&t.watch(e.externalValue,o=>{if(o){const p=new Date(o);if(p.toString()!=="Invalid Date"){const h=(p.getMonth()+1).toString().padStart(2,"0"),U=p.getDate().toString().padStart(2,"0"),N=p.getFullYear().toString();n.value=`${h}/${U}/${N}`,d({delay:50});return}}},{immediate:!0});const A=t.computed(()=>[["Date",`${F.value} / ${b.value} / ${y.value}`],["Digits only",M.value],["min",e.min?.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"})??null],["max",e.max?.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"})??null]]),m=t.computed(()=>{if(!T.value){if(!v.value)return!0;const p=f.value;return p?R(p):!1}if(!k.value)return!0;const o=f.value;return!v.value||!o?!1:R(o)}),D=t.computed(()=>{if(!T.value){if(!v.value)return;const p=f.value;return p?R(p)?"valid":"out-of-bounds":"invalid-date"}if(!k.value)return;if(M.value.length===0||!v.value)return"incomplete";const o=f.value;return o?R(o)?"valid":"out-of-bounds":"invalid-date"}),q=t.computed(()=>{const o=D.value;if(!o||o==="valid")return"";if(o==="incomplete")return"Required";if(o==="invalid-date")return`Must be in ${I.value} format.`;const p=e.min?e.min.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null,h=e.max?e.max.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null;if(o==="out-of-bounds"){if(p&&h)return`Must be between ${p} and ${h}.`;if(p)return`Must be on or after ${p}.`;if(h)return`Must be on or before ${h}.`}return""}),Z=()=>{t.nextTick(()=>{const o=document.getElementById(e.id);if(!o){console.warn(`ID (#${e.id}) not found for styling.`);return}const p=o.closest(".k-datepicker");if(!p){console.warn(`.k-datepicker parent not found for #${e.id} styling.`);return}const h=p.parentElement;if(h){if(h.classList.contains("fk-datepicker"))return;h.classList.add("fk-datepicker")}else console.warn(`Parent of .k-datepicker not found for #${e.id} styling.`)})};return t.onMounted(()=>{Z()}),{raw:n,cursorPos:l,debugEnabled:V,debugLines:A,placeholder:I,isValid:m,reason:t.readonly(D),validationMessage:q,digitsOnly:M,month:t.readonly(F),day:t.readonly(b),year:t.readonly(y),datePart:E,handleChange:Y,handleKeyDown:re,handleWheel:i,handleKeyUp:g,handleClick:J,handleBlur:u,initStyling:Z}}function We(e){const n=t.ref(""),l=t.ref(void 0),V=t.ref(!!e.debug),I=t.ref(!1),T=1440*60*1e3,k=365*T,w=new Date,x=new Date(w.getTime()-k),M=new Date(w.getTime()+k);e.min=e.min??x,e.max=e.max??M;const E=t.computed(()=>(n.value??"").replace(/\D/g,"")),F=(a,c)=>new Date(a,c,0).getDate(),b=(a,c,S)=>c>=1&&c<=12&&a>=1e3&&S>=1&&S<=F(a,c),y=a=>Date.UTC(a.getFullYear(),a.getMonth(),a.getDate()),C=a=>{if(!a)return null;const c=e.min??new Date(Date.now()-90*T),S=e.max??new Date,$=y(a);return $<y(c)||$>y(S)?null:a},R=(a,c)=>e.allowReverse??!1?!0:a<=c,f=t.computed(()=>(n.value?.length??0)>=23&&E.value.length>=16),v=a=>{if((a??"").length<23||E.value.length<16)return{start:null,end:null};const c=a.substring(0,10),S=a.substring(13,23),[$,ee,te]=c.split("/").map(se=>parseInt(se||"0",10)),[ie,ce,de]=S.split("/").map(se=>parseInt(se||"0",10)),fe=new Date(te,$-1,ee),ye=new Date(de,ie-1,ce),Se=b(te,$,ee)&&fe.toString()!=="Invalid Date",ke=b(de,ie,ce)&&ye.toString()!=="Invalid Date";return{start:Se?fe:null,end:ke?ye:null}},L=e.externalValid??t.ref(!0),H=t.computed(()=>v(n.value)),Y=t.computed(()=>{const a=C(H.value.start),c=C(H.value.end);return{start:a,end:c}}),J=t.computed(()=>{if(!f.value)return;const a=Y.value.start,c=Y.value.end;if(!a||!c)return;const S=Math.abs(y(c)-y(a));return Math.round(S/864e5+1)}),X=t.computed(()=>{if(!f.value)return!1;const{start:a,end:c}=H.value;if(!a||!c||!Y.value.start||!Y.value.end)return!1;const S=Y.value.start,$=Y.value.end;return!(!R(S,$)||typeof e.maxSpanDays=="number"&&J.value!==void 0&&J.value>e.maxSpanDays)}),re=t.computed(()=>{const{start:a,end:c}=H.value;if(!f.value)return"incomplete";if(!a||!c)return"invalid-date";if(!Y.value.start||!Y.value.end)return"out-of-bounds";const S=Y.value.start,$=Y.value.end;return R(S,$)?typeof e.maxSpanDays=="number"&&J.value!==void 0&&J.value>e.maxSpanDays?"span-exceeds-limit":"valid":"reversed-range"}),i=t.ref(void 0),g=t.computed(()=>{if(L.value!==!1)return"";const{min:a,max:c}=e,S=i.value;if(!S)return"";switch(S){case"incomplete":return"Required";case"invalid-date":return"One or both dates invalid.";case"reversed-range":return"End Date must be on or after Start Date.";case"out-of-bounds":return a&&c?`Dates must be between ${m(a)} and ${m(c)}.`:"Dates must be within the allowed range.";case"span-exceeds-limit":return typeof e.maxSpanDays=="number"?`Date range exceeds ${e.maxSpanDays} days.`:"Date range exceeds maximum allowed span.";default:return""}}),u=["ArrowUp","ArrowDown"],d=["ArrowLeft","ArrowRight"],A=(a,c)=>String(a).padStart(c,"0"),m=a=>`${A(a.getMonth()+1,2)}/${A(a.getDate(),2)}/${A(a.getFullYear(),4)}`,D=a=>a<=2?{side:"start",part:"mm"}:a<=5?{side:"start",part:(a<=3,"dd")}:a<=11?{side:"start",part:"yyyy"}:a<=15?{side:"end",part:"mm"}:a<=18?{side:"end",part:"dd"}:{side:"end",part:"yyyy"},q=(a,c,S)=>{const $=c?.selectionStart??l.value??0;l.value=$;const{start:ee,end:te}=v(n.value);if(!ee&&!te){const W=new Date,le=m(W);n.value=`${le} - ${le}`,e.onChange({value:{start:W,end:W},event:S}),t.nextTick(()=>{requestAnimationFrame(()=>{const ne=document.getElementById(e.id),ae=l.value??0;ne&&(ne.focus(),ne.setSelectionRange(ae,ae))})});return}const ie=new Date,ce=D($);let de=ee?new Date(ee):new Date(ie),fe=te?new Date(te):new Date(ie);const ye=(W,le)=>{if(le==="mm"){const ne=W.getMonth()+1,ae=a==="ArrowUp"?ne<12?ne+1:1:ne>1?ne-1:12;W.setMonth(ae-1);const ge=F(W.getFullYear(),ae);W.getDate()>ge&&W.setDate(ge)}else if(le==="dd"){const ne=F(W.getFullYear(),W.getMonth()+1),ae=W.getDate(),ge=a==="ArrowUp"?ae<ne?ae+1:1:ae>1?ae-1:ne;W.setDate(ge)}else if(le==="yyyy"){const ne=W.getFullYear();W.setFullYear(a==="ArrowUp"?ne+1:Math.max(1,ne-1));const ae=F(W.getFullYear(),W.getMonth()+1);W.getDate()>ae&&W.setDate(ae)}};ce.side==="start"?ye(de,ce.part):ye(fe,ce.part);const Se=m(de),ke=m(fe);n.value=`${Se} - ${ke}`;const se=C(de),we=C(fe);se&&we&&R(se,we)?e.onChange({value:{start:se,end:we},event:S}):e.onChange({value:null,event:S}),t.nextTick(()=>{requestAnimationFrame(()=>{const W=document.getElementById(e.id),le=l.value??0;W&&(W.focus(),W.setSelectionRange(le,le))})})},Z=a=>{const{start:c,end:S}=v(n.value);if(!c||!S){e.onChange({value:null,event:a});return}const $=C(c),ee=C(S);if(!$||!ee){e.onChange({value:null,event:a});return}if(!R($,ee)){e.onChange({value:null,event:a});return}e.onChange({value:{start:$,end:ee},event:a})},o=a=>{const c=a.value??"",S=a.event;if(!c&&S&&S.type==="click"){oe(S);return}n.value=c;const $=S?.target;l.value=$?.selectionStart??0,Z(a)},p=a=>{l.value=a.target.selectionStart??0},h=a=>{if(a.code==="Space"||a.key===" "){a.preventDefault(),a.stopPropagation(),e.onShowCalendar(a);return}if(a.key==="ArrowDown"&&a.altKey){a.preventDefault(),a.stopPropagation(),e.onShowCalendar(a);return}if(u.includes(a.key)){a.preventDefault(),a.stopPropagation();const c=a.target;q(a.key,c,a);return}},U=a=>{a.preventDefault();const c=a.deltaY<0?"ArrowUp":"ArrowDown";q(c,a.target,a)},N=a=>{if(d.includes(a.key)||u.includes(a.key)){const c=a.target;l.value=c?.selectionStart??0}},B=()=>{i.value=re.value,(e.manageValid??!0)&&(L.value=X.value)},Q=a=>{B()},oe=a=>{console.log("Clear event:",a),n.value="",l.value=0,e.onChange({value:null,event:a}),B(),t.nextTick(()=>{const c=document.getElementById(e.id);c&&(c.focus(),c.setSelectionRange(0,0))})};e.externalValue&&t.watch(e.externalValue,a=>{const c=a?.start??null,S=a?.end??null;if(c&&S){if(n.value=`${m(c)} - ${m(S)}`,e.isOpen?.value&&I.value&&e.onRequestClose){const $=typeof e.closeDelay=="number"?e.closeDelay:e.closeDelay?.value??0;setTimeout(()=>{e.onRequestClose?.(),I.value=!1,B()},$)}return}},{immediate:!0});const r=t.computed(()=>n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0"),s=t.computed(()=>n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0"),P=t.computed(()=>n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0"),O=t.computed(()=>n.value&&n.value.substring(13,15).replace(/\D/g,"0")||"0"),z=t.computed(()=>n.value&&n.value.substring(16,18).replace(/\D/g,"0")||"0"),j=t.computed(()=>n.value&&n.value.substring(19,23).replace(/\D/g,"0")||"0"),K=t.computed(()=>{const{start:a,end:c}=v(n.value);return[{label:"Raw",value:n.value},{label:"Min Date",value:`${e.min?e.min.toDateString():"-"}`},{label:"Max Date",value:`${e.max?e.max.toDateString():"-"}`},{label:"Start",value:`${String(r.value).padStart(2,"0")} / ${String(s.value).padStart(2,"0")} / ${String(P.value).padStart(4,"0")}`},{label:"End",value:`${String(O.value).padStart(2,"0")} / ${String(z.value).padStart(2,"0")} / ${String(j.value).padStart(4,"0")}`},{label:"Digits only",value:E.value},{label:"Mask complete",value:`${f.value}`},{label:"Parsed",value:`${a?a.toDateString():"-"} | ${c?c.toDateString():"-"}`},{label:"Valid (managed)",value:`${L.value??"-"}`},{label:"Span (days)",value:`${J.value??"-"}`},{label:"Reason",value:`${re.value??"-"}`},{label:"Cursor in",value:`${l.value??"-"} (${(()=>{const S=l.value??0,$=D(S);return`${$.side}.${$.part}`})()})`}]}),G=()=>{t.nextTick(()=>{const a=document.getElementById(e.id);if(!a){console.warn(`#${e.id} not found for styling.`);return}const c=a.closest("div");if(!c){console.warn(`Parent div of #${e.id} not found for styling.`);return}c.classList.contains("fk-daterangepicker")||c.classList.add("fk-daterangepicker")})};t.onMounted(()=>{G()});const me=()=>{t.nextTick(()=>{try{const a=Array.from(document.querySelectorAll(".k-animation-container"));if(!a.length)return;const S=[...a].reverse().find(te=>te.querySelector(".k-calendar"))?.querySelector(".k-calendar");if(!S)return;const $=S.querySelectorAll(".k-calendar-table");let ee=!1;$.forEach(te=>{te.tabIndex===0&&(ee?te.tabIndex=-1:ee=!0)})}catch(a){console.warn(a)}})};return e.isOpen&&t.watch(e.isOpen,a=>{a&&setTimeout(()=>me(),0)},{immediate:!1}),{raw:n,cursorPos:l,debugEnabled:V,debugLines:K,digitsOnly:E,valid:L,validComputed:t.readonly(X),reason:t.readonly(re),validationMessage:t.readonly(g),spanDays:t.readonly(J),month1:t.readonly(r),day1:t.readonly(s),year1:t.readonly(P),month2:t.readonly(O),day2:t.readonly(z),year2:t.readonly(j),handleChange:o,handleKeyDown:h,handleWheel:U,handleKeyUp:N,handleClick:p,handleBlur:Q,handleClear:oe,onCalendarChange:()=>{I.value=!0},initStyling:G}}function Ye(e){const n=t.ref(""),l=t.ref(void 0),V=t.ref(!!e.debug),I=t.ref(e.timeFormat??"hh:mm AM"),T=t.computed(()=>!!e.required),k=t.ref(!1),w=["ArrowUp","ArrowDown"],x=["ArrowLeft","ArrowRight"],M=t.computed(()=>(n.value??"").replace(/\D/g,"")),E={H:/[0-9]/,h:/[0-9]/,M:/[0-9]/,m:/[0-9]/,A:/[AaPp]/,a:/[Mm]/},F=r=>r<=2?"hh":r<=5?"mm":"ampm",b=t.computed(()=>{const r=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0",s=parseInt(r);return Math.min(Math.max(s,0),23)}),y=t.computed(()=>{const r=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0",s=parseInt(r);return Math.min(Math.max(s,0),59)}),C=t.computed(()=>(n.value?.substring(6,8)||"AM").toUpperCase().startsWith("P")?"PM":"AM"),R=t.computed(()=>{const r=parseInt(n.value?.substring(0,2).replace(/\D/g,"0")||"0"),s=C.value;return r===12?s==="AM"?0:12:s==="PM"?r+12:r}),f=t.computed(()=>v.value?`${String(R.value).padStart(2,"0")}:${String(y.value).padStart(2,"0")}:00`:null),v=t.computed(()=>/^(\d{2}):(\d{2})\s([AP]M)$/i.test(n.value??"")),L=(r,s,P)=>{let O=r%12;return O===0&&(O=12),`${String(O).padStart(2,"0")}:${String(s).padStart(2,"0")} ${P}`},H=r=>{const s=r.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!s)return null;const P=parseInt(s[1]),O=parseInt(s[2]),z=s[3].toUpperCase();if(P<1||P>12||O<0||O>59)return null;let j=P%12;z==="PM"&&(j+=12);const K=new Date;return K.setSeconds(0,0),K.setHours(j),K.setMinutes(O),K},Y=r=>{if(M.value.length===0){e.onChange({value:null,event:r});return}if(!v.value){e.onChange({value:null,event:r});return}const s=H(n.value);s&&X(s)?e.onChange({value:s,event:r}):e.onChange({value:null,event:r})},J=r=>r.getHours()*60+r.getMinutes(),X=r=>{const s=e.min??void 0,P=e.max??void 0,O=J(r);if(s){const z=J(s);if(O<z)return!1}if(P){const z=J(P);if(O>z)return!1}return!0},re=r=>{const s=r.getHours(),P=s>=12?"PM":"AM";n.value=L(s,r.getMinutes(),P)},i=(r,s)=>{e.onChange({value:r,event:s})},g=()=>{t.nextTick(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const r=document.getElementById(e.id);if(r){r.focus();const s=(r.value??"").length;r.setSelectionRange(s,s)}})})})},u=r=>{const s=r?.event?.target;return s?s.closest(".k-time-now")?"now":s.closest(".k-time-accept")?"set":null:null},d=(r,s)=>{r&&X(r)?i(r,s):i(null,s)},A=(...r)=>{const s=r[0];if(!s)return;const P=u(s);if(P==="now"){const z=new Date;re(z),d(z,s),g();return}if(s?.value instanceof Date){const z=new Date(s.value);re(z),d(z,s),P==="set"&&g();return}if(s?.value===null){n.value="",i(null,s);return}n.value=s.value;const O=s.event?.target;l.value=O?.selectionStart??0;try{const z=l.value??0;if(F(z)==="ampm"&&(n.value??"").length>=8){const j=n.value.charAt(6);/[Aa]/.test(j)?(n.value=`${n.value.slice(0,6)}AM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const K=document.getElementById(e.id);K&&(K.focus(),K.setSelectionRange(8,8))})})):/[Pp]/.test(j)&&(n.value=`${n.value.slice(0,6)}PM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const K=document.getElementById(e.id);K&&(K.focus(),K.setSelectionRange(8,8))})}))}}catch{}Y(s)},m=r=>{l.value=r.target.selectionStart??0},D=(r,s,P)=>{const O=s?.selectionStart??l.value??0;l.value=O;const z=F(O),j=(n.value??"").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!j){if((n.value??"").length===0||M.value.length===0){const c=new Date,S=c.getHours(),$=S>=12?"PM":"AM";n.value=L(S,c.getMinutes(),$);const ee=H(n.value);d(ee,P),t.nextTick(()=>{requestAnimationFrame(()=>{const te=document.getElementById(e.id),ie=l.value??0;te&&(te.focus(),te.setSelectionRange(ie,ie))})})}return}let K=parseInt(j[1]),G=parseInt(j[2]),me=j[3].toUpperCase();if(z==="hh")r==="ArrowUp"?K=K<12?K+1:1:K=K>1?K-1:12;else if(z==="mm"){const c=e.minuteStepRef?.value??e.minuteStep??1;if(c===1)r==="ArrowUp"?G=G<59?G+1:0:G=G>0?G-1:59;else if(r==="ArrowUp"){const S=G%c;let $=S===0?G+c:G+(c-S);$>=60&&($=0),G=$}else{const S=G%c;let $=S===0?G-c:G-S;$<0&&($=60-c),G=$}}else z==="ampm"&&(me=me==="AM"?"PM":"AM");n.value=`${String(K).padStart(2,"0")}:${String(G).padStart(2,"0")} ${me}`;const a=H(n.value);d(a,P),t.nextTick(()=>{requestAnimationFrame(()=>{const c=document.getElementById(e.id),S=l.value??0;c&&(c.focus(),c.setSelectionRange(S,S))})})},q=r=>{if(r.code==="Space"||r.key===" "){r.preventDefault(),r.stopPropagation(),e.onShowPicker(r);return}if(r.key==="ArrowDown"&&r.altKey){r.preventDefault(),r.stopPropagation(),e.onShowPicker(r);return}if(w.includes(r.key)){if(r.altKey)return;r.preventDefault(),r.stopPropagation();const s=r.target;D(r.key,s,r);return}},Z=r=>{r.preventDefault();const s=r.deltaY<0?"ArrowUp":"ArrowDown";D(s,r.target,r)},o=r=>{const s=r.target;if(x.includes(r.key)){l.value=s?.selectionStart??0;return}if(w.includes(r.key)){if(r.altKey)return;l.value=s?.selectionStart??0}},p=r=>{k.value=!0,T.value&&e.externalValue&&e.externalValue.value===void 0&&M.value.length===0&&(e.externalValue.value="");const s=r.target;s&&(l.value=s.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,r=>{if(r){const s=new Date(r);if(s.toString()!=="Invalid Date"){const P=s.getHours(),O=P>=12?"PM":"AM";n.value=L(P,s.getMinutes(),O);return}}},{immediate:!0});const h=t.computed(()=>[["Time",n.value||"--:-- --"],["Hour (12h)",b.value],["Hour (24h)",R.value],["Minute",y.value],["Period",C.value],["Time (24h)",f.value??"--:--:--"],["Digits only",M.value],["Parsed Date",U.value?.toLocaleDateString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["min",e.min?.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["max",e.max?.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["valid",N.value],["reason",B.value],["validationMessage",Q.value]]),U=t.computed(()=>H(n.value)??null),N=t.computed(()=>{if(!T.value){if(!v.value)return!0;const s=U.value;return s?X(s):!1}if(!k.value)return!0;const r=U.value;return!v.value||!r?!1:X(r)}),B=t.computed(()=>{if(!T.value){if(!v.value)return;const s=U.value;return s?X(s)?"valid":"out-of-bounds":"invalid-time"}if(!k.value)return;if(M.value.length===0||!v.value)return"incomplete";const r=U.value;return r?X(r)?"valid":"out-of-bounds":"invalid-time"}),Q=t.computed(()=>{const r=B.value;if(!r||r==="valid")return"";if(r==="incomplete")return"Required";if(r==="invalid-time")return`Must be in ${I.value} format.`;const s={hour:"2-digit",minute:"2-digit"},P=e.min?e.min.toLocaleTimeString("en-US",s):null,O=e.max?e.max.toLocaleTimeString("en-US",s):null;if(r==="out-of-bounds"){if(P&&O)return`Must be between ${P} and ${O}.`;if(P)return`Must be ${P} or later.`;if(O)return`Must be ${O} or earlier.`}return""}),oe=()=>{t.nextTick(()=>{const r=document.getElementById(e.id);if(!r){console.warn(`#${e.id} not found for styling.`);return}const s=r.closest(".k-timepicker");if(!s){console.warn(`.k-timepicker parent of #${e.id} not found for styling.`);return}const P=s.parentElement;if(!P){console.warn(`Parent of .k-timepicker not found for #${e.id} styling.`);return}P.classList.contains("fk-timepicker")||P.classList.add("fk-timepicker")})};return t.onMounted(()=>{oe()}),{raw:n,rules:E,debugEnabled:V,debugLines:h,placeholder:I,isValid:N,reason:t.readonly(B),validationMessage:Q,isComplete:v,inRangeTime:X,cursorPos:l,hour:t.readonly(b),hour24:t.readonly(R),minute:t.readonly(y),period:t.readonly(C),time24:t.readonly(f),parsedRawTime:t.readonly(U),handleChange:A,handleKeyDown:q,handleKeyUp:o,handleClick:m,handleWheel:Z,handleBlur:p,initStyling:oe}}function je(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}const Ie=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Ge=Object.prototype.toString,_e=e=>Ge.call(e)==="[object Object]",ue=()=>{},Je=Xe();function Xe(){var e,n;return Ie&&((e=window?.navigator)==null?void 0:e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((n=window?.navigator)==null?void 0:n.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function he(e){return Array.isArray(e)?e:[e]}function Qe(e,n,l){return t.watch(e,n,{...l,immediate:!0})}const Te=Ie?window:void 0;function pe(e){var n;const l=t.toValue(e);return(n=l?.$el)!=null?n:l}function be(...e){const n=[],l=()=>{n.forEach(w=>w()),n.length=0},V=(w,x,M,E)=>(w.addEventListener(x,M,E),()=>w.removeEventListener(x,M,E)),I=t.computed(()=>{const w=he(t.toValue(e[0])).filter(x=>x!=null);return w.every(x=>typeof x!="string")?w:void 0}),T=Qe(()=>{var w,x;return[(x=(w=I.value)==null?void 0:w.map(M=>pe(M)))!=null?x:[Te].filter(M=>M!=null),he(t.toValue(I.value?e[1]:e[0])),he(t.unref(I.value?e[2]:e[1])),t.toValue(I.value?e[3]:e[2])]},([w,x,M,E])=>{if(l(),!w?.length||!x?.length||!M?.length)return;const F=_e(E)?{...E}:E;n.push(...w.flatMap(b=>x.flatMap(y=>M.map(C=>V(b,y,C,F)))))},{flush:"post"}),k=()=>{T(),l()};return je(l),k}let Ce=!1;function et(e,n,l={}){const{window:V=Te,ignore:I=[],capture:T=!0,detectIframe:k=!1,controls:w=!1}=l;if(!V)return w?{stop:ue,cancel:ue,trigger:ue}:ue;if(Je&&!Ce){Ce=!0;const f={passive:!0};Array.from(V.document.body.children).forEach(v=>v.addEventListener("click",ue,f)),V.document.documentElement.addEventListener("click",ue,f)}let x=!0;const M=f=>t.toValue(I).some(v=>{if(typeof v=="string")return Array.from(V.document.querySelectorAll(v)).some(L=>L===f.target||f.composedPath().includes(L));{const L=pe(v);return L&&(f.target===L||f.composedPath().includes(L))}});function E(f){const v=t.toValue(f);return v&&v.$.subTree.shapeFlag===16}function F(f,v){const L=t.toValue(f),H=L.$.subTree&&L.$.subTree.children;return H==null||!Array.isArray(H)?!1:H.some(Y=>Y.el===v.target||v.composedPath().includes(Y.el))}const b=f=>{const v=pe(e);if(f.target!=null&&!(!(v instanceof Element)&&E(e)&&F(e,f))&&!(!v||v===f.target||f.composedPath().includes(v))){if("detail"in f&&f.detail===0&&(x=!M(f)),!x){x=!0;return}n(f)}};let y=!1;const C=[be(V,"click",f=>{y||(y=!0,setTimeout(()=>{y=!1},0),b(f))},{passive:!0,capture:T}),be(V,"pointerdown",f=>{const v=pe(e);x=!M(f)&&!!(v&&!f.composedPath().includes(v))},{passive:!0}),k&&be(V,"blur",f=>{setTimeout(()=>{var v;const L=pe(e);((v=V.document.activeElement)==null?void 0:v.tagName)==="IFRAME"&&!L?.contains(V.document.activeElement)&&n(f)},0)},{passive:!0})].filter(Boolean),R=()=>C.forEach(f=>f());return w?{stop:R,cancel:()=>{x=!1},trigger:f=>{x=!0,b(f),x=!1}}:R}function tt(e){const n=t.shallowRef(null),l=[".k-animation-container .k-popup",".k-popup",".k-timepicker-popup",".k-menu-popup"],V=Array.isArray(e.popupSelector)?e.popupSelector:[e.popupSelector??l].flat(),I=E=>E?typeof e.initialFocus=="string"?E.querySelector(e.initialFocus)??E:typeof e.initialFocus=="function"?e.initialFocus(E)??E:E.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??E:null,{activate:T,deactivate:k}=Ve.useFocusTrap(n,{escapeDeactivates:!1,clickOutsideDeactivates:!1,fallbackFocus:()=>n.value,initialFocus:()=>I(n.value),...e.focusTrapOptions??{}});let w=null,x=t.ref(null);const M=()=>{if(e.resolvePopupEl)return e.resolvePopupEl();const E=(b,y)=>{const C=Array.from(b.querySelectorAll(y));if(!C.length)return null;const R=C.filter(f=>f.offsetParent!==null||f.getClientRects().length>0);return R[R.length-1]??C[C.length-1]??null},F=e.triggerEl?.value?.closest?.(".k-animation-container")??document.body;for(const b of V){const y=E(F,b);if(y)return y}for(const b of V){const y=E(document,b);if(y)return y}return null};return et(n,E=>{x.value="outside",e.isOpen.value&&e.onRequestClose?.("outside",E)}),t.watch(()=>e.isOpen.value,E=>{E?(x.value=null,t.nextTick(()=>{const F=M();F&&(n.value=F,setTimeout(()=>T(),0),w||(w=b=>{b.key==="Escape"&&(x.value="escape",e.isOpen.value&&e.onRequestClose?.("escape",b))},document.addEventListener("keydown",w,!0)))})):(k(),w&&(document.removeEventListener("keydown",w,!0),w=null),n.value=null,x.value==="outside"&&t.nextTick(()=>{const F=()=>{const b=e.triggerEl?.value,y=b?.querySelector("input"),C=document.activeElement;C&&(C===y||b&&b.contains(C))&&(y??b)?.blur?.()};requestAnimationFrame(()=>setTimeout(F,0))}),e.returnFocusToTrigger!==!1&&x.value==="escape"&&e.triggerEl?.value&&(console.log("Returning focus to trigger element:",e.triggerEl.value),t.nextTick(()=>{const F=()=>{const b=e.triggerEl?.value;if(!b)return;(b.querySelector("input")??b)?.focus?.()};requestAnimationFrame(()=>setTimeout(F,0))})))}),{popupRef:n,activate:T,deactivate:k,lastCloseReason:t.readonly(x),setPopupEl:E=>n.value=E}}_.useFieldsetTouchTracker=Ee,_.useFieldsetValidationKit=Me,_.useGridA11y=$e,_.useGridActiveFilter=Re,_.useMaskedDateInput=Ze,_.useMaskedDateRangeInput=We,_.useMaskedTimeInput=Ye,_.usePopupTrap=tt,_.useUSAddress=He,_.useZipTextBox=xe,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,101 @@
1
+ # useUSAddress
2
+
3
+ [← Back to Composables README](https://github.com/NantHealth/featherk/blob/integration/packages/composables/README.md)
4
+
5
+ Composable that orchestrates a full US address form experience for Kendo Vue inputs.
6
+
7
+ `useUSAddress` composes:
8
+
9
+ - `useFieldsetValidationKit` for delayed validation (`submitted || touched`)
10
+ - `useZipTextBox` for dynamic ZIP/ZIP+4 formatting and validity
11
+ - internal field/state handlers for address lines, city, and state
12
+
13
+ It returns field bindings, delayed validity refs, submit/reset actions, and a normalized payload.
14
+
15
+ ## Prerequisites
16
+
17
+ - Vue 3 Composition API
18
+ - Kendo Vue form inputs (`TextBox`, `DropDownList`)
19
+
20
+ ## Quick Start
21
+
22
+ ```ts
23
+ import { ref } from "vue";
24
+ import { useUSAddress } from "@featherk/composables/address";
25
+
26
+ const formRef = ref<HTMLFormElement | null>(null);
27
+ const fieldsetRef = ref<HTMLFieldSetElement | null>(null);
28
+
29
+ const address = useUSAddress({
30
+ formRef,
31
+ fieldsetRef,
32
+ });
33
+
34
+ async function onSubmit() {
35
+ const result = await address.submit();
36
+
37
+ if (!result.isValid) {
38
+ return;
39
+ }
40
+
41
+ // Normalized payload safe for transport
42
+ console.log(result.payload);
43
+ }
44
+
45
+ function onReset() {
46
+ address.reset();
47
+ }
48
+ ```
49
+
50
+ ## Payload
51
+
52
+ `submit()` returns a normalized payload when valid:
53
+
54
+ ```ts
55
+ export interface USAddressSubmitPayload {
56
+ address1: string;
57
+ address2: string;
58
+ city: string;
59
+ state: string; // upper-cased
60
+ zip: string; // digits only
61
+ }
62
+ ```
63
+
64
+ Normalization rules:
65
+
66
+ - trims whitespace for `address1`, `address2`, and `city`
67
+ - upper-cases `state`
68
+ - strips non-digits from `zip`
69
+
70
+ ## Returned API (high level)
71
+
72
+ State and bindings:
73
+
74
+ - `formData`
75
+ - `zipDisplay`
76
+ - `zipWrapperClass`
77
+ - `stateOptions`
78
+ - `stateDefaultItem`
79
+
80
+ Validation:
81
+
82
+ - `addressValidate`
83
+ - `address1Valid`, `cityValid`, `stateValid`, `zipValid`, `addressValid`
84
+ - `touched`
85
+
86
+ Handlers:
87
+
88
+ - `onAddress1Input`, `onAddress2Input`, `onCityInput`, `onStateChange`, `onZipInput`
89
+ - `onFieldsetFocusout`
90
+
91
+ Actions:
92
+
93
+ - `submit()`
94
+ - `reset()`
95
+
96
+ ## Behavior Notes
97
+
98
+ - Delayed validation is inactive until submit or fieldset touch.
99
+ - Invalid submit focuses the first invalid Kendo control in the form.
100
+ - Reset clears submit/touch state and field values.
101
+ - ZIP behavior remains delegated to `useZipTextBox`.
@@ -6,6 +6,10 @@ Composable for a multi-mask ZIP code input that pairs with the Kendo Vue `TextBo
6
6
 
7
7
  Kendo Vue's `MaskedTextBox` does not handle dynamic mask switching between a 5-digit and 9-digit ZIP format gracefully. This composable solves that by managing formatting, validation state, and payload construction explicitly — leaving the `TextBox` as a simple controlled input.
8
8
 
9
+ ## Related
10
+
11
+ - Looking for a full address form orchestration composable? See [`useUSAddress`](https://github.com/NantHealth/featherk/blob/integration/packages/composables/docs/address/useUSAddress.md).
12
+
9
13
  ## Prerequisites
10
14
 
11
15
  - Vue 3 Composition API
@@ -152,4 +156,4 @@ When the user types into the middle of the value, `handleZipInput` captures the
152
156
  ## Notes
153
157
 
154
158
  - The composable does **not** emit intermediate states. `buildPayload()` always returns raw digits regardless of validity; you control whether to use it by checking the return value of `submitAndValidate()`.
155
- - This composable is a building block for the planned `useAddress` composable, which will compose `useZipTextBox` alongside state/city fields.
159
+ - This composable is a building block for `useUSAddress`, which composes `useZipTextBox` alongside address line, city, and state field handlers.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@featherk/composables",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "main": "dist/featherk-composables.umd.js",
5
5
  "module": "dist/featherk-composables.es.js",
6
6
  "types": "dist/index.d.ts",