ad_space 0.1.4 → 0.1.6
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 +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +33 -1
- data/ad_space.gemspec +1 -3
- data/app/controllers/ad_space/advertisements_controller.rb +6 -3
- data/app/controllers/ad_space/api/v1/advertisements_controller.rb +21 -9
- data/app/controllers/ad_space/application_controller.rb +34 -0
- data/app/controllers/ad_space/slots_controller.rb +6 -3
- data/app/models/ad_space/i18n_config.rb +25 -0
- data/app/views/ad_space/advertisements/_advertisement.html.erb +0 -15
- data/app/views/ad_space/advertisements/_form.html.erb +6 -6
- data/app/views/ad_space/advertisements/edit.html.erb +3 -3
- data/app/views/ad_space/advertisements/index.html.erb +3 -3
- data/app/views/ad_space/advertisements/new.html.erb +2 -2
- data/app/views/ad_space/advertisements/show.html.erb +5 -5
- data/app/views/ad_space/dashboard/index.html.erb +4 -4
- data/app/views/ad_space/slots/_form.html.erb +4 -4
- data/app/views/ad_space/slots/_slot.html.erb +5 -5
- data/app/views/ad_space/slots/edit.html.erb +3 -3
- data/app/views/ad_space/slots/index.html.erb +3 -3
- data/app/views/ad_space/slots/new.html.erb +2 -2
- data/app/views/ad_space/slots/show.html.erb +3 -3
- data/bin/rails +14 -0
- data/config/i18n-tasks.yml +155 -0
- data/config/locales/zh-CN.yml +240 -0
- data/lib/ad_space/configuration.rb +5 -0
- data/lib/ad_space/version.rb +1 -1
- data/public/ad_space-assets/application.js +31 -0
- data/public/ad_space-assets/application.js.map +7 -0
- metadata +8 -2
@@ -0,0 +1,31 @@
|
|
1
|
+
(()=>{var Ps=Object.defineProperty;var v=(r,e)=>()=>(r&&(e=r(r=0)),e);var Bs=(r,e)=>{for(var t in e)Ps(r,t,{get:e[t],enumerable:!0})};var O,Se=v(()=>{O={logger:self.console,WebSocket:self.WebSocket}});var c,D=v(()=>{Se();c={log(...r){this.enabled&&(r.push(Date.now()),O.logger.log("[ActionCable]",...r))}}});var z,Ae,J,Te,ct=v(()=>{D();z=()=>new Date().getTime(),Ae=r=>(z()-r)/1e3,J=class{constructor(e){this.visibilityDidChange=this.visibilityDidChange.bind(this),this.connection=e,this.reconnectAttempts=0}start(){this.isRunning()||(this.startedAt=z(),delete this.stoppedAt,this.startPolling(),addEventListener("visibilitychange",this.visibilityDidChange),c.log(`ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`))}stop(){this.isRunning()&&(this.stoppedAt=z(),this.stopPolling(),removeEventListener("visibilitychange",this.visibilityDidChange),c.log("ConnectionMonitor stopped"))}isRunning(){return this.startedAt&&!this.stoppedAt}recordPing(){this.pingedAt=z()}recordConnect(){this.reconnectAttempts=0,this.recordPing(),delete this.disconnectedAt,c.log("ConnectionMonitor recorded connect")}recordDisconnect(){this.disconnectedAt=z(),c.log("ConnectionMonitor recorded disconnect")}startPolling(){this.stopPolling(),this.poll()}stopPolling(){clearTimeout(this.pollTimeout)}poll(){this.pollTimeout=setTimeout(()=>{this.reconnectIfStale(),this.poll()},this.getPollInterval())}getPollInterval(){let{staleThreshold:e,reconnectionBackoffRate:t}=this.constructor,s=Math.pow(1+t,Math.min(this.reconnectAttempts,10)),n=(this.reconnectAttempts===0?1:t)*Math.random();return e*1e3*s*(1+n)}reconnectIfStale(){this.connectionIsStale()&&(c.log(`ConnectionMonitor detected stale connection. reconnectAttempts = ${this.reconnectAttempts}, time stale = ${Ae(this.refreshedAt)} s, stale threshold = ${this.constructor.staleThreshold} s`),this.reconnectAttempts++,this.disconnectedRecently()?c.log(`ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${Ae(this.disconnectedAt)} s`):(c.log("ConnectionMonitor reopening"),this.connection.reopen()))}get refreshedAt(){return this.pingedAt?this.pingedAt:this.startedAt}connectionIsStale(){return Ae(this.refreshedAt)>this.constructor.staleThreshold}disconnectedRecently(){return this.disconnectedAt&&Ae(this.disconnectedAt)<this.constructor.staleThreshold}visibilityDidChange(){document.visibilityState==="visible"&&setTimeout(()=>{(this.connectionIsStale()||!this.connection.isOpen())&&(c.log(`ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`),this.connection.reopen())},200)}};J.staleThreshold=6;J.reconnectionBackoffRate=.15;Te=J});var G,lt=v(()=>{G={message_types:{welcome:"welcome",disconnect:"disconnect",ping:"ping",confirmation:"confirm_subscription",rejection:"reject_subscription"},disconnect_reasons:{unauthorized:"unauthorized",invalid_request:"invalid_request",server_restart:"server_restart",remote:"remote"},default_mount_path:"/cable",protocols:["actioncable-v1-json","actioncable-unsupported"]}});var X,ht,Dr,rs,Q,Ce,ut=v(()=>{Se();ct();lt();D();({message_types:X,protocols:ht}=G),Dr=ht.slice(0,ht.length-1),rs=[].indexOf,Q=class{constructor(e){this.open=this.open.bind(this),this.consumer=e,this.subscriptions=this.consumer.subscriptions,this.monitor=new Te(this),this.disconnected=!0}send(e){return this.isOpen()?(this.webSocket.send(JSON.stringify(e)),!0):!1}open(){if(this.isActive())return c.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`),!1;{let e=[...ht,...this.consumer.subprotocols||[]];return c.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${e}`),this.webSocket&&this.uninstallEventHandlers(),this.webSocket=new O.WebSocket(this.consumer.url,e),this.installEventHandlers(),this.monitor.start(),!0}}close({allowReconnect:e}={allowReconnect:!0}){if(e||this.monitor.stop(),this.isOpen())return this.webSocket.close()}reopen(){if(c.log(`Reopening WebSocket, current state is ${this.getState()}`),this.isActive())try{return this.close()}catch(e){c.log("Failed to reopen WebSocket",e)}finally{c.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`),setTimeout(this.open,this.constructor.reopenDelay)}else return this.open()}getProtocol(){if(this.webSocket)return this.webSocket.protocol}isOpen(){return this.isState("open")}isActive(){return this.isState("open","connecting")}triedToReconnect(){return this.monitor.reconnectAttempts>0}isProtocolSupported(){return rs.call(Dr,this.getProtocol())>=0}isState(...e){return rs.call(e,this.getState())>=0}getState(){if(this.webSocket){for(let e in O.WebSocket)if(O.WebSocket[e]===this.webSocket.readyState)return e.toLowerCase()}return null}installEventHandlers(){for(let e in this.events){let t=this.events[e].bind(this);this.webSocket[`on${e}`]=t}}uninstallEventHandlers(){for(let e in this.events)this.webSocket[`on${e}`]=function(){}}};Q.reopenDelay=500;Q.prototype.events={message(r){if(!this.isProtocolSupported())return;let{identifier:e,message:t,reason:s,reconnect:i,type:n}=JSON.parse(r.data);switch(n){case X.welcome:return this.triedToReconnect()&&(this.reconnectAttempted=!0),this.monitor.recordConnect(),this.subscriptions.reload();case X.disconnect:return c.log(`Disconnecting. Reason: ${s}`),this.close({allowReconnect:i});case X.ping:return this.monitor.recordPing();case X.confirmation:return this.subscriptions.confirmSubscription(e),this.reconnectAttempted?(this.reconnectAttempted=!1,this.subscriptions.notify(e,"connected",{reconnected:!0})):this.subscriptions.notify(e,"connected",{reconnected:!1});case X.rejection:return this.subscriptions.reject(e);default:return this.subscriptions.notify(e,"received",t)}},open(){if(c.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`),this.disconnected=!1,!this.isProtocolSupported())return c.log("Protocol is unsupported. Stopping monitor and disconnecting."),this.close({allowReconnect:!1})},close(r){if(c.log("WebSocket onclose event"),!this.disconnected)return this.disconnected=!0,this.monitor.recordDisconnect(),this.subscriptions.notifyAll("disconnected",{willAttemptReconnect:this.monitor.isRunning()})},error(){c.log("WebSocket onerror event")}};Ce=Q});var qr,R,dt=v(()=>{qr=function(r,e){if(e!=null)for(let t in e){let s=e[t];r[t]=s}return r},R=class{constructor(e,t={},s){this.consumer=e,this.identifier=JSON.stringify(t),qr(this,s)}perform(e,t={}){return t.action=e,this.send(t)}send(e){return this.consumer.send({command:"message",identifier:this.identifier,data:JSON.stringify(e)})}unsubscribe(){return this.consumer.subscriptions.remove(this)}}});var mt,Le,pt=v(()=>{D();mt=class{constructor(e){this.subscriptions=e,this.pendingSubscriptions=[]}guarantee(e){this.pendingSubscriptions.indexOf(e)==-1?(c.log(`SubscriptionGuarantor guaranteeing ${e.identifier}`),this.pendingSubscriptions.push(e)):c.log(`SubscriptionGuarantor already guaranteeing ${e.identifier}`),this.startGuaranteeing()}forget(e){c.log(`SubscriptionGuarantor forgetting ${e.identifier}`),this.pendingSubscriptions=this.pendingSubscriptions.filter(t=>t!==e)}startGuaranteeing(){this.stopGuaranteeing(),this.retrySubscribing()}stopGuaranteeing(){clearTimeout(this.retryTimeout)}retrySubscribing(){this.retryTimeout=setTimeout(()=>{this.subscriptions&&typeof this.subscriptions.subscribe=="function"&&this.pendingSubscriptions.map(e=>{c.log(`SubscriptionGuarantor resubscribing ${e.identifier}`),this.subscriptions.subscribe(e)})},500)}},Le=mt});var P,ft=v(()=>{dt();pt();D();P=class{constructor(e){this.consumer=e,this.guarantor=new Le(this),this.subscriptions=[]}create(e,t){let s=e,i=typeof s=="object"?s:{channel:s},n=new R(this.consumer,i,t);return this.add(n)}add(e){return this.subscriptions.push(e),this.consumer.ensureActiveConnection(),this.notify(e,"initialized"),this.subscribe(e),e}remove(e){return this.forget(e),this.findAll(e.identifier).length||this.sendCommand(e,"unsubscribe"),e}reject(e){return this.findAll(e).map(t=>(this.forget(t),this.notify(t,"rejected"),t))}forget(e){return this.guarantor.forget(e),this.subscriptions=this.subscriptions.filter(t=>t!==e),e}findAll(e){return this.subscriptions.filter(t=>t.identifier===e)}reload(){return this.subscriptions.map(e=>this.subscribe(e))}notifyAll(e,...t){return this.subscriptions.map(s=>this.notify(s,e,...t))}notify(e,t,...s){let i;return typeof e=="string"?i=this.findAll(e):i=[e],i.map(n=>typeof n[t]=="function"?n[t](...s):void 0)}subscribe(e){this.sendCommand(e,"subscribe")&&this.guarantor.guarantee(e)}confirmSubscription(e){c.log(`Subscription confirmed ${e}`),this.findAll(e).map(t=>this.guarantor.forget(t))}sendCommand(e,t){let{identifier:s}=e;return this.consumer.send({command:t,identifier:s})}}});function gt(r){if(typeof r=="function"&&(r=r()),r&&!/^wss?:/i.test(r)){let e=document.createElement("a");return e.href=r,e.href=e.href,e.protocol=e.protocol.replace("http","ws"),e.href}else return r}var q,is=v(()=>{ut();ft();q=class{constructor(e){this._url=e,this.subscriptions=new P(this),this.connection=new Ce(this),this.subprotocols=[]}get url(){return gt(this._url)}send(e){return this.connection.send(e)}connect(){return this.connection.open()}disconnect(){return this.connection.close({allowReconnect:!1})}ensureActiveConnection(){if(!this.connection.isActive())return this.connection.open()}addSubProtocol(e){this.subprotocols=[...this.subprotocols,e]}}});var os={};Bs(os,{Connection:()=>Ce,ConnectionMonitor:()=>Te,Consumer:()=>q,INTERNAL:()=>G,Subscription:()=>R,SubscriptionGuarantor:()=>Le,Subscriptions:()=>P,adapters:()=>O,createConsumer:()=>Hr,createWebSocketURL:()=>gt,getConfig:()=>ns,logger:()=>c});function Hr(r=ns("url")||G.default_mount_path){return new q(r)}function ns(r){let e=document.head.querySelector(`meta[name='action-cable-${r}']`);if(e)return e.getAttribute("content")}var as=v(()=>{ut();ct();is();lt();dt();ft();pt();Se();D()});(function(){if(window.Reflect===void 0||window.customElements===void 0||window.customElements.polyfillWrapFlushCallback)return;let r=HTMLElement,e={HTMLElement:function(){return Reflect.construct(r,[],this.constructor)}};window.HTMLElement=e.HTMLElement,HTMLElement.prototype=r.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,r)})();(function(r){if(typeof r.requestSubmit=="function")return;r.requestSubmit=function(s){s?(e(s,this),s.click()):(s=document.createElement("input"),s.type="submit",s.hidden=!0,this.appendChild(s),s.click(),this.removeChild(s))};function e(s,i){s instanceof HTMLElement||t(TypeError,"parameter 1 is not of type 'HTMLElement'"),s.type=="submit"||t(TypeError,"The specified element is not a submit button"),s.form==i||t(DOMException,"The specified element is not owned by this form element","NotFoundError")}function t(s,i,n){throw new s("Failed to execute 'requestSubmit' on 'HTMLFormElement': "+i+".",n)}})(HTMLFormElement.prototype);var Jt=new WeakMap;function Is(r){let e=r instanceof Element?r:r instanceof Node?r.parentElement:null,t=e?e.closest("input, button"):null;return t?.type=="submit"?t:null}function xs(r){let e=Is(r.target);e&&e.form&&Jt.set(e.form,e)}(function(){if("submitter"in Event.prototype)return;let r=window.Event.prototype;if("SubmitEvent"in window&&/Apple Computer/.test(navigator.vendor))r=window.SubmitEvent.prototype;else if("SubmitEvent"in window)return;addEventListener("click",xs,!0),Object.defineProperty(r,"submitter",{get(){if(this.type=="submit"&&this.target instanceof HTMLFormElement)return Jt.get(this.target)}})})();var L;(function(r){r.eager="eager",r.lazy="lazy"})(L||(L={}));var w=class r extends HTMLElement{static get observedAttributes(){return["disabled","complete","loading","src"]}constructor(){super(),this.loaded=Promise.resolve(),this.delegate=new r.delegateConstructor(this)}connectedCallback(){this.delegate.connect()}disconnectedCallback(){this.delegate.disconnect()}reload(){return this.delegate.sourceURLReloaded()}attributeChangedCallback(e){e=="loading"?this.delegate.loadingStyleChanged():e=="complete"?this.delegate.completeChanged():e=="src"?this.delegate.sourceURLChanged():this.delegate.disabledChanged()}get src(){return this.getAttribute("src")}set src(e){e?this.setAttribute("src",e):this.removeAttribute("src")}get loading(){return Ns(this.getAttribute("loading")||"")}set loading(e){e?this.setAttribute("loading",e):this.removeAttribute("loading")}get disabled(){return this.hasAttribute("disabled")}set disabled(e){e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get autoscroll(){return this.hasAttribute("autoscroll")}set autoscroll(e){e?this.setAttribute("autoscroll",""):this.removeAttribute("autoscroll")}get complete(){return!this.delegate.isLoading}get isActive(){return this.ownerDocument===document&&!this.isPreview}get isPreview(){var e,t;return(t=(e=this.ownerDocument)===null||e===void 0?void 0:e.documentElement)===null||t===void 0?void 0:t.hasAttribute("data-turbo-preview")}};function Ns(r){switch(r.toLowerCase()){case"lazy":return L.lazy;default:return L.eager}}function d(r){return new URL(r.toString(),document.baseURI)}function F(r){let e;if(r.hash)return r.hash.slice(1);if(e=r.href.match(/#(.*)$/))return e[1]}function at(r,e){let t=e?.getAttribute("formaction")||r.getAttribute("action")||r.action;return d(t)}function Ds(r){return(_s(r).match(/\.[^.]*$/)||[])[0]||""}function qs(r){return!!Ds(r).match(/^(?:|\.(?:htm|html|xhtml|php))$/)}function Hs(r,e){let t=Us(e);return r.href===d(t).href||r.href.startsWith(t)}function I(r,e){return Hs(r,e)&&qs(r)}function Ne(r){let e=F(r);return e!=null?r.href.slice(0,-(e.length+1)):r.href}function ae(r){return Ne(r)}function Vs(r,e){return d(r).href==d(e).href}function $s(r){return r.pathname.split("/").slice(1)}function _s(r){return $s(r).slice(-1)[0]}function Us(r){return js(r.origin+r.pathname)}function js(r){return r.endsWith("/")?r:r+"/"}var H=class{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 d(this.response.url)}get isHTML(){return this.contentType&&this.contentType.match(/^(?:text\/([^\s;,]+\b)?html|application\/xhtml\+xml)\b/)}get statusCode(){return this.response.status}get contentType(){return this.header("Content-Type")}get responseText(){return this.response.clone().text()}get responseHTML(){return this.isHTML?this.response.clone().text():Promise.resolve(void 0)}header(e){return this.response.headers.get(e)}};function V(r){if(r.getAttribute("data-turbo-eval")=="false")return r;{let e=document.createElement("script"),t=he("csp-nonce");return t&&(e.nonce=t),e.textContent=r.textContent,e.async=!1,Ws(e,r),e}}function Ws(r,e){for(let{name:t,value:s}of e.attributes)r.setAttribute(t,s)}function Ks(r){let e=document.createElement("template");return e.innerHTML=r,e.content}function u(r,{target:e,cancelable:t,detail:s}={}){let i=new CustomEvent(r,{cancelable:t,bubbles:!0,composed:!0,detail:s});return e&&e.isConnected?e.dispatchEvent(i):document.documentElement.dispatchEvent(i),i}function ce(){return new Promise(r=>requestAnimationFrame(()=>r()))}function zs(){return new Promise(r=>setTimeout(()=>r(),0))}function Js(){return Promise.resolve()}function Gt(r=""){return new DOMParser().parseFromString(r,"text/html")}function Xt(r,...e){let t=Gs(r,e).replace(/^\n/,"").split(`
|
2
|
+
`),s=t[0].match(/^\s+/),i=s?s[0].length:0;return t.map(n=>n.slice(i)).join(`
|
3
|
+
`)}function Gs(r,e){return r.reduce((t,s,i)=>{let n=e[i]==null?"":e[i];return t+s+n},"")}function x(){return Array.from({length:36}).map((r,e)=>e==8||e==13||e==18||e==23?"-":e==14?"4":e==19?(Math.floor(Math.random()*4)+8).toString(16):Math.floor(Math.random()*15).toString(16)).join("")}function le(r,...e){for(let t of e.map(s=>s?.getAttribute(r)))if(typeof t=="string")return t;return null}function Xs(r,...e){return e.some(t=>t&&t.hasAttribute(r))}function De(...r){for(let e of r)e.localName=="turbo-frame"&&e.setAttribute("busy",""),e.setAttribute("aria-busy","true")}function qe(...r){for(let e of r)e.localName=="turbo-frame"&&e.removeAttribute("busy"),e.removeAttribute("aria-busy")}function Qs(r,e=2e3){return new Promise(t=>{let s=()=>{r.removeEventListener("error",s),r.removeEventListener("load",s),t()};r.addEventListener("load",s,{once:!0}),r.addEventListener("error",s,{once:!0}),setTimeout(t,e)})}function Qt(r){switch(r){case"replace":return history.replaceState;case"advance":case"restore":return history.pushState}}function Ys(r){return r=="advance"||r=="replace"||r=="restore"}function ye(...r){let e=le("data-turbo-action",...r);return Ys(e)?e:null}function Yt(r){return document.querySelector(`meta[name="${r}"]`)}function he(r){let e=Yt(r);return e&&e.content}function Zs(r,e){let t=Yt(r);return t||(t=document.createElement("meta"),t.setAttribute("name",r),document.head.appendChild(t)),t.setAttribute("content",e),t}function ue(r,e){var t;if(r instanceof Element)return r.closest(e)||ue(r.assignedSlot||((t=r.getRootNode())===null||t===void 0?void 0:t.host),e)}var p;(function(r){r[r.get=0]="get",r[r.post=1]="post",r[r.put=2]="put",r[r.patch=3]="patch",r[r.delete=4]="delete"})(p||(p={}));function er(r){switch(r.toLowerCase()){case"get":return p.get;case"post":return p.post;case"put":return p.put;case"patch":return p.patch;case"delete":return p.delete}}var $=class{constructor(e,t,s,i=new URLSearchParams,n=null){this.abortController=new AbortController,this.resolveRequestPromise=o=>{},this.delegate=e,this.method=t,this.headers=this.defaultHeaders,this.body=i,this.url=s,this.target=n}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),await this.allowRequestToBeIntercepted(e);try{this.delegate.requestStarted(this);let t=await fetch(this.url.href,e);return await this.receive(t)}catch(t){if(t.name!=="AbortError")throw this.willDelegateErrorHandling(t)&&this.delegate.requestErrored(this,t),t}finally{this.delegate.requestFinished(this)}}async receive(e){let t=new H(e);return u("turbo:before-fetch-response",{cancelable:!0,detail:{fetchResponse:t},target:this.target}).defaultPrevented?this.delegate.requestPreventedHandlingResponse(this,t):t.succeeded?this.delegate.requestSucceededWithResponse(this,t):this.delegate.requestFailedWithResponse(this,t),t}get fetchOptions(){var e;return{method:p[this.method].toUpperCase(),credentials:"same-origin",headers:this.headers,redirect:"follow",body:this.isSafe?null:this.body,signal:this.abortSignal,referrer:(e=this.delegate.referrer)===null||e===void 0?void 0:e.href}}get defaultHeaders(){return{Accept:"text/html, application/xhtml+xml"}}get isSafe(){return this.method===p.get}get abortSignal(){return this.abortController.signal}acceptResponseType(e){this.headers.Accept=[e,this.headers.Accept].join(", ")}async allowRequestToBeIntercepted(e){let t=new Promise(i=>this.resolveRequestPromise=i);u("turbo:before-fetch-request",{cancelable:!0,detail:{fetchOptions:e,url:this.url,resume:this.resolveRequestPromise},target:this.target}).defaultPrevented&&await t}willDelegateErrorHandling(e){return!u("turbo:fetch-request-error",{target:this.target,cancelable:!0,detail:{request:this,error:e}}).defaultPrevented}},He=class{constructor(e,t){this.started=!1,this.intersect=s=>{let i=s.slice(-1)[0];i?.isIntersecting&&this.delegate.elementAppearedInViewport(this.element)},this.delegate=e,this.element=t,this.intersectionObserver=new IntersectionObserver(this.intersect)}start(){this.started||(this.started=!0,this.intersectionObserver.observe(this.element))}stop(){this.started&&(this.started=!1,this.intersectionObserver.unobserve(this.element))}},E=class{static wrap(e){return typeof e=="string"?new this(Ks(e)):e}constructor(e){this.fragment=tr(e)}};E.contentType="text/vnd.turbo-stream.html";function tr(r){for(let e of r.querySelectorAll("turbo-stream")){let t=document.importNode(e,!0);for(let s of t.templateElement.content.querySelectorAll("script"))s.replaceWith(V(s));e.replaceWith(t)}return r}var T;(function(r){r[r.initialized=0]="initialized",r[r.requesting=1]="requesting",r[r.waiting=2]="waiting",r[r.receiving=3]="receiving",r[r.stopping=4]="stopping",r[r.stopped=5]="stopped"})(T||(T={}));var C;(function(r){r.urlEncoded="application/x-www-form-urlencoded",r.multipart="multipart/form-data",r.plain="text/plain"})(C||(C={}));function sr(r){switch(r.toLowerCase()){case C.multipart:return C.multipart;case C.plain:return C.plain;default:return C.urlEncoded}}var _=class r{static confirmMethod(e,t,s){return Promise.resolve(confirm(e))}constructor(e,t,s,i=!1){this.state=T.initialized,this.delegate=e,this.formElement=t,this.submitter=s,this.formData=rr(t,s),this.location=d(this.action),this.method==p.get&&or(this.location,[...this.body.entries()]),this.fetchRequest=new $(this,this.method,this.location,this.body,this.formElement),this.mustRedirect=i}get method(){var e;let t=((e=this.submitter)===null||e===void 0?void 0:e.getAttribute("formmethod"))||this.formElement.getAttribute("method")||"";return er(t.toLowerCase())||p.get}get action(){var e;let t=typeof this.formElement.action=="string"?this.formElement.action:null;return!((e=this.submitter)===null||e===void 0)&&e.hasAttribute("formaction")?this.submitter.getAttribute("formaction")||"":this.formElement.getAttribute("action")||t||""}get body(){return this.enctype==C.urlEncoded||this.method==p.get?new URLSearchParams(this.stringFormData):this.formData}get enctype(){var e;return sr(((e=this.submitter)===null||e===void 0?void 0:e.getAttribute("formenctype"))||this.formElement.enctype)}get isSafe(){return this.fetchRequest.isSafe}get stringFormData(){return[...this.formData].reduce((e,[t,s])=>e.concat(typeof s=="string"?[[t,s]]:[]),[])}async start(){let{initialized:e,requesting:t}=T,s=le("data-turbo-confirm",this.submitter,this.formElement);if(!(typeof s=="string"&&!await r.confirmMethod(s,this.formElement,this.submitter))&&this.state==e)return this.state=t,this.fetchRequest.perform()}stop(){let{stopping:e,stopped:t}=T;if(this.state!=e&&this.state!=t)return this.state=e,this.fetchRequest.cancel(),!0}prepareRequest(e){if(!e.isSafe){let t=ir(he("csrf-param"))||he("csrf-token");t&&(e.headers["X-CSRF-Token"]=t)}this.requestAcceptsTurboStreamResponse(e)&&e.acceptResponseType(E.contentType)}requestStarted(e){var t;this.state=T.waiting,(t=this.submitter)===null||t===void 0||t.setAttribute("disabled",""),this.setSubmitsWith(),u("turbo:submit-start",{target:this.formElement,detail:{formSubmission:this}}),this.delegate.formSubmissionStarted(this)}requestPreventedHandlingResponse(e,t){this.result={success:t.succeeded,fetchResponse:t}}requestSucceededWithResponse(e,t){if(t.clientError||t.serverError)this.delegate.formSubmissionFailedWithResponse(this,t);else if(this.requestMustRedirect(e)&&nr(t)){let s=new Error("Form responses must redirect to another location");this.delegate.formSubmissionErrored(this,s)}else this.state=T.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){var t;this.state=T.stopped,(t=this.submitter)===null||t===void 0||t.removeAttribute("disabled"),this.resetSubmitterText(),u("turbo:submit-end",{target:this.formElement,detail:Object.assign({formSubmission:this},this.result)}),this.delegate.formSubmissionFinished(this)}setSubmitsWith(){if(!(!this.submitter||!this.submitsWith)){if(this.submitter.matches("button"))this.originalSubmitText=this.submitter.innerHTML,this.submitter.innerHTML=this.submitsWith;else if(this.submitter.matches("input")){let e=this.submitter;this.originalSubmitText=e.value,e.value=this.submitsWith}}}resetSubmitterText(){if(!(!this.submitter||!this.originalSubmitText)){if(this.submitter.matches("button"))this.submitter.innerHTML=this.originalSubmitText;else if(this.submitter.matches("input")){let e=this.submitter;e.value=this.originalSubmitText}}}requestMustRedirect(e){return!e.isSafe&&this.mustRedirect}requestAcceptsTurboStreamResponse(e){return!e.isSafe||Xs("data-turbo-stream",this.submitter,this.formElement)}get submitsWith(){var e;return(e=this.submitter)===null||e===void 0?void 0:e.getAttribute("data-turbo-submits-with")}};function rr(r,e){let t=new FormData(r),s=e?.getAttribute("name"),i=e?.getAttribute("value");return s&&t.append(s,i||""),t}function ir(r){if(r!=null){let t=(document.cookie?document.cookie.split("; "):[]).find(s=>s.startsWith(r));if(t){let s=t.split("=").slice(1).join("=");return s?decodeURIComponent(s):void 0}}}function nr(r){return r.statusCode==200&&!r.redirected}function or(r,e){let t=new URLSearchParams;for(let[s,i]of e)i instanceof File||t.append(s,i);return r.search=t.toString(),r}var N=class{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(){let e="[inert], :disabled, [hidden], details:not([open]), dialog:not([open])";for(let t of this.element.querySelectorAll("[autofocus]"))if(t.closest(e)==null)return t;return null}get permanentElements(){return es(this.element)}getPermanentElementById(e){return Zt(this.element,e)}getPermanentElementMapForSnapshot(e){let t={};for(let s of this.permanentElements){let{id:i}=s,n=e.getPermanentElementById(i);n&&(t[i]=[s,n])}return t}};function Zt(r,e){return r.querySelector(`#${e}[data-turbo-permanent]`)}function es(r){return r.querySelectorAll("[id][data-turbo-permanent]")}var U=class{constructor(e,t){this.started=!1,this.submitCaptured=()=>{this.eventTarget.removeEventListener("submit",this.submitBubbled,!1),this.eventTarget.addEventListener("submit",this.submitBubbled,!1)},this.submitBubbled=s=>{if(!s.defaultPrevented){let i=s.target instanceof HTMLFormElement?s.target:void 0,n=s.submitter||void 0;i&&ar(i,n)&&cr(i,n)&&this.delegate.willSubmitForm(i,n)&&(s.preventDefault(),s.stopImmediatePropagation(),this.delegate.formSubmitted(i,n))}},this.delegate=e,this.eventTarget=t}start(){this.started||(this.eventTarget.addEventListener("submit",this.submitCaptured,!0),this.started=!0)}stop(){this.started&&(this.eventTarget.removeEventListener("submit",this.submitCaptured,!0),this.started=!1)}};function ar(r,e){return(e?.getAttribute("formmethod")||r.getAttribute("method"))!="dialog"}function cr(r,e){if(e?.hasAttribute("formtarget")||r.hasAttribute("target")){let t=e?.getAttribute("formtarget")||r.target;for(let s of document.getElementsByName(t))if(s instanceof HTMLIFrameElement)return!1;return!0}else return!0}var de=class{constructor(e,t){this.resolveRenderPromise=s=>{},this.resolveInterceptionPromise=s=>{},this.delegate=e,this.element=t}scrollToAnchor(e){let t=this.snapshot.getElementForAnchor(e);t?(this.scrollToElement(t),this.focusElement(t)):this.scrollToPosition({x:0,y:0})}scrollToAnchorFromLocation(e){this.scrollToAnchor(F(e))}scrollToElement(e){e.scrollIntoView()}focusElement(e){e instanceof HTMLElement&&(e.hasAttribute("tabindex")?e.focus():(e.setAttribute("tabindex","-1"),e.focus(),e.removeAttribute("tabindex")))}scrollToPosition({x:e,y:t}){this.scrollRoot.scrollTo(e,t)}scrollToTop(){this.scrollToPosition({x:0,y:0})}get scrollRoot(){return window}async render(e){let{isPreview:t,shouldRender:s,newSnapshot:i}=e;if(s)try{this.renderPromise=new Promise(l=>this.resolveRenderPromise=l),this.renderer=e,await this.prepareToRenderSnapshot(e);let n=new Promise(l=>this.resolveInterceptionPromise=l),o={resume:this.resolveInterceptionPromise,render:this.renderer.renderElement};this.delegate.allowsImmediateRender(i,o)||await n,await this.renderSnapshot(e),this.delegate.viewRenderedSnapshot(i,t),this.delegate.preloadOnLoadLinksForView(this.element),this.finishRenderingSnapshot(e)}finally{delete this.renderer,this.resolveRenderPromise(void 0),delete this.renderPromise}else this.invalidate(e.reloadReason)}invalidate(e){this.delegate.viewInvalidated(e)}async prepareToRenderSnapshot(e){this.markAsPreview(e.isPreview),await e.prepareToRender()}markAsPreview(e){e?this.element.setAttribute("data-turbo-preview",""):this.element.removeAttribute("data-turbo-preview")}async renderSnapshot(e){await e.render()}finishRenderingSnapshot(e){e.finishRendering()}},Ve=class extends de{missing(){this.element.innerHTML='<strong class="turbo-frame-error">Content missing</strong>'}get snapshot(){return new N(this.element)}},me=class{constructor(e,t){this.clickBubbled=s=>{this.respondsToEventTarget(s.target)?this.clickEvent=s:delete this.clickEvent},this.linkClicked=s=>{this.clickEvent&&this.respondsToEventTarget(s.target)&&s.target instanceof Element&&this.delegate.shouldInterceptLinkClick(s.target,s.detail.url,s.detail.originalEvent)&&(this.clickEvent.preventDefault(),s.preventDefault(),this.delegate.linkClickIntercepted(s.target,s.detail.url,s.detail.originalEvent)),delete this.clickEvent},this.willVisit=s=>{delete this.clickEvent},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)}respondsToEventTarget(e){let t=e instanceof Element?e:e instanceof Node?e.parentElement:null;return t&&t.closest("turbo-frame, html")==this.element}},pe=class{constructor(e,t){this.started=!1,this.clickCaptured=()=>{this.eventTarget.removeEventListener("click",this.clickBubbled,!1),this.eventTarget.addEventListener("click",this.clickBubbled,!1)},this.clickBubbled=s=>{if(s instanceof MouseEvent&&this.clickEventIsSignificant(s)){let i=s.composedPath&&s.composedPath()[0]||s.target,n=this.findLinkFromClickTarget(i);if(n&&lr(n)){let o=this.getLocationForLink(n);this.delegate.willFollowLinkToLocation(n,o,s)&&(s.preventDefault(),this.delegate.followedLinkToLocation(n,o))}}},this.delegate=e,this.eventTarget=t}start(){this.started||(this.eventTarget.addEventListener("click",this.clickCaptured,!0),this.started=!0)}stop(){this.started&&(this.eventTarget.removeEventListener("click",this.clickCaptured,!0),this.started=!1)}clickEventIsSignificant(e){return!(e.target&&e.target.isContentEditable||e.defaultPrevented||e.which>1||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)}findLinkFromClickTarget(e){return ue(e,"a[href]:not([target^=_]):not([download])")}getLocationForLink(e){return d(e.getAttribute("href")||"")}};function lr(r){if(r.hasAttribute("target")){for(let e of document.getElementsByName(r.target))if(e instanceof HTMLIFrameElement)return!1;return!0}else return!0}var fe=class{constructor(e,t){this.delegate=e,this.linkInterceptor=new pe(this,t)}start(){this.linkInterceptor.start()}stop(){this.linkInterceptor.stop()}willFollowLinkToLocation(e,t,s){return this.delegate.willSubmitFormLinkToLocation(e,t,s)&&e.hasAttribute("data-turbo-method")}followedLinkToLocation(e,t){let s=document.createElement("form"),i="hidden";for(let[A,oe]of t.searchParams)s.append(Object.assign(document.createElement("input"),{type:i,name:A,value:oe}));let n=Object.assign(t,{search:""});s.setAttribute("data-turbo","true"),s.setAttribute("action",n.href),s.setAttribute("hidden","");let o=e.getAttribute("data-turbo-method");o&&s.setAttribute("method",o);let a=e.getAttribute("data-turbo-frame");a&&s.setAttribute("data-turbo-frame",a);let l=ye(e);l&&s.setAttribute("data-turbo-action",l);let m=e.getAttribute("data-turbo-confirm");m&&s.setAttribute("data-turbo-confirm",m),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())}},ge=class{static async preservingPermanentElements(e,t,s){let i=new this(e,t);i.enter(),await s(),i.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){let t=this.getPlaceholderById(e.id);t?.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(r){let e=document.createElement("meta");return e.setAttribute("name","turbo-permanent-placeholder"),e.setAttribute("content",r.id),e}var j=class{constructor(e,t,s,i,n=!0){this.activeElement=null,this.currentSnapshot=e,this.newSnapshot=t,this.isPreview=i,this.willRender=n,this.renderElement=s,this.promise=new Promise((o,a)=>this.resolvingFunctions={resolve:o,reject:a})}get shouldRender(){return!0}get reloadReason(){}prepareToRender(){}finishRendering(){this.resolvingFunctions&&(this.resolvingFunctions.resolve(),delete this.resolvingFunctions)}async preservingPermanentElements(e){await ge.preservingPermanentElements(this,this.permanentElementMap,e)}focusFirstAutofocusableElement(){let e=this.connectedSnapshot.firstAutofocusableElement;ur(e)&&e.focus()}enteringBardo(e){this.activeElement||e.contains(this.currentSnapshot.activeElement)&&(this.activeElement=this.currentSnapshot.activeElement)}leavingBardo(e){e.contains(this.activeElement)&&this.activeElement instanceof HTMLElement&&(this.activeElement.focus(),this.activeElement=null)}get connectedSnapshot(){return this.newSnapshot.isConnected?this.newSnapshot:this.currentSnapshot}get currentElement(){return this.currentSnapshot.element}get newElement(){return this.newSnapshot.element}get permanentElementMap(){return this.currentSnapshot.getPermanentElementMapForSnapshot(this.newSnapshot)}};function ur(r){return r&&typeof r.focus=="function"}var W=class extends j{static renderElement(e,t){var s;let i=document.createRange();i.selectNodeContents(e),i.deleteContents();let n=t,o=(s=n.ownerDocument)===null||s===void 0?void 0:s.createRange();o&&(o.selectNodeContents(n),e.appendChild(o.extractContents()))}constructor(e,t,s,i,n,o=!0){super(t,s,i,n,o),this.delegate=e}get shouldRender(){return!0}async render(){await ce(),this.preservingPermanentElements(()=>{this.loadFrameElement()}),this.scrollFrameIntoView(),await ce(),this.focusFirstAutofocusableElement(),await ce(),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=dr(this.currentElement.getAttribute("data-autoscroll-block"),"end"),s=mr(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=V(e);e.replaceWith(t)}}get newScriptElements(){return this.currentElement.querySelectorAll("script")}};function dr(r,e){return r=="end"||r=="start"||r=="center"||r=="nearest"?r:e}function mr(r,e){return r=="auto"||r=="smooth"?r:e}var ve=class r{static get defaultCSS(){return Xt`
|
4
|
+
.turbo-progress-bar {
|
5
|
+
position: fixed;
|
6
|
+
display: block;
|
7
|
+
top: 0;
|
8
|
+
left: 0;
|
9
|
+
height: 3px;
|
10
|
+
background: #0076ff;
|
11
|
+
z-index: 2147483647;
|
12
|
+
transition:
|
13
|
+
width ${r.animationDuration}ms ease-out,
|
14
|
+
opacity ${r.animationDuration/2}ms ${r.animationDuration/2}ms ease-in;
|
15
|
+
transform: translate3d(0, 0, 0);
|
16
|
+
}
|
17
|
+
`}constructor(){this.hiding=!1,this.value=0,this.visible=!1,this.trickle=()=>{this.setValue(this.value+Math.random()/100)},this.stylesheetElement=this.createStylesheetElement(),this.progressElement=this.createProgressElement(),this.installStylesheetElement(),this.setValue(0)}show(){this.visible||(this.visible=!0,this.installProgressElement(),this.startTrickling())}hide(){this.visible&&!this.hiding&&(this.hiding=!0,this.fadeProgressElement(()=>{this.uninstallProgressElement(),this.stopTrickling(),this.visible=!1,this.hiding=!1}))}setValue(e){this.value=e,this.refresh()}installStylesheetElement(){document.head.insertBefore(this.stylesheetElement,document.head.firstChild)}installProgressElement(){this.progressElement.style.width="0",this.progressElement.style.opacity="1",document.documentElement.insertBefore(this.progressElement,document.body),this.refresh()}fadeProgressElement(e){this.progressElement.style.opacity="0",setTimeout(e,r.animationDuration*1.5)}uninstallProgressElement(){this.progressElement.parentNode&&document.documentElement.removeChild(this.progressElement)}startTrickling(){this.trickleInterval||(this.trickleInterval=window.setInterval(this.trickle,r.animationDuration))}stopTrickling(){window.clearInterval(this.trickleInterval),delete this.trickleInterval}refresh(){requestAnimationFrame(()=>{this.progressElement.style.width=`${10+this.value*90}%`})}createStylesheetElement(){let e=document.createElement("style");return e.type="text/css",e.textContent=r.defaultCSS,this.cspNonce&&(e.nonce=this.cspNonce),e}createProgressElement(){let e=document.createElement("div");return e.className="turbo-progress-bar",e}get cspNonce(){return he("csp-nonce")}};ve.animationDuration=300;var $e=class extends N{constructor(){super(...arguments),this.detailsByOuterHTML=this.children.filter(e=>!vr(e)).map(e=>wr(e)).reduce((e,t)=>{let{outerHTML:s}=t,i=s in e?e[s]:{type:pr(t),tracked:fr(t),elements:[]};return Object.assign(Object.assign({},e),{[s]:Object.assign(Object.assign({},i),{elements:[...i.elements,t]})})},{})}get trackedElementSignature(){return Object.keys(this.detailsByOuterHTML).filter(e=>this.detailsByOuterHTML[e].tracked).join("")}getScriptElementsNotInSnapshot(e){return this.getElementsMatchingTypeNotInSnapshot("script",e)}getStylesheetElementsNotInSnapshot(e){return this.getElementsMatchingTypeNotInSnapshot("stylesheet",e)}getElementsMatchingTypeNotInSnapshot(e,t){return Object.keys(this.detailsByOuterHTML).filter(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:i,elements:n}=this.detailsByOuterHTML[t];return s==null&&!i?[...e,...n]:n.length>1?[...e,...n.slice(1)]: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:[i]}=this.detailsByOuterHTML[s];return yr(i,e)?i:t},void 0)}};function pr(r){if(gr(r))return"script";if(br(r))return"stylesheet"}function fr(r){return r.getAttribute("data-turbo-track")=="reload"}function gr(r){return r.localName=="script"}function vr(r){return r.localName=="noscript"}function br(r){let e=r.localName;return e=="style"||e=="link"&&r.getAttribute("rel")=="stylesheet"}function yr(r,e){return r.localName=="meta"&&r.getAttribute("name")==e}function wr(r){return r.hasAttribute("nonce")&&r.setAttribute("nonce",""),r}var g=class r extends N{static fromHTMLString(e=""){return this.fromDocument(Gt(e))}static fromElement(e){return this.fromDocument(e.ownerDocument)}static fromDocument({head:e,body:t}){return new this(t,new $e(e))}constructor(e,t){super(e),this.headSnapshot=t}clone(){let e=this.element.cloneNode(!0),t=this.element.querySelectorAll("select"),s=e.querySelectorAll("select");for(let[i,n]of t.entries()){let o=s[i];for(let a of o.selectedOptions)a.selected=!1;for(let a of n.selectedOptions)o.options[a.index].selected=!0}for(let i of e.querySelectorAll('input[type="password"]'))i.value="";return new r(e,this.headSnapshot)}get headElement(){return this.headSnapshot.element}get rootLocation(){var e;let t=(e=this.getSetting("root"))!==null&&e!==void 0?e:"/";return d(t)}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"}getSetting(e){return this.headSnapshot.getMetaValue(`turbo-${e}`)}},B;(function(r){r.visitStart="visitStart",r.requestStart="requestStart",r.requestEnd="requestEnd",r.visitEnd="visitEnd"})(B||(B={}));var f;(function(r){r.initialized="initialized",r.started="started",r.canceled="canceled",r.failed="failed",r.completed="completed"})(f||(f={}));var Er={action:"advance",historyChanged:!1,visitCachedSnapshot:()=>{},willRender:!0,updateHistory:!0,shouldCacheSnapshot:!0,acceptsStreamResponse:!1},k;(function(r){r[r.networkFailure=0]="networkFailure",r[r.timeoutFailure=-1]="timeoutFailure",r[r.contentTypeMismatch=-2]="contentTypeMismatch"})(k||(k={}));var _e=class{constructor(e,t,s,i={}){this.identifier=x(),this.timingMetrics={},this.followedRedirect=!1,this.historyChanged=!1,this.scrolled=!1,this.shouldCacheSnapshot=!0,this.acceptsStreamResponse=!1,this.snapshotCached=!1,this.state=f.initialized,this.delegate=e,this.location=t,this.restorationIdentifier=s||x();let{action:n,historyChanged:o,referrer:a,snapshot:l,snapshotHTML:m,response:M,visitCachedSnapshot:A,willRender:oe,updateHistory:Ms,shouldCacheSnapshot:Fs,acceptsStreamResponse:Rs}=Object.assign(Object.assign({},Er),i);this.action=n,this.historyChanged=o,this.referrer=a,this.snapshot=l,this.snapshotHTML=m,this.response=M,this.isSamePage=this.delegate.locationWithActionIsSamePage(this.location,this.action),this.visitCachedSnapshot=A,this.willRender=oe,this.updateHistory=Ms,this.scrolled=!oe,this.shouldCacheSnapshot=Fs,this.acceptsStreamResponse=Rs}get adapter(){return this.delegate.adapter}get view(){return this.delegate.view}get history(){return this.delegate.history}get restorationData(){return this.history.getRestorationDataForIdentifier(this.restorationIdentifier)}get silent(){return this.isSamePage}start(){this.state==f.initialized&&(this.recordTimingMetric(B.visitStart),this.state=f.started,this.adapter.visitStarted(this),this.delegate.visitStarted(this))}cancel(){this.state==f.started&&(this.request&&this.request.cancel(),this.cancelRender(),this.state=f.canceled)}complete(){this.state==f.started&&(this.recordTimingMetric(B.visitEnd),this.state=f.completed,this.followRedirect(),this.followedRedirect||(this.adapter.visitCompleted(this),this.delegate.visitCompleted(this)))}fail(){this.state==f.started&&(this.state=f.failed,this.adapter.visitFailed(this))}changeHistory(){var e;if(!this.historyChanged&&this.updateHistory){let t=this.location.href===((e=this.referrer)===null||e===void 0?void 0:e.href)?"replace":this.action,s=Qt(t);this.history.update(s,this.location,this.restorationIdentifier),this.historyChanged=!0}}issueRequest(){this.hasPreloadedResponse()?this.simulateRequest():this.shouldIssueRequest()&&!this.request&&(this.request=new $(this,p.get,this.location),this.request.perform())}simulateRequest(){this.response&&(this.startRequest(),this.recordResponse(),this.finishRequest())}startRequest(){this.recordTimingMetric(B.requestStart),this.adapter.visitRequestStarted(this)}recordResponse(e=this.response){if(this.response=e,e){let{statusCode:t}=e;jt(t)?this.adapter.visitRequestCompleted(this):this.adapter.visitRequestFailedWithStatusCode(this,t)}}finishRequest(){this.recordTimingMetric(B.requestEnd),this.adapter.visitRequestFinished(this)}loadResponse(){if(this.response){let{statusCode:e,responseHTML:t}=this.response;this.render(async()=>{this.shouldCacheSnapshot&&this.cacheSnapshot(),this.view.renderPromise&&await this.view.renderPromise,jt(e)&&t!=null?(await this.view.renderPage(g.fromHTMLString(t),!1,this.willRender,this),this.performScroll(),this.adapter.visitRendered(this),this.complete()):(await this.view.renderError(g.fromHTMLString(t),this),this.adapter.visitRendered(this),this.fail())})}}getCachedSnapshot(){let e=this.view.getCachedSnapshotForLocation(this.location)||this.getPreloadedSnapshot();if(e&&(!F(this.location)||e.hasAnchor(F(this.location)))&&(this.action=="restore"||e.isPreviewable))return e}getPreloadedSnapshot(){if(this.snapshotHTML)return g.fromHTMLString(this.snapshotHTML)}hasCachedSnapshot(){return this.getCachedSnapshot()!=null}loadCachedSnapshot(){let e=this.getCachedSnapshot();if(e){let t=this.shouldIssueRequest();this.render(async()=>{this.cacheSnapshot(),this.isSamePage?this.adapter.visitRendered(this):(this.view.renderPromise&&await this.view.renderPromise,await this.view.renderPage(e,t,this.willRender,this),this.performScroll(),this.adapter.visitRendered(this),t||this.complete())})}}followRedirect(){var e;this.redirectedToLocation&&!this.followedRedirect&&(!((e=this.response)===null||e===void 0)&&e.redirected)&&(this.adapter.visitProposedToLocation(this.redirectedToLocation,{action:"replace",response:this.response,shouldCacheSnapshot:!1,willRender:!1}),this.followedRedirect=!0)}goToSamePageAnchor(){this.isSamePage&&this.render(async()=>{this.cacheSnapshot(),this.performScroll(),this.changeHistory(),this.adapter.visitRendered(this)})}prepareRequest(e){this.acceptsStreamResponse&&e.acceptResponseType(E.contentType)}requestStarted(){this.startRequest()}requestPreventedHandlingResponse(e,t){}async requestSucceededWithResponse(e,t){let s=await t.responseHTML,{redirected:i,statusCode:n}=t;s==null?this.recordResponse({statusCode:k.contentTypeMismatch,redirected:i}):(this.redirectedToLocation=t.redirected?t.location:void 0,this.recordResponse({statusCode:n,responseHTML:s,redirected:i}))}async requestFailedWithResponse(e,t){let s=await t.responseHTML,{redirected:i,statusCode:n}=t;s==null?this.recordResponse({statusCode:k.contentTypeMismatch,redirected:i}):this.recordResponse({statusCode:n,responseHTML:s,redirected:i})}requestErrored(e,t){this.recordResponse({statusCode:k.networkFailure,redirected:!1})}requestFinished(){this.finishRequest()}performScroll(){!this.scrolled&&!this.view.forceReloaded&&(this.action=="restore"?this.scrollToRestoredPosition()||this.scrollToAnchor()||this.view.scrollToTop():this.scrollToAnchor()||this.view.scrollToTop(),this.isSamePage&&this.delegate.visitScrolledToSamePageLocation(this.view.lastRenderedLocation,this.location),this.scrolled=!0)}scrollToRestoredPosition(){let{scrollPosition:e}=this.restorationData;if(e)return this.view.scrollToPosition(e),!0}scrollToAnchor(){let e=F(this.location);if(e!=null)return this.view.scrollToAnchor(e),!0}recordTimingMetric(e){this.timingMetrics[e]=new Date().getTime()}getTimingMetrics(){return Object.assign({},this.timingMetrics)}getHistoryMethodForAction(e){switch(e){case"replace":return history.replaceState;case"advance":case"restore":return history.pushState}}hasPreloadedResponse(){return typeof this.response=="object"}shouldIssueRequest(){return this.isSamePage?!1:this.action=="restore"?!this.hasCachedSnapshot():this.willRender}cacheSnapshot(){this.snapshotCached||(this.view.cacheSnapshot(this.snapshot).then(e=>e&&this.visitCachedSnapshot(e)),this.snapshotCached=!0)}async render(e){this.cancelRender(),await new Promise(t=>{this.frame=requestAnimationFrame(()=>t())}),await e(),delete this.frame}cancelRender(){this.frame&&(cancelAnimationFrame(this.frame),delete this.frame)}};function jt(r){return r>=200&&r<300}var Ue=class{constructor(e){this.progressBar=new ve,this.showProgressBar=()=>{this.progressBar.show()},this.session=e}visitProposedToLocation(e,t){this.navigator.startVisit(e,t?.restorationIdentifier||x(),t)}visitStarted(e){this.location=e.location,e.loadCachedSnapshot(),e.issueRequest(),e.goToSamePageAnchor()}visitRequestStarted(e){this.progressBar.setValue(0),e.hasCachedSnapshot()||e.action!="restore"?this.showVisitProgressBarAfterDelay():this.showProgressBar()}visitRequestCompleted(e){e.loadResponse()}visitRequestFailedWithStatusCode(e,t){switch(t){case k.networkFailure:case k.timeoutFailure:case k.contentTypeMismatch:return this.reload({reason:"request_failed",context:{statusCode:t}});default:return e.loadResponse()}}visitRequestFinished(e){this.progressBar.setValue(1),this.hideVisitProgressBar()}visitCompleted(e){}pageInvalidated(e){this.reload(e)}visitFailed(e){}visitRendered(e){}formSubmissionStarted(e){this.progressBar.setValue(0),this.showFormProgressBarAfterDelay()}formSubmissionFinished(e){this.progressBar.setValue(1),this.hideFormProgressBar()}showVisitProgressBarAfterDelay(){this.visitProgressBarTimeout=window.setTimeout(this.showProgressBar,this.session.progressBarDelay)}hideVisitProgressBar(){this.progressBar.hide(),this.visitProgressBarTimeout!=null&&(window.clearTimeout(this.visitProgressBarTimeout),delete this.visitProgressBarTimeout)}showFormProgressBarAfterDelay(){this.formProgressBarTimeout==null&&(this.formProgressBarTimeout=window.setTimeout(this.showProgressBar,this.session.progressBarDelay))}hideFormProgressBar(){this.progressBar.hide(),this.formProgressBarTimeout!=null&&(window.clearTimeout(this.formProgressBarTimeout),delete this.formProgressBarTimeout)}reload(e){var t;u("turbo:reload",{detail:e}),window.location.href=((t=this.location)===null||t===void 0?void 0:t.toString())||window.location.href}get navigator(){return this.session.navigator}},je=class{constructor(){this.selector="[data-turbo-temporary]",this.deprecatedSelector="[data-turbo-cache=false]",this.started=!1,this.removeTemporaryElements=e=>{for(let t of this.temporaryElements)t.remove()}}start(){this.started||(this.started=!0,addEventListener("turbo:before-cache",this.removeTemporaryElements,!1))}stop(){this.started&&(this.started=!1,removeEventListener("turbo:before-cache",this.removeTemporaryElements,!1))}get temporaryElements(){return[...document.querySelectorAll(this.selector),...this.temporaryElementsWithDeprecation]}get temporaryElementsWithDeprecation(){let e=document.querySelectorAll(this.deprecatedSelector);return e.length&&console.warn(`The ${this.deprecatedSelector} selector is deprecated and will be removed in a future version. Use ${this.selector} instead.`),[...e]}},We=class{constructor(e,t){this.session=e,this.element=t,this.linkInterceptor=new me(this,t),this.formSubmitObserver=new U(this,t)}start(){this.linkInterceptor.start(),this.formSubmitObserver.start()}stop(){this.linkInterceptor.stop(),this.formSubmitObserver.stop()}shouldInterceptLinkClick(e,t,s){return this.shouldRedirect(e)}linkClickIntercepted(e,t,s){let i=this.findFrameElement(e);i&&i.delegate.linkClickIntercepted(e,t,s)}willSubmitForm(e,t){return e.closest("turbo-frame")==null&&this.shouldSubmit(e,t)&&this.shouldRedirect(e,t)}formSubmitted(e,t){let s=this.findFrameElement(e,t);s&&s.delegate.formSubmitted(e,t)}shouldSubmit(e,t){var s;let i=at(e,t),n=this.element.ownerDocument.querySelector('meta[name="turbo-root"]'),o=d((s=n?.content)!==null&&s!==void 0?s:"/");return this.shouldRedirect(e,t)&&I(i,o)}shouldRedirect(e,t){if(e instanceof HTMLFormElement?this.session.submissionIsNavigatable(e,t):this.session.elementIsNavigatable(e)){let i=this.findFrameElement(e,t);return i?i!=e.closest("turbo-frame"):!1}else return!1}findFrameElement(e,t){let s=t?.getAttribute("data-turbo-frame")||e.getAttribute("data-turbo-frame");if(s&&s!="_top"){let i=this.element.querySelector(`#${s}:not([disabled])`);if(i instanceof w)return i}}},Ke=class{constructor(e){this.restorationIdentifier=x(),this.restorationData={},this.started=!1,this.pageLoaded=!1,this.onPopState=t=>{if(this.shouldHandlePopState()){let{turbo:s}=t.state||{};if(s){this.location=new URL(window.location.href);let{restorationIdentifier:i}=s;this.restorationIdentifier=i,this.delegate.historyPoppedToLocationWithRestorationIdentifier(this.location,i)}}},this.onPageLoad=async t=>{await Js(),this.pageLoaded=!0},this.delegate=e}start(){this.started||(addEventListener("popstate",this.onPopState,!1),addEventListener("load",this.onPageLoad,!1),this.started=!0,this.replace(new URL(window.location.href)))}stop(){this.started&&(removeEventListener("popstate",this.onPopState,!1),removeEventListener("load",this.onPageLoad,!1),this.started=!1)}push(e,t){this.update(history.pushState,e,t)}replace(e,t){this.update(history.replaceState,e,t)}update(e,t,s=x()){let i={turbo:{restorationIdentifier:s}};e.call(history,i,"",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]=Object.assign(Object.assign({},s),e)}assumeControlOfScrollRestoration(){var e;this.previousScrollRestoration||(this.previousScrollRestoration=(e=history.scrollRestoration)!==null&&e!==void 0?e:"auto",history.scrollRestoration="manual")}relinquishControlOfScrollRestoration(){this.previousScrollRestoration&&(history.scrollRestoration=this.previousScrollRestoration,delete this.previousScrollRestoration)}shouldHandlePopState(){return this.pageIsLoaded()}pageIsLoaded(){return this.pageLoaded||document.readyState=="complete"}},ze=class{constructor(e){this.delegate=e}proposeVisit(e,t={}){this.delegate.allowsVisitingLocationWithAction(e,t.action)&&(I(e,this.view.snapshot.rootLocation)?this.delegate.visitProposedToLocation(e,t):window.location.href=e.toString())}startVisit(e,t,s={}){this.stop(),this.currentVisit=new _e(this,d(e),t,Object.assign({referrer:this.location},s)),this.currentVisit.start()}submitForm(e,t){this.stop(),this.formSubmission=new _(this,e,t,!0),this.formSubmission.start()}stop(){this.formSubmission&&(this.formSubmission.stop(),delete this.formSubmission),this.currentVisit&&(this.currentVisit.cancel(),delete this.currentVisit)}get adapter(){return this.delegate.adapter}get view(){return this.delegate.view}get history(){return this.delegate.history}formSubmissionStarted(e){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 i=e.isSafe;i||this.view.clearSnapshotCache();let{statusCode:n,redirected:o}=t,l={action:this.getActionForFormSubmission(e),shouldCacheSnapshot:i,response:{statusCode:n,responseHTML:s,redirected:o}};this.proposeVisit(t.location,l)}}}async formSubmissionFailedWithResponse(e,t){let s=await t.responseHTML;if(s){let i=g.fromHTMLString(s);t.serverError?await this.view.renderError(i,this.currentVisit):await this.view.renderPage(i,!1,!0,this.currentVisit),this.view.scrollToTop(),this.view.clearSnapshotCache()}}formSubmissionErrored(e,t){console.error(t)}formSubmissionFinished(e){typeof this.adapter.formSubmissionFinished=="function"&&this.adapter.formSubmissionFinished(e)}visitStarted(e){this.delegate.visitStarted(e)}visitCompleted(e){this.delegate.visitCompleted(e)}locationWithActionIsSamePage(e,t){let s=F(e),i=F(this.view.lastRenderedLocation),n=t==="restore"&&typeof s>"u";return t!=="replace"&&Ne(e)===Ne(this.view.lastRenderedLocation)&&(n||s!=null&&s!==i)}visitScrolledToSamePageLocation(e,t){this.delegate.visitScrolledToSamePageLocation(e,t)}get location(){return this.history.location}get restorationIdentifier(){return this.history.restorationIdentifier}getActionForFormSubmission({submitter:e,formElement:t}){return ye(e,t)||"advance"}},y;(function(r){r[r.initial=0]="initial",r[r.loading=1]="loading",r[r.interactive=2]="interactive",r[r.complete=3]="complete"})(y||(y={}));var Je=class{constructor(e){this.stage=y.initial,this.started=!1,this.interpretReadyState=()=>{let{readyState:t}=this;t=="interactive"?this.pageIsInteractive():t=="complete"&&this.pageIsComplete()},this.pageWillUnload=()=>{this.delegate.pageWillUnload()},this.delegate=e}start(){this.started||(this.stage==y.initial&&(this.stage=y.loading),document.addEventListener("readystatechange",this.interpretReadyState,!1),addEventListener("pagehide",this.pageWillUnload,!1),this.started=!0)}stop(){this.started&&(document.removeEventListener("readystatechange",this.interpretReadyState,!1),removeEventListener("pagehide",this.pageWillUnload,!1),this.started=!1)}pageIsInteractive(){this.stage==y.loading&&(this.stage=y.interactive,this.delegate.pageBecameInteractive())}pageIsComplete(){this.pageIsInteractive(),this.stage==y.interactive&&(this.stage=y.complete,this.delegate.pageLoaded())}get readyState(){return document.readyState}},Ge=class{constructor(e){this.started=!1,this.onScroll=()=>{this.updatePosition({x:window.pageXOffset,y:window.pageYOffset})},this.delegate=e}start(){this.started||(addEventListener("scroll",this.onScroll,!1),this.onScroll(),this.started=!0)}stop(){this.started&&(removeEventListener("scroll",this.onScroll,!1),this.started=!1)}updatePosition(e){this.delegate.scrollPositionChanged(e)}},Xe=class{render({fragment:e}){ge.preservingPermanentElements(this,Sr(e),()=>document.documentElement.appendChild(e))}enteringBardo(e,t){t.replaceWith(e.cloneNode(!0))}leavingBardo(){}};function Sr(r){let e=es(document.documentElement),t={};for(let s of e){let{id:i}=s;for(let n of r.querySelectorAll("turbo-stream")){let o=Zt(n.templateElement.content,i);o&&(t[i]=[s,o])}}return t}var Qe=class{constructor(e){this.sources=new Set,this.started=!1,this.inspectFetchResponse=t=>{let s=Ar(t);s&&Tr(s)&&(t.preventDefault(),this.receiveMessageResponse(s))},this.receiveMessageEvent=t=>{this.started&&typeof t.data=="string"&&this.receiveMessageHTML(t.data)},this.delegate=e}start(){this.started||(this.started=!0,addEventListener("turbo:before-fetch-response",this.inspectFetchResponse,!1))}stop(){this.started&&(this.started=!1,removeEventListener("turbo:before-fetch-response",this.inspectFetchResponse,!1))}connectStreamSource(e){this.streamSourceIsConnected(e)||(this.sources.add(e),e.addEventListener("message",this.receiveMessageEvent,!1))}disconnectStreamSource(e){this.streamSourceIsConnected(e)&&(this.sources.delete(e),e.removeEventListener("message",this.receiveMessageEvent,!1))}streamSourceIsConnected(e){return this.sources.has(e)}async receiveMessageResponse(e){let t=await e.responseHTML;t&&this.receiveMessageHTML(t)}receiveMessageHTML(e){this.delegate.receivedMessageFromStream(E.wrap(e))}};function Ar(r){var e;let t=(e=r.detail)===null||e===void 0?void 0:e.fetchResponse;if(t instanceof H)return t}function Tr(r){var e;return((e=r.contentType)!==null&&e!==void 0?e:"").startsWith(E.contentType)}var be=class extends j{static renderElement(e,t){let{documentElement:s,body:i}=document;s.replaceChild(t,i)}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=V(e);t.replaceChild(s,e)}}}get newHead(){return this.newSnapshot.headSnapshot.element}get scriptElements(){return document.documentElement.querySelectorAll("script")}},K=class extends j{static renderElement(e,t){document.body&&t instanceof HTMLBodyElement?document.body.replaceWith(t):document.documentElement.appendChild(t)}get shouldRender(){return this.newSnapshot.isVisitable&&this.trackedElementsAreIdentical}get reloadReason(){if(!this.newSnapshot.isVisitable)return{reason:"turbo_visit_control_is_reload"};if(!this.trackedElementsAreIdentical)return{reason:"tracked_element_mismatch"}}async prepareToRender(){await this.mergeHead()}async render(){this.willRender&&await this.replaceBody()}finishRendering(){super.finishRendering(),this.isPreview||this.focusFirstAutofocusableElement()}get currentHeadSnapshot(){return this.currentSnapshot.headSnapshot}get newHeadSnapshot(){return this.newSnapshot.headSnapshot}get newElement(){return this.newSnapshot.element}async mergeHead(){let e=this.mergeProvisionalElements(),t=this.copyNewHeadStylesheetElements();this.copyNewHeadScriptElements(),await e,await t}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(Qs(t)),document.head.appendChild(t);await Promise.all(e)}copyNewHeadScriptElements(){for(let e of this.newHeadScriptElements)document.head.appendChild(V(e))}async mergeProvisionalElements(){let e=[...this.newHeadProvisionalElements];for(let t of this.currentHeadProvisionalElements)this.isCurrentElementInElementList(t,e)||document.head.removeChild(t);for(let t of e)document.head.appendChild(t)}isCurrentElementInElementList(e,t){for(let[s,i]of t.entries()){if(e.tagName=="TITLE"){if(i.tagName!="TITLE")continue;if(e.innerHTML==i.innerHTML)return t.splice(s,1),!0}if(i.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.activateNewBodyScriptElements()}activateNewBodyScriptElements(){for(let e of this.newBodyScriptElements){let t=V(e);e.replaceWith(t)}}async assignNewBody(){await this.renderElement(this.currentElement,this.newElement)}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")}},Ye=class{constructor(e){this.keys=[],this.snapshots={},this.size=e}has(e){return ae(e)in this.snapshots}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(){this.snapshots={}}read(e){return this.snapshots[ae(e)]}write(e,t){this.snapshots[ae(e)]=t}touch(e){let t=ae(e),s=this.keys.indexOf(t);s>-1&&this.keys.splice(s,1),this.keys.unshift(t),this.trim()}trim(){for(let e of this.keys.splice(this.size))delete this.snapshots[e]}},Ze=class extends de{constructor(){super(...arguments),this.snapshotCache=new Ye(10),this.lastRenderedLocation=new URL(location.href),this.forceReloaded=!1}renderPage(e,t=!1,s=!0,i){let n=new K(this.snapshot,e,K.renderElement,t,s);return n.shouldRender?i?.changeHistory():this.forceReloaded=!0,this.render(n)}renderError(e,t){t?.changeHistory();let s=new be(this.snapshot,e,be.renderElement,!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 zs();let s=e.clone();return this.snapshotCache.put(t,s),s}}getCachedSnapshotForLocation(e){return this.snapshotCache.get(e)}get snapshot(){return g.fromElement(this.element)}},et=class{constructor(e){this.selector="a[data-turbo-preload]",this.delegate=e}get snapshotCache(){return this.delegate.navigator.view.snapshotCache}start(){if(document.readyState==="loading")return document.addEventListener("DOMContentLoaded",()=>{this.preloadOnLoadLinksForView(document.body)});this.preloadOnLoadLinksForView(document.body)}preloadOnLoadLinksForView(e){for(let t of e.querySelectorAll(this.selector))this.preloadURL(t)}async preloadURL(e){let t=new URL(e.href);if(!this.snapshotCache.has(t))try{let i=await(await fetch(t.toString(),{headers:{"VND.PREFETCH":"true",Accept:"text/html"}})).text(),n=g.fromHTMLString(i);this.snapshotCache.put(t,n)}catch{}}},tt=class{constructor(){this.navigator=new ze(this),this.history=new Ke(this),this.preloader=new et(this),this.view=new Ze(this,document.documentElement),this.adapter=new Ue(this),this.pageObserver=new Je(this),this.cacheObserver=new je,this.linkClickObserver=new pe(this,window),this.formSubmitObserver=new U(this,document),this.scrollObserver=new Ge(this),this.streamObserver=new Qe(this),this.formLinkClickObserver=new fe(this,document.documentElement),this.frameRedirector=new We(this,document.documentElement),this.streamMessageRenderer=new Xe,this.drive=!0,this.enabled=!0,this.progressBarDelay=500,this.started=!1,this.formMode="on"}start(){this.started||(this.pageObserver.start(),this.cacheObserver.start(),this.formLinkClickObserver.start(),this.linkClickObserver.start(),this.formSubmitObserver.start(),this.scrollObserver.start(),this.streamObserver.start(),this.frameRedirector.start(),this.history.start(),this.preloader.start(),this.started=!0,this.enabled=!0)}disable(){this.enabled=!1}stop(){this.started&&(this.pageObserver.stop(),this.cacheObserver.stop(),this.formLinkClickObserver.stop(),this.linkClickObserver.stop(),this.formSubmitObserver.stop(),this.scrollObserver.stop(),this.streamObserver.stop(),this.frameRedirector.stop(),this.history.stop(),this.started=!1)}registerAdapter(e){this.adapter=e}visit(e,t={}){let s=t.frame?document.getElementById(t.frame):null;s instanceof w?(s.src=e.toString(),s.loaded):this.navigator.proposeVisit(d(e),t)}connectStreamSource(e){this.streamObserver.connectStreamSource(e)}disconnectStreamSource(e){this.streamObserver.disconnectStreamSource(e)}renderStreamMessage(e){this.streamMessageRenderer.render(E.wrap(e))}clearCache(){this.view.clearSnapshotCache()}setProgressBarDelay(e){this.progressBarDelay=e}setFormMode(e){this.formMode=e}get location(){return this.history.location}get restorationIdentifier(){return this.history.restorationIdentifier}historyPoppedToLocationWithRestorationIdentifier(e,t){this.enabled?this.navigator.startVisit(e,t,{action:"restore",historyChanged:!0}):this.adapter.pageInvalidated({reason:"turbo_disabled"})}scrollPositionChanged(e){this.history.updateRestorationData({scrollPosition:e})}willSubmitFormLinkToLocation(e,t){return this.elementIsNavigatable(e)&&I(t,this.snapshot.rootLocation)}submittedFormLinkToLocation(){}willFollowLinkToLocation(e,t,s){return this.elementIsNavigatable(e)&&I(t,this.snapshot.rootLocation)&&this.applicationAllowsFollowingLinkToLocation(e,t,s)}followedLinkToLocation(e,t){let s=this.getActionForLink(e),i=e.hasAttribute("data-turbo-stream");this.visit(t.href,{action:s,acceptsStreamResponse:i})}allowsVisitingLocationWithAction(e,t){return this.locationWithActionIsSamePage(e,t)||this.applicationAllowsVisitingLocation(e)}visitProposedToLocation(e,t){Wt(e),this.adapter.visitProposedToLocation(e,t)}visitStarted(e){e.acceptsStreamResponse||De(document.documentElement),Wt(e.location),e.silent||this.notifyApplicationAfterVisitingLocation(e.location,e.action)}visitCompleted(e){qe(document.documentElement),this.notifyApplicationAfterPageLoad(e.getTimingMetrics())}locationWithActionIsSamePage(e,t){return this.navigator.locationWithActionIsSamePage(e,t)}visitScrolledToSamePageLocation(e,t){this.notifyApplicationAfterVisitingSamePageLocation(e,t)}willSubmitForm(e,t){let s=at(e,t);return this.submissionIsNavigatable(e,t)&&I(d(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(){var e;!((e=this.navigator.currentVisit)===null||e===void 0)&&e.silent||this.notifyApplicationBeforeCachingSnapshot()}allowsImmediateRender({element:e},t){let s=this.notifyApplicationBeforeRender(e,t),{defaultPrevented:i,detail:{render:n}}=s;return this.view.renderer&&n&&(this.view.renderer.renderElement=n),!i}viewRenderedSnapshot(e,t){this.view.lastRenderedLocation=this.history.location,this.notifyApplicationAfterRender()}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 u("turbo:click",{target:e,detail:{url:t.href,originalEvent:s},cancelable:!0})}notifyApplicationBeforeVisitingLocation(e){return u("turbo:before-visit",{detail:{url:e.href},cancelable:!0})}notifyApplicationAfterVisitingLocation(e,t){return u("turbo:visit",{detail:{url:e.href,action:t}})}notifyApplicationBeforeCachingSnapshot(){return u("turbo:before-cache")}notifyApplicationBeforeRender(e,t){return u("turbo:before-render",{detail:Object.assign({newBody:e},t),cancelable:!0})}notifyApplicationAfterRender(){return u("turbo:render")}notifyApplicationAfterPageLoad(e={}){return u("turbo:load",{detail:{url:this.location.href,timing:e}})}notifyApplicationAfterVisitingSamePageLocation(e,t){dispatchEvent(new HashChangeEvent("hashchange",{oldURL:e.toString(),newURL:t.toString()}))}notifyApplicationAfterFrameLoad(e){return u("turbo:frame-load",{target:e})}notifyApplicationAfterFrameRender(e,t){return u("turbo:frame-render",{detail:{fetchResponse:e},target:t,cancelable:!0})}submissionIsNavigatable(e,t){if(this.formMode=="off")return!1;{let s=t?this.elementIsNavigatable(t):!0;return this.formMode=="optin"?s&&e.closest('[data-turbo="true"]')!=null:s&&this.elementIsNavigatable(e)}}elementIsNavigatable(e){let t=ue(e,"[data-turbo]"),s=ue(e,"turbo-frame");return this.drive||s?t?t.getAttribute("data-turbo")!="false":!0:t?t.getAttribute("data-turbo")=="true":!1}getActionForLink(e){return ye(e)||"advance"}get snapshot(){return this.view.snapshot}};function Wt(r){Object.defineProperties(r,Cr)}var Cr={absoluteURL:{get(){return this.toString()}}},st=class{constructor(e){this.session=e}clear(){this.session.clearCache()}resetCacheControl(){this.setCacheControl("")}exemptPageFromCache(){this.setCacheControl("no-cache")}exemptPageFromPreview(){this.setCacheControl("no-preview")}setCacheControl(e){Zs("turbo-cache-control",e)}},ts={after(){this.targetElements.forEach(r=>{var e;return(e=r.parentElement)===null||e===void 0?void 0:e.insertBefore(this.templateContent,r.nextSibling)})},append(){this.removeDuplicateTargetChildren(),this.targetElements.forEach(r=>r.append(this.templateContent))},before(){this.targetElements.forEach(r=>{var e;return(e=r.parentElement)===null||e===void 0?void 0:e.insertBefore(this.templateContent,r)})},prepend(){this.removeDuplicateTargetChildren(),this.targetElements.forEach(r=>r.prepend(this.templateContent))},remove(){this.targetElements.forEach(r=>r.remove())},replace(){this.targetElements.forEach(r=>r.replaceWith(this.templateContent))},update(){this.targetElements.forEach(r=>{r.innerHTML="",r.append(this.templateContent)})}},h=new tt,Lr=new st(h),{navigator:kr}=h;function ss(){h.start()}function Or(r){h.registerAdapter(r)}function Mr(r,e){h.visit(r,e)}function we(r){h.connectStreamSource(r)}function Ee(r){h.disconnectStreamSource(r)}function Fr(r){h.renderStreamMessage(r)}function Rr(){console.warn("Please replace `Turbo.clearCache()` with `Turbo.cache.clear()`. The top-level function is deprecated and will be removed in a future version of Turbo.`"),h.clearCache()}function Pr(r){h.setProgressBarDelay(r)}function Br(r){_.confirmMethod=r}function Ir(r){h.setFormMode(r)}var xr=Object.freeze({__proto__:null,navigator:kr,session:h,cache:Lr,PageRenderer:K,PageSnapshot:g,FrameRenderer:W,start:ss,registerAdapter:Or,visit:Mr,connectStreamSource:we,disconnectStreamSource:Ee,renderStreamMessage:Fr,clearCache:Rr,setProgressBarDelay:Pr,setConfirmMethod:Br,setFormMode:Ir,StreamActions:ts}),rt=class extends Error{},it=class{constructor(e){this.fetchResponseLoaded=t=>{},this.currentFetchRequest=null,this.resolveVisitPromise=()=>{},this.connected=!1,this.hasBeenLoaded=!1,this.ignoredAttributes=new Set,this.action=null,this.visitCachedSnapshot=({element:t})=>{let s=t.querySelector("#"+this.element.id);s&&this.previousFrameElement&&s.replaceChildren(...this.previousFrameElement.children),delete this.previousFrameElement},this.element=e,this.view=new Ve(this,this.element),this.appearanceObserver=new He(this,this.element),this.formLinkClickObserver=new fe(this,this.element),this.linkInterceptor=new me(this,this.element),this.restorationIdentifier=x(),this.formSubmitObserver=new U(this,this.element)}connect(){this.connected||(this.connected=!0,this.loadingStyle==L.lazy?this.appearanceObserver.start():this.loadSourceURL(),this.formLinkClickObserver.start(),this.linkInterceptor.start(),this.formSubmitObserver.start())}disconnect(){this.connected&&(this.connected=!1,this.appearanceObserver.stop(),this.formLinkClickObserver.stop(),this.linkInterceptor.stop(),this.formSubmitObserver.stop())}disabledChanged(){this.loadingStyle==L.eager&&this.loadSourceURL()}sourceURLChanged(){this.isIgnoringChangesTo("src")||(this.element.isConnected&&(this.complete=!1),(this.loadingStyle==L.eager||this.hasBeenLoaded)&&this.loadSourceURL())}sourceURLReloaded(){let{src:e}=this.element;return this.ignoringChangesToAttribute("complete",()=>{this.element.removeAttribute("complete")}),this.element.src=null,this.element.src=e,this.element.loaded}completeChanged(){this.isIgnoringChangesTo("complete")||this.loadSourceURL()}loadingStyleChanged(){this.loadingStyle==L.lazy?this.appearanceObserver.start():(this.appearanceObserver.stop(),this.loadSourceURL())}async loadSourceURL(){this.enabled&&this.isActive&&!this.complete&&this.sourceURL&&(this.element.loaded=this.visit(d(this.sourceURL)),this.appearanceObserver.stop(),await this.element.loaded,this.hasBeenLoaded=!0)}async loadResponse(e){(e.redirected||e.succeeded&&e.isHTML)&&(this.sourceURL=e.response.url);try{let t=await e.responseHTML;if(t){let s=Gt(t);g.fromDocument(s).isVisitable?await this.loadFrameResponse(e,s):await this.handleUnvisitableFrameResponse(e)}}finally{this.fetchResponseLoaded=()=>{}}}elementAppearedInViewport(e){this.proposeVisitIfNavigatedWithAction(e,e),this.loadSourceURL()}willSubmitFormLinkToLocation(e){return this.shouldInterceptNavigation(e)}submittedFormLinkToLocation(e,t,s){let i=this.findFrameElement(e);i&&s.setAttribute("data-turbo-frame",i.id)}shouldInterceptLinkClick(e,t,s){return this.shouldInterceptNavigation(e)}linkClickIntercepted(e,t){this.navigateFrame(e,t)}willSubmitForm(e,t){return e.closest("turbo-frame")==this.element&&this.shouldInterceptNavigation(e,t)}formSubmitted(e,t){this.formSubmission&&this.formSubmission.stop(),this.formSubmission=new _(this,e,t);let{fetchRequest:s}=this.formSubmission;this.prepareRequest(s),this.formSubmission.start()}prepareRequest(e){var t;e.headers["Turbo-Frame"]=this.id,!((t=this.currentNavigationElement)===null||t===void 0)&&t.hasAttribute("data-turbo-stream")&&e.acceptResponseType(E.contentType)}requestStarted(e){De(this.element)}requestPreventedHandlingResponse(e,t){this.resolveVisitPromise()}async requestSucceededWithResponse(e,t){await this.loadResponse(t),this.resolveVisitPromise()}async requestFailedWithResponse(e,t){await this.loadResponse(t),this.resolveVisitPromise()}requestErrored(e,t){console.error(t),this.resolveVisitPromise()}requestFinished(e){qe(this.element)}formSubmissionStarted({formElement:e}){De(e,this.findFrameElement(e))}formSubmissionSucceededWithResponse(e,t){let s=this.findFrameElement(e.formElement,e.submitter);s.delegate.proposeVisitIfNavigatedWithAction(s,e.formElement,e.submitter),s.delegate.loadResponse(t),e.isSafe||h.clearCache()}formSubmissionFailedWithResponse(e,t){this.element.delegate.loadResponse(t),h.clearCache()}formSubmissionErrored(e,t){console.error(t)}formSubmissionFinished({formElement:e}){qe(e,this.findFrameElement(e))}allowsImmediateRender({element:e},t){let s=u("turbo:before-frame-render",{target:this.element,detail:Object.assign({newFrame:e},t),cancelable:!0}),{defaultPrevented:i,detail:{render:n}}=s;return this.view.renderer&&n&&(this.view.renderer.renderElement=n),!i}viewRenderedSnapshot(e,t){}preloadOnLoadLinksForView(e){h.preloadOnLoadLinksForView(e)}viewInvalidated(){}willRenderFrame(e,t){this.previousFrameElement=e.cloneNode(!0)}async loadFrameResponse(e,t){let s=await this.extractForeignFrameElement(t.body);if(s){let i=new N(s),n=new W(this,this.view.snapshot,i,W.renderElement,!1,!1);this.view.renderPromise&&await this.view.renderPromise,this.changeHistory(),await this.view.render(n),this.complete=!0,h.frameRendered(e,this.element),h.frameLoaded(this.element),this.fetchResponseLoaded(e)}else this.willHandleFrameMissingFromResponse(e)&&this.handleFrameMissingFromResponse(e)}async visit(e){var t;let s=new $(this,p.get,e,new URLSearchParams,this.element);return(t=this.currentFetchRequest)===null||t===void 0||t.cancel(),this.currentFetchRequest=s,new Promise(i=>{this.resolveVisitPromise=()=>{this.resolveVisitPromise=()=>{},this.currentFetchRequest=null,i()},s.perform()})}navigateFrame(e,t,s){let i=this.findFrameElement(e,s);i.delegate.proposeVisitIfNavigatedWithAction(i,e,s),this.withCurrentNavigationElement(e,()=>{i.src=t})}proposeVisitIfNavigatedWithAction(e,t,s){if(this.action=ye(s,t,e),this.action){let i=g.fromElement(e).clone(),{visitCachedSnapshot:n}=e.delegate;e.delegate.fetchResponseLoaded=o=>{if(e.src){let{statusCode:a,redirected:l}=o,m=e.ownerDocument.documentElement.outerHTML,A={response:{statusCode:a,redirected:l,responseHTML:m},visitCachedSnapshot:n,willRender:!1,updateHistory:!1,restorationIdentifier:this.restorationIdentifier,snapshot:i};this.action&&(A.action=this.action),h.visit(e.src,A)}}}}changeHistory(){if(this.action){let e=Qt(this.action);h.history.update(e,d(this.element.src||""),this.restorationIdentifier)}}async handleUnvisitableFrameResponse(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.visitResponse(e.response)}willHandleFrameMissingFromResponse(e){this.element.setAttribute("complete","");let t=e.response,s=async(n,o={})=>{n instanceof Response?this.visitResponse(n):h.visit(n,o)};return!u("turbo:frame-missing",{target:this.element,detail:{response:t,visit:s},cancelable:!0}).defaultPrevented}handleFrameMissingFromResponse(e){this.view.missing(),this.throwFrameMissingError(e)}throwFrameMissingError(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 rt(t)}async visitResponse(e){let t=new H(e),s=await t.responseHTML,{location:i,redirected:n,statusCode:o}=t;return h.visit(i,{response:{redirected:n,statusCode:o,responseHTML:s}})}findFrameElement(e,t){var s;let i=le("data-turbo-frame",t,e)||this.element.getAttribute("target");return(s=Kt(i))!==null&&s!==void 0?s:this.element}async extractForeignFrameElement(e){let t,s=CSS.escape(this.id);try{if(t=zt(e.querySelector(`turbo-frame#${s}`),this.sourceURL),t)return t;if(t=zt(e.querySelector(`turbo-frame[src][recurse~=${s}]`),this.sourceURL),t)return await t.loaded,await this.extractForeignFrameElement(t)}catch(i){return console.error(i),new w}return null}formActionIsVisitable(e,t){let s=at(e,t);return I(d(s),this.rootLocation)}shouldInterceptNavigation(e,t){let s=le("data-turbo-frame",t,e)||this.element.getAttribute("target");if(e instanceof HTMLFormElement&&!this.formActionIsVisitable(e,t)||!this.enabled||s=="_top")return!1;if(s){let i=Kt(s);if(i)return!i.disabled}return!(!h.elementIsNavigatable(e)||t&&!h.elementIsNavigatable(t))}get id(){return this.element.id}get enabled(){return!this.element.disabled}get sourceURL(){if(this.element.src)return this.element.src}set sourceURL(e){this.ignoringChangesToAttribute("src",()=>{this.element.src=e??null})}get loadingStyle(){return this.element.loading}get isLoading(){return this.formSubmission!==void 0||this.resolveVisitPromise()!==void 0}get complete(){return this.element.hasAttribute("complete")}set complete(e){this.ignoringChangesToAttribute("complete",()=>{e?this.element.setAttribute("complete",""):this.element.removeAttribute("complete")})}get isActive(){return this.element.isActive&&this.connected}get rootLocation(){var e;let t=this.element.ownerDocument.querySelector('meta[name="turbo-root"]'),s=(e=t?.content)!==null&&e!==void 0?e:"/";return d(s)}isIgnoringChangesTo(e){return this.ignoredAttributes.has(e)}ignoringChangesToAttribute(e,t){this.ignoredAttributes.add(e),t(),this.ignoredAttributes.delete(e)}withCurrentNavigationElement(e,t){this.currentNavigationElement=e,t(),delete this.currentNavigationElement}};function Kt(r){if(r!=null){let e=document.getElementById(r);if(e instanceof w)return e}}function zt(r,e){if(r){let t=r.getAttribute("src");if(t!=null&&e!=null&&Vs(t,e))throw new Error(`Matching <turbo-frame id="${r.id}"> element has a source URL which references itself`);if(r.ownerDocument!==document&&(r=document.importNode(r,!0)),r instanceof w)return r.connectedCallback(),r.disconnectedCallback(),r}}var nt=class r 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(){var e;return(e=this.renderPromise)!==null&&e!==void 0?e:this.renderPromise=(async()=>{let t=this.beforeRenderEvent;this.dispatchEvent(t)&&(await ce(),await t.detail.render(this))})()}disconnect(){try{this.remove()}catch{}}removeDuplicateTargetChildren(){this.duplicateChildren.forEach(e=>e.remove())}get duplicateChildren(){var e;let t=this.targetElements.flatMap(i=>[...i.children]).filter(i=>!!i.id),s=[...((e=this.templateContent)===null||e===void 0?void 0:e.children)||[]].filter(i=>!!i.id).map(i=>i.id);return t.filter(i=>s.includes(i.id))}get performAction(){if(this.action){let e=ts[this.action];if(e)return e;this.raise("unknown action")}this.raise("action attribute is missing")}get targetElements(){if(this.target)return this.targetElementsById;if(this.targets)return this.targetElementsByQuery;this.raise("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.raise("first child element must be a <template> element")}get action(){return this.getAttribute("action")}get target(){return this.getAttribute("target")}get targets(){return this.getAttribute("targets")}raise(e){throw new Error(`${this.description}: ${e}`)}get description(){var e,t;return(t=((e=this.outerHTML.match(/<[^>]+>/))!==null&&e!==void 0?e:[])[0])!==null&&t!==void 0?t:"<turbo-stream>"}get beforeRenderEvent(){return new CustomEvent("turbo:before-stream-render",{bubbles:!0,cancelable:!0,detail:{newStream:this,render:r.renderElement}})}get targetElementsById(){var e;let t=(e=this.ownerDocument)===null||e===void 0?void 0:e.getElementById(this.target);return t!==null?[t]:[]}get targetElementsByQuery(){var e;let t=(e=this.ownerDocument)===null||e===void 0?void 0:e.querySelectorAll(this.targets);return t.length!==0?Array.prototype.slice.call(t):[]}},ot=class extends HTMLElement{constructor(){super(...arguments),this.streamSource=null}connectedCallback(){this.streamSource=this.src.match(/^ws{1,2}:/)?new WebSocket(this.src):new EventSource(this.src),we(this.streamSource)}disconnectedCallback(){this.streamSource&&Ee(this.streamSource)}get src(){return this.getAttribute("src")||""}};w.delegateConstructor=it;customElements.get("turbo-frame")===void 0&&customElements.define("turbo-frame",w);customElements.get("turbo-stream")===void 0&&customElements.define("turbo-stream",nt);customElements.get("turbo-stream-source")===void 0&&customElements.define("turbo-stream-source",ot);(()=>{let r=document.currentScript;if(r&&!r.hasAttribute("data-turbo-suppress-warning"))for(r=r.parentElement;r;){if(r==document.body)return console.warn(Xt`
|
18
|
+
You are loading Turbo from a <script> element inside the <body> element. This is probably not what you meant to do!
|
19
|
+
|
20
|
+
Load your application’s JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change.
|
21
|
+
|
22
|
+
For more information, see: https://turbo.hotwired.dev/handbook/building#working-with-script-elements
|
23
|
+
|
24
|
+
——
|
25
|
+
Suppress this warning by adding a "data-turbo-suppress-warning" attribute to: %s
|
26
|
+
`,r.outerHTML);r=r.parentElement}})();window.Turbo=xr;ss();var ls;async function Vr(){return ls||cs($r().then(cs))}function cs(r){return ls=r}async function $r(){let{createConsumer:r}=await Promise.resolve().then(()=>(as(),os));return r()}async function hs(r,e){let{subscriptions:t}=await Vr();return t.create(r,e)}function Y(r){return!r||typeof r!="object"||r instanceof Date||r instanceof RegExp?r:Array.isArray(r)?r.map(Y):Object.keys(r).reduce(function(e,t){var s=t[0].toLowerCase()+t.slice(1).replace(/([A-Z]+)/g,function(i,n){return"_"+n.toLowerCase()});return e[s]=Y(r[t]),e},{})}var vt=class extends HTMLElement{async connectedCallback(){we(this),this.subscription=await hs(this.channel,{received:this.dispatchMessageEvent.bind(this),connected:this.subscriptionConnected.bind(this),disconnected:this.subscriptionDisconnected.bind(this)})}disconnectedCallback(){Ee(this),this.subscription&&this.subscription.unsubscribe()}dispatchMessageEvent(e){let t=new MessageEvent("message",{data:e});return this.dispatchEvent(t)}subscriptionConnected(){this.setAttribute("connected","")}subscriptionDisconnected(){this.removeAttribute("connected")}get channel(){let e=this.getAttribute("channel"),t=this.getAttribute("signed-stream-name");return{channel:e,signed_stream_name:t,...Y({...this.dataset})}}};customElements.get("turbo-cable-stream-source")===void 0&&customElements.define("turbo-cable-stream-source",vt);function us(r){if(r.target instanceof HTMLFormElement){let{target:e,detail:{fetchOptions:t}}=r;e.addEventListener("turbo:submit-start",({detail:{formSubmission:{submitter:s}}})=>{let i=Wr(t.body)?t.body:new URLSearchParams,n=Ur(s,i,e);/get/i.test(n)||(/post/i.test(n)?i.delete("_method"):i.set("_method",n),t.method="post")},{once:!0})}}function Ur(r,e,t){let s=jr(r),i=e.get("_method"),n=t.getAttribute("method")||"get";return typeof s=="string"?s:typeof i=="string"?i:n}function jr(r){return(r instanceof HTMLButtonElement||r instanceof HTMLInputElement)&&r.hasAttribute("formmethod")?r.formMethod:null}function Wr(r){return r instanceof FormData||r instanceof URLSearchParams}addEventListener("turbo:before-fetch-request",us);var bt=class{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=Kr(e);for(let s of this.bindings){if(t.immediatePropagationStopped)break;s.handleEvent(t)}}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort((e,t)=>{let s=e.index,i=t.index;return s<i?-1:s>i?1:0})}};function Kr(r){if("immediatePropagationStopped"in r)return r;{let{stopImmediatePropagation:e}=r;return Object.assign(r,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,e.call(this)}})}}var yt=class{constructor(e){this.application=e,this.eventListenerMaps=new Map,this.started=!1}start(){this.started||(this.started=!0,this.eventListeners.forEach(e=>e.connect()))}stop(){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){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);t.hasBindings()||(t.disconnect(),this.removeMappedEventListenerFor(e))}removeMappedEventListenerFor(e){let{eventTarget:t,eventName:s,eventOptions:i}=e,n=this.fetchEventListenerMapForEventTarget(t),o=this.cacheKey(s,i);n.delete(o),n.size==0&&this.eventListenerMaps.delete(t)}fetchEventListenerForBinding(e){let{eventTarget:t,eventName:s,eventOptions:i}=e;return this.fetchEventListener(t,s,i)}fetchEventListener(e,t,s){let i=this.fetchEventListenerMapForEventTarget(e),n=this.cacheKey(t,s),o=i.get(n);return o||(o=this.createEventListener(e,t,s),i.set(n,o)),o}createEventListener(e,t,s){let i=new bt(e,t,s);return this.started&&i.connect(),i}fetchEventListenerMapForEventTarget(e){let t=this.eventListenerMaps.get(e);return t||(t=new Map,this.eventListenerMaps.set(e,t)),t}cacheKey(e,t){let s=[e];return Object.keys(t).sort().forEach(i=>{s.push(`${t[i]?"":"!"}${i}`)}),s.join(":")}},zr={stop({event:r,value:e}){return e&&r.stopPropagation(),!0},prevent({event:r,value:e}){return e&&r.preventDefault(),!0},self({event:r,value:e,element:t}){return e?t===r.target:!0}},Jr=/^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function Gr(r){let t=r.trim().match(Jr)||[],s=t[2],i=t[3];return i&&!["keydown","keyup","keypress"].includes(s)&&(s+=`.${i}`,i=""),{eventTarget:Xr(t[4]),eventName:s,eventOptions:t[7]?Qr(t[7]):{},identifier:t[5],methodName:t[6],keyFilter:t[1]||i}}function Xr(r){if(r=="window")return window;if(r=="document")return document}function Qr(r){return r.split(":").reduce((e,t)=>Object.assign(e,{[t.replace(/^!/,"")]:!/^!/.test(t)}),{})}function Yr(r){if(r==window)return"window";if(r==document)return"document"}function $t(r){return r.replace(/(?:[_-])([a-z0-9])/g,(e,t)=>t.toUpperCase())}function wt(r){return $t(r.replace(/--/g,"-").replace(/__/g,"_"))}function ee(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Es(r){return r.replace(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}function Zr(r){return r.match(/[^\s]+/g)||[]}function ds(r){return r!=null}function Et(r,e){return Object.prototype.hasOwnProperty.call(r,e)}var ms=["meta","ctrl","alt","shift"],St=class{constructor(e,t,s,i){this.element=e,this.index=t,this.eventTarget=s.eventTarget||e,this.eventName=s.eventName||ei(e)||ke("missing event name"),this.eventOptions=s.eventOptions||{},this.identifier=s.identifier||ke("missing identifier"),this.methodName=s.methodName||ke("missing method name"),this.keyFilter=s.keyFilter||"",this.schema=i}static forToken(e,t){return new this(e.element,e.index,Gr(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(i=>!ms.includes(i))[0];return s?(Et(this.keyMappings,s)||ke(`contains unknown key filter: ${this.keyFilter}`),this.keyMappings[s].toLowerCase()!==e.key.toLowerCase()):!1}shouldIgnoreMouseEvent(e){if(!this.keyFilter)return!1;let t=[this.keyFilter];return!!this.keyFilterDissatisfied(e,t)}get params(){let e={},t=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(let{name:s,value:i}of Array.from(this.element.attributes)){let n=s.match(t),o=n&&n[1];o&&(e[$t(o)]=ti(i))}return e}get eventTargetName(){return Yr(this.eventTarget)}get keyMappings(){return this.schema.keyMappings}keyFilterDissatisfied(e,t){let[s,i,n,o]=ms.map(a=>t.includes(a));return e.metaKey!==s||e.ctrlKey!==i||e.altKey!==n||e.shiftKey!==o}},ps={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:r=>r.getAttribute("type")=="submit"?"click":"input",select:()=>"change",textarea:()=>"input"};function ei(r){let e=r.tagName.toLowerCase();if(e in ps)return ps[e](r)}function ke(r){throw new Error(r)}function ti(r){try{return JSON.parse(r)}catch{return r}}var At=class{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);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 new Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(e){let{element:t}=this.action,{actionDescriptorFilters:s}=this.context.application,{controller:i}=this.context,n=!0;for(let[o,a]of Object.entries(this.eventOptions))if(o in s){let l=s[o];n=n&&l({name:o,value:a,event:e,element:t,controller:i})}else continue;return n}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(i){let{identifier:n,controller:o,element:a,index:l}=this,m={identifier:n,controller:o,element:a,index:l,event:e};this.context.handleError(i,`invoking action "${this.action}"`,m)}}willBeInvokedByEvent(e){let t=e.target;return e instanceof KeyboardEvent&&this.action.shouldIgnoreKeyboardEvent(e)||e instanceof MouseEvent&&this.action.shouldIgnoreMouseEvent(e)?!1:this.element===t?!0:t instanceof Element&&this.element.contains(t)?this.scope.containsElement(t):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}},Oe=class{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(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh())}pause(e){this.started&&(this.mutationObserver.disconnect(),this.started=!1),e(),this.started||(this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0)}stop(){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))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){e.type=="attributes"?this.processAttributeChange(e.target,e.attributeName):e.type=="childList"&&(this.processRemovedNodes(e.removedNodes),this.processAddedNodes(e.addedNodes))}processAttributeChange(e,t){this.elements.has(e)?this.delegate.elementAttributeChanged&&this.matchElement(e)?this.delegate.elementAttributeChanged(e,t):this.removeElement(e):this.matchElement(e)&&this.addElement(e)}processRemovedNodes(e){for(let t of Array.from(e)){let s=this.elementFromNode(t);s&&this.processTree(s,this.removeElement)}}processAddedNodes(e){for(let t of Array.from(e)){let s=this.elementFromNode(t);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){return e.isConnected!=this.element.isConnected?!1:this.element.contains(e)}addElement(e){this.elements.has(e)||this.elementIsActive(e)&&(this.elements.add(e),this.delegate.elementMatched&&this.delegate.elementMatched(e))}removeElement(e){this.elements.has(e)&&(this.elements.delete(e),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(e))}},Me=class{constructor(e,t,s){this.attributeName=t,this.delegate=s,this.elementObserver=new Oe(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){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(e,this.attributeName)}elementUnmatched(e){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(e,this.attributeName)}elementAttributeChanged(e,t){this.delegate.elementAttributeValueChanged&&this.attributeName==t&&this.delegate.elementAttributeValueChanged(e,t)}};function si(r,e,t){Ss(r,e).add(t)}function ri(r,e,t){Ss(r,e).delete(t),ii(r,e)}function Ss(r,e){let t=r.get(e);return t||(t=new Set,r.set(e,t)),t}function ii(r,e){let t=r.get(e);t!=null&&t.size==0&&r.delete(e)}var S=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){si(this.valuesByKey,e,t)}delete(e,t){ri(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)}};var Tt=class{constructor(e,t,s,i){this._selector=t,this.details=i,this.elementObserver=new Oe(e,this),this.delegate=s,this.matchesByElement=new S}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);return this.delegate.selectorMatchElement?s&&this.delegate.selectorMatchElement(e,this.details):s}else return!1}matchElementsInTree(e){let{selector:t}=this;if(t){let s=this.matchElement(e)?[e]:[],i=Array.from(e.querySelectorAll(t)).filter(n=>this.matchElement(n));return s.concat(i)}else return[]}elementMatched(e){let{selector:t}=this;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 i=this.matchElement(e),n=this.matchesByElement.has(s,e);i&&!n?this.selectorMatched(e,s):!i&&n&&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)}},Ct=class{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(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh())}stop(){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;t&&this.refreshAttribute(t,e.oldValue)}refreshAttribute(e,t){let s=this.delegate.getStringMapKeyForAttribute(e);if(s!=null){this.stringMap.has(e)||this.stringMapKeyAdded(s,e);let i=this.element.getAttribute(e);if(this.stringMap.get(e)!=i&&this.stringMapValueChanged(i,s,t),i==null){let n=this.stringMap.get(e);this.stringMap.delete(e),n&&this.stringMapKeyRemoved(s,e,n)}else this.stringMap.set(e,i)}}stringMapKeyAdded(e,t){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(e,t)}stringMapValueChanged(e,t,s){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(e,t,s)}stringMapKeyRemoved(e,t,s){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())}},Fe=class{constructor(e,t,s){this.attributeObserver=new Me(e,t,this),this.delegate=s,this.tokensByElement=new S}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),i=oi(t,s).findIndex(([n,o])=>!ai(n,o));return i==-1?[[],[]]:[t.slice(i),s.slice(i)]}readTokensForElement(e){let t=this.attributeName,s=e.getAttribute(t)||"";return ni(s,e,t)}};function ni(r,e,t){return r.trim().split(/\s+/).filter(s=>s.length).map((s,i)=>({element:e,attributeName:t,content:s,index:i}))}function oi(r,e){let t=Math.max(r.length,e.length);return Array.from({length:t},(s,i)=>[r[i],e[i]])}function ai(r,e){return r&&e&&r.index==e.index&&r.content==e.content}var Re=class{constructor(e,t,s){this.tokenListObserver=new Fe(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);s&&(this.fetchValuesByTokenForElement(t).set(e,s),this.delegate.elementMatchedValue(t,s))}tokenUnmatched(e){let{element:t}=e,{value:s}=this.fetchParseResultForToken(e);s&&(this.fetchValuesByTokenForElement(t).delete(e),this.delegate.elementUnmatchedValue(t,s))}fetchParseResultForToken(e){let t=this.parseResultsByToken.get(e);return t||(t=this.parseToken(e),this.parseResultsByToken.set(e,t)),t}fetchValuesByTokenForElement(e){let t=this.valuesByTokenByElement.get(e);return t||(t=new Map,this.valuesByTokenByElement.set(e,t)),t}parseToken(e){try{return{value:this.delegate.parseValueForToken(e)}}catch(t){return{error:t}}}},Lt=class{constructor(e,t){this.context=e,this.delegate=t,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new Re(this.element,this.actionAttribute,this),this.valueListObserver.start())}stop(){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 At(this.context,e);this.bindingsByAction.set(e,t),this.delegate.bindingConnected(t)}disconnectAction(e){let t=this.bindingsByAction.get(e);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=St.forToken(e,this.schema);if(t.identifier==this.identifier)return t}elementMatchedValue(e,t){this.connectAction(t)}elementUnmatchedValue(e,t){this.disconnectAction(t)}},kt=class{constructor(e,t){this.context=e,this.receiver=t,this.stringMapObserver=new Ct(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];this.hasValue(e)||this.invokeChangedCallback(e,s.writer(this.receiver[e]),s.writer(s.defaultValue))}stringMapValueChanged(e,t,s){let i=this.valueDescriptorNameMap[t];e!==null&&(s===null&&(s=i.writer(i.defaultValue)),this.invokeChangedCallback(t,e,s))}stringMapKeyRemoved(e,t,s){let i=this.valueDescriptorNameMap[e];this.hasValue(e)?this.invokeChangedCallback(e,i.writer(this.receiver[e]),s):this.invokeChangedCallback(e,i.writer(i.defaultValue),s)}invokeChangedCallbacksForDefaultValues(){for(let{key:e,name:t,defaultValue:s,writer:i}of this.valueDescriptors)s!=null&&!this.controller.data.has(e)&&this.invokeChangedCallback(t,i(s),void 0)}invokeChangedCallback(e,t,s){let i=`${e}Changed`,n=this.receiver[i];if(typeof n=="function"){let o=this.valueDescriptorNameMap[e];try{let a=o.reader(t),l=s;s&&(l=o.reader(s)),n.call(this.receiver,a,l)}catch(a){throw a instanceof TypeError&&(a.message=`Stimulus Value "${this.context.identifier}.${o.name}" - ${a.message}`),a}}}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${ee(t.name)}`;return this.receiver[s]}},Ot=class{constructor(e,t){this.context=e,this.delegate=t,this.targetsByName=new S}start(){this.tokenListObserver||(this.tokenListObserver=new Fe(this.element,this.attributeName,this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver)}tokenMatched({element:e,content:t}){this.scope.containsElement(e)&&this.connectTarget(e,t)}tokenUnmatched({element:e,content:t}){this.disconnectTarget(e,t)}connectTarget(e,t){var s;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;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 te(r,e){let t=As(r);return Array.from(t.reduce((s,i)=>(li(i,e).forEach(n=>s.add(n)),s),new Set))}function ci(r,e){return As(r).reduce((s,i)=>(s.push(...hi(i,e)),s),[])}function As(r){let e=[];for(;r;)e.push(r),r=Object.getPrototypeOf(r);return e.reverse()}function li(r,e){let t=r[e];return Array.isArray(t)?t:[]}function hi(r,e){let t=r[e];return t?Object.keys(t).map(s=>[s,t[s]]):[]}var Mt=class{constructor(e,t){this.started=!1,this.context=e,this.delegate=t,this.outletsByName=new S,this.outletElementsByName=new S,this.selectorObserverMap=new Map,this.attributeObserverMap=new Map}start(){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(){this.started&&(this.started=!1,this.disconnectAllOutlets(),this.stopSelectorObservers(),this.stopAttributeObservers())}stopSelectorObservers(){this.selectorObserverMap.size>0&&(this.selectorObserverMap.forEach(e=>e.stop()),this.selectorObserverMap.clear())}stopAttributeObservers(){this.attributeObserverMap.size>0&&(this.attributeObserverMap.forEach(e=>e.stop()),this.attributeObserverMap.clear())}selectorMatched(e,t,{outletName:s}){let i=this.getOutlet(e,s);i&&this.connectOutlet(i,e,s)}selectorUnmatched(e,t,{outletName:s}){let i=this.getOutletFromMap(e,s);i&&this.disconnectOutlet(i,e,s)}selectorMatchElement(e,{outletName:t}){let s=this.selector(t),i=this.hasOutlet(e,t),n=e.matches(`[${this.schema.controllerAttribute}~=${t}]`);return s?i&&n&&e.matches(s):!1}elementMatchedAttribute(e,t){let s=this.getOutletNameFromOutletAttributeName(t);s&&this.updateSelectorObserverForOutlet(s)}elementAttributeValueChanged(e,t){let s=this.getOutletNameFromOutletAttributeName(t);s&&this.updateSelectorObserverForOutlet(s)}elementUnmatchedAttribute(e,t){let s=this.getOutletNameFromOutletAttributeName(t);s&&this.updateSelectorObserverForOutlet(s)}connectOutlet(e,t,s){var i;this.outletElementsByName.has(s,t)||(this.outletsByName.add(s,e),this.outletElementsByName.add(s,t),(i=this.selectorObserverMap.get(s))===null||i===void 0||i.pause(()=>this.delegate.outletConnected(e,t,s)))}disconnectOutlet(e,t,s){var i;this.outletElementsByName.has(s,t)&&(this.outletsByName.delete(s,e),this.outletElementsByName.delete(s,t),(i=this.selectorObserverMap.get(s))===null||i===void 0||i.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);t&&(t.selector=this.selector(e))}setupSelectorObserverForOutlet(e){let t=this.selector(e),s=new Tt(document.body,t,this,{outletName:e});this.selectorObserverMap.set(e,s),s.start()}setupAttributeObserverForOutlet(e){let t=this.attributeNameForOutletName(e),s=new Me(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 S;return this.router.modules.forEach(t=>{let s=t.definition.controllerConstructor;te(s,"outlets").forEach(n=>e.add(n,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}},Ft=class{constructor(e,t){this.logDebugActivity=(s,i={})=>{let{identifier:n,controller:o,element:a}=this;i=Object.assign({identifier:n,controller:o,element:a},i),this.application.logDebugActivity(this.identifier,s,i)},this.module=e,this.scope=t,this.controller=new e.controllerConstructor(this),this.bindingObserver=new Lt(this,this.dispatcher),this.valueObserver=new kt(this,this.controller),this.targetObserver=new Ot(this,this),this.outletObserver=new Mt(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:i,controller:n,element:o}=this;s=Object.assign({identifier:i,controller:n,element:o},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(`${wt(s)}OutletConnected`,e,t)}outletDisconnected(e,t,s){this.invokeControllerMethod(`${wt(s)}OutletDisconnected`,e,t)}invokeControllerMethod(e,...t){let s=this.controller;typeof s[e]=="function"&&s[e](...t)}};function ui(r){return di(r,mi(r))}function di(r,e){let t=vi(r),s=pi(r.prototype,e);return Object.defineProperties(t.prototype,s),t}function mi(r){return te(r,"blessings").reduce((t,s)=>{let i=s(r);for(let n in i){let o=t[n]||{};t[n]=Object.assign(o,i[n])}return t},{})}function pi(r,e){return gi(e).reduce((t,s)=>{let i=fi(r,e,s);return i&&Object.assign(t,{[s]:i}),t},{})}function fi(r,e,t){let s=Object.getOwnPropertyDescriptor(r,t);if(!(s&&"value"in s)){let n=Object.getOwnPropertyDescriptor(e,t).value;return s&&(n.get=s.get||n.get,n.set=s.set||n.set),n}}var gi=(()=>typeof Object.getOwnPropertySymbols=="function"?r=>[...Object.getOwnPropertyNames(r),...Object.getOwnPropertySymbols(r)]:Object.getOwnPropertyNames)(),vi=(()=>{function r(t){function s(){return Reflect.construct(t,arguments,new.target)}return s.prototype=Object.create(t.prototype,{constructor:{value:s}}),Reflect.setPrototypeOf(s,t),s}function e(){let s=r(function(){this.a.call(this)});return s.prototype.a=function(){},new s}try{return e(),r}catch{return s=>class extends s{}}})();function bi(r){return{identifier:r.identifier,controllerConstructor:ui(r.controllerConstructor)}}var Rt=class{constructor(e,t){this.application=e,this.definition=bi(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);t&&(this.connectedContexts.delete(t),t.disconnect())}fetchContextForScope(e){let t=this.contextsByScope.get(e);return t||(t=new Ft(this,e),this.contextsByScope.set(e,t)),t}},Pt=class{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 Zr(t)}getAttributeName(e){return this.data.getAttributeNameForKey(this.getDataKey(e))}getDataKey(e){return`${e}-class`}get data(){return this.scope.data}},Bt=class{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}-${Es(e)}`}},It=class{constructor(e){this.warnedKeysByObject=new WeakMap,this.logger=e}warn(e,t,s){let i=this.warnedKeysByObject.get(e);i||(i=new Set,this.warnedKeysByObject.set(e,i)),i.has(t)||(i.add(t),this.logger.warn(s,e))}};function xt(r,e){return`[${r}~="${e}"]`}var Nt=class{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 xt(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 xt(this.schema.targetAttribute,t)}deprecate(e,t){if(e){let{identifier:s}=this,i=this.schema.targetAttribute,n=this.schema.targetAttributeForScope(s);this.guide.warn(e,`target:${t}`,`Please replace ${i}="${s}.${t}" with ${n}="${t}". The ${i} attribute is deprecated and will be removed in a future version of Stimulus.`)}return e}get guide(){return this.scope.guide}},Dt=class{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(i=>this.matchesElement(i,e,t))[0]}findAllElements(e,t){return this.scope.queryElements(e).filter(i=>this.matchesElement(i,e,t))}matchesElement(e,t,s){let i=e.getAttribute(this.scope.schema.controllerAttribute)||"";return e.matches(t)&&i.split(" ").includes(s)}},qt=class r{constructor(e,t,s,i){this.targets=new Nt(this),this.classes=new Pt(this),this.data=new Bt(this),this.containsElement=n=>n.closest(this.controllerSelector)===this.element,this.schema=e,this.element=t,this.identifier=s,this.guide=new It(i),this.outlets=new Dt(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 xt(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new r(this.schema,document.documentElement,this.identifier,this.guide.logger)}},Ht=class{constructor(e,t,s){this.element=e,this.schema=t,this.delegate=s,this.valueListObserver=new Re(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),i=s.get(t);return i||(i=this.delegate.createScopeForElementAndIdentifier(e,t),s.set(t,i)),i}elementMatchedValue(e,t){let s=(this.scopeReferenceCounts.get(t)||0)+1;this.scopeReferenceCounts.set(t,s),s==1&&this.delegate.scopeConnected(t)}elementUnmatchedValue(e,t){let s=this.scopeReferenceCounts.get(t);s&&(this.scopeReferenceCounts.set(t,s-1),s==1&&this.delegate.scopeDisconnected(t))}fetchScopesByIdentifierForElement(e){let t=this.scopesByIdentifierByElement.get(e);return t||(t=new Map,this.scopesByIdentifierByElement.set(e,t)),t}},Vt=class{constructor(e){this.application=e,this.scopeObserver=new Ht(this.element,this.schema,this),this.scopesByIdentifier=new S,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 Rt(this.application,e);this.connectModule(t);let s=e.controllerConstructor.afterLoad;s&&s.call(e.controllerConstructor,e.identifier,this.application)}unloadIdentifier(e){let t=this.modulesByIdentifier.get(e);t&&this.disconnectModule(t)}getContextForElementAndIdentifier(e,t){let s=this.modulesByIdentifier.get(t);if(s)return s.contexts.find(i=>i.element==e)}proposeToConnectScopeForElementAndIdentifier(e,t){let s=this.scopeObserver.parseValueForElementAndIdentifier(e,t);s?this.scopeObserver.elementMatchedValue(s.element,s):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 qt(this.schema,e,t,this.logger)}scopeConnected(e){this.scopesByIdentifier.add(e.identifier,e);let t=this.modulesByIdentifier.get(e.identifier);t&&t.connectContextForScope(e)}scopeDisconnected(e){this.scopesByIdentifier.delete(e.identifier,e);let t=this.modulesByIdentifier.get(e.identifier);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))}},yi={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:r=>`data-${r}-target`,outletAttributeForScope:(r,e)=>`data-${r}-${e}-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"},fs("abcdefghijklmnopqrstuvwxyz".split("").map(r=>[r,r]))),fs("0123456789".split("").map(r=>[r,r])))};function fs(r){return r.reduce((e,[t,s])=>Object.assign(Object.assign({},e),{[t]:s}),{})}var Pe=class{constructor(e=document.documentElement,t=yi){this.logger=console,this.debug=!1,this.logDebugActivity=(s,i,n={})=>{this.debug&&this.logFormattedMessage(s,i,n)},this.element=e,this.schema=t,this.dispatcher=new yt(this),this.router=new Vt(this),this.actionDescriptorFilters=Object.assign({},zr)}static start(e,t){let s=new this(e,t);return s.start(),s}async start(){await wi(),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(i=>{i.controllerConstructor.shouldLoad&&this.router.loadDefinition(i)})}unload(e,...t){(Array.isArray(e)?e:[e,...t]).forEach(i=>this.router.unloadIdentifier(i))}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 i;this.logger.error(`%s
|
27
|
+
|
28
|
+
%o
|
29
|
+
|
30
|
+
%o`,t,e,s),(i=window.onerror)===null||i===void 0||i.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 wi(){return new Promise(r=>{document.readyState=="loading"?document.addEventListener("DOMContentLoaded",()=>r()):r()})}function Ei(r){return te(r,"classes").reduce((t,s)=>Object.assign(t,Si(s)),{})}function Si(r){return{[`${r}Class`]:{get(){let{classes:e}=this;if(e.has(r))return e.get(r);{let t=e.getAttributeName(r);throw new Error(`Missing attribute "${t}"`)}}},[`${r}Classes`]:{get(){return this.classes.getAll(r)}},[`has${ee(r)}Class`]:{get(){return this.classes.has(r)}}}}function Ai(r){return te(r,"outlets").reduce((t,s)=>Object.assign(t,Ti(s)),{})}function gs(r,e,t){return r.application.getControllerForElementAndIdentifier(e,t)}function vs(r,e,t){let s=gs(r,e,t);if(s||(r.application.router.proposeToConnectScopeForElementAndIdentifier(e,t),s=gs(r,e,t),s))return s}function Ti(r){let e=wt(r);return{[`${e}Outlet`]:{get(){let t=this.outlets.find(r),s=this.outlets.getSelectorForOutletName(r);if(t){let i=vs(this,t,r);if(i)return i;throw new Error(`The provided outlet element is missing an outlet controller "${r}" instance for host controller "${this.identifier}"`)}throw new Error(`Missing outlet element "${r}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${s}".`)}},[`${e}Outlets`]:{get(){let t=this.outlets.findAll(r);return t.length>0?t.map(s=>{let i=vs(this,s,r);if(i)return i;console.warn(`The provided outlet element is missing an outlet controller "${r}" instance for host controller "${this.identifier}"`,s)}).filter(s=>s):[]}},[`${e}OutletElement`]:{get(){let t=this.outlets.find(r),s=this.outlets.getSelectorForOutletName(r);if(t)return t;throw new Error(`Missing outlet element "${r}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${s}".`)}},[`${e}OutletElements`]:{get(){return this.outlets.findAll(r)}},[`has${ee(e)}Outlet`]:{get(){return this.outlets.has(r)}}}}function Ci(r){return te(r,"targets").reduce((t,s)=>Object.assign(t,Li(s)),{})}function Li(r){return{[`${r}Target`]:{get(){let e=this.targets.find(r);if(e)return e;throw new Error(`Missing target element "${r}" for "${this.identifier}" controller`)}},[`${r}Targets`]:{get(){return this.targets.findAll(r)}},[`has${ee(r)}Target`]:{get(){return this.targets.has(r)}}}}function ki(r){let e=ci(r,"values"),t={valueDescriptorMap:{get(){return e.reduce((s,i)=>{let n=Ts(i,this.identifier),o=this.data.getAttributeNameForKey(n.key);return Object.assign(s,{[o]:n})},{})}}};return e.reduce((s,i)=>Object.assign(s,Oi(i)),t)}function Oi(r,e){let t=Ts(r,e),{key:s,name:i,reader:n,writer:o}=t;return{[i]:{get(){let a=this.data.get(s);return a!==null?n(a):t.defaultValue},set(a){a===void 0?this.data.delete(s):this.data.set(s,o(a))}},[`has${ee(i)}`]:{get(){return this.data.has(s)||t.hasCustomDefaultValue}}}}function Ts([r,e],t){return Pi({controller:t,token:r,typeDefinition:e})}function Be(r){switch(r){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function Z(r){switch(typeof r){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(r))return"array";if(Object.prototype.toString.call(r)==="[object Object]")return"object"}function Mi(r){let{controller:e,token:t,typeObject:s}=r,i=ds(s.type),n=ds(s.default),o=i&&n,a=i&&!n,l=!i&&n,m=Be(s.type),M=Z(r.typeObject.default);if(a)return m;if(l)return M;if(m!==M){let A=e?`${e}.${t}`:t;throw new Error(`The specified default value for the Stimulus Value "${A}" must match the defined type "${m}". The provided default value of "${s.default}" is of type "${M}".`)}if(o)return m}function Fi(r){let{controller:e,token:t,typeDefinition:s}=r,n=Mi({controller:e,token:t,typeObject:s}),o=Z(s),a=Be(s),l=n||o||a;if(l)return l;let m=e?`${e}.${s}`:t;throw new Error(`Unknown value type "${m}" for "${t}" value`)}function Ri(r){let e=Be(r);if(e)return bs[e];let t=Et(r,"default"),s=Et(r,"type"),i=r;if(t)return i.default;if(s){let{type:n}=i,o=Be(n);if(o)return bs[o]}return r}function Pi(r){let{token:e,typeDefinition:t}=r,s=`${Es(e)}-value`,i=Fi(r);return{type:i,key:s,name:$t(s),get defaultValue(){return Ri(t)},get hasCustomDefaultValue(){return Z(t)!==void 0},reader:Bi[i],writer:ys[i]||ys.default}}var bs={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},Bi={array(r){let e=JSON.parse(r);if(!Array.isArray(e))throw new TypeError(`expected value of type "array" but instead got value "${r}" of type "${Z(e)}"`);return e},boolean(r){return!(r=="0"||String(r).toLowerCase()=="false")},number(r){return Number(r.replace(/_/g,""))},object(r){let e=JSON.parse(r);if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(`expected value of type "object" but instead got value "${r}" of type "${Z(e)}"`);return e},string(r){return r}},ys={default:Ii,array:ws,object:ws};function ws(r){return JSON.stringify(r)}function Ii(r){return`${r}`}var b=class{constructor(e){this.context=e}static get shouldLoad(){return!0}static afterLoad(e,t){}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:i=this.identifier,bubbles:n=!0,cancelable:o=!0}={}){let a=i?`${i}:${e}`:e,l=new CustomEvent(a,{detail:s,bubbles:n,cancelable:o});return t.dispatchEvent(l),l}};b.blessings=[Ei,Ci,ki,Ai];b.targets=[];b.outlets=[];b.values={};var se=Pe.start();se.debug=!1;window.Stimulus=se;var Ie=class extends b{static values={isDspAd:{type:Boolean,default:!0},isSplash:{type:Boolean,default:!1}};static targets=["adType","slot","splashUiType","splashCountdown","smCover","mdCover","lgCover","baseCover","schemeUrl"];connect(){this.render()}handleAdTypeChnage(r){this.isDspAdValue=r.target.value=="dsp",this.render()}handleSlotChange(r){let e=r.target[r.target.selectedIndex].getAttribute("data-is-splash");this.isSplashValue=e==="true",this.render()}render(){if(this.isSplashValue)if(this.isDspAdValue){this.schemeUrlTarget.style.display="none";let r=this.schemeUrlTarget.querySelector("input[type='text']");r&&(r.value=null),this.smCoverTarget.style.display="none";let e=this.smCoverTarget.querySelector("input[type='file']");e&&(e.value=null),this.mdCoverTarget.style.display="none";let t=this.mdCoverTarget.querySelector("input[type='file']");t&&(t.value=null),this.lgCoverTarget.style.display="none";let s=this.lgCoverTarget.querySelector("input[type='file']");s&&(s.value=null),this.baseCoverTarget.style.display="none";let i=this.baseCoverTarget.querySelector("input[type='file']");i&&(i.value=null),this.splashCountdownTarget.style.display="block",this.splashUiTypeTarget.style.display="block"}else this.splashCountdownTarget.style.display="block",this.splashUiTypeTarget.style.display="block",this.smCoverTarget.style.display="block",this.mdCoverTarget.style.display="block",this.lgCoverTarget.style.display="block",this.baseCoverTarget.style.display="block",this.schemeUrlTarget.style.display="block";else if(this.isDspAdValue){this.schemeUrlTarget.style.display="none";let r=this.schemeUrlTarget.querySelector("input[type='text']");r&&(r.value=null),this.splashCountdownTarget.style.display="none";let e=this.splashCountdownTarget.querySelector("input[type='number']");e&&(e.value=5),this.splashUiTypeTarget.style.display="none";let t=this.splashUiTypeTarget.querySelector("select");t&&(t.value="half"),this.smCoverTarget.style.display="none";let s=this.smCoverTarget.querySelector("input[type='file']");s&&(s.value=null),this.mdCoverTarget.style.display="none";let i=this.mdCoverTarget.querySelector("input[type='file']");i&&(i.value=null),this.lgCoverTarget.style.display="none";let n=this.lgCoverTarget.querySelector("input[type='file']");n&&(n.value=null),this.baseCoverTarget.style.display="none";let o=this.baseCoverTarget.querySelector("input[type='file']");o&&(o.value=null)}else{this.schemeUrlTarget.style.display="block",this.baseCoverTarget.style.display="block",this.splashCountdownTarget.style.display="none";let r=this.splashCountdownTarget.querySelector("input[type='number']");r&&(r.value=5),this.splashUiTypeTarget.style.display="none";let e=this.splashUiTypeTarget.querySelector("select");e&&(e.value="half"),this.smCoverTarget.style.display="none";let t=this.smCoverTarget.querySelector("input[type='file']");t&&(t.value=null),this.mdCoverTarget.style.display="none";let s=this.mdCoverTarget.querySelector("input[type='file']");s&&(s.value=null),this.lgCoverTarget.style.display="none";let i=this.lgCoverTarget.querySelector("input[type='file']");i&&(i.value=null)}}};var re=class{constructor(e){this.response=e}get statusCode(){return this.response.status}get redirected(){return this.response.redirected}get ok(){return this.response.ok}get unauthenticated(){return this.statusCode===401}get unprocessableEntity(){return this.statusCode===422}get authenticationURL(){return this.response.headers.get("WWW-Authenticate")}get contentType(){return(this.response.headers.get("Content-Type")||"").replace(/;.*$/,"")}get headers(){return this.response.headers}get html(){return this.contentType.match(/^(application|text)\/(html|xhtml\+xml)$/)?this.text:Promise.reject(new Error(`Expected an HTML response but got "${this.contentType}" instead`))}get json(){return this.contentType.match(/^application\/.*json$/)?this.responseJson||(this.responseJson=this.response.json()):Promise.reject(new Error(`Expected a JSON response but got "${this.contentType}" instead`))}get text(){return this.responseText||(this.responseText=this.response.text())}get isTurboStream(){return this.contentType.match(/^text\/vnd\.turbo-stream\.html/)}async renderTurboStream(){if(this.isTurboStream)window.Turbo?await window.Turbo.renderStreamMessage(await this.text):console.warn("You must set `window.Turbo = Turbo` to automatically process Turbo Stream events with request.js");else return Promise.reject(new Error(`Expected a Turbo Stream response but got "${this.contentType}" instead`))}};var ie=class{static register(e){this.interceptor=e}static get(){return this.interceptor}static reset(){this.interceptor=void 0}};function Cs(r){let e=document.cookie?document.cookie.split("; "):[],t=`${encodeURIComponent(r)}=`,s=e.find(i=>i.startsWith(t));if(s){let i=s.split("=").slice(1).join("=");if(i)return decodeURIComponent(i)}}function Ls(r){let e={};for(let t in r){let s=r[t];s!==void 0&&(e[t]=s)}return e}function _t(r){let e=document.head.querySelector(`meta[name="${r}"]`);return e&&e.content}function ks(r){return[...r].reduce((e,[t,s])=>e.concat(typeof s=="string"?[[t,s]]:[]),[])}function Os(r,e){for(let[t,s]of e)s instanceof window.File||(r.has(t)&&!t.includes("[]")?(r.delete(t),r.set(t,s)):r.append(t,s))}var ne=class{constructor(e,t,s={}){this.method=e,this.options=s,this.originalUrl=t.toString()}async perform(){try{let s=ie.get();s&&await s(this)}catch(s){console.error(s)}let e=new re(await window.fetch(this.url,this.fetchOptions));return e.unauthenticated&&e.authenticationURL?Promise.reject(window.location.href=e.authenticationURL):((e.ok||e.unprocessableEntity)&&e.isTurboStream&&await e.renderTurboStream(),e)}addHeader(e,t){let s=this.additionalHeaders;s[e]=t,this.options.headers=s}sameHostname(){if(!this.originalUrl.startsWith("http:"))return!0;try{return new URL(this.originalUrl).hostname===window.location.hostname}catch{return!0}}get fetchOptions(){return{method:this.method.toUpperCase(),headers:this.headers,body:this.formattedBody,signal:this.signal,credentials:this.credentials,redirect:this.redirect}}get headers(){let e={"X-Requested-With":"XMLHttpRequest","Content-Type":this.contentType,Accept:this.accept};return this.sameHostname()&&(e["X-CSRF-Token"]=this.csrfToken),Ls(Object.assign(e,this.additionalHeaders))}get csrfToken(){return Cs(_t("csrf-param"))||_t("csrf-token")}get contentType(){return this.options.contentType?this.options.contentType:this.body==null||this.body instanceof window.FormData?void 0:this.body instanceof window.File?this.body.type:"application/json"}get accept(){switch(this.responseKind){case"html":return"text/html, application/xhtml+xml";case"turbo-stream":return"text/vnd.turbo-stream.html, text/html, application/xhtml+xml";case"json":return"application/json, application/vnd.api+json";default:return"*/*"}}get body(){return this.options.body}get query(){let e=(this.originalUrl.split("?")[1]||"").split("#")[0],t=new URLSearchParams(e),s=this.options.query;s instanceof window.FormData?s=ks(s):s instanceof window.URLSearchParams?s=s.entries():s=Object.entries(s||{}),Os(t,s);let i=t.toString();return i.length>0?`?${i}`:""}get url(){return this.originalUrl.split("?")[0].split("#")[0]+this.query}get responseKind(){return this.options.responseKind||"html"}get signal(){return this.options.signal}get redirect(){return this.options.redirect||"follow"}get credentials(){return this.options.credentials||"same-origin"}get additionalHeaders(){return this.options.headers||{}}get formattedBody(){let e=Object.prototype.toString.call(this.body)==="[object String]";return this.headers["Content-Type"]==="application/json"&&!e?JSON.stringify(this.body):this.body}};async function Ut(r,e){return new ne("delete",r,e).perform()}var xe=class extends b{static targets=["input","preview","removeButton"];static values={url:{type:String,default:null}};connect(){this.inputTarget.addEventListener("change",this.preview.bind(this)),this.removeButtonTarget.addEventListener("click",this.remove.bind(this))}preview(){let r=this.inputTarget.files[0];if(r){let e=new FileReader;e.onload=t=>{this.previewTarget.src=t.target.result,this.removeButtonTarget.style.display="block"},e.readAsDataURL(r)}else this.previewTarget.src="",this.removeButtonTarget.style.display="none"}async remove(){this.urlValue?(await Ut(this.urlValue)).ok&&(this.inputTarget.value="",this.previewTarget.src="",this.removeButtonTarget.style.display="none"):(this.inputTarget.value="",this.previewTarget.src="",this.removeButtonTarget.style.display="none")}};se.register("hello",Ie);se.register("image-upload",xe);})();
|
31
|
+
//# sourceMappingURL=application.js.map
|