@ape.swap/bonds-sdk 2.0.7-test.4 → 2.0.8-seedify
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AccordionText/index.d.ts +0 -2
- package/dist/main.d.ts +1 -1
- package/dist/main.js +203 -989
- package/dist/styles.css +4 -3
- package/dist/views/BondModal/BondModal.d.ts +0 -1
- package/dist/views/BondModal/components/BondModalHeaderAlt.d.ts +8 -0
- package/dist/views/YourBondsModal/components/LinkShare/utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -4,6 +4,7 @@ import { useWaitForTransactionReceipt, useChainId, useAccount, useSwitchChain, u
|
|
|
4
4
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
5
5
|
import axios from 'axios';
|
|
6
6
|
import { ConnectButton as ConnectButton$1 } from '@rainbow-me/rainbowkit';
|
|
7
|
+
import domtoimage from 'dom-to-image';
|
|
7
8
|
|
|
8
9
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
9
10
|
|
|
@@ -6294,7 +6295,7 @@ const Text$1 = /*#__PURE__*/React__default.forwardRef(function Text(props, ref)
|
|
|
6294
6295
|
* Image style variants can be defined in the theme.images object.
|
|
6295
6296
|
* @see https://theme-ui.com/components/image/
|
|
6296
6297
|
*/
|
|
6297
|
-
const Image
|
|
6298
|
+
const Image = /*#__PURE__*/React__default.forwardRef(function Image(props, ref) {
|
|
6298
6299
|
const __outerCss = props.__css;
|
|
6299
6300
|
return jsx$2(Box$1, {
|
|
6300
6301
|
ref: ref,
|
|
@@ -7447,7 +7448,7 @@ const pulse = keyframes$1({
|
|
|
7447
7448
|
'50%': { opacity: 0.4 },
|
|
7448
7449
|
'100%': { opacity: 1 },
|
|
7449
7450
|
});
|
|
7450
|
-
const styles$
|
|
7451
|
+
const styles$g = {
|
|
7451
7452
|
waves: {
|
|
7452
7453
|
position: 'relative',
|
|
7453
7454
|
overflow: 'hidden',
|
|
@@ -7479,7 +7480,7 @@ const styles$h = {
|
|
|
7479
7480
|
|
|
7480
7481
|
const Skeleton = (_a) => {
|
|
7481
7482
|
var { variant: variant$1 = variant.RECT, animation: animation$1 = animation.PULSE } = _a, props = __rest(_a, ["variant", "animation"]);
|
|
7482
|
-
return (jsx$2(Box$1, Object.assign({}, props, { sx: Object.assign(Object.assign({}, (animation$1 === animation.WAVES ? styles$
|
|
7483
|
+
return (jsx$2(Box$1, Object.assign({}, props, { sx: Object.assign(Object.assign({}, (animation$1 === animation.WAVES ? styles$g.waves : styles$g.pulse)), { height: props.height, width: props.width, borderRadius: variant$1 === variant.RECT ? '10px' : '50%' }) })));
|
|
7483
7484
|
};
|
|
7484
7485
|
|
|
7485
7486
|
var placements;
|
|
@@ -7517,7 +7518,7 @@ const container = (hide) => ({
|
|
|
7517
7518
|
display: hide ? 'none' : 'block',
|
|
7518
7519
|
},
|
|
7519
7520
|
});
|
|
7520
|
-
const styles$
|
|
7521
|
+
const styles$f = {
|
|
7521
7522
|
default: Object.assign({ color: 'text', fontSize: 0, lineHeight: '18px', fontWeight: 'normal' }, baseStyle$1),
|
|
7522
7523
|
bottomRight: {
|
|
7523
7524
|
'&::before': Object.assign(Object.assign({ position: 'absolute' }, bottomArrow), { right: '3%', borderBottomColor: 'white2' }),
|
|
@@ -7576,7 +7577,7 @@ const TooltipBubble = (_a) => {
|
|
|
7576
7577
|
const handleClick = (event) => {
|
|
7577
7578
|
event.stopPropagation();
|
|
7578
7579
|
};
|
|
7579
|
-
return (jsxs(Box$1, { sx: container(hideTooltip), onClick: handleClick, children: [jsx$2(Box$1, { sx: Object.assign({ position: 'absolute' }, (placementStyles[placement] || {})), children: jsx$2(Box$1, Object.assign({ sx: Object.assign(Object.assign(Object.assign(Object.assign({ position: 'relative' }, styles$
|
|
7580
|
+
return (jsxs(Box$1, { sx: container(hideTooltip), onClick: handleClick, children: [jsx$2(Box$1, { sx: Object.assign({ position: 'absolute' }, (placementStyles[placement] || {})), children: jsx$2(Box$1, Object.assign({ sx: Object.assign(Object.assign(Object.assign(Object.assign({ position: 'relative' }, styles$f.default), styles$f[placement]), backgroundColorStyle), { width, transform: transformTip }) }, props, { children: body })) }), children] }));
|
|
7580
7581
|
};
|
|
7581
7582
|
|
|
7582
7583
|
const warned = new Set();
|
|
@@ -17532,7 +17533,7 @@ const AnimatePresence = ({ children, exitBeforeEnter, custom, initial = true, on
|
|
|
17532
17533
|
}) }));
|
|
17533
17534
|
};
|
|
17534
17535
|
|
|
17535
|
-
const styles$
|
|
17536
|
+
const styles$e = {
|
|
17536
17537
|
container: {
|
|
17537
17538
|
padding: '20px',
|
|
17538
17539
|
background: 'white2',
|
|
@@ -17708,7 +17709,7 @@ const defaultStyle = {
|
|
|
17708
17709
|
transform: 'scale(0.9)',
|
|
17709
17710
|
},
|
|
17710
17711
|
};
|
|
17711
|
-
const styles$
|
|
17712
|
+
const styles$d = {
|
|
17712
17713
|
primary: Object.assign({}, defaultStyle),
|
|
17713
17714
|
transparent: Object.assign(Object.assign({}, defaultStyle), { backgroundColor: 'transparent', backgroundRepeat: 'no-repeat', padding: '0px', border: 'none', cursor: 'pointer', svg: {
|
|
17714
17715
|
background: 'transparent',
|
|
@@ -17717,12 +17718,12 @@ const styles$e = {
|
|
|
17717
17718
|
|
|
17718
17719
|
const IconButton = (_a) => {
|
|
17719
17720
|
var { icon = icons.DISCORD, color = 'white1', background = 'yellow', variant = iconButtonVariants.PRIMARY, iconWidth, children } = _a, props = __rest(_a, ["icon", "color", "background", "variant", "iconWidth", "children"]);
|
|
17720
|
-
return (jsx$2(Button$1, Object.assign({}, props, { variant: variant, sx: Object.assign(Object.assign({ display: 'flex', alignItems: 'center', justifyContent: 'center', position: 'relative', variant: `buttons.${variant}`, color: 'primaryBright', background }, (variant === iconButtonVariants.PRIMARY ? styles$
|
|
17721
|
+
return (jsx$2(Button$1, Object.assign({}, props, { variant: variant, sx: Object.assign(Object.assign({ display: 'flex', alignItems: 'center', justifyContent: 'center', position: 'relative', variant: `buttons.${variant}`, color: 'primaryBright', background }, (variant === iconButtonVariants.PRIMARY ? styles$d.primary : {})), (variant === iconButtonVariants.TRANSPARENT ? styles$d.transparent : {})), children: children || (jsx$2("span", { sx: { height: iconWidth, width: iconWidth }, children: jsx$2(Svg, Object.assign({ color: color, icon: icon }, props, { width: iconWidth })) })) })));
|
|
17721
17722
|
};
|
|
17722
17723
|
|
|
17723
17724
|
const ModalHeader = (_a) => {
|
|
17724
17725
|
var { children, onDismiss, hideDivider } = _a, props = __rest(_a, ["children", "onDismiss", "hideDivider"]);
|
|
17725
|
-
return (jsxs(Fragment$1, { children: [jsxs(Flex$1, Object.assign({}, props, { sx: styles$
|
|
17726
|
+
return (jsxs(Fragment$1, { children: [jsxs(Flex$1, Object.assign({}, props, { sx: styles$e.modalHead, children: [children, onDismiss && jsx$2(IconButton, { icon: "close", color: "text", variant: "transparent", onClick: onDismiss })] })), !hideDivider && jsx$2(Divider, {})] }));
|
|
17726
17727
|
};
|
|
17727
17728
|
|
|
17728
17729
|
const Modal = (_a) => {
|
|
@@ -17738,10 +17739,10 @@ const Modal = (_a) => {
|
|
|
17738
17739
|
}, transition: {
|
|
17739
17740
|
opacity: { duration: 0.2 },
|
|
17740
17741
|
transform: { duration: 0.2 },
|
|
17741
|
-
}, exit: { opacity: 0, transform: 'translate(-50%, -50%) scale(0)' } }, props, { sx: Object.assign(Object.assign({}, styles$
|
|
17742
|
+
}, exit: { opacity: 0, transform: 'translate(-50%, -50%) scale(0)' } }, props, { sx: Object.assign(Object.assign({}, styles$e.container), { zIndex }), onAnimationComplete: onAnimationComplete, children: [title && (jsx$2(ModalHeader, { onDismiss: onClose, children: jsx$2(Text, { sx: { fontSize: '22px', fontWeight: 700, lineHeight: '33px' }, children: title }) })), children] }))) }), open && jsx$2(Box$1, { sx: Object.assign(Object.assign({}, styles$e.backdrop), backdrop), onClick: onClose })] }));
|
|
17742
17743
|
};
|
|
17743
17744
|
|
|
17744
|
-
const styles$
|
|
17745
|
+
const styles$c = {
|
|
17745
17746
|
container: {
|
|
17746
17747
|
display: 'flex',
|
|
17747
17748
|
borderRadius: '10px',
|
|
@@ -43601,7 +43602,7 @@ function offset() {
|
|
|
43601
43602
|
return null;
|
|
43602
43603
|
}
|
|
43603
43604
|
|
|
43604
|
-
function styles$
|
|
43605
|
+
function styles$b() {
|
|
43605
43606
|
const window = getWindow();
|
|
43606
43607
|
if (this[0]) return window.getComputedStyle(this[0], null);
|
|
43607
43608
|
return {};
|
|
@@ -43980,7 +43981,7 @@ const Methods = {
|
|
|
43980
43981
|
transitionEnd: transitionEnd$1,
|
|
43981
43982
|
outerWidth,
|
|
43982
43983
|
outerHeight,
|
|
43983
|
-
styles: styles$
|
|
43984
|
+
styles: styles$b,
|
|
43984
43985
|
offset,
|
|
43985
43986
|
css,
|
|
43986
43987
|
each: each$1,
|
|
@@ -48581,7 +48582,7 @@ const getDotPos = (index, carouselLength) => {
|
|
|
48581
48582
|
: index - carouselLength;
|
|
48582
48583
|
};
|
|
48583
48584
|
|
|
48584
|
-
const styles$
|
|
48585
|
+
const styles$a = {
|
|
48585
48586
|
mainComponent: {
|
|
48586
48587
|
width: '100%',
|
|
48587
48588
|
flexDirection: 'column',
|
|
@@ -48654,7 +48655,7 @@ const CardRecommendationsMobile = ({ recommendations }) => {
|
|
|
48654
48655
|
display: 'flex',
|
|
48655
48656
|
justifyContent: 'center',
|
|
48656
48657
|
}, children: jsx$2(CardRecommendation, { cardIndex: index, bond: bond, handleBuyBondClick: () => window.open(`https://ape.bond/bonds?bondAddress=${bond.billAddress}&bondChain=${bond.chainId}`, '_blank', 'noreferrer') }, `${bond.billAddress}-${index}`) }, index));
|
|
48657
|
-
}) }), jsx$2(Flex, { sx: styles$
|
|
48658
|
+
}) }), jsx$2(Flex, { sx: styles$a.bubbleContainer, children: [...Array(recommendations === null || recommendations === void 0 ? void 0 : recommendations.length)].map((_, i) => {
|
|
48658
48659
|
return jsx$2(SwiperDots, { isActive: i === activeSlide, onClick: () => slideTo(i) }, i);
|
|
48659
48660
|
}) })] }));
|
|
48660
48661
|
};
|
|
@@ -70802,954 +70803,6 @@ const remove0xPrefix = (str) => {
|
|
|
70802
70803
|
return str;
|
|
70803
70804
|
};
|
|
70804
70805
|
|
|
70805
|
-
const styles$a = {
|
|
70806
|
-
linkShareButton: {
|
|
70807
|
-
background: 'migration',
|
|
70808
|
-
width: '36px',
|
|
70809
|
-
height: '26px',
|
|
70810
|
-
justifyContent: 'center',
|
|
70811
|
-
alignItems: 'center',
|
|
70812
|
-
borderRadius: '8px',
|
|
70813
|
-
cursor: 'pointer',
|
|
70814
|
-
},
|
|
70815
|
-
containerLinksShare: {
|
|
70816
|
-
position: 'absolute',
|
|
70817
|
-
height: '28px',
|
|
70818
|
-
right: '8.5px',
|
|
70819
|
-
top: '9px',
|
|
70820
|
-
justifyContent: 'center',
|
|
70821
|
-
alignItems: 'center',
|
|
70822
|
-
gap: '10px',
|
|
70823
|
-
zIndex: 3,
|
|
70824
|
-
},
|
|
70825
|
-
};
|
|
70826
|
-
|
|
70827
|
-
var domToImage = {exports: {}};
|
|
70828
|
-
|
|
70829
|
-
(function (module) {
|
|
70830
|
-
(function (global) {
|
|
70831
|
-
|
|
70832
|
-
var util = newUtil();
|
|
70833
|
-
var inliner = newInliner();
|
|
70834
|
-
var fontFaces = newFontFaces();
|
|
70835
|
-
var images = newImages();
|
|
70836
|
-
|
|
70837
|
-
// Default impl options
|
|
70838
|
-
var defaultOptions = {
|
|
70839
|
-
// Default is to fail on error, no placeholder
|
|
70840
|
-
imagePlaceholder: undefined,
|
|
70841
|
-
// Default cache bust is false, it will use the cache
|
|
70842
|
-
cacheBust: false
|
|
70843
|
-
};
|
|
70844
|
-
|
|
70845
|
-
var domtoimage = {
|
|
70846
|
-
toSvg: toSvg,
|
|
70847
|
-
toPng: toPng,
|
|
70848
|
-
toJpeg: toJpeg,
|
|
70849
|
-
toBlob: toBlob,
|
|
70850
|
-
toPixelData: toPixelData,
|
|
70851
|
-
impl: {
|
|
70852
|
-
fontFaces: fontFaces,
|
|
70853
|
-
images: images,
|
|
70854
|
-
util: util,
|
|
70855
|
-
inliner: inliner,
|
|
70856
|
-
options: {}
|
|
70857
|
-
}
|
|
70858
|
-
};
|
|
70859
|
-
|
|
70860
|
-
module.exports = domtoimage;
|
|
70861
|
-
|
|
70862
|
-
|
|
70863
|
-
/**
|
|
70864
|
-
* @param {Node} node - The DOM Node object to render
|
|
70865
|
-
* @param {Object} options - Rendering options
|
|
70866
|
-
* @param {Function} options.filter - Should return true if passed node should be included in the output
|
|
70867
|
-
* (excluding node means excluding it's children as well). Not called on the root node.
|
|
70868
|
-
* @param {String} options.bgcolor - color for the background, any valid CSS color value.
|
|
70869
|
-
* @param {Number} options.width - width to be applied to node before rendering.
|
|
70870
|
-
* @param {Number} options.height - height to be applied to node before rendering.
|
|
70871
|
-
* @param {Object} options.style - an object whose properties to be copied to node's style before rendering.
|
|
70872
|
-
* @param {Number} options.quality - a Number between 0 and 1 indicating image quality (applicable to JPEG only),
|
|
70873
|
-
defaults to 1.0.
|
|
70874
|
-
* @param {String} options.imagePlaceholder - dataURL to use as a placeholder for failed images, default behaviour is to fail fast on images we can't fetch
|
|
70875
|
-
* @param {Boolean} options.cacheBust - set to true to cache bust by appending the time to the request url
|
|
70876
|
-
* @return {Promise} - A promise that is fulfilled with a SVG image data URL
|
|
70877
|
-
* */
|
|
70878
|
-
function toSvg(node, options) {
|
|
70879
|
-
options = options || {};
|
|
70880
|
-
copyOptions(options);
|
|
70881
|
-
return Promise.resolve(node)
|
|
70882
|
-
.then(function (node) {
|
|
70883
|
-
return cloneNode(node, options.filter, true);
|
|
70884
|
-
})
|
|
70885
|
-
.then(embedFonts)
|
|
70886
|
-
.then(inlineImages)
|
|
70887
|
-
.then(applyOptions)
|
|
70888
|
-
.then(function (clone) {
|
|
70889
|
-
return makeSvgDataUri(clone,
|
|
70890
|
-
options.width || util.width(node),
|
|
70891
|
-
options.height || util.height(node)
|
|
70892
|
-
);
|
|
70893
|
-
});
|
|
70894
|
-
|
|
70895
|
-
function applyOptions(clone) {
|
|
70896
|
-
if (options.bgcolor) clone.style.backgroundColor = options.bgcolor;
|
|
70897
|
-
|
|
70898
|
-
if (options.width) clone.style.width = options.width + 'px';
|
|
70899
|
-
if (options.height) clone.style.height = options.height + 'px';
|
|
70900
|
-
|
|
70901
|
-
if (options.style)
|
|
70902
|
-
Object.keys(options.style).forEach(function (property) {
|
|
70903
|
-
clone.style[property] = options.style[property];
|
|
70904
|
-
});
|
|
70905
|
-
|
|
70906
|
-
return clone;
|
|
70907
|
-
}
|
|
70908
|
-
}
|
|
70909
|
-
|
|
70910
|
-
/**
|
|
70911
|
-
* @param {Node} node - The DOM Node object to render
|
|
70912
|
-
* @param {Object} options - Rendering options, @see {@link toSvg}
|
|
70913
|
-
* @return {Promise} - A promise that is fulfilled with a Uint8Array containing RGBA pixel data.
|
|
70914
|
-
* */
|
|
70915
|
-
function toPixelData(node, options) {
|
|
70916
|
-
return draw(node, options || {})
|
|
70917
|
-
.then(function (canvas) {
|
|
70918
|
-
return canvas.getContext('2d').getImageData(
|
|
70919
|
-
0,
|
|
70920
|
-
0,
|
|
70921
|
-
util.width(node),
|
|
70922
|
-
util.height(node)
|
|
70923
|
-
).data;
|
|
70924
|
-
});
|
|
70925
|
-
}
|
|
70926
|
-
|
|
70927
|
-
/**
|
|
70928
|
-
* @param {Node} node - The DOM Node object to render
|
|
70929
|
-
* @param {Object} options - Rendering options, @see {@link toSvg}
|
|
70930
|
-
* @return {Promise} - A promise that is fulfilled with a PNG image data URL
|
|
70931
|
-
* */
|
|
70932
|
-
function toPng(node, options) {
|
|
70933
|
-
return draw(node, options || {})
|
|
70934
|
-
.then(function (canvas) {
|
|
70935
|
-
return canvas.toDataURL();
|
|
70936
|
-
});
|
|
70937
|
-
}
|
|
70938
|
-
|
|
70939
|
-
/**
|
|
70940
|
-
* @param {Node} node - The DOM Node object to render
|
|
70941
|
-
* @param {Object} options - Rendering options, @see {@link toSvg}
|
|
70942
|
-
* @return {Promise} - A promise that is fulfilled with a JPEG image data URL
|
|
70943
|
-
* */
|
|
70944
|
-
function toJpeg(node, options) {
|
|
70945
|
-
options = options || {};
|
|
70946
|
-
return draw(node, options)
|
|
70947
|
-
.then(function (canvas) {
|
|
70948
|
-
return canvas.toDataURL('image/jpeg', options.quality || 1.0);
|
|
70949
|
-
});
|
|
70950
|
-
}
|
|
70951
|
-
|
|
70952
|
-
/**
|
|
70953
|
-
* @param {Node} node - The DOM Node object to render
|
|
70954
|
-
* @param {Object} options - Rendering options, @see {@link toSvg}
|
|
70955
|
-
* @return {Promise} - A promise that is fulfilled with a PNG image blob
|
|
70956
|
-
* */
|
|
70957
|
-
function toBlob(node, options) {
|
|
70958
|
-
return draw(node, options || {})
|
|
70959
|
-
.then(util.canvasToBlob);
|
|
70960
|
-
}
|
|
70961
|
-
|
|
70962
|
-
function copyOptions(options) {
|
|
70963
|
-
// Copy options to impl options for use in impl
|
|
70964
|
-
if(typeof(options.imagePlaceholder) === 'undefined') {
|
|
70965
|
-
domtoimage.impl.options.imagePlaceholder = defaultOptions.imagePlaceholder;
|
|
70966
|
-
} else {
|
|
70967
|
-
domtoimage.impl.options.imagePlaceholder = options.imagePlaceholder;
|
|
70968
|
-
}
|
|
70969
|
-
|
|
70970
|
-
if(typeof(options.cacheBust) === 'undefined') {
|
|
70971
|
-
domtoimage.impl.options.cacheBust = defaultOptions.cacheBust;
|
|
70972
|
-
} else {
|
|
70973
|
-
domtoimage.impl.options.cacheBust = options.cacheBust;
|
|
70974
|
-
}
|
|
70975
|
-
}
|
|
70976
|
-
|
|
70977
|
-
function draw(domNode, options) {
|
|
70978
|
-
return toSvg(domNode, options)
|
|
70979
|
-
.then(util.makeImage)
|
|
70980
|
-
.then(util.delay(100))
|
|
70981
|
-
.then(function (image) {
|
|
70982
|
-
var canvas = newCanvas(domNode);
|
|
70983
|
-
canvas.getContext('2d').drawImage(image, 0, 0);
|
|
70984
|
-
return canvas;
|
|
70985
|
-
});
|
|
70986
|
-
|
|
70987
|
-
function newCanvas(domNode) {
|
|
70988
|
-
var canvas = document.createElement('canvas');
|
|
70989
|
-
canvas.width = options.width || util.width(domNode);
|
|
70990
|
-
canvas.height = options.height || util.height(domNode);
|
|
70991
|
-
|
|
70992
|
-
if (options.bgcolor) {
|
|
70993
|
-
var ctx = canvas.getContext('2d');
|
|
70994
|
-
ctx.fillStyle = options.bgcolor;
|
|
70995
|
-
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
70996
|
-
}
|
|
70997
|
-
|
|
70998
|
-
return canvas;
|
|
70999
|
-
}
|
|
71000
|
-
}
|
|
71001
|
-
|
|
71002
|
-
function cloneNode(node, filter, root) {
|
|
71003
|
-
if (!root && filter && !filter(node)) return Promise.resolve();
|
|
71004
|
-
|
|
71005
|
-
return Promise.resolve(node)
|
|
71006
|
-
.then(makeNodeCopy)
|
|
71007
|
-
.then(function (clone) {
|
|
71008
|
-
return cloneChildren(node, clone, filter);
|
|
71009
|
-
})
|
|
71010
|
-
.then(function (clone) {
|
|
71011
|
-
return processClone(node, clone);
|
|
71012
|
-
});
|
|
71013
|
-
|
|
71014
|
-
function makeNodeCopy(node) {
|
|
71015
|
-
if (node instanceof HTMLCanvasElement) return util.makeImage(node.toDataURL());
|
|
71016
|
-
return node.cloneNode(false);
|
|
71017
|
-
}
|
|
71018
|
-
|
|
71019
|
-
function cloneChildren(original, clone, filter) {
|
|
71020
|
-
var children = original.childNodes;
|
|
71021
|
-
if (children.length === 0) return Promise.resolve(clone);
|
|
71022
|
-
|
|
71023
|
-
return cloneChildrenInOrder(clone, util.asArray(children), filter)
|
|
71024
|
-
.then(function () {
|
|
71025
|
-
return clone;
|
|
71026
|
-
});
|
|
71027
|
-
|
|
71028
|
-
function cloneChildrenInOrder(parent, children, filter) {
|
|
71029
|
-
var done = Promise.resolve();
|
|
71030
|
-
children.forEach(function (child) {
|
|
71031
|
-
done = done
|
|
71032
|
-
.then(function () {
|
|
71033
|
-
return cloneNode(child, filter);
|
|
71034
|
-
})
|
|
71035
|
-
.then(function (childClone) {
|
|
71036
|
-
if (childClone) parent.appendChild(childClone);
|
|
71037
|
-
});
|
|
71038
|
-
});
|
|
71039
|
-
return done;
|
|
71040
|
-
}
|
|
71041
|
-
}
|
|
71042
|
-
|
|
71043
|
-
function processClone(original, clone) {
|
|
71044
|
-
if (!(clone instanceof Element)) return clone;
|
|
71045
|
-
|
|
71046
|
-
return Promise.resolve()
|
|
71047
|
-
.then(cloneStyle)
|
|
71048
|
-
.then(clonePseudoElements)
|
|
71049
|
-
.then(copyUserInput)
|
|
71050
|
-
.then(fixSvg)
|
|
71051
|
-
.then(function () {
|
|
71052
|
-
return clone;
|
|
71053
|
-
});
|
|
71054
|
-
|
|
71055
|
-
function cloneStyle() {
|
|
71056
|
-
copyStyle(window.getComputedStyle(original), clone.style);
|
|
71057
|
-
|
|
71058
|
-
function copyStyle(source, target) {
|
|
71059
|
-
if (source.cssText) target.cssText = source.cssText;
|
|
71060
|
-
else copyProperties(source, target);
|
|
71061
|
-
|
|
71062
|
-
function copyProperties(source, target) {
|
|
71063
|
-
util.asArray(source).forEach(function (name) {
|
|
71064
|
-
target.setProperty(
|
|
71065
|
-
name,
|
|
71066
|
-
source.getPropertyValue(name),
|
|
71067
|
-
source.getPropertyPriority(name)
|
|
71068
|
-
);
|
|
71069
|
-
});
|
|
71070
|
-
}
|
|
71071
|
-
}
|
|
71072
|
-
}
|
|
71073
|
-
|
|
71074
|
-
function clonePseudoElements() {
|
|
71075
|
-
[':before', ':after'].forEach(function (element) {
|
|
71076
|
-
clonePseudoElement(element);
|
|
71077
|
-
});
|
|
71078
|
-
|
|
71079
|
-
function clonePseudoElement(element) {
|
|
71080
|
-
var style = window.getComputedStyle(original, element);
|
|
71081
|
-
var content = style.getPropertyValue('content');
|
|
71082
|
-
|
|
71083
|
-
if (content === '' || content === 'none') return;
|
|
71084
|
-
|
|
71085
|
-
var className = util.uid();
|
|
71086
|
-
clone.className = clone.className + ' ' + className;
|
|
71087
|
-
var styleElement = document.createElement('style');
|
|
71088
|
-
styleElement.appendChild(formatPseudoElementStyle(className, element, style));
|
|
71089
|
-
clone.appendChild(styleElement);
|
|
71090
|
-
|
|
71091
|
-
function formatPseudoElementStyle(className, element, style) {
|
|
71092
|
-
var selector = '.' + className + ':' + element;
|
|
71093
|
-
var cssText = style.cssText ? formatCssText(style) : formatCssProperties(style);
|
|
71094
|
-
return document.createTextNode(selector + '{' + cssText + '}');
|
|
71095
|
-
|
|
71096
|
-
function formatCssText(style) {
|
|
71097
|
-
var content = style.getPropertyValue('content');
|
|
71098
|
-
return style.cssText + ' content: ' + content + ';';
|
|
71099
|
-
}
|
|
71100
|
-
|
|
71101
|
-
function formatCssProperties(style) {
|
|
71102
|
-
|
|
71103
|
-
return util.asArray(style)
|
|
71104
|
-
.map(formatProperty)
|
|
71105
|
-
.join('; ') + ';';
|
|
71106
|
-
|
|
71107
|
-
function formatProperty(name) {
|
|
71108
|
-
return name + ': ' +
|
|
71109
|
-
style.getPropertyValue(name) +
|
|
71110
|
-
(style.getPropertyPriority(name) ? ' !important' : '');
|
|
71111
|
-
}
|
|
71112
|
-
}
|
|
71113
|
-
}
|
|
71114
|
-
}
|
|
71115
|
-
}
|
|
71116
|
-
|
|
71117
|
-
function copyUserInput() {
|
|
71118
|
-
if (original instanceof HTMLTextAreaElement) clone.innerHTML = original.value;
|
|
71119
|
-
if (original instanceof HTMLInputElement) clone.setAttribute("value", original.value);
|
|
71120
|
-
}
|
|
71121
|
-
|
|
71122
|
-
function fixSvg() {
|
|
71123
|
-
if (!(clone instanceof SVGElement)) return;
|
|
71124
|
-
clone.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
|
|
71125
|
-
|
|
71126
|
-
if (!(clone instanceof SVGRectElement)) return;
|
|
71127
|
-
['width', 'height'].forEach(function (attribute) {
|
|
71128
|
-
var value = clone.getAttribute(attribute);
|
|
71129
|
-
if (!value) return;
|
|
71130
|
-
|
|
71131
|
-
clone.style.setProperty(attribute, value);
|
|
71132
|
-
});
|
|
71133
|
-
}
|
|
71134
|
-
}
|
|
71135
|
-
}
|
|
71136
|
-
|
|
71137
|
-
function embedFonts(node) {
|
|
71138
|
-
return fontFaces.resolveAll()
|
|
71139
|
-
.then(function (cssText) {
|
|
71140
|
-
var styleNode = document.createElement('style');
|
|
71141
|
-
node.appendChild(styleNode);
|
|
71142
|
-
styleNode.appendChild(document.createTextNode(cssText));
|
|
71143
|
-
return node;
|
|
71144
|
-
});
|
|
71145
|
-
}
|
|
71146
|
-
|
|
71147
|
-
function inlineImages(node) {
|
|
71148
|
-
return images.inlineAll(node)
|
|
71149
|
-
.then(function () {
|
|
71150
|
-
return node;
|
|
71151
|
-
});
|
|
71152
|
-
}
|
|
71153
|
-
|
|
71154
|
-
function makeSvgDataUri(node, width, height) {
|
|
71155
|
-
return Promise.resolve(node)
|
|
71156
|
-
.then(function (node) {
|
|
71157
|
-
node.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
|
|
71158
|
-
return new XMLSerializer().serializeToString(node);
|
|
71159
|
-
})
|
|
71160
|
-
.then(util.escapeXhtml)
|
|
71161
|
-
.then(function (xhtml) {
|
|
71162
|
-
return '<foreignObject x="0" y="0" width="100%" height="100%">' + xhtml + '</foreignObject>';
|
|
71163
|
-
})
|
|
71164
|
-
.then(function (foreignObject) {
|
|
71165
|
-
return '<svg xmlns="http://www.w3.org/2000/svg" width="' + width + '" height="' + height + '">' +
|
|
71166
|
-
foreignObject + '</svg>';
|
|
71167
|
-
})
|
|
71168
|
-
.then(function (svg) {
|
|
71169
|
-
return 'data:image/svg+xml;charset=utf-8,' + svg;
|
|
71170
|
-
});
|
|
71171
|
-
}
|
|
71172
|
-
|
|
71173
|
-
function newUtil() {
|
|
71174
|
-
return {
|
|
71175
|
-
escape: escape,
|
|
71176
|
-
parseExtension: parseExtension,
|
|
71177
|
-
mimeType: mimeType,
|
|
71178
|
-
dataAsUrl: dataAsUrl,
|
|
71179
|
-
isDataUrl: isDataUrl,
|
|
71180
|
-
canvasToBlob: canvasToBlob,
|
|
71181
|
-
resolveUrl: resolveUrl,
|
|
71182
|
-
getAndEncode: getAndEncode,
|
|
71183
|
-
uid: uid(),
|
|
71184
|
-
delay: delay,
|
|
71185
|
-
asArray: asArray,
|
|
71186
|
-
escapeXhtml: escapeXhtml,
|
|
71187
|
-
makeImage: makeImage,
|
|
71188
|
-
width: width,
|
|
71189
|
-
height: height
|
|
71190
|
-
};
|
|
71191
|
-
|
|
71192
|
-
function mimes() {
|
|
71193
|
-
/*
|
|
71194
|
-
* Only WOFF and EOT mime types for fonts are 'real'
|
|
71195
|
-
* see http://www.iana.org/assignments/media-types/media-types.xhtml
|
|
71196
|
-
*/
|
|
71197
|
-
var WOFF = 'application/font-woff';
|
|
71198
|
-
var JPEG = 'image/jpeg';
|
|
71199
|
-
|
|
71200
|
-
return {
|
|
71201
|
-
'woff': WOFF,
|
|
71202
|
-
'woff2': WOFF,
|
|
71203
|
-
'ttf': 'application/font-truetype',
|
|
71204
|
-
'eot': 'application/vnd.ms-fontobject',
|
|
71205
|
-
'png': 'image/png',
|
|
71206
|
-
'jpg': JPEG,
|
|
71207
|
-
'jpeg': JPEG,
|
|
71208
|
-
'gif': 'image/gif',
|
|
71209
|
-
'tiff': 'image/tiff',
|
|
71210
|
-
'svg': 'image/svg+xml'
|
|
71211
|
-
};
|
|
71212
|
-
}
|
|
71213
|
-
|
|
71214
|
-
function parseExtension(url) {
|
|
71215
|
-
var match = /\.([^\.\/]*?)$/g.exec(url);
|
|
71216
|
-
if (match) return match[1];
|
|
71217
|
-
else return '';
|
|
71218
|
-
}
|
|
71219
|
-
|
|
71220
|
-
function mimeType(url) {
|
|
71221
|
-
var extension = parseExtension(url).toLowerCase();
|
|
71222
|
-
return mimes()[extension] || '';
|
|
71223
|
-
}
|
|
71224
|
-
|
|
71225
|
-
function isDataUrl(url) {
|
|
71226
|
-
return url.search(/^(data:)/) !== -1;
|
|
71227
|
-
}
|
|
71228
|
-
|
|
71229
|
-
function toBlob(canvas) {
|
|
71230
|
-
return new Promise(function (resolve) {
|
|
71231
|
-
var binaryString = window.atob(canvas.toDataURL().split(',')[1]);
|
|
71232
|
-
var length = binaryString.length;
|
|
71233
|
-
var binaryArray = new Uint8Array(length);
|
|
71234
|
-
|
|
71235
|
-
for (var i = 0; i < length; i++)
|
|
71236
|
-
binaryArray[i] = binaryString.charCodeAt(i);
|
|
71237
|
-
|
|
71238
|
-
resolve(new Blob([binaryArray], {
|
|
71239
|
-
type: 'image/png'
|
|
71240
|
-
}));
|
|
71241
|
-
});
|
|
71242
|
-
}
|
|
71243
|
-
|
|
71244
|
-
function canvasToBlob(canvas) {
|
|
71245
|
-
if (canvas.toBlob)
|
|
71246
|
-
return new Promise(function (resolve) {
|
|
71247
|
-
canvas.toBlob(resolve);
|
|
71248
|
-
});
|
|
71249
|
-
|
|
71250
|
-
return toBlob(canvas);
|
|
71251
|
-
}
|
|
71252
|
-
|
|
71253
|
-
function resolveUrl(url, baseUrl) {
|
|
71254
|
-
var doc = document.implementation.createHTMLDocument();
|
|
71255
|
-
var base = doc.createElement('base');
|
|
71256
|
-
doc.head.appendChild(base);
|
|
71257
|
-
var a = doc.createElement('a');
|
|
71258
|
-
doc.body.appendChild(a);
|
|
71259
|
-
base.href = baseUrl;
|
|
71260
|
-
a.href = url;
|
|
71261
|
-
return a.href;
|
|
71262
|
-
}
|
|
71263
|
-
|
|
71264
|
-
function uid() {
|
|
71265
|
-
var index = 0;
|
|
71266
|
-
|
|
71267
|
-
return function () {
|
|
71268
|
-
return 'u' + fourRandomChars() + index++;
|
|
71269
|
-
|
|
71270
|
-
function fourRandomChars() {
|
|
71271
|
-
/* see http://stackoverflow.com/a/6248722/2519373 */
|
|
71272
|
-
return ('0000' + (Math.random() * Math.pow(36, 4) << 0).toString(36)).slice(-4);
|
|
71273
|
-
}
|
|
71274
|
-
};
|
|
71275
|
-
}
|
|
71276
|
-
|
|
71277
|
-
function makeImage(uri) {
|
|
71278
|
-
return new Promise(function (resolve, reject) {
|
|
71279
|
-
var image = new Image();
|
|
71280
|
-
image.onload = function () {
|
|
71281
|
-
resolve(image);
|
|
71282
|
-
};
|
|
71283
|
-
image.onerror = reject;
|
|
71284
|
-
image.src = uri;
|
|
71285
|
-
});
|
|
71286
|
-
}
|
|
71287
|
-
|
|
71288
|
-
function getAndEncode(url) {
|
|
71289
|
-
var TIMEOUT = 30000;
|
|
71290
|
-
if(domtoimage.impl.options.cacheBust) {
|
|
71291
|
-
// Cache bypass so we dont have CORS issues with cached images
|
|
71292
|
-
// Source: https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache
|
|
71293
|
-
url += ((/\?/).test(url) ? "&" : "?") + (new Date()).getTime();
|
|
71294
|
-
}
|
|
71295
|
-
|
|
71296
|
-
return new Promise(function (resolve) {
|
|
71297
|
-
var request = new XMLHttpRequest();
|
|
71298
|
-
|
|
71299
|
-
request.onreadystatechange = done;
|
|
71300
|
-
request.ontimeout = timeout;
|
|
71301
|
-
request.responseType = 'blob';
|
|
71302
|
-
request.timeout = TIMEOUT;
|
|
71303
|
-
request.open('GET', url, true);
|
|
71304
|
-
request.send();
|
|
71305
|
-
|
|
71306
|
-
var placeholder;
|
|
71307
|
-
if(domtoimage.impl.options.imagePlaceholder) {
|
|
71308
|
-
var split = domtoimage.impl.options.imagePlaceholder.split(/,/);
|
|
71309
|
-
if(split && split[1]) {
|
|
71310
|
-
placeholder = split[1];
|
|
71311
|
-
}
|
|
71312
|
-
}
|
|
71313
|
-
|
|
71314
|
-
function done() {
|
|
71315
|
-
if (request.readyState !== 4) return;
|
|
71316
|
-
|
|
71317
|
-
if (request.status !== 200) {
|
|
71318
|
-
if(placeholder) {
|
|
71319
|
-
resolve(placeholder);
|
|
71320
|
-
} else {
|
|
71321
|
-
fail('cannot fetch resource: ' + url + ', status: ' + request.status);
|
|
71322
|
-
}
|
|
71323
|
-
|
|
71324
|
-
return;
|
|
71325
|
-
}
|
|
71326
|
-
|
|
71327
|
-
var encoder = new FileReader();
|
|
71328
|
-
encoder.onloadend = function () {
|
|
71329
|
-
var content = encoder.result.split(/,/)[1];
|
|
71330
|
-
resolve(content);
|
|
71331
|
-
};
|
|
71332
|
-
encoder.readAsDataURL(request.response);
|
|
71333
|
-
}
|
|
71334
|
-
|
|
71335
|
-
function timeout() {
|
|
71336
|
-
if(placeholder) {
|
|
71337
|
-
resolve(placeholder);
|
|
71338
|
-
} else {
|
|
71339
|
-
fail('timeout of ' + TIMEOUT + 'ms occured while fetching resource: ' + url);
|
|
71340
|
-
}
|
|
71341
|
-
}
|
|
71342
|
-
|
|
71343
|
-
function fail(message) {
|
|
71344
|
-
console.error(message);
|
|
71345
|
-
resolve('');
|
|
71346
|
-
}
|
|
71347
|
-
});
|
|
71348
|
-
}
|
|
71349
|
-
|
|
71350
|
-
function dataAsUrl(content, type) {
|
|
71351
|
-
return 'data:' + type + ';base64,' + content;
|
|
71352
|
-
}
|
|
71353
|
-
|
|
71354
|
-
function escape(string) {
|
|
71355
|
-
return string.replace(/([.*+?^${}()|\[\]\/\\])/g, '\\$1');
|
|
71356
|
-
}
|
|
71357
|
-
|
|
71358
|
-
function delay(ms) {
|
|
71359
|
-
return function (arg) {
|
|
71360
|
-
return new Promise(function (resolve) {
|
|
71361
|
-
setTimeout(function () {
|
|
71362
|
-
resolve(arg);
|
|
71363
|
-
}, ms);
|
|
71364
|
-
});
|
|
71365
|
-
};
|
|
71366
|
-
}
|
|
71367
|
-
|
|
71368
|
-
function asArray(arrayLike) {
|
|
71369
|
-
var array = [];
|
|
71370
|
-
var length = arrayLike.length;
|
|
71371
|
-
for (var i = 0; i < length; i++) array.push(arrayLike[i]);
|
|
71372
|
-
return array;
|
|
71373
|
-
}
|
|
71374
|
-
|
|
71375
|
-
function escapeXhtml(string) {
|
|
71376
|
-
return string.replace(/#/g, '%23').replace(/\n/g, '%0A');
|
|
71377
|
-
}
|
|
71378
|
-
|
|
71379
|
-
function width(node) {
|
|
71380
|
-
var leftBorder = px(node, 'border-left-width');
|
|
71381
|
-
var rightBorder = px(node, 'border-right-width');
|
|
71382
|
-
return node.scrollWidth + leftBorder + rightBorder;
|
|
71383
|
-
}
|
|
71384
|
-
|
|
71385
|
-
function height(node) {
|
|
71386
|
-
var topBorder = px(node, 'border-top-width');
|
|
71387
|
-
var bottomBorder = px(node, 'border-bottom-width');
|
|
71388
|
-
return node.scrollHeight + topBorder + bottomBorder;
|
|
71389
|
-
}
|
|
71390
|
-
|
|
71391
|
-
function px(node, styleProperty) {
|
|
71392
|
-
var value = window.getComputedStyle(node).getPropertyValue(styleProperty);
|
|
71393
|
-
return parseFloat(value.replace('px', ''));
|
|
71394
|
-
}
|
|
71395
|
-
}
|
|
71396
|
-
|
|
71397
|
-
function newInliner() {
|
|
71398
|
-
var URL_REGEX = /url\(['"]?([^'"]+?)['"]?\)/g;
|
|
71399
|
-
|
|
71400
|
-
return {
|
|
71401
|
-
inlineAll: inlineAll,
|
|
71402
|
-
shouldProcess: shouldProcess,
|
|
71403
|
-
impl: {
|
|
71404
|
-
readUrls: readUrls,
|
|
71405
|
-
inline: inline
|
|
71406
|
-
}
|
|
71407
|
-
};
|
|
71408
|
-
|
|
71409
|
-
function shouldProcess(string) {
|
|
71410
|
-
return string.search(URL_REGEX) !== -1;
|
|
71411
|
-
}
|
|
71412
|
-
|
|
71413
|
-
function readUrls(string) {
|
|
71414
|
-
var result = [];
|
|
71415
|
-
var match;
|
|
71416
|
-
while ((match = URL_REGEX.exec(string)) !== null) {
|
|
71417
|
-
result.push(match[1]);
|
|
71418
|
-
}
|
|
71419
|
-
return result.filter(function (url) {
|
|
71420
|
-
return !util.isDataUrl(url);
|
|
71421
|
-
});
|
|
71422
|
-
}
|
|
71423
|
-
|
|
71424
|
-
function inline(string, url, baseUrl, get) {
|
|
71425
|
-
return Promise.resolve(url)
|
|
71426
|
-
.then(function (url) {
|
|
71427
|
-
return baseUrl ? util.resolveUrl(url, baseUrl) : url;
|
|
71428
|
-
})
|
|
71429
|
-
.then(get || util.getAndEncode)
|
|
71430
|
-
.then(function (data) {
|
|
71431
|
-
return util.dataAsUrl(data, util.mimeType(url));
|
|
71432
|
-
})
|
|
71433
|
-
.then(function (dataUrl) {
|
|
71434
|
-
return string.replace(urlAsRegex(url), '$1' + dataUrl + '$3');
|
|
71435
|
-
});
|
|
71436
|
-
|
|
71437
|
-
function urlAsRegex(url) {
|
|
71438
|
-
return new RegExp('(url\\([\'"]?)(' + util.escape(url) + ')([\'"]?\\))', 'g');
|
|
71439
|
-
}
|
|
71440
|
-
}
|
|
71441
|
-
|
|
71442
|
-
function inlineAll(string, baseUrl, get) {
|
|
71443
|
-
if (nothingToInline()) return Promise.resolve(string);
|
|
71444
|
-
|
|
71445
|
-
return Promise.resolve(string)
|
|
71446
|
-
.then(readUrls)
|
|
71447
|
-
.then(function (urls) {
|
|
71448
|
-
var done = Promise.resolve(string);
|
|
71449
|
-
urls.forEach(function (url) {
|
|
71450
|
-
done = done.then(function (string) {
|
|
71451
|
-
return inline(string, url, baseUrl, get);
|
|
71452
|
-
});
|
|
71453
|
-
});
|
|
71454
|
-
return done;
|
|
71455
|
-
});
|
|
71456
|
-
|
|
71457
|
-
function nothingToInline() {
|
|
71458
|
-
return !shouldProcess(string);
|
|
71459
|
-
}
|
|
71460
|
-
}
|
|
71461
|
-
}
|
|
71462
|
-
|
|
71463
|
-
function newFontFaces() {
|
|
71464
|
-
return {
|
|
71465
|
-
resolveAll: resolveAll,
|
|
71466
|
-
impl: {
|
|
71467
|
-
readAll: readAll
|
|
71468
|
-
}
|
|
71469
|
-
};
|
|
71470
|
-
|
|
71471
|
-
function resolveAll() {
|
|
71472
|
-
return readAll()
|
|
71473
|
-
.then(function (webFonts) {
|
|
71474
|
-
return Promise.all(
|
|
71475
|
-
webFonts.map(function (webFont) {
|
|
71476
|
-
return webFont.resolve();
|
|
71477
|
-
})
|
|
71478
|
-
);
|
|
71479
|
-
})
|
|
71480
|
-
.then(function (cssStrings) {
|
|
71481
|
-
return cssStrings.join('\n');
|
|
71482
|
-
});
|
|
71483
|
-
}
|
|
71484
|
-
|
|
71485
|
-
function readAll() {
|
|
71486
|
-
return Promise.resolve(util.asArray(document.styleSheets))
|
|
71487
|
-
.then(getCssRules)
|
|
71488
|
-
.then(selectWebFontRules)
|
|
71489
|
-
.then(function (rules) {
|
|
71490
|
-
return rules.map(newWebFont);
|
|
71491
|
-
});
|
|
71492
|
-
|
|
71493
|
-
function selectWebFontRules(cssRules) {
|
|
71494
|
-
return cssRules
|
|
71495
|
-
.filter(function (rule) {
|
|
71496
|
-
return rule.type === CSSRule.FONT_FACE_RULE;
|
|
71497
|
-
})
|
|
71498
|
-
.filter(function (rule) {
|
|
71499
|
-
return inliner.shouldProcess(rule.style.getPropertyValue('src'));
|
|
71500
|
-
});
|
|
71501
|
-
}
|
|
71502
|
-
|
|
71503
|
-
function getCssRules(styleSheets) {
|
|
71504
|
-
var cssRules = [];
|
|
71505
|
-
styleSheets.forEach(function (sheet) {
|
|
71506
|
-
try {
|
|
71507
|
-
util.asArray(sheet.cssRules || []).forEach(cssRules.push.bind(cssRules));
|
|
71508
|
-
} catch (e) {
|
|
71509
|
-
console.log('Error while reading CSS rules from ' + sheet.href, e.toString());
|
|
71510
|
-
}
|
|
71511
|
-
});
|
|
71512
|
-
return cssRules;
|
|
71513
|
-
}
|
|
71514
|
-
|
|
71515
|
-
function newWebFont(webFontRule) {
|
|
71516
|
-
return {
|
|
71517
|
-
resolve: function resolve() {
|
|
71518
|
-
var baseUrl = (webFontRule.parentStyleSheet || {}).href;
|
|
71519
|
-
return inliner.inlineAll(webFontRule.cssText, baseUrl);
|
|
71520
|
-
},
|
|
71521
|
-
src: function () {
|
|
71522
|
-
return webFontRule.style.getPropertyValue('src');
|
|
71523
|
-
}
|
|
71524
|
-
};
|
|
71525
|
-
}
|
|
71526
|
-
}
|
|
71527
|
-
}
|
|
71528
|
-
|
|
71529
|
-
function newImages() {
|
|
71530
|
-
return {
|
|
71531
|
-
inlineAll: inlineAll,
|
|
71532
|
-
impl: {
|
|
71533
|
-
newImage: newImage
|
|
71534
|
-
}
|
|
71535
|
-
};
|
|
71536
|
-
|
|
71537
|
-
function newImage(element) {
|
|
71538
|
-
return {
|
|
71539
|
-
inline: inline
|
|
71540
|
-
};
|
|
71541
|
-
|
|
71542
|
-
function inline(get) {
|
|
71543
|
-
if (util.isDataUrl(element.src)) return Promise.resolve();
|
|
71544
|
-
|
|
71545
|
-
return Promise.resolve(element.src)
|
|
71546
|
-
.then(get || util.getAndEncode)
|
|
71547
|
-
.then(function (data) {
|
|
71548
|
-
return util.dataAsUrl(data, util.mimeType(element.src));
|
|
71549
|
-
})
|
|
71550
|
-
.then(function (dataUrl) {
|
|
71551
|
-
return new Promise(function (resolve, reject) {
|
|
71552
|
-
element.onload = resolve;
|
|
71553
|
-
element.onerror = reject;
|
|
71554
|
-
element.src = dataUrl;
|
|
71555
|
-
});
|
|
71556
|
-
});
|
|
71557
|
-
}
|
|
71558
|
-
}
|
|
71559
|
-
|
|
71560
|
-
function inlineAll(node) {
|
|
71561
|
-
if (!(node instanceof Element)) return Promise.resolve(node);
|
|
71562
|
-
|
|
71563
|
-
return inlineBackground(node)
|
|
71564
|
-
.then(function () {
|
|
71565
|
-
if (node instanceof HTMLImageElement)
|
|
71566
|
-
return newImage(node).inline();
|
|
71567
|
-
else
|
|
71568
|
-
return Promise.all(
|
|
71569
|
-
util.asArray(node.childNodes).map(function (child) {
|
|
71570
|
-
return inlineAll(child);
|
|
71571
|
-
})
|
|
71572
|
-
);
|
|
71573
|
-
});
|
|
71574
|
-
|
|
71575
|
-
function inlineBackground(node) {
|
|
71576
|
-
var background = node.style.getPropertyValue('background');
|
|
71577
|
-
|
|
71578
|
-
if (!background) return Promise.resolve(node);
|
|
71579
|
-
|
|
71580
|
-
return inliner.inlineAll(background)
|
|
71581
|
-
.then(function (inlined) {
|
|
71582
|
-
node.style.setProperty(
|
|
71583
|
-
'background',
|
|
71584
|
-
inlined,
|
|
71585
|
-
node.style.getPropertyPriority('background')
|
|
71586
|
-
);
|
|
71587
|
-
})
|
|
71588
|
-
.then(function () {
|
|
71589
|
-
return node;
|
|
71590
|
-
});
|
|
71591
|
-
}
|
|
71592
|
-
}
|
|
71593
|
-
}
|
|
71594
|
-
})();
|
|
71595
|
-
} (domToImage));
|
|
71596
|
-
|
|
71597
|
-
var domToImageExports = domToImage.exports;
|
|
71598
|
-
var domtoimage = /*@__PURE__*/getDefaultExportFromCjs(domToImageExports);
|
|
71599
|
-
|
|
71600
|
-
function getTemplateHTML(data) {
|
|
71601
|
-
var _a, _b, _c;
|
|
71602
|
-
const isProfit = data.data.payout * +data.data.payoutTokenPrice - data.data.dollarValue > 0;
|
|
71603
|
-
const getTokenImage = (symbol) => {
|
|
71604
|
-
return `${APESWAP_LIST_REPO}/assets/${symbol.toUpperCase()}.png`;
|
|
71605
|
-
};
|
|
71606
|
-
const getPrincipalToken = () => {
|
|
71607
|
-
var _a, _b, _c, _d;
|
|
71608
|
-
if (((_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.payoutTokenData.address.toLowerCase()) !== ((_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b.token0.address.toLowerCase()))
|
|
71609
|
-
return (_c = data === null || data === void 0 ? void 0 : data.data) === null || _c === void 0 ? void 0 : _c.token0.symbol;
|
|
71610
|
-
return (_d = data === null || data === void 0 ? void 0 : data.data) === null || _d === void 0 ? void 0 : _d.token1.symbol;
|
|
71611
|
-
};
|
|
71612
|
-
const getCalculateOff = () => {
|
|
71613
|
-
if (!data || !data.data)
|
|
71614
|
-
return 0;
|
|
71615
|
-
return 100 - (data.data.dollarValue / (data.data.payout * +data.data.payoutTokenPrice)) * 100;
|
|
71616
|
-
};
|
|
71617
|
-
const getCalculatePriceDiscount = () => {
|
|
71618
|
-
if (!data || !data.data)
|
|
71619
|
-
return 0;
|
|
71620
|
-
return +data.data.payoutTokenPrice - (+data.data.payoutTokenPrice * getCalculateOff()) / 100;
|
|
71621
|
-
};
|
|
71622
|
-
return `
|
|
71623
|
-
<div id="template-card" class="sharebondimage-card">
|
|
71624
|
-
<img src="/images/bills/title.png" alt="title" style="width: 169px; height: 52px;" />
|
|
71625
|
-
<div class="sharebondimage-nft">
|
|
71626
|
-
<div style="position: relative">
|
|
71627
|
-
<div class="sharebondimage-nft-id">
|
|
71628
|
-
<span>#${data.tokenId}</span>
|
|
71629
|
-
</div>
|
|
71630
|
-
<img src="${data.image}" alt="bill-nft" />
|
|
71631
|
-
</div>
|
|
71632
|
-
</div>
|
|
71633
|
-
<div class="sharebondimage-container-info">
|
|
71634
|
-
<div class="sharebondimage-container-discount">
|
|
71635
|
-
<img src="${getTokenImage((_a = data.data) === null || _a === void 0 ? void 0 : _a.payoutTokenData.symbol)}" alt="payout-token-symbol" style="width: 59px; height: 59px;" />
|
|
71636
|
-
<div class="sharebondimage-container-discount-price">
|
|
71637
|
-
<div class="sharebondimage-container-discount-token">
|
|
71638
|
-
<span>${(_b = data.data) === null || _b === void 0 ? void 0 : _b.payoutTokenData.symbol}</span>
|
|
71639
|
-
<span style="text-decoration: line-through">
|
|
71640
|
-
$${formatTransactionAmount(+data.data.payoutTokenPrice)}
|
|
71641
|
-
</span>
|
|
71642
|
-
</div>
|
|
71643
|
-
<span class="sharebondimage-container-discount-price-discount">
|
|
71644
|
-
$${formatTransactionAmount(getCalculatePriceDiscount())}
|
|
71645
|
-
</span>
|
|
71646
|
-
</div>
|
|
71647
|
-
<div class="sharebondimage-container-off">
|
|
71648
|
-
<span>
|
|
71649
|
-
${formatNumber$3(getCalculateOff())}% OFF
|
|
71650
|
-
</span>
|
|
71651
|
-
</div>
|
|
71652
|
-
</div>
|
|
71653
|
-
<div class="sharebondimage-container-tokens">
|
|
71654
|
-
<div class="sharebondimage-container-token">
|
|
71655
|
-
<img src="${getTokenImage(getPrincipalToken())}" alt="principal-symbol" />
|
|
71656
|
-
<div class="sharebondimage-amount-deposit">
|
|
71657
|
-
${formatTransactionAmount(data.data.deposit)}
|
|
71658
|
-
</div>
|
|
71659
|
-
<div class="sharebondimage-dollarvalue">
|
|
71660
|
-
$${formatNumber$3(data.data.dollarValue)}
|
|
71661
|
-
</div>
|
|
71662
|
-
</div>
|
|
71663
|
-
<div class="sharebondimage-container-token">
|
|
71664
|
-
<img src="${getTokenImage((_c = data.data) === null || _c === void 0 ? void 0 : _c.payoutTokenData.symbol)}" alt="payout-token2-symbol" />
|
|
71665
|
-
<div class="sharebondimage-container-earntoken">
|
|
71666
|
-
<div class="sharebondimage-amount-earntoken">
|
|
71667
|
-
<div class="sharebondimage-amount-payout">
|
|
71668
|
-
${formatNumber$3(data.data.payout)}
|
|
71669
|
-
</div>
|
|
71670
|
-
<div class="sharebondimage-amount-dollarvalue">
|
|
71671
|
-
$${formatNumber$3(data.data.payout * +data.data.payoutTokenPrice)}
|
|
71672
|
-
</div>
|
|
71673
|
-
</div>
|
|
71674
|
-
<div class="sharebondimage-profit" style="${!isProfit ? 'display: none' : ''}">
|
|
71675
|
-
<span>
|
|
71676
|
-
+${formatNumber$3(data.data.payout * +data.data.payoutTokenPrice - data.data.dollarValue)}
|
|
71677
|
-
profit!
|
|
71678
|
-
</span>
|
|
71679
|
-
</div>
|
|
71680
|
-
</div>
|
|
71681
|
-
</div>
|
|
71682
|
-
</div>
|
|
71683
|
-
</div>
|
|
71684
|
-
</div>
|
|
71685
|
-
`;
|
|
71686
|
-
}
|
|
71687
|
-
|
|
71688
|
-
function generateImageFromTemplate(bondNFTData, link, apiUrl) {
|
|
71689
|
-
return __awaiter$9(this, void 0, void 0, function* () {
|
|
71690
|
-
var _a;
|
|
71691
|
-
if (bondNFTData) {
|
|
71692
|
-
const container = document.createElement('div');
|
|
71693
|
-
container.style.position = 'absolute';
|
|
71694
|
-
container.style.top = '-9999px';
|
|
71695
|
-
container.innerHTML = getTemplateHTML(bondNFTData);
|
|
71696
|
-
document.body.appendChild(container);
|
|
71697
|
-
const templateElement = container.querySelector('#template-card');
|
|
71698
|
-
if (!templateElement)
|
|
71699
|
-
return;
|
|
71700
|
-
const fileName = `bond_share_${(_a = bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.data.billNftAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()}_${bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.chainId}_${bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.tokenId}`;
|
|
71701
|
-
const existingImage = yield checkImageExists(fileName);
|
|
71702
|
-
if (existingImage) {
|
|
71703
|
-
share(link);
|
|
71704
|
-
}
|
|
71705
|
-
else {
|
|
71706
|
-
domtoimage
|
|
71707
|
-
.toJpeg(templateElement)
|
|
71708
|
-
.then((dataUrl) => __awaiter$9(this, void 0, void 0, function* () {
|
|
71709
|
-
const response = yield fetch(dataUrl);
|
|
71710
|
-
const blob = yield response.blob();
|
|
71711
|
-
let formData = new FormData();
|
|
71712
|
-
formData.append('file', blob, fileName);
|
|
71713
|
-
yield axios.post(`${apiUrl}/cloudinary/uploadFile`, formData, {
|
|
71714
|
-
headers: { 'Content-Type': 'multipart/form-data' },
|
|
71715
|
-
});
|
|
71716
|
-
share(link);
|
|
71717
|
-
}))
|
|
71718
|
-
.catch((error) => {
|
|
71719
|
-
console.error('Error converting image:', error);
|
|
71720
|
-
});
|
|
71721
|
-
}
|
|
71722
|
-
}
|
|
71723
|
-
});
|
|
71724
|
-
}
|
|
71725
|
-
function share(link) {
|
|
71726
|
-
const linkElement = document.createElement('a');
|
|
71727
|
-
linkElement.href = link;
|
|
71728
|
-
linkElement.target = '_blank';
|
|
71729
|
-
linkElement.click();
|
|
71730
|
-
}
|
|
71731
|
-
function checkImageExists(fileName) {
|
|
71732
|
-
return __awaiter$9(this, void 0, void 0, function* () {
|
|
71733
|
-
let existImg = true;
|
|
71734
|
-
try {
|
|
71735
|
-
yield axios.get(`https://res.cloudinary.com/dtlafxop8/image/upload/v1/bond_share/${fileName}.jpg`);
|
|
71736
|
-
}
|
|
71737
|
-
catch (e) {
|
|
71738
|
-
existImg = false;
|
|
71739
|
-
}
|
|
71740
|
-
return existImg;
|
|
71741
|
-
});
|
|
71742
|
-
}
|
|
71743
|
-
|
|
71744
|
-
const LinkShare = ({ bondNFTData, userBill, }) => {
|
|
71745
|
-
var _a;
|
|
71746
|
-
const mainUrl = useURLByEnvironment('mainUrl');
|
|
71747
|
-
const apiUrl = useURLByEnvironment('apiV2');
|
|
71748
|
-
const shareUrl = `${mainUrl}/bond-nft?bondAddress=${(_a = bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.data.billNftAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()}%26bondChain=${bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.chainId}%26tokenId=${userBill === null || userBill === void 0 ? void 0 : userBill.id}`;
|
|
71749
|
-
const text = `I've filled my bags with $${userBill === null || userBill === void 0 ? void 0 : userBill.bond.earnToken.symbol} at a discount, thanks to Bonds-only on @apebond! Check it out: `;
|
|
71750
|
-
return (jsxs(Flex$1, { sx: styles$a.containerLinksShare, children: [jsx$2(Flex$1, { sx: styles$a.linkShareButton, onClick: () => generateImageFromTemplate(bondNFTData, `https://twitter.com/intent/tweet?text=${text}&url=${shareUrl}`, apiUrl), children: jsx$2(Svg, { icon: "twitter", width: 16 }) }), jsx$2(Flex$1, { sx: styles$a.linkShareButton, onClick: () => generateImageFromTemplate(bondNFTData, `https://warpcast.com/~/compose?text=${text}&embeds[]=${shareUrl}`, apiUrl), children: jsx$2(Svg, { icon: "Farcaster", width: 16 }) })] }));
|
|
71751
|
-
};
|
|
71752
|
-
|
|
71753
70806
|
const YourBondsModal = ({ onDismiss, userBill }) => {
|
|
71754
70807
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
|
|
71755
70808
|
// Hooks
|
|
@@ -71819,7 +70872,7 @@ const YourBondsModal = ({ onDismiss, userBill }) => {
|
|
|
71819
70872
|
justifyContent: 'center',
|
|
71820
70873
|
alignItems: 'center',
|
|
71821
70874
|
zIndex: 1,
|
|
71822
|
-
}, children: jsx$2(Spinner, { width: 100 }) }))
|
|
70875
|
+
}, children: jsx$2(Spinner, { width: 100 }) }))] }), jsxs(Flex$1, { className: "yourbondsmodal yourbondinfo", children: [jsxs(Flex$1, { className: "yourbondinfo title-container", children: [jsx$2(Flex$1, { className: "title-container bondicon", children: userBill && (jsx$2(TokenImage, { symbol: (_h = (_g = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _g === void 0 ? void 0 : _g.showcaseTokenName) !== null && _h !== void 0 ? _h : (_k = (_j = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _j === void 0 ? void 0 : _j.earnToken) === null || _k === void 0 ? void 0 : _k.symbol, size: 40, chain: userBill === null || userBill === void 0 ? void 0 : userBill.bond.chainId })) }), jsx$2(Flex$1, { className: "title-container tokenname", children: (_m = (_l = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _l === void 0 ? void 0 : _l.showcaseTokenName) !== null && _m !== void 0 ? _m : userBill === null || userBill === void 0 ? void 0 : userBill.bond.earnToken.symbol }), jsx$2(Flex$1, { className: "title-container tokentags", children: (_p = (_o = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _o === void 0 ? void 0 : _o.tags) === null || _p === void 0 ? void 0 : _p.slice(0, 1).map((tag) => {
|
|
71823
70876
|
return (jsx$2(Flex$1, { sx: { marginRight: '10px' }, children: jsx$2(ListTag, { text: tag === null || tag === void 0 ? void 0 : tag.toUpperCase() }) }, tag));
|
|
71824
70877
|
}) }), jsxs(Text, { sx: { color: 'text', opacity: '0.6', fontSize: ['12px', '12px', '12px', '16px'] }, children: ["#", userBill === null || userBill === void 0 ? void 0 : userBill.id] })] }), jsxs(Flex$1, { className: "yourbondinfo blocks-container", children: [jsxs(Flex$1, { className: "attributes-container", children: [jsxs(Flex$1, { className: "attributes-header", sx: {
|
|
71825
70878
|
borderRadius: `${isOpenTraits ? '6px 6px 0px 0px' : 'normal'}`,
|
|
@@ -72142,10 +71195,12 @@ function useUserBonds() {
|
|
|
72142
71195
|
}
|
|
72143
71196
|
const getUserBonds = (account, bondList) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
72144
71197
|
try {
|
|
72145
|
-
|
|
72146
|
-
|
|
72147
|
-
|
|
72148
|
-
|
|
71198
|
+
const results = yield Promise.allSettled(MAINNET_CHAINS.map((chain) => fetchUserOwnedBillsDataAsync(chain, account, bondList)));
|
|
71199
|
+
// Filter out only fulfilled promises
|
|
71200
|
+
const fulfilledResults = results
|
|
71201
|
+
.filter((result) => result.status === 'fulfilled')
|
|
71202
|
+
.map((result) => result.value);
|
|
71203
|
+
return fulfilledResults.flat().flatMap((result) => result.userOwnedBills);
|
|
72149
71204
|
}
|
|
72150
71205
|
catch (_a) {
|
|
72151
71206
|
return [];
|
|
@@ -72542,8 +71597,8 @@ const remainingPercentage = (bond) => {
|
|
|
72542
71597
|
};
|
|
72543
71598
|
const getDiscountColor = (discount) => {
|
|
72544
71599
|
if (!discount)
|
|
72545
|
-
return '
|
|
72546
|
-
return discount < 0 ? '
|
|
71600
|
+
return '';
|
|
71601
|
+
return discount < 0 ? 'discount-negative' : 'discount-positive';
|
|
72547
71602
|
};
|
|
72548
71603
|
const calculateARR = (bond) => {
|
|
72549
71604
|
const discount2 = 'discount' in bond ? bond.discount : undefined;
|
|
@@ -73821,15 +72876,11 @@ const ZapModal = ({ onDismiss, outputToken, account, chainId }) => {
|
|
|
73821
72876
|
: 'BUY' })) }), jsx$2(Flex, { sx: { marginTop: '10px', justifyContent: 'center' }, children: jsx$2(Link, { href: "https://docs.ape.bond/apebond/products-and-features/zap", target: "_blank", rel: "noopener noreferrer", sx: { textDecoration: 'none' }, children: jsxs(Text, { style: { fontSize: '12px', lineHeight: '18px', fontWeight: 400, borderBottom: '1px solid' }, children: ["Learn more", '>'] }) }) })] })] }));
|
|
73822
72877
|
};
|
|
73823
72878
|
|
|
73824
|
-
const AccordionText = ({
|
|
73825
|
-
const [isDropdownExpanded, setIsDropdownExpanded] = useState(false);
|
|
73826
|
-
const toggleDropdown = () => {
|
|
73827
|
-
setIsDropdownExpanded(!isDropdownExpanded);
|
|
73828
|
-
};
|
|
72879
|
+
const AccordionText = ({ isVisible = false }) => {
|
|
73829
72880
|
if (!isVisible) {
|
|
73830
72881
|
return null;
|
|
73831
72882
|
}
|
|
73832
|
-
return (jsxs(Fragment$1, { children: [
|
|
72883
|
+
return (jsxs(Fragment$1, { children: [jsx$2(Flex, { className: "accordion-title", children: "Bonds at Seedify are an exciting new product!" }), jsx$2(AnimatePresence, { children: jsx$2(motion.div, { initial: { height: 0 }, animate: { height: 'fit-content' }, transition: { opacity: { duration: 0.2 } }, exit: { height: 0 }, sx: { overflow: 'hidden', width: '100%' }, children: jsxs(Flex, { className: "accordion-body", sx: { flexDirection: 'column' }, children: [jsx$2("p", { children: "Are you a strong believer in a project? Do you want to buy project tokens at a discount compared to the market? If so, you've arrived at the right place!" }), jsx$2("p", { children: "Bonds allow you to purchase project tokens at a discounted price with a short-term linear vesting. Its a perfect solution for projects you're planning to buy and hold tokens of!" }), jsx$2("p", { children: "When you buy a Bond, you essentially are given an NFT (which you can transfer across your wallets). Whichever wallet owns the NFT will be able to Claim tokens of that project post-purchase until vesting period ends. Bonds at Seedify can range their vesting from 7 Days to 90 Days, with 30 Days being the standard." })] }) }) })] }));
|
|
73833
72884
|
};
|
|
73834
72885
|
|
|
73835
72886
|
const useSoulZapBondQuote = (typedValue, inputCurrency, bond, account) => {
|
|
@@ -74060,13 +73111,25 @@ const ProjectDescription = ({ description }) => {
|
|
|
74060
73111
|
}, onClick: () => setIsOpen(true), children: ["View More ", '>'] }))] }), jsx$2(Flex, { sx: { display: ['none', 'none', 'none', 'flex'] }, children: jsx$2(SafeHTMLComponent, { html: description !== null && description !== void 0 ? description : '' }) })] }));
|
|
74061
73112
|
};
|
|
74062
73113
|
|
|
73114
|
+
const BondModalHeaderAlt = ({ bondData, onDismiss, showProjectInfoButton, }) => {
|
|
73115
|
+
const [onOpenSlippageModal] = useModal(jsx$2(SlippageModal, {}));
|
|
73116
|
+
const handleClose = () => {
|
|
73117
|
+
if (typeof window !== 'undefined') {
|
|
73118
|
+
window.history.pushState({}, '', `/bonds`);
|
|
73119
|
+
}
|
|
73120
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
73121
|
+
};
|
|
73122
|
+
return (jsx$2(Flex, { className: "modaltable-container title-container", children: jsx$2(Flex, { className: "slipagge-close-icons", sx: { flexDirection: 'row' }, children: onDismiss ? (jsxs(Fragment$1, { children: [jsx$2(Flex, { sx: { mb: '-5px', pr: '10px' }, onClick: onOpenSlippageModal, children: jsx$2(Svg, { icon: "cog", width: "16px" }) }), jsx$2(IconButton, { icon: "close", color: "text", variant: "transparent", onClick: handleClose })] })) : (jsx$2(Flex, { sx: {}, onClick: onOpenSlippageModal, children: jsx$2(Svg, { icon: "cog", width: "16px" }) })) }) }));
|
|
73123
|
+
};
|
|
73124
|
+
|
|
74063
73125
|
const BondModal = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond,
|
|
74064
73126
|
// ??
|
|
74065
|
-
accordionTitle = 'What are Bonds?', accordionBody = 'Body',
|
|
73127
|
+
accordionTitle = 'What are Bonds?', accordionBody = 'Body', }) => {
|
|
74066
73128
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
74067
73129
|
const SDKConfig = useSDKConfig();
|
|
74068
73130
|
// State
|
|
74069
73131
|
const [modalVariant, setModalVariant] = useState(SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.modalVariant);
|
|
73132
|
+
const [accordionVisible, setAccordionVisible] = useState(false);
|
|
74070
73133
|
// Hooks
|
|
74071
73134
|
const userChainId = useChainId();
|
|
74072
73135
|
const { address: account } = useAccount();
|
|
@@ -74264,15 +73327,15 @@ accordionTitle = 'What are Bonds?', accordionBody = 'Body', accordionVisible = f
|
|
|
74264
73327
|
(bondData === null || bondData === void 0 ? void 0 : bondData.soldOut) ||
|
|
74265
73328
|
!account ||
|
|
74266
73329
|
!inputValue ||
|
|
74267
|
-
parseFloat(inputValue) === 0, onClick: handleApprove, children: "enable" })) })] })
|
|
74268
|
-
|
|
73330
|
+
parseFloat(inputValue) === 0, onClick: handleApprove, children: "enable" })) })] })] })] })) })) : (jsx$2(Fragment$1, { children: bondData && (jsxs(Flex, { className: "modal-content font-small gpt", children: [typeof window !== 'undefined' && window.location.origin === 'http://localhost:5173' && (jsxs(Text, { sx: { borderBottom: '1px solid white' }, children: ["Dev Mode - Current view: \"alt\"", jsx$2(Text, { onClick: () => setModalVariant('standard'), sx: { ml: '15px', textDecoration: 'underline', cursor: 'pointer' }, children: "Switch view" })] })), jsx$2(Flex, { className: "bondmodal-header-alt", sx: { mb: '20px' }, children: jsx$2(BondModalHeaderAlt, { bondData: bondData, onDismiss: onDismiss, showProjectInfoButton: (SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.referenceId) === 'apebond' }) }), jsxs(Flex, { className: "modaltable-container", sx: { flexDirection: 'row', gap: '20px' }, children: [jsxs(Flex, { sx: { width: '500px', flexDirection: 'column' }, children: [jsx$2("img", { src: "https://placehold.co/400x200" }), jsx$2(Flex, { className: "modaltable-container description-container paragraph-spaced", sx: { marginTop: '20px' }, children: bondData === null || bondData === void 0 ? void 0 : bondData.shortDescription })] }), jsxs(Flex, { sx: { flexDirection: 'column', width: '600px' }, children: [jsxs(Flex, { sx: { alignItems: 'center' }, children: [jsx$2(Flex, { sx: { minWidth: '300px' }, children: jsxs("h2", { sx: { margin: '0px' }, children: [bondData === null || bondData === void 0 ? void 0 : bondData.showcaseTokenName, ' ', jsx$2(Svg, { width: 20, height: 20, icon: (_k = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[bondData.chainId]) !== null && _k !== void 0 ? _k : 'question' })] }) }), jsxs(Flex, { sx: { justifyContent: 'space-between', flexGrow: 1 }, children: [jsx$2(TokenImage, { symbol: (_l = bondData.showcaseTokenName) !== null && _l !== void 0 ? _l : bondData.earnToken.symbol, size: 20 }), jsx$2("span", { children: bondData.earnToken.symbol }), " ", jsx$2("span", { children: "|" }), ' ', jsxs("span", { children: ["Market Price: $", earnTokenPrice(bondData)] })] })] }), jsxs(Flex, { sx: { flexDirection: 'column', marginTop: '20px' }, children: [jsx$2(TokenSelectorPanel, { typedValue: inputValue, setTypedValue: setInputValue, selectedToken: inputToken, handleMaxBtn: () => { var _a; return setInputValue((_a = new BigNumber$1(inputCurrencyBalance !== null && inputCurrencyBalance !== void 0 ? inputCurrencyBalance : '0')) === null || _a === void 0 ? void 0 : _a.toString()); }, handleCurrencySelect: handleCurrencySelect, chainId: bondData === null || bondData === void 0 ? void 0 : bondData.chainId, enableZap: true, bondPrincipalToken: bondData === null || bondData === void 0 ? void 0 : bondData.lpToken, tokenBalance: inputCurrencyBalance, selectedTokenPrice: inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price }), jsxs(Flex, { className: "modal-youreceive-row", sx: { justifyContent: 'space-between', alignItems: 'center' }, children: [jsxs(Flex, { className: "modal-youreceive-textbox", children: ["You will receive:", jsx$2(Flex, { className: "modal-youreceive-tokenimage", sx: { marginLeft: '15px', marginRight: '5px' }, children: jsx$2(TokenImage, { symbol: (_m = bondData.showcaseTokenName) !== null && _m !== void 0 ? _m : bondData.earnToken.symbol, size: 20 }) }), jsxs("span", { className: "modal-receive-text", children: [(lodashExports.toNumber(inputValue) / lodashExports.toNumber(earnTokenPrice(bondData))).toFixed(0), ' ', bondData.earnToken.symbol, " + \u00A0", (youGet(bondData, inputValue) -
|
|
73331
|
+
lodashExports.toNumber(inputValue) / lodashExports.toNumber(earnTokenPrice(bondData))).toFixed(0)] }), jsx$2("span", { className: "text-highlight", children: "\u00A0additional" })] }), jsx$2(Flex, { className: "button-container buy", sx: { justifyContent: 'end' }, children: !account ? (jsx$2(ConnectButton, {})) : userChainId !== bondData.chainId ? (jsx$2(Button, { className: "switch-button button-narrow", disabled: loadingTx || isConfirming || (bondData === null || bondData === void 0 ? void 0 : bondData.soldOut), onClick: (event) => {
|
|
74269
73332
|
event.stopPropagation();
|
|
74270
73333
|
switchChain({ chainId: bondData.chainId });
|
|
74271
|
-
}, children: `Switch to ${NETWORK_LABEL[bondData.chainId]}` })) : approvalState === ApprovalState.APPROVED ? (jsxs(Button, { className: "action-button", load: load, disabled: load || (bondData === null || bondData === void 0 ? void 0 : bondData.soldOut) || !account || !inputValue || parseFloat(inputValue) === 0, onClick: handleBothPurchases, children: ["buy
|
|
73334
|
+
}, children: `Switch to ${NETWORK_LABEL[bondData.chainId]}` })) : approvalState === ApprovalState.APPROVED ? (jsxs(Button, { className: "action-button", load: load, disabled: load || (bondData === null || bondData === void 0 ? void 0 : bondData.soldOut) || !account || !inputValue || parseFloat(inputValue) === 0, onClick: handleBothPurchases, children: ["buy", ' ', isZap ? (jsx$2("span", { style: { marginLeft: '8px' }, children: jsx$2(Svg, { icon: "ZapIcon" }) })) : ('')] })) : (jsx$2(Button, { className: "action-button", load: approvalState === ApprovalState.PENDING, disabled: approvalState === ApprovalState.PENDING ||
|
|
74272
73335
|
(bondData === null || bondData === void 0 ? void 0 : bondData.soldOut) ||
|
|
74273
73336
|
!account ||
|
|
74274
73337
|
!inputValue ||
|
|
74275
|
-
parseFloat(inputValue) === 0, onClick: handleApprove, children: "enable" })) })] }), jsx$2(Flex, { sx: { width: '100%', marginTop: '10px', marginBottom: '10px' }, children: jsx$2("hr", { className: "fading-hr" }) }), jsxs(Flex, { sx: { width: '100%' }, children: [jsxs(Flex, { sx: { width: '50%', flexDirection: 'column' }, children: ["Market Price: $", formatUSDNumber((youGet(bondData, inputValue) * lodashExports.toNumber(earnTokenPrice(bondData))).toString()), jsx$2("hr", { className: "fading-hr" }), jsx$2("span", { className: "text-highlight flex-inline", children: "Our price: " }), jsxs("span", { className: "flex-inline", children: ["$", formatUSDNumber((lodashExports.toNumber(inputValue) * lodashExports.toNumber(bondData.principalTokenPrice)).toString()), ' '] }), jsxs("span", { className: "text-highlight flex-inline", children: ["(discount rate ", bondData === null || bondData === void 0 ? void 0 : bondData.discount.toFixed(2), "%)"] })] }), jsx$2(Flex, { sx: { width: '50px', alignItems: 'center', justifyContent: 'center' }, children: "vs." }), jsxs(Flex, { sx: { width: '50%', flexDirection: 'column' }, children: ["If purchased from market:", ' ', (lodashExports.toNumber(inputValue) / lodashExports.toNumber(earnTokenPrice(bondData))).toFixed(0), ' ', bondData.earnToken.symbol, jsx$2("hr", { className: "fading-hr" }), jsx$2("span", { className: "text-highlight flex-inline", children: "Amount you will get:" }), ' ', youGet(bondData, inputValue).toFixed(0), ' ', jsx$2("span", { className: "flex-inline", children: bondData.earnToken.symbol })] })] })] })] })] }), jsxs(Flex, { className: "footer-details", children: [jsxs(Flex, { sx: { width: '25%', justifyContent: 'center' }, children: ["Vesting start date:", ' ', new Intl.DateTimeFormat('en-GB', { day: '2-digit', month: 'short', year: 'numeric' }).format(new Date())] }), jsxs(Flex, { sx: { width: '25%', justifyContent: 'center' }, children: ["Vesting end date:", ' ', new Intl.DateTimeFormat('en-GB', { day: '2-digit', month: 'short', year: 'numeric' }).format(new Date(Date.now() + vestingTime((_o = bondData === null || bondData === void 0 ? void 0 : bondData.vestingTerm) !== null && _o !== void 0 ? _o : 0).days * 86400000))] }), jsx$2(Flex, { sx: { width: '25%', justifyContent: 'center' }, children: "Vesting type: Linear" }),
|
|
73338
|
+
parseFloat(inputValue) === 0, onClick: handleApprove, children: "enable" })) })] }), jsx$2(Flex, { sx: { width: '100%', marginTop: '10px', marginBottom: '10px' }, children: jsx$2("hr", { className: "fading-hr" }) }), jsxs(Flex, { sx: { width: '100%' }, children: [jsxs(Flex, { sx: { width: '50%', flexDirection: 'column' }, children: ["Market Price: $", formatUSDNumber((youGet(bondData, inputValue) * lodashExports.toNumber(earnTokenPrice(bondData))).toString()), jsx$2("hr", { className: "fading-hr" }), jsx$2("span", { className: "text-highlight flex-inline", children: "Our price: " }), jsxs("span", { className: "flex-inline", children: ["$", formatUSDNumber((lodashExports.toNumber(inputValue) * lodashExports.toNumber(bondData.principalTokenPrice)).toString()), ' '] }), jsxs("span", { className: "text-highlight flex-inline", children: ["(discount rate ", bondData === null || bondData === void 0 ? void 0 : bondData.discount.toFixed(2), "%)"] })] }), jsx$2(Flex, { sx: { width: '50px', alignItems: 'center', justifyContent: 'center' }, children: "vs." }), jsxs(Flex, { sx: { width: '50%', flexDirection: 'column' }, children: ["If purchased from market:", ' ', (lodashExports.toNumber(inputValue) / lodashExports.toNumber(earnTokenPrice(bondData))).toFixed(0), ' ', bondData.earnToken.symbol, jsx$2("hr", { className: "fading-hr" }), jsx$2("span", { className: "text-highlight flex-inline", children: "Amount you will get:" }), ' ', youGet(bondData, inputValue).toFixed(0), ' ', jsx$2("span", { className: "flex-inline", children: bondData.earnToken.symbol })] })] })] })] })] }), jsxs(Flex, { className: "footer-details", children: [jsxs(Flex, { sx: { width: '25%', justifyContent: 'center' }, children: ["Vesting start date:", ' ', new Intl.DateTimeFormat('en-GB', { day: '2-digit', month: 'short', year: 'numeric' }).format(new Date())] }), jsxs(Flex, { sx: { width: '25%', justifyContent: 'center' }, children: ["Vesting end date:", ' ', new Intl.DateTimeFormat('en-GB', { day: '2-digit', month: 'short', year: 'numeric' }).format(new Date(Date.now() + vestingTime((_o = bondData === null || bondData === void 0 ? void 0 : bondData.vestingTerm) !== null && _o !== void 0 ? _o : 0).days * 86400000))] }), jsx$2(Flex, { sx: { width: '25%', justifyContent: 'center' }, children: "Vesting type: Linear" }), jsxs(Flex, { sx: { width: '25%', justifyContent: 'center' }, onClick: () => setAccordionVisible(!accordionVisible), children: ["What are bonds? \u00A0 ", jsx$2(Svg, { icon: "caret", direction: accordionVisible ? 'up' : 'down' })] })] }), accordionVisible && (jsx$2(Flex, { className: "modaltable-container accordion-container", children: jsx$2(AccordionText, { isVisible: accordionVisible }) }))] })) })) }));
|
|
74276
73339
|
};
|
|
74277
73340
|
|
|
74278
73341
|
/*
|
|
@@ -74462,7 +73525,11 @@ var ProgressBarWrapper$1 = React__default.memo(ProgressBarWrapper);
|
|
|
74462
73525
|
|
|
74463
73526
|
const BondRow = ({ bond }) => {
|
|
74464
73527
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
74465
|
-
const billAddress = 'billAddress' in bond
|
|
73528
|
+
const billAddress = 'billAddress' in bond
|
|
73529
|
+
? bond.billAddress
|
|
73530
|
+
: 'contractAddress' in bond
|
|
73531
|
+
? bond.contractAddress[bond.chainId]
|
|
73532
|
+
: undefined;
|
|
74466
73533
|
const discount = 'discount' in bond ? bond.discount : undefined;
|
|
74467
73534
|
// Modal
|
|
74468
73535
|
const [openBuyModal] = useModal(jsx$2(ModalHandler, { bondAddress: billAddress, bondChain: bond.chainId }), true, true, `buyBondModal-${billAddress}-${bond.chainId}`);
|
|
@@ -74501,7 +73568,7 @@ const BondRow = ({ bond }) => {
|
|
|
74501
73568
|
const tokens = new BigNumber$1(tokensRemaining);
|
|
74502
73569
|
return tokens.times(payoutTokenPrice);
|
|
74503
73570
|
};
|
|
74504
|
-
return (jsxs("div", { className: "bond-row", onClick: handleOpenModal, children: [jsx$2("div", { className: "token-info-container", children: jsx$2(TokenInfoAndName, { bill: bond }) }), jsxs("div", { className: "bond-info-columns", children: [jsx$2("div", { className:
|
|
73571
|
+
return (jsxs("div", { className: "bond-row", onClick: handleOpenModal, children: [jsx$2("div", { className: "token-info-container", children: jsx$2(TokenInfoAndName, { bill: bond }) }), jsxs("div", { className: "bond-info-columns", children: [jsx$2("div", { className: `discount-column ${getDiscountColor(discount)}`, children: discount !== undefined ? `${discount === null || discount === void 0 ? void 0 : discount.toFixed(2)}%` : '-' }), jsx$2("div", { className: "arr-column", children: calculateARR(bond) !== undefined ? calculateARR(bond) : '-' }), jsx$2("div", { className: "terms-column", children: ((_a = vestingTime(bond === null || bond === void 0 ? void 0 : bond.vestingTerm)) === null || _a === void 0 ? void 0 : _a.days) ? `${(_b = vestingTime(bond === null || bond === void 0 ? void 0 : bond.vestingTerm)) === null || _b === void 0 ? void 0 : _b.days} D` : '-' }), jsx$2("div", { className: "tokens-remaining-column", children: jsx$2(ProgressBarWrapper$1, { title: '', value: jsx$2(ProgressBar, { value: remainingPercentage(bond) }), style: {
|
|
74505
73572
|
width: '127px',
|
|
74506
73573
|
height: '25px',
|
|
74507
73574
|
flexDirection: 'column',
|
|
@@ -74529,7 +73596,7 @@ const HotBondCard = ({ bond }) => {
|
|
|
74529
73596
|
},
|
|
74530
73597
|
});
|
|
74531
73598
|
};
|
|
74532
|
-
return (jsx$2(Flex, { sx: styles$
|
|
73599
|
+
return (jsx$2(Flex, { sx: styles$a.desktopCard, onClick: handleOpenModal, children: jsxs(Flex, { sx: { flexDirection: 'column', width: '100%' }, children: [jsxs(Flex, { sx: { width: '100%', height: '75px' }, children: [jsx$2(Flex, { sx: { width: '66.66%' }, children: jsx$2(TokenInfoAndName, { bill: bond, isHotBond: true }) }), jsx$2(Flex, { className: "column column-tokenicons", sx: { width: '33.33% !important', justifyContent: 'center !important', alignItems: 'center' }, children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(BondInfoTooltip, { earnTokenContract: (_c = (_b = (_a = bond === null || bond === void 0 ? void 0 : bond.earnToken) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b[bond === null || bond === void 0 ? void 0 : bond.chainId]) !== null && _c !== void 0 ? _c : '', earnTokenSymbol: (_e = (_d = bond === null || bond === void 0 ? void 0 : bond.earnToken) === null || _d === void 0 ? void 0 : _d.symbol) !== null && _e !== void 0 ? _e : '', bondContract: (_f = bond === null || bond === void 0 ? void 0 : bond.billAddress) !== null && _f !== void 0 ? _f : '', projectLink: bond === null || bond === void 0 ? void 0 : bond.projectLink, twitter: bond === null || bond === void 0 ? void 0 : bond.twitter, audit: bond === null || bond === void 0 ? void 0 : bond.audit, chain: bond === null || bond === void 0 ? void 0 : bond.chainId }), width: "205px", placement: "bottomRight", transformTip: "translate(11%, 0%)", children: jsx$2(Svg, { icon: "more", width: "20px" }) }) })] }), jsxs(Flex, { sx: { width: '100%', justifyContent: 'space-around' }, children: [jsxs(Flex, { sx: { flexDirection: 'column', alignItems: 'center', width: '100%' }, children: [jsx$2(Flex, { sx: { opacity: 0.6, fontSize: '12px', fontWeight: 400 }, children: "Discount" }), jsx$2(Flex, { className: `${getDiscountColor(discount)}`, sx: { width: '100%', justifyContent: 'center' }, children: discount !== undefined ? `${discount === null || discount === void 0 ? void 0 : discount.toFixed(2)}%` : '-' })] }), jsxs(Flex, { sx: { flexDirection: 'column', alignItems: 'center', width: '100%' }, children: [jsx$2(Flex, { sx: { opacity: 0.6, fontSize: '12px', fontWeight: 400, width: '100%', justifyContent: 'center' }, children: "ARR" }), jsx$2(Flex, { sx: { width: '100%', justifyContent: 'center' }, children: calculateARR(bond) !== undefined ? calculateARR(bond) : '-' })] }), jsxs(Flex, { sx: { flexDirection: 'column', alignItems: 'center', width: '100%' }, children: [jsx$2(Flex, { sx: { opacity: 0.6, fontSize: '12px', fontWeight: 400, width: '100%', justifyContent: 'center' }, children: "Terms" }), jsx$2(Flex, { sx: { width: '100%', justifyContent: 'center' }, children: ((_g = vestingTime(bond === null || bond === void 0 ? void 0 : bond.vestingTerm)) === null || _g === void 0 ? void 0 : _g.days) ? `${(_h = vestingTime(bond === null || bond === void 0 ? void 0 : bond.vestingTerm)) === null || _h === void 0 ? void 0 : _h.days} D` : '-' })] })] })] }) }));
|
|
74533
73600
|
};
|
|
74534
73601
|
|
|
74535
73602
|
function useHotBondContracts() {
|
|
@@ -74580,7 +73647,7 @@ const HotBondCards = () => {
|
|
|
74580
73647
|
setActiveSlide(index);
|
|
74581
73648
|
swiper === null || swiper === void 0 ? void 0 : swiper.slideTo(index);
|
|
74582
73649
|
};
|
|
74583
|
-
return (jsxs(Flex, { sx: styles$
|
|
73650
|
+
return (jsxs(Flex, { sx: styles$a.mainComponent, children: [jsx$2(Flex, { sx: styles$a.hotBondTitle, children: "HOT BONDS" }), jsx$2(Flex, { sx: styles$a.desktopCards, children: filteredBonds === null || filteredBonds === void 0 ? void 0 : filteredBonds.slice(0, 3).map((bond, index) => {
|
|
74584
73651
|
return jsx$2(HotBondCard, { bond: bond }, `${bond.billAddress}-${index}`);
|
|
74585
73652
|
}) }), jsxs(Flex, { sx: {
|
|
74586
73653
|
flexDirection: 'column',
|
|
@@ -74599,7 +73666,7 @@ const HotBondCards = () => {
|
|
|
74599
73666
|
display: 'flex',
|
|
74600
73667
|
justifyContent: 'center',
|
|
74601
73668
|
}, children: jsx$2(HotBondCard, { bond: bond }, `${bond.billAddress}-${index}`) }, index));
|
|
74602
|
-
}) }), jsx$2(Flex, { sx: styles$
|
|
73669
|
+
}) }), jsx$2(Flex, { sx: styles$a.bubbleContainer, children: [...Array(hotBonds === null || hotBonds === void 0 ? void 0 : hotBonds.length)].map((_, i) => {
|
|
74603
73670
|
return jsx$2(SwiperDots, { isActive: i === activeSlide, onClick: () => slideTo(i) }, i);
|
|
74604
73671
|
}) })] })] }));
|
|
74605
73672
|
};
|
|
@@ -74760,7 +73827,7 @@ const RecommendationCards$1 = () => {
|
|
|
74760
73827
|
color: 'grey',
|
|
74761
73828
|
fontSize: ['11px'],
|
|
74762
73829
|
fontWeight: 500,
|
|
74763
|
-
}, children: "BONDS MARKETS:" }), jsx$2(RecommendationSelector, { options: options, activeOption: activeOption, setActiveOption: setActiveOption })] }), jsx$2(Flex, { sx: { display: ['none', 'none', 'none', 'flex'] }, children: jsx$2(Image
|
|
73830
|
+
}, children: "BONDS MARKETS:" }), jsx$2(RecommendationSelector, { options: options, activeOption: activeOption, setActiveOption: setActiveOption })] }), jsx$2(Flex, { sx: { display: ['none', 'none', 'none', 'flex'] }, children: jsx$2(Image, { width: 190, height: 20, alt: "poweredBy", src: "/images/bills/powered.png", sx: {
|
|
74764
73831
|
width: '190px',
|
|
74765
73832
|
height: '20px',
|
|
74766
73833
|
cursor: 'pointer',
|
|
@@ -74833,6 +73900,9 @@ const Bonds = () => {
|
|
|
74833
73900
|
if (filterOption !== 'SOLD OUT') {
|
|
74834
73901
|
billsToReturn = billsToReturn === null || billsToReturn === void 0 ? void 0 : billsToReturn.filter((bond) => !isBondSoldOut(bond));
|
|
74835
73902
|
}
|
|
73903
|
+
if (filterOption === 'SOLD OUT') {
|
|
73904
|
+
billsToReturn = billsToReturn === null || billsToReturn === void 0 ? void 0 : billsToReturn.filter((bond) => !bond.soldOut);
|
|
73905
|
+
}
|
|
74836
73906
|
if (filterOption === 'FAVORITES') {
|
|
74837
73907
|
billsToReturn = billsToReturn === null || billsToReturn === void 0 ? void 0 : billsToReturn.filter((bill) => { var _a, _b; return favTokens.includes((_b = (_a = bill === null || bill === void 0 ? void 0 : bill.earnToken) === null || _a === void 0 ? void 0 : _a.symbol) === null || _b === void 0 ? void 0 : _b.toLowerCase()); });
|
|
74838
73908
|
}
|
|
@@ -74890,8 +73960,8 @@ const FullBondsView = () => {
|
|
|
74890
73960
|
};
|
|
74891
73961
|
|
|
74892
73962
|
const Toggle = ({ options, activeOption, handleToggle, claimableBillsAmount, }) => {
|
|
74893
|
-
return (jsx$2(Flex, { sx: styles$
|
|
74894
|
-
return (jsx$2(motion.div, { animate: { opacity: option === activeOption ? 1 : 0.6, scale: option === activeOption ? 1 : 0.9 }, exit: { opacity: 0, scale: 0.9 }, transition: { duration: 0.2, type: 'spring', stiffness: 50 }, sx: { overflow: 'hidden', width: '100%' }, children: jsx$2(Flex, { sx: Object.assign(Object.assign({}, styles$
|
|
73963
|
+
return (jsx$2(Flex, { sx: styles$c.container, children: jsx$2(AnimatePresence, { initial: false, children: options.map((option) => {
|
|
73964
|
+
return (jsx$2(motion.div, { animate: { opacity: option === activeOption ? 1 : 0.6, scale: option === activeOption ? 1 : 0.9 }, exit: { opacity: 0, scale: 0.9 }, transition: { duration: 0.2, type: 'spring', stiffness: 50 }, sx: { overflow: 'hidden', width: '100%' }, children: jsx$2(Flex, { sx: Object.assign(Object.assign({}, styles$c.switch), { background: option === activeOption ? 'primaryButton' : 'white2' }), onClick: () => handleToggle(option), children: jsxs(Text, { sx: { fontSize: '14px' }, children: [option, option === BondsViewOptions.YOURBONDS && claimableBillsAmount ? ` (${claimableBillsAmount})` : ''] }) }) }, option));
|
|
74895
73965
|
}) }) }));
|
|
74896
73966
|
};
|
|
74897
73967
|
|
|
@@ -91453,4 +90523,148 @@ const ProjectViewWithProviders = (props) => {
|
|
|
91453
90523
|
return (jsx$2(Providers, { children: jsx$2(ProjectView, Object.assign({}, props)) }));
|
|
91454
90524
|
};
|
|
91455
90525
|
|
|
90526
|
+
function getTemplateHTML(data) {
|
|
90527
|
+
var _a, _b, _c;
|
|
90528
|
+
const isProfit = data.data.payout * +data.data.payoutTokenPrice - data.data.dollarValue > 0;
|
|
90529
|
+
const getTokenImage = (symbol) => {
|
|
90530
|
+
return `${APESWAP_LIST_REPO}/assets/${symbol.toUpperCase()}.png`;
|
|
90531
|
+
};
|
|
90532
|
+
const getPrincipalToken = () => {
|
|
90533
|
+
var _a, _b, _c, _d;
|
|
90534
|
+
if (((_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.payoutTokenData.address.toLowerCase()) !== ((_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b.token0.address.toLowerCase()))
|
|
90535
|
+
return (_c = data === null || data === void 0 ? void 0 : data.data) === null || _c === void 0 ? void 0 : _c.token0.symbol;
|
|
90536
|
+
return (_d = data === null || data === void 0 ? void 0 : data.data) === null || _d === void 0 ? void 0 : _d.token1.symbol;
|
|
90537
|
+
};
|
|
90538
|
+
const getCalculateOff = () => {
|
|
90539
|
+
if (!data || !data.data)
|
|
90540
|
+
return 0;
|
|
90541
|
+
return 100 - (data.data.dollarValue / (data.data.payout * +data.data.payoutTokenPrice)) * 100;
|
|
90542
|
+
};
|
|
90543
|
+
const getCalculatePriceDiscount = () => {
|
|
90544
|
+
if (!data || !data.data)
|
|
90545
|
+
return 0;
|
|
90546
|
+
return +data.data.payoutTokenPrice - (+data.data.payoutTokenPrice * getCalculateOff()) / 100;
|
|
90547
|
+
};
|
|
90548
|
+
return `
|
|
90549
|
+
<div id="template-card" class="sharebondimage-card">
|
|
90550
|
+
<img src="/images/bills/title.png" alt="title" style="width: 169px; height: 52px;" />
|
|
90551
|
+
<div class="sharebondimage-nft">
|
|
90552
|
+
<div style="position: relative">
|
|
90553
|
+
<div class="sharebondimage-nft-id">
|
|
90554
|
+
<span>#${data.tokenId}</span>
|
|
90555
|
+
</div>
|
|
90556
|
+
<img src="${data.image}" alt="bill-nft" />
|
|
90557
|
+
</div>
|
|
90558
|
+
</div>
|
|
90559
|
+
<div class="sharebondimage-container-info">
|
|
90560
|
+
<div class="sharebondimage-container-discount">
|
|
90561
|
+
<img src="${getTokenImage((_a = data.data) === null || _a === void 0 ? void 0 : _a.payoutTokenData.symbol)}" alt="payout-token-symbol" style="width: 59px; height: 59px;" />
|
|
90562
|
+
<div class="sharebondimage-container-discount-price">
|
|
90563
|
+
<div class="sharebondimage-container-discount-token">
|
|
90564
|
+
<span>${(_b = data.data) === null || _b === void 0 ? void 0 : _b.payoutTokenData.symbol}</span>
|
|
90565
|
+
<span style="text-decoration: line-through">
|
|
90566
|
+
$${formatTransactionAmount(+data.data.payoutTokenPrice)}
|
|
90567
|
+
</span>
|
|
90568
|
+
</div>
|
|
90569
|
+
<span class="sharebondimage-container-discount-price-discount">
|
|
90570
|
+
$${formatTransactionAmount(getCalculatePriceDiscount())}
|
|
90571
|
+
</span>
|
|
90572
|
+
</div>
|
|
90573
|
+
<div class="sharebondimage-container-off">
|
|
90574
|
+
<span>
|
|
90575
|
+
${formatNumber$3(getCalculateOff())}% OFF
|
|
90576
|
+
</span>
|
|
90577
|
+
</div>
|
|
90578
|
+
</div>
|
|
90579
|
+
<div class="sharebondimage-container-tokens">
|
|
90580
|
+
<div class="sharebondimage-container-token">
|
|
90581
|
+
<img src="${getTokenImage(getPrincipalToken())}" alt="principal-symbol" />
|
|
90582
|
+
<div class="sharebondimage-amount-deposit">
|
|
90583
|
+
${formatTransactionAmount(data.data.deposit)}
|
|
90584
|
+
</div>
|
|
90585
|
+
<div class="sharebondimage-dollarvalue">
|
|
90586
|
+
$${formatNumber$3(data.data.dollarValue)}
|
|
90587
|
+
</div>
|
|
90588
|
+
</div>
|
|
90589
|
+
<div class="sharebondimage-container-token">
|
|
90590
|
+
<img src="${getTokenImage((_c = data.data) === null || _c === void 0 ? void 0 : _c.payoutTokenData.symbol)}" alt="payout-token2-symbol" />
|
|
90591
|
+
<div class="sharebondimage-container-earntoken">
|
|
90592
|
+
<div class="sharebondimage-amount-earntoken">
|
|
90593
|
+
<div class="sharebondimage-amount-payout">
|
|
90594
|
+
${formatNumber$3(data.data.payout)}
|
|
90595
|
+
</div>
|
|
90596
|
+
<div class="sharebondimage-amount-dollarvalue">
|
|
90597
|
+
$${formatNumber$3(data.data.payout * +data.data.payoutTokenPrice)}
|
|
90598
|
+
</div>
|
|
90599
|
+
</div>
|
|
90600
|
+
<div class="sharebondimage-profit" style="${!isProfit ? 'display: none' : ''}">
|
|
90601
|
+
<span>
|
|
90602
|
+
+${formatNumber$3(data.data.payout * +data.data.payoutTokenPrice - data.data.dollarValue)}
|
|
90603
|
+
profit!
|
|
90604
|
+
</span>
|
|
90605
|
+
</div>
|
|
90606
|
+
</div>
|
|
90607
|
+
</div>
|
|
90608
|
+
</div>
|
|
90609
|
+
</div>
|
|
90610
|
+
</div>
|
|
90611
|
+
`;
|
|
90612
|
+
}
|
|
90613
|
+
|
|
90614
|
+
function generateImageFromTemplate(bondNFTData, link, apiUrl) {
|
|
90615
|
+
return __awaiter$9(this, void 0, void 0, function* () {
|
|
90616
|
+
var _a;
|
|
90617
|
+
if (bondNFTData) {
|
|
90618
|
+
const container = document.createElement('div');
|
|
90619
|
+
container.style.position = 'absolute';
|
|
90620
|
+
container.style.top = '-9999px';
|
|
90621
|
+
container.innerHTML = getTemplateHTML(bondNFTData);
|
|
90622
|
+
document.body.appendChild(container);
|
|
90623
|
+
const templateElement = container.querySelector('#template-card');
|
|
90624
|
+
if (!templateElement)
|
|
90625
|
+
return;
|
|
90626
|
+
const fileName = `bond_share_${(_a = bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.data.billNftAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()}_${bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.chainId}_${bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.tokenId}`;
|
|
90627
|
+
const existingImage = yield checkImageExists(fileName);
|
|
90628
|
+
if (existingImage) {
|
|
90629
|
+
share(link);
|
|
90630
|
+
}
|
|
90631
|
+
else {
|
|
90632
|
+
domtoimage
|
|
90633
|
+
.toJpeg(templateElement)
|
|
90634
|
+
.then((dataUrl) => __awaiter$9(this, void 0, void 0, function* () {
|
|
90635
|
+
const response = yield fetch(dataUrl);
|
|
90636
|
+
const blob = yield response.blob();
|
|
90637
|
+
let formData = new FormData();
|
|
90638
|
+
formData.append('file', blob, fileName);
|
|
90639
|
+
yield axios.post(`${apiUrl}/cloudinary/uploadFile`, formData, {
|
|
90640
|
+
headers: { 'Content-Type': 'multipart/form-data' },
|
|
90641
|
+
});
|
|
90642
|
+
share(link);
|
|
90643
|
+
}))
|
|
90644
|
+
.catch((error) => {
|
|
90645
|
+
console.error('Error converting image:', error);
|
|
90646
|
+
});
|
|
90647
|
+
}
|
|
90648
|
+
}
|
|
90649
|
+
});
|
|
90650
|
+
}
|
|
90651
|
+
function share(link) {
|
|
90652
|
+
const linkElement = document.createElement('a');
|
|
90653
|
+
linkElement.href = link;
|
|
90654
|
+
linkElement.target = '_blank';
|
|
90655
|
+
linkElement.click();
|
|
90656
|
+
}
|
|
90657
|
+
function checkImageExists(fileName) {
|
|
90658
|
+
return __awaiter$9(this, void 0, void 0, function* () {
|
|
90659
|
+
let existImg = true;
|
|
90660
|
+
try {
|
|
90661
|
+
yield axios.get(`https://res.cloudinary.com/dtlafxop8/image/upload/v1/bond_share/${fileName}.jpg`);
|
|
90662
|
+
}
|
|
90663
|
+
catch (e) {
|
|
90664
|
+
existImg = false;
|
|
90665
|
+
}
|
|
90666
|
+
return existImg;
|
|
90667
|
+
});
|
|
90668
|
+
}
|
|
90669
|
+
|
|
91456
90670
|
export { BondModalWithProviders as BondModal, BondsWithProviders as Bonds, FullBondsViewWithProviders as FullBondsView, ProjectViewWithProviders as ProjectView, YourBondsWithProviders as YourBonds, generateImageFromTemplate };
|