@coldwired/actions
Advanced tools
Comparing version 0.4.1 to 0.5.0
@@ -1,1 +0,1 @@ | ||
"use strict";var j=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var r=(i,e,t)=>(j(i,e,"read from private field"),t?t.call(i):e.get(i)),c=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},l=(i,e,t,a)=>(j(i,e,"write to private field"),a?a.call(i,t):e.set(i,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@coldwired/utils"),B=require("morphdom");var z=process.env.NODE_ENV==="production",k="Invariant failed";function _(i,e){if(!i){if(z)throw new Error(k);var t=typeof e=="function"?e():e,a=t?"".concat(k,": ").concat(t):k;throw new Error(a)}}var S,w,C;class J{constructor(e,t){c(this,S,void 0);c(this,w,void 0);c(this,C,void 0);l(this,S,e),l(this,w,new MutationObserver(a=>{for(const s of a)this.onAttributeMutation(s)})),l(this,C,t)}observe(){r(this,w).observe(r(this,S),{attributes:!0,attributeFilter:["class"],attributeOldValue:!0,subtree:!0})}disconnect(){r(this,w).disconnect()}onAttributeMutation(e){if(o.isElement(e.target))if(e.oldValue){const t=new Set(e.oldValue.split(/\s/).filter(Boolean));r(this,C).classListChanged(e.target,t)}else r(this,C).classListChanged(e.target,new Set([]))}}S=new WeakMap,w=new WeakMap,C=new WeakMap;const U=["role","disabled","tab-index","aria-autocomplete","aria-checked","aria-disabled","aria-errormessage","aria-expanded","aria-haspopup","aria-hidden","aria-invalid","aria-label","aria-level","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-placeholder","aria-pressed","aria-readonly","aria-required","aria-selected","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","aria-busy","aria-live","aria-relevant","aria-atomic","aria-dropeffect","aria-grabbed","aria-activedescendant","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-describedby","aria-description","aria-details","aria-errormessage","aria-flowto","aria-labelledby","aria-owns","aria-posinset","aria-rowcount","aria-rowindex","aria-rowspan","aria-setsize","aria-atomic","aria-busy","aria-controls","aria-current","aria-describedby","aria-description","aria-details","aria-disabled","aria-dropeffect","aria-errormessage","aria-flowto","aria-grabbed","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-live","aria-owns","aria-relevant","aria-roledescription"];var x,N,M;class E{constructor(e,t){c(this,x,void 0);c(this,N,void 0);c(this,M,void 0);l(this,x,e),l(this,N,new MutationObserver(a=>{for(const s of a)this.onAttributeMutation(s)})),l(this,M,t)}observe(){r(this,N).observe(r(this,x),{attributes:!0,attributeFilter:U,subtree:!0})}disconnect(){r(this,N).disconnect()}onAttributeMutation(e){if(o.isElement(e.target)&&e.attributeName){const t=e.target.getAttribute(e.attributeName);r(this,M).attributeChanged(e.target,e.attributeName,t)}}}x=new WeakMap,N=new WeakMap,M=new WeakMap;var g;class G{constructor(){c(this,g,new WeakMap)}get(e){return r(this,g).get(e)??null}getOrCreate(e){let t=r(this,g).get(e);return t||(t={addedClassNames:new Set,removedClassNames:new Set,touched:!1,attributes:{}},r(this,g).set(e,t)),t}clear(){l(this,g,new WeakMap)}}g=new WeakMap;function I(i,e,t){i instanceof Document?(_(e instanceof Document,"Cannot morph document to element"),K(i,e,t)):i instanceof Element&&(_(!(e instanceof Document),"Cannot morph element to document"),e instanceof DocumentFragment?P(i,e,t):typeof e=="string"?P(i,o.parseHTMLFragment(e,i.ownerDocument),t):L(i,e,t))}function P(i,e,t){if(e.normalize(),t!=null&&t.childrenOnly){const a=e.ownerDocument.createElement("div");a.append(e),L(i,a,t)}else{const[a,s,...n]=[...e.childNodes].filter(o.isElementOrText);o.isElement(a)?(s&&i.after(s),L(i,a,t)):o.isElement(s)?(i.before(a),L(i,s,t)):(s&&i.after(s),i.replaceWith(a)),i.after(...n)}}function L(i,e,t){const a=t==null?void 0:t.forceAttribute;if(B(i,e,{childrenOnly:t==null?void 0:t.childrenOnly,onBeforeElUpdated(s,n){var q;const y=a?!!n.closest(`[${a}]`):!1,d=(q=t==null?void 0:t.metadata)==null?void 0:q.get(s);if(y&&d&&(o.isFormInputElement(s)||o.isFormOptionElement(s))&&(d.touched=!1),s.isEqualNode(n))return!1;if(!y&&d){n.classList.add(...d.addedClassNames),n.classList.remove(...d.removedClassNames);for(const[F,T]of Object.entries(d.attributes))T==null?n.removeAttribute(F):n.setAttribute(F,T);d.touched&&(o.isInputElement(s)&&(s.type=="checkbox"||s.type=="radio")?Object.assign(n,{checked:s.checked}):o.isFormOptionElement(s)?Object.assign(n,{selected:s.selected}):o.isFormInputElement(s)&&Object.assign(n,{value:s.value}))}return!0}}),a){i.removeAttribute(a);for(const s of[...i.querySelectorAll(`[${a}]`)])s.removeAttribute(a)}}function K(i,e,t){e.head&&Q(i.head,i.adoptNode(e.head)),L(i.body,i.adoptNode(e.body),t)}function Q(i,e){B(i,e,{childrenOnly:!0,onBeforeElUpdated(t,a){return!t.isEqualNode(a)},onBeforeNodeDiscarded(t){return!o.isLinkElement(t)}})}const H={forceAttribute:"data-turbo-force",hiddenClassName:"hidden"},R=["after","before","append","prepend","remove","replace","update","focus","enable","disable","hide","show"],X=["after","before","append","prepend","replace","update"];var h,b,u,f,v,p,m,O,A;class Y{constructor({element:e,schema:t}){c(this,h,void 0);c(this,b,void 0);c(this,u,void 0);c(this,f,void 0);c(this,v,void 0);c(this,p,new G);c(this,m,new AbortController);c(this,O,[]);c(this,A,new Map);l(this,h,e),l(this,b,{...H,...t}),l(this,v,{handleEvent:this.handleEvent.bind(this),classListChanged:this.classListChanged.bind(this),attributeChanged:this.attributeChanged.bind(this)}),l(this,u,new J(r(this,h),r(this,v))),l(this,f,new E(r(this,h),r(this,v)))}async ready(){await Promise.all(r(this,O))}get element(){return r(this,h)}start(){r(this,u).observe(),r(this,f).observe(),r(this,h).addEventListener("input",r(this,v))}stop(){this.reset(),r(this,u).disconnect(),r(this,f).disconnect(),r(this,h).removeEventListener("input",r(this,v))}reset(){r(this,m).abort(),l(this,m,new AbortController),r(this,A).clear(),r(this,p).clear()}applyActions(e){const t=e.filter(ee),a=o.groupBy(e.filter(te),({delay:s})=>s);this.scheduleActions(t);for(const[s,n]of a)this.scheduleActions(n,s)}applyPinnedActions(e){const t=[...r(this,A)].flatMap(([,a])=>a);this._applyActionsInContext(t,e)}after(e){this.applyActions([{action:"after",...e}])}before(e){this.applyActions([{action:"before",...e}])}append(e){this.applyActions([{action:"append",...e}])}prepend(e){this.applyActions([{action:"prepend",...e}])}remove(e){this.applyActions([{action:"remove",...e}])}replace(e){this.applyActions([{action:"replace",...e}])}update(e){this.applyActions([{action:"update",...e}])}focus(e){this.applyActions([{action:"focus",...e}])}disable(e){this.applyActions([{action:"disable",...e}])}enable(e){this.applyActions([{action:"enable",...e}])}hide(e){this.applyActions([{action:"hide",...e}])}show(e){this.applyActions([{action:"show",...e}])}morph(e,t,a){r(this,u).disconnect(),r(this,f).disconnect(),I(e,t,{forceAttribute:r(this,b).forceAttribute,metadata:r(this,p),...a}),r(this,u).observe(),r(this,f).observe()}scheduleActions(e,t){r(this,O).push(this._scheduleActions(e,t))}async _scheduleActions(e,t){var a;if(!t)await o.nextAnimationFrame();else{try{await o.wait(t,r(this,m).signal)}catch(s){if(s instanceof o.AbortError)return;throw s}if((a=r(this,m).signal)!=null&&a.aborted)return}for(const s of e)ae(s),this.pinAction(s);this._applyActionsInContext(e,r(this,h))}_applyActionsInContext(e,t){const[a,s]=o.partition(e,W);this._applyActions(s,t),r(this,u).disconnect(),r(this,f).disconnect(),this._applyActions(a,t),r(this,u).observe(),r(this,f).observe()}_applyActions(e,t){for(const a of e){const s=ie(t,a.targets);this[`_${a.action}`]({...a,targets:s})}}pinAction({delay:e,pin:t,...a}){if(t&&!e){const s=`${a.action}--${a.targets}`;if(t=="last")r(this,A).set(s,[a]);else{let n=r(this,A).get(s);n||(n=[],r(this,A).set(s,n)),n.push(a)}}}_after({targets:e,fragment:t}){if(t)for(const a of e)a.after(t.cloneNode(!0))}_before({targets:e,fragment:t}){if(t)for(const a of e)a.before(t.cloneNode(!0))}_append({targets:e,fragment:t}){if(t){V(e,t);for(const a of e)a.append(t.cloneNode(!0))}}_prepend({targets:e,fragment:t}){if(t){V(e,t);for(const a of e)a.prepend(t.cloneNode(!0))}}_replace({targets:e,fragment:t}){if(t)for(const a of e)I(a,t.cloneNode(!0),{forceAttribute:r(this,b).forceAttribute,metadata:r(this,p)})}_update({targets:e,fragment:t}){if(t)for(const a of e)I(a,t.cloneNode(!0),{forceAttribute:r(this,b).forceAttribute,metadata:r(this,p),childrenOnly:!0})}_remove({targets:e}){for(const t of e)t.remove()}_focus({targets:e}){for(const t of e)o.focusElement(t)}_show({targets:e}){for(const t of e)t.classList.remove(r(this,b).hiddenClassName)}_hide({targets:e}){for(const t of e)t.classList.add(r(this,b).hiddenClassName)}_enable({targets:e}){for(const t of e)"disabled"in t&&(t.disabled=!1)}_disable({targets:e}){for(const t of e)"disabled"in t&&(t.disabled=!0)}handleEvent(e){const t=e.composedPath&&e.composedPath()[0]||e.target;e.type=="input"&&o.isFormInputElement(t)&&(r(this,p).getOrCreate(t).touched=!0)}classListChanged(e,t){const a=r(this,p).getOrCreate(e),s=new Set(e.classList),n=$(s,t),y=$(t,s);for(const d of n)a.addedClassNames.add(d),a.removedClassNames.delete(d);for(const d of y)a.removedClassNames.add(d),a.addedClassNames.delete(d)}attributeChanged(e,t,a){r(this,p).getOrCreate(e).attributes[t]=a}}h=new WeakMap,b=new WeakMap,u=new WeakMap,f=new WeakMap,v=new WeakMap,p=new WeakMap,m=new WeakMap,O=new WeakMap,A=new WeakMap;function V(i,e){for(const t of Z(i,e))t.remove()}function Z(i,e){const t=i.flatMap(s=>[...s.children]).filter(s=>!!s.id),a=new Set([...e.children].filter(s=>!!s.id).map(s=>s.id));return t.filter(s=>a.has(s.id))}function $(i,e){return new Set([...i].filter(t=>!e.has(t)))}function D(i){return!!i&&R.includes(i)}function ee(i){return!i.delay}function te(i){return!!i.delay}function W(i){return X.includes(i.action)}function ie(i,e){return[...i.querySelectorAll(e)]}function ae(i){_(!(i.delay&&i.pin),"[actions] a delayed action cannot be pinned"),_(!W(i)||i.fragment,"[actions] fragment is required")}class se extends HTMLElement{constructor(){super(),this.style.display="none"}connectedCallback(){var n,y;const e=this.getAttribute("type"),t=((n=this.parentElement)==null?void 0:n.tagName)=="HEAD"?this.ownerDocument.documentElement:this.previousElementSibling;_(e,'[dispatch-event] must have "type" attribute'),_(t,"[dispatch-event] must have a target element");const a=(y=this.querySelector('script[type="application/json"]'))==null?void 0:y.textContent,s=a?re(a):null;o.dispatch(e,{target:t,detail:s}),this.remove()}}customElements.get("dispatch-event")||customElements.define("dispatch-event",se);function re(i){const e=i.trim().replace(/^<!\[CDATA\[/,"").replace(/\]\]>$/,"").trim();if(!e)return null;try{return JSON.parse(e)}catch{return null}}exports.Actions=Y;exports.defaultSchema=H;exports.isValidActionName=D; | ||
"use strict";var j=(a,e,t)=>{if(!e.has(a))throw TypeError("Cannot "+t)};var s=(a,e,t)=>(j(a,e,"read from private field"),t?t.call(a):e.get(a)),c=(a,e,t)=>{if(e.has(a))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(a):e.set(a,t)},l=(a,e,t,i)=>(j(a,e,"write to private field"),i?i.call(a,t):e.set(a,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@coldwired/utils"),B=require("morphdom");var z=process.env.NODE_ENV==="production",k="Invariant failed";function L(a,e){if(!a){if(z)throw new Error(k);var t=typeof e=="function"?e():e,i=t?"".concat(k,": ").concat(t):k;throw new Error(i)}}var x,C,N;class J{constructor(e,t){c(this,x,void 0);c(this,C,void 0);c(this,N,void 0);l(this,x,e),l(this,C,new MutationObserver(i=>{for(const r of i)this.onAttributeMutation(r)})),l(this,N,t)}observe(){s(this,C).observe(s(this,x),{attributes:!0,attributeFilter:["class"],attributeOldValue:!0,subtree:!0})}disconnect(){s(this,C).disconnect()}onAttributeMutation(e){if(o.isElement(e.target))if(e.oldValue){const t=new Set(e.oldValue.split(/\s/).filter(Boolean));s(this,N).classListChanged(e.target,t)}else s(this,N).classListChanged(e.target,new Set([]))}}x=new WeakMap,C=new WeakMap,N=new WeakMap;const U=["role","disabled","tab-index","aria-autocomplete","aria-checked","aria-disabled","aria-errormessage","aria-expanded","aria-haspopup","aria-hidden","aria-invalid","aria-label","aria-level","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-placeholder","aria-pressed","aria-readonly","aria-required","aria-selected","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","aria-busy","aria-live","aria-relevant","aria-atomic","aria-dropeffect","aria-grabbed","aria-activedescendant","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-describedby","aria-description","aria-details","aria-errormessage","aria-flowto","aria-labelledby","aria-owns","aria-posinset","aria-rowcount","aria-rowindex","aria-rowspan","aria-setsize","aria-atomic","aria-busy","aria-controls","aria-current","aria-describedby","aria-description","aria-details","aria-disabled","aria-dropeffect","aria-errormessage","aria-flowto","aria-grabbed","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-live","aria-owns","aria-relevant","aria-roledescription"];var M,_,O;class E{constructor(e,t){c(this,M,void 0);c(this,_,void 0);c(this,O,void 0);l(this,M,e),l(this,_,new MutationObserver(i=>{for(const r of i)this.onAttributeMutation(r)})),l(this,O,t)}observe(){s(this,_).observe(s(this,M),{attributes:!0,attributeFilter:U,subtree:!0})}disconnect(){s(this,_).disconnect()}onAttributeMutation(e){if(o.isElement(e.target)&&e.attributeName){const t=e.target.getAttribute(e.attributeName);s(this,O).attributeChanged(e.target,e.attributeName,t)}}}M=new WeakMap,_=new WeakMap,O=new WeakMap;var g;class G{constructor(){c(this,g,new WeakMap)}get(e){return s(this,g).get(e)??null}getOrCreate(e){let t=s(this,g).get(e);return t||(t={addedClassNames:new Set,removedClassNames:new Set,touched:!1,attributes:{}},s(this,g).set(e,t)),t}clear(){l(this,g,new WeakMap)}}g=new WeakMap;function I(a,e,t){a instanceof Document?(L(e instanceof Document,"Cannot morph document to element"),K(a,e,t)):a instanceof Element&&(L(!(e instanceof Document),"Cannot morph element to document"),e instanceof DocumentFragment?P(a,e,t):typeof e=="string"?P(a,o.parseHTMLFragment(e,a.ownerDocument),t):S(a,e,t))}function P(a,e,t){if(e.normalize(),t!=null&&t.childrenOnly){const i=e.ownerDocument.createElement("div");i.append(e),S(a,i,t)}else{const[i,r,...n]=[...e.childNodes].filter(o.isElementOrText);o.isElement(i)?(r&&a.after(r),S(a,i,t)):o.isElement(r)?(a.before(i),S(a,r,t)):(r&&a.after(r),a.replaceWith(i)),a.after(...n)}}function S(a,e,t){const i=t==null?void 0:t.forceAttribute;if(B(a,e,{childrenOnly:t==null?void 0:t.childrenOnly,onBeforeElUpdated(r,n){var q;const y=i?!!n.closest(`[${i}]`):!1,d=(q=t==null?void 0:t.metadata)==null?void 0:q.get(r);if(y&&d&&(o.isFormInputElement(r)||o.isFormOptionElement(r))&&(d.touched=!1),r.isEqualNode(n))return!1;if(!y&&d){n.classList.add(...d.addedClassNames),n.classList.remove(...d.removedClassNames);for(const[F,T]of Object.entries(d.attributes))T==null?n.removeAttribute(F):n.setAttribute(F,T);d.touched&&(o.isInputElement(r)&&(r.type=="checkbox"||r.type=="radio")?Object.assign(n,{checked:r.checked}):o.isFormOptionElement(r)?Object.assign(n,{selected:r.selected}):o.isFormInputElement(r)&&Object.assign(n,{value:r.value}))}return!0}}),i){a.removeAttribute(i);for(const r of[...a.querySelectorAll(`[${i}]`)])r.removeAttribute(i)}}function K(a,e,t){e.head&&Q(a.head,a.adoptNode(e.head)),S(a.body,a.adoptNode(e.body),t)}function Q(a,e){B(a,e,{childrenOnly:!0,onBeforeElUpdated(t,i){return!t.isEqualNode(i)},onBeforeNodeDiscarded(t){return!o.isLinkElement(t)}})}const H={forceAttribute:"data-turbo-force",hiddenClassName:"hidden"},R=["after","before","append","prepend","remove","replace","update","focus","enable","disable","hide","show"],X=["after","before","append","prepend","replace","update"];var h,b,u,f,v,p,m,w,A;class Y{constructor({element:e,schema:t}){c(this,h,void 0);c(this,b,void 0);c(this,u,void 0);c(this,f,void 0);c(this,v,void 0);c(this,p,new G);c(this,m,new AbortController);c(this,w,new Set);c(this,A,new Map);l(this,h,e),l(this,b,{...H,...t}),l(this,v,{handleEvent:this.handleEvent.bind(this),classListChanged:this.classListChanged.bind(this),attributeChanged:this.attributeChanged.bind(this)}),l(this,u,new J(s(this,h),s(this,v))),l(this,f,new E(s(this,h),s(this,v)))}async ready(){await Promise.all(s(this,w))}get element(){return s(this,h)}start(){s(this,u).observe(),s(this,f).observe(),s(this,h).addEventListener("input",s(this,v))}stop(){this.reset(),s(this,u).disconnect(),s(this,f).disconnect(),s(this,h).removeEventListener("input",s(this,v))}reset(){s(this,m).abort(),l(this,m,new AbortController),s(this,w).clear(),s(this,A).clear(),s(this,p).clear()}applyActions(e){const t=e.filter(ee),i=o.groupBy(e.filter(te),({delay:r})=>r);this.scheduleActions(t);for(const[r,n]of i)this.scheduleActions(n,r)}applyPinnedActions(e){const t=[...s(this,A)].flatMap(([,i])=>i);this._applyActionsInContext(t,e)}after(e){this.applyActions([{action:"after",...e}])}before(e){this.applyActions([{action:"before",...e}])}append(e){this.applyActions([{action:"append",...e}])}prepend(e){this.applyActions([{action:"prepend",...e}])}remove(e){this.applyActions([{action:"remove",...e}])}replace(e){this.applyActions([{action:"replace",...e}])}update(e){this.applyActions([{action:"update",...e}])}focus(e){this.applyActions([{action:"focus",...e}])}disable(e){this.applyActions([{action:"disable",...e}])}enable(e){this.applyActions([{action:"enable",...e}])}hide(e){this.applyActions([{action:"hide",...e}])}show(e){this.applyActions([{action:"show",...e}])}morph(e,t,i){s(this,u).disconnect(),s(this,f).disconnect(),I(e,t,{forceAttribute:s(this,b).forceAttribute,metadata:s(this,p),...i}),s(this,u).observe(),s(this,f).observe()}scheduleActions(e,t){const i=this._scheduleActions(e,t);s(this,w).add(i),i.finally(()=>s(this,w).delete(i))}async _scheduleActions(e,t){var i;if(!t)await o.nextAnimationFrame();else{try{await o.wait(t,s(this,m).signal)}catch(r){if(r instanceof o.AbortError)return;throw r}if((i=s(this,m).signal)!=null&&i.aborted)return}for(const r of e)ae(r),this.pinAction(r);this._applyActionsInContext(e,s(this,h))}_applyActionsInContext(e,t){const[i,r]=o.partition(e,W);this._applyActions(r,t),s(this,u).disconnect(),s(this,f).disconnect(),this._applyActions(i,t),s(this,u).observe(),s(this,f).observe()}_applyActions(e,t){for(const i of e){const r=ie(t,i.targets);this[`_${i.action}`]({...i,targets:r})}}pinAction({delay:e,pin:t,...i}){if(t&&!e){const r=`${i.action}--${i.targets}`;if(t=="last")s(this,A).set(r,[i]);else{let n=s(this,A).get(r);n||(n=[],s(this,A).set(r,n)),n.push(i)}}}_after({targets:e,fragment:t}){if(t)for(const i of e)i.after(t.cloneNode(!0))}_before({targets:e,fragment:t}){if(t)for(const i of e)i.before(t.cloneNode(!0))}_append({targets:e,fragment:t}){if(t){V(e,t);for(const i of e)i.append(t.cloneNode(!0))}}_prepend({targets:e,fragment:t}){if(t){V(e,t);for(const i of e)i.prepend(t.cloneNode(!0))}}_replace({targets:e,fragment:t}){if(t)for(const i of e)I(i,t.cloneNode(!0),{forceAttribute:s(this,b).forceAttribute,metadata:s(this,p)})}_update({targets:e,fragment:t}){if(t)for(const i of e)I(i,t.cloneNode(!0),{forceAttribute:s(this,b).forceAttribute,metadata:s(this,p),childrenOnly:!0})}_remove({targets:e}){for(const t of e)t.remove()}_focus({targets:e}){for(const t of e)o.focusElement(t)}_show({targets:e}){for(const t of e)t.classList.remove(s(this,b).hiddenClassName)}_hide({targets:e}){for(const t of e)t.classList.add(s(this,b).hiddenClassName)}_enable({targets:e}){for(const t of e)"disabled"in t&&(t.disabled=!1)}_disable({targets:e}){for(const t of e)"disabled"in t&&(t.disabled=!0)}handleEvent(e){const t=e.composedPath&&e.composedPath()[0]||e.target;e.type=="input"&&o.isFormInputElement(t)&&(s(this,p).getOrCreate(t).touched=!0)}classListChanged(e,t){const i=s(this,p).getOrCreate(e),r=new Set(e.classList),n=$(r,t),y=$(t,r);for(const d of n)i.addedClassNames.add(d),i.removedClassNames.delete(d);for(const d of y)i.removedClassNames.add(d),i.addedClassNames.delete(d)}attributeChanged(e,t,i){s(this,p).getOrCreate(e).attributes[t]=i}}h=new WeakMap,b=new WeakMap,u=new WeakMap,f=new WeakMap,v=new WeakMap,p=new WeakMap,m=new WeakMap,w=new WeakMap,A=new WeakMap;function V(a,e){for(const t of Z(a,e))t.remove()}function Z(a,e){const t=a.flatMap(r=>[...r.children]).filter(r=>!!r.id),i=new Set([...e.children].filter(r=>!!r.id).map(r=>r.id));return t.filter(r=>i.has(r.id))}function $(a,e){return new Set([...a].filter(t=>!e.has(t)))}function D(a){return!!a&&R.includes(a)}function ee(a){return!a.delay}function te(a){return!!a.delay}function W(a){return X.includes(a.action)}function ie(a,e){return[...a.querySelectorAll(e)]}function ae(a){L(!(a.delay&&a.pin),"[actions] a delayed action cannot be pinned"),L(!W(a)||a.fragment,"[actions] fragment is required")}class se extends HTMLElement{constructor(){super(),this.style.display="none"}connectedCallback(){var n,y;const e=this.getAttribute("type"),t=((n=this.parentElement)==null?void 0:n.tagName)=="HEAD"?this.ownerDocument.documentElement:this.previousElementSibling;L(e,'[dispatch-event] must have "type" attribute'),L(t,"[dispatch-event] must have a target element");const i=(y=this.querySelector('script[type="application/json"]'))==null?void 0:y.textContent,r=i?re(i):null;o.dispatch(e,{target:t,detail:r}),this.remove()}}customElements.get("dispatch-event")||customElements.define("dispatch-event",se);function re(a){const e=a.trim().replace(/^<!\[CDATA\[/,"").replace(/\]\]>$/,"").trim();if(!e)return null;try{return JSON.parse(e)}catch{return null}}exports.Actions=Y;exports.defaultSchema=H;exports.isValidActionName=D; |
@@ -1,34 +0,34 @@ | ||
var j = (a, e, t) => { | ||
if (!e.has(a)) | ||
var j = (i, e, t) => { | ||
if (!e.has(i)) | ||
throw TypeError("Cannot " + t); | ||
}; | ||
var r = (a, e, t) => (j(a, e, "read from private field"), t ? t.call(a) : e.get(a)), o = (a, e, t) => { | ||
if (e.has(a)) | ||
var s = (i, e, t) => (j(i, e, "read from private field"), t ? t.call(i) : e.get(i)), o = (i, e, t) => { | ||
if (e.has(i)) | ||
throw TypeError("Cannot add the same private member more than once"); | ||
e instanceof WeakSet ? e.add(a) : e.set(a, t); | ||
}, c = (a, e, t, i) => (j(a, e, "write to private field"), i ? i.call(a, t) : e.set(a, t), t); | ||
e instanceof WeakSet ? e.add(i) : e.set(i, t); | ||
}, c = (i, e, t, a) => (j(i, e, "write to private field"), a ? a.call(i, t) : e.set(i, t), t); | ||
import { isElement as O, parseHTMLFragment as J, isElementOrText as U, isFormInputElement as T, isFormOptionElement as B, isInputElement as G, isLinkElement as K, groupBy as Q, nextAnimationFrame as R, wait as X, AbortError as Y, partition as Z, focusElement as D, dispatch as E } from "@coldwired/utils"; | ||
import W from "morphdom"; | ||
var ee = process.env.NODE_ENV === "production", k = "Invariant failed"; | ||
function N(a, e) { | ||
if (!a) { | ||
function _(i, e) { | ||
if (!i) { | ||
if (ee) | ||
throw new Error(k); | ||
var t = typeof e == "function" ? e() : e, i = t ? "".concat(k, ": ").concat(t) : k; | ||
throw new Error(i); | ||
var t = typeof e == "function" ? e() : e, a = t ? "".concat(k, ": ").concat(t) : k; | ||
throw new Error(a); | ||
} | ||
} | ||
var L, w, C; | ||
var x, C, m; | ||
class te { | ||
constructor(e, t) { | ||
o(this, L, void 0); | ||
o(this, w, void 0); | ||
o(this, x, void 0); | ||
o(this, C, void 0); | ||
c(this, L, e), c(this, w, new MutationObserver((i) => { | ||
for (const s of i) | ||
this.onAttributeMutation(s); | ||
})), c(this, C, t); | ||
o(this, m, void 0); | ||
c(this, x, e), c(this, C, new MutationObserver((a) => { | ||
for (const r of a) | ||
this.onAttributeMutation(r); | ||
})), c(this, m, t); | ||
} | ||
observe() { | ||
r(this, w).observe(r(this, L), { | ||
s(this, C).observe(s(this, x), { | ||
attributes: !0, | ||
@@ -41,3 +41,3 @@ attributeFilter: ["class"], | ||
disconnect() { | ||
r(this, w).disconnect(); | ||
s(this, C).disconnect(); | ||
} | ||
@@ -48,8 +48,8 @@ onAttributeMutation(e) { | ||
const t = new Set(e.oldValue.split(/\s/).filter(Boolean)); | ||
r(this, C).classListChanged(e.target, t); | ||
s(this, m).classListChanged(e.target, t); | ||
} else | ||
r(this, C).classListChanged(e.target, /* @__PURE__ */ new Set([])); | ||
s(this, m).classListChanged(e.target, /* @__PURE__ */ new Set([])); | ||
} | ||
} | ||
L = new WeakMap(), w = new WeakMap(), C = new WeakMap(); | ||
x = new WeakMap(), C = new WeakMap(), m = new WeakMap(); | ||
const ae = [ | ||
@@ -129,15 +129,15 @@ "role", | ||
]; | ||
var x, m, M; | ||
var S, N, M; | ||
class ie { | ||
constructor(e, t) { | ||
o(this, x, void 0); | ||
o(this, m, void 0); | ||
o(this, S, void 0); | ||
o(this, N, void 0); | ||
o(this, M, void 0); | ||
c(this, x, e), c(this, m, new MutationObserver((i) => { | ||
for (const s of i) | ||
this.onAttributeMutation(s); | ||
c(this, S, e), c(this, N, new MutationObserver((a) => { | ||
for (const r of a) | ||
this.onAttributeMutation(r); | ||
})), c(this, M, t); | ||
} | ||
observe() { | ||
r(this, m).observe(r(this, x), { | ||
s(this, N).observe(s(this, S), { | ||
attributes: !0, | ||
@@ -149,3 +149,3 @@ attributeFilter: ae, | ||
disconnect() { | ||
r(this, m).disconnect(); | ||
s(this, N).disconnect(); | ||
} | ||
@@ -155,7 +155,7 @@ onAttributeMutation(e) { | ||
const t = e.target.getAttribute(e.attributeName); | ||
r(this, M).attributeChanged(e.target, e.attributeName, t); | ||
s(this, M).attributeChanged(e.target, e.attributeName, t); | ||
} | ||
} | ||
} | ||
x = new WeakMap(), m = new WeakMap(), M = new WeakMap(); | ||
S = new WeakMap(), N = new WeakMap(), M = new WeakMap(); | ||
var y; | ||
@@ -167,6 +167,6 @@ class se { | ||
get(e) { | ||
return r(this, y).get(e) ?? null; | ||
return s(this, y).get(e) ?? null; | ||
} | ||
getOrCreate(e) { | ||
let t = r(this, y).get(e); | ||
let t = s(this, y).get(e); | ||
return t || (t = { | ||
@@ -177,3 +177,3 @@ addedClassNames: /* @__PURE__ */ new Set(), | ||
attributes: {} | ||
}, r(this, y).set(e, t)), t; | ||
}, s(this, y).set(e, t)), t; | ||
} | ||
@@ -185,28 +185,28 @@ clear() { | ||
y = new WeakMap(); | ||
function I(a, e, t) { | ||
a instanceof Document ? (N(e instanceof Document, "Cannot morph document to element"), re(a, e, t)) : a instanceof Element && (N(!(e instanceof Document), "Cannot morph element to document"), e instanceof DocumentFragment ? P(a, e, t) : typeof e == "string" ? P( | ||
a, | ||
J(e, a.ownerDocument), | ||
function I(i, e, t) { | ||
i instanceof Document ? (_(e instanceof Document, "Cannot morph document to element"), re(i, e, t)) : i instanceof Element && (_(!(e instanceof Document), "Cannot morph element to document"), e instanceof DocumentFragment ? P(i, e, t) : typeof e == "string" ? P( | ||
i, | ||
J(e, i.ownerDocument), | ||
t | ||
) : _(a, e, t)); | ||
) : L(i, e, t)); | ||
} | ||
function P(a, e, t) { | ||
function P(i, e, t) { | ||
if (e.normalize(), t != null && t.childrenOnly) { | ||
const i = e.ownerDocument.createElement("div"); | ||
i.append(e), _(a, i, t); | ||
const a = e.ownerDocument.createElement("div"); | ||
a.append(e), L(i, a, t); | ||
} else { | ||
const [i, s, ...n] = [...e.childNodes].filter( | ||
const [a, r, ...n] = [...e.childNodes].filter( | ||
U | ||
); | ||
O(i) ? (s && a.after(s), _(a, i, t)) : O(s) ? (a.before(i), _(a, s, t)) : (s && a.after(s), a.replaceWith(i)), a.after(...n); | ||
O(a) ? (r && i.after(r), L(i, a, t)) : O(r) ? (i.before(a), L(i, r, t)) : (r && i.after(r), i.replaceWith(a)), i.after(...n); | ||
} | ||
} | ||
function _(a, e, t) { | ||
const i = t == null ? void 0 : t.forceAttribute; | ||
if (W(a, e, { | ||
function L(i, e, t) { | ||
const a = t == null ? void 0 : t.forceAttribute; | ||
if (W(i, e, { | ||
childrenOnly: t == null ? void 0 : t.childrenOnly, | ||
onBeforeElUpdated(s, n) { | ||
onBeforeElUpdated(r, n) { | ||
var q; | ||
const A = i ? !!n.closest(`[${i}]`) : !1, d = (q = t == null ? void 0 : t.metadata) == null ? void 0 : q.get(s); | ||
if (A && d && (T(s) || B(s)) && (d.touched = !1), s.isEqualNode(n)) | ||
const A = a ? !!n.closest(`[${a}]`) : !1, d = (q = t == null ? void 0 : t.metadata) == null ? void 0 : q.get(r); | ||
if (A && d && (T(r) || B(r)) && (d.touched = !1), r.isEqualNode(n)) | ||
return !1; | ||
@@ -217,20 +217,20 @@ if (!A && d) { | ||
$ == null ? n.removeAttribute(F) : n.setAttribute(F, $); | ||
d.touched && (G(s) && (s.type == "checkbox" || s.type == "radio") ? Object.assign(n, { checked: s.checked }) : B(s) ? Object.assign(n, { selected: s.selected }) : T(s) && Object.assign(n, { value: s.value })); | ||
d.touched && (G(r) && (r.type == "checkbox" || r.type == "radio") ? Object.assign(n, { checked: r.checked }) : B(r) ? Object.assign(n, { selected: r.selected }) : T(r) && Object.assign(n, { value: r.value })); | ||
} | ||
return !0; | ||
} | ||
}), i) { | ||
a.removeAttribute(i); | ||
for (const s of [...a.querySelectorAll(`[${i}]`)]) | ||
s.removeAttribute(i); | ||
}), a) { | ||
i.removeAttribute(a); | ||
for (const r of [...i.querySelectorAll(`[${a}]`)]) | ||
r.removeAttribute(a); | ||
} | ||
} | ||
function re(a, e, t) { | ||
e.head && ne(a.head, a.adoptNode(e.head)), _(a.body, a.adoptNode(e.body), t); | ||
function re(i, e, t) { | ||
e.head && ne(i.head, i.adoptNode(e.head)), L(i.body, i.adoptNode(e.body), t); | ||
} | ||
function ne(a, e) { | ||
W(a, e, { | ||
function ne(i, e) { | ||
W(i, e, { | ||
childrenOnly: !0, | ||
onBeforeElUpdated(t, i) { | ||
return !t.isEqualNode(i); | ||
onBeforeElUpdated(t, a) { | ||
return !t.isEqualNode(a); | ||
}, | ||
@@ -259,3 +259,3 @@ onBeforeNodeDiscarded(t) { | ||
], de = ["after", "before", "append", "prepend", "replace", "update"]; | ||
var l, p, h, u, b, f, g, S, v; | ||
var l, p, h, u, b, f, g, w, v; | ||
class we { | ||
@@ -270,3 +270,3 @@ constructor({ element: e, schema: t }) { | ||
o(this, g, new AbortController()); | ||
o(this, S, []); | ||
o(this, w, /* @__PURE__ */ new Set()); | ||
o(this, v, /* @__PURE__ */ new Map()); | ||
@@ -277,27 +277,27 @@ c(this, l, e), c(this, p, { ...oe, ...t }), c(this, b, { | ||
attributeChanged: this.attributeChanged.bind(this) | ||
}), c(this, h, new te(r(this, l), r(this, b))), c(this, u, new ie(r(this, l), r(this, b))); | ||
}), c(this, h, new te(s(this, l), s(this, b))), c(this, u, new ie(s(this, l), s(this, b))); | ||
} | ||
async ready() { | ||
await Promise.all(r(this, S)); | ||
await Promise.all(s(this, w)); | ||
} | ||
get element() { | ||
return r(this, l); | ||
return s(this, l); | ||
} | ||
start() { | ||
r(this, h).observe(), r(this, u).observe(), r(this, l).addEventListener("input", r(this, b)); | ||
s(this, h).observe(), s(this, u).observe(), s(this, l).addEventListener("input", s(this, b)); | ||
} | ||
stop() { | ||
this.reset(), r(this, h).disconnect(), r(this, u).disconnect(), r(this, l).removeEventListener("input", r(this, b)); | ||
this.reset(), s(this, h).disconnect(), s(this, u).disconnect(), s(this, l).removeEventListener("input", s(this, b)); | ||
} | ||
reset() { | ||
r(this, g).abort(), c(this, g, new AbortController()), r(this, v).clear(), r(this, f).clear(); | ||
s(this, g).abort(), c(this, g, new AbortController()), s(this, w).clear(), s(this, v).clear(), s(this, f).clear(); | ||
} | ||
applyActions(e) { | ||
const t = e.filter(he), i = Q(e.filter(ue), ({ delay: s }) => s); | ||
const t = e.filter(he), a = Q(e.filter(ue), ({ delay: r }) => r); | ||
this.scheduleActions(t); | ||
for (const [s, n] of i) | ||
this.scheduleActions(n, s); | ||
for (const [r, n] of a) | ||
this.scheduleActions(n, r); | ||
} | ||
applyPinnedActions(e) { | ||
const t = [...r(this, v)].flatMap(([, i]) => i); | ||
const t = [...s(this, v)].flatMap(([, a]) => a); | ||
this._applyActionsInContext(t, e); | ||
@@ -341,14 +341,15 @@ } | ||
} | ||
morph(e, t, i) { | ||
r(this, h).disconnect(), r(this, u).disconnect(), I(e, t, { | ||
forceAttribute: r(this, p).forceAttribute, | ||
metadata: r(this, f), | ||
...i | ||
}), r(this, h).observe(), r(this, u).observe(); | ||
morph(e, t, a) { | ||
s(this, h).disconnect(), s(this, u).disconnect(), I(e, t, { | ||
forceAttribute: s(this, p).forceAttribute, | ||
metadata: s(this, f), | ||
...a | ||
}), s(this, h).observe(), s(this, u).observe(); | ||
} | ||
scheduleActions(e, t) { | ||
r(this, S).push(this._scheduleActions(e, t)); | ||
const a = this._scheduleActions(e, t); | ||
s(this, w).add(a), a.finally(() => s(this, w).delete(a)); | ||
} | ||
async _scheduleActions(e, t) { | ||
var i; | ||
var a; | ||
if (!t) | ||
@@ -358,33 +359,33 @@ await R(); | ||
try { | ||
await X(t, r(this, g).signal); | ||
} catch (s) { | ||
if (s instanceof Y) | ||
await X(t, s(this, g).signal); | ||
} catch (r) { | ||
if (r instanceof Y) | ||
return; | ||
throw s; | ||
throw r; | ||
} | ||
if ((i = r(this, g).signal) != null && i.aborted) | ||
if ((a = s(this, g).signal) != null && a.aborted) | ||
return; | ||
} | ||
for (const s of e) | ||
pe(s), this.pinAction(s); | ||
this._applyActionsInContext(e, r(this, l)); | ||
for (const r of e) | ||
pe(r), this.pinAction(r); | ||
this._applyActionsInContext(e, s(this, l)); | ||
} | ||
_applyActionsInContext(e, t) { | ||
const [i, s] = Z(e, z); | ||
this._applyActions(s, t), r(this, h).disconnect(), r(this, u).disconnect(), this._applyActions(i, t), r(this, h).observe(), r(this, u).observe(); | ||
const [a, r] = Z(e, z); | ||
this._applyActions(r, t), s(this, h).disconnect(), s(this, u).disconnect(), this._applyActions(a, t), s(this, h).observe(), s(this, u).observe(); | ||
} | ||
_applyActions(e, t) { | ||
for (const i of e) { | ||
const s = fe(t, i.targets); | ||
this[`_${i.action}`]({ ...i, targets: s }); | ||
for (const a of e) { | ||
const r = fe(t, a.targets); | ||
this[`_${a.action}`]({ ...a, targets: r }); | ||
} | ||
} | ||
pinAction({ delay: e, pin: t, ...i }) { | ||
pinAction({ delay: e, pin: t, ...a }) { | ||
if (t && !e) { | ||
const s = `${i.action}--${i.targets}`; | ||
const r = `${a.action}--${a.targets}`; | ||
if (t == "last") | ||
r(this, v).set(s, [i]); | ||
s(this, v).set(r, [a]); | ||
else { | ||
let n = r(this, v).get(s); | ||
n || (n = [], r(this, v).set(s, n)), n.push(i); | ||
let n = s(this, v).get(r); | ||
n || (n = [], s(this, v).set(r, n)), n.push(a); | ||
} | ||
@@ -395,9 +396,9 @@ } | ||
if (t) | ||
for (const i of e) | ||
i.after(t.cloneNode(!0)); | ||
for (const a of e) | ||
a.after(t.cloneNode(!0)); | ||
} | ||
_before({ targets: e, fragment: t }) { | ||
if (t) | ||
for (const i of e) | ||
i.before(t.cloneNode(!0)); | ||
for (const a of e) | ||
a.before(t.cloneNode(!0)); | ||
} | ||
@@ -407,4 +408,4 @@ _append({ targets: e, fragment: t }) { | ||
V(e, t); | ||
for (const i of e) | ||
i.append(t.cloneNode(!0)); | ||
for (const a of e) | ||
a.append(t.cloneNode(!0)); | ||
} | ||
@@ -415,4 +416,4 @@ } | ||
V(e, t); | ||
for (const i of e) | ||
i.prepend(t.cloneNode(!0)); | ||
for (const a of e) | ||
a.prepend(t.cloneNode(!0)); | ||
} | ||
@@ -422,6 +423,6 @@ } | ||
if (t) | ||
for (const i of e) | ||
I(i, t.cloneNode(!0), { | ||
forceAttribute: r(this, p).forceAttribute, | ||
metadata: r(this, f) | ||
for (const a of e) | ||
I(a, t.cloneNode(!0), { | ||
forceAttribute: s(this, p).forceAttribute, | ||
metadata: s(this, f) | ||
}); | ||
@@ -431,6 +432,6 @@ } | ||
if (t) | ||
for (const i of e) | ||
I(i, t.cloneNode(!0), { | ||
forceAttribute: r(this, p).forceAttribute, | ||
metadata: r(this, f), | ||
for (const a of e) | ||
I(a, t.cloneNode(!0), { | ||
forceAttribute: s(this, p).forceAttribute, | ||
metadata: s(this, f), | ||
childrenOnly: !0 | ||
@@ -449,7 +450,7 @@ }); | ||
for (const t of e) | ||
t.classList.remove(r(this, p).hiddenClassName); | ||
t.classList.remove(s(this, p).hiddenClassName); | ||
} | ||
_hide({ targets: e }) { | ||
for (const t of e) | ||
t.classList.add(r(this, p).hiddenClassName); | ||
t.classList.add(s(this, p).hiddenClassName); | ||
} | ||
@@ -466,46 +467,46 @@ _enable({ targets: e }) { | ||
const t = e.composedPath && e.composedPath()[0] || e.target; | ||
e.type == "input" && T(t) && (r(this, f).getOrCreate(t).touched = !0); | ||
e.type == "input" && T(t) && (s(this, f).getOrCreate(t).touched = !0); | ||
} | ||
classListChanged(e, t) { | ||
const i = r(this, f).getOrCreate(e), s = new Set(e.classList), n = H(s, t), A = H(t, s); | ||
const a = s(this, f).getOrCreate(e), r = new Set(e.classList), n = H(r, t), A = H(t, r); | ||
for (const d of n) | ||
i.addedClassNames.add(d), i.removedClassNames.delete(d); | ||
a.addedClassNames.add(d), a.removedClassNames.delete(d); | ||
for (const d of A) | ||
i.removedClassNames.add(d), i.addedClassNames.delete(d); | ||
a.removedClassNames.add(d), a.addedClassNames.delete(d); | ||
} | ||
attributeChanged(e, t, i) { | ||
r(this, f).getOrCreate(e).attributes[t] = i; | ||
attributeChanged(e, t, a) { | ||
s(this, f).getOrCreate(e).attributes[t] = a; | ||
} | ||
} | ||
l = new WeakMap(), p = new WeakMap(), h = new WeakMap(), u = new WeakMap(), b = new WeakMap(), f = new WeakMap(), g = new WeakMap(), S = new WeakMap(), v = new WeakMap(); | ||
function V(a, e) { | ||
for (const t of le(a, e)) | ||
l = new WeakMap(), p = new WeakMap(), h = new WeakMap(), u = new WeakMap(), b = new WeakMap(), f = new WeakMap(), g = new WeakMap(), w = new WeakMap(), v = new WeakMap(); | ||
function V(i, e) { | ||
for (const t of le(i, e)) | ||
t.remove(); | ||
} | ||
function le(a, e) { | ||
const t = a.flatMap((s) => [...s.children]).filter((s) => !!s.id), i = new Set( | ||
[...e.children].filter((s) => !!s.id).map((s) => s.id) | ||
function le(i, e) { | ||
const t = i.flatMap((r) => [...r.children]).filter((r) => !!r.id), a = new Set( | ||
[...e.children].filter((r) => !!r.id).map((r) => r.id) | ||
); | ||
return t.filter((s) => i.has(s.id)); | ||
return t.filter((r) => a.has(r.id)); | ||
} | ||
function H(a, e) { | ||
return new Set([...a].filter((t) => !e.has(t))); | ||
function H(i, e) { | ||
return new Set([...i].filter((t) => !e.has(t))); | ||
} | ||
function Ce(a) { | ||
return !!a && ce.includes(a); | ||
function Ce(i) { | ||
return !!i && ce.includes(i); | ||
} | ||
function he(a) { | ||
return !a.delay; | ||
function he(i) { | ||
return !i.delay; | ||
} | ||
function ue(a) { | ||
return !!a.delay; | ||
function ue(i) { | ||
return !!i.delay; | ||
} | ||
function z(a) { | ||
return de.includes(a.action); | ||
function z(i) { | ||
return de.includes(i.action); | ||
} | ||
function fe(a, e) { | ||
return [...a.querySelectorAll(e)]; | ||
function fe(i, e) { | ||
return [...i.querySelectorAll(e)]; | ||
} | ||
function pe(a) { | ||
N(!(a.delay && a.pin), "[actions] a delayed action cannot be pinned"), N(!z(a) || a.fragment, "[actions] fragment is required"); | ||
function pe(i) { | ||
_(!(i.delay && i.pin), "[actions] a delayed action cannot be pinned"), _(!z(i) || i.fragment, "[actions] fragment is required"); | ||
} | ||
@@ -519,12 +520,12 @@ class be extends HTMLElement { | ||
const e = this.getAttribute("type"), t = ((n = this.parentElement) == null ? void 0 : n.tagName) == "HEAD" ? this.ownerDocument.documentElement : this.previousElementSibling; | ||
N(e, '[dispatch-event] must have "type" attribute'), N(t, "[dispatch-event] must have a target element"); | ||
const i = (A = this.querySelector( | ||
_(e, '[dispatch-event] must have "type" attribute'), _(t, "[dispatch-event] must have a target element"); | ||
const a = (A = this.querySelector( | ||
'script[type="application/json"]' | ||
)) == null ? void 0 : A.textContent, s = i ? ve(i) : null; | ||
E(e, { target: t, detail: s }), this.remove(); | ||
)) == null ? void 0 : A.textContent, r = a ? ve(a) : null; | ||
E(e, { target: t, detail: r }), this.remove(); | ||
} | ||
} | ||
customElements.get("dispatch-event") || customElements.define("dispatch-event", be); | ||
function ve(a) { | ||
const e = a.trim().replace(/^<!\[CDATA\[/, "").replace(/\]\]>$/, "").trim(); | ||
function ve(i) { | ||
const e = i.trim().replace(/^<!\[CDATA\[/, "").replace(/\]\]>$/, "").trim(); | ||
if (!e) | ||
@@ -531,0 +532,0 @@ return null; |
@@ -17,3 +17,3 @@ { | ||
}, | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"keywords": [ | ||
@@ -20,0 +20,0 @@ "turbo" |
31886
676