@spscommerce/ds-react 6.33.1 → 6.33.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs.js CHANGED
@@ -193,7 +193,7 @@
193
193
  </SpsAdvancedSearch>
194
194
  </>;
195
195
  }
196
- `}}}};let Xt=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");function wn(e){return H.useRef(e||Xt())}function Tt(e,t){const n=wn(e),s=H.useRef(`${n.current}_ctrl`);return H.useEffect(()=>{t&&(t.id=s.current,t.update())},[t]),{wrapperId:n.current,controlId:s.current}}var mb="[object Object]";function fb(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function hb(e,t){return function(n){return e(t(n))}}var gb=Function.prototype,lc=Object.prototype,cc=gb.toString,Sb=lc.hasOwnProperty,bb=cc.call(Object),vb=lc.toString,yb=hb(Object.getPrototypeOf,Object);function Tb(e){return!!e&&typeof e=="object"}function wb(e){if(!Tb(e)||vb.call(e)!=mb||fb(e))return!1;var t=yb(e);if(t===null)return!0;var n=Sb.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&cc.call(n)==bb}var dc=wb;const Lt=new Set,Un=new Set,Qt=new Set,Sa=new Set;function pc(e){Lt.has(e)||Qt.has(e)||Sa.has(e)||Un.add(e)}function uc(e){Lt.has(e)||Qt.has(e)||Un.has(e)||Sa.add(e)}const Yr=Gn.default||Gn,os="MM/DD/YYYY",Eb=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,mc=Symbol("Date Parse Error");function Yn(e){return e.year*1e4+e.month*100+e.date}const he=Object.freeze({createFrom(e){if(!e)return null;if(typeof e=="string"){const t=Eb.exec(e);if(t){const[,n,s,o]=t;return Object.freeze({year:Number(o),month:Number(n),date:Number(s)})}return Object.freeze({[mc]:!0,year:void 0,month:void 0,date:void 0})}return Object.freeze({year:e.year(),month:e.month()+1,date:e.date()})},createRangeFrom(e){return e?e.split(/[^\d]*-[^\d]*/).map(he.createFrom):null},isValid(e){return e&&typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&he.toMoment(e).isValid()},nullifyInvalidDate(e){return he.isValid(e)?e:null},toMoment(e){return e?Yr(G(N({},e),{month:e.month-1})):null},toString(e){const t=he.toMoment(e);return t?t.format(os):""},toStringRange(e){return e?e.map(he.toString).join("-"):""},create(){const e=new Date;return Object.freeze({year:e.getFullYear(),month:e.getMonth()+1,date:e.getDate()})},isSameDate(e,t){return e&&t&&e.year===t.year&&e.month===t.month&&e.date===t.date},isSameMonth(e,t){return e&&t&&e.year===t.year&&e.month===t.month},isAfter(e,t){return!e||!t?null:Yn(e)>Yn(t)},isBefore(e,t){return!e||!t?null:Yn(e)<Yn(t)},isInRange(e,t,n=!0){if(!e||!t||!t[0]||!t[1])return null;const s=Yn(e),[o,i]=t.map(Yn);return e&&o&&i&&(n&&s>=o&&s<=i||!n&&s>o&&s<i)},prevMonth(e){return Object.freeze({year:e.month===1?e.year-1:e.year,month:e.month-1||12,date:e.date})},nextMonth(e){return Object.freeze({year:e.month===12?e.year+1:e.year,month:e.month+1>12?1:e.month+1,date:e.date})},createRangeFromPreset(e){if(typeof e.definition=="function")return e.definition();const t=Yr(),n=t.clone().subtract(Yr.duration(e.definition));return[he.createFrom(n),he.createFrom(t)]}}),ba=function(t){if(Array.isArray(t)){const n=ba(t[0]),s=ba(t[1]);return n||s}if(t&&t.hasOwnProperty("year")){if(t[mc])return{dateFormat:os};if(!he.isValid(t))return{dateValidity:!0}}return null};Lt.add("dateFormat");Lt.add("dateValidity");const fc=function(t){if(Array.isArray(t)){const n=ba(t);if(n)return n;if(t&&he.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};Lt.add("dateRangeOrder");const hc=function({minDate:t,maxDate:n}){function s(o){const i=he.isBefore(o,t),c=he.isAfter(o,n),l={minExceeded:i?he.toString(t):null,maxExceeded:c?he.toString(n):null};return i||c?{dateConstraint:l}:null}return function(i){if(!i)return null;if(Array.isArray(i)){const c=s(i[0]),l=s(i[1]);return c||l}return i.hasOwnProperty("year")?s(i):null}};Lt.add("dateConstraint");var Cb=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",date:ba,dateRange:fc,dateConstraint:hc});function rn(e,t){for(const n of[].concat(e)){const s=t(n);if(s)return s}return null}const xb=function(t){function n(s){return Number(s)>=t?null:{min:t}}return s=>rn(s,n)};Lt.add("min");const Db=function(t){function n(s){return Number(s)<=t?null:{max:t}}return s=>rn(s,n)};Un.add("max");const Ib=function(t){return typeof t=="undefined"||t===null||t===""||Number.isNaN(t)||(t==null?void 0:t.length)===0?{required:!0}:null};Un.add("required");const Nb=function(t){function n(s){return s===void 0||s.toString().length<t?{minLength:t}:null}return s=>rn(s,n)};Lt.add("minLength");const kb=function(t){function n(s){return s===void 0||s.toString().length<=t?null:{maxLength:t}}return s=>rn(s,n)};Qt.add("maxLength");const Mb=function(t){const n=t instanceof RegExp?t:new RegExp(t);function s(o){return n.test(o)?null:{pattern:t}}return o=>rn(o,s)};Lt.add("pattern");const Rb=function(e){function t(n){return/^\p{L}*$/u.test(n)?null:{alpha:!0}}return rn(e,t)};Qt.add("alpha");const _b=function(e){function t(n){return/^[0-9,. ]*$/.test(n)?null:{numeric:!0}}return rn(e,t)};Qt.add("numeric");const Lb=function(e){function t(n){return/^[^0-9]*$/.test(n)?null:{nonNumeric:!0}}return rn(e,t)};Qt.add("nonNumeric");const is=Object.freeze(G(N({},Cb),{min:xb,max:Db,required:Ib,minLength:Nb,maxLength:kb,pattern:Mb,alpha:Rb,numeric:_b,nonNumeric:Lb,OnBlurErrorKeys:Lt}));function va(e,t=[]){const n=t.reduce((s,o)=>Object.assign(s,o(e)||{}),{});return Object.keys(n).length?n:null}class En{constructor(t,n){this.path=t,this.update=n,this.validators=[],this.errors=null,this.revealAllErrors=!1,this.preventativeErrors=[],this.submitted=!1}setValidators(t){return this.update(this.path,null,null,t),this}validate(t){return this.validators&&this.validators.length>0?(this.errors=va(t,this.validators),this.update(null),this.isFocused()&&this.onFocus&&this.onFocus()):this.errors&&(this.errors=null,this.update(null)),this}isValid(){return!this.errors||this.isPristine()}hasErrors(){return!!this.errors}isVisibilyInvalid(){return this.errors&&(this.revealAllErrors&&!Object.keys(this.errors).some(t=>Sa.has(t))||this.revealAllErrors&&Object.keys(this.errors).some(t=>Sa.has(t))&&this.isSubmitted()||!this.isPristine()&&Object.keys(this.errors).some(t=>Un.has(t)))}hasError(t){return this.errors&&Object.prototype.hasOwnProperty.call(this.errors,t)}hasPreventativeError(t){return this.preventativeErrors.includes(t)}hasPreventativeErrors(){return this.preventativeErrors.length>0}isRequired(){return this.validators&&this.validators.indexOf(is.required)>-1}isSubmitted(){return this.submitted}onFocus(){}onBlur(){}}class Cn extends En{constructor(){super(...arguments);this.id=Xt(),this.focused=!1,this.pristine=!0}setValue(t){if(this.revealAllErrors=!1,this.preventativeErrors=[],this.validators&&this.validators.length>0){const n=va(t,this.validators);if(n&&Object.keys(n).filter(o=>Qt.has(o)).length>0){this.preventativeErrors=Object.keys(n);return}}this.update(this.path,t)}isPristine(){return this.pristine}markAsPristine(){return this.pristine=!0,this.revealAllErrors=!1,this.update(null),this}markAsDirty(){return this.pristine=!1,this.update(null),this}isFocused(){return this.focused}markAsFocused(){return this.focused=!0,this.update(null),this.onFocus&&this.onFocus(),this}markAsBlurred(){return this.update(this.path,null,!0),this.onBlur&&this.onBlur(),this.preventativeErrors=[],this}markAsSubmitted(){return this.submitted=!0,this.update(null),this}}class ls extends Cn{constructor(t,n,s){const o=s?n:t,i=s||n;super(o,i);s&&this.inferMembers(t)}inferSpsControl(t,n){return cs(t,[...this.path,n],this.update)}rollup(t){return Object.keys(this.fields).reduce((n,s)=>n&&(!this.fields[s][t]||this.fields[s][t]()),!0)}isFocused(){return super.isFocused()||this.rollup("isFocused")}isValid(){return super.isValid()&&this.rollup("isValid")}hasErrors(){return super.hasErrors()||Object.keys(this.fields).some(t=>this.fields[t].hasErrors())}contentsAreValid(){return this.rollup("isValid")&&this.rollup("contentsAreValid")}isPristine(){return super.isPristine()&&this.rollup("isPristine")}markAsPristine(){super.markAsPristine();for(const t of Object.keys(this.fields))this.fields[t].markAsPristine();return this}markAsDirty(){super.markAsDirty();for(const t of Object.keys(this.fields))this.fields[t].markAsDirty();return this}markAsBlurred(){super.markAsBlurred();for(const t of Object.keys(this.fields))this.fields[t].markAsBlurred();return this}markAsSubmitted(){super.markAsSubmitted();for(const t of Object.keys(this.fields))this.fields[t].markAsSubmitted();return this}}class gc extends ls{inferMembers(t){this.fields={};for(const n of Object.keys(t))this.fields[n]=this.inferSpsControl(t[n],n)}}class Sc extends ls{inferMembers(t){this.fields=t.map((n,s)=>this.inferSpsControl(n,String(s)))}}function cs(e,t,n){return e instanceof En?(e.path=t,e.update=n,e):Array.isArray(e)?new Sc(e,t,n):dc(e)?new gc(e,t,n):new Cn(t,n)}function zr(e,t){return t.length===0||!e?e:zr(e.fields[t[0]],t.slice(1,t.length))}function jr(e,t){if(t.length===0||!e)return[e];const n=t[0];if(t=t.slice(1,t.length),n==="*"){const s=Array.isArray(e.fields)?e.fields:Object.keys(e.fields).map(o=>e.fields[o]);return t.length===0?s:s.reduce((o,i)=>[...o,...jr(i,t)],[])}return jr(e.fields[n],t)}function bc(e,t,n){for(const s of Object.keys(t)){const o=t[s];for(const i of jr(e,s.split(".")))i&&o&&n(i,o)}}function ds(e,t,n,s=!1){bc(t,n,(o,i)=>{o.validators=typeof i=="function"?i(e):i,s&&(o.errors=va(y.getPath(e,o.path),o.validators))})}function qr(e,t){const n=t[0];return t=t.slice(1),Array.isArray(e)?e.map((s,o)=>o===Number(n)?qr(s,t):s):dc(e)?Object.keys(e).reduce((s,o)=>Object.assign(s,{[o]:o===n?qr(e[o],t):e[o]}),{}):e}function Ob(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function Bb(e,t){Ob(e);const n=H.useMemo(()=>{y.deepFreeze(e);const f=cs(e,[],p);return t&&ds(e,f,t,!0),f},[]),s=H.useRef(),o=H.useRef(t),i=H.useCallback((f,m)=>{var S,T,x;let g;if(s.current=null,m)if(m.path)if(m.markAsBlurred){const E=zr(f.formMeta,m.path);E&&(E.focused=!1,E.revealAllErrors=!0)}else if(m.newValidators){if(o.current){const E=m.path.join(".");o.current=G(N({},o.current),{[E]:m.newValidators}),ds(f.formValue,f.formMeta,o.current,!0)}}else g=qr(f.formValue,m.path),y.setPath(g,m.path,m.value);else g=m.value;if(((S=m.updateFormOptions)==null?void 0:S.validators)&&(o.current=N(N({},o.current),m.updateFormOptions.validators),ds(f.formValue,f.formMeta,o.current,(x=(T=m.updateFormOptions)==null?void 0:T.runValidators)!=null?x:!0)),g){y.deepFreeze(g);const E=y.diff(f.formValue,g);for(const{type:D,key:I,parentPath:v,objects:[k,_]}of E){const B=zr(f.formMeta,v);if(typeof I!="symbol"&&B)switch(D){case y.DiffChange.ADDITION:B.fields[I]=cs(_[I],[...v,I],p);break;case y.DiffChange.DELETION:Array.isArray(B.fields)?B.fields.splice(Number(I),1):delete B.fields[I];break;case y.DiffChange.ALTERATION:if(!k[I]&&_[I]&&!(B.fields[I]instanceof ls)){const M=cs(_[I],[...v,I],p);M instanceof Cn&&B.fields[I]instanceof Cn&&(M.id=B.fields[I].id,M.focused=B.fields[I].focused,M.pristine=B.fields[I].pristine),B.fields[I]=M}break}}if(o.current){ds(g,f.formMeta,o.current);const D=new Set;bc(f.formMeta,t,(I,v)=>{typeof v=="function"&&(I.validate(y.getPath(g,I.path)),D.add(I))});for(const{type:I,key:v,parentPath:k,objects:[,_]}of E)if(typeof v!="symbol"){let B=f.formMeta,M=g;if(B){for(const P of k)B=B.fields[P],M=M[P],D.has(B)||B.validate(M);if(I===y.DiffChange.ADDITION||I===y.DiffChange.ALTERATION){const P=B.fields[v];if(!D.has(P)&&(B.fields[v].validate(_[v]),I===y.DiffChange.ADDITION&&P.fields))for(const[F,L]of Object.entries(P.fields))L.validate(_[v][F])}}}}}return{formValue:g||f.formValue,formMeta:f.formMeta,updateForm:f.updateForm}},[]),[c,l]=H.useReducer(i,{formValue:e,formMeta:n,updateForm:u});function p(f,m,g=!1,S){f?l({path:f,value:m,markAsBlurred:g,newValidators:S}):u()}function u(f,m){if(f||m){s.current&&window.clearTimeout(s.current);const g=window.setTimeout(l,0,{value:f,updateFormOptions:m});s.current=g}else if(!s.current){const g=window.setTimeout(l,0,{});s.current=g}}return H.useEffect(()=>()=>{s.current&&window.clearTimeout(s.current)},[]),c}const Pb=G(N({},z),{focusInputOnClick:w.exports.bool,formMeta:ce(),formControl:ce(),inputRef:_t()}),it=a.forwardRef((e,t)=>{const I=e,{className:n,children:s,focusInputOnClick:o,formControl:i,formMeta:c,inputRef:l,onClick:p}=I,u=q(I,["className","children","focusInputOnClick","formControl","formMeta","inputRef","onClick"]),f=a.useRef(),g=l||(t||f);function S(){g&&g!==t&&g.current&&g.current.focus()}function T(){g&&g!==t&&g.current&&c&&c instanceof Cn&&c.markAsFocused()}function x(){g&&g!==t&&g.current&&c&&c instanceof Cn&&c.markAsBlurred()}const E=K("sps-form-group",(i&&i.isRequired()||c&&c.isRequired())&&"sps-form-group--required",(i&&!i.isValid()||c&&c.isVisibilyInvalid())&&"sps-form-group--error",c&&c.hasPreventativeErrors()&&"sps-form-group--preventative-error",n);function D(v){o&&S(),p&&p(v)}return a.useEffect(()=>{function v(k){k.target.classList.contains("sps-form-control__clear-btn")&&k.preventDefault()}return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]),a.createElement("div",G(N({},u),{className:E,ref:t,tabIndex:-1,onClick:D,onFocus:T,onBlur:x}),s)});Object.assign(it,{spsFormComponentWrapperPropTypes:Pb,displayName:"SpsFormComponentWrapper"});function vc(e){return typeof e=="object"&&e!=null&&e.nodeType===1}function yc(e,t){return(!t||e!=="hidden")&&e!=="visible"&&e!=="clip"}function Jr(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return yc(n.overflowY,t)||yc(n.overflowX,t)||function(s){var o=function(i){if(!i.ownerDocument||!i.ownerDocument.defaultView)return null;try{return i.ownerDocument.defaultView.frameElement}catch{return null}}(s);return!!o&&(o.clientHeight<s.scrollHeight||o.clientWidth<s.scrollWidth)}(e)}return!1}function ps(e,t,n,s,o,i,c,l){return i<e&&c>t||i>e&&c<t?0:i<=e&&l<=n||c>=t&&l>=n?i-e-s:c>t&&l<n||i<e&&l>n?c-t+o:0}function Tc(e,t){var n=window,s=t.scrollMode,o=t.block,i=t.inline,c=t.boundary,l=t.skipOverflowHiddenElements,p=typeof c=="function"?c:function(Ke){return Ke!==c};if(!vc(e))throw new TypeError("Invalid target");for(var u=document.scrollingElement||document.documentElement,f=[],m=e;vc(m)&&p(m);){if((m=m.parentElement)===u){f.push(m);break}m!=null&&m===document.body&&Jr(m)&&!Jr(document.documentElement)||m!=null&&Jr(m,l)&&f.push(m)}for(var g=n.visualViewport?n.visualViewport.width:innerWidth,S=n.visualViewport?n.visualViewport.height:innerHeight,T=window.scrollX||pageXOffset,x=window.scrollY||pageYOffset,E=e.getBoundingClientRect(),D=E.height,I=E.width,v=E.top,k=E.right,_=E.bottom,B=E.left,M=o==="start"||o==="nearest"?v:o==="end"?_:v+D/2,P=i==="center"?B+I/2:i==="end"?k:B,F=[],L=0;L<f.length;L++){var $=f[L],V=$.getBoundingClientRect(),W=V.height,le=V.width,me=V.top,se=V.right,re=V.bottom,oe=V.left;if(s==="if-needed"&&v>=0&&B>=0&&_<=S&&k<=g&&v>=me&&_<=re&&B>=oe&&k<=se)return F;var j=getComputedStyle($),Q=parseInt(j.borderLeftWidth,10),Z=parseInt(j.borderTopWidth,10),ee=parseInt(j.borderRightWidth,10),ae=parseInt(j.borderBottomWidth,10),de=0,Y=0,ge="offsetWidth"in $?$.offsetWidth-$.clientWidth-Q-ee:0,Ie="offsetHeight"in $?$.offsetHeight-$.clientHeight-Z-ae:0;if(u===$)de=o==="start"?M:o==="end"?M-S:o==="nearest"?ps(x,x+S,S,Z,ae,x+M,x+M+D,D):M-S/2,Y=i==="start"?P:i==="center"?P-g/2:i==="end"?P-g:ps(T,T+g,g,Q,ee,T+P,T+P+I,I),de=Math.max(0,de+x),Y=Math.max(0,Y+T);else{de=o==="start"?M-me-Z:o==="end"?M-re+ae+Ie:o==="nearest"?ps(me,re,W,Z,ae+Ie,M,M+D,D):M-(me+W/2)+Ie/2,Y=i==="start"?P-oe-Q:i==="center"?P-(oe+le/2)+ge/2:i==="end"?P-se+ee+ge:ps(oe,se,le,Q,ee+ge,P,P+I,I);var Ce=$.scrollLeft,we=$.scrollTop;M+=we-(de=Math.max(0,Math.min(we+de,$.scrollHeight-W+Ie))),P+=Ce-(Y=Math.max(0,Math.min(Ce+Y,$.scrollWidth-le+ge)))}F.push({el:$,top:de,left:Y})}return F}function wc(e){return e===Object(e)&&Object.keys(e).length!==0}function Ab(e,t){t===void 0&&(t="auto");var n="scrollBehavior"in document.body.style;e.forEach(function(s){var o=s.el,i=s.top,c=s.left;o.scroll&&n?o.scroll({top:i,left:c,behavior:t}):(o.scrollTop=i,o.scrollLeft=c)})}function Fb(e){return e===!1?{block:"end",inline:"nearest"}:wc(e)?e:{block:"start",inline:"nearest"}}function Ec(e,t){var n=!e.ownerDocument.documentElement.contains(e);if(wc(t)&&typeof t.behavior=="function")return t.behavior(n?[]:Tc(e,t));if(!n){var s=Fb(t);return Ab(Tc(e,s),s.behavior)}}var Kb=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",default:Ec});const Vb={alt:"string",size:"SpinnerSize",title:"string"},$b=G(N({},z),{alt:w.exports.string,size:ve(R.SpinnerSize),title:w.exports.string});function us(e){const m=e,{alt:t,className:n,size:s=R.SpinnerSize.MEDIUM,"data-testid":o,title:i,unsafelyReplaceClassName:c}=m,l=q(m,["alt","className","size","data-testid","title","unsafelyReplaceClassName"]),{t:p}=a.useContext(Le),u=t||i||p("design-system:spinner.defaultAltText"),f=K(c||"sps-spinner",`sps-spinner--${s}`,n);return a.createElement("i",N({className:f,"data-testid":o,title:u},l))}Object.assign(us,{props:Vb,propTypes:$b,displayName:"SpsSpinner"});const Hb=60;function ms(e){return typeof e=="undefined"?"inherit":`${e}px`}function Cc(e){switch(e){case R.Position.TOP_LEFT:return R.Position.BOTTOM_LEFT;case R.Position.TOP_MIDDLE:return R.Position.BOTTOM_MIDDLE;case R.Position.TOP_RIGHT:return R.Position.BOTTOM_RIGHT;case R.Position.RIGHT_TOP:return R.Position.LEFT_TOP;case R.Position.RIGHT_MIDDLE:return R.Position.LEFT_MIDDLE;case R.Position.RIGHT_BOTTOM:return R.Position.LEFT_BOTTOM;case R.Position.BOTTOM_RIGHT:return R.Position.TOP_RIGHT;case R.Position.BOTTOM_MIDDLE:return R.Position.TOP_MIDDLE;case R.Position.BOTTOM_LEFT:return R.Position.TOP_LEFT;case R.Position.LEFT_BOTTOM:return R.Position.RIGHT_BOTTOM;case R.Position.LEFT_MIDDLE:return R.Position.RIGHT_MIDDLE;case R.Position.LEFT_TOP:return R.Position.RIGHT_TOP}}function Wb(e,t,n,s,o,i,c,l){const p=c&&c.current,u=p?p.scrollTop:window.pageYOffset,f=l?0:u,m=p?p.scrollLeft:window.pageXOffset,g=l?0:m,[S,T]=e.split(" ");let x,E,D,I;switch(S){case"top":D=t.height-n.top-f-i[0];break;case"left":E=t.width-n.left-g-i[0];break;case"right":I=n.right+g-i[0];break;case"bottom":x=n.bottom+f-i[0];break;default:throw new Error(`Invalid position ${e}`)}switch(T){case"left":I=n.left+g+i[1];break;case"top":x=n.top+f+i[1];break;case"middle":S==="top"||S==="bottom"?I=n.left+g+n.width/2-o/2+i[1]:(S==="left"||S==="right")&&(x=n.top+f+n.height/2-s.height/2+i[1]);break;case"bottom":D=t.height-n.bottom-f+i[1];break;case"right":E=t.width-n.right-g+i[1];break;default:throw new Error(`Invalid position ${e}`)}return[x,E,D,I]}function xn(e,t,n,{altPosition:s,setMinWidth:o=!1,setWidth:i=!1,parentElementRef:c,fixed:l=!1,offsets:p=[0,0]}){if(e.current&&t.current){const u=Math.max(document.documentElement.clientHeight,window.innerHeight||0),f=document.documentElement.getBoundingClientRect().width,m=c&&c.current?c.current:document.documentElement,g=l?{width:f,height:u,top:0,left:0,bottom:u,right:f}:m.getBoundingClientRect(),S=e.current.getBoundingClientRect(),T=t.current.getBoundingClientRect(),[x]=n.split(" ");let E=n;s&&(x==="top"&&T.top-S.height<Hb||x==="right"&&T.right+S.width>f||x==="bottom"&&T.bottom+S.height>u||x==="left"&&T.left-S.width<0)&&(E=s);const D=o?Math.max(T.width,S.width):S.width,I=i?T.width:D,[v,k,_,B]=Wb(E,g,T,S,I,p,c,l),M={top:ms(v),right:ms(k),bottom:ms(_),left:ms(B)};return l&&(M.position="fixed",M.zIndex=R.ZStratum.BAR),o&&(M.minWidth=`${T.width}px`),i&&(M.width=`${T.width}px`),[M,E===s]}return[{},!1]}const wt=H.createContext(null);function zn(e,t=[]){const n=H.useContext(wt);return H.useMemo(()=>s=>{const i=n&&n.parentElementRef&&n.parentElementRef.current||document.body;let c,l=i.lastElementChild;for(;l!==i.firstElementChild;){if(l.hasAttribute("data-portalid")&&l.getAttribute("data-portalid")===e){c=l;break}l=l.previousElementSibling}if(c)i.contains(c)||i.appendChild(c);else{c=document.createElement("div"),c.setAttribute("data-portalid",e);for(const p of t)c.classList.add(p);i.appendChild(c)}return Hr.createPortal(s,c)},[n])}const Gb={docs:{options:"Eventually<any[]> | (filter?: string) => Eventually<any[]>",captionKey:"string",disabledOptions:"any[]",comparisonKey:"string",tall:"boolean",textKey:"string",valueKey:"string",zeroState:"string",maxHeightPx:"number",maxHeightRem:"number",disableOptionsMemoization:"boolean",onSpecialActionSelect:"() => void"},propTypes:{captionKey:w.exports.string,comparisonKey:w.exports.string,disabledOptions:w.exports.arrayOf(w.exports.any),options:w.exports.oneOfType([w.exports.array,w.exports.instanceOf(Promise),te()]).isRequired,tall:w.exports.bool,textKey:w.exports.string,valueKey:w.exports.string,zeroState:w.exports.string,maxHeightPx:w.exports.number,maxHeightRem:w.exports.number}},Ub={hideInlineSearch:w.exports.bool,onSearchChange:te(),search:w.exports.string,searchDebounce:w.exports.number,searchPlaceholder:w.exports.string,searchInputRef:_t(),onSpecialActionSelect:te()},Yb=G(N(N(N({},z),Gb.propTypes),Ub),{attachTo:_t().isRequired,conformWidth:w.exports.bool,id:w.exports.string.isRequired,isOpen:w.exports.bool,keepOpen:w.exports.bool,keyDown:ce(),nullOption:w.exports.string,offsets:w.exports.arrayOf(w.exports.number),onOptionListChanged:te(),onOptionSelected:te(),onPositionFlip:te(),onSelfToggle:te(),optionRole:w.exports.string,positionOverride:w.exports.arrayOf(ve(R.Position)),selectedOption:w.exports.any,specialAction:te(),ignoreWidthStyles:w.exports.bool,loading:w.exports.bool,filterByTextAndCaptionKey:w.exports.bool,disableOptionsMemoization:w.exports.bool});async function xc(e,t,n,s,o,i){const c=typeof e.options=="function"?e.options(t.value):e.options||[],l=c instanceof Promise,p=m=>m.replace(/([.?*+^$[\]\\(){}|-])/g,"");n({pending:l}),i.current=l?c:null;const u=l?await c||[]:c||[];if(l&&i.current!==c)return;let f=Array.from(u).filter(Boolean).map(m=>new R.SpsOptionListOption(m,typeof m=="function"?{textKey:"label",captionKey:"caption"}:{textKey:e.textKey,captionKey:e.captionKey}));if(e.nullOption&&f.unshift(new R.SpsOptionListOption(null,{text:e.nullOption})),t.value){const m=p(t.value);n({replacementPattern:new RegExp(m,"ig")}),f=f.filter(g=>{const S=new RegExp(m,"i"),T=p(g.text);return e.filterByTextAndCaptionKey?S.test(T)||S.test(p(g.caption)):S.test(T)})}else n({replacementPattern:null});if(e.disabledOptions)for(const m of f)e.disabledOptions.includes(m.value)&&(m.disabled=!0);s(Object.freeze(f)),e.onOptionListChanged&&e.onOptionListChanged(f.length),o(f.some(m=>m.value&&!!m.value.icon)),n({pending:!1})}function zb(e,t,n){const[s,o]=a.useState(Object.freeze([])),[i,c]=a.useState(!1),l=a.useRef(null),p=a.useRef(e.options);(typeof e.options!="function"||e.disableOptionsMemoization)&&(p.current=e.options);const u=a.useMemo(()=>typeof p.current=="function"?y.debounce(xc,typeof e.searchDebounce!="undefined"?e.searchDebounce:500):xc,[p.current,e.disabledOptions]);return a.useEffect(()=>{u(e,t,n,o,c,l)},[p.current,t.value,e.disabledOptions]),[s,i]}class on{constructor(t,n){this.target=t,this.isPgStoppedInternal=!1,this.currentTarget=t,this.nativeEvent=new CustomEvent("change",n),Object.defineProperty(this.nativeEvent,"target",{value:t,writable:!1,configurable:!1,enumerable:!0})}get bubbles(){return this.nativeEvent.bubbles}get cancelable(){return this.nativeEvent.cancelable}get defaultPrevented(){return this.nativeEvent.defaultPrevented}get eventPhase(){return this.nativeEvent.eventPhase}get isTrusted(){return this.nativeEvent.isTrusted}get timeStamp(){return this.nativeEvent.timeStamp}get type(){return this.nativeEvent.type}preventDefault(){this.nativeEvent.preventDefault()}isDefaultPrevented(){return this.defaultPrevented}stopPropagation(){this.nativeEvent.stopPropagation(),this.isPgStoppedInternal=!0}isPropagationStopped(){return this.isPgStoppedInternal}persist(){throw new Error("This is not a real React ChangeEvent. React does not permit the creation of SyntheticEvents in userland.")}}function jb(e,t){return N(N({},e),t)}function Vt(e){return H.useReducer(jb,e)}function qb({hideInlineSearch:e,options:t,onSearchChange:n,search:s="",searchPlaceholder:o="Search\u2026",searchInputRef:i}){const[c,l]=Vt({isAsync:typeof t=="function",pending:!1,value:s,replacementPattern:null}),p=a.useCallback(S=>{l({value:S.target.value}),n&&n(S)},[n]),u=a.useCallback(S=>{S.nativeEvent.stopImmediatePropagation(),S.stopPropagation()},[]),f=a.useCallback(S=>{S.nativeEvent.stopImmediatePropagation(),l({value:""}),n&&n(new on(i.current)),i.current&&i.current.focus()},[n]),m=S=>{!S||["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"].includes(S.key)||S.stopPropagation()};return a.useEffect(()=>{l({value:s})},[s]),[c.isAsync&&!e&&a.createElement("div",{className:"sps-option-list__search sps-form-group sps-text-input"},a.createElement("div",{className:"sps-form-control"},!c.value&&a.createElement("i",{className:"sps-icon sps-icon-filter sps-text-input__icon"}),a.createElement("input",{type:"text",className:"sps-text-input__input",placeholder:o,ref:i,value:c.value,onChange:p,onClick:u,onKeyDown:m}),c.value&&a.createElement("i",{className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:f}))),c,l]}const Jb=Ec||Kb,Zb=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"],Xb=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function Qb(e,t,n){return n?(e&&e[n])===(t&&t[n]):e===t}function Dc(e,t,n){return typeof n.value=="function"&&n.disabled?!0:t?!!(e==null?void 0:e.find(s=>{var o;return s[t]&&s[t]===((o=n==null?void 0:n.value)==null?void 0:o[t])})):!1}const ya=a.forwardRef((e,t)=>{const An=e,{captionKey:n,comparisonKey:s,disabledOptions:o,options:i,tall:c,textKey:l,valueKey:p,zeroState:u,hideInlineSearch:f,onSearchChange:m,search:g,searchDebounce:S,searchPlaceholder:T,onSpecialActionSelect:x,attachTo:E,className:D,conformWidth:I,id:v,ignoreWidthStyles:k,isOpen:_,keepOpen:B,keyDown:M,nullOption:P,onOptionListChanged:F,onOptionSelected:L,onPositionFlip:$,onSelfToggle:V,optionRole:W,positionOverride:le,selectedOption:me,specialAction:se,unsafelyReplaceClassName:re,loading:oe,filterByTextAndCaptionKey:j,maxHeightPx:Q,maxHeightRem:Z,disableOptionsMemoization:ee,"data-testid":ae}=An,de=q(An,["captionKey","comparisonKey","disabledOptions","options","tall","textKey","valueKey","zeroState","hideInlineSearch","onSearchChange","search","searchDebounce","searchPlaceholder","onSpecialActionSelect","attachTo","className","conformWidth","id","ignoreWidthStyles","isOpen","keepOpen","keyDown","nullOption","onOptionListChanged","onOptionSelected","onPositionFlip","onSelfToggle","optionRole","positionOverride","selectedOption","specialAction","unsafelyReplaceClassName","loading","filterByTextAndCaptionKey","maxHeightPx","maxHeightRem","disableOptionsMemoization","data-testid"]),Y=a.useMemo(()=>se?new R.SpsOptionListOption(se,{textKey:"label",captionKey:"caption"}):null,[se]),[ge,Ie]=a.useState(-1),[Ce,we]=a.useState(_),Ke=t||a.useRef(null),$e=a.useRef(null),je=a.useRef(null),et=zn("sps-option-list-portal"),qe=a.useContext(wt),[ut,ct]=le||[R.Position.BOTTOM_LEFT,R.Position.TOP_LEFT],[[vt,Ee],We]=a.useState([{},!1]),Ye=a.useRef(null),[Ve,be,He]=qb(G(N({},e),{searchInputRef:Ye})),[Oe,Ge]=zb(e,be,He);a.useEffect(()=>{We(Ce?xn(Ke,E,ut,N({altPosition:ct,setMinWidth:!k,setWidth:!k&&I},qe)):[{},!1])},[Ce,ut,ct,Oe]),a.useEffect(()=>{const ye=()=>{Ce&&We(xn(Ke,E,ut,N({altPosition:ct,setMinWidth:!k,setWidth:!k&&I},qe)))};return document.addEventListener("scroll",ye),()=>{document.removeEventListener("scroll",ye)}},[Ce]),a.useEffect(()=>{Ie(-1)},[be]);const Tr=K(re||"sps-option-list","z-stratum-dropdown",Ce&&"sps-option-list--open",be.isAsync&&"sps-option-list--searchable",Ee&&"sps-option-list--opens-upward",se&&se.label&&"sps-option-list--has-special-action",D),Bn=K(re||"sps-option-list__options",c&&"sps-option-list__options--tall"),tt=a.useCallback(()=>{Ce||(we(!0),Ye.current&&Ye.current.focus(),Ie(-1),V&&V(!0))},[Ce,V]),Te=a.useCallback(()=>{Ce&&(we(!1),Ie(-1),V&&V(!1))},[Ce,V]),yt=a.useCallback((ye,pe)=>{pe||ye&&!ye.disabled&&(typeof ye.value=="function"?(ye.value(),x&&x()):typeof L=="function"&&L(ye.value),B||Te())},[L,Te]),gn=a.useCallback((ye,pe,ot)=>{ye.stopPropagation(),yt(pe,ot)},[yt]),Pn=a.useRef(o||[]);Pn.current=o||[];const wr=a.useCallback(ye=>{switch(ye.key){case"Tab":case"Escape":Te();break;case"Enter":if(ge>-1){const pe=Oe[ge]||Y;ye.preventDefault();const ot=!!pe&&Dc(Pn.current,s,pe);!ot&&pe&&typeof L=="function"&&typeof pe.value=="function"?pe.value():pe&&yt(pe,ot)}break;case"Up":case"ArrowUp":{let pe=ge;Ee?ge<=-1?pe=Oe.length-1:ge===0?se&&(pe=Oe.length):ge<Oe.length&&(pe=ge-1):ge>-1&&(pe=ge-1),pe!==ge&&(ye.preventDefault(),Ie(pe));break}case"Down":case"ArrowDown":{tt();let pe=ge;Ee?ge!==-1&&(ge>=Oe.length?pe=0:ge===Oe.length-1?pe=-1:pe=ge+1):ge<Oe.length-1+Number(!!se)&&(pe=ge+1),pe!==ge&&(ye.preventDefault(),Ie(pe));break}default:tt()}},[Te,tt,ge,yt,L,Ee,Oe]),Er=a.useCallback(ye=>{const pe=Oe.findIndex(ot=>{if(ot.textKey){const Sn=ot.textKey;return ot.value[Sn].toLowerCase().charAt([0])===ye.key.toLocaleLowerCase()}return ot.value.toString().toLowerCase().charAt([0])===ye.key.toLocaleLowerCase()});pe>-1&&Ie(pe)},[Oe]),$a=a.useCallback(ye=>{!ye||(Zb.includes(ye.key)?wr(ye):Xb.includes(ye.key)&&Er(ye))},[Te,tt,ge,yt,L,Ee,Oe]);a.useEffect(()=>{if(qe!==null&&document.getElementsByClassName("sps-modal__body").length>0){const ye=()=>{V(!1)},pe=document.getElementsByClassName("sps-modal__body")[0];return pe.addEventListener("scroll",ye),()=>{pe.removeEventListener("scroll",ye)}}},[]),a.useEffect(()=>{je.current&&Jb(je.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[ge]),a.useEffect(()=>{we(_),_?Ye.current&&Ye.current.focus():Ie(-1)},[_]),a.useEffect(()=>{$a(M)},[M]),a.useEffect(()=>{!Ce&&$e.current&&(He({value:""}),$e.current.scrollTop=0),Ce&&$&&$(Ee)},[Ce]);const at=Q?Q/16:Z,Ha=at?{maxHeight:`${at}rem`}:{};return et(a.createElement("div",N({className:Tr,id:v,"aria-activedescendant":ge>-1?`${v}-option-${ge}`:null,tabIndex:-1,ref:Ke,style:vt,onMouseLeave:()=>Ie(-1),"data-testid":ae},de),Ve,a.createElement("div",{className:Bn,ref:$e,"data-testid":`${ae}-options`,style:Ha},!oe&&!be.pending&&u&&Oe.length===0&&a.createElement("div",{className:"sps-option-list__zero-state"},u),(oe||be.pending)&&a.createElement("div",{className:"sps-option-list__loading"},a.createElement(us,null)),!oe&&!be.pending&&Oe.map((ye,pe)=>{const ot=`${v}-option-${pe}`,Sn=Qb(ye.value,me,s),bn=Dc(Pn.current,s,ye);return a.createElement("a",{key:ot,id:ot,role:W,"aria-selected":Sn,href:ye.href,className:K("sps-option-list__option",ye.caption&&"sps-option-list__option--has-caption",ye.disabled&&"sps-option-list__option--disabled",ye.bold&&"sps-option-list__option--bold",(Sn||bn)&&"sps-option-list__option--selected",ge===pe&&"sps-option-list__option--highlighted"),onClick:ia=>gn(ia,ye,bn),onMouseOver:()=>Ie(pe),tabIndex:-1,ref:ge===pe?je:null,"data-testid":`${ae}-option-${pe}`},ye.value&&ye.value.icon&&a.createElement("i",{className:K("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ye.value.icon)}`)}),(!ye.value||!ye.value.icon&&Ge)&&a.createElement("span",{className:"sps-option-list__option-icon-spacer"}),a.createElement("span",{dangerouslySetInnerHTML:{__html:ye.getHtml(be.replacementPattern)}}),ye.caption&&a.createElement("div",{className:"sps-option-list__option-caption"},a.createElement("span",{dangerouslySetInnerHTML:{__html:ye.caption.replace(be.replacementPattern,"<u>$&</u>")}})))})),Y&&se.label&&a.createElement("a",{className:K("sps-option-list__option","sps-option-list__special-action",ge===Oe.length&&"sps-option-list__option--highlighted",se.disabled&&"sps-option-list__special-action--disabled"),href:Y.href,target:Y.href&&se.newTab?"_blank":"_self",onClick:ye=>gn(ye,Y),onMouseOver:()=>Ie(Oe.length),"data-testid":`${ae}-special-action`},se.icon&&a.createElement("i",{className:K("sps-icon","sps-option-list__option-icon",`sps-icon-${String(se.icon)}`)}),!se.icon&&Ge&&a.createElement("span",{className:"sps-option-list__option-icon-spacer"}),a.createElement("span",null,se.label))))});Object.assign(ya,{propTypes:Yb,displayName:"SpsOptionList"});function ev(e,t,n=[]){return a.useMemo(()=>o=>a.createElement(e,N({},N(N({},o),t)),o.children),n)}const Ic=function({children:e,elements:t}){if(t.length===0)return a.createElement(a.Fragment,null,e);const[n,s]=Array.isArray(t[0])?t[0]:[t[0]];return a.createElement(n,N({},s!=null?s:{}),a.createElement(Ic,{elements:t.slice(1)},e))},Nc=function(s){var o=s,{children:e,providers:t=[]}=o,n=q(o,["children","providers"]);return a.createElement("div",N({},n),a.createElement(Ic,{elements:t},e))},tv=function(s){var o=s,{children:e,className:t}=o,n=q(o,["children","className"]);return a.createElement(Nc,N({className:`sps-app ${t}`},n),e)};function Et(e=[],t=[]){const n=Array.isArray(e)?y.flatten(e):[e],s=t.map(i=>Array.isArray(i)?i:[i]),o=new Array(s.length+1).fill(null).map(()=>[]);for(const i of n){let c=!1;for(let l=0;l<s.length;l+=1)for(const{type:p,props:u={}}of s[l])if(i.type===p&&Object.keys(u).every(m=>u[m]===i.props[m])){c=!0,o[l].push(i);break}c||o[o.length-1].push(i)}return o}function kc(e,t,n){const s=Object.entries(t).filter(([,i])=>typeof i!="string"&&i.deprecated).map(([i])=>i),o=s.map(i=>n[i]);a.useEffect(()=>{o.find(i=>typeof i!="undefined")&&console.warn(`The following prop(s) of ${e} are deprecated: ${s.join(", ")}`)},o)}function Zr(e,t){const n=H.useRef(!1);H.useEffect(()=>{if(n.current)return e();n.current=!0},t)}function Mc(e,t,n){const s=a.useRef(t(...n));a.useEffect(()=>(document.addEventListener(e,s.current),()=>document.removeEventListener(e,s.current)),[]),a.useEffect(()=>{document.removeEventListener(e,s.current),s.current=t(...n),document.addEventListener(e,s.current)},n)}function nv(e,t,n){return function(o){var i,c;!((i=e.current)==null?void 0:i.contains(o.target))&&!((c=t.current)==null?void 0:c.contains(o.target))&&n()}}function Ta(e,t,n){const s=a.useRef(!1),[o,i]=a.useState(!1),c=a.useCallback(()=>{s.current?s.current=!1:i(!0)},[]),l=a.useCallback((p=!1)=>{i(!1),s.current=p,n&&n()},[]);return Mc("mousedown",nv,[e,t,l]),{showPopup:o,doShowPopup:c,doHidePopup:l}}const av={debounce:"number",disabled:"boolean",formMeta:"SpsFormFieldMeta<string>",icon:"SpsIcon",onChange:"React.ChangeEventHandler",placeholder:"string",suggestions:{type:`
196
+ `}}}};let Xt=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");function wn(e){return H.useRef(e||Xt())}function Tt(e,t){const n=wn(e),s=H.useRef(`${n.current}_ctrl`);return H.useEffect(()=>{t&&(t.id=s.current,t.update())},[t]),{wrapperId:n.current,controlId:s.current}}var mb="[object Object]";function fb(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function hb(e,t){return function(n){return e(t(n))}}var gb=Function.prototype,lc=Object.prototype,cc=gb.toString,Sb=lc.hasOwnProperty,bb=cc.call(Object),vb=lc.toString,yb=hb(Object.getPrototypeOf,Object);function Tb(e){return!!e&&typeof e=="object"}function wb(e){if(!Tb(e)||vb.call(e)!=mb||fb(e))return!1;var t=yb(e);if(t===null)return!0;var n=Sb.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&cc.call(n)==bb}var dc=wb;const Lt=new Set,Un=new Set,Qt=new Set,Sa=new Set;function pc(e){Lt.has(e)||Qt.has(e)||Sa.has(e)||Un.add(e)}function uc(e){Lt.has(e)||Qt.has(e)||Un.has(e)||Sa.add(e)}const Yr=Gn.default||Gn,os="MM/DD/YYYY",Eb=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,mc=Symbol("Date Parse Error");function Yn(e){return e.year*1e4+e.month*100+e.date}const he=Object.freeze({createFrom(e){if(!e)return null;if(typeof e=="string"){const t=Eb.exec(e);if(t){const[,n,s,o]=t;return Object.freeze({year:Number(o),month:Number(n),date:Number(s)})}return Object.freeze({[mc]:!0,year:void 0,month:void 0,date:void 0})}return Object.freeze({year:e.year(),month:e.month()+1,date:e.date()})},createRangeFrom(e){return e?e.split(/[^\d]*-[^\d]*/).map(he.createFrom):null},isValid(e){return e&&typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&he.toMoment(e).isValid()},nullifyInvalidDate(e){return he.isValid(e)?e:null},toMoment(e){return e?Yr(G(N({},e),{month:e.month-1})):null},toString(e){const t=he.toMoment(e);return t?t.format(os):""},toStringRange(e){return e?e.map(he.toString).join("-"):""},create(){const e=new Date;return Object.freeze({year:e.getFullYear(),month:e.getMonth()+1,date:e.getDate()})},isSameDate(e,t){return e&&t&&e.year===t.year&&e.month===t.month&&e.date===t.date},isSameMonth(e,t){return e&&t&&e.year===t.year&&e.month===t.month},isAfter(e,t){return!e||!t?null:Yn(e)>Yn(t)},isBefore(e,t){return!e||!t?null:Yn(e)<Yn(t)},isInRange(e,t,n=!0){if(!e||!t||!t[0]||!t[1])return null;const s=Yn(e),[o,i]=t.map(Yn);return e&&o&&i&&(n&&s>=o&&s<=i||!n&&s>o&&s<i)},prevMonth(e){return Object.freeze({year:e.month===1?e.year-1:e.year,month:e.month-1||12,date:e.date})},nextMonth(e){return Object.freeze({year:e.month===12?e.year+1:e.year,month:e.month+1>12?1:e.month+1,date:e.date})},createRangeFromPreset(e){if(typeof e.definition=="function")return e.definition();const t=Yr(),n=t.clone().subtract(Yr.duration(e.definition));return[he.createFrom(n),he.createFrom(t)]}}),ba=function(t){if(Array.isArray(t)){const n=ba(t[0]),s=ba(t[1]);return n||s}if(t&&t.hasOwnProperty("year")){if(t[mc])return{dateFormat:os};if(!he.isValid(t))return{dateValidity:!0}}return null};Lt.add("dateFormat");Lt.add("dateValidity");const fc=function(t){if(Array.isArray(t)){const n=ba(t);if(n)return n;if(t&&he.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};Lt.add("dateRangeOrder");const hc=function({minDate:t,maxDate:n}){function s(o){const i=he.isBefore(o,t),c=he.isAfter(o,n),l={minExceeded:i?he.toString(t):null,maxExceeded:c?he.toString(n):null};return i||c?{dateConstraint:l}:null}return function(i){if(!i)return null;if(Array.isArray(i)){const c=s(i[0]),l=s(i[1]);return c||l}return i.hasOwnProperty("year")?s(i):null}};Lt.add("dateConstraint");var Cb=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",date:ba,dateRange:fc,dateConstraint:hc});function rn(e,t){for(const n of[].concat(e)){const s=t(n);if(s)return s}return null}const xb=function(t){function n(s){return Number(s)>=t?null:{min:t}}return s=>rn(s,n)};Lt.add("min");const Db=function(t){function n(s){return Number(s)<=t?null:{max:t}}return s=>rn(s,n)};Un.add("max");const Ib=function(t){return typeof t=="undefined"||t===null||t===""||Number.isNaN(t)||(t==null?void 0:t.length)===0?{required:!0}:null};Un.add("required");const Nb=function(t){function n(s){return s===void 0||s.toString().length<t?{minLength:t}:null}return s=>rn(s,n)};Lt.add("minLength");const kb=function(t){function n(s){return s===void 0||s.toString().length<=t?null:{maxLength:t}}return s=>rn(s,n)};Qt.add("maxLength");const Mb=function(t){const n=t instanceof RegExp?t:new RegExp(t);function s(o){return n.test(o)?null:{pattern:t}}return o=>rn(o,s)};Lt.add("pattern");const Rb=function(e){function t(n){return/^\p{L}*$/u.test(n)?null:{alpha:!0}}return rn(e,t)};Qt.add("alpha");const _b=function(e){function t(n){return/^[0-9,. ]*$/.test(n)?null:{numeric:!0}}return rn(e,t)};Qt.add("numeric");const Lb=function(e){function t(n){return/^[^0-9]*$/.test(n)?null:{nonNumeric:!0}}return rn(e,t)};Qt.add("nonNumeric");const is=Object.freeze(G(N({},Cb),{min:xb,max:Db,required:Ib,minLength:Nb,maxLength:kb,pattern:Mb,alpha:Rb,numeric:_b,nonNumeric:Lb,OnBlurErrorKeys:Lt}));function va(e,t=[]){const n=t.reduce((s,o)=>Object.assign(s,o(e)||{}),{});return Object.keys(n).length?n:null}class En{constructor(t,n){this.path=t,this.update=n,this.validators=[],this.errors=null,this.revealAllErrors=!1,this.preventativeErrors=[],this.submitted=!1}setValidators(t){return this.update(this.path,null,null,t),this}validate(t){return this.validators&&this.validators.length>0?(this.errors=va(t,this.validators),this.update(null),this.isFocused()&&this.onFocus&&this.onFocus()):this.errors&&(this.errors=null,this.update(null)),this}isValid(){return!this.errors||this.isPristine()}hasErrors(){return!!this.errors}isVisibilyInvalid(){return this.errors&&(this.revealAllErrors&&!Object.keys(this.errors).some(t=>Sa.has(t))||this.revealAllErrors&&Object.keys(this.errors).some(t=>Sa.has(t))&&this.isSubmitted()||!this.isPristine()&&Object.keys(this.errors).some(t=>Un.has(t)))}hasError(t){return this.errors&&Object.prototype.hasOwnProperty.call(this.errors,t)}hasPreventativeError(t){return this.preventativeErrors.includes(t)}hasPreventativeErrors(){return this.preventativeErrors.length>0}isRequired(){return this.validators&&this.validators.indexOf(is.required)>-1}isSubmitted(){return this.submitted}onFocus(){}onBlur(){}}class Cn extends En{constructor(){super(...arguments);this.id=Xt(),this.focused=!1,this.pristine=!0}setValue(t){if(this.revealAllErrors=!1,this.preventativeErrors=[],this.validators&&this.validators.length>0){const n=va(t,this.validators);if(n&&Object.keys(n).filter(o=>Qt.has(o)).length>0){this.preventativeErrors=Object.keys(n);return}}this.update(this.path,t)}isPristine(){return this.pristine}markAsPristine(){return this.pristine=!0,this.revealAllErrors=!1,this.update(null),this}markAsDirty(){return this.pristine=!1,this.update(null),this}isFocused(){return this.focused}markAsFocused(){return this.focused=!0,this.update(null),this.onFocus&&this.onFocus(),this}markAsBlurred(){return this.update(this.path,null,!0),this.onBlur&&this.onBlur(),this.preventativeErrors=[],this}markAsSubmitted(){return this.submitted=!0,this.update(null),this}}class ls extends Cn{constructor(t,n,s){const o=s?n:t,i=s||n;super(o,i);s&&this.inferMembers(t)}inferSpsControl(t,n){return cs(t,[...this.path,n],this.update)}rollup(t){return Object.keys(this.fields).reduce((n,s)=>n&&(!this.fields[s][t]||this.fields[s][t]()),!0)}isFocused(){return super.isFocused()||this.rollup("isFocused")}isValid(){return super.isValid()&&this.rollup("isValid")}hasErrors(){return super.hasErrors()||Object.keys(this.fields).some(t=>this.fields[t].hasErrors())}contentsAreValid(){return this.rollup("isValid")&&this.rollup("contentsAreValid")}isPristine(){return super.isPristine()&&this.rollup("isPristine")}markAsPristine(){super.markAsPristine();for(const t of Object.keys(this.fields))this.fields[t].markAsPristine();return this}markAsDirty(){super.markAsDirty();for(const t of Object.keys(this.fields))this.fields[t].markAsDirty();return this}markAsBlurred(){super.markAsBlurred();for(const t of Object.keys(this.fields))this.fields[t].markAsBlurred();return this}markAsSubmitted(){super.markAsSubmitted();for(const t of Object.keys(this.fields))this.fields[t].markAsSubmitted();return this}}class gc extends ls{inferMembers(t){this.fields={};for(const n of Object.keys(t))this.fields[n]=this.inferSpsControl(t[n],n)}}class Sc extends ls{inferMembers(t){this.fields=t.map((n,s)=>this.inferSpsControl(n,String(s)))}}function cs(e,t,n){return e instanceof En?(e.path=t,e.update=n,e):Array.isArray(e)?new Sc(e,t,n):dc(e)?new gc(e,t,n):new Cn(t,n)}function zr(e,t){return t.length===0||!e?e:zr(e.fields[t[0]],t.slice(1,t.length))}function jr(e,t){if(t.length===0||!e)return[e];const n=t[0];if(t=t.slice(1,t.length),n==="*"){const s=Array.isArray(e.fields)?e.fields:Object.keys(e.fields).map(o=>e.fields[o]);return t.length===0?s:s.reduce((o,i)=>[...o,...jr(i,t)],[])}return jr(e.fields[n],t)}function bc(e,t,n){for(const s of Object.keys(t)){const o=t[s];for(const i of jr(e,s.split(".")))i&&o&&n(i,o)}}function ds(e,t,n,s=!1){bc(t,n,(o,i)=>{o.validators=typeof i=="function"?i(e):i,s&&(o.errors=va(y.getPath(e,o.path),o.validators))})}function qr(e,t){const n=t[0];return t=t.slice(1),Array.isArray(e)?e.map((s,o)=>o===Number(n)?qr(s,t):s):dc(e)?Object.keys(e).reduce((s,o)=>Object.assign(s,{[o]:o===n?qr(e[o],t):e[o]}),{}):e}function Ob(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function Bb(e,t={}){Ob(e);const n=H.useMemo(()=>{y.deepFreeze(e);const f=cs(e,[],p);return t&&ds(e,f,t,!0),f},[]),s=H.useRef(),o=H.useRef(t),i=H.useCallback((f,m)=>{var S,T,x;let g;if(s.current=null,m)if(m.path)if(m.markAsBlurred){const E=zr(f.formMeta,m.path);E&&(E.focused=!1,E.revealAllErrors=!0)}else if(m.newValidators){if(o.current){const E=m.path.join(".");o.current=G(N({},o.current),{[E]:m.newValidators}),ds(f.formValue,f.formMeta,o.current,!0)}}else g=qr(f.formValue,m.path),y.setPath(g,m.path,m.value);else g=m.value;if(((S=m.updateFormOptions)==null?void 0:S.validators)&&(o.current=N(N({},o.current),m.updateFormOptions.validators),ds(f.formValue,f.formMeta,o.current,(x=(T=m.updateFormOptions)==null?void 0:T.runValidators)!=null?x:!0)),g){y.deepFreeze(g);const E=y.diff(f.formValue,g);for(const{type:D,key:I,parentPath:v,objects:[k,_]}of E){const B=zr(f.formMeta,v);if(typeof I!="symbol"&&B)switch(D){case y.DiffChange.ADDITION:B.fields[I]=cs(_[I],[...v,I],p);break;case y.DiffChange.DELETION:Array.isArray(B.fields)?B.fields.splice(Number(I),1):delete B.fields[I];break;case y.DiffChange.ALTERATION:if(!k[I]&&_[I]&&!(B.fields[I]instanceof ls)){const M=cs(_[I],[...v,I],p);M instanceof Cn&&B.fields[I]instanceof Cn&&(M.id=B.fields[I].id,M.focused=B.fields[I].focused,M.pristine=B.fields[I].pristine),B.fields[I]=M}break}}if(o.current){ds(g,f.formMeta,o.current);const D=new Set;bc(f.formMeta,t,(I,v)=>{typeof v=="function"&&(I.validate(y.getPath(g,I.path)),D.add(I))});for(const{type:I,key:v,parentPath:k,objects:[,_]}of E)if(typeof v!="symbol"){let B=f.formMeta,M=g;if(B){for(const P of k)B=B.fields[P],M=M[P],D.has(B)||B.validate(M);if(I===y.DiffChange.ADDITION||I===y.DiffChange.ALTERATION){const P=B.fields[v];if(!D.has(P)&&(B.fields[v].validate(_[v]),I===y.DiffChange.ADDITION&&P.fields))for(const[F,L]of Object.entries(P.fields))L.validate(_[v][F])}}}}}return{formValue:g||f.formValue,formMeta:f.formMeta,updateForm:f.updateForm}},[]),[c,l]=H.useReducer(i,{formValue:e,formMeta:n,updateForm:u});function p(f,m,g=!1,S){f?l({path:f,value:m,markAsBlurred:g,newValidators:S}):u()}function u(f,m){if(f||m){s.current&&window.clearTimeout(s.current);const g=window.setTimeout(l,0,{value:f,updateFormOptions:m});s.current=g}else if(!s.current){const g=window.setTimeout(l,0,{});s.current=g}}return H.useEffect(()=>()=>{s.current&&window.clearTimeout(s.current)},[]),c}const Pb=G(N({},z),{focusInputOnClick:w.exports.bool,formMeta:ce(),formControl:ce(),inputRef:_t()}),it=a.forwardRef((e,t)=>{const I=e,{className:n,children:s,focusInputOnClick:o,formControl:i,formMeta:c,inputRef:l,onClick:p}=I,u=q(I,["className","children","focusInputOnClick","formControl","formMeta","inputRef","onClick"]),f=a.useRef(),g=l||(t||f);function S(){g&&g!==t&&g.current&&g.current.focus()}function T(){g&&g!==t&&g.current&&c&&c instanceof Cn&&c.markAsFocused()}function x(){g&&g!==t&&g.current&&c&&c instanceof Cn&&c.markAsBlurred()}const E=K("sps-form-group",(i&&i.isRequired()||c&&c.isRequired())&&"sps-form-group--required",(i&&!i.isValid()||c&&c.isVisibilyInvalid())&&"sps-form-group--error",c&&c.hasPreventativeErrors()&&"sps-form-group--preventative-error",n);function D(v){o&&S(),p&&p(v)}return a.useEffect(()=>{function v(k){k.target.classList.contains("sps-form-control__clear-btn")&&k.preventDefault()}return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]),a.createElement("div",G(N({},u),{className:E,ref:t,tabIndex:-1,onClick:D,onFocus:T,onBlur:x}),s)});Object.assign(it,{spsFormComponentWrapperPropTypes:Pb,displayName:"SpsFormComponentWrapper"});function vc(e){return typeof e=="object"&&e!=null&&e.nodeType===1}function yc(e,t){return(!t||e!=="hidden")&&e!=="visible"&&e!=="clip"}function Jr(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return yc(n.overflowY,t)||yc(n.overflowX,t)||function(s){var o=function(i){if(!i.ownerDocument||!i.ownerDocument.defaultView)return null;try{return i.ownerDocument.defaultView.frameElement}catch{return null}}(s);return!!o&&(o.clientHeight<s.scrollHeight||o.clientWidth<s.scrollWidth)}(e)}return!1}function ps(e,t,n,s,o,i,c,l){return i<e&&c>t||i>e&&c<t?0:i<=e&&l<=n||c>=t&&l>=n?i-e-s:c>t&&l<n||i<e&&l>n?c-t+o:0}function Tc(e,t){var n=window,s=t.scrollMode,o=t.block,i=t.inline,c=t.boundary,l=t.skipOverflowHiddenElements,p=typeof c=="function"?c:function(Ke){return Ke!==c};if(!vc(e))throw new TypeError("Invalid target");for(var u=document.scrollingElement||document.documentElement,f=[],m=e;vc(m)&&p(m);){if((m=m.parentElement)===u){f.push(m);break}m!=null&&m===document.body&&Jr(m)&&!Jr(document.documentElement)||m!=null&&Jr(m,l)&&f.push(m)}for(var g=n.visualViewport?n.visualViewport.width:innerWidth,S=n.visualViewport?n.visualViewport.height:innerHeight,T=window.scrollX||pageXOffset,x=window.scrollY||pageYOffset,E=e.getBoundingClientRect(),D=E.height,I=E.width,v=E.top,k=E.right,_=E.bottom,B=E.left,M=o==="start"||o==="nearest"?v:o==="end"?_:v+D/2,P=i==="center"?B+I/2:i==="end"?k:B,F=[],L=0;L<f.length;L++){var $=f[L],V=$.getBoundingClientRect(),W=V.height,le=V.width,me=V.top,se=V.right,re=V.bottom,oe=V.left;if(s==="if-needed"&&v>=0&&B>=0&&_<=S&&k<=g&&v>=me&&_<=re&&B>=oe&&k<=se)return F;var j=getComputedStyle($),Q=parseInt(j.borderLeftWidth,10),Z=parseInt(j.borderTopWidth,10),ee=parseInt(j.borderRightWidth,10),ae=parseInt(j.borderBottomWidth,10),de=0,Y=0,ge="offsetWidth"in $?$.offsetWidth-$.clientWidth-Q-ee:0,Ie="offsetHeight"in $?$.offsetHeight-$.clientHeight-Z-ae:0;if(u===$)de=o==="start"?M:o==="end"?M-S:o==="nearest"?ps(x,x+S,S,Z,ae,x+M,x+M+D,D):M-S/2,Y=i==="start"?P:i==="center"?P-g/2:i==="end"?P-g:ps(T,T+g,g,Q,ee,T+P,T+P+I,I),de=Math.max(0,de+x),Y=Math.max(0,Y+T);else{de=o==="start"?M-me-Z:o==="end"?M-re+ae+Ie:o==="nearest"?ps(me,re,W,Z,ae+Ie,M,M+D,D):M-(me+W/2)+Ie/2,Y=i==="start"?P-oe-Q:i==="center"?P-(oe+le/2)+ge/2:i==="end"?P-se+ee+ge:ps(oe,se,le,Q,ee+ge,P,P+I,I);var Ce=$.scrollLeft,we=$.scrollTop;M+=we-(de=Math.max(0,Math.min(we+de,$.scrollHeight-W+Ie))),P+=Ce-(Y=Math.max(0,Math.min(Ce+Y,$.scrollWidth-le+ge)))}F.push({el:$,top:de,left:Y})}return F}function wc(e){return e===Object(e)&&Object.keys(e).length!==0}function Ab(e,t){t===void 0&&(t="auto");var n="scrollBehavior"in document.body.style;e.forEach(function(s){var o=s.el,i=s.top,c=s.left;o.scroll&&n?o.scroll({top:i,left:c,behavior:t}):(o.scrollTop=i,o.scrollLeft=c)})}function Fb(e){return e===!1?{block:"end",inline:"nearest"}:wc(e)?e:{block:"start",inline:"nearest"}}function Ec(e,t){var n=!e.ownerDocument.documentElement.contains(e);if(wc(t)&&typeof t.behavior=="function")return t.behavior(n?[]:Tc(e,t));if(!n){var s=Fb(t);return Ab(Tc(e,s),s.behavior)}}var Kb=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",default:Ec});const Vb={alt:"string",size:"SpinnerSize",title:"string"},$b=G(N({},z),{alt:w.exports.string,size:ve(R.SpinnerSize),title:w.exports.string});function us(e){const m=e,{alt:t,className:n,size:s=R.SpinnerSize.MEDIUM,"data-testid":o,title:i,unsafelyReplaceClassName:c}=m,l=q(m,["alt","className","size","data-testid","title","unsafelyReplaceClassName"]),{t:p}=a.useContext(Le),u=t||i||p("design-system:spinner.defaultAltText"),f=K(c||"sps-spinner",`sps-spinner--${s}`,n);return a.createElement("i",N({className:f,"data-testid":o,title:u},l))}Object.assign(us,{props:Vb,propTypes:$b,displayName:"SpsSpinner"});const Hb=60;function ms(e){return typeof e=="undefined"?"inherit":`${e}px`}function Cc(e){switch(e){case R.Position.TOP_LEFT:return R.Position.BOTTOM_LEFT;case R.Position.TOP_MIDDLE:return R.Position.BOTTOM_MIDDLE;case R.Position.TOP_RIGHT:return R.Position.BOTTOM_RIGHT;case R.Position.RIGHT_TOP:return R.Position.LEFT_TOP;case R.Position.RIGHT_MIDDLE:return R.Position.LEFT_MIDDLE;case R.Position.RIGHT_BOTTOM:return R.Position.LEFT_BOTTOM;case R.Position.BOTTOM_RIGHT:return R.Position.TOP_RIGHT;case R.Position.BOTTOM_MIDDLE:return R.Position.TOP_MIDDLE;case R.Position.BOTTOM_LEFT:return R.Position.TOP_LEFT;case R.Position.LEFT_BOTTOM:return R.Position.RIGHT_BOTTOM;case R.Position.LEFT_MIDDLE:return R.Position.RIGHT_MIDDLE;case R.Position.LEFT_TOP:return R.Position.RIGHT_TOP}}function Wb(e,t,n,s,o,i,c,l){const p=c&&c.current,u=p?p.scrollTop:window.pageYOffset,f=l?0:u,m=p?p.scrollLeft:window.pageXOffset,g=l?0:m,[S,T]=e.split(" ");let x,E,D,I;switch(S){case"top":D=t.height-n.top-f-i[0];break;case"left":E=t.width-n.left-g-i[0];break;case"right":I=n.right+g-i[0];break;case"bottom":x=n.bottom+f-i[0];break;default:throw new Error(`Invalid position ${e}`)}switch(T){case"left":I=n.left+g+i[1];break;case"top":x=n.top+f+i[1];break;case"middle":S==="top"||S==="bottom"?I=n.left+g+n.width/2-o/2+i[1]:(S==="left"||S==="right")&&(x=n.top+f+n.height/2-s.height/2+i[1]);break;case"bottom":D=t.height-n.bottom-f+i[1];break;case"right":E=t.width-n.right-g+i[1];break;default:throw new Error(`Invalid position ${e}`)}return[x,E,D,I]}function xn(e,t,n,{altPosition:s,setMinWidth:o=!1,setWidth:i=!1,parentElementRef:c,fixed:l=!1,offsets:p=[0,0]}){if(e.current&&t.current){const u=Math.max(document.documentElement.clientHeight,window.innerHeight||0),f=document.documentElement.getBoundingClientRect().width,m=c&&c.current?c.current:document.documentElement,g=l?{width:f,height:u,top:0,left:0,bottom:u,right:f}:m.getBoundingClientRect(),S=e.current.getBoundingClientRect(),T=t.current.getBoundingClientRect(),[x]=n.split(" ");let E=n;s&&(x==="top"&&T.top-S.height<Hb||x==="right"&&T.right+S.width>f||x==="bottom"&&T.bottom+S.height>u||x==="left"&&T.left-S.width<0)&&(E=s);const D=o?Math.max(T.width,S.width):S.width,I=i?T.width:D,[v,k,_,B]=Wb(E,g,T,S,I,p,c,l),M={top:ms(v),right:ms(k),bottom:ms(_),left:ms(B)};return l&&(M.position="fixed",M.zIndex=R.ZStratum.BAR),o&&(M.minWidth=`${T.width}px`),i&&(M.width=`${T.width}px`),[M,E===s]}return[{},!1]}const wt=H.createContext(null);function zn(e,t=[]){const n=H.useContext(wt);return H.useMemo(()=>s=>{const i=n&&n.parentElementRef&&n.parentElementRef.current||document.body;let c,l=i.lastElementChild;for(;l!==i.firstElementChild;){if(l.hasAttribute("data-portalid")&&l.getAttribute("data-portalid")===e){c=l;break}l=l.previousElementSibling}if(c)i.contains(c)||i.appendChild(c);else{c=document.createElement("div"),c.setAttribute("data-portalid",e);for(const p of t)c.classList.add(p);i.appendChild(c)}return Hr.createPortal(s,c)},[n])}const Gb={docs:{options:"Eventually<any[]> | (filter?: string) => Eventually<any[]>",captionKey:"string",disabledOptions:"any[]",comparisonKey:"string",tall:"boolean",textKey:"string",valueKey:"string",zeroState:"string",maxHeightPx:"number",maxHeightRem:"number",disableOptionsMemoization:"boolean",onSpecialActionSelect:"() => void"},propTypes:{captionKey:w.exports.string,comparisonKey:w.exports.string,disabledOptions:w.exports.arrayOf(w.exports.any),options:w.exports.oneOfType([w.exports.array,w.exports.instanceOf(Promise),te()]).isRequired,tall:w.exports.bool,textKey:w.exports.string,valueKey:w.exports.string,zeroState:w.exports.string,maxHeightPx:w.exports.number,maxHeightRem:w.exports.number}},Ub={hideInlineSearch:w.exports.bool,onSearchChange:te(),search:w.exports.string,searchDebounce:w.exports.number,searchPlaceholder:w.exports.string,searchInputRef:_t(),onSpecialActionSelect:te()},Yb=G(N(N(N({},z),Gb.propTypes),Ub),{attachTo:_t().isRequired,conformWidth:w.exports.bool,id:w.exports.string.isRequired,isOpen:w.exports.bool,keepOpen:w.exports.bool,keyDown:ce(),nullOption:w.exports.string,offsets:w.exports.arrayOf(w.exports.number),onOptionListChanged:te(),onOptionSelected:te(),onPositionFlip:te(),onSelfToggle:te(),optionRole:w.exports.string,positionOverride:w.exports.arrayOf(ve(R.Position)),selectedOption:w.exports.any,specialAction:te(),ignoreWidthStyles:w.exports.bool,loading:w.exports.bool,filterByTextAndCaptionKey:w.exports.bool,disableOptionsMemoization:w.exports.bool});async function xc(e,t,n,s,o,i){const c=typeof e.options=="function"?e.options(t.value):e.options||[],l=c instanceof Promise,p=m=>m.replace(/([.?*+^$[\]\\(){}|-])/g,"");n({pending:l}),i.current=l?c:null;const u=l?await c||[]:c||[];if(l&&i.current!==c)return;let f=Array.from(u).filter(Boolean).map(m=>new R.SpsOptionListOption(m,typeof m=="function"?{textKey:"label",captionKey:"caption"}:{textKey:e.textKey,captionKey:e.captionKey}));if(e.nullOption&&f.unshift(new R.SpsOptionListOption(null,{text:e.nullOption})),t.value){const m=p(t.value);n({replacementPattern:new RegExp(m,"ig")}),f=f.filter(g=>{const S=new RegExp(m,"i"),T=p(g.text);return e.filterByTextAndCaptionKey?S.test(T)||S.test(p(g.caption)):S.test(T)})}else n({replacementPattern:null});if(e.disabledOptions)for(const m of f)e.disabledOptions.includes(m.value)&&(m.disabled=!0);s(Object.freeze(f)),e.onOptionListChanged&&e.onOptionListChanged(f.length),o(f.some(m=>m.value&&!!m.value.icon)),n({pending:!1})}function zb(e,t,n){const[s,o]=a.useState(Object.freeze([])),[i,c]=a.useState(!1),l=a.useRef(null),p=a.useRef(e.options);(typeof e.options!="function"||e.disableOptionsMemoization)&&(p.current=e.options);const u=a.useMemo(()=>typeof p.current=="function"?y.debounce(xc,typeof e.searchDebounce!="undefined"?e.searchDebounce:500):xc,[p.current,e.disabledOptions]);return a.useEffect(()=>{u(e,t,n,o,c,l)},[p.current,t.value,e.disabledOptions]),[s,i]}class on{constructor(t,n){this.target=t,this.isPgStoppedInternal=!1,this.currentTarget=t,this.nativeEvent=new CustomEvent("change",n),Object.defineProperty(this.nativeEvent,"target",{value:t,writable:!1,configurable:!1,enumerable:!0})}get bubbles(){return this.nativeEvent.bubbles}get cancelable(){return this.nativeEvent.cancelable}get defaultPrevented(){return this.nativeEvent.defaultPrevented}get eventPhase(){return this.nativeEvent.eventPhase}get isTrusted(){return this.nativeEvent.isTrusted}get timeStamp(){return this.nativeEvent.timeStamp}get type(){return this.nativeEvent.type}preventDefault(){this.nativeEvent.preventDefault()}isDefaultPrevented(){return this.defaultPrevented}stopPropagation(){this.nativeEvent.stopPropagation(),this.isPgStoppedInternal=!0}isPropagationStopped(){return this.isPgStoppedInternal}persist(){throw new Error("This is not a real React ChangeEvent. React does not permit the creation of SyntheticEvents in userland.")}}function jb(e,t){return N(N({},e),t)}function Vt(e){return H.useReducer(jb,e)}function qb({hideInlineSearch:e,options:t,onSearchChange:n,search:s="",searchPlaceholder:o="Search\u2026",searchInputRef:i}){const[c,l]=Vt({isAsync:typeof t=="function",pending:!1,value:s,replacementPattern:null}),p=a.useCallback(S=>{l({value:S.target.value}),n&&n(S)},[n]),u=a.useCallback(S=>{S.nativeEvent.stopImmediatePropagation(),S.stopPropagation()},[]),f=a.useCallback(S=>{S.nativeEvent.stopImmediatePropagation(),l({value:""}),n&&n(new on(i.current)),i.current&&i.current.focus()},[n]),m=S=>{!S||["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"].includes(S.key)||S.stopPropagation()};return a.useEffect(()=>{l({value:s})},[s]),[c.isAsync&&!e&&a.createElement("div",{className:"sps-option-list__search sps-form-group sps-text-input"},a.createElement("div",{className:"sps-form-control"},!c.value&&a.createElement("i",{className:"sps-icon sps-icon-filter sps-text-input__icon"}),a.createElement("input",{type:"text",className:"sps-text-input__input",placeholder:o,ref:i,value:c.value,onChange:p,onClick:u,onKeyDown:m}),c.value&&a.createElement("i",{className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:f}))),c,l]}const Jb=Ec||Kb,Zb=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"],Xb=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function Qb(e,t,n){return n?(e&&e[n])===(t&&t[n]):e===t}function Dc(e,t,n){return typeof n.value=="function"&&n.disabled?!0:t?!!(e==null?void 0:e.find(s=>{var o;return s[t]&&s[t]===((o=n==null?void 0:n.value)==null?void 0:o[t])})):!1}const ya=a.forwardRef((e,t)=>{const An=e,{captionKey:n,comparisonKey:s,disabledOptions:o,options:i,tall:c,textKey:l,valueKey:p,zeroState:u,hideInlineSearch:f,onSearchChange:m,search:g,searchDebounce:S,searchPlaceholder:T,onSpecialActionSelect:x,attachTo:E,className:D,conformWidth:I,id:v,ignoreWidthStyles:k,isOpen:_,keepOpen:B,keyDown:M,nullOption:P,onOptionListChanged:F,onOptionSelected:L,onPositionFlip:$,onSelfToggle:V,optionRole:W,positionOverride:le,selectedOption:me,specialAction:se,unsafelyReplaceClassName:re,loading:oe,filterByTextAndCaptionKey:j,maxHeightPx:Q,maxHeightRem:Z,disableOptionsMemoization:ee,"data-testid":ae}=An,de=q(An,["captionKey","comparisonKey","disabledOptions","options","tall","textKey","valueKey","zeroState","hideInlineSearch","onSearchChange","search","searchDebounce","searchPlaceholder","onSpecialActionSelect","attachTo","className","conformWidth","id","ignoreWidthStyles","isOpen","keepOpen","keyDown","nullOption","onOptionListChanged","onOptionSelected","onPositionFlip","onSelfToggle","optionRole","positionOverride","selectedOption","specialAction","unsafelyReplaceClassName","loading","filterByTextAndCaptionKey","maxHeightPx","maxHeightRem","disableOptionsMemoization","data-testid"]),Y=a.useMemo(()=>se?new R.SpsOptionListOption(se,{textKey:"label",captionKey:"caption"}):null,[se]),[ge,Ie]=a.useState(-1),[Ce,we]=a.useState(_),Ke=t||a.useRef(null),$e=a.useRef(null),je=a.useRef(null),et=zn("sps-option-list-portal"),qe=a.useContext(wt),[ut,ct]=le||[R.Position.BOTTOM_LEFT,R.Position.TOP_LEFT],[[vt,Ee],We]=a.useState([{},!1]),Ye=a.useRef(null),[Ve,be,He]=qb(G(N({},e),{searchInputRef:Ye})),[Oe,Ge]=zb(e,be,He);a.useEffect(()=>{We(Ce?xn(Ke,E,ut,N({altPosition:ct,setMinWidth:!k,setWidth:!k&&I},qe)):[{},!1])},[Ce,ut,ct,Oe]),a.useEffect(()=>{const ye=()=>{Ce&&We(xn(Ke,E,ut,N({altPosition:ct,setMinWidth:!k,setWidth:!k&&I},qe)))};return document.addEventListener("scroll",ye),()=>{document.removeEventListener("scroll",ye)}},[Ce]),a.useEffect(()=>{Ie(-1)},[be]);const Tr=K(re||"sps-option-list","z-stratum-dropdown",Ce&&"sps-option-list--open",be.isAsync&&"sps-option-list--searchable",Ee&&"sps-option-list--opens-upward",se&&se.label&&"sps-option-list--has-special-action",D),Bn=K(re||"sps-option-list__options",c&&"sps-option-list__options--tall"),tt=a.useCallback(()=>{Ce||(we(!0),Ye.current&&Ye.current.focus(),Ie(-1),V&&V(!0))},[Ce,V]),Te=a.useCallback(()=>{Ce&&(we(!1),Ie(-1),V&&V(!1))},[Ce,V]),yt=a.useCallback((ye,pe)=>{pe||ye&&!ye.disabled&&(typeof ye.value=="function"?(ye.value(),x&&x()):typeof L=="function"&&L(ye.value),B||Te())},[L,Te]),gn=a.useCallback((ye,pe,ot)=>{ye.stopPropagation(),yt(pe,ot)},[yt]),Pn=a.useRef(o||[]);Pn.current=o||[];const wr=a.useCallback(ye=>{switch(ye.key){case"Tab":case"Escape":Te();break;case"Enter":if(ge>-1){const pe=Oe[ge]||Y;ye.preventDefault();const ot=!!pe&&Dc(Pn.current,s,pe);!ot&&pe&&typeof L=="function"&&typeof pe.value=="function"?pe.value():pe&&yt(pe,ot)}break;case"Up":case"ArrowUp":{let pe=ge;Ee?ge<=-1?pe=Oe.length-1:ge===0?se&&(pe=Oe.length):ge<Oe.length&&(pe=ge-1):ge>-1&&(pe=ge-1),pe!==ge&&(ye.preventDefault(),Ie(pe));break}case"Down":case"ArrowDown":{tt();let pe=ge;Ee?ge!==-1&&(ge>=Oe.length?pe=0:ge===Oe.length-1?pe=-1:pe=ge+1):ge<Oe.length-1+Number(!!se)&&(pe=ge+1),pe!==ge&&(ye.preventDefault(),Ie(pe));break}default:tt()}},[Te,tt,ge,yt,L,Ee,Oe]),Er=a.useCallback(ye=>{const pe=Oe.findIndex(ot=>{if(ot.textKey){const Sn=ot.textKey;return ot.value[Sn].toLowerCase().charAt([0])===ye.key.toLocaleLowerCase()}return ot.value.toString().toLowerCase().charAt([0])===ye.key.toLocaleLowerCase()});pe>-1&&Ie(pe)},[Oe]),$a=a.useCallback(ye=>{!ye||(Zb.includes(ye.key)?wr(ye):Xb.includes(ye.key)&&Er(ye))},[Te,tt,ge,yt,L,Ee,Oe]);a.useEffect(()=>{if(qe!==null&&document.getElementsByClassName("sps-modal__body").length>0){const ye=()=>{V(!1)},pe=document.getElementsByClassName("sps-modal__body")[0];return pe.addEventListener("scroll",ye),()=>{pe.removeEventListener("scroll",ye)}}},[]),a.useEffect(()=>{je.current&&Jb(je.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[ge]),a.useEffect(()=>{we(_),_?Ye.current&&Ye.current.focus():Ie(-1)},[_]),a.useEffect(()=>{$a(M)},[M]),a.useEffect(()=>{!Ce&&$e.current&&(He({value:""}),$e.current.scrollTop=0),Ce&&$&&$(Ee)},[Ce]);const at=Q?Q/16:Z,Ha=at?{maxHeight:`${at}rem`}:{};return et(a.createElement("div",N({className:Tr,id:v,"aria-activedescendant":ge>-1?`${v}-option-${ge}`:null,tabIndex:-1,ref:Ke,style:vt,onMouseLeave:()=>Ie(-1),"data-testid":ae},de),Ve,a.createElement("div",{className:Bn,ref:$e,"data-testid":`${ae}-options`,style:Ha},!oe&&!be.pending&&u&&Oe.length===0&&a.createElement("div",{className:"sps-option-list__zero-state"},u),(oe||be.pending)&&a.createElement("div",{className:"sps-option-list__loading"},a.createElement(us,null)),!oe&&!be.pending&&Oe.map((ye,pe)=>{const ot=`${v}-option-${pe}`,Sn=Qb(ye.value,me,s),bn=Dc(Pn.current,s,ye);return a.createElement("a",{key:ot,id:ot,role:W,"aria-selected":Sn,href:ye.href,className:K("sps-option-list__option",ye.caption&&"sps-option-list__option--has-caption",ye.disabled&&"sps-option-list__option--disabled",ye.bold&&"sps-option-list__option--bold",(Sn||bn)&&"sps-option-list__option--selected",ge===pe&&"sps-option-list__option--highlighted"),onClick:ia=>gn(ia,ye,bn),onMouseOver:()=>Ie(pe),tabIndex:-1,ref:ge===pe?je:null,"data-testid":`${ae}-option-${pe}`},ye.value&&ye.value.icon&&a.createElement("i",{className:K("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ye.value.icon)}`)}),(!ye.value||!ye.value.icon&&Ge)&&a.createElement("span",{className:"sps-option-list__option-icon-spacer"}),a.createElement("span",{dangerouslySetInnerHTML:{__html:ye.getHtml(be.replacementPattern)}}),ye.caption&&a.createElement("div",{className:"sps-option-list__option-caption"},a.createElement("span",{dangerouslySetInnerHTML:{__html:ye.caption.replace(be.replacementPattern,"<u>$&</u>")}})))})),Y&&se.label&&a.createElement("a",{className:K("sps-option-list__option","sps-option-list__special-action",ge===Oe.length&&"sps-option-list__option--highlighted",se.disabled&&"sps-option-list__special-action--disabled"),href:Y.href,target:Y.href&&se.newTab?"_blank":"_self",onClick:ye=>gn(ye,Y),onMouseOver:()=>Ie(Oe.length),"data-testid":`${ae}-special-action`},se.icon&&a.createElement("i",{className:K("sps-icon","sps-option-list__option-icon",`sps-icon-${String(se.icon)}`)}),!se.icon&&Ge&&a.createElement("span",{className:"sps-option-list__option-icon-spacer"}),a.createElement("span",null,se.label))))});Object.assign(ya,{propTypes:Yb,displayName:"SpsOptionList"});function ev(e,t,n=[]){return a.useMemo(()=>o=>a.createElement(e,N({},N(N({},o),t)),o.children),n)}const Ic=function({children:e,elements:t}){if(t.length===0)return a.createElement(a.Fragment,null,e);const[n,s]=Array.isArray(t[0])?t[0]:[t[0]];return a.createElement(n,N({},s!=null?s:{}),a.createElement(Ic,{elements:t.slice(1)},e))},Nc=function(s){var o=s,{children:e,providers:t=[]}=o,n=q(o,["children","providers"]);return a.createElement("div",N({},n),a.createElement(Ic,{elements:t},e))},tv=function(s){var o=s,{children:e,className:t}=o,n=q(o,["children","className"]);return a.createElement(Nc,N({className:`sps-app ${t}`},n),e)};function Et(e=[],t=[]){const n=Array.isArray(e)?y.flatten(e):[e],s=t.map(i=>Array.isArray(i)?i:[i]),o=new Array(s.length+1).fill(null).map(()=>[]);for(const i of n){let c=!1;for(let l=0;l<s.length;l+=1)for(const{type:p,props:u={}}of s[l])if(i.type===p&&Object.keys(u).every(m=>u[m]===i.props[m])){c=!0,o[l].push(i);break}c||o[o.length-1].push(i)}return o}function kc(e,t,n){const s=Object.entries(t).filter(([,i])=>typeof i!="string"&&i.deprecated).map(([i])=>i),o=s.map(i=>n[i]);a.useEffect(()=>{o.find(i=>typeof i!="undefined")&&console.warn(`The following prop(s) of ${e} are deprecated: ${s.join(", ")}`)},o)}function Zr(e,t){const n=H.useRef(!1);H.useEffect(()=>{if(n.current)return e();n.current=!0},t)}function Mc(e,t,n){const s=a.useRef(t(...n));a.useEffect(()=>(document.addEventListener(e,s.current),()=>document.removeEventListener(e,s.current)),[]),a.useEffect(()=>{document.removeEventListener(e,s.current),s.current=t(...n),document.addEventListener(e,s.current)},n)}function nv(e,t,n){return function(o){var i,c;!((i=e.current)==null?void 0:i.contains(o.target))&&!((c=t.current)==null?void 0:c.contains(o.target))&&n()}}function Ta(e,t,n){const s=a.useRef(!1),[o,i]=a.useState(!1),c=a.useCallback(()=>{s.current?s.current=!1:i(!0)},[]),l=a.useCallback((p=!1)=>{i(!1),s.current=p,n&&n()},[]);return Mc("mousedown",nv,[e,t,l]),{showPopup:o,doShowPopup:c,doHidePopup:l}}const av={debounce:"number",disabled:"boolean",formMeta:"SpsFormFieldMeta<string>",icon:"SpsIcon",onChange:"React.ChangeEventHandler",placeholder:"string",suggestions:{type:`
197
197
  Eventually<Iterable<string>>
198
198
  | ((filter?: string) => Eventually<Iterable<string>>)
199
199
  `,required:!0},tallOptionList:"boolean",value:"string",zeroState:"string",loading:"boolean",maxHeightOptionListPx:"number",maxHeightOptionListRem:"number",disableOptionsMemoization:"boolean"},sv=G(N({},z),{debounce:w.exports.number,disabled:w.exports.bool,formControl:ce(),formMeta:ce(),icon:ve(R.SpsIcon),onChange:te(),placeholder:w.exports.string,suggestions:w.exports.oneOfType([w.exports.arrayOf(w.exports.string),w.exports.instanceOf(Promise),te()]).isRequired,tallOptionList:w.exports.bool,value:w.exports.string,zeroState:w.exports.string,loading:w.exports.bool,maxHeightOptionListPx:w.exports.number,maxHeightOptionListRem:w.exports.number,disableOptionsMemoization:w.exports.bool});function fs(k){var _=k,{className:e,debounce:t=0,disabled:n,formControl:s,formMeta:o,onChange:i,icon:c,id:l,placeholder:p="",suggestions:u,unsafelyReplaceClassName:f,tallOptionList:m,value:g="",zeroState:S,loading:T,maxHeightOptionListPx:x,maxHeightOptionListRem:E,disableOptionsMemoization:D,"data-testid":I}=_,v=q(_,["className","debounce","disabled","formControl","formMeta","onChange","icon","id","placeholder","suggestions","unsafelyReplaceClassName","tallOptionList","value","zeroState","loading","maxHeightOptionListPx","maxHeightOptionListRem","disableOptionsMemoization","data-testid"]);const B=o||s,{wrapperId:M,controlId:P}=Tt(l,B),[F,L]=Vt({keyDown:null,opensUpward:!1}),$=a.useRef(),V=a.useRef(),W=a.useRef(),{showPopup:le,doShowPopup:me,doHidePopup:se}=Ta($,W);function re(de,Y){B&&(B.setValue(de),B.markAsDirty()),i&&i(Y||new on({value:de}))}function oe(de){V.current.value="",re(""),de.stopPropagation()}function j(de){re(de.target.value,de)}function Q(de){n||(["Up","ArrowUp","Down","ArrowDown","Enter"].indexOf(de.key)>-1&&(de.preventDefault(),de.persist()),de.stopPropagation(),L({keyDown:de})),de.key==="Tab"&&se()}function Z(de){de?me():se()}function ee(de){L({opensUpward:de})}const ae=K(f||"sps-autocomplete",le&&"sps-autocomplete--open",le&&"z-stratum-dropdown",F.opensUpward&&"sps-autocomplete--opens-upward",n&&"sps-form-control--disabled",e);return a.createElement(it,{id:M,className:ae,formControl:s,formMeta:o,inputRef:V,ref:$,focusInputOnClick:!0,onClick:de=>de.nativeEvent.stopImmediatePropagation(),"data-testId":`${I}`},a.createElement("div",{className:"sps-text-input"},a.createElement("div",{className:"sps-form-control"},c&&a.createElement("i",{className:K("sps-text-input__icon","sps-icon",`sps-icon-${c}`)}),a.createElement("input",N({type:"text",ref:V,value:g,className:"sps-text-input__input",placeholder:p,onFocus:me,onClick:me,onChange:j,onKeyDown:Q,disabled:n,id:P,"data-testid":`${I}__input`},v)),g&&!n&&a.createElement("i",{"aria-label":"clear",className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:de=>oe(de)}))),a.createElement(ya,{id:`${M}_options`,ref:W,attachTo:$,isOpen:le,options:u,hideInlineSearch:!0,keyDown:F.keyDown,onOptionSelected:re,onPositionFlip:ee,onSelfToggle:Z,offsets:[1,0],search:g,searchDebounce:t,tall:m,zeroState:S,loading:T,maxHeightPx:x,maxHeightRem:E,disableOptionsMemoization:D}))}Object.assign(fs,{props:av,propTypes:sv,displayName:"SpsAutocomplete"});const Rc={basic:{label:"Basic",examples:{basic:{react:y.code`
package/lib/index.es.js CHANGED
@@ -1222,7 +1222,7 @@ function checkFormObject(value) {
1222
1222
  throw new TypeError("The initial value of useSpsForm() hook must be an object.");
1223
1223
  }
1224
1224
  }
1225
- function useSpsForm(value, validatorMap) {
1225
+ function useSpsForm(value, validatorMap = {}) {
1226
1226
  checkFormObject(value);
1227
1227
  const formMeta = useMemo$1(() => {
1228
1228
  deepFreeze(value);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spscommerce/ds-react",
3
3
  "description": "SPS Design System React components",
4
- "version": "6.33.1",
4
+ "version": "6.33.2",
5
5
  "author": "SPS Commerce",
6
6
  "license": "UNLICENSED",
7
7
  "repository": "https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/ds-react",
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@react-stately/collections": "^3.3.3",
31
- "@spscommerce/ds-colors": "6.33.1",
32
- "@spscommerce/ds-illustrations": "6.33.1",
33
- "@spscommerce/ds-shared": "6.33.1",
34
- "@spscommerce/positioning": "6.33.1",
31
+ "@spscommerce/ds-colors": "6.33.2",
32
+ "@spscommerce/ds-illustrations": "6.33.2",
33
+ "@spscommerce/ds-shared": "6.33.2",
34
+ "@spscommerce/positioning": "6.33.2",
35
35
  "@spscommerce/utils": "^6.11.3",
36
36
  "moment": "^2.25.3",
37
37
  "moment-timezone": "^0.5.28",
@@ -40,10 +40,10 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "@react-stately/collections": "^3.3.3",
43
- "@spscommerce/ds-colors": "6.33.1",
44
- "@spscommerce/ds-illustrations": "6.33.1",
45
- "@spscommerce/ds-shared": "6.33.1",
46
- "@spscommerce/positioning": "6.33.1",
43
+ "@spscommerce/ds-colors": "6.33.2",
44
+ "@spscommerce/ds-illustrations": "6.33.2",
45
+ "@spscommerce/ds-shared": "6.33.2",
46
+ "@spscommerce/positioning": "6.33.2",
47
47
  "@spscommerce/utils": "^6.11.3",
48
48
  "@testing-library/react": "^10.4.0",
49
49
  "@types/prop-types": "^15.7.1",