(()=>{var vo=Object.defineProperty,bo=Object.defineProperties;var yo=Object.getOwnPropertyDescriptors;var Kt=Object.getOwnPropertySymbols;var ar=Object.prototype.hasOwnProperty,lr=Object.prototype.propertyIsEnumerable;var is=(t,e,i)=>e in t?vo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,H=(t,e)=>{for(var i in e||(e={}))ar.call(e,i)&&is(t,i,e[i]);if(Kt)for(var i of Kt(e))lr.call(e,i)&&is(t,i,e[i]);return t},Ce=(t,e)=>bo(t,yo(e));var hr=(t,e)=>{var i={};for(var s in t)ar.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(t!=null&&Kt)for(var s of Kt(t))e.indexOf(s)<0&&lr.call(t,s)&&(i[s]=t[s]);return i};var ss=(t,e,i)=>(is(t,typeof e!="symbol"?e+"":e,i),i);var L=(t,e,i)=>new Promise((s,r)=>{var n=l=>{try{a(i.next(l))}catch(c){r(c)}},o=l=>{try{a(i.throw(l))}catch(c){r(c)}},a=l=>l.done?s(l.value):Promise.resolve(l.value).then(n,o);a((i=i.apply(t,e)).next())});var De=class{constructor(e={}){e=Object.assign({resolveTimeout:null,resolveValue:!0,rejectTimeout:null,rejectValue:!1},e),this._promise=new Promise((o,a)=>{this.resolve=o,this.reject=a}),this.then=this._promise.then.bind(this._promise),this.catch=this._promise.catch.bind(this._promise),this.finally=this._promise.finally.bind(this._promise),this[Symbol.toStringTag]="Promise";let{resolveTimeout:i,resolveValue:s,rejectTimeout:r,rejectValue:n}=e;i&&setTimeout(()=>this.resolve(s),i),r&&setTimeout(()=>this.reject(n),r)}};var cr="layer";function dr(t,e){document.dispatchEvent(new CustomEvent("doofinder.register",{detail:{name:t,entrypoint:e}}))}var Ct=t=>typeof t=="function"?t:function(){return t},So=typeof self!="undefined"?self:null,xt=typeof window!="undefined"?window:null,ze=So||xt||ze,Eo="2.0.0",xe={connecting:0,open:1,closing:2,closed:3},wo=1e4,To=1e3,fe={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},Oe={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},rs={longpoll:"longpoll",websocket:"websocket"},Ao={complete:4},Gt=class{constructor(t,e,i,s){this.channel=t,this.event=e,this.payload=i||function(){return{}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(t){this.timeout=t,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(t,e){return this.hasReceived(t)&&e(this.receivedResp.response),this.recHooks.push({status:t,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}matchReceive({status:t,response:e,_ref:i}){this.recHooks.filter(s=>s.status===t).forEach(s=>s.callback(e))}cancelRefEvent(){!this.refEvent||this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,t=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=t,this.matchReceive(t)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}trigger(t,e){this.channel.trigger(this.refEvent,{status:t,response:e})}},ur=class{constructor(t,e){this.callback=t,this.timerCalc=e,this.timer=null,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},Co=class{constructor(t,e,i){this.state=fe.closed,this.topic=t,this.params=Ct(e||{}),this.socket=i,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Gt(this,Oe.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new ur(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=fe.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=fe.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic} ${this.joinRef()}`),this.state=fe.closed,this.socket.remove(this)}),this.onError(s=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.isJoining()&&this.joinPush.reset(),this.state=fe.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic} (${this.joinRef()})`,this.joinPush.timeout),new Gt(this,Oe.leave,Ct({}),this.timeout).send(),this.state=fe.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(Oe.reply,(s,r)=>{this.trigger(this.replyEventName(r),s)})}join(t=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=t,this.joinedOnce=!0,this.rejoin(),this.joinPush}onClose(t){this.on(Oe.close,t)}onError(t){return this.on(Oe.error,e=>t(e))}on(t,e){let i=this.bindingRef++;return this.bindings.push({event:t,ref:i,callback:e}),i}off(t,e){this.bindings=this.bindings.filter(i=>!(i.event===t&&(typeof e=="undefined"||e===i.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(t,e,i=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${t}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new Gt(this,t,function(){return e},i);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=fe.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(Oe.close,"leave")},i=new Gt(this,Oe.leave,Ct({}),t);return i.receive("ok",()=>e()).receive("timeout",()=>e()),i.send(),this.canPush()||i.trigger("ok",{}),i}onMessage(t,e,i){return e}isMember(t,e,i,s){return this.topic!==t?!1:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:t,event:e,payload:i,joinRef:s}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(t=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=fe.joining,this.joinPush.resend(t))}trigger(t,e,i,s){let r=this.onMessage(t,e,i,s);if(e&&!r)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let n=this.bindings.filter(o=>o.event===t);for(let o=0;o{let a=this.parseJSON(t.responseText);o&&o(a)},n&&(t.ontimeout=n),t.onprogress=()=>{},t.send(s),t}static xhrRequest(t,e,i,s,r,n,o,a){return t.open(e,i,!0),t.timeout=n,t.setRequestHeader("Content-Type",s),t.onerror=()=>a&&a(null),t.onreadystatechange=()=>{if(t.readyState===Ao.complete&&a){let l=this.parseJSON(t.responseText);a(l)}},o&&(t.ontimeout=o),t.send(r),t}static parseJSON(t){if(!t||t==="")return null;try{return JSON.parse(t)}catch(e){return console&&console.log("failed to parse JSON response",t),null}}static serialize(t,e){let i=[];for(var s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let r=e?`${e}[${s}]`:s,n=t[s];typeof n=="object"?i.push(this.serialize(n,r)):i.push(encodeURIComponent(r)+"="+encodeURIComponent(n))}return i.join("&")}static appendParams(t,e){if(Object.keys(e).length===0)return t;let i=t.match(/\?/)?"&":"?";return`${t}${i}${this.serialize(e)}`}},xo=t=>{let e="",i=new Uint8Array(t),s=i.byteLength;for(let r=0;rthis.poll(),0)}normalizeEndpoint(t){return t.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+rs.websocket),"$1/"+rs.longpoll)}endpointURL(){return Yt.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,i){this.close(t,e,i),this.readyState=xe.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===xe.open||this.readyState===xe.connecting}poll(){this.ajax("GET","application/json",null,()=>this.ontimeout(),t=>{if(t){var{status:e,token:i,messages:s}=t;this.token=i}else e=0;switch(e){case 200:s.forEach(r=>{setTimeout(()=>this.onmessage({data:r}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=xe.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${e}`)}})}send(t){typeof t!="string"&&(t=xo(t)),this.currentBatch?this.currentBatch.push(t):this.awaitingBatchAck?this.batchBuffer.push(t):(this.currentBatch=[t],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(t){this.awaitingBatchAck=!0,this.ajax("POST","application/x-ndjson",t.join(` `),()=>this.onerror("timeout"),e=>{this.awaitingBatchAck=!1,!e||e.status!==200?(this.onerror(e&&e.status),this.closeAndRetry(1011,"internal server error",!1)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[])})}close(t,e,i){for(let r of this.reqs)r.abort();this.readyState=xe.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:t,reason:e,wasClean:i});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent!="undefined"?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(t,e,i,s,r){let n,o=()=>{this.reqs.delete(n),s()};n=Yt.request(t,this.endpointURL(),e,i,this.timeout,o,a=>{this.reqs.delete(n),this.isActive()&&r(a)}),this.reqs.add(n)}};var Qt={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(t,e){if(t.payload.constructor===ArrayBuffer)return e(this.binaryEncode(t));{let i=[t.join_ref,t.ref,t.topic,t.event,t.payload];return e(JSON.stringify(i))}},decode(t,e){if(t.constructor===ArrayBuffer)return e(this.binaryDecode(t));{let[i,s,r,n,o]=JSON.parse(t);return e({join_ref:i,ref:s,topic:r,event:n,payload:o})}},binaryEncode(t){let{join_ref:e,ref:i,event:s,topic:r,payload:n}=t,o=this.META_LENGTH+e.length+i.length+r.length+s.length,a=new ArrayBuffer(this.HEADER_LENGTH+o),l=new DataView(a),c=0;l.setUint8(c++,this.KINDS.push),l.setUint8(c++,e.length),l.setUint8(c++,i.length),l.setUint8(c++,r.length),l.setUint8(c++,s.length),Array.from(e,m=>l.setUint8(c++,m.charCodeAt(0))),Array.from(i,m=>l.setUint8(c++,m.charCodeAt(0))),Array.from(r,m=>l.setUint8(c++,m.charCodeAt(0))),Array.from(s,m=>l.setUint8(c++,m.charCodeAt(0)));var f=new Uint8Array(a.byteLength+n.byteLength);return f.set(new Uint8Array(a),0),f.set(new Uint8Array(n),a.byteLength),f.buffer},binaryDecode(t){let e=new DataView(t),i=e.getUint8(0),s=new TextDecoder;switch(i){case this.KINDS.push:return this.decodePush(t,e,s);case this.KINDS.reply:return this.decodeReply(t,e,s);case this.KINDS.broadcast:return this.decodeBroadcast(t,e,s)}},decodePush(t,e,i){let s=e.getUint8(1),r=e.getUint8(2),n=e.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,a=i.decode(t.slice(o,o+s));o=o+s;let l=i.decode(t.slice(o,o+r));o=o+r;let c=i.decode(t.slice(o,o+n));o=o+n;let f=t.slice(o,t.byteLength);return{join_ref:a,ref:null,topic:l,event:c,payload:f}},decodeReply(t,e,i){let s=e.getUint8(1),r=e.getUint8(2),n=e.getUint8(3),o=e.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,l=i.decode(t.slice(a,a+s));a=a+s;let c=i.decode(t.slice(a,a+r));a=a+r;let f=i.decode(t.slice(a,a+n));a=a+n;let m=i.decode(t.slice(a,a+o));a=a+o;let w=t.slice(a,t.byteLength),_={status:m,response:w};return{join_ref:l,ref:c,topic:f,event:Oe.reply,payload:_}},decodeBroadcast(t,e,i){let s=e.getUint8(1),r=e.getUint8(2),n=this.HEADER_LENGTH+2,o=i.decode(t.slice(n,n+s));n=n+s;let a=i.decode(t.slice(n,n+r));n=n+r;let l=t.slice(n,t.byteLength);return{join_ref:null,ref:null,topic:o,event:a,payload:l}}},fr=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=e.timeout||wo,this.transport=e.transport||ze.WebSocket||kt,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=e.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=e.sessionStorage||ze&&ze.sessionStorage,this.establishedConnections=0,this.defaultEncoder=Qt.encode.bind(Qt),this.defaultDecoder=Qt.decode.bind(Qt),this.closeWasClean=!1,this.disconnecting=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.transport!==kt?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;xt&&xt.addEventListener&&(xt.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock)}),xt.addEventListener("pageshow",s=>{i===this.connectClock&&(i=null,this.connect())})),this.heartbeatIntervalMs=e.heartbeatIntervalMs||3e4,this.rejoinAfterMs=s=>e.rejoinAfterMs?e.rejoinAfterMs(s):[1e3,2e3,5e3][s-1]||1e4,this.reconnectAfterMs=s=>e.reconnectAfterMs?e.reconnectAfterMs(s):[10,50,100,150,200,250,500,1e3,2e3][s-1]||5e3,this.logger=e.logger||null,!this.logger&&e.debug&&(this.logger=(s,r,n)=>{console.log(`${s}: ${r}`,n)}),this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=Ct(e.params||{}),this.endPoint=`${t}/${rs.websocket}`,this.vsn=e.vsn||Eo,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new ur(()=>{this.teardown(()=>this.connect())},this.reconnectAfterMs)}getLongPollTransport(){return kt}replaceTransport(t){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=t}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let t=Yt.appendParams(Yt.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return t.charAt(0)!=="/"?t:t.charAt(1)==="/"?`${this.protocol()}:${t}`:`${this.protocol()}://${location.host}${t}`}disconnect(t,e,i){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,t&&t()},e,i)}connect(t){t&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=Ct(t)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==kt?this.connectWithFallback(kt,this.longPollFallbackMs):this.transportConnect())}log(t,e,i){this.logger&&this.logger(t,e,i)}hasLogger(){return this.logger!==null}onOpen(t){let e=this.makeRef();return this.stateChangeCallbacks.open.push([e,t]),e}onClose(t){let e=this.makeRef();return this.stateChangeCallbacks.close.push([e,t]),e}onError(t){let e=this.makeRef();return this.stateChangeCallbacks.error.push([e,t]),e}onMessage(t){let e=this.makeRef();return this.stateChangeCallbacks.message.push([e,t]),e}ping(t){if(!this.isConnected())return!1;let e=this.makeRef(),i=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:e});let s=this.onMessage(r=>{r.ref===e&&(this.off([s]),t(Date.now()-i))});return!0}transportConnect(){this.connectClock++,this.closeWasClean=!1,this.conn=new this.transport(this.endPointURL()),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=t=>this.onConnError(t),this.conn.onmessage=t=>this.onConnMessage(t),this.conn.onclose=t=>this.onConnClose(t)}getSession(t){return this.sessionStore&&this.sessionStore.getItem(t)}storeSession(t,e){this.sessionStore&&this.sessionStore.setItem(t,e)}connectWithFallback(t,e=2500){clearTimeout(this.fallbackTimer);let i=!1,s=!0,r,n,o=a=>{this.log("transport",`falling back to ${t.name}...`,a),this.off([r,n]),s=!1,this.replaceTransport(t),this.transportConnect()};if(this.getSession(`phx:fallback:${t.name}`))return o("memorized");this.fallbackTimer=setTimeout(o,e),n=this.onError(a=>{this.log("transport","error",a),s&&!i&&(clearTimeout(this.fallbackTimer),o(a))}),this.onOpen(()=>{if(i=!0,!s)return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${t.name}`,"true"),this.log("transport",`established ${t.name} fallback`);clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(o,e),this.ping(a=>{this.log("transport","connected to primary after",a),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`${this.transport.name} connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,t])=>t())}heartbeatTimeout(){this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.triggerChanError(),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),To,"heartbeat timeout"))}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(t,e,i){if(!this.conn)return t&&t();let s=this.connectClock;this.waitForBufferDone(()=>{s===this.connectClock&&(this.conn&&(e?this.conn.close(e,i||""):this.conn.close()),this.waitForSocketClosed(()=>{s===this.connectClock&&(this.conn&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),t&&t())}))})}waitForBufferDone(t,e=1){if(e===5||!this.conn||!this.conn.bufferedAmount){t();return}setTimeout(()=>{this.waitForBufferDone(t,e+1)},150*e)}waitForSocketClosed(t,e=1){if(e===5||!this.conn||this.conn.readyState===xe.closed){t();return}setTimeout(()=>{this.waitForSocketClosed(t,e+1)},150*e)}onConnClose(t){let e=t&&t.code;this.hasLogger()&&this.log("transport","close",t),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&e!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,i])=>i(t))}onConnError(t){this.hasLogger()&&this.log("transport",t);let e=this.transport,i=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,s])=>{s(t,e,i)}),(e===this.transport||i>0)&&this.triggerChanError()}triggerChanError(){this.channels.forEach(t=>{t.isErrored()||t.isLeaving()||t.isClosed()||t.trigger(Oe.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case xe.connecting:return"connecting";case xe.open:return"open";case xe.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(t){this.off(t.stateChangeRefs),this.channels=this.channels.filter(e=>e!==t)}off(t){for(let e in this.stateChangeCallbacks)this.stateChangeCallbacks[e]=this.stateChangeCallbacks[e].filter(([i])=>t.indexOf(i)===-1)}channel(t,e={}){let i=new Co(t,e,this);return this.channels.push(i),i}push(t){if(this.hasLogger()){let{topic:e,event:i,payload:s,ref:r,join_ref:n}=t;this.log("push",`${e} ${i} (${n}, ${r})`,s)}this.isConnected()?this.encode(t,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(t,e=>this.conn.send(e)))}makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}sendHeartbeat(){this.pendingHeartbeatRef&&!this.isConnected()||(this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs))}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}onConnMessage(t){this.decode(t.data,e=>{let{topic:i,event:s,payload:r,ref:n,join_ref:o}=e;n&&n===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.pendingHeartbeatRef=null,this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${r.status||""} ${i} ${s} ${n&&"("+n+")"||""}`,r);for(let a=0;ai.topic===t&&(i.isJoined()||i.isJoining()));e&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${t}"`),e.leave())}};var pr=(t,e,i)=>{e.forEach(s=>{t.addEventListener(s,i)})},mr=(t,e,i)=>{e.forEach(s=>{t.removeEventListener(s,i)})},ns=class{constructor(e){this.defaults={idle:1e4,events:["mousemove","scroll","keydown","mousedown","touchstart"],onIdle:null,onActive:null,onHide:null,onShow:null,keepTracking:!0,startAtIdle:!1,recurIdleCall:!1},this.throwOnBadKey(Object.keys(e),Object.keys(this.defaults)),this.settings=Object.assign({},this.defaults,e),this.visibilityEvents=["visibilitychange","webkitvisibilitychange","mozvisibilitychange","msvisibilitychange"],this.clearTimeout=null,this.reset(),this.stopListener=i=>{this.stop()},this.idlenessEventsHandler=i=>{this.idle&&(this.idle=!1,this.settings.onActive&&this.settings.onActive.call()),this.resetTimeout(this.settings)},this.visibilityEventsHandler=i=>{document.hidden||document.webkitHidden||document.mozHidden||document.msHidden?this.visible&&(this.visible=!1,this.settings.onHide&&this.settings.onHide.call()):this.visible||(this.visible=!0,this.settings.onShow&&this.settings.onShow.call())}}resetTimeout(e,i=this.settings.keepTracking){this.clearTimeout&&(this.clearTimeout(),this.clearTimeout=null),i&&this.timeout(this.settings)}timeout(e){var i=this.settings.recurIdleCall?{set:setInterval.bind(window),clear:clearInterval.bind(window)}:{set:setTimeout.bind(window),clear:clearTimeout.bind(window)},s=i.set(function(){this.idle=!0,this.settings.onIdle&&this.settings.onIdle.call()}.bind(this),this.settings.idle);this.clearTimeout=()=>i.clear(s)}start(){return window.addEventListener("idle:stop",this.stopListener),this.timeout(this.settings),pr(window,this.settings.events,this.idlenessEventsHandler),(this.settings.onShow||this.settings.onHide)&&pr(document,this.visibilityEvents,this.visibilityEventsHandler),this}stop(){return window.removeEventListener("idle:stop",this.stopListener),mr(window,this.settings.events,this.idlenessEventsHandler),this.resetTimeout(this.settings,!1),(this.settings.onShow||this.settings.onHide)&&mr(document,this.visibilityEvents,this.visibilityEventsHandler),this}reset({idle:e=this.settings.startAtIdle,visible:i=!this.settings.startAtIdle}={}){return this.idle=e,this.visible=i,this}throwOnBadKey(e,i){e.forEach(function(s){if(!i.includes(s))throw`set: Unknown key ${s}`})}set(e){this.throwOnBadKey(Object.keys(e),Object.keys(this.defaults)),this.settings=Object.assign(this.settings,e)}};var os=class extends fr{constructor(e,i={}){super(e,i);this.preventReconnect=!1,this.shouldReconnect=!1,this.idleMonitor=new ns({idle:3*60*1e3,onActive:this.onShowOrActive.bind(this),onShow:this.onShowOrActive.bind(this)}),this.idleMonitor.start()}onShowOrActive(){this.shouldReconnect&&this.idleMonitor.visible&&!this.idleMonitor.idle&&(this.shouldReconnect=!1,this.reconnectTimer.scheduleTimeout())}onConnClose(e){let i=e&&e.code===1001&&e.wasClean&&e.type==="close";this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(),this.clearHeartbeats(),this.preventReconnect||(!this.closeWasClean&&!i?this.scheduleReconnect():this.idleMonitor.stop()),this.stateChangeCallbacks.close.forEach(([,s])=>s(e))}scheduleReconnect(){!this.idleMonitor.idle&&this.idleMonitor.visible?this.reconnectTimer.scheduleTimeout():(this.reconnectTimer.reset(),this.shouldReconnect=!0)}};var B="search",Zt="consecutive-reloads",gr=10,_r=5e3,vr=1e4,br=3e4,ei=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],pe="data-phx-component";var yr="track-static";var ae="data-phx-ref",ke="data-phx-ref-src",ti="track-uploads",me="data-phx-upload-ref",at="data-phx-preflighted-refs",Sr="data-phx-done-refs",as="drop-target",Pt="data-phx-active-refs",lt=`${B}:live-file:updated`,ii="data-phx-skip",si="data-phx-id",ls="data-phx-prune",hs="page-loading",cs="phx-connected",ht="phx-loading",Rt="phx-no-feedback",Lt="phx-error",ds="phx-client-error",ri="phx-server-error",Ke="data-phx-parent-id",ni="data-phx-main",Pe="data-dfd-root-id",oi="viewport-top",ai="viewport-bottom",Er="trigger-action",Ge="feedback-for",Ye="feedback-group",It="phx-has-focused",wr=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],li=["checkbox","radio"],ct="phx-has-submitted",_e="data-dfd-view",He=`[${_e}]`,us="data-phx-sticky",Ue="data-phx-static",hi="data-phx-readonly",Qe="data-phx-disabled",Dt="disable-with",Ot="data-phx-disable-with-restore",dt="hook",Tr="debounce",Ar="throttle",ut="update",ci="stream",di="data-phx-stream",Cr="key",Ee="phxPrivate",fs="auto-recover",Ht="phx:live-socket:debug",ui="phx:live-socket:profiling",fi="phx:live-socket:latency-sim",xr="progress",ps="mounted",kr=1,Pr=200,Rr="dfd-",Lr=3e4;var ft="debounce-trigger",pt="throttled",ms="debounce-prev-key",Ir={debounce:300,throttle:300},Mt="d",we="s",pi="r",le="c",gs="e",_s="r",vs="t",Dr="p",bs="stream";var mi=class{constructor(e,i,s){this.liveSocket=s,this.entry=e,this.offset=0,this.chunkSize=i,this.chunkTimer=null,this.errored=!1,this.uploadChannel=s.channel(`lvu:${e.ref}`,{token:e.metadata()})}error(e){this.errored||(this.uploadChannel.leave(),this.errored=!0,clearTimeout(this.chunkTimer),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,i=this.entry.file.slice(this.offset,this.chunkSize+this.offset);e.onload=s=>{if(s.target.error===null)this.offset+=s.target.result.byteLength,this.pushChunk(s.target.result);else return se("Read error: "+s.target.error)},e.readAsArrayBuffer(i)}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))}).receive("error",({reason:i})=>this.error(i))}};var se=(t,e)=>console.error&&console.error(t,e),ve=t=>{let e=typeof t;return e==="number"||e==="string"&&/^(0|[1-9]\d*)$/.test(t)};function Or(t=document){let e=new Set,i=t.querySelectorAll("*[id]");for(let s=0,r=i.length;s{t.liveSocket.isDebugEnabled()&&console.log(`${t.id} ${e}: ${i} - `,s)},gi=t=>typeof t=="function"?t:function(){return t},mt=t=>JSON.parse(JSON.stringify(t)),gt=(t,e,i)=>{do{if(t.matches(`[${e}]`)&&!t.disabled)return t;t=t.parentElement||t.parentNode}while(t!==null&&t.nodeType===1&&!(i&&i.isSameNode(t)||t.matches(He)));return null},Ze=t=>t!==null&&typeof t=="object"&&!(t instanceof Array),Mr=(t,e)=>JSON.stringify(t)===JSON.stringify(e),ys=t=>{for(let e in t)return!1;return!0},Te=(t,e)=>t&&e(t),Nr=function(t,e,i,s){t.forEach(r=>{new mi(r,i.config.chunk_size,s).upload()})};var Fr={canPushState(){return typeof history.pushState!="undefined"},dropLocal(t,e,i){return t.removeItem(this.localKey(e,i))},updateLocal(t,e,i,s,r){let n=this.getLocal(t,e,i),o=this.localKey(e,i),a=n===null?s:r(n);return t.setItem(o,JSON.stringify(a)),a},getLocal(t,e,i){return JSON.parse(t.getItem(this.localKey(e,i)))},updateCurrentState(t){!this.canPushState()||history.replaceState(t(history.state||{}),"",window.location.href)},pushState(t,e,i){if(this.canPushState()){if(i!==window.location.href){if(e.type=="redirect"&&e.scroll){let r=history.state||{};r.scroll=e.scroll,history.replaceState(r,"",window.location.href)}delete e.scroll,history[t+"State"](e,"",i||null);let s=this.getHashTargetEl(window.location.hash);s?s.scrollIntoView():e.type==="redirect"&&window.scroll(0,0)}}else this.redirect(i)},setCookie(t,e){document.cookie=`${t}=${e}`},getCookie(t){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${t}s*=s*([^;]*).*$)|^.*$`),"$1")},redirect(t,e){e&&Fr.setCookie("__phoenix_flash__",e+"; max-age=60000; path=/"),window.location=t},localKey(t,e){return`${t}-${e}`},getHashTargetEl(t){let e=t.toString().substring(1);if(e!=="")return document.getElementById(e)||document.querySelector(`a[name="${e}"]`)}},Re=Fr;var ko={focusMain(){let t=document.querySelector("main h1, main, h1");if(t){let e=t.tabIndex;t.tabIndex=-1,t.focus(),t.tabIndex=e}},anyOf(t,e){return e.find(i=>t instanceof i)},isFocusable(t,e){return t instanceof HTMLAnchorElement&&t.rel!=="ignore"||t instanceof HTMLAreaElement&&t.href!==void 0||!t.disabled&&this.anyOf(t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||t instanceof HTMLIFrameElement||t.tabIndex>0||!e&&t.getAttribute("tabindex")!==null&&t.getAttribute("aria-hidden")!=="true"},attemptFocus(t,e){if(this.isFocusable(t,e))try{t.focus()}catch(i){}return!!document.activeElement&&document.activeElement.isSameNode(t)},focusFirstInteractive(t){let e=t.firstElementChild;for(;e;){if(this.attemptFocus(e,!0)||this.focusFirstInteractive(e,!0))return!0;e=e.nextElementSibling}},focusFirst(t){let e=t.firstElementChild;for(;e;){if(this.attemptFocus(e)||this.focusFirst(e))return!0;e=e.nextElementSibling}},focusLast(t){let e=t.lastElementChild;for(;e;){if(this.attemptFocus(e)||this.focusLast(e))return!0;e=e.previousElementSibling}}},Be=ko;var _i=null,$r=200,Po={exec(t,e,i,s,r){let[n,o]=r||[null,{callback:r&&r.callback}];(e.charAt(0)==="["?JSON.parse(e):[[n,o]]).forEach(([l,c])=>{l===n&&o.data&&(c.data=Object.assign(c.data||{},o.data),c.callback=c.callback||o.callback),this.filterToEls(s,c).forEach(f=>{this[`exec_${l}`](t,e,i,s,f,c)})})},isVisible(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length>0)},isInViewport(t){let e=t.getBoundingClientRect(),i=window.innerHeight||document.documentElement.clientHeight,s=window.innerWidth||document.documentElement.clientWidth;return e.right>0&&e.bottom>0&&e.left{let c=l.getAttribute(n);if(!c)throw new Error(`expected ${n} to contain JS command on "${o}"`);i.liveSocket.execJS(l,c,t)})},exec_dispatch(t,e,i,s,r,{to:n,event:o,detail:a,bubbles:l}){a=a||{},a.dispatcher=s,p.dispatchEvent(r,o,{detail:a,bubbles:l})},exec_push(t,e,i,s,r,n){let{event:o,data:a,target:l,page_loading:c,loading:f,value:m,dispatcher:w,callback:_}=n,S={loading:f,value:m,target:l,page_loading:!!c},E=t==="change"&&w?w:s,R=l||E.getAttribute(i.binding("target"))||E;i.withinTargets(R,(F,I)=>{if(!!F.isConnected())if(t==="change"){let{newCid:V,_target:j}=n;j=j||(p.isFormInput(s)?s.name:void 0),j&&(S._target=j),F.pushInput(s,I,V,o||e,S,_)}else if(t==="submit"){let{submitter:V}=n;F.submitForm(s,I,o||e,V,S,_)}else F.pushEvent(t,s,I,o||e,a,S,_)})},exec_navigate(t,e,i,s,r,{href:n,replace:o}){i.liveSocket.historyRedirect(n,o?"replace":"push")},exec_patch(t,e,i,s,r,{href:n,replace:o}){i.liveSocket.pushHistoryPatch(n,o?"replace":"push",s)},exec_focus(t,e,i,s,r){window.requestAnimationFrame(()=>Be.attemptFocus(r))},exec_focus_first(t,e,i,s,r){window.requestAnimationFrame(()=>Be.focusFirstInteractive(r)||Be.focusFirst(r))},exec_push_focus(t,e,i,s,r){window.requestAnimationFrame(()=>_i=r||s)},exec_pop_focus(t,e,i,s,r){window.requestAnimationFrame(()=>{_i&&_i.focus(),_i=null})},exec_add_class(t,e,i,s,r,{names:n,transition:o,time:a}){this.addOrRemoveClasses(r,n,[],o,a,i)},exec_remove_class(t,e,i,s,r,{names:n,transition:o,time:a}){this.addOrRemoveClasses(r,[],n,o,a,i)},exec_toggle_class(t,e,i,s,r,{to:n,names:o,transition:a,time:l}){this.toggleClasses(r,o,a,i)},exec_toggle_attr(t,e,i,s,r,{attr:[n,o,a]}){r.hasAttribute(n)?a!==void 0?r.getAttribute(n)===o?this.setOrRemoveAttrs(r,[[n,a]],[]):this.setOrRemoveAttrs(r,[[n,o]],[]):this.setOrRemoveAttrs(r,[],[n]):this.setOrRemoveAttrs(r,[[n,o]],[])},exec_transition(t,e,i,s,r,{time:n,transition:o}){this.addOrRemoveClasses(r,[],[],o,n,i)},exec_toggle(t,e,i,s,r,{display:n,ins:o,outs:a,time:l}){this.toggle(t,i,r,n,o,a,l)},exec_show(t,e,i,s,r,{display:n,transition:o,time:a}){this.show(t,i,r,n,o,a)},exec_hide(t,e,i,s,r,{display:n,transition:o,time:a}){this.hide(t,i,r,n,o,a)},exec_set_attr(t,e,i,s,r,{attr:[n,o]}){this.setOrRemoveAttrs(r,[[n,o]],[])},exec_remove_attr(t,e,i,s,r,{attr:n}){this.setOrRemoveAttrs(r,[],[n])},show(t,e,i,s,r,n){this.isVisible(i)||this.toggle(t,e,i,s,r,null,n)},hide(t,e,i,s,r,n){this.isVisible(i)&&this.toggle(t,e,i,s,null,r,n)},toggle(t,e,i,s,r,n,o){o=o||$r;let[a,l,c]=r||[[],[],[]],[f,m,w]=n||[[],[],[]];if(a.length>0||f.length>0)if(this.isVisible(i)){let _=()=>{this.addOrRemoveClasses(i,m,a.concat(l).concat(c)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,f,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(i,w,m))})};i.dispatchEvent(new Event(`${B}:hide-start`)),e.transition(o,_,()=>{this.addOrRemoveClasses(i,[],f.concat(w)),p.putSticky(i,"toggle",S=>S.style.display="none"),i.dispatchEvent(new Event(`${B}:hide-end`))})}else{if(t==="remove")return;let _=()=>{this.addOrRemoveClasses(i,l,f.concat(m).concat(w));let S=s||this.defaultDisplay(i);p.putSticky(i,"toggle",E=>E.style.display=S),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(i,c,l))})};i.dispatchEvent(new Event(`${B}:show-start`)),e.transition(o,_,()=>{this.addOrRemoveClasses(i,[],a.concat(c)),i.dispatchEvent(new Event(`${B}:show-end`))})}else this.isVisible(i)?window.requestAnimationFrame(()=>{i.dispatchEvent(new Event(`${B}:hide-start`)),p.putSticky(i,"toggle",_=>_.style.display="none"),i.dispatchEvent(new Event(`${B}:hide-end`))}):window.requestAnimationFrame(()=>{i.dispatchEvent(new Event(`${B}:show-start`));let _=s||this.defaultDisplay(i);p.putSticky(i,"toggle",S=>S.style.display=_),i.dispatchEvent(new Event(`${B}:show-end`))})},toggleClasses(t,e,i,s,r){window.requestAnimationFrame(()=>{let[n,o]=p.getSticky(t,"classes",[[],[]]),a=e.filter(c=>n.indexOf(c)<0&&!t.classList.contains(c)),l=e.filter(c=>o.indexOf(c)<0&&t.classList.contains(c));this.addOrRemoveClasses(t,a,l,i,s,r)})},addOrRemoveClasses(t,e,i,s,r,n){r=r||$r;let[o,a,l]=s||[[],[],[]];if(o.length>0){let c=()=>{this.addOrRemoveClasses(t,a,[].concat(o).concat(l)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(t,o,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(t,l,a))})},f=()=>this.addOrRemoveClasses(t,e.concat(l),i.concat(o).concat(a));return n.transition(r,c,f)}window.requestAnimationFrame(()=>{let[c,f]=p.getSticky(t,"classes",[[],[]]),m=e.filter(E=>c.indexOf(E)<0&&!t.classList.contains(E)),w=i.filter(E=>f.indexOf(E)<0&&t.classList.contains(E)),_=c.filter(E=>i.indexOf(E)<0).concat(m),S=f.filter(E=>e.indexOf(E)<0).concat(w);p.putSticky(t,"classes",E=>(E.classList.remove(...S),E.classList.add(..._),[_,S]))})},setOrRemoveAttrs(t,e,i){let[s,r]=p.getSticky(t,"attrs",[[],[]]),n=e.map(([l,c])=>l).concat(i),o=s.filter(([l,c])=>!n.includes(l)).concat(e),a=r.filter(l=>!n.includes(l)).concat(i);p.putSticky(t,"attrs",l=>(a.forEach(c=>l.removeAttribute(c)),o.forEach(([c,f])=>l.setAttribute(c,f)),[o,a]))},hasAllClasses(t,e){return e.every(i=>t.classList.contains(i))},isToggledOut(t,e){return!this.isVisible(t)||this.hasAllClasses(t,e)},filterToEls(t,{to:e}){return e?p.all(document,e):[t]},defaultDisplay(t){return{tr:"table-row",td:"table-cell"}[t.tagName.toLowerCase()]||"block"}},te=Po;var be={byId(t){return document.getElementById(t)||se(`no id found for ${t}`)},removeClass(t,e){t.classList.remove(e),t.classList.length===0&&t.removeAttribute("class")},all(t,e,i){if(!t)return[];let s=Array.from(t.querySelectorAll(e));return i?s.forEach(i):s},childNodeLength(t){let e=document.createElement("template");return e.innerHTML=t,e.content.childElementCount},isUploadInput(t){return t.type==="file"&&t.getAttribute(me)!==null},isAutoUpload(t){return t.hasAttribute("data-phx-auto-upload")},findUploadInputs(t){let e=t.id,i=this.all(document,`input[type="file"][${me}][form="${e}"]`);return this.all(t,`input[type="file"][${me}]`).concat(i)},findComponentNodeList(t,e){return this.filterWithinSameLiveView(this.all(t,`[${pe}="${e}"]`),t)},isPhxDestroyed(t){return!!(t.id&&be.private(t,"destroyed"))},wantsNewTab(t){let e=t.ctrlKey||t.shiftKey||t.metaKey||t.button&&t.button===1,i=t.target instanceof HTMLAnchorElement&&t.target.hasAttribute("download"),s=t.target.hasAttribute("target")&&t.target.getAttribute("target").toLowerCase()==="_blank";return e||s||i},isUnloadableFormSubmit(t){return t.target&&t.target.getAttribute("method")==="dialog"||t.submitter&&t.submitter.getAttribute("formmethod")==="dialog"?!1:!t.defaultPrevented&&!this.wantsNewTab(t)},isNewPageClick(t,e){let i=t.target instanceof HTMLAnchorElement?t.target.getAttribute("href"):null,s;if(t.defaultPrevented||i===null||this.wantsNewTab(t)||i.startsWith("mailto:")||i.startsWith("tel:")||t.target.isContentEditable)return!1;try{s=new URL(i)}catch(r){try{s=new URL(i,e)}catch(n){return!0}}return s.host===e.host&&s.protocol===e.protocol&&s.pathname===e.pathname&&s.search===e.search?s.hash===""&&!s.href.endsWith("#"):s.protocol.startsWith("http")},markPhxChildDestroyed(t){this.isPhxChild(t)&&t.setAttribute(_e,""),this.putPrivate(t,"destroyed",!0)},findPhxChildrenInFragment(t,e){let i=document.createElement("template");return i.innerHTML=t,this.findPhxChildren(i.content,e)},isIgnored(t,e){return(t.getAttribute(e)||t.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(t,e,i){return t.getAttribute&&i.indexOf(t.getAttribute(e))>=0},findPhxSticky(t){return this.all(t,`[${us}]`)},findPhxChildren(t,e){return this.all(t,`${He}[${Ke}="${e}"]`)},findParentCIDs(t,e){let i=new Set(e),s=e.reduce((r,n)=>{let o=`[${pe}="${n}"] [${pe}]`;return this.filterWithinSameLiveView(this.all(t,o),t).map(a=>parseInt(a.getAttribute(pe))).forEach(a=>r.delete(a)),r},i);return s.size===0?new Set(e):s},filterWithinSameLiveView(t,e){return e.querySelector(He)?t.filter(i=>this.withinSameLiveView(i,e)):t},withinSameLiveView(t,e){for(;t=t.parentNode;){if(t.isSameNode(e))return!0;if(t.getAttribute(_e)!==null)return!1}},private(t,e){return t[Ee]&&t[Ee][e]},deletePrivate(t,e){t[Ee]&&delete t[Ee][e]},putPrivate(t,e,i){t[Ee]||(t[Ee]={}),t[Ee][e]=i},updatePrivate(t,e,i,s){let r=this.private(t,e);r===void 0?this.putPrivate(t,e,s(i)):this.putPrivate(t,e,s(r))},copyPrivates(t,e){e[Ee]&&(t[Ee]=e[Ee])},putTitle(t){let e=document.querySelector("title");if(e){let{prefix:i,suffix:s}=e.dataset;document.title=`${i||""}${t}${s||""}`}else document.title=t},debounce(t,e,i,s,r,n,o,a){let l=t.getAttribute(i),c=t.getAttribute(r);l===""&&(l=s),c===""&&(c=n);let f=l||c;switch(f){case null:return a();case"blur":this.once(t,"debounce-blur")&&t.addEventListener("blur",()=>a());return;default:let m=parseInt(f),w=()=>c?this.deletePrivate(t,pt):a(),_=this.incCycle(t,ft,w);if(isNaN(m))return se(`invalid throttle/debounce value: ${f}`);if(c){let E=!1;if(e.type==="keydown"){let R=this.private(t,ms);this.putPrivate(t,ms,e.key),E=R!==e.key}if(!E&&this.private(t,pt))return!1;{a();let R=setTimeout(()=>{o()&&this.triggerCycle(t,ft)},m);this.putPrivate(t,pt,R)}}else setTimeout(()=>{o()&&this.triggerCycle(t,ft,_)},m);let S=t.form;S&&this.once(S,"bind-debounce")&&S.addEventListener("submit",()=>{Array.from(new FormData(S).entries(),([E])=>{let R=S.querySelector(`[name="${E}"]`);this.incCycle(R,ft),this.deletePrivate(R,pt)})}),this.once(t,"bind-debounce")&&t.addEventListener("blur",()=>{clearTimeout(this.private(t,pt)),this.triggerCycle(t,ft)})}},triggerCycle(t,e,i){let[s,r]=this.private(t,e);i||(i=s),i===s&&(this.incCycle(t,e),r())},once(t,e){return this.private(t,e)===!0?!1:(this.putPrivate(t,e,!0),!0)},incCycle(t,e,i=function(){}){let[s]=this.private(t,e)||[0,i];return s++,this.putPrivate(t,e,[s,i]),s},isFeedbackContainer(t,e){return t.hasAttribute&&t.hasAttribute(e)},maybeHideFeedback(t,e,i,s){let r={};e.forEach(n=>{if(!t.contains(n))return;let o=n.getAttribute(i);if(!o){te.addOrRemoveClasses(n,[],[Rt]);return}if(r[o]===!0){this.hideFeedback(n);return}r[o]=this.shouldHideFeedback(t,o,s),r[o]===!0&&this.hideFeedback(n)})},hideFeedback(t){te.addOrRemoveClasses(t,[Rt],[])},shouldHideFeedback(t,e,i){let s=`[name="${e}"], [name="${e}[]"], [${i}="${e}"]`,r=!1;return be.all(t,s,n=>{(this.private(n,It)||this.private(n,ct))&&(r=!0)}),!r},feedbackSelector(t,e,i){let s=`[${e}="${t.name}"], [${e}="${t.name.replace(/\[\]$/,"")}"]`;return t.getAttribute(i)&&(s+=`,[${e}="${t.getAttribute(i)}"]`),s},resetForm(t,e,i){Array.from(t.elements).forEach(s=>{let r=this.feedbackSelector(s,e,i);this.deletePrivate(s,It),this.deletePrivate(s,ct),this.all(document,r,n=>{te.addOrRemoveClasses(n,[Rt],[])})})},showError(t,e,i){if(t.name){let s=this.feedbackSelector(t,e,i);this.all(document,s,r=>{te.addOrRemoveClasses(r,[],[Rt])})}},isPhxChild(t){return t.getAttribute&&t.getAttribute(Ke)},isPhxSticky(t){return t.getAttribute&&t.getAttribute(us)!==null},isChildOfAny(t,e){return!!e.find(i=>i.contains(t))},firstPhxChild(t){return this.isPhxChild(t)?t:this.all(t,`[${Ke}]`)[0]},dispatchEvent(t,e,i={}){let s=!0;t.nodeName==="INPUT"&&t.type==="file"&&e==="click"&&(s=!1);let o={bubbles:i.bubbles===void 0?s:!!i.bubbles,cancelable:!0,detail:i.detail||{}},a=e==="click"?new MouseEvent("click",o):new CustomEvent(e,o);t.dispatchEvent(a)},cloneNode(t,e){if(typeof e=="undefined")return t.cloneNode(!0);{let i=t.cloneNode(!1);return i.innerHTML=e,i}},mergeAttrs(t,e,i={}){let s=new Set(i.exclude||[]),r=i.isIgnored,n=e.attributes;for(let a=n.length-1;a>=0;a--){let l=n[a].name;if(s.has(l))l==="value"&&t.value===e.value&&t.setAttribute("value",e.getAttribute(l));else{let c=e.getAttribute(l);t.getAttribute(l)!==c&&(!r||r&&l.startsWith("data-"))&&t.setAttribute(l,c)}}let o=t.attributes;for(let a=o.length-1;a>=0;a--){let l=o[a].name;r?l.startsWith("data-")&&!e.hasAttribute(l)&&![ae,ke].includes(l)&&t.removeAttribute(l):e.hasAttribute(l)||t.removeAttribute(l)}},mergeFocusedInput(t,e){t instanceof HTMLSelectElement||be.mergeAttrs(t,e,{exclude:["value"]}),e.readOnly?t.setAttribute("readonly",!0):t.removeAttribute("readonly")},hasSelectionRange(t){return t.setSelectionRange&&(t.type==="text"||t.type==="textarea")},restoreFocus(t,e,i){if(t instanceof HTMLSelectElement&&t.focus(),!be.isTextualInput(t))return;let s=t.matches(":focus");t.readOnly&&t.blur(),s||t.focus(),this.hasSelectionRange(t)&&t.setSelectionRange(e,i)},isFormInput(t){return/^(?:input|select|textarea)$/i.test(t.tagName)&&t.type!=="button"},syncAttrsToProps(t){t instanceof HTMLInputElement&&li.indexOf(t.type.toLocaleLowerCase())>=0&&(t.checked=t.getAttribute("checked")!==null)},isTextualInput(t){return wr.indexOf(t.type)>=0},isNowTriggerFormExternal(t,e){return t.getAttribute&&t.getAttribute(e)!==null},syncPendingRef(t,e,i){let s=t.getAttribute(ae);if(s===null)return!0;let r=t.getAttribute(ke);return be.isFormInput(t)||t.getAttribute(i)!==null?(be.isUploadInput(t)&&be.mergeAttrs(t,e,{isIgnored:!0}),be.putPrivate(t,ae,e),!1):(ei.forEach(n=>{t.classList.contains(n)&&e.classList.add(n)}),e.setAttribute(ae,s),e.setAttribute(ke,r),!0)},cleanChildNodes(t,e){if(be.isPhxUpdate(t,e,["append","prepend"])){let i=[];t.childNodes.forEach(s=>{s.id||(!(s.nodeType===Node.TEXT_NODE&&s.nodeValue.trim()==="")&&s.nodeType!==s.COMMENT_NODE&&se(`only HTML element tags with an id are allowed inside containers with phx-update. removing illegal node: "${(s.outerHTML||s.nodeValue).trim()}" `),i.push(s))}),i.forEach(s=>s.remove())}},replaceRootContainer(t,e,i){let s=new Set(["id",_e,Ue,ni,Pe]);if(t.tagName.toLowerCase()===e.toLowerCase())return Array.from(t.attributes).filter(r=>!s.has(r.name.toLowerCase())).forEach(r=>t.removeAttribute(r.name)),Object.keys(i).filter(r=>!s.has(r.toLowerCase())).forEach(r=>t.setAttribute(r,i[r])),t;{let r=document.createElement(e);return Object.keys(i).forEach(n=>r.setAttribute(n,i[n])),s.forEach(n=>r.setAttribute(n,t.getAttribute(n))),r.innerHTML=t.innerHTML,t.replaceWith(r),r}},getSticky(t,e,i){let s=(be.private(t,"sticky")||[]).find(([r])=>e===r);if(s){let[r,n,o]=s;return o}else return typeof i=="function"?i():i},deleteSticky(t,e){this.updatePrivate(t,"sticky",[],i=>i.filter(([s,r])=>s!==e))},putSticky(t,e,i){let s=i(t);this.updatePrivate(t,"sticky",[],r=>{let n=r.findIndex(([o])=>e===o);return n>=0?r[n]=[e,i,s]:r.push([e,i,s]),r})},applyStickyOperations(t){let e=be.private(t,"sticky");!e||e.forEach(([i,s,r])=>this.putSticky(t,i,s))}},p=be;var Le=class{static isActive(e,i){let s=i._phxRef===void 0,r=Le.isPreflightInProgress(i),o=e.getAttribute(Pt).split(",").indexOf(J.genFileRef(i))>=0;return i.size>0&&(s||o||!r)}static isPreflighted(e,i){return e.getAttribute(at).split(",").indexOf(J.genFileRef(i))>=0&&this.isActive(e,i)}static isPreflightInProgress(e){return e._preflightInProgress===!0}static markPreflightInProgress(e){e._preflightInProgress=!0}constructor(e,i,s){this.ref=J.genFileRef(i),this.fileEl=e,this.file=i,this.view=s,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(lt,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,()=>{J.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(lt,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),p.isAutoUpload(this.fileEl)||J.clearFiles(this.fileEl)}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(lt,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(Pt).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,meta:typeof this.file.meta=="function"?this.file.meta():void 0}}uploader(e){if(this.meta.uploader){let i=e[this.meta.uploader]||se(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:i}}else return{name:"channel",callback:Nr}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||se(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:e})}};var Ro=0,J=class{static genFileRef(e){let i=e._phxRef;return i!==void 0?i:(e._phxRef=(Ro++).toString(),e._phxRef)}static getEntryDataURL(e,i,s){let r=this.activeFiles(e).find(n=>this.genFileRef(n)===i);s(URL.createObjectURL(r))}static hasUploadsInProgress(e){let i=0;return p.findUploadInputs(e).forEach(s=>{s.getAttribute(at)!==s.getAttribute(Sr)&&i++}),i>0}static serializeUploads(e){let i=this.activeFiles(e),s={};return i.forEach(r=>{let n={path:e.name},o=e.getAttribute(me);s[o]=s[o]||[],n.ref=this.genFileRef(r),n.last_modified=r.lastModified,n.name=r.name||n.ref,n.relative_path=r.webkitRelativePath,n.type=r.type,n.size=r.size,typeof r.meta=="function"&&(n.meta=r.meta()),s[o].push(n)}),s}static clearFiles(e){e.value=null,e.removeAttribute(me),p.putPrivate(e,"files",[])}static untrackFile(e,i){p.putPrivate(e,"files",p.private(e,"files").filter(s=>!Object.is(s,i)))}static trackFiles(e,i,s){if(e.getAttribute("multiple")!==null){let r=i.filter(n=>!this.activeFiles(e).find(o=>Object.is(o,n)));p.putPrivate(e,"files",this.activeFiles(e).concat(r)),e.value=null}else s&&s.files.length>0&&(e.files=s.files),p.putPrivate(e,"files",i)}static activeFileInputs(e){let i=p.findUploadInputs(e);return Array.from(i).filter(s=>s.files&&this.activeFiles(s).length>0)}static activeFiles(e){return(p.private(e,"files")||[]).filter(i=>Le.isActive(e,i))}static inputsAwaitingPreflight(e){let i=p.findUploadInputs(e);return Array.from(i).filter(s=>this.filesAwaitingPreflight(s).length>0)}static filesAwaitingPreflight(e){return this.activeFiles(e).filter(i=>!Le.isPreflighted(e,i)&&!Le.isPreflightInProgress(i))}static markPreflightInProgress(e){e.forEach(i=>Le.markPreflightInProgress(i.file))}constructor(e,i,s){this.view=i,this.onComplete=s,this._entries=Array.from(J.filesAwaitingPreflight(e)||[]).map(r=>new Le(e,r,i)),J.markPreflightInProgress(this._entries),this.numEntriesInProgress=this._entries.length}entries(){return this._entries}initAdapterUpload(e,i,s){this._entries=this._entries.map(n=>(n.zipPostFlight(e),n.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()}),n));let r=this._entries.reduce((n,o)=>{if(!o.meta)return n;let{name:a,callback:l}=o.uploader(s.uploaders);return n[a]=n[a]||{callback:l,entries:[]},n[a].entries.push(o),n},{});for(let n in r){let{callback:o,entries:a}=r[n];o(a,i,e,s)}}};var Lo={LiveFileUpload:{activeRefs(){return this.el.getAttribute(Pt)},preflightedRefs(){return this.el.getAttribute(at)},mounted(){this.preflightedWas=this.preflightedRefs()},updated(){let t=this.preflightedRefs();this.preflightedWas!==t&&(this.preflightedWas=t,t===""&&this.__view.cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(lt))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(me)),J.getEntryDataURL(this.inputEl,this.ref,t=>{this.url=t,this.el.src=t})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",()=>Be.focusLast(this.el)),this.focusEnd.addEventListener("focus",()=>Be.focusFirst(this.el)),this.el.addEventListener(`${B}:show-end`,()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&Be.focusFirst(this.el)}}},Ur=Lo;var vi=class{constructor(e,i,s){let r=new Set,n=new Set([...i.children].map(a=>a.id)),o=[];Array.from(e.children).forEach(a=>{if(a.id&&(r.add(a.id),n.has(a.id))){let l=a.previousElementSibling&&a.previousElementSibling.id;o.push({elementId:a.id,previousElementId:l})}}),this.containerId=i.id,this.updateType=s,this.elementsToModify=o,this.elementIdsToAdd=[...n].filter(a=>!r.has(a))}perform(){let e=p.byId(this.containerId);this.elementsToModify.forEach(i=>{i.previousElementId?Te(document.getElementById(i.previousElementId),s=>{Te(document.getElementById(i.elementId),r=>{r.previousElementSibling&&r.previousElementSibling.id==s.id||s.insertAdjacentElement("afterend",r)})}):Te(document.getElementById(i.elementId),s=>{s.previousElementSibling==null||e.insertAdjacentElement("afterbegin",s)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(i=>{Te(document.getElementById(i),s=>e.insertAdjacentElement("afterbegin",s))})}};var Br=11;function Io(t,e){var i=e.attributes,s,r,n,o,a;if(!(e.nodeType===Br||t.nodeType===Br)){for(var l=i.length-1;l>=0;l--)s=i[l],r=s.name,n=s.namespaceURI,o=s.value,n?(r=s.localName||r,a=t.getAttributeNS(n,r),a!==o&&(s.prefix==="xmlns"&&(r=s.name),t.setAttributeNS(n,r,o))):(a=t.getAttribute(r),a!==o&&t.setAttribute(r,o));for(var c=t.attributes,f=c.length-1;f>=0;f--)s=c[f],r=s.name,n=s.namespaceURI,n?(r=s.localName||r,e.hasAttributeNS(n,r)||t.removeAttributeNS(n,r)):e.hasAttribute(r)||t.removeAttribute(r)}}var bi,Do="http://www.w3.org/1999/xhtml",ue=typeof document=="undefined"?void 0:document,Oo=!!ue&&"content"in ue.createElement("template"),Ho=!!ue&&ue.createRange&&"createContextualFragment"in ue.createRange();function Mo(t){var e=ue.createElement("template");return e.innerHTML=t,e.content.childNodes[0]}function No(t){bi||(bi=ue.createRange(),bi.selectNode(ue.body));var e=bi.createContextualFragment(t);return e.childNodes[0]}function Fo(t){var e=ue.createElement("body");return e.innerHTML=t,e.childNodes[0]}function $o(t){return t=t.trim(),Oo?Mo(t):Ho?No(t):Fo(t)}function yi(t,e){var i=t.nodeName,s=e.nodeName,r,n;return i===s?!0:(r=i.charCodeAt(0),n=s.charCodeAt(0),r<=90&&n>=97?i===s.toUpperCase():n<=90&&r>=97?s===i.toUpperCase():!1)}function Uo(t,e){return!e||e===Do?ue.createElement(t):ue.createElementNS(e,t)}function Bo(t,e){for(var i=t.firstChild;i;){var s=i.nextSibling;e.appendChild(i),i=s}return e}function Ss(t,e,i){t[i]!==e[i]&&(t[i]=e[i],t[i]?t.setAttribute(i,""):t.removeAttribute(i))}var Vr={OPTION:function(t,e){var i=t.parentNode;if(i){var s=i.nodeName.toUpperCase();s==="OPTGROUP"&&(i=i.parentNode,s=i&&i.nodeName.toUpperCase()),s==="SELECT"&&!i.hasAttribute("multiple")&&(t.hasAttribute("selected")&&!e.selected&&(t.setAttribute("selected","selected"),t.removeAttribute("selected")),i.selectedIndex=-1)}Ss(t,e,"selected")},INPUT:function(t,e){Ss(t,e,"checked"),Ss(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),e.hasAttribute("value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var i=e.value;t.value!==i&&(t.value=i);var s=t.firstChild;if(s){var r=s.nodeValue;if(r==i||!i&&r==t.placeholder)return;s.nodeValue=i}},SELECT:function(t,e){if(!e.hasAttribute("multiple")){for(var i=-1,s=0,r=t.firstChild,n,o;r;)if(o=r.nodeName&&r.nodeName.toUpperCase(),o==="OPTGROUP")n=r,r=n.firstChild;else{if(o==="OPTION"){if(r.hasAttribute("selected")){i=s;break}s++}r=r.nextSibling,!r&&n&&(r=n.nextSibling,n=null)}t.selectedIndex=i}}},Nt=1,jr=11,Xr=3,qr=8;function Ve(){}function Vo(t){if(t)return t.getAttribute&&t.getAttribute("id")||t.id}function jo(t){return function(i,s,r){if(r||(r={}),typeof s=="string")if(i.nodeName==="#document"||i.nodeName==="HTML"||i.nodeName==="BODY"){var n=s;s=ue.createElement("html"),s.innerHTML=n}else s=$o(s);else s.nodeType===jr&&(s=s.firstElementChild);var o=r.getNodeKey||Vo,a=r.onBeforeNodeAdded||Ve,l=r.onNodeAdded||Ve,c=r.onBeforeElUpdated||Ve,f=r.onElUpdated||Ve,m=r.onBeforeNodeDiscarded||Ve,w=r.onNodeDiscarded||Ve,_=r.onBeforeElChildrenUpdated||Ve,S=r.skipFromChildren||Ve,E=r.addChild||function(k,x){return k.appendChild(x)},R=r.childrenOnly===!0,F=Object.create(null),I=[];function V(k){I.push(k)}function j(k,x){if(k.nodeType===Nt)for(var q=k.firstChild;q;){var D=void 0;x&&(D=o(q))?V(D):(w(q),q.firstChild&&j(q,x)),q=q.nextSibling}}function K(k,x,q){m(k)!==!1&&(x&&x.removeChild(k),w(k),j(k,q))}function Q(k){if(k.nodeType===Nt||k.nodeType===jr)for(var x=k.firstChild;x;){var q=o(x);q&&(F[q]=x),Q(x),x=x.nextSibling}}Q(i);function X(k){l(k);for(var x=k.firstChild;x;){var q=x.nextSibling,D=o(x);if(D){var M=F[D];M&&yi(x,M)?(x.parentNode.replaceChild(M,x),g(M,x)):X(x)}else X(x);x=q}}function Z(k,x,q){for(;x;){var D=x.nextSibling;(q=o(x))?V(q):K(x,k,!0),x=D}}function g(k,x,q){var D=o(x);if(D&&delete F[D],!q){var M=c(k,x);if(M===!1||(M instanceof HTMLElement&&(k=M,Q(k)),t(k,x),f(k),_(k,x)===!1))return}k.nodeName!=="TEXTAREA"?P(k,x):Vr.TEXTAREA(k,x)}function P(k,x){var q=S(k,x),D=x.firstChild,M=k.firstChild,Ie,Se,Fe,$e,ge;e:for(;D;){for($e=D.nextSibling,Ie=o(D);!q&&M;){if(Fe=M.nextSibling,D.isSameNode&&D.isSameNode(M)){D=$e,M=Fe;continue e}Se=o(M);var Je=M.nodeType,ne=void 0;if(Je===D.nodeType&&(Je===Nt?(Ie?Ie!==Se&&((ge=F[Ie])?Fe===ge?ne=!1:(k.insertBefore(ge,M),Se?V(Se):K(M,k,!0),M=ge,Se=o(M)):ne=!1):Se&&(ne=!1),ne=ne!==!1&&yi(M,D),ne&&g(M,D)):(Je===Xr||Je==qr)&&(ne=!0,M.nodeValue!==D.nodeValue&&(M.nodeValue=D.nodeValue))),ne){D=$e,M=Fe;continue e}Se?V(Se):K(M,k,!0),M=Fe}if(Ie&&(ge=F[Ie])&&yi(ge,D))q||E(k,ge),g(ge,D);else{var Et=a(D);Et!==!1&&(Et&&(D=Et),D.actualize&&(D=D.actualize(k.ownerDocument||ue)),E(k,D),X(D))}D=$e,M=Fe}Z(k,M,Se);var wt=Vr[k.nodeName];wt&&wt(k,x)}var O=i,ee=O.nodeType,ye=s.nodeType;if(!R){if(ee===Nt)ye===Nt?yi(i,s)||(w(i),O=Bo(i,Uo(s.nodeName,s.namespaceURI))):O=s;else if(ee===Xr||ee===qr){if(ye===ee)return O.nodeValue!==s.nodeValue&&(O.nodeValue=s.nodeValue),O;O=s}}if(O===s)w(i);else{if(s.isSameNode&&s.isSameNode(O))return;if(g(O,s,R),I)for(var ot=0,yt=I.length;ot{if(s&&s.isSameNode(r)&&p.isFormInput(r))return p.mergeFocusedInput(r,n),!1}})}constructor(e,i,s,r,n,o){this.view=e,this.liveSocket=e.liveSocket,this.container=i,this.id=s,this.rootID=e.root.id,this.html=r,this.streams=n,this.streamInserts={},this.streamComponentRestore={},this.targetCID=o,this.cidPatch=ve(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]}}before(e,i){this.callbacks[`before${e}`].push(i)}after(e,i){this.callbacks[`after${e}`].push(i)}trackBefore(e,...i){this.callbacks[`before${e}`].forEach(s=>s(...i))}trackAfter(e,...i){this.callbacks[`after${e}`].forEach(s=>s(...i))}markPrunableContentForRemoval(){let e=this.liveSocket.binding(ut);p.all(this.container,`[${e}=append] > *, [${e}=prepend] > *`,i=>{i.setAttribute(ls,"")})}perform(e){let{view:i,liveSocket:s,container:r,html:n}=this,o=this.isCIDPatch()?this.targetCIDContainer(n):r;if(this.isCIDPatch()&&!o)return;let a=s.getActiveElement(),{selectionStart:l,selectionEnd:c}=a&&p.hasSelectionRange(a)?a:{},f=s.binding(ut),m=s.binding(Ge),w=s.binding(Ye),_=s.binding(Dt),S=s.binding(oi),E=s.binding(ai),R=s.binding(Er),F=[],I=[],V=[],j=[],K=null;function Q(X,Z){Es(X,Z,{childrenOnly:X.getAttribute(pe)===null,getNodeKey:g=>p.isPhxDestroyed(g)?null:e?g.id:g.id||g.getAttribute&&g.getAttribute(si),skipFromChildren:g=>g.getAttribute(f)===ci,addChild:(g,P)=>{let{ref:O,streamAt:ee}=this.getStreamInsert(P);if(O===void 0)return g.appendChild(P);if(this.setStreamRef(P,O),ee===0)g.insertAdjacentElement("afterbegin",P);else if(ee===-1)g.appendChild(P);else if(ee>0){let ye=Array.from(g.children)[ee];g.insertBefore(P,ye)}},onBeforeNodeAdded:g=>{this.trackBefore("added",g);let P=g;return!e&&this.streamComponentRestore[g.id]&&(P=this.streamComponentRestore[g.id],delete this.streamComponentRestore[g.id],Q.bind(this)(P,g)),P},onNodeAdded:g=>{g.getAttribute&&this.maybeReOrderStream(g,!0),p.isFeedbackContainer(g,m)&&I.push(g),g instanceof HTMLImageElement&&g.srcset?g.srcset=g.srcset:g instanceof HTMLVideoElement&&g.autoplay&&g.play(),p.isNowTriggerFormExternal(g,R)&&(K=g),(p.isPhxChild(g)&&i.ownsElement(g)||p.isPhxSticky(g)&&i.ownsElement(g.parentNode))&&this.trackAfter("phxChildAdded",g),F.push(g)},onNodeDiscarded:g=>this.onNodeDiscarded(g),onBeforeNodeDiscarded:g=>g.getAttribute&&g.getAttribute(ls)!==null?!0:!(g.parentElement!==null&&g.id&&p.isPhxUpdate(g.parentElement,f,[ci,"append","prepend"])||this.maybePendingRemove(g)||this.skipCIDSibling(g)),onElUpdated:g=>{p.isNowTriggerFormExternal(g,R)&&(K=g),V.push(g),this.maybeReOrderStream(g,!1)},onBeforeElUpdated:(g,P)=>{if((p.isFeedbackContainer(g,m)||p.isFeedbackContainer(P,m))&&(I.push(g),I.push(P)),p.cleanChildNodes(P,f),this.skipCIDSibling(P))return this.maybeReOrderStream(g),!1;if(p.isPhxSticky(g))return!1;if(p.isIgnored(g,f)||g.form&&g.form.isSameNode(K))return this.trackBefore("updated",g,P),p.mergeAttrs(g,P,{isIgnored:!0}),V.push(g),p.applyStickyOperations(g),!1;if(g.type==="number"&&g.validity&&g.validity.badInput)return!1;if(!p.syncPendingRef(g,P,_))return p.isUploadInput(g)&&(this.trackBefore("updated",g,P),V.push(g)),p.applyStickyOperations(g),!1;if(p.isPhxChild(P)){let ye=g.getAttribute(_e);return p.mergeAttrs(g,P,{exclude:[Ue]}),ye!==""&&g.setAttribute(_e,ye),g.setAttribute(Pe,this.rootID),p.applyStickyOperations(g),!1}p.copyPrivates(P,g);let O=a&&g.isSameNode(a)&&p.isFormInput(g),ee=O&&this.isChangedSelect(g,P);return O&&g.type!=="hidden"&&!ee?(this.trackBefore("updated",g,P),p.mergeFocusedInput(g,P),p.syncAttrsToProps(g),V.push(g),p.applyStickyOperations(g),!1):(ee&&g.blur(),p.isPhxUpdate(P,f,["append","prepend"])&&j.push(new vi(g,P,P.getAttribute(f))),p.syncAttrsToProps(P),p.applyStickyOperations(P),this.trackBefore("updated",g,P),!0)}})}return this.trackBefore("added",r),this.trackBefore("updated",r,r),s.time("morphdom",()=>{this.streams.forEach(([X,Z,g,P])=>{Z.forEach(([O,ee,ye])=>{this.streamInserts[O]={ref:X,streamAt:ee,limit:ye,reset:P}}),P!==void 0&&p.all(r,`[${di}="${X}"]`,O=>{this.removeStreamChildElement(O)}),g.forEach(O=>{let ee=r.querySelector(`[id="${O}"]`);ee&&this.removeStreamChildElement(ee)})}),e&&p.all(this.container,`[${f}=${ci}]`,X=>{this.liveSocket.owner(X,Z=>{Z===this.view&&Array.from(X.children).forEach(g=>{this.removeStreamChildElement(g)})})}),Q.bind(this)(o,n)}),s.isDebugEnabled()&&Or(s.doofinderMount),j.length>0&&s.time("post-morph append/prepend restoration",()=>{j.forEach(X=>X.perform())}),p.maybeHideFeedback(o,I,m,w),s.silenceEvents(()=>p.restoreFocus(a,l,c)),p.dispatchEvent(document,`${B}:update`),F.forEach(X=>this.trackAfter("added",X)),V.forEach(X=>this.trackAfter("updated",X)),this.transitionPendingRemoves(),K&&(s.unload(),Object.getPrototypeOf(K).submit.call(K)),!0}onNodeDiscarded(e){(p.isPhxChild(e)||p.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}removeStreamChildElement(e){this.streamInserts[e.id]?(this.streamComponentRestore[e.id]=e,e.remove()):this.maybePendingRemove(e)||(e.remove(),this.onNodeDiscarded(e))}getStreamInsert(e){return(e.id?this.streamInserts[e.id]:{})||{}}setStreamRef(e,i){p.putSticky(e,di,s=>s.setAttribute(di,i))}maybeReOrderStream(e,i){let{ref:s,streamAt:r,reset:n}=this.getStreamInsert(e);if(r!==void 0&&(this.setStreamRef(e,s),!(!n&&!i)&&!!e.parentElement)){if(r===0)e.parentElement.insertBefore(e,e.parentElement.firstElementChild);else if(r>0){let o=Array.from(e.parentElement.children),a=o.indexOf(e);if(r>=o.length-1)e.parentElement.appendChild(e);else{let l=o[r];a>r?e.parentElement.insertBefore(e,l):e.parentElement.insertBefore(e,l.nextElementSibling)}}this.maybeLimitStream(e)}}maybeLimitStream(e){let{limit:i}=this.getStreamInsert(e),s=i!==null&&Array.from(e.parentElement.children);i&&i<0&&s.length>i*-1?s.slice(0,s.length+i).forEach(r=>this.removeStreamChildElement(r)):i&&i>=0&&s.length>i&&s.slice(i).forEach(r=>this.removeStreamChildElement(r))}transitionPendingRemoves(){let{pendingRemoves:e,liveSocket:i}=this;e.length>0&&(i.transitionRemoves(e),i.requestDOMUpdate(()=>{e.forEach(s=>{let r=p.firstPhxChild(s);r&&i.destroyViewByEl(r),s.remove()}),this.trackAfter("transitionsDiscarded",e)}))}isChangedSelect(e,i){if(!(e instanceof HTMLSelectElement)||e.multiple)return!1;if(e.options.length!==i.options.length)return!0;let s=e.selectedOptions[0],r=i.selectedOptions[0];return s&&s.hasAttribute("selected")&&r.setAttribute("selected",s.getAttribute("selected")),!e.isEqualNode(i)}isCIDPatch(){return this.cidPatch}skipCIDSibling(e){return e.nodeType===Node.ELEMENT_NODE&&e.hasAttribute(ii)}targetCIDContainer(e){if(!this.isCIDPatch())return;let[i,...s]=p.findComponentNodeList(this.container,this.targetCID);return s.length===0&&p.childNodeLength(e)===1?i:i&&i.parentNode}indexOf(e,i){return Array.from(e.children).indexOf(i)}};var qo=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),Jo=new Set(["'",'"']),Jr=(t,e,i)=>{let s=0,r=!1,n,o,a,l,c,f,m=t.match(/^(\s*(?:\s*)*)<([^\s\/>]+)/);if(m===null)throw new Error(`malformed html ${t}`);for(s=m[0].length,n=m[1],a=m[2],l=s,s;s";s++)if(t.charAt(s)==="="){let S=t.slice(s-3,s)===" id";s++;let E=t.charAt(s);if(Jo.has(E)){let R=s;for(s++,s;s=n.length+a.length;){let S=t.charAt(w);if(r)S==="-"&&t.slice(w-3,w)===""&&t.slice(w-2,w)==="--")r=!0,w-=3;else{if(S===">")break;w-=1}}o=t.slice(w+1,t.length);let _=Object.keys(e).map(S=>e[S]===!0?S:`${S}="${e[S]}"`).join(" ");if(i){let S=c?` id="${c}"`:"";qo.has(a)?f=`<${a}${S}${_===""?"":" "}${_}/>`:f=`<${a}${S}${_===""?"":" "}${_}>`}else{let S=t.slice(l,w+1);f=`<${a}${_===""?"":" "}${_}${S}`}return[f,n,o]},Ft=class{static extract(e){let{[_s]:i,[gs]:s,[vs]:r}=e;return delete e[_s],delete e[gs],delete e[vs],{diff:e,title:r,reply:i||null,events:s||[]}}constructor(e,i){this.viewId=e,this.rendered={},this.magicId=0,this.mergeDiff(i)}parentViewId(){return this.viewId}toString(e){let[i,s]=this.recursiveToString(this.rendered,this.rendered[le],e,!0,{});return[i,s]}recursiveToString(e,i=e[le],s,r,n){s=s?new Set(s):null;let o={buffer:"",components:i,onlyCids:s,streams:new Set};return this.toOutputBuffer(e,null,o,r,n),[o.buffer,o.streams]}componentCIDs(e){return Object.keys(e[le]||{}).map(i=>parseInt(i))}isComponentOnlyDiff(e){return e[le]?Object.keys(e).length===1:!1}getComponent(e,i){return e[le][i]}resetRender(e){this.rendered[le][e]&&(this.rendered[le][e].reset=!0)}mergeDiff(e){let i=e[le],s={};if(delete e[le],this.rendered=this.mutableMerge(this.rendered,e),this.rendered[le]=this.rendered[le]||{},i){let r=this.rendered[le];for(let n in i)i[n]=this.cachedFindComponent(n,i[n],r,i,s);for(let n in i)r[n]=i[n];e[le]=i}}cachedFindComponent(e,i,s,r,n){if(n[e])return n[e];{let o,a,l=i[we];if(ve(l)){let c;l>0?c=this.cachedFindComponent(l,r[l],s,r,n):c=s[-l],a=c[we],o=this.cloneMerge(c,i,!0),o[we]=a}else o=i[we]!==void 0||s[e]===void 0?i:this.cloneMerge(s[e],i,!1);return n[e]=o,o}}mutableMerge(e,i){return i[we]!==void 0?i:(this.doMutableMerge(e,i),e)}doMutableMerge(e,i){for(let s in i){let r=i[s],n=e[s];Ze(r)&&r[we]===void 0&&Ze(n)?this.doMutableMerge(n,r):e[s]=r}e[pi]&&(e.newRender=!0)}cloneMerge(e,i,s){let r=H(H({},e),i);for(let n in r){let o=i[n],a=e[n];Ze(o)&&o[we]===void 0&&Ze(a)?r[n]=this.cloneMerge(a,o,s):o===void 0&&Ze(a)&&(r[n]=this.cloneMerge(a,{},s))}return s?(delete r.magicId,delete r.newRender):e[pi]&&(r.newRender=!0),r}componentToString(e){let[i,s]=this.recursiveCIDToString(this.rendered[le],e,null),[r,n,o]=Jr(i,{});return[r,s]}pruneCIDs(e){e.forEach(i=>delete this.rendered[le][i])}get(){return this.rendered}isNewFingerprint(e={}){return!!e[we]}templateStatic(e,i){return typeof e=="number"?i[e]:e}nextMagicID(){return this.magicId++,`m${this.magicId}-${this.parentViewId()}`}toOutputBuffer(e,i,s,r,n={}){if(e[Mt])return this.comprehensionToBuffer(e,i,s);let{[we]:o}=e;o=this.templateStatic(o,i);let a=e[pi],l=s.buffer;a&&(s.buffer=""),r&&a&&!e.magicId&&(e.newRender=!0,e.magicId=this.nextMagicID()),s.buffer+=o[0];for(let c=1;c0||c.length>0||f)&&(delete e[bs],e[Mt]=[],s.streams.add(o))}dynamicToBuffer(e,i,s,r){if(typeof e=="number"){let[n,o]=this.recursiveCIDToString(s.components,e,s.onlyCids);s.buffer+=n,s.streams=new Set([...s.streams,...o])}else Ze(e)?this.toOutputBuffer(e,i,s,r,{}):s.buffer+=e}recursiveCIDToString(e,i,s){let r=e[i]||se(`no component for CID ${i}`,e),n={[pe]:i},o=s&&!s.has(i);r.newRender=!o,r.magicId=`c${i}-${this.parentViewId()}`;let a=!r.reset,[l,c]=this.recursiveToString(r,e,s,a,n);return delete r.reset,[l,c]}};var Wo=1,je=class{static makeID(){return Wo++}static elementID(e){return e.phxHookId}constructor(e,i,s){this.__view=e,this.liveSocket=e.liveSocket,this.__callbacks=s,this.__listeners=new Set,this.__isDisconnected=!1,this.el=i,this.el.phxHookId=this.constructor.makeID();for(let r in this.__callbacks)this[r]=this.__callbacks[r]}__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,i={},s=function(){}){return this.__view.pushHookEvent(this.el,null,e,i,s)}pushEventTo(e,i,s={},r=function(){}){return this.__view.withinTargets(e,(n,o)=>n.pushHookEvent(this.el,o,i,s,r))}handleEvent(e,i){let s=(r,n)=>n?e:i(r.detail);return this.liveSocket.doofinderMount.addEventListener(`${B}:${e}`,s),this.__listeners.add(s),s}removeHandleEvent(e){let i=e(null,!0);this.liveSocket.doofinderMount.removeEventListener(`${B}:${i}`,e),this.__listeners.delete(e)}upload(e,i){return this.__view.dispatchUploads(null,e,i)}uploadTo(e,i,s){return this.__view.withinTargets(e,(r,n)=>{r.dispatchUploads(n,i,s)})}__cleanup__(){this.__listeners.forEach(e=>this.removeHandleEvent(e))}};var Si=(t,e,i=[])=>{let c=e,{submitter:s}=c,r=hr(c,["submitter"]),n;if(s&&s.name){let f=document.createElement("input");f.type="hidden";let m=s.getAttribute("form");m&&f.setAttribute("form",m),f.name=s.name,f.value=s.value,s.parentElement.insertBefore(f,s),n=f}let o=new FormData(t),a=[];o.forEach((f,m,w)=>{f instanceof File&&a.push(m)}),a.forEach(f=>o.delete(f));let l=new URLSearchParams;for(let[f,m]of o.entries())(i.length===0||i.indexOf(f)>=0)&&l.append(f,m);s&&n&&s.parentElement.removeChild(n);for(let f in r)l.append(f,r[f]);return l.toString()},_t=class{constructor(e,i,s,r,n){this.isDead=!1,this.liveSocket=i,this.flash=r,this.parent=s,this.root=s?s.root:this,this.el=e,this.id=this.el.id,this.ref=0,this.childJoins=0,this.loaderTimer=null,this.pendingDiffs=[],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.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>{let o=this.href&&this.expandURL(this.href);return{redirect:this.redirect?o:void 0,url:this.redirect?void 0:o||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(ni)}connectParams(e){let i=this.liveSocket.params(this.el),s=p.all(document,`[${this.binding(yr)}]`).map(r=>r.src||r.href).filter(r=>typeof r=="string");return s.length>0&&(i._track_static=s),i._mounts=this.joinCount,i._live_referer=e,i}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(_e)}getStatic(){let e=this.el.getAttribute(Ue);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 i=()=>{e();for(let s in this.viewHooks)this.destroyHook(this.viewHooks[s])};p.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",i).receive("error",i).receive("timeout",i)}setContainerClasses(...e){this.el.classList.remove(cs,ht,Lt,ds,ri),this.el.classList.add(...e)}showLoader(e){if(clearTimeout(this.loaderTimer),e)this.loaderTimer=setTimeout(()=>this.showLoader(),e);else{for(let i in this.viewHooks)this.viewHooks[i].__disconnected();this.setContainerClasses(ht)}}execAll(e){p.all(this.el,`[${e}]`,i=>this.liveSocket.execJS(i,i.getAttribute(e)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(cs),this.execAll(this.binding("connected"))}triggerReconnected(){for(let e in this.viewHooks)this.viewHooks[e].__reconnected()}log(e,i){this.liveSocket.log(this,e,i)}transition(e,i,s=function(){}){this.liveSocket.transition(e,i,s)}withinTargets(e,i){if(e instanceof HTMLElement||e instanceof SVGElement)return this.liveSocket.owner(e,s=>i(s,e));if(ve(e))p.findComponentNodeList(this.el,e).length===0?se(`no component found matching phx-target of ${e}`):i(this,parseInt(e));else{let s=Array.from(document.querySelectorAll(e));s.length===0&&se(`nothing found matching the phx-target selector "${e}"`),s.forEach(r=>this.liveSocket.owner(r,n=>i(n,r)))}}applyDiff(e,i,s){this.log(e,()=>["",mt(i)]);let{diff:r,reply:n,events:o,title:a}=Ft.extract(i);s({diff:r,reply:n,events:o}),a&&window.requestAnimationFrame(()=>p.putTitle(a))}onJoin(e){let{rendered:i,container:s}=e;if(s){let[r,n]=s;this.el=p.replaceRootContainer(this.el,r,n)}this.childJoins=0,this.joinPending=!0,this.flash=null,Re.dropLocal(this.liveSocket.localStorage,window.location.pathname,Zt),this.applyDiff("mount",i,({diff:r,events:n})=>{this.rendered=new Ft(this.id,r);let[o,a]=this.renderContainer(null,"join");this.dropPendingRefs();let l=this.formsForRecovery(o);this.joinCount++,l.length>0?l.forEach(([c,f,m],w)=>{this.pushFormRecovery(c,m,_=>{w===l.length-1&&this.onJoinComplete(_,o,a,n)})}):this.onJoinComplete(e,o,a,n)})}dropPendingRefs(){p.all(document,`[${ke}="${this.id}"][${ae}]`,e=>{e.removeAttribute(ae),e.removeAttribute(ke)})}onJoinComplete({live_patch:e},i,s,r){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(e,i,s,r);p.findPhxChildrenInFragment(i,this.id).filter(o=>{let a=o.id&&this.el.querySelector(`[id="${o.id}"]`),l=a&&a.getAttribute(Ue);return l&&o.setAttribute(Ue,l),a&&a.setAttribute(Pe,this.root.id),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,i,s,r)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(e,i,s,r)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(e,i,s,r)])}attachTrueDocEl(){this.el=p.byId(this.id),this.el.setAttribute(Pe,this.root.id)}execNewMounted(){let e=this.binding(oi),i=this.binding(ai);p.all(this.el,`[${e}], [${i}]`,s=>{this.maybeAddNewHook(s)}),p.all(this.el,`[${this.binding(dt)}], [data-phx-${dt}]`,s=>{this.maybeAddNewHook(s)}),p.all(this.el,`[${this.binding(ps)}]`,s=>this.maybeMounted(s))}applyJoinPatch(e,i,s,r){this.attachTrueDocEl();let n=new et(this,this.el,this.id,i,s,null);if(n.markPrunableContentForRemoval(),this.performPatch(n,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(r),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,i){this.liveSocket.triggerDOM("onBeforeElUpdated",[e,i]);let s=this.getHook(e),r=s&&p.isIgnored(e,this.binding(ut));if(s&&!e.isEqualNode(i)&&!(r&&Mr(e.dataset,i.dataset)))return s.__beforeUpdate(),s}maybeMounted(e){let i=e.getAttribute(this.binding(ps)),s=i&&p.private(e,"mounted");i&&!s&&(this.liveSocket.execJS(e,i),p.putPrivate(e,"mounted",!0))}maybeAddNewHook(e,i){let s=this.addHook(e);s&&s.__mounted()}performPatch(e,i,s=!1){let r=[],n=!1,o=new Set;return e.after("added",a=>{this.liveSocket.triggerDOM("onNodeAdded",[a]),this.maybeAddNewHook(a),a.getAttribute&&this.maybeMounted(a)}),e.after("phxChildAdded",a=>{p.isPhxSticky(a)?this.liveSocket.joinRootViews():n=!0}),e.before("updated",(a,l)=>{this.triggerBeforeUpdateHook(a,l)&&o.add(a.id)}),e.after("updated",a=>{o.has(a.id)&&this.getHook(a).__updated()}),e.after("discarded",a=>{a.nodeType===Node.ELEMENT_NODE&&r.push(a)}),e.after("transitionsDiscarded",a=>this.afterElementsRemoved(a,i)),e.perform(s),this.afterElementsRemoved(r,i),n}afterElementsRemoved(e,i){let s=[];e.forEach(r=>{let n=p.all(r,`[${pe}]`),o=p.all(r,`[${this.binding(dt)}]`);n.concat(r).forEach(a=>{let l=this.componentID(a);ve(l)&&s.indexOf(l)===-1&&s.push(l)}),o.concat(r).forEach(a=>{let l=this.getHook(a);l&&this.destroyHook(l)})}),i&&this.maybePushComponentsDestroyed(s)}joinNewChildren(){p.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(Ke)][e.id]}destroyDescendent(e){for(let i in this.root.children)for(let s in this.root.children[i])if(s===e)return this.root.children[i][s].destroy()}joinChild(e){if(!this.getChildById(e.id)){let s=new _t(e,this.liveSocket,this);return this.root.children[this.id][s.id]=s,s.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,i])=>{e.isDestroyed()||i()}),this.pendingJoinOps=[]})}update(e,i){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:e,events:i});this.rendered.mergeDiff(e);let s=!1;this.rendered.isComponentOnlyDiff(e)?this.liveSocket.time("component patch complete",()=>{p.findParentCIDs(this.el,this.rendered.componentCIDs(e)).forEach(n=>{this.componentPatch(this.rendered.getComponent(e,n),n)&&(s=!0)})}):ys(e)||this.liveSocket.time("full patch complete",()=>{let[r,n]=this.renderContainer(e,"update"),o=new et(this,this.el,this.id,r,n,null);s=this.performPatch(o,!0)}),this.liveSocket.dispatchEvents(i),s&&this.joinNewChildren()}renderContainer(e,i){return this.liveSocket.time(`toString diff (${i})`,()=>{let s=this.el.tagName,r=e?this.rendered.componentCIDs(e):null,[n,o]=this.rendered.toString(r);return[`<${s}>${n}`,o]})}componentPatch(e,i){if(ys(e))return!1;let[s,r]=this.rendered.componentToString(i),n=new et(this,this.el,this.id,s,r,i);return this.performPatch(n,!0)}getHook(e){return this.viewHooks[je.elementID(e)]}addHook(e){if(je.elementID(e)||!e.getAttribute)return;let i=e.getAttribute(`data-phx-${dt}`)||e.getAttribute(this.binding(dt));if(i&&!this.ownsElement(e))return;let s=this.liveSocket.getHookCallbacks(i);if(s){e.id||se(`no DOM ID for hook "${i}". Hooks require a unique ID on each element.`,e);let r=new je(this,e,s);return this.viewHooks[je.elementID(r.el)]=r,r}else i!==null&&se(`unknown hook found for "${i}"`,e)}destroyHook(e){e.__destroyed(),e.__cleanup__(),delete this.viewHooks[je.elementID(e.el)]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:e,events:i})=>this.update(e,i)),this.pendingDiffs=[],this.eachChild(e=>e.applyPendingUpdates())}eachChild(e){let i=this.root.children[this.id]||{};for(let s in i)e(this.getChildById(s))}onChannel(e,i){this.liveSocket.onChannel(this.channel,e,s=>{this.isJoinPending()?this.root.pendingJoinOps.push([this,()=>i(s)]):this.liveSocket.requestDOMUpdate(()=>i(s))})}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",e=>{this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",e,({diff:i,events:s})=>this.update(i,s))})}),this.onChannel("redirect",({to:e,flash:i})=>this.onRedirect({to:e,flash:i})),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:i,kind:s,flash:r}=e,n=this.expandURL(i);this.liveSocket.historyRedirect(n,s,r)}onLivePatch(e){let{to:i,kind:s}=e;this.href=this.expandURL(i),this.liveSocket.historyPatch(i,s)}expandURL(e){return e.startsWith("/")?`${window.location.protocol}//${window.location.host}${e}`:e}onRedirect({to:e,flash:i}){this.liveSocket.redirect(e,i)}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=i=>{i=i||function(){},e?e(this.joinCount,i):i()},this.liveSocket.wrapPush(this,{timeout:!1},()=>this.channel.join().receive("ok",i=>{this.isDestroyed()||this.liveSocket.requestDOMUpdate(()=>this.onJoin(i))}).receive("error",i=>!this.isDestroyed()&&this.onJoinError(i)).receive("timeout",()=>!this.isDestroyed()&&this.onJoinError({reason:"timeout"})))}onJoinError(e){if(e.reason==="reload"){this.log("error",()=>[`failed mount with ${e.status}. Falling back to page request`,e]),this.isMain()&&this.onRedirect({to:this.href});return}else if(e.reason==="unauthorized"||e.reason==="stale"){this.log("error",()=>["unauthorized live_redirect. Falling back to page request",e]),this.isMain()&&this.onRedirect({to:this.href});return}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.displayError([ht,Lt,ri]),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(Pr)}}onError(e){this.onClose(e),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",e]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([ht,Lt,ri]):this.displayError([ht,Lt,ds]))}displayError(e){this.isMain()&&p.dispatchEvent(window,`${B}:page-loading-start`,{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(...e),this.execAll(this.binding("disconnected"))}pushWithReply(e,i,s,r=function(){}){if(!this.isConnected())return;let[n,[o],a]=e?e():[null,[],{}],l=function(){};return(a.page_loading||o&&o.getAttribute(this.binding(hs))!==null)&&(l=this.liveSocket.withPageLoading({kind:"element",target:o})),typeof s.cid!="number"&&delete s.cid,this.liveSocket.wrapPush(this,{timeout:!0},()=>this.channel.push(i,s,Lr).receive("ok",c=>{let f=m=>{c.redirect&&this.onRedirect(c.redirect),c.live_patch&&this.onLivePatch(c.live_patch),c.live_redirect&&this.onLiveRedirect(c.live_redirect),l(),r(c,m)};c.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",c.diff,({diff:m,reply:w,events:_})=>{n!==null&&this.undoRefs(n),this.update(m,_),f(w)})}):(n!==null&&this.undoRefs(n),f(null))}))}undoRefs(e){!this.isConnected()||p.all(document,`[${ke}="${this.id}"][${ae}="${e}"]`,i=>{let s=i.getAttribute(Qe),r=i.getAttribute(hi);i.removeAttribute(ae),i.removeAttribute(ke),r!==null&&(i.readOnly=r==="true",i.removeAttribute(hi)),s!==null&&(i.disabled=s==="true",i.removeAttribute(Qe)),ei.forEach(a=>p.removeClass(i,a));let n=i.getAttribute(Ot);n!==null&&(i.innerText=n,i.removeAttribute(Ot));let o=p.private(i,ae);if(o){let a=this.triggerBeforeUpdateHook(i,o);et.patchEl(i,o,this.liveSocket.getActiveElement()),a&&a.__updated(),p.deletePrivate(i,ae)}})}putRef(e,i,s={}){let r=this.ref++,n=this.binding(Dt);return s.loading&&(e=e.concat(p.all(document,s.loading))),e.forEach(o=>{o.classList.add(`phx-${i}-loading`),o.setAttribute(ae,r),o.setAttribute(ke,this.el.id);let a=o.getAttribute(n);a!==null&&(o.getAttribute(Ot)||o.setAttribute(Ot,o.innerText),a!==""&&(o.innerText=a),o.setAttribute(Qe,o.getAttribute(Qe)||o.disabled),o.setAttribute("disabled",""))}),[r,e,s]}componentID(e){let i=e.getAttribute&&e.getAttribute(pe);return i?parseInt(i):null}targetComponentID(e,i,s={}){if(ve(i))return i;let r=s.target||e.getAttribute(this.binding("target"));return ve(r)?parseInt(r):i&&(r!==null||s.target)?this.closestComponentID(i):null}closestComponentID(e){return ve(e)?e:e?Te(e.closest(`[${pe}]`),i=>this.ownsElement(i)&&this.componentID(i)):null}pushHookEvent(e,i,s,r,n){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",s,r]),!1;let[o,a,l]=this.putRef([e],"hook");return this.pushWithReply(()=>[o,a,l],"event",{type:"hook",event:s,value:r,cid:this.closestComponentID(i)},(c,f)=>n(f,o)),o}extractMeta(e,i,s){let r=this.binding("value-");for(let n=0;n=0&&!e.checked&&delete i.value),s){i||(i={});for(let n in s)i[n]=s[n]}return i}pushEvent(e,i,s,r,n,o={},a){this.pushWithReply(()=>this.putRef([i],e,o),"event",{type:e,event:r,value:this.extractMeta(i,n,o.value),cid:this.targetComponentID(i,s,o)},(l,c)=>a&&a(c))}pushFileProgress(e,i,s,r=function(){}){this.liveSocket.withinOwners(e.form,(n,o)=>{n.pushWithReply(null,"progress",{event:e.getAttribute(n.binding(xr)),ref:e.getAttribute(me),entry_ref:i,progress:s,cid:n.targetComponentID(e.form,o)},r)})}pushInput(e,i,s,r,n,o){let a,l=ve(s)?s:this.targetComponentID(e.form,i,n),c=()=>this.putRef([e,e.form],"change",n),f,m=this.extractMeta(e.form);e instanceof HTMLButtonElement&&(m.submitter=e),e.getAttribute(this.binding("change"))?f=Si(e.form,H({_target:n._target},m),[e.name]):f=Si(e.form,H({_target:n._target},m)),p.isUploadInput(e)&&e.files&&e.files.length>0&&J.trackFiles(e,Array.from(e.files)),a=J.serializeUploads(e);let w={type:"form",event:r,value:f,uploads:a,cid:l};this.pushWithReply(c,"event",w,_=>{if(p.showError(e,this.liveSocket.binding(Ge),this.liveSocket.binding(Ye)),p.isUploadInput(e)&&p.isAutoUpload(e)){if(J.filesAwaitingPreflight(e).length>0){let[S,E]=c();this.uploadFiles(e.form,i,S,l,R=>{o&&o(_),this.triggerAwaitingSubmit(e.form),this.undoRefs(S)})}}else o&&o(_)})}triggerAwaitingSubmit(e){let i=this.getScheduledSubmit(e);if(i){let[s,r,n,o]=i;this.cancelSubmit(e),o()}}getScheduledSubmit(e){return this.formSubmits.find(([i,s,r,n])=>i.isSameNode(e))}scheduleSubmit(e,i,s,r){if(this.getScheduledSubmit(e))return!0;this.formSubmits.push([e,i,s,r])}cancelSubmit(e){this.formSubmits=this.formSubmits.filter(([i,s,r])=>i.isSameNode(e)?(this.undoRefs(s),!1):!0)}disableForm(e,i={}){let s=m=>!(gt(m,`${this.binding(ut)}=ignore`,m.form)||gt(m,"data-phx-update=ignore",m.form)),r=m=>m.hasAttribute(this.binding(Dt)),n=m=>m.tagName=="BUTTON",o=m=>["INPUT","TEXTAREA","SELECT"].includes(m.tagName),a=Array.from(e.elements),l=a.filter(r),c=a.filter(n).filter(s),f=a.filter(o).filter(s);return c.forEach(m=>{m.setAttribute(Qe,m.disabled),m.disabled=!0}),f.forEach(m=>{m.setAttribute(hi,m.readOnly),m.readOnly=!0,m.files&&(m.setAttribute(Qe,m.disabled),m.disabled=!0)}),e.setAttribute(this.binding(hs),""),this.putRef([e].concat(l).concat(c).concat(f),"submit",i)}pushFormSubmit(e,i,s,r,n,o){let a=()=>this.disableForm(e,n),l=this.targetComponentID(e,i);if(J.hasUploadsInProgress(e)){let[c,f]=a(),m=()=>this.pushFormSubmit(e,i,s,r,n,o);return this.scheduleSubmit(e,c,n,m)}else if(J.inputsAwaitingPreflight(e).length>0){let[c,f]=a(),m=()=>[c,f,n];this.uploadFiles(e,i,c,l,w=>{let _=this.extractMeta(e),S=Si(e,H({submitter:r},_));this.pushWithReply(m,"event",{type:"form",event:s,value:S,cid:l},o)})}else if(!(e.hasAttribute(ae)&&e.classList.contains("phx-submit-loading"))){let c=this.extractMeta(e),f=Si(e,H({submitter:r},c));this.pushWithReply(a,"event",{type:"form",event:s,value:f,cid:l},o)}}uploadFiles(e,i,s,r,n){let o=this.joinCount,a=J.activeFileInputs(e),l=a.length;a.forEach(c=>{let f=new J(c,this,()=>{l--,l===0&&n()}),m=f.entries().map(_=>_.toPreflightPayload());if(m.length===0){l--;return}let w={ref:c.getAttribute(me),entries:m,cid:this.targetComponentID(c.form,i)};this.log("upload",()=>["sending preflight request",w]),this.pushWithReply(null,"allow_upload",w,_=>{if(this.log("upload",()=>["got preflight response",_]),_.error){this.undoRefs(s);let[S,E]=_.error;this.log("upload",()=>[`error for entry ${S}`,E])}else{let S=E=>{this.channel.onError(()=>{this.joinCount===o&&E()})};f.initAdapterUpload(_,S,this.liveSocket)}})})}dispatchUploads(e,i,s){let r=this.targetCtxElement(e)||this.el,n=p.findUploadInputs(r).filter(o=>o.name===i);n.length===0?se(`no live file inputs found matching the name "${i}"`):n.length>1?se(`duplicate live file inputs found matching the name "${i}"`):p.dispatchEvent(n[0],ti,{detail:{files:s}})}targetCtxElement(e){if(ve(e)){let[i]=p.findComponentNodeList(this.el,e);return i}else return e||null}pushFormRecovery(e,i,s){this.liveSocket.withinOwners(e,(r,n)=>{let o=this.binding("change"),a=Array.from(e.elements).filter(f=>p.isFormInput(f)&&f.name&&!f.hasAttribute(o));if(a.length===0)return;a.forEach(f=>f.hasAttribute(me)&&J.clearFiles(f));let l=a.find(f=>f.type!=="hidden")||a[0],c=e.getAttribute(this.binding(fs))||e.getAttribute(this.binding("change"));te.exec("change",c,r,l,["push",{_target:l.name,newCid:i,callback:s}])})}pushLinkPatch(e,i,s){let r=this.liveSocket.setPendingLink(e),n=i?()=>this.putRef([i],"click"):null,o=()=>this.liveSocket.redirect(window.location.href),a=e.startsWith("/")?`${location.protocol}//${location.host}${e}`:e,l=this.pushWithReply(n,"live_patch",{url:a},c=>{this.liveSocket.requestDOMUpdate(()=>{c.link_redirect?this.liveSocket.replaceMain(e,null,s,r):(this.liveSocket.commitPendingLink(r)&&(this.href=e),this.applyPendingUpdates(),s&&s(r))})});l?l.receive("timeout",o):o()}formsForRecovery(e){if(this.joinCount===0)return[];let i=this.binding("change"),s=document.createElement("template");return s.innerHTML=e,p.all(this.el,`form[${i}]`).filter(r=>r.id&&this.ownsElement(r)).filter(r=>r.elements.length>0).filter(r=>r.getAttribute(this.binding(fs))!=="ignore").map(r=>{let n=CSS.escape(r.getAttribute(i)),o=s.content.querySelector(`form[id="${r.id}"][${i}="${n}"]`);return o?[r,o,this.targetComponentID(o)]:[r,r,this.targetComponentID(r)]}).filter(([r,n,o])=>n)}maybePushComponentsDestroyed(e){let i=e.filter(s=>p.findComponentNodeList(this.el,s).length===0);i.length>0&&(i.forEach(s=>this.rendered.resetRender(s)),this.pushWithReply(null,"cids_will_destroy",{cids:i},()=>{let s=i.filter(r=>p.findComponentNodeList(this.el,r).length===0);s.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:s},r=>{this.rendered.pruneCIDs(r.cids)})}))}ownsElement(e){let i=e.closest(He);return e.getAttribute(Ke)===this.id||i&&i.id===this.id||!i&&this.isDead}submitForm(e,i,s,r,n={}){p.putPrivate(e,ct,!0);let o=this.liveSocket.binding(Ge),a=this.liveSocket.binding(Ye),l=Array.from(e.elements);l.forEach(c=>p.putPrivate(c,ct,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,i,s,r,n,()=>{l.forEach(c=>p.showError(c,o,a)),this.liveSocket.restorePreviouslyActiveFocus()})}binding(e){return this.liveSocket.binding(e)}};var $t=class{constructor(e,i,s={}){if(this.unloaded=!1,!i||i.constructor.name==="Object")throw new Error(` a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example: import {Socket} from "phoenix" import {LiveSocket} from "phoenix_live_view" let liveSocket = new LiveSocket("/live", Socket, {...}) `);this.socket=new i(e,s),this.bindingPrefix=s.bindingPrefix||Rr,this.opts=s,this.params=gi(s.params||{}),this.viewLogger=s.viewLogger,this.metadataCallbacks=s.metadata||{},this.defaults=Object.assign(mt(Ir),s.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=mt(window.location),this.hooks=s.hooks||{},this.uploaders=s.uploaders||{},this.loaderTimeout=s.loaderTimeout||kr,this.reloadWithJitterTimer=null,this.maxReloads=s.maxReloads||gr,this.reloadJitterMin=s.reloadJitterMin||_r,this.reloadJitterMax=s.reloadJitterMax||vr,this.failsafeJitter=s.failsafeJitter||br,this.localStorage=s.localStorage||window.localStorage,this.sessionStorage=s.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:gi(),onBeforeElUpdated:gi()},s.dom||{}),this.doofinderMount=s.doofinderMount,this.connectCallback=s.connectCallback||(()=>{}),this.disconnectCallback=s.disconnectCallback||(()=>{}),this.unbindFunctions=[],this.transitions=new Wr,window.addEventListener("pagehide",r=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()}),this.socket.onOpen(()=>{this.connectCallback()})}isProfileEnabled(){return this.sessionStorage.getItem(ui)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(Ht)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(Ht)==="false"}enableDebug(){this.sessionStorage.setItem(Ht,"true")}enableProfiling(){this.sessionStorage.setItem(ui,"true")}disableDebug(){this.sessionStorage.setItem(Ht,"false")}disableProfiling(){this.sessionStorage.removeItem(ui)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(fi,e)}disableLatencySim(){this.sessionStorage.removeItem(fi)}getLatencySim(){let e=this.sessionStorage.getItem(fi);return e?parseInt(e):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug(),this.joinRootViews()&&(this.bindTopLevelEvents(),this.socket.connect())}disconnect(e){clearTimeout(this.reloadWithJitterTimer),this.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,i,s=null){this.owner(e,r=>te.exec(s,i,r,e))}execJSHookPush(e,i,s,r){this.withinOwners(e,n=>{te.exec("hook",i,n,e,["push",{data:s,callback:r}])})}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,i){this.domCallbacks[e](...i)}time(e,i){if(!this.isProfileEnabled()||!console.time)return i();console.time(e);let s=i();return console.timeEnd(e),s}log(e,i,s){if(this.viewLogger){let[r,n]=s();this.viewLogger(e,i,r,n)}else if(this.isDebugEnabled()){let[r,n]=s();Hr(e,i,r,n)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,i,s=function(){}){this.transitions.addTransition(e,i,s)}onChannel(e,i,s){e.on(i,r=>{let n=this.getLatencySim();n?setTimeout(()=>s(r),n):s(r)})}wrapPush(e,i,s){let r=this.getLatencySim(),n=e.joinCount;if(!r)return this.isConnected()&&i.timeout?s().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"])})}):s();let o={receives:[],receive(a,l){this.receives.push([a,l])}};return setTimeout(()=>{e.isDestroyed()||o.receives.reduce((a,[l,c])=>a.receive(l,c),s())},r),o}reloadWithJitter(e,i){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let s=this.reloadJitterMin,r=this.reloadJitterMax,n=Math.floor(Math.random()*(r-s+1))+s;Re.updateLocal(this.localStorage,window.location.pathname,Zt,0,a=>a+1)>this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{this.disconnectCallback()},n)}getHookCallbacks(e){return e&&e.startsWith("Phoenix.")?Ur[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,i){return this.socket.channel(e,i)}joinRootViews(){if(this.doofinderMount){let e=this.newRootView(this.doofinderMount);return e.setHref(this.getHref()),e.join(),this.main=e,!0}else return!1}redirect(e,i){this.disconnect(this.disconnectCallback),Re.redirect(e,i)}replaceMain(e,i,s=null,r=this.setPendingLink(e)){let n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=p.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(o,i,n),this.main.setRedirect(e),this.transitionRemoves(null,!0),this.main.join((a,l)=>{a===1&&this.commitPendingLink(r)&&this.requestDOMUpdate(()=>{p.findPhxSticky(document).forEach(c=>o.appendChild(c)),this.outgoingMainEl.replaceWith(o),this.outgoingMainEl=null,s&&s(r),l()})})}transitionRemoves(e,i){let s=this.binding("remove");if(e=e||p.all(document,`[${s}]`),i){let r=p.findPhxSticky(document)||[];e=e.filter(n=>!p.isChildOfAny(n,r))}e.forEach(r=>{this.execJS(r,r.getAttribute(s),"remove")})}isPhxView(e){return e.getAttribute&&e.getAttribute(_e)!==null}newRootView(e,i,s){let r=new _t(e,this,null,i,s);return this.roots[r.id]=r,r}owner(e,i){let s=Te(e.closest(He),r=>this.getViewByEl(r))||this.main;s&&i(s)}withinOwners(e,i){this.owner(e,s=>i(s,e))}getViewByEl(e){let i=e.getAttribute(Pe);return Te(this.getRootById(i),s=>s.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 i=this.getRootById(e.getAttribute(Pe));i&&i.id===e.id?(i.destroy(),delete this.roots[i.id]):i&&i.destroyDescendent(e.id)}setActiveElement(e){if(this.activeElement===e)return;this.activeElement=e;let i=()=>{e===this.activeElement&&(this.activeElement=null),e.removeEventListener("mouseup",this),e.removeEventListener("touchend",this)};e.addEventListener("mouseup",i),e.addEventListener("touchend",i)}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(i=>{if(i&&i.code===1e3&&this.main)return this.reloadWithJitter(this.main)}),this.unbindFunctions.push((()=>{let i=function(){};return document.body.addEventListener("click",i),function(){document.body.removeEventListener("click",i)}})()),window.addEventListener("pageshow",i=>{i.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),this.bindClicks(),e||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(i,s,r,n,o,a)=>{let l=n.getAttribute(this.binding(Cr)),c=i.key&&i.key.toLowerCase();if(l&&l.toLowerCase()!==c)return;let f=H({key:i.key},this.eventMeta(s,i,n));te.exec(s,o,r,n,["push",{data:f}])}),this.bind({blur:"focusout",focus:"focusin"},(i,s,r,n,o,a)=>{if(!a){let l=H({key:i.key},this.eventMeta(s,i,n));te.exec(s,o,r,n,["push",{data:l}])}}),this.bind({blur:"blur",focus:"focus"},(i,s,r,n,o,a)=>{if(a==="window"){let l=this.eventMeta(s,i,n);te.exec(s,o,r,n,["push",{data:l}])}}),this.unbindFunctions.push((()=>{let i=s=>s.preventDefault();return this.doofinderMount.addEventListener("dragover",i),()=>this.doofinderMount.removeEventListener("dragover",i)})()),this.unbindFunctions.push((()=>{let i=s=>{s.preventDefault();let r=Te(gt(s.target,this.binding(as)),a=>a.getAttribute(this.binding(as))),n=r&&document.getElementById(r),o=Array.from(s.dataTransfer.files||[]);!n||n.disabled||o.length===0||!(n.files instanceof FileList)||(J.trackFiles(n,o,s.dataTransfer),n.dispatchEvent(new Event("input",{bubbles:!0})))};return this.doofinderMount.addEventListener("drop",i),()=>this.doofinderMount.removeEventListener("drop",i)})()),this.on(ti,i=>{let s=i.target;if(!p.isUploadInput(s))return;let r=Array.from(i.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);J.trackFiles(s,r),s.dispatchEvent(new Event("input",{bubbles:!0}))},this.doofinderMount))}unbindTopLevelEvents(){this.unbindFunctions.forEach(e=>e()),this.unbindFunctions=[]}eventMeta(e,i,s){let r=this.metadataCallbacks[e];return r?r(i,s):{}}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,i){for(let s in e){let r=e[s];this.on(r,n=>{let o=this.binding(s),a=this.binding(`window-${s}`),l=n.target.getAttribute&&n.target.getAttribute(o);l?this.debounce(n.target,n,r,()=>{this.withinOwners(n.target,c=>{i(n,s,c,n.target,l,null)})}):p.all(document,`[${a}]`,c=>{let f=c.getAttribute(a);this.debounce(c,n,r,()=>{this.withinOwners(c,m=>{i(n,s,m,c,f,"window")})})})},this.doofinderMount)}}bindClicks(){let e=i=>{this.clickStartedAtTarget=i.target};this.doofinderMount.addEventListener("click",e),this.unbindFunctions.push(()=>this.doofinderMount.removeEventListener("click",e)),this.bindClick("click","click",!1),this.bindClick("mousedown","capture-click",!0)}bindClick(e,i,s){let r=this.binding(i),n=o=>{if(!this.isConnected())return;let a=null;if(s)a=o.target.matches(`[${r}]`)?o.target:o.target.querySelector(`[${r}]`);else{o.detail===0&&(this.clickStartedAtTarget=o.target);let c=this.clickStartedAtTarget||o.target;a=gt(c,r),this.dispatchClickAway(o,c),this.clickStartedAtTarget=null}let l=a&&a.getAttribute(r);if(!l){!s&&p.isNewPageClick(o,window.location)&&this.unload();return}a.getAttribute("href")==="#"&&o.preventDefault(),!a.hasAttribute(ae)&&(a.disabled||this.debounce(a,o,"click",()=>{this.withinOwners(a,c=>{te.exec("click",l,c,a,["push",{data:this.eventMeta("click",o,a)}])})}))};this.doofinderMount.addEventListener(e,n,s),this.unbindFunctions.push(()=>this.doofinderMount.removeEventListener(e,n,s))}dispatchClickAway(e,i){let s=this.binding("click-away");p.all(document,`[${s}]`,r=>{r.isSameNode(i)||r.contains(i)||this.withinOwners(r,n=>{let o=r.getAttribute(s);te.isVisible(r)&&te.isInViewport(r)&&te.exec("click",o,n,r,["push",{data:this.eventMeta("click",e,e.target)}])})})}maybeScroll(e){typeof e=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,e)})}dispatchEvent(e,i={}){p.dispatchEvent(this.doofinderMount,`${B}:${e}`,{detail:i})}dispatchEvents(e){e.forEach(([i,s])=>this.dispatchEvent(i,s))}withPageLoading(e,i){p.dispatchEvent(this.doofinderMount,`${B}:page-loading-start`,{detail:e});let s=()=>p.dispatchEvent(this.doofinderMount,`${B}:page-loading-stop`,{detail:e});return i?i(s):s}pushHistoryPatch(e,i,s){if(!this.isConnected()||!this.main.isMain())return Re.redirect(e);this.withPageLoading({to:e,kind:"patch"},r=>{this.main.pushLinkPatch(e,s,n=>{this.historyPatch(e,i,n),r()})})}historyPatch(e,i,s=this.setPendingLink(e)){!this.commitPendingLink(s)||(Re.pushState(i,{type:"patch",id:this.main.id},e),p.dispatchEvent(window,`${B}:navigate`,{detail:{patch:!0,href:e,pop:!1}}),this.registerNewLocation(window.location))}historyRedirect(e,i,s){if(!this.isConnected()||!this.main.isMain())return Re.redirect(e,s);if(/^\/$|^\/[^\/]+.*$/.test(e)){let{protocol:n,host:o}=window.location;e=`${n}//${o}${e}`}let r=window.scrollY;this.withPageLoading({to:e,kind:"redirect"},n=>{this.replaceMain(e,s,o=>{o===this.linkRef&&(Re.pushState(i,{type:"redirect",id:this.main.id,scroll:r},e),p.dispatchEvent(window,`${B}:navigate`,{detail:{href:e,patch:!1,pop:!1}}),this.registerNewLocation(window.location)),n()})})}replaceRootHistory(){Re.pushState("replace",{root:!0,type:"patch",id:this.main.id})}registerNewLocation(e){let{pathname:i,search:s}=this.currentLocation;return i+s===e.pathname+e.search?!1:(this.currentLocation=mt(e),!0)}bindForms(){let e=0,i=!1;this.on("submit",s=>{let r=s.target.getAttribute(this.binding("submit")),n=s.target.getAttribute(this.binding("change"));!i&&n&&!r&&(i=!0,s.preventDefault(),s.stopPropagation(),this.withinOwners(s.target,o=>{o.disableForm(s.target),window.requestAnimationFrame(()=>{p.isUnloadableFormSubmit(s)&&this.unload(),s.target.submit()})}))},this.doofinderMount),this.on("submit",s=>{let r=s.target.getAttribute(this.binding("submit"));if(!r){p.isUnloadableFormSubmit(s)&&this.unload();return}s.preventDefault(),s.stopPropagation(),s.target.disabled=!0,this.withinOwners(s.target,n=>{te.exec("submit",r,n,s.target,["push",{submitter:s.submitter}])})},this.doofinderMount);for(let s of["change","input"])this.on(s,r=>{r.stopPropagation();let n=this.binding("change"),o=r.target,a=o.getAttribute(n),l=o.form&&o.form.getAttribute(n),c=a||l;if(!c||o.type==="number"&&o.validity&&o.validity.badInput)return;let f=a?o:o.form,m=e;e++;let{at:w,type:_}=p.private(o,"prev-iteration")||{};w===m-1&&s==="change"&&_==="input"||(p.putPrivate(o,"prev-iteration",{at:m,type:s}),this.debounce(o,r,s,()=>{this.withinOwners(f,S=>{p.putPrivate(o,It,!0),p.isTextualInput(o)||this.setActiveElement(o),te.exec("change",c,S,o,["push",{_target:r.target.name,dispatcher:f}])})}))},this.doofinderMount);this.on("reset",s=>{let r=s.target;p.resetForm(r,this.binding(Ge),this.binding(Ye));let n=Array.from(r.elements).find(o=>o.type==="reset");n&&window.requestAnimationFrame(()=>{n.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(e,i,s,r){if(s==="blur"||s==="focusout")return r();let n=this.binding(Tr),o=this.binding(Ar),a=this.defaults.debounce.toString(),l=this.defaults.throttle.toString();this.withinOwners(e,c=>{let f=()=>!c.isDestroyed()&&document.body.contains(e);p.debounce(e,i,n,a,o,l,f,()=>{r()})})}silenceEvents(e){this.silenced=!0,e(),this.silenced=!1}on(e,i,s=window){let r=n=>{this.silenced||i(n)};s.addEventListener(e,r),this.unbindFunctions.push(function(){s.removeEventListener(e,r)})}},Wr=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,i,s){i();let r=setTimeout(()=>{this.transitions.delete(r),s(),this.flushPendingOps()},e);this.transitions.add(r)}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())}};var ws=class{constructor(e){let{url:i,mount:s,hooks:r,params:n,mainHook:o,appName:a,disconnectCallback:l}=e,c={hooks:r,doofinderMount:s,params:n,metadata:{click:function(f){return{keys:{altKey:f.altKey,shiftKey:f.shiftKey,ctrlKey:f.ctrlKey,metaKey:f.metaKey}}}},disconnectCallback:l};this.__mainHook=o,this.__socket=new $t(i,os,c),this.__appName=a}get connected(){return this.__socket.isConnected()}enableDebug(){this.__socket.enableDebug()}disableDebug(){this.__socket.disableDebug()}setPreventReconnect(e=!1){var i;this.__socket.preventReconnect=e,e&&((i=this.__socket.reconnectTimer)==null||i.reset())}getHooksByName(e){if(this.connected){let i=this.__socket.doofinderMount,s=this.__socket.getViewByEl(i);return Array.from(i.querySelectorAll(`[dfd-hook="${e}"]`)).map(n=>s.getHook(n))}else return[]}connect(e){this.connected||this.__socket.connect(),Doofinder.Session.setLive(this.__appName),e()}disconnect(e){this.__socket.unbindTopLevelEvents(),this.__socket.destroyAllViews(),this.__socket.disconnect(e),this.__socket=null}pushEvent(e,i={},s=void 0){let[r]=this.getHooksByName(this.__mainHook);if(!r)throw new Error(`${this.__mainHook} hook is not ready!`);r.pushEvent(e,i,s)}};var zo="df-cookies-allowed",Ko=window.localStorage;function zr(){return JSON.parse(Ko.getItem(zo)||"false")}var vt=class{constructor(e,i){this._bucket=e,this._store=i||window.localStorage}get data(){return JSON.parse(this._store.getItem(this._bucket))||{}}set data(e){!zr()||this._store.setItem(this._bucket,JSON.stringify(e))}getItem(e){return this.data[e]}setItem(e,i){let s=this.data;s[e]=i,this.data=s}removeItem(e){let i=this.data;delete i[e],this.data=i}clear(){this.data={}}destroy(){this._store.removeItem(this._bucket)}popItem(e){let i=this.data,s=i[e];return delete i[e],this.data=i,s}};var Ts="dfd-animate",As="dfd-fixed-layout",Me="hidden",Ei="ai_fullscreen",wi="floating",Ti="fullscreen",tt="static";function Ai(t){let e=["left","top","right","bottom","width","height","scrollLeft","scrollTop","scrollWidth","scrollHeight"],i=e.reduce((r,n)=>(r[n]=0,r),{}),s=t;if(s===window)i=Ce(H({},i),{width:s.outerWidth,height:s.outerHeight,clientWidth:s.innerWidth,clientHeight:s.innerHeight,scrollLeft:s.scrollX,scrollTop:s.scrollY,scrollWidth:document.scrollWidth,scrollHeight:document.scrollHeight});else{if(s===document)s=document.documentElement,i=Ce(H({},i),{width:s.offsetWidth,height:s.offsetHeight});else if(s.getBoundingClientRect){let r=s.getBoundingClientRect();i=e.reduce((n,o)=>(n[o]=r[o],n),{})}i=Ce(H({},i),{clientWidth:s.clientWidth,clientHeight:s.clientHeight,scrollLeft:s.scrollLeft,scrollTop:s.scrollTop,scrollWidth:s.scrollWidth,scrollHeight:s.scrollHeight})}return i}function Kr(t){let e=t;for(;e&&getComputedStyle(e).position!=="fixed";)e=e.offsetParent;return!!e}"use strict";var Cs=class{constructor(e,i={}){this.options=H({align:i.align,offsetX:0,offsetY:4,marginY:20,marginX:20,fillViewPortWidth:768},i),this.element=e}__origin__(e){let i=Ai(e),s=Ai(document),r=s.width<=this.options.fillViewPortWidth,n={width:i.width,top:i.top+i.height,left:i.left,fixed:Kr(e),align:function(){let o=Math.abs(i.left)*100/s.width,a=Math.abs(s.clientWidth-i.right)*100/s.width;switch(!0){case r:case Math.abs(o-a)<=15:return"center";case on-a&&(this.element.style.height=`${n-a}px`):this.element.style.height=`${n-a}px`}destroy(){["position","top","left","right","height","maxWidth","marginLeft"].forEach(e=>this.element.style[e]=null),this.options=null,this.element=null}};function Ci(t,e=66,i=!1){let s;return function(...r){s?Date.now()-s>=e?(t(...r),s=Date.now()):i&&console.log("throttle: discard execution"):(t(...r),s=Date.now())}}var it=class{constructor(e){this.mount=e,this._positionReference=null}__animate__(){return new Promise(e=>{setTimeout(()=>{this.mount.classList.add(Ts),e()},10)})}get positionReference(){return this._positionReference}show(){return L(this,null,function*(){let e=this.hidden();return e&&(this.mount.removeAttribute(Me),yield this.__animate__()),e})}hide(){return L(this,null,function*(){let e=!this.hidden();return e&&(this.mount.setAttribute(Me,""),this.mount.classList.remove(Ts),this.mount.innerHTML=""),e})}updatePosition(e){return L(this,null,function*(){this._positionReference=e.positionReference})}destroy(){this.mount=void 0}hidden(){return this.mount.hasAttribute(Me)}};var xs=class extends it{constructor(e,i={}){super(e);this.handleWindowChange=Ci(this.handleWindowChange.bind(this)),this._position=new Cs(this.mount,i)}__addListeners__(){window.addEventListener("resize",this.handleWindowChange,{passive:!0})}__removeListeners__(){window.removeEventListener("resize",this.handleWindowChange)}get position(){return this._position}handleWindowChange(){this._position.update(this._positionReference)}show(){var e=i=>super[i];return L(this,null,function*(){let s=this.hidden();return s&&(this.mount.style.opacity="0",this.mount.removeAttribute(Me)),this._position.update(this._positionReference),s&&(this.mount.setAttribute(Me,""),this.mount.style.opacity=null,yield e("show").call(this),this.__addListeners__()),s})}hide(){var e=i=>super[i];return L(this,null,function*(){let s=!this.hidden();return s&&(this.__removeListeners__(),yield e("hide").call(this)),s})}updatePosition(e){var i=s=>super[s];return L(this,null,function*(){i("updatePosition").call(this,e),setTimeout(()=>{this._position.update(this._positionReference)},100)})}destroy(){this.__removeListeners__(),this._position.destroy(),this._position=null,super.destroy()}};var ks=class extends it{show(){var e=i=>super[i];return L(this,null,function*(){let s=this.hidden();return s&&(document.documentElement.classList.add(As),yield e("show").call(this)),s})}hide(){var e=i=>super[i];return L(this,null,function*(){let s=yield e("hide").call(this);return s&&document.documentElement.classList.remove(As),s})}};function bt(t=8){let e="";for(;e.length{let n=0,o=null,a=e.interval||Yo,l=e.times||Go;o=setInterval(function(){n++this.off(e,i)}once(e,i){if(this._checkReady())return this.el.addEventListener(e,i,{once:!0,passive:!0}),()=>this.off(e,i)}off(e,i){this._checkReady()&&this.el.removeEventListener(e,i)}emit(e,i){if(this._checkReady()){let s=new CustomEvent(e,{detail:i,bubbles:!1,cancelable:!1,composed:!1});this.el.dispatchEvent(s)}}teardown(){this._checkReady()&&(this.el=this.el.remove())}_checkReady(){if(this.el)return!0;throw new Error("tried to access a dead event bus!")}};var Ds="__DF_DEBUG_MODE__",Gr="true",Li=window.sessionStorage;function Yr(){Li.setItem(Ds,Gr)}function Qr(){Li.removeItem(Ds)}function Zr(){return Li.getItem(Ds)===Gr}function Os(t){return Li.getItem(t)||window[t]}function C(...t){Zr()&&console.log("[doofinder]",...t)}var en=function(t){let e=t.slice(0,4);return RegExp(`#${e}/(brand-categories|classic|classic-initial|embedded|fullscreen|fullscreen-brand-categories|fullscreen-initial|mobile|mobile-brand-categories|mobile-initial)/`)},tn=function(t){let e=t.slice(0,4);return RegExp(`#${e}/(category-pages|mobile-category-pages)/`)};"use strict";var Ne=window.history,Ii=class{constructor({installationId:e,autoload:i,urlHash:s,layerType:r}){this._installationId=e,this._layerType=r,this._autoload=i?Object.freeze(i):null,this._urlHash=s,this._storage=new vt(`${e}.data`,window.sessionStorage),this.__initialSetup__()}get hasAutoloadQueryParam(){return this.__getQueryFromAutoload__()!==null}get isTransitory(){return this._isTransitory}get query(){return this.__getQuery__()}get startPage(){var e;return(e=this._startPage)!=null?e:1}get targetItemId(){return this._targetItemId}get value(){return this._value}set targetItemId(e){this._targetItemId=e}saveTransitory(e){if(!this.__valid__(this._value)){C(`[state] [${this._layerType}] saveTransitory: not valid for `,this._value);return}C(`[state] [${this._layerType}] saveTransitory:`,this._value),this._storage.setItem(this.__getStateKey__(),{value:this.__simplify__(this._value),location:e})}update(e,i,s){if(!this.__hasChanged__(e,i,s))return C(`[state] [${this._layerType}] update not performed, the state has not changed.`,e,i,s),!1;this.__valid__(e)&&(C(`[state] [${this._layerType}] new state value: `,e),this._value=e),this._targetItemId=i,this._isTransitory=s;let r=window.location.origin+window.location.pathname+window.location.search;this._urlHash&&(r=r+this._value),C(`[state] [${this._layerType}] replaceState:`,r),Ne.replaceState(this.__getNewStateObject__(),"",r)}__hasChanged__(e,i,s){return e!=this._value||i!=this._targetItemId||s!=this._isTransitory}__initialSetup__(){let e=this.__fromStorage__(),i=this.__fromHistory__()||e||this.__fromHash__()||this.__fromAutoload__()||"";i=i.match("^#([A-Za-z0-9-]+)/(embedded|classic)/$")?"":i,this._value=i,this._targetItemId=this.__getTargetItem__(),this._isTransitory=this.__isTransitory__(!!e),this._startPage=this.__getPage__(),e&&Ne.replaceState(this.__getNewStateObject__(),"",window.location.href)}__fromAutoload__(){if(!this._autoload)return C(`[state] [${this._layerType}] __fromAutoload__ with autoload false - state:`,null),null;let e=this.__getQueryFromAutoload__(),i=e!=null?`#/${this._autoload.screen}/q=${e.trim()}`:null;return C(`[state] [${this._layerType}] __fromAutoload__ (query) state:`,i),i}__fromHash__(){let e=this.__validHash__(window.location.hash)?`#${window.location.hash.split("#",2)[1]}`:null;return C(`[state] [${this._layerType}] __fromHash__ state:`,e),e}__fromHistory__(){let e=null;return this.__validDoofinderStateInHistory__()&&(e=Ne.state[this.__getStateKey__()].value),C(`[state] [${this._layerType}] __fromHistory__ state:`,e),e}__fromStorage__(){let e=this._storage.popItem(this.__getStateKey__());return!!e&&!window.location.href.includes(e.location)?(C(`[state] [${this._layerType}] __fromStorage__ discarded as it is from diferent location:`,e),null):(C(`[state] [${this._layerType}] __fromStorage__ state:`,e),!!e&&e.value)}__getNewStateObject__(){let e={[this.__getStateKey__()]:{value:this._value,transitory:this._isTransitory,targetItemId:this._targetItemId}};return C(`[state] [${this._layerType}] __getNewStateObject__:`,e),this.__validHistoryState__()?H(H({},Ne.state),e):e}__getQuery__(){if(this._value){let e=this._value.split("/"),i=e[e.length-1];return Object.fromEntries(new URLSearchParams(i)).q}return""}__getPage__(){if(!this._value)return 1;let e=this._value.split("/"),i=e[e.length-1],{p:s}=Object.fromEntries(new URLSearchParams(i));return parseInt(s,10)||1}__getQueryFromAutoload__(){return this._autoload?new URLSearchParams(window.location.search).get(this._autoload.param):null}__getTargetItem__(){let e=null;return this.__validDoofinderStateInHistory__()&&(e=Ne.state[this.__getStateKey__()].targetItemId),C(`[state] [${this._layerType}] __getTargetItem__:`,e),e}__getStateKey__(){return this._layerType=="category_pages"?Ii.CP_STATE_KEY:Ii.STATE_KEY}__isTransitory__(e){let i=e;return this.__validDoofinderStateInHistory__()&&(i=Ne.state[this.__getStateKey__()].transitory),C(`[state] [${this._layerType}] __isTransitory__:`,i),i}__simplify__(e){var o;let s=new URL(window.location.origin+window.location.pathname+window.location.search+e).hash.split("/"),r=(o=s.pop())!=null?o:"",n=Object.fromEntries(r.split("&").map(a=>a.split("=")));return(n==null?void 0:n.q)?`${s.join("/")}/m=${n.m}&q=${n.q}`:""}__valid__(e){return this.__validHash__(e)||e===""}__validHistoryState__(){return typeof Ne.state=="object"&&Ne.state!==null}__validDoofinderStateInHistory__(){return this.__validHistoryState__()&&Ne.state[this.__getStateKey__()]!=null}__validHash__(e){let i=this._layerType!=="category_pages"?en(this._installationId):tn(this._installationId);return typeof e=="string"&&(i.test(e)||e.startsWith(`#/${this._installationId}/`))}},st=Ii;ss(st,"STATE_KEY","dfState"),ss(st,"CP_STATE_KEY","dfCpState");var Hs="df:trigger:click",Ut="df:trigger:focus",Bt="df:trigger:input",Ms="df:trigger:submit";var rt=1;"use strict";var Zo="[dfd-carousel-btn-left]",ea="[dfd-carousel-btn-right]",sn="[dfd-carousel-content]",Di="ltr",rn={mounted(){this.btnLeftEl=this.el.querySelector(Zo),this.btnRightEl=this.el.querySelector(ea),this.contentEl=this.el.querySelector(sn),getComputedStyle(this.contentEl).direction==="rtl"&&(Di="rtl"),this.getVisibleChildren=()=>{let t=this.contentEl.getBoundingClientRect();return Array.from(this.contentEl.children).filter(e=>{let i=e.getBoundingClientRect();return t.left<=i.left&&t.right>=i.right})},this.nextPage=()=>{let t=this.getVisibleChildren();if(t.length<=0)return;let e=t.slice(-1).pop(),i=e.nextElementSibling;if(!i)return;let s=this.contentEl.getBoundingClientRect(),r=e.getBoundingClientRect(),n=i.getBoundingClientRect(),o=r.width,a=i?n.x-r.x-r.width:0,l;Di==="ltr"?l=this.contentEl.scrollLeft+(r.x-s.x):l=this.contentEl.scrollLeft-(r.x+s.x),this.contentEl.scroll({left:l+o+a/2,behavior:"smooth"})},this.previousPage=()=>{let t=this.getVisibleChildren();if(t.length<=0)return;let e=t[0],i=e.previousElementSibling;if(!i)return;let s=this.contentEl.getBoundingClientRect(),r=e.getBoundingClientRect(),n=i.getBoundingClientRect(),o=n.width-(s.x-n.x),a=i?r.x-n.x-n.width:0,l;Di==="ltr"?l=this.contentEl.scrollLeft-s.width:l=this.contentEl.scrollLeft+s.width,this.contentEl.scroll({left:l+o+a/2,behavior:"smooth"})},this.btnLeftEl.addEventListener("click",this.previousPage),this.btnRightEl.addEventListener("click",this.nextPage),this.tag.dispatch("doofinder.carousel.load")},updated(){this.contentEl=this.el.querySelector(sn),getComputedStyle(this.contentEl).direction==="rtl"&&(Di="rtl"),this.tag.dispatch("doofinder.carousel.update")},destroyed(){this.btnLeftEl.removeEventListener("click",this.previousPage),this.btnRightEl.removeEventListener("click",this.nextPage)}};var Oi=240;function ta(t){return!!t.type.match(/image\/.*/)}function nn(t){return L(this,null,function*(){if(!ta(t))throw"invalid image, can't search";let e=yield on(t),i=yield ia(e);return yield on(i)})}function on(t){return new Promise(function(e,i){let s=new FileReader;s.onload=function(){e(s.result)},s.onerror=function(){i(s.error)},s.readAsDataURL(t)})}function ia(t){return new Promise(function(e,i){let s=new Image;s.onload=function(){let r=document.createElement("canvas");r.width=Oi,r.height=Oi,r.getContext("2d").drawImage(s,0,0,Oi,Oi),r.toBlob(function(n){e(n)},"image/jpeg")},s.onerror=function(r){i("resize image error")},s.src=t})}var an={mounted(){this.search=t=>L(this,null,function*(){this.el.dataset.status="loading";try{let e=yield nn(t);this.pushEvent("search",{search:{image:e}},i=>{delete this.el.dataset.status})}catch(e){delete this.el.dataset.status}}),this.el.addEventListener("change",t=>this.search(t.target.files[0]))}};function Ns(t){setTimeout(()=>{t.focus()},0)}function ln(t){setTimeout(()=>{t.select()},0)}"use strict";var hn={mounted(){ln(this.el),this.search=t=>{let e=this.el.dataset.dfdAction||"search";this.pushEvent(e,{search:{query:t}})},this.handleEvent("set-input-value",t=>this.el.value=t.query),this.handleEvent("set-input-focus",()=>Ns(this.el)),this.handleEvent("unset-input-focus",()=>{setTimeout(()=>{var t;(t=document.activeElement)==null||t.blur()},0)}),this.el.addEventListener("input",()=>this.search(this.el.value)),this.el.addEventListener("keydown",t=>{let e=this.el.getAttribute("dfd-value-suggestion");t.key==="Tab"&&e&&e!==this.el.value&&(this.el.value=e,Ns(this.el),this.search(e))})}};"use strict";var cn={mounted(){let t={add_to_cart:e=>()=>{let i=JSON.parse(e.dataset.item);if(this.el.querySelectorAll("[data-role=variant_selected][value='']").length>0){let s=this.el.querySelector("[data-role=variant_selected][value='']").dataset.variant,r=this.evaluate_filters(s);this.pushEvent("get-variants",{item:i,filters:r},()=>{this.execJS(`[data-role=selector][data-variant="${s}"]`,"show")})}else if(this.el.dataset.quantity=="true"&&this.el.dataset.status=="initial"&&this.el.dataset.quantityPinned=="false"){this.execJS(null,"set_attr",["data-status","quantity"]),this.execJS("[data-role=decrease_quantity]","hide"),this.execJS("[data-role=delete_quantity]","show");let s=this.el.querySelector("[data-role=amount_selected]"),r=parseInt(s==null?void 0:s.getAttribute("min"),10)||1;this.update_quantity(s,r)}else{this.send(i),this.execJS(null,"set_attr",["data-status","initial"]);let s=this.el.querySelector("[data-role=amount_selected]"),r=parseInt(s==null?void 0:s.getAttribute("min"),10)||1;this.update_quantity(s,r),this.el.querySelector("[data-role=select_variant].selected")&&this.execJS("[data-role=select_variant].selected","remove_class","selected"),this.el.querySelectorAll("[data-role=open_selector]").forEach(o=>{this.execJS(`[data-role=open_selector][data-variant="${o.dataset.variant}"] input`,"set_attr",["value",o.dataset.variant])}),this.el.querySelectorAll("[data-role=open_selector]").forEach(o=>{this.execJS(`[data-role=variant_selected][data-variant="${o.dataset.variant}"]`,"remove_attr","data-index"),this.execJS(`[data-role=variant_selected][data-variant="${o.dataset.variant}"]`,"set_attr",["value",""])})}},increase_quantity:e=>()=>{var n;let i=this.el.querySelector("[data-role=amount_selected]"),s=parseInt((n=this.el.dataset)==null?void 0:n.quantityStep,10)||1,r=parseInt(i.value)+s;this.update_quantity(i,r)},decrease_quantity:e=>()=>{var o;let i=this.el.querySelector("[data-role=amount_selected]"),s=parseInt(i.value),r=parseInt((o=this.el.dataset)==null?void 0:o.quantityStep,10)||1,n=s>r?s-r:s;this.update_quantity(i,n)},delete_quantity:e=>()=>{this.execJS(null,"set_attr",["data-status","initial"])},open_selector:e=>()=>{if(!e.dataset.item){this.execJS(`[data-role=selector][data-variant="${e.dataset.variant}"]`,"show");return}let i=this.evaluate_filters(e.dataset.variant),s=JSON.parse(e.dataset.item);this.pushEvent("get-variants",{item:s,filters:i},()=>{this.execJS(`[data-role=selector][data-variant="${e.dataset.variant}"]`,"show")})},select_variant:e=>()=>{let i=e.closest("[data-role=selector]").dataset.variant;this.el.querySelector("[data-role=select_variant].selected")&&this.execJS("[data-role=select_variant].selected","remove_class","selected"),this.execJS(`[data-role=selector][data-variant="${i}"]`,"hide"),this.execJS(`[data-role=selector][data-variant="${i}"] [data-id="${e.dataset.id}"]`,"add_class","selected"),this.execJS(`[data-role=open_selector][data-variant="${i}] input`,"set_attr",["value",e.dataset.val]),this.execJS(`[data-role=variant_selected][data-variant="${i}"]`,"set_attr",["value",e.dataset.val]),this.restore_filters(i),this.execJS(null,"set_attr",["data-status","initial"])},close_selector:e=>()=>{let i=e.closest("[data-role=selector]").dataset.variant;this.execJS(`[data-role=selector][data-variant="${i}"]`,"hide"),this.execJS(null,"set_attr",["data-status","initial"])},send:e=>()=>{let i=Array.from(this.el.querySelectorAll("[data-role=variant_selected]")).map(n=>n.value),s=this.el.querySelector("[data-role=amount_selected]").value,r=JSON.parse(e.dataset.item);s&&!i.includes("")&&this.send(r)}};this.el.addEventListener("click",e=>{if(e.target.closest("[data-role]")){let i=Object.keys(t).find(s=>e.target.closest("[data-role]").dataset.role.match(s));i&&t[i](e.target.closest("[data-role]"))()}}),this.el.addEventListener("input",e=>{let i=e.target.closest("[data-role=amount_selected]");i&&i.value!=""&&this.update_quantity(i,parseInt(i.value))}),this.execJS=(e,i,s)=>{let r=this.el.querySelector(e);e==null&&(r=this.el),r!=null&&(i=="set_attr"?this.liveSocket.execJS(r,'[["'+i+'",{"to": null, "attr":["'+s[0]+'","'+s[1]+'"]}]]'):i=="remove_class"||i=="add_class"?this.liveSocket.execJS(r,'[["'+i+'",{"to": null, "time":200,"names":["'+s+'"],"transition":[[],[],[]]}]]'):this.liveSocket.execJS(r,'[["'+i+'",{"to": null}]]'))},this.update_quantity=(e,i)=>{this.execJS("[data-role=amount_selected]","set_attr",["value",parseInt(i)]),e.value=i,this.evaluate_quantity(i)},this.evaluate_quantity=e=>{var s;let i=parseInt((s=this.el.dataset)==null?void 0:s.quantityStep,10)||1;e<=i&&this.el.dataset.quantityPinned=="false"?(this.execJS("[data-role=decrease_quantity]","hide"),this.execJS("[data-role=delete_quantity]","show"),this.execJS("[data-role=increase_quantity]","show")):(this.execJS("[data-role=decrease_quantity]","show"),this.execJS("[data-role=delete_quantity]","hide"),this.execJS("[data-role=increase_quantity]","show"))},this.evaluate_quantity(1),this.evaluate_filters=e=>{let i=this.el.querySelector(`[data-role=variant_selected][data-variant="${e}"]`).dataset.index;return Array.from(this.el.querySelectorAll("[data-role=variant_selected][data-index]")).filter(s=>i==null||parseInt(s.dataset.index)({key:s.dataset.variant,value:s.value}))},this.restore_filters=e=>{let i=this.el.querySelector(`[data-role=variant_selected][data-variant="${e}"]`).dataset.index,s=this.el.querySelectorAll("[data-role=variant_selected][data-index]").length;i===void 0&&this.execJS(`[data-role=variant_selected][data-variant="${e}"]`,"set_attr",["data-index",s+1]);for(let r=parseInt(i)+1;r<=s;r++){let n=this.el.querySelector(`[data-role=variant_selected][data-index="${r}"]`).dataset.variant;this.execJS(`[data-role=variant_selected][data-variant="${n}"]`,"set_attr",["value",""]),this.execJS(`[data-role=variant_selected][data-variant="${n}]`,"remove_attr","data-index"),this.execJS(`[data-role=open_selector][data-variant="${n}"] input`,"set_attr",["value",n])}},this.send=e=>{let i=Array.from(this.el.querySelectorAll("[data-role=variant_selected][data-index]")).map(r=>({key:r.dataset.variant,value:r.value})),s=this.el.querySelector("[data-role=amount_selected]").value;this.start_add_to_cart(),this.pushEvent("add-to-cart-beta",{item:e,amount:s,filters:i},r=>{r.statusPromise=new De({resolveTimeout:3e3,rejectTimeout:5e3}),r.statusPromise.then(this.finish_add_to_cart,this.finish_add_to_cart),document.dispatchEvent(new CustomEvent("doofinder.cart.add",{detail:r}))})},this.start_add_to_cart=()=>{this.execJS(".dfd-cart-check-button[data-role=add_to_cart]","add_class","dfd-btn-loading"),this.execJS(".dfd-cart-add-button [data-role=add_to_cart]","add_class","dfd-btn-loading")},this.finish_add_to_cart=e=>{this.execJS(".dfd-cart-check-button[data-role=add_to_cart]","remove_class","dfd-btn-loading"),this.execJS(".dfd-cart-add-button [data-role=add_to_cart]","remove_class","dfd-btn-loading"),this.execJS(".dfd-cart-check-button[data-role=add_to_cart]","add_class","dfd-btn-done"),this.execJS(".dfd-cart-add-button [data-role=add_to_cart]","add_class","dfd-btn-done"),setTimeout(()=>{this.execJS(".dfd-cart-check-button[data-role=add_to_cart]","remove_class","dfd-btn-done"),this.execJS(".dfd-cart-add-button [data-role=add_to_cart]","remove_class","dfd-btn-done")},500),typeof e=="function"&&e()}}};function nt(t){return`${B}:${t}`}"use strict";var Hi="doofinder.cart.add.click",sa="doofinder.cart.add",Mi="doofinder.cart.hide.price",Ni="doofinder.cart.display.price",Fs="dfd-btn-loading",dn="dfd-btn-done",un="dfd-btn-error";function fn(t){t.addToCartResolveTimeout=3e3,t.addToCartRejectTimeout=5e3,t.addToCartButtonFeedback=function(i,s){let r=ra.bind(null,i,s),n=aa.bind(null,i,i.innerHTML),o=na.bind(null,i,n),a=oa.bind(null,i,n);r().then(o,a)},t.handleCartAddClick=i=>{let s=i.detail.target?document.getElementById(i.detail.target.id):i.target,r=new De({resolveTimeout:t.addToCartResolveTimeout,rejectTimeout:t.addToCartRejectTimeout});r.then(n=>{t.pushEvent("add-to-cart",{item:i.detail.item,dfid:i.detail.dfid},()=>{typeof n=="function"&&n()}),t.pushEvent("close-add-to-cart-button",{item:i.detail.item,dfid:i.detail.dfid})},n=>{typeof n=="function"&&n(),t.pushEvent("close-add-to-cart-button",{item:i.detail.item,dfid:i.detail.dfid})}),setTimeout(()=>t.tag.dispatch(sa,Ce(H({},i.detail.item),{statusPromise:r})),1e3),t.addToCartButtonFeedback&&t.addToCartButtonFeedback(s,r)},t.handleHidePrice=i=>{let s=i.detail.target?document.getElementById(i.detail.target.id):i.target;s.closest(".dfd-card-row").querySelector(".dfd-card-pricing").style.display="none"},t.handleDisplayPrice=i=>{let s=i.detail.target?document.getElementById(i.detail.target.id):i.target;s.closest(".dfd-card-row").querySelector(".dfd-card-pricing").style.display="flex"};let e=!!t.tag&&!!t.tag.dom?t.tag.dom.mount:t.tag.mount;e.addEventListener(Hi,t.handleCartAddClick),e.addEventListener(nt(Hi),t.handleCartAddClick),e.addEventListener(Mi,t.handleHidePrice),e.addEventListener(nt(Mi),t.handleHidePrice),e.addEventListener(Ni,t.handleDisplayPrice),e.addEventListener(nt(Ni),t.handleDisplayPrice)}function pn(t){let e=!!t.tag&&!!t.tag.dom?t.tag.dom.mount:t.tag.mount;e.removeEventListener(Hi,t.handleCartAddClick),e.removeEventListener(nt(Hi),t.handleCartAddClick),e.removeEventListener(Mi,t.handleHidePrice),e.removeEventListener(nt(Mi),t.handleHidePrice),e.removeEventListener(Ni,t.handleDisplayPrice),e.removeEventListener(nt(Ni),t.handleDisplayPrice)}function ra(t,e){return t.setAttribute("disabled",""),t.setAttribute("dfd-update","ignore"),t.innerHTML="",t.classList.add(Fs),e}function na(t,e){t.classList.remove(Fs),t.classList.add(dn),setTimeout(e,1e3)}function oa(t,e){t.classList.remove(Fs),t.classList.add(un),setTimeout(e,2e3)}function aa(t,e){t.classList.remove(dn),t.classList.remove(un),t.innerHTML=e,t.removeAttribute("dfd-update"),t.removeAttribute("disabled")}"use strict";function la(t){var s;let[e]=document.getElementsByClassName("dfd-searchbox-input");if(!e){this.tag.trigger.updateQuery((s=t==null?void 0:t.search)==null?void 0:s.query);return}let i=e.value.length;e.focus(),e.setSelectionRange(i,i),e.click()}var mn={mounted(){this.__focusInput=la.bind(this),this.close=()=>this.pushEvent("close-layer"),this.handleEvent("close",()=>{this.tag.disconnect()}),this.handleEvent("change-state",({state:t})=>{this.tag.updateState({value:t})}),this.handleEvent("disconnect",t=>{t.errors.forEach(e=>console.error("[Doofinder] error:",e)),Doofinder.Session.removeLive("layer"),this.tag.destroy()}),this.handleEvent("load",t=>{this.tag.onLoad(t),this.tag.dispatch("doofinder.layer.load",{display_type:t.display_type}),this.pushEvent("ready")}),this.handleEvent("click-suggestion",t=>L(this,null,function*(){this.__focusInput(t)})),this.handleEvent("set-trigger-focus",()=>L(this,null,function*(){this.tag.trigger.focus()})),this.handleEvent("search",t=>{this.tag.dispatch("doofinder.layer.search",t)}),this.handleEvent("item-click",t=>{this.tag.dispatch("doofinder.layer.itemClick",t)}),this.handleEvent("update-latest-searches",({entries:t})=>{this.tag.updateLatestSearches(t)}),this.el.addEventListener("contextmenu",t=>{let e=t.target.closest('[dfd-click="item-click"]');if(e){let i=e.getAttribute("dfd-value-link"),s=e.getAttribute("dfd-value-dfid");this.pushEvent("item-click",{link:i,dfid:s},()=>{this.debug(`item-click sent for ${s} to ${i}`)})}}),this.el.addEventListener("error",({target:t})=>{if(t.tagName!=="IMG")return;let e=t.closest('[data-dfd-role="card-thumbnail"]');setTimeout(()=>{e==null||e.parentElement.setAttribute("dfd-update","ignore"),e==null||e.classList.add("dfd-card-thumbnail-404")},1)},!0),this.applyOperationBySelector=function(t,e){if(t.startsWith("#")){let i=document.getElementById(t);e(i)}else this.el.querySelectorAll(t).forEach(i=>{e(i)})},this.handleEvent("dom:add-class",({target:t,newClass:e})=>{this.applyOperationBySelector(t.selector,i=>i==null?void 0:i.classList.add(e))}),this.handleEvent("dom:remove-class",({target:t,oldClass:e})=>{this.applyOperationBySelector(t.selector,i=>i==null?void 0:i.classList.remove(e))}),this.handleEvent("dom:add-attribute",({target:t,name:e,value:i})=>{this.applyOperationBySelector(t.selector,s=>s==null?void 0:s.setAttribute(e,i))}),this.handleEvent("dom:remove-attribute",({target:t,name:e})=>{this.applyOperationBySelector(t.selector,i=>i==null?void 0:i.removeAttribute(e))}),this.handleEvent("redirection:update",({redirection:t})=>{this.tag.trigger.redirection=t}),fn(this)},updated(){this.tag.dispatch("doofinder.layer.update")},destroyed(){pn(this)}},gn={mounted(){this.handleEvent("disconnect",t=>{t.errors.forEach(e=>console.error("[Doofinder] error:",e)),Doofinder.Session.removeLive("layer"),this.tag.destroy()})}};var _n=Object.freeze({Linear:function(t){return t},EaseInQuad:function(t){return t*t},EaseOutQuad:function(t){return t*(2-t)},EaseInOutQuad:function(t){return t<.5?2*t*t:-1+(4-2*t)*t},EaseInCubic:function(t){return t*t*t},EaseOutCubic:function(t){return--t*t*t+1},EaseInOutCubic:function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},EaseInQuart:function(t){return t*t*t*t},EaseOutQuart:function(t){return 1- --t*t*t*t},EaseInOutQuart:function(t){return t<.5?8*t*t*t*t:1-8*--t*t*t*t},EaseInQuint:function(t){return t*t*t*t*t},EaseOutQuint:function(t){return 1+--t*t*t*t*t},EaseInOutQuint:function(t){return t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t}});function vn(t,e,i,s,r=_n.EaseInQuint){let n=Date.now(),o=e[t];return new Promise((a,l)=>{function c(){let f=Date.now(),m=Math.min(1,(f-n)/s),w=r(m);e[t]=o+w*(i-o),m<1?requestAnimationFrame(c):a()}o===i?a():requestAnimationFrame(c)})}var bn=vn.bind(null,"scrollTop"),jc=vn.bind(null,"scrollLeft");function ha(t){let e=t.scrollHeight>t.clientHeight,s=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!s}function Fi(t){return!t||t===document.documentElement?document.documentElement:ha(t)?t:Fi(t.parentNode)}function yn(t,e){return typeof t!="undefined"?t:e}var Vt=class{constructor(e,i,s={}){let{threshold:r}=s;this.handleIntersection=this.handleIntersection.bind(this),this._callback=i,this._io=new IntersectionObserver(this.handleIntersection,{root:e,threshold:yn(r,0)})}observe(e){this._io.disconnect(),e&&this._io.observe(e),C("[ScrollObserver][observe]",e)}unobserve(){this._io.disconnect(),C("[ScrollObserver][unobserve]")}handleIntersection([e]){C("[ScrollObserver][intersection detected] target:",e.target),this._callback(e)}};var Sn='[data-dfd-role~="scroll-sentinel"]',En='[data-dfd-role~="scroll-top-sentinel"]',ca="div.dfd-card";function jt(t,e,i){i?t.scrollTop=e:bn(t,e,250)}function da(t){var s,r;let e=((s=document.querySelector(ca))==null?void 0:s.offsetHeight)||0,i=((r=document.querySelector(Sn))==null?void 0:r.offsetHeight)||0;return t.scrollHeight-i-e*2.6}var wn={mounted(){this.sentinel=()=>this.el.querySelector(Sn),this.scrollTopSentinel=()=>this.el.querySelector(En),this.scrollTarget=()=>this.el.dataset.dfdScrollTarget,this.refreshObservers=()=>{this.scrollObserver.observe(this.sentinel()),this.scrollTopObserver.observe(this.scrollTopSentinel())},this.changeBackToTopVisibility=t=>{this.pushEvent("change-back-to-top-visibility",{visible:t})},this.scrollObserver=new Vt(this.el,({target:t,isIntersecting:e})=>{if(!e)return;let i={index:t.dataset.index};this.debug('[push] "load-more", params:',i),this.pushEvent("load-more",i)}),this.scrollTopObserver=new Vt(this.el,({isIntersecting:t})=>{this.changeBackToTopVisibility(!t)}),this.handleEvent("search",t=>{this.debug('[handle] "search", params:',t);let{index:e,page:i}=t,s=this.sentinel();!ua(t.filter)&&i===1&&e===(s==null?void 0:s.dataset.index)&&(this.changeBackToTopVisibility(!1),jt(this.el,0,!0)),this.refreshObservers()}),this.handleEvent("back-to-top",({id:t,fast:e})=>{this.debug(`[handle] "back-to-top", id: ${t}, fast: ${e}`),this.scrollTarget()==="window"?window.scrollTo(0,0):(!t||t===this.el.id)&&jt(this.el,0,!!e)}),this.handleEvent("change-current-index",()=>{this.scrollObserver.observe(this.sentinel()),this.scrollTopObserver.observe(this.scrollTopSentinel()),jt(this.el,0,!0)}),this.scrollObserver.observe(this.sentinel()),this.scrollTopObserver.observe(this.scrollTopSentinel())},destroyed(){this.scrollObserver.unobserve(),this.scrollObserver=null,this.scrollTopObserver.unobserve(),this.scrollTopObserver=null}},$s={mounted(){this.hideVirtualKeyboard=Ci(()=>{let t=document.querySelector("input:focus");t?(this.debug("[hideVirtualKeyboard][blur] input:",t),t.blur()):this.debug("[hideVirtualKeyboard][noop]")},100),this.debug("[observe][touchstart] hideVirtualKeyboard()"),this.el.addEventListener("touchstart",this.hideVirtualKeyboard)},destroyed(){this.debug("[unobserve][touchstart] hideVirtualKeyboard()"),this.el.removeEventListener("touchstart",this.hideVirtualKeyboard)}},Us={mounted(){this.scrollTarget=()=>this.el.dataset.dfdScrollTarget,this.scrollTopSentinel=()=>this.el.querySelector(En),this.transientTargetCard=()=>this.el.querySelector(`[dfd-value-dfid="${this.tag.state.targetItemId}"]`),this.changeBackToTopVisibility=t=>{this.pushEvent("change-back-to-top-visibility",{visible:t})},this.scrollTopObserver=new Vt(null,({isIntersecting:t})=>{this.changeBackToTopVisibility(!t)}),this.scrollTopObserver.observe(this.scrollTopSentinel()),this.handleEvent("update-scroll",t=>{setTimeout((()=>{let e=this.transientTargetCard();this.debug('[handle] "update-scroll"',"params:",t,"card:",e),this.tag.targetItemId=null,e!==null?e.scrollIntoView({behavior:"smooth",block:"nearest"}):t.scroll_end&&jt(Fi(this.el),da(this.el),!1)}).bind(this),1e3)}),this.handleEvent("back-to-top",({id:t,fast:e})=>{this.debug(`[handle] "back-to-top", id: ${t}, fast: ${e}`),this.scrollTarget()==="window"?window.scrollTo(0,0):(!t||t===this.el.id)&&jt(Fi(this.el),0,e)})}};function ua(t){return!!t&&Object.keys(t).length>0}function $i(t,e,i,s){return new Intl.NumberFormat(t,{style:"currency",maximumFractionDigits:parseInt(i,10),numberingSystem:s,currency:e})}function Ui(t,e,i){return new Intl.NumberFormat(t,{maximumFractionDigits:parseInt(e,10),numberingSystem:i})}var Bs=class{constructor(e,i,s,r,n){this.template=e,this.symbol=i,this.thousand=s,this.decimal=r,this.precision=n}format(e){let i=e<0,s=Math.pow(10,this.precision),r=(Math.round(e*s)/s).toFixed(this.precision),n=`${parseInt(Math.abs(r||0).toFixed(this.precision),10)}`,o=n.length>3?n.length%3:0,a=r.split(".")[1],l=[];return o>0&&l.push(`${n.substring(0,o)}${this.thousand}`),l.push(n.substring(o).replace(/(\d{3})(?=\d)/g,"$1"+this.thousand)),this.precision>0&&parseInt(a,10)>0&&l.push(`${this.decimal}${a}`),l=this.template.replace(/%s/g,this.symbol).replace(/%v/g,l.join("")),i&&(l=`-${l}`),l}};"use strict";var Xe;(function(t){t.Range="range",t.Steps="steps",t.Positions="positions",t.Count="count",t.Values="values"})(Xe||(Xe={}));var ce;(function(t){t[t.None=-1]="None",t[t.NoValue=0]="NoValue",t[t.LargeValue=1]="LargeValue",t[t.SmallValue=2]="SmallValue"})(ce||(ce={}));function fa(t){return Bi(t)&&typeof t.from=="function"}function Bi(t){return typeof t=="object"&&typeof t.to=="function"}function Tn(t){t.parentElement.removeChild(t)}function Vs(t){return t!=null}function An(t){t.preventDefault()}function pa(t){return t.filter(function(e){return this[e]?!1:this[e]=!0},{})}function ma(t,e){return Math.round(t/e)*e}function ga(t,e){var i=t.getBoundingClientRect(),s=t.ownerDocument,r=s.documentElement,n=kn(s);return/webkit.*Chrome.*Mobile/i.test(navigator.userAgent)&&(n.x=0),e?i.top+n.y-r.clientTop:i.left+n.x-r.clientLeft}function Ae(t){return typeof t=="number"&&!isNaN(t)&&isFinite(t)}function Cn(t,e,i){i>0&&(he(t,e),setTimeout(function(){ji(t,e)},i))}function xn(t){return Math.max(Math.min(t,100),0)}function Vi(t){return Array.isArray(t)?t:[t]}function _a(t){t=String(t);var e=t.split(".");return e.length>1?e[1].length:0}function he(t,e){t.classList&&!/\s/.test(e)?t.classList.add(e):t.className+=" "+e}function ji(t,e){t.classList&&!/\s/.test(e)?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}function va(t,e){return t.classList?t.classList.contains(e):new RegExp("\\b"+e+"\\b").test(t.className)}function kn(t){var e=window.pageXOffset!==void 0,i=(t.compatMode||"")==="CSS1Compat",s=e?window.pageXOffset:i?t.documentElement.scrollLeft:t.body.scrollLeft,r=e?window.pageYOffset:i?t.documentElement.scrollTop:t.body.scrollTop;return{x:s,y:r}}function ba(){return window.navigator.pointerEnabled?{start:"pointerdown",move:"pointermove",end:"pointerup"}:window.navigator.msPointerEnabled?{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:{start:"mousedown touchstart",move:"mousemove touchmove",end:"mouseup touchend"}}function ya(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("test",null,e)}catch(i){}return t}function Sa(){return window.CSS&&CSS.supports&&CSS.supports("touch-action","none")}function js(t,e){return 100/(e-t)}function Xs(t,e,i){return e*100/(t[i+1]-t[i])}function Ea(t,e){return Xs(t,t[0]<0?e+Math.abs(t[0]):e-t[0],0)}function wa(t,e){return e*(t[1]-t[0])/100+t[0]}function Xt(t,e){for(var i=1;t>=e[i];)i+=1;return i}function Ta(t,e,i){if(i>=t.slice(-1)[0])return 100;var s=Xt(i,t),r=t[s-1],n=t[s],o=e[s-1],a=e[s];return o+Ea([r,n],i)/js(o,a)}function Aa(t,e,i){if(i>=100)return t.slice(-1)[0];var s=Xt(i,e),r=t[s-1],n=t[s],o=e[s-1],a=e[s];return wa([r,n],(i-o)*js(o,a))}function Ca(t,e,i,s){if(s===100)return s;var r=Xt(s,t),n=t[r-1],o=t[r];return i?s-n>(o-n)/2?o:n:e[r-1]?t[r-1]+ma(s-t[r-1],e[r-1]):s}var Pn=function(){function t(e,i,s){this.xPct=[],this.xVal=[],this.xSteps=[],this.xNumSteps=[],this.xHighestCompleteStep=[],this.xSteps=[s||!1],this.xNumSteps=[!1],this.snap=i;var r,n=[];for(Object.keys(e).forEach(function(o){n.push([Vi(e[o]),o])}),n.sort(function(o,a){return o[0][0]-a[0][0]}),r=0;rthis.xPct[r+1];)r++;else e===this.xPct[this.xPct.length-1]&&(r=this.xPct.length-2);!s&&e===this.xPct[r+1]&&r++,i===null&&(i=[]);var n,o=1,a=i[r],l=0,c=0,f=0,m=0;for(s?n=(e-this.xPct[r])/(this.xPct[r+1]-this.xPct[r]):n=(this.xPct[r+1]-e)/(this.xPct[r+1]-this.xPct[r]);a>0;)l=this.xPct[r+1+m]-this.xPct[r+m],i[r+m]*o+100-n*100>100?(c=l*n,o=(a-100*n)/i[r+m],n=1):(c=i[r+m]*l/100*o,o=0),s?(f=f-c,this.xPct.length+m>=1&&m--):(f=f+c,this.xPct.length-m>=1&&m++),a=i[r+m]*o;return e+f},t.prototype.toStepping=function(e){return e=Ta(this.xVal,this.xPct,e),e},t.prototype.fromStepping=function(e){return Aa(this.xVal,this.xPct,e)},t.prototype.getStep=function(e){return e=Ca(this.xPct,this.xSteps,this.snap,e),e},t.prototype.getDefaultStep=function(e,i,s){var r=Xt(e,this.xPct);return(e===100||i&&e===this.xPct[r-1])&&(r=Math.max(r-1,1)),(this.xVal[r]-this.xVal[r-1])/s},t.prototype.getNearbySteps=function(e){var i=Xt(e,this.xPct);return{stepBefore:{startValue:this.xVal[i-2],step:this.xNumSteps[i-2],highestStep:this.xHighestCompleteStep[i-2]},thisStep:{startValue:this.xVal[i-1],step:this.xNumSteps[i-1],highestStep:this.xHighestCompleteStep[i-1]},stepAfter:{startValue:this.xVal[i],step:this.xNumSteps[i],highestStep:this.xHighestCompleteStep[i]}}},t.prototype.countStepDecimals=function(){var e=this.xNumSteps.map(_a);return Math.max.apply(null,e)},t.prototype.hasNoSize=function(){return this.xVal[0]===this.xVal[this.xVal.length-1]},t.prototype.convert=function(e){return this.getStep(this.toStepping(e))},t.prototype.handleEntryPoint=function(e,i){var s;if(e==="min"?s=0:e==="max"?s=100:s=parseFloat(e),!Ae(s)||!Ae(i[0]))throw new Error("noUiSlider: 'range' value isn't numeric.");this.xPct.push(s),this.xVal.push(i[0]);var r=Number(i[1]);s?this.xSteps.push(isNaN(r)?!1:r):isNaN(r)||(this.xSteps[0]=r),this.xHighestCompleteStep.push(0)},t.prototype.handleStepPoint=function(e,i){if(!!i){if(this.xVal[e]===this.xVal[e+1]){this.xSteps[e]=this.xHighestCompleteStep[e]=this.xVal[e];return}this.xSteps[e]=Xs([this.xVal[e],this.xVal[e+1]],i,0)/js(this.xPct[e],this.xPct[e+1]);var s=(this.xVal[e+1]-this.xVal[e])/this.xNumSteps[e],r=Math.ceil(Number(s.toFixed(3))-1),n=this.xVal[e]+this.xNumSteps[e]*r;this.xHighestCompleteStep[e]=n}},t}(),Rn={to:function(t){return t===void 0?"":t.toFixed(2)},from:Number},Ln={target:"target",base:"base",origin:"origin",handle:"handle",handleLower:"handle-lower",handleUpper:"handle-upper",touchArea:"touch-area",horizontal:"horizontal",vertical:"vertical",background:"background",connect:"connect",connects:"connects",ltr:"ltr",rtl:"rtl",textDirectionLtr:"txt-dir-ltr",textDirectionRtl:"txt-dir-rtl",draggable:"draggable",drag:"state-drag",tap:"state-tap",active:"active",tooltip:"tooltip",pips:"pips",pipsHorizontal:"pips-horizontal",pipsVertical:"pips-vertical",marker:"marker",markerHorizontal:"marker-horizontal",markerVertical:"marker-vertical",markerNormal:"marker-normal",markerLarge:"marker-large",markerSub:"marker-sub",value:"value",valueHorizontal:"value-horizontal",valueVertical:"value-vertical",valueNormal:"value-normal",valueLarge:"value-large",valueSub:"value-sub"},qe={tooltips:".__tooltips",aria:".__aria"};function xa(t,e){if(!Ae(e))throw new Error("noUiSlider: 'step' is not numeric.");t.singleStep=e}function ka(t,e){if(!Ae(e))throw new Error("noUiSlider: 'keyboardPageMultiplier' is not numeric.");t.keyboardPageMultiplier=e}function Pa(t,e){if(!Ae(e))throw new Error("noUiSlider: 'keyboardMultiplier' is not numeric.");t.keyboardMultiplier=e}function Ra(t,e){if(!Ae(e))throw new Error("noUiSlider: 'keyboardDefaultStep' is not numeric.");t.keyboardDefaultStep=e}function La(t,e){if(typeof e!="object"||Array.isArray(e))throw new Error("noUiSlider: 'range' is not an object.");if(e.min===void 0||e.max===void 0)throw new Error("noUiSlider: Missing 'min' or 'max' in 'range'.");t.spectrum=new Pn(e,t.snap||!1,t.singleStep)}function Ia(t,e){if(e=Vi(e),!Array.isArray(e)||!e.length)throw new Error("noUiSlider: 'start' option is incorrect.");t.handles=e.length,t.start=e}function Da(t,e){if(typeof e!="boolean")throw new Error("noUiSlider: 'snap' option must be a boolean.");t.snap=e}function Oa(t,e){if(typeof e!="boolean")throw new Error("noUiSlider: 'animate' option must be a boolean.");t.animate=e}function Ha(t,e){if(typeof e!="number")throw new Error("noUiSlider: 'animationDuration' option must be a number.");t.animationDuration=e}function In(t,e){var i=[!1],s;if(e==="lower"?e=[!0,!1]:e==="upper"&&(e=[!1,!0]),e===!0||e===!1){for(s=1;s1)throw new Error("noUiSlider: 'padding' option must not exceed 100% of the range.")}}function $a(t,e){switch(e){case"ltr":t.dir=0;break;case"rtl":t.dir=1;break;default:throw new Error("noUiSlider: 'direction' option was not recognized.")}}function Ua(t,e){if(typeof e!="string")throw new Error("noUiSlider: 'behaviour' must be a string containing options.");var i=e.indexOf("tap")>=0,s=e.indexOf("drag")>=0,r=e.indexOf("fixed")>=0,n=e.indexOf("snap")>=0,o=e.indexOf("hover")>=0,a=e.indexOf("unconstrained")>=0,l=e.indexOf("invert-connects")>=0,c=e.indexOf("drag-all")>=0,f=e.indexOf("smooth-steps")>=0;if(r){if(t.handles!==2)throw new Error("noUiSlider: 'fixed' behaviour must be used with 2 handles");Dn(t,t.start[1]-t.start[0])}if(l&&t.handles!==2)throw new Error("noUiSlider: 'invert-connects' behaviour must be used with 2 handles");if(a&&(t.margin||t.limit))throw new Error("noUiSlider: 'unconstrained' behaviour cannot be used with margin or limit");t.events={tap:i||n,drag:s,dragAll:c,smoothSteps:f,fixed:r,snap:n,hover:o,unconstrained:a,invertConnects:l}}function Ba(t,e){if(e!==!1)if(e===!0||Bi(e)){t.tooltips=[];for(var i=0;i= 2) required for mode 'count'.");for(var d=h.values-1,u=100/d,v=[];d--;)v[d]=d*u;return v.push(100),Ie(v,h.stepped)}return h.mode===Xe.Positions?Ie(h.values,h.stepped):h.mode===Xe.Values?h.stepped?h.values.map(function(b){return _.fromStepping(_.getStep(_.toStepping(b)))}):h.values:[]}function Ie(h,d){return h.map(function(u){return _.fromStepping(d?_.getStep(u):u)})}function Se(h){function d(U,W){return Number((U+W).toFixed(7))}var u=M(h),v={},b=_.xVal[0],y=_.xVal[_.xVal.length-1],A=!1,T=!1,$=0;return u=pa(u.slice().sort(function(U,W){return U-W})),u[0]!==b&&(u.unshift(b),A=!0),u[u.length-1]!==y&&(u.push(y),T=!0),u.forEach(function(U,W){var z,N,Y,oe=U,ie=u[W+1],re,Qi,Zi,es,rr,ts,nr,or=h.mode===Xe.Steps;for(or&&(z=_.xNumSteps[W]),z||(z=ie-oe),ie===void 0&&(ie=oe),z=Math.max(z,1e-7),N=oe;N<=ie;N=d(N,z)){for(re=_.toStepping(N),Qi=re-$,rr=Qi/(h.density||1),ts=Math.round(rr),nr=Qi/ts,Y=1;Y<=ts;Y+=1)Zi=$+Y*nr,v[Zi.toFixed(5)]=[_.fromStepping(Zi),0];es=u.indexOf(N)>-1?ce.LargeValue:or?ce.SmallValue:ce.NoValue,!W&&A&&N!==ie&&(es=0),N===ie&&T||(v[re.toFixed(5)]=[N,es]),$=re}}),v}function Fe(h,d,u){var v,b,y=j.createElement("div"),A=(v={},v[ce.None]="",v[ce.NoValue]=e.cssClasses.valueNormal,v[ce.LargeValue]=e.cssClasses.valueLarge,v[ce.SmallValue]=e.cssClasses.valueSub,v),T=(b={},b[ce.None]="",b[ce.NoValue]=e.cssClasses.markerNormal,b[ce.LargeValue]=e.cssClasses.markerLarge,b[ce.SmallValue]=e.cssClasses.markerSub,b),$=[e.cssClasses.valueHorizontal,e.cssClasses.valueVertical],U=[e.cssClasses.markerHorizontal,e.cssClasses.markerVertical];he(y,e.cssClasses.pips),he(y,e.ort===0?e.cssClasses.pipsHorizontal:e.cssClasses.pipsVertical);function W(N,Y){var oe=Y===e.cssClasses.value,ie=oe?$:U,re=oe?A:T;return Y+" "+ie[e.ort]+" "+re[N]}function z(N,Y,oe){if(oe=d?d(Y,oe):oe,oe!==ce.None){var ie=Z(y,!1);ie.className=W(oe,e.cssClasses.marker),ie.style[e.style]=N+"%",oe>ce.NoValue&&(ie=Z(y,!1),ie.className=W(oe,e.cssClasses.value),ie.setAttribute("data-value",String(Y)),ie.style[e.style]=N+"%",ie.innerHTML=String(u.to(Y)))}}return Object.keys(h).forEach(function(N){z(N,h[N][0],h[N][1])}),y}function $e(){m&&(Tn(m),m=null)}function ge(h){$e();var d=Se(h),u=h.filter,v=h.format||{to:function(b){return String(Math.round(b))}};return m=o.appendChild(Fe(d,u,v)),m}function Je(){var h=a.getBoundingClientRect(),d="offset"+["Width","Height"][e.ort];return e.ort===0?h.width||a[d]:h.height||a[d]}function ne(h,d,u,v){var b=function(A){var T=Et(A,v.pageOffset,v.target||d);if(!T||ot()&&!v.doNotReject||va(o,e.cssClasses.tap)&&!v.doNotReject||h===s.start&&T.buttons!==void 0&&T.buttons>1||v.hover&&T.buttons)return!1;n||T.preventDefault(),T.calcPoint=T.points[e.ort],u(T,v)},y=[];return h.split(" ").forEach(function(A){d.addEventListener(A,b,n?{passive:!0}:!1),y.push([A,b])}),y}function Et(h,d,u){var v=h.type.indexOf("touch")===0,b=h.type.indexOf("mouse")===0,y=h.type.indexOf("pointer")===0,A=0,T=0;if(h.type.indexOf("MSPointer")===0&&(y=!0),h.type==="mousedown"&&!h.buttons&&!h.touches)return!1;if(v){var $=function(z){var N=z.target;return N===u||u.contains(N)||h.composed&&h.composedPath().shift()===u};if(h.type==="touchstart"){var U=Array.prototype.filter.call(h.touches,$);if(U.length>1)return!1;A=U[0].pageX,T=U[0].pageY}else{var W=Array.prototype.find.call(h.changedTouches,$);if(!W)return!1;A=W.pageX,T=W.pageY}}return d=d||kn(j),(b||y)&&(A=h.clientX+d.x,T=h.clientY+d.y),h.pageOffset=d,h.points=[A,T],h.cursor=b||y,h}function wt(h){var d=h-ga(a,e.ort),u=d*100/Je();return u=xn(u),e.dir?100-u:u}function io(h){var d=100,u=!1;return c.forEach(function(v,b){if(!yt(b)){var y=E[b],A=Math.abs(y-h),T=A===100&&d===100,$=Ay;($||U||T)&&(u=b,d=A)}}),u}function so(h,d){h.type==="mouseout"&&h.target.nodeName==="HTML"&&h.relatedTarget===null&&Wi(h,d)}function ro(h,d){if(navigator.appVersion.indexOf("MSIE 9")===-1&&h.buttons===0&&d.buttonsProperty!==0)return Wi(h,d);var u=(e.dir?-1:1)*(h.calcPoint-d.startCalcPoint),v=u*100/d.baseSize;Qs(u>0,v,d.locations,d.handleNumbers,d.connect)}function Wi(h,d){d.handle&&(ji(d.handle,e.cssClasses.active),F-=1),d.listeners.forEach(function(u){K.removeEventListener(u[0],u[1])}),F===0&&(ji(o,e.cssClasses.drag),Yi(),h.cursor&&(Q.style.cursor="",Q.removeEventListener("selectstart",An))),e.events.smoothSteps&&(d.handleNumbers.forEach(function(u){We(u,E[u],!0,!0,!1,!1)}),d.handleNumbers.forEach(function(u){G("update",u)})),d.handleNumbers.forEach(function(u){G("change",u),G("set",u),G("end",u)})}function zi(h,d){if(!d.handleNumbers.some(yt)){var u;if(d.handleNumbers.length===1){var v=c[d.handleNumbers[0]];u=v.children[0],F+=1,he(u,e.cssClasses.active)}h.stopPropagation();var b=[],y=ne(s.move,K,ro,{target:h.target,handle:u,connect:d.connect,listeners:b,startCalcPoint:h.calcPoint,baseSize:Je(),pageOffset:h.pageOffset,handleNumbers:d.handleNumbers,buttonsProperty:h.buttons,locations:E.slice()}),A=ne(s.end,K,Wi,{target:h.target,handle:u,listeners:b,doNotReject:!0,handleNumbers:d.handleNumbers}),T=ne("mouseout",K,so,{target:h.target,handle:u,listeners:b,doNotReject:!0,handleNumbers:d.handleNumbers});b.push.apply(b,y.concat(A,T)),h.cursor&&(Q.style.cursor=getComputedStyle(h.target).cursor,c.length>1&&he(o,e.cssClasses.drag),Q.addEventListener("selectstart",An,!1)),d.handleNumbers.forEach(function($){G("start",$)})}}function no(h){h.stopPropagation();var d=wt(h.calcPoint),u=io(d);u!==!1&&(e.events.snap||Cn(o,e.cssClasses.tap,e.animationDuration),We(u,d,!0,!0),Yi(),G("slide",u,!0),G("update",u,!0),e.events.snap?zi(h,{handleNumbers:[u]}):(G("change",u,!0),G("set",u,!0)))}function oo(h){var d=wt(h.calcPoint),u=_.getStep(d),v=_.fromStepping(u);Object.keys(I).forEach(function(b){b.split(".")[0]==="hover"&&I[b].forEach(function(y){y.call(zt,v)})})}function ao(h,d){if(ot()||yt(d))return!1;var u=["Left","Right"],v=["Down","Up"],b=["PageDown","PageUp"],y=["Home","End"];e.dir&&!e.ort?u.reverse():e.ort&&!e.dir&&(v.reverse(),b.reverse());var A=h.key.replace("Arrow",""),T=A===b[0],$=A===b[1],U=A===v[0]||A===u[0]||T,W=A===v[1]||A===u[1]||$,z=A===y[0],N=A===y[1];if(!U&&!W&&!z&&!N)return!0;h.preventDefault();var Y;if(W||U){var oe=U?0:1,ie=ir(d),re=ie[oe];if(re===null)return!1;re===!1&&(re=_.getDefaultStep(E[d],U,e.keyboardDefaultStep)),$||T?re*=e.keyboardPageMultiplier:re*=e.keyboardMultiplier,re=Math.max(re,1e-7),re=(U?-1:1)*re,Y=S[d]+re}else N?Y=e.spectrum.xVal[e.spectrum.xVal.length-1]:Y=e.spectrum.xVal[0];return We(d,_.toStepping(Y),!0,!0),G("slide",d),G("update",d),G("change",d),G("set",d),!1}function Ys(h){h.fixed||c.forEach(function(d,u){ne(s.start,d.children[0],zi,{handleNumbers:[u]})}),h.tap&&ne(s.start,a,no,{}),h.hover&&ne(s.move,a,oo,{hover:!0}),h.drag&&f.forEach(function(d,u){if(!(d===!1||u===0||u===f.length-1)){var v=c[u-1],b=c[u],y=[d],A=[v,b],T=[u-1,u];he(d,e.cssClasses.draggable),h.fixed&&(y.push(v.children[0]),y.push(b.children[0])),h.dragAll&&(A=c,T=R),y.forEach(function($){ne(s.start,$,zi,{handles:A,handleNumbers:T,connect:d})})}})}function Ki(h,d){I[h]=I[h]||[],I[h].push(d),h.split(".")[0]==="update"&&c.forEach(function(u,v){G("update",v)})}function lo(h){return h===qe.aria||h===qe.tooltips}function Tt(h){var d=h&&h.split(".")[0],u=d?h.substring(d.length):h;Object.keys(I).forEach(function(v){var b=v.split(".")[0],y=v.substring(b.length);(!d||d===b)&&(!u||u===y)&&(!lo(y)||u===y)&&delete I[v]})}function G(h,d,u){Object.keys(I).forEach(function(v){var b=v.split(".")[0];h===b&&I[v].forEach(function(y){y.call(zt,S.map(e.format.to),d,S.slice(),u||!1,E.slice(),zt)})})}function Jt(h,d,u,v,b,y,A){var T;return c.length>1&&!e.events.unconstrained&&(v&&d>0&&(T=_.getAbsoluteDistance(h[d-1],e.margin,!1),u=Math.max(u,T)),b&&d1&&e.limit&&(v&&d>0&&(T=_.getAbsoluteDistance(h[d-1],e.limit,!1),u=Math.min(u,T)),b&&d1?v.forEach(function(z,N){var Y=Jt(y,z,y[z]+d,$[N],U[N],!1,T);Y===!1?d=0:(d=Y-y[z],y[z]=Y)}):$=U=[!0];var W=!1;v.forEach(function(z,N){W=We(z,u[z]+d,$[N],U[N],!1,T)||W}),W&&(v.forEach(function(z){G("update",z),G("slide",z)}),b!=null&&G("drag",A))}function Zs(h,d){return e.dir?100-h-d:h}function ho(h,d){E[h]=d,S[h]=_.fromStepping(d);var u=Zs(d,0)-X,v="translate("+Gi(u+"%","0")+")";if(c[h].style[e.transformRule]=v,e.events.invertConnects&&E.length>1){var b=E.every(function(y,A,T){return A===0||y>=T[A-1]});if(V!==!b){go();return}}At(h),At(h+1),V&&(At(h-1),At(h+2))}function Yi(){R.forEach(function(h){var d=E[h]>50?-1:1,u=3+(c.length+d*h);c[h].style.zIndex=String(u)})}function We(h,d,u,v,b,y){return b||(d=Jt(E,h,d,u,v,!1,y)),d===!1?!1:(ho(h,d),!0)}function At(h){if(!!f[h]){var d=E.slice();V&&d.sort(function(T,$){return T-$});var u=0,v=100;h!==0&&(u=d[h-1]),h!==f.length-1&&(v=d[h]);var b=v-u,y="translate("+Gi(Zs(u,b)+"%","0")+")",A="scale("+Gi(b/100,"1")+")";f[h].style[e.transformRule]=y+" "+A}}function er(h,d){return h===null||h===!1||h===void 0||(typeof h=="number"&&(h=String(h)),h=e.format.from(h),h!==!1&&(h=_.toStepping(h)),h===!1||isNaN(h))?E[d]:h}function Wt(h,d,u){var v=Vi(h),b=E[0]===void 0;d=d===void 0?!0:d,e.animate&&!b&&Cn(o,e.cssClasses.tap,e.animationDuration),R.forEach(function(T){We(T,er(v[T],T),!0,!1,u)});var y=R.length===1?0:1;if(b&&_.hasNoSize()&&(u=!0,E[0]=0,R.length>1)){var A=100/(R.length-1);R.forEach(function(T){E[T]=T*A})}for(;y=0&&hu.stepAfter.startValue&&(b=u.stepAfter.startValue-v),v>u.thisStep.startValue?y=u.thisStep.step:u.stepBefore.step===!1?y=!1:y=v-u.stepBefore.highestStep,d===100?b=null:d===0&&(y=null);var A=_.countStepDecimals();return b!==null&&b!==!1&&(b=Number(b.toFixed(A))),y!==null&&y!==!1&&(y=Number(y.toFixed(A))),[y,b]}function po(){return R.map(ir)}function mo(h,d){var u=tr(),v=["margin","limit","padding","range","animate","snap","step","format","pips","tooltips","connect"];v.forEach(function(y){h[y]!==void 0&&(i[y]=h[y])});var b=On(i);v.forEach(function(y){h[y]!==void 0&&(e[y]=b[y])}),_=b.spectrum,e.margin=b.margin,e.limit=b.limit,e.padding=b.padding,e.pips?ge(e.pips):$e(),e.tooltips?q():x(),E=[],Wt(Vs(h.start)?h.start:u,d),h.connect&&sr()}function sr(){for(;l.firstChild;)l.removeChild(l.firstChild);for(var h=0;h<=e.handles;h++)f[h]=P(l,e.connect[h]),At(h);Ys({drag:e.events.drag,fixed:!0})}function go(){V=!V,In(e,e.connect.map(function(h){return!h})),sr()}function _o(){a=ee(o),O(e.connect,a),Ys(e.events),Wt(e.start),e.pips&&ge(e.pips),e.tooltips&&q(),D()}_o();var zt={destroy:fo,steps:po,on:Ki,off:Tt,get:tr,set:Wt,setHandle:uo,reset:co,disable:St,enable:k,__moveHandles:function(h,d,u){Qs(h,d,E,u)},options:i,updateOptions:mo,target:o,removePips:$e,removeTooltips:x,getPositions:function(){return E.slice()},getTooltips:function(){return w},getOrigins:function(){return c},pips:ge};return zt}function Ga(t,e){if(!t||!t.nodeName)throw new Error("noUiSlider: create requires a single element, got: "+t);if(t.noUiSlider)throw new Error("noUiSlider: Slider was already initialized.");var i=On(e),s=Ka(t,i,e);return t.noUiSlider=s,s}var Hn={__spectrum:Pn,cssClasses:Ln,create:Ga};function Mn(t){return t.filter((e,i)=>t.indexOf(e)===i)}function Nn(t){let e={};return{to(i){let s=t.format(i);return e[s]=i,s},from(i){return e[i]}}}function qs(t,e){let{min:i,max:s,from:r,to:n}=t;return i=parseFloat(i),s=parseFloat(s),i===s&&s++,r=parseFloat(r)||i,n=parseFloat(n)||s,{range:{min:i,max:s},start:[e.to(r),e.to(n)]}}function Fn(t,e,i,s={}){let r=t.dataset.facetLabel||"";return Hn.create(t,H({cssPrefix:"dfd-slider-",orientation:"horizontal",direction:s.rtl?"rtl":"ltr",tooltips:!0,padding:0,connect:!0,animate:!0,step:1,keyboardSupport:!0,format:e,handleAttributes:[{"aria-label":`Minimum ${r}`},{"aria-label":`Maximum ${r}`}],pips:{mode:"count",values:3,density:6,stepped:!0,format:e}},i))}function $n(t,e,i){let s=getComputedStyle(t).direction==="rtl",r=t.noUiSlider.options.direction==="rtl",n=t.noUiSlider.options.orientation==="vertical",a=t.noUiSlider.getTooltips().map(c=>c.cloneNode(!0)),l=t.noUiSlider.getOrigins();a.forEach(function(c,f){c&&l[f].appendChild(c)}),t.noUiSlider.on("update",function(c,f,m,w,_){let S=[[]],E=[[]],R=[[]],F=0;a[0]&&(S[0][0]=0,E[0][0]=_[0],R[0][0]=c[0]);for(let I=1;I<_.length;I++)(!a[I]||_[I]-_[I-1]>e)&&(F++,S[F]=[],R[F]=[],E[F]=[]),a[I]&&(S[F].push(I),R[F].push(c[I]),E[F].push(_[I]));S.forEach(function(I,V){let j=I.length;for(let K=0;Ktypeof r=="string"?new Bs(r,o,a,s,parseInt(n,10)):i?$i(e,i,parseInt(n,10),E):Ui(e,parseInt(l,10),E))();this.format=Nn(F),this.slider=Fn(this.el,this.format,qs({min:c,max:f,from:m,to:w},this.format),{rtl:R}),this.slider.on("change",I=>{let[V,j]=I,Q={index:this.el.dataset.index,range:{[t]:{from:this.format.from(V),to:this.format.from(j)}}};_?this.pushEventTo(_,"slide",Q):this.pushEvent("slide",Q)}),S||$n(this.el,25," - ")},updated(){let{min:t,max:e,from:i,to:s}=this.el.dataset;this.slider.updateOptions(qs({min:t,max:e,from:i,to:s},this.format))},destroyed(){this.el.noUiSlider.destroy()}};"use strict";var Bn={mounted(){let t=0,e=0;this.el.addEventListener("touchstart",i=>{t=i.changedTouches[0].screenY},!1),this.el.addEventListener("touchend",i=>{e=i.changedTouches[0].screenY,e>t&&this.pushEvent(this.el.dataset.action,{index:""})},!1)}};"use strict";var Vn={mounted(){this.getLineHeight=()=>{let t=document.createElement("div");t.style.position="absolute",t.style.visibility="hidden",t.style.height="auto",t.style.width=this.el.offsetWidth+"px",t.style.fontSize=window.getComputedStyle(this.el).fontSize,t.style.fontFamily=window.getComputedStyle(this.el).fontFamily,t.style.lineHeight=window.getComputedStyle(this.el).lineHeight,t.style.padding=window.getComputedStyle(this.el).padding,t.style.border=window.getComputedStyle(this.el).border,t.innerHTML="A",document.body.appendChild(t);let e=t.offsetHeight;return document.body.removeChild(t),e},this.scrollMessagesToBottom=()=>{let t=document.querySelector(".dfd-messages-list");t&&t.scrollTo({top:t.scrollHeight,behavior:"smooth"})},this.resize=()=>{this.el.style.height="auto";let t=this.el.scrollHeight,e=this.lineHeight*this.maxLines;t<=e?(this.el.style.height=t+"px",this.el.style.overflowY="hidden"):(this.el.style.height=e+"px",this.el.style.overflowY="auto")},this.maxLines=4,this.originalHeight=this.el.scrollHeight,this.lineHeight=this.getLineHeight(),this.el.style.height="auto",this.el.style.overflowY="hidden",this.el.addEventListener("input",()=>this.resize()),this.el.addEventListener("change",()=>this.resize()),this.el.addEventListener("keyup",()=>this.resize()),this.el.addEventListener("paste",()=>{setTimeout(()=>this.resize(),0)}),this.el.addEventListener("keydown",t=>{if(t.key!="Enter"||t.shiftKey)return;t.preventDefault();let e=this.el.closest("form");if(e){let i=new Event("submit",{bubbles:!0,cancelable:!0});e.dispatchEvent(i)}}),this.handleEvent("set-textarea-value",t=>{t.id===this.el.id&&(this.el.value=t.value,this.resize())}),this.handleEvent("scroll-messages-to-bottom",()=>{this.scrollMessagesToBottom()}),this.resize()},updated(){this.resize()}};var Xi=window.SpeechRecognition||window.webkitSpeechRecognition||null,jn=["click"],Xn=["start","end","error","result"],Ya="voice-search",qn="voice-status-change";function Qa(t){return t.results.length>0?t.results[0][0].transcript:null}var Jn={mounted(){!Xi||(this.recording=!1,this.driver=new Xi,this.driver.continuous=!1,this.driver.interimResults=!1,this.handleVoiceEvent=t=>{switch(t.type){case"end":case"error":this.driver.stop(),this.recording=!1,this.pushEvent(qn,{recording:!1});break;case"click":this.driver[this.recording?"stop":"start"](),this.recording=!this.recording,this.pushEvent(qn,{recording:this.recording});break;case"result":{let e=Qa(t);e&&this.pushEvent(Ya,{query:e});break}}},jn.forEach(t=>this.el.addEventListener(t,this.handleVoiceEvent)),Xn.forEach(t=>this.driver.addEventListener(t,this.handleVoiceEvent)))},destroyed(){jn.forEach(t=>this.el.removeEventListener(t,this.handleVoiceEvent)),Xn.forEach(t=>this.driver.removeEventListener(t,this.handleVoiceEvent)),this.driver=null}};function de(t,e,...i){var o;let s=((o=i.find(a=>!!a.options))==null?void 0:o.options)||{},r={get tag(){return e},get options(){return s},debug(...a){C(`[hook][${t}]`,...a)}};return["mounted","beforeUpdate","updated","destroyed","disconnected","reconnected"].forEach(a=>{let l=i.map(c=>c[a]).filter(c=>!!c);r[a]=function(){l.length>0&&this.debug(`${a}()`),l.forEach(c=>c.call(this))}}),r}var Wn={mounted(){this.el.addEventListener("keydown",t=>{t.target===this.el&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),document.getElementById(this.el.dataset.cardLinkId).click())})}};function zn(t){return JSON.parse(JSON.stringify(t))}function Js(t,e,i){let s=i.x,r=s+i.width,n=i.y,o=n+i.height;return t>=s&&t<=r&&e>=n&&e<=o}function qt(t,e=!1){let i=Os("__DF_LAYER_SERVER__")||`https://${t.toLowerCase()}-layer.doofinder.com`;return e?i.replace(/^http/,"ws"):i}function Kn(){var t;if("maxTouchPoints"in navigator)return navigator.maxTouchPoints>0;if("msMaxTouchPoints"in navigator)return navigator.msMaxTouchPoints>0;{let e=(t=window.matchMedia)==null?void 0:t.call(window,"(pointer:coarse)");if((e==null?void 0:e.media)==="(pointer:coarse)")return!!e.matches;if("orientation"in window)return!0;{let i=navigator.userAgent;return/\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(i)||/\b(Android|Windows Phone|iPad|iPod)\b/i.test(i)}}}function Ws(t){let e=document.cookie.match(new RegExp("(?:^|; )"+t.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));if(e)return decodeURIComponent(e[1])}function Gn(t){if(t instanceof PointerEvent)switch(t.pointerType){case"mouse":case"pen":case"touch":return!0;default:return!1}else if(t instanceof MouseEvent){let{pageX:e,pageY:i,target:s}=t;return!(e===i&&e===0&&Za(s))}return!1}function Za(t){return t.getAttribute("type")==="submit"&&(t.tagName==="BUTTON"||t.tagName==="INPUT")}function zs(t){return typeof t=="undefined"?null:t}var el="Search",Yn=Kn(),Qn="latestSearches",tl=10,il="dfd-root",qi=class{constructor(e){this.__handleTriggerEvent__=this.__handleTriggerEvent__.bind(this),this.__handleLinkClick__=this.__handleLinkClick__.bind(this),this.__handleDocumentMousedown__=this.__handleDocumentMousedown__.bind(this),this.__handleDocumentKeyup__=this.__handleDocumentKeyup__.bind(this),this.__updateSocketParams__=this.__updateSocketParams__.bind(this),this.__afterConnect__=this.__afterConnect__.bind(this),this.__afterDisconnect__=this.__afterDisconnect__.bind(this);let{autoload:i,currency:s,exportResultsData:r,hashid:n,id:o,installationId:a,is_checkout:l,language:c,layerType:f,search_query_retention:m,trigger:w,urlHash:_,zone:S}=e;this._installationId=a,this._zone=S,this._hashid=n,this._language=c,this._currency=s,this._exportResultsData=r,this._layerType=f,l&&this.dispatch("doofinder.layer.checkout",{url:window.location.href}),this._mount=this.__createMount__(o),this._mount.addEventListener("click",this.__handleLinkClick__),this._eventBus=new Is(this._mount.id),this._eventBusSubscriptions=[Hs,Ut,Bt,Ms].map(E=>this._eventBus.on(E,this.__handleTriggerEvent__)),this._trigger=w,this._trigger.setEventBus(this._eventBus),this._display=new Ls(this._mount),this._state=this.__defineNewState__(a,i,_,f),this._data=new vt(`${a}.data`),this._sessionData=new vt(`${a}.data`,window.sessionStorage),this._params=this.__buildSocketParams__(e),this._hooks=this.__buildSocketHooks__(e),this._connection=null,this._connectedPromise=new De,this._theme=null,this._searchQueryRetention=m,this._urlHash=_,this._autoload=i,this.closable&&this.mount.classList.add("dfd-closable"),this._trigger.flushMessages(),this.__loadState__().then(()=>this.dispatch("doofinder.ready"))}__createMount__(e){let i=document.createElement("div");return i.id=e||`df-${bt(32)}`,i.dataset.dfdView=el,i.setAttribute(Me,""),i.classList.add(il),Object.defineProperty(i,"doofinderTag",{value:this,writable:!1}),i}get mount(){return this._mount}get trigger(){return this._trigger}get display(){return this._display}get hashid(){return this._hashid}get installationId(){return this._installationId}get zone(){return this._zone}get language(){return this._language}get currency(){return this._currency}get exportResultsData(){return this._exportResultsData}get layerType(){return this._layerType}get searchQueryRetention(){return this._searchQueryRetention}get data(){return this._data}get state(){return this._state}get closable(){return this.display.type!==tt||!this._state.hasAutoloadQueryParam}set targetItemId(e){this.state.targetItemId=e}enableDebug(){return this._connection?(this._connection.enableDebug(),!0):!1}debug(...e){C("[tag]",...e)}updateState({value:e=this._state.targetItemId,itemId:i=this._state.targetItemId,isTransitory:s=this._state.isTransitory}){this._state.update(e,i,s)}__handleTriggerEvent__(e){let{source:i,originalEvent:s}=e.detail,{query:r}=e.detail,n=r?{query:r}:{};this.connect(n).then(()=>{if(this.__shouldDisplay__(e)){this.show(i),e.type===Bt&&this.search(r);return}e.type===Ms&&this.submit(r,o=>{var l;if(!o){this.show(i);return}let{submit:a}=o||{};a&&((l=s==null?void 0:s.target.closest("form"))==null||l.submit())})})}__shouldDisplay__(e){let{query:i}=e.detail;switch(this._display.type){case wi:return(e.type===Bt||e.type===Ut)&&(this._display.screenType==="classic-initial"||!!i);case tt:return(e.type===Bt||e.type===Ut)&&!!i;case Ei:case Ti:return e.type===Hs||e.type===Ut;default:return!1}}__handleLinkClick__(e){var r,n;if(this.dispatch("doofinder.layer.click",{originalEvent:e}),e.target.href===window.location.href){e.preventDefault(),this.__closeAndPreserveQuery__();return}if(!e.target.href){(r=this._connection)==null||r.setPreventReconnect(!1);return}let i=e.target.closest("[dfd-value-dfid]"),s=i==null?void 0:i.getAttribute("dfd-value-dfid");s&&this.updateState({itemId:s}),(n=this._connection)==null||n.setPreventReconnect(!0),this._layerType!=="category_pages"&&this._searchQueryRetention&&this._state.saveTransitory(e.target.href)}__closeAndPreserveQuery__(){if(this.searchQueryRetention){let e=this._state.query;setTimeout(()=>{this._trigger.updateQuery(e)},300)}this.close()}__handleDocumentMousedown__(e){if(this._display.hidden||this._display.type===tt||!Gn(e))return;let{clientX:i,clientY:s}=e;if(Js(i,s,this._mount.getBoundingClientRect()))return;let r=this._display.method.positionReference;!!r&&(Js(i,s,r.getBoundingClientRect())||e.target.closest('button[type="submit"]')&&e.target.closest("form")===r.closest("form"))||this.close()}__handleDocumentKeyup__(e){var i;e.key==="Escape"&&this.layerType!=="category_pages"&&((i=document.activeElement)==null||i.blur(),this.close())}__loadState__(){if(this._layerType==="category_pages"||(this.debug("load state:",this._state.value),this._trigger.updateQuery(this._searchQueryRetention?this._state.query:""),!this._state.value))return Promise.resolve();let e=this._state.value;return this.connect({state:e}).then(()=>{this._state.isTransitory?this.debug("Layer not opened because the state is transitory"):this.show()})}getLatestSearches(){return this._data.getItem(Qn)||[]}updateLatestSearches(e){this._data.setItem(Qn,e)}onLoad(e){let{min_capture_length:i,capture_submit:s,align:r,display_type:n,insertion_point:o,insertion_method:a,screen_type:l,theme:c}=e;this.__updateTrigger__({min_capture_length:i,capture_submit:s}),this.__updateDisplay__({display_type:n,insertion_point:o,insertion_method:a,screen_type:l,theme:c,align:r}),this._connectedPromise.resolve(e)}__updateTrigger__({min_capture_length:e,capture_submit:i}){this._trigger.setCaptureLength(e),this._trigger.captureSubmit=i}__updateDisplay__({display_type:e,insertion_point:i,insertion_method:s,screen_type:r,theme:n,align:o}){this._display.setType(e,{placement:{insertionPoint:i,insertionMethod:s},align:o}),this._display.screenType=r,this._display.updateTheme(n),this._display.hidden||this.updatePosition()}updatePosition(e){return L(this,null,function*(){this._display.updatePosition({positionReference:e||(yield this._trigger.getElement())})})}close(){var e,i;this.closable&&((i=(e=this.getHooksByName("Layer"))==null?void 0:e.pop())==null||i.close())}show(e){return L(this,null,function*(){yield this.updatePosition(e),yield this._display.show(),this.updateState({isTransitory:!1}),setTimeout(()=>{var i;return(i=this._connection)==null?void 0:i.pushEvent("update-scroll",{page:this.state.startPage,dfid:this.state.targetItemId})},200),this.dispatch("doofinder.show")})}hide(){return L(this,null,function*(){this._display&&(yield this._display.hide()),this.dispatch("doofinder.hide")})}dispatch(e,i={}){let s=Ce(H({},i),{tag:this});document.dispatchEvent(new CustomEvent(e,{detail:s}))}connect(e){return this._connection||(this.debug(`creating live socket for layer: ${this._mount.id}`),this._connection=new ws(this.__connectionSetup__(e)),this._connection.connect(this.__afterConnect__)),this._connectedPromise}isConnected(){return this._connection?this._connection.connected:!1}open(){return L(this,arguments,function*(e={}){let{search:i,screen:s}=e,r=H({},e);i!=null&&!s&&(r.screen="fallback"),typeof i=="string"&&(delete r.search,r.query=i),yield this.connect(r),yield this.show(),typeof i=="object"&&this.search(i)})}openCategoryPages(e){return L(this,null,function*(){let{search:i}=e,s={search:i},r=this._state.value;r&&(s.state=r),C("[category pages] connect with",s),yield this.connect(s),yield this.show(),r||(C("[category pages] no state, opening with: ",i),this.search(i))})}disconnect(){var e;this.layerType!=="category_pages"&&(this.debug(`disconnecting from live socket: ${this._mount.id}`),this._trigger.updateQuery(""),this.updateState({value:"",itemId:null,isTransitory:!1}),this.hide(),(e=this._connection)==null||e.disconnect(this.__afterDisconnect__),this._connection=null,this._connectedPromise=new De)}destroy(){return L(this,null,function*(){var e;this.debug(`destroy: ${this._mount.id}`),this.hide(),(e=this._connection)==null||e.disconnect(this.__afterDisconnect__),this._connection=null,this._eventBusSubscriptions.forEach(i=>i()),this._eventBusSubscriptions=null,this._eventBus.teardown(),this._eventBus=null,yield this._display.destroy(),this._display=null,this._trigger.destroy(),this._mount.replaceChildren(),this.dispatch("doofinder.destroy")})}getHooksByName(e){var i;return(i=this._connection)==null?void 0:i.getHooksByName(e)}search(e,i){var r;let s=typeof e=="string"?{query:e}:e;(r=this._connection)==null||r.pushEvent("search-suggest",{search:s},i)}changeLocale(e,i,s){var r;(r=this._connection)==null||r.pushEvent("change-locale",{language:e,currency:i},s)}submit(e,i){var s;(s=this._connection)==null||s.pushEvent("search-submit",{search:{query:e}},i)}__buildSocketParams__(e){let{params:i,sort:s,vars:r,indices:n,state:o,priceName:a}=e,l={hashid:this._hashid,origin:window.location.hostname,indices:n,params:i,sort:s,vars:r,state:o,price_name:a};return["indices","search-server"].filter(c=>!l[c]).forEach(c=>delete l[c]),l}__buildSocketHooks__(e){let i=e.hooks||{},s={Carousel:de("Carousel",this,rn,i.Carousel||{}),ImageSearch:de("ImageSearch",this,an),Input:de("Input",this,hn,i.Input||{}),Layer:de("Layer",this,mn,i.Layer||{}),LayerNotAvailable:de("LayerNotAvailable",this,gn),AddToCart:de("AddToCart",this,cn,i.AddToCart||{}),EmbeddedResults:de("EmbeddedResults",this,Us,Yn?$s:{},i.EmbeddedResults||{}),Results:de("Results",this,wn,Yn?$s:{},Us,i.Results||{}),Slider:de("Slider",this,Un,i.Slider||{}),Swipe:de("Swipe",this,Bn,i.Swipe||{}),Textarea:de("Textarea",this,Vn,i.Textarea||{}),VoiceSearch:de("VoiceSearch",this,Jn,i.VoiceSearch||{}),CardTabNavigation:de("CardTabNavigation",this,Wn,i.CardLink||{})};return C("[tag] Hooks created:",this._mount.id,s),Object.keys(i).filter(r=>!s[r]).forEach(r=>{s[r]=de(r,this,i[r]||{})}),s}__connectionSetup__(e){return{url:`${qt(this._zone,!0)}/layer/${rt}`,mount:this._mount,hooks:this._hooks,mainHook:"Layer",params:()=>this.__updateSocketParams__(e),appName:"layer",disconnectCallback:(()=>{this.debug("layer died and can't reconnect automatically! \u{1F92C}"),this.__afterDisconnect__()}).bind(this)}}__updateSocketParams__(e){var s,r,n,o;let i=Ce(H({},zn(this._params)),{zone:this.zone,installation_id:this.installationId,language:this.language,currency:this.currency,session_id:Doofinder.Session.getSessionId(),tab_id:"getTabId"in Doofinder.Session?Doofinder.Session.getTabId():null,session_alive:Doofinder.Session.isLive("layer"),user_id:Doofinder.Session.getUserId(),latest_searches:this.getLatestSearches(),voice_supported:!!Xi,export_results_data:zs((s=this.exportResultsData)==null?void 0:s.slice(0,tl)),ga_client_id:zs((r=Ws("_ga"))==null?void 0:r.substring(6)),layer_type:this.layerType,state:this._state.value,mount_id:this._mount.id,current_url:window.location.href});return this._layerType==="category_pages"&&(i.search=e.search),((n=this._connection)==null?void 0:n.connected)||(i=H(H({},i),e)),this.debug(`__updateSocketParams__ for layer: ${this._mount.id}`,i," socket connected? ",(o=this._connection)==null?void 0:o.connected," overrides: ",e," current state",this._state.value),i}__afterConnect__(){document.addEventListener("mousedown",this.__handleDocumentMousedown__),document.addEventListener("keyup",this.__handleDocumentKeyup__,{passive:!0})}__afterDisconnect__(){document.removeEventListener("keyup",this.__handleDocumentKeyup__),document.removeEventListener("mousedown",this.__handleDocumentMousedown__),this.dispatch("doofinder.disconnect")}__defineNewState__(e,i,s,r){return new st({installationId:e,autoload:i,urlHash:s,layerType:r})}};var sl=Object.freeze({language(t){let e=(t==null?void 0:t.replaceAll("_","-").trim().split("-"))||[];function i(s){return s?`-${s.toUpperCase()}`:""}if(e.length<3){let[s,r]=e;return`${s==null?void 0:s.toLowerCase()}${i(r)}`}else{let[s,r,n]=e;return`${s==null?void 0:s.toLowerCase()}-${r.toUpperCase()}${i(n)}`}},currency(t){return t==null?void 0:t.trim().toUpperCase()}});function Ks(t){return L(this,null,function*(){let e=document.createElement("style");e.appendChild(document.createTextNode((t||"").trim())),document.head.appendChild(e)})}function Zn(t){return L(this,null,function*(){var o;let e=nl(t);C("[category pages] displayForSeo options: ",t,"params: ",e);let i=yield ol(e);if(C("[category pages] displayForSeo htmlContent: ",i),!i)return;let s=rl(t.id,i);t.device=="mobile"&&(s.classList.remove("dfd-embedded"),s.classList.add("dfd-mobile_embedded")),t.custom_css.forEach(Ks);let r=(o=t.custom_properties)==null?void 0:o.join(` `);Ks(`#${s.id} { ${r||""} }`);let n=document.querySelector(t.insertion_point);C("[category pages] displayForSeo insertion point: ",n),n&&n.replaceWith(s)})}function rl(t,e){let i=document.createElement("div");return i.id=t||`df-${bt(32)}`,i.dataset.dfdView="Search",i.classList.add("dfd-root"),i.insertAdjacentHTML("afterbegin",e),i}function nl(t){let{installationId:e,hashid:i,language:s,currency:r,zone:n,search:o,sort:a,urlHash:l,vars:c,layerType:f,autoload:m,priceName:w}=t,_=Doofinder.Session.getSessionId(),S=Doofinder.Session.getUserId(),E=new st({installationId:e,autoload:m,urlHash:l,layerType:f}).value;return{installationId:e,hashid:i,language:s,currency:r,zone:n,state:E,search:o,sort:a,price_name:w,session_id:_,user_id:S,vars:c}}function ol(t){return L(this,null,function*(){let{zone:e}=t,i=qt(e),s=new URL(`${i}/api/${rt}/categorypage`);return Object.keys(t).forEach(function(n){let o=t[n];typeof o=="undefined"||o==null||(typeof o=="object"&&(o=JSON.stringify(o)),s.searchParams.append(n,o))}),yield fetch(s).then(function(n){return n.ok?n.text():""})})}function eo(t){let{hashid:e,url_patterns:i}=t,s=window.location.toString();return C("[category merchandising] __getNewOptions__ category merchandising URL patterns: ",i," url: ",s),al(e,i,s)}function al(t,e,i){try{let s=ll(t,e,i);if(!s)return C("[category merchandising] configuration not found for current location, urlStr: ",i),null;let r=Gs(s),n=[...i.matchAll(r)][0].groups,o=hl(s,n);return o.url_pattern_id=s.id,C("[category merchandising] configuration found for current location, urlStr: ",i,"URLPattern: ",s,"capturedValues from URL: ",n,"params to open the layer: ",o),o}catch(s){return C("[category merchandising] error trying to get category merchandising search options: ",s),null}}function ll(t,e,i){let s=e.filter(r=>r.hashid===t).find(r=>{let n=Gs(r);return[...i.matchAll(n)].length>0});return s||e.filter(r=>!r.hashid).find(r=>{let n=Gs(r);return[...i.matchAll(n)].length>0})}function Gs(t){let[,,e,i]=t.pattern.match(/(\/?)(.+)\1([a-z]*)/i);i=i||"g";let s=new RegExp(e,i);return C("pattern ",e,"flags",i,"regexp",s),s}function hl(t,e){let i="{{",s="}}",{params:r}=t,n=JSON.stringify(r.search);for(let o in e){let a=`${i}${o}${s}`,l=cl(t,o,`${e[o]}`);C("[category merchandising] replacing old value: ",a,", new value ",l,"at",n),n=n.replaceAll(a,l)}return JSON.parse(n)}function cl(t,e,i){var r;let s=(r=t.params)==null?void 0:r.transformers;if(!s||!s[e])return C("[category merchandising] __applyTransformer__ transformers not found in URLPattern",t," for ",e),i;try{return Array.isArray(s[e])?dl(s[e],i):typeof s[e]=="string"?ul(s[e],i):i}catch(n){C("[category merchandising] __applyTransformer__ error ","URLPattern: ",t,"key",e,"value",i,"error",n)}return i}function dl(t,e){C("[category merchandising] __applyTransformerDefinedAsArray__ ",t);let[i,s]=t,r=i.split("."),n=window[r[0]];return r.slice(1).forEach(o=>n=window[o]),typeof n=="function"?(C("[category merchandising] __applyTransformer__ call function ",i," args: ",[e,s]),n(e,s)):(C("[category merchandising] __applyTransformer__ transformer",i," is not a function. Type: ",typeof n),e)}function ul(t,e){let i=(0,eval)(t);return C("[category merchandising] __applyTransformerDefinedAsString__ completionValue obtained with eval",i," evaluated code ",t),typeof i=="function"?i(e):e}var Ji=[];document.addEventListener("doofinder.destroy",t=>{Ji=Ji.filter(e=>e!==t.detail)});var to={getTags(){return Ji.slice(0)},create(t){let e=new qi(t);return t.layerType==="category_pages"&&(t.search=eo(t),t.search&&(Zn(t),e.openCategoryPages(t))),Ji.push(e),e},destroy(t){var e;t instanceof qi?t.destroy():(e=t==null?void 0:t.doofinderTag)==null||e.destroy()},enableDebug:Yr,disableDebug:Qr,debug:C,utils:{buildNumericFormatter:Ui,buildCurrencyFormatter:$i}};Object.defineProperty(to,"__version__",{value:rt});dr(cr,to);})();