UNPKG

unpoly

Version:

Progressive enhancement for HTML

1 lines 179 kB
(()=>{var t={4118(t,e,n){"use strict";n.r(e)},1006(t,e,n){"use strict";n.r(e)},891(t,e,n){"use strict";n.r(e)},7078(t,e,n){"use strict";n.r(e)},100(t,e,n){"use strict";n.r(e)},1712(t,e,n){"use strict";n.r(e)},889(){up.browser={submitForm:function(t){t.submit()},canPushState:function(){return"GET"===up.protocol.initialRequestMethod()},canJQuery:function(){return!!window.jQuery},assertConfirmed:function(t){if(t.confirm&&!window.confirm(t.confirm))throw new up.Aborted("User canceled action");return!0},popCookie:function(t){let e=document.cookie.match(new RegExp(t+"=(\\w+)"))?.[1];if(e)return document.cookie=t+"=;Max-Age=0;Path=/",e}}},8504(){const t=up.element,e=up.util;up.BodyShifter=class BodyShifter{constructor(){this.t=new Set,this.i=0,this.o=e.cleaner()}lowerStack(){0===--this.i&&this.u()}raiseStack(){1===++this.i&&this.h()}onAnchoredElementInserted(t){return this.t.add(t),this.l(t,"right"),()=>this.t.delete(t)}p(){return this.i>0}h(){this.m=up.viewport.rootScrollbarWidth(),this.o(t.setStyleTemp(t.root,{"--up-scrollbar-width":this.m+"px"})),this.l(document.body,"padding-right");for(let t of this.t)this.l(t,"right")}u(){this.o.clean()}l(e,n){if(!this.p())return;let i=t.style(e,n);this.o(t.setStyleTemp(e,{["--up-original-"+n]:i}),t.addClassTemp(e,"up-scrollbar-away"))}}},8195(){const t=up.util,e=up.element;up.Change.Addition=class Addition extends up.Change{constructor(t){super(t),this.v=t.acceptLayer,this._=t.dismissLayer,this.k=t.eventPlans||[],this.S=t.response}handleLayerChangeRequests(t,e){this.layer.isOverlay()&&(this.C(),this.layer.assertAlive(),this.layer.tryAcceptForLocation(e,this.S),this.layer.assertAlive(),this.layer.tryAcceptForElements(t,this.S),this.layer.assertAlive(),this.O(),this.layer.assertAlive(),this.layer.tryDismissForLocation(e,this.S),this.layer.assertAlive(),this.layer.tryDismissForElements(t,this.S),this.layer.assertAlive()),this.layer.asCurrent(()=>{for(let t of this.k)up.emit({...t,response:this.S}),this.layer.assertAlive()})}C(){t.isDefined(this.v)&&this.layer.accept(this.v,{response:this.S})}O(){t.isDefined(this._)&&this.layer.dismiss(this._,{response:this.S})}F({oldElement:t,newElement:n,source:i}){"keep"===i&&(i=t&&up.fragment.source(t)),i&&e.setMissingAttr(n,"up-source",up.fragment.normalizeSource(i))}T({newElement:t,time:n}){e.setMissingAttr(t,"up-time",!!n&&n.toUTCString())}R({newElement:t,etag:n}){e.setMissingAttr(t,"up-etag",n||!1)}setReloadAttrs(t){this.F(t),this.T(t),this.R(t)}executeSteps({steps:t,responseDoc:e,noneOptions:n}){return new up.Change.UpdateSteps({steps:t,noneOptions:n}).execute(e)}}},6347(){up.Change=class Change{constructor(t){this.options=t}execute(){throw new up.NotImplemented}deriveFailOptions(){return up.RenderOptions.deriveFailOptions(this.options)}}},2113(){const t=up.util;up.Change.CloseLayer=class CloseLayer extends up.Change{constructor(t){super(t),this.P=t.verb,this.layer=up.layer.get(t),this.L=t.origin,this.A=t.value,this.D=t.preventable??!0,this.S=t.response,this.$=t.history??!0}execute(){if(this.layer.assertAlive(),up.browser.assertConfirmed(this.options),this.M().defaultPrevented&&this.D)throw new up.Aborted("Close event was prevented");this.H(),up.fragment.abort({reason:"Layer is closing",layer:this.layer}),this.layer.state="closing";const{parent:t}=this.layer;this.layer.peel(),this.N(t),this.layer.teardownHandlers(),this.layer.destroyElements(this.options),this.layer.stack.remove(this.layer),this.$&&t.restoreHistory(),this.layer.state="closed",this.j(t)}M(){let e=this.layer.emit(this.B(`up:layer:${this.P}`),{callback:this.layer.callback(`on${t.upperCaseFirst(this.P)}`),log:[`Will ${this.P} ${this.layer} with value %o`,this.A]});return this.A=e.value,e}H(){let t=this.B(`up:layer:${this.P}ing`);this.layer.emit(t,{log:!1})}j(e){const n=`${this.P}ed`,i=t.upperCaseFirst(n);return this.layer.emit(this.B(`up:layer:${n}`),{baseLayer:e,callback:this.layer.callback(`on${i}`),ensureBubbles:!0,log:[`${i} ${this.layer} with value %o`,this.A]})}B(t){return up.event.build(t,{layer:this.layer,value:this.A,origin:this.L,response:this.S})}N(t){let e=this.layer.hasFocus();if(this.layer.overlayFocus.teardown(),t.overlayFocus?.moveToFront(),e){let e=this.layer.origin||t.element;up.focus(e,{preventScroll:!0})}}}},864(){up.Change.DestroyFragment=class DestroyFragment extends up.Change{constructor(t){super(t),this.I=up.layer.get(t)||up.layer.current,this.q=this.options.element,this.U=this.options.animation,this.V=this.options.log}execute(){this.K=this.q.parentNode,up.fragment.markAsDestroying(this.q),up.animate(this.q,this.U,{...this.options,onFinished:()=>{this.X(),this.W(),this.options.onFinished?.()}})}X(){this.I.asCurrent(()=>{up.fragment.abort(this.q),up.script.clean(this.q,{layer:this.I}),this.q.remove()})}W(){up.fragment.emitDestroyed(this.q,{parent:this.K,log:this.V})}}},5249(){var t;const e=up.util;up.Change.FromContent=(t=class FromContent extends up.Change{constructor(t){super(t),this.L=t.origin,this.G=t.preflight,this.J=up.layer.getAll(t)}Y(){let t=[];return this.Z(),this.tt(),this.et(t,this.J,this.options.target),this.et(t,this.J,this.options.fallback),t}nt(t){return"new"===t||t.isAlive()}Z(){this.J=e.filter(this.J,this.nt)}et(t,e,n){for(let i of e)for(let e of this.it(n,i)){const n={...this.options,target:e,layer:i,defaultPlacement:this.rt()},r="new"===i?new up.Change.OpenLayer(n):new up.Change.UpdateLayer(n);t.push(r)}}it(t,e){return up.fragment.expandTargets(t,{layer:e,mode:this.options.mode,origin:this.L})}execute(){return this.options.preload?Promise.resolve():this.st(this.ot.bind(this))||this.ut()}ot(t){return up.fragment.mutate(()=>t.execute(this.ht(),this.ct.bind(this,t)))}lt(t){return!(t instanceof up.CannotMatch)}ct(t){let e=this.Y()[0];t!==e&&up.puts("up.render()",'Could not match primary target "%s". Updating a fallback target "%s".',e.target,t.target);let{assets:n}=this.ht();n&&up.script.assertAssetsOK(n,t.options),this.options.handleAbort(this.getPreflightProps())}ht(){if(this.G)return;const t=e.pick(this.options,["target","content","fragment","document","html","cspInfo","origin","data"]);return up.migrate.handleResponseDocOptions?.(t),"content"===this.rt()&&(t.target=this.ft(t.target)),new up.ResponseDoc(t)}tt(){if(this.G)return;let t=this.ht();this.options.fragment&&(this.options.target||=t.rootSelector()),this.options.title=up.history.refineOption(this.options.title,t.title),this.options.metaTags=up.history.refineOption(this.options.metaTags,t.metaTags),this.options.lang=up.history.refineOption(this.options.lang,t.lang)}rt(){if(!this.options.document&&!this.options.fragment)return"content"}ft(t){let e=this.J[0]||up.layer.root;return this.it(t||":main",e)[0]}getPreflightProps(t={}){return this.st(t=>t.getPreflightProps())||t.optional||this.dt()}dt(){this.gt("Could not find target in current page")}ut(){this.gt("Could not find common target in current page and response")}gt(t){if(this.Y().length){const n=e.uniq(e.map(this.Y(),"target")),i=up.layer.optionToString(this.options.layer);throw new up.CannotMatch([t+" (tried selectors %o in %s)",n,i])}if(0!==this.J.length)throw this.options.didForceFailOptions?new up.CannotMatch("No target selector given for failed responses (https://unpoly.com/failed-responses)"):new up.CannotMatch("No target selector given");this.yt()}yt(){throw new up.CannotMatch("Could not find a layer to render in. You may have passed an unmatchable layer reference, or a detached element.")}st(t){for(let e of this.Y())try{return t(e)}catch(t){if(this.lt(t))throw t}}},e.memoizeMethod(t.prototype,{Y:!0,ht:!0,getPreflightProps:!0}),t)},9797(){var t;const e=up.util;up.Change.FromResponse=(t=class FromResponse extends up.Change{constructor(t){super(t),this.S=t.response,this.wt=this.S.request}execute(){if(up.fragment.config.skipResponse(this.bt())?this.vt():(this.wt.assertEmitted("up:fragment:loaded",{...this.bt(),callback:this.options.onLoaded,log:["Loaded fragment from %s",this.S.description],skip:()=>this.vt()}),this._t()),e.evalOption(this.options.fail,this.S)??!this.S.ok)throw this.kt(this.deriveFailOptions());return this.kt(this.options)}_t(){if(!up.fragment.config.renderableResponse(this.S))throw new up.CannotParse(['Cannot render response with content-type "%s" (configure with up.fragment.config.renderableResponse)',this.S.contentType])}vt(){up.puts("up.render()","Skipping "+this.S.description),this.options.target=":none",this.options.failTarget=":none"}kt(t){return t.didForceFailOptions&&up.puts("up.render()","Rendering failed response using fail-prefixed options (https://unpoly.com/failed-responses)"),this.St(t),t.meta=this.Et(),t.verifyFinished=e=>this.Ct(e,t),new up.Change.FromContent(t).execute()}async Ct(t,e){if(!up.fragment.shouldRevalidate(this.wt,this.S,e))return;let n=e.target,i=t.target;if(/:(before|after)/.test(n))up.warn("up.render()","Cannot revalidate cache when prepending/appending (target %s)",n);else{up.puts("up.render()",'Revalidating cached response for target "%s"',i);let n=await up.reload(i,{...e,...up.RenderOptions.NO_MOTION,...up.RenderOptions.NO_INPUT_INTERFERENCE,...up.RenderOptions.NO_PREVIEWS,feedback:e.feedback,preferOldElements:t.fragments,layer:t.layer,onFinished:null,expiredResponse:this.S,preview:this.Ot(e),abort:!1,cache:!1,background:!0});if(!n.none)return n}}Ot({preview:t,revalidatePreview:e}){return!0===e?t:e}bt(){const{expiredResponse:t}=this.options;return{request:this.wt,response:this.S,renderOptions:this.options,revalidating:!!t,expiredResponse:t}}Et(){let t={revalidating:!!this.options.expiredResponse,ok:this.S.ok};return up.migrate.processHelloMeta?.(t,this.S),t}St(t){const n=this.S.url;let i=n,r=this.wt.hash;r&&(t.hash=r,i+=r),"GET"===this.S.method?t.source=up.history.refineOption(t.source,n):(t.source=up.history.refineOption(t.source,"keep"),t.history=!!t.location);let s=this.S.openLayer;s&&(up.script.adoptRenderOptionsFromHeader(s,this.S.cspInfo),Object.assign(t,{...up.Layer.Overlay.UNSET_VISUALS,target:void 0,...up.fragment.config.navigateOptions,...s,layer:"new"})),t.location=up.history.refineOption(t.location,i),t.title=up.history.refineOption(t.title,this.S.title),t.eventPlans=this.S.eventPlans;let o=this.S.target;o&&(t.target=o),t.acceptLayer=this.S.acceptLayer,t.dismissLayer=this.S.dismissLayer,t.document=this.S.text,this.S.none&&(t.target=":none"),t.context=e.merge(t.context,this.S.context),t.cspInfo=this.S.cspInfo,t.time??=this.S.lastModified,t.etag??=this.S.etag}},e.memoizeMethod(t.prototype,{bt:!0}),t)},1589(){var t;const e=up.util;up.Change.FromURL=(t=class FromURL extends up.Change{async execute(){let t=this.xt();if(t)return up.puts("up.render()",t),up.network.loadPage(this.options),e.unresolvablePromise();let n=this.Ft(),i=this.request=up.request(n);return this.options.onRequestKnown?.(i),this.options.preload?i:(this.options.handleAbort({request:i,...n}),i.runPreviews(this.options),await e.always(i,t=>this.Tt(t)))}xt(){return e.isCrossOrigin(this.options.url)?"Loading cross-origin content in new page":this.options.history&&!up.browser.canPushState()?"Loading content in new page to restore history support":void 0}Ft(){const t=this.Rt(this.options),n=this.Rt(this.deriveFailOptions(),{optional:!0});return{...this.options,...t,...e.withRenamedKeys(n,up.fragment.failKey)}}getPreflightProps(){return this.Ft()}Rt(t,e){return new up.Change.FromContent({...t,preflight:!0}).getPreflightProps(e)}Tt(t){return t instanceof up.Response?this.Pt(t):this.Lt(t)}Pt(t){return new up.Change.FromResponse({...this.options,response:t}).execute()}Lt(t){if(t instanceof up.Offline){let e=["Cannot load fragment from %s: %s",t.request.description,t.reason];this.request.emit("up:fragment:offline",{callback:this.options.onOffline,renderOptions:this.options,retry:t=>up.render({...this.options,...t}),log:e})}throw t}},e.memoizeMethod(t.prototype,{Ft:!0}),t)},5845(){let t=up.util;up.Change.OpenLayer=class OpenLayer extends up.Change.Addition{constructor(t){super(t),this.target=t.target,this.L=t.origin,this.At=t.baseLayer}getPreflightProps(){return{mode:this.options.mode,context:this.Dt().context,origin:this.options.origin,target:this.target,bindLayer:this.At,layer:"new",bindFragments:t.compact([up.fragment.get(":main",{layer:this.At})]),fragments:[]}}execute(e,n){this.$t(e),n(),this.Mt();let i=t.memoize(()=>this.Ht(e)),r=this.layer.on("up:layer:accepting up:layer:dismissing",i);try{let t=[this.Nt(e),...i()];return new up.RenderResult({layer:this.layer,target:this.target,renderOptions:this.options,partialResults:t})}finally{r()}}$t(t){if(":none"===this.target?this.jt=document.createElement("up-none"):this.jt=t.select(this.target),!this.jt||!this.At.isAlive())throw new up.CannotMatch}Mt(){up.puts("up.render()",`Opening element "${this.target}" in new overlay`),this.Bt(),this.layer=this.Dt(),this.At.peel({history:!this.layer.history,intent:this.options.peel}),this.At.saveHistory(),up.layer.stack.push(this.layer),this.layer.createElements(),this.layer.setupHandlers()}Nt(t){this.handleLayerChangeRequests([this.jt],this.It()),t.commitElement(this.jt),this.layer.setContent(this.jt),t.finalizeElement(this.jt),this.qt(),this.setReloadAttrs({newElement:this.jt,source:this.options.source});let e=this.Ut();this.N(),this.zt(),this.layer.state="opened",this.Vt(),this.layer.assertAlive();let n=this.layer.startOpenAnimation();return{fragments:[this.jt],finished:Promise.all([e,n]),verifyFinished:()=>this.layer.assertAlive()}}Ht(t){let e=this.Kt().other;return this.executeSteps({steps:e,responseDoc:t})}async Ut(){await up.hello(this.layer.element,{...this.options,layer:this.layer,dataRoot:this.jt})}Dt(){return up.layer.build(this.options,t=>this.options=up.RenderOptions.finalize(t))}qt(){"auto"===this.layer.history&&(this.layer.history=up.fragment.hasAutoHistory([this.jt],this.layer)),this.layer.history&&=this.At.history,this.layer.updateHistory(this.Xt())}N(){this.At.overlayFocus?.moveToBack(),this.layer.overlayFocus.moveToFront(),new up.FragmentFocus({fragment:this.jt,layer:this.layer,autoMeans:["autofocus","layer"],inputDevice:this.options.inputDevice}).process(this.options.focus)}zt(){const t={...this.options,fragment:this.jt,layer:this.layer,autoMeans:["hash","layer"]};new up.FragmentScrolling(t).process(this.options.scrollMap??this.options.scroll)}Bt(){up.event.assertEmitted("up:layer:open",{origin:this.L,baseLayer:this.At,layerOptions:this.options,log:"Opening new overlay"})}Vt(){this.layer.emit("up:layer:opened",{origin:this.L,callback:this.layer.callback("onOpened"),log:`Opened new ${this.layer}`})}Kt(){return up.radio.hungrySteps(this.Wt())}Wt(){return{...this.options,layer:this.layer,history:this.layer.history}}Xt(){return up.history.options(this.options)}It(){return this.Wt().location}}},5224(){var t;const e=up.util;up.Change.UpdateLayer=(t=class UpdateLayer extends up.Change.Addition{constructor(t){super(t=up.RenderOptions.finalize(t)),this.layer=t.layer,this.target=t.target,this.Gt=t.context,this.Jt=up.fragment.parseTargetSteps(this.target,this.options)}getPreflightProps(){this.Qt();let t=this.Yt();return{layer:this.layer,bindLayer:this.layer,mode:this.layer.mode,context:e.merge(this.layer.context,this.Gt),origin:this.options.origin,target:this.Zt(),fragments:t,bindFragments:t}}Zt(){this.Qt();let t=this.Jt.filter(t=>!t.maybe||t.oldElement?.isConnected);return e.map(t,"selector").join(", ")||":none"}Yt(){return this.Qt(),e.map(this.Jt,"oldElement")}execute(t,n){this.$t(t),n();let i=e.memoize(()=>this.Ht(t)),r=this.layer.on("up:layer:accepting up:layer:dismissing",i);try{let e=[...this.te(t),...i()];return new up.RenderResult({target:this.target,layer:this.layer,renderOptions:this.options,partialResults:e})}finally{r()}}te(t){this.Jt.length&&up.puts("up.render()",`Updating "${this.Zt()}" in ${this.layer}`),this.ee(),this.options.saveScroll&&up.viewport.saveScroll({layer:this.layer}),this.options.saveFocus&&up.viewport.saveFocus({layer:this.layer});let{peel:n}=this.options;return n&&this.layer.peel({history:!this.ne(),intent:n}),!1!==this.options.abort&&up.fragment.abort(this.Yt(),{reason:"Fragment is being replaced",jid:this.options.jid}),Object.assign(this.layer.context,this.Gt),this.handleLayerChangeRequests(e.map(this.Jt,"newElement"),this.It()),this.layer.updateHistory(this.Xt()),this.executeSteps({steps:this.Jt,noneOptions:this.options,responseDoc:t})}Ht(t){let e=this.Kt().other;return this.executeSteps({steps:e,responseDoc:t})}Qt(){this.ie(),this.re()}$t(t){this.ie(),this.se(),this.re(),this.oe(t)}se(){this.Jt.push(...this.Kt().current)}ie(){this.Jt=this.Jt.filter(t=>{const n=new up.FragmentFinder(e.pick(t,["selector","origin","layer","match","preferOldElements"]));if(t.oldElement||=n.find(),t.oldElement)return!0;if(!t.maybe)throw new up.CannotMatch})}oe(t){this.Jt=t.selectSteps(this.Jt)}re(){this.Jt=up.fragment.compressNestedSteps(this.Jt)}Kt(){return up.radio.hungrySteps(this.Wt())}ee(){let t=up.FocusCapsule.preserve(this.layer),e=up.viewport.getScrollTops({layer:this.layer});this.Jt.forEach((n,i)=>{n.focusCapsule=t,n.oldScrollTops=e,n.scrollMap&&(n.scroll=!1),i>0&&(n.focus=!1,n.scrollMap=void 0,"keep"!==n.scroll&&(n.scroll=!1),n.data=void 0)})}ne(){return e.evalAutoOption(this.options.history,this.ue.bind(this))}ue(){const t=e.map(this.Jt,"oldElement");return up.fragment.hasAutoHistory(t,this.layer)}It(){return this.Xt().location}Wt(){return{...this.options,layer:this.layer,history:this.ne()}}Xt(){return this.ne()?up.history.options(this.options):{}}},e.memoizeMethod(t.prototype,{Qt:!0,ie:!0,ne:!0,Kt:!0}),t)},302(){const t=up.util,e=up.element;up.Change.UpdateSteps=class UpdateSteps extends up.Change.Addition{constructor(e){super(e),this.Jt=t.copy(t.assert(e.steps)),this.ae=e.noneOptions||{}}execute(t){return this.responseDoc=t,this.Jt=t.selectSteps(this.Jt),this.Jt=t.commitSteps(this.Jt),[...this.he(),this.ce()]}he(){return this.Jt.length?this.Jt.toReversed().map(t=>this.le(t)).toReversed():this.pe()}ce(){return{verifyFinished:()=>{for(let t of this.Jt)t.layer.assertAlive()}}}le(t){switch(t.placement){case"swap":{let e=up.fragment.keepPlan(t);return e?this.fe(t,e):this.de(t)}case"content":return this.me(t);case"before":case"after":return this.ge(t);default:up.fail("Unknown placement: %o",t.placement)}}pe(){return this.N(null,this.ae),this.zt(null,this.ae),[{}]}fe(t,e){if(e)return up.fragment.emitKept(e),this.N(t.oldElement,t),this.zt(t.oldElement,t),{}}de(t){const e=t.parentElement??t.oldElement.parentNode;let n;up.fragment.markAsDestroying(t.oldElement),this.ye(t);let i=up.motion.morph(t.oldElement,t.newElement,t.transition,{...t,afterInsert:()=>{this.we(t),n=this.be(t.newElement,t),this.ve(t),this.N(t.newElement,t),this.zt(t.newElement,t)},beforeRemove:()=>{up.script.clean(t.oldElement,{layer:t.layer})},afterRemove:()=>{up.fragment.emitDestroyed(t.oldElement,{parent:e,log:!1}),t.afterRemove?.()}});return{fragments:[t.newElement],finished:Promise.all([i,n])}}me(t){let n=[...t.newElement.children],i=e.wrapChildren(t.oldElement),r=e.wrapChildren(t.newElement);return{fragments:n,finished:this.de({...t,placement:"swap",parentElement:t.oldElement.parentNode,oldElement:i,newElement:r,focus:!1,afterRemove:()=>{e.unwrap(r),this.N(t.oldElement,t)}}).finished}}ge(t){let n=[...t.newElement.children],i=e.wrapChildren(t.newElement),r="before"===t.placement?"afterbegin":"beforeend";t.oldElement.insertAdjacentElement(r,i);let s=this.be(i,t);this.zt(i,t);let o=up.animate(i,t.animation,{...t,onFinished:()=>{e.unwrap(i);const n=e.leadingElement(t.oldElement.childNodes)||t.oldElement;this.N(n,t)}});return{fragments:n,finished:Promise.all([s,o])}}be(t,e){return this.responseDoc.finalizeElement(t),this.setReloadAttrs(e),up.hello(t,e)}ye(e){const n=[];if(e.keep)for(let i of e.oldElement.querySelectorAll("[up-keep]")){let r=up.fragment.keepPlan({...e,oldElement:i,descendantsOnly:!0});if(r){const e=i.cloneNode(!0);i.insertAdjacentElement("beforebegin",e),i.classList.add("up-keeping"),up.script.block(r.newElement);let s=up.viewport.subtree(r.oldElement);r.revivers=t.map(s,function(t){let e=up.viewport.copyCursorProps(t);return()=>up.viewport.copyCursorProps(e,t)}),this._e()?r.newElement.replaceWith(i):document.body.append(i),n.push(r)}}e.descendantKeepPlans=n}we(t){for(let e of t.descendantKeepPlans){e.newElement.replaceWith(e.oldElement);for(let t of e.revivers)t()}}ve(t){for(let e of t.descendantKeepPlans)e.oldElement.classList.remove("up-keeping"),up.fragment.emitKept(e)}_e(){return t.some(this.Jt,t=>t.oldElement.matches("body"))}N(t,e){new up.FragmentFocus({...e,fragment:t,autoMeans:up.fragment.config.autoFocus}).process(e.focus)}zt(t,e){new up.FragmentScrolling({...e,fragment:t,autoMeans:up.fragment.config.autoScroll}).process(e.scrollMap??e.scroll)}}},3526(){const t=up.util,e=up.element;up.Config=class Config{constructor(t=()=>({})){this.ke=t,this.reset(),document.addEventListener("up:framework:reset",()=>this.reset())}reset(){Object.assign(this,this.ke())}matches(t,e,n){return t?.matches(this.selector(e,n))}matchesFn(t){return(e,n)=>this.matches(e,t,n)}selector(n,i=""){let r=this[n],s=this["no"+t.upperCaseFirst(n)];return e.unionSelector(r,s,i)}selectorFn(t){return e=>this.selector(t,e)}selectorFns(t){return[this.selectorFn(t),this.matchesFn(t)]}}},8379(){const t=up.util,e=/'nonce-([^']+)'/g;function n(n){let i=n.matchAll(e);return t.map(i,"1")}up.CSPInfo=class CSPInfo{constructor(t="",e=[]){this.declaration=t,this.nonces=e}isStrictDynamic(){return this.declaration.includes("'strict-dynamic'")}isUnsafeEval(){return this.declaration.includes("'unsafe-eval'")}static fromHeader(t){let e={};if(t){let i=t.split(/\s*;\s*/);for(let t of i){let i=t.match(/^(script|default)-src\s/)?.[1];i&&(e[i]=[t,n(t)])}}let i=e.script||e.default;return i?new this(...i):this.none()}static none(){return new this}}},1739(){const t=up.util;up.DestructorPass=class DestructorPass{constructor(t,e){this.Se=t,this.Ee=e}run(){for(let e of this.Ce()){let n=t.pluckKey(e,"upDestructors");n?.clean(e)}}Ce(){const t={...this.Ee,destroying:!0};return up.fragment.subtree(this.Se,".up-can-clean",t)}}},611(){const t=up.util,e=up.element;up.EventEmitter=class EventEmitter extends up.Record{keys(){return["target","event","baseLayer","callback","log","ensureBubbles"]}emit(){return this.Oe(),this.baseLayer?this.baseLayer.asCurrent(()=>this.xe()):this.xe(),this.event}xe(){this.target.dispatchEvent(this.event),this.ensureBubbles&&!this.target.isConnected&&document.dispatchEvent(this.event),up.error.guard(()=>this.callback?.(this.event))}assertEmitted(){const t=this.emit();if(t.defaultPrevented)throw new up.Aborted(`Event ${t.type} was prevented`)}Oe(){if(!up.log.config.enabled)return;let e,n=this.log;t.isArray(n)?[n,...e]=n:e=[];const{type:i}=this.event;t.isString(n)?up.puts(i,n,...e):!1!==n&&up.puts(i,`Event ${i}`)}static fromEmitArgs(n,i={}){let r,s=t.extractOptions(n);return s=t.merge(i,s),t.isElementLike(n[0])?s.target=e.get(n.shift()):n[0]instanceof up.Layer&&(s.layer=n.shift()),t.isGiven(s.layer)&&(r=up.layer.get(s.layer),s.target||=r.element,s.baseLayer||=r),s.baseLayer&&(s.baseLayer=up.layer.get(s.baseLayer)),t.isString(s.target)?s.target=up.fragment.get(s.target,{layer:s.layer}):s.target||(s.target=document),n[0]?.preventDefault?(s.event=n[0],s.log??=n[0].log):t.isString(n[0])?s.event=up.event.build(n[0],s):s.event=up.event.build(s),new this(s)}}},5229(){const t=up.util;up.EventListener=class EventListener extends up.Record{keys(){return["element","eventType","selector","callback","guard","baseLayer","passive","once","capture","beforeBoot"]}constructor(t){super(t),this.Fe=this.constructor.Te(t),this.isDefault=up.framework.evaling,this.beforeBoot??=0===this.eventType.indexOf("up:framework:"),this.nativeCallback=this.nativeCallback.bind(this)}bind(){const t=this.element.upEventListeners||={};t[this.Fe]&&up.fail("up.on(): The %o callback %o cannot be registered more than once",this.eventType,this.callback),t[this.Fe]=this,this.element.addEventListener(...this.Re())}Re(){let e=t.compactObject(t.pick(this,["once","passive","capture"]));return[this.eventType,this.nativeCallback,e]}unbind(){let t=this.element.upEventListeners;t&&delete t[this.Fe],this.element.removeEventListener(...this.Re())}nativeCallback(e){if(up.framework.beforeBoot&&!this.beforeBoot)return;let n=e.target;if(this.selector){let e=t.evalOption(this.selector);n=n.closest(e)}if((!this.guard||this.guard(e))&&n){const t=[e,n],i=this.callback.length;if(1!==i&&2!==i){const e=up.script.data(n);t.push(e)}if("click"===this.eventType&&n.disabled)return;const r=this.callback.bind(n,...t);this.baseLayer?this.baseLayer.asCurrent(r):r()}}static fromElement(t){let e=t.element.upEventListeners;if(e)return e[this.Te(t)]}static Te(e){return e.callback.upUid||=t.uid(),[e.eventType,e.selector,e.callback.upUid].join("|")}static allNonDefault(e){let n=e.upEventListeners;if(n){const e=Object.values(n);return t.reject(e,"isDefault")}return[]}}},3441(){const t=up.util;up.EventListenerGroup=class EventListenerGroup extends up.Record{keys(){return["elements","eventTypes","selector","callback","guard","baseLayer","passive","once","capture","beforeBoot"]}bind(){const e=t.cleaner();return this.Pe(function(t){const n=new up.EventListener(t);return n.bind(),e(n.unbind.bind(n))}),e.clean}Pe(t){for(let e of this.elements)for(let n of this.eventTypes)t(this.Le(e,n))}Le(t,e){return{...this.attributes(),element:t,eventType:e}}unbind(){this.Pe(function(t){let e=up.EventListener.fromElement(t);e&&e.unbind()})}static fromBindArgs(e,n){const i=(e=t.copy(e)).pop();let r;r=e[0].addEventListener?[e.shift()]:t.isJQuery(e[0])||t.isList(e[0])&&e[0][0].addEventListener?e.shift():[document];let s=t.getSimpleTokens(e.shift()),o=up.migrate.fixEventTypes;o&&(s=o(s));const u=t.extractOptions(e);return new this({elements:r,eventTypes:s,selector:e[0],callback:i,...u,...n})}}},621(){const t=up.util;up.FieldWatcher=class FieldWatcher{constructor(t,e,n){this.Ee=e,this.Ae=t,this.De=n,this.$e=e.batch,this.Me=e.logPrefix??"up.watch()",this.He=e.includeDisabled,this.Ne()}start(){return this.je=null,this.Be=this.Ie(),this.qe=null,this.Ue=!1,t.sequence(this.ze(),this.Ve(),this.Ke(),()=>this.Xe())}Ne(){const t=t=>up.fail(t,this.Me,this.Ae);this.De||t("No callback provided for %s (%o)"),this.Ae.matches("input[type=radio]")&&t("Use %s with the container of a radio group, not with an individual radio button (%o)"),up.form.isField(this.Ae)&&!this.Ae.name&&t("%s can only watch fields with a name (%o)")}ze(){return up.form.isField(this.Ae)?this.We(this.Ae):up.form.trackFields(this.Ae,t=>this.We(t))}Ve(){return up.on("up:fragment:aborted",{guard:({target:t})=>t.contains(this.Ge)},()=>this.Xe())}Ke(){return up.on("reset",{guard:({target:t})=>t===this.Ge},t=>this.Je(t))}get Ge(){return up.form.getRegion(this.Ae)}Qe(e){let n=t.copy(this.Ee);return up.form.watchOptions(e,n,{defaults:{event:"input"}})}We(t){let e=this.Qe(t),n=e.event;return up.on(t,n,t=>this.Ye(t,e))}Xe(){this.je=null}Ze(e,n){this.je=e,this.tn=n;let i=n.delay||0;clearTimeout(this.qe),this.qe=t.timer(i,()=>{this.qe=null,this.en()})}nn(e){return!t.isEqual(e,this.Be)&&!t.isEqual(this.je,e)}async en(){if(!this.je)return;if(this.Ue)return;if(this.qe)return;if(!up.fragment.isAlive(this.Ge))return;let e=t.omit(this.tn,["event","delay"]);const n=this.rn(this.Be,this.je);this.Be=this.je,this.je=null,this.Ue=!0,this.tn=null;const i=[];if(this.$e)i.push(this.sn(n,e));else for(let t in n){const r=n[t];i.push(this.sn(r,t,e))}if(t.some(i,t.isPromise)){let t=Promise.allSettled(i);await t}this.Ue=!1,this.en()}sn(...t){return up.error.guard(this.De,...t)}rn(e,n){const i={};let r=Object.keys(e);r=r.concat(Object.keys(n)),r=t.uniq(r);for(let s of r){const r=e[s],o=n[s];t.isEqual(r,o)||(i[s]=o)}return i}Ie(){return up.Params.fromContainer(this.Ae,{includeDisabled:this.He}).toObject()}Ye(t,e={}){const n=this.Ie();this.nn(n)&&(up.log.putsEvent(t),this.Ze(n,e))}Je(e){t.task(()=>this.Ye(e))}}},7275(){const t=up.util;up.FIFOCache=class FIFOCache{constructor({capacity:e=10,normalizeKey:n=t.identity}={}){this.un=new Map,this.an=e,this.hn=n}get(t){return t=this.hn(t),this.un.get(t)}set(t,e){if(this.un.size===this.an){let t=this.un.keys().next().value;this.un.delete(t)}t=this.hn(t),this.un.set(t,e)}clear(){this.un.clear()}}},1438(){up.FocusCapsule=class FocusCapsule{constructor(t,e){this.q=t,this.cn=e,this.ln=up.viewport.copyCursorProps(this.q)}wasLost(){return document.activeElement!==this.q&&!this.pn}autoVoid(){up.on("focusin",{once:!0},()=>this.pn=!0)}restore(t,e){if(!this.wasLost())return!1;let n=up.fragment.get(this.cn,{layer:t});return n?(up.viewport.copyCursorProps(this.ln,n),up.focus(n,e),!0):void 0}static preserve(t){let e=up.viewport.focusedElementWithin(t.element);if(!e)return;let n=up.fragment.tryToTarget(e);return n?new this(e,n):void 0}}},1499(){const t=up.util,e=up.element;up.FormValidator=class FormValidator{constructor(t){this.fn=t,this.dn=[],this.mn=null,this.gn=!1,this.yn()}start(){return up.form.trackFields(this.fn,{guard:t=>this.wn(t)},t=>this.bn(t))}wn(t){return t.closest("[up-validate]:not([up-validate=false])")}bn(t){let e=up.form.validateOptions(t).event;return up.on(t,e,e=>{t.closest(".up-keeping")||(up.log.putsEvent(e),up.error.muteUncriticalRejection(this.validate({origin:t})))})}yn(){up.fragment.onAborted(this.fn,t=>this.vn(t))}vn(t){let e,n=new up.Aborted(t.reason);for(;e=this.dn.shift();)e.deferred.reject(n)}validate(t={}){let e=this._n(t);return this.dn.push(...e),this.kn(),e[0]?.deferred}_n(e){let n=this.Sn(e)||this.En(e)||this.Cn(e.origin),i=t.newDeferred();for(let r of n){let n=up.form.validateOptions(r.origin,e);r.batch=t.pluckKey(n,"batch"),r.renderOptions=n,r.destination=`${n.method} ${n.url}`,r.target=up.fragment.resolveOrigin(r.target,r),r.deferred=i}return n}En({origin:t,...e}){if(up.form.isField(t))return this.On(t)||this.xn(t,e)}xn(t,{formGroup:e=!0}){if(!e)return;let n=up.form.groupSolution(t);return n?(up.puts("up.validate()","Validating form group of field %o",t),[n]):void 0}Sn({target:e,origin:n}){if(t.isString(e)){up.puts("up.validate()",'Validating target "%s"',e);let i=up.fragment.splitTarget(e);return t.compact(i.map(function(t){let e=up.fragment.get(t,{origin:n});if(e)return{element:e,target:t,origin:n};up.fail('Validation target "%s" does not match an element',t)}))}}Cn(t){return up.puts("up.validate()","Validating element %o",t),[{element:t,target:up.fragment.toTarget(t),origin:t}]}On(t){let n=t.closest("[up-validate]");if(n){let i=e.booleanOrStringAttr(n,"up-validate");return this.Sn({target:i,origin:t})}}kn(){let e=this.dn.map(t=>t.renderOptions.delay),n=Math.min(...e)||0;clearTimeout(this.mn),this.mn=t.timer(n,()=>{this.mn=null,this.Fn()})}Fn(){up.error.muteUncriticalRejection(this.Tn())}async Tn(){if(!this.dn.length)return;if(this.gn)return;if(this.mn)return;let t=this.Rn(),e=this.Pn(t);this.gn=!0;try{let n=up.render(e);for(let e of t)e.deferred.resolve(n);await n}finally{this.gn=!1,this.Fn()}}Rn(){let t=[],e=0;for(;e<this.dn.length;){let n=this.dn[e];0===t.length||this.Ln(t[0],n)?(t.push(n),this.dn.splice(e,1)):e++}return t}Ln(t,e){return t.destination===e.destination&&t.batch&&e.batch}Pn(e){let n=t.map(e,"origin"),i=t.flatMap(n,up.form.fields),r=t.uniq(t.map(i,"name")),s=t.map(e,"renderOptions"),o=up.form.destinationOptions(this.fn),u=t.mergeDefined(o,...s);return u.target=t.map(e,"target").join(", "),u.origin=this.fn,u.focus??="keep",u.failOptions=!1,u.defaultMaybe=!0,u.params=up.Params.merge(o.params,...t.map(s,"params")),u.headers=t.merge(o.headers,...t.map(s,"headers")),this.An(u.headers,r),u.feedback=t.some(s,"feedback"),u.data=void 0,u.dataMap=t.mapObject(e,({target:t,element:e,renderOptions:{data:n,keepData:i}})=>[t,i?up.data(e):n]),u.preview=void 0,u.previewMap=t.mapObject(e,({target:t,renderOptions:{preview:e}})=>[t,e]),u.placeholder=void 0,u.placeholderMap=t.mapObject(e,({target:t,renderOptions:{placeholder:e}})=>[t,e]),u.disable=e.map(t=>up.fragment.resolveOrigin(t.renderOptions.disable,t)),u.guardEvent=up.event.build("up:form:validate",{fields:i,log:"Validating form",params:u.params,form:this.fn}),u}An(t,e){let n=up.protocol.headerize("validate"),i=e.join(" ");(!i||i.length>up.protocol.config.maxHeaderSize)&&(i=":unknown"),t[n]=i}}},5887(){const t=up.util,e=/^([^ >+(]+) (.+)$/;up.FragmentFinder=class FragmentFinder{constructor(t){this.Ee=t,this.L=t.origin,this.Dn=t.selector,this.$n=t.document||window.document,this.Mn=t.match??up.fragment.config.match,this.Hn=t.preferOldElements}find(){return this.Nn()||this.jn()||this.Bn()}Nn(){if(this.Hn)return this.Hn.find(t=>this.$n.contains(t)&&up.fragment.matches(t,this.Dn))}jn(){if("region"===this.Mn&&!up.fragment.containsMainPseudo(this.Dn)&&this.L?.isConnected)return this.In()||this.qn()}In(){return up.fragment.closest(this.L,this.Dn,this.Ee)}qn(){let n=up.fragment.splitTarget(this.Dn);return t.findResult(n,t=>{let n=t.match(e);if(n){let t=up.fragment.closest(this.L,n[1],this.Ee);if(t)return up.fragment.getFirstDescendant(t,n[2])}})}Bn(){return up.fragment.getFirstDescendant(this.$n,this.Dn,this.Ee)}}},7919(){const t=up.util,e=up.element,n={preventScroll:!0};up.FragmentFocus=class FragmentFocus extends up.FragmentProcessor{keys(){return super.keys().concat(["hash","focusVisible","focusCapsule","inputDevice"])}processPrimitive(e){switch(e){case"keep":return this.Un();case"restore":return this.zn();case"target":case!0:return this.Vn(this.fragment);case"layer":return this.Vn(this.layer.getFocusElement());case"main":return this.Kn(":main");case"hash":return this.Xn();case"autofocus":return this.Wn();default:if(t.isString(e))return this.Kn(e)}}processElement(t){return this.Vn(t)}resolveCondition(t){return"lost"===t?this.Gn():super.resolveCondition(t)}Kn(t){let e=this.findSelector(t);return this.Vn(e)}Un(){return this.focusCapsule?.restore(this.layer,n)}zn(){return up.viewport.restoreFocus({layer:this.layer})}Wn(){let t=this.fragment&&e.subtreeFirst(this.fragment,"[autofocus]");if(t)return this.Vn(t)}Vn(t){if(t)return up.focus(t,{force:!0,...n,inputDevice:this.inputDevice,focusVisible:this.focusVisible}),!0}Xn(){let t=up.viewport.firstHashTarget(this.hash,{layer:this.layer});if(t)return this.Vn(t)}Gn(){return this.focusCapsule?.wasLost()}}},3728(){const t=up.element,e=up.util;up.FragmentPolling=class FragmentPolling{static forFragment(t){return t.upPolling||=new this(t)}constructor(t){this.Ee=up.radio.pollOptions(t),this.Se=t,up.destructor(t,this.Jn.bind(this)),this.Qn="stopped",this.Yn=null,this.Zn=e.uid(),this.ti=!1,this.ei()}onPollAttributeObserved(){this.ni()}ii({newLayer:t,jid:e}){e===this.Zn||t||this.ri()}si(){"stop"!==this.Yn&&this.ni()}Jn(){this.ri()}ni(t){if(Object.assign(this.Ee,t),"stopped"===this.Qn){if(!up.fragment.isTargetable(this.Se))return void up.warn("[up-poll]","Cannot poll untargetable fragment %o",this.Se);this.Qn="started",this.oi(),this.ui()}}ri(){"started"===this.Qn&&(this.ai(),this.Qn="stopped")}forceStart(t){Object.assign(this.Ee,t),this.Yn="start",this.ni()}forceStop(){this.Yn="stop",this.ri()}oi(){this.hi||(this.hi=!0,up.destructor(this.Se,up.on("visibilitychange up:layer:opened up:layer:dismissed up:layer:accepted",this.ci.bind(this))),up.fragment.onAborted(this.Se,this.ii.bind(this)),up.fragment.onKept(this.Se,this.si.bind(this)))}ci(){this.li()?this.ui():this.ai()}li(){return!document.hidden&&("any"===this.Ee.ifLayer||this.pi())}ai(){clearTimeout(this.fi),this.fi=null}ui(){this.fi||this.ti||"stopped"===this.Qn||(this.ai(),this.fi=setTimeout(this.di.bind(this),this.mi()))}di(){this.fi=null,this.gi()}gi(){if("stopped"!==this.Qn)return up.fragment.isAlive(this.Se)?void(this.li()?this.yi():up.puts("[up-poll]","Will not poll hidden fragment")):(this.ri(),void up.puts("[up-poll]","Stopped polling a detached fragment"))}wi(){return this.Ee.interval??t.numberAttr(this.Se,"up-interval")??up.radio.config.pollInterval}mi(){return Math.max(this.wi()-this.bi(),0)}bi(){return new Date-this._i}pi(){return this.layer||=up.layer.get(this.Se),this.layer?.isFront?.()}yi(){this.ai(),this.ti=!0;let t=up.event.build("up:fragment:poll",{log:["Polling fragment",this.Se]}),e={...this.Ee,guardEvent:t,jid:this.Zn};up.reload(this.Se,e).then(this.ki.bind(this),this.Si.bind(this))}ki({fragment:t}){this.ti=!1,this.ei(),t?this.Ei(t):this.ui()}Ei(t){"start"===this.Yn&&up.fragment.matches(this.Se,t)&&this.constructor.forFragment(t).forceStart(this.Ee)}Si(t){this.ti=!1,this.ei(),this.ui(),up.error.throwCritical(t)}ei(){this._i=new Date}}},2459(){const t=up.util;up.FragmentProcessor=class FragmentProcessor extends up.Record{keys(){return["fragment","autoMeans","origin","layer"]}process(t){let e=this.preprocessOnce(t);return this.tryProcess(e)}preprocessOnce(e){return t.getComplexTokens(e)}tryProcess(e){if(t.isArray(e))return this.processArray(e);if(t.isOptions(e))return this.processSelectorMap(e);if(t.isFunction(e)){let t=up.error.guard(e,this.fragment,this.attributes());return this.tryProcess(t)}if(t.isElement(e))return this.processElement(e);if(t.isString(e)){if("auto"===e)return this.tryProcess(this.autoMeans);let t=e.match(/^(.+?)-if-(.+?)$/);if(t)return this.resolveCondition(t[2])&&this.tryProcess(t[1])}return this.processPrimitive(e)}processSelectorMap(t){return Object.keys(t).filter(e=>{let n=this.findSelector(e);if(n){let i=new this.constructor({...this.attributes(),fragment:n}),r=t[e];return i.process(r)}})}processArray(e){return t.find(e,t=>this.tryProcess(t))}resolveCondition(t){if("main"===t)return this.fragment&&up.fragment.contains(this.fragment,":main")}findSelector(t){const e={layer:this.layer,origin:this.origin};let n=this.fragment&&up.fragment.get(this.fragment,t,e)||up.fragment.get(t,e);if(n)return n;up.warn("up.render()",'Could not find an element matching "%s"',t)}}},9844(){const t=up.util;up.FragmentScrolling=class FragmentScrolling extends up.FragmentProcessor{keys(){return super.keys().concat(["hash","mode","revealTop","revealMax","revealSnap","scrollBehavior","oldScrollTops"])}processPrimitive(e){switch(e){case"top":return this.Ci(0);case"bottom":return this.Ci(-0);case"layer":return this.Oi();case"main":return this.xi(":main");case"keep":return this.Fi();case"restore":return this.Ti();case"hash":return this.hash&&up.viewport.revealHash(this.hash,this.attributes());case"target":case"reveal":case!0:return this.Ri(this.fragment);default:if(t.isNumber(e))return this.Ci(e);if(t.isString(e))return this.xi(e)}}processElement(t){return this.Ri(t)}Ri(t){if(t)return up.reveal(t,this.attributes()),!0}xi(t){let e=this.findSelector(t);return this.Ri(e)}Oi(){return this.Ri(this.layer.getBoxElement())}Ci(t){return up.viewport.scrollTo(t,{...this.attributes(),around:this.fragment})}Fi(){if(this.oldScrollTops)return this.Ti({scrollTops:this.oldScrollTops})}Ti(t){return up.viewport.restoreScroll({...this.attributes(),around:this.fragment,...t})}}},4281(){const t=up.util;up.HelloFragment=class HelloFragment{constructor(t,e,n,{layer:i,data:r,dataRoot:s,dataMap:o,meta:u,insertedEvent:a}){i||=up.layer.get(t)||up.layer.current,this.Ae=t,this.Pi=e,this.Li=n,this.I=i,this.Ai=r,this.Di=s||t,this.$i=o,this.Mi=[],this.Hi=a??!0,u||={},u.layer??=i,u.ok??=!0,u.revalidating??=!1,this.Ni=u}async run(){return up.puts("up.hello()","Compiling fragment %o",this.Ae),this.ji(),this.Bi(this.Pi),this.Ii(),this.Bi(this.Li),this.qi(),await Promise.all(this.Mi),this.Ae}Ii(){up.emit(this.Ae,"up:compilers:before",{log:!1})}qi(){this.Hi&&up.fragment.emitInserted(this.Ae,this.Ni)}ji(){if(this.Ai&&(this.Di.upCompileData=this.Ai),this.$i)for(let t in this.$i)for(let e of this.Ui(t))e.upCompileData=this.$i[t]}Bi(t){this.I.asCurrent(()=>{for(let e of t)this.zi(e)})}zi(t){const e=this.Vi(t);if(e.length){if(t.isDefault||up.puts("up.hello()",'Compiling %d× "%s" on %s',e.length,t.selector,this.I),t.batch)this.Ki(t,e);else for(let n of e)this.Xi(t,n);up.migrate.postCompile?.(e,t)}}Xi(t,e){const n=[e];if(1!==t.length){const t=up.script.data(e);n.push(t,this.Ni)}this.Wi(t,e,n,t=>up.destructor(e,t))}Ki(e,n){const i=[n];if(1!==e.length){const e=t.map(n,up.script.data);i.push(e,this.Ni)}this.Wi(e,n,i,()=>this.Gi(e))}async Wi(e,n,i,r){let s=up.error.guard(()=>e.apply(n,i));if(t.isPromise(s)){let t=up.error.guardPromise(s);this.Mi.push(t),s=await t}s&&r(s)}Gi(t){let e=new up.Error(["Batch compiler (%s) cannot return a destructor",t.selector]);reportError(e)}Ui(e){return up.fragment.subtree(this.Ae,t.evalOption(e),{layer:this.I})}Vi(e){let n=this.Ui(e.selector);return e.rerun||(n=t.filter(n,t=>{let n=t.upAppliedCompilers||=new Set;if(!n.has(e))return n.add(e),!0})),n}}},7687(){const t=up.element,e=up.util;up.Layer=class Layer extends up.Record{keys(){return["element","stack","history","mode","context","lastScrollTops","lastFocusCapsules"]}defaults(){return{context:{},lastScrollTops:up.viewport.newStateCache(),lastFocusCapsules:up.viewport.newStateCache()}}constructor(t={}){super(t),e.assert(this.mode)}setupHandlers(){up.link.convertClicks(this),this.Ji=up.on("up:location:changed",t=>this.Qi(t))}teardownHandlers(){this.Ji?.()}mainTargets(){return up.layer.mainTargets(this.mode)}sync(){}accept(){throw new up.NotImplemented}dismiss(){throw new up.NotImplemented}peel(t){this.stack.peel(this,t)}evalOption(t){return e.evalOption(t,this)}isCurrent(){return this.stack.isCurrent(this)}isFront(){return this.stack.isFront(this)}isRoot(){return this.stack.isRoot(this)}isOverlay(){return this.stack.isOverlay(this)}isAlive(){throw new up.NotImplemented}assertAlive(){if(!this.isAlive())throw new up.Aborted("Layer is no longer alive")}get parent(){return this.stack.parentOf(this)}get child(){return this.stack.childOf(this)}get ancestors(){return this.stack.ancestorsOf(this)}get descendants(){return this.stack.descendantsOf(this)}get subtree(){return[this,...this.descendants]}get index(){return this.Yi??=this.stack.indexOf(this)}getContentElement(){return this.contentElement||this.element}getBoxElement(){return this.boxElement||this.element}getFocusElement(){return this.getBoxElement()}getFirstSwappableElement(){throw new up.NotImplemented}contains(t){return t.closest(up.layer.anySelector())===this.element}on(...t){return this.Zi(t).bind()}off(...t){return this.Zi(t).unbind()}Zi(t){return up.EventListenerGroup.fromBindArgs(t,{guard:t=>this.tr(t),elements:[this.element],baseLayer:this})}tr(t){return this.contains(t.target)}wasHitByMouseEvent({clientX:t,clientY:e}){const n=document.elementFromPoint(t,e);return!n||this.contains(n)}er(t){return up.EventEmitter.fromEmitArgs(t,{layer:this})}emit(...t){return this.er(t).emit()}saveHistory(){e.assert(this.isFront()),this.showsLiveHistory()&&(this.nr=this.title,this.ir=this.metaTags,this.rr=this.location,this.sr=this.lang)}restoreHistory(){this.showsLiveHistory()&&(this.rr&&up.history.push(this.rr),this.nr&&(document.title=this.nr),this.ir&&up.history.updateMetaTags(this.ir),e.isString(this.sr)&&up.history.updateLang(this.sr))}asCurrent(t){return this.stack.asCurrent(this,t)}updateHistory(t){e.isString(t.location)&&this.ur(t.location,{push:!0}),up.history.config.updateMetaTags&&e.isList(t.metaTags)&&(up.migrate?.warnOfHungryMetaTags?.(t.metaTags),this.ar(t.metaTags)),e.isString(t.title)&&this.hr(t.title),e.isString(t.lang)&&this.cr(t.lang)}showsLiveHistory(){return this.history&&this.isFront()}Qi({location:t}){this.showsLiveHistory()&&this.ur(t,{push:!1})}get title(){return this.showsLiveHistory()?document.title:this.nr}hr(t){this.nr=t,this.showsLiveHistory()&&(document.title=t)}get metaTags(){return this.showsLiveHistory()?up.history.findMetaTags():this.ir}ar(t){this.ir=t,this.showsLiveHistory()&&up.history.updateMetaTags(t)}get lang(){return this.showsLiveHistory()?up.history.getLang():this.sr}cr(t){this.sr=t,this.showsLiveHistory()&&up.history.updateLang(t)}get location(){return this.showsLiveHistory()?up.history.location:this.rr}ur(t,{push:e}){let n=this.rr,i=up.history.location;this.rr=t,t!==i&&this.showsLiveHistory()&&e&&up.history.push(t),t!==n&&"opening"!==this.state&&this.emit("up:layer:location:changed",{location:t,previousLocation:n,log:!1})}selector(t){return this.constructor.selector(t)}static selector(t){throw new up.NotImplemented}toString(){throw new up.NotImplemented}affix(...e){return t.affix(this.getFirstSwappableElement(),...e)}[e.isEqual.key](t){return this.constructor===t.constructor&&this.element===t.element}hasFocus(){let t=document.activeElement;return t!==document.body&&this.element.contains(t)}reset(){Object.assign(this,this.defaults())}}},3383(){var t;up.Layer.Cover=((t=class Cover extends up.Layer.OverlayWithViewport{}).mode="cover",t)},8268(){var t;up.Layer.Drawer=((t=class Drawer extends up.Layer.OverlayWithViewport{}).mode="drawer",t)},2009(){var t;up.Layer.Modal=((t=class Modal extends up.Layer.OverlayWithViewport{}).mode="modal",t)},7304(){var t;const e=up.element,n=up.util;up.Layer.Overlay=((t=class Overlay extends up.Layer{keys(){return[...super.keys(),...this.constructor.VISUAL_KEYS,"onOpened","onAccept","onAccepted","onDismiss","onDismissed","acceptEvent","dismissEvent","acceptLocation","dismissLocation","acceptFragment","dismissFragment"]}constructor(t){super(t),this.state="opening",!0===this.dismissible?this.dismissible=["button","key","outside"]:!1===this.dismissible?this.dismissible=[]:this.dismissible=n.getSimpleTokens(this.dismissible),this.acceptLocation&&(this.acceptLocation=new up.URLPattern(this.acceptLocation)),this.dismissLocation&&(this.dismissLocation=new up.URLPattern(this.dismissLocation))}callback(t){let e=this[t];if(e)return e.bind(this)}createElement(t){this.nesting||=this.lr();const e=n.compactObject(n.pick(this,["align","position","size","class","nesting"]));this.element=this.affixPart(t,null,e)}createBackdropElement(t){this.backdropElement=this.affixPart(t,"backdrop")}createViewportElement(t){this.viewportElement=this.affixPart(t,"viewport",{"up-viewport":""})}createBoxElement(t){this.boxElement=this.affixPart(t,"box")}createContentElement(t){this.contentElement=this.affixPart(t,"content")}setContent(t){this.contentElement.append(t),this.onContentSet()}onContentSet(){}createDismissElement(t){return this.dismissElement=this.affixPart(t,"dismiss",{"up-dismiss":'":button"',"aria-label":this.dismissARIALabel}),e.affix(this.dismissElement,'span[aria-hidden="true"]',{text:this.dismissLabel})}affixPart(t,n,i={}){return e.affix(t,this.selector(n),i)}static selector(t){return n.compact(["up",this.mode,t]).join("-")}lr(){const{parent:t}=this;return this.mode===t.mode?1+t.lr():0}setupHandlers(){super.setupHandlers(),this.overlayFocus=new up.OverlayFocus(this),this.pr("button")&&this.createDismissElement(this.getBoxElement()),this.pr("outside")&&(this.viewportElement?up.on(this.viewportElement,"up:click",t=>{t.target===this.viewportElement&&this.dr(t,!0)}):this.mr=this.parent.on("up:click",(t,e)=>{if(!up.layer.isWithinForeignOverlay(e)){const n=this.origin&&this.origin.contains(e);this.dr(t,n)}})),this.pr("key")&&(this.gr=up.event.onEscape(t=>this.onEscapePressed(t))),this.registerAttrCloser("up-accept",(t,e)=>{this.accept(t,e)}),this.registerAttrCloser("up-dismiss",(t,e)=>{this.dismiss(t,e)}),up.migrate.registerLayerCloser?.(this),this.yr(this.acceptEvent,this.accept),this.yr(this.dismissEvent,this.dismiss),this.on("up:click","label[for]",(t,e)=>this.wr(t,e))}wr(t,n){let i=n.getAttribute("for"),r=up.form.fieldSelector(e.idSelector(i)),s=up.fragment.all(r,{layer:"any"}),o=up.fragment.all(r,{layer:this});if(s.length>1&&o[0]!==s[0]){t.preventDefault();const e=o[0];e.focus(),e.matches("input[type=checkbox], input[type=radio]")&&e.click()}}dr(t,e){up.log.putsEvent(t),e&&up.event.halt(t),up.error.muteUncriticalSync(()=>this.dismiss(":outside",{origin:t.target}))}onEscapePressed(t){if(this.isFront()){let e=up.form.focusedField();e?e.blur():this.pr("key")&&(up.event.halt(t,{log:!0}),up.error.muteUncriticalSync(()=>this.dismiss(":key")))}}registerAttrCloser(t,e){this.br(t,e),this.vr(t,e)}br(t,n){this.on("up:click",`[${t}]:not(form)`,(i,r)=>{up.event.halt(i,{log:!0});const s=e.jsonAttr(r,t);this._r(r,s,n)})}vr(t,e){this.on("submit",`[${t}]`,(t,n)=>{up.event.halt(t,{log:!0});const i=up.Params.fromForm(n);this._r(n,i,e)})}_r(t,e,n){const i={origin:t},r=new up.OptionsParser(t,i);r.booleanOrString("animation"),r.string("easing"),r.number("duration"),r.string("confirm"),up.error.muteUncriticalSync(()=>n(e,i))}yr(t,e){if(t)return this.on(t,t=>{t.preventDefault(),up.error.muteUncriticalSync(()=>e.call(this,t,{response:t.response}))})}tryAcceptForElements(t,e){this.kr(this.acceptFragment,this.accept,t,e)}tryDismissForElements(t,e){this.kr(this.dismissFragment,this.dismiss,t,e)}kr(t,i,r,s){let o=n.findResult(r,n=>e.subtreeFirst(n,t));if(o){const t=up.data(o);up.error.muteUncriticalSync(()=>i.call(this,t,{response:s}))}}tryAcceptForLocation(t,e){this.Sr(t,this.acceptLocation,this.accept,e)}tryDismissForLocation(t,e){this.Sr(t,this.dismissLocation,this.dismiss,e)}Sr(t,e,n,i){let r=t&&e?.recognize(t);if(r){const e={...r,location:t};up.error.muteUncriticalSync(()=>n.call(this,e,{response:i}))}}teardownHandlers(){super.teardownHandlers(),this.mr?.(),this.gr?.()}destroyElements(t){const e=this.closeAnimationProps(t);up.destroy(this.element,{...t,...e,onFinished:()=>{this.onElementsRemoved(),t.onFinished?.()},log:!1})}onElementsRemoved(){}Er(t,e){return!up.motion.isNone(t)&&(e=this.backdrop&&e,(n,i)=>{const r=up.animate(this.getBoxElement(),t,i),s=up.animate(this.backdropElement,e,i);return Promise.all([r,s])})}startOpenAnimation(t={}){const e=this.openAnimationProps(t);return up.animate(this.element,e.animation,{...e,onFinished:()=>{this.wasEverVisible=!0,t.onFinished?.()}})}openAnimationProps(t={}){let e=t.animation??this.evalOption(this.openAnimation);return{animation:this.Er(e,"fade-in"),easing:t.easing||this.openEasing,duration:t.duration||this.openDuration}}closeAnimationProps(t={}){let e=this.wasEverVisible&&(t.animation??this.evalOption(this.closeAnimation));return{animation:this.Er(e,"fade-out"),easing:t.easing||this.closeEasing,duration:t.duration??this.closeDuration}}isAlive(){return["opening","opened"].includes(this.state)}accept(t=null,e={}){return this.Cr("accept",t,e)}dismiss(t=null,e={}){return this.Cr("dismis