1/** 2 * Bundled by jsDelivr using Rollup v4.62.2 and esbuild v0.28.1. 3 * Original file: /npm/@hotwired/[email protected]/dist/turbo.es2017-esm.js 4 * 5 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files 6 */ 7(function(s){if(typeof s.requestSubmit=="function")return;s.requestSubmit=function(r){r?(e(r,this),r.click()):(r=document.createElement("input"),r.type="submit",r.hidden=!0,this.appendChild(r),r.click(),this.removeChild(r))};function e(r,i){r instanceof HTMLElement||t(TypeError,"parameter 1 is not of type 'HTMLElement'"),r.type=="submit"||t(TypeError,"The specified element is not a submit button"),r.form==i||t(DOMException,"The specified element is not owned by this form element","NotFoundError")}function t(r,i,a){throw new r("Failed to execute 'requestSubmit' on 'HTMLFormElement': "+i+".",a)}})(HTMLFormElement.prototype);const Pe=new WeakMap;function ut(s){const e=s instanceof Element?s:s instanceof Node?s.parentElement:null,t=e?e.closest("input, button"):null;return t?.type=="submit"?t:null}function mt(s){const e=ut(s.target);e&&e.form&&Pe.set(e.form,e)}(function(){if("submitter"in Event.prototype)return;let s=window.Event.prototype;if("SubmitEvent"in window){const e=window.SubmitEvent.prototype;if(/Apple Computer/.test(navigator.vendor)&&!("submitter"in e))s=e;else return}addEventListener("click",mt,!0),Object.defineProperty(s,"submitter",{get(){if(this.type=="submit"&&this.target instanceof HTMLFormElement)return Pe.get(this.target)}})})();const W={eager:"eager",lazy:"lazy"};class k extends HTMLElement{static delegateConstructor=void 0;loaded=Promise.resolve();static get observedAttributes(){return["disabled","loading","src"]}constructor(){super(),this.delegate=new k.delegateConstructor(this)}connectedCallback(){this.delegate.connect()}disconnectedCallback(){this.delegate.disconnect()}reload(){return this.delegate.sourceURLReloaded()}attributeChangedCallback(e){e=="loading"?this.delegate.loadingStyleChanged():e=="src"?this.delegate.sourceURLChanged():e=="disabled"&&this.delegate.disabledChanged()}get src(){return this.getAttribute("src")}set src(e){e?this.setAttribute("src",e):this.removeAttribute("src")}get refresh(){return this.getAttribute("refresh")}set refresh(e){e?this.setAttribute("refresh",e):this.removeAttribute("refresh")}get shouldReloadWithMorph(){return this.src&&this.refresh==="morph"}get loading(){return ft(this.getAttribute("loading")||"")}set loading(e){e?this.setAttribute("loading",e):this.removeAttribute("loading")}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get autoscroll(){return this.hasAttribute("autoscroll")}set autoscroll(e){e?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")}}function ft(s){return s.toLowerCase()==="lazy"?W.lazy:W.eager}const pt={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 G(s){if(s.getAttribute("data-turbo-eval")=="false")return s;{const e=document.createElement("script"),t=He();return t&&(e.nonce=t),e.textContent=s.textContent,e.async=!1,gt(e,s),e}}function gt(s,e){for(const{name:t,value:r}of e.attributes)s.setAttribute(t,r)}function bt(s){const e=document.createElement("template");return e.innerHTML=s,e.content}function E(s,{target:e,cancelable:t,detail:r}={}){const i=new CustomEvent(s,{cancelable:t,bubbles:!0,composed:!0,detail:r});return e&&e.isConnected?e.dispatchEvent(i):document.documentElement.dispatchEvent(i),i}function Ce(s){s.preventDefault(),s.stopImmediatePropagation()}function Z(){return document.visibilityState==="hidden"?ke():Me()}function Me(){return new Promise(s=>requestAnimationFrame(()=>s()))}function ke(){return new Promise(s=>setTimeout(()=>s(),0))}function vt(){return Promise.resolve()}function Fe(s=""){return new DOMParser().parseFromString(s,"text/html")}function Ie(s,...e){const t=St(s,e).replace(/^\n/,"").split(` 8`),r=t[0].match(/^\s+/),i=r?r[0].length:0;return t.map(a=>a.slice(i)).join(` 9`)}function St(s,e){return s.reduce((t,r,i)=>{const a=e[i]==null?"":e[i];return t+r+a},"")}function O(){return Array.from({length:36}).map((s,e)=>e==8||e==13||e==18||e==23?"-":e==14?"4":e==19?(Math.floor(Math.random()*4)+8).toString(16):Math.floor(Math.random()*15).toString(16)).join("")}function ee(s,...e){for(const t of e.map(r=>r?.getAttribute(s)))if(typeof t=="string")return t;return null}function wt(s,...e){return e.some(t=>t&&t.hasAttribute(s))}function te(...s){for(const e of s)e.localName=="turbo-frame"&&e.setAttribute("busy",""),e.setAttribute("aria-busy","true")}function se(...s){for(const e of s)e.localName=="turbo-frame"&&e.removeAttribute("busy"),e.removeAttribute("aria-busy")}function yt(s,e=2e3){return new Promise(t=>{const r=()=>{s.removeEventListener("error",r),s.removeEventListener("load",r),t()};s.addEventListener("load",r,{once:!0}),s.addEventListener("error",r,{once:!0}),setTimeout(t,e)})}function qe(s){switch(s){case"replace":return history.replaceState;case"advance":case"restore":return history.pushState}}function Et(s){return s=="advance"||s=="replace"||s=="restore"}function x(...s){const e=ee("data-turbo-action",...s);return Et(e)?e:null}function fe(s){return document.querySelector(`meta[name="${s}"]`)}function re(s){const e=fe(s);return e&&e.content}function He(){const s=fe("csp-nonce");if(s){const{nonce:e,content:t}=s;return e==""?t:e}}
9function At(s,e){let t=fe(s);return t||(t=document.createElement("meta"),t.setAttribute("name",s),document.head.appendChild(t)),t.setAttribute("content",e),t}function j(s,e){if(s instanceof Element)return s.closest(e)||j(s.assignedSlot||s.getRootNode()?.host,e)}function pe(s){return!!s&&s.closest("[inert], :disabled, [hidden], details:not([open]), dialog:not([open])")==null&&typeof s.focus=="function"}function Be(s){return Array.from(s.querySelectorAll("[autofocus]")).find(pe)}async function Lt(s,e){const t=e();s(),await Me();const r=e();return[t,r]}function Oe(s){if(s==="_blank")return!1;if(s){for(const e of document.getElementsByName(s))if(e instanceof HTMLIFrameElement)return!1;return!0}else return!0}function Ne(s){return j(s,"a[href]:not([target^=_]):not([download])")}function De(s){return P(s.getAttribute("href")||"")}function Rt(s,e){let t=null;return(...r)=>{const i=()=>s.apply(this,r);clearTimeout(t),t=setTimeout(i,e)}}const Tt={"aria-disabled":{beforeSubmit:s=>{s.setAttribute("aria-disabled","true"),s.addEventListener("click",Ce)},afterSubmit:s=>{s.removeAttribute("aria-disabled"),s.removeEventListener("click",Ce)}},disabled:{beforeSubmit:s=>s.disabled=!0,afterSubmit:s=>s.disabled=!1}};class Pt{#e=null;constructor(e){Object.assign(this,e)}get submitter(){return this.#e}set submitter(e){this.#e=Tt[e]||e}}const Ct=new Pt({mode:"on",submitter:"disabled"}),T={drive:pt,forms:Ct};function P(s){return new URL(s.toString(),document.baseURI)}function U(s){let e;if(s.hash)return s.hash.slice(1);if(e=s.href.match(/#(.*)$/))return e[1]}function ge(s,e){const t=e?.getAttribute("formaction")||s.getAttribute("action")||s.action;return P(t)}function Mt(s){return(qt(s).match(/\.[^.]*$/)||[])[0]||""}function kt(s,e){const t=Ht(e);return s.href===P(t).href||s.href.startsWith(t)}function N(s,e){return kt(s,e)&&!T.drive.unvisitableExtensions.has(Mt(s))}function be(s){const e=U(s);return e!=null?s.href.slice(0,-(e.length+1)):s.href}function ie(s){return be(s)}function Ft(s,e){return P(s).href==P(e).href}function It(s){return s.pathname.split("/").slice(1)}function qt(s){return It(s).slice(-1)[0]}function Ht(s){return Bt(s.origin+s.pathname)}function Bt(s){return s.endsWith("/")?s:s+"/"}class ne{constructor(e){this.response=e}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 P(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(e){return this.response.headers.get(e)}}class Ot extends Set{constructor(e){super(),this.maxSize=e}add(e){if(this.size>=this.maxSize){const r=this.values().next().value;this.delete(r)}super.add(e)}}const Ve=new Ot(20),Nt=window.fetch;function ve(s,e={}){const t=new Headers(e.headers||{}),r=O();return Ve.add(r),t.append("X-Turbo-Request-Id",r),Nt(s,{...e,headers:t})}function oe(s){switch(s.toLowerCase()){case"get":return M.get;case"post":return M.post;case"put":return M.put;case"patch":return M.patch;case"delete":return M.delete}}const M={get:"get",post:"post",put:"put",patch:"patch",delete:"delete"};function We(s){switch(s.toLowerCase()){case D.multipart:return D.multipart;case D.plain:return D.plain;default:return D.urlEncoded}}const D={urlEncoded:"application/x-www-form-urlencoded",multipart:"multipart/form-data",plain:"text/plain"};class K{abortController=new AbortController;#e=e=>{};constructor(e,t,r,i=new URLSearchParams,a=null,f=D.urlEncoded){const[w,C]=xe(P(r),t,i,f);this.delegate=e,this.url=w,this.target=a,this.fetchOptions={credentials:"same-origin",redirect:"follow",method:t.toUpperCase(),headers:{...this.defaultHeaders}
9,body:C,signal:this.abortSignal,referrer:this.delegate.referrer?.href},this.enctype=f}get method(){return this.fetchOptions.method}set method(e){const t=this.isSafe?this.url.searchParams:this.fetchOptions.body||new FormData,r=oe(e)||M.get;this.url.search="";const[i,a]=xe(this.url,r,t,this.enctype);this.url=i,this.fetchOptions.body=a,this.fetchOptions.method=r.toUpperCase()}get headers(){return this.fetchOptions.headers}set headers(e){this.fetchOptions.headers=e}get body(){return this.isSafe?this.url.searchParams:this.fetchOptions.body}set body(e){this.fetchOptions.body=e}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:e}=this;this.delegate.prepareRequest(this);const t=await this.#t(e);try{this.delegate.requestStarted(this),t.detail.fetchRequest?this.response=t.detail.fetchRequest.response:this.response=ve(this.url.href,e);const r=await this.response;return await this.receive(r)}catch(r){if(r.name!=="AbortError")throw this.#s(r)&&this.delegate.requestErrored(this,r),r}finally{this.delegate.requestFinished(this)}}async receive(e){const t=new ne(e);return E("turbo:before-fetch-response",{cancelable:!0,detail:{fetchResponse:t},target:this.target}).defaultPrevented?this.delegate.requestPreventedHandlingResponse(this,t):t.succeeded?this.delegate.requestSucceededWithResponse(this,t):this.delegate.requestFailedWithResponse(this,t),t}get defaultHeaders(){return{Accept:"text/html, application/xhtml+xml"}}get isSafe(){return ae(this.method)}get abortSignal(){return this.abortController.signal}acceptResponseType(e){this.headers.Accept=[e,this.headers.Accept].join(", ")}async#t(e){const t=new Promise(i=>this.#e=i),r=E("turbo:before-fetch-request",{cancelable:!0,detail:{fetchOptions:e,url:this.url,resume:this.#e},target:this.target});return this.url=r.detail.url,r.defaultPrevented&&await t,r}#s(e){return!E("turbo:fetch-request-error",{target:this.target,cancelable:!0,detail:{request:this,error:e}}).defaultPrevented}}function ae(s){return oe(s)==M.get}function xe(s,e,t,r){const i=Array.from(t).length>0?new URLSearchParams(Ue(t)):s.searchParams;return ae(e)?[Dt(s,i),null]:r==D.urlEncoded?[s,i]:[s,t]}function Ue(s){const e=[];for(const[t,r]of s)r instanceof File||e.push([t,r]);return e}function Dt(s,e){const t=new URLSearchParams(Ue(e));return s.search=t.toString(),s}class Vt{started=!1;constructor(e,t){this.delegate=e,this.element=t,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=e=>{e.slice(-1)[0]?.isIntersecting&&this.delegate.elementAppearedInViewport(this.element)}}class X{static contentType="text/vnd.turbo-stream.html";static wrap(e){return typeof e=="string"?new this(bt(e)):e}constructor(e){this.fragment=Wt(e)}}function Wt(s){for(const e of s.querySelectorAll("turbo-stream")){const t=document.importNode(e,!0);for(const r of t.templateElement.content.querySelectorAll("script"))r.replaceWith(G(r));e.replaceWith(t)}return s}const xt=100;class Ut{#e=null;#t=null;get(e){if(this.#t&&this.#t.url===e&&this.#t.expire>Date.now())return this.#t.request}setLater(e,t,r){this.clear(),this.#e=setTimeout(()=>{t.perform(),this.set(e,t,r),this.#e=null},xt)}set(e,t,r){this.#t={url:e,request:t,expire:new Date(new Date().getTime()+r)}}clear(){this.#e&&clearTimeout(this.#e),this.#t=null}}const _t=10*1e3,Y=new Ut,J={initialized:"initialized",requesting:"requesting",waiting:"waiting",receiving:"receiving",stopping:"stopping",stopped:"stopped"};class ue{state=J.initialized;static confirmMethod(e){return Promise.resolve(confirm(e))}constructor(e,t,r,i=!1){const a=Yt(t,r),f=Xt(Kt(t,r),a),w=zt(t,r),C=Jt(t,r);this.delegate=e,this.formElement=t,this.submitter=r,this.fetchRequest=new K(this,a,f,w,t,C),this.mustRedirect=i}get method(){return this.fetchRequest.method}set method(e){this.fetchRequest.method=e}get action(){return this.fetchRequest.url.toString()}set action(e){this.fetchRequest.url=P(e)}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:e,requesting:t}=J,r=ee("data-turbo-confirm",this.submitter,this.formElement);if(!(typeof r=="string"&&!await(typeof T.forms.confirm=="function"?T.forms.confirm:ue.confirmMethod)(r,this.formElement,this.submitter))&&this.state==e)return this.state=t,this.fetchRequest.perform()}stop(){const{stopping:e,stopped:t}=J;if(this.state!=e&&this.state!=t)return this.state=e,this.fetchRequest.cancel(),!0}prepareRequest(e){if(!e.isSafe){const t=$t(re("csrf-param"))||re("csrf-token");t&&(e.headers["X-CSRF-Token"]=t)}this.requestAcceptsTurboStreamResponse(e)&&e.acceptResponseType(X.contentType)}requestStarted(e){this.state=J.waiting,this.submitter&&T.forms.submitter.beforeSubmit(this.submitter),this.setSubmitsWith(),te(this.formElement),E("turbo:submit-start",{target:this.formElement,detail
9:{formSubmission:this}}),this.delegate.formSubmissionStarted(this)}requestPreventedHandlingResponse(e,t){Y.clear(),this.result={success:t.succeeded,fetchResponse:t}}requestSucceededWithResponse(e,t){if(t.clientError||t.serverError){this.delegate.formSubmissionFailedWithResponse(this,t);return}if(Y.clear(),this.requestMustRedirect(e)&&jt(t)){const r=new Error("Form responses must redirect to another location");this.delegate.formSubmissionErrored(this,r)}else this.state=J.receiving,this.result={success:!0,fetchResponse:t},this.delegate.formSubmissionSucceededWithResponse(this,t)}requestFailedWithResponse(e,t){this.result={success:!1,fetchResponse:t},this.delegate.formSubmissionFailedWithResponse(this,t)}requestErrored(e,t){this.result={success:!1,error:t},this.delegate.formSubmissionErrored(this,t)}requestFinished(e){this.state=J.stopped,this.submitter&&T.forms.submitter.afterSubmit(this.submitter),this.resetSubmitterText(),se(this.formElement),E("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 e=this.submitter;this.originalSubmitText=e.value,e.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")){const e=this.submitter;e.value=this.originalSubmitText}}}requestMustRedirect(e){return!e.isSafe&&this.mustRedirect}requestAcceptsTurboStreamResponse(e){return!e.isSafe||wt("data-turbo-stream",this.submitter,this.formElement)}get submitsWith(){return this.submitter?.getAttribute("data-turbo-submits-with")}}function zt(s,e){const t=new FormData(s),r=e?.getAttribute("name"),i=e?.getAttribute("value");return r&&t.append(r,i||""),t}function $t(s){if(s!=null){const t=(document.cookie?document.cookie.split("; "):[]).find(r=>r.startsWith(s));if(t){const r=t.split("=").slice(1).join("=");return r?decodeURIComponent(r):void 0}}}function jt(s){return s.statusCode==200&&!s.redirected}function Kt(s,e){const t=typeof s.action=="string"?s.action:null;return e?.hasAttribute("formaction")?e.getAttribute("formaction")||"":s.getAttribute("action")||t||""}function Xt(s,e){const t=P(s);return ae(e)&&(t.search=""),t}function Yt(s,e){const t=e?.getAttribute("formmethod")||s.getAttribute("method")||"";return oe(t.toLowerCase())||M.get}function Jt(s,e){return We(e?.getAttribute("formenctype")||s.enctype)}class ce{constructor(e){this.element=e}get activeElement(){return this.element.ownerDocument.activeElement}get children(){return[...this.element.children]}hasAnchor(e){return this.getElementForAnchor(e)!=null}getElementForAnchor(e){return e?this.element.querySelector(`[id='${e}'], a[name='${e}']`):null}get isConnected(){return this.element.isConnected}get firstAutofocusableElement(){return Be(this.element)}get permanentElements(){return ze(this.element)}getPermanentElementById(e){return _e(this.element,e)}getPermanentElementMapForSnapshot(e){const t={};for(const r of this.permanentElements){const{id:i}=r,a=e.getPermanentElementById(i);a&&(t[i]=[r,a])}return t}}function _e(s,e){return s.querySelector(`#${e}[data-turbo-permanent]`)}function ze(s){return s.querySelectorAll("[id][data-turbo-permanent]")}class Se{started=!1;constructor(e,t){this.delegate=e,this.eventTarget=t}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=e=>{if(!e.defaultPrevented){const t=e.target instanceof HTMLFormElement?e.target:void 0,r=e.submitter||void 0;t&&Qt(t,r)&&Gt(t,r)&&this.delegate.willSubmitForm(t,r)&&(e.preventDefault(),e.stopImmediatePropagation(),this.delegate.formSubmitted(t,r))}}}function Qt(s,e){return(e?.getAttribute("formmethod")||s.getAttribute("method"))!="dialog"}function Gt(s,e){const t=e?.getAttribute("formtarget")||s.getAttribute("target");return Oe(t)}class $e{#e=e=>{};#t=e=>{};constructor(e,t){this.delegate=e,this.element=t}scrollToAnchor(e){const t=this.snapshot.getElementForAnchor(e);t?(this.scrollToElement(t),this.focusElement(t)):this.scrollToPosition({x:0,y:0})}scrollToAnchorFromLocation(e){this.scrollToAnchor(U(e))}scrollToElement(e){e.scrollIntoView()}focusElement(e){e instanceof HTMLElement&&(e.hasAttribute("tabindex")?e.focus():(e.setAttribute("tabindex","-1"),e.focus(),e.removeAttribute("tabindex")))}scrollToPosition({x:e,y:t}){this.scrollRoot.scrollTo(e,t)}scrollToTop(){this.scrollToPosition({x:0,y:0})}get scrollRoot(){return window}
9async render(e){const{isPreview:t,shouldRender:r,willRender:i,newSnapshot:a}=e,f=i;if(r)try{this.renderPromise=new Promise(I=>this.#e=I),this.renderer=e,await this.prepareToRenderSnapshot(e);const w=new Promise(I=>this.#t=I),C={resume:this.#t,render:this.renderer.renderElement,renderMethod:this.renderer.renderMethod};this.delegate.allowsImmediateRender(a,C)||await w,await this.renderSnapshot(e),this.delegate.viewRenderedSnapshot(a,t,this.renderer.renderMethod),this.delegate.preloadOnLoadLinksForView(this.element),this.finishRenderingSnapshot(e)}finally{delete this.renderer,this.#e(void 0),delete this.renderPromise}else f&&this.invalidate(e.reloadReason)}invalidate(e){this.delegate.viewInvalidated(e)}async prepareToRenderSnapshot(e){this.markAsPreview(e.isPreview),await e.prepareToRender()}markAsPreview(e){e?this.element.setAttribute("data-turbo-preview",""):this.element.removeAttribute("data-turbo-preview")}markVisitDirection(e){this.element.setAttribute("data-turbo-visit-direction",e)}unmarkVisitDirection(){this.element.removeAttribute("data-turbo-visit-direction")}async renderSnapshot(e){await e.render()}finishRenderingSnapshot(e){e.finishRendering()}}class Zt extends $e{missing(){this.element.innerHTML='<strong class="turbo-frame-error">Content missing</strong>'}get snapshot(){return new ce(this.element)}}class je{constructor(e,t){this.delegate=e,this.element=t}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=e=>{this.clickEventIsSignificant(e)?this.clickEvent=e:delete this.clickEvent};linkClicked=e=>{this.clickEvent&&this.clickEventIsSignificant(e)&&this.delegate.shouldInterceptLinkClick(e.target,e.detail.url,e.detail.originalEvent)&&(this.clickEvent.preventDefault(),e.preventDefault(),this.delegate.linkClickIntercepted(e.target,e.detail.url,e.detail.originalEvent)),delete this.clickEvent};willVisit=e=>{delete this.clickEvent};clickEventIsSignificant(e){const t=e.composed?e.target?.parentElement:e.target,r=Ne(t)||t;return r instanceof Element&&r.closest("turbo-frame, html")==this.element}}class Ke{started=!1;constructor(e,t){this.delegate=e,this.eventTarget=t}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=e=>{if(e instanceof MouseEvent&&this.clickEventIsSignificant(e)){const t=e.composedPath&&e.composedPath()[0]||e.target,r=Ne(t);if(r&&Oe(r.target)){const i=De(r);this.delegate.willFollowLinkToLocation(r,i,e)&&(e.preventDefault(),this.delegate.followedLinkToLocation(r,i))}}};clickEventIsSignificant(e){return!(e.target&&e.target.isContentEditable||e.defaultPrevented||e.which>1||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)}}class Xe{constructor(e,t){this.delegate=e,this.linkInterceptor=new Ke(this,t)}start(){this.linkInterceptor.start()}stop(){this.linkInterceptor.stop()}canPrefetchRequestToLocation(e,t){return!1}prefetchAndCacheRequestToLocation(e,t){}willFollowLinkToLocation(e,t,r){return this.delegate.willSubmitFormLinkToLocation(e,t,r)&&(e.hasAttribute("data-turbo-method")||e.hasAttribute("data-turbo-stream"))}followedLinkToLocation(e,t){const r=document.createElement("form"),i="hidden";for(const[z,p]of t.searchParams)r.append(Object.assign(document.createElement("input"),{type:i,name:z,value:p}));const a=Object.assign(t,{search:""});r.setAttribute("data-turbo","true"),r.setAttribute("action",a.href),r.setAttribute("hidden","");const f=e.getAttribute("data-turbo-method");f&&r.setAttribute("method",f);const w=e.getAttribute("data-turbo-frame");w&&r.setAttribute("data-turbo-frame",w);const C=x(e);C&&r.setAttribute("data-turbo-action",C);const B=e.getAttribute("data-turbo-confirm");B&&r.setAttribute("data-turbo-confirm",B),e.hasAttribute("data-turbo-stream")&&r.setAttribute("data-turbo-stream",""),this.delegate.submittedFormLinkToLocation(e,t,r),document.body.appendChild(r),r.addEventListener("turbo:submit-end",()=>r.remove(),{once:!0}),requestAnimationFrame(()=>r.requestSubmit())}}class Ye{static async preservingPermanentElements(e,t,r){const i=new this(e,t);i.enter(),await r(),i.leave()}constructor(e,t){this.delegate=e,this.permanentElementMap=t}enter(){for(const e in this.permanentElementMap){const[t,r]=this.permanentElementMap[e];this.delegate.enteringBardo(t,r),this.replaceNewPermanentElementWithPlaceholder(r)}}leave(){for(const e in this.permanentElementMap){const[t]=this.permanentElementMap[e];this.replaceCurrentPermanentElementWithClone(t),this.replacePlaceholderWithPermanentElement(t),this.delegate.leavingBardo(t)}}replaceNewPermanentElementWithPlaceholder(e){const t=es(e);e.replaceWith(t)}replaceCurrentPermanentElementWithClone(e){const t=e.cloneNode(!0);e.replaceWith(t)}replacePlaceholderWithPermanentElement(e){this.getPlaceholderById(e.id)?.replaceWith(e)}getPlaceholderById(e){return this.placeholders.find(t=>t.content==e)}get placeholders(){return[...document.querySelectorAll("meta[name=turbo-permanent-placeholder][content]")]}}function es(s){const e=document.createElement("meta");return e.setAttribute("name","turbo-permanent-placeholder"),e.setAttribute("content",s.id),e}class we{#e=null;static renderElement(e,t){}
9constructor(e,t,r,i=!0){this.currentSnapshot=e,this.newSnapshot=t,this.isPreview=r,this.willRender=i,this.renderElement=this.constructor.renderElement,this.promise=new Promise((a,f)=>this.resolvingFunctions={resolve:a,reject:f})}get shouldRender(){return!0}get shouldAutofocus(){return!0}get reloadReason(){}prepareToRender(){}render(){}finishRendering(){this.resolvingFunctions&&(this.resolvingFunctions.resolve(),delete this.resolvingFunctions)}async preservingPermanentElements(e){await Ye.preservingPermanentElements(this,this.permanentElementMap,e)}focusFirstAutofocusableElement(){if(this.shouldAutofocus){const e=this.connectedSnapshot.firstAutofocusableElement;e&&e.focus()}}enteringBardo(e){this.#e||e.contains(this.currentSnapshot.activeElement)&&(this.#e=this.currentSnapshot.activeElement)}leavingBardo(e){e.contains(this.#e)&&this.#e instanceof HTMLElement&&(this.#e.focus(),this.#e=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 le extends we{static renderElement(e,t){const r=document.createRange();r.selectNodeContents(e),r.deleteContents();const i=t,a=i.ownerDocument?.createRange();a&&(a.selectNodeContents(i),e.appendChild(a.extractContents()))}constructor(e,t,r,i,a,f=!0){super(t,r,i,a,f),this.delegate=e}get shouldRender(){return!0}async render(){await Z(),this.preservingPermanentElements(()=>{this.loadFrameElement()}),this.scrollFrameIntoView(),await Z(),this.focusFirstAutofocusableElement(),await Z(),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 e=this.currentElement.firstElementChild,t=ts(this.currentElement.getAttribute("data-autoscroll-block"),"end"),r=ss(this.currentElement.getAttribute("data-autoscroll-behavior"),"auto");if(e)return e.scrollIntoView({block:t,behavior:r}),!0}return!1}activateScriptElements(){for(const e of this.newScriptElements){const t=G(e);e.replaceWith(t)}}get newScriptElements(){return this.currentElement.querySelectorAll("script")}}function ts(s,e){return s=="end"||s=="start"||s=="center"||s=="nearest"?s:e}function ss(s,e){return s=="auto"||s=="smooth"?s:e}var rs=(function(){const s=()=>{},e={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:s,afterNodeAdded:s,beforeNodeMorphed:s,afterNodeMorphed:s,beforeNodeRemoved:s,afterNodeRemoved:s,beforeAttributeUpdated:s},head:{style:"merge",shouldPreserve:p=>p.getAttribute("im-preserve")==="true",shouldReAppend:p=>p.getAttribute("im-re-append")==="true",shouldRemove:s,afterHeadMorphed:s},restoreFocus:!0};function t(p,y,v={}){p=I(p);const S=z(y),g=B(p,S,v),m=i(g,()=>w(g,p,S,c=>c.morphStyle==="innerHTML"?(a(c,p,S),Array.from(p.childNodes)):r(c,p,S)));return g.pantry.remove(),m}function r(p,y,v){const S=z(y);let g=Array.from(S.childNodes);const m=g.indexOf(y),c=g.length-(m+1);return a(p,S,v,y,y.nextSibling),g=Array.from(S.childNodes),g.slice(m,g.length-c)}function i(p,y){if(!p.config.restoreFocus)return y();let v=document.activeElement;if(!(v instanceof HTMLInputElement||v instanceof HTMLTextAreaElement))return y();const{id:S,selectionStart:g,selectionEnd:m}=v,c=y();return S&&S!==document.activeElement?.id&&(v=p.target.querySelector(`#${S}`),v?.focus()),v&&!v.selectionEnd&&m&&v.setSelectionRange(g,m),c}const a=(function(){function p(n,o,u,h=null,d=null){o instanceof HTMLTemplateElement&&u instanceof HTMLTemplateElement&&(o=o.content,u=u.content),h||=o.firstChild;for(const b of u.childNodes){if(h&&h!=d){const A=v(n,b,h,d);if(A){A!==h&&g(n,h,A),f(A,b,n),h=A.nextSibling;continue}}if(b instanceof Element&&n.persistentIds.has(b.id)){const A=m(o,b.id,h,n);f(A,b,n),h=A.nextSibling;continue}const R=y(o,b,h,n);R&&(h=R.nextSibling)}for(;h&&h!=d;){const b=h;h=h.nextSibling,S(n,b)}}function y(n,o,u,h){if(h.callbacks.beforeNodeAdded(o)===!1)return null;if(h.idMap.has(o)){const d=document.createElement(o.tagName);return n.insertBefore(d,u),f(d,o,h),h.callbacks.afterNodeAdded(d),d}else{const d=document.importNode(o,!0);return n.insertBefore(d,u),h.callbacks.afterNodeAdded(d),d}}const v=(function(){function n(h,d,b,R){let A=null,$=d.nextSibling,Te=0,q=b;for(;q&&q!=R;){if(u(q,d)){if(o(h,q,d))return q;A===null&&(h.idMap.has(q)||(A=q))}if(A===null&&$&&u(q,$)&&(Te++,$=$.nextSibling,Te>=2&&(A=void 0)),q.contains(document.activeElement))break;q=q.nextSibling}return A||null}function o(h,d,b){let R=h.idMap.get(d),A=h.idMap.get(b);if(!A||!R)return!1;for(const $ of R)if(A.has($))return!0;return!1}function u(h,d){const b=h,R=d;return b.nodeType===R.nodeType&&b.tagName===R.tagName&&(!b.id||b.id===R.id)}return n})();function S(n,o){if(n.idMap.has(o))l(n.pantry,o,null);else{if(n.callbacks.beforeNodeRemoved(o)===!1)return;o.parentNode?.removeChild(o),n.callbacks.afterNodeRemoved(o)}}function g(n,o,u){let h=o;for(;h&&h!==u;){let d=h;h=h.nextSibling,S(n,d)}return h}function m(n,o,u,h){const d=h.target.querySelector(`#${o}`)||h.pantry.querySelector(`#${o}`);return c(d,h),l(n,d,u),d}function c(n,o){const u=n.id;for(;n=n.parentNode;){let h=o.idMap.get(n);h&&(h.delete(u),h.size||o.idMap.delete(n))}}function l(n,o,u){if(n.moveBefore)try{n.moveBefore(o,u)}catch{n.insertBefore(o,u)}else n.insertBefore(o,u)}return p})(),f=(function(){function p(c,l,n){return n.ignoreActive&&c===document.activeElement?null:(n.callbacks.beforeNodeMorphed(c,l)===!1||(c instanceof HTMLHeadElement&&n.head.ignore||(c instanceof HTMLHeadElement&&n.head.style!=="morph"?C(c,l,
9n):(y(c,l,n),m(c,n)||a(n,c,l))),n.callbacks.afterNodeMorphed(c,l)),c)}function y(c,l,n){let o=l.nodeType;if(o===1){const u=c,h=l,d=u.attributes,b=h.attributes;for(const R of b)g(R.name,u,"update",n)||u.getAttribute(R.name)!==R.value&&u.setAttribute(R.name,R.value);for(let R=d.length-1;0<=R;R--){const A=d[R];if(A&&!h.hasAttribute(A.name)){if(g(A.name,u,"remove",n))continue;u.removeAttribute(A.name)}}m(u,n)||v(u,h,n)}(o===8||o===3)&&c.nodeValue!==l.nodeValue&&(c.nodeValue=l.nodeValue)}function v(c,l,n){if(c instanceof HTMLInputElement&&l instanceof HTMLInputElement&&l.type!=="file"){let o=l.value,u=c.value;S(c,l,"checked",n),S(c,l,"disabled",n),l.hasAttribute("value")?u!==o&&(g("value",c,"update",n)||(c.setAttribute("value",o),c.value=o)):g("value",c,"remove",n)||(c.value="",c.removeAttribute("value"))}else if(c instanceof HTMLOptionElement&&l instanceof HTMLOptionElement)S(c,l,"selected",n);else if(c instanceof HTMLTextAreaElement&&l instanceof HTMLTextAreaElement){let o=l.value,u=c.value;if(g("value",c,"update",n))return;o!==u&&(c.value=o),c.firstChild&&c.firstChild.nodeValue!==o&&(c.firstChild.nodeValue=o)}}function S(c,l,n,o){const u=l[n],h=c[n];if(u!==h){const d=g(n,c,"update",o);d||(c[n]=l[n]),u?d||c.setAttribute(n,""):g(n,c,"remove",o)||c.removeAttribute(n)}}function g(c,l,n,o){return c==="value"&&o.ignoreActiveValue&&l===document.activeElement?!0:o.callbacks.beforeAttributeUpdated(c,l,n)===!1}function m(c,l){return!!l.ignoreActiveValue&&c===document.activeElement&&c!==document.body}return p})();function w(p,y,v,S){if(p.head.block){const g=y.querySelector("head"),m=v.querySelector("head");if(g&&m){const c=C(g,m,p);return Promise.all(c).then(()=>{const l=Object.assign(p,{head:{block:!1,ignore:!0}});return S(l)})}}return S(p)}function C(p,y,v){let S=[],g=[],m=[],c=[],l=new Map;for(const o of y.children)l.set(o.outerHTML,o);for(const o of p.children){let u=l.has(o.outerHTML),h=v.head.shouldReAppend(o),d=v.head.shouldPreserve(o);u||d?h?g.push(o):(l.delete(o.outerHTML),m.push(o)):v.head.style==="append"?h&&(g.push(o),c.push(o)):v.head.shouldRemove(o)!==!1&&g.push(o)}c.push(...l.values());let n=[];for(const o of c){let u=document.createRange().createContextualFragment(o.outerHTML).firstChild;if(v.callbacks.beforeNodeAdded(u)!==!1){if("href"in u&&u.href||"src"in u&&u.src){let h,d=new Promise(function(b){h=b});u.addEventListener("load",function(){h()}),n.push(d)}p.appendChild(u),v.callbacks.afterNodeAdded(u),S.push(u)}}for(const o of g)v.callbacks.beforeNodeRemoved(o)!==!1&&(p.removeChild(o),v.callbacks.afterNodeRemoved(o));return v.head.afterHeadMorphed(p,{added:S,kept:m,removed:g}),n}const B=(function(){function p(l,n,o){const{persistentIds:u,idMap:h}=m(l,n),d=y(o),b=d.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(b))throw`Do not understand how to morph style ${b}`;return{target:l,newContent:n,config:d,morphStyle:b,ignoreActive:d.ignoreActive,ignoreActiveValue:d.ignoreActiveValue,restoreFocus:d.restoreFocus,idMap:h,persistentIds:u,pantry:v(),callbacks:d.callbacks,head:d.head}}function y(l){let n=Object.assign({},e);return Object.assign(n,l),n.callbacks=Object.assign({},e.callbacks,l.callbacks),n.head=Object.assign({},e.head,l.head),n}function v(){const l=document.createElement("div");return l.hidden=!0,document.body.insertAdjacentElement("afterend",l),l}function S(l){let n=Array.from(l.querySelectorAll("[id]"));return l.id&&n.push(l),n}function g(l,n,o,u){for(const h of u)if(n.has(h.id)){let d=h;for(;d;){let b=l.get(d);if(b==null&&(b=new Set,l.set(d,b)),b.add(h.id),d===o)break;d=d.parentElement}}}function m(l,n){const o=S(l),u=S(n),h=c(o,u);let d=new Map;g(d,h,l,o);const b=n.__idiomorphRoot||n;return g(d,h,b,u),{persistentIds:h,idMap:d}}function c(l,n){let o=new Set,u=new Map;for(const{id:d,tagName:b}of l)u.has(d)?o.add(d):u.set(d,b);let h=new Set;for(const{id:d,tagName:b}of n)h.has(d)?o.add(d):u.get(d)===b&&h.add(d);for(const d of o)h.delete(d);return h}return p})(),{normalizeElement:I,normalizeParent:z}=(function(){const p=new WeakSet;function y(m){return m instanceof Document?m.documentElement:m}function v(m){if(m==null)return document.createElement("div");if(typeof m=="string")return v(g(m));if(p.has(m))return m;if(m instanceof Node){if(m.parentNode)return S(m);{const c=document.createElement("div");return c.append(m),c}}else{const c=document.createElement("div");for(const l of[...m])c.append(l);return c}}function S(m){return{childNodes:[m],querySelectorAll:c=>{const l=m.querySelectorAll(c);return m.matches(c)?[m,...l]:l},insertBefore:(c,l)=>m.parentNode.insertBefore(c,l),moveBefore:(c,l)=>m.parentNode.moveBefore(c,l),get __idiomorphRoot(){return m}}}function g(m){let c=new DOMParser,l=m.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(l.match(/<\/html>/)||l.match(/<\/head>/)||l.match(/<\/body>/)){let n=c.parseFromString(m,"text/html");if(l.match(/<\/html>/))return p.add(n),n;{let o=n.firstChild;return o&&p.add(o),o}}else{let o=c.parseFromString("<body><template>"+m+"</template></body>","text/html").body.querySelector("template").content;return p.add(o),o}}return{normalizeElement:y,normalizeParent:v}})();return{morph:t,defaults:e}})();function ye(s,e,{callbacks:t,...r}={}){rs.morph(s,e,{...r,callbacks:new is(t)})}function Je(s,e){ye(s,e.childNodes,{morphStyle:"innerHTML"})}class is{#e;constructor({beforeNodeMorphed:e}={}){this.#e=e||(()=>!0)}beforeNodeAdded=e=>!(e.id&&e.hasAttribute("data-turbo-permanent")&&document.getElementById(e.id));beforeNodeMorphed=(e,t)=>{if(e instanceof Element)return!e.hasAttribute("data-turbo-permanent")&&this.#e(e,t)?!E("turbo:before-morph-element",{cancelable:!0,target:e,detail:{currentElement:e,newElement:t}}).defaultPrevented:!1};beforeAttributeUpdated=(e,t,r)=>!E("turbo:before-morph-attribute",{cancelable:!0,target:t,detail
9:{attributeName:e,mutationType:r}}).defaultPrevented;beforeNodeRemoved=e=>this.beforeNodeMorphed(e);afterNodeMorphed=(e,t)=>{e instanceof Element&&E("turbo:morph-element",{target:e,detail:{currentElement:e,newElement:t}})}}class ns extends le{static renderElement(e,t){E("turbo:before-frame-morph",{target:e,detail:{currentElement:e,newElement:t}}),Je(e,t)}async preservingPermanentElements(e){return await e()}}class V{static animationDuration=300;static get defaultCSS(){return Ie` 10 .turbo-progress-bar { 11 position: fixed; 12 display: block; 13 top: 0; 14 left: 0; 15 height: 3px; 16 background: #0076ff; 17 z-index: 2147483647; 18 transition: 19 width ${V.animationDuration}ms ease-out, 20 opacity ${V.animationDuration/2}ms ${V.animationDuration/2}ms ease-in; 21 transform: translate3d(0, 0, 0); 22 } 23 `}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(e){this.value=e,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(e){this.progressElement.style.opacity="0",setTimeout(e,V.animationDuration*1.5)}uninstallProgressElement(){this.progressElement.parentNode&&document.documentElement.removeChild(this.progressElement)}startTrickling(){this.trickleInterval||(this.trickleInterval=window.setInterval(this.trickle,V.animationDuration))}stopTrickling(){window.clearInterval(this.trickleInterval),delete this.trickleInterval}trickle=()=>{this.setValue(this.value+Math.random()/100)};refresh(){requestAnimationFrame(()=>{this.progressElement.style.width=`${10+this.value*90}%`})}createStylesheetElement(){const e=document.createElement("style");e.type="text/css",e.textContent=V.defaultCSS;const t=He();return t&&(e.nonce=t),e}createProgressElement(){const e=document.createElement("div");return e.className="turbo-progress-bar",e}}class os extends ce{detailsByOuterHTML=this.children.filter(e=>!hs(e)).map(e=>ms(e)).reduce((e,t)=>{const{outerHTML:r}=t,i=r in e?e[r]:{type:as(t),tracked:cs(t),elements:[]};return{...e,[r]:{...i,elements:[...i.elements,t]}}},{});get trackedElementSignature(){return Object.keys(this.detailsByOuterHTML).filter(e=>this.detailsByOuterHTML[e].tracked).join("")}getScriptElementsNotInSnapshot(e){return this.getElementsMatchingTypeNotInSnapshot("script",e)}getStylesheetElementsNotInSnapshot(e){return this.getElementsMatchingTypeNotInSnapshot("stylesheet",e)}getElementsMatchingTypeNotInSnapshot(e,t){return Object.keys(this.detailsByOuterHTML).filter(r=>!(r in t.detailsByOuterHTML)).map(r=>this.detailsByOuterHTML[r]).filter(({type:r})=>r==e).map(({elements:[r]})=>r)}get provisionalElements(){return Object.keys(this.detailsByOuterHTML).reduce((e,t)=>{const{type:r,tracked:i,elements:a}=this.detailsByOuterHTML[t];return r==null&&!i?[...e,...a]:a.length>1?[...e,...a.slice(1)]:e},[])}getMetaValue(e){const t=this.findMetaElementByName(e);return t?t.getAttribute("content"):null}findMetaElementByName(e){return Object.keys(this.detailsByOuterHTML).reduce((t,r)=>{const{elements:[i]}=this.detailsByOuterHTML[r];return us(i,e)?i:t},void 0|void 0)}}function as(s){if(ls(s))return"script";if(ds(s))return"stylesheet"}function cs(s){return s.getAttribute("data-turbo-track")=="reload"}function ls(s){return s.localName=="script"}function hs(s){return s.localName=="noscript"}function ds(s){const e=s.localName;return e=="style"||e=="link"&&s.getAttribute("rel")=="stylesheet"}function us(s,e){return s.localName=="meta"&&s.getAttribute("name")==e}function ms(s){return s.hasAttribute("nonce")&&s.setAttribute("nonce",""),s}class F extends ce{static fromHTMLString(e=""){return this.fromDocument(Fe(e))}static fromElement(e){return this.fromDocument(e.ownerDocument)}static fromDocument({documentElement:e,body:t,head:r}){return new this(e,t,new os(r))}constructor(e,t,r){super(t),this.documentElement=e,this.headSnapshot=r}clone(){const e=this.element.cloneNode(!0),t=this.element.querySelectorAll("select"),r=e.querySelectorAll("select");for(const[i,a]of t.entries()){const f=r[i];for(const w of f.selectedOptions)w.selected=!1;for(const w of a.selectedOptions)f.options[w.index].selected=!0}for(const i of e.querySelectorAll('input[type="password"]'))i.value="";return new F(this.documentElement,e,this.headSnapshot)}get lang(){return this.documentElement.getAttribute("lang")}get headElement(){return this.headSnapshot.element}get rootLocation(){const e=this.getSetting("root")??"/";return P(e)}
23get cacheControlValue(){return this.getSetting("cache-control")}get isPreviewable(){return this.cacheControlValue!="no-preview"}get isCacheable(){return this.cacheControlValue!="no-cache"}get isVisitable(){return this.getSetting("visit-control")!="reload"}get prefersViewTransitions(){return this.headSnapshot.getMetaValue("view-transition")==="same-origin"}get shouldMorphPage(){return this.getSetting("refresh-method")==="morph"}get shouldPreserveScrollPosition(){return this.getSetting("refresh-scroll")==="preserve"}getSetting(e){return this.headSnapshot.getMetaValue(`turbo-${e}`)}}class fs{#e=!1;#t=Promise.resolve();renderChange(e,t){return e&&this.viewTransitionsAvailable&&!this.#e?(this.#e=!0,this.#t=this.#t.then(async()=>{await document.startViewTransition(t).finished})):this.#t=this.#t.then(t),this.#t}get viewTransitionsAvailable(){return document.startViewTransition}}const ps={action:"advance",historyChanged:!1,visitCachedSnapshot:()=>{},willRender:!0,updateHistory:!0,shouldCacheSnapshot:!0,acceptsStreamResponse:!1},he={visitStart:"visitStart",requestStart:"requestStart",requestEnd:"requestEnd",visitEnd:"visitEnd"},H={initialized:"initialized",started:"started",canceled:"canceled",failed:"failed",completed:"completed"},Q={networkFailure:0,timeoutFailure:-1,contentTypeMismatch:-2},gs={advance:"forward",restore:"back",replace:"none"};class bs{identifier=O();timingMetrics={};followedRedirect=!1;historyChanged=!1;scrolled=!1;shouldCacheSnapshot=!0;acceptsStreamResponse=!1;snapshotCached=!1;state=H.initialized;viewTransitioner=new fs;constructor(e,t,r,i={}){this.delegate=e,this.location=t,this.restorationIdentifier=r||O();const{action:a,historyChanged:f,referrer:w,snapshot:C,snapshotHTML:B,response:I,visitCachedSnapshot:z,willRender:p,updateHistory:y,shouldCacheSnapshot:v,acceptsStreamResponse:S,direction:g}={...ps,...i};this.action=a,this.historyChanged=f,this.referrer=w,this.snapshot=C,this.snapshotHTML=B,this.response=I,this.isSamePage=this.delegate.locationWithActionIsSamePage(this.location,this.action),this.isPageRefresh=this.view.isPageRefresh(this),this.visitCachedSnapshot=z,this.willRender=p,this.updateHistory=y,this.scrolled=!p,this.shouldCacheSnapshot=v,this.acceptsStreamResponse=S,this.direction=g||gs[a]}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)}get silent(){return this.isSamePage}start(){this.state==H.initialized&&(this.recordTimingMetric(he.visitStart),this.state=H.started,this.adapter.visitStarted(this),this.delegate.visitStarted(this))}cancel(){this.state==H.started&&(this.request&&this.request.cancel(),this.cancelRender(),this.state=H.canceled)}complete(){this.state==H.started&&(this.recordTimingMetric(he.visitEnd),this.adapter.visitCompleted(this),this.state=H.completed,this.followRedirect(),this.followedRedirect||this.delegate.visitCompleted(this))}fail(){this.state==H.started&&(this.state=H.failed,this.adapter.visitFailed(this),this.delegate.visitCompleted(this))}changeHistory(){if(!this.historyChanged&&this.updateHistory){const e=this.location.href===this.referrer?.href?"replace":this.action,t=qe(e);this.history.update(t,this.location,this.restorationIdentifier),this.historyChanged=!0}}issueRequest(){this.hasPreloadedResponse()?this.simulateRequest():this.shouldIssueRequest()&&!this.request&&(this.request=new K(this,M.get,this.location),this.request.perform())}simulateRequest(){this.response&&(this.startRequest(),this.recordResponse(),this.finishRequest())}startRequest(){this.recordTimingMetric(he.requestStart),this.adapter.visitRequestStarted(this)}recordResponse(e=this.response){if(this.response=e,e){const{statusCode:t}=e;Qe(t)?this.adapter.visitRequestCompleted(this):this.adapter.visitRequestFailedWithStatusCode(this,t)}}finishRequest(){this.recordTimingMetric(he.requestEnd),this.adapter.visitRequestFinished(this)}loadResponse(){if(this.response){const{statusCode:e,responseHTML:t}=this.response;this.render(async()=>{if(this.shouldCacheSnapshot&&this.cacheSnapshot(),this.view.renderPromise&&await this.view.renderPromise,Qe(e)&&t!=null){const r=F.fromHTMLString(t);await this.renderPageSnapshot(r,!1),this.adapter.visitRendered(this),this.complete()}else await this.view.renderError(F.fromHTMLString(t),this),this.adapter.visitRendered(this),this.fail()})}}getCachedSnapshot(){const e=this.view.getCachedSnapshotForLocation(this.location)||this.getPreloadedSnapshot();if(e&&(!U(this.location)||e.hasAnchor(U(this.location)))&&(this.action=="restore"||e.isPreviewable))return e}getPreloadedSnapshot(){if(this.snapshotHTML)return F.fromHTMLString(this.snapshotHTML)}hasCachedSnapshot(){return this.getCachedSnapshot()!=null}loadCachedSnapshot(){const e=this.getCachedSnapshot();if(e){const t=this.shouldIssueRequest();this.render(async()=>{this.cacheSnapshot(),this.isSamePage||this.isPageRefresh?this.adapter.visitRendered(this):(this.view.renderPromise&&await this.view.renderPromise,await this.renderPageSnapshot(e,t),this.adapter.visitRendered(this),t||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)}goToSamePageAnchor(){this.isSamePage&&this.render(async()=>{this.cacheSnapshot(),this.performScroll(),this.changeHistory(),this.adapter.visitRendered(this)})}prepareRequest(e){this.acceptsStreamResponse&&e.acceptResponseType(X.contentType)}
23requestStarted(){this.startRequest()}requestPreventedHandlingResponse(e,t){}async requestSucceededWithResponse(e,t){const r=await t.responseHTML,{redirected:i,statusCode:a}=t;r==null?this.recordResponse({statusCode:Q.contentTypeMismatch,redirected:i}):(this.redirectedToLocation=t.redirected?t.location:void 0,this.recordResponse({statusCode:a,responseHTML:r,redirected:i}))}async requestFailedWithResponse(e,t){const r=await t.responseHTML,{redirected:i,statusCode:a}=t;r==null?this.recordResponse({statusCode:Q.contentTypeMismatch,redirected:i}):this.recordResponse({statusCode:a,responseHTML:r,redirected:i})}requestErrored(e,t){this.recordResponse({statusCode:Q.networkFailure,redirected:!1})}requestFinished(){this.finishRequest()}performScroll(){!this.scrolled&&!this.view.forceReloaded&&!this.view.shouldPreserveScrollPosition(this)&&(this.action=="restore"?this.scrollToRestoredPosition()||this.scrollToAnchor()||this.view.scrollToTop():this.scrollToAnchor()||this.view.scrollToTop(),this.isSamePage&&this.delegate.visitScrolledToSamePageLocation(this.view.lastRenderedLocation,this.location),this.scrolled=!0)}scrollToRestoredPosition(){const{scrollPosition:e}=this.restorationData;if(e)return this.view.scrollToPosition(e),!0}scrollToAnchor(){const e=U(this.location);if(e!=null)return this.view.scrollToAnchor(e),!0}recordTimingMetric(e){this.timingMetrics[e]=new Date().getTime()}getTimingMetrics(){return{...this.timingMetrics}}hasPreloadedResponse(){return typeof this.response=="object"}shouldIssueRequest(){return this.isSamePage?!1:this.action=="restore"?!this.hasCachedSnapshot():this.willRender}cacheSnapshot(){this.snapshotCached||(this.view.cacheSnapshot(this.snapshot).then(e=>e&&this.visitCachedSnapshot(e)),this.snapshotCached=!0)}async render(e){this.cancelRender(),await new Promise(t=>{this.frame=document.visibilityState==="hidden"?setTimeout(()=>t(),0):requestAnimationFrame(()=>t())}),await e(),delete this.frame}async renderPageSnapshot(e,t){await this.viewTransitioner.renderChange(this.view.shouldTransitionTo(e),async()=>{await this.view.renderPage(e,t,this.willRender,this),this.performScroll()})}cancelRender(){this.frame&&(cancelAnimationFrame(this.frame),delete this.frame)}}function Qe(s){return s>=200&&s<300}class vs{progressBar=new V;constructor(e){this.session=e}visitProposedToLocation(e,t){N(e,this.navigator.rootLocation)?this.navigator.startVisit(e,t?.restorationIdentifier||O(),t):window.location.href=e.toString()}visitStarted(e){this.location=e.location,e.loadCachedSnapshot(),e.issueRequest(),e.goToSamePageAnchor()}visitRequestStarted(e){this.progressBar.setValue(0),e.hasCachedSnapshot()||e.action!="restore"?this.showVisitProgressBarAfterDelay():this.showProgressBar()}visitRequestCompleted(e){e.loadResponse()}visitRequestFailedWithStatusCode(e,t){switch(t){case Q.networkFailure:case Q.timeoutFailure:case Q.contentTypeMismatch:return this.reload({reason:"request_failed",context:{statusCode:t}});default:return e.loadResponse()}}visitRequestFinished(e){}visitCompleted(e){this.progressBar.setValue(1),this.hideVisitProgressBar()}pageInvalidated(e){this.reload(e)}visitFailed(e){this.progressBar.setValue(1),this.hideVisitProgressBar()}visitRendered(e){}linkPrefetchingIsEnabledForLocation(e){return!0}formSubmissionStarted(e){this.progressBar.setValue(0),this.showFormProgressBarAfterDelay()}formSubmissionFinished(e){this.progressBar.setValue(1),this.hideFormProgressBar()}showVisitProgressBarAfterDelay(){this.visitProgressBarTimeout=window.setTimeout(this.showProgressBar,this.session.progressBarDelay)}hideVisitProgressBar(){this.progressBar.hide(),this.visitProgressBarTimeout!=null&&(window.clearTimeout(this.visitProgressBarTimeout),delete this.visitProgressBarTimeout)}showFormProgressBarAfterDelay(){this.formProgressBarTimeout==null&&(this.formProgressBarTimeout=window.setTimeout(this.showProgressBar,this.session.progressBarDelay))}hideFormProgressBar(){this.progressBar.hide(),this.formProgressBarTimeout!=null&&(window.clearTimeout(this.formProgressBarTimeout),delete this.formProgressBarTimeout)}showProgressBar=()=>{this.progressBar.show()};reload(e){E("turbo:reload",{detail:e}),window.location.href=this.location?.toString()||window.location.href}get navigator(){return this.session.navigator}}class Ss{selector="[data-turbo-temporary]";deprecatedSelector="[data-turbo-cache=false]";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=e=>{for(const t of this.temporaryElements)t.remove()};get temporaryElements(){return[...document.querySelectorAll(this.selector),...this.temporaryElementsWithDeprecation]}get temporaryElementsWithDeprecation(){const e=document.querySelectorAll(this.deprecatedSelector);return e.length&&console.warn(`The ${this.deprecatedSelector} selector is deprecated and will be removed in a future version. Use ${this.selector} instead.`),[...e]}}class ws{constructor(e,t){this.session=e,this.element=t,this.linkInterceptor=new je(this,t),this.formSubmitObserver=new Se(this,t)}start(){this.linkInterceptor.start(),this.formSubmitObserver.start()}stop(){this.linkInterceptor.stop(),this.formSubmitObserver.stop()}shouldInterceptLinkClick(e,t,r){return this.#t(e)}linkClickIntercepted(e,t,r){const i=this.#s(e);i&&i.delegate.linkClickIntercepted(e,t,r)}willSubmitForm(e,t){return e.closest("turbo-frame")==null&&this.#e(e,t)&&this.#t(e,t)}formSubmitted(e,t){const r=this.#s(e,t);r&&r.delegate.formSubmitted(e,t)}#e(e,t){const r=ge(e,t),i=this.element.ownerDocument.querySelector('meta[name="turbo-root"]'),a=P(i?.content??"/");return this.#t(e,t)&&N(r,a)}#t(e,t){if(e instanceof HTMLFormElement?this.session.submissionIsNavigatable(e,t):this.session.elementIsNavigatable(e)){const i=this.#s(e,t);return i?i!=e.closest("turbo-frame"):!1}else return!1}#s(e,t){const r=t?.getAttribute("data-turbo-frame")||e.getAttribute("data-turbo-frame");
23if(r&&r!="_top"){const i=this.element.querySelector(`#${r}:not([disabled])`);if(i instanceof k)return i}}}class ys{location;restorationIdentifier=O();restorationData={};started=!1;pageLoaded=!1;currentIndex=0;constructor(e){this.delegate=e}start(){this.started||(addEventListener("popstate",this.onPopState,!1),addEventListener("load",this.onPageLoad,!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),removeEventListener("load",this.onPageLoad,!1),this.started=!1)}push(e,t){this.update(history.pushState,e,t)}replace(e,t){this.update(history.replaceState,e,t)}update(e,t,r=O()){e===history.pushState&&++this.currentIndex;const i={turbo:{restorationIdentifier:r,restorationIndex:this.currentIndex}};e.call(history,i,"",t.href),this.location=t,this.restorationIdentifier=r}getRestorationDataForIdentifier(e){return this.restorationData[e]||{}}updateRestorationData(e){const{restorationIdentifier:t}=this,r=this.restorationData[t];this.restorationData[t]={...r,...e}}assumeControlOfScrollRestoration(){this.previousScrollRestoration||(this.previousScrollRestoration=history.scrollRestoration??"auto",history.scrollRestoration="manual")}relinquishControlOfScrollRestoration(){this.previousScrollRestoration&&(history.scrollRestoration=this.previousScrollRestoration,delete this.previousScrollRestoration)}onPopState=e=>{if(this.shouldHandlePopState()){const{turbo:t}=e.state||{};if(t){this.location=new URL(window.location.href);const{restorationIdentifier:r,restorationIndex:i}=t;this.restorationIdentifier=r;const a=i>this.currentIndex?"forward":"back";this.delegate.historyPoppedToLocationWithRestorationIdentifierAndDirection(this.location,r,a),this.currentIndex=i}}};onPageLoad=async e=>{await vt(),this.pageLoaded=!0};shouldHandlePopState(){return this.pageIsLoaded()}pageIsLoaded(){return this.pageLoaded||document.readyState=="complete"}}class Es{started=!1;#e=null;constructor(e,t){this.delegate=e,this.eventTarget=t}start(){this.started||(this.eventTarget.readyState==="loading"?this.eventTarget.addEventListener("DOMContentLoaded",this.#t,{once:!0}):this.#t())}stop(){this.started&&(this.eventTarget.removeEventListener("mouseenter",this.#s,{capture:!0,passive:!0}),this.eventTarget.removeEventListener("mouseleave",this.#n,{capture:!0,passive:!0}),this.eventTarget.removeEventListener("turbo:before-fetch-request",this.#i,!0),this.started=!1)}#t=()=>{this.eventTarget.addEventListener("mouseenter",this.#s,{capture:!0,passive:!0}),this.eventTarget.addEventListener("mouseleave",this.#n,{capture:!0,passive:!0}),this.eventTarget.addEventListener("turbo:before-fetch-request",this.#i,!0),this.started=!0};#s=e=>{if(re("turbo-prefetch")==="false")return;const t=e.target;if(t.matches&&t.matches("a[href]:not([target^=_]):not([download])")&&this.#c(t)){const i=t,a=De(i);if(this.delegate.canPrefetchRequestToLocation(i,a)){this.#e=i;const f=new K(this,M.get,a,new URLSearchParams,t);Y.setLater(a.toString(),f,this.#r)}}};#n=e=>{e.target===this.#e&&this.#o()};#o=()=>{Y.clear(),this.#e=null};#i=e=>{if(e.target.tagName!=="FORM"&&e.detail.fetchOptions.method==="GET"){const t=Y.get(e.detail.url.toString());t&&(e.detail.fetchRequest=t),Y.clear()}};prepareRequest(e){const t=e.target;e.headers["X-Sec-Purpose"]="prefetch";const r=t.closest("turbo-frame"),i=t.getAttribute("data-turbo-frame")||r?.getAttribute("target")||r?.id;i&&i!=="_top"&&(e.headers["Turbo-Frame"]=i)}requestSucceededWithResponse(){}requestStarted(e){}requestErrored(e){}requestFinished(e){}requestPreventedHandlingResponse(e,t){}requestFailedWithResponse(e,t){}get#r(){return Number(re("turbo-prefetch-cache-time"))||_t}#c(e){return!(!e.getAttribute("href")||As(e)||Ls(e)||Rs(e)||Ts(e)||Cs(e))}}const As=s=>s.origin!==document.location.origin||!["http:","https:"].includes(s.protocol)||s.hasAttribute("target"),Ls=s=>s.pathname+s.search===document.location.pathname+document.location.search||s.href.startsWith("#"),Rs=s=>{if(s.getAttribute("data-turbo-prefetch")==="false"||s.getAttribute("data-turbo")==="false")return!0;const e=j(s,"[data-turbo-prefetch]");return!!(e&&e.getAttribute("data-turbo-prefetch")==="false")},Ts=s=>{const e=s.getAttribute("data-turbo-method");return!!(e&&e.toLowerCase()!=="get"||Ps(s)||s.hasAttribute("data-turbo-confirm")||s.hasAttribute("data-turbo-stream"))},Ps=s=>s.hasAttribute("data-remote")||s.hasAttribute("data-behavior")||s.hasAttribute("data-confirm")||s.hasAttribute("data-method"),Cs=s=>E("turbo:before-prefetch",{target:s,cancelable:!0}).defaultPrevented;class Ms{constructor(e){this.delegate=e}proposeVisit(e,t={}){this.delegate.allowsVisitingLocationWithAction(e,t.action)&&this.delegate.visitProposedToLocation(e,t)}startVisit(e,t,r={}){this.stop(),this.currentVisit=new bs(this,P(e),t,{referrer:this.location,...r}),this.currentVisit.start()}submitForm(e,t){this.stop(),this.formSubmission=new ue(this,e,t,!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(e){typeof this.adapter.formSubmissionStarted=="function"&&this.adapter.formSubmissionStarted(e)}async formSubmissionSucceededWithResponse(e,t){if(e==this.formSubmission){const r=await t.responseHTML;if(r){const i=e.isSafe;i||this.view.clearSnapshotCache();const{statusCode:a,redirected:f}=t,C={action:this.#e(e,t),shouldCacheSnapshot:i,response:{statusCode:a,responseHTML:r,redirected:f}};this.proposeVisit(t.location,C)}}}async formSubmissionFailedWithResponse(e,t){const r=await t.responseHTML;if(r){const i=F.fromHTMLString(r);t.serverError?await this.view.renderError(i,this.currentVisit):await this.view.renderPage(i,!1,!0,this.currentVisit),i.shouldPreserveScrollPosition||this.view.scrollToTop(),this.view.clearSnapshotCache()}}formSubmissionErrored(e,t){console.error(t)}formSubmissionFinished(e){typeof this.adapter.formSubmissionFinished=="function"&&this.adapter.formSubmissionFinished(e)}linkPrefetchingIsEnabledForLocation(e){return typeof this.adapter.linkPrefetchingIsEnabledForLocation=="function"?this.adapter.linkPrefetchingIsEnabledForLocation(e):!0}visitStarted(e){this.delegate.visitStarted(e)}visitCompleted(e){this.delegate.visitCompleted(e),delete this.currentVisit}locationWithActionIsSamePage(e,t){const r=U(e),i=U(this.view.lastRenderedLocation),a=t==="restore"&&typeof r>"u";return t!=="replace"&&be(e)===be(this.view.lastRenderedLocation)&&(a||r!=null&&r!==i)}visitScrolledToSamePageLocation(e,t){this.delegate.visitScrolledToSamePageLocation(e,t)}get location(){return this.history.location}get restorationIdentifier(){return this.history.restorationIdentifier}#e(e,t){const{submitter:r,formElement:i}=e;return x(r,i)||this.#t(t)}#t(e){return e.redirected&&e.location.href===this.location?.href?"replace":"advance"}}const _={initial:0,loading:1,interactive:2,complete:3};class ks{stage=_.initial;started=!1;constructor(e){this.delegate=e}start(){this.started||(this.stage==_.initial&&(this.stage=_.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:e}=this;
23e=="interactive"?this.pageIsInteractive():e=="complete"&&this.pageIsComplete()};pageIsInteractive(){this.stage==_.loading&&(this.stage=_.interactive,this.delegate.pageBecameInteractive())}pageIsComplete(){this.pageIsInteractive(),this.stage==_.interactive&&(this.stage=_.complete,this.delegate.pageLoaded())}pageWillUnload=()=>{this.delegate.pageWillUnload()};get readyState(){return document.readyState}}class Fs{started=!1;constructor(e){this.delegate=e}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(e){this.delegate.scrollPositionChanged(e)}}class Is{render({fragment:e}){Ye.preservingPermanentElements(this,qs(e),()=>{Hs(e,()=>{Bs(()=>{document.documentElement.appendChild(e)})})})}enteringBardo(e,t){t.replaceWith(e.cloneNode(!0))}leavingBardo(){}}function qs(s){const e=ze(document.documentElement),t={};for(const r of e){const{id:i}=r;for(const a of s.querySelectorAll("turbo-stream")){const f=_e(a.templateElement.content,i);f&&(t[i]=[r,f])}}return t}async function Hs(s,e){const t=`turbo-stream-autofocus-${O()}`,r=s.querySelectorAll("turbo-stream"),i=Os(r);let a=null;if(i&&(i.id?a=i.id:a=t,i.id=a),e(),await Z(),(document.activeElement==null||document.activeElement==document.body)&&a){const w=document.getElementById(a);pe(w)&&w.focus(),w&&w.id==t&&w.removeAttribute("id")}}async function Bs(s){const[e,t]=await Lt(s,()=>document.activeElement),r=e&&e.id;if(r){const i=document.getElementById(r);pe(i)&&i!=t&&i.focus()}}function Os(s){for(const e of s){const t=Be(e.templateElement.content);if(t)return t}return null}class Ns{sources=new Set;#e=!1;constructor(e){this.delegate=e}start(){this.#e||(this.#e=!0,addEventListener("turbo:before-fetch-response",this.inspectFetchResponse,!1))}stop(){this.#e&&(this.#e=!1,removeEventListener("turbo:before-fetch-response",this.inspectFetchResponse,!1))}connectStreamSource(e){this.streamSourceIsConnected(e)||(this.sources.add(e),e.addEventListener("message",this.receiveMessageEvent,!1))}disconnectStreamSource(e){this.streamSourceIsConnected(e)&&(this.sources.delete(e),e.removeEventListener("message",this.receiveMessageEvent,!1))}streamSourceIsConnected(e){return this.sources.has(e)}inspectFetchResponse=e=>{const t=Ds(e);t&&Vs(t)&&(e.preventDefault(),this.receiveMessageResponse(t))};receiveMessageEvent=e=>{this.#e&&typeof e.data=="string"&&this.receiveMessageHTML(e.data)};async receiveMessageResponse(e){const t=await e.responseHTML;t&&this.receiveMessageHTML(t)}receiveMessageHTML(e){this.delegate.receivedMessageFromStream(X.wrap(e))}}function Ds(s){const e=s.detail?.fetchResponse;if(e instanceof ne)return e}function Vs(s){return(s.contentType??"").startsWith(X.contentType)}class Ws extends we{static renderElement(e,t){const{documentElement:r,body:i}=document;r.replaceChild(t,i)}async render(){this.replaceHeadAndBody(),this.activateScriptElements()}replaceHeadAndBody(){const{documentElement:e,head:t}=document;e.replaceChild(this.newHead,t),this.renderElement(this.currentElement,this.newElement)}activateScriptElements(){for(const e of this.scriptElements){const t=e.parentNode;if(t){const r=G(e);t.replaceChild(r,e)}}}get newHead(){return this.newSnapshot.headSnapshot.element}get scriptElements(){return document.documentElement.querySelectorAll("script")}}class de extends we{static renderElement(e,t){document.body&&t instanceof HTMLBodyElement?document.body.replaceWith(t):document.documentElement.appendChild(t)}get shouldRender(){return this.newSnapshot.isVisitable&&this.trackedElementsAreIdentical}get reloadReason(){if(!this.newSnapshot.isVisitable)return{reason:"turbo_visit_control_is_reload"};if(!this.trackedElementsAreIdentical)return{reason:"tracked_element_mismatch"}}async prepareToRender(){this.#e(),await this.mergeHead()}async render(){this.willRender&&await this.replaceBody()}finishRendering(){super.finishRendering(),this.isPreview||this.focusFirstAutofocusableElement()}get currentHeadSnapshot(){return this.currentSnapshot.headSnapshot}
23get newHeadSnapshot(){return this.newSnapshot.headSnapshot}get newElement(){return this.newSnapshot.element}#e(){const{documentElement:e}=this.currentSnapshot,{lang:t}=this.newSnapshot;t?e.setAttribute("lang",t):e.removeAttribute("lang")}async mergeHead(){const e=this.mergeProvisionalElements(),t=this.copyNewHeadStylesheetElements();this.copyNewHeadScriptElements(),await e,await t,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 e=[];for(const t of this.newHeadStylesheetElements)e.push(yt(t)),document.head.appendChild(t);await Promise.all(e)}copyNewHeadScriptElements(){for(const e of this.newHeadScriptElements)document.head.appendChild(G(e))}removeUnusedDynamicStylesheetElements(){for(const e of this.unusedDynamicStylesheetElements)document.head.removeChild(e)}async mergeProvisionalElements(){const e=[...this.newHeadProvisionalElements];for(const t of this.currentHeadProvisionalElements)this.isCurrentElementInElementList(t,e)||document.head.removeChild(t);for(const t of e)document.head.appendChild(t)}isCurrentElementInElementList(e,t){for(const[r,i]of t.entries()){if(e.tagName=="TITLE"){if(i.tagName!="TITLE")continue;if(e.innerHTML==i.innerHTML)return t.splice(r,1),!0}if(i.isEqualNode(e))return t.splice(r,1),!0}return!1}removeCurrentHeadProvisionalElements(){for(const e of this.currentHeadProvisionalElements)document.head.removeChild(e)}copyNewHeadProvisionalElements(){for(const e of this.newHeadProvisionalElements)document.head.appendChild(e)}activateNewBody(){document.adoptNode(this.newElement),this.activateNewBodyScriptElements()}activateNewBodyScriptElements(){for(const e of this.newBodyScriptElements){const t=G(e);e.replaceWith(t)}}async assignNewBody(){await this.renderElement(this.currentElement,this.newElement)}get unusedDynamicStylesheetElements(){return this.oldHeadStylesheetElements.filter(e=>e.getAttribute("data-turbo-track")==="dynamic")}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 xs extends de{static renderElement(e,t){ye(e,t,{callbacks:{beforeNodeMorphed:r=>!Ge(r)}});for(const r of e.querySelectorAll("turbo-frame"))Ge(r)&&r.reload();E("turbo:morph",{detail:{currentElement:e,newElement:t}})}async preservingPermanentElements(e){return await e()}get renderMethod(){return"morph"}get shouldAutofocus(){return!1}}function Ge(s){return s instanceof k&&s.src&&s.refresh==="morph"&&!s.closest("[data-turbo-permanent]")}class Us{keys=[];snapshots={};constructor(e){this.size=e}has(e){return ie(e)in this.snapshots}get(e){if(this.has(e)){const t=this.read(e);return this.touch(e),t}}put(e,t){return this.write(e,t),this.touch(e),t}clear(){this.snapshots={}}read(e){return this.snapshots[ie(e)]}write(e,t){this.snapshots[ie(e)]=t}touch(e){const t=ie(e),r=this.keys.indexOf(t);r>-1&&this.keys.splice(r,1),this.keys.unshift(t),this.trim()}trim(){for(const e of this.keys.splice(this.size))delete this.snapshots[e]}}class _s extends $e{snapshotCache=new Us(10);lastRenderedLocation=new URL(location.href);forceReloaded=!1;shouldTransitionTo(e){return this.snapshot.prefersViewTransitions&&e.prefersViewTransitions}renderPage(e,t=!1,r=!0,i){const f=this.isPageRefresh(i)&&this.snapshot.shouldMorphPage?xs:de,w=new f(this.snapshot,e,t,r);return w.shouldRender?i?.changeHistory():this.forceReloaded=!0,this.render(w)}renderError(e,t){t?.changeHistory();const r=new Ws(this.snapshot,e,!1);return this.render(r)}clearSnapshotCache(){this.snapshotCache.clear()}async cacheSnapshot(e=this.snapshot){if(e.isCacheable){this.delegate.viewWillCacheSnapshot();const{lastRenderedLocation:t}=this;await ke();const r=e.clone();return this.snapshotCache.put(t,r),r}}getCachedSnapshotForLocation(e){return this.snapshotCache.get(e)}isPageRefresh(e){return!e||this.lastRenderedLocation.pathname===e.location.pathname&&e.action==="replace"}shouldPreserveScrollPosition(e){return this.isPageRefresh(e)&&this.snapshot.shouldPreserveScrollPosition}get snapshot(){return F.fromElement(this.element)}}class zs{selector="a[data-turbo-preload]";constructor(e,t){this.delegate=e,this.snapshotCache=t}start(){document.readyState==="loading"?document.addEventListener("DOMContentLoaded",this.#e):this.preloadOnLoadLinksForView(document.body)}stop(){document.removeEventListener("DOMContentLoaded",this.#e)}preloadOnLoadLinksForView(e){for(const t of e.querySelectorAll(this.selector))this.delegate.shouldPreloadLink(t)&&this.preloadURL(t)}async preloadURL(e){const t=new URL(e.href);if(this.snapshotCache.has(t))return;await new K(this,M.get,t,new URLSearchParams,e).perform()}prepareRequest(e){e.headers["X-Sec-Purpose"]="prefetch"}async requestSucceededWithResponse(e,t){try{const r=await t.responseHTML,i=F.fromHTMLString(r);this.snapshotCache.put(e.url,i)}catch{}}requestStarted(e){}requestErrored(e){}requestFinished(e){}requestPreventedHandlingResponse(e,t){}requestFailedWithResponse(e,t){}#e=()=>{this.preloadOnLoadLinksForView(document.body)}}class $s{constructor(e){this.session=e}clear(){this.session.clearCache()}resetCacheControl(){this.#e("")}exemptPageFromCache(){this.#e("no-cache")}exemptPageFromPreview(){this.#e("no-preview")}#e(e){At("turbo-cache-control",e)}}class js{navigator=new Ms(this);history=new ys(this);view=new _s(this,document.documentElement);adapter=new vs(this);
23pageObserver=new ks(this);cacheObserver=new Ss;linkPrefetchObserver=new Es(this,document);linkClickObserver=new Ke(this,window);formSubmitObserver=new Se(this,document);scrollObserver=new Fs(this);streamObserver=new Ns(this);formLinkClickObserver=new Xe(this,document.documentElement);frameRedirector=new ws(this,document.documentElement);streamMessageRenderer=new Is;cache=new $s(this);enabled=!0;started=!1;#e=150;constructor(e){this.recentRequests=e,this.preloader=new zs(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(e){this.adapter=e}visit(e,t={}){const r=t.frame?document.getElementById(t.frame):null;if(r instanceof k){const i=t.action||x(r);r.delegate.proposeVisitIfNavigatedWithAction(r,i),r.src=e.toString()}else this.navigator.proposeVisit(P(e),t)}refresh(e,t){const r=t&&this.recentRequests.has(t),i=e===document.baseURI;!r&&!this.navigator.currentVisit&&i&&this.visit(e,{action:"replace",shouldCacheSnapshot:!1})}connectStreamSource(e){this.streamObserver.connectStreamSource(e)}disconnectStreamSource(e){this.streamObserver.disconnectStreamSource(e)}renderStreamMessage(e){this.streamMessageRenderer.render(X.wrap(e))}clearCache(){this.view.clearSnapshotCache()}setProgressBarDelay(e){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=e}set progressBarDelay(e){T.drive.progressBarDelay=e}get progressBarDelay(){return T.drive.progressBarDelay}set drive(e){T.drive.enabled=e}get drive(){return T.drive.enabled}set formMode(e){T.forms.mode=e}get formMode(){return T.forms.mode}get location(){return this.history.location}get restorationIdentifier(){return this.history.restorationIdentifier}get pageRefreshDebouncePeriod(){return this.#e}set pageRefreshDebouncePeriod(e){this.refresh=Rt(this.debouncedRefresh.bind(this),e),this.#e=e}shouldPreloadLink(e){const t=e.hasAttribute("data-turbo-method"),r=e.hasAttribute("data-turbo-stream"),i=e.getAttribute("data-turbo-frame"),a=i=="_top"?null:document.getElementById(i)||j(e,"turbo-frame:not([disabled])");if(t||r||a instanceof k)return!1;{const f=new URL(e.href);return this.elementIsNavigatable(e)&&N(f,this.snapshot.rootLocation)}}historyPoppedToLocationWithRestorationIdentifierAndDirection(e,t,r){this.enabled?this.navigator.startVisit(e,t,{action:"restore",historyChanged:!0,direction:r}):this.adapter.pageInvalidated({reason:"turbo_disabled"})}scrollPositionChanged(e){this.history.updateRestorationData({scrollPosition:e})}willSubmitFormLinkToLocation(e,t){return this.elementIsNavigatable(e)&&N(t,this.snapshot.rootLocation)}submittedFormLinkToLocation(){}canPrefetchRequestToLocation(e,t){return this.elementIsNavigatable(e)&&N(t,this.snapshot.rootLocation)&&this.navigator.linkPrefetchingIsEnabledForLocation(t)}willFollowLinkToLocation(e,t,r){return this.elementIsNavigatable(e)&&N(t,this.snapshot.rootLocation)&&this.applicationAllowsFollowingLinkToLocation(e,t,r)}followedLinkToLocation(e,t){const r=this.getActionForLink(e),i=e.hasAttribute("data-turbo-stream");this.visit(t.href,{action:r,acceptsStreamResponse:i})}allowsVisitingLocationWithAction(e,t){return this.locationWithActionIsSamePage(e,t)||this.applicationAllowsVisitingLocation(e)}visitProposedToLocation(e,t){Ze(e),this.adapter.visitProposedToLocation(e,t)}visitStarted(e){e.acceptsStreamResponse||(te(document.documentElement),this.view.markVisitDirection(e.direction)),Ze(e.location),e.silent||this.notifyApplicationAfterVisitingLocation(e.location,e.action)}visitCompleted(e){this.view.unmarkVisitDirection(),se(document.documentElement),this.notifyApplicationAfterPageLoad(e.getTimingMetrics())}locationWithActionIsSamePage(e,t){return this.navigator.locationWithActionIsSamePage(e,t)}visitScrolledToSamePageLocation(e,t){this.notifyApplicationAfterVisitingSamePageLocation(e,t)}willSubmitForm(e,t){const r=ge(e,t);return this.submissionIsNavigatable(e,t)&&N(P(r),this.snapshot.rootLocation)}formSubmitted(e,t){this.navigator.submitForm(e,t)}pageBecameInteractive(){this.view.lastRenderedLocation=this.location,this.notifyApplicationAfterPageLoad()}
23pageLoaded(){this.history.assumeControlOfScrollRestoration()}pageWillUnload(){this.history.relinquishControlOfScrollRestoration()}receivedMessageFromStream(e){this.renderStreamMessage(e)}viewWillCacheSnapshot(){this.navigator.currentVisit?.silent||this.notifyApplicationBeforeCachingSnapshot()}allowsImmediateRender({element:e},t){const r=this.notifyApplicationBeforeRender(e,t),{defaultPrevented:i,detail:{render:a}}=r;return this.view.renderer&&a&&(this.view.renderer.renderElement=a),!i}viewRenderedSnapshot(e,t,r){this.view.lastRenderedLocation=this.history.location,this.notifyApplicationAfterRender(r)}preloadOnLoadLinksForView(e){this.preloader.preloadOnLoadLinksForView(e)}viewInvalidated(e){this.adapter.pageInvalidated(e)}frameLoaded(e){this.notifyApplicationAfterFrameLoad(e)}frameRendered(e,t){this.notifyApplicationAfterFrameRender(e,t)}applicationAllowsFollowingLinkToLocation(e,t,r){return!this.notifyApplicationAfterClickingLinkToLocation(e,t,r).defaultPrevented}applicationAllowsVisitingLocation(e){return!this.notifyApplicationBeforeVisitingLocation(e).defaultPrevented}notifyApplicationAfterClickingLinkToLocation(e,t,r){return E("turbo:click",{target:e,detail:{url:t.href,originalEvent:r},cancelable:!0})}notifyApplicationBeforeVisitingLocation(e){return E("turbo:before-visit",{detail:{url:e.href},cancelable:!0})}notifyApplicationAfterVisitingLocation(e,t){return E("turbo:visit",{detail:{url:e.href,action:t}})}notifyApplicationBeforeCachingSnapshot(){return E("turbo:before-cache")}notifyApplicationBeforeRender(e,t){return E("turbo:before-render",{detail:{newBody:e,...t},cancelable:!0})}notifyApplicationAfterRender(e){return E("turbo:render",{detail:{renderMethod:e}})}notifyApplicationAfterPageLoad(e={}){return E("turbo:load",{detail:{url:this.location.href,timing:e}})}notifyApplicationAfterVisitingSamePageLocation(e,t){dispatchEvent(new HashChangeEvent("hashchange",{oldURL:e.toString(),newURL:t.toString()}))}notifyApplicationAfterFrameLoad(e){return E("turbo:frame-load",{target:e})}notifyApplicationAfterFrameRender(e,t){return E("turbo:frame-render",{detail:{fetchResponse:e},target:t,cancelable:!0})}submissionIsNavigatable(e,t){if(T.forms.mode=="off")return!1;{const r=t?this.elementIsNavigatable(t):!0;return T.forms.mode=="optin"?r&&e.closest('[data-turbo="true"]')!=null:r&&this.elementIsNavigatable(e)}}elementIsNavigatable(e){const t=j(e,"[data-turbo]"),r=j(e,"turbo-frame");return T.drive.enabled||r?t?t.getAttribute("data-turbo")!="false":!0:t?t.getAttribute("data-turbo")=="true":!1}getActionForLink(e){return x(e)||"advance"}get snapshot(){return this.view.snapshot}}function Ze(s){Object.defineProperties(s,Ks)}const Ks={absoluteURL:{get(){return this.toString()}}},L=new js(Ve),{cache:et,navigator:tt}=L;function Ee(){L.start()}function st(s){L.registerAdapter(s)}function rt(s,e){L.visit(s,e)}function Ae(s){L.connectStreamSource(s)}function Le(s){L.disconnectStreamSource(s)}function it(s){L.renderStreamMessage(s)}function nt(){console.warn("Please replace `Turbo.clearCache()` with `Turbo.cache.clear()`. The top-level function is deprecated and will be removed in a future version of Turbo.`"),L.clearCache()}function ot(s){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.`"),T.drive.progressBarDelay=s}function at(s){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.`"),T.forms.confirm=s}function ct(s){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.`"),T.forms.mode=s}var Xs=Object.freeze({__proto__:null,navigator:tt,session:L,cache:et,PageRenderer:de,PageSnapshot:F,FrameRenderer:le,fetch:ve,config:T,start:Ee,registerAdapter:st,visit:rt,connectStreamSource:Ae,disconnectStreamSource:Le,renderStreamMessage:it,clearCache:nt,setProgressBarDelay:ot,setConfirmMethod:at,setFormMode:ct});
23class Ys extends Error{}class Js{fetchResponseLoaded=e=>Promise.resolve();#e=null;#t=()=>{};#s=!1;#n=!1;#o=new Set;#i=!1;action=null;constructor(e){this.element=e,this.view=new Zt(this,this.element),this.appearanceObserver=new Vt(this,this.element),this.formLinkClickObserver=new Xe(this,this.element),this.linkInterceptor=new je(this,this.element),this.restorationIdentifier=O(),this.formSubmitObserver=new Se(this,this.element)}connect(){this.#s||(this.#s=!0,this.loadingStyle==W.lazy?this.appearanceObserver.start():this.#r(),this.formLinkClickObserver.start(),this.linkInterceptor.start(),this.formSubmitObserver.start())}disconnect(){this.#s&&(this.#s=!1,this.appearanceObserver.stop(),this.formLinkClickObserver.stop(),this.linkInterceptor.stop(),this.formSubmitObserver.stop())}disabledChanged(){this.loadingStyle==W.eager&&this.#r()}sourceURLChanged(){this.#v("src")||(this.element.isConnected&&(this.complete=!1),(this.loadingStyle==W.eager||this.#n)&&this.#r())}sourceURLReloaded(){const{refresh:e,src:t}=this.element;return this.#i=t&&e==="morph",this.element.removeAttribute("complete"),this.element.src=null,this.element.src=t,this.element.loaded}loadingStyleChanged(){this.loadingStyle==W.lazy?this.appearanceObserver.start():(this.appearanceObserver.stop(),this.#r())}async#r(){this.enabled&&this.isActive&&!this.complete&&this.sourceURL&&(this.element.loaded=this.#d(P(this.sourceURL)),this.appearanceObserver.stop(),await this.element.loaded,this.#n=!0)}async loadResponse(e){(e.redirected||e.succeeded&&e.isHTML)&&(this.sourceURL=e.response.url);try{const t=await e.responseHTML;if(t){const r=Fe(t);F.fromDocument(r).isVisitable?await this.#c(e,r):await this.#m(e)}}finally{this.#i=!1,this.fetchResponseLoaded=()=>Promise.resolve()}}elementAppearedInViewport(e){this.proposeVisitIfNavigatedWithAction(e,x(e)),this.#r()}willSubmitFormLinkToLocation(e){return this.#l(e)}submittedFormLinkToLocation(e,t,r){const i=this.#a(e);i&&r.setAttribute("data-turbo-frame",i.id)}shouldInterceptLinkClick(e,t,r){return this.#l(e)}linkClickIntercepted(e,t){this.#u(e,t)}willSubmitForm(e,t){return e.closest("turbo-frame")==this.element&&this.#l(e,t)}formSubmitted(e,t){this.formSubmission&&this.formSubmission.stop(),this.formSubmission=new ue(this,e,t);const{fetchRequest:r}=this.formSubmission;this.prepareRequest(r),this.formSubmission.start()}prepareRequest(e){e.headers["Turbo-Frame"]=this.id,this.currentNavigationElement?.hasAttribute("data-turbo-stream")&&e.acceptResponseType(X.contentType)}requestStarted(e){te(this.element)}requestPreventedHandlingResponse(e,t){this.#t()}async requestSucceededWithResponse(e,t){await this.loadResponse(t),this.#t()}async requestFailedWithResponse(e,t){await this.loadResponse(t),this.#t()}requestErrored(e,t){console.error(t),this.#t()}requestFinished(e){se(this.element)}formSubmissionStarted({formElement:e}){te(e,this.#a(e))}formSubmissionSucceededWithResponse(e,t){const r=this.#a(e.formElement,e.submitter);r.delegate.proposeVisitIfNavigatedWithAction(r,x(e.submitter,e.formElement,r)),r.delegate.loadResponse(t),e.isSafe||L.clearCache()}formSubmissionFailedWithResponse(e,t){this.element.delegate.loadResponse(t),L.clearCache()}formSubmissionErrored(e,t){console.error(t)}formSubmissionFinished({formElement:e}){se(e,this.#a(e))}allowsImmediateRender({element:e},t){const r=E("turbo:before-frame-render",{target:this.element,detail:{newFrame:e,...t},cancelable:!0}),{defaultPrevented:i,detail:{render:a}}=r;return this.view.renderer&&a&&(this.view.renderer.renderElement=a),!i}viewRenderedSnapshot(e,t,r){}preloadOnLoadLinksForView(e){L.preloadOnLoadLinksForView(e)}viewInvalidated(){}willRenderFrame(e,t){this.previousFrameElement=e.cloneNode(!0)}visitCachedSnapshot=({element:e})=>{const t=e.querySelector("#"+this.element.id);t&&this.previousFrameElement&&t.replaceChildren(...this.previousFrameElement.children),delete this.previousFrameElement};async#c(e,t){const r=await this.extractForeignFrameElement(t.body),i=this.#i?ns:le;if(r){const a=new ce(r),f=new i(this,this.view.snapshot,a,!1,!1);this.view.renderPromise&&await this.view.renderPromise,this.changeHistory(),await this.view.render(f),this.complete=!0,L.frameRendered(e,this.element),L.frameLoaded(this.element),await this.fetchResponseLoaded(e)}else this.#f(e)&&this.#p(e)}async#d(e){const t=new K(this,M.get,e,new URLSearchParams,this.element);return this.#e?.cancel(),this.#e=t,new Promise(r=>{this.#t=()=>{this.#t=()=>{},this.#e=null,r()},t.perform()})}#u(e,t,r){const i=this.#a(e,r);i.delegate.proposeVisitIfNavigatedWithAction(i,x(r,e,i)),this.#w(e,()=>{i.src=t})}proposeVisitIfNavigatedWithAction(e,t=null){if(this.action=t,this.action){const r=F.fromElement(e).clone(),{visitCachedSnapshot:i}=e.delegate;e.delegate.fetchResponseLoaded=async a=>{if(e.src){const{statusCode:f,redirected:w}=a,C=await a.responseHTML,I={response:{statusCode:f,redirected:w,responseHTML:C},visitCachedSnapshot:i,willRender:!1,updateHistory:!1,restorationIdentifier:this.restorationIdentifier,snapshot:r};this.action&&(I.action=this.action),L.visit(e.src,I)}}}}changeHistory(){if(this.action){const e=qe(this.action);L.history.update(e,P(this.element.src||""),this.restorationIdentifier)}}
23async#m(e){console.warn(`The response (${e.statusCode}) from <turbo-frame id="${this.element.id}"> is performing a full page visit due to turbo-visit-control.`),await this.#h(e.response)}#f(e){this.element.setAttribute("complete","");const t=e.response,r=async(a,f)=>{a instanceof Response?this.#h(a):L.visit(a,f)};return!E("turbo:frame-missing",{target:this.element,detail:{response:t,visit:r},cancelable:!0}).defaultPrevented}#p(e){this.view.missing(),this.#g(e)}#g(e){const t=`The response (${e.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 Ys(t)}async#h(e){const t=new ne(e),r=await t.responseHTML,{location:i,redirected:a,statusCode:f}=t;return L.visit(i,{response:{redirected:a,statusCode:f,responseHTML:r}})}#a(e,t){const r=ee("data-turbo-frame",t,e)||this.element.getAttribute("target");return lt(r)??this.element}async extractForeignFrameElement(e){let t;const r=CSS.escape(this.id);try{if(t=ht(e.querySelector(`turbo-frame#${r}`),this.sourceURL),t)return t;if(t=ht(e.querySelector(`turbo-frame[src][recurse~=${r}]`),this.sourceURL),t)return await t.loaded,await this.extractForeignFrameElement(t)}catch(i){return console.error(i),new k}return null}#b(e,t){const r=ge(e,t);return N(P(r),this.rootLocation)}#l(e,t){const r=ee("data-turbo-frame",t,e)||this.element.getAttribute("target");if(e instanceof HTMLFormElement&&!this.#b(e,t)||!this.enabled||r=="_top")return!1;if(r){const i=lt(r);if(i)return!i.disabled}return!(!L.elementIsNavigatable(e)||t&&!L.elementIsNavigatable(t))}get id(){return this.element.id}get enabled(){return!this.element.disabled}get sourceURL(){if(this.element.src)return this.element.src}set sourceURL(e){this.#S("src",()=>{this.element.src=e??null})}get loadingStyle(){return this.element.loading}get isLoading(){return this.formSubmission!==void 0||this.#t()!==void 0}get complete(){return this.element.hasAttribute("complete")}set complete(e){e?this.element.setAttribute("complete",""):this.element.removeAttribute("complete")}get isActive(){return this.element.isActive&&this.#s}get rootLocation(){const t=this.element.ownerDocument.querySelector('meta[name="turbo-root"]')?.content??"/";return P(t)}#v(e){return this.#o.has(e)}#S(e,t){this.#o.add(e),t(),this.#o.delete(e)}#w(e,t){this.currentNavigationElement=e,t(),delete this.currentNavigationElement}}function lt(s){if(s!=null){const e=document.getElementById(s);if(e instanceof k)return e}}function ht(s,e){if(s){const t=s.getAttribute("src");if(t!=null&&e!=null&&Ft(t,e))throw new Error(`Matching <turbo-frame id="${s.id}"> element has a source URL which references itself`);if(s.ownerDocument!==document&&(s=document.importNode(s,!0)),s instanceof k)return s.connectedCallback(),s.disconnectedCallback(),s}}const Re={after(){this.targetElements.forEach(s=>s.parentElement?.insertBefore(this.templateContent,s.nextSibling))},append(){this.removeDuplicateTargetChildren(),this.targetElements.forEach(s=>s.append(this.templateContent))},before(){this.targetElements.forEach(s=>s.parentElement?.insertBefore(this.templateContent,s))},prepend(){this.removeDuplicateTargetChildren(),this.targetElements.forEach(s=>s.prepend(this.templateContent))},remove(){this.targetElements.forEach(s=>s.remove())},replace(){const s=this.getAttribute("method");this.targetElements.forEach(e=>{s==="morph"?ye(e,this.templateContent):e.replaceWith(this.templateContent)})},update(){const s=this.getAttribute("method");this.targetElements.forEach(e=>{s==="morph"?Je(e,this.templateContent):(e.innerHTML="",e.append(this.templateContent))})},refresh(){L.refresh(this.baseURI,this.requestId)}};class me extends HTMLElement{static async renderElement(e){await e.performAction()}async connectedCallback(){try{await this.render()}catch(e){console.error(e)}finally{this.disconnect()}}async render(){return this.renderPromise??=(async()=>{const e=this.beforeRenderEvent;this.dispatchEvent(e)&&(await Z(),await e.detail.render(this))})()}disconnect(){try{this.remove()}catch{}}
23removeDuplicateTargetChildren(){this.duplicateChildren.forEach(e=>e.remove())}get duplicateChildren(){const e=this.targetElements.flatMap(r=>[...r.children]).filter(r=>!!r.getAttribute("id")),t=[...this.templateContent?.children||[]].filter(r=>!!r.getAttribute("id")).map(r=>r.getAttribute("id"));return e.filter(r=>t.includes(r.getAttribute("id")))}get performAction(){if(this.action){const e=Re[this.action];if(e)return e;this.#e("unknown action")}this.#e("action attribute is missing")}get targetElements(){if(this.target)return this.targetElementsById;if(this.targets)return this.targetElementsByQuery;this.#e("target or targets attribute is missing")}get templateContent(){return this.templateElement.content.cloneNode(!0)}get templateElement(){if(this.firstElementChild===null){const e=this.ownerDocument.createElement("template");return this.appendChild(e),e}else if(this.firstElementChild instanceof HTMLTemplateElement)return this.firstElementChild;this.#e("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")}#e(e){throw new Error(`${this.description}: ${e}`)}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:me.renderElement}})}get targetElementsById(){const e=this.ownerDocument?.getElementById(this.target);return e!==null?[e]:[]}get targetElementsByQuery(){const e=this.ownerDocument?.querySelectorAll(this.targets);return e.length!==0?Array.prototype.slice.call(e):[]}}class dt extends HTMLElement{streamSource=null;connectedCallback(){this.streamSource=this.src.match(/^ws{1,2}:/)?new WebSocket(this.src):new EventSource(this.src),Ae(this.streamSource)}disconnectedCallback(){this.streamSource&&(this.streamSource.close(),Le(this.streamSource))}get src(){return this.getAttribute("src")||""}}k.delegateConstructor=Js,customElements.get("turbo-frame")===void 0&&customElements.define("turbo-frame",k),customElements.get("turbo-stream")===void 0&&customElements.define("turbo-stream",me),customElements.get("turbo-stream-source")===void 0&&customElements.define("turbo-stream-source",dt),(()=>{let s=document.currentScript;if(s&&!s.hasAttribute("data-turbo-suppress-warning"))for(s=s.parentElement;s;){if(s==document.body)return console.warn(Ie` 24 You are loading Turbo from a <script> element inside the <body> element. This is probably not what you meant to do! 25 26 Load your applicationâs JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change. 27 28 For more information, see: https://turbo.hotwired.dev/handbook/building#working-with-script-elements 29 30 ââ 31 Suppress this warning by adding a "data-turbo-suppress-warning" attribute to: %s 32 `,s.outerHTML);s=s.parentElement}})(),window.Turbo={...Xs,StreamActions:Re},Ee();export{D as FetchEnctype,M as FetchMethod,K as FetchRequest,ne as FetchResponse,k as FrameElement,W as FrameLoadingStyle,le as FrameRenderer,de as PageRenderer,F as PageSnapshot,Re as StreamActions,me as StreamElement,dt as StreamSourceElement,et as cache,nt as clearCache,T as config,Ae as connectStreamSource,Le as disconnectStreamSource,ve as fetch,We as fetchEnctypeFromString,oe as fetchMethodFromString,ae as isSafe,tt as navigator,st as registerAdapter,it as renderStreamMessage,L as session,at as setConfirmMethod,ct as setFormMode,ot as setProgressBarDelay,Ee as start,rt as visit};
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.