hotsheet 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7673a487cd90b7b75909e47e0b54d3f7eaa2700a090c57ca312c2705fe131636
4
- data.tar.gz: 5332b3053203b994aa6f1b462e2bfac52e6d91692efa345e0edb2d216dfbdfeb
3
+ metadata.gz: fec7d8829b931fdbe26880b40c2bbe6ee973f3cdc0ae7f28b28c59f32794e990
4
+ data.tar.gz: 94f26776a76faee5b0b0b6d1af1aaadeda1876271a356960e7878de3c96e870f
5
5
  SHA512:
6
- metadata.gz: f88b1af1c03151a85a1a73a0be965b84ad14d8d5e69884747df14bb681e0ba5ce32f192ef83041d69e032b5bc1c397ffbaab97ad0d5d48ee1226f196a2ee252b
7
- data.tar.gz: 91cb18100cecf60b7ef91bda862f7bc5d598230e0e27c45b9efc6308d0e4f2a876dbb3fec4f919060e4db90f50023b8beb01aff1555ca14620daec0b2ff3d20c
6
+ metadata.gz: a3733c6554d2c1555598129d060c1df88ed71bc738387db3d6d78a4251a56684b32769a302a0c04cbb37db12c2ce43c9ef635b8703de15eb77a231beba1c3e70
7
+ data.tar.gz: 861a98fd4dd53aaea05de901385170640f77d60bda9ba527f4ddd8256fb5a1978e615847d0a9c2b8a4fb5cea07c04f282845156508eb38dfa52e77f80d3affcd
data/README.md CHANGED
@@ -41,6 +41,14 @@ Hotsheet.configure do
41
41
 
42
42
  # Leave the block out to include all database columns.
43
43
  sheet :Post
44
+
45
+ # Pass a `scope` (a lambda evaluated on the model) to restrict the rows.
46
+ # When the same model is used more than once, give each sheet a unique
47
+ # name with `as:`; it is used in the URL and the navigation.
48
+ sheet :User, scope: -> { where(admin: true) }, as: :admins do
49
+ column :name
50
+ column :email
51
+ end
44
52
  end
