qureal-editor 1.0.13 → 1.0.15
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/index.es.js +22 -3
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +22 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -75,7 +75,8 @@ function QurealiFrame(_ref) {
|
|
|
75
75
|
id: "qureal_iframe",
|
|
76
76
|
title: "Qureal"
|
|
77
77
|
// src={`http://localhost:3201/embed/${creation_slug}`}
|
|
78
|
-
|
|
78
|
+
// src={type === "creation" ? `https://show.qureal.com/embed/${slug}?${preview ? "preview&" : ""}${query}` : `https://show.qureal.com/ts/${slug}?${preview ? "preview&" : ""}${query}`}
|
|
79
|
+
, src: "https://show.qureal.com/" + (type === "creation" ? "embed" : "ts") + "/" + slug + "?" + (preview ? "preview&" : "") + query
|
|
79
80
|
// src={type === "creation" ? `http://localhost:3201/embed/${slug}?${preview ? "preview&" : ""}${query}` : `https://show.qureal.com/ts/${slug}`}
|
|
80
81
|
, style: _extends({
|
|
81
82
|
width: "100%",
|
|
@@ -106,7 +107,15 @@ function QurealViewer(_ref) {
|
|
|
106
107
|
_ref$style = _ref.style,
|
|
107
108
|
style = _ref$style === undefined ? {} : _ref$style,
|
|
108
109
|
_ref$actionRef = _ref.actionRef,
|
|
109
|
-
actionRef = _ref$actionRef === undefined ? {} : _ref$actionRef
|
|
110
|
+
actionRef = _ref$actionRef === undefined ? {} : _ref$actionRef,
|
|
111
|
+
_ref$organization = _ref.organization,
|
|
112
|
+
organization = _ref$organization === undefined ? null : _ref$organization,
|
|
113
|
+
_ref$person = _ref.person,
|
|
114
|
+
person = _ref$person === undefined ? null : _ref$person,
|
|
115
|
+
_ref$background = _ref.background,
|
|
116
|
+
background = _ref$background === undefined ? null : _ref$background,
|
|
117
|
+
_ref$fit = _ref.fit,
|
|
118
|
+
fit = _ref$fit === undefined ? false : _ref$fit;
|
|
110
119
|
|
|
111
120
|
|
|
112
121
|
var sendToIFrame = function sendToIFrame(msg) {
|
|
@@ -149,6 +158,16 @@ function QurealViewer(_ref) {
|
|
|
149
158
|
}
|
|
150
159
|
}, [actionRef]);
|
|
151
160
|
|
|
161
|
+
useEffect(function () {
|
|
162
|
+
sendToIFrame({
|
|
163
|
+
message_type: "SET_ICTX",
|
|
164
|
+
data: {
|
|
165
|
+
organization: organization,
|
|
166
|
+
person: person
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}, [organization, person]);
|
|
170
|
+
|
|
152
171
|
useEffect(function () {
|
|
153
172
|
var handler = function handler(ev) {
|
|
154
173
|
if (ALLOWED_ORIGINS.includes(ev.origin) && _typeof(ev.data) === "object") {
|
|
@@ -172,7 +191,7 @@ function QurealViewer(_ref) {
|
|
|
172
191
|
return React.createElement(QurealiFrame$1, {
|
|
173
192
|
slug: slug,
|
|
174
193
|
preview: preview,
|
|
175
|
-
query: queryfy(prefill),
|
|
194
|
+
query: "" + queryfy(prefill) + (background ? "&qi_background=" + background : "") + (fit ? "&qi_fit" : ""),
|
|
176
195
|
type: type,
|
|
177
196
|
style: style
|
|
178
197
|
});
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/QurealiFrame.js","../src/QurealViewer.js","../src/use-action.js"],"sourcesContent":["import React, { Fragment, useEffect, useRef } from \"react\";\n\n\nfunction QurealiFrame({ slug, preview, query, type = \"creation\", style = {} }) {\n\n\n return (\n <Fragment>\n <iframe\n id=\"qureal_iframe\"\n title=\"Qureal\"\n // src={`http://localhost:3201/embed/${creation_slug}`}\n src={type === \"creation\" ? `https://show.qureal.com/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n // src={type === \"creation\" ? `http://localhost:3201/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n style={{\n width: \"100%\",\n height: \"100vh\",\n ...style\n }}\n />\n </Fragment>\n );\n}\n\n// export default QurealiFrame;\nexport default React.memo(QurealiFrame, () => true)\n","import React, { Fragment, useEffect, useRef } from \"react\";\nimport QurealiFrame from \"./QurealiFrame\";\n\nconst ALLOWED_ORIGINS = [\"https://show.qureal.com\", \"http://localhost:3201\"];\n\nfunction QurealViewer({\n slug = \"qi_sample\",\n preview = false,\n prefill = {},\n type = \"creation\", // creation or template \n onFormSubmit = () => { },\n style = {},\n actionRef = {}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/QurealiFrame.js","../src/QurealViewer.js","../src/use-action.js"],"sourcesContent":["import React, { Fragment, useEffect, useRef } from \"react\";\n\n\nfunction QurealiFrame({ slug, preview, query, type = \"creation\", style = {} }) {\n\n\n return (\n <Fragment>\n <iframe\n id=\"qureal_iframe\"\n title=\"Qureal\"\n // src={`http://localhost:3201/embed/${creation_slug}`}\n // src={type === \"creation\" ? `https://show.qureal.com/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}?${preview ? \"preview&\" : \"\"}${query}`}\n src={`https://show.qureal.com/${type === \"creation\" ? \"embed\" : \"ts\"}/${slug}?${preview ? \"preview&\" : \"\"}${query}`}\n // src={type === \"creation\" ? `http://localhost:3201/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n style={{\n width: \"100%\",\n height: \"100vh\",\n ...style\n }}\n />\n </Fragment>\n );\n}\n\n// export default QurealiFrame;\nexport default React.memo(QurealiFrame, () => true)\n","import React, { Fragment, useEffect, useRef } from \"react\";\nimport QurealiFrame from \"./QurealiFrame\";\n\nconst ALLOWED_ORIGINS = [\"https://show.qureal.com\", \"http://localhost:3201\"];\n\nfunction QurealViewer({\n slug = \"qi_sample\",\n preview = false,\n prefill = {},\n type = \"creation\", // creation or template \n onFormSubmit = () => { },\n style = {},\n actionRef = {},\n organization = null,\n person = null,\n background = null,\n fit = false,\n}) {\n\n const sendToIFrame = (msg) => {\n console.log(\"Sending data to iFrame\")\n const qureal_element = document.getElementById(\"qureal_iframe\");\n\n const qureal_window = qureal_element ? qureal_element.contentWindow : null;\n if (qureal_window) {\n qureal_window.postMessage(msg, \"*\");\n console.log(\"Data sent to iframe\")\n }\n }\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"OPEN_CREATION\",\n data: {\n slug: slug,\n preview: preview,\n prefill: prefill\n }\n })\n }, [slug, preview])\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"PREFILL\",\n data: {\n prefill: prefill\n }\n })\n }, [prefill])\n\n useEffect(() => {\n if ([\"DOWNLOAD\", \"SHARE\"].includes(actionRef.type)) {\n sendToIFrame({\n message_type: actionRef.type,\n data: actionRef.data || {}\n })\n }\n }, [actionRef])\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"SET_ICTX\",\n data: {\n organization: organization,\n person: person\n }\n })\n }, [organization, person])\n\n useEffect(() => {\n const handler = (ev) => {\n if (ALLOWED_ORIGINS.includes(ev.origin) && typeof ev.data === \"object\") {\n switch (ev.data.event_type) {\n case \"FORM_SUBMIT\":\n onFormSubmit(ev.data.data);\n break;\n default:\n console.log(\"No event type found\");\n console.log(ev.data);\n }\n }\n };\n\n window.addEventListener(\"message\", handler);\n return () => window.removeEventListener(\"message\", handler);\n }, []);\n\n return (\n <QurealiFrame\n slug={slug}\n preview={preview}\n query={`${queryfy(prefill)}${background ? `&qi_background=${background}` : \"\"}${fit ? \"&qi_fit\" : \"\"}`}\n type={type}\n style={style}\n />\n );\n}\n\n// export default QurealiFrame;\nexport default QurealViewer\n\n\nfunction queryfy(obj) {\n const buildQuery = (prefix, obj) => {\n return Object.keys(obj)\n .map(key => {\n const value = obj[key];\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n if (typeof value === 'object' && value !== null) {\n return buildQuery(prefixedKey, value);\n } else {\n return `${prefixedKey}=${value}`;\n }\n })\n .join(\"&\");\n };\n\n return buildQuery(\"\", obj);\n}","import { useState } from \"react\"\n\nfunction useQurealActions() {\n const [actionRef, setActionRef] = useState({});\n\n function download() {\n setActionRef({\n type: \"DOWNLOAD\",\n data: {}\n })\n }\n\n\n function share() {\n setActionRef({\n type: \"SHARE\",\n data: {}\n })\n }\n\n return { actionRef, download, share }\n}\n\nexport default useQurealActions;"],"names":["QurealiFrame","slug","preview","query","type","style","React","memo","ALLOWED_ORIGINS","QurealViewer","prefill","onFormSubmit","actionRef","organization","person","background","fit","sendToIFrame","msg","log","qureal_element","document","getElementById","qureal_window","contentWindow","postMessage","includes","data","handler","ev","origin","babelHelpers.typeof","event_type","addEventListener","window","removeEventListener","queryfy","obj","buildQuery","prefix","Object","keys","map","value","key","prefixedKey","join","useQurealActions","useState","setActionRef","download","share"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAASA,YAAT,OAA+E;QAAvDC,IAAuD,QAAvDA,IAAuD;QAAjDC,OAAiD,QAAjDA,OAAiD;QAAxCC,KAAwC,QAAxCA,KAAwC;yBAAjCC,IAAiC;QAAjCA,IAAiC,6BAA1B,UAA0B;0BAAdC,KAAc;QAAdA,KAAc,8BAAN,EAAM;;;WAIvE;gBAAA;;;gBAEW,eADP;mBAEU;;;cAGN,mCAAgCD,SAAS,UAAT,GAAsB,OAAtB,GAAgC,IAAhE,UAAwEH,IAAxE,UAAgFC,UAAU,UAAV,GAAuB,EAAvG,IAA4GC;;cAE5G;uBACW,MADX;wBAEY;eACLE,KAHP;;KATZ;;;;AAoBJ,qBAAeC,MAAMC,IAAN,CAAWP,YAAX,EAAyB;WAAM,IAAN;CAAzB,CAAf;;ACvBA,IAAMQ,kBAAkB,CAAC,yBAAD,EAA4B,uBAA5B,CAAxB;;AAEA,SAASC,YAAT,OAYG;yBAXCR,IAWD;QAXCA,IAWD,6BAXQ,WAWR;4BAVCC,OAUD;QAVCA,OAUD,gCAVW,KAUX;4BATCQ,OASD;QATC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AEvC,oBAAF,EAAasC,kBAAb,EAAuBC,YAAvB,EAAP;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -82,7 +82,8 @@ function QurealiFrame(_ref) {
|
|
|
82
82
|
id: "qureal_iframe",
|
|
83
83
|
title: "Qureal"
|
|
84
84
|
// src={`http://localhost:3201/embed/${creation_slug}`}
|
|
85
|
-
|
|
85
|
+
// src={type === "creation" ? `https://show.qureal.com/embed/${slug}?${preview ? "preview&" : ""}${query}` : `https://show.qureal.com/ts/${slug}?${preview ? "preview&" : ""}${query}`}
|
|
86
|
+
, src: "https://show.qureal.com/" + (type === "creation" ? "embed" : "ts") + "/" + slug + "?" + (preview ? "preview&" : "") + query
|
|
86
87
|
// src={type === "creation" ? `http://localhost:3201/embed/${slug}?${preview ? "preview&" : ""}${query}` : `https://show.qureal.com/ts/${slug}`}
|
|
87
88
|
, style: _extends({
|
|
88
89
|
width: "100%",
|
|
@@ -113,7 +114,15 @@ function QurealViewer(_ref) {
|
|
|
113
114
|
_ref$style = _ref.style,
|
|
114
115
|
style = _ref$style === undefined ? {} : _ref$style,
|
|
115
116
|
_ref$actionRef = _ref.actionRef,
|
|
116
|
-
actionRef = _ref$actionRef === undefined ? {} : _ref$actionRef
|
|
117
|
+
actionRef = _ref$actionRef === undefined ? {} : _ref$actionRef,
|
|
118
|
+
_ref$organization = _ref.organization,
|
|
119
|
+
organization = _ref$organization === undefined ? null : _ref$organization,
|
|
120
|
+
_ref$person = _ref.person,
|
|
121
|
+
person = _ref$person === undefined ? null : _ref$person,
|
|
122
|
+
_ref$background = _ref.background,
|
|
123
|
+
background = _ref$background === undefined ? null : _ref$background,
|
|
124
|
+
_ref$fit = _ref.fit,
|
|
125
|
+
fit = _ref$fit === undefined ? false : _ref$fit;
|
|
117
126
|
|
|
118
127
|
|
|
119
128
|
var sendToIFrame = function sendToIFrame(msg) {
|
|
@@ -156,6 +165,16 @@ function QurealViewer(_ref) {
|
|
|
156
165
|
}
|
|
157
166
|
}, [actionRef]);
|
|
158
167
|
|
|
168
|
+
React.useEffect(function () {
|
|
169
|
+
sendToIFrame({
|
|
170
|
+
message_type: "SET_ICTX",
|
|
171
|
+
data: {
|
|
172
|
+
organization: organization,
|
|
173
|
+
person: person
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}, [organization, person]);
|
|
177
|
+
|
|
159
178
|
React.useEffect(function () {
|
|
160
179
|
var handler = function handler(ev) {
|
|
161
180
|
if (ALLOWED_ORIGINS.includes(ev.origin) && _typeof(ev.data) === "object") {
|
|
@@ -179,7 +198,7 @@ function QurealViewer(_ref) {
|
|
|
179
198
|
return React__default.createElement(QurealiFrame$1, {
|
|
180
199
|
slug: slug,
|
|
181
200
|
preview: preview,
|
|
182
|
-
query: queryfy(prefill),
|
|
201
|
+
query: "" + queryfy(prefill) + (background ? "&qi_background=" + background : "") + (fit ? "&qi_fit" : ""),
|
|
183
202
|
type: type,
|
|
184
203
|
style: style
|
|
185
204
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/QurealiFrame.js","../src/QurealViewer.js","../src/use-action.js"],"sourcesContent":["import React, { Fragment, useEffect, useRef } from \"react\";\n\n\nfunction QurealiFrame({ slug, preview, query, type = \"creation\", style = {} }) {\n\n\n return (\n <Fragment>\n <iframe\n id=\"qureal_iframe\"\n title=\"Qureal\"\n // src={`http://localhost:3201/embed/${creation_slug}`}\n src={type === \"creation\" ? `https://show.qureal.com/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n // src={type === \"creation\" ? `http://localhost:3201/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n style={{\n width: \"100%\",\n height: \"100vh\",\n ...style\n }}\n />\n </Fragment>\n );\n}\n\n// export default QurealiFrame;\nexport default React.memo(QurealiFrame, () => true)\n","import React, { Fragment, useEffect, useRef } from \"react\";\nimport QurealiFrame from \"./QurealiFrame\";\n\nconst ALLOWED_ORIGINS = [\"https://show.qureal.com\", \"http://localhost:3201\"];\n\nfunction QurealViewer({\n slug = \"qi_sample\",\n preview = false,\n prefill = {},\n type = \"creation\", // creation or template \n onFormSubmit = () => { },\n style = {},\n actionRef = {}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/QurealiFrame.js","../src/QurealViewer.js","../src/use-action.js"],"sourcesContent":["import React, { Fragment, useEffect, useRef } from \"react\";\n\n\nfunction QurealiFrame({ slug, preview, query, type = \"creation\", style = {} }) {\n\n\n return (\n <Fragment>\n <iframe\n id=\"qureal_iframe\"\n title=\"Qureal\"\n // src={`http://localhost:3201/embed/${creation_slug}`}\n // src={type === \"creation\" ? `https://show.qureal.com/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}?${preview ? \"preview&\" : \"\"}${query}`}\n src={`https://show.qureal.com/${type === \"creation\" ? \"embed\" : \"ts\"}/${slug}?${preview ? \"preview&\" : \"\"}${query}`}\n // src={type === \"creation\" ? `http://localhost:3201/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n style={{\n width: \"100%\",\n height: \"100vh\",\n ...style\n }}\n />\n </Fragment>\n );\n}\n\n// export default QurealiFrame;\nexport default React.memo(QurealiFrame, () => true)\n","import React, { Fragment, useEffect, useRef } from \"react\";\nimport QurealiFrame from \"./QurealiFrame\";\n\nconst ALLOWED_ORIGINS = [\"https://show.qureal.com\", \"http://localhost:3201\"];\n\nfunction QurealViewer({\n slug = \"qi_sample\",\n preview = false,\n prefill = {},\n type = \"creation\", // creation or template \n onFormSubmit = () => { },\n style = {},\n actionRef = {},\n organization = null,\n person = null,\n background = null,\n fit = false,\n}) {\n\n const sendToIFrame = (msg) => {\n console.log(\"Sending data to iFrame\")\n const qureal_element = document.getElementById(\"qureal_iframe\");\n\n const qureal_window = qureal_element ? qureal_element.contentWindow : null;\n if (qureal_window) {\n qureal_window.postMessage(msg, \"*\");\n console.log(\"Data sent to iframe\")\n }\n }\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"OPEN_CREATION\",\n data: {\n slug: slug,\n preview: preview,\n prefill: prefill\n }\n })\n }, [slug, preview])\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"PREFILL\",\n data: {\n prefill: prefill\n }\n })\n }, [prefill])\n\n useEffect(() => {\n if ([\"DOWNLOAD\", \"SHARE\"].includes(actionRef.type)) {\n sendToIFrame({\n message_type: actionRef.type,\n data: actionRef.data || {}\n })\n }\n }, [actionRef])\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"SET_ICTX\",\n data: {\n organization: organization,\n person: person\n }\n })\n }, [organization, person])\n\n useEffect(() => {\n const handler = (ev) => {\n if (ALLOWED_ORIGINS.includes(ev.origin) && typeof ev.data === \"object\") {\n switch (ev.data.event_type) {\n case \"FORM_SUBMIT\":\n onFormSubmit(ev.data.data);\n break;\n default:\n console.log(\"No event type found\");\n console.log(ev.data);\n }\n }\n };\n\n window.addEventListener(\"message\", handler);\n return () => window.removeEventListener(\"message\", handler);\n }, []);\n\n return (\n <QurealiFrame\n slug={slug}\n preview={preview}\n query={`${queryfy(prefill)}${background ? `&qi_background=${background}` : \"\"}${fit ? \"&qi_fit\" : \"\"}`}\n type={type}\n style={style}\n />\n );\n}\n\n// export default QurealiFrame;\nexport default QurealViewer\n\n\nfunction queryfy(obj) {\n const buildQuery = (prefix, obj) => {\n return Object.keys(obj)\n .map(key => {\n const value = obj[key];\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n if (typeof value === 'object' && value !== null) {\n return buildQuery(prefixedKey, value);\n } else {\n return `${prefixedKey}=${value}`;\n }\n })\n .join(\"&\");\n };\n\n return buildQuery(\"\", obj);\n}","import { useState } from \"react\"\n\nfunction useQurealActions() {\n const [actionRef, setActionRef] = useState({});\n\n function download() {\n setActionRef({\n type: \"DOWNLOAD\",\n data: {}\n })\n }\n\n\n function share() {\n setActionRef({\n type: \"SHARE\",\n data: {}\n })\n }\n\n return { actionRef, download, share }\n}\n\nexport default useQurealActions;"],"names":["QurealiFrame","slug","preview","query","type","style","React","memo","ALLOWED_ORIGINS","QurealViewer","prefill","onFormSubmit","actionRef","organization","person","background","fit","sendToIFrame","msg","log","qureal_element","document","getElementById","qureal_window","contentWindow","postMessage","includes","data","handler","ev","origin","babelHelpers.typeof","event_type","addEventListener","window","removeEventListener","queryfy","obj","buildQuery","prefix","Object","keys","map","value","key","prefixedKey","join","useQurealActions","useState","setActionRef","download","share"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAASA,YAAT,OAA+E;QAAvDC,IAAuD,QAAvDA,IAAuD;QAAjDC,OAAiD,QAAjDA,OAAiD;QAAxCC,KAAwC,QAAxCA,KAAwC;yBAAjCC,IAAiC;QAAjCA,IAAiC,6BAA1B,UAA0B;0BAAdC,KAAc;QAAdA,KAAc,8BAAN,EAAM;;;WAIvEC;sBAAA;;;gBAEW,eADP;mBAEU;;;cAGN,mCAAgCF,SAAS,UAAT,GAAsB,OAAtB,GAAgC,IAAhE,UAAwEH,IAAxE,UAAgFC,UAAU,UAAV,GAAuB,EAAvG,IAA4GC;;cAE5G;uBACW,MADX;wBAEY;eACLE,KAHP;;KATZ;;;;AAoBJ,qBAAeC,eAAMC,IAAN,CAAWP,YAAX,EAAyB;WAAM,IAAN;CAAzB,CAAf;;ACvBA,IAAMQ,kBAAkB,CAAC,yBAAD,EAA4B,uBAA5B,CAAxB;;AAEA,SAASC,YAAT,OAYG;yBAXCR,IAWD;QAXCA,IAWD,6BAXQ,WAWR;4BAVCC,OAUD;QAVCA,OAUD,gCAVW,KAUX;4BATCQ,OASD;QATCA,OASD,gCATW,EASX;yBARCN,IAQD;QARCA,IAQD,6BARQ,UAQR;iCAPCO,YAOD;QAPCA,YAOD,qCAPgB,YAAM,EAOtB;0BANCN,KAMD;QANCA,KAMD,8BANS,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