claude-web/node_modules/@interactjs/core/scope.prod.js

5 lines
4.1 KiB
JavaScript

/* interact.js 1.10.27 | https://raw.github.com/taye/interact.js/main/LICENSE */
import browser from"../utils/browser.prod.js";import clone from"../utils/clone.prod.js";import domObjects from"../utils/domObjects.prod.js";import extend from"../utils/extend.prod.js";import is from"../utils/is.prod.js";import raf from"../utils/raf.prod.js";import*as win from"../utils/window.prod.js";import{Eventable}from"./Eventable.prod.js";import events from"./events.prod.js";import interactions from"./interactions.prod.js";import{Interactable}from"./Interactable.prod.js";import{InteractableSet}from"./InteractableSet.prod.js";import{InteractEvent}from"./InteractEvent.prod.js";import{createInteractStatic}from"./InteractStatic.prod.js";import{defaults}from"./options.prod.js";import"../utils/arr.prod.js";import"../utils/normalizeListeners.prod.js";import"../utils/domUtils.prod.js";import"../utils/pointerExtend.prod.js";import"../utils/pointerUtils.prod.js";import"./interactablePreventDefault.prod.js";import"./Interaction.prod.js";import"../utils/hypot.prod.js";import"../utils/misc.prod.js";import"../utils/rect.prod.js";import"./PointerInfo.prod.js";import"./interactionFinder.prod.js";import"../utils/isNonNativeEvent.prod.js";import"../utils/getOriginXY.prod.js";import"./BaseEvent.prod.js";class Scope{constructor(){this.id="__interact_scope_"+Math.floor(100*Math.random()),this.isInitialized=!1,this.listenerMaps=[],this.browser=browser,this.defaults=clone(defaults),this.Eventable=Eventable,this.actions={map:{},phases:{start:!0,move:!0,end:!0},methodDict:{},phaselessTypes:{}},this.interactStatic=createInteractStatic(this),this.InteractEvent=InteractEvent,this.Interactable=void 0,this.interactables=new InteractableSet(this),this._win=void 0,this.document=void 0,this.window=void 0,this.documents=[],this._plugins={list:[],map:{}},this.onWindowUnload=t=>this.removeDocument(t.target);const t=this;this.Interactable=class extends Interactable{get _defaults(){return t.defaults}set(i){return super.set(i),t.fire("interactable:set",{options:i,interactable:this}),this}unset(){super.unset();const i=t.interactables.list.indexOf(this);i<0||(t.interactables.list.splice(i,1),t.fire("interactable:unset",{interactable:this}))}}}addListeners(t,i){this.listenerMaps.push({id:i,map:t})}fire(t,i){for(const{map:{[t]:e}}of this.listenerMaps)if(e&&!1===e(i,this,t))return!1}init(t){return this.isInitialized?this:initScope(this,t)}pluginIsInstalled(t){const{id:i}=t;return i?!!this._plugins.map[i]:-1!==this._plugins.list.indexOf(t)}usePlugin(t,i){if(!this.isInitialized)return this;if(this.pluginIsInstalled(t))return this;if(t.id&&(this._plugins.map[t.id]=t),this._plugins.list.push(t),t.install&&t.install(this,i),t.listeners&&t.before){let i=0;const e=this.listenerMaps.length,s=t.before.reduce(((t,i)=>(t[i]=!0,t[pluginIdRoot(i)]=!0,t)),{});for(;i<e;i++){const t=this.listenerMaps[i].id;if(t&&(s[t]||s[pluginIdRoot(t)]))break}this.listenerMaps.splice(i,0,{id:t.id,map:t.listeners})}else t.listeners&&this.listenerMaps.push({id:t.id,map:t.listeners});return this}addDocument(t,i){if(-1!==this.getDocIndex(t))return!1;const e=win.getWindow(t);i=i?extend({},i):{},this.documents.push({doc:t,options:i}),this.events.documents.push(t),t!==this.document&&this.events.add(e,"unload",this.onWindowUnload),this.fire("scope:add-document",{doc:t,window:e,scope:this,options:i})}removeDocument(t){const i=this.getDocIndex(t),e=win.getWindow(t),s=this.documents[i].options;this.events.remove(e,"unload",this.onWindowUnload),this.documents.splice(i,1),this.events.documents.splice(i,1),this.fire("scope:remove-document",{doc:t,window:e,scope:this,options:s})}getDocIndex(t){for(let i=0;i<this.documents.length;i++)if(this.documents[i].doc===t)return i;return-1}getDocOptions(t){const i=this.getDocIndex(t);return-1===i?null:this.documents[i].options}now(){return(this.window.Date||Date).now()}}function initScope(t,i){return t.isInitialized=!0,is.window(i)&&win.init(i),domObjects.init(i),browser.init(i),raf.init(i),t.window=i,t.document=i.document,t.usePlugin(interactions),t.usePlugin(events),t}function pluginIdRoot(t){return t&&t.replace(/\/.*$/,"")}export{Scope,initScope};
//# sourceMappingURL=scope.prod.js.map