jenesius-vue-modal
Advanced tools
Comparing version 1.11.7 to 1.11.8
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".modal-container{position:fixed;left:0;top:0;height:100%;width:100%;display:flex;align-items:center;justify-content:center;background-color:#3e3e3e21;cursor:pointer}.modal-item{cursor:default}.modal-list-enter-active,.modal-list-leave-active,.modal-list-enter-active .modal-item,.modal-list-leave-active .modal-item{transition:all .2s ease}.modal-list-enter-from,.modal-list-leave-to{opacity:0!important}.modal-list-enter-from .modal-item,.modal-list-leave-to .modal-item{transform:translateY(-60px)}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})(); | ||
"use strict";/*! | ||
* jenesius-vue-modal v1.11.7 | ||
* jenesius-vue-modal v1.11.8 | ||
* (c) 2024 Jenesius | ||
* @license MIT | ||
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("vue");var D=function(n,e){return D=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])},D(n,e)};function ne(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");D(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function F(n,e,t,r){function a(o){return o instanceof t?o:new t(function(l){l(o)})}return new(t||(t=Promise))(function(o,l){function f(i){try{s(r.next(i))}catch(u){l(u)}}function c(i){try{s(r.throw(i))}catch(u){l(u)}}function s(i){i.done?o(i.value):a(i.value).then(f,c)}s((r=r.apply(n,e||[])).next())})}function M(n,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,a,o,l;return l={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function f(s){return function(i){return c([s,i])}}function c(s){if(r)throw new TypeError("Generator is already executing.");for(;l&&(l=0,s[0]&&(t=0)),t;)try{if(r=1,a&&(o=s[0]&2?a.return:s[0]?a.throw||((o=a.return)&&o.call(a),0):a.next)&&!(o=o.call(a,s[1])).done)return o;switch(a=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return t.label++,{value:s[1],done:!1};case 5:t.label++,a=s[1],s=[0];continue;case 7:s=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){t.label=s[1];break}if(s[0]===6&&t.label<o[1]){t.label=o[1],o=s;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(s);break}o[2]&&t.ops.pop(),t.trys.pop();continue}s=e.call(n,t)}catch(i){s=[6,i],a=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}var g=function(n){ne(e,n);function e(t,r){r===void 0&&(r=null);var a=n.call(this)||this;return a.isModalError=!0,a.message=t,a.details=r,a}return e.Undefined=function(t){return new e("Modal with id: ".concat(t," not founded. The modal window may have been closed earlier."))},e.UndefinedGuardName=function(t){return new e("Guard's name ".concat(t," is not declaration."))},e.NextReject=function(t){return new e("Guard returned false. Modal navigation was stopped. Modal id ".concat(t))},e.GuardDeclarationType=function(t){return new e("Guard's type should be a function. Provided:",t)},e.RejectedByBeforeEach=function(){return new e("The opening of the modal was stopped in beforeEach")},e.ConfigurationType=function(t){return new e("Configuration type must be an Object. Provided",t)},e.ConfigurationUndefinedParam=function(t,r){return new e("In configuration founded unknown parameter: ".concat(t,". Available are ").concat(r.join(", ")," "))},e.QueueNoEmpty=function(){return new e("Modal's queue is not empty. Probably some modal reject closing by onClose hook.")},e.EmptyModalQueue=function(){return new e("Modal queue is empty.")},e.NotInitialized=function(t){return new e("Modal Container not found. Put container from jenesius-vue-modal in App's template. Namespace: ".concat(t,". Check documentation for more information https://modal.jenesius.com/docs.html/installation#getting-started."))},e.ModalComponentNotProvided=function(){return new e("The first parameter(VueComponent) was not specified.")},e.DuplicatedRouterIntegration=function(){return new e("useModalRouter.init should escaped only once.")},e.ModalRouterIntegrationNotInitialized=function(){return new e("The integration was not initialized. Please, use useModalRouter.init(router). For more information: https://modal.jenesius.com/docs.html/integration-vue-router#installation")},e.ModalEventNameMustBeString=function(t){return new e("Event name must be a string. Provided: ".concat(t))},e.ModalNotFoundByID=function(t){return new e("Modal with ID ".concat(t," was not found."))},e.ModalNotExistsInStore=function(t){return new e("Provided name(".concat(t,") don't exist in the store. Has the given name been added to the store?"))},e}(Error),P=function(){function n(){this.state=new Map,n.instance=this}return n.prototype.getByName=function(e){return e===void 0&&(e=n.DEFAULT_NAMESPACE),this.state.has(e)||this.state.set(e,{queue:h.reactive([]),initialized:!1}),this.state.get(e)},n.prototype.forceClean=function(){this.state.forEach(function(e){e.queue.splice(0,e.queue.length)})},n.DEFAULT_NAMESPACE="default",n}(),X=function(){var n=new P,e={scrollLock:!0,animation:"modal-list",backgroundClose:!0,escClose:!0,store:{},skipInitCheck:!1,draggable:!1,appear:!0,beforeEach:function(){}},t=n.getByName().queue;return h.watch(function(){return t},function(){e.scrollLock&&(t.length?document.body.style.overflowY="hidden":document.body.style.overflowY="auto")},{deep:!0}),{namespaceStore:n,configuration:e}}();function b(n){return X.namespaceStore.getByName(n)}var y=X.configuration;function W(n){var e={backgroundClose:y.backgroundClose,isRoute:!1,namespace:P.DEFAULT_NAMESPACE,draggable:y.draggable};return n.backgroundClose!==void 0&&(e.backgroundClose=n.backgroundClose),n.isRoute&&(e.isRoute=n.isRoute),n.namespace&&(e.namespace=n.namespace),n.draggable!==void 0&&(e.draggable=n.draggable),e}function G(n){n===void 0&&(n={});var e={background:!1,esc:!1};return Object.assign(e,n)}function H(n){return n||(n={}),n}function T(n,e){e===void 0&&(e={});var t=I.STORE.get(n);if(!t)return Promise.reject(g.ModalNotFoundByID(n));var r=b(t.namespace),a=r.queue.findIndex(function(l){return l.id===n});if(a===-1)return Promise.reject(g.Undefined(n));var o=_.get(n,"close").map(function(l){return oe(l,n,G(e))});return Z(o).then(function(){r.queue.splice(a,1)}).then(function(){_.get(n,"destroy").forEach(function(l){return l(G(e))})}).then(function(){_.delete(n)})}var I=function(){function n(e,t,r){var a=this;this.events=h.reactive({}),this.backgroundClose=!0,this.isRoute=!1,this.id=n.modalId++,this.component=e,this.props=h.ref(t),this.closed=h.computed(function(){return!b(r.namespace).queue.includes(a)}),e.beforeModalClose&&_.add(this.id,"close",e.beforeModalClose);var o=W(r);this.backgroundClose=o.backgroundClose,this.isRoute=o.isRoute,this.namespace=o.namespace,this.draggable=o.draggable,n.STORE.set(this.id,this)}return n.prototype.close=function(){return T(this.id)},Object.defineProperty(n.prototype,"onclose",{set:function(e){_.add(this.id,"close",e)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ondestroy",{set:function(e){_.add(this.id,"destroy",e)},enumerable:!1,configurable:!0}),n.prototype.on=function(e,t){var r=this;return Array.isArray(this.events[e])||(this.events[e]=[]),this.events[e].push(t),function(){var a=r.events[e].indexOf(t);a!==-1&&r.events[e].splice(a,1)}},n.STORE=new Map,n.modalId=0,n.EVENT_PROMPT="jenesius-vue-modal:____P____R____O____M____P____T",n}();function J(n){return I.STORE.get(n)}var re={store:{},add:function(n,e,t){var r,a;if(typeof t!="function")throw g.GuardDeclarationType(t);this.store[n]||(this.store[n]=(r={},r[e]=[],r)),this.store[n][e]||(this.store[n][e]=[]),(a=this.store[n][e])===null||a===void 0||a.push(t)},get:function(n,e){return n in this.store?e in this.store[n]?this.store[n][e]||[]:[]:[]},delete:function(n){n in this.store&&delete this.store[n]}};const _=re;function Z(n){return n.reduce(function(e,t){return e.then(function(){return t()})},Promise.resolve())}function oe(n,e,t){return function(){return new Promise(function(r,a){var o,l=function(f){f===void 0&&(f=!0),f===!1&&a(g.NextReject(e)),r()};Promise.resolve(n.call((o=J(e))===null||o===void 0?void 0:o.instance,t)).then(l).catch(function(f){return a(f)})})}}function V(n){return n=H(n),Z(b(n.namespace).queue.map(function(e){return function(){return e.close()}}))}function q(n){var e=b(n),t=e.queue;if(t.length!==0)return t[t.length-1]}function ie(n){n=H(n);var e=q(n.namespace);return e?e.close():Promise.resolve()}function ae(n,e,t){return F(this,void 0,void 0,function(){var r,a,o,l;return M(this,function(f){switch(f.label){case 0:if(r=W(t),a=b(r.namespace),r.namespace===P.DEFAULT_NAMESPACE&&!a.initialized&&!y.skipInitCheck)throw g.NotInitialized(r.namespace);return[4,y.beforeEach()];case 1:if(f.sent()===!1)throw g.RejectedByBeforeEach();if(typeof n=="string"){if(o=ee(n),!o)throw g.ModalNotExistsInStore(n);n=o}if(!n)throw g.ModalComponentNotProvided();return l=new I(n,e,r),a.queue.push(h.markRaw(l)),[2,l]}})})}function L(n,e,t){return e===void 0&&(e={}),t===void 0&&(t={}),Promise.resolve().then(function(){return ae(n,e,t)})}function K(n,e,t){return e===void 0&&(e={}),t===void 0&&(t={}),V({namespace:t.namespace}).then(function(){var r=b(t.namespace);if(r.queue.length)throw g.QueueNoEmpty()}).then(function(){return L(n,e,t)})}function ue(n){if(typeof n!="object")throw g.ConfigurationType(n);Object.assign(y,n)}function se(n){var e,t,r,a=h.getCurrentInstance(),o=String(((e=a==null?void 0:a.props)===null||e===void 0?void 0:e.modalId)||((t=a==null?void 0:a.props)===null||t===void 0?void 0:t["modal-id"])||((r=a==null?void 0:a.attrs)===null||r===void 0?void 0:r.modalId)),l=o.replace(/[^0-9]/g,"");_.add(Number(l),"close",n)}function ce(n,e,t){return e===void 0&&(e={}),t===void 0&&(t={}),F(this,void 0,void 0,function(){var r,a,o=this;return M(this,function(l){switch(l.label){case 0:return[4,L(n,e,t)];case 1:return r=l.sent(),a=!1,[2,new Promise(function(f){r.on(I.EVENT_PROMPT,function(c){return F(o,void 0,void 0,function(){return M(this,function(s){return a=!0,[2,r.close().then(function(){return f(c)}).catch(function(){return a=!1})]})})}),r.ondestroy=function(){a||f(null)}})]}})})}function ee(n){return y.store[n]||void 0}function le(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var B={exports:{}},x,Q;function de(){if(Q)return x;Q=1;var n=1e3,e=n*60,t=e*60,r=t*24,a=r*7,o=r*365.25;x=function(i,u){u=u||{};var d=typeof i;if(d==="string"&&i.length>0)return l(i);if(d==="number"&&isFinite(i))return u.long?c(i):f(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function l(i){if(i=String(i),!(i.length>100)){var u=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(u){var d=parseFloat(u[1]),p=(u[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return d*o;case"weeks":case"week":case"w":return d*a;case"days":case"day":case"d":return d*r;case"hours":case"hour":case"hrs":case"hr":case"h":return d*t;case"minutes":case"minute":case"mins":case"min":case"m":return d*e;case"seconds":case"second":case"secs":case"sec":case"s":return d*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return d;default:return}}}}function f(i){var u=Math.abs(i);return u>=r?Math.round(i/r)+"d":u>=t?Math.round(i/t)+"h":u>=e?Math.round(i/e)+"m":u>=n?Math.round(i/n)+"s":i+"ms"}function c(i){var u=Math.abs(i);return u>=r?s(i,u,r,"day"):u>=t?s(i,u,t,"hour"):u>=e?s(i,u,e,"minute"):u>=n?s(i,u,n,"second"):i+" ms"}function s(i,u,d,p){var E=u>=d*1.5;return Math.round(i/d)+" "+p+(E?"s":"")}return x}function fe(n){t.debug=t,t.default=t,t.coerce=c,t.disable=o,t.enable=a,t.enabled=l,t.humanize=de(),t.destroy=s,Object.keys(n).forEach(i=>{t[i]=n[i]}),t.names=[],t.skips=[],t.formatters={};function e(i){let u=0;for(let d=0;d<i.length;d++)u=(u<<5)-u+i.charCodeAt(d),u|=0;return t.colors[Math.abs(u)%t.colors.length]}t.selectColor=e;function t(i){let u,d=null,p,E;function v(...m){if(!v.enabled)return;const C=v,k=Number(new Date),R=k-(u||k);C.diff=R,C.prev=u,C.curr=k,u=k,m[0]=t.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let w=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(S,A)=>{if(S==="%%")return"%";w++;const O=t.formatters[A];if(typeof O=="function"){const j=m[w];S=O.call(C,j),m.splice(w,1),w--}return S}),t.formatArgs.call(C,m),(C.log||t.log).apply(C,m)}return v.namespace=i,v.useColors=t.useColors(),v.color=t.selectColor(i),v.extend=r,v.destroy=t.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(p!==t.namespaces&&(p=t.namespaces,E=t.enabled(i)),E),set:m=>{d=m}}),typeof t.init=="function"&&t.init(v),v}function r(i,u){const d=t(this.namespace+(typeof u>"u"?":":u)+i);return d.log=this.log,d}function a(i){t.save(i),t.namespaces=i,t.names=[],t.skips=[];let u;const d=(typeof i=="string"?i:"").split(/[\s,]+/),p=d.length;for(u=0;u<p;u++)d[u]&&(i=d[u].replace(/\*/g,".*?"),i[0]==="-"?t.skips.push(new RegExp("^"+i.slice(1)+"$")):t.names.push(new RegExp("^"+i+"$")))}function o(){const i=[...t.names.map(f),...t.skips.map(f).map(u=>"-"+u)].join(",");return t.enable(""),i}function l(i){if(i[i.length-1]==="*")return!0;let u,d;for(u=0,d=t.skips.length;u<d;u++)if(t.skips[u].test(i))return!1;for(u=0,d=t.names.length;u<d;u++)if(t.names[u].test(i))return!0;return!1}function f(i){return i.toString().substring(2,i.toString().length-2).replace(/\.\*\?$/,"*")}function c(i){return i instanceof Error?i.stack||i.message:i}function s(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}var he=fe;(function(n,e){e.formatArgs=r,e.save=a,e.load=o,e.useColors=t,e.storage=l(),e.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function t(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+n.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;c.splice(1,0,s,"color: inherit");let i=0,u=0;c[0].replace(/%[a-zA-Z%]/g,d=>{d!=="%%"&&(i++,d==="%c"&&(u=i))}),c.splice(u,0,s)}e.log=console.debug||console.log||(()=>{});function a(c){try{c?e.storage.setItem("debug",c):e.storage.removeItem("debug")}catch{}}function o(){let c;try{c=e.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function l(){try{return localStorage}catch{}}n.exports=he(e);const{formatters:f}=n.exports;f.j=function(c){try{return JSON.stringify(c)}catch(s){return"[UnexpectedJSONParseError]: "+s.message}}})(B,B.exports);var me=B.exports;const ve=le(me);function ge(n){return ve("jenesius-vue-modal:".concat(n))}const pe=["onPointerdown"],Y=h.defineComponent({__name:"WidgetModalContainerItem",props:{id:{}},setup(n){const e=ge("modal-item"),t=n,r=J(t.id),a=h.ref(),o=h.ref();function l(){if(r.backgroundClose)return T(r.id,{background:!0}).catch(()=>{})}h.watch(()=>o.value,c=>{var s;if(r.instance=c,e(`Modal(${r.id}) instance is saved.`),r.draggable){const i=`[modalid=_modal_${t.id}]`,u=typeof r.draggable=="string"?r.draggable:i;e(`The modal window is movable(${u}).`),a.value?(e("Finding an item to drag: %s",u),f((s=a.value)==null?void 0:s.querySelector(i),a.value.querySelector(u))):e("The modal container is not mounted. Modal id %d.",r.id)}}),h.onMounted(()=>{e(`Modal(${r.id}) is mounted`)});function f(c,s){if(!s){e("draggable item not found.");return}if(!c){e("HTML modal is not founded.");return}s.addEventListener("pointerdown",i=>{var S;const u=(S=c.getAttribute("style"))==null?void 0:S.match(/transform: translate\((.*)px,\s*(.*)px\)/),d=u==null?void 0:u[1],p=u==null?void 0:u[2];let E=typeof d=="string"?Number.parseInt(d):0,v=typeof p=="string"?Number.parseInt(p):0;const{clientX:m,clientY:C}=i,k=m,R=C;e(`movement started at (${R}, ${R})`),document.addEventListener("pointermove",w,{passive:!0}),document.addEventListener("pointerup",$,{once:!0});function w(A){const{clientX:O,clientY:j}=A,z=E+O-k,U=v+j-R;e(`move at (${z}, ${U})`),c.style.transform=`translate(${z}px,${U}px)`}function $(A){e("movement completed"),document.removeEventListener("pointermove",w),A.preventDefault()}})}return(c,s)=>(h.openBlock(),h.createElementBlock("div",{class:"widget__modal-container__item modal-container",onPointerdown:h.withModifiers(l,["self","stop"]),ref_key:"modalContainerRef",ref:a},[(h.openBlock(),h.createBlock(h.resolveDynamicComponent(h.unref(r).component),h.mergeProps(h.unref(r).props.value,{class:"modal-item widget__modal-wrap",modalId:`_modal_${c.id}`,ref_key:"modalRef",ref:o},h.toHandlers(h.unref(r).events)),null,16,["modalId"]))],40,pe))}});function Ce(n){n===void 0&&(n=P.DEFAULT_NAMESPACE);var e=P.instance.getByName(n);e.initialized=!0,n===P.DEFAULT_NAMESPACE&&document.addEventListener("keyup",function(t){if(y.escClose&&(t.key==="Escape"||t.code==="Escape")){var r=q(n);if(!r)return;T(r.id,{esc:!0}).catch(function(){})}})}const ye={props:{namespace:String},setup(n){return h.onMounted(()=>{Ce(n.namespace)}),()=>{const e=b(n.namespace);return h.h(h.TransitionGroup,{name:y.animation,tag:"div",appear:y.appear},{default:()=>e.queue.map(t=>h.h(Y,{key:t.id,id:t.id}))})}},components:{WidgetContainerModalItem:Y}};var N={router:null};function be(n){var e=this;if(N.router)throw g.DuplicatedRouterIntegration();N.router=n;function t(r){for(var a=r.matched.length-1;a>=0;a--){var o=r.matched[a].components,l=Object.values(o).find(function(f){return f._isModal});if(l)return l}return null}n.beforeEach(function(r,a){return F(e,void 0,void 0,function(){var o,l,f;return M(this,function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),o=t(a),o&&!(!((f=(l=o.getModalObject())===null||l===void 0?void 0:l.closed)===null||f===void 0)&&f.value)?[4,o.close(!0)]:[3,2];case 1:c.sent(),c.label=2;case 2:return[3,4];case 3:return c.sent(),[2,!1];case 4:return[2]}})})}),n.afterEach(function(r){return F(e,void 0,void 0,function(){var a;return M(this,function(o){switch(o.label){case 0:return a=t(r),a?[4,a.initialize()]:[3,2];case 1:o.sent(),o.label=2;case 2:return[2]}})})})}function te(n){var e=null,t=!1;function r(){return F(this,void 0,void 0,function(){return M(this,function(a){switch(a.label){case 0:if(!N.router)throw g.ModalRouterIntegrationNotInitialized();return t=!1,e=null,[4,K(n,h.computed(function(){var o;return(o=N.router)===null||o===void 0?void 0:o.currentRoute.value.params}),{isRoute:!0})];case 1:return e=a.sent(),e.onclose=function(){var o;t||(o=N.router)===null||o===void 0||o.back()},[2]}})})}return{getModalObject:function(){return e},_isModal:!0,close:function(a){return a===void 0&&(a=!1),F(this,void 0,void 0,function(){return M(this,function(o){switch(o.label){case 0:return t=a,e?[4,e.close()]:[3,2];case 1:return[2,o.sent()];case 2:return[2]}})})},initialize:r,setup:function(){return function(){return null}}}}te.init=be;var we=b().queue;function _e(n){return b(n).queue}exports.Modal=I;exports.closeById=T;exports.closeModal=V;exports.config=ue;exports.container=ye;exports.getComponentFromStore=ee;exports.getCurrentModal=q;exports.getQueueByNamespace=_e;exports.modalQueue=we;exports.onBeforeModalClose=se;exports.openModal=K;exports.popModal=ie;exports.promptModal=ce;exports.pushModal=L;exports.useModalRouter=te; | ||
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("vue");var D=function(n,e){return D=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])},D(n,e)};function ne(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");D(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function F(n,e,t,r){function o(i){return i instanceof t?i:new t(function(l){l(i)})}return new(t||(t=Promise))(function(i,l){function f(a){try{s(r.next(a))}catch(u){l(u)}}function c(a){try{s(r.throw(a))}catch(u){l(u)}}function s(a){a.done?i(a.value):o(a.value).then(f,c)}s((r=r.apply(n,e||[])).next())})}function M(n,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,l;return l={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function f(s){return function(a){return c([s,a])}}function c(s){if(r)throw new TypeError("Generator is already executing.");for(;l&&(l=0,s[0]&&(t=0)),t;)try{if(r=1,o&&(i=s[0]&2?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[s[0]&2,i.value]),s[0]){case 0:case 1:i=s;break;case 4:return t.label++,{value:s[1],done:!1};case 5:t.label++,o=s[1],s=[0];continue;case 7:s=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){t.label=s[1];break}if(s[0]===6&&t.label<i[1]){t.label=i[1],i=s;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(s);break}i[2]&&t.ops.pop(),t.trys.pop();continue}s=e.call(n,t)}catch(a){s=[6,a],o=0}finally{r=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}var g=function(n){ne(e,n);function e(t,r){r===void 0&&(r=null);var o=n.call(this)||this;return o.isModalError=!0,o.message=t,o.details=r,o}return e.Undefined=function(t){return new e("Modal with id: ".concat(t," not founded. The modal window may have been closed earlier."))},e.UndefinedGuardName=function(t){return new e("Guard's name ".concat(t," is not declaration."))},e.NextReject=function(t){return new e("Guard returned false. Modal navigation was stopped. Modal id ".concat(t))},e.GuardDeclarationType=function(t){return new e("Guard's type should be a function. Provided:",t)},e.RejectedByBeforeEach=function(){return new e("The opening of the modal was stopped in beforeEach")},e.ConfigurationType=function(t){return new e("Configuration type must be an Object. Provided",t)},e.ConfigurationUndefinedParam=function(t,r){return new e("In configuration founded unknown parameter: ".concat(t,". Available are ").concat(r.join(", ")," "))},e.QueueNoEmpty=function(){return new e("Modal's queue is not empty. Probably some modal reject closing by onClose hook.")},e.EmptyModalQueue=function(){return new e("Modal queue is empty.")},e.NotInitialized=function(t){return new e("Modal Container not found. Put container from jenesius-vue-modal in App's template. Namespace: ".concat(t,". Check documentation for more information https://modal.jenesius.com/docs.html/installation#getting-started."))},e.ModalComponentNotProvided=function(){return new e("The first parameter(VueComponent) was not specified.")},e.DuplicatedRouterIntegration=function(){return new e("useModalRouter.init should escaped only once.")},e.ModalRouterIntegrationNotInitialized=function(){return new e("The integration was not initialized. Please, use useModalRouter.init(router). For more information: https://modal.jenesius.com/docs.html/integration-vue-router#installation")},e.ModalEventNameMustBeString=function(t){return new e("Event name must be a string. Provided: ".concat(t))},e.ModalNotFoundByID=function(t){return new e("Modal with ID ".concat(t," was not found."))},e.ModalNotExistsInStore=function(t){return new e("Provided name(".concat(t,") don't exist in the store. Has the given name been added to the store?"))},e}(Error),P=function(){function n(){this.state=new Map,n.instance=this}return n.prototype.getByName=function(e){return e===void 0&&(e=n.DEFAULT_NAMESPACE),this.state.has(e)||this.state.set(e,{queue:h.reactive([]),initialized:!1}),this.state.get(e)},n.prototype.forceClean=function(){this.state.forEach(function(e){e.queue.splice(0,e.queue.length)})},n.DEFAULT_NAMESPACE="default",n}(),X=function(){var n=new P,e={scrollLock:!0,animation:"modal-list",backgroundClose:!0,escClose:!0,store:{},skipInitCheck:!1,draggable:!1,appear:!0,singleShow:!1,beforeEach:function(){}},t=n.getByName().queue;return h.watch(function(){return t},function(){e.scrollLock&&(t.length?document.body.style.overflowY="hidden":document.body.style.overflowY="auto")},{deep:!0}),{namespaceStore:n,configuration:e}}();function b(n){return X.namespaceStore.getByName(n)}var C=X.configuration;function W(n){var e={backgroundClose:C.backgroundClose,isRoute:!1,namespace:P.DEFAULT_NAMESPACE,draggable:C.draggable};return n.backgroundClose!==void 0&&(e.backgroundClose=n.backgroundClose),n.isRoute&&(e.isRoute=n.isRoute),n.namespace&&(e.namespace=n.namespace),n.draggable!==void 0&&(e.draggable=n.draggable),e}function G(n){n===void 0&&(n={});var e={background:!1,esc:!1};return Object.assign(e,n)}function H(n){return n||(n={}),n}function T(n,e){e===void 0&&(e={});var t=I.STORE.get(n);if(!t)return Promise.reject(g.ModalNotFoundByID(n));var r=b(t.namespace),o=r.queue.findIndex(function(l){return l.id===n});if(o===-1)return Promise.reject(g.Undefined(n));var i=_.get(n,"close").map(function(l){return oe(l,n,G(e))});return Z(i).then(function(){r.queue.splice(o,1)}).then(function(){_.get(n,"destroy").forEach(function(l){return l(G(e))})}).then(function(){_.delete(n)})}var I=function(){function n(e,t,r){var o=this;this.events=h.reactive({}),this.backgroundClose=!0,this.isRoute=!1,this.id=n.modalId++,this.component=e,this.props=h.ref(t),this.closed=h.computed(function(){return!b(r.namespace).queue.includes(o)}),e.beforeModalClose&&_.add(this.id,"close",e.beforeModalClose);var i=W(r);this.backgroundClose=i.backgroundClose,this.isRoute=i.isRoute,this.namespace=i.namespace,this.draggable=i.draggable,n.STORE.set(this.id,this)}return n.prototype.close=function(){return T(this.id)},Object.defineProperty(n.prototype,"onclose",{set:function(e){_.add(this.id,"close",e)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ondestroy",{set:function(e){_.add(this.id,"destroy",e)},enumerable:!1,configurable:!0}),n.prototype.on=function(e,t){var r=this;return Array.isArray(this.events[e])||(this.events[e]=[]),this.events[e].push(t),function(){var o=r.events[e].indexOf(t);o!==-1&&r.events[e].splice(o,1)}},n.STORE=new Map,n.modalId=0,n.EVENT_PROMPT="jenesius-vue-modal:____P____R____O____M____P____T",n}();function J(n){return I.STORE.get(n)}var re={store:{},add:function(n,e,t){var r,o;if(typeof t!="function")throw g.GuardDeclarationType(t);this.store[n]||(this.store[n]=(r={},r[e]=[],r)),this.store[n][e]||(this.store[n][e]=[]),(o=this.store[n][e])===null||o===void 0||o.push(t)},get:function(n,e){return n in this.store?e in this.store[n]?this.store[n][e]||[]:[]:[]},delete:function(n){n in this.store&&delete this.store[n]}};const _=re;function Z(n){return n.reduce(function(e,t){return e.then(function(){return t()})},Promise.resolve())}function oe(n,e,t){return function(){return new Promise(function(r,o){var i,l=function(f){f===void 0&&(f=!0),f===!1&&o(g.NextReject(e)),r()};Promise.resolve(n.call((i=J(e))===null||i===void 0?void 0:i.instance,t)).then(l).catch(function(f){return o(f)})})}}function V(n){return n=H(n),Z(b(n.namespace).queue.map(function(e){return function(){return e.close()}}))}function q(n){var e=b(n),t=e.queue;if(t.length!==0)return t[t.length-1]}function ie(n){n=H(n);var e=q(n.namespace);return e?e.close():Promise.resolve()}function ae(n,e,t){return F(this,void 0,void 0,function(){var r,o,i,l;return M(this,function(f){switch(f.label){case 0:if(r=W(t),o=b(r.namespace),r.namespace===P.DEFAULT_NAMESPACE&&!o.initialized&&!C.skipInitCheck)throw g.NotInitialized(r.namespace);return[4,C.beforeEach()];case 1:if(f.sent()===!1)throw g.RejectedByBeforeEach();if(typeof n=="string"){if(i=ee(n),!i)throw g.ModalNotExistsInStore(n);n=i}if(!n)throw g.ModalComponentNotProvided();return l=new I(n,e,r),o.queue.push(h.markRaw(l)),[2,l]}})})}function L(n,e,t){return e===void 0&&(e={}),t===void 0&&(t={}),Promise.resolve().then(function(){return ae(n,e,t)})}function K(n,e,t){return e===void 0&&(e={}),t===void 0&&(t={}),V({namespace:t.namespace}).then(function(){var r=b(t.namespace);if(r.queue.length)throw g.QueueNoEmpty()}).then(function(){return L(n,e,t)})}function ue(n){if(typeof n!="object")throw g.ConfigurationType(n);Object.assign(C,n)}function se(n){var e,t,r,o=h.getCurrentInstance(),i=String(((e=o==null?void 0:o.props)===null||e===void 0?void 0:e.modalId)||((t=o==null?void 0:o.props)===null||t===void 0?void 0:t["modal-id"])||((r=o==null?void 0:o.attrs)===null||r===void 0?void 0:r.modalId)),l=i.replace(/[^0-9]/g,"");_.add(Number(l),"close",n)}function ce(n,e,t){return e===void 0&&(e={}),t===void 0&&(t={}),F(this,void 0,void 0,function(){var r,o,i=this;return M(this,function(l){switch(l.label){case 0:return[4,L(n,e,t)];case 1:return r=l.sent(),o=!1,[2,new Promise(function(f){r.on(I.EVENT_PROMPT,function(c){return F(i,void 0,void 0,function(){return M(this,function(s){return o=!0,[2,r.close().then(function(){return f(c)}).catch(function(){return o=!1})]})})}),r.ondestroy=function(){o||f(null)}})]}})})}function ee(n){return C.store[n]||void 0}function le(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var B={exports:{}},x,Q;function de(){if(Q)return x;Q=1;var n=1e3,e=n*60,t=e*60,r=t*24,o=r*7,i=r*365.25;x=function(a,u){u=u||{};var d=typeof a;if(d==="string"&&a.length>0)return l(a);if(d==="number"&&isFinite(a))return u.long?c(a):f(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))};function l(a){if(a=String(a),!(a.length>100)){var u=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(a);if(u){var d=parseFloat(u[1]),p=(u[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return d*i;case"weeks":case"week":case"w":return d*o;case"days":case"day":case"d":return d*r;case"hours":case"hour":case"hrs":case"hr":case"h":return d*t;case"minutes":case"minute":case"mins":case"min":case"m":return d*e;case"seconds":case"second":case"secs":case"sec":case"s":return d*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return d;default:return}}}}function f(a){var u=Math.abs(a);return u>=r?Math.round(a/r)+"d":u>=t?Math.round(a/t)+"h":u>=e?Math.round(a/e)+"m":u>=n?Math.round(a/n)+"s":a+"ms"}function c(a){var u=Math.abs(a);return u>=r?s(a,u,r,"day"):u>=t?s(a,u,t,"hour"):u>=e?s(a,u,e,"minute"):u>=n?s(a,u,n,"second"):a+" ms"}function s(a,u,d,p){var E=u>=d*1.5;return Math.round(a/d)+" "+p+(E?"s":"")}return x}function fe(n){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=l,t.humanize=de(),t.destroy=s,Object.keys(n).forEach(a=>{t[a]=n[a]}),t.names=[],t.skips=[],t.formatters={};function e(a){let u=0;for(let d=0;d<a.length;d++)u=(u<<5)-u+a.charCodeAt(d),u|=0;return t.colors[Math.abs(u)%t.colors.length]}t.selectColor=e;function t(a){let u,d=null,p,E;function v(...m){if(!v.enabled)return;const y=v,S=Number(new Date),R=S-(u||S);y.diff=R,y.prev=u,y.curr=S,u=S,m[0]=t.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let w=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(k,A)=>{if(k==="%%")return"%";w++;const O=t.formatters[A];if(typeof O=="function"){const j=m[w];k=O.call(y,j),m.splice(w,1),w--}return k}),t.formatArgs.call(y,m),(y.log||t.log).apply(y,m)}return v.namespace=a,v.useColors=t.useColors(),v.color=t.selectColor(a),v.extend=r,v.destroy=t.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(p!==t.namespaces&&(p=t.namespaces,E=t.enabled(a)),E),set:m=>{d=m}}),typeof t.init=="function"&&t.init(v),v}function r(a,u){const d=t(this.namespace+(typeof u>"u"?":":u)+a);return d.log=this.log,d}function o(a){t.save(a),t.namespaces=a,t.names=[],t.skips=[];let u;const d=(typeof a=="string"?a:"").split(/[\s,]+/),p=d.length;for(u=0;u<p;u++)d[u]&&(a=d[u].replace(/\*/g,".*?"),a[0]==="-"?t.skips.push(new RegExp("^"+a.slice(1)+"$")):t.names.push(new RegExp("^"+a+"$")))}function i(){const a=[...t.names.map(f),...t.skips.map(f).map(u=>"-"+u)].join(",");return t.enable(""),a}function l(a){if(a[a.length-1]==="*")return!0;let u,d;for(u=0,d=t.skips.length;u<d;u++)if(t.skips[u].test(a))return!1;for(u=0,d=t.names.length;u<d;u++)if(t.names[u].test(a))return!0;return!1}function f(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function c(a){return a instanceof Error?a.stack||a.message:a}function s(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}var he=fe;(function(n,e){e.formatArgs=r,e.save=o,e.load=i,e.useColors=t,e.storage=l(),e.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function t(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+n.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;c.splice(1,0,s,"color: inherit");let a=0,u=0;c[0].replace(/%[a-zA-Z%]/g,d=>{d!=="%%"&&(a++,d==="%c"&&(u=a))}),c.splice(u,0,s)}e.log=console.debug||console.log||(()=>{});function o(c){try{c?e.storage.setItem("debug",c):e.storage.removeItem("debug")}catch{}}function i(){let c;try{c=e.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function l(){try{return localStorage}catch{}}n.exports=he(e);const{formatters:f}=n.exports;f.j=function(c){try{return JSON.stringify(c)}catch(s){return"[UnexpectedJSONParseError]: "+s.message}}})(B,B.exports);var me=B.exports;const ve=le(me);function ge(n){return ve("jenesius-vue-modal:".concat(n))}const pe=["onPointerdown"],Y=h.defineComponent({__name:"WidgetModalContainerItem",props:{id:{},show:{type:Boolean}},setup(n){const e=ge("modal-item"),t=n,r=J(t.id),o=h.ref(),i=h.ref();function l(){if(r.backgroundClose)return T(r.id,{background:!0}).catch(()=>{})}h.watch(()=>i.value,c=>{var s;if(r.instance=c,e(`Modal(${r.id}) instance is saved.`),r.draggable){const a=`[modalid=_modal_${t.id}]`,u=typeof r.draggable=="string"?r.draggable:a;e(`The modal window is movable(${u}).`),o.value?(e("Finding an item to drag: %s",u),f((s=o.value)==null?void 0:s.querySelector(a),o.value.querySelector(u))):e("The modal container is not mounted. Modal id %d.",r.id)}}),h.onMounted(()=>{e(`Modal(${r.id}) is mounted`)});function f(c,s){if(!s){e("draggable item not found.");return}if(!c){e("HTML modal is not founded.");return}s.addEventListener("pointerdown",a=>{var k;const u=(k=c.getAttribute("style"))==null?void 0:k.match(/transform: translate\((.*)px,\s*(.*)px\)/),d=u==null?void 0:u[1],p=u==null?void 0:u[2];let E=typeof d=="string"?Number.parseInt(d):0,v=typeof p=="string"?Number.parseInt(p):0;const{clientX:m,clientY:y}=a,S=m,R=y;e(`movement started at (${R}, ${R})`),document.addEventListener("pointermove",w,{passive:!0}),document.addEventListener("pointerup",$,{once:!0});function w(A){const{clientX:O,clientY:j}=A,z=E+O-S,U=v+j-R;e(`move at (${z}, ${U})`),c.style.transform=`translate(${z}px,${U}px)`}function $(A){e("movement completed"),document.removeEventListener("pointermove",w),A.preventDefault()}})}return(c,s)=>h.withDirectives((h.openBlock(),h.createElementBlock("div",{class:"widget__modal-container__item modal-container",onPointerdown:h.withModifiers(l,["self","stop"]),ref_key:"modalContainerRef",ref:o},[(h.openBlock(),h.createBlock(h.resolveDynamicComponent(h.unref(r).component),h.mergeProps(h.unref(r).props.value,{class:"modal-item widget__modal-wrap",modalId:`_modal_${c.id}`,ref_key:"modalRef",ref:i},h.toHandlers(h.unref(r).events)),null,16,["modalId"]))],40,pe)),[[h.vShow,c.show]])}});function Ce(n){n===void 0&&(n=P.DEFAULT_NAMESPACE);var e=P.instance.getByName(n);e.initialized=!0,n===P.DEFAULT_NAMESPACE&&document.addEventListener("keyup",function(t){if(C.escClose&&(t.key==="Escape"||t.code==="Escape")){var r=q(n);if(!r)return;T(r.id,{esc:!0}).catch(function(){})}})}const ye={props:{namespace:String},setup(n){return h.onMounted(()=>{Ce(n.namespace)}),()=>{const e=b(n.namespace);return h.h(h.TransitionGroup,{name:C.animation,tag:"div",appear:C.appear},{default:()=>e.queue.map((t,r,o)=>h.h(Y,{key:t.id,id:t.id,show:C.singleShow===!0?r===o.length-1:!0}))})}},components:{WidgetContainerModalItem:Y}};var N={router:null};function be(n){var e=this;if(N.router)throw g.DuplicatedRouterIntegration();N.router=n;function t(r){for(var o=r.matched.length-1;o>=0;o--){var i=r.matched[o].components,l=Object.values(i).find(function(f){return f._isModal});if(l)return l}return null}n.beforeEach(function(r,o){return F(e,void 0,void 0,function(){var i,l,f;return M(this,function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),i=t(o),i&&!(!((f=(l=i.getModalObject())===null||l===void 0?void 0:l.closed)===null||f===void 0)&&f.value)?[4,i.close(!0)]:[3,2];case 1:c.sent(),c.label=2;case 2:return[3,4];case 3:return c.sent(),[2,!1];case 4:return[2]}})})}),n.afterEach(function(r){return F(e,void 0,void 0,function(){var o;return M(this,function(i){switch(i.label){case 0:return o=t(r),o?[4,o.initialize()]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}})})})}function te(n){var e=null,t=!1;function r(){return F(this,void 0,void 0,function(){return M(this,function(o){switch(o.label){case 0:if(!N.router)throw g.ModalRouterIntegrationNotInitialized();return t=!1,e=null,[4,K(n,h.computed(function(){var i;return(i=N.router)===null||i===void 0?void 0:i.currentRoute.value.params}),{isRoute:!0})];case 1:return e=o.sent(),e.onclose=function(){var i;t||(i=N.router)===null||i===void 0||i.back()},[2]}})})}return{getModalObject:function(){return e},_isModal:!0,close:function(o){return o===void 0&&(o=!1),F(this,void 0,void 0,function(){return M(this,function(i){switch(i.label){case 0:return t=o,e?[4,e.close()]:[3,2];case 1:return[2,i.sent()];case 2:return[2]}})})},initialize:r,setup:function(){return function(){return null}}}}te.init=be;var we=b().queue;function _e(n){return b(n).queue}exports.Modal=I;exports.closeById=T;exports.closeModal=V;exports.config=ue;exports.container=ye;exports.getComponentFromStore=ee;exports.getCurrentModal=q;exports.getQueueByNamespace=_e;exports.modalQueue=we;exports.onBeforeModalClose=se;exports.openModal=K;exports.popModal=ie;exports.promptModal=ce;exports.pushModal=L;exports.useModalRouter=te; | ||
//# sourceMappingURL=jenesius-vue-modal.cjs.js.map |
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".modal-container{position:fixed;left:0;top:0;height:100%;width:100%;display:flex;align-items:center;justify-content:center;background-color:#3e3e3e21;cursor:pointer}.modal-item{cursor:default}.modal-list-enter-active,.modal-list-leave-active,.modal-list-enter-active .modal-item,.modal-list-leave-active .modal-item{transition:all .2s ease}.modal-list-enter-from,.modal-list-leave-to{opacity:0!important}.modal-list-enter-from .modal-item,.modal-list-leave-to .modal-item{transform:translateY(-60px)}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})(); | ||
import { reactive as W, watch as H, ref as x, computed as J, markRaw as ie, getCurrentInstance as ae, defineComponent as ue, onMounted as Z, openBlock as U, createElementBlock as se, withModifiers as ce, createBlock as le, resolveDynamicComponent as de, unref as T, mergeProps as fe, toHandlers as he, h as G, TransitionGroup as me } from "vue"; | ||
import { reactive as W, watch as H, ref as x, computed as J, markRaw as ie, getCurrentInstance as ae, defineComponent as ue, onMounted as Z, withDirectives as se, openBlock as U, createElementBlock as ce, withModifiers as le, createBlock as de, resolveDynamicComponent as fe, unref as T, mergeProps as he, toHandlers as me, vShow as ve, h as G, TransitionGroup as ge } from "vue"; | ||
/*! | ||
* jenesius-vue-modal v1.11.7 | ||
* jenesius-vue-modal v1.11.8 | ||
* (c) 2024 Jenesius | ||
@@ -12,7 +12,7 @@ * @license MIT | ||
} || function(t, r) { | ||
for (var a in r) | ||
Object.prototype.hasOwnProperty.call(r, a) && (t[a] = r[a]); | ||
for (var o in r) | ||
Object.prototype.hasOwnProperty.call(r, o) && (t[o] = r[o]); | ||
}, D(n, e); | ||
}; | ||
function ve(n, e) { | ||
function pe(n, e) { | ||
if (typeof e != "function" && e !== null) | ||
@@ -27,11 +27,11 @@ throw new TypeError("Class extends value " + String(e) + " is not a constructor or null"); | ||
function _(n, e, t, r) { | ||
function a(o) { | ||
return o instanceof t ? o : new t(function(l) { | ||
l(o); | ||
function o(i) { | ||
return i instanceof t ? i : new t(function(l) { | ||
l(i); | ||
}); | ||
} | ||
return new (t || (t = Promise))(function(o, l) { | ||
function f(i) { | ||
return new (t || (t = Promise))(function(i, l) { | ||
function f(a) { | ||
try { | ||
s(r.next(i)); | ||
s(r.next(a)); | ||
} catch (u) { | ||
@@ -41,5 +41,5 @@ l(u); | ||
} | ||
function c(i) { | ||
function c(a) { | ||
try { | ||
s(r.throw(i)); | ||
s(r.throw(a)); | ||
} catch (u) { | ||
@@ -49,4 +49,4 @@ l(u); | ||
} | ||
function s(i) { | ||
i.done ? o(i.value) : a(i.value).then(f, c); | ||
function s(a) { | ||
a.done ? i(a.value) : o(a.value).then(f, c); | ||
} | ||
@@ -58,6 +58,6 @@ s((r = r.apply(n, e || [])).next()); | ||
var t = { label: 0, sent: function() { | ||
if (o[0] & 1) | ||
throw o[1]; | ||
return o[1]; | ||
}, trys: [], ops: [] }, r, a, o, l; | ||
if (i[0] & 1) | ||
throw i[1]; | ||
return i[1]; | ||
}, trys: [], ops: [] }, r, o, i, l; | ||
return l = { next: f(0), throw: f(1), return: f(2) }, typeof Symbol == "function" && (l[Symbol.iterator] = function() { | ||
@@ -67,4 +67,4 @@ return this; | ||
function f(s) { | ||
return function(i) { | ||
return c([s, i]); | ||
return function(a) { | ||
return c([s, a]); | ||
}; | ||
@@ -77,8 +77,8 @@ } | ||
try { | ||
if (r = 1, a && (o = s[0] & 2 ? a.return : s[0] ? a.throw || ((o = a.return) && o.call(a), 0) : a.next) && !(o = o.call(a, s[1])).done) | ||
return o; | ||
switch (a = 0, o && (s = [s[0] & 2, o.value]), s[0]) { | ||
if (r = 1, o && (i = s[0] & 2 ? o.return : s[0] ? o.throw || ((i = o.return) && i.call(o), 0) : o.next) && !(i = i.call(o, s[1])).done) | ||
return i; | ||
switch (o = 0, i && (s = [s[0] & 2, i.value]), s[0]) { | ||
case 0: | ||
case 1: | ||
o = s; | ||
i = s; | ||
break; | ||
@@ -88,3 +88,3 @@ case 4: | ||
case 5: | ||
t.label++, a = s[1], s = [0]; | ||
t.label++, o = s[1], s = [0]; | ||
continue; | ||
@@ -95,26 +95,26 @@ case 7: | ||
default: | ||
if (o = t.trys, !(o = o.length > 0 && o[o.length - 1]) && (s[0] === 6 || s[0] === 2)) { | ||
if (i = t.trys, !(i = i.length > 0 && i[i.length - 1]) && (s[0] === 6 || s[0] === 2)) { | ||
t = 0; | ||
continue; | ||
} | ||
if (s[0] === 3 && (!o || s[1] > o[0] && s[1] < o[3])) { | ||
if (s[0] === 3 && (!i || s[1] > i[0] && s[1] < i[3])) { | ||
t.label = s[1]; | ||
break; | ||
} | ||
if (s[0] === 6 && t.label < o[1]) { | ||
t.label = o[1], o = s; | ||
if (s[0] === 6 && t.label < i[1]) { | ||
t.label = i[1], i = s; | ||
break; | ||
} | ||
if (o && t.label < o[2]) { | ||
t.label = o[2], t.ops.push(s); | ||
if (i && t.label < i[2]) { | ||
t.label = i[2], t.ops.push(s); | ||
break; | ||
} | ||
o[2] && t.ops.pop(), t.trys.pop(); | ||
i[2] && t.ops.pop(), t.trys.pop(); | ||
continue; | ||
} | ||
s = e.call(n, t); | ||
} catch (i) { | ||
s = [6, i], a = 0; | ||
} catch (a) { | ||
s = [6, a], o = 0; | ||
} finally { | ||
r = o = 0; | ||
r = i = 0; | ||
} | ||
@@ -129,7 +129,7 @@ if (s[0] & 5) | ||
function(n) { | ||
ve(e, n); | ||
pe(e, n); | ||
function e(t, r) { | ||
r === void 0 && (r = null); | ||
var a = n.call(this) || this; | ||
return a.isModalError = !0, a.message = t, a.details = r, a; | ||
var o = n.call(this) || this; | ||
return o.isModalError = !0, o.message = t, o.details = r, o; | ||
} | ||
@@ -197,2 +197,3 @@ return e.Undefined = function(t) { | ||
appear: !0, | ||
singleShow: !1, | ||
beforeEach: function() { | ||
@@ -213,9 +214,9 @@ } | ||
} | ||
var C = V.configuration; | ||
var p = V.configuration; | ||
function K(n) { | ||
var e = { | ||
backgroundClose: C.backgroundClose, | ||
backgroundClose: p.backgroundClose, | ||
isRoute: !1, | ||
namespace: S.DEFAULT_NAMESPACE, | ||
draggable: C.draggable | ||
draggable: p.draggable | ||
}; | ||
@@ -235,3 +236,3 @@ return n.backgroundClose !== void 0 && (e.backgroundClose = n.backgroundClose), n.isRoute && (e.isRoute = n.isRoute), n.namespace && (e.namespace = n.namespace), n.draggable !== void 0 && (e.draggable = n.draggable), e; | ||
} | ||
function L(n, e) { | ||
function B(n, e) { | ||
e === void 0 && (e = {}); | ||
@@ -241,12 +242,12 @@ var t = I.STORE.get(n); | ||
return Promise.reject(v.ModalNotFoundByID(n)); | ||
var r = y(t.namespace), a = r.queue.findIndex(function(l) { | ||
var r = y(t.namespace), o = r.queue.findIndex(function(l) { | ||
return l.id === n; | ||
}); | ||
if (a === -1) | ||
if (o === -1) | ||
return Promise.reject(v.Undefined(n)); | ||
var o = w.get(n, "close").map(function(l) { | ||
return pe(l, n, Y(e)); | ||
var i = w.get(n, "close").map(function(l) { | ||
return ye(l, n, Y(e)); | ||
}); | ||
return ne(o).then(function() { | ||
r.queue.splice(a, 1); | ||
return ne(i).then(function() { | ||
r.queue.splice(o, 1); | ||
}).then(function() { | ||
@@ -264,11 +265,11 @@ w.get(n, "destroy").forEach(function(l) { | ||
function n(e, t, r) { | ||
var a = this; | ||
var o = this; | ||
this.events = W({}), this.backgroundClose = !0, this.isRoute = !1, this.id = n.modalId++, this.component = e, this.props = x(t), this.closed = J(function() { | ||
return !y(r.namespace).queue.includes(a); | ||
return !y(r.namespace).queue.includes(o); | ||
}), e.beforeModalClose && w.add(this.id, "close", e.beforeModalClose); | ||
var o = K(r); | ||
this.backgroundClose = o.backgroundClose, this.isRoute = o.isRoute, this.namespace = o.namespace, this.draggable = o.draggable, n.STORE.set(this.id, this); | ||
var i = K(r); | ||
this.backgroundClose = i.backgroundClose, this.isRoute = i.isRoute, this.namespace = i.namespace, this.draggable = i.draggable, n.STORE.set(this.id, this); | ||
} | ||
return n.prototype.close = function() { | ||
return L(this.id); | ||
return B(this.id); | ||
}, Object.defineProperty(n.prototype, "onclose", { | ||
@@ -295,4 +296,4 @@ /** | ||
return Array.isArray(this.events[e]) || (this.events[e] = []), this.events[e].push(t), function() { | ||
var a = r.events[e].indexOf(t); | ||
a !== -1 && r.events[e].splice(a, 1); | ||
var o = r.events[e].indexOf(t); | ||
o !== -1 && r.events[e].splice(o, 1); | ||
}; | ||
@@ -305,9 +306,9 @@ }, n.STORE = /* @__PURE__ */ new Map(), n.modalId = 0, n.EVENT_PROMPT = "jenesius-vue-modal:____P____R____O____M____P____T", n; | ||
} | ||
var ge = { | ||
var Ce = { | ||
store: {}, | ||
add: function(n, e, t) { | ||
var r, a; | ||
var r, o; | ||
if (typeof t != "function") | ||
throw v.GuardDeclarationType(t); | ||
this.store[n] || (this.store[n] = (r = {}, r[e] = [], r)), this.store[n][e] || (this.store[n][e] = []), (a = this.store[n][e]) === null || a === void 0 || a.push(t); | ||
this.store[n] || (this.store[n] = (r = {}, r[e] = [], r)), this.store[n][e] || (this.store[n][e] = []), (o = this.store[n][e]) === null || o === void 0 || o.push(t); | ||
}, | ||
@@ -321,3 +322,3 @@ get: function(n, e) { | ||
}; | ||
const w = ge; | ||
const w = Ce; | ||
function ne(n) { | ||
@@ -330,10 +331,10 @@ return n.reduce(function(e, t) { | ||
} | ||
function pe(n, e, t) { | ||
function ye(n, e, t) { | ||
return function() { | ||
return new Promise(function(r, a) { | ||
var o, l = function(f) { | ||
f === void 0 && (f = !0), f === !1 && a(v.NextReject(e)), r(); | ||
return new Promise(function(r, o) { | ||
var i, l = function(f) { | ||
f === void 0 && (f = !0), f === !1 && o(v.NextReject(e)), r(); | ||
}; | ||
Promise.resolve(n.call((o = te(e)) === null || o === void 0 ? void 0 : o.instance, t)).then(l).catch(function(f) { | ||
return a(f); | ||
Promise.resolve(n.call((i = te(e)) === null || i === void 0 ? void 0 : i.instance, t)).then(l).catch(function(f) { | ||
return o(f); | ||
}); | ||
@@ -343,3 +344,3 @@ }); | ||
} | ||
function Ce(n) { | ||
function be(n) { | ||
return n = ee(n), ne(y(n.namespace).queue.map(function(e) { | ||
@@ -356,3 +357,3 @@ return function() { | ||
} | ||
function Te(n) { | ||
function xe(n) { | ||
n = ee(n); | ||
@@ -362,11 +363,11 @@ var e = re(n.namespace); | ||
} | ||
function ye(n, e, t) { | ||
function we(n, e, t) { | ||
return _(this, void 0, void 0, function() { | ||
var r, a, o, l; | ||
var r, o, i, l; | ||
return F(this, function(f) { | ||
switch (f.label) { | ||
case 0: | ||
if (r = K(t), a = y(r.namespace), r.namespace === S.DEFAULT_NAMESPACE && !a.initialized && !C.skipInitCheck) | ||
if (r = K(t), o = y(r.namespace), r.namespace === S.DEFAULT_NAMESPACE && !o.initialized && !p.skipInitCheck) | ||
throw v.NotInitialized(r.namespace); | ||
return [4, C.beforeEach()]; | ||
return [4, p.beforeEach()]; | ||
case 1: | ||
@@ -376,9 +377,9 @@ if (f.sent() === !1) | ||
if (typeof n == "string") { | ||
if (o = we(n), !o) | ||
if (i = Fe(n), !i) | ||
throw v.ModalNotExistsInStore(n); | ||
n = o; | ||
n = i; | ||
} | ||
if (!n) | ||
throw v.ModalComponentNotProvided(); | ||
return l = new I(n, e, r), a.queue.push(ie(l)), [2, l]; | ||
return l = new I(n, e, r), o.queue.push(ie(l)), [2, l]; | ||
} | ||
@@ -390,7 +391,7 @@ }); | ||
return e === void 0 && (e = {}), t === void 0 && (t = {}), Promise.resolve().then(function() { | ||
return ye(n, e, t); | ||
return we(n, e, t); | ||
}); | ||
} | ||
function be(n, e, t) { | ||
return e === void 0 && (e = {}), t === void 0 && (t = {}), Ce({ | ||
function _e(n, e, t) { | ||
return e === void 0 && (e = {}), t === void 0 && (t = {}), be({ | ||
namespace: t.namespace | ||
@@ -405,14 +406,14 @@ }).then(function() { | ||
} | ||
function je(n) { | ||
function De(n) { | ||
if (typeof n != "object") | ||
throw v.ConfigurationType(n); | ||
Object.assign(C, n); | ||
Object.assign(p, n); | ||
} | ||
function xe(n) { | ||
var e, t, r, a = ae(), o = String(((e = a == null ? void 0 : a.props) === null || e === void 0 ? void 0 : e.modalId) || ((t = a == null ? void 0 : a.props) === null || t === void 0 ? void 0 : t["modal-id"]) || ((r = a == null ? void 0 : a.attrs) === null || r === void 0 ? void 0 : r.modalId)), l = o.replace(/[^0-9]/g, ""); | ||
function qe(n) { | ||
var e, t, r, o = ae(), i = String(((e = o == null ? void 0 : o.props) === null || e === void 0 ? void 0 : e.modalId) || ((t = o == null ? void 0 : o.props) === null || t === void 0 ? void 0 : t["modal-id"]) || ((r = o == null ? void 0 : o.attrs) === null || r === void 0 ? void 0 : r.modalId)), l = i.replace(/[^0-9]/g, ""); | ||
w.add(Number(l), "close", n); | ||
} | ||
function De(n, e, t) { | ||
function Be(n, e, t) { | ||
return e === void 0 && (e = {}), t === void 0 && (t = {}), _(this, void 0, void 0, function() { | ||
var r, a, o = this; | ||
var r, o, i = this; | ||
return F(this, function(l) { | ||
@@ -423,10 +424,10 @@ switch (l.label) { | ||
case 1: | ||
return r = l.sent(), a = !1, [2, new Promise(function(f) { | ||
return r = l.sent(), o = !1, [2, new Promise(function(f) { | ||
r.on(I.EVENT_PROMPT, function(c) { | ||
return _(o, void 0, void 0, function() { | ||
return _(i, void 0, void 0, function() { | ||
return F(this, function(s) { | ||
return a = !0, [2, r.close().then(function() { | ||
return o = !0, [2, r.close().then(function() { | ||
return f(c); | ||
}).catch(function() { | ||
return a = !1; | ||
return o = !1; | ||
})]; | ||
@@ -436,3 +437,3 @@ }); | ||
}), r.ondestroy = function() { | ||
a || f(null); | ||
o || f(null); | ||
}; | ||
@@ -444,29 +445,29 @@ })]; | ||
} | ||
function we(n) { | ||
return C.store[n] || void 0; | ||
function Fe(n) { | ||
return p.store[n] || void 0; | ||
} | ||
function _e(n) { | ||
function Ee(n) { | ||
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n; | ||
} | ||
var q = { exports: {} }, j, Q; | ||
function Fe() { | ||
function Me() { | ||
if (Q) | ||
return j; | ||
Q = 1; | ||
var n = 1e3, e = n * 60, t = e * 60, r = t * 24, a = r * 7, o = r * 365.25; | ||
j = function(i, u) { | ||
var n = 1e3, e = n * 60, t = e * 60, r = t * 24, o = r * 7, i = r * 365.25; | ||
j = function(a, u) { | ||
u = u || {}; | ||
var d = typeof i; | ||
if (d === "string" && i.length > 0) | ||
return l(i); | ||
if (d === "number" && isFinite(i)) | ||
return u.long ? c(i) : f(i); | ||
var d = typeof a; | ||
if (d === "string" && a.length > 0) | ||
return l(a); | ||
if (d === "number" && isFinite(a)) | ||
return u.long ? c(a) : f(a); | ||
throw new Error( | ||
"val is not a non-empty string or a valid number. val=" + JSON.stringify(i) | ||
"val is not a non-empty string or a valid number. val=" + JSON.stringify(a) | ||
); | ||
}; | ||
function l(i) { | ||
if (i = String(i), !(i.length > 100)) { | ||
function l(a) { | ||
if (a = String(a), !(a.length > 100)) { | ||
var u = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( | ||
i | ||
a | ||
); | ||
@@ -481,7 +482,7 @@ if (u) { | ||
case "y": | ||
return d * o; | ||
return d * i; | ||
case "weeks": | ||
case "week": | ||
case "w": | ||
return d * a; | ||
return d * o; | ||
case "days": | ||
@@ -521,28 +522,28 @@ case "day": | ||
} | ||
function f(i) { | ||
var u = Math.abs(i); | ||
return u >= r ? Math.round(i / r) + "d" : u >= t ? Math.round(i / t) + "h" : u >= e ? Math.round(i / e) + "m" : u >= n ? Math.round(i / n) + "s" : i + "ms"; | ||
function f(a) { | ||
var u = Math.abs(a); | ||
return u >= r ? Math.round(a / r) + "d" : u >= t ? Math.round(a / t) + "h" : u >= e ? Math.round(a / e) + "m" : u >= n ? Math.round(a / n) + "s" : a + "ms"; | ||
} | ||
function c(i) { | ||
var u = Math.abs(i); | ||
return u >= r ? s(i, u, r, "day") : u >= t ? s(i, u, t, "hour") : u >= e ? s(i, u, e, "minute") : u >= n ? s(i, u, n, "second") : i + " ms"; | ||
function c(a) { | ||
var u = Math.abs(a); | ||
return u >= r ? s(a, u, r, "day") : u >= t ? s(a, u, t, "hour") : u >= e ? s(a, u, e, "minute") : u >= n ? s(a, u, n, "second") : a + " ms"; | ||
} | ||
function s(i, u, d, g) { | ||
function s(a, u, d, g) { | ||
var E = u >= d * 1.5; | ||
return Math.round(i / d) + " " + g + (E ? "s" : ""); | ||
return Math.round(a / d) + " " + g + (E ? "s" : ""); | ||
} | ||
return j; | ||
} | ||
function Ee(n) { | ||
t.debug = t, t.default = t, t.coerce = c, t.disable = o, t.enable = a, t.enabled = l, t.humanize = Fe(), t.destroy = s, Object.keys(n).forEach((i) => { | ||
t[i] = n[i]; | ||
function ke(n) { | ||
t.debug = t, t.default = t, t.coerce = c, t.disable = i, t.enable = o, t.enabled = l, t.humanize = Me(), t.destroy = s, Object.keys(n).forEach((a) => { | ||
t[a] = n[a]; | ||
}), t.names = [], t.skips = [], t.formatters = {}; | ||
function e(i) { | ||
function e(a) { | ||
let u = 0; | ||
for (let d = 0; d < i.length; d++) | ||
u = (u << 5) - u + i.charCodeAt(d), u |= 0; | ||
for (let d = 0; d < a.length; d++) | ||
u = (u << 5) - u + a.charCodeAt(d), u |= 0; | ||
return t.colors[Math.abs(u) % t.colors.length]; | ||
} | ||
t.selectColor = e; | ||
function t(i) { | ||
function t(a) { | ||
let u, d = null, g, E; | ||
@@ -552,4 +553,4 @@ function m(...h) { | ||
return; | ||
const p = m, M = Number(/* @__PURE__ */ new Date()), P = M - (u || M); | ||
p.diff = P, p.prev = u, p.curr = M, u = M, h[0] = t.coerce(h[0]), typeof h[0] != "string" && h.unshift("%O"); | ||
const C = m, M = Number(/* @__PURE__ */ new Date()), P = M - (u || M); | ||
C.diff = P, C.prev = u, C.curr = M, u = M, h[0] = t.coerce(h[0]), typeof h[0] != "string" && h.unshift("%O"); | ||
let b = 0; | ||
@@ -563,11 +564,11 @@ h[0] = h[0].replace(/%([a-zA-Z%])/g, (k, A) => { | ||
const O = h[b]; | ||
k = N.call(p, O), h.splice(b, 1), b--; | ||
k = N.call(C, O), h.splice(b, 1), b--; | ||
} | ||
return k; | ||
}), t.formatArgs.call(p, h), (p.log || t.log).apply(p, h); | ||
}), t.formatArgs.call(C, h), (C.log || t.log).apply(C, h); | ||
} | ||
return m.namespace = i, m.useColors = t.useColors(), m.color = t.selectColor(i), m.extend = r, m.destroy = t.destroy, Object.defineProperty(m, "enabled", { | ||
return m.namespace = a, m.useColors = t.useColors(), m.color = t.selectColor(a), m.extend = r, m.destroy = t.destroy, Object.defineProperty(m, "enabled", { | ||
enumerable: !0, | ||
configurable: !1, | ||
get: () => d !== null ? d : (g !== t.namespaces && (g = t.namespaces, E = t.enabled(i)), E), | ||
get: () => d !== null ? d : (g !== t.namespaces && (g = t.namespaces, E = t.enabled(a)), E), | ||
set: (h) => { | ||
@@ -578,37 +579,37 @@ d = h; | ||
} | ||
function r(i, u) { | ||
const d = t(this.namespace + (typeof u > "u" ? ":" : u) + i); | ||
function r(a, u) { | ||
const d = t(this.namespace + (typeof u > "u" ? ":" : u) + a); | ||
return d.log = this.log, d; | ||
} | ||
function a(i) { | ||
t.save(i), t.namespaces = i, t.names = [], t.skips = []; | ||
function o(a) { | ||
t.save(a), t.namespaces = a, t.names = [], t.skips = []; | ||
let u; | ||
const d = (typeof i == "string" ? i : "").split(/[\s,]+/), g = d.length; | ||
const d = (typeof a == "string" ? a : "").split(/[\s,]+/), g = d.length; | ||
for (u = 0; u < g; u++) | ||
d[u] && (i = d[u].replace(/\*/g, ".*?"), i[0] === "-" ? t.skips.push(new RegExp("^" + i.slice(1) + "$")) : t.names.push(new RegExp("^" + i + "$"))); | ||
d[u] && (a = d[u].replace(/\*/g, ".*?"), a[0] === "-" ? t.skips.push(new RegExp("^" + a.slice(1) + "$")) : t.names.push(new RegExp("^" + a + "$"))); | ||
} | ||
function o() { | ||
const i = [ | ||
function i() { | ||
const a = [ | ||
...t.names.map(f), | ||
...t.skips.map(f).map((u) => "-" + u) | ||
].join(","); | ||
return t.enable(""), i; | ||
return t.enable(""), a; | ||
} | ||
function l(i) { | ||
if (i[i.length - 1] === "*") | ||
function l(a) { | ||
if (a[a.length - 1] === "*") | ||
return !0; | ||
let u, d; | ||
for (u = 0, d = t.skips.length; u < d; u++) | ||
if (t.skips[u].test(i)) | ||
if (t.skips[u].test(a)) | ||
return !1; | ||
for (u = 0, d = t.names.length; u < d; u++) | ||
if (t.names[u].test(i)) | ||
if (t.names[u].test(a)) | ||
return !0; | ||
return !1; | ||
} | ||
function f(i) { | ||
return i.toString().substring(2, i.toString().length - 2).replace(/\.\*\?$/, "*"); | ||
function f(a) { | ||
return a.toString().substring(2, a.toString().length - 2).replace(/\.\*\?$/, "*"); | ||
} | ||
function c(i) { | ||
return i instanceof Error ? i.stack || i.message : i; | ||
function c(a) { | ||
return a instanceof Error ? a.stack || a.message : a; | ||
} | ||
@@ -620,5 +621,5 @@ function s() { | ||
} | ||
var Me = Ee; | ||
var Se = ke; | ||
(function(n, e) { | ||
e.formatArgs = r, e.save = a, e.load = o, e.useColors = t, e.storage = l(), e.destroy = (() => { | ||
e.formatArgs = r, e.save = o, e.load = i, e.useColors = t, e.storage = l(), e.destroy = (() => { | ||
let c = !1; | ||
@@ -718,5 +719,5 @@ return () => { | ||
c.splice(1, 0, s, "color: inherit"); | ||
let i = 0, u = 0; | ||
let a = 0, u = 0; | ||
c[0].replace(/%[a-zA-Z%]/g, (d) => { | ||
d !== "%%" && (i++, d === "%c" && (u = i)); | ||
d !== "%%" && (a++, d === "%c" && (u = a)); | ||
}), c.splice(u, 0, s); | ||
@@ -726,3 +727,3 @@ } | ||
}); | ||
function a(c) { | ||
function o(c) { | ||
try { | ||
@@ -733,3 +734,3 @@ c ? e.storage.setItem("debug", c) : e.storage.removeItem("debug"); | ||
} | ||
function o() { | ||
function i() { | ||
let c; | ||
@@ -748,3 +749,3 @@ try { | ||
} | ||
n.exports = Me(e); | ||
n.exports = Se(e); | ||
const { formatters: f } = n.exports; | ||
@@ -759,26 +760,27 @@ f.j = function(c) { | ||
})(q, q.exports); | ||
var ke = q.exports; | ||
const Se = /* @__PURE__ */ _e(ke); | ||
function Pe(n) { | ||
return Se("jenesius-vue-modal:".concat(n)); | ||
var Pe = q.exports; | ||
const Ae = /* @__PURE__ */ Ee(Pe); | ||
function Re(n) { | ||
return Ae("jenesius-vue-modal:".concat(n)); | ||
} | ||
const Ae = ["onPointerdown"], X = /* @__PURE__ */ ue({ | ||
const Ne = ["onPointerdown"], X = /* @__PURE__ */ ue({ | ||
__name: "WidgetModalContainerItem", | ||
props: { | ||
id: {} | ||
id: {}, | ||
show: { type: Boolean } | ||
}, | ||
setup(n) { | ||
const e = Pe("modal-item"), t = n, r = te(t.id), a = x(), o = x(); | ||
const e = Re("modal-item"), t = n, r = te(t.id), o = x(), i = x(); | ||
function l() { | ||
if (r.backgroundClose) | ||
return L(r.id, { background: !0 }).catch(() => { | ||
return B(r.id, { background: !0 }).catch(() => { | ||
}); | ||
} | ||
H(() => o.value, (c) => { | ||
H(() => i.value, (c) => { | ||
var s; | ||
if (r.instance = c, e(`Modal(${r.id}) instance is saved.`), r.draggable) { | ||
const i = `[modalid=_modal_${t.id}]`, u = typeof r.draggable == "string" ? r.draggable : i; | ||
e(`The modal window is movable(${u}).`), a.value ? (e("Finding an item to drag: %s", u), f( | ||
(s = a.value) == null ? void 0 : s.querySelector(i), | ||
a.value.querySelector(u) | ||
const a = `[modalid=_modal_${t.id}]`, u = typeof r.draggable == "string" ? r.draggable : a; | ||
e(`The modal window is movable(${u}).`), o.value ? (e("Finding an item to drag: %s", u), f( | ||
(s = o.value) == null ? void 0 : s.querySelector(a), | ||
o.value.querySelector(u) | ||
)) : e("The modal container is not mounted. Modal id %d.", r.id); | ||
@@ -798,8 +800,8 @@ } | ||
} | ||
s.addEventListener("pointerdown", (i) => { | ||
s.addEventListener("pointerdown", (a) => { | ||
var k; | ||
const u = (k = c.getAttribute("style")) == null ? void 0 : k.match(/transform: translate\((.*)px,\s*(.*)px\)/), d = u == null ? void 0 : u[1], g = u == null ? void 0 : u[2]; | ||
let E = typeof d == "string" ? Number.parseInt(d) : 0, m = typeof g == "string" ? Number.parseInt(g) : 0; | ||
const { clientX: h, clientY: p } = i, M = h, P = p; | ||
e(`movement started at (${P}, ${P})`), document.addEventListener("pointermove", b, { passive: !0 }), document.addEventListener("pointerup", B, { once: !0 }); | ||
const { clientX: h, clientY: C } = a, M = h, P = C; | ||
e(`movement started at (${P}, ${P})`), document.addEventListener("pointermove", b, { passive: !0 }), document.addEventListener("pointerup", L, { once: !0 }); | ||
function b(A) { | ||
@@ -809,3 +811,3 @@ const { clientX: N, clientY: O } = A, $ = E + N - M, z = m + O - P; | ||
} | ||
function B(A) { | ||
function L(A) { | ||
e("movement completed"), document.removeEventListener("pointermove", b), A.preventDefault(); | ||
@@ -815,26 +817,28 @@ } | ||
} | ||
return (c, s) => (U(), se("div", { | ||
return (c, s) => se((U(), ce("div", { | ||
class: "widget__modal-container__item modal-container", | ||
onPointerdown: ce(l, ["self", "stop"]), | ||
onPointerdown: le(l, ["self", "stop"]), | ||
ref_key: "modalContainerRef", | ||
ref: a | ||
ref: o | ||
}, [ | ||
(U(), le(de(T(r).component), fe(T(r).props.value, { | ||
(U(), de(fe(T(r).component), he(T(r).props.value, { | ||
class: "modal-item widget__modal-wrap", | ||
modalId: `_modal_${c.id}`, | ||
ref_key: "modalRef", | ||
ref: o | ||
}, he(T(r).events)), null, 16, ["modalId"])) | ||
], 40, Ae)); | ||
ref: i | ||
}, me(T(r).events)), null, 16, ["modalId"])) | ||
], 40, Ne)), [ | ||
[ve, c.show] | ||
]); | ||
} | ||
}); | ||
function Re(n) { | ||
function Ie(n) { | ||
n === void 0 && (n = S.DEFAULT_NAMESPACE); | ||
var e = S.instance.getByName(n); | ||
e.initialized = !0, n === S.DEFAULT_NAMESPACE && document.addEventListener("keyup", function(t) { | ||
if (C.escClose && (t.key === "Escape" || t.code === "Escape")) { | ||
if (p.escClose && (t.key === "Escape" || t.code === "Escape")) { | ||
var r = re(n); | ||
if (!r) | ||
return; | ||
L(r.id, { esc: !0 }).catch(function() { | ||
B(r.id, { esc: !0 }).catch(function() { | ||
}); | ||
@@ -844,3 +848,3 @@ } | ||
} | ||
const qe = { | ||
const Le = { | ||
props: { | ||
@@ -851,9 +855,10 @@ namespace: String | ||
return Z(() => { | ||
Re(n.namespace); | ||
Ie(n.namespace); | ||
}), () => { | ||
const e = y(n.namespace); | ||
return G(me, { name: C.animation, tag: "div", appear: C.appear }, { | ||
default: () => e.queue.map((t) => G(X, { | ||
return G(ge, { name: p.animation, tag: "div", appear: p.appear }, { | ||
default: () => e.queue.map((t, r, o) => G(X, { | ||
key: t.id, | ||
id: t.id | ||
id: t.id, | ||
show: p.singleShow === !0 ? r === o.length - 1 : !0 | ||
})) | ||
@@ -868,3 +873,3 @@ }); | ||
}; | ||
function Ne(n) { | ||
function Oe(n) { | ||
var e = this; | ||
@@ -875,4 +880,4 @@ if (R.router) | ||
function t(r) { | ||
for (var a = r.matched.length - 1; a >= 0; a--) { | ||
var o = r.matched[a].components, l = Object.values(o).find(function(f) { | ||
for (var o = r.matched.length - 1; o >= 0; o--) { | ||
var i = r.matched[o].components, l = Object.values(i).find(function(f) { | ||
return f._isModal; | ||
@@ -885,9 +890,9 @@ }); | ||
} | ||
n.beforeEach(function(r, a) { | ||
n.beforeEach(function(r, o) { | ||
return _(e, void 0, void 0, function() { | ||
var o, l, f; | ||
var i, l, f; | ||
return F(this, function(c) { | ||
switch (c.label) { | ||
case 0: | ||
return c.trys.push([0, 3, , 4]), o = t(a), o && !(!((f = (l = o.getModalObject()) === null || l === void 0 ? void 0 : l.closed) === null || f === void 0) && f.value) ? [4, o.close(!0)] : [3, 2]; | ||
return c.trys.push([0, 3, , 4]), i = t(o), i && !(!((f = (l = i.getModalObject()) === null || l === void 0 ? void 0 : l.closed) === null || f === void 0) && f.value) ? [4, i.close(!0)] : [3, 2]; | ||
case 1: | ||
@@ -909,9 +914,9 @@ c.sent(), c.label = 2; | ||
return _(e, void 0, void 0, function() { | ||
var a; | ||
return F(this, function(o) { | ||
switch (o.label) { | ||
var o; | ||
return F(this, function(i) { | ||
switch (i.label) { | ||
case 0: | ||
return a = t(r), a ? [4, a.initialize()] : [3, 2]; | ||
return o = t(r), o ? [4, o.initialize()] : [3, 2]; | ||
case 1: | ||
o.sent(), o.label = 2; | ||
i.sent(), i.label = 2; | ||
case 2: | ||
@@ -927,19 +932,19 @@ return [ | ||
} | ||
function Ie(n) { | ||
function Te(n) { | ||
var e = null, t = !1; | ||
function r() { | ||
return _(this, void 0, void 0, function() { | ||
return F(this, function(a) { | ||
switch (a.label) { | ||
return F(this, function(o) { | ||
switch (o.label) { | ||
case 0: | ||
if (!R.router) | ||
throw v.ModalRouterIntegrationNotInitialized(); | ||
return t = !1, e = null, [4, be(n, J(function() { | ||
var o; | ||
return (o = R.router) === null || o === void 0 ? void 0 : o.currentRoute.value.params; | ||
return t = !1, e = null, [4, _e(n, J(function() { | ||
var i; | ||
return (i = R.router) === null || i === void 0 ? void 0 : i.currentRoute.value.params; | ||
}), { isRoute: !0 })]; | ||
case 1: | ||
return e = a.sent(), e.onclose = function() { | ||
var o; | ||
t || (o = R.router) === null || o === void 0 || o.back(); | ||
return e = o.sent(), e.onclose = function() { | ||
var i; | ||
t || (i = R.router) === null || i === void 0 || i.back(); | ||
}, [ | ||
@@ -962,10 +967,10 @@ 2 | ||
_isModal: !0, | ||
close: function(a) { | ||
return a === void 0 && (a = !1), _(this, void 0, void 0, function() { | ||
return F(this, function(o) { | ||
switch (o.label) { | ||
close: function(o) { | ||
return o === void 0 && (o = !1), _(this, void 0, void 0, function() { | ||
return F(this, function(i) { | ||
switch (i.label) { | ||
case 0: | ||
return t = a, e ? [4, e.close()] : [3, 2]; | ||
return t = o, e ? [4, e.close()] : [3, 2]; | ||
case 1: | ||
return [2, o.sent()]; | ||
return [2, i.sent()]; | ||
case 2: | ||
@@ -995,5 +1000,5 @@ return [ | ||
} | ||
Ie.init = Ne; | ||
var Le = y().queue; | ||
function Be(n) { | ||
Te.init = Oe; | ||
var $e = y().queue; | ||
function ze(n) { | ||
return y(n).queue; | ||
@@ -1003,17 +1008,17 @@ } | ||
I as Modal, | ||
L as closeById, | ||
Ce as closeModal, | ||
je as config, | ||
qe as container, | ||
we as getComponentFromStore, | ||
B as closeById, | ||
be as closeModal, | ||
De as config, | ||
Le as container, | ||
Fe as getComponentFromStore, | ||
re as getCurrentModal, | ||
Be as getQueueByNamespace, | ||
Le as modalQueue, | ||
xe as onBeforeModalClose, | ||
be as openModal, | ||
Te as popModal, | ||
De as promptModal, | ||
ze as getQueueByNamespace, | ||
$e as modalQueue, | ||
qe as onBeforeModalClose, | ||
_e as openModal, | ||
xe as popModal, | ||
Be as promptModal, | ||
oe as pushModal, | ||
Ie as useModalRouter | ||
Te as useModalRouter | ||
}; | ||
//# sourceMappingURL=jenesius-vue-modal.es.js.map |
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".modal-container{position:fixed;left:0;top:0;height:100%;width:100%;display:flex;align-items:center;justify-content:center;background-color:#3e3e3e21;cursor:pointer}.modal-item{cursor:default}.modal-list-enter-active,.modal-list-leave-active,.modal-list-enter-active .modal-item,.modal-list-leave-active .modal-item{transition:all .2s ease}.modal-list-enter-from,.modal-list-leave-to{opacity:0!important}.modal-list-enter-from .modal-item,.modal-list-leave-to .modal-item{transform:translateY(-60px)}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})(); | ||
(function(m,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],f):(m=typeof globalThis<"u"?globalThis:m||self,f(m.JenesiusVueModal={},m.Vue))})(this,function(m,f){"use strict";/*! | ||
* jenesius-vue-modal v1.11.7 | ||
* jenesius-vue-modal v1.11.8 | ||
* (c) 2024 Jenesius | ||
* @license MIT | ||
*/var D=function(n,e){return D=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])},D(n,e)};function re(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");D(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function _(n,e,t,r){function a(o){return o instanceof t?o:new t(function(l){l(o)})}return new(t||(t=Promise))(function(o,l){function h(i){try{s(r.next(i))}catch(u){l(u)}}function c(i){try{s(r.throw(i))}catch(u){l(u)}}function s(i){i.done?o(i.value):a(i.value).then(h,c)}s((r=r.apply(n,e||[])).next())})}function F(n,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,a,o,l;return l={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function h(s){return function(i){return c([s,i])}}function c(s){if(r)throw new TypeError("Generator is already executing.");for(;l&&(l=0,s[0]&&(t=0)),t;)try{if(r=1,a&&(o=s[0]&2?a.return:s[0]?a.throw||((o=a.return)&&o.call(a),0):a.next)&&!(o=o.call(a,s[1])).done)return o;switch(a=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return t.label++,{value:s[1],done:!1};case 5:t.label++,a=s[1],s=[0];continue;case 7:s=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){t.label=s[1];break}if(s[0]===6&&t.label<o[1]){t.label=o[1],o=s;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(s);break}o[2]&&t.ops.pop(),t.trys.pop();continue}s=e.call(n,t)}catch(i){s=[6,i],a=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}typeof SuppressedError=="function"&&SuppressedError;var p=function(n){re(e,n);function e(t,r){r===void 0&&(r=null);var a=n.call(this)||this;return a.isModalError=!0,a.message=t,a.details=r,a}return e.Undefined=function(t){return new e("Modal with id: ".concat(t," not founded. The modal window may have been closed earlier."))},e.UndefinedGuardName=function(t){return new e("Guard's name ".concat(t," is not declaration."))},e.NextReject=function(t){return new e("Guard returned false. Modal navigation was stopped. Modal id ".concat(t))},e.GuardDeclarationType=function(t){return new e("Guard's type should be a function. Provided:",t)},e.RejectedByBeforeEach=function(){return new e("The opening of the modal was stopped in beforeEach")},e.ConfigurationType=function(t){return new e("Configuration type must be an Object. Provided",t)},e.ConfigurationUndefinedParam=function(t,r){return new e("In configuration founded unknown parameter: ".concat(t,". Available are ").concat(r.join(", ")," "))},e.QueueNoEmpty=function(){return new e("Modal's queue is not empty. Probably some modal reject closing by onClose hook.")},e.EmptyModalQueue=function(){return new e("Modal queue is empty.")},e.NotInitialized=function(t){return new e("Modal Container not found. Put container from jenesius-vue-modal in App's template. Namespace: ".concat(t,". Check documentation for more information https://modal.jenesius.com/docs.html/installation#getting-started."))},e.ModalComponentNotProvided=function(){return new e("The first parameter(VueComponent) was not specified.")},e.DuplicatedRouterIntegration=function(){return new e("useModalRouter.init should escaped only once.")},e.ModalRouterIntegrationNotInitialized=function(){return new e("The integration was not initialized. Please, use useModalRouter.init(router). For more information: https://modal.jenesius.com/docs.html/integration-vue-router#installation")},e.ModalEventNameMustBeString=function(t){return new e("Event name must be a string. Provided: ".concat(t))},e.ModalNotFoundByID=function(t){return new e("Modal with ID ".concat(t," was not found."))},e.ModalNotExistsInStore=function(t){return new e("Provided name(".concat(t,") don't exist in the store. Has the given name been added to the store?"))},e}(Error),k=function(){function n(){this.state=new Map,n.instance=this}return n.prototype.getByName=function(e){return e===void 0&&(e=n.DEFAULT_NAMESPACE),this.state.has(e)||this.state.set(e,{queue:f.reactive([]),initialized:!1}),this.state.get(e)},n.prototype.forceClean=function(){this.state.forEach(function(e){e.queue.splice(0,e.queue.length)})},n.DEFAULT_NAMESPACE="default",n}(),z=function(){var n=new k,e={scrollLock:!0,animation:"modal-list",backgroundClose:!0,escClose:!0,store:{},skipInitCheck:!1,draggable:!1,appear:!0,beforeEach:function(){}},t=n.getByName().queue;return f.watch(function(){return t},function(){e.scrollLock&&(t.length?document.body.style.overflowY="hidden":document.body.style.overflowY="auto")},{deep:!0}),{namespaceStore:n,configuration:e}}();function y(n){return z.namespaceStore.getByName(n)}var b=z.configuration;function U(n){var e={backgroundClose:b.backgroundClose,isRoute:!1,namespace:k.DEFAULT_NAMESPACE,draggable:b.draggable};return n.backgroundClose!==void 0&&(e.backgroundClose=n.backgroundClose),n.isRoute&&(e.isRoute=n.isRoute),n.namespace&&(e.namespace=n.namespace),n.draggable!==void 0&&(e.draggable=n.draggable),e}function G(n){n===void 0&&(n={});var e={background:!1,esc:!1};return Object.assign(e,n)}function Q(n){return n||(n={}),n}function T(n,e){e===void 0&&(e={});var t=A.STORE.get(n);if(!t)return Promise.reject(p.ModalNotFoundByID(n));var r=y(t.namespace),a=r.queue.findIndex(function(l){return l.id===n});if(a===-1)return Promise.reject(p.Undefined(n));var o=M.get(n,"close").map(function(l){return ie(l,n,G(e))});return X(o).then(function(){r.queue.splice(a,1)}).then(function(){M.get(n,"destroy").forEach(function(l){return l(G(e))})}).then(function(){M.delete(n)})}var A=function(){function n(e,t,r){var a=this;this.events=f.reactive({}),this.backgroundClose=!0,this.isRoute=!1,this.id=n.modalId++,this.component=e,this.props=f.ref(t),this.closed=f.computed(function(){return!y(r.namespace).queue.includes(a)}),e.beforeModalClose&&M.add(this.id,"close",e.beforeModalClose);var o=U(r);this.backgroundClose=o.backgroundClose,this.isRoute=o.isRoute,this.namespace=o.namespace,this.draggable=o.draggable,n.STORE.set(this.id,this)}return n.prototype.close=function(){return T(this.id)},Object.defineProperty(n.prototype,"onclose",{set:function(e){M.add(this.id,"close",e)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ondestroy",{set:function(e){M.add(this.id,"destroy",e)},enumerable:!1,configurable:!0}),n.prototype.on=function(e,t){var r=this;return Array.isArray(this.events[e])||(this.events[e]=[]),this.events[e].push(t),function(){var a=r.events[e].indexOf(t);a!==-1&&r.events[e].splice(a,1)}},n.STORE=new Map,n.modalId=0,n.EVENT_PROMPT="jenesius-vue-modal:____P____R____O____M____P____T",n}();function Y(n){return A.STORE.get(n)}var oe={store:{},add:function(n,e,t){var r,a;if(typeof t!="function")throw p.GuardDeclarationType(t);this.store[n]||(this.store[n]=(r={},r[e]=[],r)),this.store[n][e]||(this.store[n][e]=[]),(a=this.store[n][e])===null||a===void 0||a.push(t)},get:function(n,e){return n in this.store?e in this.store[n]?this.store[n][e]||[]:[]:[]},delete:function(n){n in this.store&&delete this.store[n]}};const M=oe;function X(n){return n.reduce(function(e,t){return e.then(function(){return t()})},Promise.resolve())}function ie(n,e,t){return function(){return new Promise(function(r,a){var o,l=function(h){h===void 0&&(h=!0),h===!1&&a(p.NextReject(e)),r()};Promise.resolve(n.call((o=Y(e))===null||o===void 0?void 0:o.instance,t)).then(l).catch(function(h){return a(h)})})}}function W(n){return n=Q(n),X(y(n.namespace).queue.map(function(e){return function(){return e.close()}}))}function B(n){var e=y(n),t=e.queue;if(t.length!==0)return t[t.length-1]}function ae(n){n=Q(n);var e=B(n.namespace);return e?e.close():Promise.resolve()}function ue(n,e,t){return _(this,void 0,void 0,function(){var r,a,o,l;return F(this,function(h){switch(h.label){case 0:if(r=U(t),a=y(r.namespace),r.namespace===k.DEFAULT_NAMESPACE&&!a.initialized&&!b.skipInitCheck)throw p.NotInitialized(r.namespace);return[4,b.beforeEach()];case 1:if(h.sent()===!1)throw p.RejectedByBeforeEach();if(typeof n=="string"){if(o=H(n),!o)throw p.ModalNotExistsInStore(n);n=o}if(!n)throw p.ModalComponentNotProvided();return l=new A(n,e,r),a.queue.push(f.markRaw(l)),[2,l]}})})}function q(n,e,t){return e===void 0&&(e={}),t===void 0&&(t={}),Promise.resolve().then(function(){return ue(n,e,t)})}function J(n,e,t){return e===void 0&&(e={}),t===void 0&&(t={}),W({namespace:t.namespace}).then(function(){var r=y(t.namespace);if(r.queue.length)throw p.QueueNoEmpty()}).then(function(){return q(n,e,t)})}function se(n){if(typeof n!="object")throw p.ConfigurationType(n);Object.assign(b,n)}function ce(n){var e,t,r,a=f.getCurrentInstance(),o=String(((e=a==null?void 0:a.props)===null||e===void 0?void 0:e.modalId)||((t=a==null?void 0:a.props)===null||t===void 0?void 0:t["modal-id"])||((r=a==null?void 0:a.attrs)===null||r===void 0?void 0:r.modalId)),l=o.replace(/[^0-9]/g,"");M.add(Number(l),"close",n)}function le(n,e,t){return e===void 0&&(e={}),t===void 0&&(t={}),_(this,void 0,void 0,function(){var r,a,o=this;return F(this,function(l){switch(l.label){case 0:return[4,q(n,e,t)];case 1:return r=l.sent(),a=!1,[2,new Promise(function(h){r.on(A.EVENT_PROMPT,function(c){return _(o,void 0,void 0,function(){return F(this,function(s){return a=!0,[2,r.close().then(function(){return h(c)}).catch(function(){return a=!1})]})})}),r.ondestroy=function(){a||h(null)}})]}})})}function H(n){return b.store[n]||void 0}function de(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var L={exports:{}},$,V;function fe(){if(V)return $;V=1;var n=1e3,e=n*60,t=e*60,r=t*24,a=r*7,o=r*365.25;$=function(i,u){u=u||{};var d=typeof i;if(d==="string"&&i.length>0)return l(i);if(d==="number"&&isFinite(i))return u.long?c(i):h(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function l(i){if(i=String(i),!(i.length>100)){var u=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(u){var d=parseFloat(u[1]),v=(u[2]||"ms").toLowerCase();switch(v){case"years":case"year":case"yrs":case"yr":case"y":return d*o;case"weeks":case"week":case"w":return d*a;case"days":case"day":case"d":return d*r;case"hours":case"hour":case"hrs":case"hr":case"h":return d*t;case"minutes":case"minute":case"mins":case"min":case"m":return d*e;case"seconds":case"second":case"secs":case"sec":case"s":return d*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return d;default:return}}}}function h(i){var u=Math.abs(i);return u>=r?Math.round(i/r)+"d":u>=t?Math.round(i/t)+"h":u>=e?Math.round(i/e)+"m":u>=n?Math.round(i/n)+"s":i+"ms"}function c(i){var u=Math.abs(i);return u>=r?s(i,u,r,"day"):u>=t?s(i,u,t,"hour"):u>=e?s(i,u,e,"minute"):u>=n?s(i,u,n,"second"):i+" ms"}function s(i,u,d,v){var S=u>=d*1.5;return Math.round(i/d)+" "+v+(S?"s":"")}return $}function he(n){t.debug=t,t.default=t,t.coerce=c,t.disable=o,t.enable=a,t.enabled=l,t.humanize=fe(),t.destroy=s,Object.keys(n).forEach(i=>{t[i]=n[i]}),t.names=[],t.skips=[],t.formatters={};function e(i){let u=0;for(let d=0;d<i.length;d++)u=(u<<5)-u+i.charCodeAt(d),u|=0;return t.colors[Math.abs(u)%t.colors.length]}t.selectColor=e;function t(i){let u,d=null,v,S;function C(...g){if(!C.enabled)return;const w=C,P=Number(new Date),I=P-(u||P);w.diff=I,w.prev=u,w.curr=P,u=P,g[0]=t.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let E=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(R,O)=>{if(R==="%%")return"%";E++;const j=t.formatters[O];if(typeof j=="function"){const x=g[E];R=j.call(w,x),g.splice(E,1),E--}return R}),t.formatArgs.call(w,g),(w.log||t.log).apply(w,g)}return C.namespace=i,C.useColors=t.useColors(),C.color=t.selectColor(i),C.extend=r,C.destroy=t.destroy,Object.defineProperty(C,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(v!==t.namespaces&&(v=t.namespaces,S=t.enabled(i)),S),set:g=>{d=g}}),typeof t.init=="function"&&t.init(C),C}function r(i,u){const d=t(this.namespace+(typeof u>"u"?":":u)+i);return d.log=this.log,d}function a(i){t.save(i),t.namespaces=i,t.names=[],t.skips=[];let u;const d=(typeof i=="string"?i:"").split(/[\s,]+/),v=d.length;for(u=0;u<v;u++)d[u]&&(i=d[u].replace(/\*/g,".*?"),i[0]==="-"?t.skips.push(new RegExp("^"+i.slice(1)+"$")):t.names.push(new RegExp("^"+i+"$")))}function o(){const i=[...t.names.map(h),...t.skips.map(h).map(u=>"-"+u)].join(",");return t.enable(""),i}function l(i){if(i[i.length-1]==="*")return!0;let u,d;for(u=0,d=t.skips.length;u<d;u++)if(t.skips[u].test(i))return!1;for(u=0,d=t.names.length;u<d;u++)if(t.names[u].test(i))return!0;return!1}function h(i){return i.toString().substring(2,i.toString().length-2).replace(/\.\*\?$/,"*")}function c(i){return i instanceof Error?i.stack||i.message:i}function s(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}var me=he;(function(n,e){e.formatArgs=r,e.save=a,e.load=o,e.useColors=t,e.storage=l(),e.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function t(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+n.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;c.splice(1,0,s,"color: inherit");let i=0,u=0;c[0].replace(/%[a-zA-Z%]/g,d=>{d!=="%%"&&(i++,d==="%c"&&(u=i))}),c.splice(u,0,s)}e.log=console.debug||console.log||(()=>{});function a(c){try{c?e.storage.setItem("debug",c):e.storage.removeItem("debug")}catch{}}function o(){let c;try{c=e.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function l(){try{return localStorage}catch{}}n.exports=me(e);const{formatters:h}=n.exports;h.j=function(c){try{return JSON.stringify(c)}catch(s){return"[UnexpectedJSONParseError]: "+s.message}}})(L,L.exports);var ge=L.exports;const pe=de(ge);function Ce(n){return pe("jenesius-vue-modal:".concat(n))}const ve=["onPointerdown"],Z=f.defineComponent({__name:"WidgetModalContainerItem",props:{id:{}},setup(n){const e=Ce("modal-item"),t=n,r=Y(t.id),a=f.ref(),o=f.ref();function l(){if(r.backgroundClose)return T(r.id,{background:!0}).catch(()=>{})}f.watch(()=>o.value,c=>{var s;if(r.instance=c,e(`Modal(${r.id}) instance is saved.`),r.draggable){const i=`[modalid=_modal_${t.id}]`,u=typeof r.draggable=="string"?r.draggable:i;e(`The modal window is movable(${u}).`),a.value?(e("Finding an item to drag: %s",u),h((s=a.value)==null?void 0:s.querySelector(i),a.value.querySelector(u))):e("The modal container is not mounted. Modal id %d.",r.id)}}),f.onMounted(()=>{e(`Modal(${r.id}) is mounted`)});function h(c,s){if(!s){e("draggable item not found.");return}if(!c){e("HTML modal is not founded.");return}s.addEventListener("pointerdown",i=>{var R;const u=(R=c.getAttribute("style"))==null?void 0:R.match(/transform: translate\((.*)px,\s*(.*)px\)/),d=u==null?void 0:u[1],v=u==null?void 0:u[2];let S=typeof d=="string"?Number.parseInt(d):0,C=typeof v=="string"?Number.parseInt(v):0;const{clientX:g,clientY:w}=i,P=g,I=w;e(`movement started at (${I}, ${I})`),document.addEventListener("pointermove",E,{passive:!0}),document.addEventListener("pointerup",ee,{once:!0});function E(O){const{clientX:j,clientY:x}=O,te=S+j-P,ne=C+x-I;e(`move at (${te}, ${ne})`),c.style.transform=`translate(${te}px,${ne}px)`}function ee(O){e("movement completed"),document.removeEventListener("pointermove",E),O.preventDefault()}})}return(c,s)=>(f.openBlock(),f.createElementBlock("div",{class:"widget__modal-container__item modal-container",onPointerdown:f.withModifiers(l,["self","stop"]),ref_key:"modalContainerRef",ref:a},[(f.openBlock(),f.createBlock(f.resolveDynamicComponent(f.unref(r).component),f.mergeProps(f.unref(r).props.value,{class:"modal-item widget__modal-wrap",modalId:`_modal_${c.id}`,ref_key:"modalRef",ref:o},f.toHandlers(f.unref(r).events)),null,16,["modalId"]))],40,ve))}}),Me="";function ye(n){n===void 0&&(n=k.DEFAULT_NAMESPACE);var e=k.instance.getByName(n);e.initialized=!0,n===k.DEFAULT_NAMESPACE&&document.addEventListener("keyup",function(t){if(b.escClose&&(t.key==="Escape"||t.code==="Escape")){var r=B(n);if(!r)return;T(r.id,{esc:!0}).catch(function(){})}})}const Ee="",be={props:{namespace:String},setup(n){return f.onMounted(()=>{ye(n.namespace)}),()=>{const e=y(n.namespace);return f.h(f.TransitionGroup,{name:b.animation,tag:"div",appear:b.appear},{default:()=>e.queue.map(t=>f.h(Z,{key:t.id,id:t.id}))})}},components:{WidgetContainerModalItem:Z}};var N={router:null};function we(n){var e=this;if(N.router)throw p.DuplicatedRouterIntegration();N.router=n;function t(r){for(var a=r.matched.length-1;a>=0;a--){var o=r.matched[a].components,l=Object.values(o).find(function(h){return h._isModal});if(l)return l}return null}n.beforeEach(function(r,a){return _(e,void 0,void 0,function(){var o,l,h;return F(this,function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),o=t(a),o&&!(!((h=(l=o.getModalObject())===null||l===void 0?void 0:l.closed)===null||h===void 0)&&h.value)?[4,o.close(!0)]:[3,2];case 1:c.sent(),c.label=2;case 2:return[3,4];case 3:return c.sent(),[2,!1];case 4:return[2]}})})}),n.afterEach(function(r){return _(e,void 0,void 0,function(){var a;return F(this,function(o){switch(o.label){case 0:return a=t(r),a?[4,a.initialize()]:[3,2];case 1:o.sent(),o.label=2;case 2:return[2]}})})})}function K(n){var e=null,t=!1;function r(){return _(this,void 0,void 0,function(){return F(this,function(a){switch(a.label){case 0:if(!N.router)throw p.ModalRouterIntegrationNotInitialized();return t=!1,e=null,[4,J(n,f.computed(function(){var o;return(o=N.router)===null||o===void 0?void 0:o.currentRoute.value.params}),{isRoute:!0})];case 1:return e=a.sent(),e.onclose=function(){var o;t||(o=N.router)===null||o===void 0||o.back()},[2]}})})}return{getModalObject:function(){return e},_isModal:!0,close:function(a){return a===void 0&&(a=!1),_(this,void 0,void 0,function(){return F(this,function(o){switch(o.label){case 0:return t=a,e?[4,e.close()]:[3,2];case 1:return[2,o.sent()];case 2:return[2]}})})},initialize:r,setup:function(){return function(){return null}}}}K.init=we;var _e=y().queue;function Fe(n){return y(n).queue}m.Modal=A,m.closeById=T,m.closeModal=W,m.config=se,m.container=be,m.getComponentFromStore=H,m.getCurrentModal=B,m.getQueueByNamespace=Fe,m.modalQueue=_e,m.onBeforeModalClose=ce,m.openModal=J,m.popModal=ae,m.promptModal=le,m.pushModal=q,m.useModalRouter=K,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}); | ||
*/var D=function(n,e){return D=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])},D(n,e)};function re(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");D(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function _(n,e,t,r){function o(i){return i instanceof t?i:new t(function(l){l(i)})}return new(t||(t=Promise))(function(i,l){function h(a){try{s(r.next(a))}catch(u){l(u)}}function c(a){try{s(r.throw(a))}catch(u){l(u)}}function s(a){a.done?i(a.value):o(a.value).then(h,c)}s((r=r.apply(n,e||[])).next())})}function F(n,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,l;return l={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function h(s){return function(a){return c([s,a])}}function c(s){if(r)throw new TypeError("Generator is already executing.");for(;l&&(l=0,s[0]&&(t=0)),t;)try{if(r=1,o&&(i=s[0]&2?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[s[0]&2,i.value]),s[0]){case 0:case 1:i=s;break;case 4:return t.label++,{value:s[1],done:!1};case 5:t.label++,o=s[1],s=[0];continue;case 7:s=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){t.label=s[1];break}if(s[0]===6&&t.label<i[1]){t.label=i[1],i=s;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(s);break}i[2]&&t.ops.pop(),t.trys.pop();continue}s=e.call(n,t)}catch(a){s=[6,a],o=0}finally{r=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}typeof SuppressedError=="function"&&SuppressedError;var p=function(n){re(e,n);function e(t,r){r===void 0&&(r=null);var o=n.call(this)||this;return o.isModalError=!0,o.message=t,o.details=r,o}return e.Undefined=function(t){return new e("Modal with id: ".concat(t," not founded. The modal window may have been closed earlier."))},e.UndefinedGuardName=function(t){return new e("Guard's name ".concat(t," is not declaration."))},e.NextReject=function(t){return new e("Guard returned false. Modal navigation was stopped. Modal id ".concat(t))},e.GuardDeclarationType=function(t){return new e("Guard's type should be a function. Provided:",t)},e.RejectedByBeforeEach=function(){return new e("The opening of the modal was stopped in beforeEach")},e.ConfigurationType=function(t){return new e("Configuration type must be an Object. Provided",t)},e.ConfigurationUndefinedParam=function(t,r){return new e("In configuration founded unknown parameter: ".concat(t,". Available are ").concat(r.join(", ")," "))},e.QueueNoEmpty=function(){return new e("Modal's queue is not empty. Probably some modal reject closing by onClose hook.")},e.EmptyModalQueue=function(){return new e("Modal queue is empty.")},e.NotInitialized=function(t){return new e("Modal Container not found. Put container from jenesius-vue-modal in App's template. Namespace: ".concat(t,". Check documentation for more information https://modal.jenesius.com/docs.html/installation#getting-started."))},e.ModalComponentNotProvided=function(){return new e("The first parameter(VueComponent) was not specified.")},e.DuplicatedRouterIntegration=function(){return new e("useModalRouter.init should escaped only once.")},e.ModalRouterIntegrationNotInitialized=function(){return new e("The integration was not initialized. Please, use useModalRouter.init(router). For more information: https://modal.jenesius.com/docs.html/integration-vue-router#installation")},e.ModalEventNameMustBeString=function(t){return new e("Event name must be a string. Provided: ".concat(t))},e.ModalNotFoundByID=function(t){return new e("Modal with ID ".concat(t," was not found."))},e.ModalNotExistsInStore=function(t){return new e("Provided name(".concat(t,") don't exist in the store. Has the given name been added to the store?"))},e}(Error),S=function(){function n(){this.state=new Map,n.instance=this}return n.prototype.getByName=function(e){return e===void 0&&(e=n.DEFAULT_NAMESPACE),this.state.has(e)||this.state.set(e,{queue:f.reactive([]),initialized:!1}),this.state.get(e)},n.prototype.forceClean=function(){this.state.forEach(function(e){e.queue.splice(0,e.queue.length)})},n.DEFAULT_NAMESPACE="default",n}(),z=function(){var n=new S,e={scrollLock:!0,animation:"modal-list",backgroundClose:!0,escClose:!0,store:{},skipInitCheck:!1,draggable:!1,appear:!0,singleShow:!1,beforeEach:function(){}},t=n.getByName().queue;return f.watch(function(){return t},function(){e.scrollLock&&(t.length?document.body.style.overflowY="hidden":document.body.style.overflowY="auto")},{deep:!0}),{namespaceStore:n,configuration:e}}();function b(n){return z.namespaceStore.getByName(n)}var y=z.configuration;function U(n){var e={backgroundClose:y.backgroundClose,isRoute:!1,namespace:S.DEFAULT_NAMESPACE,draggable:y.draggable};return n.backgroundClose!==void 0&&(e.backgroundClose=n.backgroundClose),n.isRoute&&(e.isRoute=n.isRoute),n.namespace&&(e.namespace=n.namespace),n.draggable!==void 0&&(e.draggable=n.draggable),e}function G(n){n===void 0&&(n={});var e={background:!1,esc:!1};return Object.assign(e,n)}function Q(n){return n||(n={}),n}function T(n,e){e===void 0&&(e={});var t=A.STORE.get(n);if(!t)return Promise.reject(p.ModalNotFoundByID(n));var r=b(t.namespace),o=r.queue.findIndex(function(l){return l.id===n});if(o===-1)return Promise.reject(p.Undefined(n));var i=M.get(n,"close").map(function(l){return ie(l,n,G(e))});return X(i).then(function(){r.queue.splice(o,1)}).then(function(){M.get(n,"destroy").forEach(function(l){return l(G(e))})}).then(function(){M.delete(n)})}var A=function(){function n(e,t,r){var o=this;this.events=f.reactive({}),this.backgroundClose=!0,this.isRoute=!1,this.id=n.modalId++,this.component=e,this.props=f.ref(t),this.closed=f.computed(function(){return!b(r.namespace).queue.includes(o)}),e.beforeModalClose&&M.add(this.id,"close",e.beforeModalClose);var i=U(r);this.backgroundClose=i.backgroundClose,this.isRoute=i.isRoute,this.namespace=i.namespace,this.draggable=i.draggable,n.STORE.set(this.id,this)}return n.prototype.close=function(){return T(this.id)},Object.defineProperty(n.prototype,"onclose",{set:function(e){M.add(this.id,"close",e)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ondestroy",{set:function(e){M.add(this.id,"destroy",e)},enumerable:!1,configurable:!0}),n.prototype.on=function(e,t){var r=this;return Array.isArray(this.events[e])||(this.events[e]=[]),this.events[e].push(t),function(){var o=r.events[e].indexOf(t);o!==-1&&r.events[e].splice(o,1)}},n.STORE=new Map,n.modalId=0,n.EVENT_PROMPT="jenesius-vue-modal:____P____R____O____M____P____T",n}();function Y(n){return A.STORE.get(n)}var oe={store:{},add:function(n,e,t){var r,o;if(typeof t!="function")throw p.GuardDeclarationType(t);this.store[n]||(this.store[n]=(r={},r[e]=[],r)),this.store[n][e]||(this.store[n][e]=[]),(o=this.store[n][e])===null||o===void 0||o.push(t)},get:function(n,e){return n in this.store?e in this.store[n]?this.store[n][e]||[]:[]:[]},delete:function(n){n in this.store&&delete this.store[n]}};const M=oe;function X(n){return n.reduce(function(e,t){return e.then(function(){return t()})},Promise.resolve())}function ie(n,e,t){return function(){return new Promise(function(r,o){var i,l=function(h){h===void 0&&(h=!0),h===!1&&o(p.NextReject(e)),r()};Promise.resolve(n.call((i=Y(e))===null||i===void 0?void 0:i.instance,t)).then(l).catch(function(h){return o(h)})})}}function W(n){return n=Q(n),X(b(n.namespace).queue.map(function(e){return function(){return e.close()}}))}function B(n){var e=b(n),t=e.queue;if(t.length!==0)return t[t.length-1]}function ae(n){n=Q(n);var e=B(n.namespace);return e?e.close():Promise.resolve()}function ue(n,e,t){return _(this,void 0,void 0,function(){var r,o,i,l;return F(this,function(h){switch(h.label){case 0:if(r=U(t),o=b(r.namespace),r.namespace===S.DEFAULT_NAMESPACE&&!o.initialized&&!y.skipInitCheck)throw p.NotInitialized(r.namespace);return[4,y.beforeEach()];case 1:if(h.sent()===!1)throw p.RejectedByBeforeEach();if(typeof n=="string"){if(i=H(n),!i)throw p.ModalNotExistsInStore(n);n=i}if(!n)throw p.ModalComponentNotProvided();return l=new A(n,e,r),o.queue.push(f.markRaw(l)),[2,l]}})})}function q(n,e,t){return e===void 0&&(e={}),t===void 0&&(t={}),Promise.resolve().then(function(){return ue(n,e,t)})}function J(n,e,t){return e===void 0&&(e={}),t===void 0&&(t={}),W({namespace:t.namespace}).then(function(){var r=b(t.namespace);if(r.queue.length)throw p.QueueNoEmpty()}).then(function(){return q(n,e,t)})}function se(n){if(typeof n!="object")throw p.ConfigurationType(n);Object.assign(y,n)}function ce(n){var e,t,r,o=f.getCurrentInstance(),i=String(((e=o==null?void 0:o.props)===null||e===void 0?void 0:e.modalId)||((t=o==null?void 0:o.props)===null||t===void 0?void 0:t["modal-id"])||((r=o==null?void 0:o.attrs)===null||r===void 0?void 0:r.modalId)),l=i.replace(/[^0-9]/g,"");M.add(Number(l),"close",n)}function le(n,e,t){return e===void 0&&(e={}),t===void 0&&(t={}),_(this,void 0,void 0,function(){var r,o,i=this;return F(this,function(l){switch(l.label){case 0:return[4,q(n,e,t)];case 1:return r=l.sent(),o=!1,[2,new Promise(function(h){r.on(A.EVENT_PROMPT,function(c){return _(i,void 0,void 0,function(){return F(this,function(s){return o=!0,[2,r.close().then(function(){return h(c)}).catch(function(){return o=!1})]})})}),r.ondestroy=function(){o||h(null)}})]}})})}function H(n){return y.store[n]||void 0}function de(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var L={exports:{}},$,V;function fe(){if(V)return $;V=1;var n=1e3,e=n*60,t=e*60,r=t*24,o=r*7,i=r*365.25;$=function(a,u){u=u||{};var d=typeof a;if(d==="string"&&a.length>0)return l(a);if(d==="number"&&isFinite(a))return u.long?c(a):h(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))};function l(a){if(a=String(a),!(a.length>100)){var u=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(a);if(u){var d=parseFloat(u[1]),v=(u[2]||"ms").toLowerCase();switch(v){case"years":case"year":case"yrs":case"yr":case"y":return d*i;case"weeks":case"week":case"w":return d*o;case"days":case"day":case"d":return d*r;case"hours":case"hour":case"hrs":case"hr":case"h":return d*t;case"minutes":case"minute":case"mins":case"min":case"m":return d*e;case"seconds":case"second":case"secs":case"sec":case"s":return d*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return d;default:return}}}}function h(a){var u=Math.abs(a);return u>=r?Math.round(a/r)+"d":u>=t?Math.round(a/t)+"h":u>=e?Math.round(a/e)+"m":u>=n?Math.round(a/n)+"s":a+"ms"}function c(a){var u=Math.abs(a);return u>=r?s(a,u,r,"day"):u>=t?s(a,u,t,"hour"):u>=e?s(a,u,e,"minute"):u>=n?s(a,u,n,"second"):a+" ms"}function s(a,u,d,v){var k=u>=d*1.5;return Math.round(a/d)+" "+v+(k?"s":"")}return $}function he(n){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=l,t.humanize=fe(),t.destroy=s,Object.keys(n).forEach(a=>{t[a]=n[a]}),t.names=[],t.skips=[],t.formatters={};function e(a){let u=0;for(let d=0;d<a.length;d++)u=(u<<5)-u+a.charCodeAt(d),u|=0;return t.colors[Math.abs(u)%t.colors.length]}t.selectColor=e;function t(a){let u,d=null,v,k;function C(...g){if(!C.enabled)return;const w=C,P=Number(new Date),I=P-(u||P);w.diff=I,w.prev=u,w.curr=P,u=P,g[0]=t.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let E=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(R,O)=>{if(R==="%%")return"%";E++;const j=t.formatters[O];if(typeof j=="function"){const x=g[E];R=j.call(w,x),g.splice(E,1),E--}return R}),t.formatArgs.call(w,g),(w.log||t.log).apply(w,g)}return C.namespace=a,C.useColors=t.useColors(),C.color=t.selectColor(a),C.extend=r,C.destroy=t.destroy,Object.defineProperty(C,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(v!==t.namespaces&&(v=t.namespaces,k=t.enabled(a)),k),set:g=>{d=g}}),typeof t.init=="function"&&t.init(C),C}function r(a,u){const d=t(this.namespace+(typeof u>"u"?":":u)+a);return d.log=this.log,d}function o(a){t.save(a),t.namespaces=a,t.names=[],t.skips=[];let u;const d=(typeof a=="string"?a:"").split(/[\s,]+/),v=d.length;for(u=0;u<v;u++)d[u]&&(a=d[u].replace(/\*/g,".*?"),a[0]==="-"?t.skips.push(new RegExp("^"+a.slice(1)+"$")):t.names.push(new RegExp("^"+a+"$")))}function i(){const a=[...t.names.map(h),...t.skips.map(h).map(u=>"-"+u)].join(",");return t.enable(""),a}function l(a){if(a[a.length-1]==="*")return!0;let u,d;for(u=0,d=t.skips.length;u<d;u++)if(t.skips[u].test(a))return!1;for(u=0,d=t.names.length;u<d;u++)if(t.names[u].test(a))return!0;return!1}function h(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function c(a){return a instanceof Error?a.stack||a.message:a}function s(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}var me=he;(function(n,e){e.formatArgs=r,e.save=o,e.load=i,e.useColors=t,e.storage=l(),e.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function t(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+n.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;c.splice(1,0,s,"color: inherit");let a=0,u=0;c[0].replace(/%[a-zA-Z%]/g,d=>{d!=="%%"&&(a++,d==="%c"&&(u=a))}),c.splice(u,0,s)}e.log=console.debug||console.log||(()=>{});function o(c){try{c?e.storage.setItem("debug",c):e.storage.removeItem("debug")}catch{}}function i(){let c;try{c=e.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function l(){try{return localStorage}catch{}}n.exports=me(e);const{formatters:h}=n.exports;h.j=function(c){try{return JSON.stringify(c)}catch(s){return"[UnexpectedJSONParseError]: "+s.message}}})(L,L.exports);var ge=L.exports;const pe=de(ge);function Ce(n){return pe("jenesius-vue-modal:".concat(n))}const ve=["onPointerdown"],Z=f.defineComponent({__name:"WidgetModalContainerItem",props:{id:{},show:{type:Boolean}},setup(n){const e=Ce("modal-item"),t=n,r=Y(t.id),o=f.ref(),i=f.ref();function l(){if(r.backgroundClose)return T(r.id,{background:!0}).catch(()=>{})}f.watch(()=>i.value,c=>{var s;if(r.instance=c,e(`Modal(${r.id}) instance is saved.`),r.draggable){const a=`[modalid=_modal_${t.id}]`,u=typeof r.draggable=="string"?r.draggable:a;e(`The modal window is movable(${u}).`),o.value?(e("Finding an item to drag: %s",u),h((s=o.value)==null?void 0:s.querySelector(a),o.value.querySelector(u))):e("The modal container is not mounted. Modal id %d.",r.id)}}),f.onMounted(()=>{e(`Modal(${r.id}) is mounted`)});function h(c,s){if(!s){e("draggable item not found.");return}if(!c){e("HTML modal is not founded.");return}s.addEventListener("pointerdown",a=>{var R;const u=(R=c.getAttribute("style"))==null?void 0:R.match(/transform: translate\((.*)px,\s*(.*)px\)/),d=u==null?void 0:u[1],v=u==null?void 0:u[2];let k=typeof d=="string"?Number.parseInt(d):0,C=typeof v=="string"?Number.parseInt(v):0;const{clientX:g,clientY:w}=a,P=g,I=w;e(`movement started at (${I}, ${I})`),document.addEventListener("pointermove",E,{passive:!0}),document.addEventListener("pointerup",ee,{once:!0});function E(O){const{clientX:j,clientY:x}=O,te=k+j-P,ne=C+x-I;e(`move at (${te}, ${ne})`),c.style.transform=`translate(${te}px,${ne}px)`}function ee(O){e("movement completed"),document.removeEventListener("pointermove",E),O.preventDefault()}})}return(c,s)=>f.withDirectives((f.openBlock(),f.createElementBlock("div",{class:"widget__modal-container__item modal-container",onPointerdown:f.withModifiers(l,["self","stop"]),ref_key:"modalContainerRef",ref:o},[(f.openBlock(),f.createBlock(f.resolveDynamicComponent(f.unref(r).component),f.mergeProps(f.unref(r).props.value,{class:"modal-item widget__modal-wrap",modalId:`_modal_${c.id}`,ref_key:"modalRef",ref:i},f.toHandlers(f.unref(r).events)),null,16,["modalId"]))],40,ve)),[[f.vShow,c.show]])}}),Me="";function ye(n){n===void 0&&(n=S.DEFAULT_NAMESPACE);var e=S.instance.getByName(n);e.initialized=!0,n===S.DEFAULT_NAMESPACE&&document.addEventListener("keyup",function(t){if(y.escClose&&(t.key==="Escape"||t.code==="Escape")){var r=B(n);if(!r)return;T(r.id,{esc:!0}).catch(function(){})}})}const Ee="",be={props:{namespace:String},setup(n){return f.onMounted(()=>{ye(n.namespace)}),()=>{const e=b(n.namespace);return f.h(f.TransitionGroup,{name:y.animation,tag:"div",appear:y.appear},{default:()=>e.queue.map((t,r,o)=>f.h(Z,{key:t.id,id:t.id,show:y.singleShow===!0?r===o.length-1:!0}))})}},components:{WidgetContainerModalItem:Z}};var N={router:null};function we(n){var e=this;if(N.router)throw p.DuplicatedRouterIntegration();N.router=n;function t(r){for(var o=r.matched.length-1;o>=0;o--){var i=r.matched[o].components,l=Object.values(i).find(function(h){return h._isModal});if(l)return l}return null}n.beforeEach(function(r,o){return _(e,void 0,void 0,function(){var i,l,h;return F(this,function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),i=t(o),i&&!(!((h=(l=i.getModalObject())===null||l===void 0?void 0:l.closed)===null||h===void 0)&&h.value)?[4,i.close(!0)]:[3,2];case 1:c.sent(),c.label=2;case 2:return[3,4];case 3:return c.sent(),[2,!1];case 4:return[2]}})})}),n.afterEach(function(r){return _(e,void 0,void 0,function(){var o;return F(this,function(i){switch(i.label){case 0:return o=t(r),o?[4,o.initialize()]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}})})})}function K(n){var e=null,t=!1;function r(){return _(this,void 0,void 0,function(){return F(this,function(o){switch(o.label){case 0:if(!N.router)throw p.ModalRouterIntegrationNotInitialized();return t=!1,e=null,[4,J(n,f.computed(function(){var i;return(i=N.router)===null||i===void 0?void 0:i.currentRoute.value.params}),{isRoute:!0})];case 1:return e=o.sent(),e.onclose=function(){var i;t||(i=N.router)===null||i===void 0||i.back()},[2]}})})}return{getModalObject:function(){return e},_isModal:!0,close:function(o){return o===void 0&&(o=!1),_(this,void 0,void 0,function(){return F(this,function(i){switch(i.label){case 0:return t=o,e?[4,e.close()]:[3,2];case 1:return[2,i.sent()];case 2:return[2]}})})},initialize:r,setup:function(){return function(){return null}}}}K.init=we;var _e=b().queue;function Fe(n){return b(n).queue}m.Modal=A,m.closeById=T,m.closeModal=W,m.config=se,m.container=be,m.getComponentFromStore=H,m.getCurrentModal=B,m.getQueueByNamespace=Fe,m.modalQueue=_e,m.onBeforeModalClose=ce,m.openModal=J,m.popModal=ae,m.promptModal=le,m.pushModal=q,m.useModalRouter=K,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}); | ||
//# sourceMappingURL=jenesius-vue-modal.umd.js.map |
@@ -53,3 +53,8 @@ /** | ||
beforeEach: () => any; | ||
/** | ||
* @description If the value is set to true, then only one modal window will be shown. If several are opened | ||
* (using pushModal), only the last one will be shown, and the rest will be hidden using `v-show`. | ||
*/ | ||
singleShow: boolean; | ||
store: Record<string, Component>; | ||
} |
{ | ||
"name": "jenesius-vue-modal", | ||
"version": "1.11.7", | ||
"version": "1.11.8", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "The progressive and simple modal system for Vue.js v3", |
import {mount} from "@vue/test-utils"; | ||
import {closeModal, config, container, getQueueByNamespace, openModal, popModal} from "../src/index"; | ||
import {closeModal, config, container, getQueueByNamespace, openModal, popModal, pushModal} from "../src/index"; | ||
import wait from "./wait"; | ||
@@ -8,2 +8,3 @@ import ModalTitle from "./components/modal-title.vue"; | ||
import triggerClickClose from "./assets/trigger-click-close"; | ||
import WidgetModalContainerItem from "../src/components/WidgetModalContainerItem.vue"; | ||
@@ -142,3 +143,23 @@ const modalQueue = getQueueByNamespace(); | ||
test("SingleShow in configuration", async () => { | ||
const app = await mount(container); | ||
config({ | ||
singleShow: true | ||
}) | ||
await pushModal(ModalTitle) | ||
await pushModal(ModalTitle) | ||
await pushModal(ModalTitle) | ||
await pushModal(ModalTitle) | ||
expect(modalQueue.length).toBe(4); | ||
const arrayModalContainer = app.findAllComponents(WidgetModalContainerItem); | ||
arrayModalContainer.map(item => item.props('show')) | ||
.forEach((value, index, arr) => expect(value).toBe(index === arr.length - 1)) | ||
}) | ||
}) |
@@ -35,2 +35,3 @@ import {mount} from "@vue/test-utils"; | ||
// @ts-ignore | ||
const wrapper = await mount(App, { stubs: { | ||
@@ -37,0 +38,0 @@ transition: false |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
348681
2973