45
53
  ```
46
54
 
@@ -1,9 +1,9 @@
1
1
  /*!
2
2
  Turbo 8.0.23
3
3
  Copyright © 2026 37signals LLC
4
- */var a={eager:"eager",lazy:"lazy"};class x extends HTMLElement{static delegateConstructor=void 0;loaded=Promise.resolve();static get observedAttributes(){return["disabled","loading","src"]}constructor(){super();this.delegate=new x.delegateConstructor(this)}connectedCallback(){this.delegate.connect()}disconnectedCallback(){this.delegate.disconnect()}reload(){return this.delegate.sourceURLReloaded()}attributeChangedCallback(H){if(H=="loading")this.delegate.loadingStyleChanged();else if(H=="src")this.delegate.sourceURLChanged();else if(H=="disabled")this.delegate.disabledChanged()}get src(){return this.getAttribute("src")}set src(H){if(H)this.setAttribute("src",H);else this.removeAttribute("src")}get refresh(){return this.getAttribute("refresh")}set refresh(H){if(H)this.setAttribute("refresh",H);else this.removeAttribute("refresh")}get shouldReloadWithMorph(){return this.src&&this.refresh==="morph"}get loading(){return xJ(this.getAttribute("loading")||"")}set loading(H){if(H)this.setAttribute("loading",H);else this.removeAttribute("loading")}get disabled(){return this.hasAttribute("disabled")}set disabled(H){if(H)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get autoscroll(){return this.hasAttribute("autoscroll")}set autoscroll(H){if(H)this.setAttribute("autoscroll","");else 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 xJ(H){switch(H.toLowerCase()){case"lazy":return a.lazy;default:return a.eager}}var hJ={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 JH(H){if(H.getAttribute("data-turbo-eval")=="false")return H;else{let J=document.createElement("script"),Q=$1();if(Q)J.nonce=Q;return J.textContent=H.textContent,J.async=!1,gJ(J,H),J}}function gJ(H,J){for(let{name:Q,value:X}of J.attributes)H.setAttribute(Q,X)}function yJ(H){let J=document.createElement("template");return J.innerHTML=H,J.content}function w(H,{target:J,cancelable:Q,detail:X}={}){let Y=new CustomEvent(H,{cancelable:Q,bubbles:!0,composed:!0,detail:X});if(J&&J.isConnected)J.dispatchEvent(Y);else document.documentElement.dispatchEvent(Y);return Y}function rH(H){H.preventDefault(),H.stopImmediatePropagation()}function e(){if(document.visibilityState==="hidden")return Q1();else return J1()}function J1(){return new Promise((H)=>requestAnimationFrame(()=>H()))}function Q1(){return new Promise((H)=>setTimeout(()=>H(),0))}function X1(H=""){return new DOMParser().parseFromString(H,"text/html")}function Y1(H,...J){let Q=bJ(H,J).replace(/^\n/,"").split(`
5
- `),X=Q[0].match(/^\s+/),Y=X?X[0].length:0;return Q.map((Z)=>Z.slice(Y)).join(`
6
- `)}function bJ(H,J){return H.reduce((Q,X,Y)=>{let Z=J[Y]==null?"":J[Y];return Q+X+Z},"")}function d(){return Array.from({length:36}).map((H,J)=>{if(J==8||J==13||J==18||J==23)return"-";else if(J==14)return"4";else if(J==19)return(Math.floor(Math.random()*4)+8).toString(16);else return Math.floor(Math.random()*16).toString(16)}).join("")}function WH(H,...J){for(let Q of J.map((X)=>X?.getAttribute(H)))if(typeof Q=="string")return Q;return null}function kJ(H,...J){return J.some((Q)=>Q&&Q.hasAttribute(H))}function AH(...H){for(let J of H){if(J.localName=="turbo-frame")J.setAttribute("busy","");J.setAttribute("aria-busy","true")}}function qH(...H){for(let J of H){if(J.localName=="turbo-frame")J.removeAttribute("busy");J.removeAttribute("aria-busy")}}function NJ(H,J=2000){return new Promise((Q)=>{let X=()=>{H.removeEventListener("error",X),H.removeEventListener("load",X),Q()};H.addEventListener("load",X,{once:!0}),H.addEventListener("error",X,{once:!0}),setTimeout(Q,J)})}function Z1(H){switch(H){case"replace":return history.replaceState;case"advance":case"restore":return history.pushState}}function fJ(H){return H=="advance"||H=="replace"||H=="restore"}function i(...H){let J=WH("data-turbo-action",...H);return fJ(J)?J:null}function SH(H){return document.querySelector(`meta[name="${H}"]`)}function UH(H){let J=SH(H);return J&&J.content}function $1(){let H=SH("csp-nonce");if(H){let{nonce:J,content:Q}=H;return J==""?Q:J}}function vJ(H,J){let Q=SH(H);if(!Q)Q=document.createElement("meta"),Q.setAttribute("name",H),document.head.appendChild(Q);return Q.setAttribute("content",J),Q}function l(H,J){if(H instanceof Element)return H.closest(J)||l(H.assignedSlot||H.getRootNode()?.host,J)}function CH(H){return!!H&&H.closest("[inert], :disabled, [hidden], details:not([open]), dialog:not([open])")==null&&typeof H.focus=="function"}function G1(H){return Array.from(H.querySelectorAll("[autofocus]")).find(CH)}async function pJ(H,J){let Q=J();H(),await J1();let X=J();return[Q,X]}function W1(H){if(H==="_blank")return!1;else if(H){for(let J of document.getElementsByName(H))if(J instanceof HTMLIFrameElement)return!1;return!0}else return!0}function A1(H){let J=l(H,"a[href], a[xlink\\:href]");if(!J)return null;if(J.href.startsWith("#"))return null;if(J.hasAttribute("download"))return null;let Q=J.getAttribute("target");if(Q&&Q!=="_self")return null;return J}function dJ(H,J){let Q=null;return(...X)=>{let Y=()=>H.apply(this,X);clearTimeout(Q),Q=setTimeout(Y,J)}}var cJ={"aria-disabled":{beforeSubmit:(H)=>{H.setAttribute("aria-disabled","true"),H.addEventListener("click",rH)},afterSubmit:(H)=>{H.removeAttribute("aria-disabled"),H.removeEventListener("click",rH)}},disabled:{beforeSubmit:(H)=>H.disabled=!0,afterSubmit:(H)=>H.disabled=!1}};class q1{#H=null;constructor(H){Object.assign(this,H)}get submitter(){return this.#H}set submitter(H){this.#H=cJ[H]||H}}var uJ=new q1({mode:"on",submitter:"disabled"}),V={drive:hJ,forms:uJ};function T(H){return new URL(H.toString(),document.baseURI)}function HH(H){let J;if(H.hash)return H.hash.slice(1);else if(J=H.href.match(/#(.*)$/))return J[1]}function wH(H,J){let Q=J?.getAttribute("formaction")||H.getAttribute("action")||H.action;return T(Q)}function sJ(H){return(aJ(H).match(/\.[^.]*$/)||[])[0]||""}function iJ(H,J){let Q=lH(J.origin+J.pathname);return lH(H.href)===Q||H.href.startsWith(Q)}function p(H,J){return iJ(H,J)&&!V.drive.unvisitableExtensions.has(sJ(H))}function U1(H){return T(H.getAttribute("href")||"")}function mJ(H){let J=HH(H);return J!=null?H.href.slice(0,-(J.length+1)):H.href}function GH(H){return mJ(H)}function z1(H,J){return T(H).href==T(J).href}function oJ(H){return H.pathname.split("/").slice(1)}function aJ(H){return oJ(H).slice(-1)[0]}function lH(H){return H.endsWith("/")?H:H+"/"}class zH{constructor(H){this.response=H}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 T(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(){if(this.isHTML)return this.response.clone().text();else return Promise.resolve(void 0)}header(H){return this.response.headers.get(H)}}class K1 extends Set{constructor(H){super();this.maxSize=H}add(H){if(this.size>=this.maxSize){let Q=this.values().next().value;this.delete(Q)}super.add(H)}}var _1=new K1(20);function B1(H,J={}){let Q=new Headers(J.headers||{}),X=d();return _1.add(X),Q.append("X-Turbo-Request-Id",X),window.fetch(H,{...J,headers:Q})}function EH(H){switch(H.toLowerCase()){case"get":return O.get;case"post":return O.post;case"put":return O.put;case"patch":return O.patch;case"delete":return O.delete}}var O={get:"get",post:"post",put:"put",patch:"patch",delete:"delete"};function rJ(H){switch(H.toLowerCase()){case s.multipart:return s.multipart;case s.plain:return s.plain;default:return s.urlEncoded}}var s={urlEncoded:"application/x-www-form-urlencoded",multipart:"multipart/form-data",plain:"text/plain"};class t{abortController=new AbortController;#H=(H)=>{};constructor(H,J,Q,X=new URLSearchParams,Y=null,Z=s.urlEncoded){let[A,B]=nH(T(Q),J,X,Z);this.delegate=H,this.url=A,this.target=Y,this.fetchOptions={credentials:"same-origin",redirect:"follow",method:J.toUpperCase(),headers:{...this.defaultHeaders},body:B,signal:this.abortSignal,referrer:this.delegate.referrer?.href},this.enctype=Z}get method(){return this.fetchOptions.method}set method(H){let J=this.isSafe?this.url.searchParams:this.fetchOptions.body||new FormData,Q=EH(H)||O.get;this.url.search="";let[X,Y]=nH(this.url,Q,J,this.enctype);this.url=X,this.fetchOptions.body=Y,this.fetchOptions.method=Q.toUpperCase()}get headers(){return this.fetchOptions.headers}set headers(H){this.fetchOptions.headers=H}get body(){if(this.isSafe)return this.url.searchParams;else return this.fetchOptions.body}set body(H){this.fetchOptions.body=H}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(){let{fetchOptions:H}=this;this.delegate.prepareRequest(this);let J=await this.#J(H);try{if(this.delegate.requestStarted(this),J.detail.fetchRequest)this.response=J.detail.fetchRequest.response;else this.response=B1(this.url.href,H);let Q=await this.response;return await this.receive(Q)}catch(Q){if(Q.name!=="AbortError"){if(this.#Q(Q))this.delegate.requestErrored(this,Q);throw Q}}finally{this.delegate.requestFinished(this)}}async receive(H){let J=new zH(H);if(w("turbo:before-fetch-response",{cancelable:!0,detail:{fetchResponse:J},target:this.target}).defaultPrevented)this.delegate.requestPreventedHandlingResponse(this,J);else if(J.succeeded)this.delegate.requestSucceededWithResponse(this,J);else this.delegate.requestFailedWithResponse(this,J);return J}get defaultHeaders(){return{Accept:"text/html, application/xhtml+xml"}}get isSafe(){return RH(this.method)}get abortSignal(){return this.abortController.signal}acceptResponseType(H){this.headers.Accept=[H,this.headers.Accept].join(", ")}async#J(H){let J=new Promise((X)=>this.#H=X),Q=w("turbo:before-fetch-request",{cancelable:!0,detail:{fetchOptions:H,url:this.url,resume:this.#H},target:this.target});if(this.url=Q.detail.url,Q.defaultPrevented)await J;return Q}#Q(H){return!w("turbo:fetch-request-error",{target:this.target,cancelable:!0,detail:{request:this,error:H}}).defaultPrevented}}function RH(H){return EH(H)==O.get}function nH(H,J,Q,X){let Y=Array.from(Q).length>0?new URLSearchParams(I1(Q)):H.searchParams;if(RH(J))return[lJ(H,Y),null];else if(X==s.urlEncoded)return[H,Y];else return[H,Q]}function I1(H){let J=[];for(let[Q,X]of H)if(X instanceof File)continue;else J.push([Q,X]);return J}function lJ(H,J){let Q=new URLSearchParams(I1(J));return H.search=Q.toString(),H}class F1{started=!1;constructor(H,J){this.delegate=H,this.element=J,this.intersectionObserver=new IntersectionObserver(this.intersect)}start(){if(!this.started)this.started=!0,this.intersectionObserver.observe(this.element)}stop(){if(this.started)this.started=!1,this.intersectionObserver.unobserve(this.element)}intersect=(H)=>{if(H.slice(-1)[0]?.isIntersecting)this.delegate.elementAppearedInViewport(this.element)}}class m{static contentType="text/vnd.turbo-stream.html";static wrap(H){if(typeof H=="string")return new this(yJ(H));else return H}constructor(H){this.fragment=nJ(H)}}function nJ(H){for(let J of H.querySelectorAll("turbo-stream")){let Q=document.importNode(J,!0);for(let X of Q.templateElement.content.querySelectorAll("script"))X.replaceWith(JH(X));J.replaceWith(Q)}return H}var tJ=(H)=>H;class VH{keys=[];entries={};#H;constructor(H,J=tJ){this.size=H,this.#H=J}has(H){return this.#H(H)in this.entries}get(H){if(this.has(H)){let J=this.read(H);return this.touch(H),J}}put(H,J){return this.write(H,J),this.touch(H),J}clear(){for(let H of Object.keys(this.entries))this.evict(H)}read(H){return this.entries[this.#H(H)]}write(H,J){this.entries[this.#H(H)]=J}touch(H){H=this.#H(H);let J=this.keys.indexOf(H);if(J>-1)this.keys.splice(J,1);this.keys.unshift(H),this.trim()}trim(){for(let H of this.keys.splice(this.size))this.evict(H)}evict(H){delete this.entries[H]}}var eJ=100;class M1 extends VH{#H=null;#J={};constructor(H=1,J=eJ){super(H,GH);this.prefetchDelay=J}putLater(H,J,Q){this.#H=setTimeout(()=>{J.perform(),this.put(H,J,Q),this.#H=null},this.prefetchDelay)}put(H,J,Q=P1){super.put(H,J),this.#J[GH(H)]=new Date(new Date().getTime()+Q)}clear(){if(super.clear(),this.#H)clearTimeout(this.#H)}evict(H){super.evict(H),delete this.#J[H]}has(H){if(super.has(H)){let J=this.#J[GH(H)];return J&&J>Date.now()}else return!1}}var P1=1e4,r=new M1,o={initialized:"initialized",requesting:"requesting",waiting:"waiting",receiving:"receiving",stopping:"stopping",stopped:"stopped"};class KH{state=o.initialized;static confirmMethod(H){return Promise.resolve(confirm(H))}constructor(H,J,Q,X=!1){let Y=ZQ(J,Q),Z=YQ(XQ(J,Q),Y),A=HQ(J,Q),B=$Q(J,Q);this.delegate=H,this.formElement=J,this.submitter=Q,this.fetchRequest=new t(this,Y,Z,A,J,B),this.mustRedirect=X}get method(){return this.fetchRequest.method}set method(H){this.fetchRequest.method=H}get action(){return this.fetchRequest.url.toString()}set action(H){this.fetchRequest.url=T(H)}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(){let{initialized:H,requesting:J}=o,Q=WH("data-turbo-confirm",this.submitter,this.formElement);if(typeof Q==="string"){if(!await(typeof V.forms.confirm==="function"?V.forms.confirm:KH.confirmMethod)(Q,this.formElement,this.submitter))return}if(this.state==H)return this.state=J,this.fetchRequest.perform()}stop(){let{stopping:H,stopped:J}=o;if(this.state!=H&&this.state!=J)return this.state=H,this.fetchRequest.cancel(),!0}prepareRequest(H){if(!H.isSafe){let J=JQ(UH("csrf-param"))||UH("csrf-token");if(J)H.headers["X-CSRF-Token"]=J}if(this.requestAcceptsTurboStreamResponse(H))H.acceptResponseType(m.contentType)}requestStarted(H){if(this.state=o.waiting,this.submitter)V.forms.submitter.beforeSubmit(this.submitter);this.setSubmitsWith(),AH(this.formElement),w("turbo:submit-start",{target:this.formElement,detail:{formSubmission:this}}),this.delegate.formSubmissionStarted(this)}requestPreventedHandlingResponse(H,J){r.clear(),this.result={success:J.succeeded,fetchResponse:J}}requestSucceededWithResponse(H,J){if(J.clientError||J.serverError){this.delegate.formSubmissionFailedWithResponse(this,J);return}if(r.clear(),this.requestMustRedirect(H)&&QQ(J)){let Q=Error("Form responses must redirect to another location");this.delegate.formSubmissionErrored(this,Q)}else this.state=o.receiving,this.result={success:!0,fetchResponse:J},this.delegate.formSubmissionSucceededWithResponse(this,J)}requestFailedWithResponse(H,J){this.result={success:!1,fetchResponse:J},this.delegate.formSubmissionFailedWithResponse(this,J)}requestErrored(H,J){this.result={success:!1,error:J},this.delegate.formSubmissionErrored(this,J)}requestFinished(H){if(this.state=o.stopped,this.submitter)V.forms.submitter.afterSubmit(this.submitter);this.resetSubmitterText(),qH(this.formElement),w("turbo:submit-end",{target:this.formElement,detail:{formSubmission:this,...this.result}}),this.delegate.formSubmissionFinished(this)}setSubmitsWith(){if(!this.submitter||!this.submitsWith)return;if(this.submitter.matches("button"))this.originalSubmitText=this.submitter.innerHTML,this.submitter.innerHTML=this.submitsWith;else if(this.submitter.matches("input")){let H=this.submitter;this.originalSubmitText=H.value,H.value=this.submitsWith}}resetSubmitterText(){if(!this.submitter||!this.originalSubmitText)return;if(this.submitter.matches("button"))this.submitter.innerHTML=this.originalSubmitText;else if(this.submitter.matches("input")){let H=this.submitter;H.value=this.originalSubmitText}}requestMustRedirect(H){return!H.isSafe&&this.mustRedirect}requestAcceptsTurboStreamResponse(H){return!H.isSafe||kJ("data-turbo-stream",this.submitter,this.formElement)}get submitsWith(){return this.submitter?.getAttribute("data-turbo-submits-with")}}function HQ(H,J){let Q=new FormData(H),X=J?.getAttribute("name"),Y=J?.getAttribute("value");if(X)Q.append(X,Y||"");return Q}function JQ(H){if(H!=null){let Q=(document.cookie?document.cookie.split("; "):[]).find((X)=>X.startsWith(H));if(Q){let X=Q.split("=").slice(1).join("=");return X?decodeURIComponent(X):void 0}}}function QQ(H){return H.statusCode==200&&!H.redirected}function XQ(H,J){let Q=typeof H.action==="string"?H.action:null;if(J?.hasAttribute("formaction"))return J.getAttribute("formaction")||"";else return H.getAttribute("action")||Q||""}function YQ(H,J){let Q=T(H);if(RH(J))Q.search="";return Q}function ZQ(H,J){let Q=J?.getAttribute("formmethod")||H.getAttribute("method")||"";return EH(Q.toLowerCase())||O.get}function $Q(H,J){return rJ(J?.getAttribute("formenctype")||H.enctype)}class QH{constructor(H){this.element=H}get activeElement(){return this.element.ownerDocument.activeElement}get children(){return[...this.element.children]}hasAnchor(H){return this.getElementForAnchor(H)!=null}getElementForAnchor(H){return H?this.element.querySelector(`[id='${H}'], a[name='${H}']`):null}get isConnected(){return this.element.isConnected}get firstAutofocusableElement(){return G1(this.element)}get permanentElements(){return j1(this.element)}getPermanentElementById(H){return L1(this.element,H)}getPermanentElementMapForSnapshot(H){let J={};for(let Q of this.permanentElements){let{id:X}=Q,Y=H.getPermanentElementById(X);if(Y)J[X]=[Q,Y]}return J}}function L1(H,J){return H.querySelector(`#${J}[data-turbo-permanent]`)}function j1(H){return H.querySelectorAll("[id][data-turbo-permanent]")}class _H{started=!1;constructor(H,J){this.delegate=H,this.eventTarget=J}start(){if(!this.started)this.eventTarget.addEventListener("submit",this.submitCaptured,!0),this.started=!0}stop(){if(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=(H)=>{if(!H.defaultPrevented){let J=H.target instanceof HTMLFormElement?H.target:void 0,Q=H.submitter||void 0;if(J&&GQ(J,Q)&&WQ(J,Q)&&this.delegate.willSubmitForm(J,Q))H.preventDefault(),H.stopImmediatePropagation(),this.delegate.formSubmitted(J,Q)}}}function GQ(H,J){return(J?.getAttribute("formmethod")||H.getAttribute("method"))!="dialog"}function WQ(H,J){let Q=J?.getAttribute("formtarget")||H.getAttribute("target");return W1(Q)}class TH{#H=(H)=>{};#J=(H)=>{};constructor(H,J){this.delegate=H,this.element=J}scrollToAnchor(H){let J=this.snapshot.getElementForAnchor(H);if(J)this.focusElement(J),this.scrollToElement(J);else this.scrollToPosition({x:0,y:0})}scrollToAnchorFromLocation(H){this.scrollToAnchor(HH(H))}scrollToElement(H){H.scrollIntoView()}focusElement(H){if(H instanceof HTMLElement)if(H.hasAttribute("tabindex"))H.focus();else H.setAttribute("tabindex","-1"),H.focus(),H.removeAttribute("tabindex")}scrollToPosition({x:H,y:J}){this.scrollRoot.scrollTo(H,J)}scrollToTop(){this.scrollToPosition({x:0,y:0})}get scrollRoot(){return window}async render(H){let{isPreview:J,shouldRender:Q,willRender:X,newSnapshot:Y}=H,Z=X;if(Q)try{this.renderPromise=new Promise((R)=>this.#H=R),this.renderer=H,await this.prepareToRenderSnapshot(H);let A=new Promise((R)=>this.#J=R),B={resume:this.#J,render:this.renderer.renderElement,renderMethod:this.renderer.renderMethod};if(!this.delegate.allowsImmediateRender(Y,B))await A;await this.renderSnapshot(H),this.delegate.viewRenderedSnapshot(Y,J,this.renderer.renderMethod),this.delegate.preloadOnLoadLinksForView(this.element),this.finishRenderingSnapshot(H)}finally{delete this.renderer,this.#H(void 0),delete this.renderPromise}else if(Z)this.invalidate(H.reloadReason)}invalidate(H){this.delegate.viewInvalidated(H)}async prepareToRenderSnapshot(H){this.markAsPreview(H.isPreview),await H.prepareToRender()}markAsPreview(H){if(H)this.element.setAttribute("data-turbo-preview","");else this.element.removeAttribute("data-turbo-preview")}markVisitDirection(H){this.element.setAttribute("data-turbo-visit-direction",H)}unmarkVisitDirection(){this.element.removeAttribute("data-turbo-visit-direction")}async renderSnapshot(H){await H.render()}finishRenderingSnapshot(H){H.finishRendering()}}class S1 extends TH{missing(){this.element.innerHTML='<strong class="turbo-frame-error">Content missing</strong>'}get snapshot(){return new QH(this.element)}}class DH{constructor(H,J){this.delegate=H,this.element=J}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=(H)=>{if(this.clickEventIsSignificant(H))this.clickEvent=H;else delete this.clickEvent};linkClicked=(H)=>{if(this.clickEvent&&this.clickEventIsSignificant(H)){if(this.delegate.shouldInterceptLinkClick(H.target,H.detail.url,H.detail.originalEvent))this.clickEvent.preventDefault(),H.preventDefault(),this.delegate.linkClickIntercepted(H.target,H.detail.url,H.detail.originalEvent)}delete this.clickEvent};willVisit=(H)=>{delete this.clickEvent};clickEventIsSignificant(H){let J=H.composed?H.target?.parentElement:H.target,Q=A1(J)||J;return Q instanceof Element&&Q.closest("turbo-frame, html")==this.element}}class OH{started=!1;constructor(H,J){this.delegate=H,this.eventTarget=J}start(){if(!this.started)this.eventTarget.addEventListener("click",this.clickCaptured,!0),this.started=!0}stop(){if(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=(H)=>{if(H instanceof MouseEvent&&this.clickEventIsSignificant(H)){let J=H.composedPath&&H.composedPath()[0]||H.target,Q=A1(J);if(Q&&W1(Q.target)){let X=U1(Q);if(this.delegate.willFollowLinkToLocation(Q,X,H))H.preventDefault(),this.delegate.followedLinkToLocation(Q,X)}}};clickEventIsSignificant(H){return!(H.target&&H.target.isContentEditable||H.defaultPrevented||H.which>1||H.altKey||H.ctrlKey||H.metaKey||H.shiftKey)}}class xH{constructor(H,J){this.delegate=H,this.linkInterceptor=new OH(this,J)}start(){this.linkInterceptor.start()}stop(){this.linkInterceptor.stop()}canPrefetchRequestToLocation(H,J){return!1}prefetchAndCacheRequestToLocation(H,J){return}willFollowLinkToLocation(H,J,Q){return this.delegate.willSubmitFormLinkToLocation(H,J,Q)&&(H.hasAttribute("data-turbo-method")||H.hasAttribute("data-turbo-stream"))}followedLinkToLocation(H,J){let Q=document.createElement("form"),X="hidden";for(let[y,b]of J.searchParams)Q.append(Object.assign(document.createElement("input"),{type:"hidden",name:y,value:b}));let Y=Object.assign(J,{search:""});Q.setAttribute("data-turbo","true"),Q.setAttribute("action",Y.href),Q.setAttribute("hidden","");let Z=H.getAttribute("data-turbo-method");if(Z)Q.setAttribute("method",Z);let A=H.getAttribute("data-turbo-frame");if(A)Q.setAttribute("data-turbo-frame",A);let B=i(H);if(B)Q.setAttribute("data-turbo-action",B);let D=H.getAttribute("data-turbo-confirm");if(D)Q.setAttribute("data-turbo-confirm",D);if(H.hasAttribute("data-turbo-stream"))Q.setAttribute("data-turbo-stream","");this.delegate.submittedFormLinkToLocation(H,J,Q),document.body.appendChild(Q),Q.addEventListener("turbo:submit-end",()=>Q.remove(),{once:!0}),requestAnimationFrame(()=>Q.requestSubmit())}}class hH{static async preservingPermanentElements(H,J,Q){let X=new this(H,J);X.enter(),await Q(),X.leave()}constructor(H,J){this.delegate=H,this.permanentElementMap=J}enter(){for(let H in this.permanentElementMap){let[J,Q]=this.permanentElementMap[H];this.delegate.enteringBardo(J,Q),this.replaceNewPermanentElementWithPlaceholder(Q)}}leave(){for(let H in this.permanentElementMap){let[J]=this.permanentElementMap[H];this.replaceCurrentPermanentElementWithClone(J),this.replacePlaceholderWithPermanentElement(J),this.delegate.leavingBardo(J)}}replaceNewPermanentElementWithPlaceholder(H){let J=AQ(H);H.replaceWith(J)}replaceCurrentPermanentElementWithClone(H){let J=H.cloneNode(!0);H.replaceWith(J)}replacePlaceholderWithPermanentElement(H){this.getPlaceholderById(H.id)?.replaceWith(H)}getPlaceholderById(H){return this.placeholders.find((J)=>J.content==H)}get placeholders(){return[...document.querySelectorAll("meta[name=turbo-permanent-placeholder][content]")]}}function AQ(H){let J=document.createElement("meta");return J.setAttribute("name","turbo-permanent-placeholder"),J.setAttribute("content",H.id),J}class BH{#H=null;static renderElement(H,J){}constructor(H,J,Q,X=!0){this.currentSnapshot=H,this.newSnapshot=J,this.isPreview=Q,this.willRender=X,this.renderElement=this.constructor.renderElement,this.promise=new Promise((Y,Z)=>this.resolvingFunctions={resolve:Y,reject:Z})}get shouldRender(){return!0}get shouldAutofocus(){return!0}get reloadReason(){return}prepareToRender(){return}render(){}finishRendering(){if(this.resolvingFunctions)this.resolvingFunctions.resolve(),delete this.resolvingFunctions}async preservingPermanentElements(H){await hH.preservingPermanentElements(this,this.permanentElementMap,H)}focusFirstAutofocusableElement(){if(this.shouldAutofocus){let H=this.connectedSnapshot.firstAutofocusableElement;if(H)H.focus()}}enteringBardo(H){if(this.#H)return;if(H.contains(this.currentSnapshot.activeElement))this.#H=this.currentSnapshot.activeElement}leavingBardo(H){if(H.contains(this.#H)&&this.#H instanceof HTMLElement)this.#H.focus(),this.#H=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 IH extends BH{static renderElement(H,J){let Q=document.createRange();Q.selectNodeContents(H),Q.deleteContents();let X=J,Y=X.ownerDocument?.createRange();if(Y)Y.selectNodeContents(X),H.appendChild(Y.extractContents())}constructor(H,J,Q,X,Y,Z=!0){super(J,Q,X,Y,Z);this.delegate=H}get shouldRender(){return!0}async render(){await e(),this.preservingPermanentElements(()=>{this.loadFrameElement()}),this.scrollFrameIntoView(),await e(),this.focusFirstAutofocusableElement(),await e(),this.activateScriptElements()}loadFrameElement(){this.delegate.willRenderFrame(this.currentElement,this.newElement),this.renderElement(this.currentElement,this.newElement)}scrollFrameIntoView(){if(this.currentElement.autoscroll||this.newElement.autoscroll){let H=this.currentElement.firstElementChild,J=qQ(this.currentElement.getAttribute("data-autoscroll-block"),"end"),Q=UQ(this.currentElement.getAttribute("data-autoscroll-behavior"),"auto");if(H)return H.scrollIntoView({block:J,behavior:Q}),!0}return!1}activateScriptElements(){for(let H of this.newScriptElements){let J=JH(H);H.replaceWith(J)}}get newScriptElements(){return this.currentElement.querySelectorAll("script")}}function qQ(H,J){if(H=="end"||H=="start"||H=="center"||H=="nearest")return H;else return J}function UQ(H,J){if(H=="auto"||H=="smooth")return H;else return J}var zQ=function(){let H=()=>{},J={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:H,afterNodeAdded:H,beforeNodeMorphed:H,afterNodeMorphed:H,beforeNodeRemoved:H,afterNodeRemoved:H,beforeAttributeUpdated:H},head:{style:"merge",shouldPreserve:(F)=>F.getAttribute("im-preserve")==="true",shouldReAppend:(F)=>F.getAttribute("im-re-append")==="true",shouldRemove:H,afterHeadMorphed:H},restoreFocus:!0};function Q(F,C,P={}){F=y(F);let L=b(C),j=R(F,L,P),K=Y(j,()=>{return B(j,F,L,(W)=>{if(W.morphStyle==="innerHTML")return Z(W,F,L),Array.from(F.childNodes);else return X(W,F,L)})});return j.pantry.remove(),K}function X(F,C,P){let L=b(C);return Z(F,L,P,C,C.nextSibling),Array.from(L.childNodes)}function Y(F,C){if(!F.config.restoreFocus)return C();let P=document.activeElement;if(!(P instanceof HTMLInputElement||P instanceof HTMLTextAreaElement))return C();let{id:L,selectionStart:j,selectionEnd:K}=P,W=C();if(L&&L!==document.activeElement?.getAttribute("id"))P=F.target.querySelector(`[id="${L}"]`),P?.focus();if(P&&!P.selectionEnd&&K)P.setSelectionRange(j,K);return W}let Z=function(){function F(G,$,U,q=null,_=null){if($ instanceof HTMLTemplateElement&&U instanceof HTMLTemplateElement)$=$.content,U=U.content;q||=$.firstChild;for(let I of U.childNodes){if(q&&q!=_){let S=P(G,I,q,_);if(S){if(S!==q)j(G,q,S);A(S,I,G),q=S.nextSibling;continue}}if(I instanceof Element){let S=I.getAttribute("id");if(G.persistentIds.has(S)){let k=K($,S,q,G);A(k,I,G),q=k.nextSibling;continue}}let M=C($,I,q,G);if(M)q=M.nextSibling}while(q&&q!=_){let I=q;q=q.nextSibling,L(G,I)}}function C(G,$,U,q){if(q.callbacks.beforeNodeAdded($)===!1)return null;if(q.idMap.has($)){let _=document.createElement($.tagName);return G.insertBefore(_,U),A(_,$,q),q.callbacks.afterNodeAdded(_),_}else{let _=document.importNode($,!0);return G.insertBefore(_,U),q.callbacks.afterNodeAdded(_),_}}let P=function(){function G(q,_,I,M){let S=null,k=_.nextSibling,aH=0,h=I;while(h&&h!=M){if(U(h,_)){if($(q,h,_))return h;if(S===null){if(!q.idMap.has(h))S=h}}if(S===null&&k&&U(h,k)){if(aH++,k=k.nextSibling,aH>=2)S=void 0}if(q.activeElementAndParents.includes(h))break;h=h.nextSibling}return S||null}function $(q,_,I){let M=q.idMap.get(_),S=q.idMap.get(I);if(!S||!M)return!1;for(let k of M)if(S.has(k))return!0;return!1}function U(q,_){let I=q,M=_;return I.nodeType===M.nodeType&&I.tagName===M.tagName&&(!I.getAttribute?.("id")||I.getAttribute?.("id")===M.getAttribute?.("id"))}return G}();function L(G,$){if(G.idMap.has($))z(G.pantry,$,null);else{if(G.callbacks.beforeNodeRemoved($)===!1)return;$.parentNode?.removeChild($),G.callbacks.afterNodeRemoved($)}}function j(G,$,U){let q=$;while(q&&q!==U){let _=q;q=q.nextSibling,L(G,_)}return q}function K(G,$,U,q){let _=q.target.getAttribute?.("id")===$&&q.target||q.target.querySelector(`[id="${$}"]`)||q.pantry.querySelector(`[id="${$}"]`);return W(_,q),z(G,_,U),_}function W(G,$){let U=G.getAttribute("id");while(G=G.parentNode){let q=$.idMap.get(G);if(q){if(q.delete(U),!q.size)$.idMap.delete(G)}}}function z(G,$,U){if(G.moveBefore)try{G.moveBefore($,U)}catch(q){G.insertBefore($,U)}else G.insertBefore($,U)}return F}(),A=function(){function F(W,z,G){if(G.ignoreActive&&W===document.activeElement)return null;if(G.callbacks.beforeNodeMorphed(W,z)===!1)return W;if(W instanceof HTMLHeadElement&&G.head.ignore);else if(W instanceof HTMLHeadElement&&G.head.style!=="morph")D(W,z,G);else if(C(W,z,G),!K(W,G))Z(G,W,z);return G.callbacks.afterNodeMorphed(W,z),W}function C(W,z,G){let $=z.nodeType;if($===1){let U=W,q=z,_=U.attributes,I=q.attributes;for(let M of I){if(j(M.name,U,"update",G))continue;if(U.getAttribute(M.name)!==M.value)U.setAttribute(M.name,M.value)}for(let M=_.length-1;0<=M;M--){let S=_[M];if(!S)continue;if(!q.hasAttribute(S.name)){if(j(S.name,U,"remove",G))continue;U.removeAttribute(S.name)}}if(!K(U,G))P(U,q,G)}if($===8||$===3){if(W.nodeValue!==z.nodeValue)W.nodeValue=z.nodeValue}}function P(W,z,G){if(W instanceof HTMLInputElement&&z instanceof HTMLInputElement&&z.type!=="file"){let $=z.value,U=W.value;if(L(W,z,"checked",G),L(W,z,"disabled",G),!z.hasAttribute("value")){if(!j("value",W,"remove",G))W.value="",W.removeAttribute("value")}else if(U!==$){if(!j("value",W,"update",G))W.setAttribute("value",$),W.value=$}}else if(W instanceof HTMLOptionElement&&z instanceof HTMLOptionElement)L(W,z,"selected",G);else if(W instanceof HTMLTextAreaElement&&z instanceof HTMLTextAreaElement){let $=z.value,U=W.value;if(j("value",W,"update",G))return;if($!==U)W.value=$;if(W.firstChild&&W.firstChild.nodeValue!==$)W.firstChild.nodeValue=$}}function L(W,z,G,$){let U=z[G],q=W[G];if(U!==q){let _=j(G,W,"update",$);if(!_)W[G]=z[G];if(U){if(!_)W.setAttribute(G,"")}else if(!j(G,W,"remove",$))W.removeAttribute(G)}}function j(W,z,G,$){if(W==="value"&&$.ignoreActiveValue&&z===document.activeElement)return!0;return $.callbacks.beforeAttributeUpdated(W,z,G)===!1}function K(W,z){return!!z.ignoreActiveValue&&W===document.activeElement&&W!==document.body}return F}();function B(F,C,P,L){if(F.head.block){let j=C.querySelector("head"),K=P.querySelector("head");if(j&&K){let W=D(j,K,F);return Promise.all(W).then(()=>{let z=Object.assign(F,{head:{block:!1,ignore:!0}});return L(z)})}}return L(F)}function D(F,C,P){let L=[],j=[],K=[],W=[],z=new Map;for(let $ of C.children)z.set($.outerHTML,$);for(let $ of F.children){let U=z.has($.outerHTML),q=P.head.shouldReAppend($),_=P.head.shouldPreserve($);if(U||_)if(q)j.push($);else z.delete($.outerHTML),K.push($);else if(P.head.style==="append"){if(q)j.push($),W.push($)}else if(P.head.shouldRemove($)!==!1)j.push($)}W.push(...z.values());let G=[];for(let $ of W){let U=document.createRange().createContextualFragment($.outerHTML).firstChild;if(P.callbacks.beforeNodeAdded(U)!==!1){if("href"in U&&U.href||"src"in U&&U.src){let q,_=new Promise(function(I){q=I});U.addEventListener("load",function(){q()}),G.push(_)}F.appendChild(U),P.callbacks.afterNodeAdded(U),L.push(U)}}for(let $ of j)if(P.callbacks.beforeNodeRemoved($)!==!1)F.removeChild($),P.callbacks.afterNodeRemoved($);return P.head.afterHeadMorphed(F,{added:L,kept:K,removed:j}),G}let R=function(){function F(G,$,U){let{persistentIds:q,idMap:_}=W(G,$),I=C(U),M=I.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(M))throw`Do not understand how to morph style ${M}`;return{target:G,newContent:$,config:I,morphStyle:M,ignoreActive:I.ignoreActive,ignoreActiveValue:I.ignoreActiveValue,restoreFocus:I.restoreFocus,idMap:_,persistentIds:q,pantry:P(),activeElementAndParents:L(G),callbacks:I.callbacks,head:I.head}}function C(G){let $=Object.assign({},J);return Object.assign($,G),$.callbacks=Object.assign({},J.callbacks,G.callbacks),$.head=Object.assign({},J.head,G.head),$}function P(){let G=document.createElement("div");return G.hidden=!0,document.body.insertAdjacentElement("afterend",G),G}function L(G){let $=[],U=document.activeElement;if(U?.tagName!=="BODY"&&G.contains(U))while(U){if($.push(U),U===G)break;U=U.parentElement}return $}function j(G){let $=Array.from(G.querySelectorAll("[id]"));if(G.getAttribute?.("id"))$.push(G);return $}function K(G,$,U,q){for(let _ of q){let I=_.getAttribute("id");if($.has(I)){let M=_;while(M){let S=G.get(M);if(S==null)S=new Set,G.set(M,S);if(S.add(I),M===U)break;M=M.parentElement}}}}function W(G,$){let U=j(G),q=j($),_=z(U,q),I=new Map;K(I,_,G,U);let M=$.__idiomorphRoot||$;return K(I,_,M,q),{persistentIds:_,idMap:I}}function z(G,$){let U=new Set,q=new Map;for(let{id:I,tagName:M}of G)if(q.has(I))U.add(I);else q.set(I,M);let _=new Set;for(let{id:I,tagName:M}of $)if(_.has(I))U.add(I);else if(q.get(I)===M)_.add(I);for(let I of U)_.delete(I);return _}return F}(),{normalizeElement:y,normalizeParent:b}=function(){let F=new WeakSet;function C(K){if(K instanceof Document)return K.documentElement;else return K}function P(K){if(K==null)return document.createElement("div");else if(typeof K==="string")return P(j(K));else if(F.has(K))return K;else if(K instanceof Node)if(K.parentNode)return new L(K);else{let W=document.createElement("div");return W.append(K),W}else{let W=document.createElement("div");for(let z of[...K])W.append(z);return W}}class L{constructor(K){this.originalNode=K,this.realParentNode=K.parentNode,this.previousSibling=K.previousSibling,this.nextSibling=K.nextSibling}get childNodes(){let K=[],W=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;while(W&&W!=this.nextSibling)K.push(W),W=W.nextSibling;return K}querySelectorAll(K){return this.childNodes.reduce((W,z)=>{if(z instanceof Element){if(z.matches(K))W.push(z);let G=z.querySelectorAll(K);for(let $=0;$<G.length;$++)W.push(G[$])}return W},[])}insertBefore(K,W){return this.realParentNode.insertBefore(K,W)}moveBefore(K,W){return this.realParentNode.moveBefore(K,W)}get __idiomorphRoot(){return this.originalNode}}function j(K){let W=new DOMParser,z=K.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(z.match(/<\/html>/)||z.match(/<\/head>/)||z.match(/<\/body>/)){let G=W.parseFromString(K,"text/html");if(z.match(/<\/html>/))return F.add(G),G;else{let $=G.firstChild;if($)F.add($);return $}}else{let $=W.parseFromString("<body><template>"+K+"</template></body>","text/html").body.querySelector("template").content;return F.add($),$}}return{normalizeElement:C,normalizeParent:P}}();return{morph:Q,defaults:J}}();function FH(H,J,{callbacks:Q,...X}={}){zQ.morph(H,J,{...X,callbacks:new E1(Q)})}function gH(H,J,Q={}){FH(H,J.childNodes,{...Q,morphStyle:"innerHTML"})}function C1(H,J){return H instanceof x&&H.shouldReloadWithMorph&&(!J||KQ(H,J))&&!H.closest("[data-turbo-permanent]")}function KQ(H,J){return J instanceof Element&&J.nodeName==="TURBO-FRAME"&&H.id===J.id&&(!J.getAttribute("src")||z1(H.src,J.getAttribute("src")))}function w1(H){return H.parentElement.closest("turbo-frame[src][refresh=morph]")}class E1{#H;constructor({beforeNodeMorphed:H}={}){this.#H=H||(()=>!0)}beforeNodeAdded=(H)=>{return!(H.id&&H.hasAttribute("data-turbo-permanent")&&document.getElementById(H.id))};beforeNodeMorphed=(H,J)=>{if(H instanceof Element)if(!H.hasAttribute("data-turbo-permanent")&&this.#H(H,J))return!w("turbo:before-morph-element",{cancelable:!0,target:H,detail:{currentElement:H,newElement:J}}).defaultPrevented;else return!1};beforeAttributeUpdated=(H,J,Q)=>{return!w("turbo:before-morph-attribute",{cancelable:!0,target:J,detail:{attributeName:H,mutationType:Q}}).defaultPrevented};beforeNodeRemoved=(H)=>{return this.beforeNodeMorphed(H)};afterNodeMorphed=(H,J)=>{if(H instanceof Element)w("turbo:morph-element",{target:H,detail:{currentElement:H,newElement:J}})}}class yH extends IH{static renderElement(H,J){w("turbo:before-frame-morph",{target:H,detail:{currentElement:H,newElement:J}}),gH(H,J,{callbacks:{beforeNodeMorphed:(Q,X)=>{if(C1(Q,X)&&w1(Q)===H)return Q.reload(),!1;return!0}}})}async preservingPermanentElements(H){return await H()}}class v{static animationDuration=300;static get defaultCSS(){return Y1`
4
+ */var X={eager:"eager",lazy:"lazy"};class F extends HTMLElement{static delegateConstructor=void 0;loaded=Promise.resolve();static get observedAttributes(){return["disabled","loading","src"]}constructor(){super();this.delegate=new F.delegateConstructor(this)}connectedCallback(){this.delegate.connect()}disconnectedCallback(){this.delegate.disconnect()}reload(){return this.delegate.sourceURLReloaded()}attributeChangedCallback(e){if(e=="loading")this.delegate.loadingStyleChanged();else if(e=="src")this.delegate.sourceURLChanged();else if(e=="disabled")this.delegate.disabledChanged()}get src(){return this.getAttribute("src")}set src(e){if(e)this.setAttribute("src",e);else this.removeAttribute("src")}get refresh(){return this.getAttribute("refresh")}set refresh(e){if(e)this.setAttribute("refresh",e);else this.removeAttribute("refresh")}get shouldReloadWithMorph(){return this.src&&this.refresh==="morph"}get loading(){return Ps(this.getAttribute("loading")||"")}set loading(e){if(e)this.setAttribute("loading",e);else this.removeAttribute("loading")}get disabled(){return this.hasAttribute("disabled")}set disabled(e){if(e)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get autoscroll(){return this.hasAttribute("autoscroll")}set autoscroll(e){if(e)this.setAttribute("autoscroll","");else 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 Ps(e){switch(e.toLowerCase()){case"lazy":return X.lazy;default:return X.eager}}var Is={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 se(e){if(e.getAttribute("data-turbo-eval")=="false")return e;else{let t=document.createElement("script"),s=at();if(s)t.nonce=s;return t.textContent=e.textContent,t.async=!1,Bs(t,e),t}}function Bs(e,t){for(let{name:s,value:r}of t.attributes)e.setAttribute(s,r)}function Ns(e){let t=document.createElement("template");return t.innerHTML=e,t.content}function T(e,{target:t,cancelable:s,detail:r}={}){let i=new CustomEvent(e,{cancelable:s,bubbles:!0,composed:!0,detail:r});if(t&&t.isConnected)t.dispatchEvent(i);else document.documentElement.dispatchEvent(i);return i}function Ye(e){e.preventDefault(),e.stopImmediatePropagation()}function ee(){if(document.visibilityState==="hidden")return rt();else return st()}function st(){return new Promise((e)=>requestAnimationFrame(()=>e()))}function rt(){return new Promise((e)=>setTimeout(()=>e(),0))}function it(e=""){return new DOMParser().parseFromString(e,"text/html")}function nt(e,...t){let s=Ds(e,t).replace(/^\n/,"").split(`
5
+ `),r=s[0].match(/^\s+/),i=r?r[0].length:0;return s.map((n)=>n.slice(i)).join(`
6
+ `)}function Ds(e,t){return e.reduce((s,r,i)=>{let n=t[i]==null?"":t[i];return s+r+n},"")}function W(){return Array.from({length:36}).map((e,t)=>{if(t==8||t==13||t==18||t==23)return"-";else if(t==14)return"4";else if(t==19)return(Math.floor(Math.random()*4)+8).toString(16);else return Math.floor(Math.random()*16).toString(16)}).join("")}function le(e,...t){for(let s of t.map((r)=>r?.getAttribute(e)))if(typeof s=="string")return s;return null}function qs(e,...t){return t.some((s)=>s&&s.hasAttribute(e))}function he(...e){for(let t of e){if(t.localName=="turbo-frame")t.setAttribute("busy","");t.setAttribute("aria-busy","true")}}function ue(...e){for(let t of e){if(t.localName=="turbo-frame")t.removeAttribute("busy");t.removeAttribute("aria-busy")}}function xs(e,t=2000){return new Promise((s)=>{let r=()=>{e.removeEventListener("error",r),e.removeEventListener("load",r),s()};e.addEventListener("load",r,{once:!0}),e.addEventListener("error",r,{once:!0}),setTimeout(s,t)})}function ot(e){switch(e){case"replace":return history.replaceState;case"advance":case"restore":return history.pushState}}function Hs(e){return e=="advance"||e=="replace"||e=="restore"}function K(...e){let t=le("data-turbo-action",...e);return Hs(t)?t:null}function Ae(e){return document.querySelector(`meta[name="${e}"]`)}function de(e){let t=Ae(e);return t&&t.content}function at(){let e=Ae("csp-nonce");if(e){let{nonce:t,content:s}=e;return t==""?s:t}}function Vs(e,t){let s=Ae(e);if(!s)s=document.createElement("meta"),s.setAttribute("name",e),document.head.appendChild(s);return s.setAttribute("content",t),s}function Q(e,t){if(e instanceof Element)return e.closest(t)||Q(e.assignedSlot||e.getRootNode()?.host,t)}function Te(e){return!!e&&e.closest("[inert], :disabled, [hidden], details:not([open]), dialog:not([open])")==null&&typeof e.focus=="function"}function ct(e){return Array.from(e.querySelectorAll("[autofocus]")).find(Te)}async function $s(e,t){let s=t();e(),await st();let r=t();return[s,r]}function lt(e){if(e==="_blank")return!1;else if(e){for(let t of document.getElementsByName(e))if(t instanceof HTMLIFrameElement)return!1;return!0}else return!0}function ht(e){let t=Q(e,"a[href], a[xlink\\:href]");if(!t)return null;if(t.href.startsWith("#"))return null;if(t.hasAttribute("download"))return null;let s=t.getAttribute("target");if(s&&s!=="_self")return null;return t}function Ws(e,t){let s=null;return(...r)=>{let i=()=>e.apply(this,r);clearTimeout(s),s=setTimeout(i,t)}}var _s={"aria-disabled":{beforeSubmit:(e)=>{e.setAttribute("aria-disabled","true"),e.addEventListener("click",Ye)},afterSubmit:(e)=>{e.removeAttribute("aria-disabled"),e.removeEventListener("click",Ye)}},disabled:{beforeSubmit:(e)=>e.disabled=!0,afterSubmit:(e)=>e.disabled=!1}};class ut{#e=null;constructor(e){Object.assign(this,e)}get submitter(){return this.#e}set submitter(e){this.#e=_s[e]||e}}var js=new ut({mode:"on",submitter:"disabled"}),C={drive:Is,forms:js};function R(e){return new URL(e.toString(),document.baseURI)}function te(e){let t;if(e.hash)return e.hash.slice(1);else if(t=e.href.match(/#(.*)$/))return t[1]}function Le(e,t){let s=t?.getAttribute("formaction")||e.getAttribute("action")||e.action;return R(s)}function Us(e){return(Xs(e).match(/\.[^.]*$/)||[])[0]||""}function Ks(e,t){let s=Qe(t.origin+t.pathname);return Qe(e.href)===s||e.href.startsWith(s)}function V(e,t){return Ks(e,t)&&!C.drive.unvisitableExtensions.has(Us(e))}function dt(e){return R(e.getAttribute("href")||"")}function zs(e){let t=te(e);return t!=null?e.href.slice(0,-(t.length+1)):e.href}function ce(e){return zs(e)}function ft(e,t){return R(e).href==R(t).href}function Js(e){return e.pathname.split("/").slice(1)}function Xs(e){return Js(e).slice(-1)[0]}function Qe(e){return e.endsWith("/")?e:e+"/"}class fe{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 R(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(){if(this.isHTML)return this.response.clone().text();else return Promise.resolve(void 0)}header(e){return this.response.headers.get(e)}}class mt extends Set{constructor(e){super();this.maxSize=e}add(e){if(this.size>=this.maxSize){let s=this.values().next().value;this.delete(s)}super.add(e)}}var pt=new mt(20);function gt(e,t={}){let s=new Headers(t.headers||{}),r=W();return pt.add(r),s.append("X-Turbo-Request-Id",r),window.fetch(e,{...t,headers:s})}function Me(e){switch(e.toLowerCase()){case"get":return k.get;case"post":return k.post;case"put":return k.put;case"patch":return k.patch;case"delete":return k.delete}}var k={get:"get",post:"post",put:"put",patch:"patch",delete:"delete"};function Ys(e){switch(e.toLowerCase()){case U.multipart:return U.multipart;case U.plain:return U.plain;default:return U.urlEncoded}}var U={urlEncoded:"application/x-www-form-urlencoded",multipart:"multipart/form-data",plain:"text/plain"};class Z{abortController=new AbortController;#e=(e)=>{};constructor(e,t,s,r=new URLSearchParams,i=null,n=U.urlEncoded){let[l,p]=Ge(R(s),t,r,n);this.delegate=e,this.url=l,this.target=i,this.fetchOptions={credentials:"same-origin",redirect:"follow",method:t.toUpperCase(),headers:{...this.defaultHeaders},body:p,signal:this.abortSignal,referrer:this.delegate.referrer?.href},this.enctype=n}get method(){return this.fetchOptions.method}set method(e){let t=this.isSafe?this.url.searchParams:this.fetchOptions.body||new FormData,s=Me(e)||k.get;this.url.search="";let[r,i]=Ge(this.url,s,t,this.enctype);this.url=r,this.fetchOptions.body=i,this.fetchOptions.method=s.toUpperCase()}get headers(){return this.fetchOptions.headers}set headers(e){this.fetchOptions.headers=e}get body(){if(this.isSafe)return this.url.searchParams;else return 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(){let{fetchOptions:e}=this;this.delegate.prepareRequest(this);let t=await this.#t(e);try{if(this.delegate.requestStarted(this),t.detail.fetchRequest)this.response=t.detail.fetchRequest.response;else this.response=gt(this.url.href,e);let s=await this.response;return await this.receive(s)}catch(s){if(s.name!=="AbortError"){if(this.#s(s))this.delegate.requestErrored(this,s);throw s}}finally{this.delegate.requestFinished(this)}}async receive(e){let t=new fe(e);if(T("turbo:before-fetch-response",{cancelable:!0,detail:{fetchResponse:t},target:this.target}).defaultPrevented)this.delegate.requestPreventedHandlingResponse(this,t);else if(t.succeeded)this.delegate.requestSucceededWithResponse(this,t);else this.delegate.requestFailedWithResponse(this,t);return t}get defaultHeaders(){return{Accept:"text/html, application/xhtml+xml"}}get isSafe(){return Ce(this.method)}get abortSignal(){return this.abortController.signal}acceptResponseType(e){this.headers.Accept=[e,this.headers.Accept].join(", ")}async#t(e){let t=new Promise((r)=>this.#e=r),s=T("turbo:before-fetch-request",{cancelable:!0,detail:{fetchOptions:e,url:this.url,resume:this.#e},target:this.target});if(this.url=s.detail.url,s.defaultPrevented)await t;return s}#s(e){return!T("turbo:fetch-request-error",{target:this.target,cancelable:!0,detail:{request:this,error:e}}).defaultPrevented}}function Ce(e){return Me(e)==k.get}function Ge(e,t,s,r){let i=Array.from(s).length>0?new URLSearchParams(bt(s)):e.searchParams;if(Ce(t))return[Qs(e,i),null];else if(r==U.urlEncoded)return[e,i];else return[e,s]}function bt(e){let t=[];for(let[s,r]of e)if(r instanceof File)continue;else t.push([s,r]);return t}function Qs(e,t){let s=new URLSearchParams(bt(t));return e.search=s.toString(),e}class vt{started=!1;constructor(e,t){this.delegate=e,this.element=t,this.intersectionObserver=new IntersectionObserver(this.intersect)}start(){if(!this.started)this.started=!0,this.intersectionObserver.observe(this.element)}stop(){if(this.started)this.started=!1,this.intersectionObserver.unobserve(this.element)}intersect=(e)=>{if(e.slice(-1)[0]?.isIntersecting)this.delegate.elementAppearedInViewport(this.element)}}class z{static contentType="text/vnd.turbo-stream.html";static wrap(e){if(typeof e=="string")return new this(Ns(e));else return e}constructor(e){this.fragment=Gs(e)}}function Gs(e){for(let t of e.querySelectorAll("turbo-stream")){let s=document.importNode(t,!0);for(let r of s.templateElement.content.querySelectorAll("script"))r.replaceWith(se(r));t.replaceWith(s)}return e}var Zs=(e)=>e;class Re{keys=[];entries={};#e;constructor(e,t=Zs){this.size=e,this.#e=t}has(e){return this.#e(e)in this.entries}get(e){if(this.has(e)){let t=this.read(e);return this.touch(e),t}}put(e,t){return this.write(e,t),this.touch(e),t}clear(){for(let e of Object.keys(this.entries))this.evict(e)}read(e){return this.entries[this.#e(e)]}write(e,t){this.entries[this.#e(e)]=t}touch(e){e=this.#e(e);let t=this.keys.indexOf(e);if(t>-1)this.keys.splice(t,1);this.keys.unshift(e),this.trim()}trim(){for(let e of this.keys.splice(this.size))this.evict(e)}evict(e){delete this.entries[e]}}var er=100;class yt extends Re{#e=null;#t={};constructor(e=1,t=er){super(e,ce);this.prefetchDelay=t}putLater(e,t,s){this.#e=setTimeout(()=>{t.perform(),this.put(e,t,s),this.#e=null},this.prefetchDelay)}put(e,t,s=Et){super.put(e,t),this.#t[ce(e)]=new Date(new Date().getTime()+s)}clear(){if(super.clear(),this.#e)clearTimeout(this.#e)}evict(e){super.evict(e),delete this.#t[e]}has(e){if(super.has(e)){let t=this.#t[ce(e)];return t&&t>Date.now()}else return!1}}var Et=1e4,Y=new yt,J={initialized:"initialized",requesting:"requesting",waiting:"waiting",receiving:"receiving",stopping:"stopping",stopped:"stopped"};class me{state=J.initialized;static confirmMethod(e){return Promise.resolve(confirm(e))}constructor(e,t,s,r=!1){let i=or(t,s),n=nr(ir(t,s),i),l=tr(t,s),p=ar(t,s);this.delegate=e,this.formElement=t,this.submitter=s,this.fetchRequest=new Z(this,i,n,l,t,p),this.mustRedirect=r}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=R(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(){let{initialized:e,requesting:t}=J,s=le("data-turbo-confirm",this.submitter,this.formElement);if(typeof s==="string"){if(!await(typeof C.forms.confirm==="function"?C.forms.confirm:me.confirmMethod)(s,this.formElement,this.submitter))return}if(this.state==e)return this.state=t,this.fetchRequest.perform()}stop(){let{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){let t=sr(de("csrf-param"))||de("csrf-token");if(t)e.headers["X-CSRF-Token"]=t}if(this.requestAcceptsTurboStreamResponse(e))e.acceptResponseType(z.contentType)}requestStarted(e){if(this.state=J.waiting,this.submitter)C.forms.submitter.beforeSubmit(this.submitter);this.setSubmitsWith(),he(this.formElement),T("turbo:submit-start",{target:this.formElement,detail:{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)&&rr(t)){let s=Error("Form responses must redirect to another location");this.delegate.formSubmissionErrored(this,s)}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){if(this.state=J.stopped,this.submitter)C.forms.submitter.afterSubmit(this.submitter);this.resetSubmitterText(),ue(this.formElement),T("turbo:submit-end",{target:this.formElement,detail:{formSubmission:this,...this.result}}),this.delegate.formSubmissionFinished(this)}setSubmitsWith(){if(!this.submitter||!this.submitsWith)return;if(this.submitter.matches("button"))this.originalSubmitText=this.submitter.innerHTML,this.submitter.innerHTML=this.submitsWith;else if(this.submitter.matches("input")){let e=this.submitter;this.originalSubmitText=e.value,e.value=this.submitsWith}}resetSubmitterText(){if(!this.submitter||!this.originalSubmitText)return;if(this.submitter.matches("button"))this.submitter.innerHTML=this.originalSubmitText;else if(this.submitter.matches("input")){let e=this.submitter;e.value=this.originalSubmitText}}requestMustRedirect(e){return!e.isSafe&&this.mustRedirect}requestAcceptsTurboStreamResponse(e){return!e.isSafe||qs("data-turbo-stream",this.submitter,this.formElement)}get submitsWith(){return this.submitter?.getAttribute("data-turbo-submits-with")}}function tr(e,t){let s=new FormData(e),r=t?.getAttribute("name"),i=t?.getAttribute("value");if(r)s.append(r,i||"");return s}function sr(e){if(e!=null){let s=(document.cookie?document.cookie.split("; "):[]).find((r)=>r.startsWith(e));if(s){let r=s.split("=").slice(1).join("=");return r?decodeURIComponent(r):void 0}}}function rr(e){return e.statusCode==200&&!e.redirected}function ir(e,t){let s=typeof e.action==="string"?e.action:null;if(t?.hasAttribute("formaction"))return t.getAttribute("formaction")||"";else return e.getAttribute("action")||s||""}function nr(e,t){let s=R(e);if(Ce(t))s.search="";return s}function or(e,t){let s=t?.getAttribute("formmethod")||e.getAttribute("method")||"";return Me(s.toLowerCase())||k.get}function ar(e,t){return Ys(t?.getAttribute("formenctype")||e.enctype)}class re{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 ct(this.element)}get permanentElements(){return St(this.element)}getPermanentElementById(e){return wt(this.element,e)}getPermanentElementMapForSnapshot(e){let t={};for(let s of this.permanentElements){let{id:r}=s,i=e.getPermanentElementById(r);if(i)t[r]=[s,i]}return t}}function wt(e,t){return e.querySelector(`#${t}[data-turbo-permanent]`)}function St(e){return e.querySelectorAll("[id][data-turbo-permanent]")}class pe{started=!1;constructor(e,t){this.delegate=e,this.eventTarget=t}start(){if(!this.started)this.eventTarget.addEventListener("submit",this.submitCaptured,!0),this.started=!0}stop(){if(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){let t=e.target instanceof HTMLFormElement?e.target:void 0,s=e.submitter||void 0;if(t&&cr(t,s)&&lr(t,s)&&this.delegate.willSubmitForm(t,s))e.preventDefault(),e.stopImmediatePropagation(),this.delegate.formSubmitted(t,s)}}}function cr(e,t){return(t?.getAttribute("formmethod")||e.getAttribute("method"))!="dialog"}function lr(e,t){let s=t?.getAttribute("formtarget")||e.getAttribute("target");return lt(s)}class Oe{#e=(e)=>{};#t=(e)=>{};constructor(e,t){this.delegate=e,this.element=t}scrollToAnchor(e){let t=this.snapshot.getElementForAnchor(e);if(t)this.focusElement(t),this.scrollToElement(t);else this.scrollToPosition({x:0,y:0})}scrollToAnchorFromLocation(e){this.scrollToAnchor(te(e))}scrollToElement(e){e.scrollIntoView()}focusElement(e){if(e instanceof HTMLElement)if(e.hasAttribute("tabindex"))e.focus();else 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}async render(e){let{isPreview:t,shouldRender:s,willRender:r,newSnapshot:i}=e,n=r;if(s)try{this.renderPromise=new Promise((M)=>this.#e=M),this.renderer=e,await this.prepareToRenderSnapshot(e);let l=new Promise((M)=>this.#t=M),p={resume:this.#t,render:this.renderer.renderElement,renderMethod:this.renderer.renderMethod};if(!this.delegate.allowsImmediateRender(i,p))await l;await this.renderSnapshot(e),this.delegate.viewRenderedSnapshot(i,t,this.renderer.renderMethod),this.delegate.preloadOnLoadLinksForView(this.element),this.finishRenderingSnapshot(e)}finally{delete this.renderer,this.#e(void 0),delete this.renderPromise}else if(n)this.invalidate(e.reloadReason)}invalidate(e){this.delegate.viewInvalidated(e)}async prepareToRenderSnapshot(e){this.markAsPreview(e.isPreview),await e.prepareToRender()}markAsPreview(e){if(e)this.element.setAttribute("data-turbo-preview","");else 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 At extends Oe{missing(){this.element.innerHTML='<strong class="turbo-frame-error">Content missing</strong>'}get snapshot(){return new re(this.element)}}class ke{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)=>{if(this.clickEventIsSignificant(e))this.clickEvent=e;else delete this.clickEvent};linkClicked=(e)=>{if(this.clickEvent&&this.clickEventIsSignificant(e)){if(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){let t=e.composed?e.target?.parentElement:e.target,s=ht(t)||t;return s instanceof Element&&s.closest("turbo-frame, html")==this.element}}class Fe{started=!1;constructor(e,t){this.delegate=e,this.eventTarget=t}start(){if(!this.started)this.eventTarget.addEventListener("click",this.clickCaptured,!0),this.started=!0}stop(){if(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)){let t=e.composedPath&&e.composedPath()[0]||e.target,s=ht(t);if(s&&lt(s.target)){let r=dt(s);if(this.delegate.willFollowLinkToLocation(s,r,e))e.preventDefault(),this.delegate.followedLinkToLocation(s,r)}}};clickEventIsSignificant(e){return!(e.target&&e.target.isContentEditable||e.defaultPrevented||e.which>1||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)}}class Pe{constructor(e,t){this.delegate=e,this.linkInterceptor=new Fe(this,t)}start(){this.linkInterceptor.start()}stop(){this.linkInterceptor.stop()}canPrefetchRequestToLocation(e,t){return!1}prefetchAndCacheRequestToLocation(e,t){return}willFollowLinkToLocation(e,t,s){return this.delegate.willSubmitFormLinkToLocation(e,t,s)&&(e.hasAttribute("data-turbo-method")||e.hasAttribute("data-turbo-stream"))}followedLinkToLocation(e,t){let s=document.createElement("form"),r="hidden";for(let[B,N]of t.searchParams)s.append(Object.assign(document.createElement("input"),{type:"hidden",name:B,value:N}));let i=Object.assign(t,{search:""});s.setAttribute("data-turbo","true"),s.setAttribute("action",i.href),s.setAttribute("hidden","");let n=e.getAttribute("data-turbo-method");if(n)s.setAttribute("method",n);let l=e.getAttribute("data-turbo-frame");if(l)s.setAttribute("data-turbo-frame",l);let p=K(e);if(p)s.setAttribute("data-turbo-action",p);let O=e.getAttribute("data-turbo-confirm");if(O)s.setAttribute("data-turbo-confirm",O);if(e.hasAttribute("data-turbo-stream"))s.setAttribute("data-turbo-stream","");this.delegate.submittedFormLinkToLocation(e,t,s),document.body.appendChild(s),s.addEventListener("turbo:submit-end",()=>s.remove(),{once:!0}),requestAnimationFrame(()=>s.requestSubmit())}}class Ie{static async preservingPermanentElements(e,t,s){let r=new this(e,t);r.enter(),await s(),r.leave()}constructor(e,t){this.delegate=e,this.permanentElementMap=t}enter(){for(let e in this.permanentElementMap){let[t,s]=this.permanentElementMap[e];this.delegate.enteringBardo(t,s),this.replaceNewPermanentElementWithPlaceholder(s)}}leave(){for(let e in this.permanentElementMap){let[t]=this.permanentElementMap[e];this.replaceCurrentPermanentElementWithClone(t),this.replacePlaceholderWithPermanentElement(t),this.delegate.leavingBardo(t)}}replaceNewPermanentElementWithPlaceholder(e){let t=hr(e);e.replaceWith(t)}replaceCurrentPermanentElementWithClone(e){let 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 hr(e){let t=document.createElement("meta");return t.setAttribute("name","turbo-permanent-placeholder"),t.setAttribute("content",e.id),t}class ge{#e=null;static renderElement(e,t){}constructor(e,t,s,r=!0){this.currentSnapshot=e,this.newSnapshot=t,this.isPreview=s,this.willRender=r,this.renderElement=this.constructor.renderElement,this.promise=new Promise((i,n)=>this.resolvingFunctions={resolve:i,reject:n})}get shouldRender(){return!0}get shouldAutofocus(){return!0}get reloadReason(){return}prepareToRender(){return}render(){}finishRendering(){if(this.resolvingFunctions)this.resolvingFunctions.resolve(),delete this.resolvingFunctions}async preservingPermanentElements(e){await Ie.preservingPermanentElements(this,this.permanentElementMap,e)}focusFirstAutofocusableElement(){if(this.shouldAutofocus){let e=this.connectedSnapshot.firstAutofocusableElement;if(e)e.focus()}}enteringBardo(e){if(this.#e)return;if(e.contains(this.currentSnapshot.activeElement))this.#e=this.currentSnapshot.activeElement}leavingBardo(e){if(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 be extends ge{static renderElement(e,t){let s=document.createRange();s.selectNodeContents(e),s.deleteContents();let r=t,i=r.ownerDocument?.createRange();if(i)i.selectNodeContents(r),e.appendChild(i.extractContents())}constructor(e,t,s,r,i,n=!0){super(t,s,r,i,n);this.delegate=e}get shouldRender(){return!0}async render(){await ee(),this.preservingPermanentElements(()=>{this.loadFrameElement()}),this.scrollFrameIntoView(),await ee(),this.focusFirstAutofocusableElement(),await ee(),this.activateScriptElements()}loadFrameElement(){this.delegate.willRenderFrame(this.currentElement,this.newElement),this.renderElement(this.currentElement,this.newElement)}scrollFrameIntoView(){if(this.currentElement.autoscroll||this.newElement.autoscroll){let e=this.currentElement.firstElementChild,t=ur(this.currentElement.getAttribute("data-autoscroll-block"),"end"),s=dr(this.currentElement.getAttribute("data-autoscroll-behavior"),"auto");if(e)return e.scrollIntoView({block:t,behavior:s}),!0}return!1}activateScriptElements(){for(let e of this.newScriptElements){let t=se(e);e.replaceWith(t)}}get newScriptElements(){return this.currentElement.querySelectorAll("script")}}function ur(e,t){if(e=="end"||e=="start"||e=="center"||e=="nearest")return e;else return t}function dr(e,t){if(e=="auto"||e=="smooth")return e;else return t}var fr=function(){let e=()=>{},t={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:e,afterNodeAdded:e,beforeNodeMorphed:e,afterNodeMorphed:e,beforeNodeRemoved:e,afterNodeRemoved:e,beforeAttributeUpdated:e},head:{style:"merge",shouldPreserve:(b)=>b.getAttribute("im-preserve")==="true",shouldReAppend:(b)=>b.getAttribute("im-re-append")==="true",shouldRemove:e,afterHeadMorphed:e},restoreFocus:!0};function s(b,A,y={}){b=B(b);let E=N(A),w=M(b,E,y),f=i(w,()=>p(w,b,E,(c)=>{if(c.morphStyle==="innerHTML")return n(c,b,E),Array.from(b.childNodes);else return r(c,b,E)}));return w.pantry.remove(),f}function r(b,A,y){let E=N(A);return n(b,E,y,A,A.nextSibling),Array.from(E.childNodes)}function i(b,A){if(!b.config.restoreFocus)return A();let y=document.activeElement;if(!(y instanceof HTMLInputElement||y instanceof HTMLTextAreaElement))return A();let{id:E,selectionStart:w,selectionEnd:f}=y,c=A();if(E&&E!==document.activeElement?.getAttribute("id"))y=b.target.querySelector(`[id="${E}"]`),y?.focus();if(y&&!y.selectionEnd&&f)y.setSelectionRange(w,f);return c}let n=function(){function b(a,o,u,h=null,m=null){if(o instanceof HTMLTemplateElement&&u instanceof HTMLTemplateElement)o=o.content,u=u.content;h||=o.firstChild;for(let g of u.childNodes){if(h&&h!=m){let S=y(a,g,h,m);if(S){if(S!==h)w(a,h,S);l(S,g,a),h=S.nextSibling;continue}}if(g instanceof Element){let S=g.getAttribute("id");if(a.persistentIds.has(S)){let D=f(o,S,h,a);l(D,g,a),h=D.nextSibling;continue}}let v=A(o,g,h,a);if(v)h=v.nextSibling}while(h&&h!=m){let g=h;h=h.nextSibling,E(a,g)}}function A(a,o,u,h){if(h.callbacks.beforeNodeAdded(o)===!1)return null;if(h.idMap.has(o)){let m=document.createElement(o.tagName);return a.insertBefore(m,u),l(m,o,h),h.callbacks.afterNodeAdded(m),m}else{let m=document.importNode(o,!0);return a.insertBefore(m,u),h.callbacks.afterNodeAdded(m),m}}let y=function(){function a(h,m,g,v){let S=null,D=m.nextSibling,Xe=0,P=g;while(P&&P!=v){if(u(P,m)){if(o(h,P,m))return P;if(S===null){if(!h.idMap.has(P))S=P}}if(S===null&&D&&u(P,D)){if(Xe++,D=D.nextSibling,Xe>=2)S=void 0}if(h.activeElementAndParents.includes(P))break;P=P.nextSibling}return S||null}function o(h,m,g){let v=h.idMap.get(m),S=h.idMap.get(g);if(!S||!v)return!1;for(let D of v)if(S.has(D))return!0;return!1}function u(h,m){let g=h,v=m;return g.nodeType===v.nodeType&&g.tagName===v.tagName&&(!g.getAttribute?.("id")||g.getAttribute?.("id")===v.getAttribute?.("id"))}return a}();function E(a,o){if(a.idMap.has(o))d(a.pantry,o,null);else{if(a.callbacks.beforeNodeRemoved(o)===!1)return;o.parentNode?.removeChild(o),a.callbacks.afterNodeRemoved(o)}}function w(a,o,u){let h=o;while(h&&h!==u){let m=h;h=h.nextSibling,E(a,m)}return h}function f(a,o,u,h){let m=h.target.getAttribute?.("id")===o&&h.target||h.target.querySelector(`[id="${o}"]`)||h.pantry.querySelector(`[id="${o}"]`);return c(m,h),d(a,m,u),m}function c(a,o){let u=a.getAttribute("id");while(a=a.parentNode){let h=o.idMap.get(a);if(h){if(h.delete(u),!h.size)o.idMap.delete(a)}}}function d(a,o,u){if(a.moveBefore)try{a.moveBefore(o,u)}catch(h){a.insertBefore(o,u)}else a.insertBefore(o,u)}return b}(),l=function(){function b(c,d,a){if(a.ignoreActive&&c===document.activeElement)return null;if(a.callbacks.beforeNodeMorphed(c,d)===!1)return c;if(c instanceof HTMLHeadElement&&a.head.ignore);else if(c instanceof HTMLHeadElement&&a.head.style!=="morph")O(c,d,a);else if(A(c,d,a),!f(c,a))n(a,c,d);return a.callbacks.afterNodeMorphed(c,d),c}function A(c,d,a){let o=d.nodeType;if(o===1){let u=c,h=d,m=u.attributes,g=h.attributes;for(let v of g){if(w(v.name,u,"update",a))continue;if(u.getAttribute(v.name)!==v.value)u.setAttribute(v.name,v.value)}for(let v=m.length-1;0<=v;v--){let S=m[v];if(!S)continue;if(!h.hasAttribute(S.name)){if(w(S.name,u,"remove",a))continue;u.removeAttribute(S.name)}}if(!f(u,a))y(u,h,a)}if(o===8||o===3){if(c.nodeValue!==d.nodeValue)c.nodeValue=d.nodeValue}}function y(c,d,a){if(c instanceof HTMLInputElement&&d instanceof HTMLInputElement&&d.type!=="file"){let o=d.value,u=c.value;if(E(c,d,"checked",a),E(c,d,"disabled",a),!d.hasAttribute("value")){if(!w("value",c,"remove",a))c.value="",c.removeAttribute("value")}else if(u!==o){if(!w("value",c,"update",a))c.setAttribute("value",o),c.value=o}}else if(c instanceof HTMLOptionElement&&d instanceof HTMLOptionElement)E(c,d,"selected",a);else if(c instanceof HTMLTextAreaElement&&d instanceof HTMLTextAreaElement){let o=d.value,u=c.value;if(w("value",c,"update",a))return;if(o!==u)c.value=o;if(c.firstChild&&c.firstChild.nodeValue!==o)c.firstChild.nodeValue=o}}function E(c,d,a,o){let u=d[a],h=c[a];if(u!==h){let m=w(a,c,"update",o);if(!m)c[a]=d[a];if(u){if(!m)c.setAttribute(a,"")}else if(!w(a,c,"remove",o))c.removeAttribute(a)}}function w(c,d,a,o){if(c==="value"&&o.ignoreActiveValue&&d===document.activeElement)return!0;return o.callbacks.beforeAttributeUpdated(c,d,a)===!1}function f(c,d){return!!d.ignoreActiveValue&&c===document.activeElement&&c!==document.body}return b}();function p(b,A,y,E){if(b.head.block){let w=A.querySelector("head"),f=y.querySelector("head");if(w&&f){let c=O(w,f,b);return Promise.all(c).then(()=>{let d=Object.assign(b,{head:{block:!1,ignore:!0}});return E(d)})}}return E(b)}function O(b,A,y){let E=[],w=[],f=[],c=[],d=new Map;for(let o of A.children)d.set(o.outerHTML,o);for(let o of b.children){let u=d.has(o.outerHTML),h=y.head.shouldReAppend(o),m=y.head.shouldPreserve(o);if(u||m)if(h)w.push(o);else d.delete(o.outerHTML),f.push(o);else if(y.head.style==="append"){if(h)w.push(o),c.push(o)}else if(y.head.shouldRemove(o)!==!1)w.push(o)}c.push(...d.values());let a=[];for(let o of c){let u=document.createRange().createContextualFragment(o.outerHTML).firstChild;if(y.callbacks.beforeNodeAdded(u)!==!1){if("href"in u&&u.href||"src"in u&&u.src){let h,m=new Promise(function(g){h=g});u.addEventListener("load",function(){h()}),a.push(m)}b.appendChild(u),y.callbacks.afterNodeAdded(u),E.push(u)}}for(let o of w)if(y.callbacks.beforeNodeRemoved(o)!==!1)b.removeChild(o),y.callbacks.afterNodeRemoved(o);return y.head.afterHeadMorphed(b,{added:E,kept:f,removed:w}),a}let M=function(){function b(a,o,u){let{persistentIds:h,idMap:m}=c(a,o),g=A(u),v=g.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(v))throw`Do not understand how to morph style ${v}`;return{target:a,newContent:o,config:g,morphStyle:v,ignoreActive:g.ignoreActive,ignoreActiveValue:g.ignoreActiveValue,restoreFocus:g.restoreFocus,idMap:m,persistentIds:h,pantry:y(),activeElementAndParents:E(a),callbacks:g.callbacks,head:g.head}}function A(a){let o=Object.assign({},t);return Object.assign(o,a),o.callbacks=Object.assign({},t.callbacks,a.callbacks),o.head=Object.assign({},t.head,a.head),o}function y(){let a=document.createElement("div");return a.hidden=!0,document.body.insertAdjacentElement("afterend",a),a}function E(a){let o=[],u=document.activeElement;if(u?.tagName!=="BODY"&&a.contains(u))while(u){if(o.push(u),u===a)break;u=u.parentElement}return o}function w(a){let o=Array.from(a.querySelectorAll("[id]"));if(a.getAttribute?.("id"))o.push(a);return o}function f(a,o,u,h){for(let m of h){let g=m.getAttribute("id");if(o.has(g)){let v=m;while(v){let S=a.get(v);if(S==null)S=new Set,a.set(v,S);if(S.add(g),v===u)break;v=v.parentElement}}}}function c(a,o){let u=w(a),h=w(o),m=d(u,h),g=new Map;f(g,m,a,u);let v=o.__idiomorphRoot||o;return f(g,m,v,h),{persistentIds:m,idMap:g}}function d(a,o){let u=new Set,h=new Map;for(let{id:g,tagName:v}of a)if(h.has(g))u.add(g);else h.set(g,v);let m=new Set;for(let{id:g,tagName:v}of o)if(m.has(g))u.add(g);else if(h.get(g)===v)m.add(g);for(let g of u)m.delete(g);return m}return b}(),{normalizeElement:B,normalizeParent:N}=function(){let b=new WeakSet;function A(f){if(f instanceof Document)return f.documentElement;else return f}function y(f){if(f==null)return document.createElement("div");else if(typeof f==="string")return y(w(f));else if(b.has(f))return f;else if(f instanceof Node)if(f.parentNode)return new E(f);else{let c=document.createElement("div");return c.append(f),c}else{let c=document.createElement("div");for(let d of[...f])c.append(d);return c}}class E{constructor(f){this.originalNode=f,this.realParentNode=f.parentNode,this.previousSibling=f.previousSibling,this.nextSibling=f.nextSibling}get childNodes(){let f=[],c=this.previousSibling?this.previousSibling.nextSibling:this.realParentNode.firstChild;while(c&&c!=this.nextSibling)f.push(c),c=c.nextSibling;return f}querySelectorAll(f){return this.childNodes.reduce((c,d)=>{if(d instanceof Element){if(d.matches(f))c.push(d);let a=d.querySelectorAll(f);for(let o=0;o<a.length;o++)c.push(a[o])}return c},[])}insertBefore(f,c){return this.realParentNode.insertBefore(f,c)}moveBefore(f,c){return this.realParentNode.moveBefore(f,c)}get __idiomorphRoot(){return this.originalNode}}function w(f){let c=new DOMParser,d=f.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(d.match(/<\/html>/)||d.match(/<\/head>/)||d.match(/<\/body>/)){let a=c.parseFromString(f,"text/html");if(d.match(/<\/html>/))return b.add(a),a;else{let o=a.firstChild;if(o)b.add(o);return o}}else{let o=c.parseFromString("<body><template>"+f+"</template></body>","text/html").body.querySelector("template").content;return b.add(o),o}}return{normalizeElement:A,normalizeParent:y}}();return{morph:s,defaults:t}}();function ve(e,t,{callbacks:s,...r}={}){fr.morph(e,t,{...r,callbacks:new Mt(s)})}function Be(e,t,s={}){ve(e,t.childNodes,{...s,morphStyle:"innerHTML"})}function Tt(e,t){return e instanceof F&&e.shouldReloadWithMorph&&(!t||mr(e,t))&&!e.closest("[data-turbo-permanent]")}function mr(e,t){return t instanceof Element&&t.nodeName==="TURBO-FRAME"&&e.id===t.id&&(!t.getAttribute("src")||ft(e.src,t.getAttribute("src")))}function Lt(e){return e.parentElement.closest("turbo-frame[src][refresh=morph]")}class Mt{#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)if(!e.hasAttribute("data-turbo-permanent")&&this.#e(e,t))return!T("turbo:before-morph-element",{cancelable:!0,target:e,detail:{currentElement:e,newElement:t}}).defaultPrevented;else return!1};beforeAttributeUpdated=(e,t,s)=>!T("turbo:before-morph-attribute",{cancelable:!0,target:t,detail:{attributeName:e,mutationType:s}}).defaultPrevented;beforeNodeRemoved=(e)=>this.beforeNodeMorphed(e);afterNodeMorphed=(e,t)=>{if(e instanceof Element)T("turbo:morph-element",{target:e,detail:{currentElement:e,newElement:t}})}}class Ne extends be{static renderElement(e,t){T("turbo:before-frame-morph",{target:e,detail:{currentElement:e,newElement:t}}),Be(e,t,{callbacks:{beforeNodeMorphed:(s,r)=>{if(Tt(s,r)&&Lt(s)===e)return s.reload(),!1;return!0}}})}async preservingPermanentElements(e){return await e()}}class H{static animationDuration=300;static get defaultCSS(){return nt`
7
7
  .turbo-progress-bar {
8
8
  position: fixed;
9
9
  display: block;
@@ -13,11 +13,11 @@ Copyright © 2026 37signals LLC
13
13
  background: #0076ff;
14
14
  z-index: 2147483647;
15
15
  transition:
16
- width ${v.animationDuration}ms ease-out,
17
- opacity ${v.animationDuration/2}ms ${v.animationDuration/2}ms ease-in;
16
+ width ${H.animationDuration}ms ease-out,
17
+ opacity ${H.animationDuration/2}ms ${H.animationDuration/2}ms ease-in;
18
18
  transform: translate3d(0, 0, 0);
19
19
  }
20
- `}hiding=!1;value=0;visible=!1;constructor(){this.stylesheetElement=this.createStylesheetElement(),this.progressElement=this.createProgressElement(),this.installStylesheetElement(),this.setValue(0)}show(){if(!this.visible)this.visible=!0,this.installProgressElement(),this.startTrickling()}hide(){if(this.visible&&!this.hiding)this.hiding=!0,this.fadeProgressElement(()=>{this.uninstallProgressElement(),this.stopTrickling(),this.visible=!1,this.hiding=!1})}setValue(H){this.value=H,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(H){this.progressElement.style.opacity="0",setTimeout(H,v.animationDuration*1.5)}uninstallProgressElement(){if(this.progressElement.parentNode)document.documentElement.removeChild(this.progressElement)}startTrickling(){if(!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(){let H=document.createElement("style");H.type="text/css",H.textContent=v.defaultCSS;let J=$1();if(J)H.nonce=J;return H}createProgressElement(){let H=document.createElement("div");return H.className="turbo-progress-bar",H}}class R1 extends QH{detailsByOuterHTML=this.children.filter((H)=>!FQ(H)).map((H)=>LQ(H)).reduce((H,J)=>{let{outerHTML:Q}=J,X=Q in H?H[Q]:{type:_Q(J),tracked:BQ(J),elements:[]};return{...H,[Q]:{...X,elements:[...X.elements,J]}}},{});get trackedElementSignature(){return Object.keys(this.detailsByOuterHTML).filter((H)=>this.detailsByOuterHTML[H].tracked).join("")}getScriptElementsNotInSnapshot(H){return this.getElementsMatchingTypeNotInSnapshot("script",H)}getStylesheetElementsNotInSnapshot(H){return this.getElementsMatchingTypeNotInSnapshot("stylesheet",H)}getElementsMatchingTypeNotInSnapshot(H,J){return Object.keys(this.detailsByOuterHTML).filter((Q)=>!(Q in J.detailsByOuterHTML)).map((Q)=>this.detailsByOuterHTML[Q]).filter(({type:Q})=>Q==H).map(({elements:[Q]})=>Q)}get provisionalElements(){return Object.keys(this.detailsByOuterHTML).reduce((H,J)=>{let{type:Q,tracked:X,elements:Y}=this.detailsByOuterHTML[J];if(Q==null&&!X)return[...H,...Y];else if(Y.length>1)return[...H,...Y.slice(1)];else return H},[])}getMetaValue(H){let J=this.findMetaElementByName(H);return J?J.getAttribute("content"):null}findMetaElementByName(H){return Object.keys(this.detailsByOuterHTML).reduce((J,Q)=>{let{elements:[X]}=this.detailsByOuterHTML[Q];return PQ(X,H)?X:J},void 0|void 0)}}function _Q(H){if(IQ(H))return"script";else if(MQ(H))return"stylesheet"}function BQ(H){return H.getAttribute("data-turbo-track")=="reload"}function IQ(H){return H.localName=="script"}function FQ(H){return H.localName=="noscript"}function MQ(H){let J=H.localName;return J=="style"||J=="link"&&H.getAttribute("rel")=="stylesheet"}function PQ(H,J){return H.localName=="meta"&&H.getAttribute("name")==J}function LQ(H){if(H.hasAttribute("nonce"))H.setAttribute("nonce","");return H}class g extends QH{static fromHTMLString(H=""){return this.fromDocument(X1(H))}static fromElement(H){return this.fromDocument(H.ownerDocument)}static fromDocument({documentElement:H,body:J,head:Q}){return new this(H,J,new R1(Q))}constructor(H,J,Q){super(J);this.documentElement=H,this.headSnapshot=Q}clone(){let H=this.element.cloneNode(!0),J=this.element.querySelectorAll("select"),Q=H.querySelectorAll("select");for(let[X,Y]of J.entries()){let Z=Q[X];for(let A of Z.selectedOptions)A.selected=!1;for(let A of Y.selectedOptions)Z.options[A.index].selected=!0}for(let X of H.querySelectorAll('input[type="password"]'))X.value="";for(let X of H.querySelectorAll("noscript"))X.remove();return new g(this.documentElement,H,this.headSnapshot)}get lang(){return this.documentElement.getAttribute("lang")}get dir(){return this.documentElement.getAttribute("dir")}get headElement(){return this.headSnapshot.element}get rootLocation(){let H=this.getSetting("root")??"/";return T(H)}get 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.getSetting("view-transition")==="true"||this.headSnapshot.getMetaValue("view-transition")==="same-origin")&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches}get refreshMethod(){return this.getSetting("refresh-method")}get refreshScroll(){return this.getSetting("refresh-scroll")}getSetting(H){return this.headSnapshot.getMetaValue(`turbo-${H}`)}}class V1{#H=!1;#J=Promise.resolve();renderChange(H,J){if(H&&this.viewTransitionsAvailable&&!this.#H)this.#H=!0,this.#J=this.#J.then(async()=>{await document.startViewTransition(J).finished});else this.#J=this.#J.then(J);return this.#J}get viewTransitionsAvailable(){return document.startViewTransition}}var jQ={action:"advance",historyChanged:!1,visitCachedSnapshot:()=>{},willRender:!0,updateHistory:!0,shouldCacheSnapshot:!0,acceptsStreamResponse:!1,refresh:{}},$H={visitStart:"visitStart",requestStart:"requestStart",requestEnd:"requestEnd",visitEnd:"visitEnd"},N={initialized:"initialized",started:"started",canceled:"canceled",failed:"failed",completed:"completed"},n={networkFailure:0,timeoutFailure:-1,contentTypeMismatch:-2},SQ={advance:"forward",restore:"back",replace:"none"};class T1{identifier=d();timingMetrics={};followedRedirect=!1;historyChanged=!1;scrolled=!1;shouldCacheSnapshot=!0;acceptsStreamResponse=!1;snapshotCached=!1;state=N.initialized;viewTransitioner=new V1;constructor(H,J,Q,X={}){this.delegate=H,this.location=J,this.restorationIdentifier=Q||d();let{action:Y,historyChanged:Z,referrer:A,snapshot:B,snapshotHTML:D,response:R,visitCachedSnapshot:y,willRender:b,updateHistory:F,shouldCacheSnapshot:C,acceptsStreamResponse:P,direction:L,refresh:j}={...jQ,...X};this.action=Y,this.historyChanged=Z,this.referrer=A,this.snapshot=B,this.snapshotHTML=D,this.response=R,this.isPageRefresh=this.view.isPageRefresh(this),this.visitCachedSnapshot=y,this.willRender=b,this.updateHistory=F,this.scrolled=!b,this.shouldCacheSnapshot=C,this.acceptsStreamResponse=P,this.direction=L||SQ[Y],this.refresh=j}get adapter(){return this.delegate.adapter}get view(){return this.delegate.view}get history(){return this.delegate.history}get restorationData(){return this.history.getRestorationDataForIdentifier(this.restorationIdentifier)}start(){if(this.state==N.initialized)this.recordTimingMetric($H.visitStart),this.state=N.started,this.adapter.visitStarted(this),this.delegate.visitStarted(this)}cancel(){if(this.state==N.started){if(this.request)this.request.cancel();this.cancelRender(),this.state=N.canceled}}complete(){if(this.state==N.started){if(this.recordTimingMetric($H.visitEnd),this.adapter.visitCompleted(this),this.state=N.completed,this.followRedirect(),!this.followedRedirect)this.delegate.visitCompleted(this)}}fail(){if(this.state==N.started)this.state=N.failed,this.adapter.visitFailed(this),this.delegate.visitCompleted(this)}changeHistory(){if(!this.historyChanged&&this.updateHistory){let H=this.location.href===this.referrer?.href?"replace":this.action,J=Z1(H);this.history.update(J,this.location,this.restorationIdentifier),this.historyChanged=!0}}issueRequest(){if(this.hasPreloadedResponse())this.simulateRequest();else if(this.shouldIssueRequest()&&!this.request)this.request=new t(this,O.get,this.location),this.request.perform()}simulateRequest(){if(this.response)this.startRequest(),this.recordResponse(),this.finishRequest()}startRequest(){this.recordTimingMetric($H.requestStart),this.adapter.visitRequestStarted(this)}recordResponse(H=this.response){if(this.response=H,H){let{statusCode:J}=H;if(tH(J))this.adapter.visitRequestCompleted(this);else this.adapter.visitRequestFailedWithStatusCode(this,J)}}finishRequest(){this.recordTimingMetric($H.requestEnd),this.adapter.visitRequestFinished(this)}loadResponse(){if(this.response){let{statusCode:H,responseHTML:J}=this.response;this.render(async()=>{if(this.shouldCacheSnapshot)this.cacheSnapshot();if(this.view.renderPromise)await this.view.renderPromise;if(tH(H)&&J!=null){let Q=g.fromHTMLString(J);await this.renderPageSnapshot(Q,!1),this.adapter.visitRendered(this),this.complete()}else await this.view.renderError(g.fromHTMLString(J),this),this.adapter.visitRendered(this),this.fail()})}}getCachedSnapshot(){let H=this.view.getCachedSnapshotForLocation(this.location)||this.getPreloadedSnapshot();if(H&&(!HH(this.location)||H.hasAnchor(HH(this.location)))){if(this.action=="restore"||H.isPreviewable)return H}}getPreloadedSnapshot(){if(this.snapshotHTML)return g.fromHTMLString(this.snapshotHTML)}hasCachedSnapshot(){return this.getCachedSnapshot()!=null}loadCachedSnapshot(){let H=this.getCachedSnapshot();if(H){let J=this.shouldIssueRequest();this.render(async()=>{if(this.cacheSnapshot(),this.isPageRefresh)this.adapter.visitRendered(this);else{if(this.view.renderPromise)await this.view.renderPromise;if(await this.renderPageSnapshot(H,J),this.adapter.visitRendered(this),!J)this.complete()}})}}followRedirect(){if(this.redirectedToLocation&&!this.followedRedirect&&this.response?.redirected)this.adapter.visitProposedToLocation(this.redirectedToLocation,{action:"replace",response:this.response,shouldCacheSnapshot:!1,willRender:!1}),this.followedRedirect=!0}prepareRequest(H){if(this.acceptsStreamResponse)H.acceptResponseType(m.contentType)}requestStarted(){this.startRequest()}requestPreventedHandlingResponse(H,J){}async requestSucceededWithResponse(H,J){let Q=await J.responseHTML,{redirected:X,statusCode:Y}=J;if(Q==null)this.recordResponse({statusCode:n.contentTypeMismatch,redirected:X});else this.redirectedToLocation=J.redirected?J.location:void 0,this.recordResponse({statusCode:Y,responseHTML:Q,redirected:X})}async requestFailedWithResponse(H,J){let Q=await J.responseHTML,{redirected:X,statusCode:Y}=J;if(Q==null)this.recordResponse({statusCode:n.contentTypeMismatch,redirected:X});else this.recordResponse({statusCode:Y,responseHTML:Q,redirected:X})}requestErrored(H,J){this.recordResponse({statusCode:n.networkFailure,redirected:!1})}requestFinished(){this.finishRequest()}performScroll(){if(!this.scrolled&&!this.view.forceReloaded&&!this.view.shouldPreserveScrollPosition(this)){if(this.action=="restore")this.scrollToRestoredPosition()||this.scrollToAnchor()||this.view.scrollToTop();else this.scrollToAnchor()||this.view.scrollToTop();this.scrolled=!0}}scrollToRestoredPosition(){let{scrollPosition:H}=this.restorationData;if(H)return this.view.scrollToPosition(H),!0}scrollToAnchor(){let H=HH(this.location);if(H!=null)return this.view.scrollToAnchor(H),!0}recordTimingMetric(H){this.timingMetrics[H]=new Date().getTime()}getTimingMetrics(){return{...this.timingMetrics}}hasPreloadedResponse(){return typeof this.response=="object"}shouldIssueRequest(){if(this.action=="restore")return!this.hasCachedSnapshot();else return this.willRender}cacheSnapshot(){if(!this.snapshotCached)this.view.cacheSnapshot(this.snapshot).then((H)=>H&&this.visitCachedSnapshot(H)),this.snapshotCached=!0}async render(H){this.cancelRender(),await new Promise((J)=>{this.frame=document.visibilityState==="hidden"?setTimeout(()=>J(),0):requestAnimationFrame(()=>J())}),await H(),delete this.frame}async renderPageSnapshot(H,J){await this.viewTransitioner.renderChange(this.view.shouldTransitionTo(H),async()=>{await this.view.renderPage(H,J,this.willRender,this),this.performScroll()})}cancelRender(){if(this.frame)cancelAnimationFrame(this.frame),delete this.frame}}function tH(H){return H>=200&&H<300}class D1{progressBar=new v;constructor(H){this.session=H}visitProposedToLocation(H,J){if(p(H,this.navigator.rootLocation))this.navigator.startVisit(H,J?.restorationIdentifier||d(),J);else window.location.href=H.toString()}visitStarted(H){this.location=H.location,this.redirectedToLocation=null,H.loadCachedSnapshot(),H.issueRequest()}visitRequestStarted(H){if(this.progressBar.setValue(0),H.hasCachedSnapshot()||H.action!="restore")this.showVisitProgressBarAfterDelay();else this.showProgressBar()}visitRequestCompleted(H){if(H.loadResponse(),H.response.redirected)this.redirectedToLocation=H.redirectedToLocation}visitRequestFailedWithStatusCode(H,J){switch(J){case n.networkFailure:case n.timeoutFailure:case n.contentTypeMismatch:return this.reload({reason:"request_failed",context:{statusCode:J}});default:return H.loadResponse()}}visitRequestFinished(H){}visitCompleted(H){this.progressBar.setValue(1),this.hideVisitProgressBar()}pageInvalidated(H){this.reload(H)}visitFailed(H){this.progressBar.setValue(1),this.hideVisitProgressBar()}visitRendered(H){}linkPrefetchingIsEnabledForLocation(H){return!0}formSubmissionStarted(H){this.progressBar.setValue(0),this.showFormProgressBarAfterDelay()}formSubmissionFinished(H){this.progressBar.setValue(1),this.hideFormProgressBar()}showVisitProgressBarAfterDelay(){this.visitProgressBarTimeout=window.setTimeout(this.showProgressBar,this.session.progressBarDelay)}hideVisitProgressBar(){if(this.progressBar.hide(),this.visitProgressBarTimeout!=null)window.clearTimeout(this.visitProgressBarTimeout),delete this.visitProgressBarTimeout}showFormProgressBarAfterDelay(){if(this.formProgressBarTimeout==null)this.formProgressBarTimeout=window.setTimeout(this.showProgressBar,this.session.progressBarDelay)}hideFormProgressBar(){if(this.progressBar.hide(),this.formProgressBarTimeout!=null)window.clearTimeout(this.formProgressBarTimeout),delete this.formProgressBarTimeout}showProgressBar=()=>{this.progressBar.show()};reload(H){w("turbo:reload",{detail:H}),window.location.href=(this.redirectedToLocation||this.location)?.toString()||window.location.href}get navigator(){return this.session.navigator}}class O1{selector="[data-turbo-temporary]";started=!1;start(){if(!this.started)this.started=!0,addEventListener("turbo:before-cache",this.removeTemporaryElements,!1)}stop(){if(this.started)this.started=!1,removeEventListener("turbo:before-cache",this.removeTemporaryElements,!1)}removeTemporaryElements=(H)=>{for(let J of this.temporaryElements)J.remove()};get temporaryElements(){return[...document.querySelectorAll(this.selector)]}}class x1{constructor(H,J){this.session=H,this.element=J,this.linkInterceptor=new DH(this,J),this.formSubmitObserver=new _H(this,J)}start(){this.linkInterceptor.start(),this.formSubmitObserver.start()}stop(){this.linkInterceptor.stop(),this.formSubmitObserver.stop()}shouldInterceptLinkClick(H,J,Q){return this.#J(H)}linkClickIntercepted(H,J,Q){let X=this.#Q(H);if(X)X.delegate.linkClickIntercepted(H,J,Q)}willSubmitForm(H,J){return H.closest("turbo-frame")==null&&this.#H(H,J)&&this.#J(H,J)}formSubmitted(H,J){let Q=this.#Q(H,J);if(Q)Q.delegate.formSubmitted(H,J)}#H(H,J){let Q=wH(H,J),X=this.element.ownerDocument.querySelector('meta[name="turbo-root"]'),Y=T(X?.content??"/");return this.#J(H,J)&&p(Q,Y)}#J(H,J){if(H instanceof HTMLFormElement?this.session.submissionIsNavigatable(H,J):this.session.elementIsNavigatable(H)){let X=this.#Q(H,J);return X?X!=H.closest("turbo-frame"):!1}else return!1}#Q(H,J){let Q=J?.getAttribute("data-turbo-frame")||H.getAttribute("data-turbo-frame");if(Q&&Q!="_top"){let X=this.element.querySelector(`#${Q}:not([disabled])`);if(X instanceof x)return X}}}class h1{location;restorationIdentifier=d();restorationData={};started=!1;currentIndex=0;constructor(H){this.delegate=H}start(){if(!this.started)addEventListener("popstate",this.onPopState,!1),this.currentIndex=history.state?.turbo?.restorationIndex||0,this.started=!0,this.replace(new URL(window.location.href))}stop(){if(this.started)removeEventListener("popstate",this.onPopState,!1),this.started=!1}push(H,J){this.update(history.pushState,H,J)}replace(H,J){this.update(history.replaceState,H,J)}update(H,J,Q=d()){if(H===history.pushState)++this.currentIndex;let X={turbo:{restorationIdentifier:Q,restorationIndex:this.currentIndex}};H.call(history,X,"",J.href),this.location=J,this.restorationIdentifier=Q}getRestorationDataForIdentifier(H){return this.restorationData[H]||{}}updateRestorationData(H){let{restorationIdentifier:J}=this,Q=this.restorationData[J];this.restorationData[J]={...Q,...H}}assumeControlOfScrollRestoration(){if(!this.previousScrollRestoration)this.previousScrollRestoration=history.scrollRestoration??"auto",history.scrollRestoration="manual"}relinquishControlOfScrollRestoration(){if(this.previousScrollRestoration)history.scrollRestoration=this.previousScrollRestoration,delete this.previousScrollRestoration}onPopState=(H)=>{let{turbo:J}=H.state||{};if(this.location=new URL(window.location.href),J){let{restorationIdentifier:Q,restorationIndex:X}=J;this.restorationIdentifier=Q;let Y=X>this.currentIndex?"forward":"back";this.delegate.historyPoppedToLocationWithRestorationIdentifierAndDirection(this.location,Q,Y),this.currentIndex=X}else this.currentIndex++,this.delegate.historyPoppedWithEmptyState(this.location)}}class g1{started=!1;#H=null;constructor(H,J){this.delegate=H,this.eventTarget=J}start(){if(this.started)return;if(this.eventTarget.readyState==="loading")this.eventTarget.addEventListener("DOMContentLoaded",this.#J,{once:!0});else this.#J()}stop(){if(!this.started)return;this.eventTarget.removeEventListener("mouseenter",this.#Q,{capture:!0,passive:!0}),this.eventTarget.removeEventListener("mouseleave",this.#$,{capture:!0,passive:!0}),this.eventTarget.removeEventListener("turbo:before-fetch-request",this.#Y,!0),this.started=!1}#J=()=>{this.eventTarget.addEventListener("mouseenter",this.#Q,{capture:!0,passive:!0}),this.eventTarget.addEventListener("mouseleave",this.#$,{capture:!0,passive:!0}),this.eventTarget.addEventListener("turbo:before-fetch-request",this.#Y,!0),this.started=!0};#Q=(H)=>{if(UH("turbo-prefetch")==="false")return;let J=H.target;if(J.matches&&J.matches("a[href]:not([target^=_]):not([download])")&&this.#W(J)){let X=J,Y=U1(X);if(this.delegate.canPrefetchRequestToLocation(X,Y)){this.#H=X;let Z=new t(this,O.get,Y,new URLSearchParams,J);Z.fetchOptions.priority="low",r.putLater(Y,Z,this.#X)}}};#$=(H)=>{if(H.target===this.#H)this.#G()};#G=()=>{r.clear(),this.#H=null};#Y=(H)=>{if(H.target.tagName!=="FORM"&&H.detail.fetchOptions.method==="GET"){let J=r.get(H.detail.url);if(J)H.detail.fetchRequest=J;r.clear()}};prepareRequest(H){let J=H.target;H.headers["X-Sec-Purpose"]="prefetch";let Q=J.closest("turbo-frame"),X=J.getAttribute("data-turbo-frame")||Q?.getAttribute("target")||Q?.id;if(X&&X!=="_top")H.headers["Turbo-Frame"]=X}requestSucceededWithResponse(){}requestStarted(H){}requestErrored(H){}requestFinished(H){}requestPreventedHandlingResponse(H,J){}requestFailedWithResponse(H,J){}get#X(){return Number(UH("turbo-prefetch-cache-time"))||P1}#W(H){if(!H.getAttribute("href"))return!1;if(CQ(H))return!1;if(wQ(H))return!1;if(EQ(H))return!1;if(RQ(H))return!1;if(TQ(H))return!1;return!0}}var CQ=(H)=>{return H.origin!==document.location.origin||!["http:","https:"].includes(H.protocol)||H.hasAttribute("target")},wQ=(H)=>{return H.pathname+H.search===document.location.pathname+document.location.search||H.href.startsWith("#")},EQ=(H)=>{if(H.getAttribute("data-turbo-prefetch")==="false")return!0;if(H.getAttribute("data-turbo")==="false")return!0;let J=l(H,"[data-turbo-prefetch]");if(J&&J.getAttribute("data-turbo-prefetch")==="false")return!0;return!1},RQ=(H)=>{let J=H.getAttribute("data-turbo-method");if(J&&J.toLowerCase()!=="get")return!0;if(VQ(H))return!0;if(H.hasAttribute("data-turbo-confirm"))return!0;if(H.hasAttribute("data-turbo-stream"))return!0;return!1},VQ=(H)=>{return H.hasAttribute("data-remote")||H.hasAttribute("data-behavior")||H.hasAttribute("data-confirm")||H.hasAttribute("data-method")},TQ=(H)=>{return w("turbo:before-prefetch",{target:H,cancelable:!0}).defaultPrevented};class y1{constructor(H){this.delegate=H}proposeVisit(H,J={}){if(this.delegate.allowsVisitingLocationWithAction(H,J.action))this.delegate.visitProposedToLocation(H,J)}startVisit(H,J,Q={}){this.stop(),this.currentVisit=new T1(this,T(H),J,{referrer:this.location,...Q}),this.currentVisit.start()}submitForm(H,J){this.stop(),this.formSubmission=new KH(this,H,J,!0),this.formSubmission.start()}stop(){if(this.formSubmission)this.formSubmission.stop(),delete this.formSubmission;if(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(H){if(typeof this.adapter.formSubmissionStarted==="function")this.adapter.formSubmissionStarted(H)}async formSubmissionSucceededWithResponse(H,J){if(H==this.formSubmission){let Q=await J.responseHTML;if(Q){let X=H.isSafe;if(!X)this.view.clearSnapshotCache();let{statusCode:Y,redirected:Z}=J,B={action:this.#H(H,J),shouldCacheSnapshot:X,response:{statusCode:Y,responseHTML:Q,redirected:Z}};this.proposeVisit(J.location,B)}}}async formSubmissionFailedWithResponse(H,J){let Q=await J.responseHTML;if(Q){let X=g.fromHTMLString(Q);if(J.serverError)await this.view.renderError(X,this.currentVisit);else await this.view.renderPage(X,!1,!0,this.currentVisit);if(X.refreshScroll!=="preserve")this.view.scrollToTop();this.view.clearSnapshotCache()}}formSubmissionErrored(H,J){console.error(J)}formSubmissionFinished(H){if(typeof this.adapter.formSubmissionFinished==="function")this.adapter.formSubmissionFinished(H)}linkPrefetchingIsEnabledForLocation(H){if(typeof this.adapter.linkPrefetchingIsEnabledForLocation==="function")return this.adapter.linkPrefetchingIsEnabledForLocation(H);return!0}visitStarted(H){this.delegate.visitStarted(H)}visitCompleted(H){this.delegate.visitCompleted(H),delete this.currentVisit}locationWithActionIsSamePage(H,J){return!1}get location(){return this.history.location}get restorationIdentifier(){return this.history.restorationIdentifier}#H(H,J){let{submitter:Q,formElement:X}=H;return i(Q,X)||this.#J(J)}#J(H){return H.redirected&&H.location.href===this.location?.href?"replace":"advance"}}var u={initial:0,loading:1,interactive:2,complete:3};class b1{stage=u.initial;started=!1;constructor(H){this.delegate=H}start(){if(!this.started){if(this.stage==u.initial)this.stage=u.loading;document.addEventListener("readystatechange",this.interpretReadyState,!1),addEventListener("pagehide",this.pageWillUnload,!1),this.started=!0}}stop(){if(this.started)document.removeEventListener("readystatechange",this.interpretReadyState,!1),removeEventListener("pagehide",this.pageWillUnload,!1),this.started=!1}interpretReadyState=()=>{let{readyState:H}=this;if(H=="interactive")this.pageIsInteractive();else if(H=="complete")this.pageIsComplete()};pageIsInteractive(){if(this.stage==u.loading)this.stage=u.interactive,this.delegate.pageBecameInteractive()}pageIsComplete(){if(this.pageIsInteractive(),this.stage==u.interactive)this.stage=u.complete,this.delegate.pageLoaded()}pageWillUnload=()=>{this.delegate.pageWillUnload()};get readyState(){return document.readyState}}class k1{started=!1;constructor(H){this.delegate=H}start(){if(!this.started)addEventListener("scroll",this.onScroll,!1),this.onScroll(),this.started=!0}stop(){if(this.started)removeEventListener("scroll",this.onScroll,!1),this.started=!1}onScroll=()=>{this.updatePosition({x:window.pageXOffset,y:window.pageYOffset})};updatePosition(H){this.delegate.scrollPositionChanged(H)}}class N1{render({fragment:H}){hH.preservingPermanentElements(this,DQ(H),()=>{OQ(H,()=>{xQ(()=>{document.documentElement.appendChild(H)})})})}enteringBardo(H,J){J.replaceWith(H.cloneNode(!0))}leavingBardo(){}}function DQ(H){let J=j1(document.documentElement),Q={};for(let X of J){let{id:Y}=X;for(let Z of H.querySelectorAll("turbo-stream")){let A=L1(Z.templateElement.content,Y);if(A)Q[Y]=[X,A]}}return Q}async function OQ(H,J){let Q=`turbo-stream-autofocus-${d()}`,X=H.querySelectorAll("turbo-stream"),Y=hQ(X),Z=null;if(Y){if(Y.id)Z=Y.id;else Z=Q;Y.id=Z}if(J(),await e(),(document.activeElement==null||document.activeElement==document.body)&&Z){let B=document.getElementById(Z);if(CH(B))B.focus();if(B&&B.id==Q)B.removeAttribute("id")}}async function xQ(H){let[J,Q]=await pJ(H,()=>document.activeElement),X=J&&J.id;if(X){let Y=document.getElementById(X);if(CH(Y)&&Y!=Q)Y.focus()}}function hQ(H){for(let J of H){let Q=G1(J.templateElement.content);if(Q)return Q}return null}class f1{sources=new Set;#H=!1;constructor(H){this.delegate=H}start(){if(!this.#H)this.#H=!0,addEventListener("turbo:before-fetch-response",this.inspectFetchResponse,!1)}stop(){if(this.#H)this.#H=!1,removeEventListener("turbo:before-fetch-response",this.inspectFetchResponse,!1)}connectStreamSource(H){if(!this.streamSourceIsConnected(H))this.sources.add(H),H.addEventListener("message",this.receiveMessageEvent,!1)}disconnectStreamSource(H){if(this.streamSourceIsConnected(H))this.sources.delete(H),H.removeEventListener("message",this.receiveMessageEvent,!1)}streamSourceIsConnected(H){return this.sources.has(H)}inspectFetchResponse=(H)=>{let J=gQ(H);if(J&&yQ(J))H.preventDefault(),this.receiveMessageResponse(J)};receiveMessageEvent=(H)=>{if(this.#H&&typeof H.data=="string")this.receiveMessageHTML(H.data)};async receiveMessageResponse(H){let J=await H.responseHTML;if(J)this.receiveMessageHTML(J)}receiveMessageHTML(H){this.delegate.receivedMessageFromStream(m.wrap(H))}}function gQ(H){let J=H.detail?.fetchResponse;if(J instanceof zH)return J}function yQ(H){return(H.contentType??"").startsWith(m.contentType)}class v1 extends BH{static renderElement(H,J){let{documentElement:Q,body:X}=document;Q.replaceChild(J,X)}async render(){this.replaceHeadAndBody(),this.activateScriptElements()}replaceHeadAndBody(){let{documentElement:H,head:J}=document;H.replaceChild(this.newHead,J),this.renderElement(this.currentElement,this.newElement)}activateScriptElements(){for(let H of this.scriptElements){let J=H.parentNode;if(J){let Q=JH(H);J.replaceChild(Q,H)}}}get newHead(){return this.newSnapshot.headSnapshot.element}get scriptElements(){return document.documentElement.querySelectorAll("script")}}class MH extends BH{static renderElement(H,J){if(document.body&&J instanceof HTMLBodyElement)document.body.replaceWith(J);else document.documentElement.appendChild(J)}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.#H(),await this.mergeHead()}async render(){if(this.willRender)await this.replaceBody()}finishRendering(){if(super.finishRendering(),!this.isPreview)this.focusFirstAutofocusableElement()}get currentHeadSnapshot(){return this.currentSnapshot.headSnapshot}get newHeadSnapshot(){return this.newSnapshot.headSnapshot}get newElement(){return this.newSnapshot.element}#H(){let{documentElement:H}=this.currentSnapshot,{dir:J,lang:Q}=this.newSnapshot;if(Q)H.setAttribute("lang",Q);else H.removeAttribute("lang");if(J)H.setAttribute("dir",J);else H.removeAttribute("dir")}async mergeHead(){let H=this.mergeProvisionalElements(),J=this.copyNewHeadStylesheetElements();if(this.copyNewHeadScriptElements(),await H,await J,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(){let H=[];for(let J of this.newHeadStylesheetElements)H.push(NJ(J)),document.head.appendChild(J);await Promise.all(H)}copyNewHeadScriptElements(){for(let H of this.newHeadScriptElements)document.head.appendChild(JH(H))}removeUnusedDynamicStylesheetElements(){for(let H of this.unusedDynamicStylesheetElements)document.head.removeChild(H)}async mergeProvisionalElements(){let H=[...this.newHeadProvisionalElements];for(let J of this.currentHeadProvisionalElements)if(!this.isCurrentElementInElementList(J,H))document.head.removeChild(J);for(let J of H)document.head.appendChild(J)}isCurrentElementInElementList(H,J){for(let[Q,X]of J.entries()){if(H.tagName=="TITLE"){if(X.tagName!="TITLE")continue;if(H.innerHTML==X.innerHTML)return J.splice(Q,1),!0}if(X.isEqualNode(H))return J.splice(Q,1),!0}return!1}removeCurrentHeadProvisionalElements(){for(let H of this.currentHeadProvisionalElements)document.head.removeChild(H)}copyNewHeadProvisionalElements(){for(let H of this.newHeadProvisionalElements)document.head.appendChild(H)}activateNewBody(){document.adoptNode(this.newElement),this.removeNoscriptElements(),this.activateNewBodyScriptElements()}removeNoscriptElements(){for(let H of this.newElement.querySelectorAll("noscript"))H.remove()}activateNewBodyScriptElements(){for(let H of this.newBodyScriptElements){let J=JH(H);H.replaceWith(J)}}async assignNewBody(){await this.renderElement(this.currentElement,this.newElement)}get unusedDynamicStylesheetElements(){return this.oldHeadStylesheetElements.filter((H)=>{return H.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 bH extends MH{static renderElement(H,J){FH(H,J,{callbacks:{beforeNodeMorphed:(Q,X)=>{if(C1(Q,X)&&!w1(Q))return Q.reload(),!1;return!0}}}),w("turbo:morph",{detail:{currentElement:H,newElement:J}})}async preservingPermanentElements(H){return await H()}get renderMethod(){return"morph"}get shouldAutofocus(){return!1}}class p1 extends VH{constructor(H){super(H,GH)}get snapshots(){return this.entries}}class d1 extends TH{snapshotCache=new p1(10);lastRenderedLocation=new URL(location.href);forceReloaded=!1;shouldTransitionTo(H){return this.snapshot.prefersViewTransitions&&H.prefersViewTransitions}renderPage(H,J=!1,Q=!0,X){let A=new(this.isPageRefresh(X)&&(X?.refresh?.method||this.snapshot.refreshMethod)==="morph"?bH:MH)(this.snapshot,H,J,Q);if(!A.shouldRender)this.forceReloaded=!0;else X?.changeHistory();return this.render(A)}renderError(H,J){J?.changeHistory();let Q=new v1(this.snapshot,H,!1);return this.render(Q)}clearSnapshotCache(){this.snapshotCache.clear()}async cacheSnapshot(H=this.snapshot){if(H.isCacheable){this.delegate.viewWillCacheSnapshot();let{lastRenderedLocation:J}=this;await Q1();let Q=H.clone();return this.snapshotCache.put(J,Q),Q}}getCachedSnapshotForLocation(H){return this.snapshotCache.get(H)}isPageRefresh(H){return!H||this.lastRenderedLocation.pathname===H.location.pathname&&H.action==="replace"}shouldPreserveScrollPosition(H){return this.isPageRefresh(H)&&(H?.refresh?.scroll||this.snapshot.refreshScroll)==="preserve"}get snapshot(){return g.fromElement(this.element)}}class c1{selector="a[data-turbo-preload]";constructor(H,J){this.delegate=H,this.snapshotCache=J}start(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",this.#H);else this.preloadOnLoadLinksForView(document.body)}stop(){document.removeEventListener("DOMContentLoaded",this.#H)}preloadOnLoadLinksForView(H){for(let J of H.querySelectorAll(this.selector))if(this.delegate.shouldPreloadLink(J))this.preloadURL(J)}async preloadURL(H){let J=new URL(H.href);if(this.snapshotCache.has(J))return;await new t(this,O.get,J,new URLSearchParams,H).perform()}prepareRequest(H){H.headers["X-Sec-Purpose"]="prefetch"}async requestSucceededWithResponse(H,J){try{let Q=await J.responseHTML,X=g.fromHTMLString(Q);this.snapshotCache.put(H.url,X)}catch(Q){}}requestStarted(H){}requestErrored(H){}requestFinished(H){}requestPreventedHandlingResponse(H,J){}requestFailedWithResponse(H,J){}#H=()=>{this.preloadOnLoadLinksForView(document.body)}}class u1{constructor(H){this.session=H}clear(){this.session.clearCache()}resetCacheControl(){this.#H("")}exemptPageFromCache(){this.#H("no-cache")}exemptPageFromPreview(){this.#H("no-preview")}#H(H){vJ("turbo-cache-control",H)}}class s1{navigator=new y1(this);history=new h1(this);view=new d1(this,document.documentElement);adapter=new D1(this);pageObserver=new b1(this);cacheObserver=new O1;linkPrefetchObserver=new g1(this,document);linkClickObserver=new OH(this,window);formSubmitObserver=new _H(this,document);scrollObserver=new k1(this);streamObserver=new f1(this);formLinkClickObserver=new xH(this,document.documentElement);frameRedirector=new x1(this,document.documentElement);streamMessageRenderer=new N1;cache=new u1(this);enabled=!0;started=!1;#H=150;constructor(H){this.recentRequests=H,this.preloader=new c1(this,this.view.snapshotCache),this.debouncedRefresh=this.refresh,this.pageRefreshDebouncePeriod=this.pageRefreshDebouncePeriod}start(){if(!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(){if(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(H){this.adapter=H}visit(H,J={}){let Q=J.frame?document.getElementById(J.frame):null;if(Q instanceof x){let X=J.action||i(Q);Q.delegate.proposeVisitIfNavigatedWithAction(Q,X),Q.src=H.toString()}else this.navigator.proposeVisit(T(H),J)}refresh(H,J={}){J=typeof J==="string"?{requestId:J}:J;let{method:Q,requestId:X,scroll:Y}=J,Z=X&&this.recentRequests.has(X),A=H===document.baseURI;if(!Z&&!this.navigator.currentVisit&&A)this.visit(H,{action:"replace",shouldCacheSnapshot:!1,refresh:{method:Q,scroll:Y}})}connectStreamSource(H){this.streamObserver.connectStreamSource(H)}disconnectStreamSource(H){this.streamObserver.disconnectStreamSource(H)}renderStreamMessage(H){this.streamMessageRenderer.render(m.wrap(H))}clearCache(){this.view.clearSnapshotCache()}setProgressBarDelay(H){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=H}set progressBarDelay(H){V.drive.progressBarDelay=H}get progressBarDelay(){return V.drive.progressBarDelay}set drive(H){V.drive.enabled=H}get drive(){return V.drive.enabled}set formMode(H){V.forms.mode=H}get formMode(){return V.forms.mode}get location(){return this.history.location}get restorationIdentifier(){return this.history.restorationIdentifier}get pageRefreshDebouncePeriod(){return this.#H}set pageRefreshDebouncePeriod(H){this.refresh=dJ(this.debouncedRefresh.bind(this),H),this.#H=H}shouldPreloadLink(H){let J=H.hasAttribute("data-turbo-method"),Q=H.hasAttribute("data-turbo-stream"),X=H.getAttribute("data-turbo-frame"),Y=X=="_top"?null:document.getElementById(X)||l(H,"turbo-frame:not([disabled])");if(J||Q||Y instanceof x)return!1;else{let Z=new URL(H.href);return this.elementIsNavigatable(H)&&p(Z,this.snapshot.rootLocation)}}historyPoppedToLocationWithRestorationIdentifierAndDirection(H,J,Q){if(this.enabled)this.navigator.startVisit(H,J,{action:"restore",historyChanged:!0,direction:Q});else this.adapter.pageInvalidated({reason:"turbo_disabled"})}historyPoppedWithEmptyState(H){this.history.replace(H),this.view.lastRenderedLocation=H,this.view.cacheSnapshot()}scrollPositionChanged(H){this.history.updateRestorationData({scrollPosition:H})}willSubmitFormLinkToLocation(H,J){return this.elementIsNavigatable(H)&&p(J,this.snapshot.rootLocation)}submittedFormLinkToLocation(){}canPrefetchRequestToLocation(H,J){return this.elementIsNavigatable(H)&&p(J,this.snapshot.rootLocation)&&this.navigator.linkPrefetchingIsEnabledForLocation(J)}willFollowLinkToLocation(H,J,Q){return this.elementIsNavigatable(H)&&p(J,this.snapshot.rootLocation)&&this.applicationAllowsFollowingLinkToLocation(H,J,Q)}followedLinkToLocation(H,J){let Q=this.getActionForLink(H),X=H.hasAttribute("data-turbo-stream");this.visit(J.href,{action:Q,acceptsStreamResponse:X})}allowsVisitingLocationWithAction(H,J){return this.applicationAllowsVisitingLocation(H)}visitProposedToLocation(H,J){eH(H),this.adapter.visitProposedToLocation(H,J)}visitStarted(H){if(!H.acceptsStreamResponse)AH(document.documentElement),this.view.markVisitDirection(H.direction);eH(H.location),this.notifyApplicationAfterVisitingLocation(H.location,H.action)}visitCompleted(H){this.view.unmarkVisitDirection(),qH(document.documentElement),this.notifyApplicationAfterPageLoad(H.getTimingMetrics())}willSubmitForm(H,J){let Q=wH(H,J);return this.submissionIsNavigatable(H,J)&&p(T(Q),this.snapshot.rootLocation)}formSubmitted(H,J){this.navigator.submitForm(H,J)}pageBecameInteractive(){this.view.lastRenderedLocation=this.location,this.notifyApplicationAfterPageLoad()}pageLoaded(){this.history.assumeControlOfScrollRestoration()}pageWillUnload(){this.history.relinquishControlOfScrollRestoration()}receivedMessageFromStream(H){this.renderStreamMessage(H)}viewWillCacheSnapshot(){this.notifyApplicationBeforeCachingSnapshot()}allowsImmediateRender({element:H},J){let Q=this.notifyApplicationBeforeRender(H,J),{defaultPrevented:X,detail:{render:Y}}=Q;if(this.view.renderer&&Y)this.view.renderer.renderElement=Y;return!X}viewRenderedSnapshot(H,J,Q){this.view.lastRenderedLocation=this.history.location,this.notifyApplicationAfterRender(Q)}preloadOnLoadLinksForView(H){this.preloader.preloadOnLoadLinksForView(H)}viewInvalidated(H){this.adapter.pageInvalidated(H)}frameLoaded(H){this.notifyApplicationAfterFrameLoad(H)}frameRendered(H,J){this.notifyApplicationAfterFrameRender(H,J)}applicationAllowsFollowingLinkToLocation(H,J,Q){return!this.notifyApplicationAfterClickingLinkToLocation(H,J,Q).defaultPrevented}applicationAllowsVisitingLocation(H){return!this.notifyApplicationBeforeVisitingLocation(H).defaultPrevented}notifyApplicationAfterClickingLinkToLocation(H,J,Q){return w("turbo:click",{target:H,detail:{url:J.href,originalEvent:Q},cancelable:!0})}notifyApplicationBeforeVisitingLocation(H){return w("turbo:before-visit",{detail:{url:H.href},cancelable:!0})}notifyApplicationAfterVisitingLocation(H,J){return w("turbo:visit",{detail:{url:H.href,action:J}})}notifyApplicationBeforeCachingSnapshot(){return w("turbo:before-cache")}notifyApplicationBeforeRender(H,J){return w("turbo:before-render",{detail:{newBody:H,...J},cancelable:!0})}notifyApplicationAfterRender(H){return w("turbo:render",{detail:{renderMethod:H}})}notifyApplicationAfterPageLoad(H={}){return w("turbo:load",{detail:{url:this.location.href,timing:H}})}notifyApplicationAfterFrameLoad(H){return w("turbo:frame-load",{target:H})}notifyApplicationAfterFrameRender(H,J){return w("turbo:frame-render",{detail:{fetchResponse:H},target:J,cancelable:!0})}submissionIsNavigatable(H,J){if(V.forms.mode=="off")return!1;else{let Q=J?this.elementIsNavigatable(J):!0;if(V.forms.mode=="optin")return Q&&H.closest('[data-turbo="true"]')!=null;else return Q&&this.elementIsNavigatable(H)}}elementIsNavigatable(H){let J=l(H,"[data-turbo]"),Q=l(H,"turbo-frame");if(V.drive.enabled||Q)if(J)return J.getAttribute("data-turbo")!="false";else return!0;else if(J)return J.getAttribute("data-turbo")=="true";else return!1}getActionForLink(H){return i(H)||"advance"}get snapshot(){return this.view.snapshot}}function eH(H){Object.defineProperties(H,bQ)}var bQ={absoluteURL:{get(){return this.toString()}}},E=new s1(_1),{cache:kQ,navigator:NQ}=E;function i1(){E.start()}function fQ(H){E.registerAdapter(H)}function vQ(H,J){E.visit(H,J)}function m1(H){E.connectStreamSource(H)}function o1(H){E.disconnectStreamSource(H)}function pQ(H){E.renderStreamMessage(H)}function dQ(H){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.`"),V.drive.progressBarDelay=H}function cQ(H){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.`"),V.forms.confirm=H}function uQ(H){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.`"),V.forms.mode=H}function sQ(H,J){bH.renderElement(H,J)}function iQ(H,J){yH.renderElement(H,J)}var mQ=Object.freeze({__proto__:null,PageRenderer:MH,PageSnapshot:g,FrameRenderer:IH,fetch:B1,config:V,session:E,cache:kQ,navigator:NQ,start:i1,registerAdapter:fQ,visit:vQ,connectStreamSource:m1,disconnectStreamSource:o1,renderStreamMessage:pQ,setProgressBarDelay:dQ,setConfirmMethod:cQ,setFormMode:uQ,morphBodyElements:sQ,morphTurboFrameElements:iQ,morphChildren:gH,morphElements:FH});class a1 extends Error{}class r1{fetchResponseLoaded=(H)=>Promise.resolve();#H=null;#J=()=>{};#Q=!1;#$=!1;#G=new Set;#Y=!1;action=null;constructor(H){this.element=H,this.view=new S1(this,this.element),this.appearanceObserver=new F1(this,this.element),this.formLinkClickObserver=new xH(this,this.element),this.linkInterceptor=new DH(this,this.element),this.restorationIdentifier=d(),this.formSubmitObserver=new _H(this,this.element)}connect(){if(!this.#Q){if(this.#Q=!0,this.loadingStyle==a.lazy)this.appearanceObserver.start();else this.#X();this.formLinkClickObserver.start(),this.linkInterceptor.start(),this.formSubmitObserver.start()}}disconnect(){if(this.#Q){if(this.#Q=!1,this.appearanceObserver.stop(),this.formLinkClickObserver.stop(),this.linkInterceptor.stop(),this.formSubmitObserver.stop(),!this.element.hasAttribute("recurse"))this.#H?.cancel()}}disabledChanged(){if(this.disabled)this.#H?.cancel();else if(this.loadingStyle==a.eager)this.#X()}sourceURLChanged(){if(this.#P("src"))return;if(!this.sourceURL)this.#H?.cancel();if(this.element.isConnected)this.complete=!1;if(this.loadingStyle==a.eager||this.#$)this.#X()}sourceURLReloaded(){let{refresh:H,src:J}=this.element;return this.#Y=J&&H==="morph",this.element.removeAttribute("complete"),this.element.src=null,this.element.src=J,this.element.loaded}loadingStyleChanged(){if(this.loadingStyle==a.lazy)this.appearanceObserver.start();else this.appearanceObserver.stop(),this.#X()}async#X(){if(this.enabled&&this.isActive&&!this.complete&&this.sourceURL)this.element.loaded=this.#z(T(this.sourceURL)),this.appearanceObserver.stop(),await this.element.loaded,this.#$=!0}async loadResponse(H){if(H.redirected||H.succeeded&&H.isHTML)this.sourceURL=H.response.url;try{let J=await H.responseHTML;if(J){let Q=X1(J);if(g.fromDocument(Q).isVisitable)await this.#W(H,Q);else await this.#_(H)}}finally{this.#Y=!1,this.fetchResponseLoaded=()=>Promise.resolve()}}elementAppearedInViewport(H){this.proposeVisitIfNavigatedWithAction(H,i(H)),this.#X()}willSubmitFormLinkToLocation(H){return this.#A(H)}submittedFormLinkToLocation(H,J,Q){let X=this.#Z(H);if(X)Q.setAttribute("data-turbo-frame",X.id)}shouldInterceptLinkClick(H,J,Q){return this.#A(H)}linkClickIntercepted(H,J){this.#K(H,J)}willSubmitForm(H,J){return H.closest("turbo-frame")==this.element&&this.#A(H,J)}formSubmitted(H,J){if(this.formSubmission)this.formSubmission.stop();this.formSubmission=new KH(this,H,J);let{fetchRequest:Q}=this.formSubmission,X=this.#Z(H,J);this.prepareRequest(Q,X),this.formSubmission.start()}prepareRequest(H,J=this){if(H.headers["Turbo-Frame"]=J.id,this.currentNavigationElement?.hasAttribute("data-turbo-stream"))H.acceptResponseType(m.contentType)}requestStarted(H){AH(this.element)}requestPreventedHandlingResponse(H,J){this.#J()}async requestSucceededWithResponse(H,J){await this.loadResponse(J),this.#J()}async requestFailedWithResponse(H,J){await this.loadResponse(J),this.#J()}requestErrored(H,J){console.error(J),this.#J()}requestFinished(H){qH(this.element)}formSubmissionStarted({formElement:H}){AH(H,this.#Z(H))}formSubmissionSucceededWithResponse(H,J){let Q=this.#Z(H.formElement,H.submitter);if(Q.delegate.proposeVisitIfNavigatedWithAction(Q,i(H.submitter,H.formElement,Q)),Q.delegate.loadResponse(J),!H.isSafe)E.clearCache()}formSubmissionFailedWithResponse(H,J){this.element.delegate.loadResponse(J),E.clearCache()}formSubmissionErrored(H,J){console.error(J)}formSubmissionFinished({formElement:H}){qH(H,this.#Z(H))}allowsImmediateRender({element:H},J){let Q=w("turbo:before-frame-render",{target:this.element,detail:{newFrame:H,...J},cancelable:!0}),{defaultPrevented:X,detail:{render:Y}}=Q;if(this.view.renderer&&Y)this.view.renderer.renderElement=Y;return!X}viewRenderedSnapshot(H,J,Q){}preloadOnLoadLinksForView(H){E.preloadOnLoadLinksForView(H)}viewInvalidated(){}willRenderFrame(H,J){this.previousFrameElement=H.cloneNode(!0)}visitCachedSnapshot=({element:H})=>{let J=H.querySelector("#"+this.element.id);if(J&&this.previousFrameElement)J.replaceChildren(...this.previousFrameElement.children);delete this.previousFrameElement};async#W(H,J){let Q=await this.extractForeignFrameElement(J.body),X=this.#Y?yH:IH;if(Q){let Y=new QH(Q),Z=new X(this,this.view.snapshot,Y,!1,!1);if(this.view.renderPromise)await this.view.renderPromise;this.changeHistory(),await this.view.render(Z),this.complete=!0,E.frameRendered(H,this.element),E.frameLoaded(this.element),await this.fetchResponseLoaded(H)}else if(this.#B(H))this.#I(H)}async#z(H){let J=new t(this,O.get,H,new URLSearchParams,this.element);return this.#H?.cancel(),this.#H=J,new Promise((Q)=>{this.#J=()=>{this.#J=()=>{},this.#H=null,Q()},J.perform()})}#K(H,J,Q){let X=this.#Z(H,Q);X.delegate.proposeVisitIfNavigatedWithAction(X,i(Q,H,X)),this.#j(H,()=>{X.src=J})}proposeVisitIfNavigatedWithAction(H,J=null){if(this.action=J,this.action){let Q=g.fromElement(H).clone(),{visitCachedSnapshot:X}=H.delegate;H.delegate.fetchResponseLoaded=async(Y)=>{if(H.src){let{statusCode:Z,redirected:A}=Y,B=await Y.responseHTML,R={response:{statusCode:Z,redirected:A,responseHTML:B},visitCachedSnapshot:X,willRender:!1,updateHistory:!1,restorationIdentifier:this.restorationIdentifier,snapshot:Q};if(this.action)R.action=this.action;E.visit(H.src,R)}}}}changeHistory(){if(this.action){let H=Z1(this.action);E.history.update(H,T(this.element.src||""),this.restorationIdentifier)}}async#_(H){console.warn(`The response (${H.statusCode}) from <turbo-frame id="${this.element.id}"> is performing a full page visit due to turbo-visit-control.`),await this.#q(H.response)}#B(H){this.element.setAttribute("complete","");let J=H.response,Q=async(Y,Z)=>{if(Y instanceof Response)this.#q(Y);else E.visit(Y,Z)};return!w("turbo:frame-missing",{target:this.element,detail:{response:J,visit:Q},cancelable:!0}).defaultPrevented}#I(H){this.view.missing(),this.#F(H)}#F(H){let J=`The response (${H.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 a1(J)}async#q(H){let J=new zH(H),Q=await J.responseHTML,{location:X,redirected:Y,statusCode:Z}=J;return E.visit(X,{response:{redirected:Y,statusCode:Z,responseHTML:Q}})}#Z(H,J){let Q=WH("data-turbo-frame",J,H)||this.element.getAttribute("target"),X=this.#U(Q);return X instanceof x?X:this.element}async extractForeignFrameElement(H){let J,Q=CSS.escape(this.id);try{if(J=H1(H.querySelector(`turbo-frame#${Q}`),this.sourceURL),J)return J;if(J=H1(H.querySelector(`turbo-frame[src][recurse~=${Q}]`),this.sourceURL),J)return await J.loaded,await this.extractForeignFrameElement(J)}catch(X){return console.error(X),new x}return null}#M(H,J){let Q=wH(H,J);return p(T(Q),this.rootLocation)}#A(H,J){let Q=WH("data-turbo-frame",J,H)||this.element.getAttribute("target");if(H instanceof HTMLFormElement&&!this.#M(H,J))return!1;if(!this.enabled||Q=="_top")return!1;if(Q){let X=this.#U(Q);if(X)return!X.disabled;else if(Q=="_parent")return!1}if(!E.elementIsNavigatable(H))return!1;if(J&&!E.elementIsNavigatable(J))return!1;return!0}get id(){return this.element.id}get disabled(){return this.element.disabled}get enabled(){return!this.disabled}get sourceURL(){if(this.element.src)return this.element.src}set sourceURL(H){this.#L("src",()=>{this.element.src=H??null})}get loadingStyle(){return this.element.loading}get isLoading(){return this.formSubmission!==void 0||this.#J()!==void 0}get complete(){return this.element.hasAttribute("complete")}set complete(H){if(H)this.element.setAttribute("complete","");else this.element.removeAttribute("complete")}get isActive(){return this.element.isActive&&this.#Q}get rootLocation(){let J=this.element.ownerDocument.querySelector('meta[name="turbo-root"]')?.content??"/";return T(J)}#P(H){return this.#G.has(H)}#L(H,J){this.#G.add(H),J(),this.#G.delete(H)}#j(H,J){this.currentNavigationElement=H,J(),delete this.currentNavigationElement}#U(H){if(H!=null){let J=H==="_parent"?this.element.parentElement.closest("turbo-frame"):document.getElementById(H);if(J instanceof x)return J}}}function H1(H,J){if(H){let Q=H.getAttribute("src");if(Q!=null&&J!=null&&z1(Q,J))throw Error(`Matching <turbo-frame id="${H.id}"> element has a source URL which references itself`);if(H.ownerDocument!==document)H=document.importNode(H,!0);if(H instanceof x)return H.connectedCallback(),H.disconnectedCallback(),H}}var l1={after(){this.removeDuplicateTargetSiblings(),this.targetElements.forEach((H)=>H.parentElement?.insertBefore(this.templateContent,H.nextSibling))},append(){this.removeDuplicateTargetChildren(),this.targetElements.forEach((H)=>H.append(this.templateContent))},before(){this.removeDuplicateTargetSiblings(),this.targetElements.forEach((H)=>H.parentElement?.insertBefore(this.templateContent,H))},prepend(){this.removeDuplicateTargetChildren(),this.targetElements.forEach((H)=>H.prepend(this.templateContent))},remove(){this.targetElements.forEach((H)=>H.remove())},replace(){let H=this.getAttribute("method");this.targetElements.forEach((J)=>{if(H==="morph")FH(J,this.templateContent);else J.replaceWith(this.templateContent)})},update(){let H=this.getAttribute("method");this.targetElements.forEach((J)=>{if(H==="morph")gH(J,this.templateContent);else J.innerHTML="",J.append(this.templateContent)})},refresh(){let H=this.getAttribute("method"),J=this.requestId,Q=this.getAttribute("scroll");E.refresh(this.baseURI,{method:H,requestId:J,scroll:Q})}};class kH extends HTMLElement{static async renderElement(H){await H.performAction()}async connectedCallback(){try{await this.render()}catch(H){console.error(H)}finally{this.disconnect()}}async render(){return this.renderPromise??=(async()=>{let H=this.beforeRenderEvent;if(this.dispatchEvent(H))await e(),await H.detail.render(this)})()}disconnect(){try{this.remove()}catch{}}removeDuplicateTargetChildren(){this.duplicateChildren.forEach((H)=>H.remove())}get duplicateChildren(){let H=this.targetElements.flatMap((Q)=>[...Q.children]).filter((Q)=>!!Q.getAttribute("id")),J=[...this.templateContent?.children||[]].filter((Q)=>!!Q.getAttribute("id")).map((Q)=>Q.getAttribute("id"));return H.filter((Q)=>J.includes(Q.getAttribute("id")))}removeDuplicateTargetSiblings(){this.duplicateSiblings.forEach((H)=>H.remove())}get duplicateSiblings(){let H=this.targetElements.flatMap((Q)=>[...Q.parentElement.children]).filter((Q)=>!!Q.id),J=[...this.templateContent?.children||[]].filter((Q)=>!!Q.id).map((Q)=>Q.id);return H.filter((Q)=>J.includes(Q.id))}get performAction(){if(this.action){let H=l1[this.action];if(H)return H;this.#H("unknown action")}this.#H("action attribute is missing")}get targetElements(){if(this.target)return this.targetElementsById;else if(this.targets)return this.targetElementsByQuery;else this.#H("target or targets attribute is missing")}get templateContent(){return this.templateElement.content.cloneNode(!0)}get templateElement(){if(this.firstElementChild===null){let H=this.ownerDocument.createElement("template");return this.appendChild(H),H}else if(this.firstElementChild instanceof HTMLTemplateElement)return this.firstElementChild;this.#H("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")}#H(H){throw Error(`${this.description}: ${H}`)}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:kH.renderElement}})}get targetElementsById(){let H=this.ownerDocument?.getElementById(this.target);if(H!==null)return[H];else return[]}get targetElementsByQuery(){let H=this.ownerDocument?.querySelectorAll(this.targets);if(H.length!==0)return Array.prototype.slice.call(H);else return[]}}class n1 extends HTMLElement{streamSource=null;connectedCallback(){this.streamSource=this.src.match(/^ws{1,2}:/)?new WebSocket(this.src):new EventSource(this.src),m1(this.streamSource)}disconnectedCallback(){if(this.streamSource)this.streamSource.close(),o1(this.streamSource)}get src(){return this.getAttribute("src")||""}}x.delegateConstructor=r1;if(customElements.get("turbo-frame")===void 0)customElements.define("turbo-frame",x);if(customElements.get("turbo-stream")===void 0)customElements.define("turbo-stream",kH);if(customElements.get("turbo-stream-source")===void 0)customElements.define("turbo-stream-source",n1);(()=>{let H=document.currentScript;if(!H)return;if(H.hasAttribute("data-turbo-suppress-warning"))return;let J=H.parentElement;while(J){if(J==document.body)return console.warn(Y1`
20
+ `}hiding=!1;value=0;visible=!1;constructor(){this.stylesheetElement=this.createStylesheetElement(),this.progressElement=this.createProgressElement(),this.installStylesheetElement(),this.setValue(0)}show(){if(!this.visible)this.visible=!0,this.installProgressElement(),this.startTrickling()}hide(){if(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,H.animationDuration*1.5)}uninstallProgressElement(){if(this.progressElement.parentNode)document.documentElement.removeChild(this.progressElement)}startTrickling(){if(!this.trickleInterval)this.trickleInterval=window.setInterval(this.trickle,H.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(){let e=document.createElement("style");e.type="text/css",e.textContent=H.defaultCSS;let t=at();if(t)e.nonce=t;return e}createProgressElement(){let e=document.createElement("div");return e.className="turbo-progress-bar",e}}class Ct extends re{detailsByOuterHTML=this.children.filter((e)=>!vr(e)).map((e)=>wr(e)).reduce((e,t)=>{let{outerHTML:s}=t,r=s in e?e[s]:{type:pr(t),tracked:gr(t),elements:[]};return{...e,[s]:{...r,elements:[...r.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((s)=>!(s in t.detailsByOuterHTML)).map((s)=>this.detailsByOuterHTML[s]).filter(({type:s})=>s==e).map(({elements:[s]})=>s)}get provisionalElements(){return Object.keys(this.detailsByOuterHTML).reduce((e,t)=>{let{type:s,tracked:r,elements:i}=this.detailsByOuterHTML[t];if(s==null&&!r)return[...e,...i];else if(i.length>1)return[...e,...i.slice(1)];else return e},[])}getMetaValue(e){let t=this.findMetaElementByName(e);return t?t.getAttribute("content"):null}findMetaElementByName(e){return Object.keys(this.detailsByOuterHTML).reduce((t,s)=>{let{elements:[r]}=this.detailsByOuterHTML[s];return Er(r,e)?r:t},void 0|void 0)}}function pr(e){if(br(e))return"script";else if(yr(e))return"stylesheet"}function gr(e){return e.getAttribute("data-turbo-track")=="reload"}function br(e){return e.localName=="script"}function vr(e){return e.localName=="noscript"}function yr(e){let t=e.localName;return t=="style"||t=="link"&&e.getAttribute("rel")=="stylesheet"}function Er(e,t){return e.localName=="meta"&&e.getAttribute("name")==t}function wr(e){if(e.hasAttribute("nonce"))e.setAttribute("nonce","");return e}class I extends re{static fromHTMLString(e=""){return this.fromDocument(it(e))}static fromElement(e){return this.fromDocument(e.ownerDocument)}static fromDocument({documentElement:e,body:t,head:s}){return new this(e,t,new Ct(s))}constructor(e,t,s){super(t);this.documentElement=e,this.headSnapshot=s}clone(){let e=this.element.cloneNode(!0),t=this.element.querySelectorAll("select"),s=e.querySelectorAll("select");for(let[r,i]of t.entries()){let n=s[r];for(let l of n.selectedOptions)l.selected=!1;for(let l of i.selectedOptions)n.options[l.index].selected=!0}for(let r of e.querySelectorAll('input[type="password"]'))r.value="";for(let r of e.querySelectorAll("noscript"))r.remove();return new I(this.documentElement,e,this.headSnapshot)}get lang(){return this.documentElement.getAttribute("lang")}get dir(){return this.documentElement.getAttribute("dir")}get headElement(){return this.headSnapshot.element}get rootLocation(){let e=this.getSetting("root")??"/";return R(e)}get 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.getSetting("view-transition")==="true"||this.headSnapshot.getMetaValue("view-transition")==="same-origin")&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches}get refreshMethod(){return this.getSetting("refresh-method")}get refreshScroll(){return this.getSetting("refresh-scroll")}getSetting(e){return this.headSnapshot.getMetaValue(`turbo-${e}`)}}class Rt{#e=!1;#t=Promise.resolve();renderChange(e,t){if(e&&this.viewTransitionsAvailable&&!this.#e)this.#e=!0,this.#t=this.#t.then(async()=>{await document.startViewTransition(t).finished});else this.#t=this.#t.then(t);return this.#t}get viewTransitionsAvailable(){return document.startViewTransition}}var Sr={action:"advance",historyChanged:!1,visitCachedSnapshot:()=>{},willRender:!0,updateHistory:!0,shouldCacheSnapshot:!0,acceptsStreamResponse:!1,refresh:{}},ae={visitStart:"visitStart",requestStart:"requestStart",requestEnd:"requestEnd",visitEnd:"visitEnd"},q={initialized:"initialized",started:"started",canceled:"canceled",failed:"failed",completed:"completed"},G={networkFailure:0,timeoutFailure:-1,contentTypeMismatch:-2},Ar={advance:"forward",restore:"back",replace:"none"};class Ot{identifier=W();timingMetrics={};followedRedirect=!1;historyChanged=!1;scrolled=!1;shouldCacheSnapshot=!0;acceptsStreamResponse=!1;snapshotCached=!1;state=q.initialized;viewTransitioner=new Rt;constructor(e,t,s,r={}){this.delegate=e,this.location=t,this.restorationIdentifier=s||W();let{action:i,historyChanged:n,referrer:l,snapshot:p,snapshotHTML:O,response:M,visitCachedSnapshot:B,willRender:N,updateHistory:b,shouldCacheSnapshot:A,acceptsStreamResponse:y,direction:E,refresh:w}={...Sr,...r};this.action=i,this.historyChanged=n,this.referrer=l,this.snapshot=p,this.snapshotHTML=O,this.response=M,this.isPageRefresh=this.view.isPageRefresh(this),this.visitCachedSnapshot=B,this.willRender=N,this.updateHistory=b,this.scrolled=!N,this.shouldCacheSnapshot=A,this.acceptsStreamResponse=y,this.direction=E||Ar[i],this.refresh=w}get adapter(){return this.delegate.adapter}get view(){return this.delegate.view}get history(){return this.delegate.history}get restorationData(){return this.history.getRestorationDataForIdentifier(this.restorationIdentifier)}start(){if(this.state==q.initialized)this.recordTimingMetric(ae.visitStart),this.state=q.started,this.adapter.visitStarted(this),this.delegate.visitStarted(this)}cancel(){if(this.state==q.started){if(this.request)this.request.cancel();this.cancelRender(),this.state=q.canceled}}complete(){if(this.state==q.started){if(this.recordTimingMetric(ae.visitEnd),this.adapter.visitCompleted(this),this.state=q.completed,this.followRedirect(),!this.followedRedirect)this.delegate.visitCompleted(this)}}fail(){if(this.state==q.started)this.state=q.failed,this.adapter.visitFailed(this),this.delegate.visitCompleted(this)}changeHistory(){if(!this.historyChanged&&this.updateHistory){let e=this.location.href===this.referrer?.href?"replace":this.action,t=ot(e);this.history.update(t,this.location,this.restorationIdentifier),this.historyChanged=!0}}issueRequest(){if(this.hasPreloadedResponse())this.simulateRequest();else if(this.shouldIssueRequest()&&!this.request)this.request=new Z(this,k.get,this.location),this.request.perform()}simulateRequest(){if(this.response)this.startRequest(),this.recordResponse(),this.finishRequest()}startRequest(){this.recordTimingMetric(ae.requestStart),this.adapter.visitRequestStarted(this)}recordResponse(e=this.response){if(this.response=e,e){let{statusCode:t}=e;if(Ze(t))this.adapter.visitRequestCompleted(this);else this.adapter.visitRequestFailedWithStatusCode(this,t)}}finishRequest(){this.recordTimingMetric(ae.requestEnd),this.adapter.visitRequestFinished(this)}loadResponse(){if(this.response){let{statusCode:e,responseHTML:t}=this.response;this.render(async()=>{if(this.shouldCacheSnapshot)this.cacheSnapshot();if(this.view.renderPromise)await this.view.renderPromise;if(Ze(e)&&t!=null){let s=I.fromHTMLString(t);await this.renderPageSnapshot(s,!1),this.adapter.visitRendered(this),this.complete()}else await this.view.renderError(I.fromHTMLString(t),this),this.adapter.visitRendered(this),this.fail()})}}getCachedSnapshot(){let e=this.view.getCachedSnapshotForLocation(this.location)||this.getPreloadedSnapshot();if(e&&(!te(this.location)||e.hasAnchor(te(this.location)))){if(this.action=="restore"||e.isPreviewable)return e}}getPreloadedSnapshot(){if(this.snapshotHTML)return I.fromHTMLString(this.snapshotHTML)}hasCachedSnapshot(){return this.getCachedSnapshot()!=null}loadCachedSnapshot(){let e=this.getCachedSnapshot();if(e){let t=this.shouldIssueRequest();this.render(async()=>{if(this.cacheSnapshot(),this.isPageRefresh)this.adapter.visitRendered(this);else{if(this.view.renderPromise)await this.view.renderPromise;if(await this.renderPageSnapshot(e,t),this.adapter.visitRendered(this),!t)this.complete()}})}}followRedirect(){if(this.redirectedToLocation&&!this.followedRedirect&&this.response?.redirected)this.adapter.visitProposedToLocation(this.redirectedToLocation,{action:"replace",response:this.response,shouldCacheSnapshot:!1,willRender:!1}),this.followedRedirect=!0}prepareRequest(e){if(this.acceptsStreamResponse)e.acceptResponseType(z.contentType)}requestStarted(){this.startRequest()}requestPreventedHandlingResponse(e,t){}async requestSucceededWithResponse(e,t){let s=await t.responseHTML,{redirected:r,statusCode:i}=t;if(s==null)this.recordResponse({statusCode:G.contentTypeMismatch,redirected:r});else this.redirectedToLocation=t.redirected?t.location:void 0,this.recordResponse({statusCode:i,responseHTML:s,redirected:r})}async requestFailedWithResponse(e,t){let s=await t.responseHTML,{redirected:r,statusCode:i}=t;if(s==null)this.recordResponse({statusCode:G.contentTypeMismatch,redirected:r});else this.recordResponse({statusCode:i,responseHTML:s,redirected:r})}requestErrored(e,t){this.recordResponse({statusCode:G.networkFailure,redirected:!1})}requestFinished(){this.finishRequest()}performScroll(){if(!this.scrolled&&!this.view.forceReloaded&&!this.view.shouldPreserveScrollPosition(this)){if(this.action=="restore")this.scrollToRestoredPosition()||this.scrollToAnchor()||this.view.scrollToTop();else this.scrollToAnchor()||this.view.scrollToTop();this.scrolled=!0}}scrollToRestoredPosition(){let{scrollPosition:e}=this.restorationData;if(e)return this.view.scrollToPosition(e),!0}scrollToAnchor(){let e=te(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(){if(this.action=="restore")return!this.hasCachedSnapshot();else return this.willRender}cacheSnapshot(){if(!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(){if(this.frame)cancelAnimationFrame(this.frame),delete this.frame}}function Ze(e){return e>=200&&e<300}class kt{progressBar=new H;constructor(e){this.session=e}visitProposedToLocation(e,t){if(V(e,this.navigator.rootLocation))this.navigator.startVisit(e,t?.restorationIdentifier||W(),t);else window.location.href=e.toString()}visitStarted(e){this.location=e.location,this.redirectedToLocation=null,e.loadCachedSnapshot(),e.issueRequest()}visitRequestStarted(e){if(this.progressBar.setValue(0),e.hasCachedSnapshot()||e.action!="restore")this.showVisitProgressBarAfterDelay();else this.showProgressBar()}visitRequestCompleted(e){if(e.loadResponse(),e.response.redirected)this.redirectedToLocation=e.redirectedToLocation}visitRequestFailedWithStatusCode(e,t){switch(t){case G.networkFailure:case G.timeoutFailure:case G.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(){if(this.progressBar.hide(),this.visitProgressBarTimeout!=null)window.clearTimeout(this.visitProgressBarTimeout),delete this.visitProgressBarTimeout}showFormProgressBarAfterDelay(){if(this.formProgressBarTimeout==null)this.formProgressBarTimeout=window.setTimeout(this.showProgressBar,this.session.progressBarDelay)}hideFormProgressBar(){if(this.progressBar.hide(),this.formProgressBarTimeout!=null)window.clearTimeout(this.formProgressBarTimeout),delete this.formProgressBarTimeout}showProgressBar=()=>{this.progressBar.show()};reload(e){T("turbo:reload",{detail:e}),window.location.href=(this.redirectedToLocation||this.location)?.toString()||window.location.href}get navigator(){return this.session.navigator}}class Ft{selector="[data-turbo-temporary]";started=!1;start(){if(!this.started)this.started=!0,addEventListener("turbo:before-cache",this.removeTemporaryElements,!1)}stop(){if(this.started)this.started=!1,removeEventListener("turbo:before-cache",this.removeTemporaryElements,!1)}removeTemporaryElements=(e)=>{for(let t of this.temporaryElements)t.remove()};get temporaryElements(){return[...document.querySelectorAll(this.selector)]}}class Pt{constructor(e,t){this.session=e,this.element=t,this.linkInterceptor=new ke(this,t),this.formSubmitObserver=new pe(this,t)}start(){this.linkInterceptor.start(),this.formSubmitObserver.start()}stop(){this.linkInterceptor.stop(),this.formSubmitObserver.stop()}shouldInterceptLinkClick(e,t,s){return this.#t(e)}linkClickIntercepted(e,t,s){let r=this.#s(e);if(r)r.delegate.linkClickIntercepted(e,t,s)}willSubmitForm(e,t){return e.closest("turbo-frame")==null&&this.#e(e,t)&&this.#t(e,t)}formSubmitted(e,t){let s=this.#s(e,t);if(s)s.delegate.formSubmitted(e,t)}#e(e,t){let s=Le(e,t),r=this.element.ownerDocument.querySelector('meta[name="turbo-root"]'),i=R(r?.content??"/");return this.#t(e,t)&&V(s,i)}#t(e,t){if(e instanceof HTMLFormElement?this.session.submissionIsNavigatable(e,t):this.session.elementIsNavigatable(e)){let r=this.#s(e,t);return r?r!=e.closest("turbo-frame"):!1}else return!1}#s(e,t){let s=t?.getAttribute("data-turbo-frame")||e.getAttribute("data-turbo-frame");if(s&&s!="_top"){let r=this.element.querySelector(`#${s}:not([disabled])`);if(r instanceof F)return r}}}class It{location;restorationIdentifier=W();restorationData={};started=!1;currentIndex=0;constructor(e){this.delegate=e}start(){if(!this.started)addEventListener("popstate",this.onPopState,!1),this.currentIndex=history.state?.turbo?.restorationIndex||0,this.started=!0,this.replace(new URL(window.location.href))}stop(){if(this.started)removeEventListener("popstate",this.onPopState,!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,s=W()){if(e===history.pushState)++this.currentIndex;let r={turbo:{restorationIdentifier:s,restorationIndex:this.currentIndex}};e.call(history,r,"",t.href),this.location=t,this.restorationIdentifier=s}getRestorationDataForIdentifier(e){return this.restorationData[e]||{}}updateRestorationData(e){let{restorationIdentifier:t}=this,s=this.restorationData[t];this.restorationData[t]={...s,...e}}assumeControlOfScrollRestoration(){if(!this.previousScrollRestoration)this.previousScrollRestoration=history.scrollRestoration??"auto",history.scrollRestoration="manual"}relinquishControlOfScrollRestoration(){if(this.previousScrollRestoration)history.scrollRestoration=this.previousScrollRestoration,delete this.previousScrollRestoration}onPopState=(e)=>{let{turbo:t}=e.state||{};if(this.location=new URL(window.location.href),t){let{restorationIdentifier:s,restorationIndex:r}=t;this.restorationIdentifier=s;let i=r>this.currentIndex?"forward":"back";this.delegate.historyPoppedToLocationWithRestorationIdentifierAndDirection(this.location,s,i),this.currentIndex=r}else this.currentIndex++,this.delegate.historyPoppedWithEmptyState(this.location)}}class Bt{started=!1;#e=null;constructor(e,t){this.delegate=e,this.eventTarget=t}start(){if(this.started)return;if(this.eventTarget.readyState==="loading")this.eventTarget.addEventListener("DOMContentLoaded",this.#t,{once:!0});else this.#t()}stop(){if(!this.started)return;this.eventTarget.removeEventListener("mouseenter",this.#s,{capture:!0,passive:!0}),this.eventTarget.removeEventListener("mouseleave",this.#o,{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.#o,{capture:!0,passive:!0}),this.eventTarget.addEventListener("turbo:before-fetch-request",this.#i,!0),this.started=!0};#s=(e)=>{if(de("turbo-prefetch")==="false")return;let t=e.target;if(t.matches&&t.matches("a[href]:not([target^=_]):not([download])")&&this.#c(t)){let r=t,i=dt(r);if(this.delegate.canPrefetchRequestToLocation(r,i)){this.#e=r;let n=new Z(this,k.get,i,new URLSearchParams,t);n.fetchOptions.priority="low",Y.putLater(i,n,this.#r)}}};#o=(e)=>{if(e.target===this.#e)this.#a()};#a=()=>{Y.clear(),this.#e=null};#i=(e)=>{if(e.target.tagName!=="FORM"&&e.detail.fetchOptions.method==="GET"){let t=Y.get(e.detail.url);if(t)e.detail.fetchRequest=t;Y.clear()}};prepareRequest(e){let t=e.target;e.headers["X-Sec-Purpose"]="prefetch";let s=t.closest("turbo-frame"),r=t.getAttribute("data-turbo-frame")||s?.getAttribute("target")||s?.id;if(r&&r!=="_top")e.headers["Turbo-Frame"]=r}requestSucceededWithResponse(){}requestStarted(e){}requestErrored(e){}requestFinished(e){}requestPreventedHandlingResponse(e,t){}requestFailedWithResponse(e,t){}get#r(){return Number(de("turbo-prefetch-cache-time"))||Et}#c(e){if(!e.getAttribute("href"))return!1;if(Tr(e))return!1;if(Lr(e))return!1;if(Mr(e))return!1;if(Cr(e))return!1;if(Or(e))return!1;return!0}}var Tr=(e)=>e.origin!==document.location.origin||!["http:","https:"].includes(e.protocol)||e.hasAttribute("target"),Lr=(e)=>e.pathname+e.search===document.location.pathname+document.location.search||e.href.startsWith("#"),Mr=(e)=>{if(e.getAttribute("data-turbo-prefetch")==="false")return!0;if(e.getAttribute("data-turbo")==="false")return!0;let t=Q(e,"[data-turbo-prefetch]");if(t&&t.getAttribute("data-turbo-prefetch")==="false")return!0;return!1},Cr=(e)=>{let t=e.getAttribute("data-turbo-method");if(t&&t.toLowerCase()!=="get")return!0;if(Rr(e))return!0;if(e.hasAttribute("data-turbo-confirm"))return!0;if(e.hasAttribute("data-turbo-stream"))return!0;return!1},Rr=(e)=>e.hasAttribute("data-remote")||e.hasAttribute("data-behavior")||e.hasAttribute("data-confirm")||e.hasAttribute("data-method"),Or=(e)=>T("turbo:before-prefetch",{target:e,cancelable:!0}).defaultPrevented;class Nt{constructor(e){this.delegate=e}proposeVisit(e,t={}){if(this.delegate.allowsVisitingLocationWithAction(e,t.action))this.delegate.visitProposedToLocation(e,t)}startVisit(e,t,s={}){this.stop(),this.currentVisit=new Ot(this,R(e),t,{referrer:this.location,...s}),this.currentVisit.start()}submitForm(e,t){this.stop(),this.formSubmission=new me(this,e,t,!0),this.formSubmission.start()}stop(){if(this.formSubmission)this.formSubmission.stop(),delete this.formSubmission;if(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){if(typeof this.adapter.formSubmissionStarted==="function")this.adapter.formSubmissionStarted(e)}async formSubmissionSucceededWithResponse(e,t){if(e==this.formSubmission){let s=await t.responseHTML;if(s){let r=e.isSafe;if(!r)this.view.clearSnapshotCache();let{statusCode:i,redirected:n}=t,p={action:this.#e(e,t),shouldCacheSnapshot:r,response:{statusCode:i,responseHTML:s,redirected:n}};this.proposeVisit(t.location,p)}}}async formSubmissionFailedWithResponse(e,t){let s=await t.responseHTML;if(s){let r=I.fromHTMLString(s);if(t.serverError)await this.view.renderError(r,this.currentVisit);else await this.view.renderPage(r,!1,!0,this.currentVisit);if(r.refreshScroll!=="preserve")this.view.scrollToTop();this.view.clearSnapshotCache()}}formSubmissionErrored(e,t){console.error(t)}formSubmissionFinished(e){if(typeof this.adapter.formSubmissionFinished==="function")this.adapter.formSubmissionFinished(e)}linkPrefetchingIsEnabledForLocation(e){if(typeof this.adapter.linkPrefetchingIsEnabledForLocation==="function")return this.adapter.linkPrefetchingIsEnabledForLocation(e);return!0}visitStarted(e){this.delegate.visitStarted(e)}visitCompleted(e){this.delegate.visitCompleted(e),delete this.currentVisit}locationWithActionIsSamePage(e,t){return!1}get location(){return this.history.location}get restorationIdentifier(){return this.history.restorationIdentifier}#e(e,t){let{submitter:s,formElement:r}=e;return K(s,r)||this.#t(t)}#t(e){return e.redirected&&e.location.href===this.location?.href?"replace":"advance"}}var j={initial:0,loading:1,interactive:2,complete:3};class Dt{stage=j.initial;started=!1;constructor(e){this.delegate=e}start(){if(!this.started){if(this.stage==j.initial)this.stage=j.loading;document.addEventListener("readystatechange",this.interpretReadyState,!1),addEventListener("pagehide",this.pageWillUnload,!1),this.started=!0}}stop(){if(this.started)document.removeEventListener("readystatechange",this.interpretReadyState,!1),removeEventListener("pagehide",this.pageWillUnload,!1),this.started=!1}interpretReadyState=()=>{let{readyState:e}=this;if(e=="interactive")this.pageIsInteractive();else if(e=="complete")this.pageIsComplete()};pageIsInteractive(){if(this.stage==j.loading)this.stage=j.interactive,this.delegate.pageBecameInteractive()}pageIsComplete(){if(this.pageIsInteractive(),this.stage==j.interactive)this.stage=j.complete,this.delegate.pageLoaded()}pageWillUnload=()=>{this.delegate.pageWillUnload()};get readyState(){return document.readyState}}class qt{started=!1;constructor(e){this.delegate=e}start(){if(!this.started)addEventListener("scroll",this.onScroll,!1),this.onScroll(),this.started=!0}stop(){if(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 xt{render({fragment:e}){Ie.preservingPermanentElements(this,kr(e),()=>{Fr(e,()=>{Pr(()=>{document.documentElement.appendChild(e)})})})}enteringBardo(e,t){t.replaceWith(e.cloneNode(!0))}leavingBardo(){}}function kr(e){let t=St(document.documentElement),s={};for(let r of t){let{id:i}=r;for(let n of e.querySelectorAll("turbo-stream")){let l=wt(n.templateElement.content,i);if(l)s[i]=[r,l]}}return s}async function Fr(e,t){let s=`turbo-stream-autofocus-${W()}`,r=e.querySelectorAll("turbo-stream"),i=Ir(r),n=null;if(i){if(i.id)n=i.id;else n=s;i.id=n}if(t(),await ee(),(document.activeElement==null||document.activeElement==document.body)&&n){let p=document.getElementById(n);if(Te(p))p.focus();if(p&&p.id==s)p.removeAttribute("id")}}async function Pr(e){let[t,s]=await $s(e,()=>document.activeElement),r=t&&t.id;if(r){let i=document.getElementById(r);if(Te(i)&&i!=s)i.focus()}}function Ir(e){for(let t of e){let s=ct(t.templateElement.content);if(s)return s}return null}class Ht{sources=new Set;#e=!1;constructor(e){this.delegate=e}start(){if(!this.#e)this.#e=!0,addEventListener("turbo:before-fetch-response",this.inspectFetchResponse,!1)}stop(){if(this.#e)this.#e=!1,removeEventListener("turbo:before-fetch-response",this.inspectFetchResponse,!1)}connectStreamSource(e){if(!this.streamSourceIsConnected(e))this.sources.add(e),e.addEventListener("message",this.receiveMessageEvent,!1)}disconnectStreamSource(e){if(this.streamSourceIsConnected(e))this.sources.delete(e),e.removeEventListener("message",this.receiveMessageEvent,!1)}streamSourceIsConnected(e){return this.sources.has(e)}inspectFetchResponse=(e)=>{let t=Br(e);if(t&&Nr(t))e.preventDefault(),this.receiveMessageResponse(t)};receiveMessageEvent=(e)=>{if(this.#e&&typeof e.data=="string")this.receiveMessageHTML(e.data)};async receiveMessageResponse(e){let t=await e.responseHTML;if(t)this.receiveMessageHTML(t)}receiveMessageHTML(e){this.delegate.receivedMessageFromStream(z.wrap(e))}}function Br(e){let t=e.detail?.fetchResponse;if(t instanceof fe)return t}function Nr(e){return(e.contentType??"").startsWith(z.contentType)}class Vt extends ge{static renderElement(e,t){let{documentElement:s,body:r}=document;s.replaceChild(t,r)}async render(){this.replaceHeadAndBody(),this.activateScriptElements()}replaceHeadAndBody(){let{documentElement:e,head:t}=document;e.replaceChild(this.newHead,t),this.renderElement(this.currentElement,this.newElement)}activateScriptElements(){for(let e of this.scriptElements){let t=e.parentNode;if(t){let s=se(e);t.replaceChild(s,e)}}}get newHead(){return this.newSnapshot.headSnapshot.element}get scriptElements(){return document.documentElement.querySelectorAll("script")}}class ye extends ge{static renderElement(e,t){if(document.body&&t instanceof HTMLBodyElement)document.body.replaceWith(t);else 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(){if(this.willRender)await this.replaceBody()}finishRendering(){if(super.finishRendering(),!this.isPreview)this.focusFirstAutofocusableElement()}get currentHeadSnapshot(){return this.currentSnapshot.headSnapshot}get newHeadSnapshot(){return this.newSnapshot.headSnapshot}get newElement(){return this.newSnapshot.element}#e(){let{documentElement:e}=this.currentSnapshot,{dir:t,lang:s}=this.newSnapshot;if(s)e.setAttribute("lang",s);else e.removeAttribute("lang");if(t)e.setAttribute("dir",t);else e.removeAttribute("dir")}async mergeHead(){let e=this.mergeProvisionalElements(),t=this.copyNewHeadStylesheetElements();if(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(){let e=[];for(let t of this.newHeadStylesheetElements)e.push(xs(t)),document.head.appendChild(t);await Promise.all(e)}copyNewHeadScriptElements(){for(let e of this.newHeadScriptElements)document.head.appendChild(se(e))}removeUnusedDynamicStylesheetElements(){for(let e of this.unusedDynamicStylesheetElements)document.head.removeChild(e)}async mergeProvisionalElements(){let e=[...this.newHeadProvisionalElements];for(let t of this.currentHeadProvisionalElements)if(!this.isCurrentElementInElementList(t,e))document.head.removeChild(t);for(let t of e)document.head.appendChild(t)}isCurrentElementInElementList(e,t){for(let[s,r]of t.entries()){if(e.tagName=="TITLE"){if(r.tagName!="TITLE")continue;if(e.innerHTML==r.innerHTML)return t.splice(s,1),!0}if(r.isEqualNode(e))return t.splice(s,1),!0}return!1}removeCurrentHeadProvisionalElements(){for(let e of this.currentHeadProvisionalElements)document.head.removeChild(e)}copyNewHeadProvisionalElements(){for(let e of this.newHeadProvisionalElements)document.head.appendChild(e)}activateNewBody(){document.adoptNode(this.newElement),this.removeNoscriptElements(),this.activateNewBodyScriptElements()}removeNoscriptElements(){for(let e of this.newElement.querySelectorAll("noscript"))e.remove()}activateNewBodyScriptElements(){for(let e of this.newBodyScriptElements){let t=se(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 De extends ye{static renderElement(e,t){ve(e,t,{callbacks:{beforeNodeMorphed:(s,r)=>{if(Tt(s,r)&&!Lt(s))return s.reload(),!1;return!0}}}),T("turbo:morph",{detail:{currentElement:e,newElement:t}})}async preservingPermanentElements(e){return await e()}get renderMethod(){return"morph"}get shouldAutofocus(){return!1}}class $t extends Re{constructor(e){super(e,ce)}get snapshots(){return this.entries}}class Wt extends Oe{snapshotCache=new $t(10);lastRenderedLocation=new URL(location.href);forceReloaded=!1;shouldTransitionTo(e){return this.snapshot.prefersViewTransitions&&e.prefersViewTransitions}renderPage(e,t=!1,s=!0,r){let l=new(this.isPageRefresh(r)&&(r?.refresh?.method||this.snapshot.refreshMethod)==="morph"?De:ye)(this.snapshot,e,t,s);if(!l.shouldRender)this.forceReloaded=!0;else r?.changeHistory();return this.render(l)}renderError(e,t){t?.changeHistory();let s=new Vt(this.snapshot,e,!1);return this.render(s)}clearSnapshotCache(){this.snapshotCache.clear()}async cacheSnapshot(e=this.snapshot){if(e.isCacheable){this.delegate.viewWillCacheSnapshot();let{lastRenderedLocation:t}=this;await rt();let s=e.clone();return this.snapshotCache.put(t,s),s}}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)&&(e?.refresh?.scroll||this.snapshot.refreshScroll)==="preserve"}get snapshot(){return I.fromElement(this.element)}}class _t{selector="a[data-turbo-preload]";constructor(e,t){this.delegate=e,this.snapshotCache=t}start(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",this.#e);else this.preloadOnLoadLinksForView(document.body)}stop(){document.removeEventListener("DOMContentLoaded",this.#e)}preloadOnLoadLinksForView(e){for(let t of e.querySelectorAll(this.selector))if(this.delegate.shouldPreloadLink(t))this.preloadURL(t)}async preloadURL(e){let t=new URL(e.href);if(this.snapshotCache.has(t))return;await new Z(this,k.get,t,new URLSearchParams,e).perform()}prepareRequest(e){e.headers["X-Sec-Purpose"]="prefetch"}async requestSucceededWithResponse(e,t){try{let s=await t.responseHTML,r=I.fromHTMLString(s);this.snapshotCache.put(e.url,r)}catch(s){}}requestStarted(e){}requestErrored(e){}requestFinished(e){}requestPreventedHandlingResponse(e,t){}requestFailedWithResponse(e,t){}#e=()=>{this.preloadOnLoadLinksForView(document.body)}}class jt{constructor(e){this.session=e}clear(){this.session.clearCache()}resetCacheControl(){this.#e("")}exemptPageFromCache(){this.#e("no-cache")}exemptPageFromPreview(){this.#e("no-preview")}#e(e){Vs("turbo-cache-control",e)}}class Ut{navigator=new Nt(this);history=new It(this);view=new Wt(this,document.documentElement);adapter=new kt(this);pageObserver=new Dt(this);cacheObserver=new Ft;linkPrefetchObserver=new Bt(this,document);linkClickObserver=new Fe(this,window);formSubmitObserver=new pe(this,document);scrollObserver=new qt(this);streamObserver=new Ht(this);formLinkClickObserver=new Pe(this,document.documentElement);frameRedirector=new Pt(this,document.documentElement);streamMessageRenderer=new xt;cache=new jt(this);enabled=!0;started=!1;#e=150;constructor(e){this.recentRequests=e,this.preloader=new _t(this,this.view.snapshotCache),this.debouncedRefresh=this.refresh,this.pageRefreshDebouncePeriod=this.pageRefreshDebouncePeriod}start(){if(!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(){if(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={}){let s=t.frame?document.getElementById(t.frame):null;if(s instanceof F){let r=t.action||K(s);s.delegate.proposeVisitIfNavigatedWithAction(s,r),s.src=e.toString()}else this.navigator.proposeVisit(R(e),t)}refresh(e,t={}){t=typeof t==="string"?{requestId:t}:t;let{method:s,requestId:r,scroll:i}=t,n=r&&this.recentRequests.has(r),l=e===document.baseURI;if(!n&&!this.navigator.currentVisit&&l)this.visit(e,{action:"replace",shouldCacheSnapshot:!1,refresh:{method:s,scroll:i}})}connectStreamSource(e){this.streamObserver.connectStreamSource(e)}disconnectStreamSource(e){this.streamObserver.disconnectStreamSource(e)}renderStreamMessage(e){this.streamMessageRenderer.render(z.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){C.drive.progressBarDelay=e}get progressBarDelay(){return C.drive.progressBarDelay}set drive(e){C.drive.enabled=e}get drive(){return C.drive.enabled}set formMode(e){C.forms.mode=e}get formMode(){return C.forms.mode}get location(){return this.history.location}get restorationIdentifier(){return this.history.restorationIdentifier}get pageRefreshDebouncePeriod(){return this.#e}set pageRefreshDebouncePeriod(e){this.refresh=Ws(this.debouncedRefresh.bind(this),e),this.#e=e}shouldPreloadLink(e){let t=e.hasAttribute("data-turbo-method"),s=e.hasAttribute("data-turbo-stream"),r=e.getAttribute("data-turbo-frame"),i=r=="_top"?null:document.getElementById(r)||Q(e,"turbo-frame:not([disabled])");if(t||s||i instanceof F)return!1;else{let n=new URL(e.href);return this.elementIsNavigatable(e)&&V(n,this.snapshot.rootLocation)}}historyPoppedToLocationWithRestorationIdentifierAndDirection(e,t,s){if(this.enabled)this.navigator.startVisit(e,t,{action:"restore",historyChanged:!0,direction:s});else this.adapter.pageInvalidated({reason:"turbo_disabled"})}historyPoppedWithEmptyState(e){this.history.replace(e),this.view.lastRenderedLocation=e,this.view.cacheSnapshot()}scrollPositionChanged(e){this.history.updateRestorationData({scrollPosition:e})}willSubmitFormLinkToLocation(e,t){return this.elementIsNavigatable(e)&&V(t,this.snapshot.rootLocation)}submittedFormLinkToLocation(){}canPrefetchRequestToLocation(e,t){return this.elementIsNavigatable(e)&&V(t,this.snapshot.rootLocation)&&this.navigator.linkPrefetchingIsEnabledForLocation(t)}willFollowLinkToLocation(e,t,s){return this.elementIsNavigatable(e)&&V(t,this.snapshot.rootLocation)&&this.applicationAllowsFollowingLinkToLocation(e,t,s)}followedLinkToLocation(e,t){let s=this.getActionForLink(e),r=e.hasAttribute("data-turbo-stream");this.visit(t.href,{action:s,acceptsStreamResponse:r})}allowsVisitingLocationWithAction(e,t){return this.applicationAllowsVisitingLocation(e)}visitProposedToLocation(e,t){et(e),this.adapter.visitProposedToLocation(e,t)}visitStarted(e){if(!e.acceptsStreamResponse)he(document.documentElement),this.view.markVisitDirection(e.direction);et(e.location),this.notifyApplicationAfterVisitingLocation(e.location,e.action)}visitCompleted(e){this.view.unmarkVisitDirection(),ue(document.documentElement),this.notifyApplicationAfterPageLoad(e.getTimingMetrics())}willSubmitForm(e,t){let s=Le(e,t);return this.submissionIsNavigatable(e,t)&&V(R(s),this.snapshot.rootLocation)}formSubmitted(e,t){this.navigator.submitForm(e,t)}pageBecameInteractive(){this.view.lastRenderedLocation=this.location,this.notifyApplicationAfterPageLoad()}pageLoaded(){this.history.assumeControlOfScrollRestoration()}pageWillUnload(){this.history.relinquishControlOfScrollRestoration()}receivedMessageFromStream(e){this.renderStreamMessage(e)}viewWillCacheSnapshot(){this.notifyApplicationBeforeCachingSnapshot()}allowsImmediateRender({element:e},t){let s=this.notifyApplicationBeforeRender(e,t),{defaultPrevented:r,detail:{render:i}}=s;if(this.view.renderer&&i)this.view.renderer.renderElement=i;return!r}viewRenderedSnapshot(e,t,s){this.view.lastRenderedLocation=this.history.location,this.notifyApplicationAfterRender(s)}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,s){return!this.notifyApplicationAfterClickingLinkToLocation(e,t,s).defaultPrevented}applicationAllowsVisitingLocation(e){return!this.notifyApplicationBeforeVisitingLocation(e).defaultPrevented}notifyApplicationAfterClickingLinkToLocation(e,t,s){return T("turbo:click",{target:e,detail:{url:t.href,originalEvent:s},cancelable:!0})}notifyApplicationBeforeVisitingLocation(e){return T("turbo:before-visit",{detail:{url:e.href},cancelable:!0})}notifyApplicationAfterVisitingLocation(e,t){return T("turbo:visit",{detail:{url:e.href,action:t}})}notifyApplicationBeforeCachingSnapshot(){return T("turbo:before-cache")}notifyApplicationBeforeRender(e,t){return T("turbo:before-render",{detail:{newBody:e,...t},cancelable:!0})}notifyApplicationAfterRender(e){return T("turbo:render",{detail:{renderMethod:e}})}notifyApplicationAfterPageLoad(e={}){return T("turbo:load",{detail:{url:this.location.href,timing:e}})}notifyApplicationAfterFrameLoad(e){return T("turbo:frame-load",{target:e})}notifyApplicationAfterFrameRender(e,t){return T("turbo:frame-render",{detail:{fetchResponse:e},target:t,cancelable:!0})}submissionIsNavigatable(e,t){if(C.forms.mode=="off")return!1;else{let s=t?this.elementIsNavigatable(t):!0;if(C.forms.mode=="optin")return s&&e.closest('[data-turbo="true"]')!=null;else return s&&this.elementIsNavigatable(e)}}elementIsNavigatable(e){let t=Q(e,"[data-turbo]"),s=Q(e,"turbo-frame");if(C.drive.enabled||s)if(t)return t.getAttribute("data-turbo")!="false";else return!0;else if(t)return t.getAttribute("data-turbo")=="true";else return!1}getActionForLink(e){return K(e)||"advance"}get snapshot(){return this.view.snapshot}}function et(e){Object.defineProperties(e,Dr)}var Dr={absoluteURL:{get(){return this.toString()}}},L=new Ut(pt),{cache:qr,navigator:xr}=L;function Kt(){L.start()}function Hr(e){L.registerAdapter(e)}function Vr(e,t){L.visit(e,t)}function zt(e){L.connectStreamSource(e)}function Jt(e){L.disconnectStreamSource(e)}function $r(e){L.renderStreamMessage(e)}function Wr(e){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.`"),C.drive.progressBarDelay=e}function _r(e){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.`"),C.forms.confirm=e}function jr(e){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.`"),C.forms.mode=e}function Ur(e,t){De.renderElement(e,t)}function Kr(e,t){Ne.renderElement(e,t)}var zr=Object.freeze({__proto__:null,PageRenderer:ye,PageSnapshot:I,FrameRenderer:be,fetch:gt,config:C,session:L,cache:qr,navigator:xr,start:Kt,registerAdapter:Hr,visit:Vr,connectStreamSource:zt,disconnectStreamSource:Jt,renderStreamMessage:$r,setProgressBarDelay:Wr,setConfirmMethod:_r,setFormMode:jr,morphBodyElements:Ur,morphTurboFrameElements:Kr,morphChildren:Be,morphElements:ve});class Xt extends Error{}class Yt{fetchResponseLoaded=(e)=>Promise.resolve();#e=null;#t=()=>{};#s=!1;#o=!1;#a=new Set;#i=!1;action=null;constructor(e){this.element=e,this.view=new At(this,this.element),this.appearanceObserver=new vt(this,this.element),this.formLinkClickObserver=new Pe(this,this.element),this.linkInterceptor=new ke(this,this.element),this.restorationIdentifier=W(),this.formSubmitObserver=new pe(this,this.element)}connect(){if(!this.#s){if(this.#s=!0,this.loadingStyle==X.lazy)this.appearanceObserver.start();else this.#r();this.formLinkClickObserver.start(),this.linkInterceptor.start(),this.formSubmitObserver.start()}}disconnect(){if(this.#s){if(this.#s=!1,this.appearanceObserver.stop(),this.formLinkClickObserver.stop(),this.linkInterceptor.stop(),this.formSubmitObserver.stop(),!this.element.hasAttribute("recurse"))this.#e?.cancel()}}disabledChanged(){if(this.disabled)this.#e?.cancel();else if(this.loadingStyle==X.eager)this.#r()}sourceURLChanged(){if(this.#y("src"))return;if(!this.sourceURL)this.#e?.cancel();if(this.element.isConnected)this.complete=!1;if(this.loadingStyle==X.eager||this.#o)this.#r()}sourceURLReloaded(){let{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(){if(this.loadingStyle==X.lazy)this.appearanceObserver.start();else this.appearanceObserver.stop(),this.#r()}async#r(){if(this.enabled&&this.isActive&&!this.complete&&this.sourceURL)this.element.loaded=this.#d(R(this.sourceURL)),this.appearanceObserver.stop(),await this.element.loaded,this.#o=!0}async loadResponse(e){if(e.redirected||e.succeeded&&e.isHTML)this.sourceURL=e.response.url;try{let t=await e.responseHTML;if(t){let s=it(t);if(I.fromDocument(s).isVisitable)await this.#c(e,s);else await this.#m(e)}}finally{this.#i=!1,this.fetchResponseLoaded=()=>Promise.resolve()}}elementAppearedInViewport(e){this.proposeVisitIfNavigatedWithAction(e,K(e)),this.#r()}willSubmitFormLinkToLocation(e){return this.#l(e)}submittedFormLinkToLocation(e,t,s){let r=this.#n(e);if(r)s.setAttribute("data-turbo-frame",r.id)}shouldInterceptLinkClick(e,t,s){return this.#l(e)}linkClickIntercepted(e,t){this.#f(e,t)}willSubmitForm(e,t){return e.closest("turbo-frame")==this.element&&this.#l(e,t)}formSubmitted(e,t){if(this.formSubmission)this.formSubmission.stop();this.formSubmission=new me(this,e,t);let{fetchRequest:s}=this.formSubmission,r=this.#n(e,t);this.prepareRequest(s,r),this.formSubmission.start()}prepareRequest(e,t=this){if(e.headers["Turbo-Frame"]=t.id,this.currentNavigationElement?.hasAttribute("data-turbo-stream"))e.acceptResponseType(z.contentType)}requestStarted(e){he(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){ue(this.element)}formSubmissionStarted({formElement:e}){he(e,this.#n(e))}formSubmissionSucceededWithResponse(e,t){let s=this.#n(e.formElement,e.submitter);if(s.delegate.proposeVisitIfNavigatedWithAction(s,K(e.submitter,e.formElement,s)),s.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}){ue(e,this.#n(e))}allowsImmediateRender({element:e},t){let s=T("turbo:before-frame-render",{target:this.element,detail:{newFrame:e,...t},cancelable:!0}),{defaultPrevented:r,detail:{render:i}}=s;if(this.view.renderer&&i)this.view.renderer.renderElement=i;return!r}viewRenderedSnapshot(e,t,s){}preloadOnLoadLinksForView(e){L.preloadOnLoadLinksForView(e)}viewInvalidated(){}willRenderFrame(e,t){this.previousFrameElement=e.cloneNode(!0)}visitCachedSnapshot=({element:e})=>{let t=e.querySelector("#"+this.element.id);if(t&&this.previousFrameElement)t.replaceChildren(...this.previousFrameElement.children);delete this.previousFrameElement};async#c(e,t){let s=await this.extractForeignFrameElement(t.body),r=this.#i?Ne:be;if(s){let i=new re(s),n=new r(this,this.view.snapshot,i,!1,!1);if(this.view.renderPromise)await this.view.renderPromise;this.changeHistory(),await this.view.render(n),this.complete=!0,L.frameRendered(e,this.element),L.frameLoaded(this.element),await this.fetchResponseLoaded(e)}else if(this.#p(e))this.#g(e)}async#d(e){let t=new Z(this,k.get,e,new URLSearchParams,this.element);return this.#e?.cancel(),this.#e=t,new Promise((s)=>{this.#t=()=>{this.#t=()=>{},this.#e=null,s()},t.perform()})}#f(e,t,s){let r=this.#n(e,s);r.delegate.proposeVisitIfNavigatedWithAction(r,K(s,e,r)),this.#w(e,()=>{r.src=t})}proposeVisitIfNavigatedWithAction(e,t=null){if(this.action=t,this.action){let s=I.fromElement(e).clone(),{visitCachedSnapshot:r}=e.delegate;e.delegate.fetchResponseLoaded=async(i)=>{if(e.src){let{statusCode:n,redirected:l}=i,p=await i.responseHTML,M={response:{statusCode:n,redirected:l,responseHTML:p},visitCachedSnapshot:r,willRender:!1,updateHistory:!1,restorationIdentifier:this.restorationIdentifier,snapshot:s};if(this.action)M.action=this.action;L.visit(e.src,M)}}}}changeHistory(){if(this.action){let e=ot(this.action);L.history.update(e,R(this.element.src||""),this.restorationIdentifier)}}async#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)}#p(e){this.element.setAttribute("complete","");let t=e.response,s=async(i,n)=>{if(i instanceof Response)this.#h(i);else L.visit(i,n)};return!T("turbo:frame-missing",{target:this.element,detail:{response:t,visit:s},cancelable:!0}).defaultPrevented}#g(e){this.view.missing(),this.#b(e)}#b(e){let 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 Xt(t)}async#h(e){let t=new fe(e),s=await t.responseHTML,{location:r,redirected:i,statusCode:n}=t;return L.visit(r,{response:{redirected:i,statusCode:n,responseHTML:s}})}#n(e,t){let s=le("data-turbo-frame",t,e)||this.element.getAttribute("target"),r=this.#u(s);return r instanceof F?r:this.element}async extractForeignFrameElement(e){let t,s=CSS.escape(this.id);try{if(t=tt(e.querySelector(`turbo-frame#${s}`),this.sourceURL),t)return t;if(t=tt(e.querySelector(`turbo-frame[src][recurse~=${s}]`),this.sourceURL),t)return await t.loaded,await this.extractForeignFrameElement(t)}catch(r){return console.error(r),new F}return null}#v(e,t){let s=Le(e,t);return V(R(s),this.rootLocation)}#l(e,t){let s=le("data-turbo-frame",t,e)||this.element.getAttribute("target");if(e instanceof HTMLFormElement&&!this.#v(e,t))return!1;if(!this.enabled||s=="_top")return!1;if(s){let r=this.#u(s);if(r)return!r.disabled;else if(s=="_parent")return!1}if(!L.elementIsNavigatable(e))return!1;if(t&&!L.elementIsNavigatable(t))return!1;return!0}get id(){return this.element.id}get disabled(){return this.element.disabled}get enabled(){return!this.disabled}get sourceURL(){if(this.element.src)return this.element.src}set sourceURL(e){this.#E("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){if(e)this.element.setAttribute("complete","");else this.element.removeAttribute("complete")}get isActive(){return this.element.isActive&&this.#s}get rootLocation(){let t=this.element.ownerDocument.querySelector('meta[name="turbo-root"]')?.content??"/";return R(t)}#y(e){return this.#a.has(e)}#E(e,t){this.#a.add(e),t(),this.#a.delete(e)}#w(e,t){this.currentNavigationElement=e,t(),delete this.currentNavigationElement}#u(e){if(e!=null){let t=e==="_parent"?this.element.parentElement.closest("turbo-frame"):document.getElementById(e);if(t instanceof F)return t}}}function tt(e,t){if(e){let s=e.getAttribute("src");if(s!=null&&t!=null&&ft(s,t))throw Error(`Matching <turbo-frame id="${e.id}"> element has a source URL which references itself`);if(e.ownerDocument!==document)e=document.importNode(e,!0);if(e instanceof F)return e.connectedCallback(),e.disconnectedCallback(),e}}var Qt={after(){this.removeDuplicateTargetSiblings(),this.targetElements.forEach((e)=>e.parentElement?.insertBefore(this.templateContent,e.nextSibling))},append(){this.removeDuplicateTargetChildren(),this.targetElements.forEach((e)=>e.append(this.templateContent))},before(){this.removeDuplicateTargetSiblings(),this.targetElements.forEach((e)=>e.parentElement?.insertBefore(this.templateContent,e))},prepend(){this.removeDuplicateTargetChildren(),this.targetElements.forEach((e)=>e.prepend(this.templateContent))},remove(){this.targetElements.forEach((e)=>e.remove())},replace(){let e=this.getAttribute("method");this.targetElements.forEach((t)=>{if(e==="morph")ve(t,this.templateContent);else t.replaceWith(this.templateContent)})},update(){let e=this.getAttribute("method");this.targetElements.forEach((t)=>{if(e==="morph")Be(t,this.templateContent);else t.innerHTML="",t.append(this.templateContent)})},refresh(){let e=this.getAttribute("method"),t=this.requestId,s=this.getAttribute("scroll");L.refresh(this.baseURI,{method:e,requestId:t,scroll:s})}};class qe 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()=>{let e=this.beforeRenderEvent;if(this.dispatchEvent(e))await ee(),await e.detail.render(this)})()}disconnect(){try{this.remove()}catch{}}removeDuplicateTargetChildren(){this.duplicateChildren.forEach((e)=>e.remove())}get duplicateChildren(){let e=this.targetElements.flatMap((s)=>[...s.children]).filter((s)=>!!s.getAttribute("id")),t=[...this.templateContent?.children||[]].filter((s)=>!!s.getAttribute("id")).map((s)=>s.getAttribute("id"));return e.filter((s)=>t.includes(s.getAttribute("id")))}removeDuplicateTargetSiblings(){this.duplicateSiblings.forEach((e)=>e.remove())}get duplicateSiblings(){let e=this.targetElements.flatMap((s)=>[...s.parentElement.children]).filter((s)=>!!s.id),t=[...this.templateContent?.children||[]].filter((s)=>!!s.id).map((s)=>s.id);return e.filter((s)=>t.includes(s.id))}get performAction(){if(this.action){let e=Qt[this.action];if(e)return e;this.#e("unknown action")}this.#e("action attribute is missing")}get targetElements(){if(this.target)return this.targetElementsById;else if(this.targets)return this.targetElementsByQuery;else this.#e("target or targets attribute is missing")}get templateContent(){return this.templateElement.content.cloneNode(!0)}get templateElement(){if(this.firstElementChild===null){let 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 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:qe.renderElement}})}get targetElementsById(){let e=this.ownerDocument?.getElementById(this.target);if(e!==null)return[e];else return[]}get targetElementsByQuery(){let e=this.ownerDocument?.querySelectorAll(this.targets);if(e.length!==0)return Array.prototype.slice.call(e);else return[]}}class Gt extends HTMLElement{streamSource=null;connectedCallback(){this.streamSource=this.src.match(/^ws{1,2}:/)?new WebSocket(this.src):new EventSource(this.src),zt(this.streamSource)}disconnectedCallback(){if(this.streamSource)this.streamSource.close(),Jt(this.streamSource)}get src(){return this.getAttribute("src")||""}}F.delegateConstructor=Yt;if(customElements.get("turbo-frame")===void 0)customElements.define("turbo-frame",F);if(customElements.get("turbo-stream")===void 0)customElements.define("turbo-stream",qe);if(customElements.get("turbo-stream-source")===void 0)customElements.define("turbo-stream-source",Gt);(()=>{let e=document.currentScript;if(!e)return;if(e.hasAttribute("data-turbo-suppress-warning"))return;let t=e.parentElement;while(t){if(t==document.body)return console.warn(nt`
21
21
  You are loading Turbo from a <script> element inside the <body> element. This is probably not what you meant to do!
22
22
 
23
23
  Load your application’s JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change.
@@ -26,8 +26,8 @@ Copyright © 2026 37signals LLC
26
26
 
27
27
  ——
28
28
  Suppress this warning by adding a "data-turbo-suppress-warning" attribute to: %s
29
- `,H.outerHTML);J=J.parentElement}})();window.Turbo={...mQ,StreamActions:l1};i1();class GJ{constructor(H,J,Q){this.eventTarget=H,this.eventName=J,this.eventOptions=Q,this.unorderedBindings=new Set}connect(){this.eventTarget.addEventListener(this.eventName,this,this.eventOptions)}disconnect(){this.eventTarget.removeEventListener(this.eventName,this,this.eventOptions)}bindingConnected(H){this.unorderedBindings.add(H)}bindingDisconnected(H){this.unorderedBindings.delete(H)}handleEvent(H){let J=oQ(H);for(let Q of this.bindings)if(J.immediatePropagationStopped)break;else Q.handleEvent(J)}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort((H,J)=>{let Q=H.index,X=J.index;return Q<X?-1:Q>X?1:0})}}function oQ(H){if("immediatePropagationStopped"in H)return H;else{let{stopImmediatePropagation:J}=H;return Object.assign(H,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,J.call(this)}})}}class WJ{constructor(H){this.application=H,this.eventListenerMaps=new Map,this.started=!1}start(){if(!this.started)this.started=!0,this.eventListeners.forEach((H)=>H.connect())}stop(){if(this.started)this.started=!1,this.eventListeners.forEach((H)=>H.disconnect())}get eventListeners(){return Array.from(this.eventListenerMaps.values()).reduce((H,J)=>H.concat(Array.from(J.values())),[])}bindingConnected(H){this.fetchEventListenerForBinding(H).bindingConnected(H)}bindingDisconnected(H,J=!1){if(this.fetchEventListenerForBinding(H).bindingDisconnected(H),J)this.clearEventListenersForBinding(H)}handleError(H,J,Q={}){this.application.handleError(H,`Error ${J}`,Q)}clearEventListenersForBinding(H){let J=this.fetchEventListenerForBinding(H);if(!J.hasBindings())J.disconnect(),this.removeMappedEventListenerFor(H)}removeMappedEventListenerFor(H){let{eventTarget:J,eventName:Q,eventOptions:X}=H,Y=this.fetchEventListenerMapForEventTarget(J),Z=this.cacheKey(Q,X);if(Y.delete(Z),Y.size==0)this.eventListenerMaps.delete(J)}fetchEventListenerForBinding(H){let{eventTarget:J,eventName:Q,eventOptions:X}=H;return this.fetchEventListener(J,Q,X)}fetchEventListener(H,J,Q){let X=this.fetchEventListenerMapForEventTarget(H),Y=this.cacheKey(J,Q),Z=X.get(Y);if(!Z)Z=this.createEventListener(H,J,Q),X.set(Y,Z);return Z}createEventListener(H,J,Q){let X=new GJ(H,J,Q);if(this.started)X.connect();return X}fetchEventListenerMapForEventTarget(H){let J=this.eventListenerMaps.get(H);if(!J)J=new Map,this.eventListenerMaps.set(H,J);return J}cacheKey(H,J){let Q=[H];return Object.keys(J).sort().forEach((X)=>{Q.push(`${J[X]?"":"!"}${X}`)}),Q.join(":")}}var aQ={stop({event:H,value:J}){if(J)H.stopPropagation();return!0},prevent({event:H,value:J}){if(J)H.preventDefault();return!0},self({event:H,value:J,element:Q}){if(J)return Q===H.target;else return!0}},rQ=/^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function lQ(H){let Q=H.trim().match(rQ)||[],X=Q[2],Y=Q[3];if(Y&&!["keydown","keyup","keypress"].includes(X))X+=`.${Y}`,Y="";return{eventTarget:nQ(Q[4]),eventName:X,eventOptions:Q[7]?tQ(Q[7]):{},identifier:Q[5],methodName:Q[6],keyFilter:Q[1]||Y}}function nQ(H){if(H=="window")return window;else if(H=="document")return document}function tQ(H){return H.split(":").reduce((J,Q)=>Object.assign(J,{[Q.replace(/^!/,"")]:!/^!/.test(Q)}),{})}function eQ(H){if(H==window)return"window";else if(H==document)return"document"}function pH(H){return H.replace(/(?:[_-])([a-z0-9])/g,(J,Q)=>Q.toUpperCase())}function NH(H){return pH(H.replace(/--/g,"-").replace(/__/g,"_"))}function YH(H){return H.charAt(0).toUpperCase()+H.slice(1)}function AJ(H){return H.replace(/([A-Z])/g,(J,Q)=>`-${Q.toLowerCase()}`)}function HX(H){return H.match(/[^\s]+/g)||[]}function t1(H){return H!==null&&H!==void 0}function fH(H,J){return Object.prototype.hasOwnProperty.call(H,J)}var e1=["meta","ctrl","alt","shift"];class qJ{constructor(H,J,Q,X){this.element=H,this.index=J,this.eventTarget=Q.eventTarget||H,this.eventName=Q.eventName||JX(H)||PH("missing event name"),this.eventOptions=Q.eventOptions||{},this.identifier=Q.identifier||PH("missing identifier"),this.methodName=Q.methodName||PH("missing method name"),this.keyFilter=Q.keyFilter||"",this.schema=X}static forToken(H,J){return new this(H.element,H.index,lQ(H.content),J)}toString(){let H=this.keyFilter?`.${this.keyFilter}`:"",J=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${H}${J}->${this.identifier}#${this.methodName}`}shouldIgnoreKeyboardEvent(H){if(!this.keyFilter)return!1;let J=this.keyFilter.split("+");if(this.keyFilterDissatisfied(H,J))return!0;let Q=J.filter((X)=>!e1.includes(X))[0];if(!Q)return!1;if(!fH(this.keyMappings,Q))PH(`contains unknown key filter: ${this.keyFilter}`);return this.keyMappings[Q].toLowerCase()!==H.key.toLowerCase()}shouldIgnoreMouseEvent(H){if(!this.keyFilter)return!1;let J=[this.keyFilter];if(this.keyFilterDissatisfied(H,J))return!0;return!1}get params(){let H={},J=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(let{name:Q,value:X}of Array.from(this.element.attributes)){let Y=Q.match(J),Z=Y&&Y[1];if(Z)H[pH(Z)]=QX(X)}return H}get eventTargetName(){return eQ(this.eventTarget)}get keyMappings(){return this.schema.keyMappings}keyFilterDissatisfied(H,J){let[Q,X,Y,Z]=e1.map((A)=>J.includes(A));return H.metaKey!==Q||H.ctrlKey!==X||H.altKey!==Y||H.shiftKey!==Z}}var HJ={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:(H)=>H.getAttribute("type")=="submit"?"click":"input",select:()=>"change",textarea:()=>"input"};function JX(H){let J=H.tagName.toLowerCase();if(J in HJ)return HJ[J](H)}function PH(H){throw Error(H)}function QX(H){try{return JSON.parse(H)}catch(J){return H}}class UJ{constructor(H,J){this.context=H,this.action=J}get index(){return this.action.index}get eventTarget(){return this.action.eventTarget}get eventOptions(){return this.action.eventOptions}get identifier(){return this.context.identifier}handleEvent(H){let J=this.prepareActionEvent(H);if(this.willBeInvokedByEvent(H)&&this.applyEventModifiers(J))this.invokeWithEvent(J)}get eventName(){return this.action.eventName}get method(){let H=this.controller[this.methodName];if(typeof H=="function")return H;throw Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(H){let{element:J}=this.action,{actionDescriptorFilters:Q}=this.context.application,{controller:X}=this.context,Y=!0;for(let[Z,A]of Object.entries(this.eventOptions))if(Z in Q){let B=Q[Z];Y=Y&&B({name:Z,value:A,event:H,element:J,controller:X})}else continue;return Y}prepareActionEvent(H){return Object.assign(H,{params:this.action.params})}invokeWithEvent(H){let{target:J,currentTarget:Q}=H;try{this.method.call(this.controller,H),this.context.logDebugActivity(this.methodName,{event:H,target:J,currentTarget:Q,action:this.methodName})}catch(X){let{identifier:Y,controller:Z,element:A,index:B}=this,D={identifier:Y,controller:Z,element:A,index:B,event:H};this.context.handleError(X,`invoking action "${this.action}"`,D)}}willBeInvokedByEvent(H){let J=H.target;if(H instanceof KeyboardEvent&&this.action.shouldIgnoreKeyboardEvent(H))return!1;if(H instanceof MouseEvent&&this.action.shouldIgnoreMouseEvent(H))return!1;if(this.element===J)return!0;else if(J instanceof Element&&this.element.contains(J))return this.scope.containsElement(J);else return this.scope.containsElement(this.action.element)}get controller(){return this.context.controller}get methodName(){return this.action.methodName}get element(){return this.scope.element}get scope(){return this.context.scope}}class dH{constructor(H,J){this.mutationObserverInit={attributes:!0,childList:!0,subtree:!0},this.element=H,this.started=!1,this.delegate=J,this.elements=new Set,this.mutationObserver=new MutationObserver((Q)=>this.processMutations(Q))}start(){if(!this.started)this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh()}pause(H){if(this.started)this.mutationObserver.disconnect(),this.started=!1;if(H(),!this.started)this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0}stop(){if(this.started)this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1}refresh(){if(this.started){let H=new Set(this.matchElementsInTree());for(let J of Array.from(this.elements))if(!H.has(J))this.removeElement(J);for(let J of Array.from(H))this.addElement(J)}}processMutations(H){if(this.started)for(let J of H)this.processMutation(J)}processMutation(H){if(H.type=="attributes")this.processAttributeChange(H.target,H.attributeName);else if(H.type=="childList")this.processRemovedNodes(H.removedNodes),this.processAddedNodes(H.addedNodes)}processAttributeChange(H,J){if(this.elements.has(H))if(this.delegate.elementAttributeChanged&&this.matchElement(H))this.delegate.elementAttributeChanged(H,J);else this.removeElement(H);else if(this.matchElement(H))this.addElement(H)}processRemovedNodes(H){for(let J of Array.from(H)){let Q=this.elementFromNode(J);if(Q)this.processTree(Q,this.removeElement)}}processAddedNodes(H){for(let J of Array.from(H)){let Q=this.elementFromNode(J);if(Q&&this.elementIsActive(Q))this.processTree(Q,this.addElement)}}matchElement(H){return this.delegate.matchElement(H)}matchElementsInTree(H=this.element){return this.delegate.matchElementsInTree(H)}processTree(H,J){for(let Q of this.matchElementsInTree(H))J.call(this,Q)}elementFromNode(H){if(H.nodeType==Node.ELEMENT_NODE)return H}elementIsActive(H){if(H.isConnected!=this.element.isConnected)return!1;else return this.element.contains(H)}addElement(H){if(!this.elements.has(H)){if(this.elementIsActive(H)){if(this.elements.add(H),this.delegate.elementMatched)this.delegate.elementMatched(H)}}}removeElement(H){if(this.elements.has(H)){if(this.elements.delete(H),this.delegate.elementUnmatched)this.delegate.elementUnmatched(H)}}}class cH{constructor(H,J,Q){this.attributeName=J,this.delegate=Q,this.elementObserver=new dH(H,this)}get element(){return this.elementObserver.element}get selector(){return`[${this.attributeName}]`}start(){this.elementObserver.start()}pause(H){this.elementObserver.pause(H)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get started(){return this.elementObserver.started}matchElement(H){return H.hasAttribute(this.attributeName)}matchElementsInTree(H){let J=this.matchElement(H)?[H]:[],Q=Array.from(H.querySelectorAll(this.selector));return J.concat(Q)}elementMatched(H){if(this.delegate.elementMatchedAttribute)this.delegate.elementMatchedAttribute(H,this.attributeName)}elementUnmatched(H){if(this.delegate.elementUnmatchedAttribute)this.delegate.elementUnmatchedAttribute(H,this.attributeName)}elementAttributeChanged(H,J){if(this.delegate.elementAttributeValueChanged&&this.attributeName==J)this.delegate.elementAttributeValueChanged(H,J)}}function XX(H,J,Q){zJ(H,J).add(Q)}function YX(H,J,Q){zJ(H,J).delete(Q),ZX(H,J)}function zJ(H,J){let Q=H.get(J);if(!Q)Q=new Set,H.set(J,Q);return Q}function ZX(H,J){let Q=H.get(J);if(Q!=null&&Q.size==0)H.delete(J)}class c{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce((J,Q)=>J.concat(Array.from(Q)),[])}get size(){return Array.from(this.valuesByKey.values()).reduce((J,Q)=>J+Q.size,0)}add(H,J){XX(this.valuesByKey,H,J)}delete(H,J){YX(this.valuesByKey,H,J)}has(H,J){let Q=this.valuesByKey.get(H);return Q!=null&&Q.has(J)}hasKey(H){return this.valuesByKey.has(H)}hasValue(H){return Array.from(this.valuesByKey.values()).some((Q)=>Q.has(H))}getValuesForKey(H){let J=this.valuesByKey.get(H);return J?Array.from(J):[]}getKeysForValue(H){return Array.from(this.valuesByKey).filter(([J,Q])=>Q.has(H)).map(([J,Q])=>J)}}class KJ{constructor(H,J,Q,X){this._selector=J,this.details=X,this.elementObserver=new dH(H,this),this.delegate=Q,this.matchesByElement=new c}get started(){return this.elementObserver.started}get selector(){return this._selector}set selector(H){this._selector=H,this.refresh()}start(){this.elementObserver.start()}pause(H){this.elementObserver.pause(H)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get element(){return this.elementObserver.element}matchElement(H){let{selector:J}=this;if(J){let Q=H.matches(J);if(this.delegate.selectorMatchElement)return Q&&this.delegate.selectorMatchElement(H,this.details);return Q}else return!1}matchElementsInTree(H){let{selector:J}=this;if(J){let Q=this.matchElement(H)?[H]:[],X=Array.from(H.querySelectorAll(J)).filter((Y)=>this.matchElement(Y));return Q.concat(X)}else return[]}elementMatched(H){let{selector:J}=this;if(J)this.selectorMatched(H,J)}elementUnmatched(H){let J=this.matchesByElement.getKeysForValue(H);for(let Q of J)this.selectorUnmatched(H,Q)}elementAttributeChanged(H,J){let{selector:Q}=this;if(Q){let X=this.matchElement(H),Y=this.matchesByElement.has(Q,H);if(X&&!Y)this.selectorMatched(H,Q);else if(!X&&Y)this.selectorUnmatched(H,Q)}}selectorMatched(H,J){this.delegate.selectorMatched(H,J,this.details),this.matchesByElement.add(J,H)}selectorUnmatched(H,J){this.delegate.selectorUnmatched(H,J,this.details),this.matchesByElement.delete(J,H)}}class _J{constructor(H,J){this.element=H,this.delegate=J,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver((Q)=>this.processMutations(Q))}start(){if(!this.started)this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh()}stop(){if(this.started)this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1}refresh(){if(this.started)for(let H of this.knownAttributeNames)this.refreshAttribute(H,null)}processMutations(H){if(this.started)for(let J of H)this.processMutation(J)}processMutation(H){let J=H.attributeName;if(J)this.refreshAttribute(J,H.oldValue)}refreshAttribute(H,J){let Q=this.delegate.getStringMapKeyForAttribute(H);if(Q!=null){if(!this.stringMap.has(H))this.stringMapKeyAdded(Q,H);let X=this.element.getAttribute(H);if(this.stringMap.get(H)!=X)this.stringMapValueChanged(X,Q,J);if(X==null){let Y=this.stringMap.get(H);if(this.stringMap.delete(H),Y)this.stringMapKeyRemoved(Q,H,Y)}else this.stringMap.set(H,X)}}stringMapKeyAdded(H,J){if(this.delegate.stringMapKeyAdded)this.delegate.stringMapKeyAdded(H,J)}stringMapValueChanged(H,J,Q){if(this.delegate.stringMapValueChanged)this.delegate.stringMapValueChanged(H,J,Q)}stringMapKeyRemoved(H,J,Q){if(this.delegate.stringMapKeyRemoved)this.delegate.stringMapKeyRemoved(H,J,Q)}get knownAttributeNames(){return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))}get currentAttributeNames(){return Array.from(this.element.attributes).map((H)=>H.name)}get recordedAttributeNames(){return Array.from(this.stringMap.keys())}}class uH{constructor(H,J,Q){this.attributeObserver=new cH(H,J,this),this.delegate=Q,this.tokensByElement=new c}get started(){return this.attributeObserver.started}start(){this.attributeObserver.start()}pause(H){this.attributeObserver.pause(H)}stop(){this.attributeObserver.stop()}refresh(){this.attributeObserver.refresh()}get element(){return this.attributeObserver.element}get attributeName(){return this.attributeObserver.attributeName}elementMatchedAttribute(H){this.tokensMatched(this.readTokensForElement(H))}elementAttributeValueChanged(H){let[J,Q]=this.refreshTokensForElement(H);this.tokensUnmatched(J),this.tokensMatched(Q)}elementUnmatchedAttribute(H){this.tokensUnmatched(this.tokensByElement.getValuesForKey(H))}tokensMatched(H){H.forEach((J)=>this.tokenMatched(J))}tokensUnmatched(H){H.forEach((J)=>this.tokenUnmatched(J))}tokenMatched(H){this.delegate.tokenMatched(H),this.tokensByElement.add(H.element,H)}tokenUnmatched(H){this.delegate.tokenUnmatched(H),this.tokensByElement.delete(H.element,H)}refreshTokensForElement(H){let J=this.tokensByElement.getValuesForKey(H),Q=this.readTokensForElement(H),X=GX(J,Q).findIndex(([Y,Z])=>!WX(Y,Z));if(X==-1)return[[],[]];else return[J.slice(X),Q.slice(X)]}readTokensForElement(H){let J=this.attributeName,Q=H.getAttribute(J)||"";return $X(Q,H,J)}}function $X(H,J,Q){return H.trim().split(/\s+/).filter((X)=>X.length).map((X,Y)=>({element:J,attributeName:Q,content:X,index:Y}))}function GX(H,J){let Q=Math.max(H.length,J.length);return Array.from({length:Q},(X,Y)=>[H[Y],J[Y]])}function WX(H,J){return H&&J&&H.index==J.index&&H.content==J.content}class sH{constructor(H,J,Q){this.tokenListObserver=new uH(H,J,this),this.delegate=Q,this.parseResultsByToken=new WeakMap,this.valuesByTokenByElement=new WeakMap}get started(){return this.tokenListObserver.started}start(){this.tokenListObserver.start()}stop(){this.tokenListObserver.stop()}refresh(){this.tokenListObserver.refresh()}get element(){return this.tokenListObserver.element}get attributeName(){return this.tokenListObserver.attributeName}tokenMatched(H){let{element:J}=H,{value:Q}=this.fetchParseResultForToken(H);if(Q)this.fetchValuesByTokenForElement(J).set(H,Q),this.delegate.elementMatchedValue(J,Q)}tokenUnmatched(H){let{element:J}=H,{value:Q}=this.fetchParseResultForToken(H);if(Q)this.fetchValuesByTokenForElement(J).delete(H),this.delegate.elementUnmatchedValue(J,Q)}fetchParseResultForToken(H){let J=this.parseResultsByToken.get(H);if(!J)J=this.parseToken(H),this.parseResultsByToken.set(H,J);return J}fetchValuesByTokenForElement(H){let J=this.valuesByTokenByElement.get(H);if(!J)J=new Map,this.valuesByTokenByElement.set(H,J);return J}parseToken(H){try{return{value:this.delegate.parseValueForToken(H)}}catch(J){return{error:J}}}}class BJ{constructor(H,J){this.context=H,this.delegate=J,this.bindingsByAction=new Map}start(){if(!this.valueListObserver)this.valueListObserver=new sH(this.element,this.actionAttribute,this),this.valueListObserver.start()}stop(){if(this.valueListObserver)this.valueListObserver.stop(),delete this.valueListObserver,this.disconnectAllActions()}get element(){return this.context.element}get identifier(){return this.context.identifier}get actionAttribute(){return this.schema.actionAttribute}get schema(){return this.context.schema}get bindings(){return Array.from(this.bindingsByAction.values())}connectAction(H){let J=new UJ(this.context,H);this.bindingsByAction.set(H,J),this.delegate.bindingConnected(J)}disconnectAction(H){let J=this.bindingsByAction.get(H);if(J)this.bindingsByAction.delete(H),this.delegate.bindingDisconnected(J)}disconnectAllActions(){this.bindings.forEach((H)=>this.delegate.bindingDisconnected(H,!0)),this.bindingsByAction.clear()}parseValueForToken(H){let J=qJ.forToken(H,this.schema);if(J.identifier==this.identifier)return J}elementMatchedValue(H,J){this.connectAction(J)}elementUnmatchedValue(H,J){this.disconnectAction(J)}}class IJ{constructor(H,J){this.context=H,this.receiver=J,this.stringMapObserver=new _J(this.element,this),this.valueDescriptorMap=this.controller.valueDescriptorMap}start(){this.stringMapObserver.start(),this.invokeChangedCallbacksForDefaultValues()}stop(){this.stringMapObserver.stop()}get element(){return this.context.element}get controller(){return this.context.controller}getStringMapKeyForAttribute(H){if(H in this.valueDescriptorMap)return this.valueDescriptorMap[H].name}stringMapKeyAdded(H,J){let Q=this.valueDescriptorMap[J];if(!this.hasValue(H))this.invokeChangedCallback(H,Q.writer(this.receiver[H]),Q.writer(Q.defaultValue))}stringMapValueChanged(H,J,Q){let X=this.valueDescriptorNameMap[J];if(H===null)return;if(Q===null)Q=X.writer(X.defaultValue);this.invokeChangedCallback(J,H,Q)}stringMapKeyRemoved(H,J,Q){let X=this.valueDescriptorNameMap[H];if(this.hasValue(H))this.invokeChangedCallback(H,X.writer(this.receiver[H]),Q);else this.invokeChangedCallback(H,X.writer(X.defaultValue),Q)}invokeChangedCallbacksForDefaultValues(){for(let{key:H,name:J,defaultValue:Q,writer:X}of this.valueDescriptors)if(Q!=null&&!this.controller.data.has(H))this.invokeChangedCallback(J,X(Q),void 0)}invokeChangedCallback(H,J,Q){let X=`${H}Changed`,Y=this.receiver[X];if(typeof Y=="function"){let Z=this.valueDescriptorNameMap[H];try{let A=Z.reader(J),B=Q;if(Q)B=Z.reader(Q);Y.call(this.receiver,A,B)}catch(A){if(A instanceof TypeError)A.message=`Stimulus Value "${this.context.identifier}.${Z.name}" - ${A.message}`;throw A}}}get valueDescriptors(){let{valueDescriptorMap:H}=this;return Object.keys(H).map((J)=>H[J])}get valueDescriptorNameMap(){let H={};return Object.keys(this.valueDescriptorMap).forEach((J)=>{let Q=this.valueDescriptorMap[J];H[Q.name]=Q}),H}hasValue(H){let J=this.valueDescriptorNameMap[H],Q=`has${YH(J.name)}`;return this.receiver[Q]}}class FJ{constructor(H,J){this.context=H,this.delegate=J,this.targetsByName=new c}start(){if(!this.tokenListObserver)this.tokenListObserver=new uH(this.element,this.attributeName,this),this.tokenListObserver.start()}stop(){if(this.tokenListObserver)this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver}tokenMatched({element:H,content:J}){if(this.scope.containsElement(H))this.connectTarget(H,J)}tokenUnmatched({element:H,content:J}){this.disconnectTarget(H,J)}connectTarget(H,J){var Q;if(!this.targetsByName.has(J,H))this.targetsByName.add(J,H),(Q=this.tokenListObserver)===null||Q===void 0||Q.pause(()=>this.delegate.targetConnected(H,J))}disconnectTarget(H,J){var Q;if(this.targetsByName.has(J,H))this.targetsByName.delete(J,H),(Q=this.tokenListObserver)===null||Q===void 0||Q.pause(()=>this.delegate.targetDisconnected(H,J))}disconnectAllTargets(){for(let H of this.targetsByName.keys)for(let J of this.targetsByName.getValuesForKey(H))this.disconnectTarget(J,H)}get attributeName(){return`data-${this.context.identifier}-target`}get element(){return this.context.element}get scope(){return this.context.scope}}function ZH(H,J){let Q=MJ(H);return Array.from(Q.reduce((X,Y)=>{return qX(Y,J).forEach((Z)=>X.add(Z)),X},new Set))}function AX(H,J){return MJ(H).reduce((X,Y)=>{return X.push(...UX(Y,J)),X},[])}function MJ(H){let J=[];while(H)J.push(H),H=Object.getPrototypeOf(H);return J.reverse()}function qX(H,J){let Q=H[J];return Array.isArray(Q)?Q:[]}function UX(H,J){let Q=H[J];return Q?Object.keys(Q).map((X)=>[X,Q[X]]):[]}class PJ{constructor(H,J){this.started=!1,this.context=H,this.delegate=J,this.outletsByName=new c,this.outletElementsByName=new c,this.selectorObserverMap=new Map,this.attributeObserverMap=new Map}start(){if(!this.started)this.outletDefinitions.forEach((H)=>{this.setupSelectorObserverForOutlet(H),this.setupAttributeObserverForOutlet(H)}),this.started=!0,this.dependentContexts.forEach((H)=>H.refresh())}refresh(){this.selectorObserverMap.forEach((H)=>H.refresh()),this.attributeObserverMap.forEach((H)=>H.refresh())}stop(){if(this.started)this.started=!1,this.disconnectAllOutlets(),this.stopSelectorObservers(),this.stopAttributeObservers()}stopSelectorObservers(){if(this.selectorObserverMap.size>0)this.selectorObserverMap.forEach((H)=>H.stop()),this.selectorObserverMap.clear()}stopAttributeObservers(){if(this.attributeObserverMap.size>0)this.attributeObserverMap.forEach((H)=>H.stop()),this.attributeObserverMap.clear()}selectorMatched(H,J,{outletName:Q}){let X=this.getOutlet(H,Q);if(X)this.connectOutlet(X,H,Q)}selectorUnmatched(H,J,{outletName:Q}){let X=this.getOutletFromMap(H,Q);if(X)this.disconnectOutlet(X,H,Q)}selectorMatchElement(H,{outletName:J}){let Q=this.selector(J),X=this.hasOutlet(H,J),Y=H.matches(`[${this.schema.controllerAttribute}~=${J}]`);if(Q)return X&&Y&&H.matches(Q);else return!1}elementMatchedAttribute(H,J){let Q=this.getOutletNameFromOutletAttributeName(J);if(Q)this.updateSelectorObserverForOutlet(Q)}elementAttributeValueChanged(H,J){let Q=this.getOutletNameFromOutletAttributeName(J);if(Q)this.updateSelectorObserverForOutlet(Q)}elementUnmatchedAttribute(H,J){let Q=this.getOutletNameFromOutletAttributeName(J);if(Q)this.updateSelectorObserverForOutlet(Q)}connectOutlet(H,J,Q){var X;if(!this.outletElementsByName.has(Q,J))this.outletsByName.add(Q,H),this.outletElementsByName.add(Q,J),(X=this.selectorObserverMap.get(Q))===null||X===void 0||X.pause(()=>this.delegate.outletConnected(H,J,Q))}disconnectOutlet(H,J,Q){var X;if(this.outletElementsByName.has(Q,J))this.outletsByName.delete(Q,H),this.outletElementsByName.delete(Q,J),(X=this.selectorObserverMap.get(Q))===null||X===void 0||X.pause(()=>this.delegate.outletDisconnected(H,J,Q))}disconnectAllOutlets(){for(let H of this.outletElementsByName.keys)for(let J of this.outletElementsByName.getValuesForKey(H))for(let Q of this.outletsByName.getValuesForKey(H))this.disconnectOutlet(Q,J,H)}updateSelectorObserverForOutlet(H){let J=this.selectorObserverMap.get(H);if(J)J.selector=this.selector(H)}setupSelectorObserverForOutlet(H){let J=this.selector(H),Q=new KJ(document.body,J,this,{outletName:H});this.selectorObserverMap.set(H,Q),Q.start()}setupAttributeObserverForOutlet(H){let J=this.attributeNameForOutletName(H),Q=new cH(this.scope.element,J,this);this.attributeObserverMap.set(H,Q),Q.start()}selector(H){return this.scope.outlets.getSelectorForOutletName(H)}attributeNameForOutletName(H){return this.scope.schema.outletAttributeForScope(this.identifier,H)}getOutletNameFromOutletAttributeName(H){return this.outletDefinitions.find((J)=>this.attributeNameForOutletName(J)===H)}get outletDependencies(){let H=new c;return this.router.modules.forEach((J)=>{let Q=J.definition.controllerConstructor;ZH(Q,"outlets").forEach((Y)=>H.add(Y,J.identifier))}),H}get outletDefinitions(){return this.outletDependencies.getKeysForValue(this.identifier)}get dependentControllerIdentifiers(){return this.outletDependencies.getValuesForKey(this.identifier)}get dependentContexts(){let H=this.dependentControllerIdentifiers;return this.router.contexts.filter((J)=>H.includes(J.identifier))}hasOutlet(H,J){return!!this.getOutlet(H,J)||!!this.getOutletFromMap(H,J)}getOutlet(H,J){return this.application.getControllerForElementAndIdentifier(H,J)}getOutletFromMap(H,J){return this.outletsByName.getValuesForKey(J).find((Q)=>Q.element===H)}get scope(){return this.context.scope}get schema(){return this.context.schema}get identifier(){return this.context.identifier}get application(){return this.context.application}get router(){return this.application.router}}class LJ{constructor(H,J){this.logDebugActivity=(Q,X={})=>{let{identifier:Y,controller:Z,element:A}=this;X=Object.assign({identifier:Y,controller:Z,element:A},X),this.application.logDebugActivity(this.identifier,Q,X)},this.module=H,this.scope=J,this.controller=new H.controllerConstructor(this),this.bindingObserver=new BJ(this,this.dispatcher),this.valueObserver=new IJ(this,this.controller),this.targetObserver=new FJ(this,this),this.outletObserver=new PJ(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(Q){this.handleError(Q,"initializing controller")}}connect(){this.bindingObserver.start(),this.valueObserver.start(),this.targetObserver.start(),this.outletObserver.start();try{this.controller.connect(),this.logDebugActivity("connect")}catch(H){this.handleError(H,"connecting controller")}}refresh(){this.outletObserver.refresh()}disconnect(){try{this.controller.disconnect(),this.logDebugActivity("disconnect")}catch(H){this.handleError(H,"disconnecting controller")}this.outletObserver.stop(),this.targetObserver.stop(),this.valueObserver.stop(),this.bindingObserver.stop()}get application(){return this.module.application}get identifier(){return this.module.identifier}get schema(){return this.application.schema}get dispatcher(){return this.application.dispatcher}get element(){return this.scope.element}get parentElement(){return this.element.parentElement}handleError(H,J,Q={}){let{identifier:X,controller:Y,element:Z}=this;Q=Object.assign({identifier:X,controller:Y,element:Z},Q),this.application.handleError(H,`Error ${J}`,Q)}targetConnected(H,J){this.invokeControllerMethod(`${J}TargetConnected`,H)}targetDisconnected(H,J){this.invokeControllerMethod(`${J}TargetDisconnected`,H)}outletConnected(H,J,Q){this.invokeControllerMethod(`${NH(Q)}OutletConnected`,H,J)}outletDisconnected(H,J,Q){this.invokeControllerMethod(`${NH(Q)}OutletDisconnected`,H,J)}invokeControllerMethod(H,...J){let Q=this.controller;if(typeof Q[H]=="function")Q[H](...J)}}function zX(H){return KX(H,_X(H))}function KX(H,J){let Q=MX(H),X=BX(H.prototype,J);return Object.defineProperties(Q.prototype,X),Q}function _X(H){return ZH(H,"blessings").reduce((Q,X)=>{let Y=X(H);for(let Z in Y){let A=Q[Z]||{};Q[Z]=Object.assign(A,Y[Z])}return Q},{})}function BX(H,J){return FX(J).reduce((Q,X)=>{let Y=IX(H,J,X);if(Y)Object.assign(Q,{[X]:Y});return Q},{})}function IX(H,J,Q){let X=Object.getOwnPropertyDescriptor(H,Q);if(!(X&&("value"in X))){let Z=Object.getOwnPropertyDescriptor(J,Q).value;if(X)Z.get=X.get||Z.get,Z.set=X.set||Z.set;return Z}}var FX=(()=>{if(typeof Object.getOwnPropertySymbols=="function")return(H)=>[...Object.getOwnPropertyNames(H),...Object.getOwnPropertySymbols(H)];else return Object.getOwnPropertyNames})(),MX=(()=>{function H(Q){function X(){return Reflect.construct(Q,arguments,new.target)}return X.prototype=Object.create(Q.prototype,{constructor:{value:X}}),Reflect.setPrototypeOf(X,Q),X}function J(){let X=H(function(){this.a.call(this)});return X.prototype.a=function(){},new X}try{return J(),H}catch(Q){return(X)=>class extends X{}}})();function PX(H){return{identifier:H.identifier,controllerConstructor:zX(H.controllerConstructor)}}class jJ{constructor(H,J){this.application=H,this.definition=PX(J),this.contextsByScope=new WeakMap,this.connectedContexts=new Set}get identifier(){return this.definition.identifier}get controllerConstructor(){return this.definition.controllerConstructor}get contexts(){return Array.from(this.connectedContexts)}connectContextForScope(H){let J=this.fetchContextForScope(H);this.connectedContexts.add(J),J.connect()}disconnectContextForScope(H){let J=this.contextsByScope.get(H);if(J)this.connectedContexts.delete(J),J.disconnect()}fetchContextForScope(H){let J=this.contextsByScope.get(H);if(!J)J=new LJ(this,H),this.contextsByScope.set(H,J);return J}}class SJ{constructor(H){this.scope=H}has(H){return this.data.has(this.getDataKey(H))}get(H){return this.getAll(H)[0]}getAll(H){let J=this.data.get(this.getDataKey(H))||"";return HX(J)}getAttributeName(H){return this.data.getAttributeNameForKey(this.getDataKey(H))}getDataKey(H){return`${H}-class`}get data(){return this.scope.data}}class CJ{constructor(H){this.scope=H}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(H){let J=this.getAttributeNameForKey(H);return this.element.getAttribute(J)}set(H,J){let Q=this.getAttributeNameForKey(H);return this.element.setAttribute(Q,J),this.get(H)}has(H){let J=this.getAttributeNameForKey(H);return this.element.hasAttribute(J)}delete(H){if(this.has(H)){let J=this.getAttributeNameForKey(H);return this.element.removeAttribute(J),!0}else return!1}getAttributeNameForKey(H){return`data-${this.identifier}-${AJ(H)}`}}class wJ{constructor(H){this.warnedKeysByObject=new WeakMap,this.logger=H}warn(H,J,Q){let X=this.warnedKeysByObject.get(H);if(!X)X=new Set,this.warnedKeysByObject.set(H,X);if(!X.has(J))X.add(J),this.logger.warn(Q,H)}}function vH(H,J){return`[${H}~="${J}"]`}class EJ{constructor(H){this.scope=H}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(H){return this.find(H)!=null}find(...H){return H.reduce((J,Q)=>J||this.findTarget(Q)||this.findLegacyTarget(Q),void 0)}findAll(...H){return H.reduce((J,Q)=>[...J,...this.findAllTargets(Q),...this.findAllLegacyTargets(Q)],[])}findTarget(H){let J=this.getSelectorForTargetName(H);return this.scope.findElement(J)}findAllTargets(H){let J=this.getSelectorForTargetName(H);return this.scope.findAllElements(J)}getSelectorForTargetName(H){let J=this.schema.targetAttributeForScope(this.identifier);return vH(J,H)}findLegacyTarget(H){let J=this.getLegacySelectorForTargetName(H);return this.deprecate(this.scope.findElement(J),H)}findAllLegacyTargets(H){let J=this.getLegacySelectorForTargetName(H);return this.scope.findAllElements(J).map((Q)=>this.deprecate(Q,H))}getLegacySelectorForTargetName(H){let J=`${this.identifier}.${H}`;return vH(this.schema.targetAttribute,J)}deprecate(H,J){if(H){let{identifier:Q}=this,X=this.schema.targetAttribute,Y=this.schema.targetAttributeForScope(Q);this.guide.warn(H,`target:${J}`,`Please replace ${X}="${Q}.${J}" with ${Y}="${J}". The ${X} attribute is deprecated and will be removed in a future version of Stimulus.`)}return H}get guide(){return this.scope.guide}}class RJ{constructor(H,J){this.scope=H,this.controllerElement=J}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(H){return this.find(H)!=null}find(...H){return H.reduce((J,Q)=>J||this.findOutlet(Q),void 0)}findAll(...H){return H.reduce((J,Q)=>[...J,...this.findAllOutlets(Q)],[])}getSelectorForOutletName(H){let J=this.schema.outletAttributeForScope(this.identifier,H);return this.controllerElement.getAttribute(J)}findOutlet(H){let J=this.getSelectorForOutletName(H);if(J)return this.findElement(J,H)}findAllOutlets(H){let J=this.getSelectorForOutletName(H);return J?this.findAllElements(J,H):[]}findElement(H,J){return this.scope.queryElements(H).filter((X)=>this.matchesElement(X,H,J))[0]}findAllElements(H,J){return this.scope.queryElements(H).filter((X)=>this.matchesElement(X,H,J))}matchesElement(H,J,Q){let X=H.getAttribute(this.scope.schema.controllerAttribute)||"";return H.matches(J)&&X.split(" ").includes(Q)}}class iH{constructor(H,J,Q,X){this.targets=new EJ(this),this.classes=new SJ(this),this.data=new CJ(this),this.containsElement=(Y)=>{return Y.closest(this.controllerSelector)===this.element},this.schema=H,this.element=J,this.identifier=Q,this.guide=new wJ(X),this.outlets=new RJ(this.documentScope,J)}findElement(H){return this.element.matches(H)?this.element:this.queryElements(H).find(this.containsElement)}findAllElements(H){return[...this.element.matches(H)?[this.element]:[],...this.queryElements(H).filter(this.containsElement)]}queryElements(H){return Array.from(this.element.querySelectorAll(H))}get controllerSelector(){return vH(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new iH(this.schema,document.documentElement,this.identifier,this.guide.logger)}}class VJ{constructor(H,J,Q){this.element=H,this.schema=J,this.delegate=Q,this.valueListObserver=new sH(this.element,this.controllerAttribute,this),this.scopesByIdentifierByElement=new WeakMap,this.scopeReferenceCounts=new WeakMap}start(){this.valueListObserver.start()}stop(){this.valueListObserver.stop()}get controllerAttribute(){return this.schema.controllerAttribute}parseValueForToken(H){let{element:J,content:Q}=H;return this.parseValueForElementAndIdentifier(J,Q)}parseValueForElementAndIdentifier(H,J){let Q=this.fetchScopesByIdentifierForElement(H),X=Q.get(J);if(!X)X=this.delegate.createScopeForElementAndIdentifier(H,J),Q.set(J,X);return X}elementMatchedValue(H,J){let Q=(this.scopeReferenceCounts.get(J)||0)+1;if(this.scopeReferenceCounts.set(J,Q),Q==1)this.delegate.scopeConnected(J)}elementUnmatchedValue(H,J){let Q=this.scopeReferenceCounts.get(J);if(Q){if(this.scopeReferenceCounts.set(J,Q-1),Q==1)this.delegate.scopeDisconnected(J)}}fetchScopesByIdentifierForElement(H){let J=this.scopesByIdentifierByElement.get(H);if(!J)J=new Map,this.scopesByIdentifierByElement.set(H,J);return J}}class TJ{constructor(H){this.application=H,this.scopeObserver=new VJ(this.element,this.schema,this),this.scopesByIdentifier=new c,this.modulesByIdentifier=new Map}get element(){return this.application.element}get schema(){return this.application.schema}get logger(){return this.application.logger}get controllerAttribute(){return this.schema.controllerAttribute}get modules(){return Array.from(this.modulesByIdentifier.values())}get contexts(){return this.modules.reduce((H,J)=>H.concat(J.contexts),[])}start(){this.scopeObserver.start()}stop(){this.scopeObserver.stop()}loadDefinition(H){this.unloadIdentifier(H.identifier);let J=new jJ(this.application,H);this.connectModule(J);let Q=H.controllerConstructor.afterLoad;if(Q)Q.call(H.controllerConstructor,H.identifier,this.application)}unloadIdentifier(H){let J=this.modulesByIdentifier.get(H);if(J)this.disconnectModule(J)}getContextForElementAndIdentifier(H,J){let Q=this.modulesByIdentifier.get(J);if(Q)return Q.contexts.find((X)=>X.element==H)}proposeToConnectScopeForElementAndIdentifier(H,J){let Q=this.scopeObserver.parseValueForElementAndIdentifier(H,J);if(Q)this.scopeObserver.elementMatchedValue(Q.element,Q);else console.error(`Couldn't find or create scope for identifier: "${J}" and element:`,H)}handleError(H,J,Q){this.application.handleError(H,J,Q)}createScopeForElementAndIdentifier(H,J){return new iH(this.schema,H,J,this.logger)}scopeConnected(H){this.scopesByIdentifier.add(H.identifier,H);let J=this.modulesByIdentifier.get(H.identifier);if(J)J.connectContextForScope(H)}scopeDisconnected(H){this.scopesByIdentifier.delete(H.identifier,H);let J=this.modulesByIdentifier.get(H.identifier);if(J)J.disconnectContextForScope(H)}connectModule(H){this.modulesByIdentifier.set(H.identifier,H),this.scopesByIdentifier.getValuesForKey(H.identifier).forEach((Q)=>H.connectContextForScope(Q))}disconnectModule(H){this.modulesByIdentifier.delete(H.identifier),this.scopesByIdentifier.getValuesForKey(H.identifier).forEach((Q)=>H.disconnectContextForScope(Q))}}var LX={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:(H)=>`data-${H}-target`,outletAttributeForScope:(H,J)=>`data-${H}-${J}-outlet`,keyMappings:Object.assign(Object.assign({enter:"Enter",tab:"Tab",esc:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",page_up:"PageUp",page_down:"PageDown"},JJ("abcdefghijklmnopqrstuvwxyz".split("").map((H)=>[H,H]))),JJ("0123456789".split("").map((H)=>[H,H])))};function JJ(H){return H.reduce((J,[Q,X])=>Object.assign(Object.assign({},J),{[Q]:X}),{})}class mH{constructor(H=document.documentElement,J=LX){this.logger=console,this.debug=!1,this.logDebugActivity=(Q,X,Y={})=>{if(this.debug)this.logFormattedMessage(Q,X,Y)},this.element=H,this.schema=J,this.dispatcher=new WJ(this),this.router=new TJ(this),this.actionDescriptorFilters=Object.assign({},aQ)}static start(H,J){let Q=new this(H,J);return Q.start(),Q}async start(){await jX(),this.logDebugActivity("application","starting"),this.dispatcher.start(),this.router.start(),this.logDebugActivity("application","start")}stop(){this.logDebugActivity("application","stopping"),this.dispatcher.stop(),this.router.stop(),this.logDebugActivity("application","stop")}register(H,J){this.load({identifier:H,controllerConstructor:J})}registerActionOption(H,J){this.actionDescriptorFilters[H]=J}load(H,...J){(Array.isArray(H)?H:[H,...J]).forEach((X)=>{if(X.controllerConstructor.shouldLoad)this.router.loadDefinition(X)})}unload(H,...J){(Array.isArray(H)?H:[H,...J]).forEach((X)=>this.router.unloadIdentifier(X))}get controllers(){return this.router.contexts.map((H)=>H.controller)}getControllerForElementAndIdentifier(H,J){let Q=this.router.getContextForElementAndIdentifier(H,J);return Q?Q.controller:null}handleError(H,J,Q){var X;this.logger.error(`%s
29
+ `,e.outerHTML);t=t.parentElement}})();window.Turbo={...zr,StreamActions:Qt};Kt();class cs{constructor(e,t,s){this.eventTarget=e,this.eventName=t,this.eventOptions=s,this.unorderedBindings=new Set}connect(){this.eventTarget.addEventListener(this.eventName,this,this.eventOptions)}disconnect(){this.eventTarget.removeEventListener(this.eventName,this,this.eventOptions)}bindingConnected(e){this.unorderedBindings.add(e)}bindingDisconnected(e){this.unorderedBindings.delete(e)}handleEvent(e){let t=Jr(e);for(let s of this.bindings)if(t.immediatePropagationStopped)break;else s.handleEvent(t)}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort((e,t)=>{let s=e.index,r=t.index;return s<r?-1:s>r?1:0})}}function Jr(e){if("immediatePropagationStopped"in e)return e;else{let{stopImmediatePropagation:t}=e;return Object.assign(e,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,t.call(this)}})}}class ls{constructor(e){this.application=e,this.eventListenerMaps=new Map,this.started=!1}start(){if(!this.started)this.started=!0,this.eventListeners.forEach((e)=>e.connect())}stop(){if(this.started)this.started=!1,this.eventListeners.forEach((e)=>e.disconnect())}get eventListeners(){return Array.from(this.eventListenerMaps.values()).reduce((e,t)=>e.concat(Array.from(t.values())),[])}bindingConnected(e){this.fetchEventListenerForBinding(e).bindingConnected(e)}bindingDisconnected(e,t=!1){if(this.fetchEventListenerForBinding(e).bindingDisconnected(e),t)this.clearEventListenersForBinding(e)}handleError(e,t,s={}){this.application.handleError(e,`Error ${t}`,s)}clearEventListenersForBinding(e){let t=this.fetchEventListenerForBinding(e);if(!t.hasBindings())t.disconnect(),this.removeMappedEventListenerFor(e)}removeMappedEventListenerFor(e){let{eventTarget:t,eventName:s,eventOptions:r}=e,i=this.fetchEventListenerMapForEventTarget(t),n=this.cacheKey(s,r);if(i.delete(n),i.size==0)this.eventListenerMaps.delete(t)}fetchEventListenerForBinding(e){let{eventTarget:t,eventName:s,eventOptions:r}=e;return this.fetchEventListener(t,s,r)}fetchEventListener(e,t,s){let r=this.fetchEventListenerMapForEventTarget(e),i=this.cacheKey(t,s),n=r.get(i);if(!n)n=this.createEventListener(e,t,s),r.set(i,n);return n}createEventListener(e,t,s){let r=new cs(e,t,s);if(this.started)r.connect();return r}fetchEventListenerMapForEventTarget(e){let t=this.eventListenerMaps.get(e);if(!t)t=new Map,this.eventListenerMaps.set(e,t);return t}cacheKey(e,t){let s=[e];return Object.keys(t).sort().forEach((r)=>{s.push(`${t[r]?"":"!"}${r}`)}),s.join(":")}}var Xr={stop({event:e,value:t}){if(t)e.stopPropagation();return!0},prevent({event:e,value:t}){if(t)e.preventDefault();return!0},self({event:e,value:t,element:s}){if(t)return s===e.target;else return!0}},Yr=/^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function Qr(e){let s=e.trim().match(Yr)||[],r=s[2],i=s[3];if(i&&!["keydown","keyup","keypress"].includes(r))r+=`.${i}`,i="";return{eventTarget:Gr(s[4]),eventName:r,eventOptions:s[7]?Zr(s[7]):{},identifier:s[5],methodName:s[6],keyFilter:s[1]||i}}function Gr(e){if(e=="window")return window;else if(e=="document")return document}function Zr(e){return e.split(":").reduce((t,s)=>Object.assign(t,{[s.replace(/^!/,"")]:!/^!/.test(s)}),{})}function ei(e){if(e==window)return"window";else if(e==document)return"document"}function $e(e){return e.replace(/(?:[_-])([a-z0-9])/g,(t,s)=>s.toUpperCase())}function xe(e){return $e(e.replace(/--/g,"-").replace(/__/g,"_"))}function ne(e){return e.charAt(0).toUpperCase()+e.slice(1)}function hs(e){return e.replace(/([A-Z])/g,(t,s)=>`-${s.toLowerCase()}`)}function ti(e){return e.match(/[^\s]+/g)||[]}function Zt(e){return e!==null&&e!==void 0}function He(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var es=["meta","ctrl","alt","shift"];class us{constructor(e,t,s,r){this.element=e,this.index=t,this.eventTarget=s.eventTarget||e,this.eventName=s.eventName||si(e)||Ee("missing event name"),this.eventOptions=s.eventOptions||{},this.identifier=s.identifier||Ee("missing identifier"),this.methodName=s.methodName||Ee("missing method name"),this.keyFilter=s.keyFilter||"",this.schema=r}static forToken(e,t){return new this(e.element,e.index,Qr(e.content),t)}toString(){let e=this.keyFilter?`.${this.keyFilter}`:"",t=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${e}${t}->${this.identifier}#${this.methodName}`}shouldIgnoreKeyboardEvent(e){if(!this.keyFilter)return!1;let t=this.keyFilter.split("+");if(this.keyFilterDissatisfied(e,t))return!0;let s=t.filter((r)=>!es.includes(r))[0];if(!s)return!1;if(!He(this.keyMappings,s))Ee(`contains unknown key filter: ${this.keyFilter}`);return this.keyMappings[s].toLowerCase()!==e.key.toLowerCase()}shouldIgnoreMouseEvent(e){if(!this.keyFilter)return!1;let t=[this.keyFilter];if(this.keyFilterDissatisfied(e,t))return!0;return!1}get params(){let e={},t=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(let{name:s,value:r}of Array.from(this.element.attributes)){let i=s.match(t),n=i&&i[1];if(n)e[$e(n)]=ri(r)}return e}get eventTargetName(){return ei(this.eventTarget)}get keyMappings(){return this.schema.keyMappings}keyFilterDissatisfied(e,t){let[s,r,i,n]=es.map((l)=>t.includes(l));return e.metaKey!==s||e.ctrlKey!==r||e.altKey!==i||e.shiftKey!==n}}var ts={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:(e)=>e.getAttribute("type")=="submit"?"click":"input",select:()=>"change",textarea:()=>"input"};function si(e){let t=e.tagName.toLowerCase();if(t in ts)return ts[t](e)}function Ee(e){throw Error(e)}function ri(e){try{return JSON.parse(e)}catch(t){return e}}class ds{constructor(e,t){this.context=e,this.action=t}get index(){return this.action.index}get eventTarget(){return this.action.eventTarget}get eventOptions(){return this.action.eventOptions}get identifier(){return this.context.identifier}handleEvent(e){let t=this.prepareActionEvent(e);if(this.willBeInvokedByEvent(e)&&this.applyEventModifiers(t))this.invokeWithEvent(t)}get eventName(){return this.action.eventName}get method(){let e=this.controller[this.methodName];if(typeof e=="function")return e;throw Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(e){let{element:t}=this.action,{actionDescriptorFilters:s}=this.context.application,{controller:r}=this.context,i=!0;for(let[n,l]of Object.entries(this.eventOptions))if(n in s){let p=s[n];i=i&&p({name:n,value:l,event:e,element:t,controller:r})}else continue;return i}prepareActionEvent(e){return Object.assign(e,{params:this.action.params})}invokeWithEvent(e){let{target:t,currentTarget:s}=e;try{this.method.call(this.controller,e),this.context.logDebugActivity(this.methodName,{event:e,target:t,currentTarget:s,action:this.methodName})}catch(r){let{identifier:i,controller:n,element:l,index:p}=this,O={identifier:i,controller:n,element:l,index:p,event:e};this.context.handleError(r,`invoking action "${this.action}"`,O)}}willBeInvokedByEvent(e){let t=e.target;if(e instanceof KeyboardEvent&&this.action.shouldIgnoreKeyboardEvent(e))return!1;if(e instanceof MouseEvent&&this.action.shouldIgnoreMouseEvent(e))return!1;if(this.element===t)return!0;else if(t instanceof Element&&this.element.contains(t))return this.scope.containsElement(t);else return this.scope.containsElement(this.action.element)}get controller(){return this.context.controller}get methodName(){return this.action.methodName}get element(){return this.scope.element}get scope(){return this.context.scope}}class We{constructor(e,t){this.mutationObserverInit={attributes:!0,childList:!0,subtree:!0},this.element=e,this.started=!1,this.delegate=t,this.elements=new Set,this.mutationObserver=new MutationObserver((s)=>this.processMutations(s))}start(){if(!this.started)this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh()}pause(e){if(this.started)this.mutationObserver.disconnect(),this.started=!1;if(e(),!this.started)this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0}stop(){if(this.started)this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1}refresh(){if(this.started){let e=new Set(this.matchElementsInTree());for(let t of Array.from(this.elements))if(!e.has(t))this.removeElement(t);for(let t of Array.from(e))this.addElement(t)}}processMutations(e){if(this.started)for(let t of e)this.processMutation(t)}processMutation(e){if(e.type=="attributes")this.processAttributeChange(e.target,e.attributeName);else if(e.type=="childList")this.processRemovedNodes(e.removedNodes),this.processAddedNodes(e.addedNodes)}processAttributeChange(e,t){if(this.elements.has(e))if(this.delegate.elementAttributeChanged&&this.matchElement(e))this.delegate.elementAttributeChanged(e,t);else this.removeElement(e);else if(this.matchElement(e))this.addElement(e)}processRemovedNodes(e){for(let t of Array.from(e)){let s=this.elementFromNode(t);if(s)this.processTree(s,this.removeElement)}}processAddedNodes(e){for(let t of Array.from(e)){let s=this.elementFromNode(t);if(s&&this.elementIsActive(s))this.processTree(s,this.addElement)}}matchElement(e){return this.delegate.matchElement(e)}matchElementsInTree(e=this.element){return this.delegate.matchElementsInTree(e)}processTree(e,t){for(let s of this.matchElementsInTree(e))t.call(this,s)}elementFromNode(e){if(e.nodeType==Node.ELEMENT_NODE)return e}elementIsActive(e){if(e.isConnected!=this.element.isConnected)return!1;else return this.element.contains(e)}addElement(e){if(!this.elements.has(e)){if(this.elementIsActive(e)){if(this.elements.add(e),this.delegate.elementMatched)this.delegate.elementMatched(e)}}}removeElement(e){if(this.elements.has(e)){if(this.elements.delete(e),this.delegate.elementUnmatched)this.delegate.elementUnmatched(e)}}}class _e{constructor(e,t,s){this.attributeName=t,this.delegate=s,this.elementObserver=new We(e,this)}get element(){return this.elementObserver.element}get selector(){return`[${this.attributeName}]`}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get started(){return this.elementObserver.started}matchElement(e){return e.hasAttribute(this.attributeName)}matchElementsInTree(e){let t=this.matchElement(e)?[e]:[],s=Array.from(e.querySelectorAll(this.selector));return t.concat(s)}elementMatched(e){if(this.delegate.elementMatchedAttribute)this.delegate.elementMatchedAttribute(e,this.attributeName)}elementUnmatched(e){if(this.delegate.elementUnmatchedAttribute)this.delegate.elementUnmatchedAttribute(e,this.attributeName)}elementAttributeChanged(e,t){if(this.delegate.elementAttributeValueChanged&&this.attributeName==t)this.delegate.elementAttributeValueChanged(e,t)}}function ii(e,t,s){fs(e,t).add(s)}function ni(e,t,s){fs(e,t).delete(s),oi(e,t)}function fs(e,t){let s=e.get(t);if(!s)s=new Set,e.set(t,s);return s}function oi(e,t){let s=e.get(t);if(s!=null&&s.size==0)e.delete(t)}class _{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce((t,s)=>t.concat(Array.from(s)),[])}get size(){return Array.from(this.valuesByKey.values()).reduce((t,s)=>t+s.size,0)}add(e,t){ii(this.valuesByKey,e,t)}delete(e,t){ni(this.valuesByKey,e,t)}has(e,t){let s=this.valuesByKey.get(e);return s!=null&&s.has(t)}hasKey(e){return this.valuesByKey.has(e)}hasValue(e){return Array.from(this.valuesByKey.values()).some((s)=>s.has(e))}getValuesForKey(e){let t=this.valuesByKey.get(e);return t?Array.from(t):[]}getKeysForValue(e){return Array.from(this.valuesByKey).filter(([t,s])=>s.has(e)).map(([t,s])=>t)}}class ms{constructor(e,t,s,r){this._selector=t,this.details=r,this.elementObserver=new We(e,this),this.delegate=s,this.matchesByElement=new _}get started(){return this.elementObserver.started}get selector(){return this._selector}set selector(e){this._selector=e,this.refresh()}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get element(){return this.elementObserver.element}matchElement(e){let{selector:t}=this;if(t){let s=e.matches(t);if(this.delegate.selectorMatchElement)return s&&this.delegate.selectorMatchElement(e,this.details);return s}else return!1}matchElementsInTree(e){let{selector:t}=this;if(t){let s=this.matchElement(e)?[e]:[],r=Array.from(e.querySelectorAll(t)).filter((i)=>this.matchElement(i));return s.concat(r)}else return[]}elementMatched(e){let{selector:t}=this;if(t)this.selectorMatched(e,t)}elementUnmatched(e){let t=this.matchesByElement.getKeysForValue(e);for(let s of t)this.selectorUnmatched(e,s)}elementAttributeChanged(e,t){let{selector:s}=this;if(s){let r=this.matchElement(e),i=this.matchesByElement.has(s,e);if(r&&!i)this.selectorMatched(e,s);else if(!r&&i)this.selectorUnmatched(e,s)}}selectorMatched(e,t){this.delegate.selectorMatched(e,t,this.details),this.matchesByElement.add(t,e)}selectorUnmatched(e,t){this.delegate.selectorUnmatched(e,t,this.details),this.matchesByElement.delete(t,e)}}class ps{constructor(e,t){this.element=e,this.delegate=t,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver((s)=>this.processMutations(s))}start(){if(!this.started)this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh()}stop(){if(this.started)this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1}refresh(){if(this.started)for(let e of this.knownAttributeNames)this.refreshAttribute(e,null)}processMutations(e){if(this.started)for(let t of e)this.processMutation(t)}processMutation(e){let t=e.attributeName;if(t)this.refreshAttribute(t,e.oldValue)}refreshAttribute(e,t){let s=this.delegate.getStringMapKeyForAttribute(e);if(s!=null){if(!this.stringMap.has(e))this.stringMapKeyAdded(s,e);let r=this.element.getAttribute(e);if(this.stringMap.get(e)!=r)this.stringMapValueChanged(r,s,t);if(r==null){let i=this.stringMap.get(e);if(this.stringMap.delete(e),i)this.stringMapKeyRemoved(s,e,i)}else this.stringMap.set(e,r)}}stringMapKeyAdded(e,t){if(this.delegate.stringMapKeyAdded)this.delegate.stringMapKeyAdded(e,t)}stringMapValueChanged(e,t,s){if(this.delegate.stringMapValueChanged)this.delegate.stringMapValueChanged(e,t,s)}stringMapKeyRemoved(e,t,s){if(this.delegate.stringMapKeyRemoved)this.delegate.stringMapKeyRemoved(e,t,s)}get knownAttributeNames(){return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))}get currentAttributeNames(){return Array.from(this.element.attributes).map((e)=>e.name)}get recordedAttributeNames(){return Array.from(this.stringMap.keys())}}class je{constructor(e,t,s){this.attributeObserver=new _e(e,t,this),this.delegate=s,this.tokensByElement=new _}get started(){return this.attributeObserver.started}start(){this.attributeObserver.start()}pause(e){this.attributeObserver.pause(e)}stop(){this.attributeObserver.stop()}refresh(){this.attributeObserver.refresh()}get element(){return this.attributeObserver.element}get attributeName(){return this.attributeObserver.attributeName}elementMatchedAttribute(e){this.tokensMatched(this.readTokensForElement(e))}elementAttributeValueChanged(e){let[t,s]=this.refreshTokensForElement(e);this.tokensUnmatched(t),this.tokensMatched(s)}elementUnmatchedAttribute(e){this.tokensUnmatched(this.tokensByElement.getValuesForKey(e))}tokensMatched(e){e.forEach((t)=>this.tokenMatched(t))}tokensUnmatched(e){e.forEach((t)=>this.tokenUnmatched(t))}tokenMatched(e){this.delegate.tokenMatched(e),this.tokensByElement.add(e.element,e)}tokenUnmatched(e){this.delegate.tokenUnmatched(e),this.tokensByElement.delete(e.element,e)}refreshTokensForElement(e){let t=this.tokensByElement.getValuesForKey(e),s=this.readTokensForElement(e),r=ci(t,s).findIndex(([i,n])=>!li(i,n));if(r==-1)return[[],[]];else return[t.slice(r),s.slice(r)]}readTokensForElement(e){let t=this.attributeName,s=e.getAttribute(t)||"";return ai(s,e,t)}}function ai(e,t,s){return e.trim().split(/\s+/).filter((r)=>r.length).map((r,i)=>({element:t,attributeName:s,content:r,index:i}))}function ci(e,t){let s=Math.max(e.length,t.length);return Array.from({length:s},(r,i)=>[e[i],t[i]])}function li(e,t){return e&&t&&e.index==t.index&&e.content==t.content}class Ue{constructor(e,t,s){this.tokenListObserver=new je(e,t,this),this.delegate=s,this.parseResultsByToken=new WeakMap,this.valuesByTokenByElement=new WeakMap}get started(){return this.tokenListObserver.started}start(){this.tokenListObserver.start()}stop(){this.tokenListObserver.stop()}refresh(){this.tokenListObserver.refresh()}get element(){return this.tokenListObserver.element}get attributeName(){return this.tokenListObserver.attributeName}tokenMatched(e){let{element:t}=e,{value:s}=this.fetchParseResultForToken(e);if(s)this.fetchValuesByTokenForElement(t).set(e,s),this.delegate.elementMatchedValue(t,s)}tokenUnmatched(e){let{element:t}=e,{value:s}=this.fetchParseResultForToken(e);if(s)this.fetchValuesByTokenForElement(t).delete(e),this.delegate.elementUnmatchedValue(t,s)}fetchParseResultForToken(e){let t=this.parseResultsByToken.get(e);if(!t)t=this.parseToken(e),this.parseResultsByToken.set(e,t);return t}fetchValuesByTokenForElement(e){let t=this.valuesByTokenByElement.get(e);if(!t)t=new Map,this.valuesByTokenByElement.set(e,t);return t}parseToken(e){try{return{value:this.delegate.parseValueForToken(e)}}catch(t){return{error:t}}}}class gs{constructor(e,t){this.context=e,this.delegate=t,this.bindingsByAction=new Map}start(){if(!this.valueListObserver)this.valueListObserver=new Ue(this.element,this.actionAttribute,this),this.valueListObserver.start()}stop(){if(this.valueListObserver)this.valueListObserver.stop(),delete this.valueListObserver,this.disconnectAllActions()}get element(){return this.context.element}get identifier(){return this.context.identifier}get actionAttribute(){return this.schema.actionAttribute}get schema(){return this.context.schema}get bindings(){return Array.from(this.bindingsByAction.values())}connectAction(e){let t=new ds(this.context,e);this.bindingsByAction.set(e,t),this.delegate.bindingConnected(t)}disconnectAction(e){let t=this.bindingsByAction.get(e);if(t)this.bindingsByAction.delete(e),this.delegate.bindingDisconnected(t)}disconnectAllActions(){this.bindings.forEach((e)=>this.delegate.bindingDisconnected(e,!0)),this.bindingsByAction.clear()}parseValueForToken(e){let t=us.forToken(e,this.schema);if(t.identifier==this.identifier)return t}elementMatchedValue(e,t){this.connectAction(t)}elementUnmatchedValue(e,t){this.disconnectAction(t)}}class bs{constructor(e,t){this.context=e,this.receiver=t,this.stringMapObserver=new ps(this.element,this),this.valueDescriptorMap=this.controller.valueDescriptorMap}start(){this.stringMapObserver.start(),this.invokeChangedCallbacksForDefaultValues()}stop(){this.stringMapObserver.stop()}get element(){return this.context.element}get controller(){return this.context.controller}getStringMapKeyForAttribute(e){if(e in this.valueDescriptorMap)return this.valueDescriptorMap[e].name}stringMapKeyAdded(e,t){let s=this.valueDescriptorMap[t];if(!this.hasValue(e))this.invokeChangedCallback(e,s.writer(this.receiver[e]),s.writer(s.defaultValue))}stringMapValueChanged(e,t,s){let r=this.valueDescriptorNameMap[t];if(e===null)return;if(s===null)s=r.writer(r.defaultValue);this.invokeChangedCallback(t,e,s)}stringMapKeyRemoved(e,t,s){let r=this.valueDescriptorNameMap[e];if(this.hasValue(e))this.invokeChangedCallback(e,r.writer(this.receiver[e]),s);else this.invokeChangedCallback(e,r.writer(r.defaultValue),s)}invokeChangedCallbacksForDefaultValues(){for(let{key:e,name:t,defaultValue:s,writer:r}of this.valueDescriptors)if(s!=null&&!this.controller.data.has(e))this.invokeChangedCallback(t,r(s),void 0)}invokeChangedCallback(e,t,s){let r=`${e}Changed`,i=this.receiver[r];if(typeof i=="function"){let n=this.valueDescriptorNameMap[e];try{let l=n.reader(t),p=s;if(s)p=n.reader(s);i.call(this.receiver,l,p)}catch(l){if(l instanceof TypeError)l.message=`Stimulus Value "${this.context.identifier}.${n.name}" - ${l.message}`;throw l}}}get valueDescriptors(){let{valueDescriptorMap:e}=this;return Object.keys(e).map((t)=>e[t])}get valueDescriptorNameMap(){let e={};return Object.keys(this.valueDescriptorMap).forEach((t)=>{let s=this.valueDescriptorMap[t];e[s.name]=s}),e}hasValue(e){let t=this.valueDescriptorNameMap[e],s=`has${ne(t.name)}`;return this.receiver[s]}}class vs{constructor(e,t){this.context=e,this.delegate=t,this.targetsByName=new _}start(){if(!this.tokenListObserver)this.tokenListObserver=new je(this.element,this.attributeName,this),this.tokenListObserver.start()}stop(){if(this.tokenListObserver)this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver}tokenMatched({element:e,content:t}){if(this.scope.containsElement(e))this.connectTarget(e,t)}tokenUnmatched({element:e,content:t}){this.disconnectTarget(e,t)}connectTarget(e,t){var s;if(!this.targetsByName.has(t,e))this.targetsByName.add(t,e),(s=this.tokenListObserver)===null||s===void 0||s.pause(()=>this.delegate.targetConnected(e,t))}disconnectTarget(e,t){var s;if(this.targetsByName.has(t,e))this.targetsByName.delete(t,e),(s=this.tokenListObserver)===null||s===void 0||s.pause(()=>this.delegate.targetDisconnected(e,t))}disconnectAllTargets(){for(let e of this.targetsByName.keys)for(let t of this.targetsByName.getValuesForKey(e))this.disconnectTarget(t,e)}get attributeName(){return`data-${this.context.identifier}-target`}get element(){return this.context.element}get scope(){return this.context.scope}}function oe(e,t){let s=ys(e);return Array.from(s.reduce((r,i)=>(ui(i,t).forEach((n)=>r.add(n)),r),new Set))}function hi(e,t){return ys(e).reduce((r,i)=>(r.push(...di(i,t)),r),[])}function ys(e){let t=[];while(e)t.push(e),e=Object.getPrototypeOf(e);return t.reverse()}function ui(e,t){let s=e[t];return Array.isArray(s)?s:[]}function di(e,t){let s=e[t];return s?Object.keys(s).map((r)=>[r,s[r]]):[]}class Es{constructor(e,t){this.started=!1,this.context=e,this.delegate=t,this.outletsByName=new _,this.outletElementsByName=new _,this.selectorObserverMap=new Map,this.attributeObserverMap=new Map}start(){if(!this.started)this.outletDefinitions.forEach((e)=>{this.setupSelectorObserverForOutlet(e),this.setupAttributeObserverForOutlet(e)}),this.started=!0,this.dependentContexts.forEach((e)=>e.refresh())}refresh(){this.selectorObserverMap.forEach((e)=>e.refresh()),this.attributeObserverMap.forEach((e)=>e.refresh())}stop(){if(this.started)this.started=!1,this.disconnectAllOutlets(),this.stopSelectorObservers(),this.stopAttributeObservers()}stopSelectorObservers(){if(this.selectorObserverMap.size>0)this.selectorObserverMap.forEach((e)=>e.stop()),this.selectorObserverMap.clear()}stopAttributeObservers(){if(this.attributeObserverMap.size>0)this.attributeObserverMap.forEach((e)=>e.stop()),this.attributeObserverMap.clear()}selectorMatched(e,t,{outletName:s}){let r=this.getOutlet(e,s);if(r)this.connectOutlet(r,e,s)}selectorUnmatched(e,t,{outletName:s}){let r=this.getOutletFromMap(e,s);if(r)this.disconnectOutlet(r,e,s)}selectorMatchElement(e,{outletName:t}){let s=this.selector(t),r=this.hasOutlet(e,t),i=e.matches(`[${this.schema.controllerAttribute}~=${t}]`);if(s)return r&&i&&e.matches(s);else return!1}elementMatchedAttribute(e,t){let s=this.getOutletNameFromOutletAttributeName(t);if(s)this.updateSelectorObserverForOutlet(s)}elementAttributeValueChanged(e,t){let s=this.getOutletNameFromOutletAttributeName(t);if(s)this.updateSelectorObserverForOutlet(s)}elementUnmatchedAttribute(e,t){let s=this.getOutletNameFromOutletAttributeName(t);if(s)this.updateSelectorObserverForOutlet(s)}connectOutlet(e,t,s){var r;if(!this.outletElementsByName.has(s,t))this.outletsByName.add(s,e),this.outletElementsByName.add(s,t),(r=this.selectorObserverMap.get(s))===null||r===void 0||r.pause(()=>this.delegate.outletConnected(e,t,s))}disconnectOutlet(e,t,s){var r;if(this.outletElementsByName.has(s,t))this.outletsByName.delete(s,e),this.outletElementsByName.delete(s,t),(r=this.selectorObserverMap.get(s))===null||r===void 0||r.pause(()=>this.delegate.outletDisconnected(e,t,s))}disconnectAllOutlets(){for(let e of this.outletElementsByName.keys)for(let t of this.outletElementsByName.getValuesForKey(e))for(let s of this.outletsByName.getValuesForKey(e))this.disconnectOutlet(s,t,e)}updateSelectorObserverForOutlet(e){let t=this.selectorObserverMap.get(e);if(t)t.selector=this.selector(e)}setupSelectorObserverForOutlet(e){let t=this.selector(e),s=new ms(document.body,t,this,{outletName:e});this.selectorObserverMap.set(e,s),s.start()}setupAttributeObserverForOutlet(e){let t=this.attributeNameForOutletName(e),s=new _e(this.scope.element,t,this);this.attributeObserverMap.set(e,s),s.start()}selector(e){return this.scope.outlets.getSelectorForOutletName(e)}attributeNameForOutletName(e){return this.scope.schema.outletAttributeForScope(this.identifier,e)}getOutletNameFromOutletAttributeName(e){return this.outletDefinitions.find((t)=>this.attributeNameForOutletName(t)===e)}get outletDependencies(){let e=new _;return this.router.modules.forEach((t)=>{let s=t.definition.controllerConstructor;oe(s,"outlets").forEach((i)=>e.add(i,t.identifier))}),e}get outletDefinitions(){return this.outletDependencies.getKeysForValue(this.identifier)}get dependentControllerIdentifiers(){return this.outletDependencies.getValuesForKey(this.identifier)}get dependentContexts(){let e=this.dependentControllerIdentifiers;return this.router.contexts.filter((t)=>e.includes(t.identifier))}hasOutlet(e,t){return!!this.getOutlet(e,t)||!!this.getOutletFromMap(e,t)}getOutlet(e,t){return this.application.getControllerForElementAndIdentifier(e,t)}getOutletFromMap(e,t){return this.outletsByName.getValuesForKey(t).find((s)=>s.element===e)}get scope(){return this.context.scope}get schema(){return this.context.schema}get identifier(){return this.context.identifier}get application(){return this.context.application}get router(){return this.application.router}}class ws{constructor(e,t){this.logDebugActivity=(s,r={})=>{let{identifier:i,controller:n,element:l}=this;r=Object.assign({identifier:i,controller:n,element:l},r),this.application.logDebugActivity(this.identifier,s,r)},this.module=e,this.scope=t,this.controller=new e.controllerConstructor(this),this.bindingObserver=new gs(this,this.dispatcher),this.valueObserver=new bs(this,this.controller),this.targetObserver=new vs(this,this),this.outletObserver=new Es(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(s){this.handleError(s,"initializing controller")}}connect(){this.bindingObserver.start(),this.valueObserver.start(),this.targetObserver.start(),this.outletObserver.start();try{this.controller.connect(),this.logDebugActivity("connect")}catch(e){this.handleError(e,"connecting controller")}}refresh(){this.outletObserver.refresh()}disconnect(){try{this.controller.disconnect(),this.logDebugActivity("disconnect")}catch(e){this.handleError(e,"disconnecting controller")}this.outletObserver.stop(),this.targetObserver.stop(),this.valueObserver.stop(),this.bindingObserver.stop()}get application(){return this.module.application}get identifier(){return this.module.identifier}get schema(){return this.application.schema}get dispatcher(){return this.application.dispatcher}get element(){return this.scope.element}get parentElement(){return this.element.parentElement}handleError(e,t,s={}){let{identifier:r,controller:i,element:n}=this;s=Object.assign({identifier:r,controller:i,element:n},s),this.application.handleError(e,`Error ${t}`,s)}targetConnected(e,t){this.invokeControllerMethod(`${t}TargetConnected`,e)}targetDisconnected(e,t){this.invokeControllerMethod(`${t}TargetDisconnected`,e)}outletConnected(e,t,s){this.invokeControllerMethod(`${xe(s)}OutletConnected`,e,t)}outletDisconnected(e,t,s){this.invokeControllerMethod(`${xe(s)}OutletDisconnected`,e,t)}invokeControllerMethod(e,...t){let s=this.controller;if(typeof s[e]=="function")s[e](...t)}}function fi(e){return mi(e,pi(e))}function mi(e,t){let s=yi(e),r=gi(e.prototype,t);return Object.defineProperties(s.prototype,r),s}function pi(e){return oe(e,"blessings").reduce((s,r)=>{let i=r(e);for(let n in i){let l=s[n]||{};s[n]=Object.assign(l,i[n])}return s},{})}function gi(e,t){return vi(t).reduce((s,r)=>{let i=bi(e,t,r);if(i)Object.assign(s,{[r]:i});return s},{})}function bi(e,t,s){let r=Object.getOwnPropertyDescriptor(e,s);if(!(r&&("value"in r))){let n=Object.getOwnPropertyDescriptor(t,s).value;if(r)n.get=r.get||n.get,n.set=r.set||n.set;return n}}var vi=(()=>{if(typeof Object.getOwnPropertySymbols=="function")return(e)=>[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];else return Object.getOwnPropertyNames})(),yi=(()=>{function e(s){function r(){return Reflect.construct(s,arguments,new.target)}return r.prototype=Object.create(s.prototype,{constructor:{value:r}}),Reflect.setPrototypeOf(r,s),r}function t(){let r=e(function(){this.a.call(this)});return r.prototype.a=function(){},new r}try{return t(),e}catch(s){return(r)=>class extends r{}}})();function Ei(e){return{identifier:e.identifier,controllerConstructor:fi(e.controllerConstructor)}}class Ss{constructor(e,t){this.application=e,this.definition=Ei(t),this.contextsByScope=new WeakMap,this.connectedContexts=new Set}get identifier(){return this.definition.identifier}get controllerConstructor(){return this.definition.controllerConstructor}get contexts(){return Array.from(this.connectedContexts)}connectContextForScope(e){let t=this.fetchContextForScope(e);this.connectedContexts.add(t),t.connect()}disconnectContextForScope(e){let t=this.contextsByScope.get(e);if(t)this.connectedContexts.delete(t),t.disconnect()}fetchContextForScope(e){let t=this.contextsByScope.get(e);if(!t)t=new ws(this,e),this.contextsByScope.set(e,t);return t}}class As{constructor(e){this.scope=e}has(e){return this.data.has(this.getDataKey(e))}get(e){return this.getAll(e)[0]}getAll(e){let t=this.data.get(this.getDataKey(e))||"";return ti(t)}getAttributeName(e){return this.data.getAttributeNameForKey(this.getDataKey(e))}getDataKey(e){return`${e}-class`}get data(){return this.scope.data}}class Ts{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(e){let t=this.getAttributeNameForKey(e);return this.element.getAttribute(t)}set(e,t){let s=this.getAttributeNameForKey(e);return this.element.setAttribute(s,t),this.get(e)}has(e){let t=this.getAttributeNameForKey(e);return this.element.hasAttribute(t)}delete(e){if(this.has(e)){let t=this.getAttributeNameForKey(e);return this.element.removeAttribute(t),!0}else return!1}getAttributeNameForKey(e){return`data-${this.identifier}-${hs(e)}`}}class Ls{constructor(e){this.warnedKeysByObject=new WeakMap,this.logger=e}warn(e,t,s){let r=this.warnedKeysByObject.get(e);if(!r)r=new Set,this.warnedKeysByObject.set(e,r);if(!r.has(t))r.add(t),this.logger.warn(s,e)}}function Ve(e,t){return`[${e}~="${t}"]`}class Ms{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return this.find(e)!=null}find(...e){return e.reduce((t,s)=>t||this.findTarget(s)||this.findLegacyTarget(s),void 0)}findAll(...e){return e.reduce((t,s)=>[...t,...this.findAllTargets(s),...this.findAllLegacyTargets(s)],[])}findTarget(e){let t=this.getSelectorForTargetName(e);return this.scope.findElement(t)}findAllTargets(e){let t=this.getSelectorForTargetName(e);return this.scope.findAllElements(t)}getSelectorForTargetName(e){let t=this.schema.targetAttributeForScope(this.identifier);return Ve(t,e)}findLegacyTarget(e){let t=this.getLegacySelectorForTargetName(e);return this.deprecate(this.scope.findElement(t),e)}findAllLegacyTargets(e){let t=this.getLegacySelectorForTargetName(e);return this.scope.findAllElements(t).map((s)=>this.deprecate(s,e))}getLegacySelectorForTargetName(e){let t=`${this.identifier}.${e}`;return Ve(this.schema.targetAttribute,t)}deprecate(e,t){if(e){let{identifier:s}=this,r=this.schema.targetAttribute,i=this.schema.targetAttributeForScope(s);this.guide.warn(e,`target:${t}`,`Please replace ${r}="${s}.${t}" with ${i}="${t}". The ${r} attribute is deprecated and will be removed in a future version of Stimulus.`)}return e}get guide(){return this.scope.guide}}class Cs{constructor(e,t){this.scope=e,this.controllerElement=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return this.find(e)!=null}find(...e){return e.reduce((t,s)=>t||this.findOutlet(s),void 0)}findAll(...e){return e.reduce((t,s)=>[...t,...this.findAllOutlets(s)],[])}getSelectorForOutletName(e){let t=this.schema.outletAttributeForScope(this.identifier,e);return this.controllerElement.getAttribute(t)}findOutlet(e){let t=this.getSelectorForOutletName(e);if(t)return this.findElement(t,e)}findAllOutlets(e){let t=this.getSelectorForOutletName(e);return t?this.findAllElements(t,e):[]}findElement(e,t){return this.scope.queryElements(e).filter((r)=>this.matchesElement(r,e,t))[0]}findAllElements(e,t){return this.scope.queryElements(e).filter((r)=>this.matchesElement(r,e,t))}matchesElement(e,t,s){let r=e.getAttribute(this.scope.schema.controllerAttribute)||"";return e.matches(t)&&r.split(" ").includes(s)}}class Ke{constructor(e,t,s,r){this.targets=new Ms(this),this.classes=new As(this),this.data=new Ts(this),this.containsElement=(i)=>i.closest(this.controllerSelector)===this.element,this.schema=e,this.element=t,this.identifier=s,this.guide=new Ls(r),this.outlets=new Cs(this.documentScope,t)}findElement(e){return this.element.matches(e)?this.element:this.queryElements(e).find(this.containsElement)}findAllElements(e){return[...this.element.matches(e)?[this.element]:[],...this.queryElements(e).filter(this.containsElement)]}queryElements(e){return Array.from(this.element.querySelectorAll(e))}get controllerSelector(){return Ve(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new Ke(this.schema,document.documentElement,this.identifier,this.guide.logger)}}class Rs{constructor(e,t,s){this.element=e,this.schema=t,this.delegate=s,this.valueListObserver=new Ue(this.element,this.controllerAttribute,this),this.scopesByIdentifierByElement=new WeakMap,this.scopeReferenceCounts=new WeakMap}start(){this.valueListObserver.start()}stop(){this.valueListObserver.stop()}get controllerAttribute(){return this.schema.controllerAttribute}parseValueForToken(e){let{element:t,content:s}=e;return this.parseValueForElementAndIdentifier(t,s)}parseValueForElementAndIdentifier(e,t){let s=this.fetchScopesByIdentifierForElement(e),r=s.get(t);if(!r)r=this.delegate.createScopeForElementAndIdentifier(e,t),s.set(t,r);return r}elementMatchedValue(e,t){let s=(this.scopeReferenceCounts.get(t)||0)+1;if(this.scopeReferenceCounts.set(t,s),s==1)this.delegate.scopeConnected(t)}elementUnmatchedValue(e,t){let s=this.scopeReferenceCounts.get(t);if(s){if(this.scopeReferenceCounts.set(t,s-1),s==1)this.delegate.scopeDisconnected(t)}}fetchScopesByIdentifierForElement(e){let t=this.scopesByIdentifierByElement.get(e);if(!t)t=new Map,this.scopesByIdentifierByElement.set(e,t);return t}}class Os{constructor(e){this.application=e,this.scopeObserver=new Rs(this.element,this.schema,this),this.scopesByIdentifier=new _,this.modulesByIdentifier=new Map}get element(){return this.application.element}get schema(){return this.application.schema}get logger(){return this.application.logger}get controllerAttribute(){return this.schema.controllerAttribute}get modules(){return Array.from(this.modulesByIdentifier.values())}get contexts(){return this.modules.reduce((e,t)=>e.concat(t.contexts),[])}start(){this.scopeObserver.start()}stop(){this.scopeObserver.stop()}loadDefinition(e){this.unloadIdentifier(e.identifier);let t=new Ss(this.application,e);this.connectModule(t);let s=e.controllerConstructor.afterLoad;if(s)s.call(e.controllerConstructor,e.identifier,this.application)}unloadIdentifier(e){let t=this.modulesByIdentifier.get(e);if(t)this.disconnectModule(t)}getContextForElementAndIdentifier(e,t){let s=this.modulesByIdentifier.get(t);if(s)return s.contexts.find((r)=>r.element==e)}proposeToConnectScopeForElementAndIdentifier(e,t){let s=this.scopeObserver.parseValueForElementAndIdentifier(e,t);if(s)this.scopeObserver.elementMatchedValue(s.element,s);else console.error(`Couldn't find or create scope for identifier: "${t}" and element:`,e)}handleError(e,t,s){this.application.handleError(e,t,s)}createScopeForElementAndIdentifier(e,t){return new Ke(this.schema,e,t,this.logger)}scopeConnected(e){this.scopesByIdentifier.add(e.identifier,e);let t=this.modulesByIdentifier.get(e.identifier);if(t)t.connectContextForScope(e)}scopeDisconnected(e){this.scopesByIdentifier.delete(e.identifier,e);let t=this.modulesByIdentifier.get(e.identifier);if(t)t.disconnectContextForScope(e)}connectModule(e){this.modulesByIdentifier.set(e.identifier,e),this.scopesByIdentifier.getValuesForKey(e.identifier).forEach((s)=>e.connectContextForScope(s))}disconnectModule(e){this.modulesByIdentifier.delete(e.identifier),this.scopesByIdentifier.getValuesForKey(e.identifier).forEach((s)=>e.disconnectContextForScope(s))}}var wi={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:(e)=>`data-${e}-target`,outletAttributeForScope:(e,t)=>`data-${e}-${t}-outlet`,keyMappings:Object.assign(Object.assign({enter:"Enter",tab:"Tab",esc:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",page_up:"PageUp",page_down:"PageDown"},ss("abcdefghijklmnopqrstuvwxyz".split("").map((e)=>[e,e]))),ss("0123456789".split("").map((e)=>[e,e])))};function ss(e){return e.reduce((t,[s,r])=>Object.assign(Object.assign({},t),{[s]:r}),{})}class ze{constructor(e=document.documentElement,t=wi){this.logger=console,this.debug=!1,this.logDebugActivity=(s,r,i={})=>{if(this.debug)this.logFormattedMessage(s,r,i)},this.element=e,this.schema=t,this.dispatcher=new ls(this),this.router=new Os(this),this.actionDescriptorFilters=Object.assign({},Xr)}static start(e,t){let s=new this(e,t);return s.start(),s}async start(){await Si(),this.logDebugActivity("application","starting"),this.dispatcher.start(),this.router.start(),this.logDebugActivity("application","start")}stop(){this.logDebugActivity("application","stopping"),this.dispatcher.stop(),this.router.stop(),this.logDebugActivity("application","stop")}register(e,t){this.load({identifier:e,controllerConstructor:t})}registerActionOption(e,t){this.actionDescriptorFilters[e]=t}load(e,...t){(Array.isArray(e)?e:[e,...t]).forEach((r)=>{if(r.controllerConstructor.shouldLoad)this.router.loadDefinition(r)})}unload(e,...t){(Array.isArray(e)?e:[e,...t]).forEach((r)=>this.router.unloadIdentifier(r))}get controllers(){return this.router.contexts.map((e)=>e.controller)}getControllerForElementAndIdentifier(e,t){let s=this.router.getContextForElementAndIdentifier(e,t);return s?s.controller:null}handleError(e,t,s){var r;this.logger.error(`%s
30
30
 
31
31
  %o
32
32
 
33
- %o`,J,H,Q),(X=window.onerror)===null||X===void 0||X.call(window,J,"",0,0,H)}logFormattedMessage(H,J,Q={}){Q=Object.assign({application:this},Q),this.logger.groupCollapsed(`${H} #${J}`),this.logger.log("details:",Object.assign({},Q)),this.logger.groupEnd()}}function jX(){return new Promise((H)=>{if(document.readyState=="loading")document.addEventListener("DOMContentLoaded",()=>H());else H()})}function SX(H){return ZH(H,"classes").reduce((Q,X)=>{return Object.assign(Q,CX(X))},{})}function CX(H){return{[`${H}Class`]:{get(){let{classes:J}=this;if(J.has(H))return J.get(H);else{let Q=J.getAttributeName(H);throw Error(`Missing attribute "${Q}"`)}}},[`${H}Classes`]:{get(){return this.classes.getAll(H)}},[`has${YH(H)}Class`]:{get(){return this.classes.has(H)}}}}function wX(H){return ZH(H,"outlets").reduce((Q,X)=>{return Object.assign(Q,EX(X))},{})}function QJ(H,J,Q){return H.application.getControllerForElementAndIdentifier(J,Q)}function XJ(H,J,Q){let X=QJ(H,J,Q);if(X)return X;if(H.application.router.proposeToConnectScopeForElementAndIdentifier(J,Q),X=QJ(H,J,Q),X)return X}function EX(H){let J=NH(H);return{[`${J}Outlet`]:{get(){let Q=this.outlets.find(H),X=this.outlets.getSelectorForOutletName(H);if(Q){let Y=XJ(this,Q,H);if(Y)return Y;throw Error(`The provided outlet element is missing an outlet controller "${H}" instance for host controller "${this.identifier}"`)}throw Error(`Missing outlet element "${H}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${X}".`)}},[`${J}Outlets`]:{get(){let Q=this.outlets.findAll(H);if(Q.length>0)return Q.map((X)=>{let Y=XJ(this,X,H);if(Y)return Y;console.warn(`The provided outlet element is missing an outlet controller "${H}" instance for host controller "${this.identifier}"`,X)}).filter((X)=>X);return[]}},[`${J}OutletElement`]:{get(){let Q=this.outlets.find(H),X=this.outlets.getSelectorForOutletName(H);if(Q)return Q;else throw Error(`Missing outlet element "${H}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${X}".`)}},[`${J}OutletElements`]:{get(){return this.outlets.findAll(H)}},[`has${YH(J)}Outlet`]:{get(){return this.outlets.has(H)}}}}function RX(H){return ZH(H,"targets").reduce((Q,X)=>{return Object.assign(Q,VX(X))},{})}function VX(H){return{[`${H}Target`]:{get(){let J=this.targets.find(H);if(J)return J;else throw Error(`Missing target element "${H}" for "${this.identifier}" controller`)}},[`${H}Targets`]:{get(){return this.targets.findAll(H)}},[`has${YH(H)}Target`]:{get(){return this.targets.has(H)}}}}function TX(H){let J=AX(H,"values"),Q={valueDescriptorMap:{get(){return J.reduce((X,Y)=>{let Z=DJ(Y,this.identifier),A=this.data.getAttributeNameForKey(Z.key);return Object.assign(X,{[A]:Z})},{})}}};return J.reduce((X,Y)=>{return Object.assign(X,DX(Y))},Q)}function DX(H,J){let Q=DJ(H,J),{key:X,name:Y,reader:Z,writer:A}=Q;return{[Y]:{get(){let B=this.data.get(X);if(B!==null)return Z(B);else return Q.defaultValue},set(B){if(B===void 0)this.data.delete(X);else this.data.set(X,A(B))}},[`has${YH(Y)}`]:{get(){return this.data.has(X)||Q.hasCustomDefaultValue}}}}function DJ([H,J],Q){return gX({controller:Q,token:H,typeDefinition:J})}function LH(H){switch(H){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function XH(H){switch(typeof H){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(H))return"array";if(Object.prototype.toString.call(H)==="[object Object]")return"object"}function OX(H){let{controller:J,token:Q,typeObject:X}=H,Y=t1(X.type),Z=t1(X.default),A=Y&&Z,B=Y&&!Z,D=!Y&&Z,R=LH(X.type),y=XH(H.typeObject.default);if(B)return R;if(D)return y;if(R!==y){let b=J?`${J}.${Q}`:Q;throw Error(`The specified default value for the Stimulus Value "${b}" must match the defined type "${R}". The provided default value of "${X.default}" is of type "${y}".`)}if(A)return R}function xX(H){let{controller:J,token:Q,typeDefinition:X}=H,Z=OX({controller:J,token:Q,typeObject:X}),A=XH(X),B=LH(X),D=Z||A||B;if(D)return D;let R=J?`${J}.${X}`:Q;throw Error(`Unknown value type "${R}" for "${Q}" value`)}function hX(H){let J=LH(H);if(J)return YJ[J];let Q=fH(H,"default"),X=fH(H,"type"),Y=H;if(Q)return Y.default;if(X){let{type:Z}=Y,A=LH(Z);if(A)return YJ[A]}return H}function gX(H){let{token:J,typeDefinition:Q}=H,X=`${AJ(J)}-value`,Y=xX(H);return{type:Y,key:X,name:pH(X),get defaultValue(){return hX(Q)},get hasCustomDefaultValue(){return XH(Q)!==void 0},reader:yX[Y],writer:ZJ[Y]||ZJ.default}}var YJ={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},yX={array(H){let J=JSON.parse(H);if(!Array.isArray(J))throw TypeError(`expected value of type "array" but instead got value "${H}" of type "${XH(J)}"`);return J},boolean(H){return!(H=="0"||String(H).toLowerCase()=="false")},number(H){return Number(H.replace(/_/g,""))},object(H){let J=JSON.parse(H);if(J===null||typeof J!="object"||Array.isArray(J))throw TypeError(`expected value of type "object" but instead got value "${H}" of type "${XH(J)}"`);return J},string(H){return H}},ZJ={default:bX,array:$J,object:$J};function $J(H){return JSON.stringify(H)}function bX(H){return`${H}`}class f{constructor(H){this.context=H}static get shouldLoad(){return!0}static afterLoad(H,J){return}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get outlets(){return this.scope.outlets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(H,{target:J=this.element,detail:Q={},prefix:X=this.identifier,bubbles:Y=!0,cancelable:Z=!0}={}){let A=X?`${X}:${H}`:H,B=new CustomEvent(A,{detail:Q,bubbles:Y,cancelable:Z});return J.dispatchEvent(B),B}}f.blessings=[SX,RX,TX,wX];f.targets=[];f.outlets=[];f.values={};class oH extends f{sheets=[];moveFocus=(H)=>{let{key:J}=H;if(J==="Tab")H.preventDefault(),document.querySelector(".table .cell[data-xy]")?.click();else if(J==="ArrowRight")this.sheets[Number(H.target.dataset.x)+1]?.focus();else if(J==="ArrowLeft")this.sheets[Number(H.target.dataset.x)-1]?.focus()};connect=()=>{this.sheets=[...this.element.querySelectorAll("[data-x]")],this.sheets.forEach((H)=>{if(H.classList.contains("active"))H.focus();H.addEventListener("keydown",this.moveFocus)})}}class jH extends f{static arrowKeys=["ArrowDown","ArrowLeft","ArrowRight","ArrowUp"];csrf=document.querySelector("meta[name=csrf-token]")?.content;flash=document.querySelector(".flash");input=document.createElement("input");textarea=document.createElement("textarea");columns=this.element.querySelectorAll(".column");cell=this.input;cells={};columnNames=[];ids=[];editMode=!1;prevValue="";update=()=>{let[H,J]=this.getPosition(),{cell:Q,prevValue:X}=this,Y=this.isText(H)?this.textarea.value:this.input.value;if(Y===X)return;let Z=new URLSearchParams({column_name:this.columnNames[H],value:Y});fetch(`${location.pathname}/${this.ids[J]}?${Z}`,{method:"PUT",headers:{"Content-Type":"application/json","X-CSRF-Token":this.csrf??""}}).then((A)=>A.json()).then((A)=>{if(A){let B=document.createElement("span");B.classList.add("alert"),B.innerHTML=A,Q.innerHTML=X,Q.click(),this.flash.replaceChildren(B),setTimeout(()=>B.remove(),5000)}})};getPosition=()=>this.cell.dataset.xy.split(",").map(Number);isText=(H)=>this.columns[H]?.getAttribute("data-type")==="text";setCell=(H)=>{if(this.editMode){let[J]=this.getPosition(),Q=this.isText(J);if(this.update(),this.editMode=!1,Q)this.cell.textContent=this.textarea.value;else this.cell.innerHTML=this.input.value,this.cell.scrollLeft=0}if(!H)return;this.cell=H,H.focus()};enableEditMode=()=>{if(!this.cell.classList.contains("readonly")){let[H]=this.getPosition(),J=this.isText(H),Q=J?this.textarea:this.input;if(J)this.textarea.style.height="";this.editMode=!0,this.prevValue=Q.value=J?this.cell.textContent??"":this.cell.innerHTML,this.cell.replaceChildren(Q),Q.select()}};focus=(H)=>{let J=H.target;if(J!==this.cell&&J.classList.contains("cell"))this.setCell(H.target);else if(!this.editMode)this.enableEditMode()};moveFocus=(H)=>{let{key:J}=H;if(this.editMode){if(J==="Enter"){let[Q,X]=this.getPosition();if(!this.isText(Q))this.setCell(this.cells[`${Q},${X+1}`])}}else if(J==="Enter")this.enableEditMode();else if(J==="Tab")H.preventDefault(),document.querySelector(".sheets .active").focus();else if(jH.arrowKeys.includes(J)){let Q=J==="ArrowDown"?[0,1]:J==="ArrowRight"?[1,0]:J==="ArrowUp"?[0,-1]:[-1,0],[X,Y]=this.getPosition().map((A,B)=>A+Q[B]),Z=this.cells[`${X},${Y}`];if(Q[0])for(let A=X;!Z&&A!==0&&A!==this.columnNames.length;A+=Q[0])Z=this.cells[`${A},${Y}`];this.setCell(Z)}};addCells=()=>{this.cells={},this.ids=[...this.element.querySelectorAll(".column:first-child .readonly")].map((H)=>H.innerHTML),this.element.querySelectorAll(".cell[data-xy]").forEach((H)=>{this.cells[H.dataset.xy]=H,H.addEventListener("click",this.focus),H.addEventListener("keydown",this.moveFocus)})};connect=()=>{this.columnNames=[...this.element.querySelectorAll(".header")].map((H)=>H.dataset.name),this.element.addEventListener("focusout",(H)=>{if(!this.element.contains(H.relatedTarget))this.setCell()}),this.addCells()};loadMore=(H)=>{let J=H.target;fetch(`${location.pathname}?page=${J.dataset.page}`).then((Q)=>Q.text()).then((Q)=>{let X=document.createElement("div");X.innerHTML=Q,X.querySelectorAll(".column").forEach((Z,A)=>{this.columns[A].append(...[...Z.children].slice(1))}),this.addCells();let Y=X.querySelector(".load-more");if(Y)this.element.querySelector(".load-more").replaceWith(Y);else this.element.querySelector(".load-more").remove()})}}var OJ=mH.start();OJ.register("nav",oH);OJ.register("sheets",jH);
33
+ %o`,t,e,s),(r=window.onerror)===null||r===void 0||r.call(window,t,"",0,0,e)}logFormattedMessage(e,t,s={}){s=Object.assign({application:this},s),this.logger.groupCollapsed(`${e} #${t}`),this.logger.log("details:",Object.assign({},s)),this.logger.groupEnd()}}function Si(){return new Promise((e)=>{if(document.readyState=="loading")document.addEventListener("DOMContentLoaded",()=>e());else e()})}function Ai(e){return oe(e,"classes").reduce((s,r)=>Object.assign(s,Ti(r)),{})}function Ti(e){return{[`${e}Class`]:{get(){let{classes:t}=this;if(t.has(e))return t.get(e);else{let s=t.getAttributeName(e);throw Error(`Missing attribute "${s}"`)}}},[`${e}Classes`]:{get(){return this.classes.getAll(e)}},[`has${ne(e)}Class`]:{get(){return this.classes.has(e)}}}}function Li(e){return oe(e,"outlets").reduce((s,r)=>Object.assign(s,Mi(r)),{})}function rs(e,t,s){return e.application.getControllerForElementAndIdentifier(t,s)}function is(e,t,s){let r=rs(e,t,s);if(r)return r;if(e.application.router.proposeToConnectScopeForElementAndIdentifier(t,s),r=rs(e,t,s),r)return r}function Mi(e){let t=xe(e);return{[`${t}Outlet`]:{get(){let s=this.outlets.find(e),r=this.outlets.getSelectorForOutletName(e);if(s){let i=is(this,s,e);if(i)return i;throw Error(`The provided outlet element is missing an outlet controller "${e}" instance for host controller "${this.identifier}"`)}throw Error(`Missing outlet element "${e}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${r}".`)}},[`${t}Outlets`]:{get(){let s=this.outlets.findAll(e);if(s.length>0)return s.map((r)=>{let i=is(this,r,e);if(i)return i;console.warn(`The provided outlet element is missing an outlet controller "${e}" instance for host controller "${this.identifier}"`,r)}).filter((r)=>r);return[]}},[`${t}OutletElement`]:{get(){let s=this.outlets.find(e),r=this.outlets.getSelectorForOutletName(e);if(s)return s;else throw Error(`Missing outlet element "${e}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${r}".`)}},[`${t}OutletElements`]:{get(){return this.outlets.findAll(e)}},[`has${ne(t)}Outlet`]:{get(){return this.outlets.has(e)}}}}function Ci(e){return oe(e,"targets").reduce((s,r)=>Object.assign(s,Ri(r)),{})}function Ri(e){return{[`${e}Target`]:{get(){let t=this.targets.find(e);if(t)return t;else throw Error(`Missing target element "${e}" for "${this.identifier}" controller`)}},[`${e}Targets`]:{get(){return this.targets.findAll(e)}},[`has${ne(e)}Target`]:{get(){return this.targets.has(e)}}}}function Oi(e){let t=hi(e,"values"),s={valueDescriptorMap:{get(){return t.reduce((r,i)=>{let n=ks(i,this.identifier),l=this.data.getAttributeNameForKey(n.key);return Object.assign(r,{[l]:n})},{})}}};return t.reduce((r,i)=>Object.assign(r,ki(i)),s)}function ki(e,t){let s=ks(e,t),{key:r,name:i,reader:n,writer:l}=s;return{[i]:{get(){let p=this.data.get(r);if(p!==null)return n(p);else return s.defaultValue},set(p){if(p===void 0)this.data.delete(r);else this.data.set(r,l(p))}},[`has${ne(i)}`]:{get(){return this.data.has(r)||s.hasCustomDefaultValue}}}}function ks([e,t],s){return Bi({controller:s,token:e,typeDefinition:t})}function we(e){switch(e){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function ie(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(e))return"array";if(Object.prototype.toString.call(e)==="[object Object]")return"object"}function Fi(e){let{controller:t,token:s,typeObject:r}=e,i=Zt(r.type),n=Zt(r.default),l=i&&n,p=i&&!n,O=!i&&n,M=we(r.type),B=ie(e.typeObject.default);if(p)return M;if(O)return B;if(M!==B){let N=t?`${t}.${s}`:s;throw Error(`The specified default value for the Stimulus Value "${N}" must match the defined type "${M}". The provided default value of "${r.default}" is of type "${B}".`)}if(l)return M}function Pi(e){let{controller:t,token:s,typeDefinition:r}=e,n=Fi({controller:t,token:s,typeObject:r}),l=ie(r),p=we(r),O=n||l||p;if(O)return O;let M=t?`${t}.${r}`:s;throw Error(`Unknown value type "${M}" for "${s}" value`)}function Ii(e){let t=we(e);if(t)return ns[t];let s=He(e,"default"),r=He(e,"type"),i=e;if(s)return i.default;if(r){let{type:n}=i,l=we(n);if(l)return ns[l]}return e}function Bi(e){let{token:t,typeDefinition:s}=e,r=`${hs(t)}-value`,i=Pi(e);return{type:i,key:r,name:$e(r),get defaultValue(){return Ii(s)},get hasCustomDefaultValue(){return ie(s)!==void 0},reader:Ni[i],writer:os[i]||os.default}}var ns={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},Ni={array(e){let t=JSON.parse(e);if(!Array.isArray(t))throw TypeError(`expected value of type "array" but instead got value "${e}" of type "${ie(t)}"`);return t},boolean(e){return!(e=="0"||String(e).toLowerCase()=="false")},number(e){return Number(e.replace(/_/g,""))},object(e){let t=JSON.parse(e);if(t===null||typeof t!="object"||Array.isArray(t))throw TypeError(`expected value of type "object" but instead got value "${e}" of type "${ie(t)}"`);return t},string(e){return e}},os={default:Di,array:as,object:as};function as(e){return JSON.stringify(e)}function Di(e){return`${e}`}class x{constructor(e){this.context=e}static get shouldLoad(){return!0}static afterLoad(e,t){return}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get outlets(){return this.scope.outlets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(e,{target:t=this.element,detail:s={},prefix:r=this.identifier,bubbles:i=!0,cancelable:n=!0}={}){let l=r?`${r}:${e}`:e,p=new CustomEvent(l,{detail:s,bubbles:i,cancelable:n});return t.dispatchEvent(p),p}}x.blessings=[Ai,Ci,Oi,Li];x.targets=[];x.outlets=[];x.values={};class Je extends x{sheets=[];moveFocus=(e)=>{let{key:t}=e;if(t==="Tab")e.preventDefault(),document.querySelector(".table .cell[data-xy]")?.click();else if(t==="ArrowRight")this.sheets[Number(e.target.dataset.x)+1]?.focus();else if(t==="ArrowLeft")this.sheets[Number(e.target.dataset.x)-1]?.focus()};connect=()=>{this.sheets=[...this.element.querySelectorAll("[data-x]")],this.sheets.forEach((e)=>{if(e.classList.contains("active"))e.focus();e.addEventListener("keydown",this.moveFocus)})}}class Se extends x{static arrowKeys=["ArrowDown","ArrowLeft","ArrowRight","ArrowUp"];csrf=document.querySelector("meta[name=csrf-token]")?.content;flash=document.querySelector(".flash");input=document.createElement("input");textarea=document.createElement("textarea");columns=this.element.querySelectorAll(".column");cell=this.input;cells={};columnNames=[];ids=[];editMode=!1;prevValue="";update=()=>{let[e,t]=this.getPosition(),{cell:s,prevValue:r}=this,i=this.isText(e)?this.textarea.value:this.input.value;if(i===r)return;let n=new URLSearchParams({column_name:this.columnNames[e],value:i});fetch(`${location.pathname}/${this.ids[t]}?${n}`,{method:"PUT",headers:{"Content-Type":"application/json","X-CSRF-Token":this.csrf??""}}).then((l)=>l.json()).then((l)=>{if(l){let p=document.createElement("span");p.classList.add("alert"),p.innerHTML=l,s.innerHTML=r,s.click(),this.flash.replaceChildren(p),setTimeout(()=>p.remove(),5000)}})};getPosition=()=>this.cell.dataset.xy.split(",").map(Number);isText=(e)=>this.columns[e]?.getAttribute("data-type")==="text";setCell=(e)=>{if(this.editMode){let[t]=this.getPosition(),s=this.isText(t);if(this.update(),this.editMode=!1,s)this.cell.textContent=this.textarea.value;else this.cell.innerHTML=this.input.value,this.cell.scrollLeft=0}if(!e)return;this.cell=e,e.focus()};enableEditMode=()=>{if(!this.cell.classList.contains("readonly")){let[e]=this.getPosition(),t=this.isText(e),s=t?this.textarea:this.input;if(t)this.textarea.style.height="";this.editMode=!0,this.prevValue=s.value=t?this.cell.textContent??"":this.cell.innerHTML,this.cell.replaceChildren(s),s.select()}};focus=(e)=>{let t=e.target;if(t!==this.cell&&t.classList.contains("cell"))this.setCell(e.target);else if(!this.editMode)this.enableEditMode()};moveFocus=(e)=>{let{key:t}=e;if(this.editMode){if(t==="Enter"){let[s,r]=this.getPosition();if(!this.isText(s))this.setCell(this.cells[`${s},${r+1}`])}}else if(t==="Enter")this.enableEditMode();else if(t==="Tab")e.preventDefault(),document.querySelector(".sheets .active").focus();else if(Se.arrowKeys.includes(t)){let s=t==="ArrowDown"?[0,1]:t==="ArrowRight"?[1,0]:t==="ArrowUp"?[0,-1]:[-1,0],[r,i]=this.getPosition().map((l,p)=>l+s[p]),n=this.cells[`${r},${i}`];if(s[0])for(let l=r;!n&&l!==0&&l!==this.columnNames.length;l+=s[0])n=this.cells[`${l},${i}`];this.setCell(n)}};addCells=()=>{this.cells={},this.ids=[...this.element.querySelectorAll(".column:first-child .readonly")].map((e)=>e.innerHTML),this.element.querySelectorAll(".cell[data-xy]").forEach((e)=>{this.cells[e.dataset.xy]=e,e.addEventListener("click",this.focus),e.addEventListener("keydown",this.moveFocus)})};connect=()=>{this.columnNames=[...this.element.querySelectorAll(".header")].map((e)=>e.dataset.name),this.element.addEventListener("focusout",(e)=>{if(!this.element.contains(e.relatedTarget))this.setCell()}),this.addCells()};loadMore=(e)=>{let t=e.target;fetch(`${location.pathname}?page=${t.dataset.page}`).then((s)=>s.text()).then((s)=>{let r=document.createElement("div");r.innerHTML=s,r.querySelectorAll(".column").forEach((n,l)=>{this.columns[l].append(...[...n.children].slice(1))}),this.addCells();let i=r.querySelector(".load-more");if(i)this.element.querySelector(".load-more").replaceWith(i);else this.element.querySelector(".load-more").remove()})}}var Fs=ze.start();Fs.register("nav",Je);Fs.register("sheets",Se);
@@ -34,7 +34,7 @@ class Hotsheet::SheetsController < Hotsheet::ApplicationController
34
34
  end
35
35
 
36
36
  def set_resource
37
- @resource = @sheet.model.find_by id: params[:id]
37
+ @resource = @sheet.scoped.find_by id: params[:id]
38
38
 
39
39
  respond Hotsheet.t "error_not_found" if @resource.nil?
40
40
  end
@@ -6,7 +6,7 @@
6
6
  <% Hotsheet.sheets.each_with_index do |entry, index| %>
7
7
  <li>
8
8
  <% sheet_name, sheet = entry %>
9
- <%= link_to sheet.model.model_name.human(count: 2), sheets_path(sheet_name),
9
+ <%= link_to sheet.label, sheets_path(sheet_name),
10
10
  class: ("active" if params[:sheet_name] == sheet_name), data: { x: index } %>
11
11
  </li>
12
12
  <% end %>
@@ -6,10 +6,12 @@ class Hotsheet::Sheet
6
6
  attr_reader :config, :model
7
7
 
8
8
  CONFIG = {
9
- per: { allowed_classes: [Integer], default: 100 }
9
+ per: { allowed_classes: [Integer], default: 100 },
10
+ as: { allowed_classes: [String, Symbol], default: nil },
11
+ scope: { allowed_classes: [Proc], default: nil }
10
12
  }.freeze
11
13
 
12
- def initialize(name, config, &columns)
14
+ def initialize(name, config = {}, &columns)
13
15
  @config = merge_config! CONFIG, config
14
16
  @model = name.to_s.constantize
15
17
  @columns = {}
@@ -18,6 +20,20 @@ class Hotsheet::Sheet
18
20
  columns ? instance_eval(&columns) : use_default_configuration
19
21
  end
20
22
 
23
+ def name
24
+ (@config[:as] || @model.table_name).to_s
25
+ end
26
+
27
+ def label
28
+ return @model.model_name.human(count: 2) unless @config[:as]
29
+
30
+ @config[:as].to_s.humanize
31
+ end
32
+
33
+ def scoped
34
+ @config[:scope] ? @model.instance_exec(&@config[:scope]) : @model
35
+ end
36
+
21
37
  def columns
22
38
  @columns.select { |_name, column| column.visible? }
23
39
  end
@@ -25,13 +41,13 @@ class Hotsheet::Sheet
25
41
  def cells_for(columns, params)
26
42
  page = page_info params[:page]
27
43
 
28
- [@model.order(:id).limit(page[:limit]).offset(page[:offset]).pluck(*columns.keys).transpose, page]
44
+ [scoped.order(:id).limit(page[:limit]).offset(page[:offset]).pluck(*columns.keys).transpose, page]
29
45
  end
30
46
 
31
47
  private
32
48
 
33
49
  def page_info(page)
34
- total = @model.count
50
+ total = scoped.count
35
51
  page = (page || 1).to_i
36
52
  limit = @config[:per]
37
53
  offset = (1..total.fdiv(limit).ceil).cover?(page) ? page.pred * limit : 0
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hotsheet
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.5"
5
5
  end
data/lib/hotsheet.rb CHANGED
@@ -42,7 +42,14 @@ module Hotsheet
42
42
  ensure_sheet_exists! name
43
43
 
44
44
  sheet = Sheet.new(name, config, &)
45
- @sheets[sheet.model.table_name] = sheet
45
+ ensure_unique_name! sheet.name
46
+ @sheets[sheet.name] = sheet
47
+ end
48
+
49
+ def ensure_unique_name!(name)
50
+ return unless @sheets.key? name
51
+
52
+ raise Hotsheet::Error, "Sheet '#{name}' is already defined; pass a unique `as:` option"
46
53
  end
47
54
 
48
55
  def ensure_sheet_exists!(name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotsheet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renuo AG