55 lines
78 KiB
JavaScript
55 lines
78 KiB
JavaScript
|
|
import{x as H,o as de,r as v,a9 as Ie,w as M,ao as X,j as e,y as I,z as P,v as L,ap as ue,aq as me,ar as fe,as as ge,a as he,M as mt,G as ft,L as gt,p as De,c as Xt,P as ze,at as Qt,d as Yt,au as Wt,O as Zt,av as en,g as tn,aw as nn,q as ht,I as pt,ax as z,C as rn,A as sn,a2 as an,b as Ne,B as ve,ay as on}from"./index-CZD3_4lD.js";import{S as q,D as ln,a as cn,b as dn,c as Ze,u as un,f as J,d as ke,e as mn,M as ne,g as et,P as tt,h as fn}from"./dropdown-menu-CFWQzY9-.js";import{B as Q}from"./badge-D3Mn__J4.js";import{d as gn,T as nt}from"./differenceInDays-BjWVl97D.js";import{G as xt}from"./gift-C8Ri1JSk.js";import{C as hn}from"./circle-check-60AjePHB.js";import{C as ae}from"./clock-CHYQgZWG.js";import{S as rt,F as pn,C as xn,H as yn}from"./star-DINAYY6y.js";import{Q as bn}from"./qr-code-J7tfaoiH.js";import{f as T,s as Y,e as yt,d as bt}from"./sv-KqUX0hpM.js";import{A as wt}from"./index-DXB3_sFe.js";import{C as wn}from"./check-CCL32zXH.js";import{H as jt}from"./heart-Bn8C2h_q.js";import{L as jn}from"./leaf-BV-5O-4e.js";import{G as Nn}from"./graduation-cap-TNnu1wlO.js";import{C as Pe}from"./chevron-down-DA--jGG2.js";import{E as vn}from"./external-link-DZgJPdR9.js";import{S as kn}from"./scroll-area-DdYSSeiY.js";import{I as Cn}from"./info-DLVcQf5T.js";import{F as st}from"./file-text-I90VDyBK.js";import{D as Sn}from"./download-JAaLZNwh.js";import{S as En}from"./send-DWELcW4W.js";import{C as An}from"./calendar-3jVgdv6R.js";import{B as Mn}from"./building-2-BpMHggJ8.js";import{T as Tn}from"./trending-up-CVyK6WFK.js";import{C as _n}from"./circle-alert-DFiBooaQ.js";import"./index-C6sfL5Wv.js";import"./chevron-right-Dvw0FPw3.js";import"./circle-CNf9xg3I.js";/**
|
||
|
|
* @license lucide-react v0.462.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const at=H("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]);/**
|
||
|
|
* @license lucide-react v0.462.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Bn=H("CircleArrowDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/**
|
||
|
|
* @license lucide-react v0.462.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const In=H("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/**
|
||
|
|
* @license lucide-react v0.462.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Dn=H("Droplets",[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]]);/**
|
||
|
|
* @license lucide-react v0.462.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Pn=H("Facebook",[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]]);/**
|
||
|
|
* @license lucide-react v0.462.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const ot=H("Medal",[["path",{d:"M7.21 15 2.66 7.14a2 2 0 0 1 .13-2.2L4.4 2.8A2 2 0 0 1 6 2h12a2 2 0 0 1 1.6.8l1.6 2.14a2 2 0 0 1 .14 2.2L16.79 15",key:"143lza"}],["path",{d:"M11 12 5.12 2.2",key:"qhuxz6"}],["path",{d:"m13 12 5.88-9.8",key:"hbye0f"}],["path",{d:"M8 7h8",key:"i86dvs"}],["circle",{cx:"12",cy:"17",r:"5",key:"qbz8iq"}],["path",{d:"M12 18v-2h-.5",key:"fawc4q"}]]);/**
|
||
|
|
* @license lucide-react v0.462.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Nt=H("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/**
|
||
|
|
* @license lucide-react v0.462.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Rn=H("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);/**
|
||
|
|
* @license lucide-react v0.462.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Ln=H("Utensils",[["path",{d:"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2",key:"cjf0a3"}],["path",{d:"M7 2v20",key:"1473qp"}],["path",{d:"M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7",key:"j28e5"}]]),Ce="https://api.quixzoom.com/api/qz",it=.15;function Fn(){const{user:t}=de(),[n,a]=v.useState([]),[r,o]=v.useState([]),[s,i]=v.useState(!0);return v.useEffect(()=>{if(!t){i(!1);return}async function u(){i(!0);const x=Ie.getToken();if(!x){i(!1);return}try{const h=await fetch(`${Ce}/payouts/history`,{headers:{Authorization:`Bearer ${x}`}});if(h.ok){const b=await h.json();a(Array.isArray(b.payouts)?b.payouts:[])}}catch(h){console.error("[usePayouts] fetchPayouts error:",h)}i(!1)}async function p(){try{const x=await fetch(`${Ce}/payouts/currencies`);if(x.ok){const h=await x.json();o(Array.isArray(h.currencies)?h.currencies:[])}}catch(x){console.error("[usePayouts] fetchCurrencies error:",x)}}u(),p()},[t]),{payouts:n,isLoading:s,calculatePayout:u=>{const p=Math.round(u*it),x=u-p;return{taxAmount:p,netAmount:x}},requestPayout:async(u,p="SEK")=>{var h;if(!t)return M.error("Du måste vara inloggad"),!1;const x=Ie.getToken();if(!x)return M.error("Ingen giltig session — logga in igen"),!1;if(u<100)return M.error("Minsta utbetalning är 100 credits"),!1;try{const b=await fetch(`${Ce}/payouts/request`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x}`},body:JSON.stringify({amount_credits:u,currency:p})}),w=await b.json();if(!b.ok)return b.status===400&&((h=w.error)!=null&&h.includes("Stripe Connect"))?(M.error("Utbetalningar kräver ett verifierat konto",{description:"Slutför onboarding via Inställningar → Utbetalningar för att aktivera Stripe Connect.",duration:6e3}),!1):(M.error(w.error||"Kunde inte skapa utbetalningsförfrågan"),!1);const g={id:w.payout_id||`tmp-${Date.now()}`,amount:u*100,tax_amount:(w.fee_credits||0)*100,net_amount:(w.net_credits||0)*100,status:w.status||"pending",reference:void 0,processed_at:null,created_at:new Date().toISOString()};a(d=>[g,...d]);const y=w.mode==="mock"?" (sandbox-läge)":"";return M.success(`Utbetalning initierad${y}`,{description:`${w.net_credits||0} credits → ${w.amount||""} ${w.currency||p} skickas till ditt konto.`}),!0}catch(b){return console.error("[usePayouts] requestPayout error:",b),M.error("Nätverksfel — försök igen"),!1}},TAX_RATE:it,currencies:r}}var ee={},Hn=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},vt={},D={};let Ke;const Un=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];D.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17};D.getSymbolTotalCodewords=function(n){return Un[n]};D.getBCHDigit=function(t){let n=0;for(;t!==0;)n++,t>>>=1;return n};D.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');Ke=n};D.isKanjiModeEnabled=function(){return typeof Ke<"u"};D.toSJIS=function(n){return Ke(n)};var pe={};(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function n(a){if(typeof a!="string")throw new Error("Param is not a string");switch(a.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+a)}}t.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},t.from=function(r,o){if(t.isValid(r))return r;try{return n(r)}catch{return o}}})(pe);function kt(){this.buffer=[],this.length=0}kt.prototype={get:function(t){const n=Math.floor(t/8);return(this.buffer[n]>>>7-t%8&1)===1},put:function(t,n){for(let a=0;a<n;a++)this.putBit((t>>>n-a-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.l
|
||
|
|
]))+`;F.KANJI=new RegExp(Z,"g");F.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");F.BYTE=new RegExp(Gn,"g");F.NUMERIC=new RegExp(_t,"g");F.ALPHANUMERIC=new RegExp(On,"g");const qn=new RegExp("^"+Z+"$"),Jn=new RegExp("^"+_t+"$"),Xn=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");F.testKanji=function(n){return qn.test(n)};F.testNumeric=function(n){return Jn.test(n)};F.testAlphanumeric=function(n){return Xn.test(n)};(function(t){const n=Oe,a=F;t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(s,i){if(!s.ccBits)throw new Error("Invalid mode: "+s);if(!n.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?s.ccBits[0]:i<27?s.ccBits[1]:s.ccBits[2]},t.getBestModeForData=function(s){return a.testNumeric(s)?t.NUMERIC:a.testAlphanumeric(s)?t.ALPHANUMERIC:a.testKanji(s)?t.KANJI:t.BYTE},t.toString=function(s){if(s&&s.id)return s.id;throw new Error("Invalid mode")},t.isValid=function(s){return s&&s.bit&&s.ccBits};function r(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+o)}}t.from=function(s,i){if(t.isValid(s))return s;try{return r(s)}catch{return i}}})($);(function(t){const n=D,a=xe,r=pe,o=$,s=Oe,i=7973,l=n.getBCHDigit(i);function c(x,h,b){for(let w=1;w<=40;w++)if(h<=t.getCapacity(w,b,x))return w}function f(x,h){return o.getCharCountIndicator(x,h)+4}function u(x,h){let b=0;return x.forEach(function(w){const g=f(w.mode,h);b+=g+w.getBitsLength()}),b}function p(x,h){for(let b=1;b<=40;b++)if(u(x,b)<=t.getCapacity(b,h,o.MIXED))return b}t.from=function(h,b){return s.isValid(h)?parseInt(h,10):b},t.getCapacity=function(h,b,w){if(!s.isValid(h))throw new Error("Invalid QR Code version");typeof w>"u"&&(w=o.BYTE);const g=n.getSymbolTotalCodewords(h),y=a.getTotalCodewordsCount(h,b),d=(g-y)*8;if(w===o.MIXED)return d;const m=d-f(w,h);switch(w){case o.NUMERIC:return Math.floor(m/10*3);case o.ALPHANUMERIC:return Math.floor(m/11*2);case o.KANJI:return Math.floor(m/13);case o.BYTE:default:return Math.floor(m/8)}},t.getBestVersionForData=function(h,b){let w;const g=r.from(b,r.M);if(Array.isArray(h)){if(h.length>1)return p(h,g);if(h.length===0)return 1;w=h[0]}else w=h;return c(w.mode,w.getLength(),g)},t.getEncodedBits=function(h){if(!s.isValid(h)||h<7)throw new Error("Invalid QR Code version");let b=h<<12;for(;n.getBCHDigit(b)-l>=0;)b^=i<<n.getBCHDigit(b)-l;return h<<12|b}})(Tt);var Bt={};const Re=D,It=1335,Qn=21522,ct=Re.getBCHDigit(It);Bt.getEncodedBits=function(n,a){const r=n.bit<<3|a;let o=r<<10;for(;Re.getBCHDigit(o)-ct>=0;)o^=It<<Re.getBCHDigit(o)-ct;return(r<<10|o)^Qn};var Dt={};const Yn=$;function K(t){this.mode=Yn.NUMERIC,this.data=t.toString()}K.getBitsLength=function(n){return 10*Math.floor(n/3)+(n%3?n%3*3+1:0)};K.prototype.getLength=function(){return this.data.length};K.prototype.getBitsLength=function(){return K.getBitsLength(this.data.length)};K.prototype.write=function(n){let a,r,o;for(a=0;a+3<=this.data.length;a+=3)r=this.data.substr(a,3),o=parseInt(r,10),n.put(o,10);const s=this.data.length-a;s>0&&(r=this.data.substr(a),o=parseInt(r,10),n.put(o,s*3+1))};var Wn=K;const Zn=$,Se=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function V(t){this.mode=Zn.ALPHANUMERIC,this.data=t}V.getBitsLength=function(n){return 11*Math.floor(n/2)+6*(n%2)};V.prototype.getLength=function(){return this.data.length};V.prototype.getBitsLength=function(){return V.getBitsLength(this.data.length)};V.prototype.write=function(n){let a;for(a=0;a+2<=this.data.length;a+=2){let r=Se.indexOf(this.data[a])*45;r+=Se.indexOf(this.data[a+1]),n.put(r,11)}this.data.length%2&&n.put(Se.indexOf(this.data[a]),6)};var er=V;const tr=$;function O(t){th
|
||
|
|
Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),t.put(a,13)}};var ar=G,Pt={exports:{}};(function(t){var n={single_source_shortest_paths:function(a,r,o){var s={},i={};i[r]=0;var l=n.PriorityQueue.make();l.push(r,0);for(var c,f,u,p,x,h,b,w,g;!l.empty();){c=l.pop(),f=c.value,p=c.cost,x=a[f]||{};for(u in x)x.hasOwnProperty(u)&&(h=x[u],b=p+h,w=i[u],g=typeof i[u]>"u",(g||w>b)&&(i[u]=b,l.push(u,b),s[u]=f))}if(typeof o<"u"&&typeof i[o]>"u"){var y=["Could not find a path from ",r," to ",o,"."].join("");throw new Error(y)}return s},extract_shortest_path_from_predecessor_list:function(a,r){for(var o=[],s=r;s;)o.push(s),a[s],s=a[s];return o.reverse(),o},find_path:function(a,r,o){var s=n.single_source_shortest_paths(a,r,o);return n.extract_shortest_path_from_predecessor_list(s,o)},PriorityQueue:{make:function(a){var r=n.PriorityQueue,o={},s;a=a||{};for(s in r)r.hasOwnProperty(s)&&(o[s]=r[s]);return o.queue=[],o.sorter=a.sorter||r.default_sorter,o},default_sorter:function(a,r){return a.cost-r.cost},push:function(a,r){var o={value:a,cost:r};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=n})(Pt);var or=Pt.exports;(function(t){const n=$,a=Wn,r=er,o=nr,s=ar,i=F,l=D,c=or;function f(y){return unescape(encodeURIComponent(y)).length}function u(y,d,m){const j=[];let C;for(;(C=y.exec(m))!==null;)j.push({data:C[0],index:C.index,mode:d,length:C[0].length});return j}function p(y){const d=u(i.NUMERIC,n.NUMERIC,y),m=u(i.ALPHANUMERIC,n.ALPHANUMERIC,y);let j,C;return l.isKanjiModeEnabled()?(j=u(i.BYTE,n.BYTE,y),C=u(i.KANJI,n.KANJI,y)):(j=u(i.BYTE_KANJI,n.BYTE,y),C=[]),d.concat(m,j,C).sort(function(E,_){return E.index-_.index}).map(function(E){return{data:E.data,mode:E.mode,length:E.length}})}function x(y,d){switch(d){case n.NUMERIC:return a.getBitsLength(y);case n.ALPHANUMERIC:return r.getBitsLength(y);case n.KANJI:return s.getBitsLength(y);case n.BYTE:return o.getBitsLength(y)}}function h(y){return y.reduce(function(d,m){const j=d.length-1>=0?d[d.length-1]:null;return j&&j.mode===m.mode?(d[d.length-1].data+=m.data,d):(d.push(m),d)},[])}function b(y){const d=[];for(let m=0;m<y.length;m++){const j=y[m];switch(j.mode){case n.NUMERIC:d.push([j,{data:j.data,mode:n.ALPHANUMERIC,length:j.length},{data:j.data,mode:n.BYTE,length:j.length}]);break;case n.ALPHANUMERIC:d.push([j,{data:j.data,mode:n.BYTE,length:j.length}]);break;case n.KANJI:d.push([j,{data:j.data,mode:n.BYTE,length:f(j.data)}]);break;case n.BYTE:d.push([{data:j.data,mode:n.BYTE,length:f(j.data)}])}}return d}function w(y,d){const m={},j={start:{}};let C=["start"];for(let N=0;N<y.length;N++){const E=y[N],_=[];for(let k=0;k<E.length;k++){const A=E[k],S=""+N+k;_.push(S),m[S]={node:A,lastCount:0},j[S]={};for(let R=0;R<C.length;R++){const B=C[R];m[B]&&m[B].node.mode===A.mode?(j[B][S]=x(m[B].lastCount+A.length,A.mode)-x(m[B].lastCount,A.mode),m[B].lastCount+=A.length):(m[B]&&(m[B].lastCount=A.length),j[B][S]=x(A.length,A.mode)+4+n.getCharCountIndicator(A.mode,d))}}C=_}for(let N=0;N<C.length;N++)j[C[N]].end=0;return{map:j,table:m}}function g(y,d){let m;const j=n.getBestModeForData(y);if(m=n.from(d,j),m!==n.BYTE&&m.bit<j.bit)throw new Error('"'+y+'" cannot be encoded with mode '+n.toString(m)+`.
|
||
|
|
Suggested mode is: `+n.toString(j));switch(m===n.KANJI&&!l.isKanjiModeEnabled()&&(m=n.BYTE),m){case n.NUMERIC:return new a(y);case n.ALPHANUMERIC:return new r(y);case n.KANJI:return new s(y);case n.BYTE:return new o(y)}}t.fromArray=function(d){return d.reduce(function(m,j){return typeof j=="string"?m.push(g(j,null)):j.data&&m.push(g(j.data,j.mode)),m},[])},t.fromString=function(d,m){const j=p(d,l.isKanjiModeEnabled()),C=b(j),N=w(C,m),E=c.find_path(N.map,"start","end"),_=[];for(let k=1;k<E.length-1;k++)_.push(N.table[E[k]].node);return t.fromArray(h(_))},t.rawSplit=function(d){return t.fromArray(p(d,l.isKanjiModeEnabled()))}})(Dt);const be=D,Ee=pe,ir=$n,lr=zn,cr=Ct,dr=St,Le=Et,Fe=xe,ur=Vn,ce=Tt,mr=Bt,fr=$,Ae=Dt;function gr(t,n){const a=t.size,r=dr.getPositions(n);for(let o=0;o<r.length;o++){const s=r[o][0],i=r[o][1];for(let l=-1;l<=7;l++)if(!(s+l<=-1||a<=s+l))for(let c=-1;c<=7;c++)i+c<=-1||a<=i+c||(l>=0&&l<=6&&(c===0||c===6)||c>=0&&c<=6&&(l===0||l===6)||l>=2&&l<=4&&c>=2&&c<=4?t.set(s+l,i+c,!0,!0):t.set(s+l,i+c,!1,!0))}}function hr(t){const n=t.size;for(let a=8;a<n-8;a++){const r=a%2===0;t.set(a,6,r,!0),t.set(6,a,r,!0)}}function pr(t,n){const a=cr.getPositions(n);for(let r=0;r<a.length;r++){const o=a[r][0],s=a[r][1];for(let i=-2;i<=2;i++)for(let l=-2;l<=2;l++)i===-2||i===2||l===-2||l===2||i===0&&l===0?t.set(o+i,s+l,!0,!0):t.set(o+i,s+l,!1,!0)}}function xr(t,n){const a=t.size,r=ce.getEncodedBits(n);let o,s,i;for(let l=0;l<18;l++)o=Math.floor(l/3),s=l%3+a-8-3,i=(r>>l&1)===1,t.set(o,s,i,!0),t.set(s,o,i,!0)}function Me(t,n,a){const r=t.size,o=mr.getEncodedBits(n,a);let s,i;for(s=0;s<15;s++)i=(o>>s&1)===1,s<6?t.set(s,8,i,!0):s<8?t.set(s+1,8,i,!0):t.set(r-15+s,8,i,!0),s<8?t.set(8,r-s-1,i,!0):s<9?t.set(8,15-s-1+1,i,!0):t.set(8,15-s-1,i,!0);t.set(r-8,8,1,!0)}function yr(t,n){const a=t.size;let r=-1,o=a-1,s=7,i=0;for(let l=a-1;l>0;l-=2)for(l===6&&l--;;){for(let c=0;c<2;c++)if(!t.isReserved(o,l-c)){let f=!1;i<n.length&&(f=(n[i]>>>s&1)===1),t.set(o,l-c,f),s--,s===-1&&(i++,s=7)}if(o+=r,o<0||a<=o){o-=r,r=-r;break}}}function br(t,n,a){const r=new ir;a.forEach(function(c){r.put(c.mode.bit,4),r.put(c.getLength(),fr.getCharCountIndicator(c.mode,t)),c.write(r)});const o=be.getSymbolTotalCodewords(t),s=Fe.getTotalCodewordsCount(t,n),i=(o-s)*8;for(r.getLengthInBits()+4<=i&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const l=(i-r.getLengthInBits())/8;for(let c=0;c<l;c++)r.put(c%2?17:236,8);return wr(r,t,n)}function wr(t,n,a){const r=be.getSymbolTotalCodewords(n),o=Fe.getTotalCodewordsCount(n,a),s=r-o,i=Fe.getBlocksCount(n,a),l=r%i,c=i-l,f=Math.floor(r/i),u=Math.floor(s/i),p=u+1,x=f-u,h=new ur(x);let b=0;const w=new Array(i),g=new Array(i);let y=0;const d=new Uint8Array(t.buffer);for(let E=0;E<i;E++){const _=E<c?u:p;w[E]=d.slice(b,b+_),g[E]=h.encode(w[E]),b+=_,y=Math.max(y,_)}const m=new Uint8Array(r);let j=0,C,N;for(C=0;C<y;C++)for(N=0;N<i;N++)C<w[N].length&&(m[j++]=w[N][C]);for(C=0;C<x;C++)for(N=0;N<i;N++)m[j++]=g[N][C];return m}function jr(t,n,a,r){let o;if(Array.isArray(t))o=Ae.fromArray(t);else if(typeof t=="string"){let f=n;if(!f){const u=Ae.rawSplit(t);f=ce.getBestVersionForData(u,a)}o=Ae.fromString(t,f||40)}else throw new Error("Invalid data");const s=ce.getBestVersionForData(o,a);if(!s)throw new Error("The amount of data is too big to be stored in a QR Code");if(!n)n=s;else if(n<s)throw new Error(`
|
||
|
|
The chosen QR Code version cannot contain this amount of data.
|
||
|
|
Minimum version required to store current data is: `+s+`.
|
||
|
|
`);const i=br(n,a,o),l=be.getSymbolSize(n),c=new lr(l);return gr(c,n),hr(c),pr(c,n),Me(c,a,0),n>=7&&xr(c,n),yr(c,i),isNaN(r)&&(r=Le.getBestMask(c,Me.bind(null,c,a))),Le.applyMask(r,c),Me(c,a,r),{modules:c,version:n,errorCorrectionLevel:a,maskPattern:r,segments:o}}vt.create=function(n,a){if(typeof n>"u"||n==="")throw new Error("No input text");let r=Ee.M,o,s;return typeof a<"u"&&(r=Ee.from(a.errorCorrectionLevel,Ee.M),o=ce.from(a.version),s=Le.from(a.maskPattern),a.toSJISFunc&&be.setToSJISFunction(a.toSJISFunc)),jr(n,o,r,s)};var Rt={},Ge={};(function(t){function n(a){if(typeof a=="number"&&(a=a.toString()),typeof a!="string")throw new Error("Color should be defined as hex string");let r=a.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+a);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(s){return[s,s]}))),r.length===6&&r.push("F","F");const o=parseInt(r.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+r.slice(0,6).join("")}}t.getOptions=function(r){r||(r={}),r.color||(r.color={});const o=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,s=r.width&&r.width>=21?r.width:void 0,i=r.scale||4;return{width:s,scale:s?4:i,margin:o,color:{dark:n(r.color.dark||"#000000ff"),light:n(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},t.getScale=function(r,o){return o.width&&o.width>=r+o.margin*2?o.width/(r+o.margin*2):o.scale},t.getImageWidth=function(r,o){const s=t.getScale(r,o);return Math.floor((r+o.margin*2)*s)},t.qrToImageData=function(r,o,s){const i=o.modules.size,l=o.modules.data,c=t.getScale(i,s),f=Math.floor((i+s.margin*2)*c),u=s.margin*c,p=[s.color.light,s.color.dark];for(let x=0;x<f;x++)for(let h=0;h<f;h++){let b=(x*f+h)*4,w=s.color.light;if(x>=u&&h>=u&&x<f-u&&h<f-u){const g=Math.floor((x-u)/c),y=Math.floor((h-u)/c);w=p[l[g*i+y]?1:0]}r[b++]=w.r,r[b++]=w.g,r[b++]=w.b,r[b]=w.a}}})(Ge);(function(t){const n=Ge;function a(o,s,i){o.clearRect(0,0,s.width,s.height),s.style||(s.style={}),s.height=i,s.width=i,s.style.height=i+"px",s.style.width=i+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(s,i,l){let c=l,f=i;typeof c>"u"&&(!i||!i.getContext)&&(c=i,i=void 0),i||(f=r()),c=n.getOptions(c);const u=n.getImageWidth(s.modules.size,c),p=f.getContext("2d"),x=p.createImageData(u,u);return n.qrToImageData(x.data,s,c),a(p,f,u),p.putImageData(x,0,0),f},t.renderToDataURL=function(s,i,l){let c=l;typeof c>"u"&&(!i||!i.getContext)&&(c=i,i=void 0),c||(c={});const f=t.render(s,i,c),u=c.type||"image/png",p=c.rendererOpts||{};return f.toDataURL(u,p.quality)}})(Rt);var Lt={};const Nr=Ge;function dt(t,n){const a=t.a/255,r=n+'="'+t.hex+'"';return a<1?r+" "+n+'-opacity="'+a.toFixed(2).slice(1)+'"':r}function Te(t,n,a){let r=t+n;return typeof a<"u"&&(r+=" "+a),r}function vr(t,n,a){let r="",o=0,s=!1,i=0;for(let l=0;l<t.length;l++){const c=Math.floor(l%n),f=Math.floor(l/n);!c&&!s&&(s=!0),t[l]?(i++,l>0&&c>0&&t[l-1]||(r+=s?Te("M",c+a,.5+f+a):Te("m",o,0),o=0,s=!1),c+1<n&&t[l+1]||(r+=Te("h",i),i=0)):o++}return r}Lt.render=function(n,a,r){const o=Nr.getOptions(a),s=n.modules.size,i=n.modules.data,l=s+o.margin*2,c=o.color.light.a?"<path "+dt(o.color.light,"fill")+' d="M0 0h'+l+"v"+l+'H0z"/>':"",f="<path "+dt(o.color.dark,"stroke")+' d="'+vr(i,s,o.margin)+'"/>',u='viewBox="0 0 '+l+" "+l+'"',x='<svg xmlns="http://www.w3.org/2000/svg" '+(o.width?'width="'+o.width+'" height="'+o.width+'" ':"")+u+' shape-rendering="crispEdges">'+c+f+`</svg>
|
||
|
|
`;return typeof r=="function"&&r(null,x),x};const kr=Hn,He=vt,Ft=Rt,Cr=Lt;function qe(t,n,a,r,o){const s=[].slice.call(arguments,1),i=s.length,l=typeof s[i-1]=="function";if(!l&&!kr())throw new Error("Callback required as last argument");if(l){if(i<2)throw new Error("Too few arguments provided");i===2?(o=a,a=n,n=r=void 0):i===3&&(n.getContext&&typeof o>"u"?(o=r,r=void 0):(o=r,r=a,a=n,n=void 0))}else{if(i<1)throw new Error("Too few arguments provided");return i===1?(a=n,n=r=void 0):i===2&&!n.getContext&&(r=a,a=n,n=void 0),new Promise(function(c,f){try{const u=He.create(a,r);c(t(u,n,r))}catch(u){f(u)}})}try{const c=He.create(a,r);o(null,t(c,n,r))}catch(c){o(c)}}ee.create=He.create;ee.toCanvas=qe.bind(null,Ft.render);ee.toDataURL=qe.bind(null,Ft.renderToDataURL);ee.toString=qe.bind(null,function(t,n,a){return Cr.render(t,a)});function Ht(){const{user:t}=de(),[n,a]=v.useState([]),[r,o]=v.useState(!0),s=v.useCallback(async()=>{if(!t){o(!1);return}o(!0);try{const u=await X(`/vouchers?user_id=${t.id}&order=issued_at.desc`);a(Array.isArray(u)?u:[])}catch(u){console.error("[useVouchers]",u)}finally{o(!1)}},[t]);v.useEffect(()=>{s()},[s]);const i=v.useCallback(async u=>{const p=JSON.stringify({id:u.id,code:u.code,title:u.title,brand:u.orderer_brand,expires:u.expires_at});return ee.toDataURL(p,{width:256,margin:2})},[]),l=n.filter(u=>u.status==="active"&&new Date(u.expires_at)>new Date),c=n.filter(u=>u.status==="redeemed"||u.status==="expired"),f=l.filter(u=>(new Date(u.expires_at).getTime()-Date.now())/864e5<=7);return{vouchers:n,activeVouchers:l,usedVouchers:c,expiresWithin7Days:f,isLoading:r,fetchVouchers:s,getQRDataUrl:i}}function ut({voucher:t}){const[n,a]=v.useState(!1),[r,o]=v.useState(null),[s,i]=v.useState(!1),{getQRDataUrl:l}=Ht(),c=gn(new Date(t.expires_at),new Date),f=c<=7&&t.status==="active",u=t.status==="expired"||new Date(t.expires_at)<new Date,p=t.status==="redeemed",x=async()=>{i(!0);const b=await l(t);o(b),i(!1),a(!0)},h=p||u?"bg-muted":f?"border-amber-500/50 bg-amber-500/5":"border-primary/30 bg-primary/5";return e.jsxs(e.Fragment,{children:[e.jsx(I,{className:`overflow-hidden ${h}`,children:e.jsxs(P,{className:"p-0",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[t.orderer_logo_url?e.jsx("img",{src:t.orderer_logo_url,alt:t.orderer_brand||"",className:"w-10 h-10 rounded-lg object-contain bg-white p-1"}):e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(xt,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:t.orderer_brand||"QuiXzoom Reward"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.reward_type==="points"?"Poäng":"Värdekupong"})]})]}),p&&e.jsxs(Q,{variant:"secondary",children:[e.jsx(hn,{className:"w-3 h-3 mr-1"}),"Inlöst"]}),u&&!p&&e.jsx(Q,{variant:"secondary",children:"Utgången"}),!p&&!u&&f&&e.jsxs(Q,{className:"bg-amber-500 text-white",children:[e.jsx(ae,{className:"w-3 h-3 mr-1"}),c,"d kvar"]}),!p&&!u&&!f&&e.jsxs(Q,{variant:"outline",className:"border-green-500 text-green-600",children:[c,"d kvar"]})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:`font-semibold ${p||u?"text-muted-foreground":""}`,children:t.title}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t.description})]}),t.value_nominal&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rt,{className:"w-4 h-4 text-amber-500"}),e.jsxs("span",{className:"font-bold text-lg",children:[t.value_nominal," krediter"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"nominellt värde"})]}),t.points&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rt,{className:"w-4 h-4 text-primary"}),e.jsxs("span",{className:"font-bold text-lg",children:[t.points," poäng"]})]}),t.redemption_instructions&&e.jsxs("p",{className:"text-xs text-muted-foreground bg-muted/50
|
||
|
|
//# sourceMappingURL=Wallet-DhBioTUc.js.map
|