phoenix_live_view 0.18.0 → 0.18.2

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.
@@ -189,7 +189,7 @@ var LiveView = (() => {
189
189
  };
190
190
  var closestPhxBinding = (el, binding, borderEl) => {
191
191
  do {
192
- if (el.matches(`[${binding}]`)) {
192
+ if (el.matches(`[${binding}]`) && !el.disabled) {
193
193
  return el;
194
194
  }
195
195
  el = el.parentElement || el.parentNode;
@@ -2329,8 +2329,6 @@ within:
2329
2329
  flash: this.flash
2330
2330
  };
2331
2331
  });
2332
- this.showLoader(this.liveSocket.loaderTimeout);
2333
- this.bindChannel();
2334
2332
  }
2335
2333
  setHref(href) {
2336
2334
  this.href = href;
@@ -2793,6 +2791,8 @@ within:
2793
2791
  this.isDead = true;
2794
2792
  }
2795
2793
  join(callback) {
2794
+ this.showLoader(this.liveSocket.loaderTimeout);
2795
+ this.bindChannel();
2796
2796
  if (this.isMain()) {
2797
2797
  this.stopCallback = this.liveSocket.withPageLoading({ to: this.href, kind: "initial" });
2798
2798
  }
@@ -3795,7 +3795,7 @@ within:
3795
3795
  }
3796
3796
  }
3797
3797
  bindClicks() {
3798
- window.addEventListener("mousedown", (e) => this.clickStartedAtTarget = e.target);
3798
+ window.addEventListener("click", (e) => this.clickStartedAtTarget = e.target);
3799
3799
  this.bindClick("click", "click", false);
3800
3800
  this.bindClick("mousedown", "capture-click", true);
3801
3801
  }
