UNPKG

@codegouvfr/react-dsfr

Version:

French State Design System React integration library

4 lines (3 loc) 34.9 kB
/*! DSFR v1.8.5 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */ const t=new class{constructor(){this.modules={}}create(t){const e=new t;this.modules[e.type]=e}getModule(t){return this.modules[t]}add(t,e){this.modules[t].add(e)}remove(t,e){this.modules[t].remove(e)}get isActive(){return this._isActive}set isActive(t){if(t===this._isActive)return;this._isActive=t;const e=Object.keys(this.modules).map((t=>this.modules[t]));if(t)for(const t of e)t.activate();else for(const t of e)t.deactivate()}get isLegacy(){return this._isLegacy}set isLegacy(t){t!==this._isLegacy&&(this._isLegacy=t)}},e="fr",s="dsfr",i="1.8.5";class n{constructor(t,e,s,i){switch(this.level=t,this.light=e,this.dark=s,i){case"warn":this.logger=console.warn;break;case"error":this.logger=console.error;break;default:this.logger=console.log}}log(...t){const e=new r(s);for(const s of t)e.add(s);this.print(e)}print(t){t.setColor(this.color),this.logger.apply(console,t.getMessage())}get color(){return window.matchMedia("(prefers-color-scheme: dark)").matches?this.dark:this.light}}class r{constructor(t){this.inputs=["%c"],this.styles=["font-family:Marianne","line-height: 1.5"],this.objects=[],t&&this.add(`${t} :`)}add(t){switch(typeof t){case"object":case"function":this.inputs.push("%o "),this.objects.push(t);break;default:this.inputs.push(`${t} `)}}setColor(t){this.styles.push(`color:${t}`)}getMessage(){return[this.inputs.join(""),this.styles.join(";"),...this.objects]}}const o={trace:new n(0,"#616161","#989898"),debug:new n(1,"#000091","#8B8BFF"),info:new n(2,"#007c3b","#00ed70"),warn:new n(3,"#ba4500","#fa5c00","warn"),error:new n(4,"#D80600","#FF4641","error")};const a=new class{constructor(){this.level=2;for(const t in o){const e=o[t];this[t]=(...t)=>{this.level<=e.level&&e.log.apply(e,t)},this[t].print=e.print.bind(e)}}state(){const e=new r;e.add(t),this.trace.print(e)}tree(){const e=t.getModule("stage");if(!e)return;const s=new r;this._branch(e.root,0,s),this.trace.print(s)}_branch(t,e,s){let i="";if(e>0){let t="";for(let s=0;s<e;s++)t+=" ";i+=t+"└─ "}i+=`[${t.id}] ${t.html}`,s.add(i),s.add({"@":t}),s.add("\n");for(const n of t.children)i+=this._branch(n,e+1,s)}},c=t=>{"loading"!==document.readyState?window.requestAnimationFrame(t):document.addEventListener("DOMContentLoaded",t)},h={AUTO:"auto",MANUAL:"manual",RUNTIME:"runtime",LOADED:"loaded",VUE:"vue",ANGULAR:"angular",REACT:"react"};const l=new class{constructor(){this._mode=h.AUTO,this.isStarted=!1,this.starting=this.start.bind(this),this.preventManipulation=!1}configure(t={},e){this.startCallback=e,!0===t.verbose&&(a.level=0),this.mode=t.mode||h.AUTO}set mode(t){switch(t){case h.AUTO:this.preventManipulation=!1,e=this.starting,c(e);break;case h.LOADED:this.preventManipulation=!1,c(this.starting);break;case h.RUNTIME:this.preventManipulation=!1,this.start();break;case h.MANUAL:this.preventManipulation=!1;break;case h.VUE:case h.ANGULAR:case h.REACT:this.preventManipulation=!0;break;default:return void a.error("Illegal mode")}var e;this._mode=t,a.info(`mode set to ${t}`)}get mode(){return this._mode}start(){a.info("start"),this.startCallback()}};class d{constructor(){this._collection=[]}forEach(t){this._collection.forEach(t)}map(t){return this._collection.map(t)}get length(){return this._collection.length}add(t){return!(this._collection.indexOf(t)>-1)&&(this._collection.push(t),this.onAdd&&this.onAdd(),this.onPopulate&&1===this._collection.length&&this.onPopulate(),!0)}remove(t){const e=this._collection.indexOf(t);if(-1===e)return!1;this._collection.splice(e,1),this.onRemove&&this.onRemove(),this.onEmpty&&0===this._collection.length&&this.onEmpty()}execute(...t){for(const e of this._collection)e&&e.apply(null,t)}clear(){this._collection.length=0}clone(){const t=new d;return t._collection=this._collection.slice(),t}get collection(){return this._collection}}class u extends d{constructor(t){super(),this.type=t,this.isActive=!1}activate(){}deactivate(){}}const p=t=>`${e}-${t}`;p.selector=(t,e)=>(void 0===e&&(e="."),`${e}${p(t)}`),(p.attr=t=>`data-${p(t)}`).selector=(t,e)=>{let s=p.attr(t);return void 0!==e&&(s+=`="${e}"`),`[${s}]`},p.event=t=>`${s}.${t}`,p.emission=(t,e)=>`emission:${t}.${e}`;const g=(t,e)=>Array.prototype.slice.call(t.querySelectorAll(e)),m=(t,e)=>{const s=t.parentElement;return s.matches(e)?s:s===document.documentElement?null:m(s,e)};class f{constructor(t,e,s){this.selector=t,this.InstanceClass=e,this.creator=s,this.instances=new d,this.isIntroduced=!1,this._instanceClassName=this.InstanceClass.instanceClassName,this._instanceClassNames=this.getInstanceClassNames(this.InstanceClass),this._property=this._instanceClassName.substring(0,1).toLowerCase()+this._instanceClassName.substring(1);const i=this._instanceClassName.replace(/[^a-zA-Z0-9]+/g,"-").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([0-9])([^0-9])/g,"$1-$2").replace(/([^0-9])([0-9])/g,"$1-$2").toLowerCase();this._attribute=p.attr(`js-${i}`)}getInstanceClassNames(t){const e=Object.getPrototypeOf(t);return e&&"Instance"!==e.instanceClassName?[...this.getInstanceClassNames(e),t.instanceClassName]:[t.instanceClassName]}hasInstanceClassName(t){return this._instanceClassNames.indexOf(t)>-1}introduce(){this.isIntroduced||(this.isIntroduced=!0,t.getModule("stage").parse(document.documentElement,this))}parse(t,e){const s=[];return t.matches&&t.matches(this.selector)&&s.push(t),!e&&t.querySelectorAll&&t.querySelector(this.selector)&&s.push.apply(s,g(t,this.selector)),s}create(t){if(!t.node.matches(this.selector))return;const e=new this.InstanceClass;return this.instances.add(e),e}remove(t){this.instances.remove(t)}dispose(){const t=this.instances.collection;for(let e=t.length-1;e>-1;e--)t[e]._dispose();this.creator=null}get instanceClassName(){return this._instanceClassName}get instanceClassNames(){return this._instanceClassNames}get property(){return this._property}get attribute(){return this._attribute}}class _ extends u{constructor(){super("register")}register(e,s,i){const n=new f(e,s,i);return this.add(n),t.isActive&&n.introduce(),n}activate(){for(const t of this.collection)t.introduce()}remove(t){t.dispose(),super.remove(t)}}let y=0;class v{constructor(t,e){e?this.id=e:(y++,this.id=y),this.node=t,this.attributeNames=[],this.instances=[],this._children=[],this._parent=null,this._projects=[]}get proxy(){const t=this;if(!this._proxy){this._proxy={id:this.id,get parent(){return t.parent?t.parent.proxy:null},get children(){return t.children.map((t=>t.proxy))}};for(const t of this.instances)this._proxy[t.registration.property]=t.proxy}return this._proxy}get html(){if(!this.node||!this.node.outerHTML)return"";const t=this.node.outerHTML.indexOf(">");return this.node.outerHTML.substring(0,t+1)}project(t){-1===this._projects.indexOf(t)&&this._projects.push(t)}populate(){const t=this._projects.slice();this._projects.length=0;for(const e of t)this.create(e)}create(t){if(this.hasInstance(t.instanceClassName))return;a.debug(`create instance of ${t.instanceClassName} on element [${this.id}]`);const e=t.create(this);this.instances.push(e),e._config(this,t),this._proxy&&(this._proxy[t.property]=e.proxy)}remove(t){const e=this.instances.indexOf(t);e>-1&&this.instances.splice(e,1),this._proxy&&delete this._proxy[t.registration.property]}get parent(){return this._parent}get ascendants(){return[this.parent,...this.parent.ascendants]}get children(){return this._children}get descendants(){const t=[...this._children];return this._children.forEach((e=>t.push(...e.descendants))),t}addChild(t,e){return this._children.indexOf(t)>-1?null:(t._parent=this,!isNaN(e)&&e>-1&&e<this._children.length?this._children.splice(e,0,t):this._children.push(t),t)}removeChild(t){const e=this._children.indexOf(t);if(-1===e)return null;t._parent=null,this._children.splice(e,1)}emit(e,s){const i=t.getModule("stage").collection,n=[];for(const t of i)n.push(...t._emit(e,s));return n}_emit(t,e){const s=[];for(const i of this.instances)s.push(...i._emitter.emit(t,e));return s}ascend(t,e){return this._parent?this._parent._ascend(t,e):[]}_ascend(t,e){const s=[];for(const i of this.instances)s.push(...i._ascent.emit(t,e));return this._parent&&s.push(...this._parent._ascend(t,e)),s}descend(t,e){const s=[];for(const i of this._children)s.push(...i._descend(t,e));return s}_descend(t,e){const s=[];for(const i of this.instances)s.push(...i._descent.emit(t,e));for(const i of this._children)s.push(...i._descend(t,e));return s}getInstance(t){for(const e of this.instances)if(e.registration.hasInstanceClassName(t))return e;return null}hasInstance(t){return null!==this.getInstance(t)}getDescendantInstances(t,e,s){if(!t)return[];const i=[];for(const n of this._children){const r=n.getInstance(t);r&&(i.push(r),s)||(e&&n.hasInstance(e)||!n.children.length||i.push.apply(i,n.getDescendantInstances(t,e,s)))}return i}getAscendantInstance(t,e){if(!t||!this._parent)return null;const s=this._parent.getInstance(t);return s||(e&&this._parent.hasInstance(e)?null:this._parent.getAscendantInstance(t,e))}dispose(){for(const t of this.instances)t._dispose();this.instances.length=0,t.remove("stage",this),this.parent.removeChild(this),this._children.length=0,a.debug(`remove element [${this.id}] ${this.html}`)}prepare(t){-1===this.attributeNames.indexOf(t)&&this.attributeNames.push(t)}examine(){const t=this.attributeNames.slice();this.attributeNames.length=0;for(let e=this.instances.length-1;e>-1;e--)this.instances[e].examine(t)}}class b extends v{constructor(){super(document.documentElement,"root"),this.node.setAttribute(p.attr("js"),!0)}}class x extends u{constructor(){super("stage"),this.root=new b,super.add(this.root),this.observer=new MutationObserver(this.mutate.bind(this)),this.modifications=[],this.willModify=!1,this.modifying=this.modify.bind(this)}hasElement(t){for(const e of this.collection)if(e.node===t)return!0;return!1}getElement(t){for(const e of this.collection)if(e.node===t)return e;const e=new v(t);return this.add(e),a.debug(`add element [${e.id}] ${e.html}`),e}getProxy(t){if(!this.hasElement(t))return null;return this.getElement(t).proxy}add(t){super.add(t),this.put(t,this.root)}put(t,e){let s=0;for(let i=e.children.length-1;i>-1;i--){const n=e.children[i],r=t.node.compareDocumentPosition(n.node);if(r&Node.DOCUMENT_POSITION_CONTAINS)return void this.put(t,n);if(r&Node.DOCUMENT_POSITION_CONTAINED_BY)e.removeChild(n),t.addChild(n,0);else if(r&Node.DOCUMENT_POSITION_PRECEDING){s=i+1;break}}e.addChild(t,s)}activate(){this.observer.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0})}deactivate(){this.observer.disconnect()}mutate(t){const e=[];t.forEach((t=>{switch(t.type){case"childList":t.removedNodes.forEach((t=>this.dispose(t))),t.addedNodes.forEach((t=>this.parse(t)));break;case"attributes":if(this.hasElement(t.target)){const s=this.getElement(t.target);s.prepare(t.attributeName),-1===e.indexOf(s)&&e.push(s);for(const t of s.descendants)-1===e.indexOf(t)&&e.push(t)}-1===this.modifications.indexOf(t.target)&&this.modifications.push(t.target)}})),e.forEach((t=>t.examine())),this.modifications.length&&!this.willModify&&(this.willModify=!0,window.requestAnimationFrame(this.modifying))}modify(){this.willModify=!1;const t=this.modifications.slice();this.modifications.length=0;for(const e of t)document.documentElement.contains(e)&&this.parse(e)}dispose(t){const e=[];this.forEach((s=>{t.contains(s.node)&&e.push(s)}));for(const t of e)t.dispose(),this.remove(t)}parse(e,s,i){const n=s?[s]:t.getModule("register").collection,r=[];for(const t of n){const s=t.parse(e,i);for(const e of s){const s=this.getElement(e);s.project(t),-1===r.indexOf(s)&&r.push(s)}}for(const t of r)t.populate()}}class C extends u{constructor(){super("render"),this.rendering=this.render.bind(this),this.nexts=new d}activate(){window.requestAnimationFrame(this.rendering)}request(t){this.nexts.add(t)}render(){if(!t.isActive)return;if(window.requestAnimationFrame(this.rendering),this.forEach((t=>t.render())),!this.nexts.length)return;const e=this.nexts.clone();this.nexts.clear(),e.forEach((t=>t.next()))}}class w extends u{constructor(){super("resize"),this.requireResize=!1,this.resizing=this.resize.bind(this);const t=this.request.bind(this);document.fonts&&document.fonts.ready.then(t),window.addEventListener("resize",t),window.addEventListener("orientationchange",t)}activate(){this.request()}request(){this.requireResize||(this.requireResize=!0,window.requestAnimationFrame(this.resizing))}resize(){this.requireResize&&(this.forEach((t=>t.resize())),this.requireResize=!1)}}class E extends u{constructor(){super("lock"),this._isLocked=!1,this._scrollY=0,this.onPopulate=this.lock.bind(this),this.onEmpty=this.unlock.bind(this)}get isLocked(){return this._isLocked}lock(){this._isLocked||(this._isLocked=!0,this._scrollY=window.scrollY,this.isLegacy?document.body.style.top=-1*this._scrollY+"px":document.body.style.setProperty("--scroll-top",-1*this._scrollY+"px"),document.documentElement.setAttribute(p.attr("scrolling"),"false"))}unlock(){this._isLocked&&(this._isLocked=!1,document.documentElement.removeAttribute(p.attr("scrolling")),this.isLegacy?document.body.style.top="":document.body.style.removeProperty("--scroll-top"),window.scroll(0,this._scrollY))}}class A extends u{constructor(){super("load"),this.loading=this.load.bind(this)}activate(){window.addEventListener("load",this.loading)}load(){this.forEach((t=>t.load()))}}const N=["Marianne","Spectral"];class L extends u{constructor(){super("font-swap"),this.swapping=this.swap.bind(this)}activate(){document.fonts&&document.fonts.addEventListener("loadingdone",this.swapping)}swap(){const t=N.filter((t=>document.fonts.check(`16px ${t}`)));this.forEach((e=>e.swapFont(t)))}}class O extends u{constructor(){super("mouse-move"),this.requireMove=!1,this._isMoving=!1,this.moving=this.move.bind(this),this.requesting=this.request.bind(this),this.onPopulate=this.listen.bind(this),this.onEmpty=this.unlisten.bind(this)}listen(){this._isMoving||(this._isMoving=!0,this.requireMove=!1,document.documentElement.addEventListener("mousemove",this.requesting))}unlisten(){this._isMoving&&(this._isMoving=!1,this.requireMove=!1,document.documentElement.removeEventListener("mousemove",this.requesting))}request(t){this._isMoving&&(this.point={x:t.clientX,y:t.clientY},this.requireMove||(this.requireMove=!0,window.requestAnimationFrame(this.moving)))}move(){this.requireMove&&(this.forEach((t=>t.mouseMove(this.point))),this.requireMove=!1)}}const S=new class{constructor(){t.create(_),t.create(x),t.create(C),t.create(w),t.create(E),t.create(A),t.create(L),t.create(O);const e=t.getModule("register");this.register=e.register.bind(e)}get isActive(){return t.isActive}start(){a.debug("START"),t.isActive=!0}stop(){a.debug("STOP"),t.isActive=!1}};const M=t=>{switch(!0){case t.hover:return"-hover";case t.active:return"-active";default:return""}},I=new class{getColor(t,e,s,i={}){const n=`--${t}-${e}-${s}${M(i)}`;return getComputedStyle(document.documentElement).getPropertyValue(n).trim()||null}},k=t=>"."===t.charAt(0)?t.substr(1):t,R=t=>t.className?t.className.split(" "):[],P=(t,e,s)=>{e=k(e);const i=R(t),n=i.indexOf(e);!0===s?n>-1&&i.splice(n,1):-1===n&&i.push(e),t.className=i.join(" ")},D=(t,e)=>P(t,e),$=(t,e)=>P(t,e,!0),q=(t,e)=>R(t).indexOf(k(e))>-1,T=['[tabindex]:not([tabindex="-1"])',"a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details","iframe"].join(),j=t=>t.querySelectorAll(T),z={};z.addClass=D,z.hasClass=q,z.removeClass=$,z.queryParentSelector=m,z.querySelectorAllArray=g,z.queryActions=j;const G={supportLocalStorage:()=>{try{return"localStorage"in window&&null!==window.localStorage}catch(t){return!1}},supportAspectRatio:()=>!!window.CSS&&CSS.supports("aspect-ratio: 16 / 9")},F={NONE:p.selector("transition-none")},U={};U.TransitionSelector=F;const H=(t,...e)=>(e.forEach((e=>{const s=Object.keys(e).reduce(((t,s)=>(t[s]=Object.getOwnPropertyDescriptor(e,s),t)),{});Object.getOwnPropertySymbols(e).forEach((t=>{const i=Object.getOwnPropertyDescriptor(e,t);i.enumerable&&(s[t]=i)})),Object.defineProperties(t,s)})),t),B={};B.completeAssign=H;const K={},V={};Object.defineProperty(V,"isLegacy",{get:()=>t.isLegacy}),V.setLegacy=()=>{t.isLegacy=!0},K.legacy=V,K.dom=z,K.support=G,K.motion=U,K.property=B,K.ns=p,K.register=S.register,K.state=t,Object.defineProperty(K,"preventManipulation",{get:()=>l.preventManipulation}),Object.defineProperty(K,"stage",{get:()=>t.getModule("stage")}),a.info(`version ${i}`);const Y=e=>t.getModule("stage").getProxy(e);Y.Modes=h,Object.defineProperty(Y,"mode",{set:t=>{l.mode=t},get:()=>l.mode}),Y.internals=K,Y.start=S.start,Y.stop=S.stop,Y.inspector=a,Y.colors=I,l.configure(window[s],Y.start),window[s]=Y;class W{constructor(){this.emissions={}}add(t,e){if("function"!=typeof e)throw new Error("closure must be a function");this.emissions[t]||(this.emissions[t]=[]),this.emissions[t].push(e)}remove(t,e){if(this.emissions[t])if(e){const s=this.emissions[t].indexOf(e);s>-1&&this.emissions[t].splice(s)}else delete this.emissions[t]}emit(t,e){if(!this.emissions[t])return[];const s=[];for(const i of this.emissions[t])i&&s.push(i(e));return s}dispose(){this.emissions=null}}class X{constructor(t,e){this.id=t,this.minWidth=e}test(){return window.matchMedia(`(min-width: ${this.minWidth}em)`).matches}}const Z={XS:new X("xs",0),SM:new X("sm",36),MD:new X("md",48),LG:new X("lg",62),XL:new X("xl",78)};class J{constructor(t=!0){this.jsAttribute=t,this._isRendering=!1,this._isResizing=!1,this._isScrollLocked=!1,this._isLoading=!1,this._isSwappingFont=!1,this._listeners={},this._keyListenerTypes=[],this._keys=[],this.handlingKey=this.handleKey.bind(this),this._emitter=new W,this._ascent=new W,this._descent=new W,this._registrations=[],this._nexts=[]}static get instanceClassName(){return"Instance"}_config(t,e){this.element=t,this.registration=e,this.node=t.node,this.id=t.node.id,this.jsAttribute&&this.setAttribute(e.attribute,!0),this.init()}init(){}get proxy(){const t=this;return{render:()=>t.render(),resize:()=>t.resize()}}register(e,s){const i=t.getModule("register").register(e,s,this);this._registrations.push(i)}getRegisteredInstances(t){for(const e of this._registrations)if(e.hasInstanceClassName(t))return e.instances.collection;return[]}dispatch(t,e,s,i){const n=new CustomEvent(t,{detail:e,bubble:!0===s,cancelable:!0===i});this.node.dispatchEvent(n)}listen(t,e,s){this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].indexOf(e)>-1||(this._listeners[t].push(e),this.node.addEventListener(t,e,s))}unlisten(t,e){if(t)if(e){if(!this._listeners[t])return;const s=this._listeners[t].indexOf(e);s>-1&&this._listeners[t].splice(s,1),this.node.removeEventListener(t,e)}else{if(!this._listeners[t])return;for(const e of this._listeners[t])this.node.removeEventListener(t,e);this._listeners[t].length=0}else for(const t in this._listeners)this.unlisten(t)}listenKey(t,e,s=!1,i=!1,n="down"){-1===this._keyListenerTypes.indexOf(n)&&(this.listen(`key${n}`,this.handlingKey),this._keyListenerTypes.push(n)),this._keys.push(new Q(n,t,e,s,i))}unlistenKey(t,e){this._keys=this._keys.filter((s=>s.code!==t||s.closure!==e)),this._keyListenerTypes.forEach((t=>{this._keys.some((e=>e.type===t))||this.unlisten(`key${t}`,this.handlingKey)}))}handleKey(t){for(const e of this._keys)e.handle(t)}get isRendering(){return this._isRendering}set isRendering(e){this._isRendering!==e&&(e?t.add("render",this):t.remove("render",this),this._isRendering=e)}render(){}request(e){this._nexts.push(e),t.getModule("render").request(this)}next(){const t=this._nexts.slice();this._nexts.length=0;for(const e of t)e&&e()}get isResizing(){return this._isResizing}set isResizing(e){this._isResizing!==e&&(e?(t.add("resize",this),this.resize()):t.remove("resize",this),this._isResizing=e)}resize(){}isBreakpoint(t){return!0==("string"==typeof t)?Z[t.toUpperCase()].test():t.test()}get isScrollLocked(){return this._isScrollLocked}set isScrollLocked(e){this._isScrollLocked!==e&&(e?t.add("lock",this):t.remove("lock",this),this._isScrollLocked=e)}get isLoading(){return this._isLoading}set isLoading(e){this._isLoading!==e&&(e?t.add("load",this):t.remove("load",this),this._isLoading=e)}load(){}get isSwappingFont(){return this._isSwappingFont}set isSwappingFont(e){this._isSwappingFont!==e&&(e?t.add("font-swap",this):t.remove("font-swap",this),this._isSwappingFont=e)}swapFont(){}get isMouseMoving(){return this._isMouseMoving}set isMouseMoving(e){this._isMouseMoving!==e&&(e?t.add("mouse-move",this):t.remove("mouse-move",this),this._isMouseMoving=e)}mouseMove(t){}examine(t){this.node.matches(this.registration.selector)?this.mutate(t):this._dispose()}mutate(t){}_dispose(){a.debug(`dispose instance of ${this.registration.instanceClassName} on element [${this.element.id}]`),this.removeAttribute(this.registration.attribute),this.unlisten(),this._keys=null,this.isRendering=!1,this.isResizing=!1,this._nexts=null,t.getModule("render").nexts.remove(this),this.isScrollLocked=!1,this.isLoading=!1,this.isSwappingFont=!1,this._emitter.dispose(),this._emitter=null,this._ascent.dispose(),this._ascent=null,this._descent.dispose(),this._descent=null,this.element.remove(this);for(const e of this._registrations)t.remove("register",e);this._registrations=null,this.registration.remove(this),this.dispose()}dispose(){}emit(t,e){return this.element.emit(t,e)}addEmission(t,e){this._emitter.add(t,e)}removeEmission(t,e){this._emitter.remove(t,e)}ascend(t,e){return this.element.ascend(t,e)}addAscent(t,e){this._ascent.add(t,e)}removeAscent(t,e){this._ascent.remove(t,e)}descend(t,e){return this.element.descend(t,e)}addDescent(t,e){this._descent.add(t,e)}removeDescent(t,e){this._descent.remove(t,e)}get style(){return this.node.style}addClass(t){D(this.node,t)}removeClass(t){$(this.node,t)}hasClass(t){return q(this.node,t)}get classNames(){return R(this.node)}remove(){this.node.parentNode.removeChild(this.node)}setAttribute(t,e){this.node.setAttribute(t,e)}getAttribute(t){return this.node.getAttribute(t)}hasAttribute(t){return this.node.hasAttribute(t)}removeAttribute(t){this.node.removeAttribute(t)}setProperty(t,e){this.node.style.setProperty(t,e)}removeProperty(t){this.node.style.removeProperty(t)}focus(){this.node.focus()}focusClosest(){const t=this._focusClosest(this.node.parentNode);t&&t.focus()}_focusClosest(t){if(!t)return null;const e=[...j(t)];if(e.length<=1)return this._focusClosest(t.parentNode);{const t=e.indexOf(this.node);return e[t+(t<e.length-1?1:-1)]}}get hasFocus(){return this.node===document.activeElement}matches(t){return this.node.matches(t)}querySelector(t){return this.node.querySelector(t)}querySelectorAll(t){return g(this.node,t)}queryParentSelector(t){return m(this.node,t)}getRect(){return this.node.getBoundingClientRect()}get isLegacy(){return t.isLegacy}}class Q{constructor(t,e,s,i,n){this.type=t,this.eventType=`key${t}`,this.code=e,this.closure=s,this.preventDefault=!0===i,this.stopPropagation=!0===n}handle(t){t.type===this.eventType&&t.keyCode===this.code&&(this.closure(t),this.preventDefault&&t.preventDefault(),this.stopPropagation&&t.stopPropagation())}}const tt={DISCLOSE:p.event("disclose"),CONCEAL:p.event("conceal")},et={RESET:p.emission("disclosure","reset"),ADDED:p.emission("disclosure","added"),REMOVED:p.emission("disclosure","removed"),GROUP:p.emission("disclosure","group"),UNGROUP:p.emission("disclosure","ungroup")};class st extends J{constructor(t,e,s,i){super(),this.type=t,this._selector=e,this.DisclosureButtonInstanceClass=s,this.disclosuresGroupInstanceClassName=i,this.modifier=this._selector+"--"+this.type.id,this.pristine=!0}static get instanceClassName(){return"Disclosure"}init(){this.addDescent(et.RESET,this.reset.bind(this)),this.addDescent(et.GROUP,this.update.bind(this)),this.addDescent(et.UNGROUP,this.update.bind(this)),this.register(`[aria-controls="${this.id}"]`,this.DisclosureButtonInstanceClass),this.ascend(et.ADDED),this.update()}get proxy(){const t=this,e=Object.assign(super.proxy,{disclose:t.disclose.bind(t),focus:t.focus.bind(t)});this.type.canConceal&&(e.conceal=t.conceal.bind(t));return H(e,{get buttons(){return t.buttons.map((t=>t.proxy))},get group(){const e=t.group;return e?e.proxy:null}})}get buttons(){return this.getRegisteredInstances(this.DisclosureButtonInstanceClass.instanceClassName)}update(){this.getGroup()}getGroup(){if(!this.disclosuresGroupInstanceClassName)return void(this._group=null);const t=this.element.getAscendantInstance(this.disclosuresGroupInstanceClassName,this.constructor.instanceClassName);t&&t.validate(this)?this._group=t:this._group=null}get group(){return this._group}disclose(t){return!this.disclosed&&(this.pristine=!1,this.disclosed=!0,!t&&this.group&&(this.group.current=this),!0)}conceal(t,e){return!!this.disclosed&&(!(!this.type.canConceal&&this.group&&this.group.current===this)&&(this.pristine=!1,this.disclosed=!1,!t&&this.group&&this.group.current===this&&(this.group.current=null),e||this.focus(),this.descend(et.RESET),!0))}get disclosed(){return this._disclosed}set disclosed(t){if(this._disclosed!==t){this.dispatch(t?tt.DISCLOSE:tt.CONCEAL,this.type),this._disclosed=t,t?this.addClass(this.modifier):this.removeClass(this.modifier);for(let e=0;e<this.buttons.length;e++)this.buttons[e].apply(t)}}reset(){}toggle(t){if(this.type.canConceal)switch(!0){case!t:case this.disclosed:this.conceal();break;default:this.disclose()}else this.disclose()}get buttonHasFocus(){return!!this.buttons.some((t=>t.hasFocus))}get hasFocus(){return!!super.hasFocus||(!!this.buttonHasFocus||this.querySelectorAll(":focus").length>0)}focus(){for(let t=0;t<this.buttons.length;t++){const e=this.buttons[t];if(e.isPrimary)return void e.focus()}}dispose(){this._group=null,super.dispose(),this.ascend(et.REMOVED)}}class it extends J{constructor(t){super(),this.type=t,this.attributeName=t.ariaState?"aria-"+t.id:p.attr(t.id)}static get instanceClassName(){return"DisclosureButton"}init(){this.controlsId=this.getAttribute("aria-controls"),this.isPrimary=this.hasAttribute(this.attributeName),this.isPrimary&&this.disclosed&&this.registration.creator.pristine&&this.registration.creator.disclose(),this.listen("click",this.click.bind(this))}get proxy(){return Object.assign(super.proxy,{focus:this.focus.bind(this)})}click(t){this.registration.creator&&this.registration.creator.toggle(this.isPrimary)}mutate(t){this.isPrimary&&t.indexOf(this.attributeName)>-1&&this.registration.creator&&(this.disclosed?this.registration.creator.disclose():this.type.canConceal&&this.registration.creator.conceal())}apply(t){this.isPrimary&&this.setAttribute(this.attributeName,t)}get disclosed(){return"true"===this.getAttribute(this.attributeName)}}class nt extends J{constructor(t,e){super(e),this.disclosureInstanceClassName=t,this._index=-1}static get instanceClassName(){return"DisclosuresGroup"}init(){this.addAscent(et.ADDED,this.update.bind(this)),this.addAscent(et.REMOVED,this.update.bind(this)),this.descend(et.GROUP),this.update()}get proxy(){const t=this,e={set index(e){t.index=e},get index(){return t.index},get length(){return t.length},get current(){const e=t.current;return e?e.proxy:null},get members(){return t.members.map((t=>t.proxy))},get hasFocus(){return t.hasFocus}};return H(super.proxy,e)}validate(t){return!0}getMembers(){const t=this.element.getDescendantInstances(this.disclosureInstanceClassName,this.constructor.instanceClassName,!0);this._members=t.filter(this.validate.bind(this))}update(){this.getMembers(),this.getIndex()}get members(){return this._members}get length(){return this.members?this.members.length:0}getIndex(){this._index=-1;for(let t=0;t<this.length;t++)this.index>-1?this.members[t].conceal(!0,!0):this.members[t].disclosed&&(this.index=t)}get index(){return this._index}set index(t){if(!(t<-1||t>=this.length||t===this._index)){this._index=t;for(let e=0;e<this.length;e++){const s=this.members[e];t===e?s.disclose(!0):s.conceal(!0,!0)}this.apply()}}get current(){return-1===this._index?null:this.members[this._index]}set current(t){this.index=this.members.indexOf(t)}get hasFocus(){const t=this.current;return!!t&&t.hasFocus}apply(){}dispose(){super.dispose(),this.descend(et.UNGROUP),this._members=null}}const rt={EXPAND:{id:"expanded",ariaState:!0,ariaControls:!0,canConceal:!0},SELECT:{id:"selected",ariaState:!0,ariaControls:!0,canConceal:!1},OPENED:{id:"opened",ariaState:!1,ariaControls:!0,canConceal:!0}};class ot extends it{constructor(){super(rt.EXPAND)}static get instanceClassName(){return"CollapseButton"}}const at={COLLAPSE:p.selector("collapse"),COLLAPSING:p.selector("collapsing")};const ct={CHANGE:p("equisized")};const ht={TOGGLE:p.event("toggle")};const lt={INJECT_SVG:`[${p.attr("inject-svg")}]`};const dt={ARTWORK_USE:`${p.selector("artwork")} use`},ut=["32x9","16x9","3x2","4x3","1x1","3x4","2x3"],pt=(t,e)=>e.map((e=>p.selector(`${t}--${e}`))).join(","),gt=`${p.selector("responsive-img")}, ${pt("responsive-img",ut)}, ${p.selector("responsive-vid")}, ${pt("responsive-vid",["16x9","4x3","1x1"])}`,mt={RATIO:`${p.selector("ratio")}, ${pt("ratio",ut)}, ${gt}`},ft=window[s];Y.core={Instance:J,Breakpoints:Z,KeyCodes:{TAB:9,ESCAPE:27,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40},Disclosure:st,DisclosureButton:it,DisclosuresGroup:nt,DisclosureType:rt,DisclosureEvent:tt,DisclosureEmission:et,Collapse:class extends st{constructor(){super(rt.EXPAND,at.COLLAPSE,ot,"CollapsesGroup")}static get instanceClassName(){return"Collapse"}init(){super.init(),this.listen("transitionend",this.transitionend.bind(this))}transitionend(t){this.removeClass(at.COLLAPSING),this.disclosed||(this.isLegacy?this.style.maxHeight="":this.style.removeProperty("--collapse-max-height"))}unbound(){this.isLegacy?this.style.maxHeight="none":this.style.setProperty("--collapse-max-height","none")}disclose(t){this.disclosed||(this.unbound(),this.request((()=>{this.addClass(at.COLLAPSING),this.adjust(),this.request((()=>{super.disclose(t)}))})))}conceal(t,e){this.disclosed&&this.request((()=>{this.addClass(at.COLLAPSING),this.adjust(),this.request((()=>{super.conceal(t,e)}))}))}adjust(){this.setProperty("--collapser","none");const t=this.node.offsetHeight;this.setProperty("--collapse",-t+"px"),this.setProperty("--collapser","")}reset(){this.pristine||(this.disclosed=!1)}},CollapseButton:ot,CollapsesGroup:class extends nt{constructor(){super("Collapse")}static get instanceClassName(){return"CollapsesGroup"}},CollapseSelector:at,RootSelector:{ROOT:":root"},Equisized:class extends J{static get instanceClassName(){return"Equisized"}init(){this.ascend(ct.CHANGE)}measure(){return this.isLegacy&&(this.style.width="auto"),this.getRect().width}adjust(t){this.isLegacy&&(this.style.width=`${t}px`)}dispose(){this.ascend(ct.CHANGE)}},EquisizedEmission:ct,Toggle:class extends J{static get instanceClassName(){return"Toggle"}init(){this.pressed="true"===this.pressed,this.listen("click",this.toggle.bind(this))}toggle(){this.pressed="true"!==this.pressed}get pressed(){return this.getAttribute("aria-pressed")}set pressed(t){this.setAttribute("aria-pressed",t?"true":"false"),this.dispatch(ht.TOGGLE,t)}get proxy(){const t=this,e=Object.assign(super.proxy,{toggle:t.toggle.bind(t)});return H(e,{get pressed(){return t.pressed},set pressed(e){t.pressed=e}})}},EquisizedsGroup:class extends J{static get instanceClassName(){return"EquisizedsGroup"}init(){this.isResizing=!0,this.isLoading=!0,this.addAscent(ct.CHANGE,this.resize.bind(this))}load(){this.resize()}resize(){const t=this.element.getDescendantInstances("Equisized");this.isLegacy||this.style.setProperty("--equisized-width","auto");const e=Math.max(...t.map((t=>t.measure())));this.isLegacy?t.forEach((t=>t.adjust(e))):this.style.setProperty("--equisized-width",`${e}px`)}},InjectSvg:class extends J{static get instanceClassName(){return"InjectSvg"}init(){this.node&&(this.img=this.node.querySelector("img")),this.isLegacy||this.replace()}get proxy(){const t=this;return Object.assign(super.proxy,{replace:t.replace.bind(t),restore:t.restore.bind(t)})}fetch(){this.img&&(this.imgID=this.img.getAttribute("id"),this.imgClass=this.img.getAttribute("class"),this.imgURL=this.img.getAttribute("src"),fetch(this.imgURL).then((t=>t.text())).then((t=>{const e=(new DOMParser).parseFromString(t,"text/html");this.svg=e.querySelector("svg"),this.svg&&this.replace()})))}replace(){if(!this.svg)return void this.fetch();this.imgID&&void 0!==this.imgID&&this.svg.setAttribute("id",this.imgID);let t=this.imgURL.match(/[ \w-]+\./)[0];t&&(t=t.slice(0,-1),["dark","light","system"].includes(t)&&(this.svg.innerHTML=this.svg.innerHTML.replaceAll('id="artwork-',`id="${t}-artwork-`),this.svg.innerHTML=this.svg.innerHTML.replaceAll('"#artwork-',`"#${t}-artwork-`))),this.imgClass&&void 0!==this.imgClass&&this.svg.setAttribute("class",this.imgClass),this.svg.hasAttribute("xmlns:a")&&this.svg.removeAttribute("xmlns:a"),this.node.setAttribute("data-fr-inject-svg",!0);var e,s;e=this.svg,s={"aria-hidden":!0,focusable:!1},Object.keys(s).forEach((t=>e.setAttribute(t,s[t]))),this.node.replaceChild(this.svg,this.img)}restore(){this.img&&this.svg&&(this.node.setAttribute("data-fr-inject-svg",!1),this.node.replaceChild(this.img,this.svg))}},InjectSvgSelector:lt,Artwork:class extends J{static get instanceClassName(){return"Artwork"}init(){this.isLegacy&&this.replace()}get proxy(){return Object.assign(super.proxy,{replace:this.replace.bind(this)})}fetch(){this.xlink=this.node.getAttribute("xlink:href");const t=this.xlink.split("#");this.svgUrl=t[0],this.svgName=t[1];const e=new XMLHttpRequest;e.onload=()=>{const t=(new DOMParser).parseFromString(e.responseText,"text/html");this.realSvgContent=t.getElementById(this.svgName),this.realSvgContent&&(this.realSvgContent.classList.add(this.node.classList),this.replace())},e.open("GET",this.svgUrl),e.send()}replace(){this.realSvgContent?this.node.parentNode.replaceChild(this.realSvgContent,this.node):this.fetch()}},ArtworkSelector:dt,Ratio:class extends J{static get instanceClassName(){return"Ratio"}init(){if(!ft.internals.support.supportAspectRatio()){this.ratio=16/9;for(const t in this.classNames)if(this.registration.selector.indexOf(this.classNames[t])>0){const e=this.classNames[t].split("ratio-");e[1]&&(this.ratio=e[1].split("x")[0]/e[1].split("x")[1])}this.isRendering=!0,this.update()}}render(){this.getRect().width!==this.currentWidth&&this.update()}update(){this.currentWidth=this.getRect().width,this.style.height=this.currentWidth/this.ratio+"px"}},RatioSelector:mt},Y.internals.register(Y.core.CollapseSelector.COLLAPSE,Y.core.Collapse),Y.internals.register(Y.core.InjectSvgSelector.INJECT_SVG,Y.core.InjectSvg),Y.internals.register(Y.core.RatioSelector.RATIO,Y.core.Ratio); //# sourceMappingURL=core.module.min.js.map