@edpire/sdk 0.6.4 → 0.6.5

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.
@@ -0,0 +1 @@
1
+ var g=Object.create;var e=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var l=(b,a,c)=>a in b?e(b,a,{enumerable:!0,configurable:!0,writable:!0,value:c}):b[a]=c;var n=(b,a)=>()=>(a||b((a={exports:{}}).exports,a),a.exports);var m=(b,a,c,f)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of i(a))!k.call(b,d)&&d!==c&&e(b,d,{get:()=>a[d],enumerable:!(f=h(a,d))||f.enumerable});return b};var o=(b,a,c)=>(c=b!=null?g(j(b)):{},m(a||!b||!b.__esModule?e(c,"default",{value:b,enumerable:!0}):c,b));var p=(b,a,c)=>l(b,typeof a!="symbol"?a+"":a,c);export{n as a,o as b,p as c};
package/dist/client.d.mts CHANGED
@@ -35,7 +35,16 @@ interface StoredAnswer {
35
35
  declare class EdpireError extends Error {
36
36
  /** HTTP status code from the API response. */
37
37
  status: number;
38
- constructor(status: number, message: string);
38
+ /**
39
+ * Seconds to wait before retrying, from the `Retry-After` response header.
40
+ * Present on `429` responses; `undefined` otherwise.
41
+ *
42
+ * Honour this instead of a fixed backoff curve: the per-question `/check`
43
+ * limiter uses a one-hour window, so this can be as high as 3600, and an
44
+ * exponential backoff capped at 30s will simply 429 again until it gives up.
45
+ */
46
+ retryAfter?: number;
47
+ constructor(status: number, message: string, retryAfter?: number);
39
48
  }
40
49
  interface EdpireClientOptions {
41
50
  /** Your Edpire API key (starts with `edp_live_`). Store server-side only. */
@@ -50,10 +59,17 @@ interface AssessmentSummary {
50
59
  id: string;
51
60
  title: string;
52
61
  description: string | null;
53
- type: string;
62
+ /**
63
+ * Free-form label (max 80 chars), set by the author. Replaces the old
64
+ * `type: "quiz" | "exam" | "practice"` enum, which the API never returned.
65
+ */
66
+ category: string | null;
54
67
  status: string;
55
68
  share_code: string | null;
56
69
  settings: Record<string, unknown>;
70
+ /** Sum of answer-key max scores. Use this to normalize scores, not the sum of `points`. */
71
+ max_score?: number;
72
+ /** Present on the list endpoint only, not on a single-assessment fetch. */
57
73
  exercise_count?: number;
58
74
  created_at: string;
59
75
  updated_at: string;
@@ -123,6 +139,13 @@ interface GradeResult {
123
139
  passed: boolean;
124
140
  passing_score_percent: number;
125
141
  attempt_number: number;
142
+ /**
143
+ * True when the assessment contains open-response questions awaiting a teacher.
144
+ * `score`, `percentage` and `passed` are then PROVISIONAL — they cover only the
145
+ * auto-graded questions. Do not store or display them as a final grade; wait for
146
+ * the `submission.grading.completed` webhook.
147
+ */
148
+ awaiting_manual_grading: boolean;
126
149
  exercise_results: Array<{
127
150
  exercise_id: string;
128
151
  total_score: number;
@@ -183,13 +206,22 @@ interface Submission {
183
206
  max_score: number;
184
207
  percentage: number;
185
208
  passed: boolean | null;
209
+ /**
210
+ * False while open-response answers still await a teacher. `score`, `percentage`
211
+ * and `passed` are provisional until this is true.
212
+ */
213
+ is_fully_graded: boolean;
186
214
  started_at: string;
187
215
  submitted_at: string | null;
188
216
  graded_at: string | null;
217
+ /** Consumer metadata echoed back from submit. Single-submission fetch only. */
218
+ meta?: Record<string, unknown> | null;
189
219
  question_results?: Array<{
190
220
  question_id: string;
191
221
  sequence_number: number;
192
222
  points: number;
223
+ /** Times the learner changed this answer. Requires recording `answer_change` events. */
224
+ change_count: number;
193
225
  result: unknown;
194
226
  }>;
195
227
  }
@@ -523,8 +555,17 @@ declare function createEdpireTokenHandler(opts: EdpireTokenHandlerOptions): (req
523
555
  * const app = express()
524
556
  * app.post("/api/edpire/token", toNodeHandler(createEdpireTokenHandler({
525
557
  * apiKey: process.env.EDPIRE_API_KEY!,
526
- * resolveLearner: (req) => req.session?.userId ?? null,
558
+ * // NOTE: `req` here is a Web-standard Request rebuilt from the Node request.
559
+ * // Express extras like `req.session` and `req.cookies` are NOT carried over —
560
+ * // read what you need from headers instead, or it returns null and 401s every learner.
561
+ * resolveLearner: async (req) => {
562
+ * const cookie = req.headers.get("cookie") ?? ""
563
+ * return await getUserIdFromCookie(cookie) // your own session lookup
564
+ * },
527
565
  * })))
566
+ *
567
+ * // Mount this route BEFORE any body parser (express.json() etc.). The handler
568
+ * // reads the request stream itself; if a parser already drained it, it hangs.
528
569
  * ```
529
570
  *
530
571
  * @example Vite dev middleware
package/dist/client.mjs CHANGED
@@ -15,12 +15,19 @@ function buildSubmitPayload(stored) {
15
15
 
16
16
  // src/client.ts
17
17
  var EdpireError = class extends Error {
18
- constructor(status, message) {
18
+ constructor(status, message, retryAfter) {
19
19
  super(message);
20
20
  this.name = "EdpireError";
21
21
  this.status = status;
22
+ this.retryAfter = retryAfter;
22
23
  }
23
24
  };
25
+ function parseRetryAfter(res) {
26
+ const raw = res.headers.get("retry-after");
27
+ if (!raw) return void 0;
28
+ const seconds = Number(raw);
29
+ return Number.isFinite(seconds) && seconds >= 0 ? seconds : void 0;
30
+ }
24
31
  var EdpireClient = class {
25
32
  constructor(options) {
26
33
  this.apiKey = options.apiKey;
@@ -40,7 +47,7 @@ var EdpireClient = class {
40
47
  });
41
48
  const json = await res.json();
42
49
  if (!res.ok || json.error) {
43
- throw new EdpireError(res.status, json.error?.message ?? `HTTP ${res.status}`);
50
+ throw new EdpireError(res.status, json.error?.message ?? `HTTP ${res.status}`, parseRetryAfter(res));
44
51
  }
45
52
  return json.data;
46
53
  }
@@ -52,7 +59,7 @@ var EdpireClient = class {
52
59
  });
53
60
  const json = await res.json();
54
61
  if (!res.ok || json.error) {
55
- throw new EdpireError(res.status, json.error?.message ?? `HTTP ${res.status}`);
62
+ throw new EdpireError(res.status, json.error?.message ?? `HTTP ${res.status}`, parseRetryAfter(res));
56
63
  }
57
64
  return {
58
65
  items: json.data,
@@ -186,10 +193,13 @@ var EdpireClient = class {
186
193
  */
187
194
  async getLearnerResults(learnerRef, params) {
188
195
  const query = new URLSearchParams();
196
+ query.set("learner_ref", learnerRef);
189
197
  if (params?.page) query.set("page", String(params.page));
190
198
  if (params?.limit) query.set("limit", String(params.limit));
191
- const qs = query.toString();
192
- return this.requestPaginated("GET", `/learners/${learnerRef}/results${qs ? `?${qs}` : ""}`);
199
+ return this.requestPaginated(
200
+ "GET",
201
+ `/learners/${encodeURIComponent(learnerRef)}/results?${query.toString()}`
202
+ );
193
203
  }
194
204
  // ── Collections ────────────────────────────────────────────────────────
195
205
  /**
@@ -0,0 +1,11 @@
1
+ import"./chunk-76CZ6Z7T.mjs";function ue(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function Le(e){if(Array.isArray(e))return e}function Ce(e,r,t){return(r=Ne(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function Re(e,r){var t=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(t!=null){var n,o,i,c,l=[],s=!0,d=!1;try{if(i=(t=t.call(e)).next,r!==0)for(;!(s=(n=i.call(t)).done)&&(l.push(n.value),l.length!==r);s=!0);}catch(M){d=!0,o=M}finally{try{if(!s&&t.return!=null&&(c=t.return(),Object(c)!==c))return}finally{if(d)throw o}}return l}}function De(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function le(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),t.push.apply(t,n)}return t}function ee(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?le(Object(t),!0).forEach(function(n){Ce(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):le(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function se(e,r){if(e==null)return{};var t,n,o=Ve(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function Ve(e,r){if(e==null)return{};var t={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(r.indexOf(n)!==-1)continue;t[n]=e[n]}return t}function fe(e,r){return Le(e)||Re(e,r)||ze(e,r)||De()}function We(e,r){if(typeof e!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,r);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function Ne(e){var r=We(e,"string");return typeof r=="symbol"?r:r+""}function ze(e,r){if(e){if(typeof e=="string")return ue(e,r);var t={}.toString.call(e).slice(8,-1);return t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set"?Array.from(e):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ue(e,r):void 0}}function Ue(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function de(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),t.push.apply(t,n)}return t}function pe(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?de(Object(t),!0).forEach(function(n){Ue(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):de(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function _e(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return function(n){return r.reduceRight(function(o,i){return i(o)},n)}}function R(e){return function r(){for(var t=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var c=arguments.length,l=new Array(c),s=0;s<c;s++)l[s]=arguments[s];return r.apply(t,[].concat(o,l))}}}function _(e){return{}.toString.call(e).includes("Object")}function qe(e){return!Object.keys(e).length}function D(e){return typeof e=="function"}function Fe(e,r){return Object.prototype.hasOwnProperty.call(e,r)}function He(e,r){return _(r)||S("changeType"),Object.keys(r).some(function(t){return!Fe(e,t)})&&S("changeField"),r}function $e(e){D(e)||S("selectorType")}function Ke(e){D(e)||_(e)||S("handlerType"),_(e)&&Object.values(e).some(function(r){return!D(r)})&&S("handlersType")}function Be(e){e||S("initialIsRequired"),_(e)||S("initialType"),qe(e)&&S("initialContent")}function ke(e,r){throw new Error(e[r]||e.default)}var Ge={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},S=R(ke)(Ge),U={changes:He,selector:$e,handler:Ke,initial:Be};function Ye(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};U.initial(e),U.handler(r);var t={current:e},n=R(Xe)(t,r),o=R(Qe)(t),i=R(U.changes)(e),c=R(Je)(t);function l(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(M){return M};return U.selector(d),d(t.current)}function s(d){_e(n,o,i,c)(d)}return[l,s]}function Je(e,r){return D(r)?r(e.current):r}function Qe(e,r){return e.current=pe(pe({},e.current),r),r}function Xe(e,r,t){return D(r)?r(e.current):Object.keys(t).forEach(function(n){var o;return(o=r[n])===null||o===void 0?void 0:o.call(r,e.current[n])}),t}var Ze={create:Ye},me=Ze;var ge={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function he(e){return function r(){for(var t=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var c=arguments.length,l=new Array(c),s=0;s<c;s++)l[s]=arguments[s];return r.apply(t,[].concat(o,l))}}}function ve(e){return{}.toString.call(e).includes("Object")}function er(e){return e||be("configIsRequired"),ve(e)||be("configType"),e.urls?(rr(),{paths:{vs:e.urls.monacoBase}}):e}function rr(){console.warn(ye.deprecation)}function tr(e,r){throw new Error(e[r]||e.default)}var ye={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
3
+ You are using deprecated way of configuration.
4
+
5
+ Instead of using
6
+ monaco.config({ urls: { monacoBase: '...' } })
7
+ use
8
+ monaco.config({ paths: { vs: '...' } })
9
+
10
+ For more please check the link https://github.com/suren-atoyan/monaco-loader#config
11
+ `},be=he(tr)(ye),we={config:er};var Oe=function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return function(o){return t.reduceRight(function(i,c){return c(i)},o)}};function re(e,r){return Object.keys(r).forEach(function(t){r[t]instanceof Object&&e[t]&&Object.assign(r[t],re(e[t],r[t]))}),ee(ee({},e),r)}var nr={type:"cancelation",msg:"operation is manually canceled"};function q(e){var r=!1,t=new Promise(function(n,o){e.then(function(i){return r?o(nr):n(i)}),e.catch(o)});return t.cancel=function(){return r=!0},t}var or=["monaco"],ir=me.create({config:ge,isInitialized:!1,resolve:null,reject:null,monaco:null}),je=fe(ir,2),V=je[0],F=je[1];function ar(e){var r=we.config(e),t=r.monaco,n=se(r,or);F(function(o){return{config:re(o.config,n),monaco:t}})}function cr(){var e=V(function(r){var t=r.monaco,n=r.isInitialized,o=r.resolve;return{monaco:t,isInitialized:n,resolve:o}});if(!e.isInitialized){if(F({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),q(te);if(window.monaco&&window.monaco.editor)return Me(window.monaco),e.resolve(window.monaco),q(te);Oe(ur,sr)(fr)}return q(te)}function ur(e){return document.body.appendChild(e)}function lr(e){var r=document.createElement("script");return e&&(r.src=e),r}function sr(e){var r=V(function(n){var o=n.config,i=n.reject;return{config:o,reject:i}}),t=lr("".concat(r.config.paths.vs,"/loader.js"));return t.onload=function(){return e()},t.onerror=r.reject,t}function fr(){var e=V(function(t){var n=t.config,o=t.resolve,i=t.reject;return{config:n,resolve:o,reject:i}}),r=window.require;r.config(e.config),r(["vs/editor/editor.main"],function(t){var n=t.m||t;Me(n),e.resolve(n)},function(t){e.reject(t)})}function Me(e){V().monaco||F({monaco:e})}function dr(){return V(function(e){var r=e.monaco;return r})}var te=new Promise(function(e,r){return F({resolve:e,reject:r})}),O={config:ar,init:cr,__getMonacoInstance:dr};import{memo as pr}from"react";import mr,{useState as Pe,useRef as T,useCallback as Se,useEffect as Ee}from"react";import{memo as gr}from"react";import ne from"react";import vr from"react";import{useEffect as Sr}from"react";import{useEffect as Tr,useRef as Ir}from"react";import{useState as Dr}from"react";import{memo as Wr}from"react";import Nr,{useState as Te,useEffect as H,useRef as j,useCallback as zr}from"react";import{useEffect as Ur,useRef as _r}from"react";var hr={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},oe=hr,br={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},yr=br;function wr({children:e}){return vr.createElement("div",{style:yr.container},e)}var Or=wr,jr=Or;function Mr({width:e,height:r,isEditorReady:t,loading:n,_ref:o,className:i,wrapperProps:c}){return ne.createElement("section",{style:{...oe.wrapper,width:e,height:r},...c},!t&&ne.createElement(jr,null,n),ne.createElement("div",{ref:o,style:{...oe.fullWidth,...!t&&oe.hide},className:i}))}var Pr=Mr,Ie=gr(Pr);function Er(e){Sr(e,[])}var ie=Er;function Ar(e,r,t=!0){let n=Ir(!0);Tr(n.current||!t?()=>{n.current=!1}:e,r)}var y=Ar;function W(){}function I(e,r,t,n){return xr(e,n)||Lr(e,r,t,n)}function xr(e,r){return e.editor.getModel(Ae(e,r))}function Lr(e,r,t,n){return e.editor.createModel(r,t,n?Ae(e,n):void 0)}function Ae(e,r){return e.Uri.parse(r)}function Cr({original:e,modified:r,language:t,originalLanguage:n,modifiedLanguage:o,originalModelPath:i,modifiedModelPath:c,keepCurrentOriginalModel:l=!1,keepCurrentModifiedModel:s=!1,theme:d="light",loading:M="Loading...",options:w={},height:K="100%",width:B="100%",className:k,wrapperProps:G={},beforeMount:Y=W,onMount:J=W}){let[b,A]=Pe(!1),[x,p]=Pe(!0),m=T(null),f=T(null),L=T(null),h=T(J),a=T(Y),E=T(!1);ie(()=>{let u=O.init();return u.then(g=>(f.current=g)&&p(!1)).catch(g=>g?.type!=="cancelation"&&console.error("Monaco initialization: error:",g)),()=>m.current?C():u.cancel()}),y(()=>{if(m.current&&f.current){let u=m.current.getOriginalEditor(),g=I(f.current,e||"",n||t||"text",i||"");g!==u.getModel()&&u.setModel(g)}},[i],b),y(()=>{if(m.current&&f.current){let u=m.current.getModifiedEditor(),g=I(f.current,r||"",o||t||"text",c||"");g!==u.getModel()&&u.setModel(g)}},[c],b),y(()=>{let u=m.current.getModifiedEditor();u.getOption(f.current.editor.EditorOption.readOnly)?u.setValue(r||""):r!==u.getValue()&&(u.executeEdits("",[{range:u.getModel().getFullModelRange(),text:r||"",forceMoveMarkers:!0}]),u.pushUndoStop())},[r],b),y(()=>{m.current?.getModel()?.original.setValue(e||"")},[e],b),y(()=>{let{original:u,modified:g}=m.current.getModel();f.current.editor.setModelLanguage(u,n||t||"text"),f.current.editor.setModelLanguage(g,o||t||"text")},[t,n,o],b),y(()=>{f.current?.editor.setTheme(d)},[d],b),y(()=>{m.current?.updateOptions(w)},[w],b);let N=Se(()=>{if(!f.current)return;a.current(f.current);let u=I(f.current,e||"",n||t||"text",i||""),g=I(f.current,r||"",o||t||"text",c||"");m.current?.setModel({original:u,modified:g})},[t,r,o,e,n,i,c]),z=Se(()=>{!E.current&&L.current&&(m.current=f.current.editor.createDiffEditor(L.current,{automaticLayout:!0,...w}),N(),f.current?.editor.setTheme(d),A(!0),E.current=!0)},[w,d,N]);Ee(()=>{b&&h.current(m.current,f.current)},[b]),Ee(()=>{!x&&!b&&z()},[x,b,z]);function C(){let u=m.current?.getModel();l||u?.original?.dispose(),s||u?.modified?.dispose(),m.current?.dispose()}return mr.createElement(Ie,{width:B,height:K,isEditorReady:b,loading:M,_ref:L,className:k,wrapperProps:G})}var Rr=Cr,Mt=pr(Rr);function Vr(){let[e,r]=Dr(O.__getMonacoInstance());return ie(()=>{let t;return e||(t=O.init(),t.then(n=>{r(n)})),()=>t?.cancel()}),e}var Et=Vr;function qr(e){let r=_r();return Ur(()=>{r.current=e},[e]),r.current}var Fr=qr,$=new Map;function Hr({defaultValue:e,defaultLanguage:r,defaultPath:t,value:n,language:o,path:i,theme:c="light",line:l,loading:s="Loading...",options:d={},overrideServices:M={},saveViewState:w=!0,keepCurrentModel:K=!1,width:B="100%",height:k="100%",className:G,wrapperProps:Y={},beforeMount:J=W,onMount:b=W,onChange:A,onValidate:x=W}){let[p,m]=Te(!1),[f,L]=Te(!0),h=j(null),a=j(null),E=j(null),N=j(b),z=j(J),C=j(),u=j(n),g=Fr(i),ae=j(!1),Q=j(!1);ie(()=>{let v=O.init();return v.then(P=>(h.current=P)&&L(!1)).catch(P=>P?.type!=="cancelation"&&console.error("Monaco initialization: error:",P)),()=>a.current?xe():v.cancel()}),y(()=>{let v=I(h.current,e||n||"",r||o||"",i||t||"");v!==a.current?.getModel()&&(w&&$.set(g,a.current?.saveViewState()),a.current?.setModel(v),w&&a.current?.restoreViewState($.get(i)))},[i],p),y(()=>{a.current?.updateOptions(d)},[d],p),y(()=>{!a.current||n===void 0||(a.current.getOption(h.current.editor.EditorOption.readOnly)?a.current.setValue(n):n!==a.current.getValue()&&(Q.current=!0,a.current.executeEdits("",[{range:a.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),a.current.pushUndoStop(),Q.current=!1))},[n],p),y(()=>{let v=a.current?.getModel();v&&o&&h.current?.editor.setModelLanguage(v,o)},[o],p),y(()=>{l!==void 0&&a.current?.revealLine(l)},[l],p),y(()=>{h.current?.editor.setTheme(c)},[c],p);let ce=zr(()=>{if(!(!E.current||!h.current)&&!ae.current){z.current(h.current);let v=i||t,P=I(h.current,n||e||"",r||o||"",v||"");a.current=h.current?.editor.create(E.current,{model:P,automaticLayout:!0,...d},M),w&&a.current.restoreViewState($.get(v)),h.current.editor.setTheme(c),l!==void 0&&a.current.revealLine(l),m(!0),ae.current=!0}},[e,r,t,n,o,i,d,M,w,c,l]);H(()=>{p&&N.current(a.current,h.current)},[p]),H(()=>{!f&&!p&&ce()},[f,p,ce]),u.current=n,H(()=>{p&&A&&(C.current?.dispose(),C.current=a.current?.onDidChangeModelContent(v=>{Q.current||A(a.current.getValue(),v)}))},[p,A]),H(()=>{if(p){let v=h.current.editor.onDidChangeMarkers(P=>{let X=a.current.getModel()?.uri;if(X&&P.find(Z=>Z.path===X.path)){let Z=h.current.editor.getModelMarkers({resource:X});x?.(Z)}});return()=>{v?.dispose()}}return()=>{}},[p,x]);function xe(){C.current?.dispose(),K?w&&$.set(i,a.current.saveViewState()):a.current.getModel()?.dispose(),a.current.dispose()}return Nr.createElement(Ie,{width:B,height:k,isEditorReady:p,loading:s,_ref:E,className:G,wrapperProps:Y})}var $r=Hr,Kr=Wr($r),Lt=Kr;export{Mt as DiffEditor,Kr as Editor,Lt as default,O as loader,Et as useMonaco};