1 line
6.3 KiB
JavaScript
1 line
6.3 KiB
JavaScript
import{B as e,Ct as t,D as n,U as r,V as i,_t as a,dt as o,ft as s,gt as c,ht as l,mt as u,pt as d,st as f,t as p,vt as m,xt as h}from"./client-CO11mUW5.js";var g=typeof window<`u`,_,v=e=>_=e,y=Symbol();function b(e){return e&&typeof e==`object`&&Object.prototype.toString.call(e)===`[object Object]`&&typeof e.toJSON!=`function`}var x=typeof window==`object`&&window.window===window?window:typeof self==`object`&&self.self===self?self:typeof global==`object`&&global.global===global?global:typeof globalThis==`object`?globalThis:{HTMLElement:null};function S(e,{autoBom:t=!1}={}){return t&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([``,e],{type:e.type}):e}function C(e,t,n){let r=new XMLHttpRequest;r.open(`GET`,e),r.responseType=`blob`,r.onload=function(){O(r.response,t,n)},r.onerror=function(){console.error(`could not download file`)},r.send()}function w(e){let t=new XMLHttpRequest;t.open(`HEAD`,e,!1);try{t.send()}catch{}return t.status>=200&&t.status<=299}function T(e){try{e.dispatchEvent(new MouseEvent(`click`))}catch{let t=new MouseEvent(`click`,{bubbles:!0,cancelable:!0,view:window,detail:0,screenX:80,screenY:20,clientX:80,clientY:20,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:null});e.dispatchEvent(t)}}var E=typeof navigator==`object`?navigator:{userAgent:``},D=/Macintosh/.test(E.userAgent)&&/AppleWebKit/.test(E.userAgent)&&!/Safari/.test(E.userAgent),O=g?typeof HTMLAnchorElement<`u`&&`download`in HTMLAnchorElement.prototype&&!D?k:`msSaveOrOpenBlob`in E?A:j:()=>{};function k(e,t=`download`,n){let r=document.createElement(`a`);r.download=t,r.rel=`noopener`,typeof e==`string`?(r.href=e,r.origin===location.origin?T(r):w(r.href)?C(e,t,n):(r.target=`_blank`,T(r))):(r.href=URL.createObjectURL(e),setTimeout(function(){URL.revokeObjectURL(r.href)},4e4),setTimeout(function(){T(r)},0))}function A(e,t=`download`,n){if(typeof e==`string`){if(w(e))C(e,t,n);else{let t=document.createElement(`a`);t.href=e,t.target=`_blank`,setTimeout(function(){T(t)})}}else navigator.msSaveOrOpenBlob(S(e,n),t)}function j(e,t,n,r){if(r||=open(``,`_blank`),r&&(r.document.title=r.document.body.innerText=`downloading...`),typeof e==`string`)return C(e,t,n);let i=e.type===`application/octet-stream`,a=/constructor/i.test(String(x.HTMLElement))||`safari`in x,o=/CriOS\/[\d]+/.test(navigator.userAgent);if((o||i&&a||D)&&typeof FileReader<`u`){let t=new FileReader;t.onloadend=function(){let e=t.result;if(typeof e!=`string`)throw r=null,Error(`Wrong reader.result type`);e=o?e:e.replace(/^data:[^;]*;/,`data:attachment/file;`),r?r.location.href=e:location.assign(e),r=null},t.readAsDataURL(e)}else{let t=URL.createObjectURL(e);r?r.location.assign(t):location.href=t,r=null,setTimeout(function(){URL.revokeObjectURL(t)},4e4)}}var{assign:M}=Object;function N(){let e=o(!0),t=e.run(()=>m({})),n=[],r=[],i=l({install(e){v(i),i._a=e,e.provide(y,i),e.config.globalProperties.$pinia=i,r.forEach(e=>n.push(e)),r=[]},use(e){return this._a?n.push(e):r.push(e),this},_p:n,_a:null,_e:e,_s:new Map,state:t});return i}var P=()=>{};function F(e,t,n,r=P){e.add(t);let i=()=>{e.delete(t)&&r()};return!n&&s()&&c(i),i}function I(e,...t){e.forEach(e=>{e(...t)})}var L=e=>e(),R=Symbol(),z=Symbol();function B(e,t){e instanceof Map&&t instanceof Map?t.forEach((t,n)=>e.set(n,t)):e instanceof Set&&t instanceof Set&&t.forEach(e.add,e);for(let n in t){if(!Object.hasOwn(t,n))continue;let r=t[n],i=e[n];e[n]=b(i)&&b(r)&&Object.hasOwn(e,n)&&!u(r)&&!d(r)?B(i,r):r}return e}var V=Symbol();function H(e){return!e||typeof e!=`object`||!Object.hasOwn(e,V)}var{assign:U}=Object;function W(e){return!!(u(e)&&e.effect)}function G(e,r,i,a){let{state:o,actions:s,getters:c}=r,u=i.state.value[e],d;function f(){return u||(i.state.value[e]=o?o():{}),U(t(i.state.value[e]),s,Object.keys(c||{}).reduce((t,r)=>(t[r]=l(n(()=>{v(i);let t=i._s.get(e);return c[r].call(t,t)})),t),{}))}return d=K(e,f,r,i,a,!0),d}function K(e,t,n={},i,s,c){let l,p=U({actions:{}},n),m={deep:!0},g,_,y=new Set,b=new Set,x,S=i.state.value[e];!c&&!S&&(i.state.value[e]={});let C;function w(t){let n;g=_=!1,typeof t==`function`?(t(i.state.value[e]),n={type:`patch function`,storeId:e,events:x}):(B(i.state.value[e],t),n={type:`patch object`,payload:t,storeId:e,events:x});let a=C=Symbol();r().then(()=>{C===a&&(g=!0)}),_=!0,I(y,n,i.state.value[e])}let T=c?function(){let{state:e}=n,t=e?e():{};this.$patch(e=>{U(e,t)})}:P;function E(){l.stop(),y.clear(),b.clear(),i._s.delete(e)}let D=(t,n=``)=>{if(R in t)return t[z]=n,t;let r=function(){v(i);let n=Array.from(arguments),a=new Set,o=new Set;function s(e){a.add(e)}function c(e){o.add(e)}I(b,{args:n,name:r[z],store:k,after:s,onError:c});let l;try{l=t.apply(this&&this.$id===e?this:k,n)}catch(e){throw I(o,e),e}return l instanceof Promise?l.then(e=>(I(a,e),e)).catch(e=>(I(o,e),Promise.reject(e))):(I(a,l),l)};return r[R]=!0,r[z]=n,r},O={_p:i,$id:e,$onAction:F.bind(null,b),$patch:w,$reset:T,$subscribe(t,n={}){if(y.has(t))return P;let r=F(y,t,n.detached,()=>a()),a=l.run(()=>f(()=>i.state.value[e],r=>{(n.flush===`sync`?_:g)&&t({storeId:e,type:`direct`,events:x},r)},U({},m,n)));return r},$dispose:E},k=a(O);i._s.set(e,k);let A=(i._a&&i._a.runWithContext||L)(()=>i._e.run(()=>(l=o()).run(()=>t({action:D}))));for(let t in A){let n=A[t];u(n)&&!W(n)||d(n)?c||(S&&H(n)&&(u(n)?n.value=S[t]:B(n,S[t])),i.state.value[e][t]=n):typeof n==`function`&&(A[t]=D(n,t),p.actions[t]=n)}return U(k,A),U(h(k),A),Object.defineProperty(k,"$state",{get:()=>i.state.value[e],set:e=>{w(t=>{U(t,e)})}}),i._p.forEach(e=>{let t=l.run(()=>e({store:k,app:i._a,pinia:i,options:p}));U(k,t)}),S&&c&&n.hydrate&&n.hydrate(k.$state,S),g=!0,_=!0,k}function q(t,n,r){let a,o=typeof n==`function`;a=o?r:n;function s(r,s){let c=e();return r||=c?i(y,null):null,r&&v(r),r=_,r._s.has(t)||(o?K(t,n,a,r):G(t,a,r)),r._s.get(t)}return s.$id=t,s}var J=q(`auth`,()=>{let e=m(null),t=m(localStorage.getItem(`access_token`)||``),r=n(()=>!!t.value);async function i(n,r){let i=await p.post(`/auth/login`,{username:n,password:r});t.value=i.access_token,e.value=i.user,localStorage.setItem(`access_token`,i.access_token),localStorage.setItem(`refresh_token`,i.refresh_token)}async function a(){t.value&&(e.value=await p.get(`/auth/me`))}function o(){t.value=``,e.value=null,localStorage.removeItem(`access_token`),localStorage.removeItem(`refresh_token`)}return{user:e,token:t,authenticated:r,login:i,loadUser:a,logout:o}});export{N as n,J as t}; |