1try{let e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ff891218-c818-47dd-89ae-419aa216720d",e._sentryDebugIdIdentifier="sentry-dbid-ff891218-c818-47dd-89ae-419aa216720d")}catch(e){}("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{}).SENTRY_RELEASE={id:"v276.0-0-gf58f8bf"};(globalThis.webpackChunk||=[]).push([[89],{89(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{K:()=>connectStreamSource,QS:()=>disconnectStreamSource,YR:()=>visit,aM:()=>renderStreamMessage});const FrameLoadingStyle_eager="eager",FrameLoadingStyle_lazy="lazy";class FrameElement extends HTMLElement{static delegateConstructor=void 0;loaded=Promise.resolve();static get observedAttributes(){return["disabled","loading","src"]}constructor(){super(),this.delegate=new FrameElement.delegateConstructor(this)}connectedCallback(){this.delegate.connect()}disconnectedCallback(){this.delegate.disconnect()}reload(){return this.delegate.sourceURLReloaded()}attributeChangedCallback(name){"loading"==name?this.delegate.loadingStyleChanged():"src"==name?this.delegate.sourceURLChanged():"disabled"==name&&this.delegate.disabledChanged()}get src(){return this.getAttribute("src")}set src(value){value?this.setAttribute("src",value):this.removeAttribute("src")}get refresh(){return this.getAttribute("refresh")}set refresh(value){value?this.setAttribute("refresh",value):this.removeAttribute("refresh")}get shouldReloadWithMorph(){return this.src&&"morph"===this.refresh}get loading(){return function frameLoadingStyleFromString(style){if("lazy"===style.toLowerCase())return FrameLoadingStyle_lazy;return FrameLoadingStyle_eager}(this.getAttribute("loading")||"")}set loading(value){value?this.setAttribute("loading",value):this.removeAttribute("loading")}get disabled(){return this.hasAttribute("disabled")}set disabled(value){value?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get autoscroll(){return this.hasAttribute("autoscroll")}set autoscroll(value){value?this.setAttribute("autoscroll",""):this.removeAttribute("autoscroll")}get complete(){return!this.delegate.isLoading}get isActive(){return this.ownerDocument===document&&!this.isPreview}get isPreview(){return this.ownerDocument?.documentElement?.hasAttribute("data-turbo-preview")}}const drive={enabled:!0,progressBarDelay:500,unvisitableExtensions:new Set([".7z",".aac",".apk",".avi",".bmp",".bz2",".css",".csv",".deb",".dmg",".doc",".docx",".exe",".gif",".gz",".heic",".heif",".ico",".iso",".jpeg",".jpg",".js",".json",".m4a",".mkv",".mov",".mp3",".mp4",".mpeg",".mpg",".msi",".ogg",".ogv",".pdf",".pkg",".png",".ppt",".pptx",".rar",".rtf",".svg",".tar",".tif",".tiff",".txt",".wav",".webm",".webp",".wma",".wmv",".xls",".xlsx",".xml",".zip"])};function activateScriptElement(element){if("false"==element.getAttribute("data-turbo-eval"))return element;{const createdScriptElement=document.createElement("script"),cspNonce=getCspNonce();return cspNonce&&(createdScriptElement.nonce=cspNonce),createdScriptElement.textContent=element.textContent,createdScriptElement.async=!1,function copyElementAttributes(destinationElement,sourceElement){for(const{name,value}of sourceElement.attributes)destinationElement.setAttribute(name,value)}(createdScriptElement,element),createdScriptElement}}function dispatch(eventName,{target,cancelable,detail}={}){const event=new CustomEvent(eventName,{cancelable,bubbles:!0,composed:!0,detail});return target&&target.isConnected?target.dispatchEvent(event):document.documentElement.dispatchEvent(event),event}function cancelEvent(event){event.preventDefault(),event.stopImmediatePropagation()}function nextRepaint(){return"hidden"===document.visibilityState?nextEventLoopTick():nextAnimationFrame()}function nextAnimationFrame(){return new Promise(resolve=>requestAnimationFrame(()=>resolve()))}function nextEventLoopTick(){return new Promise(resolve=>setTimeout(()=>resolve(),0))}function parseHTMLDocument(html=""){return(new DOMParser).parseFromString(html,"text/html")}function unindent(strings,...values){const lines=function interpolate(strings,values){return strings.reduce((result,string,i)=>result+string+(null==values[i]?"":values[i]),"")}(strings,values).replace(/^\n/,"").split("\n"),match=lines[0].match(/^\s+/),indent=match?match[0].length:0;return lines.map(line=>line.slice(indent)).join("\n")}function uuid(){return Array.from({length:36}).map((_,i)=>8==i||13==i||18==i||23==i?"-":14==i?"4":19==i?(Math.floor(4*Math.random())+8).toString(16):Math.floor(16*Math.random()).toString(16)).join("")}function getAttribute(attributeName,...elements){for(const value of elements.map(element=>element?.getAttribute(attributeName)))if("string"==typeof value)return value;return null}function markAsBusy(...elements){for(const element of elements)"turbo-frame"==element.localName&&element.setAttribute("busy",""),element.setAttribute("aria-busy","true")}function clearBusyState(...elements){for(const element of elements)"turbo-frame"==element.localName&&element.removeAttribute("busy"),element.removeAttribute("aria-busy")}function waitForLoad(element,timeoutInMilliseconds=2e3){return new Promise(resolve=>{const onComplete=()=>{element.removeEventListener("error",onComplete),element.removeEventListener("load",onComplete),resolve()};element.addEventListener("load",onComplete,{once:!0}),element.addEventListener("error",onComplete,{once:!0}),setTimeout(resolve,timeoutInMilliseconds)})}function getHistoryMethodForAction(action){switch(action){case"replace":return history.replaceState;case"advance":case"restore":return history.pushState}}function getVisitAction(...elements){const action=getAttribute("data-turbo-action",...elements);return function isAction(action){return"advance"==action||"replace"==action||"restore"==action}(action)?action:null}function getMetaElement(name){return document.querySelector(`meta[name="${name}"]`)}function getMetaContent(name){const element=getMetaElement(name);return element&&element.content}function getCspNonce(){const element=getMetaElement("csp-nonce");if(element){const{nonce,content}=element;return""==nonce?content:nonce}}function findClosestRecursively(element,selector){if(element instanceof Element)return element.closest(selector)||findClosestRecursively(element.assignedSlot||element.getRootNode()?.host,selector)}function elementIsFocusable(element){return!!element&&null==element.closest("[inert], :disabled, [hidden], details:not([open]), dialog:not([open])")&&"function"==typeof element.focus}function queryAutofocusableElement(elementOrDocumentFragment){return Array.from(elementOrDocumentFragment.querySelectorAll("[autofocus]")).find(elementIsFocusable)}function doesNotTargetIFrame(name){if("_blank"===name)return!1;if(name){for(const element of document.getElementsByName(name))if(element instanceof HTMLIFrameElement)return!1;return!0}return!0}function findLinkFromClickTarget(target){const link=findClosestRecursively(target,"a[href], a[xlink\\:href]");if(!link)return null;if(link.href.startsWith("#"))return null;if(link.hasAttribute("download"))return null;const linkTarget=link.getAttribute("target");return linkTarget&&"_self"!==linkTarget?null:link}const submitter={"aria-disabled":{beforeSubmit:submitter=>{submitter.setAttribute("aria-disabled","true"),submitter.addEventListener("click",cancelEvent)},afterSubmit:submitter=>{submitter.removeAttribute("aria-disabled"),submitter.removeEventListener("click",cancelEvent)}},disabled:{beforeSubmit:submitter=>submitter.disabled=!0,afterSubmit:submitter=>submitter.disabled=!1}};const forms=new class Config{#submitter=null;constructor(config){Object.assign(this,config)}get submitter(){return this.#submitter}set submitter(value){this.#submitter=submitter[value]||value}}({mode:"on",submitter:"disabled"}),config={drive,forms};function expandURL(locatable){return new URL(locatable.toString(),document.baseURI)}function getAnchor(url){let anchorMatch;return url.hash?url.hash.slice(1):(anchorMatch=url.href.match(/#(.*)$/))?anchorMatch[1]:void 0}function getAction$1(form,submitter){return expandURL(submitter?.getAttribute("formaction")||form.getAttribute("action")||form.action)}function getExtension(url){return(function getLastPathComponent(url){return function getPathComponents(url){return url.pathname.split("/").slice(1)}(url).slice(-1)[0]}(url).match(/\.[^.]*$/)||[])[0]||""}function locationIsVisitable(location,rootLocation){return function isPrefixedBy(baseURL,url){const prefix=addTrailingSlash(url.origin+url.pathname);return addTrailingSlash(baseURL.href)===prefix||baseURL.href.startsWith(prefix)}(location,rootLocation)&&!config.drive.unvisitableExtensions.has(getExtension(location))}function getLocationForLink(link){return expandURL(link.getAttribute("href")||"")}function toCacheKey(url){return function getRequestURL(url){const anchor=getAnchor(url);return null!=anchor?url.href.slice(0,-(anchor.length+1)):url.href}(url)}function urlsAreEqual(left,right){return expandURL(left).href==expandURL(right).href}function addTrailingSlash(value){return value.endsWith("/")?value:value+"/"}class FetchResponse{constructor(response){this.response=response}get succeeded(){return this.response.ok}get failed(){return!this.succeeded}get clientError(){return this.statusCode>=400&&this.statusCode<=499}get serverError(){return this.statusCode>=500&&this.statusCode<=599}get redirected(){return this.response.redirected}get location(){return expandURL(this.response.url)}get isHTML(){return this.contentType&&this.contentType.match(/^(?:text\/([^\s;,]+\b)?html|application\/xhtml\+xml)\b/)}get statusCode(){return this.response.status}get contentType(){return this.header("Content-Type")}get responseText(){return this.response.clone().text()}get responseHTML(){return this.isHTML?this.response.clone().text():Promise.resolve(void 0)}header(name){return this.response.headers.get(name)}}class LimitedSet extends Set{constructor(maxSize){super(),this.maxSize=maxSize}add(value){if(this.size>=this.maxSize){const oldestValue=this.values().next().value;this.delete(oldestValue)}super.add(value)}}const recentRequests=new LimitedSet(20);function fetchWithTurboHeaders(url,options={}){const modifiedHeaders=new Headers(options.headers||{}),requestUID=uuid();return recentRequests.add(requestUID),modifiedHeaders.append("X-Turbo-Request-Id",requestUID),window.fetch(url,{...options,headers:modifiedHeaders})}function fetchMethodFromString(method){switch(method.toLowerCase()){case"get":return FetchMethod.get;case"post":return FetchMethod.post;case"put":return FetchMethod.put;case"patch":return FetchMethod.patch;case"delete":return FetchMethod.delete}}const FetchMethod={get:"get",post:"post",put:"put",patch:"patch",delete:"delete"};const FetchEnctype={urlEncoded:"application/x-www-form-urlencoded",multipart:"multipart/form-data",plain:"text/plain"};class FetchRequest{abortController=new AbortController;#resolveRequestPromise=_value=>{};constructor(delegate,method,location,requestBody=new URLSearchParams,target=null,enctype=FetchEnctype.urlEncoded){const[url,body]=buildResourceAndBody(expandURL(location),method,requestBody,enctype);this.delegate=delegate,this.url=url,this.target=target,this.fetchOptions={credentials:"same-origin",redirect:"follow",method:method.toUpperCase(),headers:{...this.defaultHeaders}
1,body,signal:this.abortSignal,referrer:this.delegate.referrer?.href},this.enctype=enctype}get method(){return this.fetchOptions.method}set method(value){const fetchBody=this.isSafe?this.url.searchParams:this.fetchOptions.body||new FormData,fetchMethod=fetchMethodFromString(value)||FetchMethod.get;this.url.search="";const[url,body]=buildResourceAndBody(this.url,fetchMethod,fetchBody,this.enctype);this.url=url,this.fetchOptions.body=body,this.fetchOptions.method=fetchMethod.toUpperCase()}get headers(){return this.fetchOptions.headers}set headers(value){this.fetchOptions.headers=value}get body(){return this.isSafe?this.url.searchParams:this.fetchOptions.body}set body(value){this.fetchOptions.body=value}get location(){return this.url}get params(){return this.url.searchParams}get entries(){return this.body?Array.from(this.body.entries()):[]}cancel(){this.abortController.abort()}async perform(){const{fetchOptions}=this;this.delegate.prepareRequest(this);const event=await this.#allowRequestToBeIntercepted(fetchOptions);try{this.delegate.requestStarted(this),event.detail.fetchRequest?this.response=event.detail.fetchRequest.response:this.response=fetchWithTurboHeaders(this.url.href,fetchOptions);const response=await this.response;return await this.receive(response)}catch(error){if("AbortError"!==error.name)throw this.#willDelegateErrorHandling(error)&&this.delegate.requestErrored(this,error),error}finally{this.delegate.requestFinished(this)}}async receive(response){const fetchResponse=new FetchResponse(response);return dispatch("turbo:before-fetch-response",{cancelable:!0,detail:{fetchResponse},target:this.target}).defaultPrevented?this.delegate.requestPreventedHandlingResponse(this,fetchResponse):fetchResponse.succeeded?this.delegate.requestSucceededWithResponse(this,fetchResponse):this.delegate.requestFailedWithResponse(this,fetchResponse),fetchResponse}get defaultHeaders(){return{Accept:"text/html, application/xhtml+xml"}}get isSafe(){return isSafe(this.method)}get abortSignal(){return this.abortController.signal}acceptResponseType(mimeType){this.headers.Accept=[mimeType,this.headers.Accept].join(", ")}async#allowRequestToBeIntercepted(fetchOptions){const requestInterception=new Promise(resolve=>this.#resolveRequestPromise=resolve),event=dispatch("turbo:before-fetch-request",{cancelable:!0,detail:{fetchOptions,url:this.url,resume:this.#resolveRequestPromise},target:this.target});return this.url=event.detail.url,event.defaultPrevented&&await requestInterception,event}#willDelegateErrorHandling(error){return!dispatch("turbo:fetch-request-error",{target:this.target,cancelable:!0,detail:{request:this,error}}).defaultPrevented}}function isSafe(fetchMethod){return fetchMethodFromString(fetchMethod)==FetchMethod.get}
1function buildResourceAndBody(resource,method,requestBody,enctype){const searchParams=Array.from(requestBody).length>0?new URLSearchParams(entriesExcludingFiles(requestBody)):resource.searchParams;return isSafe(method)?[mergeIntoURLSearchParams(resource,searchParams),null]:enctype==FetchEnctype.urlEncoded?[resource,searchParams]:[resource,requestBody]}function entriesExcludingFiles(requestBody){const entries=[];for(const[name,value]of requestBody)value instanceof File||entries.push([name,value]);return entries}function mergeIntoURLSearchParams(url,requestBody){const searchParams=new URLSearchParams(entriesExcludingFiles(requestBody));return url.search=searchParams.toString(),url}class AppearanceObserver{started=!1;constructor(delegate,element){this.delegate=delegate,this.element=element,this.intersectionObserver=new IntersectionObserver(this.intersect)}start(){this.started||(this.started=!0,this.intersectionObserver.observe(this.element))}stop(){this.started&&(this.started=!1,this.intersectionObserver.unobserve(this.element))}intersect=entries=>{const lastEntry=entries.slice(-1)[0];lastEntry?.isIntersecting&&this.delegate.elementAppearedInViewport(this.element)}}class StreamMessage{static contentType="text/vnd.turbo-stream.html";static wrap(message){return"string"==typeof message?new this(function createDocumentFragment(html){const template=document.createElement("template");return template.innerHTML=html,template.content}(message)):message}constructor(fragment){this.fragment=function importStreamElements(fragment){for(const element of fragment.querySelectorAll("turbo-stream")){const streamElement=document.importNode(element,!0);for(const inertScriptElement of streamElement.templateElement.content.querySelectorAll("script"))inertScriptElement.replaceWith(activateScriptElement(inertScriptElement));element.replaceWith(streamElement)}return fragment}(fragment)}}const identity=key=>key;class LRUCache{keys=[];entries={};#toCacheKey;constructor(size,toCacheKey=identity){this.size=size,this.#toCacheKey=toCacheKey}has(key){return this.#toCacheKey(key)in this.entries}get(key){if(this.has(key)){const entry=this.read(key);return this.touch(key),entry}}put(key,entry){return this.write(key,entry),this.touch(key),entry}clear(){for(const key of Object.keys(this.entries))this.evict(key)}read(key){return this.entries[this.#toCacheKey(key)]}write(key,entry){this.entries[this.#toCacheKey(key)]=entry}touch(key){key=this.#toCacheKey(key);const index=this.keys.indexOf(key);index>-1&&this.keys.splice(index,1),this.keys.unshift(key),this.trim()}trim(){for(const key of this.keys.splice(this.size))this.evict(key)}evict(key){delete this.entries[key]}}const cacheTtl=1e4,prefetchCache=new class PrefetchCache extends LRUCache{#prefetchTimeout=null;#maxAges={};constructor(size=1,prefetchDelay=100){super(size,toCacheKey),this.prefetchDelay=prefetchDelay}putLater(url,request,ttl){this.#prefetchTimeout=setTimeout(()=>{request.perform(),this.put(url,request,ttl),this.#prefetchTimeout=null},this.prefetchDelay)}put(url,request,ttl=cacheTtl){super.put(url,request),this.#maxAges[toCacheKey(url)]=new Date((new Date).getTime()+ttl)}clear(){super.clear(),this.#prefetchTimeout&&clearTimeout(this.#prefetchTimeout)}evict(key){super.evict(key),delete this.#maxAges[key]}has(key){if(super.has(key)){const maxAge=this.#maxAges[toCacheKey(key)];return maxAge&&maxAge>Date.now()}return!1}},FormSubmissionState={initialized:"initialized",requesting:"requesting",waiting:"waiting",receiving:"receiving",stopping:"stopping",stopped:"stopped"};class FormSubmission{state=FormSubmissionState.initialized;static confirmMethod(message){return Promise.resolve(confirm(message))}constructor(delegate,formElement,submitter,mustRedirect=!1){const method=function getMethod(formElement,submitter){const method=submitter?.getAttribute("formmethod")||formElement.getAttribute("method")||"";return fetchMethodFromString(method.toLowerCase())||FetchMethod.get}(formElement,submitter),action=function getAction(formAction,fetchMethod){const action=expandURL(formAction);isSafe(fetchMethod)&&(action.search="");return action}(function getFormAction(formElement,submitter){const formElementAction="string"==typeof formElement.action?formElement.action:null;return submitter?.hasAttribute("formaction")?submitter.getAttribute("formaction")||"":formElement.getAttribute("action")||formElementAction||""}(formElement,submitter),method),body=function buildFormData(formElement,submitter){const formData=new FormData(formElement),name=submitter?.getAttribute("name"),value=submitter?.getAttribute("value");name&&formData.append(name,value||"");return formData}(formElement,submitter),enctype=function getEnctype(formElement,submitter){return function fetchEnctypeFromString(encoding){switch(encoding.toLowerCase()){case FetchEnctype.multipart:return FetchEnctype.multipart;case FetchEnctype.plain:return FetchEnctype.plain;default:return FetchEnctype.urlEncoded}}(submitter?.getAttribute("formenctype")||formElement.enctype)}(formElement,submitter);this.delegate=delegate,this.formElement=formElement,this.submitter=submitter,this.fetchRequest=new FetchRequest(this,method,action,body,formElement,enctype),this.mustRedirect=mustRedirect}get method(){return this.fetchRequest.method}set method(value){this.fetchRequest.method=value}get action(){return this.fetchRequest.url.toString()}set action(value){this.fetchRequest.url=expandURL(value)}get body(){return this.fetchRequest.body}get enctype(){return this.fetchRequest.enctype}get isSafe(){return this.fetchRequest.isSafe}get location(){return this.fetchRequest.url}async start(){const{initialized,requesting}=FormSubmissionState,confirmationMessage=getAttribute("data-turbo-confirm",this.submitter,this.formElement);if("string"==typeof confirmationMessage){const confirmMethod="function"==typeof config.forms.confirm?config.forms.confirm:FormSubmission.confirmMethod;if(!await confirmMethod(confirmationMessage,this.formElement,this.submitter))return}if(this.state==initialized)return this.state=requesting,this.fetchRequest.perform()}stop(){const{stopping,stopped}=FormSubmissionState;if(this.state!=stopping&&this.state!=stopped)return this.state=stopping,this.fetchRequest.cancel(),!0}prepareRequest(request){if(!request.isSafe){const token=function getCookieValue(cookieName){if(null!=cookieName){const cookie=(document.cookie?document.cookie.split("; "):[]).find(cookie=>cookie.startsWith(cookieName));if(cookie){const value=cookie.split("=").slice(1).join("=");return value?decodeURIComponent(value):void 0}}}(getMetaContent("csrf-param"))||getMetaContent("csrf-token");token&&(request.headers["X-CSRF-Token"]=token)}this.requestAcceptsTurboStreamResponse(request)&&request.acceptResponseType(StreamMessage.contentType)}requestStarted(_request){this.state=FormSubmissionState.waiting,this.submitter&&config.forms.submitter.beforeSubmit(this.submitter),this.setSubmitsWith(),markAsBusy(this.formElement),dispatch("turbo:submit-start",{target:this.formElement,detail
1:{formSubmission:this}}),this.delegate.formSubmissionStarted(this)}requestPreventedHandlingResponse(request,response){prefetchCache.clear(),this.result={success:response.succeeded,fetchResponse:response}}requestSucceededWithResponse(request,response){if(response.clientError||response.serverError)this.delegate.formSubmissionFailedWithResponse(this,response);else if(prefetchCache.clear(),this.requestMustRedirect(request)&&function responseSucceededWithoutRedirect(response){return 200==response.statusCode&&!response.redirected}(response)){const error=new Error("Form responses must redirect to another location");this.delegate.formSubmissionErrored(this,error)}else this.state=FormSubmissionState.receiving,this.result={success:!0,fetchResponse:response},this.delegate.formSubmissionSucceededWithResponse(this,response)}requestFailedWithResponse(request,response){this.result={success:!1,fetchResponse:response},this.delegate.formSubmissionFailedWithResponse(this,response)}requestErrored(request,error){this.result={success:!1,error},this.delegate.formSubmissionErrored(this,error)}requestFinished(_request){this.state=FormSubmissionState.stopped,this.submitter&&config.forms.submitter.afterSubmit(this.submitter),this.resetSubmitterText(),clearBusyState(this.formElement),dispatch("turbo:submit-end",{target:this.formElement,detail:{formSubmission:this,...this.result}}),this.delegate.formSubmissionFinished(this)}setSubmitsWith(){if(this.submitter&&this.submitsWith)if(this.submitter.matches("button"))this.originalSubmitText=this.submitter.innerHTML,this.submitter.innerHTML=this.submitsWith;else if(this.submitter.matches("input")){const input=this.submitter;this.originalSubmitText=input.value,input.value=this.submitsWith}}resetSubmitterText(){if(this.submitter&&this.originalSubmitText)if(this.submitter.matches("button"))this.submitter.innerHTML=this.originalSubmitText;else if(this.submitter.matches("input")){this.submitter.value=this.originalSubmitText}}requestMustRedirect(request){return!request.isSafe&&this.mustRedirect}requestAcceptsTurboStreamResponse(request){return!request.isSafe||function hasAttribute(attributeName,...elements){return elements.some(element=>element&&element.hasAttribute(attributeName))}("data-turbo-stream",this.submitter,this.formElement)}get submitsWith(){return this.submitter?.getAttribute("data-turbo-submits-with")}}class Snapshot{constructor(element){this.element=element}get activeElement(){return this.element.ownerDocument.activeElement}get children(){return[...this.element.children]}hasAnchor(anchor){return null!=this.getElementForAnchor(anchor)}getElementForAnchor(anchor){return anchor?this.element.querySelector(`[id='${anchor}'], a[name='${anchor}']`):null}get isConnected(){return this.element.isConnected}get firstAutofocusableElement(){return queryAutofocusableElement(this.element)}get permanentElements(){return queryPermanentElementsAll(this.element)}getPermanentElementById(id){return getPermanentElementById(this.element,id)}getPermanentElementMapForSnapshot(snapshot){const permanentElementMap={};for(const currentPermanentElement of this.permanentElements){const{id}=currentPermanentElement,newPermanentElement=snapshot.getPermanentElementById(id);newPermanentElement&&(permanentElementMap[id]=[currentPermanentElement,newPermanentElement])}return permanentElementMap}}function getPermanentElementById(node,id){return node.querySelector(`#${id}[data-turbo-permanent]`)}function queryPermanentElementsAll(node){return node.querySelectorAll("[id][data-turbo-permanent]")}class FormSubmitObserver{started=!1;constructor(delegate,eventTarget){this.delegate=delegate,this.eventTarget=eventTarget}start(){this.started||(this.eventTarget.addEventListener("submit",this.submitCaptured,!0),this.started=!0)}stop(){this.started&&(this.eventTarget.removeEventListener("submit",this.submitCaptured,!0),this.started=!1)}submitCaptured=()=>{this.eventTarget.removeEventListener("submit",this.submitBubbled,!1),this.eventTarget.addEventListener("submit",this.submitBubbled,!1)};submitBubbled=event=>{if(!event.defaultPrevented){const form=event.target instanceof HTMLFormElement?event.target:void 0,submitter=event.submitter||void 0;form&&function submissionDoesNotDismissDialog(form,submitter){const method=submitter?.getAttribute("formmethod")||form.getAttribute("method");return"dialog"!=method}(form,submitter)&&function submissionDoesNotTargetIFrame(form,submitter){const target=submitter?.getAttribute("formtarget")||form.getAttribute("target");return doesNotTargetIFrame(target)}(form,submitter)&&this.delegate.willSubmitForm(form,submitter)&&(event.preventDefault(),event.stopImmediatePropagation(),this.delegate.formSubmitted(form,submitter))}}}class View{#resolveRenderPromise=_value=>{};#resolveInterceptionPromise=_value=>{};constructor(delegate,element){this.delegate=delegate,this.element=element}
1scrollToAnchor(anchor){const element=this.snapshot.getElementForAnchor(anchor);element?(this.focusElement(element),this.scrollToElement(element)):this.scrollToPosition({x:0,y:0})}scrollToAnchorFromLocation(location){this.scrollToAnchor(getAnchor(location))}scrollToElement(element){element.scrollIntoView()}focusElement(element){element instanceof HTMLElement&&(element.hasAttribute("tabindex")?element.focus():(element.setAttribute("tabindex","-1"),element.focus(),element.removeAttribute("tabindex")))}scrollToPosition({x,y}){this.scrollRoot.scrollTo(x,y)}scrollToTop(){this.scrollToPosition({x:0,y:0})}get scrollRoot(){return window}async render(renderer){const{isPreview,shouldRender,willRender,newSnapshot:snapshot}=renderer,shouldInvalidate=willRender;if(shouldRender)try{this.renderPromise=new Promise(resolve=>this.#resolveRenderPromise=resolve),this.renderer=renderer,await this.prepareToRenderSnapshot(renderer);const renderInterception=new Promise(resolve=>this.#resolveInterceptionPromise=resolve),options={resume:this.#resolveInterceptionPromise,render:this.renderer.renderElement,renderMethod:this.renderer.renderMethod};this.delegate.allowsImmediateRender(snapshot,options)||await renderInterception,await this.renderSnapshot(renderer),this.delegate.viewRenderedSnapshot(snapshot,isPreview,this.renderer.renderMethod),this.delegate.preloadOnLoadLinksForView(this.element),this.finishRenderingSnapshot(renderer)}finally{delete this.renderer,this.#resolveRenderPromise(void 0),delete this.renderPromise}else shouldInvalidate&&this.invalidate(renderer.reloadReason)}invalidate(reason){this.delegate.viewInvalidated(reason)}async prepareToRenderSnapshot(renderer){this.markAsPreview(renderer.isPreview),await renderer.prepareToRender()}markAsPreview(isPreview){isPreview?this.element.setAttribute("data-turbo-preview",""):this.element.removeAttribute("data-turbo-preview")}markVisitDirection(direction){this.element.setAttribute("data-turbo-visit-direction",direction)}unmarkVisitDirection(){this.element.removeAttribute("data-turbo-visit-direction")}async renderSnapshot(renderer){await renderer.render()}finishRenderingSnapshot(renderer){renderer.finishRendering()}}class FrameView extends View{missing(){this.element.innerHTML='<strong class="turbo-frame-error">Content missing</strong>'}get snapshot(){return new Snapshot(this.element)}}class LinkInterceptor{constructor(delegate,element){this.delegate=delegate,this.element=element}start(){this.element.addEventListener("click",this.clickBubbled),document.addEventListener("turbo:click",this.linkClicked),document.addEventListener("turbo:before-visit",this.willVisit)}stop(){this.element.removeEventListener("click",this.clickBubbled),document.removeEventListener("turbo:click",this.linkClicked),document.removeEventListener("turbo:before-visit",this.willVisit)}clickBubbled=event=>{this.clickEventIsSignificant(event)?this.clickEvent=event:delete this.clickEvent};linkClicked=event=>{this.clickEvent&&this.clickEventIsSignificant(event)&&this.delegate.shouldInterceptLinkClick(event.target,event.detail.url,event.detail.originalEvent)&&(this.clickEvent.preventDefault(),event.preventDefault(),this.delegate.linkClickIntercepted(event.target,event.detail.url,event.detail.originalEvent)),delete this.clickEvent};willVisit=_event=>{delete this.clickEvent};clickEventIsSignificant(event){const target=event.composed?event.target?.parentElement:event.target,element=findLinkFromClickTarget(target)||target;return element instanceof Element&&element.closest("turbo-frame, html")==this.element}}class LinkClickObserver{started=!1;constructor(delegate,eventTarget){this.delegate=delegate,this.eventTarget=eventTarget}start(){this.started||(this.eventTarget.addEventListener("click",this.clickCaptured,!0),this.started=!0)}stop(){this.started&&(this.eventTarget.removeEventListener("click",this.clickCaptured,!0),this.started=!1)}clickCaptured=()=>{this.eventTarget.removeEventListener("click",this.clickBubbled,!1),this.eventTarget.addEventListener("click",this.clickBubbled,!1)};clickBubbled=event=>{if(event instanceof MouseEvent&&this.clickEventIsSignificant(event)){const link=findLinkFromClickTarget(event.composedPath&&event.composedPath()[0]||event.target);if(link&&doesNotTargetIFrame(link.target)){const location=getLocationForLink(link);this.delegate.willFollowLinkToLocation(link,location,event)&&(event.preventDefault(),this.delegate.followedLinkToLocation(link,location))}}};clickEventIsSignificant(event){return!(event.target&&event.target.isContentEditable||event.defaultPrevented||event.which>1||event.altKey||event.ctrlKey||event.metaKey||event.shiftKey)}}class FormLinkClickObserver{constructor(delegate,element){this.delegate=delegate,this.linkInterceptor=new LinkClickObserver(this,element)}start(){this.linkInterceptor.start()}stop(){this.linkInterceptor.stop()}canPrefetchRequestToLocation(link,location){return!1}prefetchAndCacheRequestToLocation(link,location){}willFollowLinkToLocation(link,location,originalEvent){return this.delegate.willSubmitFormLinkToLocation(link,location,originalEvent)&&(link.hasAttribute("data-turbo-method")||link.hasAttribute("data-turbo-stream"))}followedLinkToLocation(link,location){const form=document.createElement("form");for(const[name,value]of location.searchParams)form.append(Object.assign(document.createElement("input"),{type:"hidden",name,value}));const action=Object.assign(location,{search:""});form.setAttribute("data-turbo","true"),form.setAttribute("action",action.href),form.setAttribute("hidden","");const method=link.getAttribute("data-turbo-method");method&&form.setAttribute("method",method);const turboFrame=link.getAttribute("data-turbo-frame");turboFrame&&form.setAttribute("data-turbo-frame",turboFrame);const turboAction=getVisitAction(link);turboAction&&form.setAttribute("data-turbo-action",turboAction);const turboConfirm=link.getAttribute("data-turbo-confirm");turboConfirm&&form.setAttribute("data-turbo-confirm",turboConfirm);link.hasAttribute("data-turbo-stream")&&form.setAttribute("data-turbo-stream",""),this.delegate.submittedFormLinkToLocation(link,location,form),document.body.appendChild(form),form.addEventListener("turbo:submit-end",()=>form.remove(),{once:!0}),requestAnimationFrame(()=>form.requestSubmit())}}class Bardo{static async preservingPermanentElements(delegate,permanentElementMap,callback){const bardo=new this(delegate,permanentElementMap);bardo.enter(),await callback(),bardo.leave()}constructor(delegate,permanentElementMap){this.delegate=delegate,this.permanentElementMap=permanentElementMap}enter(){for(const id in this.permanentElementMap){const[currentPermanentElement,newPermanentElement]=this.permanentElementMap[id];this.delegate.enteringBardo(currentPermanentElement,newPermanentElement),this.replaceNewPermanentElementWithPlaceholder(newPermanentElement)}}leave(){for(const id in this.permanentElementMap){const[currentPermanentElement]=this.permanentElementMap[id];this.replaceCurrentPermanentElementWithClone(currentPermanentElement),this.replacePlaceholderWithPermanentElement(currentPermanentElement),this.delegate.leavingBardo(currentPermanentElement)}}replaceNewPermanentElementWithPlaceholder(permanentElement){const placeholder=function createPlaceholderForPermanentElement(permanentElement){const element=document.createElement("meta");return element.setAttribute("name","turbo-permanent-placeholder"),element.setAttribute("content",permanentElement.id),element}(permanentElement);permanentElement.replaceWith(placeholder)}replaceCurrentPermanentElementWithClone(permanentElement){const clone=permanentElement.cloneNode(!0);permanentElement.replaceWith(clone)}replacePlaceholderWithPermanentElement(permanentElement){const placeholder=this.getPlaceholderById(permanentElement.id);placeholder?.replaceWith(permanentElement)}getPlaceholderById(id){return this.placeholders.find(element=>element.content==id)}get placeholders(){return[...document.querySelectorAll("meta[name=turbo-permanent-placeholder][content]")]}}class Renderer{#activeElement=null;static renderElement(currentElement,newElement){}
1constructor(currentSnapshot,newSnapshot,isPreview,willRender=!0){this.currentSnapshot=currentSnapshot,this.newSnapshot=newSnapshot,this.isPreview=isPreview,this.willRender=willRender,this.renderElement=this.constructor.renderElement,this.promise=new Promise((resolve,reject)=>this.resolvingFunctions={resolve,reject})}get shouldRender(){return!0}get shouldAutofocus(){return!0}get reloadReason(){}prepareToRender(){}render(){}finishRendering(){this.resolvingFunctions&&(this.resolvingFunctions.resolve(),delete this.resolvingFunctions)}async preservingPermanentElements(callback){await Bardo.preservingPermanentElements(this,this.permanentElementMap,callback)}focusFirstAutofocusableElement(){if(this.shouldAutofocus){const element=this.connectedSnapshot.firstAutofocusableElement;element&&element.focus()}}enteringBardo(currentPermanentElement){this.#activeElement||currentPermanentElement.contains(this.currentSnapshot.activeElement)&&(this.#activeElement=this.currentSnapshot.activeElement)}leavingBardo(currentPermanentElement){currentPermanentElement.contains(this.#activeElement)&&this.#activeElement instanceof HTMLElement&&(this.#activeElement.focus(),this.#activeElement=null)}get connectedSnapshot(){return this.newSnapshot.isConnected?this.newSnapshot:this.currentSnapshot}get currentElement(){return this.currentSnapshot.element}get newElement(){return this.newSnapshot.element}get permanentElementMap(){return this.currentSnapshot.getPermanentElementMapForSnapshot(this.newSnapshot)}get renderMethod(){return"replace"}}class FrameRenderer extends Renderer{static renderElement(currentElement,newElement){const destinationRange=document.createRange();destinationRange.selectNodeContents(currentElement),destinationRange.deleteContents();const frameElement=newElement,sourceRange=frameElement.ownerDocument?.createRange();sourceRange&&(sourceRange.selectNodeContents(frameElement),currentElement.appendChild(sourceRange.extractContents()))}constructor(delegate,currentSnapshot,newSnapshot,renderElement,isPreview,willRender=!0){super(currentSnapshot,newSnapshot,renderElement,isPreview,willRender),this.delegate=delegate}get shouldRender(){return!0}async render(){await nextRepaint(),this.preservingPermanentElements(()=>{this.loadFrameElement()}),this.scrollFrameIntoView(),await nextRepaint(),this.focusFirstAutofocusableElement(),await nextRepaint(),this.activateScriptElements()}loadFrameElement(){this.delegate.willRenderFrame(this.currentElement,this.newElement),this.renderElement(this.currentElement,this.newElement)}scrollFrameIntoView(){if(this.currentElement.autoscroll||this.newElement.autoscroll){const element=this.currentElement.firstElementChild,block=function readScrollLogicalPosition(value,defaultValue){return"end"==value||"start"==value||"center"==value||"nearest"==value?value:defaultValue}(this.currentElement.getAttribute("data-autoscroll-block"),"end"),behavior=function readScrollBehavior(value,defaultValue){return"auto"==value||"smooth"==value?value:defaultValue}(this.currentElement.getAttribute("data-autoscroll-behavior"),"auto");if(element)return element.scrollIntoView({block,behavior}),!0}return!1}activateScriptElements(){for(const inertScriptElement of this.newScriptElements){const activatedScriptElement=activateScriptElement(inertScriptElement);inertScriptElement.replaceWith(activatedScriptElement)}}get newScriptElements(){return this.currentElement.querySelectorAll("script")}}var Idiomorph=function(){const noOp=()=>{},defaults={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:noOp,afterNodeAdded:noOp,beforeNodeMorphed:noOp,afterNodeMorphed:noOp,beforeNodeRemoved:noOp,afterNodeRemoved:noOp,beforeAttributeUpdated:noOp},head:{style:"merge",shouldPreserve:elt=>"true"===elt.getAttribute("im-preserve"),shouldReAppend:elt=>"true"===elt.getAttribute("im-re-append"),shouldRemove:noOp,afterHeadMorphed:noOp},restoreFocus:!0};const morphChildren=function(){function createNode(oldParent,newChild,insertionPoint,ctx){if(!1===ctx.callbacks.beforeNodeAdded(newChild))return null;if(ctx.idMap.has(newChild)){const newEmptyChild=document.createElement(newChild.tagName);return oldParent.insertBefore(newEmptyChild,insertionPoint),morphNode(newEmptyChild,newChild,ctx),ctx.callbacks.afterNodeAdded(newEmptyChild),newEmptyChild}
vendor: 8,214 bytes, line 1
1{const newClonedChild=document.importNode(newChild,!0);return oldParent.insertBefore(newClonedChild,insertionPoint),ctx.callbacks.afterNodeAdded(newClonedChild),newClonedChild}}const findBestMatch=function(){function isIdSetMatch(ctx,oldNode,newNode){let oldSet=ctx.idMap.get(oldNode),newSet=ctx.idMap.get(newNode);if(!newSet||!oldSet)return!1;for(const id of oldSet)if(newSet.has(id))return!0;return!1}function isSoftMatch(oldNode,newNode){const oldElt=oldNode,newElt=newNode;return oldElt.nodeType===newElt.nodeType&&oldElt.tagName===newElt.tagName&&(!oldElt.getAttribute?.("id")||oldElt.getAttribute?.("id")===newElt.getAttribute?.("id"))}return function findBestMatch(ctx,node,startPoint,endPoint){let softMatch=null,nextSibling=node.nextSibling,siblingSoftMatchCount=0,cursor=startPoint;for(;cursor&&cursor!=endPoint;){if(isSoftMatch(cursor,node)){if(isIdSetMatch(ctx,cursor,node))return cursor;null===softMatch&&(ctx.idMap.has(cursor)||(softMatch=cursor))}if(null===softMatch&&nextSibling&&isSoftMatch(cursor,nextSibling)&&(siblingSoftMatchCount++,nextSibling=nextSibling.nextSibling,siblingSoftMatchCount>=2&&(softMatch=void 0)),ctx.activeElementAndParents.includes(cursor))break;cursor=cursor.nextSibling}return softMatch||null}}();function removeNode(ctx,node){if(ctx.idMap.has(node))moveBefore(ctx.pantry,node,null);else{if(!1===ctx.callbacks.beforeNodeRemoved(node))return;node.parentNode?.removeChild(node),ctx.callbacks.afterNodeRemoved(node)}}function removeNodesBetween(ctx,startInclusive,endExclusive){let cursor=startInclusive;for(;cursor&&cursor!==endExclusive;){let tempNode=cursor;cursor=cursor.nextSibling,removeNode(ctx,tempNode)}return cursor}function moveBeforeById(parentNode,id,after,ctx){const target=ctx.target.getAttribute?.("id")===id&&ctx.target||ctx.target.querySelector(`[id="${id}"]`)||ctx.pantry.querySelector(`[id="${id}"]`);return function removeElementFromAncestorsIdMaps(element,ctx){const id=element.getAttribute("id");for(;element=element.parentNode;){let idSet=ctx.idMap.get(element);idSet&&(idSet.delete(id),idSet.size||ctx.idMap.delete(element))}}(target,ctx),moveBefore(parentNode,target,after),target}function moveBefore(parentNode,element,after){if(parentNode.moveBefore)try{parentNode.moveBefore(element,after)}catch(e){parentNode.insertBefore(element,after)}else parentNode.insertBefore(element,after)}return function morphChildren(ctx,oldParent,newParent,insertionPoint=null,endPoint=null){oldParent instanceof HTMLTemplateElement&&newParent instanceof HTMLTemplateElement&&(oldParent=oldParent.content,newParent=newParent.content),insertionPoint||=oldParent.firstChild;for(const newChild of newParent.childNodes){if(insertionPoint&&insertionPoint!=endPoint){const bestMatch=findBestMatch(ctx,newChild,insertionPoint,endPoint);if(bestMatch){bestMatch!==insertionPoint&&removeNodesBetween(ctx,insertionPoint,bestMatch),morphNode(bestMatch,newChild,ctx),insertionPoint=bestMatch.nextSibling;continue}}if(newChild instanceof Element){const newChildId=newChild.getAttribute("id");if(ctx.persistentIds.has(newChildId)){const movedChild=moveBeforeById(oldParent,newChildId,insertionPoint,ctx);morphNode(movedChild,newChild,ctx),insertionPoint=movedChild.nextSibling;continue}}const insertedNode=createNode(oldParent,newChild,insertionPoint,ctx);insertedNode&&(insertionPoint=insertedNode.nextSibling)}for(;insertionPoint&&insertionPoint!=endPoint;){const tempNode=insertionPoint;insertionPoint=insertionPoint.nextSibling,removeNode(ctx,tempNode)}}}(),morphNode=function(){function syncBooleanAttribute(oldElement,newElement,attributeName,ctx){const newLiveValue=newElement[attributeName];if(newLiveValue!==oldElement[attributeName]){const ignoreUpdate=ignoreAttribute(attributeName,oldElement,"update",ctx);ignoreUpdate||(oldElement[attributeName]=newElement[attributeName]),newLiveValue?ignoreUpdate||oldElement.setAttribute(attributeName,""):ignoreAttribute(attributeName,oldElement,"remove",ctx)||oldElement.removeAttribute(attributeName)}}function ignoreAttribute(attr,element,updateType,ctx){return!("value"!==attr||!ctx.ignoreActiveValue||element!==document.activeElement)||!1===ctx.callbacks.beforeAttributeUpdated(attr,element,updateType)}function ignoreValueOfActiveElement(possibleActiveElement,ctx){return!!ctx.ignoreActiveValue&&possibleActiveElement===document.activeElement&&possibleActiveElement!==document.body}return function morphNode(oldNode,newContent,ctx){return ctx.ignoreActive&&oldNode===document.activeElement?null:(!1===ctx.callbacks.beforeNodeMorphed(oldNode,newContent)||(oldNode instanceof HTMLHeadElement&&ctx.head.ignore||(oldNode instanceof HTMLHeadElement&&"morph"!==ctx.head.style?handleHeadElement(oldNode,newContent,ctx):(!function morphAttributes(oldNode,newNode,ctx){let type=newNode.nodeType;if(1===type){const oldElt=oldNode,newElt=newNode,oldAttributes=oldElt.attributes,newAttributes=newElt.attributes;for(const newAttribute of newAttributes)ignoreAttribute(newAttribute.name,oldElt,"update",ctx)||oldElt.getAttribute(newAttribute.name)!==newAttribute.value&&oldElt.setAttribute(newAttribute.name,newAttribute.value);for(let i=oldAttributes.length-1;0<=i;i--){const oldAttribute=oldAttributes[i];if(oldAttribute&&!newElt.hasAttribute(oldAttribute.name)){if(ignoreAttribute(oldAttribute.name,oldElt,"remove",ctx))continue;oldElt.removeAttribute(oldAttribute.name)}}ignoreValueOfActiveElement(oldElt,ctx)||function syncInputValue(oldElement,newElement,ctx){if(oldElement instanceof HTMLInputElement&&newElement instanceof HTMLInputElement&&"file"!==newElement.type){let newValue=newElement.value,oldValue=oldElement.value;syncBooleanAttribute(oldElement,newElement,"checked",ctx),syncBooleanAttribute(oldElement,newElement,"disabled",ctx),newElement.hasAttribute("value")?oldValue!==newValue&&(ignoreAttribute("value",oldElement,"update",ctx)||(oldElement.setAttribute("value",newValue),oldElement.value=newValue)):ignoreAttribute("value",oldElement,"remove",ctx)||(oldElement.value="",oldElement.removeAttribute("value"))}else if(oldElement instanceof HTMLOptionElement&&newElement instanceof HTMLOptionElement)syncBooleanAttribute(oldElement,newElement,"selected",ctx);else if(oldElement instanceof HTMLTextAreaElement&&newElement instanceof HTMLTextAreaElement){let newValue=newElement.value,oldValue=oldElement.value;if(ignoreAttribute("value",oldElement,"update",ctx))return;newValue!==oldValue&&(oldElement.value=newValue),oldElement.firstChild&&oldElement.firstChild.nodeValue!==newValue&&(oldElement.firstChild.nodeValue=newValue)}}(oldElt,newElt,ctx)}8!==type&&3!==type||oldNode.nodeValue!==newNode.nodeValue&&(oldNode.nodeValue=newNode.nodeValue)}(oldNode,newContent,ctx),ignoreValueOfActiveElement(oldNode,ctx)||morphChildren(ctx,oldNode,newContent))),ctx.callbacks.afterNodeMorphed(oldNode,newContent)),oldNode)}}();function handleHeadElement(oldHead,newHead,ctx){let added=[],removed=[],preserved=[],nodesToAppend=[],srcToNewHeadNodes=new Map;for(const newHeadChild of newHead.children)srcToNewHeadNodes.set(newHeadChild.outerHTML,newHeadChild);for(const currentHeadElt of oldHead.children){let inNewContent=srcToNewHeadNodes.has(currentHeadElt.outerHTML),isReAppended=ctx.head.shouldReAppend(currentHeadElt),isPreserved=ctx.head.shouldPreserve(currentHeadElt);inNewContent||isPreserved?isReAppended?removed.push(currentHeadElt):(srcToNewHeadNodes.delete(currentHeadElt.outerHTML),preserved.push(currentHeadElt)):"append"===ctx.head.style?isReAppended&&(removed.push(currentHeadElt),nodesToAppend.push(currentHeadElt)):!1!==ctx.head.shouldRemove(currentHeadElt)&&removed.push(currentHeadElt)}nodesToAppend.push(...srcToNewHeadNodes.values());let promises=[];for(const newNode of nodesToAppend){let newElt=document.createRange().createContextualFragment(newNode.outerHTML).firstChild;if(!1!==ctx.callbacks.beforeNodeAdded(newElt)){if("href"in newElt&&newElt.href||"src"in newElt&&newElt.src){let resolve,promise=new Promise(function(_resolve){resolve=_resolve});newElt.addEventListener("load",function(){resolve()}),promises.push(promise)}oldHead.appendChild(newElt),ctx.callbacks.afterNodeAdded(newElt),added.push(newElt)}}for(const removedElement of removed)!1!==ctx.callbacks.beforeNodeRemoved(removedElement)&&(old
1Head.removeChild(removedElement),ctx.callbacks.afterNodeRemoved(removedElement));return ctx.head.afterHeadMorphed(oldHead,{added,kept:preserved,removed}),promises}const createMorphContext=function(){function createPantry(){const pantry=document.createElement("div");return pantry.hidden=!0,document.body.insertAdjacentElement("afterend",pantry),pantry}function createActiveElementAndParents(oldNode){let activeElementAndParents=[],elt=document.activeElement;if("BODY"!==elt?.tagName&&oldNode.contains(elt))for(;elt&&(activeElementAndParents.push(elt),elt!==oldNode);)elt=elt.parentElement;return activeElementAndParents}function findIdElements(root){let elements=Array.from(root.querySelectorAll("[id]"));return root.getAttribute?.("id")&&elements.push(root),elements}function populateIdMapWithTree(idMap,persistentIds,root,elements){for(const elt of elements){const id=elt.getAttribute("id");if(persistentIds.has(id)){let current=elt;for(;current;){let idSet=idMap.get(current);if(null==idSet&&(idSet=new Set,idMap.set(current,idSet)),idSet.add(id),current===root)break;current=current.parentElement}}}}return function createMorphContext(oldNode,newContent,config){const{persistentIds,idMap}=function createIdMaps(oldContent,newContent){const oldIdElements=findIdElements(oldContent),newIdElements=findIdElements(newContent),persistentIds=function createPersistentIds(oldIdElements,newIdElements){let duplicateIds=new Set,oldIdTagNameMap=new Map;for(const{id,tagName}of oldIdElements)oldIdTagNameMap.has(id)?duplicateIds.add(id):oldIdTagNameMap.set(id,tagName);let persistentIds=new Set;for(const{id,tagName}of newIdElements)persistentIds.has(id)?duplicateIds.add(id):oldIdTagNameMap.get(id)===tagName&&persistentIds.add(id);for(const id of duplicateIds)persistentIds.delete(id);return persistentIds}(oldIdElements,newIdElements);let idMap=new Map;populateIdMapWithTree(idMap,persistentIds,oldContent,oldIdElements);const newRoot=newContent.__idiomorphRoot||newContent;return populateIdMapWithTree(idMap,persistentIds,newRoot,newIdElements),{persistentIds,idMap}}(oldNode,newContent),mergedConfig=function mergeDefaults(config){let finalConfig=Object.assign({},defaults);return Object.assign(finalConfig,config),finalConfig.callbacks=Object.assign({},defaults.callbacks,config.callbacks),finalConfig.head=Object.assign({},defaults.head,config.head),finalConfig}(config),morphStyle=mergedConfig.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(morphStyle))throw`Do not understand how to morph style ${morphStyle}`;return{target:oldNode,newContent,config:mergedConfig,morphStyle,ignoreActive:mergedConfig.ignoreActive,ignoreActiveValue:mergedConfig.ignoreActiveValue,restoreFocus:mergedConfig.restoreFocus,idMap,persistentIds,pantry:createPantry(),activeElementAndParents:createActiveElementAndParents(oldNode),callbacks:mergedConfig.callbacks,head:mergedConfig.head}}}(),{normalizeElement,normalizeParent}=function(){const generatedByIdiomorph=new WeakSet;class SlicedParentNode{constructor(node){this.originalNode=node,this.realParentNode=node.parentNode,this.previousSibling=node.previousSibling,this.nextSibling=node.nextSibling}get childNodes(){const nodes=[];let cursor=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;for(;cursor&&cursor!=this.nextSibling;)nodes.push(cursor),cursor=cursor.nextSibling;return nodes}querySelectorAll(selector){return this.childNodes.reduce((results,node)=>{if(node instanceof Element){node.matches(selector)&&results.push(node);const nodeList=node.querySelectorAll(selector);for(let i=0;i<nodeList.length;i++)results.push(nodeList[i])}return results},[])}insertBefore(node,referenceNode){return this.realParentNode.insertBefore(node,referenceNode)}moveBefore(node,referenceNode){return this.realParentNode.moveBefore(node,referenceNode)}get __idiomorphRoot(){return this.originalNode}}return{normalizeElement:function normalizeElement(content){return content instanceof Document?content.documentElement:content},normalizeParent:function normalizeParent(newContent){if(null==newContent)return document.createElement("div");if("string"==typeof newContent)return normalizeParent(function parseContent(newContent){let parser=new DOMParser,contentWithSvgsRemoved=newContent.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(contentWithSvgsRemoved.match(/<\/html>/)||contentWithSvgsRemoved.match(/<\/head>/)||contentWithSvgsRemoved.match(/<\/body>/)){let content=parser.parseFromString(newContent,"text/html");if(contentWithSvgsRemoved.match(/<\/html>/))return generatedByIdiomorph.add(content),content;{let htmlElement=content.firstChild;return htmlElement&&generatedByIdiomorph.add(htmlElement),htmlElement}}{let content=parser.parseFromString("<body><template>"+newContent+"</template></body>","text/html").body.querySelector("template").content;return generatedByIdiomorph.add(content),content}}(newContent));if(generatedByIdiomorph.has(newContent))return newContent;if(newContent instanceof Node){if(newContent.parentNode)return new SlicedParentNode(newContent);{const dummyParent=document.createElement("div");return dummyParent.append(newContent),dummyParent}}{const dummyParent=document.createElement("div");for(const elt of[...newContent])dummyParent.append(elt);return dummyParent}}}}();return{morph:function morph(oldNode,newContent,config={}){oldNode=normalizeElement(oldNode);const newNode=normalizeParent(newContent),ctx=createMorphContext(oldNode,newNode,config),morphedNodes=function saveAndRestoreFocus(ctx,fn
1){if(!ctx.config.restoreFocus)return fn();let activeElement=document.activeElement;if(!(activeElement instanceof HTMLInputElement||activeElement instanceof HTMLTextAreaElement))return fn();const{id:activeElementId,selectionStart,selectionEnd}=activeElement,results=fn();activeElementId&&activeElementId!==document.activeElement?.getAttribute("id")&&(activeElement=ctx.target.querySelector(`[id="${activeElementId}"]`),activeElement?.focus());activeElement&&!activeElement.selectionEnd&&selectionEnd&&activeElement.setSelectionRange(selectionStart,selectionEnd);return results}(ctx,()=>function withHeadBlocking(ctx,oldNode,newNode,callback){if(ctx.head.block){const oldHead=oldNode.querySelector("head"),newHead=newNode.querySelector("head");if(oldHead&&newHead){const promises=handleHeadElement(oldHead,newHead,ctx);return Promise.all(promises).then(()=>{const newCtx=Object.assign(ctx,{head:{block:!1,ignore:!0}});return callback(newCtx)})}}return callback(ctx)}(ctx,oldNode,newNode,ctx=>"innerHTML"===ctx.morphStyle?(morphChildren(ctx,oldNode,newNode),Array.from(oldNode.childNodes)):function morphOuterHTML(ctx,oldNode,newNode){const oldParent=normalizeParent(oldNode);return morphChildren(ctx,oldParent,newNode,oldNode,oldNode.nextSibling),Array.from(oldParent.childNodes)}(ctx,oldNode,newNode)));return ctx.pantry.remove(),morphedNodes},defaults}}();function morphElements(currentElement,newElement,{callbacks,...options}={}){Idiomorph.morph(currentElement,newElement,{...options,callbacks:new DefaultIdiomorphCallbacks(callbacks)})}function morphChildren(currentElement,newElement,options={}){morphElements(currentElement,newElement.childNodes,{...options,morphStyle:"innerHTML"})}function shouldRefreshFrameWithMorphing(currentFrame,newFrame){return currentFrame instanceof FrameElement&¤tFrame.shouldReloadWithMorph&&(!newFrame||function areFramesCompatibleForRefreshing(currentFrame,newFrame){return newFrame instanceof Element&&"TURBO-FRAME"===newFrame.nodeName&¤tFrame.id===newFrame.id&&(!newFrame.getAttribute("src")||urlsAreEqual(currentFrame.src,newFrame.getAttribute("src")))}(currentFrame,newFrame))&&!currentFrame.closest("[data-turbo-permanent]")}function closestFrameReloadableWithMorphing(node){return node.parentElement.closest("turbo-frame[src][refresh=morph]")}class DefaultIdiomorphCallbacks{#beforeNodeMorphed;constructor({beforeNodeMorphed}={}){this.#beforeNodeMorphed=beforeNodeMorphed||(()=>!0)}beforeNodeAdded=node=>!(node.id&&node.hasAttribute("data-turbo-permanent")&&document.getElementById(node.id));beforeNodeMorphed=(currentElement,newElement)=>{if(currentElement instanceof Element){if(!currentElement.hasAttribute("data-turbo-permanent")&&this.#beforeNodeMorphed(currentElement,newElement)){return!dispatch("turbo:before-morph-element",{cancelable:!0,target:currentElement,detail:{currentElement,newElement}}).defaultPrevented}return!1}};beforeAttributeUpdated=(attributeName,target,mutationType)=>!dispatch("turbo:before-morph-attribute",{cancelable:!0,target,detail:{attributeName,mutationType}}).defaultPrevented;beforeNodeRemoved=node=>this.beforeNodeMorphed(node);afterNodeMorphed=(currentElement,newElement)=>{currentElement instanceof Element&&dispatch("turbo:morph-element",{target:currentElement,detail:{currentElement,newElement}})}}class MorphingFrameRenderer extends FrameRenderer{static renderElement(currentElement,newElement){dispatch("turbo:before-frame-morph",{target:currentElement,detail:{currentElement,newElement}}),morphChildren(currentElement,newElement,{callbacks:{beforeNodeMorphed:(node,newNode)=>!shouldRefreshFrameWithMorphing(node,newNode)||closestFrameReloadableWithMorphing(node)!==currentElement||(node.reload(),!1)}})}async preservingPermanentElements(callback){return await callback()}}class ProgressBar{static animationDuration=300;static get defaultCSS(){return unindent` 2 .turbo-progress-bar { 3 position: fixed; 4 display: block; 5 top: 0; 6 left: 0; 7 height: 3px; 8 background: #0076ff; 9 z-index: 2147483647; 10 transition: 11 width ${ProgressBar.animationDuration}ms ease-out, 12 opacity ${ProgressBar.animationDuration/2}ms ${ProgressBar.animationDuration/2}ms ease-in; 13 transform: translate3d(0, 0, 0); 14 } 15 `}hiding=!1;value=0;visible=!1;constructor(){this.stylesheetElement=this.createStylesheetElement(),this.progressElement=this.createProgressElement(),this.installStylesheetElement(),this.setValue(0)}show(){this.visible||(this.visible=!0,this.installProgressElement(),this.startTrickling())}hide(){this.visible&&!this.hiding&&(this.hiding=!0,this.fadeProgressElement(()=>{this.uninstallProgressElement(),this.stopTrickling(),this.visible=!1,this.hiding=!1}))}setValue(value){this.value=value,this.refresh()}installStylesheetElement(){document.head.insertBefore(this.stylesheetElement,document.head.firstChild)}installProgressElement(){this.progressElement.style.width="0",this.progressElement.style.opacity="1",document.documentElement.insertBefore(this.progressElement,document.body),this.refresh()}fadeProgressElement(callback){this.progressElement.style.opacity="0",setTimeout(callback,1.5*ProgressBar.animationDuration)}uninstallProgressElement(){this.progressElement.parentNode&&document.documentElement.removeChild(this.progressElement)}startTrickling(){this.trickleInterval||(this.trickleInterval=window.setInterval(this.trickle,ProgressBar.animationDuration))}stopTrickling(){window.clearInterval(this.trickleInterval),delete this.trickleInterval}trickle=()=>{this.setValue(this.value+Math.random()/100)};refresh(){requestAnimationFrame(()=>{this.progressElement.style.width=10+90*this.value+"%"})}createStylesheetElement(){const element=document.createElement("style");element.type="text/css",element.textContent=ProgressBar.defaultCSS;const cspNonce=getCspNonce();return cspNonce&&(element.nonce=cspNonce),element}createProgressElement(){const element=document.createElement("div");return element.className="turbo-progress-bar",element}}class HeadSnapshot extends Snapshot{detailsByOuterHTML=this.children.filter(element=>!function elementIsNoscript(element){const tagName=element.localName;return"noscript"==tagName}(element)).map(element=>function elementWithoutNonce(element){element.hasAttribute("nonce")&&element.setAttribute("nonce","");return element}(element)).reduce((result,element)=>{const{outerHTML}=element,details=outerHTML in result?result[outerHTML]:{type:elementType(element),tracked:elementIsTracked(element),elements:[]};return{...result,[outerHTML]:{...details,elements:[...details.elements,element]}}},{});get trackedElementSignature(){return Object.keys(this.detailsByOuterHTML).filter(outerHTML=>
15this.detailsByOuterHTML[outerHTML].tracked).join("")}getScriptElementsNotInSnapshot(snapshot){return this.getElementsMatchingTypeNotInSnapshot("script",snapshot)}getStylesheetElementsNotInSnapshot(snapshot){return this.getElementsMatchingTypeNotInSnapshot("stylesheet",snapshot)}getElementsMatchingTypeNotInSnapshot(matchedType,snapshot){return Object.keys(this.detailsByOuterHTML).filter(outerHTML=>!(outerHTML in snapshot.detailsByOuterHTML)).map(outerHTML=>this.detailsByOuterHTML[outerHTML]).filter(({type})=>type==matchedType).map(({elements:[element]})=>element)}get provisionalElements(){return Object.keys(this.detailsByOuterHTML).reduce((result,outerHTML)=>{const{type,tracked,elements}=this.detailsByOuterHTML[outerHTML];return null!=type||tracked?elements.length>1?[...result,...elements.slice(1)]:result:[...result,...elements]},[])}getMetaValue(name){const element=this.findMetaElementByName(name);return element?element.getAttribute("content"):null}findMetaElementByName(name){return Object.keys(this.detailsByOuterHTML).reduce((result,outerHTML)=>{const{elements:[element]}=this.detailsByOuterHTML[outerHTML];return function elementIsMetaElementWithName(element,name){const tagName=element.localName;return"meta"==tagName&&element.getAttribute("name")==name}(element,name)?element:result},0)}}function elementType(element){return function elementIsScript(element){const tagName=element.localName;return"script"==tagName}(element)?"script":function elementIsStylesheet(element){const tagName=element.localName;return"style"==tagName||"link"==tagName&&"stylesheet"==element.getAttribute("rel")}(element)?"stylesheet":void 0}function elementIsTracked(element){return"reload"==element.getAttribute("data-turbo-track")}class PageSnapshot extends Snapshot{static fromHTMLString(html=""){return this.fromDocument(parseHTMLDocument(html))}static fromElement(element){return this.fromDocument(element.ownerDocument)}static fromDocument({documentElement,body,head}){return new this(documentElement,body,new HeadSnapshot(head))}constructor(documentElement,body,headSnapshot){super(body),this.documentElement=documentElement,this.headSnapshot=headSnapshot}clone(){const clonedElement=this.element.cloneNode(!0),selectElements=this.element.querySelectorAll("select"),clonedSelectElements=clonedElement.querySelectorAll("select");for(const[index,source]of selectElements.entries()){const clone=clonedSelectElements[index];for(const option of clone.selectedOptions)option.selected=!1;for(const option of source.selectedOptions)clone.options[option.index].selected=!0}for(const clonedPasswordInput of clonedElement.querySelectorAll('input[type="password"]'))clonedPasswordInput.value="";for(const clonedNoscriptElement of clonedElement.querySelectorAll("noscript"))clonedNoscriptElement.remove();return new PageSnapshot(this.documentElement,clonedElement,this.headSnapshot)}get lang(){return this.documentElement.getAttribute("lang")}get dir(){return this.documentElement.getAttribute("dir")}get headElement(){return this.headSnapshot.element}get rootLocation(){return expandURL(this.getSetting("root")??"/")}get cacheControlValue(){return this.getSetting("cache-control")}get isPreviewable(){return"no-preview"!=this.cacheControlValue}get isCacheable(){return"no-cache"!=this.cacheControlValue}get isVisitable(){return"reload"!=this.getSetting("visit-control")}get prefersViewTransitions(){return("true"===this.getSetting("view-transition")||"same-origin"===this.headSnapshot.getMetaValue("view-transition"))&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches}get refreshMethod(){return this.getSetting("refresh-method")}get refreshScroll(){return this.getSetting("refresh-scroll")}getSetting(name){return this.headSnapshot.getMetaValue(`turbo-${name}`)}}class ViewTransitioner{#viewTransitionStarted=!1;#lastOperation=Promise.resolve();renderChange(useViewTransition,render){return useViewTransition&&this.viewTransitionsAvailable&&!this.#viewTransitionStarted?(this.#viewTransitionStarted=!0,this.#lastOperation=this.#lastOperation.then(async()=>{await document.startViewTransition(render).finished})):this.#lastOperation=this.#lastOperation.then(render),this.#lastOperation}get viewTransitionsAvailable(){return document.startViewTransition}}const defaultOptions={action:"advance",historyChanged:!1,visitCachedSnapshot:()=>{},willRender:!0,updateHistory:!0,shouldCacheSnapshot:!0,acceptsStreamResponse:!1,refresh:{}},TimingMetric_visitStart="visitStart",TimingMetric_requestStart="requestStart",TimingMetric_requestEnd="requestEnd",TimingMetric_visitEnd="visitEnd",VisitState_initialized="initialized",VisitState_started="started",VisitState_canceled="canceled",VisitState_failed="failed",VisitState_completed="completed",SystemStatusCode_networkFailure=0,SystemStatusCode_timeoutFailure=-1,SystemStatusCode_contentTypeMismatch=-2,Direction={advance:"forward",restore:"back",replace:"none"};class Visit{identifier=uuid();timingMetrics={};followedRedirect=!1;historyChanged=!1;scrolled=!1;shouldCacheSnapshot=!0;acceptsStreamResponse=!1;snapshotCached=!1;state=VisitState_initialized;viewTransitioner=new ViewTransitioner;constructor(delegate,location,restorationIdentifier,options={}){this.delegate=delegate,this.location=location,this.restorationIdentifier=restorationIdentifier||uuid();const{action,historyChanged,referrer,snapshot,snapshotHTML,response,visitCachedSnapshot,willRender,updateHistory,shouldCacheSnapshot,acceptsStreamResponse,direction,refresh}={...defaultOptions,...options};this.action=action,this.historyChanged=historyChanged,this.referrer=referrer,this.snapshot=snapsh
15ot,this.snapshotHTML=snapshotHTML,this.response=response,this.isPageRefresh=this.view.isPageRefresh(this),this.visitCachedSnapshot=visitCachedSnapshot,this.willRender=willRender,this.updateHistory=updateHistory,this.scrolled=!willRender,this.shouldCacheSnapshot=shouldCacheSnapshot,this.acceptsStreamResponse=acceptsStreamResponse,this.direction=direction||Direction[action],this.refresh=refresh}get adapter(){return this.delegate.adapter}get view(){return this.delegate.view}get history(){return this.delegate.history}get restorationData(){return this.history.getRestorationDataForIdentifier(this.restorationIdentifier)}start(){this.state==VisitState_initialized&&(this.recordTimingMetric(TimingMetric_visitStart),this.state=VisitState_started,this.adapter.visitStarted(this),this.delegate.visitStarted(this))}cancel(){this.state==VisitState_started&&(this.request&&this.request.cancel(),this.cancelRender(),this.state=VisitState_canceled)}complete(){this.state==VisitState_started&&(this.recordTimingMetric(TimingMetric_visitEnd),this.adapter.visitCompleted(this),this.state=VisitState_completed,this.followRedirect(),this.followedRedirect||this.delegate.visitCompleted(this))}fail(){this.state==VisitState_started&&(this.state=VisitState_failed,this.adapter.visitFailed(this),this.delegate.visitCompleted(this))}changeHistory(){if(!this.historyChanged&&this.updateHistory){const method=getHistoryMethodForAction(this.location.href===this.referrer?.href?"replace":this.action);this.history.update(method,this.location,this.restorationIdentifier),this.historyChanged=!0}}issueRequest(){this.hasPreloadedResponse()?this.simulateRequest():this.shouldIssueRequest()&&!this.request&&(this.request=new FetchRequest(this,FetchMethod.get,this.location),this.request.perform())}simulateRequest(){this.response&&(this.startRequest(),this.recordResponse(),this.finishRequest())}startRequest(){this.recordTimingMetric(TimingMetric_requestStart),this.adapter.visitRequestStarted(this)}recordResponse(response=this.response){if(this.response=response,response){const{statusCode}=response;isSuccessful(statusCode)?this.adapter.visitRequestCompleted(this):this.adapter.visitRequestFailedWithStatusCode(this,statusCode)}}finishRequest(){this.recordTimingMetric(TimingMetric_requestEnd),this.adapter.visitRequestFinished(this)}loadResponse(){if(this.response){const{statusCode,responseHTML}=this.response;this.render(async()=>{if(this.shouldCacheSnapshot&&this.cacheSnapshot(),this.view.renderPromise&&await this.view.renderPromise,isSuccessful(statusCode)&&null!=responseHTML){const snapshot=PageSnapshot.fromHTMLString(responseHTML);await this.renderPageSnapshot(snapshot,!1),this.adapter.visitRendered(this),this.complete()}else await this.view.renderError(PageSnapshot.fromHTMLString(responseHTML),this),this.adapter.visitRendered(this),this.fail()})}}getCachedSnapshot(){const snapshot=this.view.getCachedSnapshotForLocation(this.location)||this.getPreloadedSnapshot();if(snapshot&&(!getAnchor(this.location)||snapshot.hasAnchor(getAnchor(this.location)))&&("restore"==this.action||snapshot.isPreviewable))return snapshot}getPreloadedSnapshot(){if(this.snapshotHTML)return PageSnapshot.fromHTMLString(this.snapshotHTML)}hasCachedSnapshot(){return null!=this.getCachedSnapshot()}loadCachedSnapshot(){const snapshot=this.getCachedSnapshot();if(snapshot){const isPreview=this.shouldIssueRequest();this.render(async()=>{this.cacheSnapshot(),this.isPageRefresh?this.adapter.visitRendered(this):(this.view.renderPromise&&await this.view.renderPromise,await this.renderPageSnapshot(snapshot,isPreview),this.adapter.visitRendered(this),isPreview||this.complete())})}}followRedirect(){this.redirectedToLocation&&!this.followedRedirect&&this.response?.redirected&&(this.adapter.visitProposedToLocation(this.redirectedToLocation,{action:"replace",response:this.response,shouldCacheSnapshot:!1,willRender:!1}),this.followedRedirect=!0)}prepareRequest(request){this.acceptsStreamResponse&&request.acceptResponseType(StreamMessage.contentType)}requestStarted(){this.startRequest()}requestPreventedHandlingResponse(_request,_response){}async requestSucceededWithResponse(request,response){const responseHTML=await response.responseHTML,{redirected,statusCode}=response;null==responseHTML?this.recordResponse({statusCode:SystemStatusCode_contentTypeMismatch,redirected}):(this.redirectedToLocation=response.redirected?response.location:void 0,this.recordResponse({statusCode,responseHTML,redirected}))}async requestFailedWithResponse(request,response){const responseHTML=await response.responseHTML,{redirected,statusCode}=response;null==responseHTML?this.recordResponse({statusCode:SystemStatusCode_contentTypeMismatch,redirected}):this.recordResponse({statusCode,responseHTML,redirected})}requestErrored(_request,_error){this.recordResponse({statusCode:SystemStatusCode_networkFailure,redirected:!1})}requestFinished(){this.finishRequest()}performScroll(){this.scrolled||this.view.forceReloaded||this.view.shouldPreserveScrollPosition(this)||("restore"==this.action?this.scrollToRestoredPosition()||this.scrollToAnchor()||this.view.scrollToTop():this.scrollToAnchor()||this.view.scrollToTop(),this.scrolled=!0)}scrollToRestoredPosition(){const{scrollPosition}=this.restorationData;if(scrollPosition)return this.view.scrollToPosition(scrollPosition),!0}scrollToAnchor(){const anchor=getAnchor(this.location);
15if(null!=anchor)return this.view.scrollToAnchor(anchor),!0}recordTimingMetric(metric){this.timingMetrics[metric]=(new Date).getTime()}getTimingMetrics(){return{...this.timingMetrics}}hasPreloadedResponse(){return"object"==typeof this.response}shouldIssueRequest(){return"restore"==this.action?!this.hasCachedSnapshot():this.willRender}cacheSnapshot(){this.snapshotCached||(this.view.cacheSnapshot(this.snapshot).then(snapshot=>snapshot&&this.visitCachedSnapshot(snapshot)),this.snapshotCached=!0)}async render(callback){this.cancelRender(),await new Promise(resolve=>{this.frame="hidden"===document.visibilityState?setTimeout(()=>resolve(),0):requestAnimationFrame(()=>resolve())}),await callback(),delete this.frame}async renderPageSnapshot(snapshot,isPreview){await this.viewTransitioner.renderChange(this.view.shouldTransitionTo(snapshot),async()=>{await this.view.renderPage(snapshot,isPreview,this.willRender,this),this.performScroll()})}cancelRender(){this.frame&&(cancelAnimationFrame(this.frame),delete this.frame)}}function isSuccessful(statusCode){return statusCode>=200&&statusCode<300}class BrowserAdapter{progressBar=new ProgressBar;constructor(session){this.session=session}visitProposedToLocation(location,options){locationIsVisitable(location,this.navigator.rootLocation)?this.navigator.startVisit(location,options?.restorationIdentifier||uuid(),options):window.location.href=location.toString()}visitStarted(visit){this.location=visit.location,this.redirectedToLocation=null,visit.loadCachedSnapshot(),visit.issueRequest()}visitRequestStarted(visit){this.progressBar.setValue(0),visit.hasCachedSnapshot()||"restore"!=visit.action?this.showVisitProgressBarAfterDelay():this.showProgressBar()}visitRequestCompleted(visit){visit.loadResponse(),visit.response.redirected&&(this.redirectedToLocation=visit.redirectedToLocation)}visitRequestFailedWithStatusCode(visit,statusCode){switch(statusCode){case SystemStatusCode_networkFailure:case SystemStatusCode_timeoutFailure:case SystemStatusCode_contentTypeMismatch:return this.reload({reason:"request_failed",context:{statusCode}});default:return visit.loadResponse()}}visitRequestFinished(_visit){}visitCompleted(_visit){this.progressBar.setValue(1),this.hideVisitProgressBar()}pageInvalidated(reason){this.reload(reason)}visitFailed(_visit){this.progressBar.setValue(1),this.hideVisitProgressBar()}visitRendered(_visit){}linkPrefetchingIsEnabledForLocation(location){return!0}formSubmissionStarted(_formSubmission){this.progressBar.setValue(0),this.showFormProgressBarAfterDelay()}formSubmissionFinished(_formSubmission){this.progressBar.setValue(1),this.hideFormProgressBar()}showVisitProgressBarAfterDelay(){this.visitProgressBarTimeout=window.setTimeout(this.showProgressBar,this.session.progressBarDelay)}hideVisitProgressBar(){this.progressBar.hide(),null!=this.visitProgressBarTimeout&&(window.clearTimeout(this.visitProgressBarTimeout),delete this.visitProgressBarTimeout)}showFormProgressBarAfterDelay(){null==this.formProgressBarTimeout&&(this.formProgressBarTimeout=window.setTimeout(this.showProgressBar,this.session.progressBarDelay))}hideFormProgressBar(){this.progressBar.hide(),null!=this.formProgressBarTimeout&&(window.clearTimeout(this.formProgressBarTimeout),delete this.formProgressBarTimeout)}showProgressBar=()=>{this.progressBar.show()};reload(reason){dispatch("turbo:reload",{detail:reason}),window.location.href=(this.redirectedToLocation||this.location)?.toString()||window.location.href}get navigator(){return this.session.navigator}}class CacheObserver{selector="[data-turbo-temporary]";started=!1;start(){this.started||(this.started=!0,addEventListener("turbo:before-cache",this.removeTemporaryElements,!1))}stop(){this.started&&(this.started=!1,removeEventListener("turbo:before-cache",this.removeTemporaryElements,!1))}removeTemporaryElements=_event=>{for(const element of this.temporaryElements)element.remove()};get temporaryElements(){return[...document.querySelectorAll(this.selector)]}}class FrameRedirector{constructor(session,element){this.session=session,this.element=element,this.linkInterceptor=new LinkInterceptor(this,element),this.formSubmitObserver=new FormSubmitObserver(this,element)}start(){this.linkInterceptor.start(),this.formSubmitObserver.start()}stop(){this.linkInterceptor.stop(),this.formSubmitObserver.stop()}shouldInterceptLinkClick(element,_location,_event){return this.#shouldRedirect(element)}linkClickIntercepted(element,url,event){const frame=this.#findFrameElement(element);frame&&frame.delegate.linkClickIntercepted(element,url,event)}willSubmitForm(element,submitter){return null==element.closest("turbo-frame")&&this.#shouldSubmit(element,submitter)&&this.#shouldRedirect(element,submitter)}formSubmitted(element,submitter){const frame=this.#findFrameElement(element,submitter);frame&&frame.delegate.formSubmitted(element,submitter)}#shouldSubmit(form,submitter){const action=getAction$1(form,submitter),meta=this.element.ownerDocument.querySelector('meta[name="turbo-root"]'),rootLocation=expandURL(meta?.content??"/");return this.#shouldRedirect(form,submitter)&&locationIsVisitable(action,rootLocation)}#shouldRedirect(element,submitter){if(element instanceof HTMLFormElement?this.session.submissionIsNavigatable(element,submitter):this.session.elementIsNavigatable(element)){const frame=this.#findFrameElement(element,submitter);
15return!!frame&&frame!=element.closest("turbo-frame")}return!1}#findFrameElement(element,submitter){const id=submitter?.getAttribute("data-turbo-frame")||element.getAttribute("data-turbo-frame");if(id&&"_top"!=id){const frame=this.element.querySelector(`#${id}:not([disabled])`);if(frame instanceof FrameElement)return frame}}}class History{location;restorationIdentifier=uuid();restorationData={};started=!1;currentIndex=0;constructor(delegate){this.delegate=delegate}start(){this.started||(addEventListener("popstate",this.onPopState,!1),this.currentIndex=history.state?.turbo?.restorationIndex||0,this.started=!0,this.replace(new URL(window.location.href)))}stop(){this.started&&(removeEventListener("popstate",this.onPopState,!1),this.started=!1)}push(location,restorationIdentifier){this.update(history.pushState,location,restorationIdentifier)}replace(location,restorationIdentifier){this.update(history.replaceState,location,restorationIdentifier)}update(method,location,restorationIdentifier=uuid()){method===history.pushState&&++this.currentIndex;const state={turbo:{restorationIdentifier,restorationIndex:this.currentIndex}};method.call(history,state,"",location.href),this.location=location,this.restorationIdentifier=restorationIdentifier}getRestorationDataForIdentifier(restorationIdentifier){return this.restorationData[restorationIdentifier]||{}}updateRestorationData(additionalData){const{restorationIdentifier}=this,restorationData=this.restorationData[restorationIdentifier];this.restorationData[restorationIdentifier]={...restorationData,...additionalData}}assumeControlOfScrollRestoration(){this.previousScrollRestoration||(this.previousScrollRestoration=history.scrollRestoration??"auto",history.scrollRestoration="manual")}relinquishControlOfScrollRestoration(){this.previousScrollRestoration&&(history.scrollRestoration=this.previousScrollRestoration,delete this.previousScrollRestoration)}onPopState=event=>{const{turbo}=event.state||{};if(this.location=new URL(window.location.href),turbo){const{restorationIdentifier,restorationIndex}=turbo;this.restorationIdentifier=restorationIdentifier;const direction=restorationIndex>this.currentIndex?"forward":"back";this.delegate.historyPoppedToLocationWithRestorationIdentifierAndDirection(this.location,restorationIdentifier,direction),this.currentIndex=restorationIndex}else this.currentIndex++,this.delegate.historyPoppedWithEmptyState(this.location)}}class LinkPrefetchObserver{started=!1;#prefetchedLink=null;constructor(delegate,eventTarget){this.delegate=delegate,this.eventTarget=eventTarget}start(){this.started||("loading"===this.eventTarget.readyState?this.eventTarget.addEventListener("DOMContentLoaded",this.#enable,{once:!0}):this.#enable())}stop(){this.started&&(this.eventTarget.removeEventListener("mouseenter",this.#tryToPrefetchRequest,{capture:!0,passive:!0}),this.eventTarget.removeEventListener("mouseleave",this.#cancelRequestIfObsolete,{capture:!0,passive:!0}),this.eventTarget.removeEventListener("turbo:before-fetch-request",this.#tryToUsePrefetchedRequest,!0),this.started=!1)}#enable=()=>{this.eventTarget.addEventListener("mouseenter",this.#tryToPrefetchRequest,{capture:!0,passive:!0}),this.eventTarget.addEventListener("mouseleave",this.#cancelRequestIfObsolete,{capture:!0,passive:!0}),this.eventTarget.addEventListener("turbo:before-fetch-request",this.#tryToUsePrefetchedRequest,!0),this.started=!0};#tryToPrefetchRequest=event=>{if("false"===getMetaContent("turbo-prefetch"))return;const target=event.target;if(target.matches&&target.matches("a[href]:not([target^=_]):not([download])")&&this.#isPrefetchable(target)){const link=target,location=getLocationForLink(link);if(this.delegate.canPrefetchRequestToLocation(link,location)){this.#prefetchedLink=link;const fetchRequest=new FetchRequest(this,FetchMethod.get,location,new URLSearchParams,target);fetchRequest.fetchOptions.priority="low",prefetchCache.putLater(location,fetchRequest,this.#cacheTtl)}}};#cancelRequestIfObsolete=event=>{event.target===this.#prefetchedLink&&this.#cancelPrefetchRequest()};#cancelPrefetchRequest=()=>{prefetchCache.clear(),this.#prefetchedLink=null};#tryToUsePrefetchedRequest=event=>{if("FORM"!==event.target.tagName&&"GET"===event.detail.fetchOptions.method){const cached=prefetchCache.get(event.detail.url);cached&&(event.detail.fetchRequest=cached),prefetchCache.clear()}};prepareRequest(request){const link=request.target;request.headers["X-Sec-Purpose"]="prefetch";const turboFrame=link.closest("turbo-frame"),turboFrameTarget=link.getAttribute("data-turbo-frame")||turboFrame?.getAttribute("target")||turboFrame?.id;turboFrameTarget&&"_top"!==turboFrameTarget&&(request.headers["Turbo-Frame"]=turboFrameTarget)}requestSucceededWithResponse(){}requestStarted(fetchRequest){}requestErrored(fetchRequest){}requestFinished(fetchRequest){}requestPreventedHandlingResponse(fetchRequest,fetchResponse){}requestFailedWithResponse(fetchRequest,fetchResponse){}get#cacheTtl(){return Number(getMetaContent("turbo-prefetch-cache-time"))||cacheTtl}#isPrefetchable(link){return!!link.getAttribute("href")&&(!unfetchableLink(link)&&(!linkToTheSamePage(link)&&(!linkOptsOut(link)&&(!nonSafeLink(link)&&!eventPrevented(link)))))}}const unfetchableLink=link=>link.origin!==document.location.origin||!["http:","https:"].includes(link.protocol)||link.hasAttribute("target"),linkToTheSamePage=link=>link.pathname+link.search===document.location.pathname+document.location.search||link.href.startsWith("#"),linkOptsOut=link=>{if("false"===link.getAttribute("data-turbo-prefetch"))return!0;
15if("false"===link.getAttribute("data-turbo"))return!0;const turboPrefetchParent=findClosestRecursively(link,"[data-turbo-prefetch]");return!(!turboPrefetchParent||"false"!==turboPrefetchParent.getAttribute("data-turbo-prefetch"))},nonSafeLink=link=>{const turboMethod=link.getAttribute("data-turbo-method");return!(!turboMethod||"get"===turboMethod.toLowerCase())||(!!isUJS(link)||(!!link.hasAttribute("data-turbo-confirm")||!!link.hasAttribute("data-turbo-stream")))},isUJS=link=>link.hasAttribute("data-remote")||link.hasAttribute("data-behavior")||link.hasAttribute("data-confirm")||link.hasAttribute("data-method"),eventPrevented=link=>dispatch("turbo:before-prefetch",{target:link,cancelable:!0}).defaultPrevented;class Navigator{constructor(delegate){this.delegate=delegate}proposeVisit(location,options={}){this.delegate.allowsVisitingLocationWithAction(location,options.action)&&this.delegate.visitProposedToLocation(location,options)}startVisit(locatable,restorationIdentifier,options={}){this.stop(),this.currentVisit=new Visit(this,expandURL(locatable),restorationIdentifier,{referrer:this.location,...options}),this.currentVisit.start()}submitForm(form,submitter){this.stop(),this.formSubmission=new FormSubmission(this,form,submitter,!0),this.formSubmission.start()}stop(){this.formSubmission&&(this.formSubmission.stop(),delete this.formSubmission),this.currentVisit&&(this.currentVisit.cancel(),delete this.currentVisit)}get adapter(){return this.delegate.adapter}get view(){return this.delegate.view}get rootLocation(){return this.view.snapshot.rootLocation}get history(){return this.delegate.history}formSubmissionStarted(formSubmission){"function"==typeof this.adapter.formSubmissionStarted&&this.adapter.formSubmissionStarted(formSubmission)}async formSubmissionSucceededWithResponse(formSubmission,fetchResponse){if(formSubmission==this.formSubmission){const responseHTML=await fetchResponse.responseHTML;if(responseHTML){const shouldCacheSnapshot=formSubmission.isSafe;shouldCacheSnapshot||this.view.clearSnapshotCache();const{statusCode,redirected}=fetchResponse,visitOptions={action:this.#getActionForFormSubmission(formSubmission,fetchResponse),shouldCacheSnapshot,response:{statusCode,responseHTML,redirected}};this.proposeVisit(fetchResponse.location,visitOptions)}}}async formSubmissionFailedWithResponse(formSubmission,fetchResponse){const responseHTML=await fetchResponse.responseHTML;if(responseHTML){const snapshot=PageSnapshot.fromHTMLString(responseHTML);fetchResponse.serverError?await this.view.renderError(snapshot,this.currentVisit):await this.view.renderPage(snapshot,!1,!0,this.currentVisit),"preserve"!==snapshot.refreshScroll&&this.view.scrollToTop(),this.view.clearSnapshotCache()}}formSubmissionErrored(formSubmission,error){console.error(error)}formSubmissionFinished(formSubmission){"function"==typeof this.adapter.formSubmissionFinished&&this.adapter.formSubmissionFinished(formSubmission)}linkPrefetchingIsEnabledForLocation(location){return"function"!=typeof this.adapter.linkPrefetchingIsEnabledForLocation||this.adapter.linkPrefetchingIsEnabledForLocation(location)}visitStarted(visit){this.delegate.visitStarted(visit)}visitCompleted(visit){this.delegate.visitCompleted(visit),delete this.currentVisit}locationWithActionIsSamePage(location,action){return!1}get location(){return this.history.location}get restorationIdentifier(){return this.history.restorationIdentifier}#getActionForFormSubmission(formSubmission,fetchResponse){const{submitter,formElement}=formSubmission;return getVisitAction(submitter,formElement)||this.#getDefaultAction(fetchResponse)}#getDefaultAction(fetchResponse){return fetchResponse.redirected&&fetchResponse.location.href===this.location?.href?"replace":"advance"}}const PageStage_initial=0,PageStage_loading=1,PageStage_interactive=2,PageStage_complete=3;class PageObserver{stage=PageStage_initial;started=!1;constructor(delegate){this.delegate=delegate}start(){this.started||(this.stage==PageStage_initial&&(this.stage=PageStage_loading),document.addEventListener("readystatechange",this.interpretReadyState,!1),addEventListener("pagehide",this.pageWillUnload,!1),this.started=!0)}stop(){this.started&&(document.removeEventListener("readystatechange",this.interpretReadyState,!1),removeEventListener("pagehide",this.pageWillUnload,!1),this.started=!1)}interpretReadyState=()=>{const{readyState}=this;
15"interactive"==readyState?this.pageIsInteractive():"complete"==readyState&&this.pageIsComplete()};pageIsInteractive(){this.stage==PageStage_loading&&(this.stage=PageStage_interactive,this.delegate.pageBecameInteractive())}pageIsComplete(){this.pageIsInteractive(),this.stage==PageStage_interactive&&(this.stage=PageStage_complete,this.delegate.pageLoaded())}pageWillUnload=()=>{this.delegate.pageWillUnload()};get readyState(){return document.readyState}}class ScrollObserver{started=!1;constructor(delegate){this.delegate=delegate}start(){this.started||(addEventListener("scroll",this.onScroll,!1),this.onScroll(),this.started=!0)}stop(){this.started&&(removeEventListener("scroll",this.onScroll,!1),this.started=!1)}onScroll=()=>{this.updatePosition({x:window.pageXOffset,y:window.pageYOffset})};updatePosition(position){this.delegate.scrollPositionChanged(position)}}class StreamMessageRenderer{render({fragment}){Bardo.preservingPermanentElements(this,function getPermanentElementMapForFragment(fragment){const permanentElementsInDocument=queryPermanentElementsAll(document.documentElement),permanentElementMap={};for(const permanentElementInDocument of permanentElementsInDocument){const{id}=permanentElementInDocument;for(const streamElement of fragment.querySelectorAll("turbo-stream")){const elementInStream=getPermanentElementById(streamElement.templateElement.content,id);elementInStream&&(permanentElementMap[id]=[permanentElementInDocument,elementInStream])}}return permanentElementMap}(fragment),()=>{!async function withAutofocusFromFragment(fragment,callback){const generatedID=`turbo-stream-autofocus-${uuid()}`,turboStreams=fragment.querySelectorAll("turbo-stream"),elementWithAutofocus=function firstAutofocusableElementInStreams(nodeListOfStreamElements){for(const streamElement of nodeListOfStreamElements){const elementWithAutofocus=queryAutofocusableElement(streamElement.templateElement.content);if(elementWithAutofocus)return elementWithAutofocus}return null}(turboStreams);let willAutofocusId=null;elementWithAutofocus&&(willAutofocusId=elementWithAutofocus.id?elementWithAutofocus.id:generatedID,elementWithAutofocus.id=willAutofocusId);callback(),await nextRepaint();if((null==document.activeElement||document.activeElement==document.body)&&willAutofocusId){const elementToAutofocus=document.getElementById(willAutofocusId);elementIsFocusable(elementToAutofocus)&&elementToAutofocus.focus(),elementToAutofocus&&elementToAutofocus.id==generatedID&&elementToAutofocus.removeAttribute("id")}}(fragment,()=>{!async function withPreservedFocus(callback){const[activeElementBeforeRender,activeElementAfterRender]=await async function around(callback,reader){const before=reader();return callback(),await nextAnimationFrame(),[before,reader()]}(callback,()=>document.activeElement),restoreFocusTo=activeElementBeforeRender&&activeElementBeforeRender.id;if(restoreFocusTo){const elementToFocus=document.getElementById(restoreFocusTo);elementIsFocusable(elementToFocus)&&elementToFocus!=activeElementAfterRender&&elementToFocus.focus()}}(()=>{document.documentElement.appendChild(fragment)})})})}enteringBardo(currentPermanentElement,newPermanentElement){newPermanentElement.replaceWith(currentPermanentElement.cloneNode(!0))}leavingBardo(){}}class StreamObserver{sources=new Set;#started=!1;constructor(delegate){this.delegate=delegate}start(){this.#started||(this.#started=!0,addEventListener("turbo:before-fetch-response",this.inspectFetchResponse,!1))}stop(){this.#started&&(this.#started=!1,removeEventListener("turbo:before-fetch-response",this.inspectFetchResponse,!1))}connectStreamSource(source){this.streamSourceIsConnected(source)||(this.sources.add(source),source.addEventListener("message",this.receiveMessageEvent,!1))}disconnectStreamSource(source){this.streamSourceIsConnected(source)&&(this.sources.delete(source),source.removeEventListener("message",this.receiveMessageEvent,!1))}streamSourceIsConnected(source){return this.sources.has(source)}inspectFetchResponse=event=>{const response=function fetchResponseFromEvent(event){const fetchResponse=event.detail?.fetchResponse;if(fetchResponse instanceof FetchResponse)return fetchResponse}(event);response&&function fetchResponseIsStream(response){const contentType=response.contentType??"";return contentType.startsWith(StreamMessage.contentType)}(response)&&(event.preventDefault(),this.receiveMessageResponse(response))};receiveMessageEvent=event=>{this.#started&&"string"==typeof event.data&&this.receiveMessageHTML(event.data)};async receiveMessageResponse(response){const html=await response.responseHTML;html&&this.receiveMessageHTML(html)}receiveMessageHTML(html){this.delegate.receivedMessageFromStream(StreamMessage.wrap(html))}}class ErrorRenderer extends Renderer{static renderElement(currentElement,newElement){const{documentElement,body}=document;documentElement.replaceChild(newElement,body)}async render(){this.replaceHeadAndBody(),this.activateScriptElements()}replaceHeadAndBody(){const{documentElement,head}=document;documentElement.replaceChild(this.newHead,head),this.renderElement(this.currentElement,this.newElement)}activateScriptElements(){for(const replaceableElement of this.scriptElements){const parentNode=replaceableElement.parentNode;if(parentNode){const element=activateScriptElement(replaceableElement);parentNode.replaceChild(element,replaceableElement)}}}
15get newHead(){return this.newSnapshot.headSnapshot.element}get scriptElements(){return document.documentElement.querySelectorAll("script")}}class PageRenderer extends Renderer{static renderElement(currentElement,newElement){document.body&&newElement instanceof HTMLBodyElement?document.body.replaceWith(newElement):document.documentElement.appendChild(newElement)}get shouldRender(){return this.newSnapshot.isVisitable&&this.trackedElementsAreIdentical}get reloadReason(){return this.newSnapshot.isVisitable?this.trackedElementsAreIdentical?void 0:{reason:"tracked_element_mismatch"}:{reason:"turbo_visit_control_is_reload"}}async prepareToRender(){this.#setLanguage(),await this.mergeHead()}async render(){this.willRender&&await this.replaceBody()}finishRendering(){super.finishRendering(),this.isPreview||this.focusFirstAutofocusableElement()}get currentHeadSnapshot(){return this.currentSnapshot.headSnapshot}get newHeadSnapshot(){return this.newSnapshot.headSnapshot}get newElement(){return this.newSnapshot.element}#setLanguage(){const{documentElement}=this.currentSnapshot,{dir,lang}=this.newSnapshot;lang?documentElement.setAttribute("lang",lang):documentElement.removeAttribute("lang"),dir?documentElement.setAttribute("dir",dir):documentElement.removeAttribute("dir")}async mergeHead(){const mergedHeadElements=this.mergeProvisionalElements(),newStylesheetElements=this.copyNewHeadStylesheetElements();this.copyNewHeadScriptElements(),await mergedHeadElements,await newStylesheetElements,this.willRender&&this.removeUnusedDynamicStylesheetElements()}async replaceBody(){await this.preservingPermanentElements(async()=>{this.activateNewBody(),await this.assignNewBody()})}get trackedElementsAreIdentical(){return this.currentHeadSnapshot.trackedElementSignature==this.newHeadSnapshot.trackedElementSignature}async copyNewHeadStylesheetElements(){const loadingElements=[];for(const element of this.newHeadStylesheetElements)loadingElements.push(waitForLoad(element)),document.head.appendChild(element);await Promise.all(loadingElements)}copyNewHeadScriptElements(){for(const element of this.newHeadScriptElements)document.head.appendChild(activateScriptElement(element))}removeUnusedDynamicStylesheetElements(){for(const element of this.unusedDynamicStylesheetElements)document.head.removeChild(element)}async mergeProvisionalElements(){const newHeadElements=[...this.newHeadProvisionalElements];for(const element of this.currentHeadProvisionalElements)this.isCurrentElementInElementList(element,newHeadElements)||document.head.removeChild(element);for(const element of newHeadElements)document.head.appendChild(element)}isCurrentElementInElementList(element,elementList){for(const[index,newElement]of elementList.entries()){if("TITLE"==element.tagName){if("TITLE"!=newElement.tagName)continue;if(element.innerHTML==newElement.innerHTML)return elementList.splice(index,1),!0}if(newElement.isEqualNode(element))return elementList.splice(index,1),!0}return!1}removeCurrentHeadProvisionalElements(){for(const element of this.currentHeadProvisionalElements)document.head.removeChild(element)}copyNewHeadProvisionalElements(){for(const element of this.newHeadProvisionalElements)document.head.appendChild(element)}activateNewBody(){document.adoptNode(this.newElement),this.removeNoscriptElements(),this.activateNewBodyScriptElements()}removeNoscriptElements(){for(const noscriptElement of this.newElement.querySelectorAll("noscript"))noscriptElement.remove()}activateNewBodyScriptElements(){for(const inertScriptElement of this.newBodyScriptElements){const activatedScriptElement=activateScriptElement(inertScriptElement);inertScriptElement.replaceWith(activatedScriptElement)}}async assignNewBody(){await this.renderElement(this.currentElement,this.newElement)}get unusedDynamicStylesheetElements(){return this.oldHeadStylesheetElements.filter(element=>"dynamic"===element.getAttribute("data-turbo-track"))}get oldHeadStylesheetElements(){return this.currentHeadSnapshot.getStylesheetElementsNotInSnapshot(this.newHeadSnapshot)}get newHeadStylesheetElements(){return this.newHeadSnapshot.getStylesheetElementsNotInSnapshot(this.currentHeadSnapshot)}get newHeadScriptElements(){return this.newHeadSnapshot.getScriptElementsNotInSnapshot(this.currentHeadSnapshot)}get currentHeadProvisionalElements(){return this.currentHeadSnapshot.provisionalElements}get newHeadProvisionalElements(){return this.newHeadSnapshot.provisionalElements}get newBodyScriptElements(){return this.newElement.querySelectorAll("script")}}class MorphingPageRenderer extends PageRenderer{static renderElement(currentElement,newElement){morphElements(currentElement,newElement,{callbacks:{beforeNodeMorphed:(node,newNode)=>!(shouldRefreshFrameWithMorphing(node,newNode)&&!closestFrameReloadableWithMorphing(node))||(node.reload(),!1)}}),dispatch("turbo:morph",{detail:{currentElement,newElement}})}async preservingPermanentElements(callback){return await callback()}get renderMethod(){return"morph"}get shouldAutofocus(){return!1}}
15class SnapshotCache extends LRUCache{constructor(size){super(size,toCacheKey)}get snapshots(){return this.entries}}class PageView extends View{snapshotCache=new SnapshotCache(10);lastRenderedLocation=new URL(location.href);forceReloaded=!1;shouldTransitionTo(newSnapshot){return this.snapshot.prefersViewTransitions&&newSnapshot.prefersViewTransitions}renderPage(snapshot,isPreview=!1,willRender=!0,visit){const renderer=new(this.isPageRefresh(visit)&&"morph"===(visit?.refresh?.method||this.snapshot.refreshMethod)?MorphingPageRenderer:PageRenderer)(this.snapshot,snapshot,isPreview,willRender);return renderer.shouldRender?visit?.changeHistory():this.forceReloaded=!0,this.render(renderer)}renderError(snapshot,visit){visit?.changeHistory();const renderer=new ErrorRenderer(this.snapshot,snapshot,!1);return this.render(renderer)}clearSnapshotCache(){this.snapshotCache.clear()}async cacheSnapshot(snapshot=this.snapshot){if(snapshot.isCacheable){this.delegate.viewWillCacheSnapshot();const{lastRenderedLocation:location}=this;await nextEventLoopTick();const cachedSnapshot=snapshot.clone();return this.snapshotCache.put(location,cachedSnapshot),cachedSnapshot}}getCachedSnapshotForLocation(location){return this.snapshotCache.get(location)}isPageRefresh(visit){return!visit||this.lastRenderedLocation.pathname===visit.location.pathname&&"replace"===visit.action}shouldPreserveScrollPosition(visit){return this.isPageRefresh(visit)&&"preserve"===(visit?.refresh?.scroll||this.snapshot.refreshScroll)}get snapshot(){return PageSnapshot.fromElement(this.element)}}class Preloader{selector="a[data-turbo-preload]";constructor(delegate,snapshotCache){this.delegate=delegate,this.snapshotCache=snapshotCache}start(){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",this.#preloadAll):this.preloadOnLoadLinksForView(document.body)}stop(){document.removeEventListener("DOMContentLoaded",this.#preloadAll)}preloadOnLoadLinksForView(element){for(const link of element.querySelectorAll(this.selector))this.delegate.shouldPreloadLink(link)&&this.preloadURL(link)}async preloadURL(link){const location=new URL(link.href);if(this.snapshotCache.has(location))return;const fetchRequest=new FetchRequest(this,FetchMethod.get,location,new URLSearchParams,link);await fetchRequest.perform()}prepareRequest(fetchRequest){fetchRequest.headers["X-Sec-Purpose"]="prefetch"}async requestSucceededWithResponse(fetchRequest,fetchResponse){try{const responseHTML=await fetchResponse.responseHTML,snapshot=PageSnapshot.fromHTMLString(responseHTML);this.snapshotCache.put(fetchRequest.url,snapshot)}catch(_){}}requestStarted(fetchRequest){}requestErrored(fetchRequest){}requestFinished(fetchRequest){}requestPreventedHandlingResponse(fetchRequest,fetchResponse){}requestFailedWithResponse(fetchRequest,fetchResponse){}#preloadAll=()=>{this.preloadOnLoadLinksForView(document.body)}}class Cache{constructor(session){this.session=session}clear(){this.session.clearCache()}resetCacheControl(){this.#setCacheControl("")}exemptPageFromCache(){this.#setCacheControl("no-cache")}exemptPageFromPreview(){this.#setCacheControl("no-preview")}#setCacheControl(value){!function setMetaContent(name,content){let element=getMetaElement(name);return element||(element=document.createElement("meta"),element.setAttribute("name",name),document.head.appendChild(element)),element.setAttribute("content",content),element}("turbo-cache-control",value)}}function extendURLWithDeprecatedProperties(url){Object.defineProperties(url,deprecatedLocationPropertyDescriptors)}const deprecatedLocationPropertyDescriptors={absoluteURL:{get(){return this.toString()}}},session=new class Session{navigator=new Navigator(this);history=new History(this);view=new PageView(this,document.documentElement);adapter=new BrowserAdapter(this);pageObserver=new PageObserver(this);cacheObserver=new CacheObserver;linkPrefetchObserver=new LinkPrefetchObserver(this,document);linkClickObserver=new LinkClickObserver(this,window);formSubmitObserver=new FormSubmitObserver(this,document);scrollObserver=new ScrollObserver(this);streamObserver=new StreamObserver(this);formLinkClickObserver=new FormLinkClickObserver(this,document.documentElement);frameRedirector=new FrameRedirector(this,document.documentElement);streamMessageRenderer=new StreamMessageRenderer;cache=new Cache(this);enabled=!0;started=!1;#pageRefreshDebouncePeriod=150;constructor(recentRequests){this.recentRequests=recentRequests,this.preloader=new Preloader(this,this.view.snapshotCache),this.debouncedRefresh=this.refresh,this.pageRefreshDebouncePeriod=this.pageRefreshDebouncePeriod}start(){this.started||(this.pageObserver.start(),this.cacheObserver.start(),this.linkPrefetchObserver.start(),this.formLinkClickObserver.start(),this.linkClickObserver.start(),this.formSubmitObserver.start(),this.scrollObserver.start(),this.streamObserver.start(),this.frameRedirector.start(),this.history.start(),this.preloader.start(),this.started=!0,this.enabled=!0)}disable(){this.enabled=!1}stop(){this.started&&(this.pageObserver.stop(),this.cacheObserver.stop(),this.linkPrefetchObserver.stop(),this.formLinkClickObserver.stop(),this.linkClickObserver.stop(),this.formSubmitObserver.stop(),this.scrollObserver.stop(),this.streamObserver.stop(),this.frameRedirector.stop(),this.history.stop(),this.preloader.stop(),this.started=!1)}registerAdapter(adapter){this.adapter=adapter}visit(location,options={}){const frameElement=options.frame?document.getElementById(options.frame):null;if(frameElement instanceof FrameElement){const action=options.action||getVisitAction(frameElement);frameElement.delegate.proposeVisitIfNavigatedWithAction(frameElement,action),frameElement.src=location.toString()}else this.navigator.proposeVisit(expandURL(location),options)}refresh(url,options={}
15){options="string"==typeof options?{requestId:options}:options;const{method,requestId,scroll}=options,isRecentRequest=requestId&&this.recentRequests.has(requestId),isCurrentUrl=url===document.baseURI;isRecentRequest||this.navigator.currentVisit||!isCurrentUrl||this.visit(url,{action:"replace",shouldCacheSnapshot:!1,refresh:{method,scroll}})}connectStreamSource(source){this.streamObserver.connectStreamSource(source)}disconnectStreamSource(source){this.streamObserver.disconnectStreamSource(source)}renderStreamMessage(message){this.streamMessageRenderer.render(StreamMessage.wrap(message))}clearCache(){this.view.clearSnapshotCache()}setProgressBarDelay(delay){console.warn("Please replace `session.setProgressBarDelay(delay)` with `session.progressBarDelay = delay`. The function is deprecated and will be removed in a future version of Turbo.`"),this.progressBarDelay=delay}set progressBarDelay(delay){config.drive.progressBarDelay=delay}get progressBarDelay(){return config.drive.progressBarDelay}set drive(value){config.drive.enabled=value}get drive(){return config.drive.enabled}set formMode(value){config.forms.mode=value}get formMode(){return config.forms.mode}get location(){return this.history.location}get restorationIdentifier(){return this.history.restorationIdentifier}get pageRefreshDebouncePeriod(){return this.#pageRefreshDebouncePeriod}set pageRefreshDebouncePeriod(value){this.refresh=function debounce(fn,delay){let timeoutId=null;return(...args)=>{clearTimeout(timeoutId),timeoutId=setTimeout(()=>fn.apply(this,args),delay)}}(this.debouncedRefresh.bind(this),value),this.#pageRefreshDebouncePeriod=value}shouldPreloadLink(element){const isUnsafe=element.hasAttribute("data-turbo-method"),isStream=element.hasAttribute("data-turbo-stream"),frameTarget=element.getAttribute("data-turbo-frame"),frame="_top"==frameTarget?null:document.getElementById(frameTarget)||findClosestRecursively(element,"turbo-frame:not([disabled])");if(isUnsafe||isStream||frame instanceof FrameElement)return!1;{const location=new URL(element.href);return this.elementIsNavigatable(element)&&locationIsVisitable(location,this.snapshot.rootLocation)}}historyPoppedToLocationWithRestorationIdentifierAndDirection(location,restorationIdentifier,direction){this.enabled?this.navigator.startVisit(location,restorationIdentifier,{action:"restore",historyChanged:!0,direction}):this.adapter.pageInvalidated({reason:"turbo_disabled"})}historyPoppedWithEmptyState(location){this.history.replace(location),this.view.lastRenderedLocation=location,this.view.cacheSnapshot()}scrollPositionChanged(position){this.history.updateRestorationData({scrollPosition:position})}willSubmitFormLinkToLocation(link,location){return this.elementIsNavigatable(link)&&locationIsVisitable(location,this.snapshot.rootLocation)}submittedFormLinkToLocation(){}canPrefetchRequestToLocation(link,location){return this.elementIsNavigatable(link)&&locationIsVisitable(location,this.snapshot.rootLocation)&&this.navigator.linkPrefetchingIsEnabledForLocation(location)}willFollowLinkToLocation(link,location,event){return this.elementIsNavigatable(link)&&locationIsVisitable(location,this.snapshot.rootLocation)&&this.applicationAllowsFollowingLinkToLocation(link,location,event)}followedLinkToLocation(link,location){const action=this.getActionForLink(link),acceptsStreamResponse=link.hasAttribute("data-turbo-stream");this.visit(location.href,{action,acceptsStreamResponse})}allowsVisitingLocationWithAction(location,action){return this.applicationAllowsVisitingLocation(location)}visitProposedToLocation(location,options){extendURLWithDeprecatedProperties(location),this.adapter.visitProposedToLocation(location,options)}visitStarted(visit){visit.acceptsStreamResponse||(markAsBusy(document.documentElement),this.view.markVisitDirection(visit.direction)),extendURLWithDeprecatedProperties(visit.location),this.notifyApplicationAfterVisitingLocation(visit.location,visit.action)}visitCompleted(visit){this.view.unmarkVisitDirection(),clearBusyState(document.documentElement),this.notifyApplicationAfterPageLoad(visit.getTimingMetrics())}willSubmitForm(form,submitter){const action=getAction$1(form,submitter);return this.submissionIsNavigatable(form,submitter)&&locationIsVisitable(expandURL(action),this.snapshot.rootLocation)}formSubmitted(form,submitter){this.navigator.submitForm(form,submitter)}pageBecameInteractive(){this.view.lastRenderedLocation=this.location,this.notifyApplicationAfterPageLoad()}
15pageLoaded(){this.history.assumeControlOfScrollRestoration()}pageWillUnload(){this.history.relinquishControlOfScrollRestoration()}receivedMessageFromStream(message){this.renderStreamMessage(message)}viewWillCacheSnapshot(){this.notifyApplicationBeforeCachingSnapshot()}allowsImmediateRender({element},options){const event=this.notifyApplicationBeforeRender(element,options),{defaultPrevented,detail:{render}}=event;return this.view.renderer&&render&&(this.view.renderer.renderElement=render),!defaultPrevented}viewRenderedSnapshot(_snapshot,_isPreview,renderMethod){this.view.lastRenderedLocation=this.history.location,this.notifyApplicationAfterRender(renderMethod)}preloadOnLoadLinksForView(element){this.preloader.preloadOnLoadLinksForView(element)}viewInvalidated(reason){this.adapter.pageInvalidated(reason)}frameLoaded(frame){this.notifyApplicationAfterFrameLoad(frame)}frameRendered(fetchResponse,frame){this.notifyApplicationAfterFrameRender(fetchResponse,frame)}applicationAllowsFollowingLinkToLocation(link,location,ev){return!this.notifyApplicationAfterClickingLinkToLocation(link,location,ev).defaultPrevented}applicationAllowsVisitingLocation(location){return!this.notifyApplicationBeforeVisitingLocation(location).defaultPrevented}notifyApplicationAfterClickingLinkToLocation(link,location,event){return dispatch("turbo:click",{target:link,detail:{url:location.href,originalEvent:event},cancelable:!0})}notifyApplicationBeforeVisitingLocation(location){return dispatch("turbo:before-visit",{detail:{url:location.href},cancelable:!0})}notifyApplicationAfterVisitingLocation(location,action){return dispatch("turbo:visit",{detail:{url:location.href,action}})}notifyApplicationBeforeCachingSnapshot(){return dispatch("turbo:before-cache")}notifyApplicationBeforeRender(newBody,options){return dispatch("turbo:before-render",{detail:{newBody,...options},cancelable:!0})}notifyApplicationAfterRender(renderMethod){return dispatch("turbo:render",{detail:{renderMethod}})}notifyApplicationAfterPageLoad(timing={}){return dispatch("turbo:load",{detail:{url:this.location.href,timing}})}notifyApplicationAfterFrameLoad(frame){return dispatch("turbo:frame-load",{target:frame})}notifyApplicationAfterFrameRender(fetchResponse,frame){return dispatch("turbo:frame-render",{detail:{fetchResponse},target:frame,cancelable:!0})}submissionIsNavigatable(form,submitter){if("off"==config.forms.mode)return!1;{const submitterIsNavigatable=!submitter||this.elementIsNavigatable(submitter);return"optin"==config.forms.mode?submitterIsNavigatable&&null!=form.closest('[data-turbo="true"]'):submitterIsNavigatable&&this.elementIsNavigatable(form)}}elementIsNavigatable(element){const container=findClosestRecursively(element,"[data-turbo]"),withinFrame=findClosestRecursively(element,"turbo-frame");return config.drive.enabled||withinFrame?!container||"false"!=container.getAttribute("data-turbo"):!!container&&"true"==container.getAttribute("data-turbo")}getActionForLink(link){return getVisitAction(link)||"advance"}get snapshot(){return this.view.snapshot}}(recentRequests),{cache,navigator:sessionNavigator}=session;function start(){session.start()}function visit(location,options){session.visit(location,options)}function connectStreamSource(source){session.connectStreamSource(source)}function disconnectStreamSource(source){session.disconnectStreamSource(source)}
15function renderStreamMessage(message){session.renderStreamMessage(message)}var Turbo=Object.freeze({__proto__:null,PageRenderer,PageSnapshot,FrameRenderer,fetch:fetchWithTurboHeaders,config,session,cache,navigator:sessionNavigator,start,registerAdapter:function registerAdapter(adapter){session.registerAdapter(adapter)},visit,connectStreamSource,disconnectStreamSource,renderStreamMessage,setProgressBarDelay:function setProgressBarDelay(delay){console.warn("Please replace `Turbo.setProgressBarDelay(delay)` with `Turbo.config.drive.progressBarDelay = delay`. The top-level function is deprecated and will be removed in a future version of Turbo.`"),config.drive.progressBarDelay=delay},setConfirmMethod:function setConfirmMethod(confirmMethod){console.warn("Please replace `Turbo.setConfirmMethod(confirmMethod)` with `Turbo.config.forms.confirm = confirmMethod`. The top-level function is deprecated and will be removed in a future version of Turbo.`"),config.forms.confirm=confirmMethod},setFormMode:function setFormMode(mode){console.warn("Please replace `Turbo.setFormMode(mode)` with `Turbo.config.forms.mode = mode`. The top-level function is deprecated and will be removed in a future version of Turbo.`"),config.forms.mode=mode},morphBodyElements:function morphBodyElements(currentBody,newBody){MorphingPageRenderer.renderElement(currentBody,newBody)},morphTurboFrameElements:function morphTurboFrameElements(currentFrame,newFrame){MorphingFrameRenderer.renderElement(currentFrame,newFrame)},morphChildren,morphElements});class TurboFrameMissingError extends Error{}function activateElement(element,currentURL){if(element){const src=element.getAttribute("src");if(null!=src&&null!=currentURL&&urlsAreEqual(src,currentURL))throw new Error(`Matching <turbo-frame id="${element.id}"> element has a source URL which references itself`);if(element.ownerDocument!==document&&(element=document.importNode(element,!0)),element instanceof FrameElement)return element.connectedCallback(),element.disconnectedCallback(),element}}const StreamActions={after(){this.removeDuplicateTargetSiblings(),this.targetElements.forEach(e=>e.parentElement?.insertBefore(this.templateContent,e.nextSibling))},append(){this.removeDuplicateTargetChildren(),this.targetElements.forEach(e=>e.append(this.templateContent))},before(){this.removeDuplicateTargetSiblings(),this.targetElements.forEach(e=>e.parentElement?.insertBefore(this.templateContent,e))},prepend(){this.removeDuplicateTargetChildren(),this.targetElements.forEach(e=>e.prepend(this.templateContent))},remove(){this.targetElements.forEach(e=>e.remove())},replace(){const method=this.getAttribute("method");this.targetElements.forEach(targetElement=>{"morph"===method?morphElements(targetElement,this.templateContent):targetElement.replaceWith(this.templateContent)})},update(){const method=this.getAttribute("method");this.targetElements.forEach(targetElement=>{"morph"===method?morphChildren(targetElement,this.templateContent):(targetElement.innerHTML="",targetElement.append(this.templateContent))})},refresh(){const method=this.getAttribute("method"),requestId=this.requestId,scroll=this.getAttribute("scroll");session.refresh(this.baseURI,{method,requestId,scroll})}};class StreamElement extends HTMLElement{static async renderElement(newElement){await newElement.performAction()}async connectedCallback(){try{await this.render()}catch(error){console.error(error)}finally{this.disconnect()}}async render(){return this.renderPromise??=(async()=>{const event=this.beforeRenderEvent;this.dispatchEvent(event)&&(await nextRepaint(),await event.detail.render(this))})()}disconnect(){try{this.remove()}catch{}}removeDuplicateTargetChildren(){this.duplicateChildren.forEach(c=>c.remove())}get duplicateChildren(){const existingChildren=this.targetElements.flatMap(e=>[...e.children]).filter(c=>!!c.getAttribute("id")),newChildrenIds=[...this.templateContent?.children||[]].filter(c=>!!c.getAttribute("id")).map(c=>c.getAttribute("id"));return existingChildren.filter(c=>newChildrenIds.includes(c.getAttribute("id")))}
15removeDuplicateTargetSiblings(){this.duplicateSiblings.forEach(c=>c.remove())}get duplicateSiblings(){const existingChildren=this.targetElements.flatMap(e=>[...e.parentElement.children]).filter(c=>!!c.id),newChildrenIds=[...this.templateContent?.children||[]].filter(c=>!!c.id).map(c=>c.id);return existingChildren.filter(c=>newChildrenIds.includes(c.id))}get performAction(){if(this.action){const actionFunction=StreamActions[this.action];if(actionFunction)return actionFunction;this.#raise("unknown action")}this.#raise("action attribute is missing")}get targetElements(){return this.target?this.targetElementsById:this.targets?this.targetElementsByQuery:void this.#raise("target or targets attribute is missing")}get templateContent(){return this.templateElement.content.cloneNode(!0)}get templateElement(){if(null===this.firstElementChild){const template=this.ownerDocument.createElement("template");return this.appendChild(template),template}if(this.firstElementChild instanceof HTMLTemplateElement)return this.firstElementChild;this.#raise("first child element must be a <template> element")}get action(){return this.getAttribute("action")}get target(){return this.getAttribute("target")}get targets(){return this.getAttribute("targets")}get requestId(){return this.getAttribute("request-id")}#raise(message){throw new Error(`${this.description}: ${message}`)}get description(){return(this.outerHTML.match(/<[^>]+>/)??[])[0]??"<turbo-stream>"}get beforeRenderEvent(){return new CustomEvent("turbo:before-stream-render",{bubbles:!0,cancelable:!0,detail:{newStream:this,render:StreamElement.renderElement}})}get targetElementsById(){const element=this.ownerDocument?.getElementById(this.target);return null!==element?[element]:[]}get targetElementsByQuery(){const elements=this.ownerDocument?.querySelectorAll(this.targets);return 0!==elements.length?Array.prototype.slice.call(elements):[]}}class StreamSourceElement extends HTMLElement{streamSource=null;connectedCallback(){this.streamSource=this.src.match(/^ws{1,2}:/)?new WebSocket(this.src):new EventSource(this.src),connectStreamSource(this.streamSource)}disconnectedCallback(){this.streamSource&&(this.streamSource.close(),disconnectStreamSource(this.streamSource))}get src(){return this.getAttribute("src")||""}}FrameElement.delegateConstructor=class FrameController{fetchResponseLoaded=_fetchResponse=>Promise.resolve();#currentFetchRequest=null;#resolveVisitPromise=()=>{};#connected=!1;#hasBeenLoaded=!1;#ignoredAttributes=new Set;#shouldMorphFrame=!1;action=null;constructor(element){this.element=element,this.view=new FrameView(this,this.element),this.appearanceObserver=new AppearanceObserver(this,this.element),this.formLinkClickObserver=new FormLinkClickObserver(this,this.element),this.linkInterceptor=new LinkInterceptor(this,this.element),this.restorationIdentifier=uuid(),this.formSubmitObserver=new FormSubmitObserver(this,this.element)}connect(){this.#connected||(this.#connected=!0,this.loadingStyle==FrameLoadingStyle_lazy?this.appearanceObserver.start():this.#loadSourceURL(),this.formLinkClickObserver.start(),this.linkInterceptor.start(),this.formSubmitObserver.start())}disconnect(){this.#connected&&(this.#connected=!1,this.appearanceObserver.stop(),this.formLinkClickObserver.stop(),this.linkInterceptor.stop(),this.formSubmitObserver.stop(),this.element.hasAttribute("recurse")||this.#currentFetchRequest?.cancel())}disabledChanged(){this.disabled?this.#currentFetchRequest?.cancel():this.loadingStyle==FrameLoadingStyle_eager&&this.#loadSourceURL()}sourceURLChanged(){this.#isIgnoringChangesTo("src")||(this.sourceURL||this.#currentFetchRequest?.cancel(),this.element.isConnected&&(this.complete=!1),(this.loadingStyle==FrameLoadingStyle_eager||this.#hasBeenLoaded)&&this.#loadSourceURL())}sourceURLReloaded(){const{refresh,src}=this.element;return this.#shouldMorphFrame=src&&"morph"===refresh,this.element.removeAttribute("complete"),this.element.src=null,this.element.src=src,this.element.loaded}loadingStyleChanged(){this.loadingStyle==FrameLoadingStyle_lazy?this.appearanceObserver.start():(this.appearanceObserver.stop(),this.#loadSourceURL())}async#loadSourceURL(){this.enabled&&this.isActive&&!this.complete&&this.sourceURL&&(this.element.loaded=this.#visit(expandURL(this.sourceURL)),this.appearanceObserver.stop(),await this.element.loaded,this.#hasBeenLoaded=!0)}async loadResponse(fetchResponse){(fetchResponse.redirected||fetchResponse.succeeded&&fetchResponse.isHTML)&&(this.sourceURL=fetchResponse.response.url);try{const html=await fetchResponse.responseHTML;if(html){const document=parseHTMLDocument(html);PageSnapshot.fromDocument(document).isVisitable?await this.#loadFrameResponse(fetchResponse,document):await this.#handleUnvisitableFrameResponse(fetchResponse)}}finally{this.#shouldMorphFrame=!1,this.fetchResponseLoaded=()=>Promise.resolve()}}elementAppearedInViewport(element){this.proposeVisitIfNavigatedWithAction(element,getVisitAction(element)),this.#loadSourceURL()}willSubmitFormLinkToLocation(link){return this.#shouldInterceptNavigation(link)}submittedFormLinkToLocation(link,_location,form){const frame=this.#findFrameElement(link);frame&&form.setAttribute("data-turbo-frame",frame.id)}shouldInterceptLinkClick(element,_location,_event){return this.#shouldInterceptNavigation(element)}linkClickIntercepted(element,location){this.#navigateFrame(element,location)}willSubmitForm(element,submitter){return element.closest("turbo-frame")==this.element&&this.#shouldInterceptNavigation(element,submitter)}formSubmitted(element,submitter){this.formSubmission&&this.formSubmission.stop(),this.formSubmission=new FormSubmission(this,element,submitter);const{fetchRequest}=this.formSubmission,frame=this.#findFrameElement(element,submitter);this.prepareRequest(fetchRequest,frame),this.formSubmission.start()}prepareRequest(request,frame=this){request.headers["Turbo-Frame"]=frame.id,this.currentNavigationElement?.hasAttribute("data-turbo-stream")&&request.acceptResponseType(StreamMessage.contentType)}requestStarted(_request){markAsBusy(this.element)}requestPreventedHandlingResponse(_request,_response){this.#resolveVisitPromise()}async requestSucceededWithResponse(request,response){await this.loadResponse(response),this.#resolveVisitPromise()}async requestFailedWithResponse(request,response){await this.loadResponse(response),this.#resolveVisitPromise()}requestErrored(request,error){console.error(error),this.#resolveVisitPromise()}requestFinished(_request){clearBusyState(this.element)}formSubmissionStarted({formElement}){markAsBusy(formElement,this.#findFrameElement(formElement))}formSubmissionSucceededWithResponse(formSubmission,response){const frame=this.#findFrameElement(formSubmission.formElement,formSubmission.submitter);frame.delegate.proposeVisitIfNavigatedWithAction(frame,getVisitAction(formSubmission.submitter,formSubmission.formElement,frame)),frame.delegate.loadResponse(response),formSubmission.isSafe||session.clearCache()}formSubmissionFailedWithResponse(formSubmission,fetchResponse){this.element.delegate.loadResponse(fetchResponse),session.clearCache()}formSubmissionErrored(formSubmission,error){console.error(error)}formSubmissionFinished({formElement}){clearBusyState(formElement,this.#findFrameElement(formElement))}allowsImmediateRender({element:newFrame},options){const event=dispatch("turbo:before-frame-render",{target:this.element,detail
15:{newFrame,...options},cancelable:!0}),{defaultPrevented,detail:{render}}=event;return this.view.renderer&&render&&(this.view.renderer.renderElement=render),!defaultPrevented}viewRenderedSnapshot(_snapshot,_isPreview,_renderMethod){}preloadOnLoadLinksForView(element){session.preloadOnLoadLinksForView(element)}viewInvalidated(){}willRenderFrame(currentElement,_newElement){this.previousFrameElement=currentElement.cloneNode(!0)}visitCachedSnapshot=({element})=>{const frame=element.querySelector("#"+this.element.id);frame&&this.previousFrameElement&&frame.replaceChildren(...this.previousFrameElement.children),delete this.previousFrameElement};async#loadFrameResponse(fetchResponse,document){const newFrameElement=await this.extractForeignFrameElement(document.body),rendererClass=this.#shouldMorphFrame?MorphingFrameRenderer:FrameRenderer;if(newFrameElement){const snapshot=new Snapshot(newFrameElement),renderer=new rendererClass(this,this.view.snapshot,snapshot,!1,!1);this.view.renderPromise&&await this.view.renderPromise,this.changeHistory(),await this.view.render(renderer),this.complete=!0,session.frameRendered(fetchResponse,this.element),session.frameLoaded(this.element),await this.fetchResponseLoaded(fetchResponse)}else this.#willHandleFrameMissingFromResponse(fetchResponse)&&this.#handleFrameMissingFromResponse(fetchResponse)}async#visit(url){const request=new FetchRequest(this,FetchMethod.get,url,new URLSearchParams,this.element);return this.#currentFetchRequest?.cancel(),this.#currentFetchRequest=request,new Promise(resolve=>{this.#resolveVisitPromise=()=>{this.#resolveVisitPromise=()=>{},this.#currentFetchRequest=null,resolve()},request.perform()})}#navigateFrame(element,url,submitter){const frame=this.#findFrameElement(element,submitter);frame.delegate.proposeVisitIfNavigatedWithAction(frame,getVisitAction(submitter,element,frame)),this.#withCurrentNavigationElement(element,()=>{frame.src=url})}proposeVisitIfNavigatedWithAction(frame,action=null){if(this.action=action,this.action){const pageSnapshot=PageSnapshot.fromElement(frame).clone(),{visitCachedSnapshot}=frame.delegate;frame.delegate.fetchResponseLoaded=async fetchResponse=>{if(frame.src){const{statusCode,redirected}=fetchResponse,options={response:{statusCode,redirected,responseHTML:await fetchResponse.responseHTML},visitCachedSnapshot,willRender:!1,updateHistory:!1,restorationIdentifier:this.restorationIdentifier,snapshot:pageSnapshot};this.action&&(options.action=this.action),session.visit(frame.src,options)}}}}changeHistory(){if(this.action){const method=getHistoryMethodForAction(this.action);session.history.update(method,expandURL(this.element.src||""),this.restorationIdentifier)}}async#handleUnvisitableFrameResponse(fetchResponse){console.warn(`The response (${fetchResponse.statusCode}) from <turbo-frame id="${this.element.id}"> is performing a full page visit due to turbo-visit-control.`),await this.#visitResponse(fetchResponse.response)}#willHandleFrameMissingFromResponse(fetchResponse){this.element.setAttribute("complete","");const response=fetchResponse.response;return!dispatch("turbo:frame-missing",{target:this.element,detail:{response,visit:async(url,options)=>{url instanceof Response?this.#visitResponse(url):session.visit(url,options)}},cancelable:!0}).defaultPrevented}#handleFrameMissingFromResponse(fetchResponse){this.view.missing(),this.#throwFrameMissingError(fetchResponse)}#throwFrameMissingError(fetchResponse){const message=`The response (${fetchResponse.statusCode}) did not contain the expected <turbo-frame id="${this.element.id}"> and will be ignored. To perform a full page visit instead, set turbo-visit-control to reload.`;throw new TurboFrameMissingError(message)}async#visitResponse(response){const wrapped=new FetchResponse(response),responseHTML=await wrapped.responseHTML,{location,redirected,statusCode}=wrapped;return session.visit(location,{response:{redirected,statusCode,responseHTML}})}#findFrameElement(element,submitter){const id=getAttribute("data-turbo-frame",submitter,element)||this.element.getAttribute("target"),target=this.#getFrameElementById(id);return target instanceof FrameElement?target:this.element}async extractForeignFrameElement(container){let element;
15const id=CSS.escape(this.id);try{if(element=activateElement(container.querySelector(`turbo-frame#${id}`),this.sourceURL),element)return element;if(element=activateElement(container.querySelector(`turbo-frame[src][recurse~=${id}]`),this.sourceURL),element)return await element.loaded,await this.extractForeignFrameElement(element)}catch(error){return console.error(error),new FrameElement}return null}#formActionIsVisitable(form,submitter){return locationIsVisitable(expandURL(getAction$1(form,submitter)),this.rootLocation)}#shouldInterceptNavigation(element,submitter){const id=getAttribute("data-turbo-frame",submitter,element)||this.element.getAttribute("target");if(element instanceof HTMLFormElement&&!this.#formActionIsVisitable(element,submitter))return!1;if(!this.enabled||"_top"==id)return!1;if(id){const frameElement=this.#getFrameElementById(id);if(frameElement)return!frameElement.disabled;if("_parent"==id)return!1}return!!session.elementIsNavigatable(element)&&!(submitter&&!session.elementIsNavigatable(submitter))}get id(){return this.element.id}get disabled(){return this.element.disabled}get enabled(){return!this.disabled}get sourceURL(){if(this.element.src)return this.element.src}set sourceURL(sourceURL){this.#ignoringChangesToAttribute("src",()=>{this.element.src=sourceURL??null})}get loadingStyle(){return this.element.loading}get isLoading(){return void 0!==this.formSubmission||void 0!==this.#resolveVisitPromise()}get complete(){return this.element.hasAttribute("complete")}set complete(value){value?this.element.setAttribute("complete",""):this.element.removeAttribute("complete")}get isActive(){return this.element.isActive&&this.#connected}get rootLocation(){const meta=this.element.ownerDocument.querySelector('meta[name="turbo-root"]');return expandURL(meta?.content??"/")}#isIgnoringChangesTo(attributeName){return this.#ignoredAttributes.has(attributeName)}#ignoringChangesToAttribute(attributeName,callback){this.#ignoredAttributes.add(attributeName),callback(),this.#ignoredAttributes.delete(attributeName)}#withCurrentNavigationElement(element,callback){this.currentNavigationElement=element,callback(),delete this.currentNavigationElement}#getFrameElementById(id){if(null!=id){const element="_parent"===id?this.element.parentElement.closest("turbo-frame"):document.getElementById(id);if(element instanceof FrameElement)return element}}},void 0===customElements.get("turbo-frame")&&customElements.define("turbo-frame",FrameElement),void 0===customElements.get("turbo-stream")&&customElements.define("turbo-stream",StreamElement),void 0===customElements.get("turbo-stream-source")&&customElements.define("turbo-stream-source",StreamSourceElement),(()=>{const scriptElement=document.currentScript;if(!scriptElement)return;if(scriptElement.hasAttribute("data-turbo-suppress-warning"))return;let element=scriptElement.parentElement;for(;element;){if(element==document.body)return console.warn(unindent` 16 You are loading Turbo from a <script> element inside the <body> element. This is probably not what you meant to do! 17 18 Load your applicationâs JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change. 19 20 For more information, see: https://turbo.hotwired.dev/handbook/building#working-with-script-elements 21 22 ââ 23 Suppress this warning by adding a "data-turbo-suppress-warning" attribute to: %s 24 `,scriptElement.outerHTML);element=element.parentElement}})(),window.Turbo={...Turbo,StreamActions},start()}}]); 25//# sourceMappingURL=89.70685678.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.