13 lines
39 KiB
JavaScript
13 lines
39 KiB
JavaScript
// Datastar v1.0.0-beta.7
|
|
var Ue=/🖕JS_DS🚀/.source,ie=Ue.slice(0,5),Ce=Ue.slice(4),O="datastar";var Be="Datastar-Request",he=300,je=1e3,Ke="type module",ve=!1,Je=!1,ze=!0,W={Morph:"morph",Inner:"inner",Outer:"outer",Prepend:"prepend",Append:"append",Before:"before",After:"after",UpsertAttributes:"upsertAttributes"},Ye=W.Morph,k={MergeFragments:"datastar-merge-fragments",MergeSignals:"datastar-merge-signals",RemoveFragments:"datastar-remove-fragments",RemoveSignals:"datastar-remove-signals",ExecuteScript:"datastar-execute-script"};var M=(r=>(r[r.Attribute=1]="Attribute",r[r.Watcher=2]="Watcher",r[r.Action=3]="Action",r))(M||{});var oe=`${O}-signals`;var j=t=>t.trim()==="true",se=t=>t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,n)=>(n?"-":"")+e.toLowerCase()),B=t=>se(t).replace(/-./g,e=>e[1].toUpperCase()),Le=t=>se(t).replace(/-/g,"_"),vn=t=>B(t).replace(/^./,e=>e[0].toUpperCase()),ye=t=>new Function(`return Object.assign({}, ${t})`)(),K=t=>t.startsWith("$")?t.slice(1):t,yn={kebab:se,snake:Le,pascal:vn};function V(t,e){for(let n of e.get("case")||[]){let r=yn[n];r&&(t=r(t))}return t}var bn="computed",Xe={type:1,name:bn,keyReq:1,valReq:1,onLoad:({key:t,mods:e,signals:n,genRX:r})=>{t=V(t,e);let i=r();n.setComputed(t,i)}};var Qe={type:1,name:"signals",removeOnLoad:()=>!0,onLoad:t=>{let{key:e,mods:n,signals:r,value:i,genRX:s}=t,l=n.has("ifmissing");if(e!==""){let u=V(e,n),g=i===""?i:s()();l?r.upsertIfMissing(u,g):r.setValue(u,g)}else{let u=ye(t.value);t.value=JSON.stringify(u);let T=s()();r.merge(T,l)}}};var Ze={type:1,name:"star",keyReq:2,valReq:2,onLoad:()=>{alert("YOU ARE PROBABLY OVERCOMPLICATING IT")}};var ae=class{#e=0;#n;constructor(e=O){this.#n=e}with(e){if(typeof e=="string")for(let n of e.split(""))this.with(n.charCodeAt(0));else this.#e=(this.#e<<5)-this.#e+e;return this}get value(){return this.#n+Math.abs(this.#e).toString(36)}};function be(t){if(t.id)return t.id;let e=new ae,n=t;for(;n;){if(n.id){e.with(n.id);break}let r=n?.parentNode;r?e.with([...r.children].indexOf(n)):e.with(n.tagName),n=r}return e.value}function le(t,e){if(!t||!(t instanceof HTMLElement||t instanceof SVGElement))return null;let n=t.dataset;if("starIgnore"in n)return null;"starIgnore__self"in n||e(t);let r=t.firstElementChild;for(;r;)le(r,e),r=r.nextElementSibling}function Se(t,e){return(...n)=>{setTimeout(()=>{t(...n)},e)}}function et(t,e,n=!1,r=!0){let i=-1,s=()=>i&&clearTimeout(i);return(...l)=>{s(),n&&!i&&t(...l),i=setTimeout(()=>{r&&t(...l),s()},e)}}function tt(t,e,n=!0,r=!1){let i=!1;return(...s)=>{i||(n&&t(...s),i=!0,setTimeout(()=>{i=!1,r&&t(...s)},e))}}var Sn="https://data-star.dev/errors";function Ie(t,e,n={}){let r=new Error;r.name=`${O} ${t} error`;let i=Le(e),s=new URLSearchParams({metadata:JSON.stringify(n)}).toString(),l=JSON.stringify(n,null,2);return r.message=`${e}
|
|
More info: ${Sn}/${t}/${i}?${s}
|
|
Context: ${l}`,r}function q(t,e,n={}){return Ie("internal",e,Object.assign({from:t},n))}function H(t,e,n={}){let r={plugin:{name:e.plugin.name,type:M[e.plugin.type]}};return Ie("init",t,Object.assign(r,n))}function N(t,e,n={}){let r={plugin:{name:e.plugin.name,type:M[e.plugin.type]},element:{id:e.el.id,tag:e.el.tagName},expression:{rawKey:e.rawKey,key:e.key,value:e.value,validSignals:e.signals.paths(),fnContent:e.fnContent}};return Ie("runtime",t,Object.assign(r,n))}var X="preact-signals",Tn=Symbol.for("preact-signals"),$=1,Q=2,ce=4,ee=8,Te=16,Z=32;function Ve(){Ae++}function Oe(){if(Ae>1){Ae--;return}let t,e=!1;for(;ue!==void 0;){let n=ue;for(ue=void 0,De++;n!==void 0;){let r=n._nextBatchedEffect;if(n._nextBatchedEffect=void 0,n._flags&=~Q,!(n._flags&ee)&&rt(n))try{n._callback()}catch(i){e||(t=i,e=!0)}n=r}}if(De=0,Ae--,e)throw t}var P;var ue,Ae=0,De=0,Ee=0;function nt(t){if(P===void 0)return;let e=t._node;if(e===void 0||e._target!==P)return e={_version:0,_source:t,_prevSource:P._sources,_nextSource:void 0,_target:P,_prevTarget:void 0,_nextTarget:void 0,_rollbackNode:e},P._sources!==void 0&&(P._sources._nextSource=e),P._sources=e,t._node=e,P._flags&Z&&t._subscribe(e),e;if(e._version===-1)return e._version=0,e._nextSource!==void 0&&(e._nextSource._prevSource=e._prevSource,e._prevSource!==void 0&&(e._prevSource._nextSource=e._nextSource),e._prevSource=P._sources,e._nextSource=void 0,P._sources._nextSource=e,P._sources=e),e}function L(t){this._value=t,this._version=0,this._node=void 0,this._targets=void 0}L.prototype.brand=Tn;L.prototype._refresh=()=>!0;L.prototype._subscribe=function(t){this._targets!==t&&t._prevTarget===void 0&&(t._nextTarget=this._targets,this._targets!==void 0&&(this._targets._prevTarget=t),this._targets=t)};L.prototype._unsubscribe=function(t){if(this._targets!==void 0){let e=t._prevTarget,n=t._nextTarget;e!==void 0&&(e._nextTarget=n,t._prevTarget=void 0),n!==void 0&&(n._prevTarget=e,t._nextTarget=void 0),t===this._targets&&(this._targets=n)}};L.prototype.subscribe=function(t){return _e(()=>{let e=this.value,n=P;P=void 0;try{t(e)}finally{P=n}})};L.prototype.valueOf=function(){return this.value};L.prototype.toString=function(){return`${this.value}`};L.prototype.toJSON=function(){return this.value};L.prototype.peek=function(){let t=P;P=void 0;try{return this.value}finally{P=t}};Object.defineProperty(L.prototype,"value",{get(){let t=nt(this);return t!==void 0&&(t._version=this._version),this._value},set(t){if(t!==this._value){if(De>100)throw q(X,"SignalCycleDetected");let e=this._value,n=t;this._value=t,this._version++,Ee++,Ve();try{for(let r=this._targets;r!==void 0;r=r._nextTarget)r._target._notify()}finally{Oe()}this?._onChange({old:e,revised:n})}}});function rt(t){for(let e=t._sources;e!==void 0;e=e._nextSource)if(e._source._version!==e._version||!e._source._refresh()||e._source._version!==e._version)return!0;return!1}function it(t){for(let e=t._sources;e!==void 0;e=e._nextSource){let n=e._source._node;if(n!==void 0&&(e._rollbackNode=n),e._source._node=e,e._version=-1,e._nextSource===void 0){t._sources=e;break}}}function ot(t){let e=t._sources,n;for(;e!==void 0;){let r=e._prevSource;e._version===-1?(e._source._unsubscribe(e),r!==void 0&&(r._nextSource=e._nextSource),e._nextSource!==void 0&&(e._nextSource._prevSource=r)):n=e,e._source._node=e._rollbackNode,e._rollbackNode!==void 0&&(e._rollbackNode=void 0),e=r}t._sources=n}function z(t){L.call(this,void 0),this._fn=t,this._sources=void 0,this._globalVersion=Ee-1,this._flags=ce}z.prototype=new L;z.prototype._refresh=function(){if(this._flags&=~Q,this._flags&$)return!1;if((this._flags&(ce|Z))===Z||(this._flags&=~ce,this._globalVersion===Ee))return!0;if(this._globalVersion=Ee,this._flags|=$,this._version>0&&!rt(this))return this._flags&=~$,!0;let t=P;try{it(this),P=this;let e=this._fn();(this._flags&Te||this._value!==e||this._version===0)&&(this._value=e,this._flags&=~Te,this._version++)}catch(e){this._value=e,this._flags|=Te,this._version++}return P=t,ot(this),this._flags&=~$,!0};z.prototype._subscribe=function(t){if(this._targets===void 0){this._flags|=ce|Z;for(let e=this._sources;e!==void 0;e=e._nextSource)e._source._subscribe(e)}L.prototype._subscribe.call(this,t)};z.prototype._unsubscribe=function(t){if(this._targets!==void 0&&(L.prototype._unsubscribe.call(this,t),this._targets===void 0)){this._flags&=~Z;for(let e=this._sources;e!==void 0;e=e._nextSource)e._source._unsubscribe(e)}};z.prototype._notify=function(){if(!(this._flags&Q)){this._flags|=ce|Q;for(let t=this._targets;t!==void 0;t=t._nextTarget)t._target._notify()}};Object.defineProperty(z.prototype,"value",{get(){if(this._flags&$)throw q(X,"SignalCycleDetected");let t=nt(this);if(this._refresh(),t!==void 0&&(t._version=this._version),this._flags&Te)throw q(X,"GetComputedError",{value:this._value});return this._value}});function st(t){return new z(t)}function at(t){let e=t._cleanup;if(t._cleanup=void 0,typeof e=="function"){Ve();let n=P;P=void 0;try{e()}catch(r){throw t._flags&=~$,t._flags|=ee,ke(t),q(X,"CleanupEffectError",{error:r})}finally{P=n,Oe()}}}function ke(t){for(let e=t._sources;e!==void 0;e=e._nextSource)e._source._unsubscribe(e);t._fn=void 0,t._sources=void 0,at(t)}function An(t){if(P!==this)throw q(X,"EndEffectError");ot(this),P=t,this._flags&=~$,this._flags&ee&&ke(this),Oe()}function fe(t){this._fn=t,this._cleanup=void 0,this._sources=void 0,this._nextBatchedEffect=void 0,this._flags=Z}fe.prototype._callback=function(){let t=this._start();try{if(this._flags&ee||this._fn===void 0)return;let e=this._fn();typeof e=="function"&&(this._cleanup=e)}finally{t()}};fe.prototype._start=function(){if(this._flags&$)throw q(X,"SignalCycleDetected");this._flags|=$,this._flags&=~ee,at(this),it(this),Ve();let t=P;return P=this,An.bind(this,t)};fe.prototype._notify=function(){this._flags&Q||(this._flags|=Q,this._nextBatchedEffect=ue,ue=this)};fe.prototype._dispose=function(){this._flags|=ee,this._flags&$||ke(this)};function _e(t){let e=new fe(t);try{e._callback()}catch(n){throw e._dispose(),n}return e._dispose.bind(e)}var lt="namespacedSignals",te=t=>{document.dispatchEvent(new CustomEvent(oe,{detail:Object.assign({added:[],removed:[],updated:[]},t)}))};function ut(t,e=!1){let n={};for(let r in t)if(Object.hasOwn(t,r)){if(e&&r.startsWith("_"))continue;let i=t[r];i instanceof L?n[r]=i.value:n[r]=ut(i)}return n}function ct(t,e,n=!1){let r={added:[],removed:[],updated:[]};for(let i in e)if(Object.hasOwn(e,i)){if(i.match(/\_\_+/))throw q(lt,"InvalidSignalKey",{key:i});let s=e[i];if(s instanceof Object&&!Array.isArray(s)){t[i]||(t[i]={});let l=ct(t[i],s,n);r.added.push(...l.added.map(u=>`${i}.${u}`)),r.removed.push(...l.removed.map(u=>`${i}.${u}`)),r.updated.push(...l.updated.map(u=>`${i}.${u}`))}else{if(Object.hasOwn(t,i)){if(n)continue;let g=t[i];if(g instanceof L){let T=g.value;g.value=s,T!==s&&r.updated.push(i);continue}}let u=new L(s);u._onChange=()=>{te({updated:[i]})},t[i]=u,r.added.push(i)}}return r}function ft(t,e){for(let n in t)if(Object.hasOwn(t,n)){let r=t[n];r instanceof L?e(n,r):ft(r,(i,s)=>{e(`${n}.${i}`,s)})}}function En(t,...e){let n={};for(let r of e){let i=r.split("."),s=t,l=n;for(let g=0;g<i.length-1;g++){let T=i[g];if(!s[T])return{};l[T]||(l[T]={}),s=s[T],l=l[T]}let u=i[i.length-1];l[u]=s[u]}return n}var xe=class{#e={};exists(e){return!!this.signal(e)}signal(e){let n=e.split("."),r=this.#e;for(let l=0;l<n.length-1;l++){let u=n[l];if(!r[u])return null;r=r[u]}let i=n[n.length-1],s=r[i];if(!s)throw q(lt,"SignalNotFound",{path:e});return s}setSignal(e,n){let r=e.split("."),i=this.#e;for(let l=0;l<r.length-1;l++){let u=r[l];i[u]||(i[u]={}),i=i[u]}let s=r[r.length-1];i[s]=n}setComputed(e,n){let r=st(()=>n());this.setSignal(e,r)}value(e){return this.signal(e)?.value}setValue(e,n){let r=this.upsertIfMissing(e,n),i=r.value;r.value=n,i!==n&&te({updated:[e]})}upsertIfMissing(e,n){let r=e.split("."),i=this.#e;for(let g=0;g<r.length-1;g++){let T=r[g];i[T]||(i[T]={}),i=i[T]}let s=r[r.length-1],l=i[s];if(l instanceof L)return l;let u=new L(n);return u._onChange=()=>{te({updated:[e]})},i[s]=u,te({added:[e]}),u}remove(...e){if(!e.length){this.#e={};return}let n=Array();for(let r of e){let i=r.split("."),s=this.#e;for(let u=0;u<i.length-1;u++){let g=i[u];if(!s[g])return;s=s[g]}let l=i[i.length-1];delete s[l],n.push(r)}te({removed:n})}merge(e,n=!1){let r=ct(this.#e,e,n);(r.added.length||r.removed.length||r.updated.length)&&te(r)}subset(...e){return En(this.values(),...e)}walk(e){ft(this.#e,e)}paths(){let e=new Array;return this.walk(n=>e.push(n)),e}values(e=!1){return ut(this.#e,e)}JSON(e=!0,n=!1){let r=this.values(n);return e?JSON.stringify(r,null,2):JSON.stringify(r)}toString(){return this.JSON()}};var dt=(t,e)=>`${t}${ie}${e}`,Re=class{aliasPrefix="";#e=new xe;#n=[];#r={};#a=[];#o=null;#t=new Map;get signals(){return this.#e}load(...e){let n=this;for(let r of e){let i={get signals(){return n.#e},effect:l=>_e(l),actions:this.#r,plugin:r,applyAttributePlugin:n.#i.bind(n)},s;switch(r.type){case 2:{let l=r;this.#a.push(l),s=l.onGlobalInit;break}case 3:{this.#r[r.name]=r;break}case 1:{let l=r;this.#n.push(l),s=l.onGlobalInit;break}default:throw H("InvalidPluginType",i)}s&&s(i)}this.#n.sort((r,i)=>{let s=i.name.length-r.name.length;return s!==0?s:r.name.localeCompare(i.name)}),this.#l()}#l=Se(()=>{this.#s(document.body),this.#u()},1);#s(e){le(e,n=>{let r=this.#t.get(n);if(r){for(let[,i]of r)i();this.#t.delete(n)}for(let i of Object.keys(n.dataset))this.#i(n,i)})}#u(){this.#o||(this.#o=new MutationObserver(e=>{for(let{target:n,type:r,attributeName:i,oldValue:s,addedNodes:l,removedNodes:u}of e)switch(r){case"childList":{for(let g of u){let T=g,b=this.#t.get(T);if(b){for(let[w,y]of b)y();this.#t.delete(T)}}for(let g of l){let T=g;this.#s(T)}}break;case"attributes":{{let g="data-",T=g+(this.aliasPrefix?`${this.aliasPrefix}-`:"");if(!i?.startsWith(T))break;let b=n,w=B(i.slice(g.length));if(s!==null&&b.dataset[w]!==s){let y=this.#t.get(b);if(y){let A=dt(w,s),S=y.get(A);S&&(S(),y.delete(A))}}w in b.dataset&&this.#i(b,w)}break}}}),this.#o.observe(document.body,{attributes:!0,attributeOldValue:!0,childList:!0,subtree:!0}))}#i(e,n){let r=n.slice(this.aliasPrefix.length),i=this.#n.find(p=>r.startsWith(p.name));if(!i)return;let s=this.#t.get(e);if(s)for(let[p,o]of s)p.startsWith(n)&&(o(),s.delete(p));e.id.length||(e.id=be(e));let[l,...u]=r.slice(i.name.length).split(/\_\_+/),g=l.length>0;g&&(l=B(l));let T=e.dataset[n]||"",b=T.length>0,w=this,y={get signals(){return w.#e},applyAttributePlugin:w.#i.bind(w),effect:p=>_e(p),actions:this.#r,genRX:()=>this.#c(y,...i.argNames||[]),plugin:i,el:e,rawKey:r,key:l,value:T,mods:new Map},A=i.keyReq||0;if(g){if(A===2)throw N(`${i.name}KeyNotAllowed`,y)}else if(A===1)throw N(`${i.name}KeyRequired`,y);let S=i.valReq||0;if(b){if(S===2)throw N(`${i.name}ValueNotAllowed`,y)}else if(S===1)throw N(`${i.name}ValueRequired`,y);if(A===3||S===3){if(g&&b)throw N(`${i.name}KeyAndValueProvided`,y);if(!g&&!b)throw N(`${i.name}KeyOrValueRequired`,y)}for(let p of u){let[o,...d]=p.split(".");y.mods.set(B(o),new Set(d.map(c=>c.toLowerCase())))}let E=i.onLoad(y);if(E){let p=this.#t.get(e);p||(p=new Map,this.#t.set(e,p)),p.set(dt(n,T),E)}let v=i.removeOnLoad;v&&v(r)===!0&&delete e.dataset[n]}#c(e,...n){let r="",i=/(\/(\\\/|[^\/])*\/|"(\\"|[^\"])*"|'(\\'|[^'])*'|`(\\`|[^`])*`|[^;])+/gm,s=e.value.trim().match(i);if(s){let S=s.length-1,E=s[S].trim();E.startsWith("return")||(s[S]=`return (${E});`),r=s.join(`;
|
|
`)}let l=new Map,u=new RegExp(`(?:${ie})(.*?)(?:${Ce})`,"gm");for(let S of r.matchAll(u)){let E=S[1],v=new ae("dsEscaped").with(E).value;l.set(v,E),r=r.replace(ie+E+Ce,v)}let g=/@(\w*)\(/gm,T=r.matchAll(g),b=new Set;for(let S of T)b.add(S[1]);let w=new RegExp(`@(${Object.keys(this.#r).join("|")})\\(`,"gm");r=r.replaceAll(w,"ctx.actions.$1.fn(ctx,");let y=e.signals.paths();if(y.length){let S=new RegExp(`\\$(${y.join("|")})(\\W|$)`,"gm");r=r.replaceAll(S,"ctx.signals.signal('$1').value$2")}for(let[S,E]of l)r=r.replace(S,E);let A=`return (()=> {
|
|
${r}
|
|
})()`;e.fnContent=A;try{let S=new Function("ctx",...n,A);return(...E)=>{try{return S(e,...E)}catch(v){throw N("ExecuteExpression",e,{error:v.message})}}}catch(S){throw N("GenerateExpression",e,{error:S.message})}}};var pt=new Re;pt.load(Ze,Qe,Xe);var Fe=pt;async function _n(t,e){let n=t.getReader(),r;for(;!(r=await n.read()).done;)e(r.value)}function xn(t){let e,n,r,i=!1;return function(l){e===void 0?(e=l,n=0,r=-1):e=wn(e,l);let u=e.length,g=0;for(;n<u;){i&&(e[n]===10&&(g=++n),i=!1);let T=-1;for(;n<u&&T===-1;++n)switch(e[n]){case 58:r===-1&&(r=n-g);break;case 13:i=!0;case 10:T=n;break}if(T===-1)break;t(e.subarray(g,T),r),g=n,r=-1}g===u?e=void 0:g!==0&&(e=e.subarray(g),n-=g)}}function Rn(t,e,n){let r=mt(),i=new TextDecoder;return function(l,u){if(l.length===0)n?.(r),r=mt();else if(u>0){let g=i.decode(l.subarray(0,u)),T=u+(l[u+1]===32?2:1),b=i.decode(l.subarray(T));switch(g){case"data":r.data=r.data?`${r.data}
|
|
${b}`:b;break;case"event":r.event=b;break;case"id":t(r.id=b);break;case"retry":{let w=Number.parseInt(b,10);Number.isNaN(w)||e(r.retry=w);break}}}}}function wn(t,e){let n=new Uint8Array(t.length+e.length);return n.set(t),n.set(e,t.length),n}function mt(){return{data:"",event:"",id:"",retry:void 0}}var Mn="text/event-stream",gt="last-event-id";function ht(t,e,{signal:n,headers:r,onopen:i,onmessage:s,onclose:l,onerror:u,openWhenHidden:g,fetch:T,retryInterval:b=1e3,retryScaler:w=2,retryMaxWaitMs:y=3e4,retryMaxCount:A=10,...S}){return new Promise((E,v)=>{let p=0,o={...r};o.accept||(o.accept=Mn);let d;function c(){d.abort(),document.hidden||_()}g||document.addEventListener("visibilitychange",c);let a=0;function h(){document.removeEventListener("visibilitychange",c),window.clearTimeout(a),d.abort()}n?.addEventListener("abort",()=>{h(),E()});let f=T??window.fetch,m=i??function(){};async function _(){d=new AbortController;try{let R=await f(e,{...S,headers:o,signal:d.signal});await m(R),await _n(R.body,xn(Rn(x=>{x?o[gt]=x:delete o[gt]},x=>{b=x},s))),l?.(),h(),E()}catch(R){if(!d.signal.aborted)try{let x=u?.(R)??b;window.clearTimeout(a),a=window.setTimeout(_,x),b*=w,b=Math.min(b,y),p++,p>=A?(h(),v(N("SseMaxRetries",t,{retryMaxCount:A}))):console.error(`Datastar failed to reach ${S.method}: ${e.toString()} retry in ${x}ms`)}catch(x){h(),v(x)}}}_()})}var ne=`${O}-sse`,He=`${O}-settling`,Y=`${O}-swapping`,we="started",Me="finished",vt="error",yt="retrying";function G(t,e){document.addEventListener(ne,n=>{if(n.detail.type!==t)return;let{argsRaw:r}=n.detail;e(r)})}function de(t,e){document.dispatchEvent(new CustomEvent(ne,{detail:{type:t,argsRaw:e}}))}var bt=t=>`${t}`.includes("text/event-stream"),U=async(t,e,n,r)=>{let{el:{id:i},el:s,signals:l}=t,{headers:u,contentType:g,includeLocal:T,selector:b,openWhenHidden:w,retryInterval:y,retryScaler:A,retryMaxWaitMs:S,retryMaxCount:E,abort:v}=Object.assign({headers:{},contentType:"json",includeLocal:!1,selector:null,openWhenHidden:!1,retryInterval:je,retryScaler:2,retryMaxWaitMs:3e4,retryMaxCount:10,abort:void 0},r),p=e.toLowerCase(),o=()=>{};try{if(de(we,{elId:i}),!n?.length)throw N("SseNoUrlProvided",t,{action:p});let d={};d[Be]=!0,g==="json"&&(d["Content-Type"]="application/json");let c=Object.assign({},d,u),a={method:e,headers:c,openWhenHidden:w,retryInterval:y,retryScaler:A,retryMaxWaitMs:S,retryMaxCount:E,signal:v,onopen:async m=>{if(m.status>=400){let _=m.status.toString();de(vt,{status:_})}},onmessage:m=>{if(!m.event.startsWith(O))return;let _=m.event,R={},x=m.data.split(`
|
|
`);for(let I of x){let D=I.indexOf(" "),Ge=I.slice(0,D),ge=R[Ge];ge||(ge=[],R[Ge]=ge);let hn=I.slice(D+1).trim();ge.push(hn)}let C={};for(let[I,D]of Object.entries(R))C[I]=D.join(`
|
|
`);de(_,C)},onerror:m=>{if(bt(m))throw N("InvalidContentType",t,{url:n});m&&(console.error(m.message),de(yt,{message:m.message}))}},h=new URL(n,window.location.origin),f=new URLSearchParams(h.search);if(g==="json"){let m=l.JSON(!1,!T);e==="GET"?f.set(O,m):a.body=m}else if(g==="form"){let m=b?document.querySelector(b):s.closest("form");if(m===null)throw b?N("SseFormNotFound",t,{action:p,selector:b}):N("SseClosestFormNotFound",t,{action:p});if(s!==m){let R=x=>x.preventDefault();m.addEventListener("submit",R),o=()=>m.removeEventListener("submit",R)}if(!m.checkValidity()){m.reportValidity(),o();return}let _=new FormData(m);if(e==="GET"){let R=new URLSearchParams(_);for(let[x,C]of R)f.set(x,C)}else a.body=_}else throw N("SseInvalidContentType",t,{action:p,contentType:g});h.search=f.toString();try{await ht(t,h.toString(),a)}catch(m){if(!bt(m))throw N("SseFetchFailed",t,{method:e,url:n,error:m})}}finally{de(Me,{elId:i}),o()}};var St={type:3,name:"delete",fn:async(t,e,n)=>U(t,"DELETE",e,{...n})};var Tt={type:3,name:"get",fn:async(t,e,n)=>U(t,"GET",e,{...n})};var At={type:3,name:"patch",fn:async(t,e,n)=>U(t,"PATCH",e,{...n})};var Et={type:3,name:"post",fn:async(t,e,n)=>U(t,"POST",e,{...n})};var _t={type:3,name:"put",fn:async(t,e,n)=>U(t,"PUT",e,{...n})};var xt={type:1,name:"indicator",keyReq:3,valReq:3,onLoad:({el:t,key:e,mods:n,signals:r,value:i})=>{let s=e?V(e,n):K(i),l=r.upsertIfMissing(s,!1),u=g=>{let{type:T,argsRaw:{elId:b}}=g.detail;if(b===t.id)switch(T){case we:l.value=!0;break;case Me:l.value=!1;break}};return document.addEventListener(ne,u),()=>{document.removeEventListener(ne,u)}}};var Rt={type:2,name:k.ExecuteScript,onGlobalInit:async t=>{G(k.ExecuteScript,({autoRemove:e=`${ze}`,attributes:n=Ke,script:r})=>{let i=j(e);if(!r?.length)throw H("NoScriptProvided",t);let s=document.createElement("script");for(let l of n.split(`
|
|
`)){let u=l.indexOf(" "),g=u?l.slice(0,u):l,T=u?l.slice(u):"";s.setAttribute(g.trim(),T.trim())}s.text=r,document.head.appendChild(s),i&&s.remove()})}};var pe=document,J=!!pe.startViewTransition;var wt=function(){"use strict";let t=()=>{},e={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:t,afterNodeAdded:t,beforeNodeMorphed:t,afterNodeMorphed:t,beforeNodeRemoved:t,afterNodeRemoved:t,beforeAttributeUpdated:t},head:{style:"merge",shouldPreserve:y=>y.getAttribute("im-preserve")==="true",shouldReAppend:y=>y.getAttribute("im-re-append")==="true",shouldRemove:t,afterHeadMorphed:t},restoreFocus:!0};function n(y,A,S={}){y=b(y);let E=w(A),v=T(y,E,S),p=i(v,()=>u(v,y,E,o=>o.morphStyle==="innerHTML"?(s(o,y,E),Array.from(y.childNodes)):r(o,y,E)));return v.pantry.remove(),p}function r(y,A,S){let E=w(A),v=Array.from(E.childNodes),p=v.indexOf(A),o=v.length-(p+1);return s(y,E,S,A,A.nextSibling),v=Array.from(E.childNodes),v.slice(p,v.length-o)}function i(y,A){if(!y.config.restoreFocus)return A();let S=document.activeElement;if(!(S instanceof HTMLInputElement||S instanceof HTMLTextAreaElement))return A();let{id:E,selectionStart:v,selectionEnd:p}=S,o=A();return E&&E!==document.activeElement?.id&&(S=y.target.querySelector(`#${E}`),S?.focus()),S&&v&&p&&S.setSelectionRange(v,p),o}let s=function(){function y(c,a,h,f=null,m=null){a instanceof HTMLTemplateElement&&h instanceof HTMLTemplateElement&&(a=a.content,h=h.content),f||=a.firstChild;for(let _ of h.childNodes){if(f&&f!=m){let x=S(c,_,f,m);if(x){x!==f&&v(c,f,x),l(x,_,c),f=x.nextSibling;continue}}if(_ instanceof Element&&c.persistentIds.has(_.id)){let x=p(a,_.id,f,c);l(x,_,c),f=x.nextSibling;continue}let R=A(a,_,f,c);R&&(f=R.nextSibling)}for(;f&&f!=m;){let _=f;f=f.nextSibling,E(c,_)}}function A(c,a,h,f){if(f.callbacks.beforeNodeAdded(a)===!1)return null;if(f.idMap.has(a)&&a instanceof Element){let m=document.createElement(a.tagName);return c.insertBefore(m,h),l(m,a,f),f.callbacks.afterNodeAdded(m),m}else{let m=document.importNode(a,!0);return c.insertBefore(m,h),f.callbacks.afterNodeAdded(m),m}}let S=function(){function c(f,m,_,R){let x=null,C=m.nextSibling,I=0,D=_;for(;D&&D!=R;){if(h(D,m)){if(a(f,D,m))return D;x===null&&(f.idMap.has(D)||(x=D))}x===null&&C&&h(D,C)&&(I++,C=C.nextSibling,I>=2&&(x=void 0)),D=D.nextSibling}return x||null}function a(f,m,_){let R=f.idMap.get(m),x=f.idMap.get(_);if(!x||!R)return!1;for(let C of R)if(x.has(C))return!0;return!1}function h(f,m){let _=f,R=m;return _.nodeType===R.nodeType&&_.tagName===R.tagName&&(!_.id||_.id===R.id)}return c}();function E(c,a){if(c.idMap.has(a)&&a instanceof Element)d(c.pantry,a,null);else{if(c.callbacks.beforeNodeRemoved(a)===!1)return;a.parentNode?.removeChild(a),c.callbacks.afterNodeRemoved(a)}}function v(c,a,h){let f=a;for(;f&&f!==h;){let m=f;f=f.nextSibling,E(c,m)}return f}function p(c,a,h,f){let m=f.target.querySelector(`#${a}`)||f.pantry.querySelector(`#${a}`);return o(m,f),d(c,m,h),m}function o(c,a){let h=c.id;for(;c=c.parentNode;){let f=a.idMap.get(c);f&&(f.delete(h),f.size||a.idMap.delete(c))}}function d(c,a,h){if(c.moveBefore)try{c.moveBefore(a,h)}catch{c.insertBefore(a,h)}else c.insertBefore(a,h)}return y}(),l=function(){function y(o,d,c){return c.ignoreActive&&o===document.activeElement?null:(c.callbacks.beforeNodeMorphed(o,d)===!1||(o instanceof HTMLHeadElement&&c.head.ignore||(o instanceof HTMLHeadElement&&c.head.style!=="morph"?g(o,d,c):(A(o,d,c),p(o,c)||s(c,o,d))),c.callbacks.afterNodeMorphed(o,d)),o)}function A(o,d,c){let a=d.nodeType;if(a===1){let h=o,f=d,m=h.attributes,_=f.attributes;for(let R of _)v(R.name,h,"update",c)||h.getAttribute(R.name)!==R.value&&h.setAttribute(R.name,R.value);for(let R=m.length-1;0<=R;R--){let x=m[R];if(x&&!f.hasAttribute(x.name)){if(v(x.name,h,"remove",c))continue;h.removeAttribute(x.name)}}p(h,c)||S(h,f,c)}(a===8||a===3)&&o.nodeValue!==d.nodeValue&&(o.nodeValue=d.nodeValue)}function S(o,d,c){if(o instanceof HTMLInputElement&&d instanceof HTMLInputElement&&d.type!=="file"){let a=d.value,h=o.value;E(o,d,"checked",c),E(o,d,"disabled",c),d.hasAttribute("value")?h!==a&&(v("value",o,"update",c)||(o.setAttribute("value",a),o.value=a)):v("value",o,"remove",c)||(o.value="",o.removeAttribute("value"))}else if(o instanceof HTMLOptionElement&&d instanceof HTMLOptionElement)E(o,d,"selected",c);else if(o instanceof HTMLTextAreaElement&&d instanceof HTMLTextAreaElement){let a=d.value,h=o.value;if(v("value",o,"update",c))return;a!==h&&(o.value=a),o.firstChild&&o.firstChild.nodeValue!==a&&(o.firstChild.nodeValue=a)}}function E(o,d,c,a){let h=d[c],f=o[c];if(h!==f){let m=v(c,o,"update",a);m||(o[c]=d[c]),h?m||o.setAttribute(c,""):v(c,o,"remove",a)||o.removeAttribute(c)}}function v(o,d,c,a){return o==="value"&&a.ignoreActiveValue&&d===document.activeElement?!0:a.callbacks.beforeAttributeUpdated(o,d,c)===!1}function p(o,d){return!!d.ignoreActiveValue&&o===document.activeElement&&o!==document.body}return y}();function u(y,A,S,E){if(y.head.block){let v=A.querySelector("head"),p=S.querySelector("head");if(v&&p){let o=g(v,p,y);return Promise.all(o).then(()=>{let d=Object.assign(y,{head:{block:!1,ignore:!0}});return E(d)})}}return E(y)}function g(y,A,S){let E=[],v=[],p=[],o=[],d=new Map;for(let a of A.children)d.set(a.outerHTML,a);for(let a of y.children){let h=d.has(a.outerHTML),f=S.head.shouldReAppend(a),m=S.head.shouldPreserve(a);h||m?f?v.push(a):(d.delete(a.outerHTML),p.push(a)):S.head.style==="append"?f&&(v.push(a),o.push(a)):S.head.shouldRemove(a)!==!1&&v.push(a)}o.push(...d.values());let c=[];for(let a of o){let h=document.createRange().createContextualFragment(a.outerHTML).firstChild;if(S.callbacks.beforeNodeAdded(h)!==!1){if("href"in h&&h.href||"src"in h&&h.src){let f,m=new Promise(function(_){f=_});h.addEventListener("load",function(){f()}),c.push(m)}y.appendChild(h),S.callbacks.afterNodeAdded(h),E.push(h)}}for(let a of v)S.callbacks.beforeNodeRemoved(a)!==!1&&(y.removeChild(a),S.callbacks.afterNodeRemoved(a));return S.head.afterHeadMorphed(y,{added:E,kept:p,removed:v}),c}let T=function(){function y(o,d,c){let a=A(c),{persistentIds:h,idMap:f}=p(o,d),m=a.morphStyle||"outerHTML";if(!["innerHTML","outerHTML"].includes(m))throw`Do not understand how to morph style ${m}`;return{target:o,newContent:d,config:a,morphStyle:m,ignoreActive:a.ignoreActive,ignoreActiveValue:a.ignoreActiveValue,restoreFocus:a.restoreFocus,idMap:f,persistentIds:h,pantry:S(),callbacks:a.callbacks,head:a.head}}function A(o){let d=Object.assign({},e);return Object.assign(d,o),d.callbacks=Object.assign({},e.callbacks,o.callbacks),d.head=Object.assign({},e.head,o.head),d}function S(){let o=document.createElement("div");return o.hidden=!0,document.body.insertAdjacentElement("afterend",o),o}function E(o){let d=Array.from(o.querySelectorAll("[id]"));return o.id&&d.push(o),d}function v(o,d,c,a){for(let h of d)if(c.has(h.id)){let f=h;for(;f;){let m=a.get(f);if(m==null&&(m=new Set,a.set(f,m)),m.add(h.id),f===o)break;f=f.parentElement}}}function p(o,d){let c=new Map,a=new Set,h=E(o);for(let x of h){let C=x.id;c.has(C)?a.add(C):c.set(C,x.tagName)}let f=new Set,m=E(d);for(let x of m){let C=x.id,I=c.get(C);(f.has(C)||I&&I!==x.tagName)&&(a.add(C),f.delete(C)),I===x.tagName&&!a.has(C)&&f.add(C)}let _=new Map;v(o,h,f,_);let R=d;return d.__idiomorphDummyParent&&(R=d.childNodes[0]),v(R,m,f,_),{persistentIds:f,idMap:_}}return y}(),{normalizeElement:b,normalizeParent:w}=function(){let y=new WeakSet;function A(v){return v instanceof Document?v.documentElement:v}function S(v){if(v==null)return document.createElement("div");if(typeof v=="string")return S(E(v));if(y.has(v))return v;if(v instanceof Node){if(v.parentNode)return{childNodes:[v],querySelectorAll:p=>{let o=v.querySelectorAll(p);return v.matches(p)?[v,...o]:o},insertBefore:(p,o)=>v.parentNode.insertBefore(p,o),moveBefore:(p,o)=>v.parentNode.moveBefore(p,o),__idiomorphDummyParent:!0};{let p=document.createElement("div");return p.append(v),p}}else{let p=document.createElement("div");for(let o of[...v])p.append(o);return p}}function E(v){let p=new DOMParser,o=v.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(o.match(/<\/html>/)||o.match(/<\/head>/)||o.match(/<\/body>/)){let d=p.parseFromString(v,"text/html");if(o.match(/<\/html>/))return y.add(d),d;{let c=d.firstChild;return c&&y.add(c),c}}else{let c=p.parseFromString("<body><template>"+v+"</template></body>","text/html").body.querySelector("template").content;return y.add(c),c}}return{normalizeElement:A,normalizeParent:S}}();return{morph:n,defaults:e}}();var Nt={type:2,name:k.MergeFragments,onGlobalInit:async t=>{let e=document.createElement("template");G(k.MergeFragments,({fragments:n="<div></div>",selector:r="",mergeMode:i=Ye,settleDuration:s=`${he}`,useViewTransition:l=`${ve}`})=>{let u=Number.parseInt(s),g=j(l);e.innerHTML=n.trim();let T=[...e.content.children];for(let b of T){if(!(b instanceof Element))throw H("NoFragmentsFound",t);let w=r||`#${b.getAttribute("id")}`,y=[...document.querySelectorAll(w)||[]];if(!y.length)throw H("NoTargetsFound",t,{selectorOrID:w});g&&J?pe.startViewTransition(()=>Mt(t,i,u,b,y)):Mt(t,i,u,b,y)}})}};function Mt(t,e,n,r,i){for(let s of i){s.classList.add(Y);let l=s.outerHTML,u=s;switch(e){case W.Morph:{let b=new Map,w=r.cloneNode(!0);le(w,A=>{!A.id?.length&&Object.keys(A.dataset).length&&(A.id=be(A))});let y=wt.morph(u,w,{restoreFocus:!0,callbacks:{beforeAttributeUpdated:(A,S,E)=>{if(E==="update"&&A.startsWith("data-")){let v=b.get(S);v||(v=[],b.set(S,v));let p=A.slice(5);v.push(B(p))}return!0}}});if(y?.length){u=y[0];for(let[A,S]of b.entries())for(let E of S)t.applyAttributePlugin(A,E)}break}case W.Inner:u.innerHTML=r.outerHTML;break;case W.Outer:u.replaceWith(r);break;case W.Prepend:u.prepend(r);break;case W.Append:u.append(r);break;case W.Before:u.before(r);break;case W.After:u.after(r);break;case W.UpsertAttributes:for(let b of r.getAttributeNames()){let w=r.getAttribute(b);u.setAttribute(b,w)}break;default:throw H("InvalidMergeMode",t,{mergeMode:e})}let g=u.classList;g?.add(Y),setTimeout(()=>{s.classList.remove(Y),g?.remove(Y)},n);let T=u.outerHTML;g&&l!==T&&(g.add(He),setTimeout(()=>{g.remove(He)},n))}}var Pt={type:2,name:k.MergeSignals,onGlobalInit:async t=>{G(k.MergeSignals,({signals:e="{}",onlyIfMissing:n=`${Je}`})=>{let{signals:r}=t,i=j(n);r.merge(ye(e),i)})}};var Ct={type:2,name:k.RemoveFragments,onGlobalInit:async t=>{G(k.RemoveFragments,({selector:e,settleDuration:n=`${he}`,useViewTransition:r=`${ve}`})=>{if(!e.length)throw H("NoSelectorProvided",t);let i=Number.parseInt(n),s=j(r),l=document.querySelectorAll(e),u=()=>{for(let g of l)g.classList.add(Y);setTimeout(()=>{for(let g of l)g.remove()},i)};s&&J?pe.startViewTransition(()=>u()):u()})}};var Lt={type:2,name:k.RemoveSignals,onGlobalInit:async t=>{G(k.RemoveSignals,({paths:e=""})=>{let n=e.split(`
|
|
`).map(r=>r.trim());if(!n?.length)throw H("NoPathsProvided",t);t.signals.remove(...n)})}};var It={type:3,name:"clipboard",fn:(t,e)=>{if(!navigator.clipboard)throw N("ClipboardNotAvailable",t);navigator.clipboard.writeText(e)}};var Dt={type:1,name:"customValidity",keyReq:2,valReq:1,onLoad:t=>{let{el:e,genRX:n,effect:r}=t;if(!(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement))throw N("CustomValidityInvalidElement",t);let i=n();return r(()=>{let s=i();if(typeof s!="string")throw N("CustomValidityInvalidExpression",t,{result:s});e.setCustomValidity(s)})}};var Vt="once",Ot="half",kt="full",Ft={type:1,name:"intersects",keyReq:2,mods:new Set([Vt,Ot,kt]),onLoad:({el:t,rawKey:e,mods:n,genRX:r})=>{let i={threshold:0};n.has(kt)?i.threshold=1:n.has(Ot)&&(i.threshold=.5);let s=r(),l=new IntersectionObserver(u=>{for(let g of u)g.isIntersecting&&(s(),n.has(Vt)&&(l.disconnect(),delete t.dataset[e]))},i);return l.observe(t),()=>l.disconnect()}};var Ht="session",Wt={type:1,name:"persist",mods:new Set([Ht]),onLoad:({key:t,effect:e,mods:n,signals:r,value:i})=>{t=V(t,n),t===""&&(t=O);let s=n.has(Ht)?sessionStorage:localStorage,l=i.split(/\s+/).filter(T=>T!=="");l=l.map(T=>K(T));let u=()=>{let T=s.getItem(t)||"{}",b=JSON.parse(T);r.merge(b)},g=()=>{let T;l.length?T=r.subset(...l):T=r.values(),s.setItem(t,JSON.stringify(T))};return u(),e(()=>{g()})}};var qt={type:1,name:"replaceUrl",keyReq:2,valReq:1,onLoad:({effect:t,genRX:e})=>{let n=e();return t(()=>{let r=n(),i=window.location.href,s=new URL(r,i).toString();window.history.replaceState({},"",s)})}};var Ne="smooth",We="instant",qe="auto",$t="hstart",Gt="hcenter",Ut="hend",Bt="hnearest",jt="vstart",Kt="vcenter",Jt="vend",zt="vnearest",Nn="focus",Pe="center",Yt="start",Xt="end",Qt="nearest",Zt={type:1,name:"scrollIntoView",keyReq:2,valReq:2,mods:new Set([Ne,We,qe,$t,Gt,Ut,Bt,jt,Kt,Jt,zt,Nn]),onLoad:t=>{let{el:e,mods:n,rawKey:r}=t;e.tabIndex||e.setAttribute("tabindex","0");let i={behavior:Ne,block:Pe,inline:Pe};if(n.has(Ne)&&(i.behavior=Ne),n.has(We)&&(i.behavior=We),n.has(qe)&&(i.behavior=qe),n.has($t)&&(i.inline=Yt),n.has(Gt)&&(i.inline=Pe),n.has(Ut)&&(i.inline=Xt),n.has(Bt)&&(i.inline=Qt),n.has(jt)&&(i.block=Yt),n.has(Kt)&&(i.block=Pe),n.has(Jt)&&(i.block=Xt),n.has(zt)&&(i.block=Qt),!(e instanceof HTMLElement||e instanceof SVGElement))throw N("ScrollIntoViewInvalidElement",t);return e.tabIndex||e.setAttribute("tabindex","0"),e.scrollIntoView(i),n.has("focus")&&e.focus(),delete e.dataset[r],()=>{}}};var en="none",tn="display",nn={type:1,name:"show",keyReq:2,valReq:1,onLoad:({el:{style:t},genRX:e,effect:n})=>{let r=e();return n(async()=>{r()?t.display===en&&t.removeProperty(tn):t.setProperty(tn,en)})}};var rn="view-transition",on={type:1,name:"viewTransition",keyReq:2,valReq:1,onGlobalInit(){let t=!1;for(let e of document.head.childNodes)e instanceof HTMLMetaElement&&e.name===rn&&(t=!0);if(!t){let e=document.createElement("meta");e.name=rn,e.content="same-origin",document.head.appendChild(e)}},onLoad:({effect:t,el:e,genRX:n})=>{if(!J){console.error("Browser does not support view transitions");return}let r=n();return t(()=>{let i=r();if(!i?.length)return;let s=e.style;s.viewTransitionName=i})}};var sn={type:1,name:"attr",valReq:1,onLoad:({el:t,key:e,effect:n,genRX:r})=>{let i=r();return e===""?n(async()=>{let s=i();for(let[l,u]of Object.entries(s))t.setAttribute(l,u)}):(e=se(e),n(async()=>{let s=!1;try{s=i()}catch{}let l;typeof s=="string"?l=s:l=JSON.stringify(s),!l||l==="false"||l==="null"||l==="undefined"?t.removeAttribute(e):t.setAttribute(e,l)}))}};var Pn=/^data:(?<mime>[^;]+);base64,(?<contents>.*)$/,an=["change","input","keydown"],ln={type:1,name:"bind",keyReq:3,valReq:3,onLoad:t=>{let{el:e,key:n,mods:r,signals:i,value:s,effect:l}=t,u=n?V(n,r):K(s),g=()=>{},T=()=>{},b=e.tagName.toLowerCase(),w="",y=b.includes("input"),A=e.getAttribute("type"),S=b.includes("checkbox")||y&&A==="checkbox";S&&(w=!1),y&&A==="number"&&(w=0);let v=b.includes("select"),p=b.includes("radio")||y&&A==="radio",o=y&&A==="file";p&&(e.getAttribute("name")?.length||e.setAttribute("name",u)),i.upsertIfMissing(u,w),g=()=>{let a="value"in e,h=i.value(u),f=`${h}`;if(S||p){let m=e;S?m.checked=!!h||h==="true":p&&(m.checked=f===m.value)}else if(!o)if(v){let m=e;if(m.multiple)for(let _ of m.options){if(_?.disabled)return;Array.isArray(h)||typeof h=="string"?_.selected=h.includes(_.value):typeof h=="number"?_.selected=h===Number(_.value):_.selected=h}else m.value=f}else a?e.value=f:e.setAttribute("value",f)},T=async()=>{if(o){let f=[...e?.files||[]],m=[],_=[],R=[];await Promise.all(f.map(x=>new Promise(C=>{let I=new FileReader;I.onload=()=>{if(typeof I.result!="string")throw N("InvalidFileResultType",t,{resultType:typeof I.result});let D=I.result.match(Pn);if(!D?.groups)throw N("InvalidDataUri",t,{result:I.result});m.push(D.groups.contents),_.push(D.groups.mime),R.push(x.name)},I.onloadend=()=>C(void 0),I.readAsDataURL(x)}))),i.setValue(u,m),i.setValue(`${u}Mimes`,_),i.setValue(`${u}Names`,R);return}let a=i.value(u),h=e||e;if(typeof a=="number"){let f=Number(h.value||h.getAttribute("value"));i.setValue(u,f)}else if(typeof a=="string"){let f=h.value||h.getAttribute("value")||"";i.setValue(u,f)}else if(typeof a=="boolean")if(S){let f=h.checked||h.getAttribute("checked")==="true";i.setValue(u,f)}else{let f=!!(h.value||h.getAttribute("value"));i.setValue(u,f)}else if(!(typeof a>"u"))if(Array.isArray(a))if(v){let _=[...e.selectedOptions].filter(R=>R.selected).map(R=>R.value);i.setValue(u,_)}else{let f=JSON.stringify(h.value.split(","));i.setValue(u,f)}else throw N("BindUnsupportedSignalType",t,{signalType:typeof a})};for(let a of an)e.addEventListener(a,T);let d=l(()=>g()),c=a=>{a.persisted&&T()};return window.addEventListener("pageshow",c),()=>{d();for(let a of an)e.removeEventListener(a,T);window.removeEventListener("pageshow",c)}}};var un={type:1,name:"class",valReq:1,onLoad:({el:t,key:e,mods:n,effect:r,genRX:i})=>{let s=t.classList,l=i();return r(()=>{if(e===""){let u=l();for(let[g,T]of Object.entries(u)){let b=g.split(/\s+/);T?s.add(...b):s.remove(...b)}}else e=V(e,n),l()?s.add(e):s.remove(e)})}};function me(t){if(!t||t.size<=0)return 0;for(let e of t){if(e.endsWith("ms"))return Number(e.replace("ms",""));if(e.endsWith("s"))return Number(e.replace("s",""))*1e3;try{return Number.parseFloat(e)}catch{}}return 0}function re(t,e,n=!1){return t?t.has(e.toLowerCase()):n}var Cn="evt",$e="signalsChange",Ln=$e.length,cn={type:1,name:"on",keyReq:1,valReq:1,argNames:[Cn],removeOnLoad:t=>t.startsWith("onLoad"),onLoad:({el:t,key:e,mods:n,rawKey:r,signals:i,value:s,effect:l,genRX:u})=>{let g=u(),T=t;n.has("window")&&(T=window);let b=p=>{p&&((n.has("prevent")||e==="submit")&&p.preventDefault(),n.has("stop")&&p.stopPropagation()),g(p)},w=n.get("delay");if(w){let p=me(w);b=Se(b,p)}let y=n.get("debounce");if(y){let p=me(y),o=re(y,"leading",!1),d=!re(y,"notrail",!1);b=et(b,p,o,d)}let A=n.get("throttle");if(A){let p=me(A),o=!re(A,"noleading",!1),d=re(A,"trail",!1);b=tt(b,p,o,d)}if(n.has("viewtransition")&&J){let p=b;b=(...o)=>document.startViewTransition(()=>p(...o))}let S={capture:!0,passive:!1,once:!1};if(n.has("capture")||(S.capture=!1),n.has("passive")&&(S.passive=!0),n.has("once")&&(S.once=!0),e==="load")return setTimeout(()=>b(),0),()=>{};if(e==="interval"){let p=1e3,o=n.get("duration");o&&(p=me(o),re(o,"leading",!1)&&(t.dataset[r.replace(".leading","")]=s,delete t.dataset[r],b()));let d=setInterval(b,p);return()=>{clearInterval(d)}}if(e==="raf"){let p,o=()=>{b(),p=requestAnimationFrame(o)};return p=requestAnimationFrame(o),()=>{p&&cancelAnimationFrame(p)}}if(e.startsWith($e)){if(e===$e){b();let d=c=>b(c);return document.addEventListener(oe,d),()=>{document.removeEventListener(oe,d)}}let p=V(B(e.slice(Ln)),n),o=new Map;return i.walk((d,c)=>{d.startsWith(p)&&o.set(c,c.value)}),l(()=>{for(let[d,c]of o)c!==d.value&&(b(),o.set(d,d.value))})}if(n.has("outside")){T=document;let p=b;b=d=>{let c=d?.target;t.contains(c)||p(d)}}let v=V(e,n);return T.addEventListener(v,b,S),()=>{T.removeEventListener(v,b)}}};var fn={type:1,name:"ref",keyReq:3,valReq:3,onLoad:({el:t,key:e,mods:n,signals:r,value:i})=>{let s=e?V(e,n):K(i);r.setValue(s,t)}};var dn={type:1,name:"text",keyReq:2,valReq:1,onLoad:t=>{let{el:e,effect:n,genRX:r}=t,i=r();return e instanceof HTMLElement||N("TextInvalidElement",t),n(()=>{let s=i(t);e.textContent=`${s}`})}};var{round:In,max:Dn,min:Vn}=Math,pn={type:3,name:"fit",fn:(t,e,n,r,i,s,l=!1,u=!1)=>{let g=(e-n)/(r-n)*(s-i)+i;return u&&(g=In(g)),l&&(g=Dn(i,Vn(s,g))),g}};var mn={type:3,name:"setAll",fn:({signals:t},e,n)=>{t.walk((r,i)=>{r.startsWith(e)&&(i.value=n)})}};var gn={type:3,name:"toggleAll",fn:({signals:t},e)=>{t.walk((n,r)=>{n.startsWith(e)&&(r.value=!r.value)})}};Fe.load(St,Tt,At,Et,_t,xt,Rt,Nt,Pt,Ct,Lt,It,Dt,Ft,Wt,qt,Zt,nn,on,sn,ln,un,cn,fn,dn,pn,mn,gn);var rs=Fe;export{rs as Datastar};
|
|
//# sourceMappingURL=datastar-1-0-0-beta-7-aebc4a389b667764.js.map
|