@eliceio/cdk-cli 0.1.0-alpha.1 → 0.1.0-alpha.3
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/README.md +171 -136
- package/es/cli.js +119 -26
- package/es/commands/build/index.d.ts +4 -1
- package/es/commands/build/index.js +28 -9
- package/es/commands/check/index.d.ts +8 -2
- package/es/commands/check/index.js +45 -5
- package/es/commands/create/index.d.ts +2 -0
- package/es/commands/create/index.js +28 -3
- package/es/commands/create/scaffold.d.ts +2 -0
- package/es/commands/create/scaffold.js +10 -6
- package/es/commands/dev/index.d.ts +1 -1
- package/es/commands/dev/index.js +6 -2
- package/es/commands/doctor/index.d.ts +12 -0
- package/es/commands/doctor/index.js +217 -7
- package/es/commands/guide/index.d.ts +29 -0
- package/es/commands/guide/index.js +120 -0
- package/es/commands/mcp/index.d.ts +134 -0
- package/es/commands/mcp/index.js +399 -0
- package/es/commands/setup/index.d.ts +40 -0
- package/es/commands/setup/index.js +157 -0
- package/es/commands/skill/index.d.ts +45 -0
- package/es/commands/skill/index.js +145 -0
- package/es/core/config.d.ts +63 -19
- package/es/core/config.js +108 -32
- package/es/core/prepare.js +3 -5
- package/es/core/project-check.d.ts +15 -0
- package/es/core/project-check.js +26 -0
- package/es/core/sandbox.d.ts +17 -0
- package/es/core/sandbox.js +182 -0
- package/es/core/templates.d.ts +25 -0
- package/es/core/templates.js +41 -0
- package/es/dev/grading.d.ts +14 -7
- package/es/dev/grading.js +27 -13
- package/es/dev/host-page.d.ts +1 -1
- package/es/dev/host-page.js +33 -33
- package/es/dev/mock-api.d.ts +20 -4
- package/es/dev/mock-api.js +70 -9
- package/es/dev/server.d.ts +9 -1
- package/es/dev/server.js +101 -25
- package/es/rules/check.js +126 -4
- package/es/rules/index.d.ts +1 -1
- package/es/rules/index.js +1 -1
- package/es/rules/manifest.d.ts +23 -9
- package/es/rules/manifest.js +60 -35
- package/es/rules/node.js +3 -1
- package/es/rules/semver.d.ts +5 -0
- package/es/rules/semver.js +32 -0
- package/es/rules/types.d.ts +29 -6
- package/es/rules.json.js +1 -1
- package/es/version.d.ts +2 -1
- package/es/version.js +5 -1
- package/guides/content-development.md +294 -0
- package/package.json +4 -2
- package/rules.json +113 -5
- package/skills/_shared/always.md +9 -0
- package/skills/elice-content-check/SKILL.md +22 -0
- package/skills/elice-content-create/SKILL.md +21 -0
- package/skills/elice-content-migrate/SKILL.md +21 -0
- package/skills/elice-content-publish/SKILL.md +22 -0
- package/templates/_shared/lib/cdk-mock.d.ts +21 -3
- package/templates/_shared/lib/cdk-mock.js +239 -80
- package/templates/_shared/lib/cdk.js +2 -2
- package/templates/_shared/lib/elice-content.css +206 -0
- package/templates/_shared/lib/elice-content.d.ts +112 -5
- package/templates/_shared/lib/elice-content.js +660 -62
- package/templates/blank/README.md +14 -5
- package/templates/blank/commentary.txt +2 -0
- package/templates/blank/completion.html +15 -0
- package/templates/blank/elice.config.json +3 -5
- package/templates/blank/gitignore +1 -0
- package/templates/blank/screens/completion.js +7 -0
- package/templates/blank/screens/edit.js +3 -0
- package/templates/blank/template.json +6 -0
- package/templates/quiz/README.md +37 -30
- package/templates/quiz/commentary.txt +2 -0
- package/templates/quiz/content.json +17 -63
- package/templates/quiz/core/behaviors.d.ts +8 -3
- package/templates/quiz/core/behaviors.js +15 -2
- package/templates/quiz/core/model.d.ts +27 -1
- package/templates/quiz/core/model.js +199 -4
- package/templates/quiz/elice.config.json +1 -6
- package/templates/quiz/gitignore +1 -0
- package/templates/quiz/grading.json +1 -10
- package/templates/quiz/screens/edit.js +106 -32
- package/templates/quiz/screens/learn.js +13 -9
- package/templates/quiz/styles.css +84 -24
- package/templates/quiz/template.json +6 -0
- package/templates/quiz/ui/templates/edit.d.ts +2 -1
- package/templates/quiz/ui/templates/edit.js +16 -13
- package/templates/quiz/ui/templates/group.js +29 -8
- package/templates/quiz/ui/templates/question.js +3 -3
- package/templates/quiz/ui/texts.js +53 -29
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @eliceio/cdk 1.0.0-alpha.
|
|
1
|
+
/* @eliceio/cdk 1.0.0-alpha.3 — UMD. Copied at build time by scripts/copy-cdk.mjs; do not edit. */
|
|
2
2
|
// ecdk-ignore-next-line api.parent-access sec.postmessage-wildcard
|
|
3
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).elice=e.elice||{})}(this,function(e){"use strict";function t(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function n(e,t,n,i,s){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?s.call(e,n):s?s.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},s={exports:{}};!function(e){!function(t){var n=function(e,t,i){if(!c(t)||l(t)||d(t)||h(t)||a(t))return t;var s,r=0,o=0;if(u(t))for(s=[],o=t.length;r<o;r++)s.push(n(e,t[r],i));else for(var f in s={},t)Object.prototype.hasOwnProperty.call(t,f)&&(s[e(f,i)]=n(e,t[f],i));return s},i=function(e){return f(e)?e:(e=e.replace(/[\-_\s]+(.)?/g,function(e,t){return t?t.toUpperCase():""})).substr(0,1).toLowerCase()+e.substr(1)},s=function(e){var t=i(e);return t.substr(0,1).toUpperCase()+t.substr(1)},r=function(e,t){return function(e,t){var n=(t=t||{}).separator||"_",i=t.split||/(?=[A-Z])/;return e.split(i).join(n)}(e,t).toLowerCase()},o=Object.prototype.toString,a=function(e){return"function"==typeof e},c=function(e){return e===Object(e)},u=function(e){return"[object Array]"==o.call(e)},l=function(e){return"[object Date]"==o.call(e)},d=function(e){return"[object RegExp]"==o.call(e)},h=function(e){return"[object Boolean]"==o.call(e)},f=function(e){return(e-=0)==e},p=function(e,t){var n=t&&"process"in t?t.process:t;return"function"!=typeof n?e:function(t,i){return n(t,e,i)}},m={camelize:i,decamelize:r,pascalize:s,depascalize:r,camelizeKeys:function(e,t){return n(p(i,t),e)},decamelizeKeys:function(e,t){return n(p(r,t),e,t)},pascalizeKeys:function(e,t){return n(p(s,t),e)},depascalizeKeys:function(){return this.decamelizeKeys.apply(this,arguments)}};e.exports?e.exports=m:t.humps=m}(i)}(s);var r=s.exports;const o=e=>r.camelizeKeys(e,(e,t)=>/^\w{2}-\w{2,3}$/.test(e)?e:t(e)),a="http://localhost".replace(/\/+$/,"");class c{constructor(e={}){this.configuration=e}set config(e){this.configuration=e}get basePath(){return null!=this.configuration.basePath?this.configuration.basePath:a}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||p}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const e=this.configuration.apiKey;if(e)return"function"==typeof e?e:()=>e}get accessToken(){const e=this.configuration.accessToken;if(e)return"function"==typeof e?e:async()=>e}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const u=new c;class l{constructor(e=u){this.configuration=e,this.fetchApi=async(e,t)=>{let n,i={url:e,init:t};for(const e of this.middleware)e.pre&&(i=await e.pre(Object.assign({fetch:this.fetchApi},i))||i);try{n=await(this.configuration.fetchApi||fetch)(i.url,i.init)}catch(e){for(const t of this.middleware)t.onError&&(n=await t.onError({fetch:this.fetchApi,url:i.url,init:i.init,error:e,response:n?n.clone():void 0})||n);if(void 0===n)throw e}for(const e of this.middleware)e.post&&(n=await e.post({fetch:this.fetchApi,url:i.url,init:i.init,response:n.clone()})||n);return n},this.middleware=e.middleware}withMiddleware(...e){const t=this.clone();return t.middleware=t.middleware.concat(...e),t}withPreMiddleware(...e){const t=e.map(e=>({pre:e}));return this.withMiddleware(...t)}withPostMiddleware(...e){const t=e.map(e=>({post:e}));return this.withMiddleware(...t)}async request(e,t){const{url:n,init:i}=await this.createFetchParams(e,t),s=await this.fetchApi(n,i);if(s&&s.status>=200&&s.status<300)return s;const r=await s.json().then(e=>o(e)).catch(()=>({}));throw new h(Object.assign(Object.assign({},function(e){var t,n,i;const s=null===(t=null==e?void 0:e.meta)||void 0===t?void 0:t.error;if(s)return{code:s.code,message:s.message,detail:null!==(n=s.details)&&void 0!==n?n:[]};return{code:null==e?void 0:e.code,message:null==e?void 0:e.message,detail:null!==(i=null==e?void 0:e.detail)&&void 0!==i?i:e}}(r)),{status:s.status}))}async createFetchParams(e,t){let n=this.configuration.basePath+e.path;void 0!==e.query&&0!==Object.keys(e.query).length&&(n+="?"+this.configuration.queryParamsStringify(e.query));const i=Object.assign({},this.configuration.headers,e.headers);Object.keys(i).forEach(e=>void 0===i[e]?delete i[e]:{});const s="function"==typeof t?t:async()=>t,o={method:e.method,headers:i,body:e.body,credentials:this.configuration.credentials},a=Object.assign(Object.assign({},o),await s({init:o,context:e}));var c,u;return{url:n,init:Object.assign(Object.assign({},a),{body:(u=a.body,"undefined"!=typeof FormData&&u instanceof FormData||a.body instanceof URLSearchParams||d(a.body)?a.body:JSON.stringify((c=a.body,r.decamelizeKeys(c,(e,t)=>/^\w{2}-\w{2,3}$/.test(e)?e:t(e)))))})}}clone(){const e=new(0,this.constructor)(this.configuration);return e.middleware=this.middleware.slice(),e}}function d(e){return"undefined"!=typeof Blob&&e instanceof Blob}class h extends Error{constructor(e){super(`[${e.code||"unknown"}] ${e.message||"N/A"}`),this.cause=e,this.name="EliceResponseError"}}class f extends Error{constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}function p(e,t=""){return Object.keys(e).map(n=>m(n,e[n],t)).filter(e=>e.length>0).join("&")}function m(e,t,n=""){const i=n+(n.length?`[${e}]`:e);if(t instanceof Array){const e=t.map(e=>encodeURIComponent(String(e))).join(`&${encodeURIComponent(i)}=`);return`${encodeURIComponent(i)}=${e}`}if(t instanceof Set){return m(e,Array.from(t),n)}return t instanceof Date?`${encodeURIComponent(i)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?p(t,i):`${encodeURIComponent(i)}=${encodeURIComponent(String(t))}`}class w{constructor(e,t=e=>e){this.raw=e,this.transformer=t}async value(){return o(this.transformer(await this.raw.json()))}}async function g(e){const{data:t}=await e.value();return t}function v(e,t=""){return`/materials/{material_id}${t}`.replace("{material_id}",encodeURIComponent(String(e)))}class y extends l{async withBearer(e={}){if(this.configuration&&this.configuration.accessToken){const t=this.configuration.accessToken,n=await t("HTTPBearer",[]);n&&(e.Authorization=`Bearer ${n}`)}return e}async authTokenRefreshRaw(e){const t=await this.request({path:"/auth/token/refresh",method:"POST",headers:await this.withBearer(),query:{}},e);return new w(t)}async authTokenRefresh(e){return g(await this.authTokenRefreshRaw(e))}async materialGetRaw(e,t){const n=await this.request({path:v(e.materialId),method:"GET",headers:await this.withBearer(),query:{}},t);return new w(n)}async materialGet(e,t){return g(await this.materialGetRaw(e,t))}async materialMeGetRaw(e,t){const n=await this.request({path:v(e.materialId,"/me"),method:"GET",headers:await this.withBearer(),query:{}},t);return new w(n)}async materialMeGet(e,t){return g(await this.materialMeGetRaw(e,t))}async submissionCreateRaw(e,t){if(null===e.submissionCreateRequest||void 0===e.submissionCreateRequest)throw new f("submissionCreateRequest","Required parameter requestParameters.submissionCreateRequest was null or undefined when calling submissionCreate.");const n={"Content-Type":"application/json"},i=await this.request({path:v(e.materialId,"/submissions"),method:"POST",headers:await this.withBearer(n),query:{},body:e.submissionCreateRequest},t);return new w(i)}async submissionCreate(e,t){return g(await this.submissionCreateRaw(e,t))}async submissionMeListRaw(e,t){const n={};void 0!==e.offset&&(n.offset=e.offset),void 0!==e.limit&&(n.limit=e.limit);const i=await this.request({path:v(e.materialId,"/submissions/me"),method:"GET",headers:await this.withBearer(),query:n},t);return new w(i)}async submissionMeList(e,t){return g(await this.submissionMeListRaw(e,t))}}var b;const _="preview";class z{constructor(e="learn",t="instructor",n={}){this.scope=e,this.viewer=t,this.settings=n,b.set(this,[])}async authTokenRefresh(){return{accessToken:"",expiresAt:new Date(Date.now()+72e5).toISOString()}}async materialGet(e){return{id:e.materialId,lecturePageId:0,courseId:0,description:{type:"text",text:""},currentVersion:{id:_,contentUrls:{},metadata:{entries:{}},fileTree:[],settings:this.settings}}}async materialMeGet(e){return{scope:this.scope,viewer:this.viewer,user:{anonymousId:"preview",fullname:null},result:null}}async submissionCreate(e){const n={isCorrect:!0,score:100};return t(this,b,"f").unshift(Object.assign({id:`preview-${t(this,b,"f").length+1}`,materialVersionId:_,accountId:0,createdAt:(new Date).toISOString(),answer:e.submissionCreateRequest.answer},n)),n}async submissionMeList(e){const{offset:n=0,limit:i=20}=e;return t(this,b,"f").slice(n,n+i)}}b=new WeakMap;function P(e,t){return"bigint"==typeof t?t.toString():t}class k{constructor(e){this._getter=e,this._value=void 0}get value(){const e=this._getter;return void 0!==e&&(this._value=e(),this._getter=void 0),this._value}}function O(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}const E="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function S(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function T(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function j(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}function I(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function C(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function R(e){return"string"==typeof e?e:e?.message}function M(e,t,n){var i;for(let s=t;s<e.length;s++)(i=e[s]).schema??(i.schema=n)}function x(e,t,n){var i;const s=e.inst?._zod?.traits;s?.has("$ZodType")&&(s.has("$ZodCheck")?(i=e).schema??(i.schema=e.inst):e.schema=e.inst);const r=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:R(e.inst?._zod.def?.error?.(e))??R(r?.(e))??R(t?.error?.(e))??R(n.customError?.(e))??R(n.localeError?.(e))??"Invalid input",a={};for(const t of Object.keys(e))"inst"!==t&&"schema"!==t&&"continue"!==t&&"input"!==t&&"__proto__"!==t&&(a[t]=e[t]);return a.path??(a.path=[]),a.message=o,t?.reportInput&&(a.input=e.input),a}function $(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function A(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return null==this?n:$(this,t,n.bind(this))},set(e){$(this,t,e)}})}let N,L=!1;const q={configurable:!0,get(){L=!0}};function U(e,t,n){const i=Object.getPrototypeOf(e._zod);t in i&&N!==e._zod?N=void 0:(N=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,q);const e=L;L=!1;try{const i=n(this);return L?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),L=L||e,i}catch(n){throw delete this[t],L=L||e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function D(e,t,n,i){const s=function(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}(e,t);s&&Object.defineProperty(s,t,{configurable:!0,get(){const e={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:e})}})}var W;const Z={value:void 0,enumerable:!1};let K="captureStackTrace"in Error?Error:null;function G(e,t,n,i){function s(e){this.def=e,this.constr=l,this.traits=new Set}s.prototype={};const r=n,o=r&&new WeakSet;function a(n,i){if(n._zod){if(n._zod.traits.has(e))return}else{Z.value=new s(i);try{Object.defineProperty(n,"_zod",Z)}finally{Z.value=void 0}}if(n._zod.traits.add(e),t(n,i),o){const e=Object.getPrototypeOf(n),t=n._zod.constr.prototype;let i=e;for(;i&&i!==t;)i=Object.getPrototypeOf(i);const s=i??e;o.has(s)||(o.add(s),function(e,t){for(const n in t){const i=Object.getOwnPropertyDescriptor(t,n);i.get?Object.defineProperty(e,n,{...i,enumerable:!1}):A(e,n,i.value)}}(s,r))}const a=l.prototype;for(const e in a)Object.prototype.hasOwnProperty.call(a,e)&&(e in n||(n[e]=a[e].bind(n)))}const c=i?.Parent??Object;class u extends c{}function l(e){const t=i?.Parent?function(e){const t=K;if(t){const n=t.stackTraceLimit;if("number"==typeof n){try{t.stackTraceLimit=0}catch{return K=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}(u):this;a(t,e);const n=t._zod.deferred;if(n){for(const e of n)e();t._zod.deferred=void 0}const s=globalThis.__zod_globalConfig?.postProcessor;return s&&s(t),t}return Object.defineProperty(u,"name",{value:e}),Object.defineProperty(l,"init",{value:a}),Object.defineProperty(l,Symbol.hasInstance,{value:t=>!!(i?.Parent&&t instanceof i.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(l,"name",{value:e}),l}class F extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}(W=globalThis).__zod_globalConfig??(W.__zod_globalConfig={});const B=globalThis.__zod_globalConfig;function V(e){return B}const J={get:function(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,P,2)),e.message},set:function(e){this._zod.message=e},enumerable:!0,configurable:!0},H={value:void 0,enumerable:!1},Y=new WeakSet([Object.prototype,Error.prototype]),X=G("$ZodError",(e,t)=>{e.name="$ZodError",H.value=t,Object.defineProperty(e,"issues",H),H.value=void 0,Object.defineProperty(e,"message",J);const n=Object.getPrototypeOf(e);Y.has(n)||(Y.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},void 0,{Parent:Error}),Q=(e=>{const t=(n,i,s,r)=>{const o=s?{...s,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new F;if(a.issues.length){const n=new(r?.Err??e)(a.issues.map(e=>x(e,o,V())));throw E(n,r?.callee??t),n}return a.value};return t})(X),ee=e=>{const t=async(n,i,s,r)=>{const o=s?{...s,async:!0}:{async:!0};let a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){const n=new(r?.Err??e)(a.issues.map(e=>x(e,o,V())));throw E(n,r?.callee??t),n}return a.value};return t},te=ee(X),ne=(e=>(t,n,i)=>{const s=i?{...i,async:!1}:{async:!1},r=t._zod.run({value:n,issues:[]},s);if(r instanceof Promise)throw new F;return r.issues.length?ie(e,r.issues,s):{success:!0,data:r.value}})(X);function ie(e,t,n){let i;return{success:!1,get error(){return i||(i=new e(t.map(e=>x(e,n,V()))),t=void 0,n=void 0),i},set error(e){i=e,t=void 0,n=void 0}}}const se=(e=>async(t,n,i)=>{const s=i?{...i,async:!0}:{async:!0};let r=t._zod.run({value:n,issues:[]},s);return r instanceof Promise&&(r=await r),r.issues.length?ie(e,r.issues,s):{success:!0,data:r.value}})(X),re=/^[\s\S]{0,}$/,oe=G("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ae=G("$ZodCheckStringFormat",(e,t)=>{var n,i;oe.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),ce={major:4,minor:6,patch:7},ue=G("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ce;const i=e._zod.def.checks,s=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(const t of s)for(const n of t._zod.onattach)n(e);if(0===s.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(t,n,i)=>{if(t.memo)return t;let s,r=I(t);for(const o of n){if(o._zod.def.when){if(C(t))continue;if(!o._zod.def.when(t))continue}else if(r)continue;const n=t.issues.length,a=o._zod.check(t);if(a instanceof Promise&&!1===i?.async)throw new F;if(s||a instanceof Promise)s=(s??Promise.resolve()).then(async()=>{await a;t.issues.length!==n&&(M(t.issues,n,e),r||(r=I(t,n)))});else{if(t.issues.length===n)continue;M(t.issues,n,e),r||(r=I(t,n))}}return s?s.then(()=>t):t},n=(n,i,r)=>{if(I(n))return n.aborted=!0,n;const o=t(i,s,r);if(o instanceof Promise){if(!1===r.async)throw new F;return o.then(t=>e._zod.parse(t,r))}return e._zod.parse(o,r)};e._zod.run=(i,r)=>{if(r.skipChecks)return e._zod.parse(i,r);if("backward"===r.direction){const t=e._zod.parse({value:i.value,issues:[]},{...r,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,r)):n(t,i,r)}const o=e._zod.parse(i,r);if(o instanceof Promise){if(!1===r.async)throw new F;return o.then(e=>t(e,s,r))}return t(o,s,r)}}},{get"~standard"(){return function(e,t,n){return $(e,t,n,!1)}(this,"~standard",(e=this,{validate:t=>{const n={async:!1};try{const i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return le(i,n)}catch(e){}return async function(e,t){const n={async:!0};return le(await e._zod.run({value:t,issues:[]},n),n)}(e,t)},vendor:"zod",version:1}));var e},set"~standard"(e){$(this,"~standard",e)}}),le=(e,t)=>e.issues.length?{issues:e.issues.map(e=>x(e,t,V()))}:{value:e.value};const de=G("$ZodString",(e,t)=>{ue.init(e,t),e._zod.pattern=t.pattern??re,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(i){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),he=G("$ZodStringFormat",(e,t)=>{ae.init(e,t),de.init(e,t)});const fe=G("$ZodJWT",(e,t)=>{he.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[i]=n;if(!i)return!1;const s=JSON.parse(atob(i));return!("typ"in s&&"JWT"!==s?.typ||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});function pe(e,t,n,i,s,r){const o=n in i,a="optional"===r;if(o||!a||"optional"!==s){if(e.issues.length){if(void 0!==s&&a&&!o)return;t.issues.push(...(c=n,u=e.issues,u.map(e=>{var t;return(t=e).path??(t.path=[]),e.path.unshift(c),e})))}var c,u;o||void 0!==s?void 0===e.value?(o||"defaulted"===s&&!a)&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}}const me=[];function we(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:me,s=i.length?[...t,...i]:t;for(const t of s)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(t)}": expected a Zod schema`);const r=(o=e.shape,Object.keys(o).filter(e=>void 0!==o[e]._zod.optin&&"optional"===o[e]._zod.optout));var o;return{...e,allKeys:s,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}const ge=G("$ZodObject",(e,t)=>{ue.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){const e=()=>{const n={...i};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=i,Object.defineProperty(t,"shape",{get:e})}const s=new k(()=>we(t));U(e,"propValues",e=>{const t=e.def.shape,n={};for(const e in t){const i=t[e]._zod;if(i.values){Object.prototype.hasOwnProperty.call(n,e)||O(n,e,new Set);for(const t of i.values)n[e].add(t);void 0!==i.optin&&n[e].add(void 0)}}return n});const r=S,o=t.catchall;let a;const c=B.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{a??(a=s.value);const i=t.value;if(!r(i))return t.issues.push({expected:"object",code:"invalid_type",input:i,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};const u=[],l=a.shape,d=n?.abortEarly;let h=t.issues.length;for(const e of a.allKeys){if(d&&t.issues.length!==h){if(I(t,h))break;h=t.issues.length}if("__proto__"===e)continue;const s=l[e],r=s._zod.optin,o=s._zod.optout,a=s._zod.run({value:i[e],issues:[]},n);a instanceof Promise?u.push(a.then(n=>pe(n,t,e,i,r,o))):pe(a,t,e,i,r,o)}return o?function(e,t,n,i,s,r,o){const a=[],c=s.keySet,u=s.catchall._zod,l=u.def.type,d=u.optin,h=u.optout;let f=0;for(const s in t){if(o&&n.issues.length!==f){if(I(n,f))break;f=n.issues.length}if(c.has(s))continue;if("__proto__"===s){"never"===l&&a.push(s);continue}if("never"===l){a.push(s);continue}const r=u.run({value:t[s],issues:[]},i);r instanceof Promise?e.push(r.then(e=>pe(e,n,s,t,d,h))):pe(r,n,s,t,d,h)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:r,continue:!0}),e.length?Promise.all(e).then(()=>n):n}(u,i,t,n,s.value,e,!0===d):u.length?Promise.all(u).then(()=>t):t}}),ve=G("$ZodLiteral",(e,t)=>{ue.init(e,t);const n=new Set(t.values);e._zod.values=n,U(e,"pattern",e=>{const t=e.def.values;return new RegExp(t.length?`^(${t.map(e=>"string"==typeof e?T(e):e?T(e.toString()):String(e)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,s)=>{const r=i.value;return n.has(r)||i.issues.push({code:"invalid_value",values:t.values,input:r,inst:e}),i}});function ye(e,t){return e.value=t.issues.length?void 0:t.value,e}const be=G("$ZodOptional",(e,t)=>{ue.init(e,t),U(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),e._zod.optout="optional",U(e,"values",e=>{const t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),U(e,"pattern",e=>{const t=e.def.innerType._zod.pattern;return t?new RegExp(`^(${function(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(void 0===e.value){if("defaulted"!==t.innerType._zod.optin)return e;const i=t.innerType._zod.run({value:e.value,issues:[]},n);return i instanceof Promise?i.then(t=>ye(e,t)):ye(e,i)}return t.innerType._zod.run(e,n)}}),_e=G("$ZodCustom",(e,t)=>{oe.init(e,t),ue.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const i=n.value,s=t.fn(i);if(s instanceof Promise)return s.then(t=>ze(t,n,i,e));ze(s,n,i,e)}});function ze(e,t,n,i){if(!e){const e={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(e.params=i._zod.def.params),t.issues.push(function(...e){const[t,n,i]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:i}:{...t}}(e))}}const Pe=G("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");ue.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){$(this,"with",e)},parse(e,t){return Q(this,e,t,{callee:this.parse})},parseAsync(e,t){return te(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return ne(this,e,t)},safeParseAsync(e,t){return se(this,e,t)},check(...e){const t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]},{parent:!0})},clone(e,t){return function(e,t,n){const i=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(i._zod.parent=e),i}(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return 0===t.length?e(this):e(this,...t)}}),ke=G("ZodMiniString",(e,t)=>{de.init(e,t),Pe.init(e,t)}),Oe=G("ZodMiniStringFormat",(e,t)=>{he.init(e,t),ke.init(e,t)}),Ee=G("ZodMiniJWT",(e,t)=>{fe.init(e,t),Oe.init(e,t)});const Se=G("ZodMiniObject",(e,t)=>{ge.init(e,t),Pe.init(e,t),D(e,"shape",e=>e._zod.def.shape,!1)});const Te=G("ZodMiniLiteral",(e,t)=>{ve.init(e,t),Pe.init(e,t)});function je(e,t){return new Te({type:"literal",values:Array.isArray(e)?e:[e],...j(t)})}const Ie=G("ZodMiniOptional",(e,t)=>{be.init(e,t),Pe.init(e,t)});function Ce(e){return new Ie({type:"optional",innerType:e})}const Re=G("ZodMiniCustom",(e,t)=>{_e.init(e,t),Pe.init(e,t)});const Me=function(e,t){const n={type:"object",shape:e??{},...j(t)};return new Se(n)}({token:Ce((xe="access token(`token`) is not a JWT",function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...j(t)})}(Ee,xe))),preview:Ce(je("1")),edit:Ce(je("1"))}).check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...j(n)})}(Re,e,t)}(e=>null!=e.token||"1"===e.preview||"1"===e.edit,{message:"access token(`token`) is not provided"}));var xe;const $e=/\/materials\/([0-9a-f-]{36})\//i;var Ae;e.ErrorCode=void 0,(Ae=e.ErrorCode||(e.ErrorCode={})).Init="init",Ae.InvalidParam="invalid_param",Ae.InvalidToken="invalid_token",Ae.NotInitialized="not_initialized",Ae.Unauthorized="unauthorized",Ae.SessionExpired="session_expired",Ae.PermissionDenied="permission_denied",Ae.ReadOnlyMode="read_only_mode",Ae.ScreenNotSupported="screen_not_supported",Ae.ContentNotReady="content_not_ready",Ae.InvalidInput="invalid_input",Ae.RateLimited="rate_limited",Ae.ExternalServiceError="external_service_error",Ae.NavigationTimeout="navigation_timeout",Ae.RequestFailed="request_failed";const Ne=Object.assign(class e extends Error{constructor(t,n,i){var s;const r=i?i instanceof Error?i:new Error(i):void 0;super(`[@eliceio/cdk] ${t} - ${n}${r?`\n${null!==(s=r.stack)&&void 0!==s?s:""}`:""}`),this.code=t,this.cause=r,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}},{code:e.ErrorCode}),Le="undefined"==typeof window,qe="eliceio-content-sdk";function Ue(){if(Le||window.parent===window)return null;const e=window.parent;return{post(t){e.postMessage(t,"*")},subscribe(t){function n(n){n.source===e&&function(e){if("object"!=typeof e||null===e)return!1;const{source:t,type:n}=e;return t===qe&&"string"==typeof n}(n.data)&&t(n.data)}return window.addEventListener("message",n),()=>{window.removeEventListener("message",n)}}}}function De(e){let t="";return t=(e=>{try{let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";return decodeURIComponent((e=>e.split("").map(e=>{let t=e.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t=`0${t}`),`%${t}`}).join(""))(atob(t)))}catch(e){throw new Ne(Ne.code.InvalidToken,"Fail to decode base64 format.",e)}})(e.split(".")[1]),t=(e=>{try{return JSON.parse(e)}catch(e){throw new Ne(Ne.code.InvalidToken,"Fail to parse JSON format.",e)}})(t),o(t)}var We,Ze,Ke;const Ge=Object.freeze({previous:"navigate-prev",next:"navigate-next",navigate:"navigate",stateSync:"navigate-state-sync"}),Fe="navigate-state";class Be{constructor(e){We.add(this),this.ctx=e}async getHasPrevious(){return(await t(this,We,"m",Ke).call(this)).hasPreviousLecturePage}async getHasNext(){return(await t(this,We,"m",Ke).call(this)).hasNextLecturePage}previous(){t(this,We,"m",Ze).call(this,Ge.previous)}next(){t(this,We,"m",Ze).call(this,Ge.next)}navigate(e){t(this,We,"m",Ze).call(this,Ge.navigate,{lecturePageId:e})}}var Ve,Je,He,Ye,Xe,Qe,et,tt,nt,it,st,rt,ot,at,ct,ut,lt,dt,ht,ft,pt,mt,wt,gt,vt,yt,bt,_t,zt;We=new WeakSet,Ze=function(e,t,n){const i=this.ctx.assertNavigable();if(this.ctx.isDraft()||null==this.ctx.channel)return!1;const s={source:qe,type:e,materialId:i};return void 0!==t&&(s.payload=t),void 0!==n&&(s.requestId=n),this.ctx.channel.post(s),!0},Ke=function(){var e;const n="undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,i=this.ctx.channel,s=null!==(e=this.ctx.stateTimeoutMs)&&void 0!==e?e:1e3;return new Promise((e,r)=>{let o=()=>{},a=null;const c=()=>{o(),null!==a&&clearTimeout(a)};let u;null!=i&&(o=i.subscribe(t=>{var i;if(t.type!==Fe||t.requestId!==n)return;c();const s=null!==(i=t.payload)&&void 0!==i?i:{};e({hasPreviousLecturePage:!0===s.hasPreviousLecturePage,hasNextLecturePage:!0===s.hasNextLecturePage})}));try{u=t(this,We,"m",Ze).call(this,Ge.stateSync,void 0,n)}catch(e){return c(),void r(e)}if(!u)return c(),void e({hasPreviousLecturePage:!1,hasNextLecturePage:!1});a=setTimeout(()=>{c(),r(new Ne(Ne.code.NavigationTimeout,"The learning page did not answer the navigation state request."))},s)})};const Pt=Object.freeze({AUTH_PERMISSION_DENIED:e.ErrorCode.PermissionDenied,AUTHENTICATION_INVALID:e.ErrorCode.Unauthorized,EXTERNAL_SERVICE_ERROR:e.ErrorCode.ExternalServiceError,INVALID_INPUT:e.ErrorCode.InvalidInput,MATERIAL_CONTENT_NOT_READY:e.ErrorCode.ContentNotReady,MATERIAL_READ_ONLY_MODE:e.ErrorCode.ReadOnlyMode,MATERIAL_TOO_MANY_SUBMISSIONS:e.ErrorCode.RateLimited});function kt(e,t){var n,i,s;if(e instanceof h){const r=null!==(i=Pt[null!==(n=e.cause.code)&&void 0!==n?n:""])&&void 0!==i?i:Ne.code.RequestFailed;return new Ne(r,null!==(s=e.cause.message)&&void 0!==s?s:t,e)}return new Ne(Ne.code.RequestFailed,t,e)}function Ot(e){return e instanceof h&&401===e.cause.status}Je=new WeakMap,He=new WeakMap,Ye=new WeakMap,Xe=new WeakMap,Qe=new WeakMap,et=new WeakMap,tt=new WeakMap,nt=new WeakMap,it=new WeakMap,st=new WeakMap,rt=new WeakMap,ot=new WeakMap,at=new WeakMap,ct=new WeakMap,ut=new WeakMap,lt=new WeakMap,Ve=new WeakSet,dt=function(){if(!this.initialized||!t(this,st,"f"))throw new Ne(Ne.code.NotInitialized,"The SDK is not initialized. Please call the init function first.");if(t(this,Qe,"f"))throw new Ne(Ne.code.SessionExpired,"The session has expired. Please reload the material.");return t(this,st,"f").materialId},ht=function(...e){if(null==t(this,nt,"f")||!e.includes(t(this,nt,"f")))throw new Ne(Ne.code.ScreenNotSupported,`This call is only available on the ${e.join(" or ")} screen.`)},ft=function(){var e,n,i;if(t(this,at,"f"))return{materials:new z(null!==(e=t(this,et,"f"))&&void 0!==e?e:"learn","instructor")};const s=new c({basePath:null!==(i=null===(n=this.options)||void 0===n?void 0:n.baseUrl)&&void 0!==i?i:"https://api-material.elice.io",accessToken:()=>{var e;return null!==(e=t(this,He,"f"))&&void 0!==e?e:""}});return{materials:new y(s)}},pt=async function(e){const i=null!=e?e:Le?"":window.location.hash,s=/(^|[#&])(token|preview|edit)=/.test(i);if(void 0===e&&!s&&t(this,ct,"f"))return t(this,ct,"f");const r=new URLSearchParams(i.replace(/^#/,"")),{data:o,error:a}=await Me.safeParseAsync(Object.fromEntries(r.entries()));if(a)throw new AggregateError(a.issues.map(e=>new Ne(Ne.code.InvalidParam,e.message)),"Failed to resolve fragment params during initialization.");return n(this,ct,o,"f"),o},mt=function(){if(Le||!window.location.hash.includes("token="))return;const e=new URLSearchParams(window.location.hash.replace(/^#/,""));e.delete("token");const t=e.toString(),{pathname:n,search:i}=window.location;window.history.replaceState(window.history.state,"",`${n}${i}${t?`#${t}`:""}`)},wt=function(e,i){var s,r,o,a,c,u;n(this,at,null==e.token,"f"),n(this,Qe,!1,"f"),t(this,Ve,"m",vt).call(this,null!==(s=e.token)&&void 0!==s?s:null);const l=t(this,He,"f")?De(t(this,He,"f")):null,d=null!==(o=null!==(r=function(e){const t=$e.exec(e);return t?t[1].toLowerCase():null}(null!=i?i:Le?"":window.location.pathname))&&void 0!==r?r:null==l?void 0:l.materialId)&&void 0!==o?o:null;if(null==d)throw new Ne(Ne.code.InvalidParam,"The material id is not found in the content URL or the access token.");return n(this,st,{materialId:d,lecturePageId:null!==(a=null==l?void 0:l.lecturePageId)&&void 0!==a?a:null,courseId:null!==(c=null==l?void 0:l.courseId)&&void 0!==c?c:null},"f"),n(this,ot,null!==(u=null==l?void 0:l.locale)&&void 0!==u?u:"ko","f"),t(this,at,"f")&&(n(this,et,"1"===e.edit?"edit":"learn","f"),n(this,nt,"1"===e.edit?"edit":"learn","f")),d},gt=async function(e){const[i,s]=await Promise.all([this.internal_apis.materials.materialGet({materialId:e}),this.internal_apis.materials.materialMeGet({materialId:e})]);var r,o,a;n(this,rt,{description:i.description,entries:i.currentVersion.metadata.entries,settings:i.currentVersion.settings},"f"),n(this,Je,s.user,"f"),n(this,it,s.result,"f"),n(this,tt,s.viewer,"f"),t(this,at,"f")||(n(this,et,s.scope,"f"),n(this,nt,(r=s.scope,o=s.viewer,a=t(this,rt,"f").entries,"edit"===r?"edit":"instructor"===o&&a.instructor?"instructor":"learn"),"f"))},vt=function(e){var t;n(this,He,e,"f");const i=e?null===(t=De(e))||void 0===t?void 0:t.exp:void 0;n(this,Ye,i?1e3*i:null,"f")},yt=function(e){if(t(this,Ve,"m",bt).call(this),t(this,at,"f")||null==t(this,Ye,"f")||Le)return;const i=null!=e?e:Math.max(0,t(this,Ye,"f")-3e5-Date.now());n(this,Xe,setTimeout(()=>{t(this,Ve,"m",_t).call(this)},i),"f")},bt=function(){null!=t(this,Xe,"f")&&(clearTimeout(t(this,Xe,"f")),n(this,Xe,null,"f"))},_t=async function(){try{const{accessToken:e}=await this.internal_apis.materials.authTokenRefresh();t(this,Ve,"m",vt).call(this,e),t(this,Ve,"m",yt).call(this)}catch(e){if(function(e){if(!Ot(e))return!1;const t=e.cause.detail;return Array.isArray(t)&&t.some(e=>{var t;return"session_expired"===(null===(t=null==e?void 0:e.ctx)||void 0===t?void 0:t.reason)})}(e)||Ot(e))return void t(this,Ve,"m",zt).call(this);t(this,Ve,"m",yt).call(this,3e4)}},zt=function(){var e,i;t(this,Ve,"m",bt).call(this),n(this,Qe,!0,"f"),null===(i=(e=this.options).onSessionExpired)||void 0===i||i.call(e)},e.EliceCDK=class{constructor(e={}){Ve.add(this),this.options=e,this.initialized=!1,Je.set(this,null),He.set(this,null),Ye.set(this,null),Xe.set(this,null),Qe.set(this,!1),et.set(this,null),tt.set(this,null),nt.set(this,null),it.set(this,null),st.set(this,null),rt.set(this,null),ot.set(this,"ko"),at.set(this,!1),ct.set(this,null),ut.set(this,void 0),lt.set(this,void 0),this.internal_apis=t(this,Ve,"m",ft).call(this),n(this,ut,Ue(),"f"),n(this,lt,new Be({channel:t(this,ut,"f"),isDraft:()=>t(this,at,"f"),assertNavigable:()=>{const e=t(this,Ve,"m",dt).call(this);return t(this,Ve,"m",ht).call(this,"learn","instructor"),e}}),"f")}get account(){return t(this,Je,"f")}get scope(){return t(this,et,"f")}get viewer(){return t(this,tt,"f")}get screen(){return t(this,nt,"f")}get result(){return t(this,it,"f")}get metadata(){return t(this,st,"f")}get material(){return t(this,rt,"f")}get locale(){return t(this,ot,"f")}get isDraft(){return t(this,at,"f")}get isSessionExpired(){return t(this,Qe,"f")}get navigation(){return t(this,lt,"f")}async init(e={}){this.initialized=!1,t(this,Ve,"m",bt).call(this);const n=await t(this,Ve,"m",pt).call(this,e.hash);void 0===e.hash&&t(this,Ve,"m",mt).call(this);try{const i=t(this,Ve,"m",wt).call(this,n,e.pathname);this.internal_apis=t(this,Ve,"m",ft).call(this),await t(this,Ve,"m",gt).call(this,i),this.initialized=!0,t(this,Ve,"m",yt).call(this)}catch(e){if(e instanceof Ne)throw e;throw kt(e,"Failed to initialize elice content sdk.")}return this}async submit(e){const n=t(this,Ve,"m",dt).call(this);t(this,Ve,"m",ht).call(this,"learn","instructor");try{return await this.internal_apis.materials.submissionCreate({materialId:n,submissionCreateRequest:{answer:e}})}catch(e){throw kt(e,"Failed to submit the answer.")}}async history(e={}){const n=t(this,Ve,"m",dt).call(this);try{return await this.internal_apis.materials.submissionMeList(Object.assign({materialId:n},e))}catch(e){throw kt(e,"Failed to load submissions.")}}saveSettings(e){var i;const s=t(this,Ve,"m",dt).call(this);t(this,Ve,"m",ht).call(this,"edit");const r={source:qe,type:"settings-change",materialId:s,payload:{settings:e}};t(this,rt,"f")&&n(this,rt,Object.assign(Object.assign({},t(this,rt,"f")),{settings:e}),"f"),null===(i=t(this,ut,"f"))||void 0===i||i.post(r)}dispose(){t(this,Ve,"m",bt).call(this)}},e.EliceCDKError=Ne,e.EliceCDKNavigation=Be,e.NAVIGATION_MESSAGE_TYPE=Ge,e.NAVIGATION_STATE_MESSAGE_TYPE=Fe});
|
|
3
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).elice=e.elice||{})}(this,function(e){"use strict";function t(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function n(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}};!function(e){!function(t){var n=function(e,t,i){if(!c(t)||l(t)||d(t)||h(t)||a(t))return t;var r,s=0,o=0;if(u(t))for(r=[],o=t.length;s<o;s++)r.push(n(e,t[s],i));else for(var f in r={},t)Object.prototype.hasOwnProperty.call(t,f)&&(r[e(f,i)]=n(e,t[f],i));return r},i=function(e){return f(e)?e:(e=e.replace(/[\-_\s]+(.)?/g,function(e,t){return t?t.toUpperCase():""})).substr(0,1).toLowerCase()+e.substr(1)},r=function(e){var t=i(e);return t.substr(0,1).toUpperCase()+t.substr(1)},s=function(e,t){return function(e,t){var n=(t=t||{}).separator||"_",i=t.split||/(?=[A-Z])/;return e.split(i).join(n)}(e,t).toLowerCase()},o=Object.prototype.toString,a=function(e){return"function"==typeof e},c=function(e){return e===Object(e)},u=function(e){return"[object Array]"==o.call(e)},l=function(e){return"[object Date]"==o.call(e)},d=function(e){return"[object RegExp]"==o.call(e)},h=function(e){return"[object Boolean]"==o.call(e)},f=function(e){return(e-=0)==e},p=function(e,t){var n=t&&"process"in t?t.process:t;return"function"!=typeof n?e:function(t,i){return n(t,e,i)}},m={camelize:i,decamelize:s,pascalize:r,depascalize:s,camelizeKeys:function(e,t){return n(p(i,t),e)},decamelizeKeys:function(e,t){return n(p(s,t),e,t)},pascalizeKeys:function(e,t){return n(p(r,t),e)},depascalizeKeys:function(){return this.decamelizeKeys.apply(this,arguments)}};e.exports?e.exports=m:t.humps=m}(i)}(r);var s=r.exports;const o=e=>s.camelizeKeys(e,(e,t)=>/^\w{2}-\w{2,3}$/.test(e)?e:t(e)),a="http://localhost".replace(/\/+$/,"");class c{constructor(e={}){this.configuration=e}set config(e){this.configuration=e}get basePath(){return null!=this.configuration.basePath?this.configuration.basePath:a}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||p}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const e=this.configuration.apiKey;if(e)return"function"==typeof e?e:()=>e}get accessToken(){const e=this.configuration.accessToken;if(e)return"function"==typeof e?e:async()=>e}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const u=new c;class l{constructor(e=u){this.configuration=e,this.fetchApi=async(e,t)=>{let n,i={url:e,init:t};for(const e of this.middleware)e.pre&&(i=await e.pre(Object.assign({fetch:this.fetchApi},i))||i);try{n=await(this.configuration.fetchApi||fetch)(i.url,i.init)}catch(e){for(const t of this.middleware)t.onError&&(n=await t.onError({fetch:this.fetchApi,url:i.url,init:i.init,error:e,response:n?n.clone():void 0})||n);if(void 0===n)throw e}for(const e of this.middleware)e.post&&(n=await e.post({fetch:this.fetchApi,url:i.url,init:i.init,response:n.clone()})||n);return n},this.middleware=e.middleware}withMiddleware(...e){const t=this.clone();return t.middleware=t.middleware.concat(...e),t}withPreMiddleware(...e){const t=e.map(e=>({pre:e}));return this.withMiddleware(...t)}withPostMiddleware(...e){const t=e.map(e=>({post:e}));return this.withMiddleware(...t)}async request(e,t){const{url:n,init:i}=await this.createFetchParams(e,t),r=await this.fetchApi(n,i);if(r&&r.status>=200&&r.status<300)return r;const s=await r.json().then(e=>o(e)).catch(()=>({}));throw new h(Object.assign(Object.assign({},function(e){var t,n,i;const r=null===(t=null==e?void 0:e.meta)||void 0===t?void 0:t.error;if(r)return{code:r.code,message:r.message,detail:null!==(n=r.details)&&void 0!==n?n:[]};return{code:null==e?void 0:e.code,message:null==e?void 0:e.message,detail:null!==(i=null==e?void 0:e.detail)&&void 0!==i?i:e}}(s)),{status:r.status}))}async createFetchParams(e,t){let n=this.configuration.basePath+e.path;void 0!==e.query&&0!==Object.keys(e.query).length&&(n+="?"+this.configuration.queryParamsStringify(e.query));const i=Object.assign({},this.configuration.headers,e.headers);Object.keys(i).forEach(e=>void 0===i[e]?delete i[e]:{});const r="function"==typeof t?t:async()=>t,o={method:e.method,headers:i,body:e.body,credentials:this.configuration.credentials},a=Object.assign(Object.assign({},o),await r({init:o,context:e}));var c,u;return{url:n,init:Object.assign(Object.assign({},a),{body:(u=a.body,"undefined"!=typeof FormData&&u instanceof FormData||a.body instanceof URLSearchParams||d(a.body)?a.body:JSON.stringify((c=a.body,s.decamelizeKeys(c,(e,t)=>/^\w{2}-\w{2,3}$/.test(e)?e:t(e)))))})}}clone(){const e=new(0,this.constructor)(this.configuration);return e.middleware=this.middleware.slice(),e}}function d(e){return"undefined"!=typeof Blob&&e instanceof Blob}class h extends Error{constructor(e){super(`[${e.code||"unknown"}] ${e.message||"N/A"}`),this.cause=e,this.name="EliceResponseError"}}class f extends Error{constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}function p(e,t=""){return Object.keys(e).map(n=>m(n,e[n],t)).filter(e=>e.length>0).join("&")}function m(e,t,n=""){const i=n+(n.length?`[${e}]`:e);if(t instanceof Array){const e=t.map(e=>encodeURIComponent(String(e))).join(`&${encodeURIComponent(i)}=`);return`${encodeURIComponent(i)}=${e}`}if(t instanceof Set){return m(e,Array.from(t),n)}return t instanceof Date?`${encodeURIComponent(i)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?p(t,i):`${encodeURIComponent(i)}=${encodeURIComponent(String(t))}`}class v{constructor(e,t=e=>e){this.raw=e,this.transformer=t}async value(){return o(this.transformer(await this.raw.json()))}}async function y(e){const{data:t}=await e.value();return t}function w(e,t=""){return`/materials/{material_id}${t}`.replace("{material_id}",encodeURIComponent(String(e)))}class g extends l{async withBearer(e={}){if(this.configuration&&this.configuration.accessToken){const t=this.configuration.accessToken,n=await t("HTTPBearer",[]);n&&(e.Authorization=`Bearer ${n}`)}return e}async authTokenRefreshRaw(e){const t=await this.request({path:"/auth/token/refresh",method:"POST",headers:await this.withBearer(),query:{}},e);return new v(t)}async authTokenRefresh(e){return y(await this.authTokenRefreshRaw(e))}async materialGetRaw(e,t){const n=await this.request({path:w(e.materialId),method:"GET",headers:await this.withBearer(),query:{}},t);return new v(n)}async materialGet(e,t){return y(await this.materialGetRaw(e,t))}async materialMeGetRaw(e,t){const n=await this.request({path:w(e.materialId,"/me"),method:"GET",headers:await this.withBearer(),query:{}},t);return new v(n)}async materialMeGet(e,t){return y(await this.materialMeGetRaw(e,t))}async materialUpdateRaw(e,t){if(null===e.materialUpdateRequest||void 0===e.materialUpdateRequest)throw new f("materialUpdateRequest","Required parameter requestParameters.materialUpdateRequest was null or undefined when calling materialUpdate.");const n={"Content-Type":"application/json"},i=await this.request({path:w(e.materialId),method:"PATCH",headers:await this.withBearer(n),query:{},body:e.materialUpdateRequest},t);return new v(i)}async materialUpdate(e,t){return y(await this.materialUpdateRaw(e,t))}async submissionCreateRaw(e,t){if(null===e.submissionCreateRequest||void 0===e.submissionCreateRequest)throw new f("submissionCreateRequest","Required parameter requestParameters.submissionCreateRequest was null or undefined when calling submissionCreate.");const n={"Content-Type":"application/json"},i=await this.request({path:w(e.materialId,"/submissions"),method:"POST",headers:await this.withBearer(n),query:{},body:e.submissionCreateRequest},t);return new v(i)}async submissionCreate(e,t){return y(await this.submissionCreateRaw(e,t))}async submissionMeListRaw(e,t){const n={};void 0!==e.offset&&(n.offset=e.offset),void 0!==e.limit&&(n.limit=e.limit);const i=await this.request({path:w(e.materialId,"/submissions/me"),method:"GET",headers:await this.withBearer(),query:n},t);return new v(i)}async submissionMeList(e,t){return y(await this.submissionMeListRaw(e,t))}}var b;e.ErrorCode=void 0,(b=e.ErrorCode||(e.ErrorCode={})).Init="init",b.InvalidParam="invalid_param",b.InvalidToken="invalid_token",b.NotInitialized="not_initialized",b.Unauthorized="unauthorized",b.SessionExpired="session_expired",b.PermissionDenied="permission_denied",b.ReadOnlyMode="read_only_mode",b.ScreenNotSupported="screen_not_supported",b.DraftNotSaved="draft_not_saved",b.ContentNotReady="content_not_ready",b.InvalidInput="invalid_input",b.RateLimited="rate_limited",b.ExternalServiceError="external_service_error",b.NavigationTimeout="navigation_timeout",b.RequestFailed="request_failed";const _=Object.assign(class e extends Error{constructor(t,n,i){var r;const s=i?i instanceof Error?i:new Error(i):void 0;super(`[@eliceio/cdk] ${t} - ${n}${s?`\n${null!==(r=s.stack)&&void 0!==r?r:""}`:""}`),this.code=t,this.cause=s,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}},{code:e.ErrorCode});var P;const z="preview";class k{constructor(e="learn",t="instructor",n={}){this.scope=e,this.viewer=t,this.settings=n,P.set(this,[])}async authTokenRefresh(){return{accessToken:"",expiresAt:new Date(Date.now()+72e5).toISOString()}}async materialGet(e){return{id:e.materialId,lecturePageId:0,courseId:0,description:{type:"text",text:""},currentVersion:{id:z,contentUrls:{},metadata:{screens:{}},fileTree:[],settings:this.settings}}}async materialMeGet(e){return{scope:this.scope,viewer:this.viewer,user:{anonymousId:"preview",fullname:null},result:null}}async materialUpdate(e){throw new _(_.code.DraftNotSaved,"Settings of an unsaved upload cannot be saved. Save the material in the editor first.")}async submissionCreate(e){const n={isCorrect:!0,score:100};return t(this,P,"f").unshift(Object.assign({id:`preview-${t(this,P,"f").length+1}`,materialVersionId:z,accountId:0,createdAt:(new Date).toISOString(),answer:e.submissionCreateRequest.answer},n)),n}async submissionMeList(e){const{offset:n=0,limit:i=20}=e;return t(this,P,"f").slice(n,n+i)}}P=new WeakMap;function O(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function S(e,t){return"bigint"==typeof t?t.toString():t}class T{constructor(e){this._getter=e,this._value=void 0}get value(){const e=this._getter;return void 0!==e&&(this._value=e(),this._getter=void 0),this._value}}function E(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}const j="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function I(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const R=new Set(["string","number","symbol"]);function C(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function x(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}function $(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function M(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function U(e){return"string"==typeof e?e:e?.message}function A(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function L(e,t,n){var i;const r=e.inst?._zod?.traits;r?.has("$ZodType")&&(r.has("$ZodCheck")?(i=e).schema??(i.schema=e.inst):e.schema=e.inst);const s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:U(e.inst?._zod.def?.error?.(e))??U(s?.(e))??U(t?.error?.(e))??U(n.customError?.(e))??U(n.localeError?.(e))??"Invalid input",a={};for(const t of Object.keys(e))"inst"!==t&&"schema"!==t&&"continue"!==t&&"input"!==t&&"__proto__"!==t&&(a[t]=e[t]);return a.path??(a.path=[]),a.message=o,t?.reportInput&&(a.input=e.input),a}function q(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function N(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return null==this?n:q(this,t,n.bind(this))},set(e){q(this,t,e)}})}let D,Z=!1;const W={configurable:!0,get(){Z=!0}};function V(e,t,n){const i=Object.getPrototypeOf(e._zod);t in i&&D!==e._zod?D=void 0:(D=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,W);const e=Z;Z=!1;try{const i=n(this);return Z?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),Z=Z||e,i}catch(n){throw delete this[t],Z=Z||e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function K(e,t,n,i){const r=function(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}(e,t);r&&Object.defineProperty(r,t,{configurable:!0,get(){const e={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:e})}})}function F(e){const t=()=>e;return t["~constantCatch"]=!0,t}var G;const B={value:void 0,enumerable:!1};let J="captureStackTrace"in Error?Error:null;function H(e,t,n,i){function r(e){this.def=e,this.constr=l,this.traits=new Set}r.prototype={};const s=n,o=s&&new WeakSet;function a(n,i){if(n._zod){if(n._zod.traits.has(e))return}else{B.value=new r(i);try{Object.defineProperty(n,"_zod",B)}finally{B.value=void 0}}if(n._zod.traits.add(e),t(n,i),o){const e=Object.getPrototypeOf(n),t=n._zod.constr.prototype;let i=e;for(;i&&i!==t;)i=Object.getPrototypeOf(i);const r=i??e;o.has(r)||(o.add(r),function(e,t){for(const n in t){const i=Object.getOwnPropertyDescriptor(t,n);i.get?Object.defineProperty(e,n,{...i,enumerable:!1}):N(e,n,i.value)}}(r,s))}const a=l.prototype;for(const e in a)Object.prototype.hasOwnProperty.call(a,e)&&(e in n||(n[e]=a[e].bind(n)))}const c=i?.Parent??Object;class u extends c{}function l(e){const t=i?.Parent?function(e){const t=J;if(t){const n=t.stackTraceLimit;if("number"==typeof n){try{t.stackTraceLimit=0}catch{return J=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}(u):this;a(t,e);const n=t._zod.deferred;if(n){for(const e of n)e();t._zod.deferred=void 0}const r=globalThis.__zod_globalConfig?.postProcessor;return r&&r(t),t}return Object.defineProperty(u,"name",{value:e}),Object.defineProperty(l,"init",{value:a}),Object.defineProperty(l,Symbol.hasInstance,{value:t=>!!(i?.Parent&&t instanceof i.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(l,"name",{value:e}),l}class Y extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}(G=globalThis).__zod_globalConfig??(G.__zod_globalConfig={});const X=globalThis.__zod_globalConfig;function Q(e){return X}const ee={get:function(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,S,2)),e.message},set:function(e){this._zod.message=e},enumerable:!0,configurable:!0},te={value:void 0,enumerable:!1},ne=new WeakSet([Object.prototype,Error.prototype]),ie=H("$ZodError",(e,t)=>{e.name="$ZodError",te.value=t,Object.defineProperty(e,"issues",te),te.value=void 0,Object.defineProperty(e,"message",ee);const n=Object.getPrototypeOf(e);ne.has(n)||(ne.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},void 0,{Parent:Error}),re=(e=>{const t=(n,i,r,s)=>{const o=r?{...r,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new Y;if(a.issues.length){const n=new(s?.Err??e)(a.issues.map(e=>L(e,o,Q())));throw j(n,s?.callee??t),n}return a.value};return t})(ie),se=e=>{const t=async(n,i,r,s)=>{const o=r?{...r,async:!0}:{async:!0};let a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){const n=new(s?.Err??e)(a.issues.map(e=>L(e,o,Q())));throw j(n,s?.callee??t),n}return a.value};return t},oe=se(ie),ae=(e=>(t,n,i)=>{const r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new Y;return s.issues.length?ce(e,s.issues,r):{success:!0,data:s.value}})(ie);function ce(e,t,n){let i;return{success:!1,get error(){return i||(i=new e(t.map(e=>L(e,n,Q()))),t=void 0,n=void 0),i},set error(e){i=e,t=void 0,n=void 0}}}const ue=(e=>async(t,n,i)=>{const r=i?{...i,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?ce(e,s.issues,r):{success:!0,data:s.value}})(ie),le=/^https?$/,de=/^[\s\S]{0,}$/,he=H("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),fe=H("$ZodCheckStringFormat",(e,t)=>{var n,i;he.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),pe={major:4,minor:6,patch:7},me=H("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=pe;const i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(const t of r)for(const n of t._zod.onattach)n(e);if(0===r.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(t,n,i)=>{if(t.memo)return t;let r,s=$(t);for(const o of n){if(o._zod.def.when){if(M(t))continue;if(!o._zod.def.when(t))continue}else if(s)continue;const n=t.issues.length,a=o._zod.check(t);if(a instanceof Promise&&!1===i?.async)throw new Y;if(r||a instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await a;t.issues.length!==n&&(A(t.issues,n,e),s||(s=$(t,n)))});else{if(t.issues.length===n)continue;A(t.issues,n,e),s||(s=$(t,n))}}return r?r.then(()=>t):t},n=(n,i,s)=>{if($(n))return n.aborted=!0,n;const o=t(i,r,s);if(o instanceof Promise){if(!1===s.async)throw new Y;return o.then(t=>e._zod.parse(t,s))}return e._zod.parse(o,s)};e._zod.run=(i,s)=>{if(s.skipChecks)return e._zod.parse(i,s);if("backward"===s.direction){const t=e._zod.parse({value:i.value,issues:[]},{...s,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,s)):n(t,i,s)}const o=e._zod.parse(i,s);if(o instanceof Promise){if(!1===s.async)throw new Y;return o.then(e=>t(e,r,s))}return t(o,r,s)}}},{get"~standard"(){return function(e,t,n){return q(e,t,n,!1)}(this,"~standard",(e=this,{validate:t=>{const n={async:!1};try{const i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return ve(i,n)}catch(e){}return async function(e,t){const n={async:!0};return ve(await e._zod.run({value:t,issues:[]},n),n)}(e,t)},vendor:"zod",version:1}));var e},set"~standard"(e){q(this,"~standard",e)}}),ve=(e,t)=>e.issues.length?{issues:e.issues.map(e=>L(e,t,Q()))}:{value:e.value};const ye=H("$ZodString",(e,t)=>{me.init(e,t),e._zod.pattern=t.pattern??de,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(i){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),we=H("$ZodStringFormat",(e,t)=>{fe.init(e,t),ye.init(e,t)});function ge(e,t){return"normalize"in t||"hostname"in t||"protocol"in t?function(e,t){if(!t.normalize&&t.protocol?.source===le.source&&!/^https?:\/\//i.test(e))return 1;try{if("undefined"!=typeof URL){const t=URL;if("function"==typeof t.parse)return t.parse(e)??2}return new URL(e)}catch{return 2}}(e,t):function(e){try{return"undefined"!=typeof URL&&"function"==typeof URL.canParse?URL.canParse(e):(new URL(e),!0)}catch{return!1}}(e)||2}const be=/[\t\n\r]/g;function _e(e){return e.replace(be,"")}const Pe=H("$ZodURL",(e,t)=>{we.init(e,t),e._zod.check=n=>{try{const i=n.value.trim(),r=ge(i,t);return 1===r?void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort}):2===r?void n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort}):!0===r?void(n.value=_e(i)):(t.hostname&&!function(e,t){return t.lastIndex=0,t.test(e.hostname)}(r,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!function(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}(r,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),void(n.value=t.normalize?r.href:_e(i)))}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}});const ze=H("$ZodJWT",(e,t)=>{we.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[i]=n;if(!i)return!1;const r=JSON.parse(atob(i));return!("typ"in r&&"JWT"!==r?.typ||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});function ke(e,t,n,i,r,s){const o=n in i,a="optional"===s;if(o||!a||"optional"!==r){if(e.issues.length){if(void 0!==r&&a&&!o)return;t.issues.push(...(c=n,u=e.issues,u.map(e=>{var t;return(t=e).path??(t.path=[]),e.path.unshift(c),e})))}var c,u;o||void 0!==r?void 0===e.value?(o||"defaulted"===r&&!a)&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}}const Oe=[];function Se(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:Oe,r=i.length?[...t,...i]:t;for(const t of r)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(t)}": expected a Zod schema`);const s=(o=e.shape,Object.keys(o).filter(e=>void 0!==o[e]._zod.optin&&"optional"===o[e]._zod.optout));var o;return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}const Te=H("$ZodObject",(e,t)=>{me.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){const e=()=>{const n={...i};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=i,Object.defineProperty(t,"shape",{get:e})}const r=new T(()=>Se(t));V(e,"propValues",e=>{const t=e.def.shape,n={};for(const e in t){const i=t[e]._zod;if(i.values){Object.prototype.hasOwnProperty.call(n,e)||E(n,e,new Set);for(const t of i.values)n[e].add(t);void 0!==i.optin&&n[e].add(void 0)}}return n});const s=I,o=t.catchall;let a;const c=X.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{a??(a=r.value);const i=t.value;if(!s(i))return t.issues.push({expected:"object",code:"invalid_type",input:i,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};const u=[],l=a.shape,d=n?.abortEarly;let h=t.issues.length;for(const e of a.allKeys){if(d&&t.issues.length!==h){if($(t,h))break;h=t.issues.length}if("__proto__"===e)continue;const r=l[e],s=r._zod.optin,o=r._zod.optout,a=r._zod.run({value:i[e],issues:[]},n);a instanceof Promise?u.push(a.then(n=>ke(n,t,e,i,s,o))):ke(a,t,e,i,s,o)}return o?function(e,t,n,i,r,s,o){const a=[],c=r.keySet,u=r.catchall._zod,l=u.def.type,d=u.optin,h=u.optout;let f=0;for(const r in t){if(o&&n.issues.length!==f){if($(n,f))break;f=n.issues.length}if(c.has(r))continue;if("__proto__"===r){"never"===l&&a.push(r);continue}if("never"===l){a.push(r);continue}const s=u.run({value:t[r],issues:[]},i);s instanceof Promise?e.push(s.then(e=>ke(e,n,r,t,d,h))):ke(s,n,r,t,d,h)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>n):n}(u,i,t,n,r.value,e,!0===d):u.length?Promise.all(u).then(()=>t):t}}),Ee=H("$ZodEnum",(e,t)=>{me.init(e,t);const n=O(t.entries),i=new Set(n);e._zod.values=i,V(e,"pattern",e=>{const t=O(e.def.entries).filter(e=>R.has(typeof e));return new RegExp(t.length?`^(${t.map(e=>C(e.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(t,r)=>{const s=t.value;return i.has(s)||t.issues.push({code:"invalid_value",values:n,input:s,inst:e}),t}}),je=H("$ZodLiteral",(e,t)=>{me.init(e,t);const n=new Set(t.values);e._zod.values=n,V(e,"pattern",e=>{const t=e.def.values;return new RegExp(t.length?`^(${t.map(e=>"string"==typeof e?C(e):e?C(e.toString()):String(e)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{const s=i.value;return n.has(s)||i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});function Ie(e,t){return e.value=t.issues.length?void 0:t.value,e}const Re=H("$ZodOptional",(e,t)=>{me.init(e,t),V(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),e._zod.optout="optional",V(e,"values",e=>{const t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),V(e,"pattern",e=>{const t=e.def.innerType._zod.pattern;return t?new RegExp(`^(${function(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(void 0===e.value){if("defaulted"!==t.innerType._zod.optin)return e;const i=t.innerType._zod.run({value:e.value,issues:[]},n);return i instanceof Promise?i.then(t=>Ie(e,t)):Ie(e,i)}return t.innerType._zod.run(e,n)}});function Ce(e,t,n,i){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>L(e,i,Q()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const xe=H("$ZodCatch",(e,t)=>{me.init(e,t),V(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),V(e,"optout",e=>e.def.innerType._zod.optout),V(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const i=t.innerType._zod.run({value:e.value,issues:[]},n);return i instanceof Promise?i.then(i=>Ce(e,i,t,n)):Ce(e,i,t,n)}}),$e=H("$ZodCustom",(e,t)=>{he.init(e,t),me.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then(t=>Me(t,n,i,e));Me(r,n,i,e)}});function Me(e,t,n,i){if(!e){const e={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(e.params=i._zod.def.params),t.issues.push(function(...e){const[t,n,i]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:i}:{...t}}(e))}}const Ue=H("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");me.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){q(this,"with",e)},parse(e,t){return re(this,e,t,{callee:this.parse})},parseAsync(e,t){return oe(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return ae(this,e,t)},safeParseAsync(e,t){return ue(this,e,t)},check(...e){const t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]},{parent:!0})},clone(e,t){return function(e,t,n){const i=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(i._zod.parent=e),i}(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return 0===t.length?e(this):e(this,...t)}}),Ae=H("ZodMiniString",(e,t)=>{ye.init(e,t),Ue.init(e,t)}),Le=H("ZodMiniStringFormat",(e,t)=>{we.init(e,t),Ae.init(e,t)}),qe=H("ZodMiniURL",(e,t)=>{Pe.init(e,t),Le.init(e,t)});const Ne=H("ZodMiniJWT",(e,t)=>{ze.init(e,t),Le.init(e,t)});const De=H("ZodMiniObject",(e,t)=>{Te.init(e,t),Ue.init(e,t),K(e,"shape",e=>e._zod.def.shape,!1)});const Ze=H("ZodMiniEnum",(e,t)=>{Ee.init(e,t),Ue.init(e,t),e.options=[...e._zod.values]});const We=H("ZodMiniLiteral",(e,t)=>{je.init(e,t),Ue.init(e,t)});function Ve(e,t){return new We({type:"literal",values:Array.isArray(e)?e:[e],...x(t)})}const Ke=H("ZodMiniOptional",(e,t)=>{Re.init(e,t),Ue.init(e,t)});function Fe(e){return new Ke({type:"optional",innerType:e})}const Ge=H("ZodMiniCatch",(e,t)=>{xe.init(e,t),Ue.init(e,t)});const Be=H("ZodMiniCustom",(e,t)=>{$e.init(e,t),Ue.init(e,t)});const Je=function(e,t){const n={type:"object",shape:e??{},...x(t)};return new De(n)}({token:Fe((Xe="access token(`token`) is not a JWT",function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...x(t)})}(Ne,Xe))),preview:Fe(Ve("1")),edit:Fe(Ve("1")),completionPolicy:Fe(Ve("1")),baseUrl:(He=Fe(function(e){return function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...x(t)})}(qe,e)}({protocol:/^https?$/})),Ye=void 0,new Ge({type:"catch",innerType:He,catchValue:F(Ye)})),screen:Fe(function(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ze({type:"enum",entries:n,...x(t)})}(["learn","instructor","completionPolicy"]))}).check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...x(n)})}(Be,e,t)}(e=>null!=e.token||"1"===e.preview||"1"===e.edit||"1"===e.completionPolicy,{message:"access token(`token`) is not provided"}));var He,Ye,Xe;const Qe=/\/materials\/([0-9a-f-]{36})\//i;const et="undefined"==typeof window,tt="eliceio-content-sdk";function nt(){if(et||window.parent===window)return null;const e=window.parent;return{post(t){e.postMessage(t,"*")},subscribe(t){function n(n){n.source===e&&function(e){if("object"!=typeof e||null===e)return!1;const{source:t,type:n}=e;return t===tt&&"string"==typeof n}(n.data)&&t(n.data)}return window.addEventListener("message",n),()=>{window.removeEventListener("message",n)}}}}function it(e){let t="";return t=(e=>{try{let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";return decodeURIComponent((e=>e.split("").map(e=>{let t=e.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t=`0${t}`),`%${t}`}).join(""))(atob(t)))}catch(e){throw new _(_.code.InvalidToken,"Fail to decode base64 format.",e)}})(e.split(".")[1]),t=(e=>{try{return JSON.parse(e)}catch(e){throw new _(_.code.InvalidToken,"Fail to parse JSON format.",e)}})(t),o(t)}var rt,st,ot;const at=Object.freeze({previous:"navigate-prev",next:"navigate-next",navigate:"navigate",stateSync:"navigate-state-sync"}),ct="navigate-state";class ut{constructor(e){rt.add(this),this.ctx=e}async getHasPrevious(){return(await t(this,rt,"m",ot).call(this)).hasPreviousLecturePage}async getHasNext(){return(await t(this,rt,"m",ot).call(this)).hasNextLecturePage}previous(){t(this,rt,"m",st).call(this,at.previous)}next(){t(this,rt,"m",st).call(this,at.next)}navigate(e){t(this,rt,"m",st).call(this,at.navigate,{lecturePageId:e})}}var lt,dt,ht,ft,pt,mt,vt,yt,wt,gt,bt,_t,Pt,zt,kt,Ot,St,Tt,Et,jt,It,Rt,Ct,xt,$t,Mt,Ut,At,Lt,qt,Nt,Dt,Zt;rt=new WeakSet,st=function(e,t,n){const i=this.ctx.assertNavigable();if(this.ctx.isDraft()||null==this.ctx.channel)return!1;const r={source:tt,type:e,materialId:i};return void 0!==t&&(r.payload=t),void 0!==n&&(r.requestId=n),this.ctx.channel.post(r),!0},ot=function(){var e;const n="undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,i=this.ctx.channel,r=null!==(e=this.ctx.stateTimeoutMs)&&void 0!==e?e:1e3;return new Promise((e,s)=>{let o=()=>{},a=null;const c=()=>{o(),null!==a&&clearTimeout(a)};let u;null!=i&&(o=i.subscribe(t=>{var i;if(t.type!==ct||t.requestId!==n)return;c();const r=null!==(i=t.payload)&&void 0!==i?i:{};e({hasPreviousLecturePage:!0===r.hasPreviousLecturePage,hasNextLecturePage:!0===r.hasNextLecturePage})}));try{u=t(this,rt,"m",st).call(this,at.stateSync,void 0,n)}catch(e){return c(),void s(e)}if(!u)return c(),void e({hasPreviousLecturePage:!1,hasNextLecturePage:!1});a=setTimeout(()=>{c(),s(new _(_.code.NavigationTimeout,"The learning page did not answer the navigation state request."))},r)})};const Wt=Object.freeze({AUTH_PERMISSION_DENIED:e.ErrorCode.PermissionDenied,AUTHENTICATION_INVALID:e.ErrorCode.Unauthorized,EXTERNAL_SERVICE_ERROR:e.ErrorCode.ExternalServiceError,INVALID_INPUT:e.ErrorCode.InvalidInput,MATERIAL_CONTENT_NOT_READY:e.ErrorCode.ContentNotReady,MATERIAL_READ_ONLY_MODE:e.ErrorCode.ReadOnlyMode,MATERIAL_TOO_MANY_SUBMISSIONS:e.ErrorCode.RateLimited});function Vt(e,t){var n,i,r;if(e instanceof h){const s=null!==(i=Wt[null!==(n=e.cause.code)&&void 0!==n?n:""])&&void 0!==i?i:_.code.RequestFailed;return new _(s,null!==(r=e.cause.message)&&void 0!==r?r:t,e)}return new _(_.code.RequestFailed,t,e)}function Kt(e){return e instanceof h&&401===e.cause.status}function Ft(e){if(!Kt(e))return!1;const t=e.cause.detail;return Array.isArray(t)&&t.some(e=>{var t;return"session_expired"===(null===(t=null==e?void 0:e.ctx)||void 0===t?void 0:t.reason)})}dt=new WeakMap,ht=new WeakMap,ft=new WeakMap,pt=new WeakMap,mt=new WeakMap,vt=new WeakMap,yt=new WeakMap,wt=new WeakMap,gt=new WeakMap,bt=new WeakMap,_t=new WeakMap,Pt=new WeakMap,zt=new WeakMap,kt=new WeakMap,Ot=new WeakMap,St=new WeakMap,Tt=new WeakMap,lt=new WeakSet,Et=function(){if(!this.initialized||!t(this,bt,"f"))throw new _(_.code.NotInitialized,"The SDK is not initialized. Please call the init function first.");if(t(this,mt,"f"))throw new _(_.code.SessionExpired,"The session has expired. Please reload the material.");return t(this,bt,"f").materialId},jt=function(e){var n;if(!t(this,bt,"f"))return;const i={source:tt,type:"settings-saved",materialId:t(this,bt,"f").materialId,payload:e};null===(n=t(this,St,"f"))||void 0===n||n.post(i)},It=function(e){const n=t(this,lt,"m",Rt).call(this,e),i=e instanceof h&&n.code!==_.code.SessionExpired?e.cause.code:void 0;return t(this,lt,"m",jt).call(this,{status:"failed",code:null!=i?i:n.code}),n},Rt=function(e){return e instanceof _?e:Ft(e)?(t(this,lt,"m",Zt).call(this),new _(_.code.SessionExpired,"The session has expired. Please reload the material.",e)):Vt(e,"Failed to save the settings.")},Ct=function(...e){if(null==t(this,wt,"f")||!e.includes(t(this,wt,"f")))throw new _(_.code.ScreenNotSupported,`This call is only available on the ${e.join(" or ")} screen.`)},xt=function(){var e,n,i,r,s;if(t(this,zt,"f"))return{materials:new k(null!==(e=t(this,vt,"f"))&&void 0!==e?e:"learn","instructor")};const o=new c({basePath:(null!==(s=null!==(i=null===(n=this.options)||void 0===n?void 0:n.baseUrl)&&void 0!==i?i:null===(r=t(this,Ot,"f"))||void 0===r?void 0:r.baseUrl)&&void 0!==s?s:"https://api-material.elice.io").replace(/\/+$/,""),accessToken:()=>{var e;return null!==(e=t(this,ht,"f"))&&void 0!==e?e:""}});return{materials:new g(o)}},$t=async function(e){const i=null!=e?e:et?"":window.location.hash,r=/(^|[#&])(token|preview|edit|completionPolicy)=/.test(i);if(void 0===e&&!r&&t(this,Ot,"f"))return t(this,Ot,"f");const s=new URLSearchParams(i.replace(/^#/,"")),{data:o,error:a}=await Je.safeParseAsync(Object.fromEntries(s.entries()));if(a)throw new AggregateError(a.issues.map(e=>new _(_.code.InvalidParam,e.message)),"Failed to resolve fragment params during initialization.");return n(this,Ot,o,"f"),o},Mt=function(){if(et||!window.location.hash.includes("token="))return;const e=new URLSearchParams(window.location.hash.replace(/^#/,""));e.delete("token");const t=e.toString(),{pathname:n,search:i}=window.location;window.history.replaceState(window.history.state,"",`${n}${i}${t?`#${t}`:""}`)},Ut=function(e,i){var r,s,o,a,c,u;n(this,zt,null==e.token,"f"),n(this,mt,!1,"f"),t(this,lt,"m",Lt).call(this,null!==(r=e.token)&&void 0!==r?r:null);const l=t(this,ht,"f")?it(t(this,ht,"f")):null,d=null!==(o=null!==(s=function(e){const t=Qe.exec(e);return t?t[1].toLowerCase():null}(null!=i?i:et?"":window.location.pathname))&&void 0!==s?s:null==l?void 0:l.materialId)&&void 0!==o?o:null;if(null==d)throw new _(_.code.InvalidParam,"The material id is not found in the content URL or the access token.");if(n(this,bt,{materialId:d,lecturePageId:null!==(a=null==l?void 0:l.lecturePageId)&&void 0!==a?a:null,courseId:null!==(c=null==l?void 0:l.courseId)&&void 0!==c?c:null},"f"),n(this,Pt,null!==(u=null==l?void 0:l.locale)&&void 0!==u?u:"ko","f"),t(this,zt,"f")){const t="1"===e.edit||"1"===e.completionPolicy;n(this,vt,t?"edit":"learn","f"),n(this,wt,"1"===e.completionPolicy?"completionPolicy":"1"===e.edit?"edit":"learn","f")}return d},At=async function(e){var i,r,s,o,a,c,u;const[l,d]=await Promise.all([this.internal_apis.materials.materialGet({materialId:e}),this.internal_apis.materials.materialMeGet({materialId:e})]),h=null!==(r=null===(i=l.currentVersion.metadata)||void 0===i?void 0:i.screens)&&void 0!==r?r:{},f={};for(const e of["learn","instructor","edit","completionPolicy"]){const{entry:t,enabled:n}=null!==(s=h[e])&&void 0!==s?s:{};!1!==n&&"string"==typeof t&&(f[e]=t)}n(this,_t,{description:l.description,entries:f,settings:l.currentVersion.settings,completionPolicy:null!==(o=l.currentVersion.completionPolicy)&&void 0!==o?o:null,completionPolicies:null!==(c=null===(a=l.currentVersion.metadata)||void 0===a?void 0:a.completionPolicies)&&void 0!==c?c:null},"f"),n(this,kt,l.currentVersion.id,"f"),n(this,dt,d.user,"f"),n(this,gt,d.result,"f"),n(this,yt,d.viewer,"f"),t(this,zt,"f")||(n(this,vt,d.scope,"f"),n(this,wt,function(e,t,n,i){return"edit"===e?null==i?"edit":"completionPolicy"===i?"completionPolicy":"instructor"===i&&n.instructor?"instructor":"learn":"instructor"===t&&n.instructor?"instructor":"learn"}(d.scope,d.viewer,t(this,_t,"f").entries,null===(u=t(this,Ot,"f"))||void 0===u?void 0:u.screen),"f"))},Lt=function(e){var t;n(this,ht,e,"f");const i=e?null===(t=it(e))||void 0===t?void 0:t.exp:void 0;n(this,ft,i?1e3*i:null,"f")},qt=function(e){if(t(this,lt,"m",Nt).call(this),t(this,zt,"f")||null==t(this,ft,"f")||et)return;const i=null!=e?e:Math.max(0,t(this,ft,"f")-3e5-Date.now());n(this,pt,setTimeout(()=>{t(this,lt,"m",Dt).call(this)},i),"f")},Nt=function(){null!=t(this,pt,"f")&&(clearTimeout(t(this,pt,"f")),n(this,pt,null,"f"))},Dt=async function(){try{const{accessToken:e}=await this.internal_apis.materials.authTokenRefresh();t(this,lt,"m",Lt).call(this,e),t(this,lt,"m",qt).call(this)}catch(e){if(Ft(e)||Kt(e))return void t(this,lt,"m",Zt).call(this);t(this,lt,"m",qt).call(this,3e4)}},Zt=function(){var e,i;t(this,lt,"m",Nt).call(this),n(this,mt,!0,"f"),null===(i=(e=this.options).onSessionExpired)||void 0===i||i.call(e)},e.EliceCDK=class{constructor(e={}){lt.add(this),this.options=e,this.initialized=!1,dt.set(this,null),ht.set(this,null),ft.set(this,null),pt.set(this,null),mt.set(this,!1),vt.set(this,null),yt.set(this,null),wt.set(this,null),gt.set(this,null),bt.set(this,null),_t.set(this,null),Pt.set(this,"ko"),zt.set(this,!1),kt.set(this,null),Ot.set(this,null),St.set(this,void 0),Tt.set(this,void 0),this.internal_apis=t(this,lt,"m",xt).call(this),n(this,St,nt(),"f"),n(this,Tt,new ut({channel:t(this,St,"f"),isDraft:()=>t(this,zt,"f"),assertNavigable:()=>{const e=t(this,lt,"m",Et).call(this);return t(this,lt,"m",Ct).call(this,"learn","instructor"),e}}),"f")}get account(){return t(this,dt,"f")}get scope(){return t(this,vt,"f")}get viewer(){return t(this,yt,"f")}get screen(){return t(this,wt,"f")}get result(){return t(this,gt,"f")}get metadata(){return t(this,bt,"f")}get material(){return t(this,_t,"f")}get locale(){return t(this,Pt,"f")}get isDraft(){return t(this,zt,"f")}get isSessionExpired(){return t(this,mt,"f")}get navigation(){return t(this,Tt,"f")}async init(e={}){this.initialized=!1,t(this,lt,"m",Nt).call(this);const n=await t(this,lt,"m",$t).call(this,e.hash);void 0===e.hash&&t(this,lt,"m",Mt).call(this);try{const i=t(this,lt,"m",Ut).call(this,n,e.pathname);this.internal_apis=t(this,lt,"m",xt).call(this),await t(this,lt,"m",At).call(this,i),this.initialized=!0,t(this,lt,"m",qt).call(this)}catch(e){if(e instanceof _)throw e;throw Vt(e,"Failed to initialize elice content sdk.")}return this}async submit(e){const n=t(this,lt,"m",Et).call(this);t(this,lt,"m",Ct).call(this,"learn","instructor");try{return await this.internal_apis.materials.submissionCreate({materialId:n,submissionCreateRequest:{answer:e}})}catch(e){throw Vt(e,"Failed to submit the answer.")}}async history(e={}){const n=t(this,lt,"m",Et).call(this);try{return await this.internal_apis.materials.submissionMeList(Object.assign({materialId:n},e))}catch(e){throw Vt(e,"Failed to load submissions.")}}async saveSettings(e){var i;this.initialized&&"edit"===t(this,wt,"f")||(t(this,lt,"m",Et).call(this),t(this,lt,"m",Ct).call(this,"edit"));try{if(t(this,zt,"f"))throw new _(_.code.DraftNotSaved,"Settings of an unsaved upload cannot be saved. Save the material in the editor first.");const r=t(this,lt,"m",Et).call(this),s=await this.internal_apis.materials.materialUpdate({materialId:r,materialUpdateRequest:{settings:e,expectedCurrentVersionId:null!==(i=t(this,kt,"f"))&&void 0!==i?i:void 0}});n(this,kt,s.currentVersion.id,"f"),t(this,_t,"f")&&n(this,_t,Object.assign(Object.assign({},t(this,_t,"f")),{settings:s.currentVersion.settings}),"f"),t(this,lt,"m",jt).call(this,{status:"saved"})}catch(e){throw t(this,lt,"m",It).call(this,e)}}async saveCompletionPolicy(e){var i,r;this.initialized&&"completionPolicy"===t(this,wt,"f")||(t(this,lt,"m",Et).call(this),t(this,lt,"m",Ct).call(this,"completionPolicy"));try{if(t(this,zt,"f"))throw new _(_.code.DraftNotSaved,"The completion policy of an unsaved upload cannot be saved. Save the material in the editor first.");const s=t(this,lt,"m",Et).call(this),o=await this.internal_apis.materials.materialUpdate({materialId:s,materialUpdateRequest:{completionPolicy:e,expectedCurrentVersionId:null!==(i=t(this,kt,"f"))&&void 0!==i?i:void 0}});n(this,kt,o.currentVersion.id,"f"),t(this,_t,"f")&&n(this,_t,Object.assign(Object.assign({},t(this,_t,"f")),{completionPolicy:null!==(r=o.currentVersion.completionPolicy)&&void 0!==r?r:e}),"f"),t(this,lt,"m",jt).call(this,{status:"saved"})}catch(e){throw t(this,lt,"m",It).call(this,e)}}dispose(){t(this,lt,"m",Nt).call(this)}},e.EliceCDKError=_,e.EliceCDKNavigation=ut,e.NAVIGATION_MESSAGE_TYPE=at,e.NAVIGATION_STATE_MESSAGE_TYPE=ct});
|
|
@@ -239,6 +239,16 @@ button:disabled {
|
|
|
239
239
|
font-size: var(--eds-fs-caption);
|
|
240
240
|
font-weight: var(--eds-fw-semibold);
|
|
241
241
|
}
|
|
242
|
+
/* 데스크톱(512px 이상): 제출 바가 아래에 붙지 않으니 아래 여백을 줄이고, 마지막 카드와 제출 바를 띄운다.
|
|
243
|
+
모바일은 제출 바가 화면 아래 고정이라 아래 여백 96px 그대로 */
|
|
244
|
+
@media (min-width: 512px) {
|
|
245
|
+
body {
|
|
246
|
+
padding-bottom: 24px;
|
|
247
|
+
}
|
|
248
|
+
.ec-submitbar {
|
|
249
|
+
margin-top: 16px;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
242
252
|
[aria-readonly='true'] {
|
|
243
253
|
opacity: 0.85;
|
|
244
254
|
}
|
|
@@ -247,6 +257,202 @@ button:disabled {
|
|
|
247
257
|
max-width: 720px;
|
|
248
258
|
margin-inline: auto;
|
|
249
259
|
}
|
|
260
|
+
/* 완료 정책 화면 (useCompletion) · 편집 화면 채점 방식 블록 (useGradingBlock): LXP 편집 › 설정 탭과 같은 모양.
|
|
261
|
+
제목 h6 · 설명 body2 secondary, 방식마다 EDS 라디오 카드(테두리 1px, 고르면 primary 테두리 · primary-opacity02 바탕) */
|
|
262
|
+
.ec-grading {
|
|
263
|
+
display: flex;
|
|
264
|
+
flex-direction: column;
|
|
265
|
+
gap: 16px;
|
|
266
|
+
}
|
|
267
|
+
.ec-grading-head h2 {
|
|
268
|
+
margin: 0 0 4px;
|
|
269
|
+
font-size: var(--eds-fs-h6);
|
|
270
|
+
line-height: var(--eds-lh-h6);
|
|
271
|
+
font-weight: var(--eds-fw-bold);
|
|
272
|
+
}
|
|
273
|
+
.ec-grading-head p {
|
|
274
|
+
margin: 0;
|
|
275
|
+
}
|
|
276
|
+
.ec-grading-types {
|
|
277
|
+
display: flex;
|
|
278
|
+
flex-direction: column;
|
|
279
|
+
gap: 8px;
|
|
280
|
+
}
|
|
281
|
+
.ec-grading-type {
|
|
282
|
+
display: flex;
|
|
283
|
+
align-items: flex-start;
|
|
284
|
+
gap: 12px;
|
|
285
|
+
padding: 14px 16px;
|
|
286
|
+
border: 1px solid var(--ec-border);
|
|
287
|
+
border-radius: var(--ec-radius);
|
|
288
|
+
cursor: pointer;
|
|
289
|
+
}
|
|
290
|
+
.ec-grading-type input {
|
|
291
|
+
width: 20px;
|
|
292
|
+
height: 20px;
|
|
293
|
+
margin: 2px 0 0;
|
|
294
|
+
accent-color: var(--ec-accent);
|
|
295
|
+
}
|
|
296
|
+
.ec-grading-type.selected {
|
|
297
|
+
border-color: var(--ec-accent);
|
|
298
|
+
background: var(--ec-accent-bg);
|
|
299
|
+
}
|
|
300
|
+
.ec-grading-text {
|
|
301
|
+
display: flex;
|
|
302
|
+
flex-direction: column;
|
|
303
|
+
gap: 2px;
|
|
304
|
+
}
|
|
305
|
+
.ec-grading-label {
|
|
306
|
+
font-weight: var(--eds-fw-semibold);
|
|
307
|
+
}
|
|
308
|
+
.ec-grading-detail {
|
|
309
|
+
margin: 8px 0 0 32px;
|
|
310
|
+
display: flex;
|
|
311
|
+
flex-direction: column;
|
|
312
|
+
gap: 12px;
|
|
313
|
+
}
|
|
314
|
+
/* 기준 답안: LXP처럼 라벨 · '작성 예시 보기' · 입력 칸 · 도움말 */
|
|
315
|
+
.ec-grading-field {
|
|
316
|
+
display: flex;
|
|
317
|
+
flex-direction: column;
|
|
318
|
+
gap: 6px;
|
|
319
|
+
}
|
|
320
|
+
.ec-grading-field-head {
|
|
321
|
+
display: flex;
|
|
322
|
+
align-items: center;
|
|
323
|
+
justify-content: space-between;
|
|
324
|
+
gap: 8px;
|
|
325
|
+
font-weight: var(--eds-fw-semibold);
|
|
326
|
+
}
|
|
327
|
+
.ec-grading-key,
|
|
328
|
+
.ec-grading-rubric {
|
|
329
|
+
width: 100%;
|
|
330
|
+
font: inherit;
|
|
331
|
+
font-size: 16px;
|
|
332
|
+
padding: 10px 12px;
|
|
333
|
+
border: 1px solid var(--ec-border);
|
|
334
|
+
border-radius: var(--ec-radius);
|
|
335
|
+
background: var(--eds-background-input);
|
|
336
|
+
color: var(--ec-fg);
|
|
337
|
+
}
|
|
338
|
+
.ec-grading-key {
|
|
339
|
+
font-family: var(--eds-font-family-code, ui-monospace, Menlo, monospace);
|
|
340
|
+
}
|
|
341
|
+
.ec-grading-key:focus,
|
|
342
|
+
.ec-grading-rubric:focus {
|
|
343
|
+
outline: 2px solid var(--ec-accent);
|
|
344
|
+
outline-offset: -1px;
|
|
345
|
+
}
|
|
346
|
+
/* EDS Button text small */
|
|
347
|
+
button.ec-text-button {
|
|
348
|
+
min-height: 32px;
|
|
349
|
+
padding: 4px 8px;
|
|
350
|
+
border: 0;
|
|
351
|
+
font-size: 13px;
|
|
352
|
+
}
|
|
353
|
+
.ec-grading-examples {
|
|
354
|
+
display: grid;
|
|
355
|
+
grid-template-columns: max-content 1fr;
|
|
356
|
+
gap: 4px 12px;
|
|
357
|
+
margin: 0;
|
|
358
|
+
padding: 12px;
|
|
359
|
+
border-radius: var(--ec-radius);
|
|
360
|
+
background: var(--ec-surface);
|
|
361
|
+
font-size: var(--eds-fs-body2);
|
|
362
|
+
}
|
|
363
|
+
.ec-grading-examples dt {
|
|
364
|
+
font-family: var(--eds-font-family-code, ui-monospace, Menlo, monospace);
|
|
365
|
+
overflow-wrap: anywhere;
|
|
366
|
+
}
|
|
367
|
+
.ec-grading-examples dd {
|
|
368
|
+
margin: 0;
|
|
369
|
+
color: var(--ec-muted);
|
|
370
|
+
}
|
|
371
|
+
/* 문항별로 고르기 · 정규식 직접 입력 (EDS ToggleButton 모양) */
|
|
372
|
+
.ec-grading-tabs {
|
|
373
|
+
display: inline-flex;
|
|
374
|
+
gap: 4px;
|
|
375
|
+
flex-wrap: wrap;
|
|
376
|
+
}
|
|
377
|
+
.ec-grading-tabs button[aria-pressed='true'] {
|
|
378
|
+
background: var(--ec-accent);
|
|
379
|
+
color: var(--eds-primary-contrast-text);
|
|
380
|
+
}
|
|
381
|
+
.ec-grading-picker {
|
|
382
|
+
display: flex;
|
|
383
|
+
flex-direction: column;
|
|
384
|
+
gap: 12px;
|
|
385
|
+
}
|
|
386
|
+
@media (max-width: 511.98px) {
|
|
387
|
+
.ec-grading-detail {
|
|
388
|
+
margin-left: 0;
|
|
389
|
+
}
|
|
390
|
+
.ec-grading-examples {
|
|
391
|
+
grid-template-columns: 1fr;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
250
394
|
[hidden] {
|
|
251
395
|
display: none !important;
|
|
252
396
|
}
|
|
397
|
+
|
|
398
|
+
/* 여러 단계 (app.usePaging): 양옆 동그란 화살표 = 자료 안 단계 이동 (EDS IconButton outlined 40px).
|
|
399
|
+
첫 · 마지막 단계에서 나가는 버튼은 글자 있는 알약(이전 자료 · 다음 자료)으로 모양을 달리한다.
|
|
400
|
+
LXP가 자료 아래에 수업 자료 사이 이전 · 다음 막대를 그리므로, 자료 안에는 아래 막대를 두지 않는다 */
|
|
401
|
+
/* 옆 여백은 끝 단계의 알약(약 80px)이 들어가는 96px로 늘 잡는다. 알약이 보일 때만 넓히면 단계마다 내용 폭이 바뀐다 */
|
|
402
|
+
.ec-paging {
|
|
403
|
+
position: relative;
|
|
404
|
+
padding-inline: 96px;
|
|
405
|
+
}
|
|
406
|
+
.ec-step-nav {
|
|
407
|
+
position: absolute;
|
|
408
|
+
top: 50%;
|
|
409
|
+
translate: 0 -50%;
|
|
410
|
+
z-index: 1;
|
|
411
|
+
min-width: 40px;
|
|
412
|
+
height: 40px;
|
|
413
|
+
padding: 0;
|
|
414
|
+
border-radius: 999px;
|
|
415
|
+
border: 1px solid var(--ec-border);
|
|
416
|
+
background: var(--ec-bg);
|
|
417
|
+
color: var(--eds-action-active);
|
|
418
|
+
font-size: 24px;
|
|
419
|
+
line-height: 1;
|
|
420
|
+
cursor: pointer;
|
|
421
|
+
}
|
|
422
|
+
.ec-step-nav:hover {
|
|
423
|
+
background: var(--eds-action-hover);
|
|
424
|
+
}
|
|
425
|
+
.ec-step-nav.prev {
|
|
426
|
+
left: 0;
|
|
427
|
+
}
|
|
428
|
+
.ec-step-nav.next {
|
|
429
|
+
right: 0;
|
|
430
|
+
}
|
|
431
|
+
.ec-step-nav.leave {
|
|
432
|
+
padding: 0 12px;
|
|
433
|
+
border-color: var(--ec-accent);
|
|
434
|
+
background: var(--ec-accent-bg);
|
|
435
|
+
color: var(--ec-accent);
|
|
436
|
+
font-size: var(--eds-fs-caption);
|
|
437
|
+
font-weight: var(--eds-fw-semibold);
|
|
438
|
+
white-space: nowrap;
|
|
439
|
+
}
|
|
440
|
+
.ec-step-count {
|
|
441
|
+
margin: 12px 0 0;
|
|
442
|
+
color: var(--ec-muted);
|
|
443
|
+
font-size: var(--eds-fs-body2);
|
|
444
|
+
}
|
|
445
|
+
@media (max-width: 511.98px) {
|
|
446
|
+
.ec-paging {
|
|
447
|
+
padding-inline: 0;
|
|
448
|
+
padding-bottom: 56px;
|
|
449
|
+
}
|
|
450
|
+
.ec-step-nav {
|
|
451
|
+
top: auto;
|
|
452
|
+
bottom: 0;
|
|
453
|
+
translate: none;
|
|
454
|
+
}
|
|
455
|
+
.ec-step-count {
|
|
456
|
+
text-align: center;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// 편집기 자동완성용 타입. lib/elice-content.js와 같이 고치지 않습니다.
|
|
2
2
|
|
|
3
|
-
export type Screen = 'learn' | 'instructor' | 'edit';
|
|
3
|
+
export type Screen = 'learn' | 'instructor' | 'edit' | 'completionPolicy';
|
|
4
4
|
export type Scope = 'learn' | 'edit';
|
|
5
5
|
export type Viewer = 'student' | 'instructor' | 'tutor';
|
|
6
6
|
|
|
@@ -22,7 +22,7 @@ export declare function pickSdk(where: {
|
|
|
22
22
|
export declare function resolveLaunch(
|
|
23
23
|
hash: string,
|
|
24
24
|
pathname: string,
|
|
25
|
-
screen: Screen
|
|
25
|
+
screen: Screen
|
|
26
26
|
): { hash: string; pathname: string; local: boolean };
|
|
27
27
|
|
|
28
28
|
/** 서버 채점 결과. 점수 없는 채점(manual · none)이면 둘 다 null */
|
|
@@ -51,11 +51,86 @@ export interface SubmitOptions<A = unknown> {
|
|
|
51
51
|
|
|
52
52
|
export interface SaveOptions<C> {
|
|
53
53
|
getContent: () => C;
|
|
54
|
+
/**
|
|
55
|
+
* 같이 저장할 채점 설정 (settings.grading, 학생에게 안 감). 문장이면 저장을 막고 보여 줌,
|
|
56
|
+
* undefined면 채점 설정은 그대로
|
|
57
|
+
*/
|
|
58
|
+
getGrading?: () => Grading | string | undefined;
|
|
54
59
|
validate?: (content: C) => true | string | false;
|
|
55
60
|
root?: Element;
|
|
56
61
|
label?: string;
|
|
57
62
|
}
|
|
58
63
|
|
|
64
|
+
/** 완료 정책 (서버 material_version.completion_policy). 지원하는 정책은 metadata completionPolicies */
|
|
65
|
+
export type CompletionPolicy = 'on_access' | 'on_submit' | 'on_graded';
|
|
66
|
+
/** 채점 방식 (settings.grading.type) */
|
|
67
|
+
export type GraderType = 'pattern' | 'rubric';
|
|
68
|
+
|
|
69
|
+
/** 채점 설정 (settings.grading, 서버 §5.1). pattern 답은 정규식 문자열 하나, rubric 기준은 문자열 하나 */
|
|
70
|
+
export type Grading =
|
|
71
|
+
| { type: 'pattern'; answer_key?: string }
|
|
72
|
+
| { type: 'rubric'; rubric?: string };
|
|
73
|
+
|
|
74
|
+
/** @deprecated Grading을 쓴다 */
|
|
75
|
+
export type GradingPart = Grading;
|
|
76
|
+
|
|
77
|
+
/** 완료 정책 읽기 · 바꾸기 (SDK material.completionPolicy · saveCompletionPolicy) */
|
|
78
|
+
export interface CompletionApi {
|
|
79
|
+
/** metadata completionPolicies (서버가 돌려주지 않으면 null, G132) */
|
|
80
|
+
readonly policies: CompletionPolicy[] | null;
|
|
81
|
+
/** 값 이름은 서버 material_version.completion_policy와 같다 */
|
|
82
|
+
get(): Promise<{ completion_policy: CompletionPolicy | null; policies: CompletionPolicy[] | null }>;
|
|
83
|
+
/** 완료 정책 화면에서만. policies 밖의 값 · 채점 설정 없는 on_graded는 거절 */
|
|
84
|
+
set(policy: CompletionPolicy): Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface GradingBlockOptions {
|
|
88
|
+
/** 고를 수 있는 채점 방식 (기본 둘 다) */
|
|
89
|
+
graders?: GraderType[];
|
|
90
|
+
/** '작성 예시 보기'에 보일 [정규식, 뜻] (기본 GRADING_EXAMPLES) */
|
|
91
|
+
examples?: Array<[string, string]>;
|
|
92
|
+
/** 블록을 넣을 곳 (기본: 화면 영역 #app 바로 뒤) */
|
|
93
|
+
root?: Element;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface CompletionOptions {
|
|
97
|
+
/** 고를 수 있는 완료 정책 (기본 metadata completionPolicies, 서버가 주지 않으면 셋 다) */
|
|
98
|
+
policies?: CompletionPolicy[];
|
|
99
|
+
/** 넣을 곳. 없으면 화면 영역(#app)을 완료 정책 영역으로 채운다 ("불러오는 중"을 지움) */
|
|
100
|
+
root?: Element;
|
|
101
|
+
label?: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** 완료 정책 문구 (열람 · 제출은 LXP 설정 탭 문구 그대로) */
|
|
105
|
+
export declare const COMPLETION_POLICIES: Readonly<
|
|
106
|
+
Record<CompletionPolicy, { label: string; description: string }>
|
|
107
|
+
>;
|
|
108
|
+
/** 채점 방식 문구 (LXP 설정 탭 문구 그대로) */
|
|
109
|
+
export declare const GRADER_TYPES: Readonly<Record<GraderType, { label: string; description: string }>>;
|
|
110
|
+
/** '작성 예시 보기' 기본 예시 [정규식, 뜻] */
|
|
111
|
+
export declare const GRADING_EXAMPLES: ReadonlyArray<[string, string]>;
|
|
112
|
+
/** 정답 정규식 길이 상한 */
|
|
113
|
+
export declare const ANSWER_KEY_MAX: number;
|
|
114
|
+
/**
|
|
115
|
+
* 정답 정규식 공통 검사: 비어 있지 않음 · 길이 · 컴파일 · ^…$ · 실행 시간(ReDoS). samples도 같이 시간을 잰다.
|
|
116
|
+
* 문제가 없으면 null, 있으면 보여 줄 문장
|
|
117
|
+
*/
|
|
118
|
+
export declare function validateAnswerRegex(regex: string, samples?: string[]): string | null;
|
|
119
|
+
/** 저장된 채점 설정을 서버 모양으로 (SDK가 바꾼 answerKey → answer_key). 채점 방식이 아니면 null */
|
|
120
|
+
export declare function normalizeGrading(grading: unknown): Grading | null;
|
|
121
|
+
|
|
122
|
+
export interface PagingOptions {
|
|
123
|
+
/** 단계 수 (1 이상) */
|
|
124
|
+
count: number;
|
|
125
|
+
/** 단계가 바뀔 때 (0부터). 시작할 때도 한 번. `content`(기본 #app)에만 그린다: replaceChildren으로 다시 그려도 버튼은 남는다 */
|
|
126
|
+
onChange: (step: number, ctx: { content: Element }) => void;
|
|
127
|
+
/** 처음 단계 (기본 0) */
|
|
128
|
+
start?: number;
|
|
129
|
+
/** 내용 영역 (기본 #app). 키트가 이 영역을 틀로 감싸고 화살표 · n / N은 틀에 둔다 */
|
|
130
|
+
root?: Element;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** 화면 맨 위 안내 한 줄. mock SDK일 때만 글자가 있고, 플랫폼(real)에서는 늘 '' */
|
|
59
134
|
export declare function statusText(app: ContentApp): string;
|
|
60
135
|
|
|
61
136
|
export interface ContentApp<C = Record<string, unknown>> {
|
|
@@ -71,22 +146,53 @@ export interface ContentApp<C = Record<string, unknown>> {
|
|
|
71
146
|
result: { score: number | null; submitCount: number; completedAt: string | null } | null;
|
|
72
147
|
readonly records: boolean;
|
|
73
148
|
readonly content: C;
|
|
149
|
+
/** 저장된 채점 설정. edit 범위(편집 · 완료 정책 화면)에서만, 없으면 null */
|
|
150
|
+
readonly grading: Grading | null;
|
|
74
151
|
submit(answer: unknown): Promise<SubmitResult>;
|
|
75
152
|
lastAnswer(): Promise<unknown>;
|
|
76
153
|
lastSubmission(): Promise<
|
|
77
154
|
(SubmitResult & { id: string; answer: unknown; createdAt: string }) | null
|
|
78
155
|
>;
|
|
79
|
-
|
|
156
|
+
/** 내용 저장 (편집 화면). grading을 주면 settings.grading으로 같이 저장, 없으면 저장된 채점 설정 그대로 */
|
|
157
|
+
saveContent(content: C, grading?: Grading): Promise<void>;
|
|
158
|
+
/** 완료 정책 (SDK material.completionPolicy · saveCompletionPolicy) */
|
|
159
|
+
readonly completion: CompletionApi;
|
|
80
160
|
/** 학생 화면 제출 영역 (보는 사람별 처리는 키트가) */
|
|
81
161
|
useSubmit<A = unknown>(
|
|
82
|
-
options: SubmitOptions<A
|
|
162
|
+
options: SubmitOptions<A>
|
|
83
163
|
): { element: Element; result: Element; restored: Promise<void> };
|
|
164
|
+
/** 여러 단계 이동: 양옆 화살표 + n / N. 첫 · 마지막 단계에서는 LXP 이전 · 다음 수업 자료로 (없으면 숨김) */
|
|
165
|
+
usePaging(options: PagingOptions): {
|
|
166
|
+
/** 키트 틀 (화살표 · n / N · 내용 영역을 담음) */
|
|
167
|
+
element: Element;
|
|
168
|
+
/** 화면 코드가 그리는 내용 영역 (기본 #app) */
|
|
169
|
+
content: Element;
|
|
170
|
+
/** 이전 · 다음 수업 자료가 있는지 확인을 마쳤을 때 */
|
|
171
|
+
ready: Promise<void>;
|
|
172
|
+
go(step: number): void;
|
|
173
|
+
readonly step: number;
|
|
174
|
+
};
|
|
84
175
|
/** 편집 화면 저장 영역 */
|
|
85
176
|
useSave(options: SaveOptions<C>): {
|
|
86
177
|
element: Element;
|
|
87
178
|
markDirty(): void;
|
|
88
179
|
readonly dirty: boolean;
|
|
89
180
|
};
|
|
181
|
+
/** 편집 화면의 채점 방식 · 답 블록 (퀴즈가 아닌 자료). getGrading을 useSave에 넘긴다 */
|
|
182
|
+
useGradingBlock(options?: GradingBlockOptions): {
|
|
183
|
+
element: Element;
|
|
184
|
+
readonly grader: GraderType;
|
|
185
|
+
getGrading(): Grading | string;
|
|
186
|
+
};
|
|
187
|
+
/** 완료 정책 화면 (LXP 설정 탭의 완료 정책 영역) */
|
|
188
|
+
useCompletion(options?: CompletionOptions): {
|
|
189
|
+
element: Element;
|
|
190
|
+
/** 지금 완료 정책을 불러온 뒤 끝남 */
|
|
191
|
+
ready: Promise<void>;
|
|
192
|
+
readonly policy: CompletionPolicy;
|
|
193
|
+
markDirty(): void;
|
|
194
|
+
readonly dirty: boolean;
|
|
195
|
+
};
|
|
90
196
|
}
|
|
91
197
|
|
|
92
198
|
export interface StartOptions {
|
|
@@ -113,9 +219,10 @@ export interface StartOptions {
|
|
|
113
219
|
search?: string;
|
|
114
220
|
/** 테스트용: location.hostname 대신 */
|
|
115
221
|
hostname?: string;
|
|
222
|
+
/** mock SDK일 때 화면 맨 위 안내 줄 (기본 true). 플랫폼에서는 늘 없음 */
|
|
116
223
|
status?: boolean;
|
|
117
224
|
}
|
|
118
225
|
|
|
119
226
|
export declare function start<C = Record<string, unknown>>(
|
|
120
|
-
options: StartOptions
|
|
227
|
+
options: StartOptions
|
|
121
228
|
): Promise<ContentApp<C>>;
|