@@ -1,4 +1,4 @@
1
- var LiveView=(()=>{var Ye=Object.defineProperty;var bt=Object.getOwnPropertySymbols;var Qt=Object.prototype.hasOwnProperty,Zt=Object.prototype.propertyIsEnumerable;var Et=(r,e,t)=>e in r?Ye(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ne=(r,e)=>{for(var t in e||(e={}))Qt.call(e,t)&&Et(r,t,e[t]);if(bt)for(var t of bt(e))Zt.call(e,t)&&Et(r,t,e[t]);return r};var ei=r=>Ye(r,"__esModule",{value:!0});var ti=(r,e)=>{ei(r);for(var t in e)Ye(r,t,{get:e[t],enumerable:!0})};var Si={};ti(Si,{LiveSocket:()=>Ke});var ke="consecutive-reloads",_t=10,St=5e3,At=1e4,yt=3e4,Ie=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading"],x="data-phx-component",Le="data-phx-link",Pt="track-static",wt="data-phx-link-state",L="data-phx-ref",j="data-phx-ref-src",De="track-uploads",M="data-phx-upload-ref",oe="data-phx-preflighted-refs",xt="data-phx-done-refs",Qe="drop-target",me="data-phx-active-refs",ae="phx:live-file:updated",ge="data-phx-skip",Ze="data-phx-prune",et="page-loading",tt="phx-connected",Re="phx-loading",it="phx-no-feedback",rt="phx-error",W="data-phx-parent-id",le="data-phx-main",K="data-phx-root-id",Tt="trigger-action",ve="feedback-for",Oe="phx-has-focused",Ct=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],He=["checkbox","radio"],Ne="phx-has-submitted",D="data-phx-session",J=`[${D}]`,st="data-phx-sticky",Y="data-phx-static",Fe="data-phx-readonly",be="data-phx-disabled",Ee="disable-with",_e="data-phx-disable-with-restore",he="hook",kt="debounce",It="throttle",Se="update",Lt="key",U="phxPrivate",nt="auto-recover",Ae="phx:live-socket:debug",Me="phx:live-socket:profiling",Ue="phx:live-socket:latency-sim",Dt="progress",ot="mounted",Rt=1,Ot=200,Ht="phx-",Nt=3e4;var de="debounce-trigger",ye="throttled",at="debounce-prev-key",Ft={debounce:300,throttle:300},lt="d",X="s",k="c",ht="e",dt="r",ut="t",Mt="p";var Xe=class{constructor(e,t,i){this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=t,this.chunkTimer=null,this.uploadChannel=i.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){clearTimeout(this.chunkTimer),this.uploadChannel.leave(),this.entry.error(e)}upload(){this.uploadChannel.onError(e=>this.error(e)),this.uploadChannel.join().receive("ok",e=>this.readNextChunk()).receive("error",e=>this.error(e))}isDone(){return this.offset>=this.entry.file.size}readNextChunk(){let e=new window.FileReader,t=this.entry.file.slice(this.offset,this.chunkSize+this.offset);e.onload=i=>{if(i.target.error===null)this.offset+=i.target.result.byteLength,this.pushChunk(i.target.result);else return P("Read error: "+i.target.error)},e.readAsArrayBuffer(t)}pushChunk(e){!this.uploadChannel.isJoined()||this.uploadChannel.push("chunk",e).receive("ok",()=>{this.entry.progress(this.offset/this.entry.file.size*100),this.isDone()||(this.chunkTimer=setTimeout(()=>this.readNextChunk(),this.liveSocket.getLatencySim()||0))})}};var P=(r,e)=>console.error&&console.error(r,e),$=r=>{let e=typeof r;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(r)};function Ut(){let r=new Set,e=document.querySelectorAll("*[id]");for(let t=0,i=e.length;t<i;t++)r.has(e[t].id)?console.error(`Multiple IDs detected: ${e[t].id}. Ensure unique element ids.`):r.add(e[t].id)}var Xt=(r,e,t,i)=>{r.liveSocket.isDebugEnabled()&&console.log(`${r.id} ${e}: ${t} - `,i)},$e=r=>typeof r=="function"?r:function(){return r},ue=r=>JSON.parse(JSON.stringify(r)),te=(r,e,t)=>{do{if(r.matches(`[${e}]`))return r;r=r.parentElement||r.parentNode}while(r!==null&&r.nodeType===1&&!(t&&t.isSameNode(r)||r.matches(J)));return null},ce=r=>r!==null&&typeof r=="object"&&!(r instanceof Array),$t=(r,e)=>JSON.stringify(r)===JSON.stringify(e),ct=r=>{for(let e in r)return!1;return!0},R=(r,e)=>r&&e(r),Bt=function(r,e,t,i){r.forEach(s=>{new Xe(s,t.config.chunk_size,i).upload()})};var Vt={canPushState(){return typeof history.pushState!="undefined"},dropLocal(r,e,t){return r.removeItem(this.localKey(e,t))},updateLocal(r,e,t,i,s){let n=this.getLocal(r,e,t),o=this.localKey(e,t),a=n===null?i:s(n);return r.setItem(o,JSON.stringify(a)),a},getLocal(r,e,t){return JSON.parse(r.getItem(this.localKey(e,t)))},updateCurrentState(r){!this.canPushState()||history.replaceState(r(history.state||{}),"",window.location.href)},pushState(r,e,t){if(this.canPushState()){if(t!==window.location.href){if(e.type=="redirect"&&e.scroll){let s=history.state||{};s.scroll=e.scroll,history.replaceState(s,"",window.location.href)}delete e.scroll,history[r+"State"](e,"",t||null);let i=this.getHashTargetEl(window.location.hash);i?i.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)}}else this.redirect(t)},setCookie(r,e){document.cookie=`${r}=${e}`},getCookie(r){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${r}s*=s*([^;]*).*$)|^.*$`),"$1")},redirect(r,e){e&&Vt.setCookie("__phoenix_flash__",e+"; max-age=60000; path=/"),window.location=r},localKey(r,e){return`${r}-${e}`},getHashTargetEl(r){let e=r.toString().substring(1);if(e!=="")return document.getElementById(e)||document.querySelector(`a[name="${e}"]`)}},O=Vt;var B={byId(r){return document.getElementById(r)||P(`no id found for ${r}`)},removeClass(r,e){r.classList.remove(e),r.classList.length===0&&r.removeAttribute("class")},all(r,e,t){if(!r)return[];let i=Array.from(r.querySelectorAll(e));return t?i.forEach(t):i},childNodeLength(r){let e=document.createElement("template");return e.innerHTML=r,e.content.childElementCount},isUploadInput(r){return r.type==="file"&&r.getAttribute(M)!==null},findUploadInputs(r){return this.all(r,`input[type="file"][${M}]`)},findComponentNodeList(r,e){return this.filterWithinSameLiveView(this.all(r,`[${x}="${e}"]`),r)},isPhxDestroyed(r){return!!(r.id&&B.private(r,"destroyed"))},markPhxChildDestroyed(r){this.isPhxChild(r)&&r.setAttribute(D,""),this.putPrivate(r,"destroyed",!0)},findPhxChildrenInFragment(r,e){let t=document.createElement("template");return t.innerHTML=r,this.findPhxChildren(t.content,e)},isIgnored(r,e){return(r.getAttribute(e)||r.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(r,e,t){return r.getAttribute&&t.indexOf(r.getAttribute(e))>=0},findPhxSticky(r){return this.all(r,`[${st}]`)},findPhxChildren(r,e){return this.all(r,`${J}[${W}="${e}"]`)},findParentCIDs(r,e){let t=new Set(e),i=e.reduce((s,n)=>{let o=`[${x}="${n}"] [${x}]`;return this.filterWithinSameLiveView(this.all(r,o),r).map(a=>parseInt(a.getAttribute(x))).forEach(a=>s.delete(a)),s},t);return i.size===0?new Set(e):i},filterWithinSameLiveView(r,e){return e.querySelector(J)?r.filter(t=>this.withinSameLiveView(t,e)):r},withinSameLiveView(r,e){for(;r=r.parentNode;){if(r.isSameNode(e))return!0;if(r.getAttribute(D)!==null)return!1}},private(r,e){return r[U]&&r[U][e]},deletePrivate(r,e){r[U]&&delete r[U][e]},putPrivate(r,e,t){r[U]||(r[U]={}),r[U][e]=t},updatePrivate(r,e,t,i){let s=this.private(r,e);s===void 0?this.putPrivate(r,e,i(t)):this.putPrivate(r,e,i(s))},copyPrivates(r,e){e[U]&&(r[U]=e[U])},putTitle(r){let e=document.querySelector("title"),{prefix:t,suffix:i}=e.dataset;document.title=`${t||""}${r}${i||""}`},debounce(r,e,t,i,s,n,o,a){let l=r.getAttribute(t),d=r.getAttribute(s);l===""&&(l=i),d===""&&(d=n);let f=l||d;switch(f){case null:return a();case"blur":this.once(r,"debounce-blur")&&r.addEventListener("blur",()=>a());return;default:let c=parseInt(f),p=()=>d?this.deletePrivate(r,ye):a(),E=this.incCycle(r,de,p);if(isNaN(c))return P(`invalid throttle/debounce value: ${f}`);if(d){let v=!1;if(e.type==="keydown"){let w=this.private(r,at);this.putPrivate(r,at,e.key),v=w!==e.key}if(!v&&this.private(r,ye))return!1;a(),this.putPrivate(r,ye,!0),setTimeout(()=>{o()&&this.triggerCycle(r,de)},c)}else setTimeout(()=>{o()&&this.triggerCycle(r,de,E)},c);let _=r.form;_&&this.once(_,"bind-debounce")&&_.addEventListener("submit",()=>{Array.from(new FormData(_).entries(),([v])=>{let w=_.querySelector(`[name="${v}"]`);this.incCycle(w,de),this.deletePrivate(w,ye)})}),this.once(r,"bind-debounce")&&r.addEventListener("blur",()=>this.triggerCycle(r,de))}},triggerCycle(r,e,t){let[i,s]=this.private(r,e);t||(t=i),t===i&&(this.incCycle(r,e),s())},once(r,e){return this.private(r,e)===!0?!1:(this.putPrivate(r,e,!0),!0)},incCycle(r,e,t=function(){}){let[i]=this.private(r,e)||[0,t];return i++,this.putPrivate(r,e,[i,t]),i},discardError(r,e,t){let i=e.getAttribute&&e.getAttribute(t),s=i&&r.querySelector(`[id="${i}"], [name="${i}"], [name="${i}[]"]`);!s||this.private(s,Oe)||this.private(s.form,Ne)||e.classList.add(it)},showError(r,e){(r.id||r.name)&&this.all(r.form,`[${e}="${r.id}"], [${e}="${r.name}"]`,t=>{this.removeClass(t,it)})},isPhxChild(r){return r.getAttribute&&r.getAttribute(W)},isPhxSticky(r){return r.getAttribute&&r.getAttribute(st)!==null},firstPhxChild(r){return this.isPhxChild(r)?r:this.all(r,`[${W}]`)[0]},dispatchEvent(r,e,t={}){let s={bubbles:t.bubbles===void 0?!0:!!t.bubbles,cancelable:!0,detail:t.detail||{}},n=e==="click"?new MouseEvent("click",s):new CustomEvent(e,s);r.dispatchEvent(n)},cloneNode(r,e){if(typeof e=="undefined")return r.cloneNode(!0);{let t=r.cloneNode(!1);return t.innerHTML=e,t}},mergeAttrs(r,e,t={}){let i=t.exclude||[],s=t.isIgnored,n=e.attributes;for(let a=n.length-1;a>=0;a--){let l=n[a].name;i.indexOf(l)<0&&r.setAttribute(l,e.getAttribute(l))}let o=r.attributes;for(let a=o.length-1;a>=0;a--){let l=o[a].name;s?l.startsWith("data-")&&!e.hasAttribute(l)&&r.removeAttribute(l):e.hasAttribute(l)||r.removeAttribute(l)}},mergeFocusedInput(r,e){r instanceof HTMLSelectElement||B.mergeAttrs(r,e,{exclude:["value"]}),e.readOnly?r.setAttribute("readonly",!0):r.removeAttribute("readonly")},hasSelectionRange(r){return r.setSelectionRange&&(r.type==="text"||r.type==="textarea")},restoreFocus(r,e,t){if(!B.isTextualInput(r))return;let i=r.matches(":focus");r.readOnly&&r.blur(),i||r.focus(),this.hasSelectionRange(r)&&r.setSelectionRange(e,t)},isFormInput(r){return/^(?:input|select|textarea)$/i.test(r.tagName)&&r.type!=="button"},syncAttrsToProps(r){r instanceof HTMLInputElement&&He.indexOf(r.type.toLocaleLowerCase())>=0&&(r.checked=r.getAttribute("checked")!==null)},isTextualInput(r){return Ct.indexOf(r.type)>=0},isNowTriggerFormExternal(r,e){return r.getAttribute&&r.getAttribute(e)!==null},syncPendingRef(r,e,t){let i=r.getAttribute(L);if(i===null)return!0;let s=r.getAttribute(j);return B.isFormInput(r)||r.getAttribute(t)!==null?(B.isUploadInput(r)&&B.mergeAttrs(r,e,{isIgnored:!0}),B.putPrivate(r,L,e),!1):(Ie.forEach(n=>{r.classList.contains(n)&&e.classList.add(n)}),e.setAttribute(L,i),e.setAttribute(j,s),!0)},cleanChildNodes(r,e){if(B.isPhxUpdate(r,e,["append","prepend"])){let t=[];r.childNodes.forEach(i=>{i.id||(i.nodeType===Node.TEXT_NODE&&i.nodeValue.trim()===""||P(`only HTML element tags with an id are allowed inside containers with phx-update.
1
+ var LiveView=(()=>{var Ye=Object.defineProperty;var bt=Object.getOwnPropertySymbols;var Qt=Object.prototype.hasOwnProperty,Zt=Object.prototype.propertyIsEnumerable;var Et=(r,e,t)=>e in r?Ye(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ne=(r,e)=>{for(var t in e||(e={}))Qt.call(e,t)&&Et(r,t,e[t]);if(bt)for(var t of bt(e))Zt.call(e,t)&&Et(r,t,e[t]);return r};var ei=r=>Ye(r,"__esModule",{value:!0});var ti=(r,e)=>{ei(r);for(var t in e)Ye(r,t,{get:e[t],enumerable:!0})};var Si={};ti(Si,{LiveSocket:()=>Ke});var ke="consecutive-reloads",_t=10,St=5e3,At=1e4,yt=3e4,Ie=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading"],x="data-phx-component",Le="data-phx-link",Pt="track-static",wt="data-phx-link-state",L="data-phx-ref",j="data-phx-ref-src",De="track-uploads",M="data-phx-upload-ref",oe="data-phx-preflighted-refs",xt="data-phx-done-refs",Qe="drop-target",me="data-phx-active-refs",ae="phx:live-file:updated",ge="data-phx-skip",Ze="data-phx-prune",et="page-loading",tt="phx-connected",Re="phx-loading",it="phx-no-feedback",rt="phx-error",W="data-phx-parent-id",le="data-phx-main",K="data-phx-root-id",Tt="trigger-action",ve="feedback-for",Oe="phx-has-focused",Ct=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],He=["checkbox","radio"],Ne="phx-has-submitted",D="data-phx-session",J=`[${D}]`,st="data-phx-sticky",Y="data-phx-static",Fe="data-phx-readonly",be="data-phx-disabled",Ee="disable-with",_e="data-phx-disable-with-restore",he="hook",kt="debounce",It="throttle",Se="update",Lt="key",U="phxPrivate",nt="auto-recover",Ae="phx:live-socket:debug",Me="phx:live-socket:profiling",Ue="phx:live-socket:latency-sim",Dt="progress",ot="mounted",Rt=1,Ot=200,Ht="phx-",Nt=3e4;var de="debounce-trigger",ye="throttled",at="debounce-prev-key",Ft={debounce:300,throttle:300},lt="d",X="s",k="c",ht="e",dt="r",ut="t",Mt="p";var Xe=class{constructor(e,t,i){this.liveSocket=i,this.entry=e,this.offset=0,this.chunkSize=t,this.chunkTimer=null,this.uploadChannel=i.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){clearTimeout(this.chunkTimer),this.uploadChannel.leave(),this.entry.error(e)}upload(){this.uploadChannel.onError(e=>this.error(e)),this.uploadChannel.join().receive("ok",e=>this.readNextChunk()).receive("error",e=>this.error(e))}isDone(){return this.offset>=this.entry.file.size}readNextChunk(){let e=new window.FileReader,t=this.entry.file.slice(this.offset,this.chunkSize+this.offset);e.onload=i=>{if(i.target.error===null)this.offset+=i.target.result.byteLength,this.pushChunk(i.target.result);else return P("Read error: "+i.target.error)},e.readAsArrayBuffer(t)}pushChunk(e){!this.uploadChannel.isJoined()||this.uploadChannel.push("chunk",e).receive("ok",()=>{this.entry.progress(this.offset/this.entry.file.size*100),this.isDone()||(this.chunkTimer=setTimeout(()=>this.readNextChunk(),this.liveSocket.getLatencySim()||0))})}};var P=(r,e)=>console.error&&console.error(r,e),$=r=>{let e=typeof r;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(r)};function Ut(){let r=new Set,e=document.querySelectorAll("*[id]");for(let t=0,i=e.length;t<i;t++)r.has(e[t].id)?console.error(`Multiple IDs detected: ${e[t].id}. Ensure unique element ids.`):r.add(e[t].id)}var Xt=(r,e,t,i)=>{r.liveSocket.isDebugEnabled()&&console.log(`${r.id} ${e}: ${t} - `,i)},$e=r=>typeof r=="function"?r:function(){return r},ue=r=>JSON.parse(JSON.stringify(r)),te=(r,e,t)=>{do{if(r.matches(`[${e}]`)&&!r.disabled)return r;r=r.parentElement||r.parentNode}while(r!==null&&r.nodeType===1&&!(t&&t.isSameNode(r)||r.matches(J)));return null},ce=r=>r!==null&&typeof r=="object"&&!(r instanceof Array),$t=(r,e)=>JSON.stringify(r)===JSON.stringify(e),ct=r=>{for(let e in r)return!1;return!0},R=(r,e)=>r&&e(r),Bt=function(r,e,t,i){r.forEach(s=>{new Xe(s,t.config.chunk_size,i).upload()})};var Vt={canPushState(){return typeof history.pushState!="undefined"},dropLocal(r,e,t){return r.removeItem(this.localKey(e,t))},updateLocal(r,e,t,i,s){let n=this.getLocal(r,e,t),o=this.localKey(e,t),a=n===null?i:s(n);return r.setItem(o,JSON.stringify(a)),a},getLocal(r,e,t){return JSON.parse(r.getItem(this.localKey(e,t)))},updateCurrentState(r){!this.canPushState()||history.replaceState(r(history.state||{}),"",window.location.href)},pushState(r,e,t){if(this.canPushState()){if(t!==window.location.href){if(e.type=="redirect"&&e.scroll){let s=history.state||{};s.scroll=e.scroll,history.replaceState(s,"",window.location.href)}delete e.scroll,history[r+"State"](e,"",t||null);let i=this.getHashTargetEl(window.location.hash);i?i.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)}}else this.redirect(t)},setCookie(r,e){document.cookie=`${r}=${e}`},getCookie(r){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${r}s*=s*([^;]*).*$)|^.*$`),"$1")},redirect(r,e){e&&Vt.setCookie("__phoenix_flash__",e+"; max-age=60000; path=/"),window.location=r},localKey(r,e){return`${r}-${e}`},getHashTargetEl(r){let e=r.toString().substring(1);if(e!=="")return document.getElementById(e)||document.querySelector(`a[name="${e}"]`)}},O=Vt;var B={byId(r){return document.getElementById(r)||P(`no id found for ${r}`)},removeClass(r,e){r.classList.remove(e),r.classList.length===0&&r.removeAttribute("class")},all(r,e,t){if(!r)return[];let i=Array.from(r.querySelectorAll(e));return t?i.forEach(t):i},childNodeLength(r){let e=document.createElement("template");return e.innerHTML=r,e.content.childElementCount},isUploadInput(r){return r.type==="file"&&r.getAttribute(M)!==null},findUploadInputs(r){return this.all(r,`input[type="file"][${M}]`)},findComponentNodeList(r,e){return this.filterWithinSameLiveView(this.all(r,`[${x}="${e}"]`),r)},isPhxDestroyed(r){return!!(r.id&&B.private(r,"destroyed"))},markPhxChildDestroyed(r){this.isPhxChild(r)&&r.setAttribute(D,""),this.putPrivate(r,"destroyed",!0)},findPhxChildrenInFragment(r,e){let t=document.createElement("template");return t.innerHTML=r,this.findPhxChildren(t.content,e)},isIgnored(r,e){return(r.getAttribute(e)||r.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(r,e,t){return r.getAttribute&&t.indexOf(r.getAttribute(e))>=0},findPhxSticky(r){return this.all(r,`[${st}]`)},findPhxChildren(r,e){return this.all(r,`${J}[${W}="${e}"]`)},findParentCIDs(r,e){let t=new Set(e),i=e.reduce((s,n)=>{let o=`[${x}="${n}"] [${x}]`;return this.filterWithinSameLiveView(this.all(r,o),r).map(a=>parseInt(a.getAttribute(x))).forEach(a=>s.delete(a)),s},t);return i.size===0?new Set(e):i},filterWithinSameLiveView(r,e){return e.querySelector(J)?r.filter(t=>this.withinSameLiveView(t,e)):r},withinSameLiveView(r,e){for(;r=r.parentNode;){if(r.isSameNode(e))return!0;if(r.getAttribute(D)!==null)return!1}},private(r,e){return r[U]&&r[U][e]},deletePrivate(r,e){r[U]&&delete r[U][e]},putPrivate(r,e,t){r[U]||(r[U]={}),r[U][e]=t},updatePrivate(r,e,t,i){let s=this.private(r,e);s===void 0?this.putPrivate(r,e,i(t)):this.putPrivate(r,e,i(s))},copyPrivates(r,e){e[U]&&(r[U]=e[U])},putTitle(r){let e=document.querySelector("title"),{prefix:t,suffix:i}=e.dataset;document.title=`${t||""}${r}${i||""}`},debounce(r,e,t,i,s,n,o,a){let l=r.getAttribute(t),d=r.getAttribute(s);l===""&&(l=i),d===""&&(d=n);let f=l||d;switch(f){case null:return a();case"blur":this.once(r,"debounce-blur")&&r.addEventListener("blur",()=>a());return;default:let c=parseInt(f),p=()=>d?this.deletePrivate(r,ye):a(),E=this.incCycle(r,de,p);if(isNaN(c))return P(`invalid throttle/debounce value: ${f}`);if(d){let v=!1;if(e.type==="keydown"){let w=this.private(r,at);this.putPrivate(r,at,e.key),v=w!==e.key}if(!v&&this.private(r,ye))return!1;a(),this.putPrivate(r,ye,!0),setTimeout(()=>{o()&&this.triggerCycle(r,de)},c)}else setTimeout(()=>{o()&&this.triggerCycle(r,de,E)},c);let _=r.form;_&&this.once(_,"bind-debounce")&&_.addEventListener("submit",()=>{Array.from(new FormData(_).entries(),([v])=>{let w=_.querySelector(`[name="${v}"]`);this.incCycle(w,de),this.deletePrivate(w,ye)})}),this.once(r,"bind-debounce")&&r.addEventListener("blur",()=>this.triggerCycle(r,de))}},triggerCycle(r,e,t){let[i,s]=this.private(r,e);t||(t=i),t===i&&(this.incCycle(r,e),s())},once(r,e){return this.private(r,e)===!0?!1:(this.putPrivate(r,e,!0),!0)},incCycle(r,e,t=function(){}){let[i]=this.private(r,e)||[0,t];return i++,this.putPrivate(r,e,[i,t]),i},discardError(r,e,t){let i=e.getAttribute&&e.getAttribute(t),s=i&&r.querySelector(`[id="${i}"], [name="${i}"], [name="${i}[]"]`);!s||this.private(s,Oe)||this.private(s.form,Ne)||e.classList.add(it)},showError(r,e){(r.id||r.name)&&this.all(r.form,`[${e}="${r.id}"], [${e}="${r.name}"]`,t=>{this.removeClass(t,it)})},isPhxChild(r){return r.getAttribute&&r.getAttribute(W)},isPhxSticky(r){return r.getAttribute&&r.getAttribute(st)!==null},firstPhxChild(r){return this.isPhxChild(r)?r:this.all(r,`[${W}]`)[0]},dispatchEvent(r,e,t={}){let s={bubbles:t.bubbles===void 0?!0:!!t.bubbles,cancelable:!0,detail:t.detail||{}},n=e==="click"?new MouseEvent("click",s):new CustomEvent(e,s);r.dispatchEvent(n)},cloneNode(r,e){if(typeof e=="undefined")return r.cloneNode(!0);{let t=r.cloneNode(!1);return t.innerHTML=e,t}},mergeAttrs(r,e,t={}){let i=t.exclude||[],s=t.isIgnored,n=e.attributes;for(let a=n.length-1;a>=0;a--){let l=n[a].name;i.indexOf(l)<0&&r.setAttribute(l,e.getAttribute(l))}let o=r.attributes;for(let a=o.length-1;a>=0;a--){let l=o[a].name;s?l.startsWith("data-")&&!e.hasAttribute(l)&&r.removeAttribute(l):e.hasAttribute(l)||r.removeAttribute(l)}},mergeFocusedInput(r,e){r instanceof HTMLSelectElement||B.mergeAttrs(r,e,{exclude:["value"]}),e.readOnly?r.setAttribute("readonly",!0):r.removeAttribute("readonly")},hasSelectionRange(r){return r.setSelectionRange&&(r.type==="text"||r.type==="textarea")},restoreFocus(r,e,t){if(!B.isTextualInput(r))return;let i=r.matches(":focus");r.readOnly&&r.blur(),i||r.focus(),this.hasSelectionRange(r)&&r.setSelectionRange(e,t)},isFormInput(r){return/^(?:input|select|textarea)$/i.test(r.tagName)&&r.type!=="button"},syncAttrsToProps(r){r instanceof HTMLInputElement&&He.indexOf(r.type.toLocaleLowerCase())>=0&&(r.checked=r.getAttribute("checked")!==null)},isTextualInput(r){return Ct.indexOf(r.type)>=0},isNowTriggerFormExternal(r,e){return r.getAttribute&&r.getAttribute(e)!==null},syncPendingRef(r,e,t){let i=r.getAttribute(L);if(i===null)return!0;let s=r.getAttribute(j);return B.isFormInput(r)||r.getAttribute(t)!==null?(B.isUploadInput(r)&&B.mergeAttrs(r,e,{isIgnored:!0}),B.putPrivate(r,L,e),!1):(Ie.forEach(n=>{r.classList.contains(n)&&e.classList.add(n)}),e.setAttribute(L,i),e.setAttribute(j,s),!0)},cleanChildNodes(r,e){if(B.isPhxUpdate(r,e,["append","prepend"])){let t=[];r.childNodes.forEach(i=>{i.id||(i.nodeType===Node.TEXT_NODE&&i.nodeValue.trim()===""||P(`only HTML element tags with an id are allowed inside containers with phx-update.
2
2
 
3
3
  removing illegal node: "${(i.outerHTML||i.nodeValue).trim()}"
4
4
 
@@ -8,10 +8,10 @@ got: "${p.nodeValue.trim()}"
8
8
 
9
9
  within:
10
10
  `,n.innerHTML.trim()),p.replaceWith(this.createSpan(p.nodeValue,t)),[!0,c]):(p.remove(),[f,c]),[!1,!1]);return!l&&!d?(P(`expected at least one HTML element tag inside a component, but the component is empty:
11
- `,n.innerHTML.trim()),this.createSpan("",t).outerHTML):(!l&&d&&P("expected at least one HTML element tag directly inside a component, but only subcomponents were found. A component must render at least one HTML tag directly inside itself.",n.innerHTML.trim()),n.innerHTML)}createSpan(e,t){let i=document.createElement("span");return i.innerText=e,i.setAttribute(x,t),i}};var Ei=1,Z=class{static makeID(){return Ei++}static elementID(e){return e.phxHookId}constructor(e,t,i){this.__view=e,this.liveSocket=e.liveSocket,this.__callbacks=i,this.__listeners=new Set,this.__isDisconnected=!1,this.el=t,this.el.phxHookId=this.constructor.makeID();for(let s in this.__callbacks)this[s]=this.__callbacks[s]}__mounted(){this.mounted&&this.mounted()}__updated(){this.updated&&this.updated()}__beforeUpdate(){this.beforeUpdate&&this.beforeUpdate()}__destroyed(){this.destroyed&&this.destroyed()}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected&&this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected&&this.disconnected()}pushEvent(e,t={},i=function(){}){return this.__view.pushHookEvent(null,e,t,i)}pushEventTo(e,t,i={},s=function(){}){return this.__view.withinTargets(e,(n,o)=>n.pushHookEvent(o,t,i,s))}handleEvent(e,t){let i=(s,n)=>n?e:t(s.detail);return window.addEventListener(`phx:${e}`,i),this.__listeners.add(i),i}removeHandleEvent(e){let t=e(null,!0);window.removeEventListener(`phx:${t}`,e),this.__listeners.delete(e)}upload(e,t){return this.__view.dispatchUploads(e,t)}uploadTo(e,t,i){return this.__view.withinTargets(e,s=>s.dispatchUploads(t,i))}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var je=null,_i={exec(r,e,t,i,s){let[n,o]=s||[null,{}];(e.charAt(0)==="["?JSON.parse(e):[[n,o]]).forEach(([l,d])=>{l===n&&o.data&&(d.data=Object.assign(d.data||{},o.data)),this.filterToEls(i,d).forEach(f=>{this[`exec_${l}`](r,e,t,i,f,d)})})},isVisible(r){return!!(r.offsetWidth||r.offsetHeight||r.getClientRects().length>0)},exec_dispatch(r,e,t,i,s,{to:n,event:o,detail:a,bubbles:l}){a=a||{},a.dispatcher=i,h.dispatchEvent(s,o,{detail:a,bubbles:l})},exec_push(r,e,t,i,s,n){if(!t.isConnected())return;let{event:o,data:a,target:l,page_loading:d,loading:f,value:c,dispatcher:p}=n,E={loading:f,value:c,target:l,page_loading:!!d},_=r==="change"&&p?p:i,v=l||_.getAttribute(t.binding("target"))||_;t.withinTargets(v,(w,C)=>{if(r==="change"){let{newCid:V,_target:N,callback:u}=n;N=N||(i instanceof HTMLInputElement?i.name:void 0),N&&(E._target=N),w.pushInput(i,C,V,o||e,E,u)}else r==="submit"?w.submitForm(i,C,o||e,E):w.pushEvent(r,i,C,o||e,a,E)})},exec_navigate(r,e,t,i,s,{href:n,replace:o}){t.liveSocket.historyRedirect(n,o?"replace":"push")},exec_patch(r,e,t,i,s,{href:n,replace:o}){t.liveSocket.pushHistoryPatch(n,o?"replace":"push",i)},exec_focus(r,e,t,i,s){window.requestAnimationFrame(()=>Q.attemptFocus(s))},exec_focus_first(r,e,t,i,s){window.requestAnimationFrame(()=>Q.focusFirstInteractive(s)||Q.focusFirst(s))},exec_push_focus(r,e,t,i,s){window.requestAnimationFrame(()=>je=s||i)},exec_pop_focus(r,e,t,i,s){window.requestAnimationFrame(()=>{je&&je.focus(),je=null})},exec_add_class(r,e,t,i,s,{names:n,transition:o,time:a}){this.addOrRemoveClasses(s,n,[],o,a,t)},exec_remove_class(r,e,t,i,s,{names:n,transition:o,time:a}){this.addOrRemoveClasses(s,[],n,o,a,t)},exec_transition(r,e,t,i,s,{time:n,transition:o}){let[a,l,d]=o,f=()=>this.addOrRemoveClasses(s,a.concat(l),[]),c=()=>this.addOrRemoveClasses(s,d,a.concat(l));t.transition(n,f,c)},exec_toggle(r,e,t,i,s,{display:n,ins:o,outs:a,time:l}){this.toggle(r,t,s,n,o,a,l)},exec_show(r,e,t,i,s,{display:n,transition:o,time:a}){this.show(r,t,s,n,o,a)},exec_hide(r,e,t,i,s,{display:n,transition:o,time:a}){this.hide(r,t,s,n,o,a)},exec_set_attr(r,e,t,i,s,{attr:[n,o]}){this.setOrRemoveAttrs(s,[[n,o]],[])},exec_remove_attr(r,e,t,i,s,{attr:n}){this.setOrRemoveAttrs(s,[],[n])},show(r,e,t,i,s,n){this.isVisible(t)||this.toggle(r,e,t,i,s,null,n)},hide(r,e,t,i,s,n){this.isVisible(t)&&this.toggle(r,e,t,i,null,s,n)},toggle(r,e,t,i,s,n,o){let[a,l,d]=s||[[],[],[]],[f,c,p]=n||[[],[],[]];if(a.length>0||f.length>0)if(this.isVisible(t)){let E=()=>{this.addOrRemoveClasses(t,c,a.concat(l).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,f,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,p,c))})};t.dispatchEvent(new Event("phx:hide-start")),e.transition(o,E,()=>{this.addOrRemoveClasses(t,[],f.concat(p)),h.putSticky(t,"toggle",_=>_.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))})}else{if(r==="remove")return;let E=()=>{this.addOrRemoveClasses(t,l,f.concat(c).concat(p)),h.putSticky(t,"toggle",_=>_.style.display=i||"block"),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,d,l))})};t.dispatchEvent(new Event("phx:show-start")),e.transition(o,E,()=>{this.addOrRemoveClasses(t,[],a.concat(d)),t.dispatchEvent(new Event("phx:show-end"))})}else this.isVisible(t)?window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:hide-start")),h.putSticky(t,"toggle",E=>E.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start")),h.putSticky(t,"toggle",E=>E.style.display=i||"block"),t.dispatchEvent(new Event("phx:show-end"))})},addOrRemoveClasses(r,e,t,i,s,n){let[o,a,l]=i||[[],[],[]];if(o.length>0){let d=()=>this.addOrRemoveClasses(r,a.concat(o),[]),f=()=>this.addOrRemoveClasses(r,e.concat(l),t.concat(o).concat(a));return n.transition(s,d,f)}window.requestAnimationFrame(()=>{let[d,f]=h.getSticky(r,"classes",[[],[]]),c=e.filter(v=>d.indexOf(v)<0&&!r.classList.contains(v)),p=t.filter(v=>f.indexOf(v)<0&&r.classList.contains(v)),E=d.filter(v=>t.indexOf(v)<0).concat(c),_=f.filter(v=>e.indexOf(v)<0).concat(p);h.putSticky(r,"classes",v=>(v.classList.remove(..._),v.classList.add(...E),[E,_]))})},setOrRemoveAttrs(r,e,t){let[i,s]=h.getSticky(r,"attrs",[[],[]]),n=e.map(([l,d])=>l).concat(t),o=i.filter(([l,d])=>!n.includes(l)).concat(e),a=s.filter(l=>!n.includes(l)).concat(t);h.putSticky(r,"attrs",l=>(a.forEach(d=>l.removeAttribute(d)),o.forEach(([d,f])=>l.setAttribute(d,f)),[o,a]))},hasAllClasses(r,e){return e.every(t=>r.classList.contains(t))},isToggledOut(r,e){return!this.isVisible(r)||this.hasAllClasses(r,e)},filterToEls(r,{to:e}){return e?h.all(document,e):[r]}},H=_i;var We=(r,e,t=[])=>{let i=new FormData(r),s=[];i.forEach((o,a,l)=>{o instanceof File&&s.push(a)}),s.forEach(o=>i.delete(o));let n=new URLSearchParams;for(let[o,a]of i.entries())(t.length===0||t.indexOf(o)>=0)&&n.append(o,a);for(let o in e)n.append(o,e[o]);return n.toString()},pe=class{constructor(e,t,i,s,n){this.isDead=!1,this.liveSocket=t,this.flash=s,this.parent=i,this.root=i?i.root:this,this.el=e,this.id=this.el.id,this.ref=0,this.childJoins=0,this.loaderTimer=null,this.pendingDiffs=[],this.pruningCIDs=[],this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(o){o&&o()},this.stopCallback=function(){},this.pendingJoinOps=this.parent?null:[],this.viewHooks={},this.uploaders={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>({redirect:this.redirect?this.href:void 0,url:this.redirect?void 0:this.href||void 0,params:this.connectParams(n),session:this.getSession(),static:this.getStatic(),flash:this.flash})),this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel()}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.getAttribute(le)!==null}connectParams(e){let t=this.liveSocket.params(this.el),i=h.all(document,`[${this.binding(Pt)}]`).map(s=>s.src||s.href).filter(s=>typeof s=="string");return i.length>0&&(t._track_static=i),t._mounts=this.joinCount,t._live_referer=e,t}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(D)}getStatic(){let e=this.el.getAttribute(Y);return e===""?null:e}destroy(e=function(){}){this.destroyAllChildren(),this.destroyed=!0,delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],clearTimeout(this.loaderTimer);let t=()=>{e();for(let i in this.viewHooks)this.destroyHook(this.viewHooks[i])};h.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",t).receive("error",t).receive("timeout",t)}setContainerClasses(...e){this.el.classList.remove(tt,Re,rt),this.el.classList.add(...e)}showLoader(e){if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(()=>this.showLoader(),e);else{for(let t in this.viewHooks)this.viewHooks[t].__disconnected();this.setContainerClasses(Re)}}execAll(e){h.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(tt),this.execAll(this.binding("connected"))}triggerReconnected(){for(let e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,t){this.liveSocket.log(this,e,t)}transition(e,t,i=function(){}){this.liveSocket.transition(e,t,i)}withinTargets(e,t){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,i=>t(i,e));if($(e))h.findComponentNodeList(this.el,e).length===0?P(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let i=Array.from(document.querySelectorAll(e));i.length===0&&P(`nothing found matching the phx-target selector "${e}"`),i.forEach(s=>this.liveSocket.owner(s,n=>t(n,s)))}}applyDiff(e,t,i){this.log(e,()=>["",ue(t)]);let{diff:s,reply:n,events:o,title:a}=we.extract(t);a&&h.putTitle(a),i({diff:s,reply:n,events:o})}onJoin(e){let{rendered:t,container:i}=e;if(i){let[s,n]=i;this.el=h.replaceRootContainer(this.el,s,n)}this.childJoins=0,this.joinPending=!0,this.flash=null,O.dropLocal(this.liveSocket.localStorage,window.location.pathname,ke),this.applyDiff("mount",t,({diff:s,events:n})=>{this.rendered=new we(this.id,s);let o=this.renderContainer(null,"join");this.dropPendingRefs();let a=this.formsForRecovery(o);this.joinCount++,a.length>0?a.forEach(([l,d,f],c)=>{this.pushFormRecovery(l,f,p=>{c===a.length-1&&this.onJoinComplete(p,o,n)})}):this.onJoinComplete(e,o,n)})}dropPendingRefs(){h.all(document,`[${j}="${this.id}"][${L}]`,e=>{e.removeAttribute(L),e.removeAttribute(j)})}onJoinComplete({live_patch:e},t,i){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i);h.findPhxChildrenInFragment(t,this.id).filter(n=>{let o=n.id&&this.el.querySelector(`[id="${n.id}"]`),a=o&&o.getAttribute(Y);return a&&n.setAttribute(Y,a),this.joinChild(n)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i)])}attachTrueDocEl(){this.el=h.byId(this.id),this.el.setAttribute(K,this.root.id)}execNewMounted(){h.all(this.el,`[${this.binding(he)}], [data-phx-${he}]`,e=>{this.maybeAddNewHook(e)}),h.all(this.el,`[${this.binding(ot)}]`,e=>this.maybeMounted(e))}applyJoinPatch(e,t,i){this.attachTrueDocEl();let s=new re(this,this.el,this.id,t,null);if(s.markPrunableContentForRemoval(),this.performPatch(s,!1),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(i),this.applyPendingUpdates(),e){let{kind:n,to:o}=e;this.liveSocket.historyPatch(o,n)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),s=i&&h.isIgnored(e,this.binding(Se));if(i&&!e.isEqualNode(t)&&!(s&&$t(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(ot)),i=t&&h.private(e,"mounted");t&&!i&&(this.liveSocket.execJS(e,t),h.putPrivate(e,"mounted",!0))}maybeAddNewHook(e,t){let i=this.addHook(e);i&&i.__mounted()}performPatch(e,t){let i=[],s=!1,n=new Set;return e.after("added",o=>{this.liveSocket.triggerDOM("onNodeAdded",[o]),this.maybeAddNewHook(o),o.getAttribute&&this.maybeMounted(o)}),e.after("phxChildAdded",o=>{h.isPhxSticky(o)?this.liveSocket.joinRootViews():s=!0}),e.before("updated",(o,a)=>{this.triggerBeforeUpdateHook(o,a)&&n.add(o.id)}),e.after("updated",o=>{n.has(o.id)&&this.getHook(o).__updated()}),e.after("discarded",o=>{o.nodeType===Node.ELEMENT_NODE&&i.push(o)}),e.after("transitionsDiscarded",o=>this.afterElementsRemoved(o,t)),e.perform(),this.afterElementsRemoved(i,t),s}afterElementsRemoved(e,t){let i=[];e.forEach(s=>{let n=h.all(s,`[${x}]`),o=h.all(s,`[${this.binding(he)}]`);n.concat(s).forEach(a=>{let l=this.componentID(a);$(l)&&i.indexOf(l)===-1&&i.push(l)}),o.concat(s).forEach(a=>{let l=this.getHook(a);l&&this.destroyHook(l)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){h.findPhxChildren(this.el,this.id).forEach(e=>this.joinChild(e))}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){return e.id===this.id?this:this.children[e.getAttribute(W)][e.id]}destroyDescendent(e){for(let t in this.root.children)for(let i in this.root.children[t])if(i===e)return this.root.children[t][i].destroy()}joinChild(e){if(!this.getChildById(e.id)){let i=new pe(e,this.liveSocket,this);return this.root.children[this.id][i.id]=i,i.join(),this.childJoins++,!0}}isJoinPending(){return this.joinPending}ackJoin(e){this.childJoins--,this.childJoins===0&&(this.parent?this.parent.ackJoin(this):this.onAllChildJoinsComplete())}onAllChildJoinsComplete(){this.joinCallback(()=>{this.pendingJoinOps.forEach(([e,t])=>{e.isDestroyed()||t()}),this.pendingJoinOps=[]})}update(e,t){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:e,events:t});this.rendered.mergeDiff(e);let i=!1;this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{h.findParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach(n=>{this.componentPatch(this.rendered.getComponent(e,n),n)&&(i=!0)})}):ct(e)||this.liveSocket.time("full patch complete",()=>{let s=this.renderContainer(e,"update"),n=new re(this,this.el,this.id,s,null);i=this.performPatch(n,!0)}),this.liveSocket.dispatchEvents(t),i&&this.joinNewChildren()}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,s=e?this.rendered.componentCIDs(e).concat(this.pruningCIDs):null,n=this.rendered.toString(s);return`<${i}>${n}</${i}>`})}componentPatch(e,t){if(ct(e))return!1;let i=this.rendered.componentToString(t),s=new re(this,this.el,this.id,i,t);return this.performPatch(s,!0)}getHook(e){return this.viewHooks[Z.elementID(e)]}addHook(e){if(Z.elementID(e)||!e.getAttribute)return;let t=e.getAttribute(`data-phx-${he}`)||e.getAttribute(this.binding(he));if(t&&!this.ownsElement(e))return;let i=this.liveSocket.getHookCallbacks(t);if(i){e.id||P(`no DOM ID for hook "${t}". Hooks require a unique ID on each element.`,e);let s=new Z(this,e,i);return this.viewHooks[Z.elementID(s.el)]=s,s}else t!==null&&P(`unknown hook found for "${t}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[Z.elementID(e.el)]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[]}onChannel(e,t){this.liveSocket.onChannel(this.channel,e,i=>{this.isJoinPending()?this.root.pendingJoinOps.push([this,()=>t(i)]):this.liveSocket.requestDOMUpdate(()=>t(i))})}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",e=>{this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",e,({diff:t,events:i})=>this.update(t,i))})}),this.onChannel("redirect",({to:e,flash:t})=>this.onRedirect({to:e,flash:t})),this.onChannel("live_patch",e=>this.onLivePatch(e)),this.onChannel("live_redirect",e=>this.onLiveRedirect(e)),this.channel.onError(e=>this.onError(e)),this.channel.onClose(e=>this.onClose(e))}destroyAllChildren(){for(let e in this.root.children[this.id])this.getChildById(e).destroy()}onLiveRedirect(e){let{to:t,kind:i,flash:s}=e,n=this.expandURL(t);this.liveSocket.historyRedirect(n,i,s)}onLivePatch(e){let{to:t,kind:i}=e;this.href=this.expandURL(t),this.liveSocket.historyPatch(t,i)}expandURL(e){return e.startsWith("/")?`${window.location.protocol}//${window.location.host}${e}`:e}onRedirect({to:e,flash:t}){this.liveSocket.redirect(e,t)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}join(e){this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=t=>{t=t||function(){},e?e(this.joinCount,t):t()},this.liveSocket.wrapPush(this,{timeout:!1},()=>this.channel.join().receive("ok",t=>{this.isDestroyed()||this.liveSocket.requestDOMUpdate(()=>this.onJoin(t))}).receive("error",t=>!this.isDestroyed()&&this.onJoinError(t)).receive("timeout",()=>!this.isDestroyed()&&this.onJoinError({reason:"timeout"})))}onJoinError(e){if(e.reason==="unauthorized"||e.reason==="stale")return this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.onRedirect({to:this.href});if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);this.log("error",()=>["unable to join",e]),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this)}onClose(e){if(!this.isDestroyed()){if(this.liveSocket.hasPendingLink()&&e!=="leave")return this.liveSocket.reloadWithJitter(this);this.destroyAllChildren(),this.liveSocket.dropActiveElement(this),document.activeElement&&document.activeElement.blur(),this.liveSocket.isUnloaded()&&this.showLoader(Ot)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||this.displayError()}displayError(){this.isMain()&&h.dispatchEvent(window,"phx:page-loading-start",{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(Re,rt),this.execAll(this.binding("disconnected"))}pushWithReply(e,t,i,s=function(){}){if(!this.isConnected())return;let[n,[o],a]=e?e():[null,[],{}],l=function(){};return(a.page_loading||o&&o.getAttribute(this.binding(et))!==null)&&(l=this.liveSocket.withPageLoading({kind:"element",target:o})),typeof i.cid!="number"&&delete i.cid,this.liveSocket.wrapPush(this,{timeout:!0},()=>this.channel.push(t,i,Nt).receive("ok",d=>{let f=c=>{d.redirect&&this.onRedirect(d.redirect),d.live_patch&&this.onLivePatch(d.live_patch),d.live_redirect&&this.onLiveRedirect(d.live_redirect),n!==null&&this.undoRefs(n),l(),s(d,c)};d.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",d.diff,({diff:c,reply:p,events:E})=>{this.update(c,E),f(p)})}):f(null)}))}undoRefs(e){!this.isConnected()||h.all(document,`[${j}="${this.id}"][${L}="${e}"]`,t=>{let i=t.getAttribute(be);t.removeAttribute(L),t.removeAttribute(j),t.getAttribute(Fe)!==null&&(t.readOnly=!1,t.removeAttribute(Fe)),i!==null&&(t.disabled=i==="true",t.removeAttribute(be)),Ie.forEach(o=>h.removeClass(t,o));let s=t.getAttribute(_e);s!==null&&(t.innerText=s,t.removeAttribute(_e));let n=h.private(t,L);if(n){let o=this.triggerBeforeUpdateHook(t,n);re.patchEl(t,n,this.liveSocket.getActiveElement()),o&&o.__updated(),h.deletePrivate(t,L)}})}putRef(e,t,i={}){let s=this.ref++,n=this.binding(Ee);return i.loading&&(e=e.concat(h.all(document,i.loading))),e.forEach(o=>{o.classList.add(`phx-${t}-loading`),o.setAttribute(L,s),o.setAttribute(j,this.el.id);let a=o.getAttribute(n);a!==null&&(o.getAttribute(_e)||o.setAttribute(_e,o.innerText),a!==""&&(o.innerText=a),o.setAttribute("disabled",""))}),[s,e,i]}componentID(e){let t=e.getAttribute&&e.getAttribute(x);return t?parseInt(t):null}targetComponentID(e,t,i={}){if($(t))return t;let s=e.getAttribute(this.binding("target"));return $(s)?parseInt(s):t&&(s!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return $(e)?e:e?R(e.closest(`[${x}]`),t=>this.ownsElement(t)&&this.componentID(t)):null}pushHookEvent(e,t,i,s){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",t,i]),!1;let[n,o,a]=this.putRef([],"hook");return this.pushWithReply(()=>[n,o,a],"event",{type:"hook",event:t,value:i,cid:this.closestComponentID(e)},(l,d)=>s(d,n)),n}extractMeta(e,t,i){let s=this.binding("value-");for(let n=0;n<e.attributes.length;n++){t||(t={});let o=e.attributes[n].name;o.startsWith(s)&&(t[o.replace(s,"")]=e.getAttribute(o))}if(e.value!==void 0&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&He.indexOf(e.type)>=0&&!e.checked&&delete t.value),i){t||(t={});for(let n in i)t[n]=i[n]}return t}pushEvent(e,t,i,s,n,o={}){this.pushWithReply(()=>this.putRef([t],e,o),"event",{type:e,event:s,value:this.extractMeta(t,n,o.value),cid:this.targetComponentID(t,i,o)})}pushFileProgress(e,t,i,s=function(){}){this.liveSocket.withinOwners(e.form,(n,o)=>{n.pushWithReply(null,"progress",{event:e.getAttribute(n.binding(Dt)),ref:e.getAttribute(M),entry_ref:t,progress:i,cid:n.targetComponentID(e.form,o)},s)})}pushInput(e,t,i,s,n,o){let a,l=$(i)?i:this.targetComponentID(e.form,t),d=()=>this.putRef([e,e.form],"change",n),f;e.getAttribute(this.binding("change"))?f=We(e.form,{_target:n._target},[e.name]):f=We(e.form,{_target:n._target}),h.isUploadInput(e)&&e.files&&e.files.length>0&&y.trackFiles(e,Array.from(e.files)),a=y.serializeUploads(e);let c={type:"form",event:s,value:f,uploads:a,cid:l};this.pushWithReply(d,"event",c,p=>{if(h.showError(e,this.liveSocket.binding(ve)),h.isUploadInput(e)&&e.getAttribute("data-phx-auto-upload")!==null){if(y.filesAwaitingPreflight(e).length>0){let[E,_]=d();this.uploadFiles(e.form,t,E,l,v=>{o&&o(p),this.triggerAwaitingSubmit(e.form)})}}else o&&o(p)})}triggerAwaitingSubmit(e){let t=this.getScheduledSubmit(e);if(t){let[i,s,n,o]=t;this.cancelSubmit(e),o()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,s,n])=>t.isSameNode(e))}scheduleSubmit(e,t,i,s){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,s])}cancelSubmit(e){this.formSubmits=this.formSubmits.filter(([t,i,s])=>t.isSameNode(e)?(this.undoRefs(i),!1):!0)}disableForm(e,t={}){let i=c=>!(te(c,`${this.binding(Se)}=ignore`,c.form)||te(c,"data-phx-update=ignore",c.form)),s=c=>c.hasAttribute(this.binding(Ee)),n=c=>c.tagName=="BUTTON",o=c=>["INPUT","TEXTAREA","SELECT"].includes(c.tagName),a=Array.from(e.elements),l=a.filter(s),d=a.filter(n).filter(i),f=a.filter(o).filter(i);return d.forEach(c=>{c.setAttribute(be,c.disabled),c.disabled=!0}),f.forEach(c=>{c.setAttribute(Fe,c.readOnly),c.readOnly=!0,c.files&&(c.setAttribute(be,c.disabled),c.disabled=!0)}),e.setAttribute(this.binding(et),""),this.putRef([e].concat(l).concat(d).concat(f),"submit",t)}pushFormSubmit(e,t,i,s,n){let o=()=>this.disableForm(e,s),a=this.targetComponentID(e,t);if(y.hasUploadsInProgress(e)){let[l,d]=o(),f=()=>this.pushFormSubmit(e,t,i,s,n);return this.scheduleSubmit(e,l,s,f)}else if(y.inputsAwaitingPreflight(e).length>0){let[l,d]=o(),f=()=>[l,d,s];this.uploadFiles(e,t,l,a,c=>{let p=We(e,{});this.pushWithReply(f,"event",{type:"form",event:i,value:p,cid:a},n)})}else{let l=We(e,{});this.pushWithReply(o,"event",{type:"form",event:i,value:l,cid:a},n)}}uploadFiles(e,t,i,s,n){let o=this.joinCount,a=y.activeFileInputs(e),l=a.length;a.forEach(d=>{let f=new y(d,this,()=>{l--,l===0&&n()});this.uploaders[d]=f;let c=f.entries().map(E=>E.toPreflightPayload()),p={ref:d.getAttribute(M),entries:c,cid:this.targetComponentID(d.form,t)};this.log("upload",()=>["sending preflight request",p]),this.pushWithReply(null,"allow_upload",p,E=>{if(this.log("upload",()=>["got preflight response",E]),E.error){this.undoRefs(i);let[_,v]=E.error;this.log("upload",()=>[`error for entry ${_}`,v])}else{let _=v=>{this.channel.onError(()=>{this.joinCount===o&&v()})};f.initAdapterUpload(E,_,this.liveSocket)}})})}dispatchUploads(e,t){let i=h.findUploadInputs(this.el).filter(s=>s.name===e);i.length===0?P(`no live file inputs found matching the name "${e}"`):i.length>1?P(`duplicate live file inputs found matching the name "${e}"`):h.dispatchEvent(i[0],De,{detail:{files:t}})}pushFormRecovery(e,t,i){this.liveSocket.withinOwners(e,(s,n)=>{let o=e.elements[0],a=e.getAttribute(this.binding(nt))||e.getAttribute(this.binding("change"));H.exec("change",a,s,o,["push",{_target:o.name,newCid:t,callback:i}])})}pushLinkPatch(e,t,i){let s=this.liveSocket.setPendingLink(e),n=t?()=>this.putRef([t],"click"):null,o=()=>this.liveSocket.redirect(window.location.href),a=this.pushWithReply(n,"live_patch",{url:e},l=>{this.liveSocket.requestDOMUpdate(()=>{l.link_redirect?this.liveSocket.replaceMain(e,null,i,s):(this.liveSocket.commitPendingLink(s)&&(this.href=e),this.applyPendingUpdates(),i&&i(s))})});a?a.receive("timeout",o):o()}formsForRecovery(e){if(this.joinCount===0)return[];let t=this.binding("change"),i=document.createElement("template");return i.innerHTML=e,h.all(this.el,`form[${t}]`).filter(s=>s.id&&this.ownsElement(s)).filter(s=>s.elements.length>0).filter(s=>s.getAttribute(this.binding(nt))!=="ignore").map(s=>{let n=i.content.querySelector(`form[id="${s.id}"][${t}="${s.getAttribute(t)}"]`);return n?[s,n,this.targetComponentID(n)]:[s,null,null]}).filter(([s,n,o])=>n)}maybePushComponentsDestroyed(e){let t=e.filter(i=>h.findComponentNodeList(this.el,i).length===0);t.length>0&&(this.pruningCIDs.push(...t),this.pushWithReply(null,"cids_will_destroy",{cids:t},()=>{this.pruningCIDs=this.pruningCIDs.filter(s=>t.indexOf(s)!==-1);let i=t.filter(s=>h.findComponentNodeList(this.el,s).length===0);i.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:i},s=>{this.rendered.pruneCIDs(s.cids)})}))}ownsElement(e){return this.isDead||e.getAttribute(W)===this.id||R(e.closest(J),t=>t.id)===this.id}submitForm(e,t,i,s={}){h.putPrivate(e,Ne,!0);let n=this.liveSocket.binding(ve),o=Array.from(e.elements);this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,s,()=>{o.forEach(a=>h.showError(a,n)),this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}};var Ke=class{constructor(e,t,i={}){if(this.unloaded=!1,!t||t.constructor.name==="Object")throw new Error(`
11
+ `,n.innerHTML.trim()),this.createSpan("",t).outerHTML):(!l&&d&&P("expected at least one HTML element tag directly inside a component, but only subcomponents were found. A component must render at least one HTML tag directly inside itself.",n.innerHTML.trim()),n.innerHTML)}createSpan(e,t){let i=document.createElement("span");return i.innerText=e,i.setAttribute(x,t),i}};var Ei=1,Z=class{static makeID(){return Ei++}static elementID(e){return e.phxHookId}constructor(e,t,i){this.__view=e,this.liveSocket=e.liveSocket,this.__callbacks=i,this.__listeners=new Set,this.__isDisconnected=!1,this.el=t,this.el.phxHookId=this.constructor.makeID();for(let s in this.__callbacks)this[s]=this.__callbacks[s]}__mounted(){this.mounted&&this.mounted()}__updated(){this.updated&&this.updated()}__beforeUpdate(){this.beforeUpdate&&this.beforeUpdate()}__destroyed(){this.destroyed&&this.destroyed()}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected&&this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected&&this.disconnected()}pushEvent(e,t={},i=function(){}){return this.__view.pushHookEvent(null,e,t,i)}pushEventTo(e,t,i={},s=function(){}){return this.__view.withinTargets(e,(n,o)=>n.pushHookEvent(o,t,i,s))}handleEvent(e,t){let i=(s,n)=>n?e:t(s.detail);return window.addEventListener(`phx:${e}`,i),this.__listeners.add(i),i}removeHandleEvent(e){let t=e(null,!0);window.removeEventListener(`phx:${t}`,e),this.__listeners.delete(e)}upload(e,t){return this.__view.dispatchUploads(e,t)}uploadTo(e,t,i){return this.__view.withinTargets(e,s=>s.dispatchUploads(t,i))}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var je=null,_i={exec(r,e,t,i,s){let[n,o]=s||[null,{}];(e.charAt(0)==="["?JSON.parse(e):[[n,o]]).forEach(([l,d])=>{l===n&&o.data&&(d.data=Object.assign(d.data||{},o.data)),this.filterToEls(i,d).forEach(f=>{this[`exec_${l}`](r,e,t,i,f,d)})})},isVisible(r){return!!(r.offsetWidth||r.offsetHeight||r.getClientRects().length>0)},exec_dispatch(r,e,t,i,s,{to:n,event:o,detail:a,bubbles:l}){a=a||{},a.dispatcher=i,h.dispatchEvent(s,o,{detail:a,bubbles:l})},exec_push(r,e,t,i,s,n){if(!t.isConnected())return;let{event:o,data:a,target:l,page_loading:d,loading:f,value:c,dispatcher:p}=n,E={loading:f,value:c,target:l,page_loading:!!d},_=r==="change"&&p?p:i,v=l||_.getAttribute(t.binding("target"))||_;t.withinTargets(v,(w,C)=>{if(r==="change"){let{newCid:V,_target:N,callback:u}=n;N=N||(i instanceof HTMLInputElement?i.name:void 0),N&&(E._target=N),w.pushInput(i,C,V,o||e,E,u)}else r==="submit"?w.submitForm(i,C,o||e,E):w.pushEvent(r,i,C,o||e,a,E)})},exec_navigate(r,e,t,i,s,{href:n,replace:o}){t.liveSocket.historyRedirect(n,o?"replace":"push")},exec_patch(r,e,t,i,s,{href:n,replace:o}){t.liveSocket.pushHistoryPatch(n,o?"replace":"push",i)},exec_focus(r,e,t,i,s){window.requestAnimationFrame(()=>Q.attemptFocus(s))},exec_focus_first(r,e,t,i,s){window.requestAnimationFrame(()=>Q.focusFirstInteractive(s)||Q.focusFirst(s))},exec_push_focus(r,e,t,i,s){window.requestAnimationFrame(()=>je=s||i)},exec_pop_focus(r,e,t,i,s){window.requestAnimationFrame(()=>{je&&je.focus(),je=null})},exec_add_class(r,e,t,i,s,{names:n,transition:o,time:a}){this.addOrRemoveClasses(s,n,[],o,a,t)},exec_remove_class(r,e,t,i,s,{names:n,transition:o,time:a}){this.addOrRemoveClasses(s,[],n,o,a,t)},exec_transition(r,e,t,i,s,{time:n,transition:o}){let[a,l,d]=o,f=()=>this.addOrRemoveClasses(s,a.concat(l),[]),c=()=>this.addOrRemoveClasses(s,d,a.concat(l));t.transition(n,f,c)},exec_toggle(r,e,t,i,s,{display:n,ins:o,outs:a,time:l}){this.toggle(r,t,s,n,o,a,l)},exec_show(r,e,t,i,s,{display:n,transition:o,time:a}){this.show(r,t,s,n,o,a)},exec_hide(r,e,t,i,s,{display:n,transition:o,time:a}){this.hide(r,t,s,n,o,a)},exec_set_attr(r,e,t,i,s,{attr:[n,o]}){this.setOrRemoveAttrs(s,[[n,o]],[])},exec_remove_attr(r,e,t,i,s,{attr:n}){this.setOrRemoveAttrs(s,[],[n])},show(r,e,t,i,s,n){this.isVisible(t)||this.toggle(r,e,t,i,s,null,n)},hide(r,e,t,i,s,n){this.isVisible(t)&&this.toggle(r,e,t,i,null,s,n)},toggle(r,e,t,i,s,n,o){let[a,l,d]=s||[[],[],[]],[f,c,p]=n||[[],[],[]];if(a.length>0||f.length>0)if(this.isVisible(t)){let E=()=>{this.addOrRemoveClasses(t,c,a.concat(l).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,f,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,p,c))})};t.dispatchEvent(new Event("phx:hide-start")),e.transition(o,E,()=>{this.addOrRemoveClasses(t,[],f.concat(p)),h.putSticky(t,"toggle",_=>_.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))})}else{if(r==="remove")return;let E=()=>{this.addOrRemoveClasses(t,l,f.concat(c).concat(p)),h.putSticky(t,"toggle",_=>_.style.display=i||"block"),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,d,l))})};t.dispatchEvent(new Event("phx:show-start")),e.transition(o,E,()=>{this.addOrRemoveClasses(t,[],a.concat(d)),t.dispatchEvent(new Event("phx:show-end"))})}else this.isVisible(t)?window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:hide-start")),h.putSticky(t,"toggle",E=>E.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start")),h.putSticky(t,"toggle",E=>E.style.display=i||"block"),t.dispatchEvent(new Event("phx:show-end"))})},addOrRemoveClasses(r,e,t,i,s,n){let[o,a,l]=i||[[],[],[]];if(o.length>0){let d=()=>this.addOrRemoveClasses(r,a.concat(o),[]),f=()=>this.addOrRemoveClasses(r,e.concat(l),t.concat(o).concat(a));return n.transition(s,d,f)}window.requestAnimationFrame(()=>{let[d,f]=h.getSticky(r,"classes",[[],[]]),c=e.filter(v=>d.indexOf(v)<0&&!r.classList.contains(v)),p=t.filter(v=>f.indexOf(v)<0&&r.classList.contains(v)),E=d.filter(v=>t.indexOf(v)<0).concat(c),_=f.filter(v=>e.indexOf(v)<0).concat(p);h.putSticky(r,"classes",v=>(v.classList.remove(..._),v.classList.add(...E),[E,_]))})},setOrRemoveAttrs(r,e,t){let[i,s]=h.getSticky(r,"attrs",[[],[]]),n=e.map(([l,d])=>l).concat(t),o=i.filter(([l,d])=>!n.includes(l)).concat(e),a=s.filter(l=>!n.includes(l)).concat(t);h.putSticky(r,"attrs",l=>(a.forEach(d=>l.removeAttribute(d)),o.forEach(([d,f])=>l.setAttribute(d,f)),[o,a]))},hasAllClasses(r,e){return e.every(t=>r.classList.contains(t))},isToggledOut(r,e){return!this.isVisible(r)||this.hasAllClasses(r,e)},filterToEls(r,{to:e}){return e?h.all(document,e):[r]}},H=_i;var We=(r,e,t=[])=>{let i=new FormData(r),s=[];i.forEach((o,a,l)=>{o instanceof File&&s.push(a)}),s.forEach(o=>i.delete(o));let n=new URLSearchParams;for(let[o,a]of i.entries())(t.length===0||t.indexOf(o)>=0)&&n.append(o,a);for(let o in e)n.append(o,e[o]);return n.toString()},pe=class{constructor(e,t,i,s,n){this.isDead=!1,this.liveSocket=t,this.flash=s,this.parent=i,this.root=i?i.root:this,this.el=e,this.id=this.el.id,this.ref=0,this.childJoins=0,this.loaderTimer=null,this.pendingDiffs=[],this.pruningCIDs=[],this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(o){o&&o()},this.stopCallback=function(){},this.pendingJoinOps=this.parent?null:[],this.viewHooks={},this.uploaders={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>({redirect:this.redirect?this.href:void 0,url:this.redirect?void 0:this.href||void 0,params:this.connectParams(n),session:this.getSession(),static:this.getStatic(),flash:this.flash}))}setHref(e){this.href=e}setRedirect(e){this.redirect=!0,this.href=e}isMain(){return this.el.getAttribute(le)!==null}connectParams(e){let t=this.liveSocket.params(this.el),i=h.all(document,`[${this.binding(Pt)}]`).map(s=>s.src||s.href).filter(s=>typeof s=="string");return i.length>0&&(t._track_static=i),t._mounts=this.joinCount,t._live_referer=e,t}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(D)}getStatic(){let e=this.el.getAttribute(Y);return e===""?null:e}destroy(e=function(){}){this.destroyAllChildren(),this.destroyed=!0,delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],clearTimeout(this.loaderTimer);let t=()=>{e();for(let i in this.viewHooks)this.destroyHook(this.viewHooks[i])};h.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",t).receive("error",t).receive("timeout",t)}setContainerClasses(...e){this.el.classList.remove(tt,Re,rt),this.el.classList.add(...e)}showLoader(e){if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(()=>this.showLoader(),e);else{for(let t in this.viewHooks)this.viewHooks[t].__disconnected();this.setContainerClasses(Re)}}execAll(e){h.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(tt),this.execAll(this.binding("connected"))}triggerReconnected(){for(let e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,t){this.liveSocket.log(this,e,t)}transition(e,t,i=function(){}){this.liveSocket.transition(e,t,i)}withinTargets(e,t){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,i=>t(i,e));if($(e))h.findComponentNodeList(this.el,e).length===0?P(`no component found matching phx-target of ${e}`):t(this,parseInt(e));else{let i=Array.from(document.querySelectorAll(e));i.length===0&&P(`nothing found matching the phx-target selector "${e}"`),i.forEach(s=>this.liveSocket.owner(s,n=>t(n,s)))}}applyDiff(e,t,i){this.log(e,()=>["",ue(t)]);let{diff:s,reply:n,events:o,title:a}=we.extract(t);a&&h.putTitle(a),i({diff:s,reply:n,events:o})}onJoin(e){let{rendered:t,container:i}=e;if(i){let[s,n]=i;this.el=h.replaceRootContainer(this.el,s,n)}this.childJoins=0,this.joinPending=!0,this.flash=null,O.dropLocal(this.liveSocket.localStorage,window.location.pathname,ke),this.applyDiff("mount",t,({diff:s,events:n})=>{this.rendered=new we(this.id,s);let o=this.renderContainer(null,"join");this.dropPendingRefs();let a=this.formsForRecovery(o);this.joinCount++,a.length>0?a.forEach(([l,d,f],c)=>{this.pushFormRecovery(l,f,p=>{c===a.length-1&&this.onJoinComplete(p,o,n)})}):this.onJoinComplete(e,o,n)})}dropPendingRefs(){h.all(document,`[${j}="${this.id}"][${L}]`,e=>{e.removeAttribute(L),e.removeAttribute(j)})}onJoinComplete({live_patch:e},t,i){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i);h.findPhxChildrenInFragment(t,this.id).filter(n=>{let o=n.id&&this.el.querySelector(`[id="${n.id}"]`),a=o&&o.getAttribute(Y);return a&&n.setAttribute(Y,a),this.joinChild(n)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i)])}attachTrueDocEl(){this.el=h.byId(this.id),this.el.setAttribute(K,this.root.id)}execNewMounted(){h.all(this.el,`[${this.binding(he)}], [data-phx-${he}]`,e=>{this.maybeAddNewHook(e)}),h.all(this.el,`[${this.binding(ot)}]`,e=>this.maybeMounted(e))}applyJoinPatch(e,t,i){this.attachTrueDocEl();let s=new re(this,this.el,this.id,t,null);if(s.markPrunableContentForRemoval(),this.performPatch(s,!1),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(i),this.applyPendingUpdates(),e){let{kind:n,to:o}=e;this.liveSocket.historyPatch(o,n)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(e,t){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,t]);let i=this.getHook(e),s=i&&h.isIgnored(e,this.binding(Se));if(i&&!e.isEqualNode(t)&&!(s&&$t(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(ot)),i=t&&h.private(e,"mounted");t&&!i&&(this.liveSocket.execJS(e,t),h.putPrivate(e,"mounted",!0))}maybeAddNewHook(e,t){let i=this.addHook(e);i&&i.__mounted()}performPatch(e,t){let i=[],s=!1,n=new Set;return e.after("added",o=>{this.liveSocket.triggerDOM("onNodeAdded",[o]),this.maybeAddNewHook(o),o.getAttribute&&this.maybeMounted(o)}),e.after("phxChildAdded",o=>{h.isPhxSticky(o)?this.liveSocket.joinRootViews():s=!0}),e.before("updated",(o,a)=>{this.triggerBeforeUpdateHook(o,a)&&n.add(o.id)}),e.after("updated",o=>{n.has(o.id)&&this.getHook(o).__updated()}),e.after("discarded",o=>{o.nodeType===Node.ELEMENT_NODE&&i.push(o)}),e.after("transitionsDiscarded",o=>this.afterElementsRemoved(o,t)),e.perform(),this.afterElementsRemoved(i,t),s}afterElementsRemoved(e,t){let i=[];e.forEach(s=>{let n=h.all(s,`[${x}]`),o=h.all(s,`[${this.binding(he)}]`);n.concat(s).forEach(a=>{let l=this.componentID(a);$(l)&&i.indexOf(l)===-1&&i.push(l)}),o.concat(s).forEach(a=>{let l=this.getHook(a);l&&this.destroyHook(l)})}),t&&this.maybePushComponentsDestroyed(i)}joinNewChildren(){h.findPhxChildren(this.el,this.id).forEach(e=>this.joinChild(e))}getChildById(e){return this.root.children[this.id][e]}getDescendentByEl(e){return e.id===this.id?this:this.children[e.getAttribute(W)][e.id]}destroyDescendent(e){for(let t in this.root.children)for(let i in this.root.children[t])if(i===e)return this.root.children[t][i].destroy()}joinChild(e){if(!this.getChildById(e.id)){let i=new pe(e,this.liveSocket,this);return this.root.children[this.id][i.id]=i,i.join(),this.childJoins++,!0}}isJoinPending(){return this.joinPending}ackJoin(e){this.childJoins--,this.childJoins===0&&(this.parent?this.parent.ackJoin(this):this.onAllChildJoinsComplete())}onAllChildJoinsComplete(){this.joinCallback(()=>{this.pendingJoinOps.forEach(([e,t])=>{e.isDestroyed()||t()}),this.pendingJoinOps=[]})}update(e,t){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:e,events:t});this.rendered.mergeDiff(e);let i=!1;this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{h.findParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach(n=>{this.componentPatch(this.rendered.getComponent(e,n),n)&&(i=!0)})}):ct(e)||this.liveSocket.time("full patch complete",()=>{let s=this.renderContainer(e,"update"),n=new re(this,this.el,this.id,s,null);i=this.performPatch(n,!0)}),this.liveSocket.dispatchEvents(t),i&&this.joinNewChildren()}renderContainer(e,t){return this.liveSocket.time(`toString diff (${t})`,()=>{let i=this.el.tagName,s=e?this.rendered.componentCIDs(e).concat(this.pruningCIDs):null,n=this.rendered.toString(s);return`<${i}>${n}</${i}>`})}componentPatch(e,t){if(ct(e))return!1;let i=this.rendered.componentToString(t),s=new re(this,this.el,this.id,i,t);return this.performPatch(s,!0)}getHook(e){return this.viewHooks[Z.elementID(e)]}addHook(e){if(Z.elementID(e)||!e.getAttribute)return;let t=e.getAttribute(`data-phx-${he}`)||e.getAttribute(this.binding(he));if(t&&!this.ownsElement(e))return;let i=this.liveSocket.getHookCallbacks(t);if(i){e.id||P(`no DOM ID for hook "${t}". Hooks require a unique ID on each element.`,e);let s=new Z(this,e,i);return this.viewHooks[Z.elementID(s.el)]=s,s}else t!==null&&P(`unknown hook found for "${t}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[Z.elementID(e.el)]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[]}onChannel(e,t){this.liveSocket.onChannel(this.channel,e,i=>{this.isJoinPending()?this.root.pendingJoinOps.push([this,()=>t(i)]):this.liveSocket.requestDOMUpdate(()=>t(i))})}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",e=>{this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",e,({diff:t,events:i})=>this.update(t,i))})}),this.onChannel("redirect",({to:e,flash:t})=>this.onRedirect({to:e,flash:t})),this.onChannel("live_patch",e=>this.onLivePatch(e)),this.onChannel("live_redirect",e=>this.onLiveRedirect(e)),this.channel.onError(e=>this.onError(e)),this.channel.onClose(e=>this.onClose(e))}destroyAllChildren(){for(let e in this.root.children[this.id])this.getChildById(e).destroy()}onLiveRedirect(e){let{to:t,kind:i,flash:s}=e,n=this.expandURL(t);this.liveSocket.historyRedirect(n,i,s)}onLivePatch(e){let{to:t,kind:i}=e;this.href=this.expandURL(t),this.liveSocket.historyPatch(t,i)}expandURL(e){return e.startsWith("/")?`${window.location.protocol}//${window.location.host}${e}`:e}onRedirect({to:e,flash:t}){this.liveSocket.redirect(e,t)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}join(e){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=t=>{t=t||function(){},e?e(this.joinCount,t):t()},this.liveSocket.wrapPush(this,{timeout:!1},()=>this.channel.join().receive("ok",t=>{this.isDestroyed()||this.liveSocket.requestDOMUpdate(()=>this.onJoin(t))}).receive("error",t=>!this.isDestroyed()&&this.onJoinError(t)).receive("timeout",()=>!this.isDestroyed()&&this.onJoinError({reason:"timeout"})))}onJoinError(e){if(e.reason==="unauthorized"||e.reason==="stale")return this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.onRedirect({to:this.href});if((e.redirect||e.live_redirect)&&(this.joinPending=!1,this.channel.leave()),e.redirect)return this.onRedirect(e.redirect);if(e.live_redirect)return this.onLiveRedirect(e.live_redirect);this.log("error",()=>["unable to join",e]),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this)}onClose(e){if(!this.isDestroyed()){if(this.liveSocket.hasPendingLink()&&e!=="leave")return this.liveSocket.reloadWithJitter(this);this.destroyAllChildren(),this.liveSocket.dropActiveElement(this),document.activeElement&&document.activeElement.blur(),this.liveSocket.isUnloaded()&&this.showLoader(Ot)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||this.displayError()}displayError(){this.isMain()&&h.dispatchEvent(window,"phx:page-loading-start",{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(Re,rt),this.execAll(this.binding("disconnected"))}pushWithReply(e,t,i,s=function(){}){if(!this.isConnected())return;let[n,[o],a]=e?e():[null,[],{}],l=function(){};return(a.page_loading||o&&o.getAttribute(this.binding(et))!==null)&&(l=this.liveSocket.withPageLoading({kind:"element",target:o})),typeof i.cid!="number"&&delete i.cid,this.liveSocket.wrapPush(this,{timeout:!0},()=>this.channel.push(t,i,Nt).receive("ok",d=>{let f=c=>{d.redirect&&this.onRedirect(d.redirect),d.live_patch&&this.onLivePatch(d.live_patch),d.live_redirect&&this.onLiveRedirect(d.live_redirect),n!==null&&this.undoRefs(n),l(),s(d,c)};d.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",d.diff,({diff:c,reply:p,events:E})=>{this.update(c,E),f(p)})}):f(null)}))}undoRefs(e){!this.isConnected()||h.all(document,`[${j}="${this.id}"][${L}="${e}"]`,t=>{let i=t.getAttribute(be);t.removeAttribute(L),t.removeAttribute(j),t.getAttribute(Fe)!==null&&(t.readOnly=!1,t.removeAttribute(Fe)),i!==null&&(t.disabled=i==="true",t.removeAttribute(be)),Ie.forEach(o=>h.removeClass(t,o));let s=t.getAttribute(_e);s!==null&&(t.innerText=s,t.removeAttribute(_e));let n=h.private(t,L);if(n){let o=this.triggerBeforeUpdateHook(t,n);re.patchEl(t,n,this.liveSocket.getActiveElement()),o&&o.__updated(),h.deletePrivate(t,L)}})}putRef(e,t,i={}){let s=this.ref++,n=this.binding(Ee);return i.loading&&(e=e.concat(h.all(document,i.loading))),e.forEach(o=>{o.classList.add(`phx-${t}-loading`),o.setAttribute(L,s),o.setAttribute(j,this.el.id);let a=o.getAttribute(n);a!==null&&(o.getAttribute(_e)||o.setAttribute(_e,o.innerText),a!==""&&(o.innerText=a),o.setAttribute("disabled",""))}),[s,e,i]}componentID(e){let t=e.getAttribute&&e.getAttribute(x);return t?parseInt(t):null}targetComponentID(e,t,i={}){if($(t))return t;let s=e.getAttribute(this.binding("target"));return $(s)?parseInt(s):t&&(s!==null||i.target)?this.closestComponentID(t):null}closestComponentID(e){return $(e)?e:e?R(e.closest(`[${x}]`),t=>this.ownsElement(t)&&this.componentID(t)):null}pushHookEvent(e,t,i,s){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",t,i]),!1;let[n,o,a]=this.putRef([],"hook");return this.pushWithReply(()=>[n,o,a],"event",{type:"hook",event:t,value:i,cid:this.closestComponentID(e)},(l,d)=>s(d,n)),n}extractMeta(e,t,i){let s=this.binding("value-");for(let n=0;n<e.attributes.length;n++){t||(t={});let o=e.attributes[n].name;o.startsWith(s)&&(t[o.replace(s,"")]=e.getAttribute(o))}if(e.value!==void 0&&(t||(t={}),t.value=e.value,e.tagName==="INPUT"&&He.indexOf(e.type)>=0&&!e.checked&&delete t.value),i){t||(t={});for(let n in i)t[n]=i[n]}return t}pushEvent(e,t,i,s,n,o={}){this.pushWithReply(()=>this.putRef([t],e,o),"event",{type:e,event:s,value:this.extractMeta(t,n,o.value),cid:this.targetComponentID(t,i,o)})}pushFileProgress(e,t,i,s=function(){}){this.liveSocket.withinOwners(e.form,(n,o)=>{n.pushWithReply(null,"progress",{event:e.getAttribute(n.binding(Dt)),ref:e.getAttribute(M),entry_ref:t,progress:i,cid:n.targetComponentID(e.form,o)},s)})}pushInput(e,t,i,s,n,o){let a,l=$(i)?i:this.targetComponentID(e.form,t),d=()=>this.putRef([e,e.form],"change",n),f;e.getAttribute(this.binding("change"))?f=We(e.form,{_target:n._target},[e.name]):f=We(e.form,{_target:n._target}),h.isUploadInput(e)&&e.files&&e.files.length>0&&y.trackFiles(e,Array.from(e.files)),a=y.serializeUploads(e);let c={type:"form",event:s,value:f,uploads:a,cid:l};this.pushWithReply(d,"event",c,p=>{if(h.showError(e,this.liveSocket.binding(ve)),h.isUploadInput(e)&&e.getAttribute("data-phx-auto-upload")!==null){if(y.filesAwaitingPreflight(e).length>0){let[E,_]=d();this.uploadFiles(e.form,t,E,l,v=>{o&&o(p),this.triggerAwaitingSubmit(e.form)})}}else o&&o(p)})}triggerAwaitingSubmit(e){let t=this.getScheduledSubmit(e);if(t){let[i,s,n,o]=t;this.cancelSubmit(e),o()}}getScheduledSubmit(e){return this.formSubmits.find(([t,i,s,n])=>t.isSameNode(e))}scheduleSubmit(e,t,i,s){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,t,i,s])}cancelSubmit(e){this.formSubmits=this.formSubmits.filter(([t,i,s])=>t.isSameNode(e)?(this.undoRefs(i),!1):!0)}disableForm(e,t={}){let i=c=>!(te(c,`${this.binding(Se)}=ignore`,c.form)||te(c,"data-phx-update=ignore",c.form)),s=c=>c.hasAttribute(this.binding(Ee)),n=c=>c.tagName=="BUTTON",o=c=>["INPUT","TEXTAREA","SELECT"].includes(c.tagName),a=Array.from(e.elements),l=a.filter(s),d=a.filter(n).filter(i),f=a.filter(o).filter(i);return d.forEach(c=>{c.setAttribute(be,c.disabled),c.disabled=!0}),f.forEach(c=>{c.setAttribute(Fe,c.readOnly),c.readOnly=!0,c.files&&(c.setAttribute(be,c.disabled),c.disabled=!0)}),e.setAttribute(this.binding(et),""),this.putRef([e].concat(l).concat(d).concat(f),"submit",t)}pushFormSubmit(e,t,i,s,n){let o=()=>this.disableForm(e,s),a=this.targetComponentID(e,t);if(y.hasUploadsInProgress(e)){let[l,d]=o(),f=()=>this.pushFormSubmit(e,t,i,s,n);return this.scheduleSubmit(e,l,s,f)}else if(y.inputsAwaitingPreflight(e).length>0){let[l,d]=o(),f=()=>[l,d,s];this.uploadFiles(e,t,l,a,c=>{let p=We(e,{});this.pushWithReply(f,"event",{type:"form",event:i,value:p,cid:a},n)})}else{let l=We(e,{});this.pushWithReply(o,"event",{type:"form",event:i,value:l,cid:a},n)}}uploadFiles(e,t,i,s,n){let o=this.joinCount,a=y.activeFileInputs(e),l=a.length;a.forEach(d=>{let f=new y(d,this,()=>{l--,l===0&&n()});this.uploaders[d]=f;let c=f.entries().map(E=>E.toPreflightPayload()),p={ref:d.getAttribute(M),entries:c,cid:this.targetComponentID(d.form,t)};this.log("upload",()=>["sending preflight request",p]),this.pushWithReply(null,"allow_upload",p,E=>{if(this.log("upload",()=>["got preflight response",E]),E.error){this.undoRefs(i);let[_,v]=E.error;this.log("upload",()=>[`error for entry ${_}`,v])}else{let _=v=>{this.channel.onError(()=>{this.joinCount===o&&v()})};f.initAdapterUpload(E,_,this.liveSocket)}})})}dispatchUploads(e,t){let i=h.findUploadInputs(this.el).filter(s=>s.name===e);i.length===0?P(`no live file inputs found matching the name "${e}"`):i.length>1?P(`duplicate live file inputs found matching the name "${e}"`):h.dispatchEvent(i[0],De,{detail:{files:t}})}pushFormRecovery(e,t,i){this.liveSocket.withinOwners(e,(s,n)=>{let o=e.elements[0],a=e.getAttribute(this.binding(nt))||e.getAttribute(this.binding("change"));H.exec("change",a,s,o,["push",{_target:o.name,newCid:t,callback:i}])})}pushLinkPatch(e,t,i){let s=this.liveSocket.setPendingLink(e),n=t?()=>this.putRef([t],"click"):null,o=()=>this.liveSocket.redirect(window.location.href),a=this.pushWithReply(n,"live_patch",{url:e},l=>{this.liveSocket.requestDOMUpdate(()=>{l.link_redirect?this.liveSocket.replaceMain(e,null,i,s):(this.liveSocket.commitPendingLink(s)&&(this.href=e),this.applyPendingUpdates(),i&&i(s))})});a?a.receive("timeout",o):o()}formsForRecovery(e){if(this.joinCount===0)return[];let t=this.binding("change"),i=document.createElement("template");return i.innerHTML=e,h.all(this.el,`form[${t}]`).filter(s=>s.id&&this.ownsElement(s)).filter(s=>s.elements.length>0).filter(s=>s.getAttribute(this.binding(nt))!=="ignore").map(s=>{let n=i.content.querySelector(`form[id="${s.id}"][${t}="${s.getAttribute(t)}"]`);return n?[s,n,this.targetComponentID(n)]:[s,null,null]}).filter(([s,n,o])=>n)}maybePushComponentsDestroyed(e){let t=e.filter(i=>h.findComponentNodeList(this.el,i).length===0);t.length>0&&(this.pruningCIDs.push(...t),this.pushWithReply(null,"cids_will_destroy",{cids:t},()=>{this.pruningCIDs=this.pruningCIDs.filter(s=>t.indexOf(s)!==-1);let i=t.filter(s=>h.findComponentNodeList(this.el,s).length===0);i.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:i},s=>{this.rendered.pruneCIDs(s.cids)})}))}ownsElement(e){return this.isDead||e.getAttribute(W)===this.id||R(e.closest(J),t=>t.id)===this.id}submitForm(e,t,i,s={}){h.putPrivate(e,Ne,!0);let n=this.liveSocket.binding(ve),o=Array.from(e.elements);this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,i,s,()=>{o.forEach(a=>h.showError(a,n)),this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}};var Ke=class{constructor(e,t,i={}){if(this.unloaded=!1,!t||t.constructor.name==="Object")throw new Error(`
12
12
  a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example:
13
13
 
14
14
  import {Socket} from "phoenix"
15
15
  import {LiveSocket} from "phoenix_live_view"
16
16
  let liveSocket = new LiveSocket("/live", Socket, {...})
17
- `);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||Ht,this.opts=i,this.params=$e(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(ue(Ft),i.defaults||{}),this.activeElement=null,this.prevActive=null,this.silenced=!1,this.main=null,this.outgoingMainEl=null,this.clickStartedAtTarget=null,this.linkRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=ue(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||Rt,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||_t,this.reloadJitterMin=i.reloadJitterMin||St,this.reloadJitterMax=i.reloadJitterMax||At,this.failsafeJitter=i.failsafeJitter||yt,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:$e(),onBeforeElUpdated:$e()},i.dom||{}),this.transitions=new Gt,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}isProfileEnabled(){return this.sessionStorage.getItem(Me)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(Ae)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(Ae)==="false"}enableDebug(){this.sessionStorage.setItem(Ae,"true")}enableProfiling(){this.sessionStorage.setItem(Me,"true")}disableDebug(){this.sessionStorage.setItem(Ae,"false")}disableProfiling(){this.sessionStorage.removeItem(Me)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(Ue,e)}disableLatencySim(){this.sessionStorage.removeItem(Ue)}getLatencySim(){let e=this.sessionStorage.getItem(Ue);return e?parseInt(e):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();let e=()=>{this.joinRootViews()?(this.bindTopLevelEvents(),this.socket.connect()):this.main?this.socket.connect():this.joinDeadView()};["complete","loaded","interactive"].indexOf(document.readyState)>=0?e():document.addEventListener("DOMContentLoaded",()=>e())}disconnect(e){clearTimeout(this.reloadWithJitterTimer),this.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){this.owner(e,s=>H.exec(i,t,s,e))}triggerDOM(e,t){this.domCallbacks[e](...t)}time(e,t){if(!this.isProfileEnabled()||!console.time)return t();console.time(e);let i=t();return console.timeEnd(e),i}log(e,t,i){if(this.viewLogger){let[s,n]=i();this.viewLogger(e,t,s,n)}else if(this.isDebugEnabled()){let[s,n]=i();Xt(e,t,s,n)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,s=>{let n=this.getLatencySim();n?setTimeout(()=>i(s),n):i(s)})}wrapPush(e,t,i){let s=this.getLatencySim(),n=e.joinCount;if(!s)return this.isConnected()&&t.timeout?i().receive("timeout",()=>{e.joinCount===n&&!e.isDestroyed()&&this.reloadWithJitter(e,()=>{this.log(e,"timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}):i();let o={receives:[],receive(a,l){this.receives.push([a,l])}};return setTimeout(()=>{e.isDestroyed()||o.receives.reduce((a,[l,d])=>a.receive(l,d),i())},s),o}reloadWithJitter(e,t){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,s=this.reloadJitterMax,n=Math.floor(Math.random()*(s-i+1))+i,o=O.updateLocal(this.localStorage,window.location.pathname,ke,0,a=>a+1);o>this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{e.isDestroyed()||e.isConnected()||(e.destroy(),t?t():this.log(e,"join",()=>[`encountered ${o} consecutive reloads`]),o>this.maxReloads&&this.log(e,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),this.hasPendingLink()?window.location=this.pendingLink:window.location.reload())},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?Jt[e.split(".")[1]]:this.hooks[e]}isUnloaded(){return this.unloaded}isConnected(){return this.socket.isConnected()}getBindingPrefix(){return this.bindingPrefix}binding(e){return`${this.getBindingPrefix()}${e}`}channel(e,t){return this.socket.channel(e,t)}joinDeadView(){this.bindTopLevelEvents({dead:!0});let e=this.newRootView(document.body);e.setHref(this.getHref()),e.joinDead(),this.main=e,window.requestAnimationFrame(()=>e.execNewMounted())}joinRootViews(){let e=!1;return h.all(document,`${J}:not([${W}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);i.setHref(this.getHref()),i.join(),t.getAttribute(le)&&(this.main=i)}e=!0}),e}redirect(e,t){this.disconnect(),O.redirect(e,t)}replaceMain(e,t,i=null,s=this.setPendingLink(e)){let n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=h.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(o,t,n),this.main.setRedirect(e),this.transitionRemoves(),this.main.join((a,l)=>{a===1&&this.commitPendingLink(s)&&this.requestDOMUpdate(()=>{h.findPhxSticky(document).forEach(d=>o.appendChild(d)),this.outgoingMainEl.replaceWith(o),this.outgoingMainEl=null,i&&requestAnimationFrame(i),l()})})}transitionRemoves(e){let t=this.binding("remove");e=e||h.all(document,`[${t}]`),e.forEach(i=>{document.body.contains(i)&&this.execJS(i,i.getAttribute(t),"remove")})}isPhxView(e){return e.getAttribute&&e.getAttribute(D)!==null}newRootView(e,t,i){let s=new pe(e,this,null,t,i);return this.roots[s.id]=s,s}owner(e,t){let i=R(e.closest(J),s=>this.getViewByEl(s))||this.main;i&&t(i)}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(K);return R(this.getRootById(t),i=>i.getDescendentByEl(e))}getRootById(e){return this.roots[e]}destroyAllViews(){for(let e in this.roots)this.roots[e].destroy(),delete this.roots[e];this.main=null}destroyViewByEl(e){let t=this.getRootById(e.getAttribute(K));t&&t.id===e.id?(t.destroy(),delete this.roots[t.id]):t&&t.destroyDescendent(e.id)}setActiveElement(e){if(this.activeElement===e)return;this.activeElement=e;let t=()=>{e===this.activeElement&&(this.activeElement=null),e.removeEventListener("mouseup",this),e.removeEventListener("touchend",this)};e.addEventListener("mouseup",t),e.addEventListener("touchend",t)}getActiveElement(){return document.activeElement===document.body?this.activeElement||document.activeElement:document.activeElement||document.body}dropActiveElement(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}bindTopLevelEvents({dead:e}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.socket.onClose(t=>{t&&t.code===1e3&&this.main&&this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",t=>{t.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),e||this.bindNav(),this.bindClicks(),e||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(t,i,s,n,o,a)=>{let l=n.getAttribute(this.binding(Lt)),d=t.key&&t.key.toLowerCase();if(l&&l.toLowerCase()!==d)return;let f=ne({key:t.key},this.eventMeta(i,t,n));H.exec(i,o,s,n,["push",{data:f}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,s,n,o,a)=>{if(!a){let l=ne({key:t.key},this.eventMeta(i,t,n));H.exec(i,o,s,n,["push",{data:l}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,s,n,o,a,l)=>{if(l==="window"){let d=this.eventMeta(i,t,n);H.exec(i,a,s,n,["push",{data:d}])}}),window.addEventListener("dragover",t=>t.preventDefault()),window.addEventListener("drop",t=>{t.preventDefault();let i=R(te(t.target,this.binding(Qe)),o=>o.getAttribute(this.binding(Qe))),s=i&&document.getElementById(i),n=Array.from(t.dataTransfer.files||[]);!s||s.disabled||n.length===0||!(s.files instanceof FileList)||(y.trackFiles(s,n),s.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(De,t=>{let i=t.target;if(!h.isUploadInput(i))return;let s=Array.from(t.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);y.trackFiles(i,s),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let s=this.metadataCallbacks[e];return s?s(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.linkRef}commitPendingLink(e){return this.linkRef!==e?!1:(this.href=this.pendingLink,this.pendingLink=null,!0)}getHref(){return this.href}hasPendingLink(){return!!this.pendingLink}bind(e,t){for(let i in e){let s=e[i];this.on(s,n=>{let o=this.binding(i),a=this.binding(`window-${i}`),l=n.target.getAttribute&&n.target.getAttribute(o);l?this.debounce(n.target,n,s,()=>{this.withinOwners(n.target,d=>{t(n,i,d,n.target,l,null)})}):h.all(document,`[${a}]`,d=>{let f=d.getAttribute(a);this.debounce(d,n,s,()=>{this.withinOwners(d,c=>{t(n,i,c,d,f,"window")})})})})}}bindClicks(){window.addEventListener("mousedown",e=>this.clickStartedAtTarget=e.target),this.bindClick("click","click",!1),this.bindClick("mousedown","capture-click",!0)}bindClick(e,t,i){let s=this.binding(t);window.addEventListener(e,n=>{let o=null;if(i)o=n.target.matches(`[${s}]`)?n.target:n.target.querySelector(`[${s}]`);else{let l=this.clickStartedAtTarget||n.target;o=te(l,s),this.dispatchClickAway(n,l),this.clickStartedAtTarget=null}let a=o&&o.getAttribute(s);!a||(o.getAttribute("href")==="#"&&n.preventDefault(),this.debounce(o,n,"click",()=>{this.withinOwners(o,l=>{H.exec("click",a,l,o,["push",{data:this.eventMeta("click",n,o)}])})}))},i)}dispatchClickAway(e,t){let i=this.binding("click-away");h.all(document,`[${i}]`,s=>{s.isSameNode(t)||s.contains(t)||this.withinOwners(e.target,n=>{let o=s.getAttribute(i);H.isVisible(s)&&H.exec("click",o,n,s,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!O.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{clearTimeout(e),e=setTimeout(()=>{O.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",t=>{if(!this.registerNewLocation(window.location))return;let{type:i,id:s,root:n,scroll:o}=t.state||{},a=window.location.href;this.requestDOMUpdate(()=>{this.main.isConnected()&&i==="patch"&&s===this.main.id?this.main.pushLinkPatch(a,null):this.replaceMain(a,null,()=>{n&&this.replaceRootHistory(),typeof o=="number"&&setTimeout(()=>{window.scrollTo(0,o)},0)})})},!1),window.addEventListener("click",t=>{let i=te(t.target,Le),s=i&&i.getAttribute(Le),n=t.metaKey||t.ctrlKey||t.button===1;if(!s||!this.isConnected()||!this.main||n)return;let o=i.href,a=i.getAttribute(wt);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==o&&this.requestDOMUpdate(()=>{if(s==="patch")this.pushHistoryPatch(o,a,i);else if(s==="redirect")this.historyRedirect(o,a);else throw new Error(`expected ${Le} to be "patch" or "redirect", got: ${s}`);let l=i.getAttribute(this.binding("click"));l&&this.requestDOMUpdate(()=>this.execJS(i,l,"click"))})},!1)}dispatchEvent(e,t={}){h.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){h.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>h.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i){if(!this.isConnected())return O.redirect(e);this.withPageLoading({to:e,kind:"patch"},s=>{this.main.pushLinkPatch(e,i,n=>{this.historyPatch(e,t,n),s()})})}historyPatch(e,t,i=this.setPendingLink(e)){!this.commitPendingLink(i)||(O.pushState(t,{type:"patch",id:this.main.id},e),this.registerNewLocation(window.location))}historyRedirect(e,t,i){if(!this.isConnected())return O.redirect(e,i);if(/^\/[^\/]+.*$/.test(e)){let{protocol:n,host:o}=window.location;e=`${n}//${o}${e}`}let s=window.scrollY;this.withPageLoading({to:e,kind:"redirect"},n=>{this.replaceMain(e,i,()=>{O.pushState(t,{type:"redirect",id:this.main.id,scroll:s},e),this.registerNewLocation(window.location),n()})})}replaceRootHistory(){O.pushState("replace",{root:!0,type:"patch",id:this.main.id})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=ue(e),!0)}bindForms(){let e=0,t=!1;this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit")),n=i.target.getAttribute(this.binding("change"));!t&&n&&!s&&(t=!0,i.preventDefault(),this.withinOwners(i.target,o=>{o.disableForm(i.target),window.requestAnimationFrame(()=>i.target.submit())}))},!0),this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit"));!s||(i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,n=>{H.exec("submit",s,n,i.target,["push",{}])}))},!1);for(let i of["change","input"])this.on(i,s=>{let n=this.binding("change"),o=s.target,a=o.getAttribute(n),l=o.form&&o.form.getAttribute(n),d=a||l;if(!d||o.type==="number"&&o.validity&&o.validity.badInput)return;let f=a?o:o.form,c=e;e++;let{at:p,type:E}=h.private(o,"prev-iteration")||{};p===c-1&&i!==E||(h.putPrivate(o,"prev-iteration",{at:c,type:i}),this.debounce(o,s,i,()=>{this.withinOwners(f,_=>{h.putPrivate(o,Oe,!0),h.isTextualInput(o)||this.setActiveElement(o),H.exec("change",d,_,o,["push",{_target:s.target.name,dispatcher:f}])})}))},!1)}debounce(e,t,i,s){if(i==="blur"||i==="focusout")return s();let n=this.binding(kt),o=this.binding(It),a=this.defaults.debounce.toString(),l=this.defaults.throttle.toString();this.withinOwners(e,d=>{let f=()=>!d.isDestroyed()&&document.body.contains(e);h.debounce(e,t,n,a,o,l,f,()=>{s()})})}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,t){window.addEventListener(e,i=>{this.silenced||t(i)})}},Gt=class{constructor(){this.transitions=new Set,this.pendingOps=[],this.reset()}reset(){this.transitions.forEach(e=>{clearTimeout(e),this.transitions.delete(e)}),this.flushPendingOps()}after(e){this.size()===0?e():this.pushPendingOp(e)}addTransition(e,t,i){t();let s=setTimeout(()=>{this.transitions.delete(s),i(),this.size()===0&&this.flushPendingOps()},e);this.transitions.add(s)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){this.pendingOps.forEach(e=>e()),this.pendingOps=[]}};return Si;})();
17
+ `);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||Ht,this.opts=i,this.params=$e(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(ue(Ft),i.defaults||{}),this.activeElement=null,this.prevActive=null,this.silenced=!1,this.main=null,this.outgoingMainEl=null,this.clickStartedAtTarget=null,this.linkRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=ue(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||Rt,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||_t,this.reloadJitterMin=i.reloadJitterMin||St,this.reloadJitterMax=i.reloadJitterMax||At,this.failsafeJitter=i.failsafeJitter||yt,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:$e(),onBeforeElUpdated:$e()},i.dom||{}),this.transitions=new Gt,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}isProfileEnabled(){return this.sessionStorage.getItem(Me)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(Ae)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(Ae)==="false"}enableDebug(){this.sessionStorage.setItem(Ae,"true")}enableProfiling(){this.sessionStorage.setItem(Me,"true")}disableDebug(){this.sessionStorage.setItem(Ae,"false")}disableProfiling(){this.sessionStorage.removeItem(Me)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(Ue,e)}disableLatencySim(){this.sessionStorage.removeItem(Ue)}getLatencySim(){let e=this.sessionStorage.getItem(Ue);return e?parseInt(e):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();let e=()=>{this.joinRootViews()?(this.bindTopLevelEvents(),this.socket.connect()):this.main?this.socket.connect():this.joinDeadView()};["complete","loaded","interactive"].indexOf(document.readyState)>=0?e():document.addEventListener("DOMContentLoaded",()=>e())}disconnect(e){clearTimeout(this.reloadWithJitterTimer),this.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){this.owner(e,s=>H.exec(i,t,s,e))}triggerDOM(e,t){this.domCallbacks[e](...t)}time(e,t){if(!this.isProfileEnabled()||!console.time)return t();console.time(e);let i=t();return console.timeEnd(e),i}log(e,t,i){if(this.viewLogger){let[s,n]=i();this.viewLogger(e,t,s,n)}else if(this.isDebugEnabled()){let[s,n]=i();Xt(e,t,s,n)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,s=>{let n=this.getLatencySim();n?setTimeout(()=>i(s),n):i(s)})}wrapPush(e,t,i){let s=this.getLatencySim(),n=e.joinCount;if(!s)return this.isConnected()&&t.timeout?i().receive("timeout",()=>{e.joinCount===n&&!e.isDestroyed()&&this.reloadWithJitter(e,()=>{this.log(e,"timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}):i();let o={receives:[],receive(a,l){this.receives.push([a,l])}};return setTimeout(()=>{e.isDestroyed()||o.receives.reduce((a,[l,d])=>a.receive(l,d),i())},s),o}reloadWithJitter(e,t){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,s=this.reloadJitterMax,n=Math.floor(Math.random()*(s-i+1))+i,o=O.updateLocal(this.localStorage,window.location.pathname,ke,0,a=>a+1);o>this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{e.isDestroyed()||e.isConnected()||(e.destroy(),t?t():this.log(e,"join",()=>[`encountered ${o} consecutive reloads`]),o>this.maxReloads&&this.log(e,"join",()=>[`exceeded ${this.maxReloads} consecutive reloads. Entering failsafe mode`]),this.hasPendingLink()?window.location=this.pendingLink:window.location.reload())},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?Jt[e.split(".")[1]]:this.hooks[e]}isUnloaded(){return this.unloaded}isConnected(){return this.socket.isConnected()}getBindingPrefix(){return this.bindingPrefix}binding(e){return`${this.getBindingPrefix()}${e}`}channel(e,t){return this.socket.channel(e,t)}joinDeadView(){this.bindTopLevelEvents({dead:!0});let e=this.newRootView(document.body);e.setHref(this.getHref()),e.joinDead(),this.main=e,window.requestAnimationFrame(()=>e.execNewMounted())}joinRootViews(){let e=!1;return h.all(document,`${J}:not([${W}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);i.setHref(this.getHref()),i.join(),t.getAttribute(le)&&(this.main=i)}e=!0}),e}redirect(e,t){this.disconnect(),O.redirect(e,t)}replaceMain(e,t,i=null,s=this.setPendingLink(e)){let n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=h.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(o,t,n),this.main.setRedirect(e),this.transitionRemoves(),this.main.join((a,l)=>{a===1&&this.commitPendingLink(s)&&this.requestDOMUpdate(()=>{h.findPhxSticky(document).forEach(d=>o.appendChild(d)),this.outgoingMainEl.replaceWith(o),this.outgoingMainEl=null,i&&requestAnimationFrame(i),l()})})}transitionRemoves(e){let t=this.binding("remove");e=e||h.all(document,`[${t}]`),e.forEach(i=>{document.body.contains(i)&&this.execJS(i,i.getAttribute(t),"remove")})}isPhxView(e){return e.getAttribute&&e.getAttribute(D)!==null}newRootView(e,t,i){let s=new pe(e,this,null,t,i);return this.roots[s.id]=s,s}owner(e,t){let i=R(e.closest(J),s=>this.getViewByEl(s))||this.main;i&&t(i)}withinOwners(e,t){this.owner(e,i=>t(i,e))}getViewByEl(e){let t=e.getAttribute(K);return R(this.getRootById(t),i=>i.getDescendentByEl(e))}getRootById(e){return this.roots[e]}destroyAllViews(){for(let e in this.roots)this.roots[e].destroy(),delete this.roots[e];this.main=null}destroyViewByEl(e){let t=this.getRootById(e.getAttribute(K));t&&t.id===e.id?(t.destroy(),delete this.roots[t.id]):t&&t.destroyDescendent(e.id)}setActiveElement(e){if(this.activeElement===e)return;this.activeElement=e;let t=()=>{e===this.activeElement&&(this.activeElement=null),e.removeEventListener("mouseup",this),e.removeEventListener("touchend",this)};e.addEventListener("mouseup",t),e.addEventListener("touchend",t)}getActiveElement(){return document.activeElement===document.body?this.activeElement||document.activeElement:document.activeElement||document.body}dropActiveElement(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}bindTopLevelEvents({dead:e}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.socket.onClose(t=>{t&&t.code===1e3&&this.main&&this.reloadWithJitter(this.main)}),document.body.addEventListener("click",function(){}),window.addEventListener("pageshow",t=>{t.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),e||this.bindNav(),this.bindClicks(),e||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(t,i,s,n,o,a)=>{let l=n.getAttribute(this.binding(Lt)),d=t.key&&t.key.toLowerCase();if(l&&l.toLowerCase()!==d)return;let f=ne({key:t.key},this.eventMeta(i,t,n));H.exec(i,o,s,n,["push",{data:f}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,s,n,o,a)=>{if(!a){let l=ne({key:t.key},this.eventMeta(i,t,n));H.exec(i,o,s,n,["push",{data:l}])}}),this.bind({blur:"blur",focus:"focus"},(t,i,s,n,o,a,l)=>{if(l==="window"){let d=this.eventMeta(i,t,n);H.exec(i,a,s,n,["push",{data:d}])}}),window.addEventListener("dragover",t=>t.preventDefault()),window.addEventListener("drop",t=>{t.preventDefault();let i=R(te(t.target,this.binding(Qe)),o=>o.getAttribute(this.binding(Qe))),s=i&&document.getElementById(i),n=Array.from(t.dataTransfer.files||[]);!s||s.disabled||n.length===0||!(s.files instanceof FileList)||(y.trackFiles(s,n),s.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(De,t=>{let i=t.target;if(!h.isUploadInput(i))return;let s=Array.from(t.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);y.trackFiles(i,s),i.dispatchEvent(new Event("input",{bubbles:!0}))}))}eventMeta(e,t,i){let s=this.metadataCallbacks[e];return s?s(t,i):{}}setPendingLink(e){return this.linkRef++,this.pendingLink=e,this.linkRef}commitPendingLink(e){return this.linkRef!==e?!1:(this.href=this.pendingLink,this.pendingLink=null,!0)}getHref(){return this.href}hasPendingLink(){return!!this.pendingLink}bind(e,t){for(let i in e){let s=e[i];this.on(s,n=>{let o=this.binding(i),a=this.binding(`window-${i}`),l=n.target.getAttribute&&n.target.getAttribute(o);l?this.debounce(n.target,n,s,()=>{this.withinOwners(n.target,d=>{t(n,i,d,n.target,l,null)})}):h.all(document,`[${a}]`,d=>{let f=d.getAttribute(a);this.debounce(d,n,s,()=>{this.withinOwners(d,c=>{t(n,i,c,d,f,"window")})})})})}}bindClicks(){window.addEventListener("click",e=>this.clickStartedAtTarget=e.target),this.bindClick("click","click",!1),this.bindClick("mousedown","capture-click",!0)}bindClick(e,t,i){let s=this.binding(t);window.addEventListener(e,n=>{let o=null;if(i)o=n.target.matches(`[${s}]`)?n.target:n.target.querySelector(`[${s}]`);else{let l=this.clickStartedAtTarget||n.target;o=te(l,s),this.dispatchClickAway(n,l),this.clickStartedAtTarget=null}let a=o&&o.getAttribute(s);!a||(o.getAttribute("href")==="#"&&n.preventDefault(),this.debounce(o,n,"click",()=>{this.withinOwners(o,l=>{H.exec("click",a,l,o,["push",{data:this.eventMeta("click",n,o)}])})}))},i)}dispatchClickAway(e,t){let i=this.binding("click-away");h.all(document,`[${i}]`,s=>{s.isSameNode(t)||s.contains(t)||this.withinOwners(e.target,n=>{let o=s.getAttribute(i);H.isVisible(s)&&H.exec("click",o,n,s,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!O.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{clearTimeout(e),e=setTimeout(()=>{O.updateCurrentState(i=>Object.assign(i,{scroll:window.scrollY}))},100)}),window.addEventListener("popstate",t=>{if(!this.registerNewLocation(window.location))return;let{type:i,id:s,root:n,scroll:o}=t.state||{},a=window.location.href;this.requestDOMUpdate(()=>{this.main.isConnected()&&i==="patch"&&s===this.main.id?this.main.pushLinkPatch(a,null):this.replaceMain(a,null,()=>{n&&this.replaceRootHistory(),typeof o=="number"&&setTimeout(()=>{window.scrollTo(0,o)},0)})})},!1),window.addEventListener("click",t=>{let i=te(t.target,Le),s=i&&i.getAttribute(Le),n=t.metaKey||t.ctrlKey||t.button===1;if(!s||!this.isConnected()||!this.main||n)return;let o=i.href,a=i.getAttribute(wt);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==o&&this.requestDOMUpdate(()=>{if(s==="patch")this.pushHistoryPatch(o,a,i);else if(s==="redirect")this.historyRedirect(o,a);else throw new Error(`expected ${Le} to be "patch" or "redirect", got: ${s}`);let l=i.getAttribute(this.binding("click"));l&&this.requestDOMUpdate(()=>this.execJS(i,l,"click"))})},!1)}dispatchEvent(e,t={}){h.dispatchEvent(window,`phx:${e}`,{detail:t})}dispatchEvents(e){e.forEach(([t,i])=>this.dispatchEvent(t,i))}withPageLoading(e,t){h.dispatchEvent(window,"phx:page-loading-start",{detail:e});let i=()=>h.dispatchEvent(window,"phx:page-loading-stop",{detail:e});return t?t(i):i}pushHistoryPatch(e,t,i){if(!this.isConnected())return O.redirect(e);this.withPageLoading({to:e,kind:"patch"},s=>{this.main.pushLinkPatch(e,i,n=>{this.historyPatch(e,t,n),s()})})}historyPatch(e,t,i=this.setPendingLink(e)){!this.commitPendingLink(i)||(O.pushState(t,{type:"patch",id:this.main.id},e),this.registerNewLocation(window.location))}historyRedirect(e,t,i){if(!this.isConnected())return O.redirect(e,i);if(/^\/[^\/]+.*$/.test(e)){let{protocol:n,host:o}=window.location;e=`${n}//${o}${e}`}let s=window.scrollY;this.withPageLoading({to:e,kind:"redirect"},n=>{this.replaceMain(e,i,()=>{O.pushState(t,{type:"redirect",id:this.main.id,scroll:s},e),this.registerNewLocation(window.location),n()})})}replaceRootHistory(){O.pushState("replace",{root:!0,type:"patch",id:this.main.id})}registerNewLocation(e){let{pathname:t,search:i}=this.currentLocation;return t+i===e.pathname+e.search?!1:(this.currentLocation=ue(e),!0)}bindForms(){let e=0,t=!1;this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit")),n=i.target.getAttribute(this.binding("change"));!t&&n&&!s&&(t=!0,i.preventDefault(),this.withinOwners(i.target,o=>{o.disableForm(i.target),window.requestAnimationFrame(()=>i.target.submit())}))},!0),this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit"));!s||(i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,n=>{H.exec("submit",s,n,i.target,["push",{}])}))},!1);for(let i of["change","input"])this.on(i,s=>{let n=this.binding("change"),o=s.target,a=o.getAttribute(n),l=o.form&&o.form.getAttribute(n),d=a||l;if(!d||o.type==="number"&&o.validity&&o.validity.badInput)return;let f=a?o:o.form,c=e;e++;let{at:p,type:E}=h.private(o,"prev-iteration")||{};p===c-1&&i!==E||(h.putPrivate(o,"prev-iteration",{at:c,type:i}),this.debounce(o,s,i,()=>{this.withinOwners(f,_=>{h.putPrivate(o,Oe,!0),h.isTextualInput(o)||this.setActiveElement(o),H.exec("change",d,_,o,["push",{_target:s.target.name,dispatcher:f}])})}))},!1)}debounce(e,t,i,s){if(i==="blur"||i==="focusout")return s();let n=this.binding(kt),o=this.binding(It),a=this.defaults.debounce.toString(),l=this.defaults.throttle.toString();this.withinOwners(e,d=>{let f=()=>!d.isDestroyed()&&document.body.contains(e);h.debounce(e,t,n,a,o,l,f,()=>{s()})})}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,t){window.addEventListener(e,i=>{this.silenced||t(i)})}},Gt=class{constructor(){this.transitions=new Set,this.pendingOps=[],this.reset()}reset(){this.transitions.forEach(e=>{clearTimeout(e),this.transitions.delete(e)}),this.flushPendingOps()}after(e){this.size()===0?e():this.pushPendingOp(e)}addTransition(e,t,i){t();let s=setTimeout(()=>{this.transitions.delete(s),i(),this.size()===0&&this.flushPendingOps()},e);this.transitions.add(s)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){this.pendingOps.forEach(e=>e()),this.pendingOps=[]}};return Si;})();