"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),f=require("framer"),p=require("@viamedici-spc/configurator-ts"),_=require("@viamedici-spc/configurator-react"),T=require("react"),Pi=require("url-join"),M=require("ts-pattern"),Di=require("react-error-boundary"),k=require("styled-components"),v=require("@viamedici-spc/fp-ts-extensions"),Ze=require("@fortawesome/free-solid-svg-icons"),et=require("@fortawesome/react-fontawesome"),Gn=require("react-dom"),Vi=require("clsx"),Jn=require("merge-props"),Oi=require("dyna-guid"),ki=require("mustache"),ji=require("react-number-format"),Fi=require("use-debounce"),Ni=require("framer-motion"),Li=require("hex-to-css-filter"),Mi=require("rgb-hex"),Bi=require("camelcase");function Zn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const E=Zn(T),$i=Zn(Gn);function G(){return f.RenderTarget.current()!==f.RenderTarget.preview}function Ki(e){if(G())return null;const{error:n}=_.useConfigurationInitialization();if(!n)return null;switch(n.type){case p.ConfiguratorErrorType.ConfigurationModelNotFound:return T.Children.toArray(e.configurationModelNotFoundContent).length>0?e.configurationModelNotFoundContent:d.jsx("span",{children:"Configuration Model not found for the specified deployment name."});case p.ConfiguratorErrorType.AuthenticationFailure:return T.Children.toArray(e.accessTokenInvalidContent).length>0?e.accessTokenInvalidContent:d.jsx("span",{children:"The HCA access token is invalid."});case p.ConfiguratorErrorType.SpecifiedDeploymentForbidden:return T.Children.toArray(e.accessTokenRestrictionContent).length>0?e.accessTokenRestrictionContent:d.jsx("span",{children:"The HCA access token does not permit using the specified Configuration Model."});case p.ConfiguratorErrorType.DecisionsToRespectInvalid:return d.jsx("span",{children:"The definition of Attribute Relations is invalid."});default:return T.Children.toArray(e.errorContent).length>0?e.errorContent:d.jsx("span",{children:"An error occurred while initializing the configuration."})}}function se(e){return T.forwardRef((t,n)=>d.jsx(Di.ErrorBoundary,{fallbackRender:()=>d.jsx("span",{children:"Component crashed"}),children:d.jsx(e,{...t,ref:n})}))}const Wi=k.createGlobalStyle` :root { --font-primary: var(--framer-font-family, "Inter", "Inter Placeholder", sans-serif); --font-heading: "Inter-Medium", "Inter", "Inter Placeholder", sans-serif; } /* font sizes */ :root { --text-base-size: calc(var(--framer-font-size, 16px) * var(--framer-font-size-scale, 1)); --text-scale-ratio: 1.2; --text-xs: calc(1em / (var(--text-scale-ratio) * var(--text-scale-ratio))); --text-sm: calc(1em / var(--text-scale-ratio)); --text-md: calc(1em * var(--text-scale-ratio)); --text-lg: calc(1em * var(--text-scale-ratio) * var(--text-scale-ratio)); --text-xl: calc(1em * var(--text-scale-ratio) * var(--text-scale-ratio) * var(--text-scale-ratio)); --text-xxl: calc(1em * var(--text-scale-ratio) * var(--text-scale-ratio) * var(--text-scale-ratio) * var(--text-scale-ratio)); --text-xxxl: calc(1em * var(--text-scale-ratio) * var(--text-scale-ratio) * var(--text-scale-ratio) * var(--text-scale-ratio) * var(--text-scale-ratio)); } `,qi=Wi,zi=k.createGlobalStyle` :root { --space-unit: 1em; --space-xxs: calc(0.25 * var(--space-unit)); --space-xs: calc(0.5 * var(--space-unit)); --space-sm: calc(0.75 * var(--space-unit)); --space-md: calc(1.25 * var(--space-unit)); --space-lg: calc(2 * var(--space-unit)); --space-xl: calc(3.25 * var(--space-unit)); --space-xxl: calc(5.25 * var(--space-unit)); --space-unit-fixed: var(--text-base-size); --space-xxs-fixed: calc(0.25 * var(--space-unit-fixed)); --space-xs-fixed: calc(0.5 * var(--space-unit-fixed)); --space-sm-fixed: calc(0.75 * var(--space-unit-fixed)); --space-md-fixed: calc(1.25 * var(--space-unit-fixed)); --space-lg-fixed: calc(2 * var(--space-unit-fixed)); --space-xl-fixed: calc(3.25 * var(--space-unit-fixed)); --space-xxl-fixed: calc(5.25 * var(--space-unit-fixed)); } `,Hi=zi,Ui=k.createGlobalStyle` :root { --shape-border-radius-xs: 5px; --shape-border-radius-sm: 7px; --shape-border-radius-md: 12px; --shape-border-radius-lg: 20px; } `,_i=Ui,Qi=k.createGlobalStyle` :root { --shadows-popover: drop-shadow(5px 5px 10px rgba(0, 0, 0, 0.4)); --shadows-dialog: 0.2px 0.4px 2.3px rgba(0, 0, 0, 0.02), 0.6px 1px 5.7px rgba(0, 0, 0, 0.025), 1.2px 2.1px 10.6px rgba(0, 0, 0, 0.03), 2.3px 4px 17.2px rgba(0, 0, 0, 0.034), 4.2px 7.2px 25.9px rgba(0, 0, 0, 0.04), 7.6px 12.8px 37.7px rgba(0, 0, 0, 0.048), 13.9px 23.6px 54.7px rgba(0, 0, 0, 0.061), 40px 68px 96px rgba(0, 0, 0, 0.1); } `,Yi=Qi;function rn(){return d.jsxs(d.Fragment,{children:[d.jsx(Yi,{}),d.jsx(_i,{}),d.jsx(Hi,{}),d.jsx(qi,{})]})}const Ke=T.createContext(null);function ye(){const{process:e,switchMode:t,applySolution:n,dismiss:o}=T.useContext(Ke);return e?{...e,switchMode:t,applySolution:n,dismiss:o}:null}function eo(e){const{explanation:t,...n}=e,o=ye();return d.jsx("button",{...n,onClick:()=>o.applySolution(t.solution),children:e.children})}function to(e,t,n){return M.match(e).returnType().with({type:p.AttributeType.Choice},o=>t.get(o.choiceValueId)??o.choiceValueId).with({type:p.AttributeType.Boolean,state:!0},()=>n.booleanDecisionStateTrueLabel).with({type:p.AttributeType.Boolean,state:!1},()=>n.booleanDecisionStateFalseLabel).with({type:p.AttributeType.Component,state:p.ComponentDecisionState.Included},()=>n.componentDecisionStateIncludedLabel).with({type:p.AttributeType.Component,state:p.ComponentDecisionState.Excluded},()=>n.componentDecisionStateExcludedLabel).with({type:p.AttributeType.Numeric},o=>o.state.toString()).exhaustive()}const no={applySolutionButtonCaption:{title:"Apply Solution Button Caption",type:f.ControlType.String,defaultValue:"Apply Solution"},configurationSubjectTitle:{title:"Configuration Subject Title",type:f.ControlType.String,defaultValue:"Configuration"},generalConflictTitle:{title:"General Conflict Title",type:f.ControlType.String,defaultValue:"Conflict"},componentDecisionStateIncludedLabel:{title:"Component Decision State Included Label",type:f.ControlType.String,defaultValue:"Included"},componentDecisionStateExcludedLabel:{title:"Component Decision State Excluded Label",type:f.ControlType.String,defaultValue:"Excluded"},booleanDecisionStateTrueLabel:{title:"Boolean Decision State True Label",type:f.ControlType.String,defaultValue:"Yes"},booleanDecisionStateFalseLabel:{title:"Boolean Decision State False Label",type:f.ControlType.String,defaultValue:"No"},isBlockedSuffix:{title:"Is Blocked Suffix",type:f.ControlType.String,defaultValue:"is blocked"},isNotSatisfiedSuffix:{title:"Is Not Satisfied Suffix",type:f.ControlType.String,defaultValue:"is not satisfied"}},Xi={fill:{title:"Fill",type:f.ControlType.Color,defaultValue:"#002134"},color:{title:"Color",type:f.ControlType.Color,defaultValue:"white"},attributeValueFill:{title:"Attribute Value Fill",type:f.ControlType.Color,defaultValue:"rgba(255, 255, 255, 0.2)"},attributeValueAddFill:{title:"Attribute Value Add Fill",type:f.ControlType.Color,defaultValue:"rgba(47, 255, 0, 0.2)"},attributeValueAddColor:{title:"Attribute Value Add Color",type:f.ControlType.Color,defaultValue:"#63e446"},attributeValueRemoveFill:{title:"Attribute Value Remove Fill",type:f.ControlType.Color,defaultValue:"#ff00004a"},attributeValueRemoveColor:{title:"Attribute Value Remove Color",type:f.ControlType.Color,defaultValue:"#ff6060"},headerValueColor:{title:"Header Value Color",type:f.ControlType.Color,defaultValue:"rgb(0, 161, 230)"},closeButtonOutline:{title:"Close Button Outline",type:f.ControlType.Color,defaultValue:"rgba(255, 255, 255, 0.8)"},listSeparator:{title:"List Separator",type:f.ControlType.Color,defaultValue:"rgba(255, 255, 255, 0.3)"},applySolutionButtonFill:{title:"Apply Solution Button Fill",type:f.ControlType.Color,defaultValue:"rgb(0, 161, 230)"},applySolutionButtonColor:{title:"Apply Solution Button Color",type:f.ControlType.Color,defaultValue:"white"},applySolutionButtonOutline:{title:"Apply Solution Button Outline",type:f.ControlType.Color,defaultValue:"rgba(255, 255, 255, 0.8)"},showMoreButtonOutline:{title:"Show More Button Outline",type:f.ControlType.Color,defaultValue:"rgba(255, 255, 255, 0.8)"},solutionTitle:{title:"Solution Title",type:f.ControlType.String,defaultValue:"Solution"},showMoreButtonCaption:{title:"Show More Button Caption",type:f.ControlType.String,defaultValue:"Show more ({{amount}})"},showConstraintsButtonCaption:{title:"Show Constraints Button Caption",type:f.ControlType.String,defaultValue:"Show Constraints"},...no},Mt=T.createContext(null),Bt=()=>T.useContext(Mt),Gi={fill:{title:"Fill",type:f.ControlType.Color,defaultValue:"rgba(255, 255, 255, 0.7)"},color:{title:"Color",type:f.ControlType.Color,defaultValue:"#171717"},attributeValueFill:{title:"Attribute Value Fill",type:f.ControlType.Color,defaultValue:"#efefef"},attributeValueAddFill:{title:"Attribute Value Add Fill",type:f.ControlType.Color,defaultValue:"#cfefc7"},attributeValueAddColor:{title:"Attribute Value Add Color",type:f.ControlType.Color,defaultValue:"#48c52b"},attributeValueRemoveFill:{title:"Attribute Value Remove Fill",type:f.ControlType.Color,defaultValue:"#ffdada"},attributeValueRemoveColor:{title:"Attribute Value Remove Color",type:f.ControlType.Color,defaultValue:"#c52b2b"},headerValueColor:{title:"Header Value Color",type:f.ControlType.Color,defaultValue:"#00a1e6"},closeButtonOutline:{title:"Close Button Outline",type:f.ControlType.Color,defaultValue:"#00a1e6"},applySolutionButtonFill:{title:"Apply Solution Button Fill",type:f.ControlType.Color,defaultValue:"#F2F2F2"},applySolutionButtonColor:{title:"Apply Solution Button Color",type:f.ControlType.Color,defaultValue:"#171717"},applySolutionButtonOutline:{title:"Apply Solution Button Outline",type:f.ControlType.Color,defaultValue:"#00a1e6"},explanationCard:{title:"Explanation Card",type:f.ControlType.Color,defaultValue:"white"},scrollShadowBorder:{title:"Scroll Shadow Border",type:f.ControlType.Color,defaultValue:"rgba(0, 0, 0, 0.3)"},backdropFilter:{title:"Backdrop Filter",type:f.ControlType.String,defaultValue:"blur(10px) saturate(200%)"},decisionExplanationSolutionsTitle:{title:"Decision Explanation Solutions Title",type:f.ControlType.String,defaultValue:"Solutions"},constraintExplanationSolutionsTitle:{title:"Constraint Explanation Solutions Title",type:f.ControlType.String,defaultValue:"Constraint Explanations"},...no},$t=T.createContext(null),oo=()=>T.useContext($t),Ji=()=>T.useContext(Mt)||T.useContext($t),Kt=Ji,Zi=k.div` display: flex; gap: var(--space-xs); align-items: center; background-color: var(--color-explain-attribute-value-fill); border-radius: 360px; padding-right: var(--space-sm); font-size: 0.9em; font-family: var(--framer-font-family, "Inter", "Inter Placeholder", sans-serif); font-weight: 500; min-width: 0; `,er=k.div` display: grid; place-content: center; border-top-left-radius: 360px; border-bottom-left-radius: 360px; height: 1.5em; width: 1.5em; flex-shrink: 0; &.mode-add { background-color: var(--color-explain-attribute-value-add-fill); color: var(--color-explain-attribute-value-add-color); } &.mode-remove { background-color: var(--color-explain-attribute-value-remove-fill); color: var(--color-explain-attribute-value-remove-color); } `,tr=k.div` white-space: nowrap; overflow: hidden; text-overflow: ellipsis; `;function nr(e){const{decision:t,choiceValuesNames:n}=e,o=t.intention,i=Kt(),r=to(t,n,i);return d.jsxs(Zi,{children:[d.jsxs(er,{className:`mode-${o}`,children:[o==="remove"&&d.jsx(et.FontAwesomeIcon,{icon:Ze.faMinus}),o==="add"&&d.jsx(et.FontAwesomeIcon,{icon:Ze.faPlus})]}),d.jsx(tr,{children:r})]})}function J(e){var t;return{localId:e.attributeId,componentPath:e.componentPath===""?[]:((t=e.componentPath)==null?void 0:t.split(" -> "))??[],sharedConfigurationModelId:e.sharedConfigurationModel===""?null:e.sharedConfigurationModel}}const ut=T.createContext(null);function dt(e){const{attributes:t}=T.useContext(ut),{activeLocale:n}=f.useLocaleInfo(),o=n.code;return T.useMemo(()=>v.pipe(t,v.RA.findFirst(i=>p.globalAttributeIdEq.equals(J(i),e)),v.O.map(i=>i.name),v.RA.fromOption,v.RA.flatten,Wt(o),v.O.toUndefined),[t,o,e.localId,e.componentPath,e.sharedConfigurationModelId])}function ze(e){const{choiceValues:t}=T.useContext(ut),{activeLocale:n}=f.useLocaleInfo(),o=_.useChoiceAttribute(e);if(!o)return v.RM.empty;const i=T.useMemo(()=>v.pipe(t,v.RA.filter(s=>p.globalAttributeIdEq.equals(J(s),e))),[t,e.localId,e.componentPath,e.sharedConfigurationModelId]),r=n.code,l=o.attribute.values;return T.useMemo(()=>v.pipe(l,v.RM.mapWithIndex((s,a)=>v.pipe(i,v.RA.findFirst(c=>c.choiceValueId===s),v.O.map(c=>c.name),v.RA.fromOption,v.RA.flatten,Wt(r))),v.RM.compact),[l,i,r])}function io(e,t){const{choiceValues:n}=T.useContext(ut),{activeLocale:o}=f.useLocaleInfo(),i=o.code;return T.useMemo(()=>v.pipe(n,v.RA.findFirst(r=>p.globalAttributeIdEq.equals(J(r),e)&&r.choiceValueId===t),v.O.map(r=>r.name),v.RA.fromOption,v.RA.flatten,Wt(i),v.O.toUndefined),[n,i,e.localId,e.componentPath,e.sharedConfigurationModelId,t])}function Wt(e){return v.flow(v.RA.findFirst(t=>t.localeCode.localeCompare(e,void 0,{sensitivity:"accent"})===0),v.O.map(t=>t.translation))}const or=k.div` display: grid; grid-template-columns: subgrid; grid-column: span 2; align-items: center; `,ir=k.div` grid-area: name; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; `,rr=k.div` grid-area: values; display: flex; flex-wrap: wrap; min-width: 0; gap: var(--space-xxs); `;function lr(e){const{decisions:t}=e,n=t[0].attributeId,o=ze(n),i=dt(n),r=Kt(),l=v.pipe(v.Str.Ord,v.Ord.contramap(a=>to(a,o,r))),s=v.pipe(t,v.RA.sort(l));return d.jsxs(or,{children:[d.jsx(ir,{children:i??n.localId}),d.jsx(rr,{children:s.map((a,c)=>d.jsx(nr,{decision:a,choiceValuesNames:o},c))})]})}function sr(e){const t=e.sharedConfigurationModelId&&`shared::${e.sharedConfigurationModelId}`,n=(e.componentPath??[]).join("::");return[t,n,e.localId].filter(o=>(o==null?void 0:o.length)>0).join("::")}const ar=v.pipe(v.Str.Ord,v.Ord.contramap(e=>e.attributeId.localId));function ro(e){const{blockingDecisions:t,desiredDecisions:n,...o}=e,i=v.pipe([...n.map(r=>({...r,intention:"add"})),...t.map(r=>({...r,intention:"remove"}))],v.RNEA.groupBy(r=>sr(r.attributeId)),v.RR.collect(v.Ord.trivial)((r,l)=>({key:r,attributeId:v.RNEA.head(l).attributeId,decisions:l})),v.RA.sort(ar));return d.jsx("div",{...o,children:i.map(r=>d.jsx(lr,{decisions:r.decisions},r.key))})}const cr=k.div` background-color: var(--color-explain-dialog-explanation-card); padding: var(--space-sm-fixed); box-shadow: 2px 1px 10px -5px rgba(0, 0, 0, 0.4); border-radius: var(--shape-border-radius-sm); `,lo=cr,ur=k(ro)` display: grid; grid-template-columns: [name] minmax(150px, auto) [values] minmax(0px, 1fr); gap: var(--space-sm); `,dr=k(eo)` border-radius: var(--shape-border-radius-sm); background-color: var(--color-explain-dialog-apply-solution-button-fill); color: var(--color-explain-dialog-apply-solution-button-color); font-size: 0.9em; font-family: var(--framer-font-family, "Inter", "Inter Placeholder", sans-serif); font-weight: 600; appearance: none; padding: 0.6em 1em; border: none; width: auto; margin-top: var(--space-md); &:focus { outline: 2px solid var(--color-explain-dialog-apply-solution-button-outline); outline-offset: 1px; } `;function fr(e){const{explanation:t}=e,{applySolutionButtonCaption:n}=oo(),o=t.solution.decisions.filter(i=>i.state!=null);return d.jsxs(lo,{children:[d.jsx(ur,{blockingDecisions:t.causedByDecisions,desiredDecisions:o}),d.jsx(dr,{explanation:t,children:n})]})}const pr=k(lo)` ul { margin: 0; } line-height: 1.5em; `,hr=k.ul` list-style-type: none; margin-inline-start: 0; padding-inline-start: 0; `,ln=k.ul` list-style-type: disc; margin-inline-start: 0; padding-inline-start: var(--space-lg); `,sn=k.li` font-size: 0.9em; font-family: var(--framer-font-family, "Inter", "Inter Placeholder", sans-serif); font-weight: 500; `;function mr(e){const{explanation:t}=e,n=t.causedByCardinalities,o=v.pipe(t.causedByRules,v.RNEA.groupBy(i=>i.configurationModelId),v.RR.collect(v.Str.Ord)((i,r)=>({configurationModelId:i,rules:v.pipe(r,v.RA.map(l=>l.localId),v.RA.sort(v.Str.Ord))})));return d.jsx(pr,{children:d.jsxs(hr,{children:[o.map(i=>d.jsxs("li",{children:[d.jsx("span",{children:i.configurationModelId}),d.jsx(ln,{children:i.rules.map(r=>d.jsx(sn,{children:r}))})]})),n.length>0&&d.jsxs("li",{children:[d.jsx("span",{children:"Cardinality"}),d.jsx(ln,{children:n.map(i=>d.jsx(sn,{children:i.localId}))})]})]})})}function so(e){const{variant:t,...n}=e,{explainQuestion:o}=ye(),i=M.match(o).returnType().with({question:p.ExplainQuestionType.whyIsStateNotPossible},()=>"why your selection is not possible").with({question:p.ExplainQuestionType.whyIsNotSatisfied,subject:p.ExplainQuestionSubject.configuration},()=>"why your configuration is not satisfied").with({question:p.ExplainQuestionType.whyIsNotSatisfied,subject:p.ExplainQuestionSubject.attribute},()=>"why your attribute is not satisfied").with(M.P.nullish,()=>"why your selections are not possible").exhaustive(),r=M.match(t).returnType().with("failedToExplain",()=>d.jsxs(d.Fragment,{children:["Failed to explain ",i,".",d.jsx("br",{}),"Please check your internet connection and try again."]})).with("noExplanationFound",()=>d.jsxs(d.Fragment,{children:["There was no explanation found for ",i,"."]})).with("noSolutionFound",()=>d.jsxs(d.Fragment,{children:["There was no solution found for ",i,"."]})).exhaustive();return d.jsx("div",{...n,children:r})}const an=k.div` font-weight: 500; font-family: var(--font-heading); margin-bottom: var(--space-xs); margin-left: var(--space-sm-fixed); `,cn=k.div` display: flex; flex-direction: column; gap: var(--space-xs); `,yr=k.div` display: flex; flex-direction: column; gap: var(--space-md); `,un=k(so)` width: min-content; min-width: 400px; margin: var(--space-sm-fixed) var(--space-md-fixed) var(--space-sm-fixed) var(--space-sm-fixed); `;function gr(){const{decisionExplanations:e,constraintExplanations:t,hasError:n}=ye(),{decisionExplanationSolutionsTitle:o,constraintExplanationSolutionsTitle:i}=oo();return n?d.jsx(un,{variant:"failedToExplain"}):e.length===0&&t.length===0?d.jsx(un,{variant:"noExplanationFound"}):d.jsxs(yr,{children:[e.length>0&&d.jsxs("div",{children:[d.jsx(an,{children:o}),d.jsx(cn,{children:e.map(r=>d.jsx(fr,{explanation:r},e.indexOf(r)))})]}),t.length>0&&d.jsxs("div",{children:[d.jsx(an,{children:i}),d.jsx(cn,{children:t.map(r=>d.jsx(mr,{explanation:r},t.indexOf(r)))})]})]})}function me(e){return ao(e)?(e.nodeName||"").toLowerCase():"#document"}function oe(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ge(e){var t;return(t=(ao(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ao(e){return e instanceof Node||e instanceof oe(e).Node}function X(e){return e instanceof Element||e instanceof oe(e).Element}function te(e){return e instanceof HTMLElement||e instanceof oe(e).HTMLElement}function Dt(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof oe(e).ShadowRoot}function He(e){const{overflow:t,overflowX:n,overflowY:o,display:i}=ie(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!["inline","contents"].includes(i)}function br(e){return["table","td","th"].includes(me(e))}function qt(e){const t=zt(),n=ie(e);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(o=>(n.willChange||"").includes(o))||["paint","layout","strict","content"].some(o=>(n.contain||"").includes(o))}function co(e){let t=Se(e);for(;te(t)&&!Ve(t);){if(qt(t))return t;t=Se(t)}return null}function zt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Ve(e){return["html","body","#document"].includes(me(e))}function ie(e){return oe(e).getComputedStyle(e)}function ft(e){return X(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Se(e){if(me(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Dt(e)&&e.host||ge(e);return Dt(t)?t.host:t}function uo(e){const t=Se(e);return Ve(t)?e.ownerDocument?e.ownerDocument.body:e.body:te(t)&&He(t)?t:uo(t)}function be(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=uo(e),r=i===((o=e.ownerDocument)==null?void 0:o.body),l=oe(i);return r?t.concat(l,l.visualViewport||[],He(i)?i:[],l.frameElement&&n?be(l.frameElement):[]):t.concat(i,be(i,[],n))}function Re(e){let t=e.activeElement;for(;((n=t)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;t=t.shadowRoot.activeElement}return t}function ne(e,t){if(!e||!t)return!1;const n=t.getRootNode==null?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&Dt(n)){let o=t;for(;o;){if(e===o)return!0;o=o.parentNode||o.host}}return!1}function fo(){const e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform}function po(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:o}=t;return n+"/"+o}).join(" "):navigator.userAgent}function xr(e){return e.mozInputSource===0&&e.isTrusted?!0:Vt()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Cr(e){return wr()?!1:!Vt()&&e.width===0&&e.height===0||Vt()&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function vr(){return/apple/i.test(navigator.vendor)}function Vt(){const e=/android/i;return e.test(fo())||e.test(po())}function wr(){return po().includes("jsdom/")}function dn(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function Sr(e){return"nativeEvent"in e}function Tr(e){return e.matches("html,body")}function he(e){return(e==null?void 0:e.ownerDocument)||document}function yt(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function Ie(e){return"composedPath"in e?e.composedPath()[0]:e.target}const Er="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function ho(e){return te(e)&&e.matches(Er)}function gt(e){e.preventDefault(),e.stopPropagation()}function Ar(e){return e?e.getAttribute("role")==="combobox"&&ho(e):!1}const Oe=Math.min,we=Math.max,tt=Math.round,Ye=Math.floor,xe=e=>({x:e,y:e}),Rr={left:"right",right:"left",bottom:"top",top:"bottom"},Ir={start:"end",end:"start"};function Ot(e,t,n){return we(e,Oe(t,n))}function Ue(e,t){return typeof e=="function"?e(t):e}function Te(e){return e.split("-")[0]}function _e(e){return e.split("-")[1]}function mo(e){return e==="x"?"y":"x"}function Ht(e){return e==="y"?"height":"width"}function pt(e){return["top","bottom"].includes(Te(e))?"y":"x"}function Ut(e){return mo(pt(e))}function Pr(e,t,n){n===void 0&&(n=!1);const o=_e(e),i=Ut(e),r=Ht(i);let l=i==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(l=nt(l)),[l,nt(l)]}function Dr(e){const t=nt(e);return[kt(e),t,kt(t)]}function kt(e){return e.replace(/start|end/g,t=>Ir[t])}function Vr(e,t,n){const o=["left","right"],i=["right","left"],r=["top","bottom"],l=["bottom","top"];switch(e){case"top":case"bottom":return n?t?i:o:t?o:i;case"left":case"right":return t?r:l;default:return[]}}function Or(e,t,n,o){const i=_e(e);let r=Vr(Te(e),n==="start",o);return i&&(r=r.map(l=>l+"-"+i),t&&(r=r.concat(r.map(kt)))),r}function nt(e){return e.replace(/left|right|bottom|top/g,t=>Rr[t])}function kr(e){return{top:0,right:0,bottom:0,left:0,...e}}function yo(e){return typeof e!="number"?kr(e):{top:e,right:e,bottom:e,left:e}}function ot(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}function fn(e,t,n){let{reference:o,floating:i}=e;const r=pt(t),l=Ut(t),s=Ht(l),a=Te(t),c=r==="y",x=o.x+o.width/2-i.width/2,h=o.y+o.height/2-i.height/2,g=o[s]/2-i[s]/2;let u;switch(a){case"top":u={x,y:o.y-i.height};break;case"bottom":u={x,y:o.y+o.height};break;case"right":u={x:o.x+o.width,y:h};break;case"left":u={x:o.x-i.width,y:h};break;default:u={x:o.x,y:o.y}}switch(_e(t)){case"start":u[l]-=g*(n&&c?-1:1);break;case"end":u[l]+=g*(n&&c?-1:1);break}return u}const jr=async(e,t,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:l}=n,s=r.filter(Boolean),a=await(l.isRTL==null?void 0:l.isRTL(t));let c=await l.getElementRects({reference:e,floating:t,strategy:i}),{x,y:h}=fn(c,o,a),g=o,u={},b=0;for(let w=0;w({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:i,rects:r,platform:l,elements:s,middlewareData:a}=t,{element:c,padding:x=0}=Ue(e,t)||{};if(c==null)return{};const h=yo(x),g={x:n,y:o},u=Ut(i),b=Ht(u),w=await l.getDimensions(c),m=u==="y",y=m?"top":"left",C=m?"bottom":"right",P=m?"clientHeight":"clientWidth",S=r.reference[b]+r.reference[u]-g[u]-r.floating[b],R=g[u]-r.reference[u],I=await(l.getOffsetParent==null?void 0:l.getOffsetParent(c));let V=I?I[P]:0;(!V||!await(l.isElement==null?void 0:l.isElement(I)))&&(V=s.floating[P]||r.floating[b]);const D=S/2-R/2,F=V/2-w[b]/2-1,A=Oe(h[y],F),N=Oe(h[C],F),B=A,W=V-w[b]-N,H=V/2-w[b]/2+D,j=Ot(B,H,W),$=!a.arrow&&_e(i)!=null&&H!==j&&r.reference[b]/2-(HB<=0)){var F,A;const B=(((F=r.flip)==null?void 0:F.index)||0)+1,W=R[B];if(W)return{data:{index:B,overflows:D},reset:{placement:W}};let H=(A=D.filter(j=>j.overflows[0]<=0).sort((j,$)=>j.overflows[1]-$.overflows[1])[0])==null?void 0:A.placement;if(!H)switch(u){case"bestFit":{var N;const j=(N=D.map($=>[$.placement,$.overflows.filter(O=>O>0).reduce((O,L)=>O+L,0)]).sort(($,O)=>$[1]-O[1])[0])==null?void 0:N[0];j&&(H=j);break}case"initialPlacement":H=s;break}if(i!==H)return{reset:{placement:H}}}return{}}}};async function Lr(e,t){const{placement:n,platform:o,elements:i}=e,r=await(o.isRTL==null?void 0:o.isRTL(i.floating)),l=Te(n),s=_e(n),a=pt(n)==="y",c=["left","top"].includes(l)?-1:1,x=r&&a?-1:1,h=Ue(t,e);let{mainAxis:g,crossAxis:u,alignmentAxis:b}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...h};return s&&typeof b=="number"&&(u=s==="end"?b*-1:b),a?{x:u*x,y:g*c}:{x:g*c,y:u*x}}const Mr=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:i,y:r,placement:l,middlewareData:s}=t,a=await Lr(t,e);return l===((n=s.offset)==null?void 0:n.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:i+a.x,y:r+a.y,data:{...a,placement:l}}}}},Br=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:i}=t,{mainAxis:r=!0,crossAxis:l=!1,limiter:s={fn:m=>{let{x:y,y:C}=m;return{x:y,y:C}}},...a}=Ue(e,t),c={x:n,y:o},x=await go(t,a),h=pt(Te(i)),g=mo(h);let u=c[g],b=c[h];if(r){const m=g==="y"?"top":"left",y=g==="y"?"bottom":"right",C=u+x[m],P=u-x[y];u=Ot(C,u,P)}if(l){const m=h==="y"?"top":"left",y=h==="y"?"bottom":"right",C=b+x[m],P=b-x[y];b=Ot(C,b,P)}const w=s.fn({...t,[g]:u,[h]:b});return{...w,data:{x:w.x-n,y:w.y-o}}}}};function bo(e){const t=ie(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const i=te(e),r=i?e.offsetWidth:n,l=i?e.offsetHeight:o,s=tt(n)!==r||tt(o)!==l;return s&&(n=r,o=l),{width:n,height:o,$:s}}function _t(e){return X(e)?e:e.contextElement}function De(e){const t=_t(e);if(!te(t))return xe(1);const n=t.getBoundingClientRect(),{width:o,height:i,$:r}=bo(t);let l=(r?tt(n.width):n.width)/o,s=(r?tt(n.height):n.height)/i;return(!l||!Number.isFinite(l))&&(l=1),(!s||!Number.isFinite(s))&&(s=1),{x:l,y:s}}const $r=xe(0);function xo(e){const t=oe(e);return!zt()||!t.visualViewport?$r:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Kr(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==oe(e)?!1:t}function Ee(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),r=_t(e);let l=xe(1);t&&(o?X(o)&&(l=De(o)):l=De(e));const s=Kr(r,n,o)?xo(r):xe(0);let a=(i.left+s.x)/l.x,c=(i.top+s.y)/l.y,x=i.width/l.x,h=i.height/l.y;if(r){const g=oe(r),u=o&&X(o)?oe(o):o;let b=g.frameElement;for(;b&&o&&u!==g;){const w=De(b),m=b.getBoundingClientRect(),y=ie(b),C=m.left+(b.clientLeft+parseFloat(y.paddingLeft))*w.x,P=m.top+(b.clientTop+parseFloat(y.paddingTop))*w.y;a*=w.x,c*=w.y,x*=w.x,h*=w.y,a+=C,c+=P,b=oe(b).frameElement}}return ot({width:x,height:h,x:a,y:c})}const Wr=[":popover-open",":modal"];function Co(e){let t=!1,n=0,o=0;function i(r){try{t=t||e.matches(r)}catch{}}if(Wr.forEach(r=>{i(r)}),t){const r=co(e);if(r){const l=r.getBoundingClientRect();n=l.x,o=l.y}}return[t,n,o]}function qr(e){let{elements:t,rect:n,offsetParent:o,strategy:i}=e;const r=ge(o),[l]=t?Co(t.floating):[!1];if(o===r||l)return n;let s={scrollLeft:0,scrollTop:0},a=xe(1);const c=xe(0),x=te(o);if((x||!x&&i!=="fixed")&&((me(o)!=="body"||He(r))&&(s=ft(o)),te(o))){const h=Ee(o);a=De(o),c.x=h.x+o.clientLeft,c.y=h.y+o.clientTop}return{width:n.width*a.x,height:n.height*a.y,x:n.x*a.x-s.scrollLeft*a.x+c.x,y:n.y*a.y-s.scrollTop*a.y+c.y}}function zr(e){return Array.from(e.getClientRects())}function vo(e){return Ee(ge(e)).left+ft(e).scrollLeft}function Hr(e){const t=ge(e),n=ft(e),o=e.ownerDocument.body,i=we(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=we(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let l=-n.scrollLeft+vo(e);const s=-n.scrollTop;return ie(o).direction==="rtl"&&(l+=we(t.clientWidth,o.clientWidth)-i),{width:i,height:r,x:l,y:s}}function Ur(e,t){const n=oe(e),o=ge(e),i=n.visualViewport;let r=o.clientWidth,l=o.clientHeight,s=0,a=0;if(i){r=i.width,l=i.height;const c=zt();(!c||c&&t==="fixed")&&(s=i.offsetLeft,a=i.offsetTop)}return{width:r,height:l,x:s,y:a}}function _r(e,t){const n=Ee(e,!0,t==="fixed"),o=n.top+e.clientTop,i=n.left+e.clientLeft,r=te(e)?De(e):xe(1),l=e.clientWidth*r.x,s=e.clientHeight*r.y,a=i*r.x,c=o*r.y;return{width:l,height:s,x:a,y:c}}function pn(e,t,n){let o;if(t==="viewport")o=Ur(e,n);else if(t==="document")o=Hr(ge(e));else if(X(t))o=_r(t,n);else{const i=xo(e);o={...t,x:t.x-i.x,y:t.y-i.y}}return ot(o)}function wo(e,t){const n=Se(e);return n===t||!X(n)||Ve(n)?!1:ie(n).position==="fixed"||wo(n,t)}function Qr(e,t){const n=t.get(e);if(n)return n;let o=be(e,[],!1).filter(s=>X(s)&&me(s)!=="body"),i=null;const r=ie(e).position==="fixed";let l=r?Se(e):e;for(;X(l)&&!Ve(l);){const s=ie(l),a=qt(l);!a&&s.position==="fixed"&&(i=null),(r?!a&&!i:!a&&s.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||He(l)&&!a&&wo(e,l))?o=o.filter(x=>x!==l):i=s,l=Se(l)}return t.set(e,o),o}function Yr(e){let{element:t,boundary:n,rootBoundary:o,strategy:i}=e;const l=[...n==="clippingAncestors"?Qr(t,this._c):[].concat(n),o],s=l[0],a=l.reduce((c,x)=>{const h=pn(t,x,i);return c.top=we(h.top,c.top),c.right=Oe(h.right,c.right),c.bottom=Oe(h.bottom,c.bottom),c.left=we(h.left,c.left),c},pn(t,s,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Xr(e){const{width:t,height:n}=bo(e);return{width:t,height:n}}function Gr(e,t,n,o){const i=te(t),r=ge(t),l=n==="fixed",s=Ee(e,!0,l,t);let a={scrollLeft:0,scrollTop:0};const c=xe(0);if(i||!i&&!l)if((me(t)!=="body"||He(r))&&(a=ft(t)),i){const w=Ee(t,!0,l,t);c.x=w.x+t.clientLeft,c.y=w.y+t.clientTop}else r&&(c.x=vo(r));let x=s.left+a.scrollLeft-c.x,h=s.top+a.scrollTop-c.y;const[g,u,b]=Co(o);return g&&(x+=u,h+=b,i&&(x+=t.clientLeft,h+=t.clientTop)),{x,y:h,width:s.width,height:s.height}}function hn(e,t){return!te(e)||ie(e).position==="fixed"?null:t?t(e):e.offsetParent}function So(e,t){const n=oe(e);if(!te(e))return n;let o=hn(e,t);for(;o&&br(o)&&ie(o).position==="static";)o=hn(o,t);return o&&(me(o)==="html"||me(o)==="body"&&ie(o).position==="static"&&!qt(o))?n:o||co(e)||n}const Jr=async function(e){const t=this.getOffsetParent||So,n=this.getDimensions;return{reference:Gr(e.reference,await t(e.floating),e.strategy,e.floating),floating:{x:0,y:0,...await n(e.floating)}}};function Zr(e){return ie(e).direction==="rtl"}const To={convertOffsetParentRelativeRectToViewportRelativeRect:qr,getDocumentElement:ge,getClippingRect:Yr,getOffsetParent:So,getElementRects:Jr,getClientRects:zr,getDimensions:Xr,getScale:De,isElement:X,isRTL:Zr};function el(e,t){let n=null,o;const i=ge(e);function r(){var s;clearTimeout(o),(s=n)==null||s.disconnect(),n=null}function l(s,a){s===void 0&&(s=!1),a===void 0&&(a=1),r();const{left:c,top:x,width:h,height:g}=e.getBoundingClientRect();if(s||t(),!h||!g)return;const u=Ye(x),b=Ye(i.clientWidth-(c+h)),w=Ye(i.clientHeight-(x+g)),m=Ye(c),C={rootMargin:-u+"px "+-b+"px "+-w+"px "+-m+"px",threshold:we(0,Oe(1,a))||1};let P=!0;function S(R){const I=R[0].intersectionRatio;if(I!==a){if(!P)return l();I?l(!1,I):o=setTimeout(()=>{l(!1,1e-7)},100)}P=!1}try{n=new IntersectionObserver(S,{...C,root:i.ownerDocument})}catch{n=new IntersectionObserver(S,C)}n.observe(e)}return l(!0),r}function tl(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:a=!1}=o,c=_t(e),x=i||r?[...c?be(c):[],...be(t)]:[];x.forEach(y=>{i&&y.addEventListener("scroll",n,{passive:!0}),r&&y.addEventListener("resize",n)});const h=c&&s?el(c,n):null;let g=-1,u=null;l&&(u=new ResizeObserver(y=>{let[C]=y;C&&C.target===c&&u&&(u.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var P;(P=u)==null||P.observe(t)})),n()}),c&&!a&&u.observe(c),u.observe(t));let b,w=a?Ee(e):null;a&&m();function m(){const y=Ee(e);w&&(y.x!==w.x||y.y!==w.y||y.width!==w.width||y.height!==w.height)&&n(),w=y,b=requestAnimationFrame(m)}return n(),()=>{var y;x.forEach(C=>{i&&C.removeEventListener("scroll",n),r&&C.removeEventListener("resize",n)}),h==null||h(),(y=u)==null||y.disconnect(),u=null,a&&cancelAnimationFrame(b)}}const nl=Br,ol=Nr,mn=Fr,il=(e,t,n)=>{const o=new Map,i={platform:To,...n},r={...i.platform,_c:o};return jr(e,t,{...i,platform:r})},rl=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:o,padding:i}=typeof e=="function"?e(n):e;return o&&t(o)?o.current!=null?mn({element:o.current,padding:i}).fn(n):{}:o?mn({element:o,padding:i}).fn(n):{}}}};var Je=typeof document<"u"?T.useLayoutEffect:T.useEffect;function it(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,o,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(o=n;o--!==0;)if(!it(e[o],t[o]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(t,i[o]))return!1;for(o=n;o--!==0;){const r=i[o];if(!(r==="_owner"&&e.$$typeof)&&!it(e[r],t[r]))return!1}return!0}return e!==e&&t!==t}function Eo(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function yn(e,t){const n=Eo(e);return Math.round(t*n)/n}function gn(e){const t=E.useRef(e);return Je(()=>{t.current=e}),t}function ll(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:o=[],platform:i,elements:{reference:r,floating:l}={},transform:s=!0,whileElementsMounted:a,open:c}=e,[x,h]=E.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,u]=E.useState(o);it(g,o)||u(o);const[b,w]=E.useState(null),[m,y]=E.useState(null),C=E.useCallback(O=>{O!==I.current&&(I.current=O,w(O))},[]),P=E.useCallback(O=>{O!==V.current&&(V.current=O,y(O))},[]),S=r||b,R=l||m,I=E.useRef(null),V=E.useRef(null),D=E.useRef(x),F=a!=null,A=gn(a),N=gn(i),B=E.useCallback(()=>{if(!I.current||!V.current)return;const O={placement:t,strategy:n,middleware:g};N.current&&(O.platform=N.current),il(I.current,V.current,O).then(L=>{const ee={...L,isPositioned:!0};W.current&&!it(D.current,ee)&&(D.current=ee,$i.flushSync(()=>{h(ee)}))})},[g,t,n,N]);Je(()=>{c===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,h(O=>({...O,isPositioned:!1})))},[c]);const W=E.useRef(!1);Je(()=>(W.current=!0,()=>{W.current=!1}),[]),Je(()=>{if(S&&(I.current=S),R&&(V.current=R),S&&R){if(A.current)return A.current(S,R,B);B()}},[S,R,B,A,F]);const H=E.useMemo(()=>({reference:I,floating:V,setReference:C,setFloating:P}),[C,P]),j=E.useMemo(()=>({reference:S,floating:R}),[S,R]),$=E.useMemo(()=>{const O={position:n,left:0,top:0};if(!j.floating)return O;const L=yn(j.floating,x.x),ee=yn(j.floating,x.y);return s?{...O,transform:"translate("+L+"px, "+ee+"px)",...Eo(j.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:L,top:ee}},[n,s,j.floating,x.x,x.y]);return E.useMemo(()=>({...x,update:B,refs:H,elements:j,floatingStyles:$}),[x,B,H,j,$])}/*! * tabbable 6.2.0 * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE */var sl=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],jt=sl.join(","),Ao=typeof Element>"u",We=Ao?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,rt=!Ao&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e==null?void 0:e.ownerDocument},lt=function e(t,n){var o;n===void 0&&(n=!0);var i=t==null||(o=t.getAttribute)===null||o===void 0?void 0:o.call(t,"inert"),r=i===""||i==="true",l=r||n&&t&&e(t.parentNode);return l},al=function(t){var n,o=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return o===""||o==="true"},cl=function(t,n,o){if(lt(t))return[];var i=Array.prototype.slice.apply(t.querySelectorAll(jt));return n&&We.call(t,jt)&&i.unshift(t),i=i.filter(o),i},ul=function e(t,n,o){for(var i=[],r=Array.from(t);r.length;){var l=r.shift();if(!lt(l,!1))if(l.tagName==="SLOT"){var s=l.assignedElements(),a=s.length?s:l.children,c=e(a,!0,o);o.flatten?i.push.apply(i,c):i.push({scopeParent:l,candidates:c})}else{var x=We.call(l,jt);x&&o.filter(l)&&(n||!t.includes(l))&&i.push(l);var h=l.shadowRoot||typeof o.getShadowRoot=="function"&&o.getShadowRoot(l),g=!lt(h,!1)&&(!o.shadowRootFilter||o.shadowRootFilter(l));if(h&&g){var u=e(h===!0?l.children:h.children,!0,o);o.flatten?i.push.apply(i,u):i.push({scopeParent:l,candidates:u})}else r.unshift.apply(r,l.children)}}return i},Ro=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Io=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||al(t))&&!Ro(t)?0:t.tabIndex},dl=function(t,n){var o=Io(t);return o<0&&n&&!Ro(t)?0:o},fl=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},Po=function(t){return t.tagName==="INPUT"},pl=function(t){return Po(t)&&t.type==="hidden"},hl=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(o){return o.tagName==="SUMMARY"});return n},ml=function(t,n){for(var o=0;osummary:first-of-type"),l=r?t.parentElement:t;if(We.call(l,"details:not([open]) *"))return!0;if(!o||o==="full"||o==="legacy-full"){if(typeof i=="function"){for(var s=t;t;){var a=t.parentElement,c=rt(t);if(a&&!a.shadowRoot&&i(a)===!0)return bn(t);t.assignedSlot?t=t.assignedSlot:!a&&c!==t.ownerDocument?t=c.host:t=a}t=s}if(xl(t))return!t.getClientRects().length;if(o!=="legacy-full")return!0}else if(o==="non-zero-area")return bn(t);return!1},vl=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var o=0;o=0)},Tl=function e(t){var n=[],o=[];return t.forEach(function(i,r){var l=!!i.scopeParent,s=l?i.scopeParent:i,a=dl(s,l),c=l?e(i.candidates):s;a===0?l?n.push.apply(n,c):n.push(s):o.push({documentOrder:r,tabIndex:a,item:i,isScope:l,content:c})}),o.sort(fl).reduce(function(i,r){return r.isScope?i.push.apply(i,r.content):i.push(r.content),i},[]).concat(n)},Qt=function(t,n){n=n||{};var o;return n.getShadowRoot?o=ul([t],n.includeContainer,{filter:xn.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:Sl}):o=cl(t,n.includeContainer,xn.bind(null,n)),Tl(o)};function Yt(e){return E.useMemo(()=>e.every(t=>t==null)?null:t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})},e)}const El=E["useInsertionEffect".toString()],Al=El||(e=>e());function Pe(e){const t=E.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return Al(()=>{t.current=e}),E.useCallback(function(){for(var n=arguments.length,o=new Array(n),i=0;ie==null?void 0:e.focus({preventScroll:n});i?r():Cn=requestAnimationFrame(r)}var le=typeof document<"u"?T.useLayoutEffect:T.useEffect;function ke(){return ke=Object.assign?Object.assign.bind():function(e){for(var t=1;t"floating-ui-"+Rl++;function Il(){const[e,t]=E.useState(()=>bt?vn():void 0);return le(()=>{e==null&&t(vn())},[]),E.useEffect(()=>{bt||(bt=!0)},[]),e}const Pl=E["useId".toString()],ht=Pl||Il,Dl=E.forwardRef(function(t,n){let{context:{placement:o,elements:{floating:i},middlewareData:{arrow:r}},width:l=14,height:s=7,tipRadius:a=0,strokeWidth:c=0,staticOffset:x,stroke:h,d:g,style:{transform:u,...b}={},...w}=t;process.env.NODE_ENV!=="production"&&(n||console.warn("Floating UI: The `ref` prop is required for the `FloatingArrow`","component."));const m=ht();if(!i)return null;c*=2;const y=c/2,C=l/2*(a/-8+1),P=s/2*a/4,[S,R]=o.split("-"),I=To.isRTL(i),V=!!g,D=S==="top"||S==="bottom",F=x&&R==="end"?"bottom":"top";let A=x&&R==="end"?"right":"left";x&&I&&(A=R==="end"?"left":"right");const N=(r==null?void 0:r.x)!=null?x||r.x:"",B=(r==null?void 0:r.y)!=null?x||r.y:"",W=g||"M0,0"+(" H"+l)+(" L"+(l-C)+","+(s-P))+(" Q"+l/2+","+s+" "+C+","+(s-P))+" Z",H={top:V?"rotate(180deg)":"",left:V?"rotate(90deg)":"rotate(-90deg)",bottom:V?"":"rotate(180deg)",right:V?"rotate(-90deg)":"rotate(90deg)"}[S];return E.createElement("svg",ke({},w,{"aria-hidden":!0,ref:n,width:V?l:l+c,height:l,viewBox:"0 0 "+l+" "+(s>l?s:l),style:{position:"absolute",pointerEvents:"none",[A]:N,[F]:B,[S]:D||V?"100%":"calc(100% - "+c/2+"px)",transform:""+H+(u??""),...b}}),c>0&&E.createElement("path",{clipPath:"url(#"+m+")",fill:"none",stroke:h,strokeWidth:c+(g?0:1),d:W}),E.createElement("path",{stroke:c&&!g?w.fill:"none",d:W}),E.createElement("clipPath",{id:m},E.createElement("rect",{x:-y,y:y*(V?-1:1),width:l+c,height:l})))});function Vl(){const e=new Map;return{emit(t,n){var o;(o=e.get(t))==null||o.forEach(i=>i(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var o;e.set(t,((o=e.get(t))==null?void 0:o.filter(i=>i!==n))||[])}}}const Ol=E.createContext(null),kl=E.createContext(null),jl=()=>{var e;return((e=E.useContext(Ol))==null?void 0:e.id)||null},Xt=()=>E.useContext(kl);function qe(e){return"data-floating-ui-"+e}function xt(e){const t=T.useRef(e);return le(()=>{t.current=e}),t}function Fl(e,t){var n;let o=[],i=(n=e.find(r=>r.id===t))==null?void 0:n.parentId;for(;i;){const r=e.find(l=>l.id===i);i=r==null?void 0:r.parentId,r&&(o=o.concat(r))}return o}function Be(e,t){let n=e.filter(i=>{var r;return i.parentId===t&&((r=i.context)==null?void 0:r.open)}),o=n;for(;o.length;)o=e.filter(i=>{var r;return(r=o)==null?void 0:r.some(l=>{var s;return i.parentId===l.id&&((s=i.context)==null?void 0:s.open)})}),n=n.concat(o);return n}let Ae=new WeakMap,Xe=new WeakSet,Ge={},Ct=0;const Nl=()=>typeof HTMLElement<"u"&&"inert"in HTMLElement.prototype,Do=e=>e&&(e.host||Do(e.parentNode)),Ll=(e,t)=>t.map(n=>{if(e.contains(n))return n;const o=Do(n);return e.contains(o)?o:null}).filter(n=>n!=null);function Ml(e,t,n,o){const i="data-floating-ui-inert",r=o?"inert":n?"aria-hidden":null,l=Ll(t,e),s=new Set,a=new Set(l),c=[];Ge[i]||(Ge[i]=new WeakMap);const x=Ge[i];l.forEach(h),g(t),s.clear();function h(u){!u||s.has(u)||(s.add(u),u.parentNode&&h(u.parentNode))}function g(u){!u||a.has(u)||Array.prototype.forEach.call(u.children,b=>{if(s.has(b))g(b);else{const w=r?b.getAttribute(r):null,m=w!==null&&w!=="false",y=(Ae.get(b)||0)+1,C=(x.get(b)||0)+1;Ae.set(b,y),x.set(b,C),c.push(b),y===1&&m&&Xe.add(b),C===1&&b.setAttribute(i,""),!m&&r&&b.setAttribute(r,"true")}})}return Ct++,()=>{c.forEach(u=>{const b=(Ae.get(u)||0)-1,w=(x.get(u)||0)-1;Ae.set(u,b),x.set(u,w),b||(!Xe.has(u)&&r&&u.removeAttribute(r),Xe.delete(u)),w||u.removeAttribute(i)}),Ct--,Ct||(Ae=new WeakMap,Ae=new WeakMap,Xe=new WeakSet,Ge={})}}function wn(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=he(e[0]).body;return Ml(e.concat(Array.from(o.querySelectorAll("[aria-live]"))),o,t,n)}const Gt=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Vo(e,t){const n=Qt(e,Gt());t==="prev"&&n.reverse();const o=n.indexOf(Re(he(e)));return n.slice(o+1)[0]}function Oo(){return Vo(document.body,"next")}function ko(){return Vo(document.body,"prev")}function $e(e,t){const n=t||e.currentTarget,o=e.relatedTarget;return!o||!ne(n,o)}function Bl(e){Qt(e,Gt()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function $l(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const o=n.dataset.tabindex;delete n.dataset.tabindex,o?n.setAttribute("tabindex",o):n.removeAttribute("tabindex")})}const Jt={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0};let Kl;function Sn(e){e.key==="Tab"&&(e.target,clearTimeout(Kl))}const st=E.forwardRef(function(t,n){const[o,i]=E.useState();le(()=>(vr()&&i("button"),document.addEventListener("keydown",Sn),()=>{document.removeEventListener("keydown",Sn)}),[]);const r={ref:n,tabIndex:0,role:o,"aria-hidden":o?void 0:!0,[qe("focus-guard")]:"",style:Jt};return E.createElement("span",ke({},t,r))}),jo=E.createContext(null),Tn=qe("portal");function Wl(e){let{id:t,root:n}=e===void 0?{}:e;const[o,i]=E.useState(null),r=ht(),l=No(),s=E.useRef(null);return le(()=>()=>{o==null||o.remove(),queueMicrotask(()=>{s.current=null})},[o]),le(()=>{if(s.current)return;const a=t?document.getElementById(t):null;if(!a)return;const c=document.createElement("div");c.id=r,c.setAttribute(Tn,""),a.appendChild(c),s.current=c,i(c)},[t,r]),le(()=>{if(s.current)return;let a=n||(l==null?void 0:l.portalNode);a&&!X(a)&&(a=a.current),a=a||document.body;let c=null;t&&(c=document.createElement("div"),c.id=t,a.appendChild(c));const x=document.createElement("div");x.id=r,x.setAttribute(Tn,""),a=c||a,a.appendChild(x),s.current=x,i(x)},[t,n,r,l]),o}function Fo(e){let{children:t,id:n,root:o=null,preserveTabOrder:i=!0}=e;const r=Wl({id:n,root:o}),[l,s]=E.useState(null),a=E.useRef(null),c=E.useRef(null),x=E.useRef(null),h=E.useRef(null),g=!!l&&!l.modal&&l.open&&i&&!!(o||r);return E.useEffect(()=>{if(!r||!i||l!=null&&l.modal)return;function u(b){r&&$e(b)&&(b.type==="focusin"?$l:Bl)(r)}return r.addEventListener("focusin",u,!0),r.addEventListener("focusout",u,!0),()=>{r.removeEventListener("focusin",u,!0),r.removeEventListener("focusout",u,!0)}},[r,i,l==null?void 0:l.modal]),E.createElement(jo.Provider,{value:E.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:a,afterOutsideRef:c,beforeInsideRef:x,afterInsideRef:h,portalNode:r,setFocusManagerState:s}),[i,r])},g&&r&&E.createElement(st,{"data-type":"outside",ref:a,onFocus:u=>{if($e(u,r)){var b;(b=x.current)==null||b.focus()}else{const w=ko()||(l==null?void 0:l.refs.domReference.current);w==null||w.focus()}}}),g&&r&&E.createElement("span",{"aria-owns":r.id,style:Jt}),r&&Gn.createPortal(t,r),g&&r&&E.createElement(st,{"data-type":"outside",ref:c,onFocus:u=>{if($e(u,r)){var b;(b=h.current)==null||b.focus()}else{const w=Oo()||(l==null?void 0:l.refs.domReference.current);w==null||w.focus(),l!=null&&l.closeOnFocusOut&&(l==null||l.onOpenChange(!1,u.nativeEvent))}}}))}const No=()=>E.useContext(jo),En=20;let ve=[];function vt(e){ve=ve.filter(t=>t.isConnected),e&&me(e)!=="body"&&(ve.push(e),ve.length>En&&(ve=ve.slice(-En)))}function An(){return ve.slice().reverse().find(e=>e.isConnected)}const ql=E.forwardRef(function(t,n){return E.createElement("button",ke({},t,{type:"button",ref:n,tabIndex:-1,style:Jt}))});function Lo(e){const{context:t,children:n,disabled:o=!1,order:i=["content"],guards:r=!0,initialFocus:l=0,returnFocus:s=!0,modal:a=!0,visuallyHiddenDismiss:c=!1,closeOnFocusOut:x=!0}=e,{open:h,refs:g,nodeId:u,onOpenChange:b,events:w,dataRef:m,elements:{domReference:y,floating:C}}=t,P=typeof l=="number"&&l<0,S=Ar(y)&&P,R=Nl()?r:!0,I=xt(i),V=xt(l),D=xt(s),F=Xt(),A=No(),N=E.useRef(null),B=E.useRef(null),W=E.useRef(!1),H=E.useRef(!1),j=A!=null,$=E.useCallback(function(z){return z===void 0&&(z=C),z?Qt(z,Gt()):[]},[C]),O=E.useCallback(z=>{const q=$(z);return I.current.map(K=>y&&K==="reference"?y:C&&K==="floating"?C:q).filter(Boolean).flat()},[y,C,I,$]);E.useEffect(()=>{if(o||!a)return;function z(K){if(K.key==="Tab"){ne(C,Re(he(C)))&&$().length===0&&!S&>(K);const U=O(),Q=Ie(K);I.current[0]==="reference"&&Q===y&&(gt(K),K.shiftKey?Ce(U[U.length-1]):Ce(U[1])),I.current[1]==="floating"&&Q===C&&K.shiftKey&&(gt(K),Ce(U[0]))}}const q=he(C);return q.addEventListener("keydown",z),()=>{q.removeEventListener("keydown",z)}},[o,y,C,a,I,S,$,O]),E.useEffect(()=>{if(o||!x)return;function z(){H.current=!0,setTimeout(()=>{H.current=!1})}function q(K){const U=K.relatedTarget;queueMicrotask(()=>{const Q=!(ne(y,U)||ne(C,U)||ne(U,C)||ne(A==null?void 0:A.portalNode,U)||U!=null&&U.hasAttribute(qe("focus-guard"))||F&&(Be(F.nodesRef.current,u).find(Y=>{var Z,ce;return ne((Z=Y.context)==null?void 0:Z.elements.floating,U)||ne((ce=Y.context)==null?void 0:ce.elements.domReference,U)})||Fl(F.nodesRef.current,u).find(Y=>{var Z,ce;return((Z=Y.context)==null?void 0:Z.elements.floating)===U||((ce=Y.context)==null?void 0:ce.elements.domReference)===U})));U&&Q&&!H.current&&U!==An()&&(W.current=!0,b(!1,K))})}if(C&&te(y))return y.addEventListener("focusout",q),y.addEventListener("pointerdown",z),!a&&C.addEventListener("focusout",q),()=>{y.removeEventListener("focusout",q),y.removeEventListener("pointerdown",z),!a&&C.removeEventListener("focusout",q)}},[o,y,C,a,u,F,A,b,x]),E.useEffect(()=>{var z;if(o)return;const q=Array.from((A==null||(z=A.portalNode)==null?void 0:z.querySelectorAll("["+qe("portal")+"]"))||[]);if(C){const K=[C,...q,N.current,B.current,I.current.includes("reference")||S?y:null].filter(Q=>Q!=null),U=a||S?wn(K,R,!R):wn(K);return()=>{U()}}},[o,y,C,a,I,A,S,R]),le(()=>{if(o||!C)return;const z=he(C),q=Re(z);queueMicrotask(()=>{const K=O(C),U=V.current,Q=(typeof U=="number"?K[U]:U.current)||C,Y=ne(C,q);!P&&!Y&&h&&Ce(Q,{preventScroll:Q===C})})},[o,h,C,P,O,V]),le(()=>{if(o||!C)return;let z=!1;const q=he(C),K=Re(q),U=m.current;vt(K);function Q(Y){let{reason:Z,event:ce,nested:Me}=Y;Z==="escape-key"&&g.domReference.current&&vt(g.domReference.current),Z==="hover"&&ce.type==="mouseleave"&&(W.current=!0),Z==="outside-press"&&(Me?(W.current=!1,z=!0):W.current=!(xr(ce)||Cr(ce)))}return w.on("openchange",Q),()=>{w.off("openchange",Q);const Y=Re(q),Z=ne(C,Y)||F&&Be(F.nodesRef.current,u).some(Ii=>{var on;return ne((on=Ii.context)==null?void 0:on.elements.floating,Y)});(Z||U.openEvent&&["click","mousedown"].includes(U.openEvent.type))&&g.domReference.current&&vt(g.domReference.current);const Me=An();D.current&&!W.current&&te(Me)&&(!(Me!==Y&&Y!==q.body)||Z)&&Ce(Me,{cancelPrevious:!1,preventScroll:z})}},[o,C,D,m,g,w,F,u]),le(()=>{if(!(o||!A))return A.setFocusManagerState({modal:a,closeOnFocusOut:x,open:h,onOpenChange:b,refs:g}),()=>{A.setFocusManagerState(null)}},[o,A,a,h,b,g,x]),le(()=>{if(o||!C||typeof MutationObserver!="function"||P)return;const z=()=>{const K=C.getAttribute("tabindex");I.current.includes("floating")||Re(he(C))!==g.domReference.current&&$().length===0?K!=="0"&&C.setAttribute("tabindex","0"):K!=="-1"&&C.setAttribute("tabindex","-1")};z();const q=new MutationObserver(z);return q.observe(C,{childList:!0,subtree:!0,attributes:!0}),()=>{q.disconnect()}},[o,C,g,I,$,P]);function L(z){return o||!c||!a?null:E.createElement(ql,{ref:z==="start"?N:B,onClick:q=>b(!1,q.nativeEvent)},typeof c=="string"?c:"Dismiss")}const ee=!o&&R&&(j||a);return E.createElement(E.Fragment,null,ee&&E.createElement(st,{"data-type":"inside",ref:A==null?void 0:A.beforeInsideRef,onFocus:z=>{if(a){const K=O();Ce(i[0]==="reference"?K[0]:K[K.length-1])}else if(A!=null&&A.preserveTabOrder&&A.portalNode)if(W.current=!1,$e(z,A.portalNode)){const K=Oo()||y;K==null||K.focus()}else{var q;(q=A.beforeOutsideRef.current)==null||q.focus()}}}),!S&&L("start"),n,L("end"),ee&&E.createElement(st,{"data-type":"inside",ref:A==null?void 0:A.afterInsideRef,onFocus:z=>{if(a)Ce(O()[0]);else if(A!=null&&A.preserveTabOrder&&A.portalNode)if(x&&(W.current=!0),$e(z,A.portalNode)){const K=ko()||y;K==null||K.focus()}else{var q;(q=A.afterOutsideRef.current)==null||q.focus()}}}))}const wt=new Set,Mo=E.forwardRef(function(t,n){let{lockScroll:o=!1,...i}=t;const r=ht();return le(()=>{if(!o)return;wt.add(r);const l=/iP(hone|ad|od)|iOS/.test(fo()),s=document.body.style,c=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",x=window.innerWidth-document.documentElement.clientWidth,h=s.left?parseFloat(s.left):window.pageXOffset,g=s.top?parseFloat(s.top):window.pageYOffset;if(s.overflow="hidden",x&&(s[c]=x+"px"),l){var u,b;const w=((u=window.visualViewport)==null?void 0:u.offsetLeft)||0,m=((b=window.visualViewport)==null?void 0:b.offsetTop)||0;Object.assign(s,{position:"fixed",top:-(g-Math.floor(m))+"px",left:-(h-Math.floor(w))+"px",right:"0"})}return()=>{wt.delete(r),wt.size===0&&(Object.assign(s,{overflow:"",[c]:""}),l&&(Object.assign(s,{position:"",top:"",left:"",right:""}),window.scrollTo(h,g)))}},[r,o]),E.createElement("div",ke({ref:n},i,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...i.style}}))});function Rn(e){return te(e.target)&&e.target.tagName==="BUTTON"}function In(e){return ho(e)}function Bo(e,t){t===void 0&&(t={});const{open:n,onOpenChange:o,dataRef:i,elements:{domReference:r}}=e,{enabled:l=!0,event:s="click",toggle:a=!0,ignoreMouse:c=!1,keyboardHandlers:x=!0}=t,h=E.useRef(),g=E.useRef(!1);return E.useMemo(()=>l?{reference:{onPointerDown(u){h.current=u.pointerType},onMouseDown(u){u.button===0&&(dn(h.current,!0)&&c||s!=="click"&&(n&&a&&(!i.current.openEvent||i.current.openEvent.type==="mousedown")?o(!1,u.nativeEvent,"click"):(u.preventDefault(),o(!0,u.nativeEvent,"click"))))},onClick(u){if(s==="mousedown"&&h.current){h.current=void 0;return}dn(h.current,!0)&&c||(n&&a&&(!i.current.openEvent||i.current.openEvent.type==="click")?o(!1,u.nativeEvent,"click"):o(!0,u.nativeEvent,"click"))},onKeyDown(u){h.current=void 0,!(u.defaultPrevented||!x||Rn(u))&&(u.key===" "&&!In(r)&&(u.preventDefault(),g.current=!0),u.key==="Enter"&&o(!(n&&a),u.nativeEvent,"click"))},onKeyUp(u){u.defaultPrevented||!x||Rn(u)||In(r)||u.key===" "&&g.current&&(g.current=!1,o(!(n&&a),u.nativeEvent,"click"))}}}:{},[l,i,s,c,x,r,a,n,o])}const zl={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Hl={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Pn=e=>{var t,n;return{escapeKey:typeof e=="boolean"?e:(t=e==null?void 0:e.escapeKey)!=null?t:!1,outsidePress:typeof e=="boolean"?e:(n=e==null?void 0:e.outsidePress)!=null?n:!0}};function $o(e,t){t===void 0&&(t={});const{open:n,onOpenChange:o,nodeId:i,elements:{reference:r,domReference:l,floating:s},dataRef:a}=e,{enabled:c=!0,escapeKey:x=!0,outsidePress:h=!0,outsidePressEvent:g="pointerdown",referencePress:u=!1,referencePressEvent:b="pointerdown",ancestorScroll:w=!1,bubbles:m,capture:y}=t,C=Xt(),P=Pe(typeof h=="function"?h:()=>!1),S=typeof h=="function"?P:h,R=E.useRef(!1),I=E.useRef(!1),{escapeKey:V,outsidePress:D}=Pn(m),{escapeKey:F,outsidePress:A}=Pn(y),N=Pe(j=>{if(!n||!c||!x||j.key!=="Escape")return;const $=C?Be(C.nodesRef.current,i):[];if(!V&&(j.stopPropagation(),$.length>0)){let O=!0;if($.forEach(L=>{var ee;if((ee=L.context)!=null&&ee.open&&!L.context.dataRef.current.__escapeKeyBubbles){O=!1;return}}),!O)return}o(!1,Sr(j)?j.nativeEvent:j,"escape-key")}),B=Pe(j=>{var $;const O=()=>{var L;N(j),(L=Ie(j))==null||L.removeEventListener("keydown",O)};($=Ie(j))==null||$.addEventListener("keydown",O)}),W=Pe(j=>{const $=R.current;R.current=!1;const O=I.current;if(I.current=!1,g==="click"&&O||$||typeof S=="function"&&!S(j))return;const L=Ie(j),ee="["+qe("inert")+"]",z=he(s).querySelectorAll(ee);let q=X(L)?L:null;for(;q&&!Ve(q);){const Q=Se(q);if(Ve(Q)||!X(Q))break;q=Q}if(z.length&&X(L)&&!Tr(L)&&!ne(L,s)&&Array.from(z).every(Q=>!ne(q,Q)))return;if(te(L)&&s){const Q=L.clientWidth>0&&L.scrollWidth>L.clientWidth,Y=L.clientHeight>0&&L.scrollHeight>L.clientHeight;let Z=Y&&j.offsetX>L.clientWidth;if(Y&&ie(L).direction==="rtl"&&(Z=j.offsetX<=L.offsetWidth-L.clientWidth),Z||Q&&j.offsetY>L.clientHeight)return}const K=C&&Be(C.nodesRef.current,i).some(Q=>{var Y;return yt(j,(Y=Q.context)==null?void 0:Y.elements.floating)});if(yt(j,s)||yt(j,l)||K)return;const U=C?Be(C.nodesRef.current,i):[];if(U.length>0){let Q=!0;if(U.forEach(Y=>{var Z;if((Z=Y.context)!=null&&Z.open&&!Y.context.dataRef.current.__outsidePressBubbles){Q=!1;return}}),!Q)return}o(!1,j,"outside-press")}),H=Pe(j=>{var $;const O=()=>{var L;W(j),(L=Ie(j))==null||L.removeEventListener(g,O)};($=Ie(j))==null||$.addEventListener(g,O)});return E.useEffect(()=>{if(!n||!c)return;a.current.__escapeKeyBubbles=V,a.current.__outsidePressBubbles=D;function j(L){o(!1,L,"ancestor-scroll")}const $=he(s);x&&$.addEventListener("keydown",F?B:N,F),S&&$.addEventListener(g,A?H:W,A);let O=[];return w&&(X(l)&&(O=be(l)),X(s)&&(O=O.concat(be(s))),!X(r)&&r&&r.contextElement&&(O=O.concat(be(r.contextElement)))),O=O.filter(L=>{var ee;return L!==((ee=$.defaultView)==null?void 0:ee.visualViewport)}),O.forEach(L=>{L.addEventListener("scroll",j,{passive:!0})}),()=>{x&&$.removeEventListener("keydown",F?B:N,F),S&&$.removeEventListener(g,A?H:W,A),O.forEach(L=>{L.removeEventListener("scroll",j)})}},[a,s,l,r,x,S,g,n,o,w,c,V,D,N,F,B,W,A,H]),E.useEffect(()=>{R.current=!1},[S,g]),E.useMemo(()=>c?{reference:{onKeyDown:N,[zl[b]]:j=>{u&&o(!1,j.nativeEvent,"reference-press")}},floating:{onKeyDown:N,onMouseDown(){I.current=!0},onMouseUp(){I.current=!0},[Hl[g]]:()=>{R.current=!0}}}:{},[c,u,g,b,o,N])}let Ft;process.env.NODE_ENV!=="production"&&(Ft=new Set);function Ko(e){var t;e===void 0&&(e={});const{open:n=!1,onOpenChange:o,nodeId:i}=e;if(process.env.NODE_ENV!=="production"){var r;const D="Floating UI: Cannot pass a virtual element to the `elements.reference` option, as it must be a real DOM element. Use `refs.setPositionReference` instead.";if((r=e.elements)!=null&&r.reference&&!X(e.elements.reference)){var l;if(!((l=Ft)!=null&&l.has(D))){var s;(s=Ft)==null||s.add(D),console.error(D)}}}const[a,c]=E.useState(null),x=((t=e.elements)==null?void 0:t.reference)||a,h=ll(e),g=Xt(),u=jl()!=null,b=Pe((D,F,A)=>{D&&(m.current.openEvent=F),y.emit("openchange",{open:D,event:F,reason:A,nested:u}),o==null||o(D,F,A)}),w=E.useRef(null),m=E.useRef({}),y=E.useState(()=>Vl())[0],C=ht(),P=E.useCallback(D=>{const F=X(D)?{getBoundingClientRect:()=>D.getBoundingClientRect(),contextElement:D}:D;h.refs.setReference(F)},[h.refs]),S=E.useCallback(D=>{(X(D)||D===null)&&(w.current=D,c(D)),(X(h.refs.reference.current)||h.refs.reference.current===null||D!==null&&!X(D))&&h.refs.setReference(D)},[h.refs]),R=E.useMemo(()=>({...h.refs,setReference:S,setPositionReference:P,domReference:w}),[h.refs,S,P]),I=E.useMemo(()=>({...h.elements,domReference:x}),[h.elements,x]),V=E.useMemo(()=>({...h,refs:R,elements:I,dataRef:m,nodeId:i,floatingId:C,events:y,open:n,onOpenChange:b}),[h,i,C,y,n,b,R,I]);return le(()=>{const D=g==null?void 0:g.nodesRef.current.find(F=>F.id===i);D&&(D.context=V)}),E.useMemo(()=>({...h,context:V,refs:R,elements:I}),[h,R,I,V])}const Dn="active",Vn="selected";function St(e,t,n){const o=new Map,i=n==="item";let r=e;if(i&&e){const{[Dn]:l,[Vn]:s,...a}=e;r=a}return{...n==="floating"&&{tabIndex:-1},...r,...t.map(l=>{const s=l?l[n]:null;return typeof s=="function"?e?s(e):null:s}).concat(e).reduce((l,s)=>(s&&Object.entries(s).forEach(a=>{let[c,x]=a;if(!(i&&[Dn,Vn].includes(c)))if(c.indexOf("on")===0){if(o.has(c)||o.set(c,[]),typeof x=="function"){var h;(h=o.get(c))==null||h.push(x),l[c]=function(){for(var g,u=arguments.length,b=new Array(u),w=0;wm(...b)).find(m=>m!==void 0)}}}else l[c]=x}),l),{})}}function Wo(e){e===void 0&&(e=[]);const t=e,n=E.useCallback(r=>St(r,e,"reference"),t),o=E.useCallback(r=>St(r,e,"floating"),t),i=E.useCallback(r=>St(r,e,"item"),e.map(r=>r==null?void 0:r.item));return E.useMemo(()=>({getReferenceProps:n,getFloatingProps:o,getItemProps:i}),[n,o,i])}function Ul(e={}){const{initialOpen:t=!1,open:n,onOpenChange:o}=e,[i,r]=E.useState(t),l=n??i,s=o??r,a=Ko({open:l,onOpenChange:s}),c=a.context,x=Bo(c,{enabled:n==null}),h=$o(c,{outsidePressEvent:"mousedown"}),g=Wo([x,h]);return E.useMemo(()=>({open:l,setOpen:s,...g,...a}),[l,s,g,a])}const qo=E.createContext(null),zo=()=>{const e=E.useContext(qo);if(e==null)throw new Error("Dialog components must be wrapped in ");return e};function _l({children:e,...t}){const n=Ul(t);return d.jsx(qo.Provider,{value:n,children:e})}const Ho=k.css` display: flex; justify-content: center; align-items: center; z-index: 100; padding: var(--space-md-fixed); `,Ql=k(Mo)` ${Ho}; `,Yl=T.forwardRef((e,t)=>{const{style:n,children:o,components:i,...r}=e,l=zo(),s=Yt([l.refs.setFloating,t]),a=(i==null?void 0:i.Overlay)??Ql;return d.jsx(Fo,{children:d.jsx(a,{lockScroll:!0,children:d.jsx(Lo,{context:l.context,children:d.jsx("div",{ref:s,...l.getFloatingProps(r),children:o})})})})}),Xl=Yl;function Uo(e){const t=T.useContext(Ke),[n,o]=T.useState(t);return d.jsx(Ke.Provider,{value:n,children:e.children})}const Gl=T.forwardRef((e,t)=>{const{setOpen:n}=zo();return d.jsx("button",{type:"button",...e,ref:t,onClick:o=>{var i;(i=e.onClick)==null||i.call(e,o),n(!1)}})}),Jl=Gl,Zl=k.span` color: var(--color-explain-header-value-color); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; `;function _o(e){const{explainQuestion:t}=ye(),{configurationSubjectTitle:n,componentDecisionStateIncludedLabel:o,componentDecisionStateExcludedLabel:i,booleanDecisionStateFalseLabel:r,booleanDecisionStateTrueLabel:l,isBlockedSuffix:s,isNotSatisfiedSuffix:a,generalConflictTitle:c}=Kt();if(!t)return d.jsx("div",{...e,children:c});const x=M.match(t).returnType().with({subject:p.ExplainQuestionSubject.configuration},()=>n).with({subject:p.ExplainQuestionSubject.attribute},g=>dt(g.attributeId)??g.attributeId.localId).with({subject:p.ExplainQuestionSubject.choiceValue},g=>ze(g.attributeId)[g.choiceValueId]??g.choiceValueId).with({subject:p.ExplainQuestionSubject.component,state:p.ComponentDecisionState.Included},()=>o).with({subject:p.ExplainQuestionSubject.component,state:p.ComponentDecisionState.Excluded},()=>i).with({subject:p.ExplainQuestionSubject.boolean,state:!0},()=>l).with({subject:p.ExplainQuestionSubject.boolean,state:!1},()=>r).with({subject:p.ExplainQuestionSubject.numeric},g=>g.state.toString()).exhaustive(),h=M.match(t).returnType().with({question:p.ExplainQuestionType.whyIsStateNotPossible},()=>s).with({question:p.ExplainQuestionType.whyIsNotSatisfied},()=>a).exhaustive();return d.jsxs("div",{...e,children:[d.jsx(Zl,{children:x})," ",h]})}const es=k.div` position: sticky; top: 0; transition: all 0.1s; border-top: 1px solid transparent; &.active { box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); border-color: var(--color-explain-dialog-scroll-shadow-border); } @media only screen and (min-resolution: 2dppx) { border-top-width: 0.5px; } `;function ts(e){const[t,n]=T.useState(!1),o=T.useRef(null);return T.useEffect(()=>{const i=new IntersectionObserver(([l])=>n(!l.isIntersecting),{root:null,threshold:1}),r=o.current;return r&&i.observe(r),()=>{r&&i.unobserve(r)}},[]),d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:o}),d.jsx(es,{...Jn(e,{className:Vi(t&&"active")})})]})}const ns=k(f.motion.div)` position: relative; background-color: var(--color-explain-dialog-fill); backdrop-filter: var(--backdrop-filter-explain-dialog); color: var(--color-explain-dialog-color); outline-offset: -1px; padding-top: 1.1em; border-radius: var(--shape-border-radius-md); box-shadow: var(--shadows-dialog); font-size: var(--text-base-size); font-family: var(--font-primary); display: grid; grid-template-rows: [header] auto [content] auto; grid-template-columns: [header content] 1fr; align-content: start; min-height: min(calc(100vh - var(--space-md) * 2), 350px); max-height: min(calc(100vh - var(--space-md) * 2), 700px); max-width: min(calc(100vw - var(--space-md) * 2), 700px); min-width: min(calc(100vw - var(--space-md) * 2), 500px); `,os=k.div` overflow-y: auto; grid-area: content; padding-left: var(--space-xs-fixed); padding-right: var(--space-xs-fixed); padding-bottom: var(--space-xs-fixed); `,is=k(ts)` margin-left: calc(var(--space-xs-fixed) * -1); margin-right: calc(var(--space-xs-fixed) * -1); `,rs=k(Jl)` position: absolute; right: var(--space-sm-fixed); top: var(--space-sm-fixed); border: none; background-color: transparent; color: inherit; font-size: var(--text-sm); cursor: pointer; border-radius: var(--shape-border-radius-xs); &:focus { outline: 2px solid var(--color-explain-dialog-close-button-outline); outline-offset: 1px; } `,ls=k(_o)` grid-area: header; font-size: var(--text-md); font-weight: 500; font-family: var(--font-heading); margin-bottom: var(--space-xs); overflow: hidden; display: flex; white-space: nowrap; text-overflow: ellipsis; margin-right: var(--space-md); margin-left: calc(var(--space-xs-fixed) + var(--space-sm-fixed)); `,ss={initial:{opacity:0,scale:.5},open:{opacity:1,scale:1,transition:{type:"spring",stiffness:600,damping:40}},close:{opacity:0,scale:.7,transition:{duration:.1,ease:"cubicInOut"}}};function as(e){return d.jsxs(ns,{variants:ss,initial:"initial",animate:"open",exit:"close",children:[d.jsx(ls,{}),d.jsxs(os,{children:[d.jsx(is,{}),e.children]}),d.jsx(rs,{children:d.jsx(et.FontAwesomeIcon,{icon:Ze.faXmark})})]})}const cs=k(Xl)` --color-explain-attribute-value-fill: ${e=>e.attributeValueFill}; --color-explain-attribute-value-add-fill: ${e=>e.attributeValueAddFill}; --color-explain-attribute-value-add-color: ${e=>e.attributeValueAddColor}; --color-explain-attribute-value-remove-fill: ${e=>e.attributeValueRemoveFill}; --color-explain-attribute-value-remove-color: ${e=>e.attributeValueRemoveColor}; --color-explain-header-value-color: ${e=>e.headerValueColor}; --color-explain-dialog-fill: ${e=>e.fill}; --color-explain-dialog-color: ${e=>e.color}; --color-explain-dialog-close-button-outline: ${e=>e.closeButtonOutline}; --color-explain-dialog-apply-solution-button-fill: ${e=>e.applySolutionButtonFill}; --color-explain-dialog-apply-solution-button-color: ${e=>e.applySolutionButtonColor}; --color-explain-dialog-apply-solution-button-outline: ${e=>e.applySolutionButtonOutline}; --color-explain-dialog-explanation-card: ${e=>e.explanationCard}; --color-explain-dialog-scroll-shadow-border: ${e=>e.scrollShadowBorder}; --backdrop-filter-explain-dialog: ${e=>e.backdropFilter}; display: grid; &:focus { outline: none; } `;function us(e){const t=ye(),n=(t==null?void 0:t.displayMode)==="dialog";return d.jsx(_l,{open:n,onOpenChange:o=>!o&&n&&(t==null?void 0:t.dismiss()),children:d.jsx(ds,{...e,isOpen:n,children:T.Children.toArray(e.content)[0]??d.jsx(as,{children:d.jsx(gr,{})})})})}function ds(e){return d.jsx(f.AnimatePresence,{initial:!1,children:e.isOpen&&d.jsx($t.Provider,{value:e,children:d.jsx(cs,{...e,components:{Overlay:ps},children:d.jsx(Uo,{children:e.children})})})})}const fs=k(f.motion(Mo))` ${Ho} `;function ps(e){return d.jsx(fs,{...e,initial:{backgroundColor:"rgba(0,0,0,0)"},animate:{backgroundColor:"rgba(0,0,0,0.1)"},exit:{backgroundColor:"rgba(0,0,0,0)"}})}function hs(e){const[t,n]=T.useState(null),{explain:o,applySolution:i}=_.useExplain(),r=T.useRef(null),l=T.useCallback(async(u,b,w,m)=>{const y=Oi.guid();r.current=y,n(null);try{const C=await u(),P=C,S=C,R=(P==null?void 0:P.decisionExplanations)??[],I=(S==null?void 0:S.constraintExplanations)??[];y==r.current&&n({controlId:m,displayMode:R.length===0&&I.length>0?"dialog":w,explainQuestion:b,hasError:!1,decisionExplanations:ms(R),constraintExplanations:I})}catch{y==r.current&&n({controlId:m,displayMode:w,explainQuestion:b,hasError:!0,decisionExplanations:null,constraintExplanations:null})}},[]),s=T.useCallback((u,b,w)=>{const m=typeof u=="function"?u(p.explainQuestionBuilder):u;return l(()=>e.explainConstraints?o(m,"full"):o(m,"decisions"),m,b,w)},[e.explainConstraints,o,l]),a=T.useCallback((u,b,w)=>l(()=>Promise.resolve(u),null,b,w),[l]),c=T.useCallback(()=>{n(null)},[]),x=T.useCallback(u=>(c(),i(u)),[i,c]),h=T.useCallback(u=>{n(b=>b!=null?{...b,displayMode:u}:b)},[]),g=T.useMemo(()=>({process:t,applySolution:x,explain:s,handleExplainAnswer:a,dismiss:c,switchMode:h}),[t,x,s,a,c,h]);return d.jsx(Ke.Provider,{value:g,children:e.children})}function ms(e){const t=v.pipe(v.Bool.Ord,v.Ord.contramap(o=>o.solution==null)),n=v.pipe(v.Num.Ord,v.Ord.contramap(o=>o.causedByDecisions.length));return v.pipe(e,v.RA.sortBy([t,n]))}const je=new Map;function at(e){const{singletonId:t,children:n}=e,[o,i]=T.useState(!1),r=T.useRef({chose:()=>i(!0)});return T.useEffect(()=>(ys(t,r.current),()=>gs(t,r.current)),[]),o?d.jsx(d.Fragment,{children:n}):null}function ys(e,t){xs(e).candidates.add(t),Qo(e)}function gs(e,t){let n=je.get(e);n!=null&&(n.candidates.delete(t),n.chosen===t&&(n.chosen=null),bs(e),Qo(e))}function Qo(e){let t=je.get(e);if(t==null||t.chosen!=null)return;const n=t.candidates.values().next().value;n!=null&&(t.chosen=n,n.chose())}function bs(e){let t=je.get(e);t==null||t.candidates.size>0||je.delete(e)}function xs(e){let t=je.get(e);return t==null&&(t={chosen:null,candidates:new Set},je.set(e,t)),t}const re={attributeId:{title:"Attribute Id",type:f.ControlType.String},componentPath:{title:"Component Path",type:f.ControlType.String},sharedConfigurationModel:{title:"Shared Configuration Model",type:f.ControlType.String}},On={description:{title:"Description",type:f.ControlType.String},regex:{title:"Regex",type:f.ControlType.String},direction:{title:"Direction",type:f.ControlType.Enum,defaultValue:"asc",options:["asc","desc"],displaySegmentedControl:!0},mode:{title:"Mode",type:f.ControlType.Enum,defaultValue:"isMatch",options:["isMatch","string","numeric"]}},Cs={choiceValueSorting:{title:"Choice Value Sorting",type:f.ControlType.Object,defaultValue:null,buttonTitle:"Definition…",controls:{defaultRules:{title:"Default Rules",type:f.ControlType.Array,control:{type:f.ControlType.Object,controls:On}},attributes:{title:"Attribute",type:f.ControlType.Array,control:{type:f.ControlType.Object,controls:{...re,choiceValues:{title:"Choice Values",type:f.ControlType.Array,control:{type:f.ControlType.String}},rules:{title:"Rules",type:f.ControlType.Array,control:{type:f.ControlType.Object,controls:On}}}}},jsonDefinition:{title:"Definition – JSON",type:f.ControlType.String,displayTextArea:!0}}}};function vs(e,t){const n=[],o=(r,l)=>{const s=n.find(c=>e.equals(c.first,r)&&e.equals(c.second,l));if(s)return s.ordering;const a=t.compare(r,l);return n.push({first:r,second:l,ordering:a}),a},i=v.Ord.fromCompare(o);return{cachedOrderings:n,...i}}function ws(){const e=[];return{getCache:(t,n)=>{const o=e.find(r=>r.eq===t&&r.ord===n);if(o)return o.ordCache;const i=vs(t,n);return e.push({eq:t,ord:n,ordCache:i}),i}}}const Yo=v.Ord.getMonoid(),Ss=new Intl.Collator("en",{sensitivity:"base"}),Ts=new Intl.Collator("en",{sensitivity:"variant"}),Es={regex:".*",direction:"asc",mode:"string"},As=v.pipe([Ss,Ts],v.RA.map(js),v.MO.concatAll(v.Ord.getMonoid())),Rs=v.pipe(v.Bool.Ord,v.Ord.contramap(e=>v.O.isSome(e))),Is=v.Num.Ord;function Ps(e,t){return v.pipe((t==null?void 0:t.attributes)??[],v.RA.findFirst(n=>p.globalAttributeIdEq.equals(J(n),e)),v.O.map(n=>[Ds(n.choiceValues??[]),kn(n.rules??[])]),v.O.getOrElse(()=>[kn((t==null?void 0:t.defaultRules)??[])]),v.RA.append(Xo(Es)),v.MO.concatAll(Yo))}function Ds(e){return v.pipe(v.Num.Ord,v.Ord.reverse,v.O.getOrd,v.Ord.reverse,v.Ord.contramap(t=>v.pipe(e,v.RA.findIndex(n=>v.Str.Eq.equals(t,n)))))}function kn(e){return v.pipe(e,v.RA.map(Xo),v.MO.concatAll(Yo))}function Xo(e){const t=v.O.tryCatch(()=>new RegExp(e.regex)),n=M.match(e.mode).returnType().with("string",()=>Vs(e.direction)).with("numeric",()=>Os(e.direction)).with("isMatch",()=>ks(e.direction)).exhaustive();return v.pipe(n,v.Ord.contramap(o=>v.pipe(t,v.O.chainNullableK(i=>(i.lastIndex=0,i[Symbol.match](o))),v.O.chain(i=>v.pipe(i,v.RA.lookup(1),v.O.alt(()=>v.pipe(i,v.RA.lookup(0))))))))}function Vs(e){return v.pipe(As,Zt(e),Go)}function Os(e){return v.pipe(Is,Zt(e),Go,v.Ord.contramap(v.O.chain(v.Num.parseFloatO)))}function ks(e){return v.pipe(Rs,Zt(e))}function Go(e){return v.pipe(e,v.Ord.reverse,v.O.getOrd,v.Ord.reverse)}function Zt(e){return t=>M.match(e).returnType().with("asc",()=>t).with("desc",()=>v.Ord.reverse(t)).exhaustive()}function js(e){return v.Ord.fromCompare((t,n)=>M.match(e.compare(t,n)).returnType().with(M.P.number.gt(0),()=>1).with(M.P.number.lt(0),()=>-1).otherwise(()=>0))}const Fs=ws(),Jo=T.createContext(null);function ct(e,t,n){const o=T.useContext(Jo),i=T.useMemo(()=>v.pipe(Ps(e,o),l=>Fs.getCache(v.Str.Eq,l),v.Ord.contramap(l=>t.get(l.id)??l.id)),[t]),{attribute:r}=_.useChoiceAttribute(e);return v.pipe(n??(r==null?void 0:r.values)??[],v.RA.sort(i))}const Ns={localization:{title:"Localization",type:f.ControlType.Object,defaultValue:null,buttonTitle:"Definition…",controls:{jsonDefinition:{title:"Definition – JSON",type:f.ControlType.String,displayTextArea:!0}}}},Zo=se(e=>{const{hcaBaseUrl:t,sessionCreation:n,accessToken:o,sessionCreateUrl:i,sessionDeleteUrl:r,deploymentName:l,channel:s,children:a,explainDialogProps:c,explainPopoverProps:x,explainConstraints:h}=e,{activeLocale:g}=f.useLocaleInfo(),u=g.code;if(T.useEffect(()=>{console.info("Current locale code:",u)},[u]),G())return d.jsxs(d.Fragment,{children:[a,d.jsx(at,{singletonId:"Configuration",children:d.jsx(rn,{})})]});const w=T.useMemo(()=>{var P;return v.pipe(v.O.fromNullable((P=e.attributeRelations)==null?void 0:P.jsonDefinition),v.O.filter(S=>S.length>0),v.O.map(S=>JSON.parse(S)),v.O.toNullable)},[e.attributeRelations]),m=T.useMemo(()=>{var P;return v.pipe(v.O.fromNullable((P=e.choiceValueSorting)==null?void 0:P.jsonDefinition),v.O.filter(S=>S.length>0),v.O.map(S=>JSON.parse(S)),v.O.orElse(()=>v.O.fromNullable(e.choiceValueSorting)),v.O.getOrElse(()=>({attributes:[],defaultRules:[]})))},[e.choiceValueSorting]),y=T.useMemo(()=>{var P;return v.pipe(v.O.fromNullable((P=e.localization)==null?void 0:P.jsonDefinition),v.O.filter(S=>S.length>0),v.O.map(S=>JSON.parse(S)),v.O.getOrElse(()=>({attributes:[],choiceValues:[]})))},[e.localization]),C=T.useMemo(()=>({apiBaseUrl:Pi(t,"api","engine"),sessionInitialisationOptions:M.match(n).with("client-side",()=>({accessToken:o})).with("server-side",()=>({sessionCreateUrl:i})).exhaustive(),configurationModelSource:{type:p.ConfigurationModelSourceType.Channel,channel:s,deploymentName:l},attributeRelations:w,allowedInExplain:{rules:{type:p.AllowedRulesInExplainType.all}}}),[t,n,o,i,r,s,l,w]);return d.jsxs(d.Fragment,{children:[d.jsxs(_.Configuration,{sessionContext:C,children:[d.jsx(Ki,{...e}),d.jsx(T.Suspense,{children:d.jsx(ut.Provider,{value:y,children:d.jsxs(hs,{explainConstraints:h,children:[d.jsx(Mt.Provider,{value:x,children:d.jsx(Jo.Provider,{value:m,children:a})}),d.jsx(us,{...c})]})})})]}),d.jsx(at,{singletonId:"Configuration",children:d.jsx(rn,{})})]})}),Ls=Zo;f.addPropertyControls(Zo,{children:{title:"Content",type:f.ControlType.ComponentInstance},channel:{type:f.ControlType.String,title:"Channel",defaultValue:"release"},deploymentName:{type:f.ControlType.String,title:"Deployment Name"},hcaBaseUrl:{title:"HCA Base URL",type:f.ControlType.String,defaultValue:"https://spc.cloud.ceventis.de/hca"},sessionCreation:{title:"Session Creation",type:f.ControlType.Enum,displaySegmentedControl:!0,segmentedControlDirection:"horizontal",defaultValue:"client-side",options:["client-side","server-side"]},accessToken:{title:"HCA Access Token",type:f.ControlType.String,obscured:!0,hidden:e=>e.sessionCreation!=="client-side"},sessionCreateUrl:{title:"Create Session URl",type:f.ControlType.String,hidden:e=>e.sessionCreation!=="server-side"},sessionDeleteUrl:{title:"Close Session URl",type:f.ControlType.String,hidden:e=>e.sessionCreation!=="server-side"},configurationModelNotFoundContent:{title:"Content – Configuration Model not found",type:f.ControlType.ComponentInstance},errorContent:{title:"Content – Error",type:f.ControlType.ComponentInstance},accessTokenInvalidContent:{title:"Content – HCA Access Token invalid",type:f.ControlType.ComponentInstance},accessTokenRestrictionContent:{title:"Content – HCA Access Token restriction",type:f.ControlType.ComponentInstance},explainDialogProps:{title:"Explain Dialog",type:f.ControlType.Object,optional:!1,controls:Gi,buttonTitle:"Props…"},explainPopoverProps:{title:"Explain Popover",type:f.ControlType.Object,optional:!1,controls:Xi,buttonTitle:"Props…"},explainConstraints:{title:"Explain Constraints",type:f.ControlType.Boolean,defaultValue:!1},attributeRelations:{title:"Attribute Relations",type:f.ControlType.Object,defaultValue:null,buttonTitle:"Definition…",controls:{jsonDefinition:{title:"Definition – JSON",type:f.ControlType.String,displayTextArea:!0}}},...Cs,...Ns});const ei={padding:{type:f.ControlType.FusedNumber,title:"Padding",toggleKey:"isMixedPadding",toggleTitles:["Padding","Padding per Side"],valueKeys:["paddingTop","paddingRight","paddingBottom","paddingLeft"],valueLabels:["Top","Right","Bottom","Left"],min:0,defaultValue:0}},Ms=e=>({paddingTop:e.isMixedPadding?e.paddingTop:e.padding,paddingRight:e.isMixedPadding?e.paddingRight:e.padding,paddingBottom:e.isMixedPadding?e.paddingBottom:e.padding,paddingLeft:e.isMixedPadding?e.paddingLeft:e.padding}),Bs={radius:{title:"Radius",type:f.ControlType.Number,defaultValue:6},...ei,border:{title:"Border",type:f.ControlType.Object,controls:{color:{type:f.ControlType.Color,title:"Color"},width:{type:f.ControlType.FusedNumber,title:"Width",toggleKey:"isMixedWidth",toggleTitles:["Width","Width per Side"],valueKeys:["widthTop","widthRight","widthBottom","widthLeft"],valueLabels:["Top","Right","Bottom","Left"],min:0,defaultValue:0}}}},$s=e=>{var t,n,o,i,r,l,s,a,c,x,h,g,u;return{borderRadius:e.radius,borderColor:(t=e.border)==null?void 0:t.color,borderTopWidth:(n=e.border)!=null&&n.isMixedWidth?(o=e.border)==null?void 0:o.widthTop:(i=e.border)==null?void 0:i.width,borderRightWidth:(r=e.border)!=null&&r.isMixedWidth?(l=e.border)==null?void 0:l.widthRight:(s=e.border)==null?void 0:s.width,borderBottomWidth:(a=e.border)!=null&&a.isMixedWidth?(c=e.border)==null?void 0:c.widthBottom:(x=e.border)==null?void 0:x.width,borderLeftWidth:(h=e.border)!=null&&h.isMixedWidth?(g=e.border)==null?void 0:g.widthLeft:(u=e.border)==null?void 0:u.width}},Ks={fill:{title:"Fill",type:f.ControlType.Color,defaultValue:"#EBEBEB"},...ei,...Bs},Ws=e=>({...Ms(e),...$s(e),backgroundColor:e.fill}),qs={color:{title:"Color",type:f.ControlType.Color,defaultValue:"black"},text:{title:"Text",type:f.ControlType.Font,controls:"basic",displayTextAlignment:!0,displayFontSize:!0}},zs=e=>({...e.text,color:e.color}),Ne={explain:{title:"Explain",type:f.ControlType.Enum,defaultValue:"popover",options:["popover","dialog","disabled"]}},Nt={type:f.ControlType.Object,optional:!0,controls:{fill:{title:"Fill",type:f.ControlType.Color,optional:!0},color:{title:"Color",type:f.ControlType.Color,optional:!0},borderColor:{title:"Border Color",type:f.ControlType.Color,optional:!0}}},ti={...re,...qs,...Ks,implicitLabelPrefix:{title:"Implicit Label Prefix",type:f.ControlType.String,defaultValue:"Implicit: "},unsatisfiedColors:{...Nt,title:"Unsatisfied Colors"},implicitSelectedColors:{...Nt,title:"Implicit Selected Colors"},...Ne},Lt=(e,t,n)=>{var r,l,s,a,c,x;const o=Ws(e),i=zs(e);return{...o,...i,backgroundColor:M.match({isSatisfied:t,isImplicitSelected:n,unsatisfiedFill:(r=e.unsatisfiedColors)==null?void 0:r.fill,implicitSelectedFill:(l=e.implicitSelectedColors)==null?void 0:l.fill}).with({isSatisfied:!1,unsatisfiedFill:M.P.string.minLength(1)},h=>h.unsatisfiedFill).with({isImplicitSelected:!0,implicitSelectedFill:M.P.string.minLength(1)},h=>h.implicitSelectedFill).otherwise(()=>o.backgroundColor),borderColor:M.match({isSatisfied:t,isImplicitSelected:n,unsatisfiedBorderColor:(s=e.unsatisfiedColors)==null?void 0:s.borderColor,implicitSelectedBorderColor:(a=e.implicitSelectedColors)==null?void 0:a.borderColor}).with({isSatisfied:!1,unsatisfiedBorderColor:M.P.string.minLength(1)},h=>h.unsatisfiedBorderColor).with({isImplicitSelected:!0,implicitSelectedBorderColor:M.P.string.minLength(1)},h=>h.implicitSelectedBorderColor).otherwise(()=>o.borderColor),color:M.match({isSatisfied:t,isImplicitSelected:n,unsatisfiedColor:(c=e.unsatisfiedColors)==null?void 0:c.color,implicitSelectedColor:(x=e.implicitSelectedColors)==null?void 0:x.color}).with({isSatisfied:!1,unsatisfiedColor:M.P.string.minLength(1)},h=>h.unsatisfiedColor).with({isImplicitSelected:!0,implicitSelectedColor:M.P.string.minLength(1)},h=>h.implicitSelectedColor).otherwise(()=>i.color),...e.style}},en={...ti,resetLabel:{title:"Reset Label",type:f.ControlType.String,defaultValue:"Reset"},blockedLabel:{title:"Blocked Label",type:f.ControlType.String,defaultValue:"Blocked"},appearance:{title:"Appearance",type:f.ControlType.Enum,defaultValue:"auto",displaySegmentedControl:!0,segmentedControlDirection:"horizontal",options:["auto","none"]}},Fe=(e,t,n)=>({...Lt(e,t,n),appearance:e.appearance});function de(){const{explain:e,handleExplainAnswer:t}=T.useContext(Ke);return{explain:e,handleExplainAnswer:t}}function Hs(e={}){const{initialOpen:t=!1,placement:n="top",modal:o=!1,open:i,onOpenChange:r,arrow:l}=e,[s,a]=T.useState(t),c=i??s,x=r??a,h=Ko({placement:n,open:c,onOpenChange:x,whileElementsMounted:tl,middleware:[Mr(((l==null?void 0:l.height)??0)+5),ol({crossAxis:n.includes("-"),fallbackAxisSideDirection:"end",padding:5}),nl({padding:5}),...l?[rl(l)]:[]]}),g=h.context,u=Bo(g,{enabled:i==null}),b=$o(g),w=Wo([u,b]);return T.useMemo(()=>({open:c,setOpen:x,...w,...h,modal:o,arrow:l}),[c,x,w,h,o,l])}const ni=T.createContext(null),Qe=()=>{const e=T.useContext(ni);if(e==null)throw new Error("Popover components must be wrapped in ");return e};function Us({children:e,...t}){const n=Hs(t);return d.jsx(ni.Provider,{value:n,children:e})}const _s=T.forwardRef(function(t,n){const o=T.Children.toArray(t.children)[0],i=Qe(),r=t.children.ref,l=Yt([i.refs.setReference,n,r]);return T.isValidElement(o)?T.cloneElement(o,i.getReferenceProps({ref:l,...t,...o.props,"data-state":i.open?"open":"closed"})):d.jsx("span",{children:"Not valid children for PopoverTrigger"})}),Qs=_s,Ys=k.div` display: flex; justify-content: center; // The Webstorm formatter doesn't support container queries and would be break it. // @formatter:off @container explain-actions (min-width: 300px) { justify-content: start; } `,Xs=k.button` color: inherit; font-size: 0.9em; font-family: var(--framer-font-family, "Inter", "Inter Placeholder", sans-serif); font-weight: 500; appearance: none; border: none; border-radius: var(--shape-border-radius-xs); margin-top: 0.9em; text-decoration: underline; cursor: pointer; background-color: transparent; &:focus { outline: 2px solid var(--color-explain-popover-show-more-button-outline); outline-offset: 1px; } `;function Gs(){const{decisionExplanations:e,switchMode:t}=ye(),{showConstraintsButtonCaption:n,showMoreButtonCaption:o}=Bt(),i=e.length-1,r=T.useMemo(()=>i>0&&ki.render(o,{amount:i}),[o,i]);return d.jsx(Ys,{children:d.jsxs(Xs,{onClick:()=>t("dialog"),children:[i>0&&d.jsx("span",{children:r}),i===0&&d.jsx("span",{children:n})]})})}const Js=k.div` font-weight: 500; font-family: var(--font-heading); margin-bottom: var(--space-xs); `,jn=k.div` height: 1px; background-color: var(--color-explain-popover-list-separator); margin-left: -1.1em; margin-right: -1.1em; @media only screen and (min-resolution: 2dppx) { height: 0.5px; } `,Zs=k.div` container: explain-actions / inline-size; `,ea=k(ro)` display: grid; grid-template-columns: [name] minmax(100px, auto) [values] minmax(100px, 1fr); gap: var(--space-sm); padding-top: var(--space-xs); padding-bottom: var(--space-xs); padding-right: 1.1em; margin-right: -1.1em; overflow: auto; max-height: 200px; `,ta=k(eo)` border-radius: 360px; background-color: var(--color-explain-popover-apply-solution-button-fill); color: var(--color-explain-popover-apply-solution-button-color); font-size: 0.9em; font-family: var(--framer-font-family, "Inter", "Inter Placeholder", sans-serif); font-weight: 600; appearance: none; padding: 0.6em 2em; border: none; width: 100%; margin-top: 1.1em; &:focus { outline: 2px solid var(--color-explain-popover-apply-solution-button-outline); outline-offset: 1px; } // The Webstorm formatter doesn't support container queries and would be break it. // @formatter:off @container explain-actions (min-width: 300px) { width: auto; } `,Tt=k(so)` width: min-content; min-width: 300px; `;function na(){const{decisionExplanations:e,constraintExplanations:t,hasError:n}=ye(),{solutionTitle:o,applySolutionButtonCaption:i}=Bt();if(n)return d.jsx(Tt,{variant:"failedToExplain"});const r=e[0];if(!r)return d.jsx(Tt,{variant:"noExplanationFound"});if(!r.solution)return d.jsx(Tt,{variant:"noSolutionFound"});const l=r.solution.decisions.filter(s=>s.state!=null);return d.jsxs(d.Fragment,{children:[d.jsx(Js,{children:o}),d.jsx(jn,{}),d.jsx(ea,{blockingDecisions:r.causedByDecisions,desiredDecisions:l}),d.jsx(jn,{}),d.jsxs(Zs,{children:[d.jsx(ta,{explanation:r,children:i}),(e.length>1||t.length>0)&&d.jsx(Gs,{})]})]})}const oi=T.createContext(null),ae=()=>T.useContext(oi);function tn(e){return T.forwardRef((t,n)=>{const o=T.useId();return d.jsx(oi.Provider,{value:o,children:d.jsx(e,{...t,ref:n})})})}const oa=T.forwardRef((e,t)=>{const{style:n,children:o,...i}=e,r=Qe(),l=Yt([r.refs.setFloating,t]);return d.jsx(Fo,{children:d.jsx(Lo,{context:r.context,modal:r.modal,children:d.jsx("div",{ref:l,style:{...r.floatingStyles,...n},...r.getFloatingProps(i),children:o})})})}),ia=oa,ra=T.forwardRef((e,t)=>{const{setOpen:n}=Qe();return d.jsx("button",{type:"button",ref:t,...e,onClick:o=>{var i;(i=e.onClick)==null||i.call(e,o),n(!1)}})}),la=ra,sa=k.div` position: relative; background-color: var(--color-explain-popover-fill); color: var(--color-explain-popover-color); outline-offset: -1px; padding: 1.1em; border-radius: var(--shape-border-radius-md); font-size: var(--text-base-size); font-family: var(--font-primary); min-width: 300px; max-width: 500px; `,aa=k(la)` position: absolute; right: var(--space-sm-fixed); top: var(--space-sm-fixed); border: none; background-color: transparent; color: inherit; font-size: var(--text-sm); cursor: pointer; border-radius: var(--shape-border-radius-xs); &:focus { outline: 2px solid var(--color-explain-popover-close-button-outline); outline-offset: 1px; } `,ca=k(_o)` font-size: var(--text-md); font-weight: 500; font-family: var(--font-heading); margin-bottom: var(--space-xs); overflow: hidden; display: flex; white-space: nowrap; text-overflow: ellipsis; margin-right: var(--space-md); `;function ua(e){return d.jsxs(sa,{children:[d.jsx(ca,{}),e.children,d.jsx(aa,{children:d.jsx(et.FontAwesomeIcon,{icon:Ze.faXmark})})]})}const da=k(ia)` --color-explain-attribute-value-fill: ${e=>e.attributeValueFill}; --color-explain-attribute-value-add-fill: ${e=>e.attributeValueAddFill}; --color-explain-attribute-value-add-color: ${e=>e.attributeValueAddColor}; --color-explain-attribute-value-remove-fill: ${e=>e.attributeValueRemoveFill}; --color-explain-attribute-value-remove-color: ${e=>e.attributeValueRemoveColor}; --color-explain-header-value-color: ${e=>e.headerValueColor}; --color-explain-popover-fill: ${e=>e.fill}; --color-explain-popover-color: ${e=>e.color}; --color-explain-popover-close-button-outline: ${e=>e.closeButtonOutline}; --color-explain-popover-list-separator: ${e=>e.listSeparator}; --color-explain-popover-apply-solution-button-fill: ${e=>e.applySolutionButtonFill}; --color-explain-popover-apply-solution-button-color: ${e=>e.applySolutionButtonColor}; --color-explain-popover-apply-solution-button-outline: ${e=>e.applySolutionButtonOutline}; --color-explain-popover-show-more-button-outline: ${e=>e.showMoreButtonOutline}; z-index: 10; filter: var(--shadows-popover); &:focus { outline: none; } `,fa=k(Dl)` fill: var(--color-explain-popover-fill); `,pa={initial:{opacity:0,scale:0},open:{opacity:1,scale:1,transition:{type:"spring",stiffness:600,damping:40}},close:{opacity:0,scale:0,transition:{duration:.2,ease:"cubicInOut"}}};function ha(e){const t=ye(),n=ae(),o=(t==null?void 0:t.displayMode)==="popover"&&(t==null?void 0:t.controlId)===n,i=T.useRef(null);return d.jsxs(Us,{open:o,onOpenChange:r=>!r&&o&&(t==null?void 0:t.dismiss()),arrow:{width:20,height:10,padding:10,element:i},children:[d.jsx(Qs,{children:e.children}),d.jsxs(ma,{isOpen:o,children:[T.Children.toArray(e.content)[0]??d.jsx(ua,{children:d.jsx(na,{})}),d.jsx(ya,{})]})]})}function ma(e){var g,u;const t=Bt(),{middlewareData:n,arrow:o,placement:i}=Qe(),r=((g=n.arrow)==null?void 0:g.x)??0,l=((u=n.arrow)==null?void 0:u.y)??0,s=(o==null?void 0:o.height)??0,a=(o==null?void 0:o.width)??0,c=r+a/2,x=l+s,h=M.match(i).with("top",()=>`${c}px calc(100% + ${s+5}px)`).with("bottom",()=>`${c}px ${-s-5}px`).with("left",()=>`calc(100% + ${s}px) ${x}px`).with("right",()=>`${-s}px ${x}px`).otherwise(()=>"");return d.jsx(f.AnimatePresence,{initial:!1,children:e.isOpen&&d.jsx(da,{...t,children:d.jsx(f.motion.div,{variants:pa,initial:"initial",animate:"open",exit:"close",style:{transformOrigin:h},children:d.jsx(Uo,{children:e.children})})})})}function ya(){const{context:e,arrow:t}=Qe();return d.jsx(fa,{ref:t.element,context:e,width:t.width,height:t.height})}function ga(e){return T.forwardRef((t,n)=>{const o=G();return t.explain!=="popover"||o?d.jsx(e,{...t}):d.jsx(ha,{children:d.jsx(e,{...t,ref:n})})})}function fe(e){return se(tn(ga(T.forwardRef(e))))}function ue(){alert(`Failed to apply your selection. Please check your internet connection and try again.`)}function ba(){alert(`Failed to reset your configuration. Please check your internet connection and try again.`)}const Fn=k.select` color: inherit; cursor: inherit; `,Nn="",Ln="",ii=fe((e,t)=>{if(G()){const A=Fe(e,!0,!1);return d.jsx(Fn,{style:A})}const o=ae(),i=J(e),r=_.useChoiceAttribute(i);if(!r)return d.jsx("span",{children:"Choice Attribute not found"});const{explain:l}=de(),s=ze(i),{attribute:a,makeDecision:c,clearDecisions:x,isMultiSelect:h,getIncludedChoiceValues:g,getBlockedChoiceValues:u,getAllowedChoiceValues:b}=r,w=ct(i,s,b()),m=ct(i,s,u()),y=g(),C=y.map(A=>A.id),P=C[0]??Ln,S=y.some(A=>{var N;return((N=A.decision)==null?void 0:N.kind)===p.DecisionKind.Explicit}),R=C.length>=1,I=y.some(A=>{var N;return((N=A.decision)==null?void 0:N.kind)===p.DecisionKind.Implicit}),V=w.length===0,D=async A=>{const N=e.explain,B=N!=="disabled"&&(()=>l(W=>W.whyIsStateNotPossible.choice(a.id).choiceValue(A).state(p.ChoiceValueDecisionState.Included),N,o));if(A===Nn)try{await x()}catch{ue()}else if(w.some(W=>W.id===A)){const W=C.some(H=>H===A)?void 0:p.ChoiceValueDecisionState.Included;try{await c(A,W)}catch(H){if(H.type===p.ConfiguratorErrorType.ConflictWithConsequence&&B){await B();return}ue()}}else m.some(W=>W.id===A)&&B&&await B()},F=va(e,a.isSatisfied,I,V);return d.jsxs(Fn,{ref:t,value:h()?C:P,multiple:h(),onChange:A=>D(A.currentTarget.value),style:F,children:[!R&&!h()&&d.jsx("option",{value:Ln}),S&&d.jsx("option",{value:Nn,children:e.resetLabel}),w.map(A=>{var N;return d.jsxs("option",{value:A.id,children:[((N=A.decision)==null?void 0:N.kind)===p.DecisionKind.Implicit?e.implicitLabelPrefix:"",s.get(A.id)??A.id]},A.id)}),m.length>0&&d.jsx("optgroup",{label:e.blockedLabel,children:m.map(A=>d.jsx("option",{value:A.id,children:s.get(A.id)??A.id},A.id))})]})}),xa=ii,Ca={...en,noOptionsAvailableColors:{...Nt,title:"No Options Available Colors"}};f.addPropertyControls(ii,Ca);const va=(e,t,n,o)=>{var r,l,s;const i=Fe(e,t,n);return{...i,backgroundColor:M.match({noOptionsAvailable:o,noOptionsAvailableFill:(r=e.noOptionsAvailableColors)==null?void 0:r.fill}).with({noOptionsAvailable:!0,noOptionsAvailableFill:M.P.string.minLength(1)},a=>a.noOptionsAvailableFill).otherwise(()=>i.backgroundColor),borderColor:M.match({noOptionsAvailable:o,noOptionsAvailableBorderColor:(l=e.noOptionsAvailableColors)==null?void 0:l.borderColor}).with({noOptionsAvailable:!0,noOptionsAvailableBorderColor:M.P.string.minLength(1)},a=>a.noOptionsAvailableBorderColor).otherwise(()=>i.borderColor),color:M.match({noOptionsAvailable:o,noOptionsAvailableColor:(s=e.noOptionsAvailableColors)==null?void 0:s.color}).with({noOptionsAvailable:!0,noOptionsAvailableColor:M.P.string.minLength(1)},a=>a.noOptionsAvailableColor).otherwise(()=>i.color)}},Mn=k.select` color: inherit; cursor: inherit; `,Bn="",Et="",At="yes",$n="no",ri=fe((e,t)=>{var C,P,S;if(G()){const R=Fe(e,!0,!1);return d.jsx(Mn,{style:R})}const o=ae(),i=J(e),r=_.useBooleanAttribute(i),{explain:l}=de();if(!r)return d.jsx("span",{children:"Boolean Attribute not found"});const{attribute:s,makeDecision:a}=r,c=async R=>{var V;const I=((V=s.decision)==null?void 0:V.kind)===p.DecisionKind.Explicit;if(R===Bn&&I)try{await a(void 0)}catch{ue()}else{const D=R===At,F=s.possibleDecisionStates.includes(D),A=e.explain,N=A!=="disabled"&&(()=>l(B=>B.whyIsStateNotPossible.boolean(s.id).state(D),A,o));if(F)try{await a(D)}catch(B){if(B.type===p.ConfiguratorErrorType.ConflictWithConsequence&&N){await N();return}ue()}else N&&await N()}},x=M.match((C=s.decision)==null?void 0:C.state).with(!0,()=>At).with(!1,()=>$n).otherwise(()=>Et),h=((P=s.decision)==null?void 0:P.kind)===p.DecisionKind.Explicit,g=((S=s.decision)==null?void 0:S.kind)===p.DecisionKind.Implicit,u=Fe(e,s.isSatisfied,g),b=s.possibleDecisionStates.includes(!0),w=s.possibleDecisionStates.includes(!1),m=d.jsxs("option",{value:At,children:[Kn(s,!0,e.implicitLabelPrefix),e.trueLabel]}),y=d.jsxs("option",{value:$n,children:[Kn(s,!1,e.implicitLabelPrefix),e.falseLabel]});return d.jsxs(Mn,{ref:t,value:x,onChange:R=>c(R.currentTarget.value),style:u,children:[x===Et&&d.jsx("option",{value:Et}),h&&d.jsx("option",{value:Bn,children:e.resetLabel}),b&&m,w&&y,(!b||!w)&&d.jsxs("optgroup",{label:e.blockedLabel,children:[!b&&m,!w&&y]})]})}),wa=ri,Kn=(e,t,n)=>{var o,i;return((o=e.decision)==null?void 0:o.kind)===p.DecisionKind.Implicit&&((i=e.decision)==null?void 0:i.state)===t?n:""},Sa={...en,trueLabel:{title:"True Label",type:f.ControlType.String,defaultValue:"Yes"},falseLabel:{title:"False Label",type:f.ControlType.String,defaultValue:"No"}};f.addPropertyControls(ri,Sa);const Wn=k.select` color: inherit; cursor: inherit; `,qn="",Rt="",It="included",Pt="excluded",li=fe((e,t)=>{var P,S,R;if(G()){const I=Fe(e,!0,!1);return d.jsx(Wn,{style:I})}const o=ae(),i=J(e),r=_.useComponentAttribute(i),{explain:l}=de();if(!r)return d.jsx("span",{children:"Component Attribute not found"});const{attribute:s,makeDecision:a}=r,c=async I=>{const V=s.possibleDecisionStates.includes(I),D=e.explain,F=D!=="disabled"&&(()=>l(A=>A.whyIsStateNotPossible.component(s.id).state(I),D,o));if(V)try{await a(I)}catch(A){if(A.type===p.ConfiguratorErrorType.ConflictWithConsequence&&F){await F();return}ue()}else F&&await F()},x=async I=>{var D;const V=((D=s.decision)==null?void 0:D.kind)===p.DecisionKind.Explicit;I===qn&&V?await a(void 0):I===It?await c(p.ComponentDecisionState.Included):I===Pt&&await c(p.ComponentDecisionState.Excluded)},h=M.match((P=s.decision)==null?void 0:P.state).with(p.ComponentDecisionState.Included,()=>It).with(p.ComponentDecisionState.Excluded,()=>Pt).otherwise(()=>Rt),g=((S=s.decision)==null?void 0:S.kind)===p.DecisionKind.Explicit,u=((R=s.decision)==null?void 0:R.kind)===p.DecisionKind.Implicit,b=Fe(e,s.isSatisfied,u),w=s.possibleDecisionStates.includes(p.ComponentDecisionState.Included),m=s.possibleDecisionStates.includes(p.ComponentDecisionState.Excluded),y=d.jsxs("option",{value:It,children:[zn(s,p.ComponentDecisionState.Included,e.implicitLabelPrefix),e.includedLabel]}),C=d.jsxs("option",{value:Pt,children:[zn(s,p.ComponentDecisionState.Excluded,e.implicitLabelPrefix),e.excludedLabel]});return d.jsxs(Wn,{ref:t,value:h,onChange:I=>x(I.currentTarget.value),style:b,children:[h===Rt&&d.jsx("option",{value:Rt}),g&&d.jsx("option",{value:qn,children:e.resetLabel}),w&&y,m&&C,(!w||!m)&&d.jsxs("optgroup",{label:e.blockedLabel,children:[!w&&y,!m&&C]})]})}),Ta=li,zn=(e,t,n)=>{var o,i;return((o=e.decision)==null?void 0:o.kind)===p.DecisionKind.Implicit&&((i=e.decision)==null?void 0:i.state)===t?n:""},Ea={...en,includedLabel:{title:"Included Label",type:f.ControlType.String,defaultValue:"Included"},excludedLabel:{title:"Excluded Label",type:f.ControlType.String,defaultValue:"Excluded"}};f.addPropertyControls(li,Ea);function si(e,t,n,o,i=1e3){const[r]=Ni.useForceUpdate(),l=Fi.useDebouncedCallback(g=>{t(g),r()},i),s=T.useRef(n),a=T.useRef(e),c=l.isPending(),x=T.useRef(c);T.useEffect(()=>{e!==a.current&&(a.current=e,c&&(l.cancel(),r()),e!==n&&o(e)),n!==s.current&&(s.current=n,n!==e?(l(n),r()):c&&(l.cancel(),r())),c!==x.current&&(x.current=c,!c&&e!==n&&o(e))},[e,n,l,c]);const h=T.useCallback(()=>{l.isPending()&&l.flush()},[l]);return T.useEffect(()=>()=>h(),[h]),{flush:h}}const Hn=k(ji)` color: inherit; `,ai=fe((e,t)=>{var C,P;if(G()){const S=Lt(e,!0,!1);return d.jsx(Hn,{style:S})}const o=ae(),i=J(e),r=_.useNumericAttribute(i),{explain:l}=de();if(!r)return d.jsx("span",{children:"Numeric Attribute not found"});const{attribute:s,makeDecision:a}=r,c=((C=s.decision)==null?void 0:C.kind)===p.DecisionKind.Implicit,x=Lt(e,s.isSatisfied,c),h=(P=s.decision)==null?void 0:P.state,[g,u]=T.useState(h),{min:b,max:w}=s.range,y=si(h,async S=>{if(Sw){alert(`The value must be greater than or equal to ${w}.`);return}try{await a(S)}catch(R){R.type===p.ConfiguratorErrorType.SetDecisionConflict?e.explain!=="disabled"&&await l(D=>D.whyIsStateNotPossible.numeric(s.id).state(S),e.explain,o):ue()}},g,S=>u(S),e.wait);return d.jsx(Hn,{getInputRef:t,thousandsGroupStyle:"thousand",decimalSeparator:e.decimalSeparator,thousandSeparator:e.thousandSeparator,allowNegative:!0,fixedDecimalScale:!0,decimalScale:s.decimalPlaces,allowEmptyFormatting:!1,displayType:"input",placeholder:e.placeholder,prefix:Ra(s,e.implicitLabelPrefix),onBlur:()=>{y.flush()},onKeyPress:S=>{S.key==="Enter"&&y.flush()},onValueChange:S=>u(S.floatValue),value:g??"",style:x})}),Aa=ai,Ra=(e,t)=>{var n;return((n=e.decision)==null?void 0:n.kind)===p.DecisionKind.Implicit?t:""},Ia={...ti,wait:{title:"Debounce Delay",type:f.ControlType.Number,defaultValue:2e3,min:0,unit:"ms"},decimalSeparator:{title:"Decimal Separator",type:f.ControlType.String,defaultValue:",",maxLength:1},thousandSeparator:{title:"Thousand Separator",type:f.ControlType.String,defaultValue:".",maxLength:1},placeholder:{title:"Placeholder",type:f.ControlType.String,defaultValue:""}};f.addPropertyControls(ai,Ia);const Le={choiceValueId:{title:"Choice Value Id",type:f.ControlType.String}};function pe(e,t){return T.Children.map(e,n=>{if(T.isValidElement(n)){const o=Jn(n.props,t);return T.cloneElement(n,o)}return n})}const ci=fe((e,t)=>{if(G())return e.children;const o=ae(),{makeDecision:i}=_.useMakeDecision(),r=J(e),l=e.choiceValueId??"",s=l.length>0,a=_.useAttributes([r],!1)[0],{explain:c}=de();if(!a)return d.jsx("span",{children:"Attribute not found"});const x=a.type===p.AttributeType.Choice,h=a.type===p.AttributeType.Numeric,g=a.type===p.AttributeType.Boolean,u=a.type===p.AttributeType.Component;if(!x&&s)return d.jsx("span",{children:"Attribute is not a Choice Attribute"});if(h)return d.jsx("span",{children:"Numeric Attribute is not supported"});let b=x?a.values.get(l):null;if(s&&b==null)return d.jsx("span",{children:"Choice Value not found"});const w=P=>M.match({state:P,attribute:a}).with({attribute:{type:p.AttributeType.Choice},state:"undefined"},()=>b.decision==null).with({attribute:{type:p.AttributeType.Choice},state:"included"},()=>{var S,R;return((S=b.decision)==null?void 0:S.state)===p.ChoiceValueDecisionState.Included&&((R=b.decision)==null?void 0:R.kind)===p.DecisionKind.Explicit}).with({attribute:{type:p.AttributeType.Choice},state:"excluded"},()=>{var S,R;return((S=b.decision)==null?void 0:S.state)===p.ChoiceValueDecisionState.Excluded&&((R=b.decision)==null?void 0:R.kind)===p.DecisionKind.Explicit}).with({attribute:{type:p.AttributeType.Boolean},state:"undefined"},{attribute:{type:p.AttributeType.Component},state:"undefined"},({attribute:S})=>S.decision==null).with({attribute:{type:p.AttributeType.Boolean},state:"true"},({attribute:S})=>{var R,I;return((R=S.decision)==null?void 0:R.state)===!0&&((I=S.decision)==null?void 0:I.kind)===p.DecisionKind.Explicit}).with({attribute:{type:p.AttributeType.Boolean},state:"false"},({attribute:S})=>{var R,I;return((R=S.decision)==null?void 0:R.state)===!1&&((I=S.decision)==null?void 0:I.kind)===p.DecisionKind.Explicit}).with({attribute:{type:p.AttributeType.Component},state:"included"},({attribute:S})=>{var R,I;return((R=S.decision)==null?void 0:R.state)===p.ComponentDecisionState.Included&&((I=S.decision)==null?void 0:I.kind)===p.DecisionKind.Explicit}).with({attribute:{type:p.AttributeType.Component},state:"excluded"},({attribute:S})=>{var R,I;return((R=S.decision)==null?void 0:R.state)===p.ComponentDecisionState.Excluded&&((I=S.decision)==null?void 0:I.kind)===p.DecisionKind.Explicit}).otherwise(()=>!1),m=P=>M.match({isChoiceAttribute:x,isBooleanAttribute:g,isComponentAttribute:u,state:P}).with({isChoiceAttribute:!0,state:"included"},()=>p.ChoiceValueDecisionState.Included).with({isChoiceAttribute:!0,state:"excluded"},()=>p.ChoiceValueDecisionState.Excluded).with({isBooleanAttribute:!0,state:"true"},()=>!0).with({isBooleanAttribute:!0,state:"false"},()=>!1).with({isComponentAttribute:!0,state:"included"},()=>p.ComponentDecisionState.Included).with({isComponentAttribute:!0,state:"excluded"},()=>p.ComponentDecisionState.Excluded).otherwise(()=>null);w(e.toggleFrom);const y=w(e.toggleTo),C=async()=>{const P=y?e.toggleFrom:e.toggleTo,S=m(P),R=u?a.possibleDecisionStates.includes(S):!1,I=g?a.possibleDecisionStates.includes(S):!1,D=(x?b.possibleDecisionStates.includes(S):!1)||I||R,F=e.explain,A=F!=="disabled"&&(async()=>{const N=M.match({isComponentAttribute:u,isBooleanAttribute:g,isChoiceAttribute:x}).returnType().with({isChoiceAttribute:!0},()=>p.ExplainQuestionSubject.choiceValue).with({isBooleanAttribute:!0},()=>p.ExplainQuestionSubject.boolean).with({isComponentAttribute:!0},()=>p.ExplainQuestionSubject.component).otherwise(()=>null);N&&await c({question:p.ExplainQuestionType.whyIsStateNotPossible,subject:N,attributeId:r,choiceValueId:l,state:S},F,o)});if(D||S==null)try{await i({type:a.type,attributeId:r,choiceValueId:l,state:S})}catch(N){if(N.type===p.ConfiguratorErrorType.ConflictWithConsequence&&A){await A();return}ue()}else A&&await A()};return pe(e.children,{onClick:C,ref:t})}),Pa=ci,Da={...re,...Le,children:{title:"Content",type:f.ControlType.ComponentInstance},toggleFrom:{title:"Toggle From",type:f.ControlType.Enum,defaultValue:"undefined",options:["undefined","included","excluded","true","false"]},toggleTo:{title:"Toggle To",type:f.ControlType.Enum,defaultValue:"included",options:["undefined","included","excluded","true","false"]},...Ne};f.addPropertyControls(ci,Da);const ui=fe((e,t)=>{if(G())return e.children;const o=ae(),{makeDecision:i}=_.useMakeDecision(),r=J(e),l=e.choiceValueId??"",s=l.length>0,a=_.useAttributes([r],!1)[0],c=_.useChoiceAttribute(r),{explain:x}=de();if(!a)return d.jsx("span",{children:"Attribute not found"});const h=a.type===p.AttributeType.Choice,g=a.type===p.AttributeType.Numeric,u=a.type===p.AttributeType.Boolean,b=a.type===p.AttributeType.Component;if(!h&&s)return d.jsx("span",{children:"Attribute is not a Choice Attribute"});let w=h?a.values.get(l):null;if(s&&w==null)return d.jsx("span",{children:"Choice Value not found"});const m=()=>M.match({isChoiceAttribute:h,isBooleanAttribute:u,isComponentAttribute:b,isNumericAttribute:g,hasChoiceValueId:s,state:e.setSelection}).with({isChoiceAttribute:!0,hasChoiceValueId:!0,state:"included"},()=>p.ChoiceValueDecisionState.Included).with({isChoiceAttribute:!0,hasChoiceValueId:!0,state:"excluded"},()=>p.ChoiceValueDecisionState.Excluded).with({isBooleanAttribute:!0,state:"true"},()=>!0).with({isBooleanAttribute:!0,state:"false"},()=>!1).with({isComponentAttribute:!0,state:"included"},()=>p.ComponentDecisionState.Included).with({isComponentAttribute:!0,state:"excluded"},()=>p.ComponentDecisionState.Excluded).with({isNumericAttribute:!0,state:"numeric"},()=>e.numericValue).otherwise(()=>null),y=async()=>{if(h&&!s&&e.setSelection==="undefined")try{await c.clearDecisions()}catch{ue()}else{const C=m(),P=b?a.possibleDecisionStates.includes(C):!1,S=u?a.possibleDecisionStates.includes(C):!1,I=(h?w.possibleDecisionStates.includes(C):!1)||S||P,V=e.explain,D=V!=="disabled"&&(async()=>{const F=M.match({isComponentAttribute:b,isBooleanAttribute:u,isChoiceAttribute:h,isNumericAttribute:g}).returnType().with({isChoiceAttribute:!0},()=>p.ExplainQuestionSubject.choiceValue).with({isBooleanAttribute:!0},()=>p.ExplainQuestionSubject.boolean).with({isComponentAttribute:!0},()=>p.ExplainQuestionSubject.component).with({isNumericAttribute:!0},()=>p.ExplainQuestionSubject.numeric).otherwise(()=>null);F&&await x({question:p.ExplainQuestionType.whyIsStateNotPossible,subject:F,attributeId:r,choiceValueId:l,state:C},V,o)});if(g||I||C==null)try{await i({type:a.type,attributeId:r,choiceValueId:l,state:C})}catch(F){const A=F;if((A.type===p.ConfiguratorErrorType.ConflictWithConsequence||A.type===p.ConfiguratorErrorType.SetDecisionConflict)&&D){await D();return}ue()}else D&&await D()}};return pe(e.children,{onClick:y,ref:t})}),Va=ui,Oa={...re,...Le,children:{title:"Content",type:f.ControlType.ComponentInstance},setSelection:{title:"Set Selection To",type:f.ControlType.Enum,defaultValue:"undefined",options:["undefined","included","excluded","true","false","numeric"]},numericValue:{title:"Numeric Value",type:f.ControlType.Number,defaultValue:0},...Ne};f.addPropertyControls(ui,Oa);const di=fe((e,t)=>{var h;if(G())return e.children;const o=ae(),{makeManyDecisions:i}=_.useMakeDecision(),{handleExplainAnswer:r}=de(),l=e.attributes.map(J),s=_.useAttributes(l,!1).map((g,u)=>{if(!g)return{error:d.jsx("span",{children:"Attribute not found"})};const b=e.attributes[u],w=b.choiceValueId??"",m=w.length>0,y=g.type===p.AttributeType.Choice,C=g.type===p.AttributeType.Numeric,P=g.type===p.AttributeType.Boolean,S=g.type===p.AttributeType.Component;if(!y&&m)return{error:d.jsx("span",{children:"Attribute is not a Choice Attribute"})};let R=y?g.values.get(w):null;if(m&&R==null)return{error:d.jsx("span",{children:"Choice Value not found"})};const I=()=>M.match({isChoiceAttribute:y,isBooleanAttribute:P,isComponentAttribute:S,isNumericAttribute:C,hasChoiceValueId:m,state:b.setSelection}).with({isChoiceAttribute:!0,hasChoiceValueId:!0,state:"included"},()=>p.ChoiceValueDecisionState.Included).with({isChoiceAttribute:!0,hasChoiceValueId:!0,state:"excluded"},()=>p.ChoiceValueDecisionState.Excluded).with({isBooleanAttribute:!0,state:"true"},()=>!0).with({isBooleanAttribute:!0,state:"false"},()=>!1).with({isComponentAttribute:!0,state:"included"},()=>p.ComponentDecisionState.Included).with({isComponentAttribute:!0,state:"excluded"},()=>p.ComponentDecisionState.Excluded).with({isNumericAttribute:!0,state:"numeric"},()=>b.numericValue).otherwise(()=>null);return{getDecisions:()=>y&&!m&&b.setSelection==="undefined"?[...g.values.values()].filter(V=>{var D;return((D=V.decision)==null?void 0:D.kind)===p.DecisionKind.Explicit}).map(V=>({type:g.type,attributeId:g.id,choiceValueId:V.id,state:null})):[{type:g.type,attributeId:g.id,choiceValueId:w,state:I()}]}}),a=(h=s.find(g=>g.error))==null?void 0:h.error;if(a)return a;const c=async()=>{const g=s.reduce((b,w)=>[...b,...w.getDecisions()],new Array),u=M.match(e.existingSelections).with("keep",()=>({type:"KeepExistingDecisions"})).with("drop",()=>({type:"DropExistingDecisions",conflictHandling:M.match(e.autoResolveConflicts).with(!1,()=>({type:"Manual",includeConstraintsInConflictExplanation:!1})).with(!0,()=>({type:"Automatic"})).exhaustive()})).exhaustive();try{await i(g,u)}catch(b){const w=b;if(console.debug("SetMany failed",w),(w==null?void 0:w.type)===p.ConfiguratorErrorType.MakeManyDecisionsConflict&&w.decisionExplanations){e.explain!=="disabled"&&await r(w,e.explain,o);return}ue();return}},x=()=>{e.trigger==="click"&&c()};return T.useEffect(()=>{e.trigger==="auto"&&c()},[]),pe(e.children,{onClick:x,ref:t})}),ka=di,ja={children:{title:"Content",type:f.ControlType.ComponentInstance},attributes:{title:"Attributes",type:f.ControlType.Array,control:{type:f.ControlType.Object,controls:{...re,...Le,setSelection:{title:"Set Selection To",type:f.ControlType.Enum,defaultValue:"undefined",options:["undefined","included","excluded","true","false","numeric"]},numericValue:{title:"Numeric Value",type:f.ControlType.Number,defaultValue:0}}}},existingSelections:{title:"Existing Selections",type:f.ControlType.Enum,defaultValue:"keep",options:["keep","drop"]},autoResolveConflicts:{title:"Auto Resolve Conflicts",type:f.ControlType.Boolean,defaultValue:!0,hidden:e=>e.existingSelections!=="drop"},trigger:{title:"Trigger",type:f.ControlType.Enum,defaultValue:"click",options:["click","auto"],displaySegmentedControl:!0,segmentedControlDirection:"horizontal"},...Ne};f.addPropertyControls(di,ja);const fi=se(e=>{if(G())return e.enabledChildren;const{canResetConfiguration:n,resetConfiguration:o}=_.useConfigurationReset(),i=async()=>{if(n)try{await o()}catch{ba()}},r=n?e.enabledChildren:e.disabledChildren;return pe(r,{onClick:i})}),Fa=fi,Na={enabledChildren:{title:"Content – Enabled",type:f.ControlType.ComponentInstance},disabledChildren:{title:"Content – Disabled",type:f.ControlType.ComponentInstance}};f.addPropertyControls(fi,Na);const pi=fe((e,t)=>{if(G())return e.unsatisfiedChildren;const o=ae(),{isSatisfied:i}=_.useConfigurationSatisfaction(),{explain:r}=de(),s=[...e.attributeId.length>0?[J(e)]:[],...e.attributes.map(J)],a=()=>{var u;const h=_.useAttributes(s,!1).map(b=>b?{isSatisfied:b.isSatisfied}:{error:d.jsx("span",{children:"Attribute not found"})}),g=(u=h.find(b=>b.error))==null?void 0:u.error;return g||h.every(b=>b.isSatisfied)},c=async()=>{e.explain!=="disabled"&&(s.length===0?await r(h=>h.whyIsNotSatisfied.configuration,e.explain,o):s.length===1&&await r(h=>h.whyIsNotSatisfied.attribute(s[0]),e.explain,o))};return(s.length>0?a():i)?e.satisfiedChildren:pe(e.unsatisfiedChildren,{onClick:c,ref:t})}),La=pi,Ma={satisfiedChildren:{title:"Content – Satisfied",type:f.ControlType.ComponentInstance},unsatisfiedChildren:{title:"Content – Unsatisfied",type:f.ControlType.ComponentInstance},...re,attributes:{title:"Attributes",type:f.ControlType.Array,control:{type:f.ControlType.Object,controls:{...re}}},...Ne};f.addPropertyControls(pi,Ma);const hi=se(T.forwardRef(function(t,n){const o=b=>M.match(b).with(1,()=>t.content1).with(2,()=>t.content2).with(3,()=>t.content3).with(4,()=>t.content4).with(5,()=>t.content5).with(6,()=>t.content6).with(7,()=>t.content7).with(8,()=>t.content8).with(9,()=>t.content9).with(10,()=>t.content10).otherwise(()=>null),i=t.variants.find(b=>b.useInDesignTime)||t.variants[0];if(G())return i&&o(i.content);const l=J(t),s=t.choiceValueId??"",a=s.length>0,c=_.useAttributes([l],!1)[0];if(!c)return d.jsx("span",{children:"Attribute not found"});const x=c.type===p.AttributeType.Choice;if(!x&&a)return d.jsx("span",{children:"Attribute is not a Choice Attribute"});const h=x&&a?c.values.get(s):null;if(a&&h==null)return d.jsx("span",{children:"Choice Value not found"});const g=b=>()=>h?b(h):[...c.values.values()].some(b),u=[...t.variants].find(({selection:b,condition:w})=>M.match({selection:b,condition:w,attribute:c}).with({attribute:{type:p.AttributeType.Choice},selection:"included",condition:"blocked"},g(m=>!m.possibleDecisionStates.includes(p.ChoiceValueDecisionState.Included))).with({attribute:{type:p.AttributeType.Choice},selection:"included",condition:"implicit"},g(m=>{var y,C;return((y=m.decision)==null?void 0:y.state)===p.ChoiceValueDecisionState.Included&&((C=m.decision)==null?void 0:C.kind)===p.DecisionKind.Implicit})).with({attribute:{type:p.AttributeType.Choice},selection:"included",condition:"explicit"},g(m=>{var y,C;return((y=m.decision)==null?void 0:y.state)===p.ChoiceValueDecisionState.Included&&((C=m.decision)==null?void 0:C.kind)===p.DecisionKind.Explicit})).with({attribute:{type:p.AttributeType.Choice},selection:"included",condition:"none"},g(m=>{var y;return((y=m.decision)==null?void 0:y.state)===p.ChoiceValueDecisionState.Included})).with({attribute:{type:p.AttributeType.Choice},selection:"excluded",condition:"blocked"},g(m=>!m.possibleDecisionStates.includes(p.ChoiceValueDecisionState.Excluded))).with({attribute:{type:p.AttributeType.Choice},selection:"excluded",condition:"implicit"},g(m=>{var y,C;return((y=m.decision)==null?void 0:y.state)===p.ChoiceValueDecisionState.Excluded&&((C=m.decision)==null?void 0:C.kind)===p.DecisionKind.Implicit})).with({attribute:{type:p.AttributeType.Choice},selection:"excluded",condition:"explicit"},g(m=>{var y,C;return((y=m.decision)==null?void 0:y.state)===p.ChoiceValueDecisionState.Excluded&&((C=m.decision)==null?void 0:C.kind)===p.DecisionKind.Explicit})).with({attribute:{type:p.AttributeType.Choice},selection:"excluded",condition:"none"},g(m=>{var y;return((y=m.decision)==null?void 0:y.state)===p.ChoiceValueDecisionState.Excluded})).with({attribute:{type:p.AttributeType.Boolean},selection:"true",condition:"blocked"},({attribute:m})=>!m.possibleDecisionStates.includes(!0)).with({attribute:{type:p.AttributeType.Boolean},selection:"true",condition:"implicit"},({attribute:m})=>{var y,C;return((y=m.decision)==null?void 0:y.state)===!0&&((C=m.decision)==null?void 0:C.kind)===p.DecisionKind.Implicit}).with({attribute:{type:p.AttributeType.Boolean},selection:"true",condition:"explicit"},({attribute:m})=>{var y,C;return((y=m.decision)==null?void 0:y.state)===!0&&((C=m.decision)==null?void 0:C.kind)===p.DecisionKind.Explicit}).with({attribute:{type:p.AttributeType.Boolean},selection:"true",condition:"none"},({attribute:m})=>{var y;return((y=m.decision)==null?void 0:y.state)===!0}).with({attribute:{type:p.AttributeType.Boolean},selection:"false",condition:"blocked"},({attribute:m})=>!m.possibleDecisionStates.includes(!1)).with({attribute:{type:p.AttributeType.Boolean},selection:"false",condition:"implicit"},({attribute:m})=>{var y,C;return((y=m.decision)==null?void 0:y.state)===!1&&((C=m.decision)==null?void 0:C.kind)===p.DecisionKind.Implicit}).with({attribute:{type:p.AttributeType.Boolean},selection:"false",condition:"explicit"},({attribute:m})=>{var y,C;return((y=m.decision)==null?void 0:y.state)===!1&&((C=m.decision)==null?void 0:C.kind)===p.DecisionKind.Explicit}).with({attribute:{type:p.AttributeType.Boolean},selection:"false",condition:"none"},({attribute:m})=>{var y;return((y=m.decision)==null?void 0:y.state)===!1}).with({attribute:{type:p.AttributeType.Component},selection:"included",condition:"blocked"},({attribute:m})=>!m.possibleDecisionStates.includes(p.ComponentDecisionState.Included)).with({attribute:{type:p.AttributeType.Component},selection:"included",condition:"implicit"},({attribute:m})=>{var y,C;return((y=m.decision)==null?void 0:y.state)===p.ComponentDecisionState.Included&&((C=m.decision)==null?void 0:C.kind)===p.DecisionKind.Implicit}).with({attribute:{type:p.AttributeType.Component},selection:"included",condition:"explicit"},({attribute:m})=>{var y,C;return((y=m.decision)==null?void 0:y.state)===p.ComponentDecisionState.Included&&((C=m.decision)==null?void 0:C.kind)===p.DecisionKind.Explicit}).with({attribute:{type:p.AttributeType.Component},selection:"included",condition:"none"},({attribute:m})=>{var y;return((y=m.decision)==null?void 0:y.state)===p.ComponentDecisionState.Included}).with({attribute:{type:p.AttributeType.Component},selection:"excluded",condition:"blocked"},({attribute:m})=>!m.possibleDecisionStates.includes(p.ComponentDecisionState.Excluded)).with({attribute:{type:p.AttributeType.Component},selection:"excluded",condition:"implicit"},({attribute:m})=>{var y,C;return((y=m.decision)==null?void 0:y.state)===p.ComponentDecisionState.Excluded&&((C=m.decision)==null?void 0:C.kind)===p.DecisionKind.Implicit}).with({attribute:{type:p.AttributeType.Component},selection:"excluded",condition:"explicit"},({attribute:m})=>{var y,C;return((y=m.decision)==null?void 0:y.state)===p.ComponentDecisionState.Excluded&&((C=m.decision)==null?void 0:C.kind)===p.DecisionKind.Explicit}).with({attribute:{type:p.AttributeType.Component},selection:"excluded",condition:"none"},({attribute:m})=>{var y;return((y=m.decision)==null?void 0:y.state)===p.ComponentDecisionState.Excluded}).with({attribute:{type:p.AttributeType.Numeric},selection:"numeric",condition:"implicit"},({attribute:m})=>{var y;return((y=m.decision)==null?void 0:y.kind)===p.DecisionKind.Implicit}).with({attribute:{type:p.AttributeType.Numeric},selection:"numeric",condition:"explicit"},({attribute:m})=>{var y;return((y=m.decision)==null?void 0:y.kind)===p.DecisionKind.Explicit}).with({attribute:{type:p.AttributeType.Numeric},selection:"numeric",condition:"none"},({attribute:m})=>m.decision!=null).with({attribute:{type:p.AttributeType.Choice},selection:"undefined"},()=>h.decision==null).with({attribute:{type:p.AttributeType.Boolean},selection:"undefined"},{attribute:{type:p.AttributeType.Component},selection:"undefined"},{attribute:{type:p.AttributeType.Numeric},selection:"undefined"},({attribute:m})=>m.decision==null).otherwise(()=>!1));return u&&pe(o(u.content),{ref:n})})),Ba=hi,$a={...re,...Le,variants:{title:"Variants",type:f.ControlType.Array,maxCount:10,control:{type:f.ControlType.Object,controls:{selection:{title:"Selection",type:f.ControlType.Enum,defaultValue:"undefined",options:["undefined","included","excluded","true","false","numeric"]},condition:{title:"Condition",type:f.ControlType.Enum,defaultValue:"none",options:["none","explicit","implicit","blocked"]},content:{title:"Content",type:f.ControlType.Enum,defaultValue:1,options:[1,2,3,4,5,6,7,8,9,10]},useInDesignTime:{title:"Design Time",type:f.ControlType.Boolean,defaultValue:!1}}}},content1:{title:"Content 1",type:f.ControlType.ComponentInstance},content2:{title:"Content 2",type:f.ControlType.ComponentInstance},content3:{title:"Content 3",type:f.ControlType.ComponentInstance},content4:{title:"Content 4",type:f.ControlType.ComponentInstance},content5:{title:"Content 5",type:f.ControlType.ComponentInstance},content6:{title:"Content 6",type:f.ControlType.ComponentInstance},content7:{title:"Content 7",type:f.ControlType.ComponentInstance},content8:{title:"Content 8",type:f.ControlType.ComponentInstance},content9:{title:"Content 9",type:f.ControlType.ComponentInstance},content10:{title:"Content 10",type:f.ControlType.ComponentInstance}};f.addPropertyControls(hi,$a);const mi=se(e=>{const t=T.useRef(),[n,o]=T.useState(null),i=T.useRef(n),r=T.useMemo(()=>e.color.startsWith("var"),[e.color]),l=r?n:e.color,s=T.useMemo(()=>{if(!l)return;const a=Mi(l);return Li.hexToCSSFilter(`#${a}`,{acceptanceLossPercentage:1,maxChecks:30}).filter.replace(";","")},[l]);return T.useLayoutEffect(()=>{if(r){const a=t.current&&getComputedStyle(t.current).color;a!=i.current&&(i.current=a,o(a))}}),d.jsx("div",{ref:t,style:{...e.style,color:e.color,filter:s},children:e.children})}),Ka=mi,Wa={children:{title:"Content",type:f.ControlType.ComponentInstance},color:{title:"Color",type:f.ControlType.Color,defaultValue:"#0000ff"}};f.addPropertyControls(mi,Wa);const yi=se(e=>{if(G())return e.children;const{error:n}=_.useConfigurationInitialization();return n?pe(e.children,{onClick:n.retry}):null}),qa=yi,za={children:{title:"Content",type:f.ControlType.ComponentInstance}};f.addPropertyControls(yi,za);function Ha(e){return T.forwardRef((t,n)=>{const o={...t.style,width:"100%",height:"100%"};return d.jsx(e,{...t,ref:n,style:o})})}const Ua=k.div` width: 10px; height: 10px; background-color: greenyellow; `;function gi(e){const t=T.useRef(null);return T.useEffect(()=>{if(!t.current)return;const n=setTimeout(()=>{t.current.scrollIntoView()},e.delay);return()=>clearTimeout(n)},[t.current]),d.jsx(Ua,{ref:t})}const _a={delay:{title:"Delay",type:f.ControlType.Number,min:0,unit:"ms",defaultValue:0,step:1}};f.addPropertyControls(gi,_a);const bi=k.div` display: contents; `,Qa=k.createGlobalStyle` :root { *:has(> ${bi}) { display: contents !important; } } `,xi=se(tn(e=>{const t=ae(),n=G(),i=(()=>{const u=b=>{var y;const w=T.Children.toArray(b)[0],m=(y=w.props)==null?void 0:y.children;return m?u(m):w};return u(e.itemTemplate)})();if(!i)return d.jsx("span",{children:"Choice Value Template not defined"});const r=(u,b)=>u.map(w=>T.cloneElement(i,{key:w,layoutId:`${t}_${w}`,attributeId:e.attributeId,componentPath:e.componentPath,sharedConfigurationModel:e.sharedConfigurationModel,choiceValueId:w,choiceValueName:b.get(w)??w}));if(n)return d.jsx(Un,{...e,children:r(["Choice Value 1","Choice Value 2","Choice Value 3"],v.RM.empty)});const l=J(e),s=_.useChoiceAttribute(l);if(!s)return d.jsx("span",{children:"Choice Attribute not found"});const a=ze(l),c=e.filter??new Array,x=[...s.attribute.values.values()].filter(u=>c.length===0||c.some(({selection:b,condition:w})=>M.match({selection:b,condition:w}).with({selection:"included",condition:"blocked"},()=>!u.possibleDecisionStates.includes(p.ChoiceValueDecisionState.Included)).with({selection:"included",condition:"implicit"},()=>{var m,y;return((m=u.decision)==null?void 0:m.state)===p.ChoiceValueDecisionState.Included&&((y=u.decision)==null?void 0:y.kind)===p.DecisionKind.Implicit}).with({selection:"included",condition:"explicit"},()=>{var m,y;return((m=u.decision)==null?void 0:m.state)===p.ChoiceValueDecisionState.Included&&((y=u.decision)==null?void 0:y.kind)===p.DecisionKind.Explicit}).with({selection:"included",condition:"none"},()=>{var m;return((m=u.decision)==null?void 0:m.state)===p.ChoiceValueDecisionState.Included}).with({selection:"excluded",condition:"blocked"},()=>!u.possibleDecisionStates.includes(p.ChoiceValueDecisionState.Excluded)).with({selection:"excluded",condition:"implicit"},()=>{var m,y;return((m=u.decision)==null?void 0:m.state)===p.ChoiceValueDecisionState.Excluded&&((y=u.decision)==null?void 0:y.kind)===p.DecisionKind.Implicit}).with({selection:"excluded",condition:"explicit"},()=>{var m,y;return((m=u.decision)==null?void 0:m.state)===p.ChoiceValueDecisionState.Excluded&&((y=u.decision)==null?void 0:y.kind)===p.DecisionKind.Explicit}).with({selection:"excluded",condition:"none"},()=>{var m;return((m=u.decision)==null?void 0:m.state)===p.ChoiceValueDecisionState.Excluded}).with({selection:"undefined"},()=>u.decision==null).otherwise(()=>!1))),g=ct(l,a,x).map(u=>u.id);return d.jsx(Un,{...e,children:r(g,a)})}));function Un(e){return d.jsxs(d.Fragment,{children:[d.jsx(at,{singletonId:"ChoiceValueListRenderer",children:d.jsx(Qa,{})}),d.jsx(bi,{style:e.style,children:e.children})]})}const Ya=xi,Xa={...re,itemTemplate:{title:"Choice Value Template",type:f.ControlType.ComponentInstance},filter:{title:"Filter",type:f.ControlType.Array,control:{type:f.ControlType.Object,controls:{selection:{title:"Selection",type:f.ControlType.Enum,defaultValue:"undefined",options:["undefined","included","excluded"]},condition:{title:"Condition",type:f.ControlType.Enum,defaultValue:"none",options:["none","explicit","implicit","blocked"]}}}}};f.addPropertyControls(xi,Xa);const{isValidElement:_n,cloneElement:Qn}=E;function Ga(e,t){return t?(Array.isArray(t)&&(t=t.map((n,o)=>_n(n)&&typeof n.props=="object"?Qn(n,{...n.props,key:o}):n)),!e||Array.isArray(e)?t:_n(e)?Qn(e,{...e.props,children:t}):e):e}const{isValidElement:Ja}=E;function Ci(e,t,n){function o(r,l){return t.visit(r,n,l)}function i(r,l){return Ci(r,t,l||n)}if(Ja(e)){if(typeof e.type=="function")return"prototype"in e.type&&e.type.prototype.isReactComponent?e=new e.type(e.props).render():e=e.type(e.props),i(e);if(e.props&&"children"in e.props){const r=e.props.children;return o(e,s=>Array.isArray(r)?r.map(a=>i(a,s)):i(r,s))}}else if(Array.isArray(e)){const r=e;return o(e,s=>r.map(a=>i(a,s)))}return o(e)}const{isValidElement:Yn}=E;function Za(e,t){let n;const{replace:o,updateState:i}=t;return"matchElement"in t?n=r=>Yn(r)&&r.type===t.matchElement:"matchLiteral"in t?n=r=>!Array.isArray(r)&&!Yn(r)&&t.matchLiteral(r):n=t.match,Ci(e,{visit(r,l,s){const a=i?i(l):l,c=s?s(a):void 0,x=Ga(r,c);return n(x,a)?o(x,a):x}},t.initialState)}function Xn(e){return d.jsx(d.Fragment,{children:Za(e.children,e)})}function ec(e){return v.pipe(e,v.Str.replace(/[\s\u2013]/g,"-"),Bi)}const tc=se(e=>{const{children:t,mode:n,replaceString:o,propName:i,elementName:r,text:l}=e;return n==="replace"?d.jsx(Xn,{match:s=>typeof s=="string",replace:s=>s===o?l:s,children:t}):n==="set-prop"?d.jsx(Xn,{match:s=>{var a;return((a=s.type)==null?void 0:a.displayName)===r},replace:s=>T.cloneElement(s,{[ec(i)]:l}),children:t}):t}),mt=tc,nn=e=>({children:{title:"Content",type:f.ControlType.ComponentInstance},mode:{title:"Mode",type:f.ControlType.Enum,defaultValue:"replace",options:["replace","set-prop"],displaySegmentedControl:!0},replaceString:{title:"Replace Text",type:f.ControlType.String,defaultValue:e,hidden:t=>t.mode!=="replace"},elementName:{title:"Element Name",type:f.ControlType.String,hidden:t=>t.mode!=="set-prop"},propName:{title:"Property Name",type:f.ControlType.String,hidden:t=>t.mode!=="set-prop"}}),vi=se(e=>{const{attributeId:t,children:n,customName:o}=e,i=J(e),r=(o==null?void 0:o.length)>0,l=G(),a=r?o:l?t:(()=>_.useAttributes([i],!1)[0]?dt(i)??t:"Attribute not found")();return d.jsx(mt,{...e,text:a})}),nc=vi,oc={...re,customName:{title:"Custom Name",type:f.ControlType.String},...nn("")};f.addPropertyControls(vi,oc);const wi=se(e=>{const{choiceValueId:t,children:n,customName:o,mode:i,replaceString:r,propName:l,elementName:s}=e,a=J(e),c=o.length>0,x=t.length>0,h=G(),u=c?o:h?t.length>0?t:"Choice Value":(()=>{const b=_.useChoiceAttribute(a);return b?x?b.attribute.values.get(t)==null?"Choice Value not found":io(a,t)??t:"Choice Value Id missing":"Choice Attribute not found"})();return d.jsx(mt,{...e,text:u})}),ic=wi,rc={...re,...Le,customName:{title:"Custom Name",type:f.ControlType.String},...nn("")};f.addPropertyControls(wi,rc);function Si(e){return e.children}const lc={children:{title:"Content",type:f.ControlType.ComponentInstance}};f.addPropertyControls(Si,lc);function Ti(e){const{children:t,fileExtension:n,fileName:o,target:i}=e;if(G())return t;const{storeConfiguration:l}=_.useConfigurationStoring();return pe(t,{onClick:async()=>{const c={type:"spc-stored-configuration",storedConfiguration:await l()};i==="file"?ac(c,`${o}.${n}`):i==="clipboard"&&cc(c)}})}const sc={children:{title:"Content",type:f.ControlType.ComponentInstance},target:{title:"Target",type:f.ControlType.Enum,defaultValue:"file",options:["file","clipboard"],optionTitles:["File","Clipboard"],displaySegmentedControl:!0,segmentedControlDirection:"vertical"},fileName:{title:"File Name",type:f.ControlType.String,defaultValue:"configuration",hidden:e=>e.target!=="file"},fileExtension:{title:"File Extension",type:f.ControlType.String,defaultValue:"json",hidden:e=>e.target!=="file"}};f.addPropertyControls(Ti,sc);function ac(e,t){const n=JSON.stringify(e),o=new Blob([n],{type:"application/json"}),i=window.URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(i)}function cc(e){const t=JSON.stringify(e);navigator.clipboard.writeText(t).catch(n=>{alert("Failed to copy the configuration to clipboard: "+n)})}var Ei=(e=>(e[e.parseError=0]="parseError",e[e.noConfiguration=1]="noConfiguration",e[e.noFileSelected=2]="noFileSelected",e[e.fileReadError=3]="fileReadError",e[e.noClipboardData=4]="noClipboardData",e[e.clipboardReadError=5]="clipboardReadError",e))(Ei||{});const Ai=fe((e,t)=>{const{children:n,fileExtension:o,source:i}=e;if(G())return n;const l=ae(),{restoreConfiguration:s}=_.useConfigurationStoring(),{handleExplainAnswer:a}=de();return pe(n,{onClick:async()=>{const x=v.pipe(await hc(i,o),v.O.toNullable);if(!x)return;const h={type:"DropExistingDecisions",conflictHandling:M.match(e.autoResolveConflicts).with(!1,()=>({type:"Manual",includeConstraintsInConflictExplanation:!1})).with(!0,()=>({type:"Automatic"})).exhaustive()};try{await s(x,h)}catch(g){const u=g;if(console.debug("Failed to restore stored configuration",u),u.type===p.ConfiguratorErrorType.StoredConfigurationInvalid){alert("The specific configuration is not supported. Maybe the configuration was created with new application version than the current one.");return}if((u==null?void 0:u.type)===p.ConfiguratorErrorType.MakeManyDecisionsConflict&&u.decisionExplanations){e.explain!=="disabled"&&await a(u,e.explain,l);return}alert("Failed to restore your configuration.");return}},ref:t})}),uc=Ai,dc={children:{title:"Content",type:f.ControlType.ComponentInstance},source:{title:"Source",type:f.ControlType.Enum,defaultValue:"file",options:["file","clipboard"],optionTitles:["File","Clipboard"],displaySegmentedControl:!0,segmentedControlDirection:"vertical"},fileExtension:{title:"File Extension",type:f.ControlType.String,defaultValue:"json",hidden:e=>e.source!=="file"},autoResolveConflicts:{title:"Auto Resolve Conflicts",type:f.ControlType.Boolean,defaultValue:!0},...Ne};f.addPropertyControls(Ai,dc);function fc(e){return()=>new Promise(t=>{const n=document.createElement("input");n.type="file",n.accept=`.${e}`,n.onchange=o=>{const i=o.target;if(!i.files||i.files.length===0){t(v.left(2));return}const r=i.files[0],l=new FileReader;l.onload=()=>{t(v.right(l.result))},l.onerror=()=>{t(v.left(3))},l.readAsText(r)},n.oncancel=()=>{t(v.left(2))},n.click()})}function pc(){return()=>navigator.clipboard.readText().then(e=>e?v.right(e):v.left(4)).catch(()=>v.left(5))}function hc(e,t){return v.pipe(e==="file"?fc(t):pc(),v.TE.chainEitherK(n=>v.E.tryCatch(()=>JSON.parse(n),()=>0)),v.TE.filterOrElse(n=>n.type==="spc-stored-configuration",()=>1),v.TE.map(n=>n.storedConfiguration),v.TE.doIfLeft(n=>()=>{console.debug(`Failed to load stored configuration: ${Ei[n]}`),n==3?alert("Failed to read the selected file. Maybe it is damaged."):n==1||n==0?e==="file"?alert("The selected file doesn't contain a valid configuration."):e==="clipboard"&&alert("The clipboard doesn't contain a valid configuration."):n==5?alert("Can't read the clipboard. Make to give a permission for reading the clipboard."):n==4&&alert("The clipboard doesn't contain a configuration.")}),v.TO.fromTaskEither)()}const Ri=se(e=>{const{fallback:t}=e,n=J(e),r=G()?"0.0":(()=>{var a;const l=_.useNumericAttribute(n);if(!l)return"Numeric Attribute not found";const s=(a=l.attribute.decision)==null?void 0:a.state;return s!=null?s.toLocaleString():t})();return d.jsx(mt,{...e,text:r})}),mc=Ri,yc={...re,fallback:{title:"Unselected Text",type:f.ControlType.String,defaultValue:""},...nn("")};f.addPropertyControls(Ri,yc);exports.AttributeName=nc;exports.BooleanSelect=wa;exports.ChoiceSelect=xa;exports.ChoiceValueListRenderer=Ya;exports.ChoiceValueName=ic;exports.Colorize=Ka;exports.ComponentSelect=Ta;exports.Configuration=Ls;exports.InitializationRetry=qa;exports.NumericInput=Aa;exports.ReplaceText=mt;exports.ResetConfiguration=Fa;exports.RestoreConfiguration=uc;exports.SatisfactionIndicator=La;exports.ScrollIntoView=gi;exports.SelectedNumericValue=mc;exports.SelectionIndicator=Ba;exports.SelectionToggle=Pa;exports.SetSelection=Va;exports.SetSelections=ka;exports.Singleton=at;exports.Slot=Si;exports.StoreConfiguration=Ti;exports.attributeIdPropertyControls=re;exports.choiceValueIdPropertyControls=Le;exports.cloneChildrenWithProps=pe;exports.explainableComponent=fe;exports.parseGlobalAttributeId=J;exports.useAttributeName=dt;exports.useChoiceValueName=io;exports.useChoiceValueNames=ze;exports.useControlId=ae;exports.useDebounceValue=si;exports.useExplain=de;exports.useExplainProcess=ye;exports.useRenderPlaceholder=G;exports.useSortedChoiceValues=ct;exports.withControlId=tn;exports.withErrorBoundary=se;exports.withFullSize=Ha;