@petit-kit/scoped 0.0.8-beta.23 → 0.0.8-beta.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function t({from:t=0,to:e=1,mass:n=1,stiffness:s=120,damping:i=14,velocity:o=0,delay:r=0,tolerance:p=.001,resumeOnTarget:m=!0}={}){function w(){return f(b)}function y(t){if(x)return w();if(O>0){const e=Math.min(t,O);if(O-=e,(t-=e)<=0)return w()}if(c(b)&&c(M)&&c(S)){let e=!0;for(let o=0;o<b.length;o+=1){S[o]+=(-s*(b[o]-M[o])-i*S[o])/n*t,b[o]+=S[o]*t;const r=b[o]-M[o];(Math.abs(S[o])>=p||Math.abs(r)>=p)&&(e=!1)}if(e){for(let t=0;t<b.length;t+=1)b[t]=M[t],S[t]=0;x=!0}return g.value=b,g.velocity=S,f(b)}if(h(b)&&h(M)&&h(S)){const e=g.objectKeys??Object.keys(b);let o=!0;for(const r of e){S[r]+=(-s*(b[r]-M[r])-i*S[r])/n*t,b[r]+=S[r]*t;const e=b[r]-M[r];(Math.abs(S[r])>=p||Math.abs(e)>=p)&&(o=!1)}if(o){for(const t of e)b[t]=M[t],S[t]=0;x=!0}return g.value=b,g.velocity=S,f(b)}const e=M;let o=S;o+=(-s*(b-e)-i*o)/n*t,b+=o*t,S=o,g.value=b,g.velocity=S;const r=b-e;return Math.abs(o)<p&&Math.abs(r)<p&&(b=e,S=0,g.value=b,g.velocity=S,x=!0),b}const g=d({from:t,to:e,velocity:o,label:"Spring"}),v=g.normalizeInput;let b=g.value,S=g.velocity??o,M=g.target,j=null,x=!1,O=r;const $=new Set;return{setTarget:function(t){const e=v(t),n=!u(e,M);if(M=e,g.target=e,b=g.value,m&&x&&n){x=!1,j=null,O=r;for(const t of $)t(M)}},getTarget:function(){return f(M)},setValue:function(t,e={}){const{resetVelocity:n=!0,resetTime:s=!0,setTarget:i=!1,markDone:o=!1}=e;b=v(t),g.value=b,i&&(M=f(b),g.target=M);const c=x||!u(b,M);if(n&&(S=null!=g.arrayLength?l(0,g.arrayLength):null!=g.objectKeys?a(0,g.objectKeys):0,g.velocity=S),s&&(j=null),o&&(x=!0),c&&!o){x=!1,j=null,O=r;for(const t of $)t(M)}},getValue:w,isDone:function(){return x},onResume:function(t){return $.add(t),()=>{$.delete(t)}},step:y,next:function(t=performance.now()){if(null==j)return j=t,w();const e=(t-j)/1e3;j=t;const n=1/30;let s=e,i=w();for(;s>0&&!x;){const t=Math.min(s,n);i=y(t),s-=t}return i}}}function e(t,e){return t?`${t}:${e}`:e}function n(t,e){if(!e||"object"!=typeof e||null==e.type)return null!=t?t:e;const{type:n,default:s}=e;if(null==t)return s;try{switch(n){case String:return String(t);case Number:{const e=Number(t);return Number.isNaN(e)?s:e}case Boolean:return""===t||"true"===t||"false"!==t&&"0"!==t&&null!=t;case Object:case Array:try{return"string"==typeof t?JSON.parse(t):t}catch{return n===Array?Array.isArray(s)?s:[]:s}default:return t}}catch{return s}}function s(t){if(!t)return;const e=t.default;return"function"==typeof e?e():e}function i(t,e,n,s){if(!s||"object"!=typeof s||!s.reflect)return;let i=null;const o=s.type;if(o!==Boolean){if(o===Object||o===Array)try{i=null==n?null:JSON.stringify(n)}catch{i=null}else i=null==n?null:String(n);null==i?t.removeAttribute(e):t.setAttribute(e,i)}else n?t.setAttribute(e,""):t.removeAttribute(e)}const o=()=>({name:"timer",extend:t=>{const e=new Set,n=new Set,s=new Set,i={setTimeout:(t,n,...s)=>{let i;return i=setTimeout((...n)=>{e.delete(i),t(...n)},n,...s),e.add(i),i},setInterval:(t,e,...s)=>{const i=setInterval(t,e,...s);return n.add(i),i},raf:(t,e)=>{let n=0,i=!0,o=0;const r="number"==typeof e&&e>0?1e3/e:0,c=e=>{if(s.delete(n),i){if(r){if(e-o>=r){const n=o?e-o:r;o=e,t(e,n)}}else{const n=o?e-o:0;o=e,t(e,n)}n=requestAnimationFrame(c),s.add(n)}};return n=requestAnimationFrame(c),s.add(n),()=>{i&&(i=!1,s.delete(n),cancelAnimationFrame(n))}}};return t.onDestroy(()=>{for(const t of e)clearTimeout(t);e.clear();for(const t of n)clearInterval(t);n.clear();for(const t of s)cancelAnimationFrame(t);s.clear()}),{timer:i}}}),r=()=>({name:"mouse",extend:t=>{const e=new Map,n=(t,n)=>{if("undefined"==typeof window)return()=>{};const s=t=>{n(t.clientX,t.clientY,t)};window.addEventListener(t,s);let i=e.get(t);return i||(i=new Set,e.set(t,i)),i.add(s),()=>{window.removeEventListener(t,s),i?.delete(s)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const[t,n]of e){for(const e of n)window.removeEventListener(t,e);n.clear()}e.clear()}}),{onMouseMove:t=>n("mousemove",t),onMouseDown:t=>n("mousedown",t),onMouseUp:t=>n("mouseup",t),onMouseWheel:t=>(t=>{if("undefined"==typeof window)return()=>{};const n=e=>{t(e.clientX,e.clientY,e.deltaY,e)};window.addEventListener("wheel",n);let s=e.get("wheel");return s||(s=new Set,e.set("wheel",s)),s.add(n),()=>{window.removeEventListener("wheel",n),s?.delete(n)}})(t)}}}),c=t=>Array.isArray(t),h=t=>null!=t&&"object"==typeof t&&!Array.isArray(t),f=t=>c(t)?t.slice():h(t)?{...t}:t,u=(t,e)=>{if(c(t)&&c(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(!Object.is(t[n],e[n]))return!1;return!0}if(h(t)&&h(e)){const n=Object.keys(t),s=Object.keys(e);if(n.length!==s.length)return!1;for(const s of n){if(!(s in e))return!1;if(!Object.is(t[s],e[s]))return!1}return!0}return!(c(t)||c(e)||h(t)||h(e))&&Object.is(t,e)},l=(t,e)=>Array.from({length:e},()=>t),a=(t,e)=>e.reduce((e,n)=>(e[n]=t,e),{}),d=({from:t,to:e,velocity:n,label:s})=>{const i={value:t,target:e,velocity:n,arrayLength:null,objectKeys:null,normalizeInput:t=>t},o=t=>{if(null==i.arrayLength){if(null!=i.objectKeys)throw new Error(`${s} value shape mismatch (array vs object).`);i.arrayLength=t,c(i.value)||(i.value=l(i.value,t)),c(i.target)||(i.target=l(i.target,t)),void 0===i.velocity||c(i.velocity)||(i.velocity=l(i.velocity,t))}},r=t=>{if(null==i.objectKeys){if(null!=i.arrayLength)throw new Error(`${s} value shape mismatch (object vs array).`);i.objectKeys=t,h(i.value)||(i.value=a(i.value,t)),h(i.target)||(i.target=a(i.target,t)),void 0===i.velocity||h(i.velocity)||(i.velocity=a(i.velocity,t))}},f=t=>{if(c(t)){if(null!=i.objectKeys)throw new Error(`${s} value shape mismatch (array vs object).`);if(null==i.arrayLength&&o(t.length),t.length!==i.arrayLength)throw new Error(`${s} value length mismatch (expected ${i.arrayLength}, got ${t.length}).`);return t.slice()}if(h(t)){if(null!=i.arrayLength)throw new Error(`${s} value shape mismatch (object vs array).`);const e=Object.keys(t);if(null==i.objectKeys&&r(e),i.objectKeys&&e.length!==i.objectKeys.length)throw new Error(`${s} value keys mismatch (expected ${i.objectKeys.length}, got ${e.length}).`);if(i.objectKeys)for(const e of i.objectKeys)if(!(e in t))throw new Error(`${s} value keys mismatch (missing key "${e}").`);return{...t}}return null!=i.arrayLength?l(t,i.arrayLength):null!=i.objectKeys?a(t,i.objectKeys):t};i.normalizeInput=f;const u=c(t)||c(e)||void 0!==n&&c(n),d=h(t)||h(e)||void 0!==n&&h(n);if(u&&d)throw new Error(`${s} value shape mismatch (array vs object).`);if(u){const s=c(t)?t.length:c(e)?e.length:n.length;o(s),i.value=f(t),i.target=f(e),void 0!==i.velocity&&(i.velocity=f(i.velocity))}else if(d){const s=h(t)?Object.keys(t):h(e)?Object.keys(e):Object.keys(n);r(s),i.value=f(t),i.target=f(e),void 0!==i.velocity&&(i.velocity=f(i.velocity))}return i};let p={x:-1,y:-1};const m={stiffness:300,damping:30,mass:1},w="0.0.8-beta.23",y={"&":"&","<":"<",">":">",'"':""","'":"'"},g=t=>null==t||""===t?"":String(t).replace(/[&<>"']/g,t=>y[t]),v=new Set(["checked","disabled","readonly","required","selected","autofocus","multiple","hidden"]),b=/bind:([a-zA-Z_$][\w$]*)="([^"]*)"/g;exports.SCOPE_VERSION=w,exports.define=function(t,e={},o){const{props:r={},shadow:c=!1,styles:h,plugins:f}=e,u=f??[],l=()=>{};class a extends HTMLElement{constructor(){super(),this.version=w,this.t={};for(const t of Object.keys(r)){const e=r[t];this.t[t]=e&&"object"==typeof e&&("type"in e||"default"in e)?e:{type:void 0,default:e,reflect:!1}}this.props={},this.state={},this.actions={},this.refs={},this.emit=this.emit.bind(this),this.listen=this.listen.bind(this),this.setState=this.setState.bind(this),this.updateState=this.updateState.bind(this),this.setProps=this.setProps.bind(this),this.scheduleUpdate=this.scheduleUpdate.bind(this),this.update=this.update.bind(this),this.forceRender=this.forceRender.bind(this),this.destroy=this.destroy.bind(this),this.$=this.$.bind(this),this.i=null,this.o=null,this.h=!1,this.u=!1,this.l=c,this.p=c?this.attachShadow({mode:"open"}):this,this.m=null,this.S=[],this.M=[],this.j=[],this.O=[],this._=[],this.A=[],this.T=[],this.k=[],this.L=null,this.C="mount",this.F=void 0,this.I=new Map,this.R=!1,this.V=!1,this.q={},this.D=t,this.H=!1,this.N=new Set,this.U=!1,this.B=new Map,this.W=0,this.J=!1}P(t){const e=this.l?this.p.host:this;let n=t.parentElement;for(;n;){if(n===e)return!1;if(n.tagName.includes("-"))return!0;n=n.parentElement}return!1}static get observedAttributes(){return Object.keys(r)}attributeChangedCallback(t,e,s){if(e===s)return;const i=this.q[t],o=n(s,this.t[t]);if(this.props[t]=o,this.R&&i!==o)for(const e of this.k)try{e(t,i,o)}catch(t){l(String(t?.message||t))}this.q[t]=o,this.N.has(t)?this.N.delete(t):this.i&&this.isConnected?this.U?this.H=!0:(this.C="props",this.F=[t],this.update(!0)):this.H=!0}connectedCallback(){for(const t in this.t){if(!this.t.hasOwnProperty(t))continue;const e=n(this.getAttribute(t),this.t[t]);this.props[t]=e,this.q[t]=e}c||this.m||(this.m=this.K());let t=null;try{if(o){const e={props:this.props,state:this.state,actions:this.actions,refs:this.refs,emit:this.emit,listen:this.listen,updateState:this.updateState.bind(this),$:this.$,host:this,onMount:t=>this.j.push(t),onDestroy:t=>this.O.push(t),onUpdate:t=>this._.push(t),onBeforeUpdate:t=>this.A.push(t),onFirstUpdate:t=>this.T.push(t),onPropsChanged:t=>this.k.push(t),shouldRender:t=>{this.L=t},link:(t,e)=>{const n=e||t;this.state[n]=this.props[t],this.k.push((e,s,i)=>{e===t&&(Object.is(this.state[n],i)||(this.state[n]=i))}),this.S.push({fn:()=>{const e=this.state[n];if(Object.is(this.props[t],e))return;this.props[t]=e,this.q[t]=e;const s=this.t[t],o=s?{...s,reflect:!0}:s,r=this.getAttribute(t);this.N.add(t),i(this,t,e,o),r===this.getAttribute(t)&&this.N.delete(t)},deps:()=>[this.state[n]]})},computed:(t,e)=>{let n;if(void 0!==e)try{const t="function"==typeof e?e():e;Array.isArray(t)&&(n=t)}catch(t){String(t?.message||t)}const s={getter:t,deps:e,value:void 0!==e?t(n):t()};this.M.push(s);const i=()=>s.value;return i.Z=s,this.G(i),i},effect:(t,e)=>{const n={fn:t,deps:e};return this.S.push(n),()=>this.X(n)},delegate:(t,e,n)=>(this.Y(t,e,n),()=>this.tt(t,e,n)),escapeHtml:g};for(const t of u)if(t)try{const n=t.extend(e,this);n&&"object"==typeof n&&Object.assign(e,n)}catch(t){l(String(t?.message||t))}t=o(e)}}catch(t){throw String(t?.message||t),t}this.i="function"!=typeof t?()=>"":t,this.U=!0,this.C="mount",this.F=void 0,this.update(!0),this.U=!1,this.H&&(this.H=!1,this.C="props",this.F=void 0,this.update(!0))}disconnectedCallback(){this.destroy()}remove(){super.remove()}$(t){const e=this.p.querySelectorAll(t);return 0===e.length?null:1===e.length?e[0]:Array.from(e)}destroy(){for(const t of this.O)try{t()}catch(t){l(String(t?.message||t))}for(const t of this.S)if(t.cleanup){try{t.cleanup()}catch(t){l(String(t?.message||t))}t.cleanup=void 0}for(const[,t]of this.I)try{this.p.removeEventListener(t.eventType,t.listener)}catch{}this.I.clear(),this.R=!1}emit(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}listen(t,e,n,s){const i=n;t.addEventListener(e,i,s);const o=()=>{try{t.removeEventListener(e,i,s)}catch{}};return this.O.push(o),o}setState(t){const e=[],n=t,s=this.state;for(const t in n){if(!Object.prototype.hasOwnProperty.call(n,t))continue;const i=n[t];Object.is(s[t],i)||(s[t]=i,e.push(t))}if(0!==e.length)if(this.U||!this.R)this.C="state",this.F=e,this.update(!0);else{if(!this.i||!this.isConnected)return;if(this.h)return;this.h=!0;const t=[...e];requestAnimationFrame(()=>{this.h=!1,this.i&&this.isConnected&&(this.C="state",this.F=t,this.update(!0))})}}updateState(t){Object.assign(this.state,t),this.i&&this.isConnected&&this.et()}setProps(t){const e=Object.keys(t);if(0===e.length)return;const n=[],s={};for(const o of e){const e=t[o],r=this.q[o];this.props[o]=e,this.R&&r!==e&&(n.push(o),s[o]=r);const c=this.t[o];c&&c.reflect&&i(this,o,e,c),this.R&&r===e||(this.q[o]=e)}if(this.R&&n.length>0)for(const e of n){const n=s[e],i=t[e];for(const t of this.k)try{t(e,n,i)}catch(t){l(String(t?.message||t))}}this.i&&this.isConnected?(this.C="props",this.F=n,this.update(!0)):this.H=!0}scheduleUpdate(){this.i&&this.isConnected&&this.et()}et(){this.u||this.h||(this.u=!0,("function"==typeof queueMicrotask?queueMicrotask:t=>Promise.resolve().then(t))(()=>{this.u=!1,this.i&&this.isConnected&&(this.h||this.update(!1))}))}update(t){if(this.i){if(t&&this.R)for(const t of this.A)try{t()}catch(t){l(String(t?.message||t))}if(t)if(null===this.L||this.L({reason:this.C,changedKeys:this.F})){this.nt();let t="";try{t=this.i()}catch(e){String(e?.message||e),t=""}"string"!=typeof t&&(t=null==t?"":String(t)),t=((t,e,n)=>{const s=Object.prototype.hasOwnProperty;return t.replace(b,(t,i,o)=>{if("text"===i||"html"===i)return t;const r=o.trim();if(!r)return t;const c=s.call(e,r),h=s.call(n,r);if(!c&&!h)return t;const f=c?e[r]:n[r];return v.has(i)?f?`${i}="" ${t}`:t:null==f?t:`${i}="${g(String(f))}" ${t}`})})(t,this.state,this.props),this.l||(t=t.replace(/<slot(?![^>]*data-scope-owner)(\s|>)/g,`<slot data-scope-owner="${this.D}"$1`)),this.J=!1;const e=null!==this.o&&Object.is(this.o,t);let n=!1;e&&this.R||(this.p.innerHTML=t,this.o=t,n=!0),this.U?("function"==typeof requestAnimationFrame?requestAnimationFrame:t=>setTimeout(t,0))(()=>{if(this.i&&this.isConnected){if(n&&!c&&this.projectSlots(),n&&this.st(),!this.R){this.R=!0;for(const t of this.j)try{t()}catch(t){l(String(t?.message||t))}for(const t in this.t){if(!this.t.hasOwnProperty(t))continue;const e=this.props[t],n=s(this.t[t]);if(e!==n)for(const s of this.k)try{s(t,n,e)}catch(t){l(String(t?.message||t))}}}this.it(),this.ot()}}):(n&&!c&&this.projectSlots(),n&&this.st(),this.it(),this.ot())}else this.it(),this.R&&this.ot();else this.J&&this.nt(),this.it(),this.R&&this.ot()}}forceRender(){this.o=null,this.i&&this.isConnected?this.U?this.H=!0:(this.C="force",this.F=void 0,this.update(!0)):this.H=!0}ot(){if(!this.V){this.V=!0;for(const t of this.T)try{t()}catch(t){l(String(t?.message||t))}}for(const t of this._)try{t()}catch(t){l(String(t?.message||t))}this.rt()}rt(){const t=(this.l?this.p:this).querySelectorAll("*"),e=Object.prototype.hasOwnProperty,n=this.state,s=this.props;for(let i=0;i<t.length;i++){const o=t[i];if(this.P(o))continue;if(0===o.attributes.length)continue;const r=o.attributes;for(let t=r.length-1;t>=0;t--){const i=r[t];if(!i.name.startsWith("bind:"))continue;const c=i.name.slice(5),h=i.value,f=h?h.trim():"";let u,l=!1;if(f){const t=this.B.get(f);if(t){t.Z&&(this.J=!0);try{u=t()}catch{}l=!0}}if(!l){const t=f||c,i=e.call(n,t),o=!i&&e.call(s,t);i?u=n[t]:o&&(u=s[t])}if("text"===c){const t=null==u?"":String(u);o.textContent!==t&&(o.textContent=t)}else if("html"===c){const t=null==u?"":String(u);o.innerHTML!==t&&(o.innerHTML=t)}else if(c in o){if(!Object.is(o[c],u))try{o[c]=u}catch{}if("value"===c)try{null==u?o.removeAttribute("value"):o.setAttribute("value",String(u))}catch{}}else if(null!=u)try{o.setAttribute(c,String(u))}catch{}const a=`__scopeBind_${c}`,d=o[a];if(d){const t=d.ct;t&&o.removeEventListener(t,d),delete o[a]}}}}ht(t,e){if(!t||!e||t.length!==e.length)return!0;for(let n=0;n<e.length;n++)if(!Object.is(t[n],e[n]))return!0;return!1}nt(){for(const t of this.M){let e,n=!0;if(void 0!==t.deps)try{const s="function"==typeof t.deps?t.deps():t.deps;Array.isArray(s)&&(e=s,n=this.ht(t.prevDeps,e))}catch(t){l(String(t?.message||t)),n=!0,e=void 0}if(n){try{t.value=void 0!==t.deps?t.getter(e):t.getter()}catch(t){l(String(t?.message||t))}e&&(t.prevDeps=e.slice())}}}it(){for(const t of this.S){let e,n=!0;if(void 0!==t.deps)try{const s="function"==typeof t.deps?t.deps():t.deps;Array.isArray(s)&&(e=s,n=this.ht(t.prevDeps,e))}catch(t){l(String(t?.message||t)),n=!0,e=void 0}if(n){if(t.cleanup){try{t.cleanup()}catch{}t.cleanup=void 0}try{const n=void 0!==t.deps?t.fn(e):t.fn();"function"==typeof n&&(t.cleanup=n)}catch{}e&&(t.prevDeps=e.slice())}}}X(t){const e=this.S.indexOf(t);if(-1!==e){if(t.cleanup)try{t.cleanup()}catch{}this.S.splice(e,1)}}G(t){const e=t.ft;if(e&&"string"==typeof e)return this.B.set(e,t),e;const n=`__scope_bind_${++this.W}__`;this.B.set(n,t);try{t.ft=n,t.toString=()=>n}catch{}return n}st(){const t=(this.l?this.p:this).querySelectorAll("*"),e=this.refs;for(const t in e)e.hasOwnProperty(t)&&delete e[t];for(let n=0;n<t.length;n++){const s=t[n];if(this.P(s))continue;const i=s.getAttribute("ref");if(i&&(e[i]?Array.isArray(e[i])?e[i].push(s):e[i]=[e[i],s]:e[i]=s),s.attributes.length>0){const t=s.attributes;for(let e=t.length-1;e>=0;e--){const n=t[e];if(!n.name.startsWith("on:"))continue;const i=n.name.slice(3),o=n.value,r=`__tinyHandler_${i}`,c=s[r];c&&s.removeEventListener(i,c),s.removeAttribute(n.name);const h=this.actions[o];if(h&&"function"==typeof h){const t=t=>{h.call(this.actions,t)};s[r]=t,s.addEventListener(i,t)}}}}}K(){const t=new Map,e=this.childNodes,n=[];for(let t=0;t<e.length;t++)n.push(e[t]);for(let e=0;e<n.length;e++){const s=n[e];let i="";1===s.nodeType&&s.getAttribute&&(i=s.getAttribute("slot")||""),t.has(i)||t.set(i,[]),t.get(i).push(s)}for(let t=0;t<n.length;t++){const e=n[t];e.parentNode&&e.parentNode.removeChild(e)}return t}projectSlots(){const t=this.m||new Map,e=(this.l?this.p:this).querySelectorAll(`slot[data-scope-owner="${this.D}"]`);if(0!==e.length)for(let n=0;n<e.length;n++){const s=e[n],i=s.getAttribute("name")||"",o=t.get(i)||[];if(o.length){const t=document.createDocumentFragment();for(let e=0;e<o.length;e++){const n=o[e];let s;if(1===n.nodeType&&n.tagName.includes("-")&&n.m instanceof Map){const t=n,e=document.createElement(t.tagName.toLowerCase());for(let n=0;n<t.attributes.length;n++){const s=t.attributes[n];e.setAttribute(s.name,s.value)}for(const n of t.m.values())for(let t=0;t<n.length;t++)e.appendChild(n[t].cloneNode(!0));s=e}else s=n.cloneNode(!0);t.appendChild(s)}s.replaceWith(t)}else{const t=s.childNodes,e=[];for(let n=0;n<t.length;n++)e.push(t[n]);if(e.length>0){const t=document.createDocumentFragment();for(let n=0;n<e.length;n++)t.appendChild(e[n]);s.replaceWith(t)}}}}Y(t,e,n){const s=`${t}::${e}`;let i=this.I.get(s);if(!i){const n=t=>{const n=t.target&&t.target.closest?t.target.closest(e):null;if(n)for(const e of i.handlers)try{e(t,n)}catch{}};i={eventType:t,selector:e,listener:n,handlers:new Set},this.I.set(s,i),this.p.addEventListener(t,n)}i.handlers.add(n)}tt(t,e,n){const s=`${t}::${e}`,i=this.I.get(s);if(i&&(i.handlers.delete(n),0===i.handlers.size)){try{this.p.removeEventListener(t,i.listener)}catch{}this.I.delete(s)}}}if(!customElements.get(t)){if(h&&"undefined"!=typeof document){const e=`scope-${t}-styles`;if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent=h,document.head.appendChild(t)}}try{customElements.define(t,a)}catch(t){String(t?.message||t)}}return a},exports.devicePlugin=()=>({name:"device",extend:t=>{const e=new Map;return t.onDestroy(()=>{for(const[t,n]of e)t.removeEventListener("change",n);e.clear()}),{onMediaQuery:(t,n,s={})=>{if("undefined"==typeof window||"undefined"==typeof matchMedia)return()=>{};const{immediate:i=!0}=s,o=matchMedia(t),r=t=>{n(t.matches,t)};return o.addEventListener("change",r),e.set(o,r),i&&n(o.matches,null),()=>{o.removeEventListener("change",r),e.delete(o)}}}}}),exports.happy=()=>{console.info("The website is using @petit-kit/scoped v"+w,"\nhttps://github.com/petit-kit/scoped")},exports.inViewPlugin=()=>({name:"inview",extend:(t,e)=>{const n=new Set,s=(t,e,s={})=>{if("undefined"==typeof window||"undefined"==typeof IntersectionObserver)return()=>{};const{immediate:i=!0,...o}=s;let r=!i;const c=new IntersectionObserver(n=>{for(const s of n)s.target===t&&(r?r=!1:e(s.isIntersecting,s))},o);return c.observe(t),n.add(c),()=>{c.unobserve(t),c.disconnect(),n.delete(c)}};return t.onDestroy(()=>{for(const t of n)t.disconnect();n.clear()}),{onInView:(t,n)=>s(e,t,n),observeInView:(t,e,n)=>s(t,e,n)}}}),exports.lenisPlugin=t=>({name:"lenis",extend:e=>{const n=new Set;return e.onDestroy(()=>{for(const{lenis:t,handler:e}of n)"function"==typeof t.off&&t.off("scroll",e);n.clear()}),{onLenisScroll:e=>{const s=t();if(!s)return()=>{};const i=t=>{e(t)};s.on("scroll",i);const o={lenis:s,handler:i};return n.add(o),()=>{n.has(o)&&(n.delete(o),"function"==typeof s.off&&s.off("scroll",i))}}}}}),exports.lerpPlugin=()=>({name:"lerp",extend:t=>{const{timer:e}=o().extend(t,t.host),n=new Set;return t.onDestroy(()=>{for(const t of n)t();n.clear()}),{createLerp:t=>function({from:t=0,to:e=1,lerp:n=.1,tolerance:s=.001,delay:i=0,resumeOnTarget:o=!0}={}){function r(){return f(m)}function l(t){if(g)return r();if(v>0){const e=Math.min(t,v);if(v-=e,(t-=e)<=0)return r()}const e=(t=>t<0?0:t>1?1:t)(n);if(0===e)return r();if(1===e)return m=f(w),a.value=m,g=!0,r();const i=t>0?1-Math.pow(1-e,60*t):0;if(c(m)&&c(w)){let t=!0;for(let e=0;e<m.length;e+=1)m[e]+=(w[e]-m[e])*i,Math.abs(w[e]-m[e])>=s&&(t=!1);if(t){for(let t=0;t<m.length;t+=1)m[t]=w[t];g=!0}return a.value=m,f(m)}if(h(m)&&h(w)){const t=a.objectKeys??Object.keys(m);let e=!0;for(const n of t)m[n]+=(w[n]-m[n])*i,Math.abs(w[n]-m[n])>=s&&(e=!1);if(e){for(const e of t)m[e]=w[e];g=!0}return a.value=m,f(m)}const o=w;return m+=(o-m)*i,a.value=m,Math.abs(o-m)<s&&(m=o,a.value=m,g=!0),m}const a=d({from:t,to:e,label:"Lerp"}),p=a.normalizeInput;let m=a.value,w=a.target,y=null,g=!1,v=i;const b=new Set;return{setTarget:function(t){const e=p(t),n=!u(e,w);if(w=e,a.target=e,m=a.value,o&&g&&n){g=!1,y=null,v=i;for(const t of b)t(w)}},getTarget:function(){return f(w)},setValue:function(t,e={}){const{resetTime:n=!0,setTarget:s=!1,markDone:o=!1}=e;m=p(t),a.value=m,s&&(w=f(m),a.target=w);const r=g||!u(m,w);if(n&&(y=null),o&&(g=!0),r&&!o){g=!1,y=null,v=i;for(const t of b)t(w)}},getValue:r,isDone:function(){return g},onResume:function(t){return b.add(t),()=>{b.delete(t)}},step:l,next:function(t=performance.now()){if(null==y)return y=t,r();const e=(t-y)/1e3;y=t;const n=1/30;let s=e,i=r();for(;s>0&&!g;){const t=Math.min(s,n);i=l(t),s-=t}return i}}}(t),runLerp:(t,s,i={})=>{const{fps:o,immediate:r=!0,stopWhenDone:c=!0}=i;let h=!1,f=null;r&&s(t.getValue(),t);const u=()=>{f||(f=e.raf(e=>{if(h)return;const n=t.next(e);s(n,t),c&&t.isDone()&&l()},o))},l=()=>{f&&(f(),f=null)};u();const a=t.onResume(()=>{!h&&c&&(r&&s(t.getValue(),t),u())}),d=()=>{h||(h=!0,a(),l(),n.delete(d))};return n.add(d),d}}}}),exports.localStoragePlugin=(t={})=>({name:"localstorage",extend:n=>{const{prefix:s="",json:i=!0}=t,o="undefined"==typeof window?null:window.localStorage;return{storage:{get:t=>{if(o)try{const n=o.getItem(e(s,t));if(null===n)return;return i?JSON.parse(n):n}catch{return}},set:(t,n)=>{if(o)try{const r=i?JSON.stringify(n):String(n);o.setItem(e(s,t),r)}catch{}},remove:t=>{o&&o.removeItem(e(s,t))},clear:()=>{if(!o)return;if(!s)return;const t=[];for(let e=0;e<o.length;e++){const n=o.key(e);null!=n&&n.startsWith(s+":")&&t.push(n)}for(const e of t)o.removeItem(e)}}}}}),exports.morphPlugin=(t,e={})=>({name:"morph",extend:(n,s)=>{const{ignoreActiveValue:i=!0,callbacks:o}=e,r=t(),c=s.p,h=s.l?ShadowRoot.prototype:HTMLElement.prototype,f=Object.getOwnPropertyDescriptor(h,"innerHTML"),u=t=>{r.morph(c,t,{morphStyle:"innerHTML",ignoreActiveValue:i,callbacks:o})};let l=!0;return Object.defineProperty(c,"innerHTML",{set(t){l?(f.set.call(this,t),l=!1):u(t)},get(){return f.get.call(this)},configurable:!0}),n.onDestroy(()=>{delete c.innerHTML}),{morph:u}}}),exports.mousePlugin=r,exports.pointerPlugin=()=>({name:"pointer",extend:e=>{const{onMouseMove:n}=r().extend(e,e.host),{timer:s}=o().extend(e,e.host);p.x=window.innerWidth/2,p.y=window.innerHeight/2;const i={x:t({from:p.x,to:p.x,...m}),y:t({from:p.y,to:p.y,...m})};return n((t,e)=>{i.x.setTarget(t),i.y.setTarget(e)}),{onPointerMove:t=>{let e=p.x,n=p.y;s.raf(s=>{const o=i.x.next(s),r=i.y.next(s);var c,h;e===o&&n===r||(t({x:o,y:r,v:(c={x:o,y:r},h={x:e,y:n},{x:c.x-h.x,y:c.y-h.y,magnitude:Math.sqrt((c.x-h.x)*(c.x-h.x)+(c.y-h.y)*(c.y-h.y))}).magnitude}),e=o,n=r)})},onMouseMove:n}}}),exports.springPlugin=()=>({name:"spring",extend:e=>{const{timer:n}=o().extend(e,e.host),s=new Set;return e.onDestroy(()=>{for(const t of s)t();s.clear()}),{createSpring:e=>t(e),runSpring:(t,e,i={})=>{const{fps:o,immediate:r=!0,stopWhenDone:c=!0}=i;let h=!1,f=null;r&&e(t.getValue(),t);const u=()=>{f||(f=n.raf(n=>{if(h)return;const s=t.next(n);e(s,t),c&&t.isDone()&&l()},o))},l=()=>{f&&(f(),f=null)};u();const a=t.onResume(()=>{!h&&c&&(r&&e(t.getValue(),t),u())}),d=()=>{h||(h=!0,a(),l(),s.delete(d))};return s.add(d),d}}}}),exports.timerPlugin=o,exports.windowPlugin=()=>({name:"window",extend:t=>{const e=new Set,n=new Set,s=new Set,i=(t,n={})=>{if("undefined"==typeof window)return()=>{};const{immediate:s=!0}=n,i=e=>{t(window.innerWidth,window.innerHeight,e)};return window.addEventListener("resize",i),e.add(i),s&&i(new UIEvent("resize")),()=>{window.removeEventListener("resize",i),e.delete(i)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const t of e)window.removeEventListener("resize",t);e.clear();for(const t of s)t.disconnect();s.clear();for(const t of n)window.removeEventListener("scroll",t);n.clear()}}),{onViewportResize:i,onWindowResize:(t,e={})=>{if("undefined"==typeof window)return()=>{};if("undefined"==typeof ResizeObserver)return i((e,n,s)=>t(e,n,s),e);const{immediate:n=!0}=e,o=document.documentElement,r=new ResizeObserver(e=>{const n=e[0];if(!n)return;const{width:s,height:i}=n.contentRect;t(s,i,n)});if(r.observe(o),s.add(r),n){const e=o.getBoundingClientRect();t(e.width,e.height,new UIEvent("resize"))}return()=>{r.disconnect(),s.delete(r)}},onWindowScroll:(t,e={})=>{if("undefined"==typeof window)return()=>{};const{immediate:s=!0}=e,i=e=>{t(window.scrollX,window.scrollY,e)};return window.addEventListener("scroll",i,{passive:!0}),n.add(i),s&&i(new Event("scroll")),()=>{window.removeEventListener("scroll",i),n.delete(i)}}}}});
|
|
1
|
+
"use strict";function t({from:t=0,to:e=1,mass:n=1,stiffness:s=120,damping:i=14,velocity:o=0,delay:r=0,tolerance:p=.001,resumeOnTarget:m=!0}={}){function w(){return f(b)}function y(t){if(x)return w();if(O>0){const e=Math.min(t,O);if(O-=e,(t-=e)<=0)return w()}if(c(b)&&c(M)&&c(S)){let e=!0;for(let o=0;o<b.length;o+=1){S[o]+=(-s*(b[o]-M[o])-i*S[o])/n*t,b[o]+=S[o]*t;const r=b[o]-M[o];(Math.abs(S[o])>=p||Math.abs(r)>=p)&&(e=!1)}if(e){for(let t=0;t<b.length;t+=1)b[t]=M[t],S[t]=0;x=!0}return g.value=b,g.velocity=S,f(b)}if(h(b)&&h(M)&&h(S)){const e=g.objectKeys??Object.keys(b);let o=!0;for(const r of e){S[r]+=(-s*(b[r]-M[r])-i*S[r])/n*t,b[r]+=S[r]*t;const e=b[r]-M[r];(Math.abs(S[r])>=p||Math.abs(e)>=p)&&(o=!1)}if(o){for(const t of e)b[t]=M[t],S[t]=0;x=!0}return g.value=b,g.velocity=S,f(b)}const e=M;let o=S;o+=(-s*(b-e)-i*o)/n*t,b+=o*t,S=o,g.value=b,g.velocity=S;const r=b-e;return Math.abs(o)<p&&Math.abs(r)<p&&(b=e,S=0,g.value=b,g.velocity=S,x=!0),b}const g=d({from:t,to:e,velocity:o,label:"Spring"}),v=g.normalizeInput;let b=g.value,S=g.velocity??o,M=g.target,j=null,x=!1,O=r;const $=new Set;return{setTarget:function(t){const e=v(t),n=!u(e,M);if(M=e,g.target=e,b=g.value,m&&x&&n){x=!1,j=null,O=r;for(const t of $)t(M)}},getTarget:function(){return f(M)},setValue:function(t,e={}){const{resetVelocity:n=!0,resetTime:s=!0,setTarget:i=!1,markDone:o=!1}=e;b=v(t),g.value=b,i&&(M=f(b),g.target=M);const c=x||!u(b,M);if(n&&(S=null!=g.arrayLength?l(0,g.arrayLength):null!=g.objectKeys?a(0,g.objectKeys):0,g.velocity=S),s&&(j=null),o&&(x=!0),c&&!o){x=!1,j=null,O=r;for(const t of $)t(M)}},getValue:w,isDone:function(){return x},onResume:function(t){return $.add(t),()=>{$.delete(t)}},step:y,next:function(t=performance.now()){if(null==j)return j=t,w();const e=(t-j)/1e3;j=t;const n=1/30;let s=e,i=w();for(;s>0&&!x;){const t=Math.min(s,n);i=y(t),s-=t}return i}}}function e(t,e){return t?`${t}:${e}`:e}function n(t,e){if(!e||"object"!=typeof e||null==e.type)return null!=t?t:e;const{type:n,default:s}=e;if(null==t)return s;try{switch(n){case String:return String(t);case Number:{const e=Number(t);return Number.isNaN(e)?s:e}case Boolean:return""===t||"true"===t||"false"!==t&&"0"!==t&&null!=t;case Object:case Array:try{return"string"==typeof t?JSON.parse(t):t}catch{return n===Array?Array.isArray(s)?s:[]:s}default:return t}}catch{return s}}function s(t){if(!t)return;const e=t.default;return"function"==typeof e?e():e}function i(t,e,n,s){if(!s||"object"!=typeof s||!s.reflect)return;let i=null;const o=s.type;if(o!==Boolean){if(o===Object||o===Array)try{i=null==n?null:JSON.stringify(n)}catch{i=null}else i=null==n?null:String(n);null==i?t.removeAttribute(e):t.setAttribute(e,i)}else n?t.setAttribute(e,""):t.removeAttribute(e)}const o=()=>({name:"timer",extend:t=>{const e=new Set,n=new Set,s=new Set,i={setTimeout:(t,n,...s)=>{let i;return i=setTimeout((...n)=>{e.delete(i),t(...n)},n,...s),e.add(i),i},setInterval:(t,e,...s)=>{const i=setInterval(t,e,...s);return n.add(i),i},raf:(t,e)=>{let n=0,i=!0,o=0;const r="number"==typeof e&&e>0?1e3/e:0,c=e=>{if(s.delete(n),i){if(r){if(e-o>=r){const n=o?e-o:r;o=e,t(e,n)}}else{const n=o?e-o:0;o=e,t(e,n)}n=requestAnimationFrame(c),s.add(n)}};return n=requestAnimationFrame(c),s.add(n),()=>{i&&(i=!1,s.delete(n),cancelAnimationFrame(n))}}};return t.onDestroy(()=>{for(const t of e)clearTimeout(t);e.clear();for(const t of n)clearInterval(t);n.clear();for(const t of s)cancelAnimationFrame(t);s.clear()}),{timer:i}}}),r=()=>({name:"mouse",extend:t=>{const e=new Map,n=(t,n)=>{if("undefined"==typeof window)return()=>{};const s=t=>{n(t.clientX,t.clientY,t)};window.addEventListener(t,s);let i=e.get(t);return i||(i=new Set,e.set(t,i)),i.add(s),()=>{window.removeEventListener(t,s),i?.delete(s)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const[t,n]of e){for(const e of n)window.removeEventListener(t,e);n.clear()}e.clear()}}),{onMouseMove:t=>n("mousemove",t),onMouseDown:t=>n("mousedown",t),onMouseUp:t=>n("mouseup",t),onMouseWheel:t=>(t=>{if("undefined"==typeof window)return()=>{};const n=e=>{t(e.clientX,e.clientY,e.deltaY,e)};window.addEventListener("wheel",n);let s=e.get("wheel");return s||(s=new Set,e.set("wheel",s)),s.add(n),()=>{window.removeEventListener("wheel",n),s?.delete(n)}})(t)}}}),c=t=>Array.isArray(t),h=t=>null!=t&&"object"==typeof t&&!Array.isArray(t),f=t=>c(t)?t.slice():h(t)?{...t}:t,u=(t,e)=>{if(c(t)&&c(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(!Object.is(t[n],e[n]))return!1;return!0}if(h(t)&&h(e)){const n=Object.keys(t),s=Object.keys(e);if(n.length!==s.length)return!1;for(const s of n){if(!(s in e))return!1;if(!Object.is(t[s],e[s]))return!1}return!0}return!(c(t)||c(e)||h(t)||h(e))&&Object.is(t,e)},l=(t,e)=>Array.from({length:e},()=>t),a=(t,e)=>e.reduce((e,n)=>(e[n]=t,e),{}),d=({from:t,to:e,velocity:n,label:s})=>{const i={value:t,target:e,velocity:n,arrayLength:null,objectKeys:null,normalizeInput:t=>t},o=t=>{if(null==i.arrayLength){if(null!=i.objectKeys)throw new Error(`${s} value shape mismatch (array vs object).`);i.arrayLength=t,c(i.value)||(i.value=l(i.value,t)),c(i.target)||(i.target=l(i.target,t)),void 0===i.velocity||c(i.velocity)||(i.velocity=l(i.velocity,t))}},r=t=>{if(null==i.objectKeys){if(null!=i.arrayLength)throw new Error(`${s} value shape mismatch (object vs array).`);i.objectKeys=t,h(i.value)||(i.value=a(i.value,t)),h(i.target)||(i.target=a(i.target,t)),void 0===i.velocity||h(i.velocity)||(i.velocity=a(i.velocity,t))}},f=t=>{if(c(t)){if(null!=i.objectKeys)throw new Error(`${s} value shape mismatch (array vs object).`);if(null==i.arrayLength&&o(t.length),t.length!==i.arrayLength)throw new Error(`${s} value length mismatch (expected ${i.arrayLength}, got ${t.length}).`);return t.slice()}if(h(t)){if(null!=i.arrayLength)throw new Error(`${s} value shape mismatch (object vs array).`);const e=Object.keys(t);if(null==i.objectKeys&&r(e),i.objectKeys&&e.length!==i.objectKeys.length)throw new Error(`${s} value keys mismatch (expected ${i.objectKeys.length}, got ${e.length}).`);if(i.objectKeys)for(const e of i.objectKeys)if(!(e in t))throw new Error(`${s} value keys mismatch (missing key "${e}").`);return{...t}}return null!=i.arrayLength?l(t,i.arrayLength):null!=i.objectKeys?a(t,i.objectKeys):t};i.normalizeInput=f;const u=c(t)||c(e)||void 0!==n&&c(n),d=h(t)||h(e)||void 0!==n&&h(n);if(u&&d)throw new Error(`${s} value shape mismatch (array vs object).`);if(u){const s=c(t)?t.length:c(e)?e.length:n.length;o(s),i.value=f(t),i.target=f(e),void 0!==i.velocity&&(i.velocity=f(i.velocity))}else if(d){const s=h(t)?Object.keys(t):h(e)?Object.keys(e):Object.keys(n);r(s),i.value=f(t),i.target=f(e),void 0!==i.velocity&&(i.velocity=f(i.velocity))}return i};let p={x:-1,y:-1};const m={stiffness:300,damping:30,mass:1},w="0.0.8-beta.24",y={"&":"&","<":"<",">":">",'"':""","'":"'"},g=t=>null==t||""===t?"":String(t).replace(/[&<>"']/g,t=>y[t]),v=new Set(["checked","disabled","readonly","required","selected","autofocus","multiple","hidden"]),b=/bind:([a-zA-Z_$][\w$]*)="([^"]*)"/g;exports.SCOPE_VERSION=w,exports.define=function(t,e={},o){const{props:r={},shadow:c=!1,styles:h,plugins:f}=e,u=f??[],l=()=>{};class a extends HTMLElement{constructor(){super(),this.version=w,this.t={};for(const t of Object.keys(r)){const e=r[t];this.t[t]=e&&"object"==typeof e&&("type"in e||"default"in e)?e:{type:void 0,default:e,reflect:!1}}this.props={},this.state={},this.actions={},this.refs={},this.emit=this.emit.bind(this),this.listen=this.listen.bind(this),this.setState=this.setState.bind(this),this.updateState=this.updateState.bind(this),this.setProps=this.setProps.bind(this),this.scheduleUpdate=this.scheduleUpdate.bind(this),this.update=this.update.bind(this),this.forceRender=this.forceRender.bind(this),this.destroy=this.destroy.bind(this),this.$=this.$.bind(this),this.i=null,this.o=null,this.h=!1,this.u=!1,this.l=c,this.p=c?this.attachShadow({mode:"open"}):this,this.m=null,this.S=[],this.M=[],this.j=[],this.O=[],this._=[],this.A=[],this.T=[],this.k=[],this.L=null,this.C="mount",this.F=void 0,this.I=new Map,this.R=!1,this.V=!1,this.q={},this.D=t,this.H=!1,this.N=new Set,this.U=!1,this.B=new Map,this.W=0,this.J=!1}P(t){const e=this.l?this.p.host:this;let n=t.parentElement;for(;n;){if(n===e)return!1;if(n.tagName.includes("-"))return!0;n=n.parentElement}return!1}static get observedAttributes(){return Object.keys(r)}attributeChangedCallback(t,e,s){if(e===s)return;const i=this.q[t],o=n(s,this.t[t]);if(this.props[t]=o,this.R&&i!==o)for(const e of this.k)try{e(t,i,o)}catch(t){l(String(t?.message||t))}this.q[t]=o,this.N.has(t)?this.N.delete(t):this.i&&this.isConnected?this.U?this.H=!0:(this.C="props",this.F=[t],this.update(!0)):this.H=!0}connectedCallback(){for(const t in this.t){if(!this.t.hasOwnProperty(t))continue;const e=n(this.getAttribute(t),this.t[t]);this.props[t]=e,this.q[t]=e}c||this.m||(this.m=this.K());let t=null;try{if(o){const e={props:this.props,state:this.state,actions:this.actions,refs:this.refs,emit:this.emit,listen:this.listen,updateState:this.updateState.bind(this),$:this.$,host:this,onMount:t=>this.j.push(t),onDestroy:t=>this.O.push(t),onUpdate:t=>this._.push(t),onBeforeUpdate:t=>this.A.push(t),onFirstUpdate:t=>this.T.push(t),onPropsChanged:t=>this.k.push(t),shouldRender:t=>{this.L=t},link:(t,e)=>{const n=e||t;this.state[n]=this.props[t],this.k.push((e,s,i)=>{e===t&&(Object.is(this.state[n],i)||(this.state[n]=i))}),this.S.push({fn:()=>{const e=this.state[n];if(Object.is(this.props[t],e))return;this.props[t]=e,this.q[t]=e;const s=this.t[t],o=s?{...s,reflect:!0}:s,r=this.getAttribute(t);this.N.add(t),i(this,t,e,o),r===this.getAttribute(t)&&this.N.delete(t)},deps:()=>[this.state[n]]})},computed:(t,e)=>{let n;if(void 0!==e)try{const t="function"==typeof e?e():e;Array.isArray(t)&&(n=t)}catch(t){String(t?.message||t)}const s={getter:t,deps:e,value:void 0!==e?t(n):t()};this.M.push(s);const i=()=>s.value;return i.Z=s,this.G(i),i},effect:(t,e)=>{const n={fn:t,deps:e};return this.S.push(n),()=>this.X(n)},delegate:(t,e,n)=>(this.Y(t,e,n),()=>this.tt(t,e,n)),escapeHtml:g};for(const t of u)if(t)try{const n=t.extend(e,this);n&&"object"==typeof n&&Object.assign(e,n)}catch(t){l(String(t?.message||t))}t=o(e)}}catch(t){throw String(t?.message||t),t}this.i="function"!=typeof t?()=>"":t,this.U=!0,this.C="mount",this.F=void 0,this.update(!0),this.U=!1,this.H&&(this.H=!1,this.C="props",this.F=void 0,this.update(!0))}disconnectedCallback(){this.destroy()}remove(){super.remove()}$(t){const e=this.p.querySelectorAll(t);return 0===e.length?null:1===e.length?e[0]:Array.from(e)}destroy(){for(const t of this.O)try{t()}catch(t){l(String(t?.message||t))}for(const t of this.S)if(t.cleanup){try{t.cleanup()}catch(t){l(String(t?.message||t))}t.cleanup=void 0}for(const[,t]of this.I)try{this.p.removeEventListener(t.eventType,t.listener)}catch{}this.I.clear(),this.R=!1}emit(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}listen(t,e,n,s){const i=n;t.addEventListener(e,i,s);const o=()=>{try{t.removeEventListener(e,i,s)}catch{}};return this.O.push(o),o}setState(t){const e=[],n=t,s=this.state;for(const t in n){if(!Object.prototype.hasOwnProperty.call(n,t))continue;const i=n[t];Object.is(s[t],i)||(s[t]=i,e.push(t))}if(0!==e.length)if(this.U||!this.R)this.C="state",this.F=e,this.update(!0);else{if(!this.i||!this.isConnected)return;if(this.h)return;this.h=!0;const t=[...e];requestAnimationFrame(()=>{this.h=!1,this.i&&this.isConnected&&(this.C="state",this.F=t,this.update(!0))})}}updateState(t){Object.assign(this.state,t),this.i&&this.isConnected&&this.et()}setProps(t){const e=Object.keys(t);if(0===e.length)return;const n=[],s={};for(const o of e){const e=t[o],r=this.q[o];this.props[o]=e,this.R&&r!==e&&(n.push(o),s[o]=r);const c=this.t[o];c&&c.reflect&&i(this,o,e,c),this.R&&r===e||(this.q[o]=e)}if(this.R&&n.length>0)for(const e of n){const n=s[e],i=t[e];for(const t of this.k)try{t(e,n,i)}catch(t){l(String(t?.message||t))}}this.i&&this.isConnected?(this.C="props",this.F=n,this.update(!0)):this.H=!0}scheduleUpdate(){this.i&&this.isConnected&&this.et()}et(){this.u||this.h||(this.u=!0,("function"==typeof queueMicrotask?queueMicrotask:t=>Promise.resolve().then(t))(()=>{this.u=!1,this.i&&this.isConnected&&(this.h||this.update(!1))}))}update(t){if(this.i){if(t&&this.R)for(const t of this.A)try{t()}catch(t){l(String(t?.message||t))}if(t)if(null===this.L||this.L({reason:this.C,changedKeys:this.F})){this.nt();let t="";try{t=this.i()}catch(e){String(e?.message||e),t=""}"string"!=typeof t&&(t=null==t?"":String(t)),t=((t,e,n)=>{const s=Object.prototype.hasOwnProperty;return t.replace(b,(t,i,o)=>{if("text"===i||"html"===i)return t;const r=o.trim();if(!r)return t;const c=s.call(e,r),h=s.call(n,r);if(!c&&!h)return t;const f=c?e[r]:n[r];return v.has(i)?f?`${i}="" ${t}`:t:null==f?t:`${i}="${g(String(f))}" ${t}`})})(t,this.state,this.props),this.l||(t=t.replace(/<slot(?![^>]*data-scope-owner)(\s|>)/g,`<slot data-scope-owner="${this.D}"$1`)),this.J=!1;const e=null!==this.o&&Object.is(this.o,t);let n=!1;e&&this.R||(this.p.innerHTML=t,this.o=t,n=!0),this.U?("function"==typeof requestAnimationFrame?requestAnimationFrame:t=>setTimeout(t,0))(()=>{if(this.i&&this.isConnected){if(n&&!c&&this.projectSlots(),n&&this.st(),!this.R){this.R=!0;for(const t of this.j)try{t()}catch(t){l(String(t?.message||t))}for(const t in this.t){if(!this.t.hasOwnProperty(t))continue;const e=this.props[t],n=s(this.t[t]);if(e!==n)for(const s of this.k)try{s(t,n,e)}catch(t){l(String(t?.message||t))}}}this.it(),this.ot()}}):(n&&!c&&this.projectSlots(),n&&this.st(),this.it(),this.ot())}else this.it(),this.R&&this.ot();else this.J&&this.nt(),this.it(),this.R&&this.ot()}}forceRender(){this.o=null,this.i&&this.isConnected?this.U?this.H=!0:(this.C="force",this.F=void 0,this.update(!0)):this.H=!0}ot(){if(!this.V){this.V=!0;for(const t of this.T)try{t()}catch(t){l(String(t?.message||t))}}for(const t of this._)try{t()}catch(t){l(String(t?.message||t))}this.rt()}rt(){const t=(this.l?this.p:this).querySelectorAll("*"),e=Object.prototype.hasOwnProperty,n=this.state,s=this.props;for(let i=0;i<t.length;i++){const o=t[i];if(this.P(o))continue;if(0===o.attributes.length)continue;const r=o.attributes;for(let t=r.length-1;t>=0;t--){const i=r[t];if(!i.name.startsWith("bind:"))continue;const c=i.name.slice(5),h=i.value,f=h?h.trim():"";let u,l=!1;if(f){const t=this.B.get(f);if(t){t.Z&&(this.J=!0);try{u=t()}catch{}l=!0}}if(!l){const t=f||c,i=e.call(n,t),o=!i&&e.call(s,t);i?u=n[t]:o&&(u=s[t])}if("text"===c){const t=null==u?"":String(u);o.textContent!==t&&(o.textContent=t)}else if("html"===c){const t=null==u?"":String(u);o.innerHTML!==t&&(o.innerHTML=t)}else if(c in o){if(!Object.is(o[c],u))try{o[c]=u}catch{}if("value"===c)try{null==u?o.removeAttribute("value"):o.setAttribute("value",String(u))}catch{}}else if(null!=u)try{o.setAttribute(c,String(u))}catch{}const a=`__scopeBind_${c}`,d=o[a];if(d){const t=d.ct;t&&o.removeEventListener(t,d),delete o[a]}}}}ht(t,e){if(!t||!e||t.length!==e.length)return!0;for(let n=0;n<e.length;n++)if(!Object.is(t[n],e[n]))return!0;return!1}nt(){for(const t of this.M){let e,n=!0;if(void 0!==t.deps)try{const s="function"==typeof t.deps?t.deps():t.deps;Array.isArray(s)&&(e=s,n=this.ht(t.prevDeps,e))}catch(t){l(String(t?.message||t)),n=!0,e=void 0}if(n){try{t.value=void 0!==t.deps?t.getter(e):t.getter()}catch(t){l(String(t?.message||t))}e&&(t.prevDeps=e.slice())}}}it(){for(const t of this.S){let e,n=!0;if(void 0!==t.deps)try{const s="function"==typeof t.deps?t.deps():t.deps;Array.isArray(s)&&(e=s,n=this.ht(t.prevDeps,e))}catch(t){l(String(t?.message||t)),n=!0,e=void 0}if(n){if(t.cleanup){try{t.cleanup()}catch{}t.cleanup=void 0}try{const n=void 0!==t.deps?t.fn(e):t.fn();"function"==typeof n&&(t.cleanup=n)}catch{}e&&(t.prevDeps=e.slice())}}}X(t){const e=this.S.indexOf(t);if(-1!==e){if(t.cleanup)try{t.cleanup()}catch{}this.S.splice(e,1)}}G(t){const e=t.ft;if(e&&"string"==typeof e)return this.B.set(e,t),e;const n=`__scope_bind_${++this.W}__`;this.B.set(n,t);try{t.ft=n,t.toString=()=>n}catch{}return n}st(){const t=(this.l?this.p:this).querySelectorAll("*"),e=this.refs;for(const t in e)e.hasOwnProperty(t)&&delete e[t];for(let n=0;n<t.length;n++){const s=t[n];if(this.P(s))continue;const i=s.getAttribute("ref");if(i&&(e[i]?Array.isArray(e[i])?e[i].push(s):e[i]=[e[i],s]:e[i]=s),s.attributes.length>0){const t=s.attributes;for(let e=t.length-1;e>=0;e--){const n=t[e];if(!n.name.startsWith("on:"))continue;const i=n.name.slice(3),o=n.value,r=`__tinyHandler_${i}`,c=s[r];c&&s.removeEventListener(i,c),s.removeAttribute(n.name);const h=this.actions[o];if(h&&"function"==typeof h){const t=t=>{h.call(this.actions,t)};s[r]=t,s.addEventListener(i,t)}}}}}K(){const t=new Map,e=this.childNodes,n=[];for(let t=0;t<e.length;t++)n.push(e[t]);for(let e=0;e<n.length;e++){const s=n[e];let i="";1===s.nodeType&&s.getAttribute&&(i=s.getAttribute("slot")||""),t.has(i)||t.set(i,[]),t.get(i).push(s)}for(let t=0;t<n.length;t++){const e=n[t];e.parentNode&&e.parentNode.removeChild(e)}return t}projectSlots(){const t=this.m||new Map,e=(this.l?this.p:this).querySelectorAll(`slot[data-scope-owner="${this.D}"]`);if(0!==e.length)for(let n=0;n<e.length;n++){const s=e[n],i=s.getAttribute("name")||"",o=t.get(i)||[];if(o.length){const t=document.createDocumentFragment();for(let e=0;e<o.length;e++){const n=o[e];let s;if(1===n.nodeType&&n.tagName.includes("-")&&n.m instanceof Map){const t=n,e=document.createElement(t.tagName.toLowerCase());for(let n=0;n<t.attributes.length;n++){const s=t.attributes[n];e.setAttribute(s.name,s.value)}for(const n of t.m.values())for(let t=0;t<n.length;t++)e.appendChild(n[t].cloneNode(!0));s=e}else s=n.cloneNode(!0);t.appendChild(s)}s.replaceWith(t)}else{const t=s.childNodes,e=[];for(let n=0;n<t.length;n++)e.push(t[n]);if(e.length>0){const t=document.createDocumentFragment();for(let n=0;n<e.length;n++)t.appendChild(e[n]);s.replaceWith(t)}}}}Y(t,e,n){const s=`${t}::${e}`;let i=this.I.get(s);if(!i){const n=t=>{const n=t.target&&t.target.closest?t.target.closest(e):null;if(n)for(const e of i.handlers)try{e(t,n)}catch{}};i={eventType:t,selector:e,listener:n,handlers:new Set},this.I.set(s,i),this.p.addEventListener(t,n)}i.handlers.add(n)}tt(t,e,n){const s=`${t}::${e}`,i=this.I.get(s);if(i&&(i.handlers.delete(n),0===i.handlers.size)){try{this.p.removeEventListener(t,i.listener)}catch{}this.I.delete(s)}}}if(!customElements.get(t)){if(h&&"undefined"!=typeof document){const e=`scope-${t}-styles`;if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent=h,document.head.appendChild(t)}}try{customElements.define(t,a)}catch(t){String(t?.message||t)}}return a},exports.devicePlugin=()=>({name:"device",extend:t=>{const e=new Map;return t.onDestroy(()=>{for(const[t,n]of e)t.removeEventListener("change",n);e.clear()}),{onMediaQuery:(t,n,s={})=>{if("undefined"==typeof window||"undefined"==typeof matchMedia)return()=>{};const{immediate:i=!0}=s,o=matchMedia(t),r=t=>{n(t.matches,t)};return o.addEventListener("change",r),e.set(o,r),i&&n(o.matches,null),()=>{o.removeEventListener("change",r),e.delete(o)}}}}}),exports.happy=()=>{console.info("The website is using @petit-kit/scoped v"+w,"\nhttps://github.com/petit-kit/scoped")},exports.inViewPlugin=()=>({name:"inview",extend:(t,e)=>{const n=new Set,s=(t,e,s={})=>{if("undefined"==typeof window||"undefined"==typeof IntersectionObserver)return()=>{};const{immediate:i=!0,...o}=s;let r=!i;const c=new IntersectionObserver(n=>{for(const s of n)s.target===t&&(r?r=!1:e(s.isIntersecting,s))},o);return c.observe(t),n.add(c),()=>{c.unobserve(t),c.disconnect(),n.delete(c)}};return t.onDestroy(()=>{for(const t of n)t.disconnect();n.clear()}),{onInView:(t,n)=>s(e,t,n),observeInView:(t,e,n)=>s(t,e,n)}}}),exports.lenisPlugin=t=>({name:"lenis",extend:e=>{const n=new Set;return e.onDestroy(()=>{for(const{lenis:t,handler:e}of n)"function"==typeof t.off&&t.off("scroll",e);n.clear()}),{onLenisScroll:e=>{const s=t();if(!s)return()=>{};const i=t=>{e(t)};s.on("scroll",i);const o={lenis:s,handler:i};return n.add(o),()=>{n.has(o)&&(n.delete(o),"function"==typeof s.off&&s.off("scroll",i))}}}}}),exports.lerpPlugin=()=>({name:"lerp",extend:t=>{const{timer:e}=o().extend(t,t.host),n=new Set;return t.onDestroy(()=>{for(const t of n)t();n.clear()}),{createLerp:t=>function({from:t=0,to:e=1,lerp:n=.1,tolerance:s=.001,delay:i=0,resumeOnTarget:o=!0}={}){function r(){return f(m)}function l(t){if(g)return r();if(v>0){const e=Math.min(t,v);if(v-=e,(t-=e)<=0)return r()}const e=(t=>t<0?0:t>1?1:t)(n);if(0===e)return r();if(1===e)return m=f(w),a.value=m,g=!0,r();const i=t>0?1-Math.pow(1-e,60*t):0;if(c(m)&&c(w)){let t=!0;for(let e=0;e<m.length;e+=1)m[e]+=(w[e]-m[e])*i,Math.abs(w[e]-m[e])>=s&&(t=!1);if(t){for(let t=0;t<m.length;t+=1)m[t]=w[t];g=!0}return a.value=m,f(m)}if(h(m)&&h(w)){const t=a.objectKeys??Object.keys(m);let e=!0;for(const n of t)m[n]+=(w[n]-m[n])*i,Math.abs(w[n]-m[n])>=s&&(e=!1);if(e){for(const e of t)m[e]=w[e];g=!0}return a.value=m,f(m)}const o=w;return m+=(o-m)*i,a.value=m,Math.abs(o-m)<s&&(m=o,a.value=m,g=!0),m}const a=d({from:t,to:e,label:"Lerp"}),p=a.normalizeInput;let m=a.value,w=a.target,y=null,g=!1,v=i;const b=new Set;return{setTarget:function(t){const e=p(t),n=!u(e,w);if(w=e,a.target=e,m=a.value,o&&g&&n){g=!1,y=null,v=i;for(const t of b)t(w)}},getTarget:function(){return f(w)},setValue:function(t,e={}){const{resetTime:n=!0,setTarget:s=!1,markDone:o=!1}=e;m=p(t),a.value=m,s&&(w=f(m),a.target=w);const r=g||!u(m,w);if(n&&(y=null),o&&(g=!0),r&&!o){g=!1,y=null,v=i;for(const t of b)t(w)}},getValue:r,isDone:function(){return g},onResume:function(t){return b.add(t),()=>{b.delete(t)}},step:l,next:function(t=performance.now()){if(null==y)return y=t,r();const e=(t-y)/1e3;y=t;const n=1/30;let s=e,i=r();for(;s>0&&!g;){const t=Math.min(s,n);i=l(t),s-=t}return i}}}(t),runLerp:(t,s,i={})=>{const{fps:o,immediate:r=!0,stopWhenDone:c=!0}=i;let h=!1,f=null;r&&s(t.getValue(),t);const u=()=>{f||(f=e.raf(e=>{if(h)return;const n=t.next(e);s(n,t),c&&t.isDone()&&l()},o))},l=()=>{f&&(f(),f=null)};u();const a=t.onResume(()=>{!h&&c&&(r&&s(t.getValue(),t),u())}),d=()=>{h||(h=!0,a(),l(),n.delete(d))};return n.add(d),d}}}}),exports.localStoragePlugin=(t={})=>({name:"localstorage",extend:n=>{const{prefix:s="",json:i=!0}=t,o="undefined"==typeof window?null:window.localStorage;return{storage:{get:t=>{if(o)try{const n=o.getItem(e(s,t));if(null===n)return;return i?JSON.parse(n):n}catch{return}},set:(t,n)=>{if(o)try{const r=i?JSON.stringify(n):String(n);o.setItem(e(s,t),r)}catch{}},remove:t=>{o&&o.removeItem(e(s,t))},clear:()=>{if(!o)return;if(!s)return;const t=[];for(let e=0;e<o.length;e++){const n=o.key(e);null!=n&&n.startsWith(s+":")&&t.push(n)}for(const e of t)o.removeItem(e)}}}}}),exports.morphPlugin=(t,e={})=>({name:"morph",extend:(n,s)=>{const{ignoreActiveValue:i=!0,callbacks:o}=e,r=t(),c=s.p,h=s.l?ShadowRoot.prototype:HTMLElement.prototype,f=Object.getOwnPropertyDescriptor(h,"innerHTML"),u=t=>{r.morph(c,t,{morphStyle:"innerHTML",ignoreActiveValue:i,callbacks:o})};let l=!0;return Object.defineProperty(c,"innerHTML",{set(t){l?(f.set.call(this,t),l=!1):u(t)},get(){return f.get.call(this)},configurable:!0}),n.onDestroy(()=>{delete c.innerHTML}),{morph:u}}}),exports.mousePlugin=r,exports.pointerPlugin=()=>({name:"pointer",extend:e=>{const{onMouseMove:n}=r().extend(e,e.host),{timer:s}=o().extend(e,e.host);p.x=window.innerWidth/2,p.y=window.innerHeight/2;const i={x:t({from:p.x,to:p.x,...m}),y:t({from:p.y,to:p.y,...m})};return n((t,e)=>{i.x.setTarget(t),i.y.setTarget(e)}),{onPointerMove:t=>{let e=p.x,n=p.y;s.raf(s=>{const o=i.x.next(s),r=i.y.next(s);var c,h;e===o&&n===r||(t({x:o,y:r,v:(c={x:o,y:r},h={x:e,y:n},{x:c.x-h.x,y:c.y-h.y,magnitude:Math.sqrt((c.x-h.x)*(c.x-h.x)+(c.y-h.y)*(c.y-h.y))}).magnitude}),e=o,n=r)})},onMouseMove:n}}}),exports.springPlugin=()=>({name:"spring",extend:e=>{const{timer:n}=o().extend(e,e.host),s=new Set;return e.onDestroy(()=>{for(const t of s)t();s.clear()}),{createSpring:e=>t(e),runSpring:(t,e,i={})=>{const{fps:o,immediate:r=!0,stopWhenDone:c=!0}=i;let h=!1,f=null;r&&e(t.getValue(),t);const u=()=>{f||(f=n.raf(n=>{if(h)return;const s=t.next(n);e(s,t),c&&t.isDone()&&l()},o))},l=()=>{f&&(f(),f=null)};u();const a=t.onResume(()=>{!h&&c&&(r&&e(t.getValue(),t),u())}),d=()=>{h||(h=!0,a(),l(),s.delete(d))};return s.add(d),d}}}}),exports.timerPlugin=o,exports.windowPlugin=()=>({name:"window",extend:t=>{const e=new Set,n=new Set,s=new Set,i=(t,n={})=>{if("undefined"==typeof window)return()=>{};const{immediate:s=!0}=n,i=e=>{t(window.innerWidth,window.innerHeight,e)};return window.addEventListener("resize",i),e.add(i),s&&i(new UIEvent("resize")),()=>{window.removeEventListener("resize",i),e.delete(i)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const t of e)window.removeEventListener("resize",t);e.clear();for(const t of s)t.disconnect();s.clear();for(const t of n)window.removeEventListener("scroll",t);n.clear()}}),{onViewportResize:i,onWindowResize:(t,e={})=>{if("undefined"==typeof window)return()=>{};if("undefined"==typeof ResizeObserver)return i((e,n,s)=>t(e,n,s),e);const{immediate:n=!0}=e,o=document.documentElement,r=new ResizeObserver(e=>{const n=e[0];if(!n)return;const{width:s,height:i}=n.contentRect;t(s,i,n)});if(r.observe(o),s.add(r),n){const e=o.getBoundingClientRect();t(e.width,e.height,new UIEvent("resize"))}return()=>{r.disconnect(),s.delete(r)}},onWindowScroll:(t,e={})=>{if("undefined"==typeof window)return()=>{};const{immediate:s=!0}=e,i=e=>{t(window.scrollX,window.scrollY,e)};return window.addEventListener("scroll",i,{passive:!0}),n.add(i),s&&i(new Event("scroll")),()=>{window.removeEventListener("scroll",i),n.delete(i)}}}}});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function t({from:t=0,to:e=1,mass:n=1,stiffness:i=120,damping:s=14,velocity:o=0,delay:r=0,tolerance:c=.001,resumeOnTarget:h=!0}={}){function f(){return p(b)}function u(t){if(O)return f();if($>0){const e=Math.min(t,$);if($-=e,(t-=e)<=0)return f()}if(d(b)&&d(M)&&d(S)){let e=!0;for(let o=0;o<b.length;o+=1){S[o]+=(-i*(b[o]-M[o])-s*S[o])/n*t,b[o]+=S[o]*t;const r=b[o]-M[o];(Math.abs(S[o])>=c||Math.abs(r)>=c)&&(e=!1)}if(e){for(let t=0;t<b.length;t+=1)b[t]=M[t],S[t]=0;O=!0}return l.value=b,l.velocity=S,p(b)}if(m(b)&&m(M)&&m(S)){const e=l.objectKeys??Object.keys(b);let o=!0;for(const r of e){S[r]+=(-i*(b[r]-M[r])-s*S[r])/n*t,b[r]+=S[r]*t;const e=b[r]-M[r];(Math.abs(S[r])>=c||Math.abs(e)>=c)&&(o=!1)}if(o){for(const t of e)b[t]=M[t],S[t]=0;O=!0}return l.value=b,l.velocity=S,p(b)}const e=M;let o=S;o+=(-i*(b-e)-s*o)/n*t,b+=o*t,S=o,l.value=b,l.velocity=S;const r=b-e;return Math.abs(o)<c&&Math.abs(r)<c&&(b=e,S=0,l.value=b,l.velocity=S,O=!0),b}const l=v({from:t,to:e,velocity:o,label:"Spring"}),a=l.normalizeInput;let b=l.value,S=l.velocity??o,M=l.target,j=null,O=!1,$=r;const x=new Set;return{setTarget:function(t){const e=a(t),n=!w(e,M);if(M=e,l.target=e,b=l.value,h&&O&&n){O=!1,j=null,$=r;for(const t of x)t(M)}},getTarget:function(){return p(M)},setValue:function(t,e={}){const{resetVelocity:n=!0,resetTime:i=!0,setTarget:s=!1,markDone:o=!1}=e;b=a(t),l.value=b,s&&(M=p(b),l.target=M);const c=O||!w(b,M);if(n&&(S=null!=l.arrayLength?y(0,l.arrayLength):null!=l.objectKeys?g(0,l.objectKeys):0,l.velocity=S),i&&(j=null),o&&(O=!0),c&&!o){O=!1,j=null,$=r;for(const t of x)t(M)}},getValue:f,isDone:function(){return O},onResume:function(t){return x.add(t),()=>{x.delete(t)}},step:u,next:function(t=performance.now()){if(null==j)return j=t,f();const e=(t-j)/1e3;j=t;const n=1/30;let i=e,s=f();for(;i>0&&!O;){const t=Math.min(i,n);s=u(t),i-=t}return s}}}function e(t,e){return t?`${t}:${e}`:e}function n(t,e){if(!e||"object"!=typeof e||null==e.type)return null!=t?t:e;const{type:n,default:i}=e;if(null==t)return i;try{switch(n){case String:return String(t);case Number:{const e=Number(t);return Number.isNaN(e)?i:e}case Boolean:return""===t||"true"===t||"false"!==t&&"0"!==t&&null!=t;case Object:case Array:try{return"string"==typeof t?JSON.parse(t):t}catch{return n===Array?Array.isArray(i)?i:[]:i}default:return t}}catch{return i}}function i(t){if(!t)return;const e=t.default;return"function"==typeof e?e():e}function s(t,e,n,i){if(!i||"object"!=typeof i||!i.reflect)return;let s=null;const o=i.type;if(o!==Boolean){if(o===Object||o===Array)try{s=null==n?null:JSON.stringify(n)}catch{s=null}else s=null==n?null:String(n);null==s?t.removeAttribute(e):t.setAttribute(e,s)}else n?t.setAttribute(e,""):t.removeAttribute(e)}function o(t,e={},o){const{props:r={},shadow:c=!1,styles:h,plugins:f}=e,u=f??[],l=()=>{};class a extends HTMLElement{constructor(){super(),this.version=x,this.t={};for(const t of Object.keys(r)){const e=r[t];this.t[t]=e&&"object"==typeof e&&("type"in e||"default"in e)?e:{type:void 0,default:e,reflect:!1}}this.props={},this.state={},this.actions={},this.refs={},this.emit=this.emit.bind(this),this.listen=this.listen.bind(this),this.setState=this.setState.bind(this),this.updateState=this.updateState.bind(this),this.setProps=this.setProps.bind(this),this.scheduleUpdate=this.scheduleUpdate.bind(this),this.update=this.update.bind(this),this.forceRender=this.forceRender.bind(this),this.destroy=this.destroy.bind(this),this.$=this.$.bind(this),this.i=null,this.o=null,this.h=!1,this.u=!1,this.l=c,this.m=c?this.attachShadow({mode:"open"}):this,this.p=null,this.S=[],this.M=[],this.j=[],this.O=[],this._=[],this.A=[],this.T=[],this.k=[],this.L=null,this.C="mount",this.F=void 0,this.I=new Map,this.R=!1,this.V=!1,this.q={},this.D=t,this.H=!1,this.N=new Set,this.U=!1,this.B=new Map,this.W=0,this.J=!1}P(t){const e=this.l?this.m.host:this;let n=t.parentElement;for(;n;){if(n===e)return!1;if(n.tagName.includes("-"))return!0;n=n.parentElement}return!1}static get observedAttributes(){return Object.keys(r)}attributeChangedCallback(t,e,i){if(e===i)return;const s=this.q[t],o=n(i,this.t[t]);if(this.props[t]=o,this.R&&s!==o)for(const e of this.k)try{e(t,s,o)}catch(t){l(String(t?.message||t))}this.q[t]=o,this.N.has(t)?this.N.delete(t):this.i&&this.isConnected?this.U?this.H=!0:(this.C="props",this.F=[t],this.update(!0)):this.H=!0}connectedCallback(){for(const t in this.t){if(!this.t.hasOwnProperty(t))continue;const e=n(this.getAttribute(t),this.t[t]);this.props[t]=e,this.q[t]=e}c||this.p||(this.p=this.K());let t=null;try{if(o){const e={props:this.props,state:this.state,actions:this.actions,refs:this.refs,emit:this.emit,listen:this.listen,updateState:this.updateState.bind(this),$:this.$,host:this,onMount:t=>this.j.push(t),onDestroy:t=>this.O.push(t),onUpdate:t=>this._.push(t),onBeforeUpdate:t=>this.A.push(t),onFirstUpdate:t=>this.T.push(t),onPropsChanged:t=>this.k.push(t),shouldRender:t=>{this.L=t},link:(t,e)=>{const n=e||t;this.state[n]=this.props[t],this.k.push((e,i,s)=>{e===t&&(Object.is(this.state[n],s)||(this.state[n]=s))}),this.S.push({fn:()=>{const e=this.state[n];if(Object.is(this.props[t],e))return;this.props[t]=e,this.q[t]=e;const i=this.t[t],o=i?{...i,reflect:!0}:i,r=this.getAttribute(t);this.N.add(t),s(this,t,e,o),r===this.getAttribute(t)&&this.N.delete(t)},deps:()=>[this.state[n]]})},computed:(t,e)=>{let n;if(void 0!==e)try{const t="function"==typeof e?e():e;Array.isArray(t)&&(n=t)}catch(t){String(t?.message||t)}const i={getter:t,deps:e,value:void 0!==e?t(n):t()};this.M.push(i);const s=()=>i.value;return s.Z=i,this.G(s),s},effect:(t,e)=>{const n={fn:t,deps:e};return this.S.push(n),()=>this.X(n)},delegate:(t,e,n)=>(this.Y(t,e,n),()=>this.tt(t,e,n)),escapeHtml:T};for(const t of u)if(t)try{const n=t.extend(e,this);n&&"object"==typeof n&&Object.assign(e,n)}catch(t){l(String(t?.message||t))}t=o(e)}}catch(t){throw String(t?.message||t),t}this.i="function"!=typeof t?()=>"":t,this.U=!0,this.C="mount",this.F=void 0,this.update(!0),this.U=!1,this.H&&(this.H=!1,this.C="props",this.F=void 0,this.update(!0))}disconnectedCallback(){this.destroy()}remove(){super.remove()}$(t){const e=this.m.querySelectorAll(t);return 0===e.length?null:1===e.length?e[0]:Array.from(e)}destroy(){for(const t of this.O)try{t()}catch(t){l(String(t?.message||t))}for(const t of this.S)if(t.cleanup){try{t.cleanup()}catch(t){l(String(t?.message||t))}t.cleanup=void 0}for(const[,t]of this.I)try{this.m.removeEventListener(t.eventType,t.listener)}catch{}this.I.clear(),this.R=!1}emit(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}listen(t,e,n,i){const s=n;t.addEventListener(e,s,i);const o=()=>{try{t.removeEventListener(e,s,i)}catch{}};return this.O.push(o),o}setState(t){const e=[],n=t,i=this.state;for(const t in n){if(!Object.prototype.hasOwnProperty.call(n,t))continue;const s=n[t];Object.is(i[t],s)||(i[t]=s,e.push(t))}if(0!==e.length)if(this.U||!this.R)this.C="state",this.F=e,this.update(!0);else{if(!this.i||!this.isConnected)return;if(this.h)return;this.h=!0;const t=[...e];requestAnimationFrame(()=>{this.h=!1,this.i&&this.isConnected&&(this.C="state",this.F=t,this.update(!0))})}}updateState(t){Object.assign(this.state,t),this.i&&this.isConnected&&this.et()}setProps(t){const e=Object.keys(t);if(0===e.length)return;const n=[],i={};for(const o of e){const e=t[o],r=this.q[o];this.props[o]=e,this.R&&r!==e&&(n.push(o),i[o]=r);const c=this.t[o];c&&c.reflect&&s(this,o,e,c),this.R&&r===e||(this.q[o]=e)}if(this.R&&n.length>0)for(const e of n){const n=i[e],s=t[e];for(const t of this.k)try{t(e,n,s)}catch(t){l(String(t?.message||t))}}this.i&&this.isConnected?(this.C="props",this.F=n,this.update(!0)):this.H=!0}scheduleUpdate(){this.i&&this.isConnected&&this.et()}et(){this.u||this.h||(this.u=!0,("function"==typeof queueMicrotask?queueMicrotask:t=>Promise.resolve().then(t))(()=>{this.u=!1,this.i&&this.isConnected&&(this.h||this.update(!1))}))}update(t){if(this.i){if(t&&this.R)for(const t of this.A)try{t()}catch(t){l(String(t?.message||t))}if(t)if(null===this.L||this.L({reason:this.C,changedKeys:this.F})){this.nt();let t="";try{t=this.i()}catch(e){String(e?.message||e),t=""}"string"!=typeof t&&(t=null==t?"":String(t)),t=((t,e,n)=>{const i=Object.prototype.hasOwnProperty;return t.replace(z,(t,s,o)=>{if("text"===s||"html"===s)return t;const r=o.trim();if(!r)return t;const c=i.call(e,r),h=i.call(n,r);if(!c&&!h)return t;const f=c?e[r]:n[r];return k.has(s)?f?`${s}="" ${t}`:t:null==f?t:`${s}="${T(String(f))}" ${t}`})})(t,this.state,this.props),this.l||(t=t.replace(/<slot(?![^>]*data-scope-owner)(\s|>)/g,`<slot data-scope-owner="${this.D}"$1`)),this.J=!1;const e=null!==this.o&&Object.is(this.o,t);let n=!1;e&&this.R||(this.m.innerHTML=t,this.o=t,n=!0),this.U?("function"==typeof requestAnimationFrame?requestAnimationFrame:t=>setTimeout(t,0))(()=>{if(this.i&&this.isConnected){if(n&&!c&&this.projectSlots(),n&&this.it(),!this.R){this.R=!0;for(const t of this.j)try{t()}catch(t){l(String(t?.message||t))}for(const t in this.t){if(!this.t.hasOwnProperty(t))continue;const e=this.props[t],n=i(this.t[t]);if(e!==n)for(const i of this.k)try{i(t,n,e)}catch(t){l(String(t?.message||t))}}}this.st(),this.ot()}}):(n&&!c&&this.projectSlots(),n&&this.it(),this.st(),this.ot())}else this.st(),this.R&&this.ot();else this.J&&this.nt(),this.st(),this.R&&this.ot()}}forceRender(){this.o=null,this.i&&this.isConnected?this.U?this.H=!0:(this.C="force",this.F=void 0,this.update(!0)):this.H=!0}ot(){if(!this.V){this.V=!0;for(const t of this.T)try{t()}catch(t){l(String(t?.message||t))}}for(const t of this._)try{t()}catch(t){l(String(t?.message||t))}this.rt()}rt(){const t=(this.l?this.m:this).querySelectorAll("*"),e=Object.prototype.hasOwnProperty,n=this.state,i=this.props;for(let s=0;s<t.length;s++){const o=t[s];if(this.P(o))continue;if(0===o.attributes.length)continue;const r=o.attributes;for(let t=r.length-1;t>=0;t--){const s=r[t];if(!s.name.startsWith(E))continue;const c=s.name.slice(5),h=s.value,f=h?h.trim():"";let u,l=!1;if(f){const t=this.B.get(f);if(t){t.Z&&(this.J=!0);try{u=t()}catch{}l=!0}}if(!l){const t=f||c,s=e.call(n,t),o=!s&&e.call(i,t);s?u=n[t]:o&&(u=i[t])}if("text"===c){const t=null==u?"":String(u);o.textContent!==t&&(o.textContent=t)}else if("html"===c){const t=null==u?"":String(u);o.innerHTML!==t&&(o.innerHTML=t)}else if(c in o){if(!Object.is(o[c],u))try{o[c]=u}catch{}if("value"===c)try{null==u?o.removeAttribute("value"):o.setAttribute("value",String(u))}catch{}}else if(null!=u)try{o.setAttribute(c,String(u))}catch{}const a=`__scopeBind_${c}`,d=o[a];if(d){const t=d.ct;t&&o.removeEventListener(t,d),delete o[a]}}}}ht(t,e){if(!t||!e||t.length!==e.length)return!0;for(let n=0;n<e.length;n++)if(!Object.is(t[n],e[n]))return!0;return!1}nt(){for(const t of this.M){let e,n=!0;if(void 0!==t.deps)try{const i="function"==typeof t.deps?t.deps():t.deps;Array.isArray(i)&&(e=i,n=this.ht(t.prevDeps,e))}catch(t){l(String(t?.message||t)),n=!0,e=void 0}if(n){try{t.value=void 0!==t.deps?t.getter(e):t.getter()}catch(t){l(String(t?.message||t))}e&&(t.prevDeps=e.slice())}}}st(){for(const t of this.S){let e,n=!0;if(void 0!==t.deps)try{const i="function"==typeof t.deps?t.deps():t.deps;Array.isArray(i)&&(e=i,n=this.ht(t.prevDeps,e))}catch(t){l(String(t?.message||t)),n=!0,e=void 0}if(n){if(t.cleanup){try{t.cleanup()}catch{}t.cleanup=void 0}try{const n=void 0!==t.deps?t.fn(e):t.fn();"function"==typeof n&&(t.cleanup=n)}catch{}e&&(t.prevDeps=e.slice())}}}X(t){const e=this.S.indexOf(t);if(-1!==e){if(t.cleanup)try{t.cleanup()}catch{}this.S.splice(e,1)}}G(t){const e=t.ft;if(e&&"string"==typeof e)return this.B.set(e,t),e;const n=`__scope_bind_${++this.W}__`;this.B.set(n,t);try{t.ft=n,t.toString=()=>n}catch{}return n}it(){const t=(this.l?this.m:this).querySelectorAll("*"),e=this.refs;for(const t in e)e.hasOwnProperty(t)&&delete e[t];for(let n=0;n<t.length;n++){const i=t[n];if(this.P(i))continue;const s=i.getAttribute("ref");if(s&&(e[s]?Array.isArray(e[s])?e[s].push(i):e[s]=[e[s],i]:e[s]=i),i.attributes.length>0){const t=i.attributes;for(let e=t.length-1;e>=0;e--){const n=t[e];if(!n.name.startsWith("on:"))continue;const s=n.name.slice(3),o=n.value,r=`__tinyHandler_${s}`,c=i[r];c&&i.removeEventListener(s,c),i.removeAttribute(n.name);const h=this.actions[o];if(h&&"function"==typeof h){const t=t=>{h.call(this.actions,t)};i[r]=t,i.addEventListener(s,t)}}}}}K(){const t=new Map,e=this.childNodes,n=[];for(let t=0;t<e.length;t++)n.push(e[t]);for(let e=0;e<n.length;e++){const i=n[e];let s="";1===i.nodeType&&i.getAttribute&&(s=i.getAttribute("slot")||""),t.has(s)||t.set(s,[]),t.get(s).push(i)}for(let t=0;t<n.length;t++){const e=n[t];e.parentNode&&e.parentNode.removeChild(e)}return t}projectSlots(){const t=this.p||new Map,e=(this.l?this.m:this).querySelectorAll(`slot[data-scope-owner="${this.D}"]`);if(0!==e.length)for(let n=0;n<e.length;n++){const i=e[n],s=i.getAttribute("name")||"",o=t.get(s)||[];if(o.length){const t=document.createDocumentFragment();for(let e=0;e<o.length;e++){const n=o[e];let i;if(1===n.nodeType&&n.tagName.includes("-")&&n.p instanceof Map){const t=n,e=document.createElement(t.tagName.toLowerCase());for(let n=0;n<t.attributes.length;n++){const i=t.attributes[n];e.setAttribute(i.name,i.value)}for(const n of t.p.values())for(let t=0;t<n.length;t++)e.appendChild(n[t].cloneNode(!0));i=e}else i=n.cloneNode(!0);t.appendChild(i)}i.replaceWith(t)}else{const t=i.childNodes,e=[];for(let n=0;n<t.length;n++)e.push(t[n]);if(e.length>0){const t=document.createDocumentFragment();for(let n=0;n<e.length;n++)t.appendChild(e[n]);i.replaceWith(t)}}}}Y(t,e,n){const i=`${t}::${e}`;let s=this.I.get(i);if(!s){const n=t=>{const n=t.target&&t.target.closest?t.target.closest(e):null;if(n)for(const e of s.handlers)try{e(t,n)}catch{}};s={eventType:t,selector:e,listener:n,handlers:new Set},this.I.set(i,s),this.m.addEventListener(t,n)}s.handlers.add(n)}tt(t,e,n){const i=`${t}::${e}`,s=this.I.get(i);if(s&&(s.handlers.delete(n),0===s.handlers.size)){try{this.m.removeEventListener(t,s.listener)}catch{}this.I.delete(i)}}}if(!customElements.get(t)){if(h&&"undefined"!=typeof document){const e=`scope-${t}-styles`;if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent=h,document.head.appendChild(t)}}try{customElements.define(t,a)}catch(t){String(t?.message||t)}}return a}const r=()=>({name:"device",extend:t=>{const e=new Map;return t.onDestroy(()=>{for(const[t,n]of e)t.removeEventListener("change",n);e.clear()}),{onMediaQuery:(t,n,i={})=>{if("undefined"==typeof window||"undefined"==typeof matchMedia)return()=>{};const{immediate:s=!0}=i,o=matchMedia(t),r=t=>{n(t.matches,t)};return o.addEventListener("change",r),e.set(o,r),s&&n(o.matches,null),()=>{o.removeEventListener("change",r),e.delete(o)}}}}}),c=(t,e={})=>({name:"morph",extend:(n,i)=>{const{ignoreActiveValue:s=!0,callbacks:o}=e,r=t(),c=i.m,h=i.l?ShadowRoot.prototype:HTMLElement.prototype,f=Object.getOwnPropertyDescriptor(h,"innerHTML"),u=t=>{r.morph(c,t,{morphStyle:"innerHTML",ignoreActiveValue:s,callbacks:o})};let l=!0;return Object.defineProperty(c,"innerHTML",{set(t){l?(f.set.call(this,t),l=!1):u(t)},get(){return f.get.call(this)},configurable:!0}),n.onDestroy(()=>{delete c.innerHTML}),{morph:u}}}),h=()=>({name:"window",extend:t=>{const e=new Set,n=new Set,i=new Set,s=(t,n={})=>{if("undefined"==typeof window)return()=>{};const{immediate:i=!0}=n,s=e=>{t(window.innerWidth,window.innerHeight,e)};return window.addEventListener("resize",s),e.add(s),i&&s(new UIEvent("resize")),()=>{window.removeEventListener("resize",s),e.delete(s)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const t of e)window.removeEventListener("resize",t);e.clear();for(const t of i)t.disconnect();i.clear();for(const t of n)window.removeEventListener("scroll",t);n.clear()}}),{onViewportResize:s,onWindowResize:(t,e={})=>{if("undefined"==typeof window)return()=>{};if("undefined"==typeof ResizeObserver)return s((e,n,i)=>t(e,n,i),e);const{immediate:n=!0}=e,o=document.documentElement,r=new ResizeObserver(e=>{const n=e[0];if(!n)return;const{width:i,height:s}=n.contentRect;t(i,s,n)});if(r.observe(o),i.add(r),n){const e=o.getBoundingClientRect();t(e.width,e.height,new UIEvent("resize"))}return()=>{r.disconnect(),i.delete(r)}},onWindowScroll:(t,e={})=>{if("undefined"==typeof window)return()=>{};const{immediate:i=!0}=e,s=e=>{t(window.scrollX,window.scrollY,e)};return window.addEventListener("scroll",s,{passive:!0}),n.add(s),i&&s(new Event("scroll")),()=>{window.removeEventListener("scroll",s),n.delete(s)}}}}}),f=()=>({name:"inview",extend:(t,e)=>{const n=new Set,i=(t,e,i={})=>{if("undefined"==typeof window||"undefined"==typeof IntersectionObserver)return()=>{};const{immediate:s=!0,...o}=i;let r=!s;const c=new IntersectionObserver(n=>{for(const i of n)i.target===t&&(r?r=!1:e(i.isIntersecting,i))},o);return c.observe(t),n.add(c),()=>{c.unobserve(t),c.disconnect(),n.delete(c)}};return t.onDestroy(()=>{for(const t of n)t.disconnect();n.clear()}),{onInView:(t,n)=>i(e,t,n),observeInView:(t,e,n)=>i(t,e,n)}}}),u=t=>({name:"lenis",extend:e=>{const n=new Set;return e.onDestroy(()=>{for(const{lenis:t,handler:e}of n)"function"==typeof t.off&&t.off("scroll",e);n.clear()}),{onLenisScroll:e=>{const i=t();if(!i)return()=>{};const s=t=>{e(t)};i.on("scroll",s);const o={lenis:i,handler:s};return n.add(o),()=>{n.has(o)&&(n.delete(o),"function"==typeof i.off&&i.off("scroll",s))}}}}}),l=()=>({name:"timer",extend:t=>{const e=new Set,n=new Set,i=new Set,s={setTimeout:(t,n,...i)=>{let s;return s=setTimeout((...n)=>{e.delete(s),t(...n)},n,...i),e.add(s),s},setInterval:(t,e,...i)=>{const s=setInterval(t,e,...i);return n.add(s),s},raf:(t,e)=>{let n=0,s=!0,o=0;const r="number"==typeof e&&e>0?1e3/e:0,c=e=>{if(i.delete(n),s){if(r){if(e-o>=r){const n=o?e-o:r;o=e,t(e,n)}}else{const n=o?e-o:0;o=e,t(e,n)}n=requestAnimationFrame(c),i.add(n)}};return n=requestAnimationFrame(c),i.add(n),()=>{s&&(s=!1,i.delete(n),cancelAnimationFrame(n))}}};return t.onDestroy(()=>{for(const t of e)clearTimeout(t);e.clear();for(const t of n)clearInterval(t);n.clear();for(const t of i)cancelAnimationFrame(t);i.clear()}),{timer:s}}}),a=()=>({name:"mouse",extend:t=>{const e=new Map,n=(t,n)=>{if("undefined"==typeof window)return()=>{};const i=t=>{n(t.clientX,t.clientY,t)};window.addEventListener(t,i);let s=e.get(t);return s||(s=new Set,e.set(t,s)),s.add(i),()=>{window.removeEventListener(t,i),s?.delete(i)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const[t,n]of e){for(const e of n)window.removeEventListener(t,e);n.clear()}e.clear()}}),{onMouseMove:t=>n("mousemove",t),onMouseDown:t=>n("mousedown",t),onMouseUp:t=>n("mouseup",t),onMouseWheel:t=>(t=>{if("undefined"==typeof window)return()=>{};const n=e=>{t(e.clientX,e.clientY,e.deltaY,e)};window.addEventListener("wheel",n);let i=e.get("wheel");return i||(i=new Set,e.set("wheel",i)),i.add(n),()=>{window.removeEventListener("wheel",n),i?.delete(n)}})(t)}}}),d=t=>Array.isArray(t),m=t=>null!=t&&"object"==typeof t&&!Array.isArray(t),p=t=>d(t)?t.slice():m(t)?{...t}:t,w=(t,e)=>{if(d(t)&&d(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(!Object.is(t[n],e[n]))return!1;return!0}if(m(t)&&m(e)){const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(const i of n){if(!(i in e))return!1;if(!Object.is(t[i],e[i]))return!1}return!0}return!(d(t)||d(e)||m(t)||m(e))&&Object.is(t,e)},y=(t,e)=>Array.from({length:e},()=>t),g=(t,e)=>e.reduce((e,n)=>(e[n]=t,e),{}),v=({from:t,to:e,velocity:n,label:i})=>{const s={value:t,target:e,velocity:n,arrayLength:null,objectKeys:null,normalizeInput:t=>t},o=t=>{if(null==s.arrayLength){if(null!=s.objectKeys)throw new Error(`${i} value shape mismatch (array vs object).`);s.arrayLength=t,d(s.value)||(s.value=y(s.value,t)),d(s.target)||(s.target=y(s.target,t)),void 0===s.velocity||d(s.velocity)||(s.velocity=y(s.velocity,t))}},r=t=>{if(null==s.objectKeys){if(null!=s.arrayLength)throw new Error(`${i} value shape mismatch (object vs array).`);s.objectKeys=t,m(s.value)||(s.value=g(s.value,t)),m(s.target)||(s.target=g(s.target,t)),void 0===s.velocity||m(s.velocity)||(s.velocity=g(s.velocity,t))}},c=t=>{if(d(t)){if(null!=s.objectKeys)throw new Error(`${i} value shape mismatch (array vs object).`);if(null==s.arrayLength&&o(t.length),t.length!==s.arrayLength)throw new Error(`${i} value length mismatch (expected ${s.arrayLength}, got ${t.length}).`);return t.slice()}if(m(t)){if(null!=s.arrayLength)throw new Error(`${i} value shape mismatch (object vs array).`);const e=Object.keys(t);if(null==s.objectKeys&&r(e),s.objectKeys&&e.length!==s.objectKeys.length)throw new Error(`${i} value keys mismatch (expected ${s.objectKeys.length}, got ${e.length}).`);if(s.objectKeys)for(const e of s.objectKeys)if(!(e in t))throw new Error(`${i} value keys mismatch (missing key "${e}").`);return{...t}}return null!=s.arrayLength?y(t,s.arrayLength):null!=s.objectKeys?g(t,s.objectKeys):t};s.normalizeInput=c;const h=d(t)||d(e)||void 0!==n&&d(n),f=m(t)||m(e)||void 0!==n&&m(n);if(h&&f)throw new Error(`${i} value shape mismatch (array vs object).`);if(h){const i=d(t)?t.length:d(e)?e.length:n.length;o(i),s.value=c(t),s.target=c(e),void 0!==s.velocity&&(s.velocity=c(s.velocity))}else if(f){const i=m(t)?Object.keys(t):m(e)?Object.keys(e):Object.keys(n);r(i),s.value=c(t),s.target=c(e),void 0!==s.velocity&&(s.velocity=c(s.velocity))}return s};let b={x:-1,y:-1};const S={stiffness:300,damping:30,mass:1},M=()=>({name:"pointer",extend:e=>{const{onMouseMove:n}=a().extend(e,e.host),{timer:i}=l().extend(e,e.host);b.x=window.innerWidth/2,b.y=window.innerHeight/2;const s={x:t({from:b.x,to:b.x,...S}),y:t({from:b.y,to:b.y,...S})};return n((t,e)=>{s.x.setTarget(t),s.y.setTarget(e)}),{onPointerMove:t=>{let e=b.x,n=b.y;i.raf(i=>{const o=s.x.next(i),r=s.y.next(i);var c,h;e===o&&n===r||(t({x:o,y:r,v:(c={x:o,y:r},h={x:e,y:n},{x:c.x-h.x,y:c.y-h.y,magnitude:Math.sqrt((c.x-h.x)*(c.x-h.x)+(c.y-h.y)*(c.y-h.y))}).magnitude}),e=o,n=r)})},onMouseMove:n}}}),j=()=>({name:"lerp",extend:t=>{const{timer:e}=l().extend(t,t.host),n=new Set;return t.onDestroy(()=>{for(const t of n)t();n.clear()}),{createLerp:t=>function({from:t=0,to:e=1,lerp:n=.1,tolerance:i=.001,delay:s=0,resumeOnTarget:o=!0}={}){function r(){return p(u)}function c(t){if(y)return r();if(g>0){const e=Math.min(t,g);if(g-=e,(t-=e)<=0)return r()}const e=(t=>t<0?0:t>1?1:t)(n);if(0===e)return r();if(1===e)return u=p(l),h.value=u,y=!0,r();const s=t>0?1-Math.pow(1-e,60*t):0;if(d(u)&&d(l)){let t=!0;for(let e=0;e<u.length;e+=1)u[e]+=(l[e]-u[e])*s,Math.abs(l[e]-u[e])>=i&&(t=!1);if(t){for(let t=0;t<u.length;t+=1)u[t]=l[t];y=!0}return h.value=u,p(u)}if(m(u)&&m(l)){const t=h.objectKeys??Object.keys(u);let e=!0;for(const n of t)u[n]+=(l[n]-u[n])*s,Math.abs(l[n]-u[n])>=i&&(e=!1);if(e){for(const e of t)u[e]=l[e];y=!0}return h.value=u,p(u)}const o=l;return u+=(o-u)*s,h.value=u,Math.abs(o-u)<i&&(u=o,h.value=u,y=!0),u}const h=v({from:t,to:e,label:"Lerp"}),f=h.normalizeInput;let u=h.value,l=h.target,a=null,y=!1,g=s;const b=new Set;return{setTarget:function(t){const e=f(t),n=!w(e,l);if(l=e,h.target=e,u=h.value,o&&y&&n){y=!1,a=null,g=s;for(const t of b)t(l)}},getTarget:function(){return p(l)},setValue:function(t,e={}){const{resetTime:n=!0,setTarget:i=!1,markDone:o=!1}=e;u=f(t),h.value=u,i&&(l=p(u),h.target=l);const r=y||!w(u,l);if(n&&(a=null),o&&(y=!0),r&&!o){y=!1,a=null,g=s;for(const t of b)t(l)}},getValue:r,isDone:function(){return y},onResume:function(t){return b.add(t),()=>{b.delete(t)}},step:c,next:function(t=performance.now()){if(null==a)return a=t,r();const e=(t-a)/1e3;a=t;const n=1/30;let i=e,s=r();for(;i>0&&!y;){const t=Math.min(i,n);s=c(t),i-=t}return s}}}(t),runLerp:(t,i,s={})=>{const{fps:o,immediate:r=!0,stopWhenDone:c=!0}=s;let h=!1,f=null;r&&i(t.getValue(),t);const u=()=>{f||(f=e.raf(e=>{if(h)return;const n=t.next(e);i(n,t),c&&t.isDone()&&l()},o))},l=()=>{f&&(f(),f=null)};u();const a=t.onResume(()=>{!h&&c&&(r&&i(t.getValue(),t),u())}),d=()=>{h||(h=!0,a(),l(),n.delete(d))};return n.add(d),d}}}}),O=()=>({name:"spring",extend:e=>{const{timer:n}=l().extend(e,e.host),i=new Set;return e.onDestroy(()=>{for(const t of i)t();i.clear()}),{createSpring:e=>t(e),runSpring:(t,e,s={})=>{const{fps:o,immediate:r=!0,stopWhenDone:c=!0}=s;let h=!1,f=null;r&&e(t.getValue(),t);const u=()=>{f||(f=n.raf(n=>{if(h)return;const i=t.next(n);e(i,t),c&&t.isDone()&&l()},o))},l=()=>{f&&(f(),f=null)};u();const a=t.onResume(()=>{!h&&c&&(r&&e(t.getValue(),t),u())}),d=()=>{h||(h=!0,a(),l(),i.delete(d))};return i.add(d),d}}}}),$=(t={})=>({name:"localstorage",extend:n=>{const{prefix:i="",json:s=!0}=t,o="undefined"==typeof window?null:window.localStorage;return{storage:{get:t=>{if(o)try{const n=o.getItem(e(i,t));if(null===n)return;return s?JSON.parse(n):n}catch{return}},set:(t,n)=>{if(o)try{const r=s?JSON.stringify(n):String(n);o.setItem(e(i,t),r)}catch{}},remove:t=>{o&&o.removeItem(e(i,t))},clear:()=>{if(!o)return;if(!i)return;const t=[];for(let e=0;e<o.length;e++){const n=o.key(e);null!=n&&n.startsWith(i+":")&&t.push(n)}for(const e of t)o.removeItem(e)}}}}}),x="0.0.8-beta.23",_=()=>{console.info("The website is using @petit-kit/scoped v"+x,"\nhttps://github.com/petit-kit/scoped")},A={"&":"&","<":"<",">":">",'"':""","'":"'"},T=t=>null==t||""===t?"":String(t).replace(/[&<>"']/g,t=>A[t]),E="bind:",k=new Set(["checked","disabled","readonly","required","selected","autofocus","multiple","hidden"]),z=/bind:([a-zA-Z_$][\w$]*)="([^"]*)"/g;export{x as SCOPE_VERSION,o as define,r as devicePlugin,_ as happy,f as inViewPlugin,u as lenisPlugin,j as lerpPlugin,$ as localStoragePlugin,c as morphPlugin,a as mousePlugin,M as pointerPlugin,O as springPlugin,l as timerPlugin,h as windowPlugin};
|
|
1
|
+
function t({from:t=0,to:e=1,mass:n=1,stiffness:i=120,damping:s=14,velocity:o=0,delay:r=0,tolerance:c=.001,resumeOnTarget:h=!0}={}){function f(){return p(b)}function u(t){if(O)return f();if($>0){const e=Math.min(t,$);if($-=e,(t-=e)<=0)return f()}if(d(b)&&d(M)&&d(S)){let e=!0;for(let o=0;o<b.length;o+=1){S[o]+=(-i*(b[o]-M[o])-s*S[o])/n*t,b[o]+=S[o]*t;const r=b[o]-M[o];(Math.abs(S[o])>=c||Math.abs(r)>=c)&&(e=!1)}if(e){for(let t=0;t<b.length;t+=1)b[t]=M[t],S[t]=0;O=!0}return l.value=b,l.velocity=S,p(b)}if(m(b)&&m(M)&&m(S)){const e=l.objectKeys??Object.keys(b);let o=!0;for(const r of e){S[r]+=(-i*(b[r]-M[r])-s*S[r])/n*t,b[r]+=S[r]*t;const e=b[r]-M[r];(Math.abs(S[r])>=c||Math.abs(e)>=c)&&(o=!1)}if(o){for(const t of e)b[t]=M[t],S[t]=0;O=!0}return l.value=b,l.velocity=S,p(b)}const e=M;let o=S;o+=(-i*(b-e)-s*o)/n*t,b+=o*t,S=o,l.value=b,l.velocity=S;const r=b-e;return Math.abs(o)<c&&Math.abs(r)<c&&(b=e,S=0,l.value=b,l.velocity=S,O=!0),b}const l=v({from:t,to:e,velocity:o,label:"Spring"}),a=l.normalizeInput;let b=l.value,S=l.velocity??o,M=l.target,j=null,O=!1,$=r;const x=new Set;return{setTarget:function(t){const e=a(t),n=!w(e,M);if(M=e,l.target=e,b=l.value,h&&O&&n){O=!1,j=null,$=r;for(const t of x)t(M)}},getTarget:function(){return p(M)},setValue:function(t,e={}){const{resetVelocity:n=!0,resetTime:i=!0,setTarget:s=!1,markDone:o=!1}=e;b=a(t),l.value=b,s&&(M=p(b),l.target=M);const c=O||!w(b,M);if(n&&(S=null!=l.arrayLength?y(0,l.arrayLength):null!=l.objectKeys?g(0,l.objectKeys):0,l.velocity=S),i&&(j=null),o&&(O=!0),c&&!o){O=!1,j=null,$=r;for(const t of x)t(M)}},getValue:f,isDone:function(){return O},onResume:function(t){return x.add(t),()=>{x.delete(t)}},step:u,next:function(t=performance.now()){if(null==j)return j=t,f();const e=(t-j)/1e3;j=t;const n=1/30;let i=e,s=f();for(;i>0&&!O;){const t=Math.min(i,n);s=u(t),i-=t}return s}}}function e(t,e){return t?`${t}:${e}`:e}function n(t,e){if(!e||"object"!=typeof e||null==e.type)return null!=t?t:e;const{type:n,default:i}=e;if(null==t)return i;try{switch(n){case String:return String(t);case Number:{const e=Number(t);return Number.isNaN(e)?i:e}case Boolean:return""===t||"true"===t||"false"!==t&&"0"!==t&&null!=t;case Object:case Array:try{return"string"==typeof t?JSON.parse(t):t}catch{return n===Array?Array.isArray(i)?i:[]:i}default:return t}}catch{return i}}function i(t){if(!t)return;const e=t.default;return"function"==typeof e?e():e}function s(t,e,n,i){if(!i||"object"!=typeof i||!i.reflect)return;let s=null;const o=i.type;if(o!==Boolean){if(o===Object||o===Array)try{s=null==n?null:JSON.stringify(n)}catch{s=null}else s=null==n?null:String(n);null==s?t.removeAttribute(e):t.setAttribute(e,s)}else n?t.setAttribute(e,""):t.removeAttribute(e)}function o(t,e={},o){const{props:r={},shadow:c=!1,styles:h,plugins:f}=e,u=f??[],l=()=>{};class a extends HTMLElement{constructor(){super(),this.version=x,this.t={};for(const t of Object.keys(r)){const e=r[t];this.t[t]=e&&"object"==typeof e&&("type"in e||"default"in e)?e:{type:void 0,default:e,reflect:!1}}this.props={},this.state={},this.actions={},this.refs={},this.emit=this.emit.bind(this),this.listen=this.listen.bind(this),this.setState=this.setState.bind(this),this.updateState=this.updateState.bind(this),this.setProps=this.setProps.bind(this),this.scheduleUpdate=this.scheduleUpdate.bind(this),this.update=this.update.bind(this),this.forceRender=this.forceRender.bind(this),this.destroy=this.destroy.bind(this),this.$=this.$.bind(this),this.i=null,this.o=null,this.h=!1,this.u=!1,this.l=c,this.m=c?this.attachShadow({mode:"open"}):this,this.p=null,this.S=[],this.M=[],this.j=[],this.O=[],this._=[],this.A=[],this.T=[],this.k=[],this.L=null,this.C="mount",this.F=void 0,this.I=new Map,this.R=!1,this.V=!1,this.q={},this.D=t,this.H=!1,this.N=new Set,this.U=!1,this.B=new Map,this.W=0,this.J=!1}P(t){const e=this.l?this.m.host:this;let n=t.parentElement;for(;n;){if(n===e)return!1;if(n.tagName.includes("-"))return!0;n=n.parentElement}return!1}static get observedAttributes(){return Object.keys(r)}attributeChangedCallback(t,e,i){if(e===i)return;const s=this.q[t],o=n(i,this.t[t]);if(this.props[t]=o,this.R&&s!==o)for(const e of this.k)try{e(t,s,o)}catch(t){l(String(t?.message||t))}this.q[t]=o,this.N.has(t)?this.N.delete(t):this.i&&this.isConnected?this.U?this.H=!0:(this.C="props",this.F=[t],this.update(!0)):this.H=!0}connectedCallback(){for(const t in this.t){if(!this.t.hasOwnProperty(t))continue;const e=n(this.getAttribute(t),this.t[t]);this.props[t]=e,this.q[t]=e}c||this.p||(this.p=this.K());let t=null;try{if(o){const e={props:this.props,state:this.state,actions:this.actions,refs:this.refs,emit:this.emit,listen:this.listen,updateState:this.updateState.bind(this),$:this.$,host:this,onMount:t=>this.j.push(t),onDestroy:t=>this.O.push(t),onUpdate:t=>this._.push(t),onBeforeUpdate:t=>this.A.push(t),onFirstUpdate:t=>this.T.push(t),onPropsChanged:t=>this.k.push(t),shouldRender:t=>{this.L=t},link:(t,e)=>{const n=e||t;this.state[n]=this.props[t],this.k.push((e,i,s)=>{e===t&&(Object.is(this.state[n],s)||(this.state[n]=s))}),this.S.push({fn:()=>{const e=this.state[n];if(Object.is(this.props[t],e))return;this.props[t]=e,this.q[t]=e;const i=this.t[t],o=i?{...i,reflect:!0}:i,r=this.getAttribute(t);this.N.add(t),s(this,t,e,o),r===this.getAttribute(t)&&this.N.delete(t)},deps:()=>[this.state[n]]})},computed:(t,e)=>{let n;if(void 0!==e)try{const t="function"==typeof e?e():e;Array.isArray(t)&&(n=t)}catch(t){String(t?.message||t)}const i={getter:t,deps:e,value:void 0!==e?t(n):t()};this.M.push(i);const s=()=>i.value;return s.Z=i,this.G(s),s},effect:(t,e)=>{const n={fn:t,deps:e};return this.S.push(n),()=>this.X(n)},delegate:(t,e,n)=>(this.Y(t,e,n),()=>this.tt(t,e,n)),escapeHtml:T};for(const t of u)if(t)try{const n=t.extend(e,this);n&&"object"==typeof n&&Object.assign(e,n)}catch(t){l(String(t?.message||t))}t=o(e)}}catch(t){throw String(t?.message||t),t}this.i="function"!=typeof t?()=>"":t,this.U=!0,this.C="mount",this.F=void 0,this.update(!0),this.U=!1,this.H&&(this.H=!1,this.C="props",this.F=void 0,this.update(!0))}disconnectedCallback(){this.destroy()}remove(){super.remove()}$(t){const e=this.m.querySelectorAll(t);return 0===e.length?null:1===e.length?e[0]:Array.from(e)}destroy(){for(const t of this.O)try{t()}catch(t){l(String(t?.message||t))}for(const t of this.S)if(t.cleanup){try{t.cleanup()}catch(t){l(String(t?.message||t))}t.cleanup=void 0}for(const[,t]of this.I)try{this.m.removeEventListener(t.eventType,t.listener)}catch{}this.I.clear(),this.R=!1}emit(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}listen(t,e,n,i){const s=n;t.addEventListener(e,s,i);const o=()=>{try{t.removeEventListener(e,s,i)}catch{}};return this.O.push(o),o}setState(t){const e=[],n=t,i=this.state;for(const t in n){if(!Object.prototype.hasOwnProperty.call(n,t))continue;const s=n[t];Object.is(i[t],s)||(i[t]=s,e.push(t))}if(0!==e.length)if(this.U||!this.R)this.C="state",this.F=e,this.update(!0);else{if(!this.i||!this.isConnected)return;if(this.h)return;this.h=!0;const t=[...e];requestAnimationFrame(()=>{this.h=!1,this.i&&this.isConnected&&(this.C="state",this.F=t,this.update(!0))})}}updateState(t){Object.assign(this.state,t),this.i&&this.isConnected&&this.et()}setProps(t){const e=Object.keys(t);if(0===e.length)return;const n=[],i={};for(const o of e){const e=t[o],r=this.q[o];this.props[o]=e,this.R&&r!==e&&(n.push(o),i[o]=r);const c=this.t[o];c&&c.reflect&&s(this,o,e,c),this.R&&r===e||(this.q[o]=e)}if(this.R&&n.length>0)for(const e of n){const n=i[e],s=t[e];for(const t of this.k)try{t(e,n,s)}catch(t){l(String(t?.message||t))}}this.i&&this.isConnected?(this.C="props",this.F=n,this.update(!0)):this.H=!0}scheduleUpdate(){this.i&&this.isConnected&&this.et()}et(){this.u||this.h||(this.u=!0,("function"==typeof queueMicrotask?queueMicrotask:t=>Promise.resolve().then(t))(()=>{this.u=!1,this.i&&this.isConnected&&(this.h||this.update(!1))}))}update(t){if(this.i){if(t&&this.R)for(const t of this.A)try{t()}catch(t){l(String(t?.message||t))}if(t)if(null===this.L||this.L({reason:this.C,changedKeys:this.F})){this.nt();let t="";try{t=this.i()}catch(e){String(e?.message||e),t=""}"string"!=typeof t&&(t=null==t?"":String(t)),t=((t,e,n)=>{const i=Object.prototype.hasOwnProperty;return t.replace(z,(t,s,o)=>{if("text"===s||"html"===s)return t;const r=o.trim();if(!r)return t;const c=i.call(e,r),h=i.call(n,r);if(!c&&!h)return t;const f=c?e[r]:n[r];return k.has(s)?f?`${s}="" ${t}`:t:null==f?t:`${s}="${T(String(f))}" ${t}`})})(t,this.state,this.props),this.l||(t=t.replace(/<slot(?![^>]*data-scope-owner)(\s|>)/g,`<slot data-scope-owner="${this.D}"$1`)),this.J=!1;const e=null!==this.o&&Object.is(this.o,t);let n=!1;e&&this.R||(this.m.innerHTML=t,this.o=t,n=!0),this.U?("function"==typeof requestAnimationFrame?requestAnimationFrame:t=>setTimeout(t,0))(()=>{if(this.i&&this.isConnected){if(n&&!c&&this.projectSlots(),n&&this.it(),!this.R){this.R=!0;for(const t of this.j)try{t()}catch(t){l(String(t?.message||t))}for(const t in this.t){if(!this.t.hasOwnProperty(t))continue;const e=this.props[t],n=i(this.t[t]);if(e!==n)for(const i of this.k)try{i(t,n,e)}catch(t){l(String(t?.message||t))}}}this.st(),this.ot()}}):(n&&!c&&this.projectSlots(),n&&this.it(),this.st(),this.ot())}else this.st(),this.R&&this.ot();else this.J&&this.nt(),this.st(),this.R&&this.ot()}}forceRender(){this.o=null,this.i&&this.isConnected?this.U?this.H=!0:(this.C="force",this.F=void 0,this.update(!0)):this.H=!0}ot(){if(!this.V){this.V=!0;for(const t of this.T)try{t()}catch(t){l(String(t?.message||t))}}for(const t of this._)try{t()}catch(t){l(String(t?.message||t))}this.rt()}rt(){const t=(this.l?this.m:this).querySelectorAll("*"),e=Object.prototype.hasOwnProperty,n=this.state,i=this.props;for(let s=0;s<t.length;s++){const o=t[s];if(this.P(o))continue;if(0===o.attributes.length)continue;const r=o.attributes;for(let t=r.length-1;t>=0;t--){const s=r[t];if(!s.name.startsWith(E))continue;const c=s.name.slice(5),h=s.value,f=h?h.trim():"";let u,l=!1;if(f){const t=this.B.get(f);if(t){t.Z&&(this.J=!0);try{u=t()}catch{}l=!0}}if(!l){const t=f||c,s=e.call(n,t),o=!s&&e.call(i,t);s?u=n[t]:o&&(u=i[t])}if("text"===c){const t=null==u?"":String(u);o.textContent!==t&&(o.textContent=t)}else if("html"===c){const t=null==u?"":String(u);o.innerHTML!==t&&(o.innerHTML=t)}else if(c in o){if(!Object.is(o[c],u))try{o[c]=u}catch{}if("value"===c)try{null==u?o.removeAttribute("value"):o.setAttribute("value",String(u))}catch{}}else if(null!=u)try{o.setAttribute(c,String(u))}catch{}const a=`__scopeBind_${c}`,d=o[a];if(d){const t=d.ct;t&&o.removeEventListener(t,d),delete o[a]}}}}ht(t,e){if(!t||!e||t.length!==e.length)return!0;for(let n=0;n<e.length;n++)if(!Object.is(t[n],e[n]))return!0;return!1}nt(){for(const t of this.M){let e,n=!0;if(void 0!==t.deps)try{const i="function"==typeof t.deps?t.deps():t.deps;Array.isArray(i)&&(e=i,n=this.ht(t.prevDeps,e))}catch(t){l(String(t?.message||t)),n=!0,e=void 0}if(n){try{t.value=void 0!==t.deps?t.getter(e):t.getter()}catch(t){l(String(t?.message||t))}e&&(t.prevDeps=e.slice())}}}st(){for(const t of this.S){let e,n=!0;if(void 0!==t.deps)try{const i="function"==typeof t.deps?t.deps():t.deps;Array.isArray(i)&&(e=i,n=this.ht(t.prevDeps,e))}catch(t){l(String(t?.message||t)),n=!0,e=void 0}if(n){if(t.cleanup){try{t.cleanup()}catch{}t.cleanup=void 0}try{const n=void 0!==t.deps?t.fn(e):t.fn();"function"==typeof n&&(t.cleanup=n)}catch{}e&&(t.prevDeps=e.slice())}}}X(t){const e=this.S.indexOf(t);if(-1!==e){if(t.cleanup)try{t.cleanup()}catch{}this.S.splice(e,1)}}G(t){const e=t.ft;if(e&&"string"==typeof e)return this.B.set(e,t),e;const n=`__scope_bind_${++this.W}__`;this.B.set(n,t);try{t.ft=n,t.toString=()=>n}catch{}return n}it(){const t=(this.l?this.m:this).querySelectorAll("*"),e=this.refs;for(const t in e)e.hasOwnProperty(t)&&delete e[t];for(let n=0;n<t.length;n++){const i=t[n];if(this.P(i))continue;const s=i.getAttribute("ref");if(s&&(e[s]?Array.isArray(e[s])?e[s].push(i):e[s]=[e[s],i]:e[s]=i),i.attributes.length>0){const t=i.attributes;for(let e=t.length-1;e>=0;e--){const n=t[e];if(!n.name.startsWith("on:"))continue;const s=n.name.slice(3),o=n.value,r=`__tinyHandler_${s}`,c=i[r];c&&i.removeEventListener(s,c),i.removeAttribute(n.name);const h=this.actions[o];if(h&&"function"==typeof h){const t=t=>{h.call(this.actions,t)};i[r]=t,i.addEventListener(s,t)}}}}}K(){const t=new Map,e=this.childNodes,n=[];for(let t=0;t<e.length;t++)n.push(e[t]);for(let e=0;e<n.length;e++){const i=n[e];let s="";1===i.nodeType&&i.getAttribute&&(s=i.getAttribute("slot")||""),t.has(s)||t.set(s,[]),t.get(s).push(i)}for(let t=0;t<n.length;t++){const e=n[t];e.parentNode&&e.parentNode.removeChild(e)}return t}projectSlots(){const t=this.p||new Map,e=(this.l?this.m:this).querySelectorAll(`slot[data-scope-owner="${this.D}"]`);if(0!==e.length)for(let n=0;n<e.length;n++){const i=e[n],s=i.getAttribute("name")||"",o=t.get(s)||[];if(o.length){const t=document.createDocumentFragment();for(let e=0;e<o.length;e++){const n=o[e];let i;if(1===n.nodeType&&n.tagName.includes("-")&&n.p instanceof Map){const t=n,e=document.createElement(t.tagName.toLowerCase());for(let n=0;n<t.attributes.length;n++){const i=t.attributes[n];e.setAttribute(i.name,i.value)}for(const n of t.p.values())for(let t=0;t<n.length;t++)e.appendChild(n[t].cloneNode(!0));i=e}else i=n.cloneNode(!0);t.appendChild(i)}i.replaceWith(t)}else{const t=i.childNodes,e=[];for(let n=0;n<t.length;n++)e.push(t[n]);if(e.length>0){const t=document.createDocumentFragment();for(let n=0;n<e.length;n++)t.appendChild(e[n]);i.replaceWith(t)}}}}Y(t,e,n){const i=`${t}::${e}`;let s=this.I.get(i);if(!s){const n=t=>{const n=t.target&&t.target.closest?t.target.closest(e):null;if(n)for(const e of s.handlers)try{e(t,n)}catch{}};s={eventType:t,selector:e,listener:n,handlers:new Set},this.I.set(i,s),this.m.addEventListener(t,n)}s.handlers.add(n)}tt(t,e,n){const i=`${t}::${e}`,s=this.I.get(i);if(s&&(s.handlers.delete(n),0===s.handlers.size)){try{this.m.removeEventListener(t,s.listener)}catch{}this.I.delete(i)}}}if(!customElements.get(t)){if(h&&"undefined"!=typeof document){const e=`scope-${t}-styles`;if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent=h,document.head.appendChild(t)}}try{customElements.define(t,a)}catch(t){String(t?.message||t)}}return a}const r=()=>({name:"device",extend:t=>{const e=new Map;return t.onDestroy(()=>{for(const[t,n]of e)t.removeEventListener("change",n);e.clear()}),{onMediaQuery:(t,n,i={})=>{if("undefined"==typeof window||"undefined"==typeof matchMedia)return()=>{};const{immediate:s=!0}=i,o=matchMedia(t),r=t=>{n(t.matches,t)};return o.addEventListener("change",r),e.set(o,r),s&&n(o.matches,null),()=>{o.removeEventListener("change",r),e.delete(o)}}}}}),c=(t,e={})=>({name:"morph",extend:(n,i)=>{const{ignoreActiveValue:s=!0,callbacks:o}=e,r=t(),c=i.m,h=i.l?ShadowRoot.prototype:HTMLElement.prototype,f=Object.getOwnPropertyDescriptor(h,"innerHTML"),u=t=>{r.morph(c,t,{morphStyle:"innerHTML",ignoreActiveValue:s,callbacks:o})};let l=!0;return Object.defineProperty(c,"innerHTML",{set(t){l?(f.set.call(this,t),l=!1):u(t)},get(){return f.get.call(this)},configurable:!0}),n.onDestroy(()=>{delete c.innerHTML}),{morph:u}}}),h=()=>({name:"window",extend:t=>{const e=new Set,n=new Set,i=new Set,s=(t,n={})=>{if("undefined"==typeof window)return()=>{};const{immediate:i=!0}=n,s=e=>{t(window.innerWidth,window.innerHeight,e)};return window.addEventListener("resize",s),e.add(s),i&&s(new UIEvent("resize")),()=>{window.removeEventListener("resize",s),e.delete(s)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const t of e)window.removeEventListener("resize",t);e.clear();for(const t of i)t.disconnect();i.clear();for(const t of n)window.removeEventListener("scroll",t);n.clear()}}),{onViewportResize:s,onWindowResize:(t,e={})=>{if("undefined"==typeof window)return()=>{};if("undefined"==typeof ResizeObserver)return s((e,n,i)=>t(e,n,i),e);const{immediate:n=!0}=e,o=document.documentElement,r=new ResizeObserver(e=>{const n=e[0];if(!n)return;const{width:i,height:s}=n.contentRect;t(i,s,n)});if(r.observe(o),i.add(r),n){const e=o.getBoundingClientRect();t(e.width,e.height,new UIEvent("resize"))}return()=>{r.disconnect(),i.delete(r)}},onWindowScroll:(t,e={})=>{if("undefined"==typeof window)return()=>{};const{immediate:i=!0}=e,s=e=>{t(window.scrollX,window.scrollY,e)};return window.addEventListener("scroll",s,{passive:!0}),n.add(s),i&&s(new Event("scroll")),()=>{window.removeEventListener("scroll",s),n.delete(s)}}}}}),f=()=>({name:"inview",extend:(t,e)=>{const n=new Set,i=(t,e,i={})=>{if("undefined"==typeof window||"undefined"==typeof IntersectionObserver)return()=>{};const{immediate:s=!0,...o}=i;let r=!s;const c=new IntersectionObserver(n=>{for(const i of n)i.target===t&&(r?r=!1:e(i.isIntersecting,i))},o);return c.observe(t),n.add(c),()=>{c.unobserve(t),c.disconnect(),n.delete(c)}};return t.onDestroy(()=>{for(const t of n)t.disconnect();n.clear()}),{onInView:(t,n)=>i(e,t,n),observeInView:(t,e,n)=>i(t,e,n)}}}),u=t=>({name:"lenis",extend:e=>{const n=new Set;return e.onDestroy(()=>{for(const{lenis:t,handler:e}of n)"function"==typeof t.off&&t.off("scroll",e);n.clear()}),{onLenisScroll:e=>{const i=t();if(!i)return()=>{};const s=t=>{e(t)};i.on("scroll",s);const o={lenis:i,handler:s};return n.add(o),()=>{n.has(o)&&(n.delete(o),"function"==typeof i.off&&i.off("scroll",s))}}}}}),l=()=>({name:"timer",extend:t=>{const e=new Set,n=new Set,i=new Set,s={setTimeout:(t,n,...i)=>{let s;return s=setTimeout((...n)=>{e.delete(s),t(...n)},n,...i),e.add(s),s},setInterval:(t,e,...i)=>{const s=setInterval(t,e,...i);return n.add(s),s},raf:(t,e)=>{let n=0,s=!0,o=0;const r="number"==typeof e&&e>0?1e3/e:0,c=e=>{if(i.delete(n),s){if(r){if(e-o>=r){const n=o?e-o:r;o=e,t(e,n)}}else{const n=o?e-o:0;o=e,t(e,n)}n=requestAnimationFrame(c),i.add(n)}};return n=requestAnimationFrame(c),i.add(n),()=>{s&&(s=!1,i.delete(n),cancelAnimationFrame(n))}}};return t.onDestroy(()=>{for(const t of e)clearTimeout(t);e.clear();for(const t of n)clearInterval(t);n.clear();for(const t of i)cancelAnimationFrame(t);i.clear()}),{timer:s}}}),a=()=>({name:"mouse",extend:t=>{const e=new Map,n=(t,n)=>{if("undefined"==typeof window)return()=>{};const i=t=>{n(t.clientX,t.clientY,t)};window.addEventListener(t,i);let s=e.get(t);return s||(s=new Set,e.set(t,s)),s.add(i),()=>{window.removeEventListener(t,i),s?.delete(i)}};return t.onDestroy(()=>{if("undefined"!=typeof window){for(const[t,n]of e){for(const e of n)window.removeEventListener(t,e);n.clear()}e.clear()}}),{onMouseMove:t=>n("mousemove",t),onMouseDown:t=>n("mousedown",t),onMouseUp:t=>n("mouseup",t),onMouseWheel:t=>(t=>{if("undefined"==typeof window)return()=>{};const n=e=>{t(e.clientX,e.clientY,e.deltaY,e)};window.addEventListener("wheel",n);let i=e.get("wheel");return i||(i=new Set,e.set("wheel",i)),i.add(n),()=>{window.removeEventListener("wheel",n),i?.delete(n)}})(t)}}}),d=t=>Array.isArray(t),m=t=>null!=t&&"object"==typeof t&&!Array.isArray(t),p=t=>d(t)?t.slice():m(t)?{...t}:t,w=(t,e)=>{if(d(t)&&d(e)){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(!Object.is(t[n],e[n]))return!1;return!0}if(m(t)&&m(e)){const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(const i of n){if(!(i in e))return!1;if(!Object.is(t[i],e[i]))return!1}return!0}return!(d(t)||d(e)||m(t)||m(e))&&Object.is(t,e)},y=(t,e)=>Array.from({length:e},()=>t),g=(t,e)=>e.reduce((e,n)=>(e[n]=t,e),{}),v=({from:t,to:e,velocity:n,label:i})=>{const s={value:t,target:e,velocity:n,arrayLength:null,objectKeys:null,normalizeInput:t=>t},o=t=>{if(null==s.arrayLength){if(null!=s.objectKeys)throw new Error(`${i} value shape mismatch (array vs object).`);s.arrayLength=t,d(s.value)||(s.value=y(s.value,t)),d(s.target)||(s.target=y(s.target,t)),void 0===s.velocity||d(s.velocity)||(s.velocity=y(s.velocity,t))}},r=t=>{if(null==s.objectKeys){if(null!=s.arrayLength)throw new Error(`${i} value shape mismatch (object vs array).`);s.objectKeys=t,m(s.value)||(s.value=g(s.value,t)),m(s.target)||(s.target=g(s.target,t)),void 0===s.velocity||m(s.velocity)||(s.velocity=g(s.velocity,t))}},c=t=>{if(d(t)){if(null!=s.objectKeys)throw new Error(`${i} value shape mismatch (array vs object).`);if(null==s.arrayLength&&o(t.length),t.length!==s.arrayLength)throw new Error(`${i} value length mismatch (expected ${s.arrayLength}, got ${t.length}).`);return t.slice()}if(m(t)){if(null!=s.arrayLength)throw new Error(`${i} value shape mismatch (object vs array).`);const e=Object.keys(t);if(null==s.objectKeys&&r(e),s.objectKeys&&e.length!==s.objectKeys.length)throw new Error(`${i} value keys mismatch (expected ${s.objectKeys.length}, got ${e.length}).`);if(s.objectKeys)for(const e of s.objectKeys)if(!(e in t))throw new Error(`${i} value keys mismatch (missing key "${e}").`);return{...t}}return null!=s.arrayLength?y(t,s.arrayLength):null!=s.objectKeys?g(t,s.objectKeys):t};s.normalizeInput=c;const h=d(t)||d(e)||void 0!==n&&d(n),f=m(t)||m(e)||void 0!==n&&m(n);if(h&&f)throw new Error(`${i} value shape mismatch (array vs object).`);if(h){const i=d(t)?t.length:d(e)?e.length:n.length;o(i),s.value=c(t),s.target=c(e),void 0!==s.velocity&&(s.velocity=c(s.velocity))}else if(f){const i=m(t)?Object.keys(t):m(e)?Object.keys(e):Object.keys(n);r(i),s.value=c(t),s.target=c(e),void 0!==s.velocity&&(s.velocity=c(s.velocity))}return s};let b={x:-1,y:-1};const S={stiffness:300,damping:30,mass:1},M=()=>({name:"pointer",extend:e=>{const{onMouseMove:n}=a().extend(e,e.host),{timer:i}=l().extend(e,e.host);b.x=window.innerWidth/2,b.y=window.innerHeight/2;const s={x:t({from:b.x,to:b.x,...S}),y:t({from:b.y,to:b.y,...S})};return n((t,e)=>{s.x.setTarget(t),s.y.setTarget(e)}),{onPointerMove:t=>{let e=b.x,n=b.y;i.raf(i=>{const o=s.x.next(i),r=s.y.next(i);var c,h;e===o&&n===r||(t({x:o,y:r,v:(c={x:o,y:r},h={x:e,y:n},{x:c.x-h.x,y:c.y-h.y,magnitude:Math.sqrt((c.x-h.x)*(c.x-h.x)+(c.y-h.y)*(c.y-h.y))}).magnitude}),e=o,n=r)})},onMouseMove:n}}}),j=()=>({name:"lerp",extend:t=>{const{timer:e}=l().extend(t,t.host),n=new Set;return t.onDestroy(()=>{for(const t of n)t();n.clear()}),{createLerp:t=>function({from:t=0,to:e=1,lerp:n=.1,tolerance:i=.001,delay:s=0,resumeOnTarget:o=!0}={}){function r(){return p(u)}function c(t){if(y)return r();if(g>0){const e=Math.min(t,g);if(g-=e,(t-=e)<=0)return r()}const e=(t=>t<0?0:t>1?1:t)(n);if(0===e)return r();if(1===e)return u=p(l),h.value=u,y=!0,r();const s=t>0?1-Math.pow(1-e,60*t):0;if(d(u)&&d(l)){let t=!0;for(let e=0;e<u.length;e+=1)u[e]+=(l[e]-u[e])*s,Math.abs(l[e]-u[e])>=i&&(t=!1);if(t){for(let t=0;t<u.length;t+=1)u[t]=l[t];y=!0}return h.value=u,p(u)}if(m(u)&&m(l)){const t=h.objectKeys??Object.keys(u);let e=!0;for(const n of t)u[n]+=(l[n]-u[n])*s,Math.abs(l[n]-u[n])>=i&&(e=!1);if(e){for(const e of t)u[e]=l[e];y=!0}return h.value=u,p(u)}const o=l;return u+=(o-u)*s,h.value=u,Math.abs(o-u)<i&&(u=o,h.value=u,y=!0),u}const h=v({from:t,to:e,label:"Lerp"}),f=h.normalizeInput;let u=h.value,l=h.target,a=null,y=!1,g=s;const b=new Set;return{setTarget:function(t){const e=f(t),n=!w(e,l);if(l=e,h.target=e,u=h.value,o&&y&&n){y=!1,a=null,g=s;for(const t of b)t(l)}},getTarget:function(){return p(l)},setValue:function(t,e={}){const{resetTime:n=!0,setTarget:i=!1,markDone:o=!1}=e;u=f(t),h.value=u,i&&(l=p(u),h.target=l);const r=y||!w(u,l);if(n&&(a=null),o&&(y=!0),r&&!o){y=!1,a=null,g=s;for(const t of b)t(l)}},getValue:r,isDone:function(){return y},onResume:function(t){return b.add(t),()=>{b.delete(t)}},step:c,next:function(t=performance.now()){if(null==a)return a=t,r();const e=(t-a)/1e3;a=t;const n=1/30;let i=e,s=r();for(;i>0&&!y;){const t=Math.min(i,n);s=c(t),i-=t}return s}}}(t),runLerp:(t,i,s={})=>{const{fps:o,immediate:r=!0,stopWhenDone:c=!0}=s;let h=!1,f=null;r&&i(t.getValue(),t);const u=()=>{f||(f=e.raf(e=>{if(h)return;const n=t.next(e);i(n,t),c&&t.isDone()&&l()},o))},l=()=>{f&&(f(),f=null)};u();const a=t.onResume(()=>{!h&&c&&(r&&i(t.getValue(),t),u())}),d=()=>{h||(h=!0,a(),l(),n.delete(d))};return n.add(d),d}}}}),O=()=>({name:"spring",extend:e=>{const{timer:n}=l().extend(e,e.host),i=new Set;return e.onDestroy(()=>{for(const t of i)t();i.clear()}),{createSpring:e=>t(e),runSpring:(t,e,s={})=>{const{fps:o,immediate:r=!0,stopWhenDone:c=!0}=s;let h=!1,f=null;r&&e(t.getValue(),t);const u=()=>{f||(f=n.raf(n=>{if(h)return;const i=t.next(n);e(i,t),c&&t.isDone()&&l()},o))},l=()=>{f&&(f(),f=null)};u();const a=t.onResume(()=>{!h&&c&&(r&&e(t.getValue(),t),u())}),d=()=>{h||(h=!0,a(),l(),i.delete(d))};return i.add(d),d}}}}),$=(t={})=>({name:"localstorage",extend:n=>{const{prefix:i="",json:s=!0}=t,o="undefined"==typeof window?null:window.localStorage;return{storage:{get:t=>{if(o)try{const n=o.getItem(e(i,t));if(null===n)return;return s?JSON.parse(n):n}catch{return}},set:(t,n)=>{if(o)try{const r=s?JSON.stringify(n):String(n);o.setItem(e(i,t),r)}catch{}},remove:t=>{o&&o.removeItem(e(i,t))},clear:()=>{if(!o)return;if(!i)return;const t=[];for(let e=0;e<o.length;e++){const n=o.key(e);null!=n&&n.startsWith(i+":")&&t.push(n)}for(const e of t)o.removeItem(e)}}}}}),x="0.0.8-beta.24",_=()=>{console.info("The website is using @petit-kit/scoped v"+x,"\nhttps://github.com/petit-kit/scoped")},A={"&":"&","<":"<",">":">",'"':""","'":"'"},T=t=>null==t||""===t?"":String(t).replace(/[&<>"']/g,t=>A[t]),E="bind:",k=new Set(["checked","disabled","readonly","required","selected","autofocus","multiple","hidden"]),z=/bind:([a-zA-Z_$][\w$]*)="([^"]*)"/g;export{x as SCOPE_VERSION,o as define,r as devicePlugin,_ as happy,f as inViewPlugin,u as lenisPlugin,j as lerpPlugin,$ as localStoragePlugin,c as morphPlugin,a as mousePlugin,M as pointerPlugin,O as springPlugin,l as timerPlugin,h as windowPlugin};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED