phoenix_live_view 0.18.13 → 0.18.15
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.
- package/README.md +5 -1
- package/assets/js/phoenix_live_view/dom.js +14 -0
- package/assets/js/phoenix_live_view/js.js +9 -6
- package/assets/js/phoenix_live_view/live_socket.js +10 -0
- package/assets/package.json +1 -1
- package/package.json +1 -1
- package/priv/static/phoenix_live_view.cjs.js +28 -6
- package/priv/static/phoenix_live_view.cjs.js.map +2 -2
- package/priv/static/phoenix_live_view.esm.js +28 -6
- package/priv/static/phoenix_live_view.esm.js.map +2 -2
- package/priv/static/phoenix_live_view.js +28 -6
- package/priv/static/phoenix_live_view.min.js +6 -4
|
@@ -528,6 +528,18 @@ var LiveView = (() => {
|
|
|
528
528
|
el.classList.add(PHX_NO_FEEDBACK_CLASS);
|
|
529
529
|
}
|
|
530
530
|
},
|
|
531
|
+
resetForm(form, phxFeedbackFor) {
|
|
532
|
+
Array.from(form.elements).forEach((input) => {
|
|
533
|
+
let query = `[${phxFeedbackFor}="${input.id}"],
|
|
534
|
+
[${phxFeedbackFor}="${input.name}"],
|
|
535
|
+
[${phxFeedbackFor}="${input.name.replace(/\[\]$/, "")}"]`;
|
|
536
|
+
this.deletePrivate(input, PHX_HAS_FOCUSED);
|
|
537
|
+
this.deletePrivate(input, PHX_HAS_SUBMITTED);
|
|
538
|
+
this.all(document, query, (feedbackEl) => {
|
|
539
|
+
feedbackEl.classList.add(PHX_NO_FEEDBACK_CLASS);
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
},
|
|
531
543
|
showError(inputEl, phxFeedbackFor) {
|
|
532
544
|
if (inputEl.id || inputEl.name) {
|
|
533
545
|
this.all(inputEl.form, `[${phxFeedbackFor}="${inputEl.id}"], [${phxFeedbackFor}="${inputEl.name}"]`, (el) => {
|
|
@@ -2273,10 +2285,7 @@ within:
|
|
|
2273
2285
|
this.addOrRemoveClasses(el, [], names, transition, time, view);
|
|
2274
2286
|
},
|
|
2275
2287
|
exec_transition(eventType, phxEvent, view, sourceEl, el, { time, transition }) {
|
|
2276
|
-
|
|
2277
|
-
let onStart = () => this.addOrRemoveClasses(el, transition_start.concat(running), []);
|
|
2278
|
-
let onDone = () => this.addOrRemoveClasses(el, transition_end, transition_start.concat(running));
|
|
2279
|
-
view.transition(time, onStart, onDone);
|
|
2288
|
+
this.addOrRemoveClasses(el, [], [], transition, time, view);
|
|
2280
2289
|
},
|
|
2281
2290
|
exec_toggle(eventType, phxEvent, view, sourceEl, el, { display, ins, outs, time }) {
|
|
2282
2291
|
this.toggle(eventType, view, el, display, ins, outs, time);
|
|
@@ -2327,7 +2336,8 @@ within:
|
|
|
2327
2336
|
}
|
|
2328
2337
|
let onStart = () => {
|
|
2329
2338
|
this.addOrRemoveClasses(el, inStartClasses, outClasses.concat(outStartClasses).concat(outEndClasses));
|
|
2330
|
-
|
|
2339
|
+
let stickyDisplay = display || this.defaultDisplay(el);
|
|
2340
|
+
dom_default.putSticky(el, "toggle", (currentEl) => currentEl.style.display = stickyDisplay);
|
|
2331
2341
|
window.requestAnimationFrame(() => {
|
|
2332
2342
|
this.addOrRemoveClasses(el, inClasses, []);
|
|
2333
2343
|
window.requestAnimationFrame(() => this.addOrRemoveClasses(el, inEndClasses, inStartClasses));
|
|
@@ -2349,7 +2359,8 @@ within:
|
|
|
2349
2359
|
} else {
|
|
2350
2360
|
window.requestAnimationFrame(() => {
|
|
2351
2361
|
el.dispatchEvent(new Event("phx:show-start"));
|
|
2352
|
-
|
|
2362
|
+
let stickyDisplay = display || this.defaultDisplay(el);
|
|
2363
|
+
dom_default.putSticky(el, "toggle", (currentEl) => currentEl.style.display = stickyDisplay);
|
|
2353
2364
|
el.dispatchEvent(new Event("phx:show-end"));
|
|
2354
2365
|
});
|
|
2355
2366
|
}
|
|
@@ -2394,6 +2405,9 @@ within:
|
|
|
2394
2405
|
},
|
|
2395
2406
|
filterToEls(sourceEl, { to }) {
|
|
2396
2407
|
return to ? dom_default.all(document, to) : [sourceEl];
|
|
2408
|
+
},
|
|
2409
|
+
defaultDisplay(el) {
|
|
2410
|
+
return { tr: "table-row", td: "table-cell" }[el.tagName.toLowerCase()] || "block";
|
|
2397
2411
|
}
|
|
2398
2412
|
};
|
|
2399
2413
|
var js_default = JS;
|
|
@@ -4194,6 +4208,14 @@ within:
|
|
|
4194
4208
|
});
|
|
4195
4209
|
}, false);
|
|
4196
4210
|
}
|
|
4211
|
+
this.on("reset", (e) => {
|
|
4212
|
+
let form = e.target;
|
|
4213
|
+
dom_default.resetForm(form, this.binding(PHX_FEEDBACK_FOR));
|
|
4214
|
+
let input = Array.from(form.elements).find((el) => el.type === "reset");
|
|
4215
|
+
window.requestAnimationFrame(() => {
|
|
4216
|
+
input.dispatchEvent(new Event("input", { bubbles: true, cancelable: false }));
|
|
4217
|
+
});
|
|
4218
|
+
});
|
|
4197
4219
|
}
|
|
4198
4220
|
debounce(el, event, eventType, callback) {
|
|
4199
4221
|
if (eventType === "blur" || eventType === "focusout") {
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
var LiveView=(()=>{var tt=Object.defineProperty;var St=Object.getOwnPropertySymbols;var si=Object.prototype.hasOwnProperty,ni=Object.prototype.propertyIsEnumerable;var At=(r,e,t)=>e in r?tt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ne=(r,e)=>{for(var t in e||(e={}))si.call(e,t)&&At(r,t,e[t]);if(St)for(var t of St(e))ni.call(e,t)&&At(r,t,e[t]);return r};var oi=r=>tt(r,"__esModule",{value:!0});var ai=(r,e)=>{oi(r);for(var t in e)tt(r,t,{get:e[t],enumerable:!0})};var xi={};ai(xi,{LiveSocket:()=>ze});var De="consecutive-reloads",yt=10,wt=5e3,Pt=1e4,xt=3e4,Oe=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading"],C="data-phx-component",He="data-phx-link",Ct="track-static",Tt="data-phx-link-state",O="data-phx-ref",j="data-phx-ref-src",Ne="track-uploads",M="data-phx-upload-ref",oe="data-phx-preflighted-refs",kt="data-phx-done-refs",it="drop-target",ve="data-phx-active-refs",ae="phx:live-file:updated",be="data-phx-skip",rt="data-phx-prune",st="page-loading",nt="phx-connected",Fe="phx-loading",ot="phx-no-feedback",at="phx-error",W="data-phx-parent-id",le="data-phx-main",q="data-phx-root-id",It="trigger-action",Ee="feedback-for",Me="phx-has-focused",Rt=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],Ue=["checkbox","radio"],_e="phx-has-submitted",H="data-phx-session",J=`[${H}]`,lt="data-phx-sticky",Y="data-phx-static",Xe="data-phx-readonly",Se="data-phx-disabled",Ae="disable-with",ye="data-phx-disable-with-restore",he="hook",Lt="debounce",Dt="throttle",de="update",ue="stream",Ot="key",U="phxPrivate",ht="auto-recover",we="phx:live-socket:debug",$e="phx:live-socket:profiling",Be="phx:live-socket:latency-sim",Ht="progress",dt="mounted",Nt=1,Ft=200,Mt="phx-",Ut=3e4;var ce="debounce-trigger",Pe="throttled",ut="debounce-prev-key",Xt={debounce:300,throttle:300},xe="d",X="s",I="c",ct="e",ft="r",pt="t",$t="p",Bt="stream";var Ve=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 Vt(){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 Jt=(r,e,t,i)=>{r.liveSocket.isDebugEnabled()&&console.log(`${r.id} ${e}: ${t} - `,i)},Je=r=>typeof r=="function"?r:function(){return r},fe=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},pe=r=>r!==null&&typeof r=="object"&&!(r instanceof Array),jt=(r,e)=>JSON.stringify(r)===JSON.stringify(e),mt=r=>{for(let e in r)return!1;return!0},B=(r,e)=>r&&e(r),Wt=function(r,e,t,i){r.forEach(s=>{new Ve(s,t.config.chunk_size,i).upload()})};var qt={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&&qt.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}"]`)}},N=qt;var V={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,`[${C}="${e}"]`),r)},isPhxDestroyed(r){return!!(r.id&&V.private(r,"destroyed"))},wantsNewTab(r){return r.ctrlKey||r.shiftKey||r.metaKey||r.button&&r.button===1||r.target.getAttribute("target")==="_blank"},isUnloadableFormSubmit(r){return!r.defaultPrevented&&!this.wantsNewTab(r)},isNewPageHref(r,e){let t;try{t=new URL(r)}catch(i){try{t=new URL(r,e)}catch(s){return!0}}return t.host===e.host&&t.protocol===e.protocol&&t.pathname===e.pathname&&t.search===e.search?t.hash===""&&!t.href.endsWith("#"):!0},markPhxChildDestroyed(r){this.isPhxChild(r)&&r.setAttribute(H,""),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,`[${lt}]`)},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=`[${C}="${n}"] [${C}]`;return this.filterWithinSameLiveView(this.all(r,o),r).map(a=>parseInt(a.getAttribute(C))).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(H)!==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");if(e){let{prefix:t,suffix:i}=e.dataset;document.title=`${t||""}${r}${i||""}`}else document.title=r},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),m=()=>d?this.deletePrivate(r,Pe):a(),g=this.incCycle(r,ce,m);if(isNaN(c))return P(`invalid throttle/debounce value: ${f}`);if(d){let _=!1;if(e.type==="keydown"){let x=this.private(r,ut);this.putPrivate(r,ut,e.key),_=x!==e.key}if(!_&&this.private(r,Pe))return!1;a(),this.putPrivate(r,Pe,!0),setTimeout(()=>{o()&&this.triggerCycle(r,ce)},c)}else setTimeout(()=>{o()&&this.triggerCycle(r,ce,g)},c);let p=r.form;p&&this.once(p,"bind-debounce")&&p.addEventListener("submit",()=>{Array.from(new FormData(p).entries(),([_])=>{let x=p.querySelector(`[name="${_}"]`);this.incCycle(x,ce),this.deletePrivate(x,Pe)})}),this.once(r,"bind-debounce")&&r.addEventListener("blur",()=>this.triggerCycle(r,ce))}},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,Me)||this.private(s,_e)||e.classList.add(ot)},showError(r,e){(r.id||r.name)&&this.all(r.form,`[${e}="${r.id}"], [${e}="${r.name}"]`,t=>{this.removeClass(t,ot)})},isPhxChild(r){return r.getAttribute&&r.getAttribute(W)},isPhxSticky(r){return r.getAttribute&&r.getAttribute(lt)!==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||V.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(!V.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&&Ue.indexOf(r.type.toLocaleLowerCase())>=0&&(r.checked=r.getAttribute("checked")!==null)},isTextualInput(r){return Rt.indexOf(r.type)>=0},isNowTriggerFormExternal(r,e){return r.getAttribute&&r.getAttribute(e)!==null},syncPendingRef(r,e,t){let i=r.getAttribute(O);if(i===null)return!0;let s=r.getAttribute(j);return V.isFormInput(r)||r.getAttribute(t)!==null?(V.isUploadInput(r)&&V.mergeAttrs(r,e,{isIgnored:!0}),V.putPrivate(r,O,e),!1):(Oe.forEach(n=>{r.classList.contains(n)&&e.classList.add(n)}),e.setAttribute(O,i),e.setAttribute(j,s),!0)},cleanChildNodes(r,e){if(V.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 it=Object.defineProperty;var At=Object.getOwnPropertySymbols;var si=Object.prototype.hasOwnProperty,ni=Object.prototype.propertyIsEnumerable;var St=(r,e,t)=>e in r?it(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,oe=(r,e)=>{for(var t in e||(e={}))si.call(e,t)&&St(r,t,e[t]);if(At)for(var t of At(e))ni.call(e,t)&&St(r,t,e[t]);return r};var oi=r=>it(r,"__esModule",{value:!0});var ai=(r,e)=>{oi(r);for(var t in e)it(r,t,{get:e[t],enumerable:!0})};var xi={};ai(xi,{LiveSocket:()=>Ye});var Oe="consecutive-reloads",yt=10,wt=5e3,Pt=1e4,xt=3e4,He=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading"],C="data-phx-component",Ne="data-phx-link",Ct="track-static",Tt="data-phx-link-state",O="data-phx-ref",j="data-phx-ref-src",Fe="track-uploads",M="data-phx-upload-ref",ae="data-phx-preflighted-refs",kt="data-phx-done-refs",rt="drop-target",Ee="data-phx-active-refs",le="phx:live-file:updated",_e="data-phx-skip",st="data-phx-prune",nt="page-loading",ot="phx-connected",Me="phx-loading",Ue="phx-no-feedback",at="phx-error",q="data-phx-parent-id",he="data-phx-main",W="data-phx-root-id",It="trigger-action",te="feedback-for",Ae="phx-has-focused",Rt=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],Xe=["checkbox","radio"],de="phx-has-submitted",H="data-phx-session",J=`[${H}]`,lt="data-phx-sticky",Y="data-phx-static",$e="data-phx-readonly",Se="data-phx-disabled",ye="disable-with",we="data-phx-disable-with-restore",ue="hook",Dt="debounce",Lt="throttle",ce="update",fe="stream",Ot="key",U="phxPrivate",ht="auto-recover",Pe="phx:live-socket:debug",Be="phx:live-socket:profiling",Ve="phx:live-socket:latency-sim",Ht="progress",dt="mounted",Nt=1,Ft=200,Mt="phx-",Ut=3e4;var pe="debounce-trigger",xe="throttled",ut="debounce-prev-key",Xt={debounce:300,throttle:300},Ce="d",X="s",I="c",ct="e",ft="r",pt="t",$t="p",Bt="stream";var Je=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 Vt(){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 Jt=(r,e,t,i)=>{r.liveSocket.isDebugEnabled()&&console.log(`${r.id} ${e}: ${t} - `,i)},je=r=>typeof r=="function"?r:function(){return r},me=r=>JSON.parse(JSON.stringify(r)),ie=(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},ge=r=>r!==null&&typeof r=="object"&&!(r instanceof Array),jt=(r,e)=>JSON.stringify(r)===JSON.stringify(e),mt=r=>{for(let e in r)return!1;return!0},B=(r,e)=>r&&e(r),qt=function(r,e,t,i){r.forEach(s=>{new Je(s,t.config.chunk_size,i).upload()})};var Wt={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&&Wt.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}"]`)}},N=Wt;var V={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,`[${C}="${e}"]`),r)},isPhxDestroyed(r){return!!(r.id&&V.private(r,"destroyed"))},wantsNewTab(r){return r.ctrlKey||r.shiftKey||r.metaKey||r.button&&r.button===1||r.target.getAttribute("target")==="_blank"},isUnloadableFormSubmit(r){return!r.defaultPrevented&&!this.wantsNewTab(r)},isNewPageHref(r,e){let t;try{t=new URL(r)}catch(i){try{t=new URL(r,e)}catch(s){return!0}}return t.host===e.host&&t.protocol===e.protocol&&t.pathname===e.pathname&&t.search===e.search?t.hash===""&&!t.href.endsWith("#"):!0},markPhxChildDestroyed(r){this.isPhxChild(r)&&r.setAttribute(H,""),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,`[${lt}]`)},findPhxChildren(r,e){return this.all(r,`${J}[${q}="${e}"]`)},findParentCIDs(r,e){let t=new Set(e),i=e.reduce((s,n)=>{let o=`[${C}="${n}"] [${C}]`;return this.filterWithinSameLiveView(this.all(r,o),r).map(a=>parseInt(a.getAttribute(C))).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(H)!==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");if(e){let{prefix:t,suffix:i}=e.dataset;document.title=`${t||""}${r}${i||""}`}else document.title=r},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),m=()=>d?this.deletePrivate(r,xe):a(),g=this.incCycle(r,pe,m);if(isNaN(c))return P(`invalid throttle/debounce value: ${f}`);if(d){let _=!1;if(e.type==="keydown"){let x=this.private(r,ut);this.putPrivate(r,ut,e.key),_=x!==e.key}if(!_&&this.private(r,xe))return!1;a(),this.putPrivate(r,xe,!0),setTimeout(()=>{o()&&this.triggerCycle(r,pe)},c)}else setTimeout(()=>{o()&&this.triggerCycle(r,pe,g)},c);let p=r.form;p&&this.once(p,"bind-debounce")&&p.addEventListener("submit",()=>{Array.from(new FormData(p).entries(),([_])=>{let x=p.querySelector(`[name="${_}"]`);this.incCycle(x,pe),this.deletePrivate(x,xe)})}),this.once(r,"bind-debounce")&&r.addEventListener("blur",()=>this.triggerCycle(r,pe))}},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,Ae)||this.private(s,de)||e.classList.add(Ue)},resetForm(r,e){Array.from(r.elements).forEach(t=>{let i=`[${e}="${t.id}"],
|
|
2
|
+
[${e}="${t.name}"],
|
|
3
|
+
[${e}="${t.name.replace(/\[\]$/,"")}"]`;this.deletePrivate(t,Ae),this.deletePrivate(t,de),this.all(document,i,s=>{s.classList.add(Ue)})})},showError(r,e){(r.id||r.name)&&this.all(r.form,`[${e}="${r.id}"], [${e}="${r.name}"]`,t=>{this.removeClass(t,Ue)})},isPhxChild(r){return r.getAttribute&&r.getAttribute(q)},isPhxSticky(r){return r.getAttribute&&r.getAttribute(lt)!==null},firstPhxChild(r){return this.isPhxChild(r)?r:this.all(r,`[${q}]`)[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||V.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(!V.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&&Xe.indexOf(r.type.toLocaleLowerCase())>=0&&(r.checked=r.getAttribute("checked")!==null)},isTextualInput(r){return Rt.indexOf(r.type)>=0},isNowTriggerFormExternal(r,e){return r.getAttribute&&r.getAttribute(e)!==null},syncPendingRef(r,e,t){let i=r.getAttribute(O);if(i===null)return!0;let s=r.getAttribute(j);return V.isFormInput(r)||r.getAttribute(t)!==null?(V.isUploadInput(r)&&V.mergeAttrs(r,e,{isIgnored:!0}),V.putPrivate(r,O,e),!1):(He.forEach(n=>{r.classList.contains(n)&&e.classList.add(n)}),e.setAttribute(O,i),e.setAttribute(j,s),!0)},cleanChildNodes(r,e){if(V.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
4
|
|
|
3
5
|
removing illegal node: "${(i.outerHTML||i.nodeValue).trim()}"
|
|
4
6
|
|
|
5
|
-
`),t.push(i))}),t.forEach(i=>i.remove())}},replaceRootContainer(r,e,t){let i=new Set(["id",H,Y,le,q]);if(r.tagName.toLowerCase()===e.toLowerCase())return Array.from(r.attributes).filter(s=>!i.has(s.name.toLowerCase())).forEach(s=>r.removeAttribute(s.name)),Object.keys(t).filter(s=>!i.has(s.toLowerCase())).forEach(s=>r.setAttribute(s,t[s])),r;{let s=document.createElement(e);return Object.keys(t).forEach(n=>s.setAttribute(n,t[n])),i.forEach(n=>s.setAttribute(n,r.getAttribute(n))),s.innerHTML=r.innerHTML,r.replaceWith(s),s}},getSticky(r,e,t){let i=(V.private(r,"sticky")||[]).find(([s])=>e===s);if(i){let[s,n,o]=i;return o}else return typeof t=="function"?t():t},deleteSticky(r,e){this.updatePrivate(r,"sticky",[],t=>t.filter(([i,s])=>i!==e))},putSticky(r,e,t){let i=t(r);this.updatePrivate(r,"sticky",[],s=>{let n=s.findIndex(([o])=>e===o);return n>=0?s[n]=[e,t,i]:s.push([e,t,i]),s})},applyStickyOperations(r){let e=V.private(r,"sticky");!e||e.forEach(([t,i,s])=>this.putSticky(r,t,i))}},h=V;var me=class{static isActive(e,t){let i=t._phxRef===void 0,n=e.getAttribute(ve).split(",").indexOf(y.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(oe).split(",").indexOf(y.genFileRef(t))>=0&&this.isActive(e,t)}constructor(e,t,i){this.ref=y.genFileRef(t),this.fileEl=e,this.file=t,this.view=i,this.meta=null,this._isCancelled=!1,this._isDone=!1,this._progress=0,this._lastProgressSent=-1,this._onDone=function(){},this._onElUpdated=this.onElUpdated.bind(this),this.fileEl.addEventListener(ae,this._onElUpdated)}metadata(){return this.meta}progress(e){this._progress=Math.floor(e),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{y.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}cancel(){this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.fileEl.removeEventListener(ae,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),y.clearFiles(this.fileEl)}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(ae,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(ve).split(",").indexOf(this.ref)===-1&&this.cancel()}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref}}uploader(e){if(this.meta.uploader){let t=e[this.meta.uploader]||P(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:Wt}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||P(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var li=0,y=class{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(li++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let s=this.activeFiles(e).find(n=>this.genFileRef(n)===t);i(URL.createObjectURL(s))}static hasUploadsInProgress(e){let t=0;return h.findUploadInputs(e).forEach(i=>{i.getAttribute(oe)!==i.getAttribute(kt)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(s=>{let n={path:e.name},o=e.getAttribute(M);i[o]=i[o]||[],n.ref=this.genFileRef(s),n.last_modified=s.lastModified,n.name=s.name||n.ref,n.relative_path=s.webkitRelativePath,n.type=s.type,n.size=s.size,i[o].push(n)}),i}static clearFiles(e){e.value=null,e.removeAttribute(M),h.putPrivate(e,"files",[])}static untrackFile(e,t){h.putPrivate(e,"files",h.private(e,"files").filter(i=>!Object.is(i,t)))}static trackFiles(e,t,i){if(e.getAttribute("multiple")!==null){let s=t.filter(n=>!this.activeFiles(e).find(o=>Object.is(o,n)));h.putPrivate(e,"files",this.activeFiles(e).concat(s)),e.value=null}else i&&i.files.length>0&&(e.files=i.files),h.putPrivate(e,"files",t)}static activeFileInputs(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>i.files&&this.activeFiles(i).length>0)}static activeFiles(e){return(h.private(e,"files")||[]).filter(t=>me.isActive(e,t))}static inputsAwaitingPreflight(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>this.filesAwaitingPreflight(i).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(t=>!me.isPreflighted(e,t))}constructor(e,t,i){this.view=t,this.onComplete=i,this._entries=Array.from(y.filesAwaitingPreflight(e)||[]).map(s=>new me(e,s,t)),this.numEntriesInProgress=this._entries.length}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map(n=>(n.zipPostFlight(e),n.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()}),n));let s=this._entries.reduce((n,o)=>{let{name:a,callback:l}=o.uploader(i.uploaders);return n[a]=n[a]||{callback:l,entries:[]},n[a].entries.push(o),n},{});for(let n in s){let{callback:o,entries:a}=s[n];o(a,t,e,i)}}};var hi={focusMain(){let r=document.querySelector("main h1, main, h1");if(r){let e=r.tabIndex;r.tabIndex=-1,r.focus(),r.tabIndex=e}},anyOf(r,e){return e.find(t=>r instanceof t)},isFocusable(r,e){return r instanceof HTMLAnchorElement&&r.rel!=="ignore"||r instanceof HTMLAreaElement&&r.href!==void 0||!r.disabled&&this.anyOf(r,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||r instanceof HTMLIFrameElement||r.tabIndex>0||!e&&r.tabIndex===0&&r.getAttribute("tabindex")!==null&&r.getAttribute("aria-hidden")!=="true"},attemptFocus(r,e){if(this.isFocusable(r,e))try{r.focus()}catch(t){}return!!document.activeElement&&document.activeElement.isSameNode(r)},focusFirstInteractive(r){let e=r.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e,!0))return!0;e=e.nextElementSibling}},focusFirst(r){let e=r.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(r){let e=r.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},Q=hi;var di={LiveFileUpload:{activeRefs(){return this.el.getAttribute(ve)},preflightedRefs(){return this.el.getAttribute(oe)},mounted(){this.preflightedWas=this.preflightedRefs()},updated(){let r=this.preflightedRefs();this.preflightedWas!==r&&(this.preflightedWas=r,r===""&&this.__view.cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(ae))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(M)),y.getEntryDataURL(this.inputEl,this.ref,r=>{this.url=r,this.el.src=r})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",()=>Q.focusLast(this.el)),this.focusEnd.addEventListener("focus",()=>Q.focusFirst(this.el)),this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&Q.focusFirst(this.el)}}},Kt=di;var je=class{constructor(e,t,i){let s=new Set,n=new Set([...t.children].map(a=>a.id)),o=[];Array.from(e.children).forEach(a=>{if(a.id&&(s.add(a.id),n.has(a.id))){let l=a.previousElementSibling&&a.previousElementSibling.id;o.push({elementId:a.id,previousElementId:l})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...n].filter(a=>!s.has(a))}perform(){let e=h.byId(this.containerId);this.elementsToModify.forEach(t=>{t.previousElementId?B(document.getElementById(t.previousElementId),i=>{B(document.getElementById(t.elementId),s=>{s.previousElementSibling&&s.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",s)})}):B(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{B(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))})}};var Gt=11;function ui(r,e){var t=e.attributes,i,s,n,o,a;if(!(e.nodeType===Gt||r.nodeType===Gt)){for(var l=t.length-1;l>=0;l--)i=t[l],s=i.name,n=i.namespaceURI,o=i.value,n?(s=i.localName||s,a=r.getAttributeNS(n,s),a!==o&&(i.prefix==="xmlns"&&(s=i.name),r.setAttributeNS(n,s,o))):(a=r.getAttribute(s),a!==o&&r.setAttribute(s,o));for(var d=r.attributes,f=d.length-1;f>=0;f--)i=d[f],s=i.name,n=i.namespaceURI,n?(s=i.localName||s,e.hasAttributeNS(n,s)||r.removeAttributeNS(n,s)):e.hasAttribute(s)||r.removeAttribute(s)}}var We,ci="http://www.w3.org/1999/xhtml",R=typeof document=="undefined"?void 0:document,fi=!!R&&"content"in R.createElement("template"),pi=!!R&&R.createRange&&"createContextualFragment"in R.createRange();function mi(r){var e=R.createElement("template");return e.innerHTML=r,e.content.childNodes[0]}function gi(r){We||(We=R.createRange(),We.selectNode(R.body));var e=We.createContextualFragment(r);return e.childNodes[0]}function vi(r){var e=R.createElement("body");return e.innerHTML=r,e.childNodes[0]}function bi(r){return r=r.trim(),fi?mi(r):pi?gi(r):vi(r)}function qe(r,e){var t=r.nodeName,i=e.nodeName,s,n;return t===i?!0:(s=t.charCodeAt(0),n=i.charCodeAt(0),s<=90&&n>=97?t===i.toUpperCase():n<=90&&s>=97?i===t.toUpperCase():!1)}function Ei(r,e){return!e||e===ci?R.createElement(r):R.createElementNS(e,r)}function _i(r,e){for(var t=r.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function gt(r,e,t){r[t]!==e[t]&&(r[t]=e[t],r[t]?r.setAttribute(t,""):r.removeAttribute(t))}var zt={OPTION:function(r,e){var t=r.parentNode;if(t){var i=t.nodeName.toUpperCase();i==="OPTGROUP"&&(t=t.parentNode,i=t&&t.nodeName.toUpperCase()),i==="SELECT"&&!t.hasAttribute("multiple")&&(r.hasAttribute("selected")&&!e.selected&&(r.setAttribute("selected","selected"),r.removeAttribute("selected")),t.selectedIndex=-1)}gt(r,e,"selected")},INPUT:function(r,e){gt(r,e,"checked"),gt(r,e,"disabled"),r.value!==e.value&&(r.value=e.value),e.hasAttribute("value")||r.removeAttribute("value")},TEXTAREA:function(r,e){var t=e.value;r.value!==t&&(r.value=t);var i=r.firstChild;if(i){var s=i.nodeValue;if(s==t||!t&&s==r.placeholder)return;i.nodeValue=t}},SELECT:function(r,e){if(!e.hasAttribute("multiple")){for(var t=-1,i=0,s=r.firstChild,n,o;s;)if(o=s.nodeName&&s.nodeName.toUpperCase(),o==="OPTGROUP")n=s,s=n.firstChild;else{if(o==="OPTION"){if(s.hasAttribute("selected")){t=i;break}i++}s=s.nextSibling,!s&&n&&(s=n.nextSibling,n=null)}r.selectedIndex=t}}},Ce=1,Yt=11,Qt=3,Zt=8;function Z(){}function Si(r){if(r)return r.getAttribute&&r.getAttribute("id")||r.id}function Ai(r){return function(t,i,s){if(s||(s={}),typeof i=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var n=i;i=R.createElement("html"),i.innerHTML=n}else i=bi(i);else i.nodeType===Yt&&(i=i.firstElementChild);var o=s.getNodeKey||Si,a=s.onBeforeNodeAdded||Z,l=s.onNodeAdded||Z,d=s.onBeforeElUpdated||Z,f=s.onElUpdated||Z,c=s.onBeforeNodeDiscarded||Z,m=s.onNodeDiscarded||Z,g=s.onBeforeElChildrenUpdated||Z,p=s.skipFromChildren||Z,_=s.addChild||function(b,v){return b.appendChild(v)},x=s.childrenOnly===!0,D=Object.create(null),u=[];function E(b){u.push(b)}function L(b,v){if(b.nodeType===Ce)for(var w=b.firstChild;w;){var S=void 0;v&&(S=o(w))?E(S):(m(w),w.firstChild&&L(w,v)),w=w.nextSibling}}function k(b,v,w){c(b)!==!1&&(v&&v.removeChild(b),m(b),L(b,w))}function bt(b){if(b.nodeType===Ce||b.nodeType===Yt)for(var v=b.firstChild;v;){var w=o(v);w&&(D[w]=v),bt(v),v=v.nextSibling}}bt(t);function Ye(b){l(b);for(var v=b.firstChild;v;){var w=v.nextSibling,S=o(v);if(S){var A=D[S];A&&qe(v,A)?(v.parentNode.replaceChild(A,v),ke(A,v)):Ye(v)}else Ye(v);v=w}}function ti(b,v,w){for(;v;){var S=v.nextSibling;(w=o(v))?E(w):k(v,b,!0),v=S}}function ke(b,v,w){var S=o(v);S&&delete D[S],!(!w&&(d(b,v)===!1||(r(b,v),f(b),g(b,v)===!1)))&&(b.nodeName!=="TEXTAREA"?ii(b,v):zt.TEXTAREA(b,v))}function ii(b,v){var w=p(b),S=v.firstChild,A=b.firstChild,re,K,se,Re,G;e:for(;S;){for(Re=S.nextSibling,re=o(S);!w&&A;){if(se=A.nextSibling,S.isSameNode&&S.isSameNode(A)){S=Re,A=se;continue e}K=o(A);var Le=A.nodeType,z=void 0;if(Le===S.nodeType&&(Le===Ce?(re?re!==K&&((G=D[re])?se===G?z=!1:(b.insertBefore(G,A),K?E(K):k(A,b,!0),A=G):z=!1):K&&(z=!1),z=z!==!1&&qe(A,S),z&&ke(A,S)):(Le===Qt||Le==Zt)&&(z=!0,A.nodeValue!==S.nodeValue&&(A.nodeValue=S.nodeValue))),z){S=Re,A=se;continue e}K?E(K):k(A,b,!0),A=se}if(re&&(G=D[re])&&qe(G,S))w||_(b,G),ke(G,S);else{var et=a(S);et!==!1&&(et&&(S=et),S.actualize&&(S=S.actualize(b.ownerDocument||R)),_(b,S),Ye(S))}S=Re,A=se}ti(b,A,K);var _t=zt[b.nodeName];_t&&_t(b,v)}var T=t,Ie=T.nodeType,Et=i.nodeType;if(!x){if(Ie===Ce)Et===Ce?qe(t,i)||(m(t),T=_i(t,Ei(i.nodeName,i.namespaceURI))):T=i;else if(Ie===Qt||Ie===Zt){if(Et===Ie)return T.nodeValue!==i.nodeValue&&(T.nodeValue=i.nodeValue),T;T=i}}if(T===i)m(t);else{if(i.isSameNode&&i.isSameNode(T))return;if(ke(T,i,x),u)for(var Qe=0,ri=u.length;Qe<ri;Qe++){var Ze=D[u[Qe]];Ze&&k(Ze,Ze.parentNode,!1)}}return!x&&T!==t&&t.parentNode&&(T.actualize&&(T=T.actualize(t.ownerDocument||R)),t.parentNode.replaceChild(T,t)),T}}var yi=Ai(ui),vt=yi;var ie=class{static patchEl(e,t,i){vt(e,t,{childrenOnly:!1,onBeforeElUpdated:(s,n)=>{if(i&&i.isSameNode(s)&&h.isFormInput(s))return h.mergeFocusedInput(s,n),!1}})}constructor(e,t,i,s,n,o){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=s,this.streams=n,this.streamInserts={},this.targetCID=o,this.cidPatch=$(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]}}before(e,t){this.callbacks[`before${e}`].push(t)}after(e,t){this.callbacks[`after${e}`].push(t)}trackBefore(e,...t){this.callbacks[`before${e}`].forEach(i=>i(...t))}trackAfter(e,...t){this.callbacks[`after${e}`].forEach(i=>i(...t))}markPrunableContentForRemoval(){let e=this.liveSocket.binding(de);h.all(this.container,`[${e}=${ue}]`,t=>t.innerHTML=""),h.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,t=>{t.setAttribute(rt,"")})}perform(){let{view:e,liveSocket:t,container:i,html:s}=this,n=this.isCIDPatch()?this.targetCIDContainer(s):i;if(this.isCIDPatch()&&!n)return;let o=t.getActiveElement(),{selectionStart:a,selectionEnd:l}=o&&h.hasSelectionRange(o)?o:{},d=t.binding(de),f=t.binding(Ee),c=t.binding(Ae),m=t.binding(It),g=[],p=[],_=[],x=null,D=t.time("premorph container prep",()=>this.buildDiffHTML(i,s,d,n));return this.trackBefore("added",i),this.trackBefore("updated",i,i),t.time("morphdom",()=>{this.streams.forEach(([u,E])=>{this.streamInserts=Object.assign(this.streamInserts,u),E.forEach(L=>{let k=i.querySelector(`[id="${L}"]`);k&&(this.maybePendingRemove(k)||(k.remove(),this.onNodeDiscarded(k)))})}),vt(n,D,{childrenOnly:n.getAttribute(C)===null,getNodeKey:u=>h.isPhxDestroyed(u)?null:u.id,skipFromChildren:u=>u.getAttribute(d)===ue,addChild:(u,E)=>{let L=E.id?this.streamInserts[E.id]:void 0;if(L===void 0)return u.appendChild(E);if(h.putPrivate(E,ue,!0),L===0)u.insertAdjacentElement("afterbegin",E);else if(L===-1)u.appendChild(E);else if(L>0){let k=Array.from(u.children)[L];u.insertBefore(E,k)}},onBeforeNodeAdded:u=>(this.trackBefore("added",u),u),onNodeAdded:u=>{u instanceof HTMLImageElement&&u.srcset?u.srcset=u.srcset:u instanceof HTMLVideoElement&&u.autoplay&&u.play(),h.isNowTriggerFormExternal(u,m)&&(x=u),h.discardError(n,u,f),(h.isPhxChild(u)&&e.ownsElement(u)||h.isPhxSticky(u)&&e.ownsElement(u.parentNode))&&this.trackAfter("phxChildAdded",u),g.push(u)},onNodeDiscarded:u=>this.onNodeDiscarded(u),onBeforeNodeDiscarded:u=>u.getAttribute&&u.getAttribute(rt)!==null?!0:!(h.private(u,ue)||u.parentElement!==null&&h.isPhxUpdate(u.parentElement,d,["append","prepend"])&&u.id||this.maybePendingRemove(u)||this.skipCIDSibling(u)),onElUpdated:u=>{h.isNowTriggerFormExternal(u,m)&&(x=u),p.push(u),this.maybeReOrderStream(u)},onBeforeElUpdated:(u,E)=>{if(h.cleanChildNodes(E,d),this.skipCIDSibling(E)||h.isPhxSticky(u))return!1;if(h.isIgnored(u,d)||u.form&&u.form.isSameNode(x))return this.trackBefore("updated",u,E),h.mergeAttrs(u,E,{isIgnored:!0}),p.push(u),h.applyStickyOperations(u),!1;if(u.type==="number"&&u.validity&&u.validity.badInput)return!1;if(!h.syncPendingRef(u,E,c))return h.isUploadInput(u)&&(this.trackBefore("updated",u,E),p.push(u)),h.applyStickyOperations(u),!1;if(h.isPhxChild(E)){let k=u.getAttribute(H);return h.mergeAttrs(u,E,{exclude:[Y]}),k!==""&&u.setAttribute(H,k),u.setAttribute(q,this.rootID),h.applyStickyOperations(u),!1}return h.copyPrivates(E,u),h.discardError(n,E,f),o&&u.isSameNode(o)&&h.isFormInput(u)&&u.type!=="hidden"?(this.trackBefore("updated",u,E),h.mergeFocusedInput(u,E),h.syncAttrsToProps(u),p.push(u),h.applyStickyOperations(u),!1):(h.isPhxUpdate(E,d,["append","prepend"])&&_.push(new je(u,E,E.getAttribute(d))),h.syncAttrsToProps(E),h.applyStickyOperations(E),this.trackBefore("updated",u,E),!0)}})}),t.isDebugEnabled()&&Vt(),_.length>0&&t.time("post-morph append/prepend restoration",()=>{_.forEach(u=>u.perform())}),t.silenceEvents(()=>h.restoreFocus(o,a,l)),h.dispatchEvent(document,"phx:update"),g.forEach(u=>this.trackAfter("added",u)),p.forEach(u=>this.trackAfter("updated",u)),this.transitionPendingRemoves(),x&&(t.unload(),x.submit()),!0}onNodeDiscarded(e){(h.isPhxChild(e)||h.isPhxSticky(e))&&this.liveSocket.destroyViewByEl(e),this.trackAfter("discarded",e)}maybePendingRemove(e){return e.getAttribute&&e.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(e),!0):!1}maybeReOrderStream(e){let t=e.id?this.streamInserts[e.id]:void 0;if(t!==void 0){if(h.putPrivate(e,ue,!0),t===0)e.parentElement.insertBefore(e,e.parentElement.firstElementChild);else if(t>0){let i=Array.from(e.parentElement.children),s=i.indexOf(e);if(t>=i.length-1)e.parentElement.appendChild(e);else{let n=i[t];s>t?e.parentElement.insertBefore(e,n):e.parentElement.insertBefore(e,n.nextElementSibling)}}}}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:t}=this;e.length>0&&(t.transitionRemoves(e),t.requestDOMUpdate(()=>{e.forEach(i=>{let s=h.firstPhxChild(i);s&&t.destroyViewByEl(s),i.remove()}),this.trackAfter("transitionsDiscarded",e)}))}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.getAttribute(be)!==null}targetCIDContainer(e){if(!this.isCIDPatch())return;let[t,...i]=h.findComponentNodeList(this.container,this.targetCID);return i.length===0&&h.childNodeLength(e)===1?t:t&&t.parentNode}buildDiffHTML(e,t,i,s){let n=this.isCIDPatch(),o=n&&s.getAttribute(C)===this.targetCID.toString();if(!n||o)return t;{let a=null,l=document.createElement("template");a=h.cloneNode(s);let[d,...f]=h.findComponentNodeList(a,this.targetCID);return l.innerHTML=t,f.forEach(c=>c.remove()),Array.from(a.childNodes).forEach(c=>{c.id&&c.nodeType===Node.ELEMENT_NODE&&c.getAttribute(C)!==this.targetCID.toString()&&(c.setAttribute(be,""),c.innerHTML="")}),Array.from(l.content.childNodes).forEach(c=>a.insertBefore(c,d)),d.remove(),a.outerHTML}}indexOf(e,t){return Array.from(e.children).indexOf(t)}};var Te=class{static extract(e){let{[ft]:t,[ct]:i,[pt]:s}=e;return delete e[ft],delete e[ct],delete e[pt],{diff:e,title:s,reply:t||null,events:i||[]}}constructor(e,t){this.viewId=e,this.rendered={},this.mergeDiff(t)}parentViewId(){return this.viewId}toString(e){let[t,i]=this.recursiveToString(this.rendered,this.rendered[I],e);return[t,i]}recursiveToString(e,t=e[I],i){i=i?new Set(i):null;let s={buffer:"",components:t,onlyCids:i,streams:new Set};return this.toOutputBuffer(e,null,s),[s.buffer,s.streams]}componentCIDs(e){return Object.keys(e[I]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[I]?Object.keys(e).length===1:!1}getComponent(e,t){return e[I][t]}mergeDiff(e){let t=e[I],i={};if(delete e[I],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[I]=this.rendered[I]||{},t){let s=this.rendered[I];for(let n in t)t[n]=this.cachedFindComponent(n,t[n],s,t,i);for(let n in t)s[n]=t[n];e[I]=t}}cachedFindComponent(e,t,i,s,n){if(n[e])return n[e];{let o,a,l=t[X];if($(l)){let d;l>0?d=this.cachedFindComponent(l,s[l],i,s,n):d=i[-l],a=d[X],o=this.cloneMerge(d,t),o[X]=a}else o=t[X]!==void 0?t:this.cloneMerge(i[e]||{},t);return n[e]=o,o}}mutableMerge(e,t){return t[X]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){for(let i in t){let s=t[i],n=e[i];pe(s)&&s[X]===void 0&&pe(n)?this.doMutableMerge(n,s):e[i]=s}}cloneMerge(e,t){let i=ne(ne({},e),t);for(let s in i){let n=t[s],o=e[s];pe(n)&&n[X]===void 0&&pe(o)&&(i[s]=this.cloneMerge(o,n))}return i}componentToString(e){let[t,i]=this.recursiveCIDToString(this.rendered[I],e);return[t,i]}pruneCIDs(e){e.forEach(t=>delete this.rendered[I][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[X]}templateStatic(e,t){return typeof e=="number"?t[e]:e}toOutputBuffer(e,t,i){if(e[xe])return this.comprehensionToBuffer(e,t,i);let{[X]:s}=e;s=this.templateStatic(s,t),i.buffer+=s[0];for(let n=1;n<s.length;n++)this.dynamicToBuffer(e[n-1],t,i),i.buffer+=s[n]}comprehensionToBuffer(e,t,i){let{[xe]:s,[X]:n,[Bt]:o}=e,[a,l]=o||[{},[]];n=this.templateStatic(n,t);let d=t||e[$t];for(let f=0;f<s.length;f++){let c=s[f];i.buffer+=n[0];for(let m=1;m<n.length;m++)this.dynamicToBuffer(c[m-1],d,i),i.buffer+=n[m]}o!==void 0&&(e[xe].length>0||l.length>0)&&(e[xe]=[],i.streams.add(o))}dynamicToBuffer(e,t,i){if(typeof e=="number"){let[s,n]=this.recursiveCIDToString(i.components,e,i.onlyCids);i.buffer+=s,i.streams=new Set([...i.streams,...n])}else pe(e)?this.toOutputBuffer(e,t,i):i.buffer+=e}recursiveCIDToString(e,t,i){let s=e[t]||P(`no component for CID ${t}`,e),n=document.createElement("template"),[o,a]=this.recursiveToString(s,e,i);n.innerHTML=o;let l=n.content,d=i&&!i.has(t),[f,c]=Array.from(l.childNodes).reduce(([m,g],p,_)=>p.nodeType===Node.ELEMENT_NODE?p.getAttribute(C)?[m,!0]:(p.setAttribute(C,t),p.id||(p.id=`${this.parentViewId()}-${t}-${_}`),d&&(p.setAttribute(be,""),p.innerHTML=""),[!0,g]):p.nodeValue.trim()!==""?(P(`only HTML element tags are allowed at the root of components.
|
|
7
|
+
`),t.push(i))}),t.forEach(i=>i.remove())}},replaceRootContainer(r,e,t){let i=new Set(["id",H,Y,he,W]);if(r.tagName.toLowerCase()===e.toLowerCase())return Array.from(r.attributes).filter(s=>!i.has(s.name.toLowerCase())).forEach(s=>r.removeAttribute(s.name)),Object.keys(t).filter(s=>!i.has(s.toLowerCase())).forEach(s=>r.setAttribute(s,t[s])),r;{let s=document.createElement(e);return Object.keys(t).forEach(n=>s.setAttribute(n,t[n])),i.forEach(n=>s.setAttribute(n,r.getAttribute(n))),s.innerHTML=r.innerHTML,r.replaceWith(s),s}},getSticky(r,e,t){let i=(V.private(r,"sticky")||[]).find(([s])=>e===s);if(i){let[s,n,o]=i;return o}else return typeof t=="function"?t():t},deleteSticky(r,e){this.updatePrivate(r,"sticky",[],t=>t.filter(([i,s])=>i!==e))},putSticky(r,e,t){let i=t(r);this.updatePrivate(r,"sticky",[],s=>{let n=s.findIndex(([o])=>e===o);return n>=0?s[n]=[e,t,i]:s.push([e,t,i]),s})},applyStickyOperations(r){let e=V.private(r,"sticky");!e||e.forEach(([t,i,s])=>this.putSticky(r,t,i))}},h=V;var ve=class{static isActive(e,t){let i=t._phxRef===void 0,n=e.getAttribute(Ee).split(",").indexOf(y.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(ae).split(",").indexOf(y.genFileRef(t))>=0&&this.isActive(e,t)}constructor(e,t,i){this.ref=y.genFileRef(t),this.fileEl=e,this.file=t,this.view=i,this.meta=null,this._isCancelled=!1,this._isDone=!1,this._progress=0,this._lastProgressSent=-1,this._onDone=function(){},this._onElUpdated=this.onElUpdated.bind(this),this.fileEl.addEventListener(le,this._onElUpdated)}metadata(){return this.meta}progress(e){this._progress=Math.floor(e),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{y.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}cancel(){this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.fileEl.removeEventListener(le,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),y.clearFiles(this.fileEl)}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(le,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(Ee).split(",").indexOf(this.ref)===-1&&this.cancel()}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref}}uploader(e){if(this.meta.uploader){let t=e[this.meta.uploader]||P(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:qt}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||P(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var li=0,y=class{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(li++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let s=this.activeFiles(e).find(n=>this.genFileRef(n)===t);i(URL.createObjectURL(s))}static hasUploadsInProgress(e){let t=0;return h.findUploadInputs(e).forEach(i=>{i.getAttribute(ae)!==i.getAttribute(kt)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(s=>{let n={path:e.name},o=e.getAttribute(M);i[o]=i[o]||[],n.ref=this.genFileRef(s),n.last_modified=s.lastModified,n.name=s.name||n.ref,n.relative_path=s.webkitRelativePath,n.type=s.type,n.size=s.size,i[o].push(n)}),i}static clearFiles(e){e.value=null,e.removeAttribute(M),h.putPrivate(e,"files",[])}static untrackFile(e,t){h.putPrivate(e,"files",h.private(e,"files").filter(i=>!Object.is(i,t)))}static trackFiles(e,t,i){if(e.getAttribute("multiple")!==null){let s=t.filter(n=>!this.activeFiles(e).find(o=>Object.is(o,n)));h.putPrivate(e,"files",this.activeFiles(e).concat(s)),e.value=null}else i&&i.files.length>0&&(e.files=i.files),h.putPrivate(e,"files",t)}static activeFileInputs(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>i.files&&this.activeFiles(i).length>0)}static activeFiles(e){return(h.private(e,"files")||[]).filter(t=>ve.isActive(e,t))}static inputsAwaitingPreflight(e){let t=h.findUploadInputs(e);return Array.from(t).filter(i=>this.filesAwaitingPreflight(i).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(t=>!ve.isPreflighted(e,t))}constructor(e,t,i){this.view=t,this.onComplete=i,this._entries=Array.from(y.filesAwaitingPreflight(e)||[]).map(s=>new ve(e,s,t)),this.numEntriesInProgress=this._entries.length}entries(){return this._entries}initAdapterUpload(e,t,i){this._entries=this._entries.map(n=>(n.zipPostFlight(e),n.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()}),n));let s=this._entries.reduce((n,o)=>{let{name:a,callback:l}=o.uploader(i.uploaders);return n[a]=n[a]||{callback:l,entries:[]},n[a].entries.push(o),n},{});for(let n in s){let{callback:o,entries:a}=s[n];o(a,t,e,i)}}};var hi={focusMain(){let r=document.querySelector("main h1, main, h1");if(r){let e=r.tabIndex;r.tabIndex=-1,r.focus(),r.tabIndex=e}},anyOf(r,e){return e.find(t=>r instanceof t)},isFocusable(r,e){return r instanceof HTMLAnchorElement&&r.rel!=="ignore"||r instanceof HTMLAreaElement&&r.href!==void 0||!r.disabled&&this.anyOf(r,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||r instanceof HTMLIFrameElement||r.tabIndex>0||!e&&r.tabIndex===0&&r.getAttribute("tabindex")!==null&&r.getAttribute("aria-hidden")!=="true"},attemptFocus(r,e){if(this.isFocusable(r,e))try{r.focus()}catch(t){}return!!document.activeElement&&document.activeElement.isSameNode(r)},focusFirstInteractive(r){let e=r.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e,!0))return!0;e=e.nextElementSibling}},focusFirst(r){let e=r.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(r){let e=r.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},Q=hi;var di={LiveFileUpload:{activeRefs(){return this.el.getAttribute(Ee)},preflightedRefs(){return this.el.getAttribute(ae)},mounted(){this.preflightedWas=this.preflightedRefs()},updated(){let r=this.preflightedRefs();this.preflightedWas!==r&&(this.preflightedWas=r,r===""&&this.__view.cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(le))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(M)),y.getEntryDataURL(this.inputEl,this.ref,r=>{this.url=r,this.el.src=r})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",()=>Q.focusLast(this.el)),this.focusEnd.addEventListener("focus",()=>Q.focusFirst(this.el)),this.el.addEventListener("phx:show-end",()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&Q.focusFirst(this.el)}}},Kt=di;var qe=class{constructor(e,t,i){let s=new Set,n=new Set([...t.children].map(a=>a.id)),o=[];Array.from(e.children).forEach(a=>{if(a.id&&(s.add(a.id),n.has(a.id))){let l=a.previousElementSibling&&a.previousElementSibling.id;o.push({elementId:a.id,previousElementId:l})}}),this.containerId=t.id,this.updateType=i,this.elementsToModify=o,this.elementIdsToAdd=[...n].filter(a=>!s.has(a))}perform(){let e=h.byId(this.containerId);this.elementsToModify.forEach(t=>{t.previousElementId?B(document.getElementById(t.previousElementId),i=>{B(document.getElementById(t.elementId),s=>{s.previousElementSibling&&s.previousElementSibling.id==i.id||i.insertAdjacentElement("afterend",s)})}):B(document.getElementById(t.elementId),i=>{i.previousElementSibling==null||e.insertAdjacentElement("afterbegin",i)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(t=>{B(document.getElementById(t),i=>e.insertAdjacentElement("afterbegin",i))})}};var Gt=11;function ui(r,e){var t=e.attributes,i,s,n,o,a;if(!(e.nodeType===Gt||r.nodeType===Gt)){for(var l=t.length-1;l>=0;l--)i=t[l],s=i.name,n=i.namespaceURI,o=i.value,n?(s=i.localName||s,a=r.getAttributeNS(n,s),a!==o&&(i.prefix==="xmlns"&&(s=i.name),r.setAttributeNS(n,s,o))):(a=r.getAttribute(s),a!==o&&r.setAttribute(s,o));for(var d=r.attributes,f=d.length-1;f>=0;f--)i=d[f],s=i.name,n=i.namespaceURI,n?(s=i.localName||s,e.hasAttributeNS(n,s)||r.removeAttributeNS(n,s)):e.hasAttribute(s)||r.removeAttribute(s)}}var We,ci="http://www.w3.org/1999/xhtml",R=typeof document=="undefined"?void 0:document,fi=!!R&&"content"in R.createElement("template"),pi=!!R&&R.createRange&&"createContextualFragment"in R.createRange();function mi(r){var e=R.createElement("template");return e.innerHTML=r,e.content.childNodes[0]}function gi(r){We||(We=R.createRange(),We.selectNode(R.body));var e=We.createContextualFragment(r);return e.childNodes[0]}function vi(r){var e=R.createElement("body");return e.innerHTML=r,e.childNodes[0]}function bi(r){return r=r.trim(),fi?mi(r):pi?gi(r):vi(r)}function Ke(r,e){var t=r.nodeName,i=e.nodeName,s,n;return t===i?!0:(s=t.charCodeAt(0),n=i.charCodeAt(0),s<=90&&n>=97?t===i.toUpperCase():n<=90&&s>=97?i===t.toUpperCase():!1)}function Ei(r,e){return!e||e===ci?R.createElement(r):R.createElementNS(e,r)}function _i(r,e){for(var t=r.firstChild;t;){var i=t.nextSibling;e.appendChild(t),t=i}return e}function gt(r,e,t){r[t]!==e[t]&&(r[t]=e[t],r[t]?r.setAttribute(t,""):r.removeAttribute(t))}var zt={OPTION:function(r,e){var t=r.parentNode;if(t){var i=t.nodeName.toUpperCase();i==="OPTGROUP"&&(t=t.parentNode,i=t&&t.nodeName.toUpperCase()),i==="SELECT"&&!t.hasAttribute("multiple")&&(r.hasAttribute("selected")&&!e.selected&&(r.setAttribute("selected","selected"),r.removeAttribute("selected")),t.selectedIndex=-1)}gt(r,e,"selected")},INPUT:function(r,e){gt(r,e,"checked"),gt(r,e,"disabled"),r.value!==e.value&&(r.value=e.value),e.hasAttribute("value")||r.removeAttribute("value")},TEXTAREA:function(r,e){var t=e.value;r.value!==t&&(r.value=t);var i=r.firstChild;if(i){var s=i.nodeValue;if(s==t||!t&&s==r.placeholder)return;i.nodeValue=t}},SELECT:function(r,e){if(!e.hasAttribute("multiple")){for(var t=-1,i=0,s=r.firstChild,n,o;s;)if(o=s.nodeName&&s.nodeName.toUpperCase(),o==="OPTGROUP")n=s,s=n.firstChild;else{if(o==="OPTION"){if(s.hasAttribute("selected")){t=i;break}i++}s=s.nextSibling,!s&&n&&(s=n.nextSibling,n=null)}r.selectedIndex=t}}},Te=1,Yt=11,Qt=3,Zt=8;function Z(){}function Ai(r){if(r)return r.getAttribute&&r.getAttribute("id")||r.id}function Si(r){return function(t,i,s){if(s||(s={}),typeof i=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var n=i;i=R.createElement("html"),i.innerHTML=n}else i=bi(i);else i.nodeType===Yt&&(i=i.firstElementChild);var o=s.getNodeKey||Ai,a=s.onBeforeNodeAdded||Z,l=s.onNodeAdded||Z,d=s.onBeforeElUpdated||Z,f=s.onElUpdated||Z,c=s.onBeforeNodeDiscarded||Z,m=s.onNodeDiscarded||Z,g=s.onBeforeElChildrenUpdated||Z,p=s.skipFromChildren||Z,_=s.addChild||function(b,v){return b.appendChild(v)},x=s.childrenOnly===!0,L=Object.create(null),u=[];function E(b){u.push(b)}function D(b,v){if(b.nodeType===Te)for(var w=b.firstChild;w;){var A=void 0;v&&(A=o(w))?E(A):(m(w),w.firstChild&&D(w,v)),w=w.nextSibling}}function k(b,v,w){c(b)!==!1&&(v&&v.removeChild(b),m(b),D(b,w))}function bt(b){if(b.nodeType===Te||b.nodeType===Yt)for(var v=b.firstChild;v;){var w=o(v);w&&(L[w]=v),bt(v),v=v.nextSibling}}bt(t);function Qe(b){l(b);for(var v=b.firstChild;v;){var w=v.nextSibling,A=o(v);if(A){var S=L[A];S&&Ke(v,S)?(v.parentNode.replaceChild(S,v),Ie(S,v)):Qe(v)}else Qe(v);v=w}}function ti(b,v,w){for(;v;){var A=v.nextSibling;(w=o(v))?E(w):k(v,b,!0),v=A}}function Ie(b,v,w){var A=o(v);A&&delete L[A],!(!w&&(d(b,v)===!1||(r(b,v),f(b),g(b,v)===!1)))&&(b.nodeName!=="TEXTAREA"?ii(b,v):zt.TEXTAREA(b,v))}function ii(b,v){var w=p(b),A=v.firstChild,S=b.firstChild,se,K,ne,De,G;e:for(;A;){for(De=A.nextSibling,se=o(A);!w&&S;){if(ne=S.nextSibling,A.isSameNode&&A.isSameNode(S)){A=De,S=ne;continue e}K=o(S);var Le=S.nodeType,z=void 0;if(Le===A.nodeType&&(Le===Te?(se?se!==K&&((G=L[se])?ne===G?z=!1:(b.insertBefore(G,S),K?E(K):k(S,b,!0),S=G):z=!1):K&&(z=!1),z=z!==!1&&Ke(S,A),z&&Ie(S,A)):(Le===Qt||Le==Zt)&&(z=!0,S.nodeValue!==A.nodeValue&&(S.nodeValue=A.nodeValue))),z){A=De,S=ne;continue e}K?E(K):k(S,b,!0),S=ne}if(se&&(G=L[se])&&Ke(G,A))w||_(b,G),Ie(G,A);else{var tt=a(A);tt!==!1&&(tt&&(A=tt),A.actualize&&(A=A.actualize(b.ownerDocument||R)),_(b,A),Qe(A))}A=De,S=ne}ti(b,S,K);var _t=zt[b.nodeName];_t&&_t(b,v)}var T=t,Re=T.nodeType,Et=i.nodeType;if(!x){if(Re===Te)Et===Te?Ke(t,i)||(m(t),T=_i(t,Ei(i.nodeName,i.namespaceURI))):T=i;else if(Re===Qt||Re===Zt){if(Et===Re)return T.nodeValue!==i.nodeValue&&(T.nodeValue=i.nodeValue),T;T=i}}if(T===i)m(t);else{if(i.isSameNode&&i.isSameNode(T))return;if(Ie(T,i,x),u)for(var Ze=0,ri=u.length;Ze<ri;Ze++){var et=L[u[Ze]];et&&k(et,et.parentNode,!1)}}return!x&&T!==t&&t.parentNode&&(T.actualize&&(T=T.actualize(t.ownerDocument||R)),t.parentNode.replaceChild(T,t)),T}}var yi=Si(ui),vt=yi;var re=class{static patchEl(e,t,i){vt(e,t,{childrenOnly:!1,onBeforeElUpdated:(s,n)=>{if(i&&i.isSameNode(s)&&h.isFormInput(s))return h.mergeFocusedInput(s,n),!1}})}constructor(e,t,i,s,n,o){this.view=e,this.liveSocket=e.liveSocket,this.container=t,this.id=i,this.rootID=e.root.id,this.html=s,this.streams=n,this.streamInserts={},this.targetCID=o,this.cidPatch=$(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]}}before(e,t){this.callbacks[`before${e}`].push(t)}after(e,t){this.callbacks[`after${e}`].push(t)}trackBefore(e,...t){this.callbacks[`before${e}`].forEach(i=>i(...t))}trackAfter(e,...t){this.callbacks[`after${e}`].forEach(i=>i(...t))}markPrunableContentForRemoval(){let e=this.liveSocket.binding(ce);h.all(this.container,`[${e}=${fe}]`,t=>t.innerHTML=""),h.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,t=>{t.setAttribute(st,"")})}perform(){let{view:e,liveSocket:t,container:i,html:s}=this,n=this.isCIDPatch()?this.targetCIDContainer(s):i;if(this.isCIDPatch()&&!n)return;let o=t.getActiveElement(),{selectionStart:a,selectionEnd:l}=o&&h.hasSelectionRange(o)?o:{},d=t.binding(ce),f=t.binding(te),c=t.binding(ye),m=t.binding(It),g=[],p=[],_=[],x=null,L=t.time("premorph container prep",()=>this.buildDiffHTML(i,s,d,n));return this.trackBefore("added",i),this.trackBefore("updated",i,i),t.time("morphdom",()=>{this.streams.forEach(([u,E])=>{this.streamInserts=Object.assign(this.streamInserts,u),E.forEach(D=>{let k=i.querySelector(`[id="${D}"]`);k&&(this.maybePendingRemove(k)||(k.remove(),this.onNodeDiscarded(k)))})}),vt(n,L,{childrenOnly:n.getAttribute(C)===null,getNodeKey:u=>h.isPhxDestroyed(u)?null:u.id,skipFromChildren:u=>u.getAttribute(d)===fe,addChild:(u,E)=>{let D=E.id?this.streamInserts[E.id]:void 0;if(D===void 0)return u.appendChild(E);if(h.putPrivate(E,fe,!0),D===0)u.insertAdjacentElement("afterbegin",E);else if(D===-1)u.appendChild(E);else if(D>0){let k=Array.from(u.children)[D];u.insertBefore(E,k)}},onBeforeNodeAdded:u=>(this.trackBefore("added",u),u),onNodeAdded:u=>{u instanceof HTMLImageElement&&u.srcset?u.srcset=u.srcset:u instanceof HTMLVideoElement&&u.autoplay&&u.play(),h.isNowTriggerFormExternal(u,m)&&(x=u),h.discardError(n,u,f),(h.isPhxChild(u)&&e.ownsElement(u)||h.isPhxSticky(u)&&e.ownsElement(u.parentNode))&&this.trackAfter("phxChildAdded",u),g.push(u)},onNodeDiscarded:u=>this.onNodeDiscarded(u),onBeforeNodeDiscarded:u=>u.getAttribute&&u.getAttribute(st)!==null?!0:!(h.private(u,fe)||u.parentElement!==null&&h.isPhxUpdate(u.parentElement,d,["append","prepend"])&&u.id||this.maybePendingRemove(u)||this.skipCIDSibling(u)),onElUpdated:u=>{h.isNowTriggerFormExternal(u,m)&&(x=u),p.push(u),this.maybeReOrderStream(u)},onBeforeElUpdated:(u,E)=>{if(h.cleanChildNodes(E,d),this.skipCIDSibling(E)||h.isPhxSticky(u))return!1;if(h.isIgnored(u,d)||u.form&&u.form.isSameNode(x))return this.trackBefore("updated",u,E),h.mergeAttrs(u,E,{isIgnored:!0}),p.push(u),h.applyStickyOperations(u),!1;if(u.type==="number"&&u.validity&&u.validity.badInput)return!1;if(!h.syncPendingRef(u,E,c))return h.isUploadInput(u)&&(this.trackBefore("updated",u,E),p.push(u)),h.applyStickyOperations(u),!1;if(h.isPhxChild(E)){let k=u.getAttribute(H);return h.mergeAttrs(u,E,{exclude:[Y]}),k!==""&&u.setAttribute(H,k),u.setAttribute(W,this.rootID),h.applyStickyOperations(u),!1}return h.copyPrivates(E,u),h.discardError(n,E,f),o&&u.isSameNode(o)&&h.isFormInput(u)&&u.type!=="hidden"?(this.trackBefore("updated",u,E),h.mergeFocusedInput(u,E),h.syncAttrsToProps(u),p.push(u),h.applyStickyOperations(u),!1):(h.isPhxUpdate(E,d,["append","prepend"])&&_.push(new qe(u,E,E.getAttribute(d))),h.syncAttrsToProps(E),h.applyStickyOperations(E),this.trackBefore("updated",u,E),!0)}})}),t.isDebugEnabled()&&Vt(),_.length>0&&t.time("post-morph append/prepend restoration",()=>{_.forEach(u=>u.perform())}),t.silenceEvents(()=>h.restoreFocus(o,a,l)),h.dispatchEvent(document,"phx:update"),g.forEach(u=>this.trackAfter("added",u)),p.forEach(u=>this.trackAfter("updated",u)),this.transitionPendingRemoves(),x&&(t.unload(),x.submit()),!0}onNodeDiscarded(e){(h.isPhxChild(e)||h.isPhxSticky(e))&&this.liveSocket.destroyViewByEl(e),this.trackAfter("discarded",e)}maybePendingRemove(e){return e.getAttribute&&e.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(e),!0):!1}maybeReOrderStream(e){let t=e.id?this.streamInserts[e.id]:void 0;if(t!==void 0){if(h.putPrivate(e,fe,!0),t===0)e.parentElement.insertBefore(e,e.parentElement.firstElementChild);else if(t>0){let i=Array.from(e.parentElement.children),s=i.indexOf(e);if(t>=i.length-1)e.parentElement.appendChild(e);else{let n=i[t];s>t?e.parentElement.insertBefore(e,n):e.parentElement.insertBefore(e,n.nextElementSibling)}}}}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:t}=this;e.length>0&&(t.transitionRemoves(e),t.requestDOMUpdate(()=>{e.forEach(i=>{let s=h.firstPhxChild(i);s&&t.destroyViewByEl(s),i.remove()}),this.trackAfter("transitionsDiscarded",e)}))}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.getAttribute(_e)!==null}targetCIDContainer(e){if(!this.isCIDPatch())return;let[t,...i]=h.findComponentNodeList(this.container,this.targetCID);return i.length===0&&h.childNodeLength(e)===1?t:t&&t.parentNode}buildDiffHTML(e,t,i,s){let n=this.isCIDPatch(),o=n&&s.getAttribute(C)===this.targetCID.toString();if(!n||o)return t;{let a=null,l=document.createElement("template");a=h.cloneNode(s);let[d,...f]=h.findComponentNodeList(a,this.targetCID);return l.innerHTML=t,f.forEach(c=>c.remove()),Array.from(a.childNodes).forEach(c=>{c.id&&c.nodeType===Node.ELEMENT_NODE&&c.getAttribute(C)!==this.targetCID.toString()&&(c.setAttribute(_e,""),c.innerHTML="")}),Array.from(l.content.childNodes).forEach(c=>a.insertBefore(c,d)),d.remove(),a.outerHTML}}indexOf(e,t){return Array.from(e.children).indexOf(t)}};var ke=class{static extract(e){let{[ft]:t,[ct]:i,[pt]:s}=e;return delete e[ft],delete e[ct],delete e[pt],{diff:e,title:s,reply:t||null,events:i||[]}}constructor(e,t){this.viewId=e,this.rendered={},this.mergeDiff(t)}parentViewId(){return this.viewId}toString(e){let[t,i]=this.recursiveToString(this.rendered,this.rendered[I],e);return[t,i]}recursiveToString(e,t=e[I],i){i=i?new Set(i):null;let s={buffer:"",components:t,onlyCids:i,streams:new Set};return this.toOutputBuffer(e,null,s),[s.buffer,s.streams]}componentCIDs(e){return Object.keys(e[I]||{}).map(t=>parseInt(t))}isComponentOnlyDiff(e){return e[I]?Object.keys(e).length===1:!1}getComponent(e,t){return e[I][t]}mergeDiff(e){let t=e[I],i={};if(delete e[I],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[I]=this.rendered[I]||{},t){let s=this.rendered[I];for(let n in t)t[n]=this.cachedFindComponent(n,t[n],s,t,i);for(let n in t)s[n]=t[n];e[I]=t}}cachedFindComponent(e,t,i,s,n){if(n[e])return n[e];{let o,a,l=t[X];if($(l)){let d;l>0?d=this.cachedFindComponent(l,s[l],i,s,n):d=i[-l],a=d[X],o=this.cloneMerge(d,t),o[X]=a}else o=t[X]!==void 0?t:this.cloneMerge(i[e]||{},t);return n[e]=o,o}}mutableMerge(e,t){return t[X]!==void 0?t:(this.doMutableMerge(e,t),e)}doMutableMerge(e,t){for(let i in t){let s=t[i],n=e[i];ge(s)&&s[X]===void 0&&ge(n)?this.doMutableMerge(n,s):e[i]=s}}cloneMerge(e,t){let i=oe(oe({},e),t);for(let s in i){let n=t[s],o=e[s];ge(n)&&n[X]===void 0&&ge(o)&&(i[s]=this.cloneMerge(o,n))}return i}componentToString(e){let[t,i]=this.recursiveCIDToString(this.rendered[I],e);return[t,i]}pruneCIDs(e){e.forEach(t=>delete this.rendered[I][t])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[X]}templateStatic(e,t){return typeof e=="number"?t[e]:e}toOutputBuffer(e,t,i){if(e[Ce])return this.comprehensionToBuffer(e,t,i);let{[X]:s}=e;s=this.templateStatic(s,t),i.buffer+=s[0];for(let n=1;n<s.length;n++)this.dynamicToBuffer(e[n-1],t,i),i.buffer+=s[n]}comprehensionToBuffer(e,t,i){let{[Ce]:s,[X]:n,[Bt]:o}=e,[a,l]=o||[{},[]];n=this.templateStatic(n,t);let d=t||e[$t];for(let f=0;f<s.length;f++){let c=s[f];i.buffer+=n[0];for(let m=1;m<n.length;m++)this.dynamicToBuffer(c[m-1],d,i),i.buffer+=n[m]}o!==void 0&&(e[Ce].length>0||l.length>0)&&(e[Ce]=[],i.streams.add(o))}dynamicToBuffer(e,t,i){if(typeof e=="number"){let[s,n]=this.recursiveCIDToString(i.components,e,i.onlyCids);i.buffer+=s,i.streams=new Set([...i.streams,...n])}else ge(e)?this.toOutputBuffer(e,t,i):i.buffer+=e}recursiveCIDToString(e,t,i){let s=e[t]||P(`no component for CID ${t}`,e),n=document.createElement("template"),[o,a]=this.recursiveToString(s,e,i);n.innerHTML=o;let l=n.content,d=i&&!i.has(t),[f,c]=Array.from(l.childNodes).reduce(([m,g],p,_)=>p.nodeType===Node.ELEMENT_NODE?p.getAttribute(C)?[m,!0]:(p.setAttribute(C,t),p.id||(p.id=`${this.parentViewId()}-${t}-${_}`),d&&(p.setAttribute(_e,""),p.innerHTML=""),[!0,g]):p.nodeValue.trim()!==""?(P(`only HTML element tags are allowed at the root of components.
|
|
6
8
|
|
|
7
9
|
got: "${p.nodeValue.trim()}"
|
|
8
10
|
|
|
9
11
|
within:
|
|
10
12
|
`,n.innerHTML.trim()),p.replaceWith(this.createSpan(p.nodeValue,t)),[!0,g]):(p.remove(),[m,g]),[!1,!1]);return!f&&!c?(P(`expected at least one HTML element tag inside a component, but the component is empty:
|
|
11
|
-
`,n.innerHTML.trim()),[this.createSpan("",t).outerHTML,a]):!f&&c?(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,a]):[n.innerHTML,a]}createSpan(e,t){let i=document.createElement("span");return i.innerText=e,i.setAttribute(C,t),i}};var wi=1,ee=class{static makeID(){return wi++}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 Ke=null,Pi={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:m}=n,g={loading:f,value:c,target:l,page_loading:!!d},p=r==="change"&&m?m:i,_=l||p.getAttribute(t.binding("target"))||p;t.withinTargets(_,(x,D)=>{if(r==="change"){let{newCid:u,_target:E,callback:L}=n;E=E||(h.isFormInput(i)?i.name:void 0),E&&(g._target=E),x.pushInput(i,D,u,o||e,g,L)}else r==="submit"?x.submitForm(i,D,o||e,g):x.pushEvent(r,i,D,o||e,a,g)})},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(()=>Ke=s||i)},exec_pop_focus(r,e,t,i,s){window.requestAnimationFrame(()=>{Ke&&Ke.focus(),Ke=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,m]=n||[[],[],[]];if(a.length>0||f.length>0)if(this.isVisible(t)){let g=()=>{this.addOrRemoveClasses(t,c,a.concat(l).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,f,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,m,c))})};t.dispatchEvent(new Event("phx:hide-start")),e.transition(o,g,()=>{this.addOrRemoveClasses(t,[],f.concat(m)),h.putSticky(t,"toggle",p=>p.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))})}else{if(r==="remove")return;let g=()=>{this.addOrRemoveClasses(t,l,f.concat(c).concat(m)),h.putSticky(t,"toggle",p=>p.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,g,()=>{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",g=>g.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start")),h.putSticky(t,"toggle",g=>g.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(_=>d.indexOf(_)<0&&!r.classList.contains(_)),m=t.filter(_=>f.indexOf(_)<0&&r.classList.contains(_)),g=d.filter(_=>t.indexOf(_)<0).concat(c),p=f.filter(_=>e.indexOf(_)<0).concat(m);h.putSticky(r,"classes",_=>(_.classList.remove(...p),_.classList.add(...g),[g,p]))})},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]}},F=Pi;var Ge=(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()},ge=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.hasAttribute(le)}connectParams(e){let t=this.liveSocket.params(this.el),i=h.all(document,`[${this.binding(Ct)}]`).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(H)}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(nt,Fe,at),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(Fe)}}execAll(e){h.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(nt),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,()=>["",fe(t)]);let{diff:s,reply:n,events:o,title:a}=Te.extract(t);i({diff:s,reply:n,events:o}),a&&window.requestAnimationFrame(()=>h.putTitle(a))}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,N.dropLocal(this.liveSocket.localStorage,window.location.pathname,De),this.applyDiff("mount",t,({diff:s,events:n})=>{this.rendered=new Te(this.id,s);let[o,a]=this.renderContainer(null,"join");this.dropPendingRefs();let l=this.formsForRecovery(o);this.joinCount++,l.length>0?l.forEach(([d,f,c],m)=>{this.pushFormRecovery(d,c,g=>{m===l.length-1&&this.onJoinComplete(g,o,a,n)})}):this.onJoinComplete(e,o,a,n)})}dropPendingRefs(){h.all(document,`[${j}="${this.id}"][${O}]`,e=>{e.removeAttribute(O),e.removeAttribute(j)})}onJoinComplete({live_patch:e},t,i,s){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i,s);h.findPhxChildrenInFragment(t,this.id).filter(o=>{let a=o.id&&this.el.querySelector(`[id="${o.id}"]`),l=a&&a.getAttribute(Y);return l&&o.setAttribute(Y,l),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,s)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i,s)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,s)])}attachTrueDocEl(){this.el=h.byId(this.id),this.el.setAttribute(q,this.root.id)}execNewMounted(){h.all(this.el,`[${this.binding(he)}], [data-phx-${he}]`,e=>{this.maybeAddNewHook(e)}),h.all(this.el,`[${this.binding(dt)}]`,e=>this.maybeMounted(e))}applyJoinPatch(e,t,i,s){this.attachTrueDocEl();let n=new ie(this,this.el,this.id,t,i,null);if(n.markPrunableContentForRemoval(),this.performPatch(n,!1),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(s),this.applyPendingUpdates(),e){let{kind:o,to:a}=e;this.liveSocket.historyPatch(a,o)}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(de));if(i&&!e.isEqualNode(t)&&!(s&&jt(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(dt)),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,`[${C}]`),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 ge(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)})}):mt(e)||this.liveSocket.time("full patch complete",()=>{let[s,n]=this.renderContainer(e,"update"),o=new ie(this,this.el,this.id,s,n,null);i=this.performPatch(o,!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,o]=this.rendered.toString(s);return[`<${i}>${n}</${i}>`,o]})}componentPatch(e,t){if(mt(e))return!1;let[i,s]=this.rendered.componentToString(t),n=new ie(this,this.el,this.id,i,s,t);return this.performPatch(n,!0)}getHook(e){return this.viewHooks[ee.elementID(e)]}addHook(e){if(ee.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 ee(this,e,i);return this.viewHooks[ee.elementID(s.el)]=s,s}else t!==null&&P(`unknown hook found for "${t}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[ee.elementID(e.el)]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[],this.eachChild(e=>e.applyPendingUpdates())}eachChild(e){let t=this.root.children[this.id]||{};for(let i in t)e(this.getChildById(i))}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(){this.eachChild(e=>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(Ft)}}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(Fe,at),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(st))!==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,Ut).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:m,events:g})=>{this.update(c,g),f(m)})}):f(null)}))}undoRefs(e){!this.isConnected()||h.all(document,`[${j}="${this.id}"][${O}="${e}"]`,t=>{let i=t.getAttribute(Se);t.removeAttribute(O),t.removeAttribute(j),t.getAttribute(Xe)!==null&&(t.readOnly=!1,t.removeAttribute(Xe)),i!==null&&(t.disabled=i==="true",t.removeAttribute(Se)),Oe.forEach(o=>h.removeClass(t,o));let s=t.getAttribute(ye);s!==null&&(t.innerText=s,t.removeAttribute(ye));let n=h.private(t,O);if(n){let o=this.triggerBeforeUpdateHook(t,n);ie.patchEl(t,n,this.liveSocket.getActiveElement()),o&&o.__updated(),h.deletePrivate(t,O)}})}putRef(e,t,i={}){let s=this.ref++,n=this.binding(Ae);return i.loading&&(e=e.concat(h.all(document,i.loading))),e.forEach(o=>{o.classList.add(`phx-${t}-loading`),o.setAttribute(O,s),o.setAttribute(j,this.el.id);let a=o.getAttribute(n);a!==null&&(o.getAttribute(ye)||o.setAttribute(ye,o.innerText),a!==""&&(o.innerText=a),o.setAttribute("disabled",""))}),[s,e,i]}componentID(e){let t=e.getAttribute&&e.getAttribute(C);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?B(e.closest(`[${C}]`),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"&&Ue.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(Ht)),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=Ge(e.form,{_target:n._target},[e.name]):f=Ge(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,m=>{if(h.showError(e,this.liveSocket.binding(Ee)),h.isUploadInput(e)&&e.getAttribute("data-phx-auto-upload")!==null){if(y.filesAwaitingPreflight(e).length>0){let[g,p]=d();this.uploadFiles(e.form,t,g,l,_=>{o&&o(m),this.triggerAwaitingSubmit(e.form)})}}else o&&o(m)})}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(de)}=ignore`,c.form)||te(c,"data-phx-update=ignore",c.form)),s=c=>c.hasAttribute(this.binding(Ae)),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(Se,c.disabled),c.disabled=!0}),f.forEach(c=>{c.setAttribute(Xe,c.readOnly),c.readOnly=!0,c.files&&(c.setAttribute(Se,c.disabled),c.disabled=!0)}),e.setAttribute(this.binding(st),""),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 m=Ge(e,{});this.pushWithReply(f,"event",{type:"form",event:i,value:m,cid:a},n)})}else{let l=Ge(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(g=>g.toPreflightPayload()),m={ref:d.getAttribute(M),entries:c,cid:this.targetComponentID(d.form,t)};this.log("upload",()=>["sending preflight request",m]),this.pushWithReply(null,"allow_upload",m,g=>{if(this.log("upload",()=>["got preflight response",g]),g.error){this.undoRefs(i);let[p,_]=g.error;this.log("upload",()=>[`error for entry ${p}`,_])}else{let p=_=>{this.channel.onError(()=>{this.joinCount===o&&_()})};f.initAdapterUpload(g,p,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],Ne,{detail:{files:t}})}pushFormRecovery(e,t,i){this.liveSocket.withinOwners(e,(s,n)=>{let o=Array.from(e.elements).find(l=>h.isFormInput(l)&&l.type!=="hidden"&&!l.hasAttribute(this.binding("change"))),a=e.getAttribute(this.binding(ht))||e.getAttribute(this.binding("change"));F.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(ht))!=="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){let t=e.closest(J);return e.getAttribute(W)===this.id||t&&t.id===this.id||!t&&this.isDead}submitForm(e,t,i,s={}){h.putPrivate(e,_e,!0);let n=this.liveSocket.binding(Ee),o=Array.from(e.elements);o.forEach(a=>h.putPrivate(a,_e,!0)),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 ze=class{constructor(e,t,i={}){if(this.unloaded=!1,!t||t.constructor.name==="Object")throw new Error(`
|
|
13
|
+
`,n.innerHTML.trim()),[this.createSpan("",t).outerHTML,a]):!f&&c?(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,a]):[n.innerHTML,a]}createSpan(e,t){let i=document.createElement("span");return i.innerText=e,i.setAttribute(C,t),i}};var wi=1,ee=class{static makeID(){return wi++}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 Ge=null,Pi={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:m}=n,g={loading:f,value:c,target:l,page_loading:!!d},p=r==="change"&&m?m:i,_=l||p.getAttribute(t.binding("target"))||p;t.withinTargets(_,(x,L)=>{if(r==="change"){let{newCid:u,_target:E,callback:D}=n;E=E||(h.isFormInput(i)?i.name:void 0),E&&(g._target=E),x.pushInput(i,L,u,o||e,g,D)}else r==="submit"?x.submitForm(i,L,o||e,g):x.pushEvent(r,i,L,o||e,a,g)})},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(()=>Ge=s||i)},exec_pop_focus(r,e,t,i,s){window.requestAnimationFrame(()=>{Ge&&Ge.focus(),Ge=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}){this.addOrRemoveClasses(s,[],[],o,n,t)},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,m]=n||[[],[],[]];if(a.length>0||f.length>0)if(this.isVisible(t)){let g=()=>{this.addOrRemoveClasses(t,c,a.concat(l).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,f,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,m,c))})};t.dispatchEvent(new Event("phx:hide-start")),e.transition(o,g,()=>{this.addOrRemoveClasses(t,[],f.concat(m)),h.putSticky(t,"toggle",p=>p.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))})}else{if(r==="remove")return;let g=()=>{this.addOrRemoveClasses(t,l,f.concat(c).concat(m));let p=i||this.defaultDisplay(t);h.putSticky(t,"toggle",_=>_.style.display=p),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,d,l))})};t.dispatchEvent(new Event("phx:show-start")),e.transition(o,g,()=>{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",g=>g.style.display="none"),t.dispatchEvent(new Event("phx:hide-end"))}):window.requestAnimationFrame(()=>{t.dispatchEvent(new Event("phx:show-start"));let g=i||this.defaultDisplay(t);h.putSticky(t,"toggle",p=>p.style.display=g),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(_=>d.indexOf(_)<0&&!r.classList.contains(_)),m=t.filter(_=>f.indexOf(_)<0&&r.classList.contains(_)),g=d.filter(_=>t.indexOf(_)<0).concat(c),p=f.filter(_=>e.indexOf(_)<0).concat(m);h.putSticky(r,"classes",_=>(_.classList.remove(...p),_.classList.add(...g),[g,p]))})},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]},defaultDisplay(r){return{tr:"table-row",td:"table-cell"}[r.tagName.toLowerCase()]||"block"}},F=Pi;var ze=(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()},be=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.hasAttribute(he)}connectParams(e){let t=this.liveSocket.params(this.el),i=h.all(document,`[${this.binding(Ct)}]`).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(H)}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(ot,Me,at),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(Me)}}execAll(e){h.all(this.el,`[${e}]`,t=>this.liveSocket.execJS(t,t.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(ot),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,()=>["",me(t)]);let{diff:s,reply:n,events:o,title:a}=ke.extract(t);i({diff:s,reply:n,events:o}),a&&window.requestAnimationFrame(()=>h.putTitle(a))}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,N.dropLocal(this.liveSocket.localStorage,window.location.pathname,Oe),this.applyDiff("mount",t,({diff:s,events:n})=>{this.rendered=new ke(this.id,s);let[o,a]=this.renderContainer(null,"join");this.dropPendingRefs();let l=this.formsForRecovery(o);this.joinCount++,l.length>0?l.forEach(([d,f,c],m)=>{this.pushFormRecovery(d,c,g=>{m===l.length-1&&this.onJoinComplete(g,o,a,n)})}):this.onJoinComplete(e,o,a,n)})}dropPendingRefs(){h.all(document,`[${j}="${this.id}"][${O}]`,e=>{e.removeAttribute(O),e.removeAttribute(j)})}onJoinComplete({live_patch:e},t,i,s){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,t,i,s);h.findPhxChildrenInFragment(t,this.id).filter(o=>{let a=o.id&&this.el.querySelector(`[id="${o.id}"]`),l=a&&a.getAttribute(Y);return l&&o.setAttribute(Y,l),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,s)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,t,i,s)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,t,i,s)])}attachTrueDocEl(){this.el=h.byId(this.id),this.el.setAttribute(W,this.root.id)}execNewMounted(){h.all(this.el,`[${this.binding(ue)}], [data-phx-${ue}]`,e=>{this.maybeAddNewHook(e)}),h.all(this.el,`[${this.binding(dt)}]`,e=>this.maybeMounted(e))}applyJoinPatch(e,t,i,s){this.attachTrueDocEl();let n=new re(this,this.el,this.id,t,i,null);if(n.markPrunableContentForRemoval(),this.performPatch(n,!1),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(s),this.applyPendingUpdates(),e){let{kind:o,to:a}=e;this.liveSocket.historyPatch(a,o)}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(ce));if(i&&!e.isEqualNode(t)&&!(s&&jt(e.dataset,t.dataset)))return i.__beforeUpdate(),i}maybeMounted(e){let t=e.getAttribute(this.binding(dt)),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,`[${C}]`),o=h.all(s,`[${this.binding(ue)}]`);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(q)][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 be(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)})}):mt(e)||this.liveSocket.time("full patch complete",()=>{let[s,n]=this.renderContainer(e,"update"),o=new re(this,this.el,this.id,s,n,null);i=this.performPatch(o,!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,o]=this.rendered.toString(s);return[`<${i}>${n}</${i}>`,o]})}componentPatch(e,t){if(mt(e))return!1;let[i,s]=this.rendered.componentToString(t),n=new re(this,this.el,this.id,i,s,t);return this.performPatch(n,!0)}getHook(e){return this.viewHooks[ee.elementID(e)]}addHook(e){if(ee.elementID(e)||!e.getAttribute)return;let t=e.getAttribute(`data-phx-${ue}`)||e.getAttribute(this.binding(ue));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 ee(this,e,i);return this.viewHooks[ee.elementID(s.el)]=s,s}else t!==null&&P(`unknown hook found for "${t}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[ee.elementID(e.el)]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:e,events:t})=>this.update(e,t)),this.pendingDiffs=[],this.eachChild(e=>e.applyPendingUpdates())}eachChild(e){let t=this.root.children[this.id]||{};for(let i in t)e(this.getChildById(i))}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(){this.eachChild(e=>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(Ft)}}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(Me,at),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(nt))!==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,Ut).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:m,events:g})=>{this.update(c,g),f(m)})}):f(null)}))}undoRefs(e){!this.isConnected()||h.all(document,`[${j}="${this.id}"][${O}="${e}"]`,t=>{let i=t.getAttribute(Se);t.removeAttribute(O),t.removeAttribute(j),t.getAttribute($e)!==null&&(t.readOnly=!1,t.removeAttribute($e)),i!==null&&(t.disabled=i==="true",t.removeAttribute(Se)),He.forEach(o=>h.removeClass(t,o));let s=t.getAttribute(we);s!==null&&(t.innerText=s,t.removeAttribute(we));let n=h.private(t,O);if(n){let o=this.triggerBeforeUpdateHook(t,n);re.patchEl(t,n,this.liveSocket.getActiveElement()),o&&o.__updated(),h.deletePrivate(t,O)}})}putRef(e,t,i={}){let s=this.ref++,n=this.binding(ye);return i.loading&&(e=e.concat(h.all(document,i.loading))),e.forEach(o=>{o.classList.add(`phx-${t}-loading`),o.setAttribute(O,s),o.setAttribute(j,this.el.id);let a=o.getAttribute(n);a!==null&&(o.getAttribute(we)||o.setAttribute(we,o.innerText),a!==""&&(o.innerText=a),o.setAttribute("disabled",""))}),[s,e,i]}componentID(e){let t=e.getAttribute&&e.getAttribute(C);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?B(e.closest(`[${C}]`),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"&&Xe.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(Ht)),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=ze(e.form,{_target:n._target},[e.name]):f=ze(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,m=>{if(h.showError(e,this.liveSocket.binding(te)),h.isUploadInput(e)&&e.getAttribute("data-phx-auto-upload")!==null){if(y.filesAwaitingPreflight(e).length>0){let[g,p]=d();this.uploadFiles(e.form,t,g,l,_=>{o&&o(m),this.triggerAwaitingSubmit(e.form)})}}else o&&o(m)})}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=>!(ie(c,`${this.binding(ce)}=ignore`,c.form)||ie(c,"data-phx-update=ignore",c.form)),s=c=>c.hasAttribute(this.binding(ye)),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(Se,c.disabled),c.disabled=!0}),f.forEach(c=>{c.setAttribute($e,c.readOnly),c.readOnly=!0,c.files&&(c.setAttribute(Se,c.disabled),c.disabled=!0)}),e.setAttribute(this.binding(nt),""),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 m=ze(e,{});this.pushWithReply(f,"event",{type:"form",event:i,value:m,cid:a},n)})}else{let l=ze(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(g=>g.toPreflightPayload()),m={ref:d.getAttribute(M),entries:c,cid:this.targetComponentID(d.form,t)};this.log("upload",()=>["sending preflight request",m]),this.pushWithReply(null,"allow_upload",m,g=>{if(this.log("upload",()=>["got preflight response",g]),g.error){this.undoRefs(i);let[p,_]=g.error;this.log("upload",()=>[`error for entry ${p}`,_])}else{let p=_=>{this.channel.onError(()=>{this.joinCount===o&&_()})};f.initAdapterUpload(g,p,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],Fe,{detail:{files:t}})}pushFormRecovery(e,t,i){this.liveSocket.withinOwners(e,(s,n)=>{let o=Array.from(e.elements).find(l=>h.isFormInput(l)&&l.type!=="hidden"&&!l.hasAttribute(this.binding("change"))),a=e.getAttribute(this.binding(ht))||e.getAttribute(this.binding("change"));F.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(ht))!=="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){let t=e.closest(J);return e.getAttribute(q)===this.id||t&&t.id===this.id||!t&&this.isDead}submitForm(e,t,i,s={}){h.putPrivate(e,de,!0);let n=this.liveSocket.binding(te),o=Array.from(e.elements);o.forEach(a=>h.putPrivate(a,de,!0)),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 Ye=class{constructor(e,t,i={}){if(this.unloaded=!1,!t||t.constructor.name==="Object")throw new Error(`
|
|
12
14
|
a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example:
|
|
13
15
|
|
|
14
16
|
import {Socket} from "phoenix"
|
|
15
17
|
import {LiveSocket} from "phoenix_live_view"
|
|
16
18
|
let liveSocket = new LiveSocket("/live", Socket, {...})
|
|
17
|
-
`);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||Mt,this.opts=i,this.params=Je(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(fe(Xt),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=fe(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||Nt,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||yt,this.reloadJitterMin=i.reloadJitterMin||wt,this.reloadJitterMax=i.reloadJitterMax||Pt,this.failsafeJitter=i.failsafeJitter||xt,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:Je(),onBeforeElUpdated:Je()},i.dom||{}),this.transitions=new ei,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}isProfileEnabled(){return this.sessionStorage.getItem($e)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(we)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(we)==="false"}enableDebug(){this.sessionStorage.setItem(we,"true")}enableProfiling(){this.sessionStorage.setItem($e,"true")}disableDebug(){this.sessionStorage.setItem(we,"false")}disableProfiling(){this.sessionStorage.removeItem($e)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(Be,e)}disableLatencySim(){this.sessionStorage.removeItem(Be)}getLatencySim(){let e=this.sessionStorage.getItem(Be);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.bindTopLevelEvents({dead:!0}),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=>F.exec(i,t,s,e))}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}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();Jt(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=N.updateLocal(this.localStorage,window.location.pathname,De,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.")?Kt[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(){let e=document.body;if(e&&!this.isPhxView(e)&&!this.isPhxView(document.firstElementChild)){let t=this.newRootView(e);t.setHref(this.getHref()),t.joinDead(),this.main||(this.main=t),window.requestAnimationFrame(()=>t.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.hasAttribute(le)&&(this.main=i)}e=!0}),e}redirect(e,t){this.unload(),N.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(H)!==null}newRootView(e,t,i){let s=new ge(e,this,null,t,i);return this.roots[s.id]=s,s}owner(e,t){let i=B(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(q);return B(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(q));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=>{if(t&&t.code===1001)return this.unload();if(t&&t.code===1e3&&this.main)return 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(Ot)),d=t.key&&t.key.toLowerCase();if(l&&l.toLowerCase()!==d)return;let f=ne({key:t.key},this.eventMeta(i,t,n));F.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));F.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);F.exec(i,a,s,n,["push",{data:d}])}}),window.addEventListener("dragover",t=>t.preventDefault()),window.addEventListener("drop",t=>{t.preventDefault();let i=B(te(t.target,this.binding(it)),o=>o.getAttribute(this.binding(it))),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,t.dataTransfer),s.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(Ne,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);if(!a){let l=n.target instanceof HTMLAnchorElement?n.target.getAttribute("href"):null;!i&&l!==null&&!h.wantsNewTab(n)&&h.isNewPageHref(l,window.location)&&this.unload();return}o.getAttribute("href")==="#"&&n.preventDefault(),this.debounce(o,n,"click",()=>{this.withinOwners(o,l=>{F.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);F.isVisible(s)&&F.exec("click",o,n,s,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!N.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{clearTimeout(e),e=setTimeout(()=>{N.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.maybeScroll(o)}):this.replaceMain(a,null,()=>{n&&this.replaceRootHistory(),this.maybeScroll(o)})})},!1),window.addEventListener("click",t=>{let i=te(t.target,He),s=i&&i.getAttribute(He);if(!s||!this.isConnected()||!this.main||h.wantsNewTab(t))return;let n=i.href,o=i.getAttribute(Tt);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==n&&this.requestDOMUpdate(()=>{if(s==="patch")this.pushHistoryPatch(n,o,i);else if(s==="redirect")this.historyRedirect(n,o);else throw new Error(`expected ${He} to be "patch" or "redirect", got: ${s}`);let a=i.getAttribute(this.binding("click"));a&&this.requestDOMUpdate(()=>this.execJS(i,a,"click"))})},!1)}maybeScroll(e){typeof e=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,e)})}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 N.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)||(N.pushState(t,{type:"patch",id:this.main.id},e),this.registerNewLocation(window.location))}historyRedirect(e,t,i){if(!this.isConnected())return N.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,()=>{N.pushState(t,{type:"redirect",id:this.main.id,scroll:s},e),this.registerNewLocation(window.location),n()})})}replaceRootHistory(){N.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=fe(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(()=>{h.isUnloadableFormSubmit(i)&&this.unload(),i.target.submit()})}))},!0),this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit"));if(!s){h.isUnloadableFormSubmit(i)&&this.unload();return}i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,n=>{F.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:m,type:g}=h.private(o,"prev-iteration")||{};m===c-1&&i!==g||(h.putPrivate(o,"prev-iteration",{at:c,type:i}),this.debounce(o,s,i,()=>{this.withinOwners(f,p=>{h.putPrivate(o,Me,!0),h.isTextualInput(o)||this.setActiveElement(o),F.exec("change",d,p,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(Lt),o=this.binding(Dt),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)})}},ei=class{constructor(){this.transitions=new Set,this.pendingOps=[]}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.flushPendingOps()},e);this.transitions.add(s)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){if(this.size()>0)return;let e=this.pendingOps.shift();e&&(e(),this.flushPendingOps())}};return xi;})();
|
|
19
|
+
`);this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||Mt,this.opts=i,this.params=je(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(me(Xt),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=me(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||Nt,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||yt,this.reloadJitterMin=i.reloadJitterMin||wt,this.reloadJitterMax=i.reloadJitterMax||Pt,this.failsafeJitter=i.failsafeJitter||xt,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:je(),onBeforeElUpdated:je()},i.dom||{}),this.transitions=new ei,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}isProfileEnabled(){return this.sessionStorage.getItem(Be)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(Pe)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(Pe)==="false"}enableDebug(){this.sessionStorage.setItem(Pe,"true")}enableProfiling(){this.sessionStorage.setItem(Be,"true")}disableDebug(){this.sessionStorage.setItem(Pe,"false")}disableProfiling(){this.sessionStorage.removeItem(Be)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(Ve,e)}disableLatencySim(){this.sessionStorage.removeItem(Ve)}getLatencySim(){let e=this.sessionStorage.getItem(Ve);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.bindTopLevelEvents({dead:!0}),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=>F.exec(i,t,s,e))}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}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();Jt(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=N.updateLocal(this.localStorage,window.location.pathname,Oe,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.")?Kt[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(){let e=document.body;if(e&&!this.isPhxView(e)&&!this.isPhxView(document.firstElementChild)){let t=this.newRootView(e);t.setHref(this.getHref()),t.joinDead(),this.main||(this.main=t),window.requestAnimationFrame(()=>t.execNewMounted())}}joinRootViews(){let e=!1;return h.all(document,`${J}:not([${q}])`,t=>{if(!this.getRootById(t.id)){let i=this.newRootView(t);i.setHref(this.getHref()),i.join(),t.hasAttribute(he)&&(this.main=i)}e=!0}),e}redirect(e,t){this.unload(),N.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(H)!==null}newRootView(e,t,i){let s=new be(e,this,null,t,i);return this.roots[s.id]=s,s}owner(e,t){let i=B(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(W);return B(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(W));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=>{if(t&&t.code===1001)return this.unload();if(t&&t.code===1e3&&this.main)return 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(Ot)),d=t.key&&t.key.toLowerCase();if(l&&l.toLowerCase()!==d)return;let f=oe({key:t.key},this.eventMeta(i,t,n));F.exec(i,o,s,n,["push",{data:f}])}),this.bind({blur:"focusout",focus:"focusin"},(t,i,s,n,o,a)=>{if(!a){let l=oe({key:t.key},this.eventMeta(i,t,n));F.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);F.exec(i,a,s,n,["push",{data:d}])}}),window.addEventListener("dragover",t=>t.preventDefault()),window.addEventListener("drop",t=>{t.preventDefault();let i=B(ie(t.target,this.binding(rt)),o=>o.getAttribute(this.binding(rt))),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,t.dataTransfer),s.dispatchEvent(new Event("input",{bubbles:!0})))}),this.on(Fe,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=ie(l,s),this.dispatchClickAway(n,l),this.clickStartedAtTarget=null}let a=o&&o.getAttribute(s);if(!a){let l=n.target instanceof HTMLAnchorElement?n.target.getAttribute("href"):null;!i&&l!==null&&!h.wantsNewTab(n)&&h.isNewPageHref(l,window.location)&&this.unload();return}o.getAttribute("href")==="#"&&n.preventDefault(),this.debounce(o,n,"click",()=>{this.withinOwners(o,l=>{F.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);F.isVisible(s)&&F.exec("click",o,n,s,["push",{data:this.eventMeta("click",e,e.target)}])})})}bindNav(){if(!N.canPushState())return;history.scrollRestoration&&(history.scrollRestoration="manual");let e=null;window.addEventListener("scroll",t=>{clearTimeout(e),e=setTimeout(()=>{N.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.maybeScroll(o)}):this.replaceMain(a,null,()=>{n&&this.replaceRootHistory(),this.maybeScroll(o)})})},!1),window.addEventListener("click",t=>{let i=ie(t.target,Ne),s=i&&i.getAttribute(Ne);if(!s||!this.isConnected()||!this.main||h.wantsNewTab(t))return;let n=i.href,o=i.getAttribute(Tt);t.preventDefault(),t.stopImmediatePropagation(),this.pendingLink!==n&&this.requestDOMUpdate(()=>{if(s==="patch")this.pushHistoryPatch(n,o,i);else if(s==="redirect")this.historyRedirect(n,o);else throw new Error(`expected ${Ne} to be "patch" or "redirect", got: ${s}`);let a=i.getAttribute(this.binding("click"));a&&this.requestDOMUpdate(()=>this.execJS(i,a,"click"))})},!1)}maybeScroll(e){typeof e=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,e)})}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 N.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)||(N.pushState(t,{type:"patch",id:this.main.id},e),this.registerNewLocation(window.location))}historyRedirect(e,t,i){if(!this.isConnected())return N.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,()=>{N.pushState(t,{type:"redirect",id:this.main.id,scroll:s},e),this.registerNewLocation(window.location),n()})})}replaceRootHistory(){N.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=me(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(()=>{h.isUnloadableFormSubmit(i)&&this.unload(),i.target.submit()})}))},!0),this.on("submit",i=>{let s=i.target.getAttribute(this.binding("submit"));if(!s){h.isUnloadableFormSubmit(i)&&this.unload();return}i.preventDefault(),i.target.disabled=!0,this.withinOwners(i.target,n=>{F.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:m,type:g}=h.private(o,"prev-iteration")||{};m===c-1&&i!==g||(h.putPrivate(o,"prev-iteration",{at:c,type:i}),this.debounce(o,s,i,()=>{this.withinOwners(f,p=>{h.putPrivate(o,Ae,!0),h.isTextualInput(o)||this.setActiveElement(o),F.exec("change",d,p,o,["push",{_target:s.target.name,dispatcher:f}])})}))},!1);this.on("reset",i=>{let s=i.target;h.resetForm(s,this.binding(te));let n=Array.from(s.elements).find(o=>o.type==="reset");window.requestAnimationFrame(()=>{n.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(e,t,i,s){if(i==="blur"||i==="focusout")return s();let n=this.binding(Dt),o=this.binding(Lt),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)})}},ei=class{constructor(){this.transitions=new Set,this.pendingOps=[]}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.flushPendingOps()},e);this.transitions.add(s)}pushPendingOp(e){this.pendingOps.push(e)}size(){return this.transitions.size}flushPendingOps(){if(this.size()>0)return;let e=this.pendingOps.shift();e&&(e(),this.flushPendingOps())}};return xi;})();
|