eat-js-sdk 0.0.1 → 0.0.2
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/eat-prompt-builder.mjs +494 -129
- package/package.json +1 -1
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
// node_modules/svelte/src/runtime/internal/utils.js
|
|
4
4
|
function noop() {
|
|
5
5
|
}
|
|
6
|
+
function assign(tar, src) {
|
|
7
|
+
for (const k in src)
|
|
8
|
+
tar[k] = src[k];
|
|
9
|
+
return (
|
|
10
|
+
/** @type {T & S} */
|
|
11
|
+
tar
|
|
12
|
+
);
|
|
13
|
+
}
|
|
6
14
|
function run(fn) {
|
|
7
15
|
return fn();
|
|
8
16
|
}
|
|
@@ -21,6 +29,28 @@
|
|
|
21
29
|
function is_empty(obj) {
|
|
22
30
|
return Object.keys(obj).length === 0;
|
|
23
31
|
}
|
|
32
|
+
function subscribe(store, ...callbacks) {
|
|
33
|
+
if (store == null) {
|
|
34
|
+
for (const callback of callbacks) {
|
|
35
|
+
callback(void 0);
|
|
36
|
+
}
|
|
37
|
+
return noop;
|
|
38
|
+
}
|
|
39
|
+
const unsub = store.subscribe(...callbacks);
|
|
40
|
+
return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
|
|
41
|
+
}
|
|
42
|
+
function get_store_value(store) {
|
|
43
|
+
let value;
|
|
44
|
+
subscribe(store, (_) => value = _)();
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
function exclude_internal_props(props) {
|
|
48
|
+
const result = {};
|
|
49
|
+
for (const k in props)
|
|
50
|
+
if (k[0] !== "$")
|
|
51
|
+
result[k] = props[k];
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
24
54
|
|
|
25
55
|
// node_modules/svelte/src/runtime/internal/globals.js
|
|
26
56
|
var globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : (
|
|
@@ -154,6 +184,9 @@
|
|
|
154
184
|
function children(element2) {
|
|
155
185
|
return Array.from(element2.childNodes);
|
|
156
186
|
}
|
|
187
|
+
function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
|
|
188
|
+
return new CustomEvent(type, { detail, bubbles, cancelable });
|
|
189
|
+
}
|
|
157
190
|
function get_custom_elements_slots(element2) {
|
|
158
191
|
const result = {};
|
|
159
192
|
element2.childNodes.forEach(
|
|
@@ -170,6 +203,30 @@
|
|
|
170
203
|
function set_current_component(component) {
|
|
171
204
|
current_component = component;
|
|
172
205
|
}
|
|
206
|
+
function get_current_component() {
|
|
207
|
+
if (!current_component)
|
|
208
|
+
throw new Error("Function called outside component initialization");
|
|
209
|
+
return current_component;
|
|
210
|
+
}
|
|
211
|
+
function createEventDispatcher() {
|
|
212
|
+
const component = get_current_component();
|
|
213
|
+
return (type, detail, { cancelable = false } = {}) => {
|
|
214
|
+
const callbacks = component.$$.callbacks[type];
|
|
215
|
+
if (callbacks) {
|
|
216
|
+
const event = custom_event(
|
|
217
|
+
/** @type {string} */
|
|
218
|
+
type,
|
|
219
|
+
detail,
|
|
220
|
+
{ cancelable }
|
|
221
|
+
);
|
|
222
|
+
callbacks.slice().forEach((fn) => {
|
|
223
|
+
fn.call(component, event);
|
|
224
|
+
});
|
|
225
|
+
return !event.defaultPrevented;
|
|
226
|
+
}
|
|
227
|
+
return true;
|
|
228
|
+
};
|
|
229
|
+
}
|
|
173
230
|
|
|
174
231
|
// node_modules/svelte/src/runtime/internal/scheduler.js
|
|
175
232
|
var dirty_components = [];
|
|
@@ -249,6 +306,20 @@
|
|
|
249
306
|
// node_modules/svelte/src/runtime/internal/transitions.js
|
|
250
307
|
var outroing = /* @__PURE__ */ new Set();
|
|
251
308
|
var outros;
|
|
309
|
+
function group_outros() {
|
|
310
|
+
outros = {
|
|
311
|
+
r: 0,
|
|
312
|
+
c: [],
|
|
313
|
+
p: outros
|
|
314
|
+
// parent group
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function check_outros() {
|
|
318
|
+
if (!outros.r) {
|
|
319
|
+
run_all(outros.c);
|
|
320
|
+
}
|
|
321
|
+
outros = outros.p;
|
|
322
|
+
}
|
|
252
323
|
function transition_in(block, local) {
|
|
253
324
|
if (block && block.i) {
|
|
254
325
|
outroing.delete(block);
|
|
@@ -348,7 +419,7 @@
|
|
|
348
419
|
}
|
|
349
420
|
component.$$.dirty[i / 31 | 0] |= 1 << i % 31;
|
|
350
421
|
}
|
|
351
|
-
function init(component, options, instance3,
|
|
422
|
+
function init(component, options, instance3, create_fragment4, not_equal, props, append_styles2 = null, dirty = [-1]) {
|
|
352
423
|
const parent_component = current_component;
|
|
353
424
|
set_current_component(component);
|
|
354
425
|
const $$ = component.$$ = {
|
|
@@ -387,7 +458,7 @@
|
|
|
387
458
|
$$.update();
|
|
388
459
|
ready = true;
|
|
389
460
|
run_all($$.before_update);
|
|
390
|
-
$$.fragment =
|
|
461
|
+
$$.fragment = create_fragment4 ? create_fragment4($$.ctx) : false;
|
|
391
462
|
if (options.target) {
|
|
392
463
|
if (options.hydrate) {
|
|
393
464
|
start_hydrating();
|
|
@@ -694,6 +765,94 @@
|
|
|
694
765
|
if (typeof window !== "undefined")
|
|
695
766
|
(window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(PUBLIC_VERSION);
|
|
696
767
|
|
|
768
|
+
// node_modules/svelte/src/runtime/store/index.js
|
|
769
|
+
var subscriber_queue = [];
|
|
770
|
+
function writable(value, start = noop) {
|
|
771
|
+
let stop;
|
|
772
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
773
|
+
function set(new_value) {
|
|
774
|
+
if (safe_not_equal(value, new_value)) {
|
|
775
|
+
value = new_value;
|
|
776
|
+
if (stop) {
|
|
777
|
+
const run_queue = !subscriber_queue.length;
|
|
778
|
+
for (const subscriber of subscribers) {
|
|
779
|
+
subscriber[1]();
|
|
780
|
+
subscriber_queue.push(subscriber, value);
|
|
781
|
+
}
|
|
782
|
+
if (run_queue) {
|
|
783
|
+
for (let i = 0; i < subscriber_queue.length; i += 2) {
|
|
784
|
+
subscriber_queue[i][0](subscriber_queue[i + 1]);
|
|
785
|
+
}
|
|
786
|
+
subscriber_queue.length = 0;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
function update2(fn) {
|
|
792
|
+
set(fn(value));
|
|
793
|
+
}
|
|
794
|
+
function subscribe2(run2, invalidate = noop) {
|
|
795
|
+
const subscriber = [run2, invalidate];
|
|
796
|
+
subscribers.add(subscriber);
|
|
797
|
+
if (subscribers.size === 1) {
|
|
798
|
+
stop = start(set, update2) || noop;
|
|
799
|
+
}
|
|
800
|
+
run2(value);
|
|
801
|
+
return () => {
|
|
802
|
+
subscribers.delete(subscriber);
|
|
803
|
+
if (subscribers.size === 0 && stop) {
|
|
804
|
+
stop();
|
|
805
|
+
stop = null;
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
return { set, update: update2, subscribe: subscribe2 };
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
// src/lib/stores/setup.ts
|
|
813
|
+
var baseUrl = writable(null);
|
|
814
|
+
var appToken = writable(null);
|
|
815
|
+
|
|
816
|
+
// src/lib/stores/general.ts
|
|
817
|
+
var skipUserValidation = writable(false);
|
|
818
|
+
|
|
819
|
+
// src/lib/composables/useSetup.ts
|
|
820
|
+
var useSetupAPI = () => {
|
|
821
|
+
const eatSetupConfig = window.eatSDK;
|
|
822
|
+
if (!eatSetupConfig) {
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
const { setup, general } = eatSetupConfig.config;
|
|
826
|
+
if (setup) {
|
|
827
|
+
const { base_url: baseURL, app_secret: appSecret } = setup;
|
|
828
|
+
baseUrl.set(String(baseURL));
|
|
829
|
+
appToken.set(String(appSecret));
|
|
830
|
+
}
|
|
831
|
+
if (general) {
|
|
832
|
+
const { skip_user_validation: skipValidation } = general;
|
|
833
|
+
skipUserValidation.set(Boolean(skipValidation));
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
|
|
837
|
+
// src/lib/composables/useBaseFetch.ts
|
|
838
|
+
var getBaseUrl = (url) => `${get_store_value(baseUrl)}/${url}`;
|
|
839
|
+
var getHeaders = (otherHeaders = {}) => {
|
|
840
|
+
return { Authorization: `Bearer ${get_store_value(appToken)}`, ...otherHeaders };
|
|
841
|
+
};
|
|
842
|
+
var useGet = async (url) => {
|
|
843
|
+
const response = await fetch(getBaseUrl(url), { headers: getHeaders() });
|
|
844
|
+
return await response.json();
|
|
845
|
+
};
|
|
846
|
+
var usePatch = async (url, body) => {
|
|
847
|
+
const headers = getHeaders({ "Content-type": "application/json" });
|
|
848
|
+
const response = await fetch(getBaseUrl(url), {
|
|
849
|
+
method: "PATCH",
|
|
850
|
+
headers,
|
|
851
|
+
body: JSON.stringify(body)
|
|
852
|
+
});
|
|
853
|
+
return await response.json();
|
|
854
|
+
};
|
|
855
|
+
|
|
697
856
|
// src/lib/composables/useMCQ.ts
|
|
698
857
|
var useAlphabetEquivalent = (index) => {
|
|
699
858
|
const alphabetArr = [
|
|
@@ -731,59 +890,40 @@
|
|
|
731
890
|
// src/lib/components/prompt/mcq/PromptMCQ.svelte
|
|
732
891
|
function get_each_context(ctx, list, i) {
|
|
733
892
|
const child_ctx = ctx.slice();
|
|
734
|
-
child_ctx[
|
|
735
|
-
child_ctx[
|
|
736
|
-
child_ctx[
|
|
893
|
+
child_ctx[11] = list[i][0];
|
|
894
|
+
child_ctx[12] = list[i][1];
|
|
895
|
+
child_ctx[14] = i;
|
|
737
896
|
return child_ctx;
|
|
738
897
|
}
|
|
739
898
|
function create_if_block(ctx) {
|
|
740
|
-
let div2;
|
|
741
|
-
let p0;
|
|
742
|
-
let t1;
|
|
743
|
-
let p1;
|
|
744
|
-
let t3;
|
|
745
|
-
let div0;
|
|
746
|
-
let t4;
|
|
747
899
|
let div1;
|
|
748
|
-
let
|
|
900
|
+
let div0;
|
|
901
|
+
let div0_class_value;
|
|
902
|
+
let t;
|
|
903
|
+
let each_value = ensure_array_like(Object.entries(
|
|
749
904
|
/*options*/
|
|
750
905
|
ctx[4]
|
|
751
|
-
);
|
|
906
|
+
));
|
|
752
907
|
let each_blocks = [];
|
|
753
908
|
for (let i = 0; i < each_value.length; i += 1) {
|
|
754
909
|
each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
|
|
755
910
|
}
|
|
756
911
|
return {
|
|
757
912
|
c() {
|
|
758
|
-
div2 = element("div");
|
|
759
|
-
p0 = element("p");
|
|
760
|
-
p0.textContent = `${/*rubric*/
|
|
761
|
-
ctx[2].text}`;
|
|
762
|
-
t1 = space();
|
|
763
|
-
p1 = element("p");
|
|
764
|
-
p1.textContent = `${/*prompt*/
|
|
765
|
-
ctx[3]}`;
|
|
766
|
-
t3 = space();
|
|
767
|
-
div0 = element("div");
|
|
768
|
-
t4 = space();
|
|
769
913
|
div1 = element("div");
|
|
914
|
+
div0 = element("div");
|
|
915
|
+
t = space();
|
|
770
916
|
for (let i = 0; i < each_blocks.length; i += 1) {
|
|
771
917
|
each_blocks[i].c();
|
|
772
918
|
}
|
|
773
|
-
attr(
|
|
774
|
-
|
|
775
|
-
attr(
|
|
776
|
-
attr(div2, "class", "bg-transparent");
|
|
919
|
+
attr(div0, "class", div0_class_value = /*isDataSaving*/
|
|
920
|
+
ctx[0] ? "absolute inset-0 bg-transparent z-50" : "");
|
|
921
|
+
attr(div1, "class", "relative");
|
|
777
922
|
},
|
|
778
923
|
m(target, anchor) {
|
|
779
|
-
insert(target,
|
|
780
|
-
append(
|
|
781
|
-
append(
|
|
782
|
-
append(div2, p1);
|
|
783
|
-
append(div2, t3);
|
|
784
|
-
append(div2, div0);
|
|
785
|
-
append(div2, t4);
|
|
786
|
-
append(div2, div1);
|
|
924
|
+
insert(target, div1, anchor);
|
|
925
|
+
append(div1, div0);
|
|
926
|
+
append(div1, t);
|
|
787
927
|
for (let i = 0; i < each_blocks.length; i += 1) {
|
|
788
928
|
if (each_blocks[i]) {
|
|
789
929
|
each_blocks[i].m(div1, null);
|
|
@@ -791,12 +931,17 @@
|
|
|
791
931
|
}
|
|
792
932
|
},
|
|
793
933
|
p(ctx2, dirty) {
|
|
794
|
-
if (dirty & /*
|
|
934
|
+
if (dirty & /*isDataSaving*/
|
|
935
|
+
1 && div0_class_value !== (div0_class_value = /*isDataSaving*/
|
|
936
|
+
ctx2[0] ? "absolute inset-0 bg-transparent z-50" : "")) {
|
|
937
|
+
attr(div0, "class", div0_class_value);
|
|
938
|
+
}
|
|
939
|
+
if (dirty & /*Object, options, selectedOption, handleOptionClick*/
|
|
795
940
|
50) {
|
|
796
|
-
each_value = ensure_array_like(
|
|
941
|
+
each_value = ensure_array_like(Object.entries(
|
|
797
942
|
/*options*/
|
|
798
943
|
ctx2[4]
|
|
799
|
-
);
|
|
944
|
+
));
|
|
800
945
|
let i;
|
|
801
946
|
for (i = 0; i < each_value.length; i += 1) {
|
|
802
947
|
const child_ctx = get_each_context(ctx2, each_value, i);
|
|
@@ -816,7 +961,7 @@
|
|
|
816
961
|
},
|
|
817
962
|
d(detaching) {
|
|
818
963
|
if (detaching) {
|
|
819
|
-
detach(
|
|
964
|
+
detach(div1);
|
|
820
965
|
}
|
|
821
966
|
destroy_each(each_blocks, detaching);
|
|
822
967
|
}
|
|
@@ -827,8 +972,8 @@
|
|
|
827
972
|
let span;
|
|
828
973
|
let t1;
|
|
829
974
|
let t2_value = (
|
|
830
|
-
/*
|
|
831
|
-
ctx[
|
|
975
|
+
/*option*/
|
|
976
|
+
ctx[12].answer + ""
|
|
832
977
|
);
|
|
833
978
|
let t2;
|
|
834
979
|
let t3;
|
|
@@ -839,9 +984,9 @@
|
|
|
839
984
|
function click_handler() {
|
|
840
985
|
return (
|
|
841
986
|
/*click_handler*/
|
|
842
|
-
ctx[
|
|
843
|
-
/*
|
|
844
|
-
ctx[
|
|
987
|
+
ctx[7](
|
|
988
|
+
/*option*/
|
|
989
|
+
ctx[12]
|
|
845
990
|
)
|
|
846
991
|
);
|
|
847
992
|
}
|
|
@@ -851,7 +996,7 @@
|
|
|
851
996
|
span = element("span");
|
|
852
997
|
span.textContent = `${useMCQ_default(
|
|
853
998
|
/*index*/
|
|
854
|
-
ctx[
|
|
999
|
+
ctx[14]
|
|
855
1000
|
)}`;
|
|
856
1001
|
t1 = space();
|
|
857
1002
|
t2 = text(t2_value);
|
|
@@ -859,12 +1004,12 @@
|
|
|
859
1004
|
attr(span, "class", "choice group-active:border-2 group-active:border-blue-1000 group-active:p-[7px]");
|
|
860
1005
|
attr(button, "aria-label", button_aria_label_value = `Option ${useMCQ_default(
|
|
861
1006
|
/*index*/
|
|
862
|
-
ctx[
|
|
863
|
-
)}: ${/*
|
|
864
|
-
ctx[
|
|
1007
|
+
ctx[14]
|
|
1008
|
+
)}: ${/*option*/
|
|
1009
|
+
ctx[12].answer}`);
|
|
865
1010
|
attr(button, "class", button_class_value = "btn-mcq-option group " + /*selectedOption*/
|
|
866
|
-
(ctx[1] === /*
|
|
867
|
-
ctx[
|
|
1011
|
+
(ctx[1] === /*option*/
|
|
1012
|
+
ctx[12].id ? "selected" : ""));
|
|
868
1013
|
},
|
|
869
1014
|
m(target, anchor) {
|
|
870
1015
|
insert(target, button, anchor);
|
|
@@ -881,8 +1026,8 @@
|
|
|
881
1026
|
ctx = new_ctx;
|
|
882
1027
|
if (dirty & /*selectedOption*/
|
|
883
1028
|
2 && button_class_value !== (button_class_value = "btn-mcq-option group " + /*selectedOption*/
|
|
884
|
-
(ctx[1] === /*
|
|
885
|
-
ctx[
|
|
1029
|
+
(ctx[1] === /*option*/
|
|
1030
|
+
ctx[12].id ? "selected" : ""))) {
|
|
886
1031
|
attr(button, "class", button_class_value);
|
|
887
1032
|
}
|
|
888
1033
|
},
|
|
@@ -896,102 +1041,204 @@
|
|
|
896
1041
|
};
|
|
897
1042
|
}
|
|
898
1043
|
function create_fragment(ctx) {
|
|
899
|
-
let
|
|
1044
|
+
let div1;
|
|
1045
|
+
let p0;
|
|
1046
|
+
let t1;
|
|
1047
|
+
let p1;
|
|
1048
|
+
let t3;
|
|
1049
|
+
let div0;
|
|
1050
|
+
let t4;
|
|
900
1051
|
let if_block = (
|
|
901
|
-
/*
|
|
902
|
-
ctx[
|
|
1052
|
+
/*options*/
|
|
1053
|
+
ctx[4] && create_if_block(ctx)
|
|
903
1054
|
);
|
|
904
1055
|
return {
|
|
905
1056
|
c() {
|
|
1057
|
+
div1 = element("div");
|
|
1058
|
+
p0 = element("p");
|
|
1059
|
+
p0.textContent = `${/*rubric*/
|
|
1060
|
+
ctx[2].text}`;
|
|
1061
|
+
t1 = space();
|
|
1062
|
+
p1 = element("p");
|
|
1063
|
+
p1.textContent = `${/*prompt*/
|
|
1064
|
+
ctx[3]}`;
|
|
1065
|
+
t3 = space();
|
|
1066
|
+
div0 = element("div");
|
|
1067
|
+
t4 = space();
|
|
906
1068
|
if (if_block)
|
|
907
1069
|
if_block.c();
|
|
908
|
-
|
|
1070
|
+
attr(p0, "class", "h5 mb-2 md:mb-4");
|
|
1071
|
+
attr(p1, "class", "h5 font-semibold");
|
|
1072
|
+
attr(div0, "class", "divider my-6");
|
|
1073
|
+
attr(div1, "class", "bg-transparent");
|
|
909
1074
|
},
|
|
910
1075
|
m(target, anchor) {
|
|
1076
|
+
insert(target, div1, anchor);
|
|
1077
|
+
append(div1, p0);
|
|
1078
|
+
append(div1, t1);
|
|
1079
|
+
append(div1, p1);
|
|
1080
|
+
append(div1, t3);
|
|
1081
|
+
append(div1, div0);
|
|
1082
|
+
append(div1, t4);
|
|
911
1083
|
if (if_block)
|
|
912
|
-
if_block.m(
|
|
913
|
-
insert(target, if_block_anchor, anchor);
|
|
1084
|
+
if_block.m(div1, null);
|
|
914
1085
|
},
|
|
915
1086
|
p(ctx2, [dirty]) {
|
|
916
1087
|
if (
|
|
917
|
-
/*
|
|
918
|
-
ctx2[
|
|
919
|
-
)
|
|
920
|
-
|
|
921
|
-
if_block.p(ctx2, dirty);
|
|
922
|
-
} else {
|
|
923
|
-
if_block = create_if_block(ctx2);
|
|
924
|
-
if_block.c();
|
|
925
|
-
if_block.m(if_block_anchor.parentNode, if_block_anchor);
|
|
926
|
-
}
|
|
927
|
-
} else if (if_block) {
|
|
928
|
-
if_block.d(1);
|
|
929
|
-
if_block = null;
|
|
930
|
-
}
|
|
1088
|
+
/*options*/
|
|
1089
|
+
ctx2[4]
|
|
1090
|
+
)
|
|
1091
|
+
if_block.p(ctx2, dirty);
|
|
931
1092
|
},
|
|
932
1093
|
i: noop,
|
|
933
1094
|
o: noop,
|
|
934
1095
|
d(detaching) {
|
|
935
1096
|
if (detaching) {
|
|
936
|
-
detach(
|
|
1097
|
+
detach(div1);
|
|
937
1098
|
}
|
|
938
1099
|
if (if_block)
|
|
939
|
-
if_block.d(
|
|
1100
|
+
if_block.d();
|
|
940
1101
|
}
|
|
941
1102
|
};
|
|
942
1103
|
}
|
|
943
1104
|
function instance($$self, $$props, $$invalidate) {
|
|
944
|
-
let {
|
|
945
|
-
|
|
1105
|
+
let { sessionData } = $$props;
|
|
1106
|
+
let { isDataSaving } = $$props;
|
|
1107
|
+
const { rubric, interaction, metadata } = sessionData;
|
|
946
1108
|
const { prompt, options } = interaction;
|
|
947
1109
|
let selectedOption;
|
|
948
|
-
const
|
|
949
|
-
|
|
1110
|
+
const dispatch = createEventDispatcher();
|
|
1111
|
+
if (metadata) {
|
|
1112
|
+
const { events } = metadata.interactions;
|
|
1113
|
+
const currentOption = events.pop();
|
|
1114
|
+
const { answer_id: answerChoiceId } = currentOption;
|
|
1115
|
+
selectedOption = answerChoiceId;
|
|
1116
|
+
}
|
|
1117
|
+
const handleOptionClick = (optionId, option) => {
|
|
1118
|
+
if (isDataSaving || optionId === selectedOption)
|
|
1119
|
+
return;
|
|
1120
|
+
$$invalidate(1, selectedOption = optionId);
|
|
1121
|
+
dispatch("saveOption", {
|
|
1122
|
+
answerChoiceId: optionId,
|
|
1123
|
+
answerChoice: option
|
|
1124
|
+
});
|
|
950
1125
|
};
|
|
951
|
-
const click_handler = (
|
|
1126
|
+
const click_handler = (option) => handleOptionClick(option.id, option.answer);
|
|
952
1127
|
$$self.$$set = ($$props2) => {
|
|
953
|
-
if ("
|
|
954
|
-
$$invalidate(
|
|
1128
|
+
if ("sessionData" in $$props2)
|
|
1129
|
+
$$invalidate(6, sessionData = $$props2.sessionData);
|
|
1130
|
+
if ("isDataSaving" in $$props2)
|
|
1131
|
+
$$invalidate(0, isDataSaving = $$props2.isDataSaving);
|
|
955
1132
|
};
|
|
956
1133
|
return [
|
|
957
|
-
|
|
1134
|
+
isDataSaving,
|
|
958
1135
|
selectedOption,
|
|
959
1136
|
rubric,
|
|
960
1137
|
prompt,
|
|
961
1138
|
options,
|
|
962
1139
|
handleOptionClick,
|
|
1140
|
+
sessionData,
|
|
963
1141
|
click_handler
|
|
964
1142
|
];
|
|
965
1143
|
}
|
|
966
1144
|
var PromptMCQ = class extends SvelteComponent {
|
|
967
1145
|
constructor(options) {
|
|
968
1146
|
super();
|
|
969
|
-
init(this, options, instance, create_fragment, safe_not_equal, {
|
|
1147
|
+
init(this, options, instance, create_fragment, safe_not_equal, { sessionData: 6, isDataSaving: 0 });
|
|
970
1148
|
}
|
|
971
|
-
get
|
|
1149
|
+
get sessionData() {
|
|
1150
|
+
return this.$$.ctx[6];
|
|
1151
|
+
}
|
|
1152
|
+
set sessionData(sessionData) {
|
|
1153
|
+
this.$$set({ sessionData });
|
|
1154
|
+
flush();
|
|
1155
|
+
}
|
|
1156
|
+
get isDataSaving() {
|
|
972
1157
|
return this.$$.ctx[0];
|
|
973
1158
|
}
|
|
974
|
-
set
|
|
975
|
-
this.$$set({
|
|
1159
|
+
set isDataSaving(isDataSaving) {
|
|
1160
|
+
this.$$set({ isDataSaving });
|
|
976
1161
|
flush();
|
|
977
1162
|
}
|
|
978
1163
|
};
|
|
979
|
-
customElements.define("prompt-mcq", create_custom_element(PromptMCQ, { "
|
|
1164
|
+
customElements.define("prompt-mcq", create_custom_element(PromptMCQ, { "sessionData": {}, "isDataSaving": {} }, [], [], true));
|
|
980
1165
|
var PromptMCQ_default = PromptMCQ;
|
|
981
1166
|
|
|
1167
|
+
// src/lib/components/prompt/skeleton/PromptSkeleton.svelte
|
|
1168
|
+
function create_fragment2(ctx) {
|
|
1169
|
+
let div3;
|
|
1170
|
+
return {
|
|
1171
|
+
c() {
|
|
1172
|
+
div3 = element("div");
|
|
1173
|
+
div3.innerHTML = `<div class="animate-skeleton w-full h-6 mb-2 rounded md:mb-4"></div> <div class="animate-skeleton w-full h-6 mb-12 rounded"></div> <div class="animate-skeleton w-full h-52 rounded"></div>`;
|
|
1174
|
+
},
|
|
1175
|
+
m(target, anchor) {
|
|
1176
|
+
insert(target, div3, anchor);
|
|
1177
|
+
},
|
|
1178
|
+
p: noop,
|
|
1179
|
+
i: noop,
|
|
1180
|
+
o: noop,
|
|
1181
|
+
d(detaching) {
|
|
1182
|
+
if (detaching) {
|
|
1183
|
+
detach(div3);
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
var PromptSkeleton = class extends SvelteComponent {
|
|
1189
|
+
constructor(options) {
|
|
1190
|
+
super();
|
|
1191
|
+
init(this, options, null, create_fragment2, safe_not_equal, {});
|
|
1192
|
+
}
|
|
1193
|
+
};
|
|
1194
|
+
customElements.define("prompt-skeleton", create_custom_element(PromptSkeleton, {}, [], [], true));
|
|
1195
|
+
var PromptSkeleton_default = PromptSkeleton;
|
|
1196
|
+
|
|
982
1197
|
// src/lib/components/prompt/PromptBuilder.svelte
|
|
983
1198
|
function add_css(target) {
|
|
984
|
-
append_styles(target, "svelte-
|
|
1199
|
+
append_styles(target, "svelte-1mk0xi4", '*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}html{-webkit-text-size-adjust:100%;font-feature-settings:normal;font-family:Mulish, sans-serif;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}*{font-family:Mulish, sans-serif}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.h5{--tw-text-opacity:1;color:rgb(8 38 99/var(--tw-text-opacity));font-size:1.25rem;letter-spacing:-0.025em;line-height:1.5rem}.divider{--tw-border-opacity:1;border-bottom-width:1px;border-color:rgb(107 121 121/var(--tw-border-opacity))}@keyframes svelte-1mk0xi4-pulse{50%{opacity:0.5}}.animate-skeleton{--tw-bg-opacity:1;animation:svelte-1mk0xi4-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;background-color:rgb(226 232 240/var(--tw-bg-opacity))}.btn-mcq-option:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);--tw-ring-opacity:1;--tw-ring-color:rgb(84 101 251/var(--tw-ring-opacity));--tw-ring-offset-width:4px;box-shadow:var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 rgba(0, 0, 0, 0));outline:2px solid transparent;outline-offset:2px;transition-duration:50ms}.btn-mcq-option{--tw-text-opacity:1;--tw-border-opacity:1;--tw-bg-opacity:1;align-items:center;background-color:rgb(247 250 250/var(--tw-bg-opacity));border-color:rgb(113 115 119/var(--tw-border-opacity));border-radius:0.5rem;border-width:1px;color:rgb(33 37 41/var(--tw-text-opacity));display:flex;font-size:1rem;line-height:1.5rem;margin-bottom:1rem;max-height:48px;padding:0.5rem 0.75rem 0.5rem 0.5rem;width:100%}.btn-mcq-option:active{--tw-border-opacity:1;--tw-bg-opacity:1;background-color:rgb(222 222 255/var(--tw-bg-opacity));border-color:rgb(8 38 99/var(--tw-border-opacity));border-width:2px}@media(hover: hover) and (pointer: fine){.btn-mcq-option:hover{--tw-bg-opacity:1;background-color:rgb(222 222 255/var(--tw-bg-opacity))}}.btn-mcq-option>.choice{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-text-opacity:1;align-items:center;background-color:rgb(255 255 255/var(--tw-bg-opacity));border-color:rgb(113 115 119/var(--tw-border-opacity));border-radius:1rem;border-width:1px;color:rgb(93 99 107/var(--tw-text-opacity));display:flex;font-size:1rem;font-weight:700;height:2rem;justify-content:center;letter-spacing:0.05em;line-height:1rem;margin-right:1rem;padding:0.5rem;width:2rem}.btn-mcq-option.selected{--tw-border-opacity:1;--tw-bg-opacity:1;background-color:rgb(222 222 255/var(--tw-bg-opacity))}.btn-mcq-option.selected,.btn-mcq-option.selected>.choice{border-color:rgb(8 38 99/var(--tw-border-opacity));border-width:2px}.btn-mcq-option.selected>.choice{--tw-border-opacity:1}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.z-50{z-index:50}.my-6{margin-bottom:1.5rem;margin-top:1.5rem}.mb-12{margin-bottom:3rem}.mb-2{margin-bottom:0.5rem}.h-52{height:13rem}.h-6{height:1.5rem}.w-full{width:100%}.rounded{border-radius:0.25rem}.border-2{border-width:2px}.border-red-600{--tw-border-opacity:1;border-color:rgb(220 38 38/var(--tw-border-opacity))}.bg-red-200{--tw-bg-opacity:1;background-color:rgb(254 202 202/var(--tw-bg-opacity))}.bg-transparent{background-color:transparent}.p-2{padding:0.5rem}.font-semibold{font-weight:600}.group:active .group-active\\:border-2{border-width:2px}.group:active .group-active\\:border-blue-1000{--tw-border-opacity:1;border-color:rgb(8 38 99/var(--tw-border-opacity))}.group:active .group-active\\:p-\\[7px\\]{padding:7px}@media(min-width: 732px){.md\\:mb-4{margin-bottom:1rem}}');
|
|
985
1200
|
}
|
|
986
|
-
function
|
|
1201
|
+
function create_else_block(ctx) {
|
|
1202
|
+
let p;
|
|
1203
|
+
return {
|
|
1204
|
+
c() {
|
|
1205
|
+
p = element("p");
|
|
1206
|
+
p.textContent = "Invalid session id.";
|
|
1207
|
+
attr(p, "class", "p-2 border-2 border-red-600 bg-red-200 rounded");
|
|
1208
|
+
},
|
|
1209
|
+
m(target, anchor) {
|
|
1210
|
+
insert(target, p, anchor);
|
|
1211
|
+
},
|
|
1212
|
+
p: noop,
|
|
1213
|
+
i: noop,
|
|
1214
|
+
o: noop,
|
|
1215
|
+
d(detaching) {
|
|
1216
|
+
if (detaching) {
|
|
1217
|
+
detach(p);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
function create_if_block_1(ctx) {
|
|
987
1223
|
let promptmcq;
|
|
988
1224
|
let current;
|
|
989
1225
|
promptmcq = new PromptMCQ_default({
|
|
990
|
-
props: {
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1226
|
+
props: {
|
|
1227
|
+
sessionData: (
|
|
1228
|
+
/*sessionData*/
|
|
1229
|
+
ctx[0]
|
|
1230
|
+
),
|
|
1231
|
+
isDataSaving: (
|
|
1232
|
+
/*isDataSaving*/
|
|
1233
|
+
ctx[2]
|
|
1234
|
+
)
|
|
1235
|
+
}
|
|
994
1236
|
});
|
|
1237
|
+
promptmcq.$on(
|
|
1238
|
+
"saveOption",
|
|
1239
|
+
/*saveOption*/
|
|
1240
|
+
ctx[3]
|
|
1241
|
+
);
|
|
995
1242
|
return {
|
|
996
1243
|
c() {
|
|
997
1244
|
create_component(promptmcq.$$.fragment);
|
|
@@ -1000,12 +1247,16 @@
|
|
|
1000
1247
|
mount_component(promptmcq, target, anchor);
|
|
1001
1248
|
current = true;
|
|
1002
1249
|
},
|
|
1003
|
-
p(ctx2,
|
|
1250
|
+
p(ctx2, dirty) {
|
|
1004
1251
|
const promptmcq_changes = {};
|
|
1005
|
-
if (dirty & /*
|
|
1252
|
+
if (dirty & /*sessionData*/
|
|
1006
1253
|
1)
|
|
1007
|
-
promptmcq_changes.
|
|
1254
|
+
promptmcq_changes.sessionData = /*sessionData*/
|
|
1008
1255
|
ctx2[0];
|
|
1256
|
+
if (dirty & /*isDataSaving*/
|
|
1257
|
+
4)
|
|
1258
|
+
promptmcq_changes.isDataSaving = /*isDataSaving*/
|
|
1259
|
+
ctx2[2];
|
|
1009
1260
|
promptmcq.$set(promptmcq_changes);
|
|
1010
1261
|
},
|
|
1011
1262
|
i(local) {
|
|
@@ -1023,46 +1274,160 @@
|
|
|
1023
1274
|
}
|
|
1024
1275
|
};
|
|
1025
1276
|
}
|
|
1026
|
-
function
|
|
1027
|
-
let
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1277
|
+
function create_if_block2(ctx) {
|
|
1278
|
+
let promptskeleton;
|
|
1279
|
+
let current;
|
|
1280
|
+
promptskeleton = new PromptSkeleton_default({});
|
|
1281
|
+
return {
|
|
1282
|
+
c() {
|
|
1283
|
+
create_component(promptskeleton.$$.fragment);
|
|
1284
|
+
},
|
|
1285
|
+
m(target, anchor) {
|
|
1286
|
+
mount_component(promptskeleton, target, anchor);
|
|
1287
|
+
current = true;
|
|
1288
|
+
},
|
|
1289
|
+
p: noop,
|
|
1290
|
+
i(local) {
|
|
1291
|
+
if (current)
|
|
1292
|
+
return;
|
|
1293
|
+
transition_in(promptskeleton.$$.fragment, local);
|
|
1294
|
+
current = true;
|
|
1295
|
+
},
|
|
1296
|
+
o(local) {
|
|
1297
|
+
transition_out(promptskeleton.$$.fragment, local);
|
|
1298
|
+
current = false;
|
|
1299
|
+
},
|
|
1300
|
+
d(detaching) {
|
|
1301
|
+
destroy_component(promptskeleton, detaching);
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
function create_fragment3(ctx) {
|
|
1306
|
+
let current_block_type_index;
|
|
1307
|
+
let if_block;
|
|
1308
|
+
let if_block_anchor;
|
|
1309
|
+
let current;
|
|
1310
|
+
const if_block_creators = [create_if_block2, create_if_block_1, create_else_block];
|
|
1311
|
+
const if_blocks = [];
|
|
1312
|
+
function select_block_type(ctx2, dirty) {
|
|
1313
|
+
if (
|
|
1314
|
+
/*isDataFetching*/
|
|
1315
|
+
ctx2[1]
|
|
1316
|
+
)
|
|
1317
|
+
return 0;
|
|
1318
|
+
if (
|
|
1319
|
+
/*sessionData*/
|
|
1320
|
+
ctx2[0]
|
|
1321
|
+
)
|
|
1322
|
+
return 1;
|
|
1323
|
+
return 2;
|
|
1324
|
+
}
|
|
1325
|
+
current_block_type_index = select_block_type(ctx, -1);
|
|
1326
|
+
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
|
|
1327
|
+
return {
|
|
1328
|
+
c() {
|
|
1329
|
+
if_block.c();
|
|
1330
|
+
if_block_anchor = empty();
|
|
1035
1331
|
},
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1332
|
+
m(target, anchor) {
|
|
1333
|
+
if_blocks[current_block_type_index].m(target, anchor);
|
|
1334
|
+
insert(target, if_block_anchor, anchor);
|
|
1335
|
+
current = true;
|
|
1039
1336
|
},
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1337
|
+
p(ctx2, [dirty]) {
|
|
1338
|
+
let previous_block_index = current_block_type_index;
|
|
1339
|
+
current_block_type_index = select_block_type(ctx2, dirty);
|
|
1340
|
+
if (current_block_type_index === previous_block_index) {
|
|
1341
|
+
if_blocks[current_block_type_index].p(ctx2, dirty);
|
|
1342
|
+
} else {
|
|
1343
|
+
group_outros();
|
|
1344
|
+
transition_out(if_blocks[previous_block_index], 1, 1, () => {
|
|
1345
|
+
if_blocks[previous_block_index] = null;
|
|
1346
|
+
});
|
|
1347
|
+
check_outros();
|
|
1348
|
+
if_block = if_blocks[current_block_type_index];
|
|
1349
|
+
if (!if_block) {
|
|
1350
|
+
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
|
|
1351
|
+
if_block.c();
|
|
1352
|
+
} else {
|
|
1353
|
+
if_block.p(ctx2, dirty);
|
|
1056
1354
|
}
|
|
1057
|
-
|
|
1355
|
+
transition_in(if_block, 1);
|
|
1356
|
+
if_block.m(if_block_anchor.parentNode, if_block_anchor);
|
|
1357
|
+
}
|
|
1358
|
+
},
|
|
1359
|
+
i(local) {
|
|
1360
|
+
if (current)
|
|
1361
|
+
return;
|
|
1362
|
+
transition_in(if_block);
|
|
1363
|
+
current = true;
|
|
1364
|
+
},
|
|
1365
|
+
o(local) {
|
|
1366
|
+
transition_out(if_block);
|
|
1367
|
+
current = false;
|
|
1368
|
+
},
|
|
1369
|
+
d(detaching) {
|
|
1370
|
+
if (detaching) {
|
|
1371
|
+
detach(if_block_anchor);
|
|
1372
|
+
}
|
|
1373
|
+
if_blocks[current_block_type_index].d(detaching);
|
|
1374
|
+
}
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
function instance2($$self, $$props, $$invalidate) {
|
|
1378
|
+
const { "session-id": sessionId } = $$props;
|
|
1379
|
+
useSetupAPI();
|
|
1380
|
+
let sessionData;
|
|
1381
|
+
let isDataFetching = true;
|
|
1382
|
+
let isDataSaving = false;
|
|
1383
|
+
const skipUserValidationStr = get_store_value(skipUserValidation) ? "?skip_user_validation=true" : "";
|
|
1384
|
+
const getSessionData = async (sessionId2) => {
|
|
1385
|
+
try {
|
|
1386
|
+
const { data } = await useGet(`sessions/${sessionId2}${skipUserValidationStr}`);
|
|
1387
|
+
const { item_id: itemId, metadata } = data;
|
|
1388
|
+
if (itemId) {
|
|
1389
|
+
await getItemData(itemId, metadata);
|
|
1390
|
+
}
|
|
1391
|
+
} catch (error) {
|
|
1392
|
+
$$invalidate(1, isDataFetching = false);
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
const getItemData = async (itemId, metadata) => {
|
|
1396
|
+
try {
|
|
1397
|
+
const { data } = await useGet(`items/${itemId}`);
|
|
1398
|
+
$$invalidate(0, sessionData = { ...data, metadata });
|
|
1399
|
+
} catch (error) {
|
|
1400
|
+
} finally {
|
|
1401
|
+
$$invalidate(1, isDataFetching = false);
|
|
1058
1402
|
}
|
|
1059
1403
|
};
|
|
1060
|
-
|
|
1404
|
+
const saveOption = async ({ detail }) => {
|
|
1405
|
+
$$invalidate(2, isDataSaving = true);
|
|
1406
|
+
try {
|
|
1407
|
+
const { answerChoiceId, answerChoice } = detail;
|
|
1408
|
+
await usePatch(`sessions/${sessionId}${skipUserValidationStr}`, {
|
|
1409
|
+
answer_id: answerChoiceId,
|
|
1410
|
+
answer_choice: answerChoice
|
|
1411
|
+
});
|
|
1412
|
+
} catch (error) {
|
|
1413
|
+
$$invalidate(2, isDataSaving = false);
|
|
1414
|
+
} finally {
|
|
1415
|
+
$$invalidate(2, isDataSaving = false);
|
|
1416
|
+
}
|
|
1417
|
+
};
|
|
1418
|
+
if (sessionId) {
|
|
1419
|
+
getSessionData(sessionId);
|
|
1420
|
+
}
|
|
1421
|
+
$$self.$$set = ($$new_props) => {
|
|
1422
|
+
$$invalidate(8, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)));
|
|
1423
|
+
};
|
|
1424
|
+
$$props = exclude_internal_props($$props);
|
|
1425
|
+
return [sessionData, isDataFetching, isDataSaving, saveOption];
|
|
1061
1426
|
}
|
|
1062
1427
|
var PromptBuilder = class extends SvelteComponent {
|
|
1063
1428
|
constructor(options) {
|
|
1064
1429
|
super();
|
|
1065
|
-
init(this, options, instance2,
|
|
1430
|
+
init(this, options, instance2, create_fragment3, safe_not_equal, {}, add_css);
|
|
1066
1431
|
}
|
|
1067
1432
|
};
|
|
1068
1433
|
customElements.define("prompt-builder", create_custom_element(PromptBuilder, {}, [], [], true));
|