craft-library 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/craft.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! Sara Lobo Library · liquid glass nav bar, bursting heart, magnetic icon, iridescent card, glass piggy bank, magic sphere, sweep, panorama, map pin, token wheel, thumbs reaction · <glass-nav>, <like-button>, <magnetic-icon>, <iridescent-card>, <piggy-bank>, <magic-sphere>, <sweep-sphere>, <panorama-reel>, <map-pin>, <token-wheel>, <thumbs-reaction> · https://saralobolibrary.com · MIT */
1
+ /*! Sara Lobo Library · liquid glass nav bar, bursting heart, magnetic icon, iridescent card, glass piggy bank, magic sphere, sweep, panorama, map pin, token wheel, thumbs reaction, fold orb, leporello · <glass-nav>, <like-button>, <magnetic-icon>, <iridescent-card>, <piggy-bank>, <magic-sphere>, <sweep-sphere>, <panorama-reel>, <map-pin>, <token-wheel>, <thumbs-reaction>, <fold-orb>, <leporello-book> · https://saralobolibrary.com · MIT */
2
2
  (() => {
3
3
  // dist/style.js
4
4
  var done = /* @__PURE__ */ new Set();
@@ -2972,7 +2972,7 @@ void main() {
2972
2972
  show();
2973
2973
  }
2974
2974
  set(o.value);
2975
- var api6 = {
2975
+ var api8 = {
2976
2976
  set,
2977
2977
  // the reaction again, as a tap would play it (from rest, so it can be shown on a loop)
2978
2978
  play: function(v) {
@@ -2995,7 +2995,7 @@ void main() {
2995
2995
  root.__joinha = null;
2996
2996
  }
2997
2997
  };
2998
- return root.__joinha = api6;
2998
+ return root.__joinha = api8;
2999
2999
  }
3000
3000
  function scan() {
3001
3001
  Array.prototype.forEach.call(document.querySelectorAll(".joinha"), function(r) {
@@ -3025,6 +3025,1419 @@ void main() {
3025
3025
  } };
3026
3026
  }
3027
3027
 
3028
+ // dist/orb.js
3029
+ var CSS7 = "/* Orb \xB7 Sara Lobo Library\n orb.js draws the orb and its ground on a canvas that fills the element. Give the element a size (it is a block,\n 100% wide; the height is yours to set, or --orb-height). */\n\n.orb {\n position: relative;\n display: block;\n width: 100%;\n height: var(--orb-height, 420px);\n overflow: hidden;\n}\n.orb-canvas {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n display: block;\n}\n";
3030
+ var api6;
3031
+ function engine6() {
3032
+ if (api6) return api6;
3033
+ const window2 = {};
3034
+ (function() {
3035
+ "use strict";
3036
+ var TONES = {
3037
+ steel: { top: [0.215, 0.22, 0.232], bot: [0.062, 0.064, 0.07], floor: [0.13, 0.135, 0.145], shadow: 0, vig: 0.32, ink: 0, disp: 0.65, halo: 0.75, orb: [0.84, 0.86, 0.9], rim: [1, 1, 1], haloC: [0.42, 0.43, 0.47] },
3038
+ mist: { top: [0.948, 0.95, 0.958], bot: [0.795, 0.8, 0.815], floor: [0.05, 0.05, 0.055], shadow: 0.17, vig: 0.12, ink: 1, disp: 1, halo: 0, orb: [0.66, 0.7, 0.78], rim: [1, 1, 1], haloC: [0, 0, 0] },
3039
+ blue: { top: [8e-3, 0.016, 0.046], bot: [3e-3, 6e-3, 0.018], floor: [0.03, 0.14, 0.58], shadow: 0, vig: 0, ink: 0, disp: 1, halo: 1, orb: [0.46, 0.64, 1], rim: [0.5, 0.74, 1], haloC: [0.1, 0.3, 1] }
3040
+ };
3041
+ var STATES = { idle: 1, typing: 1, listening: 1, thinking: 1, speaking: 1 };
3042
+ var VS2 = "attribute vec2 p;void main(){gl_Position=vec4(p,0.0,1.0);}";
3043
+ var FS2 = [
3044
+ "precision highp float;",
3045
+ "uniform vec2 uRes,uC;uniform float uR;",
3046
+ "uniform vec3 uTop,uBot,uFloor;uniform float uShadow,uVig;",
3047
+ "uniform float uT,uAttend,uLevel,uPulse,uBlur,uPhase,uFill,uSpeak,uInk,uDispK,uHaloK;",
3048
+ "uniform vec3 uBands,uGaze,uLight,uOrbCol,uRimCol,uHaloCol;uniform mat3 uRot;",
3049
+ "float sq(float x){return x*x;}",
3050
+ "float hash12(vec2 p){vec3 p3=fract(vec3(p.xyx)*.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}",
3051
+ // the ground: a vertical gradient, a soft floor light, a vignette and, on light grounds, a contact shadow
3052
+ "vec3 ground(vec2 f){vec2 uv=f/uRes;vec3 c=mix(uBot,uTop,smoothstep(0.0,0.85,uv.y));float bx=uv.x-0.5;",
3053
+ " c+=uFloor*exp(-sq(uv.y/0.2))*(0.55+0.45*exp(-sq(bx/0.45)));c*=1.0-uVig*sq(bx*1.5);",
3054
+ " vec2 q=(f-uC)/uR;c*=1.0-uShadow*exp(-sq((q.y+1.5)/0.17)-sq(q.x/0.72));return c;}",
3055
+ "vec3 tm(vec3 x){return 1.0-exp(-max(x,0.0)*1.1);}",
3056
+ "float Fp(float f,float S){return sign(f)*(1.0-exp(-S*abs(f)))/S;}",
3057
+ "mat2 rot(float a){float c=cos(a),s=sin(a);return mat2(c,-s,s,c);}",
3058
+ // the two folds: the sphere's skin turned into itself, twisted along an axis
3059
+ "float sheetA(vec3 q){vec2 xz=rot(2.3*q.y+uPhase)*q.xz;vec3 r=vec3(xz.x,q.y,xz.y);",
3060
+ " float rr=0.80+0.05*sin(3.0*r.y+uT*0.4)+0.06*uBands.x*uLevel;",
3061
+ " return length(r-vec3(0.46+0.14*sin(2.2*q.y+0.6),0.0,0.0))-rr+uLevel*0.035*sin(11.0*r.y-8.0*uT)*(0.4+uBands.y);}",
3062
+ "float sheetB(vec3 q){vec2 yz=rot(-2.0*q.x-0.7*uPhase+2.2)*q.yz;vec3 r=vec3(q.x,yz.x,yz.y);",
3063
+ " return length(r-vec3(-0.52,0.12+0.12*sin(2.0*q.x+1.4),0.0))-(0.76+0.04*sin(2.4*r.z+uT*0.3))+uLevel*0.03*sin(9.0*r.x+7.0*uT)*(0.4+uBands.z);}",
3064
+ "void main(){",
3065
+ " vec2 f=gl_FragCoord.xy;vec3 bg=ground(f);vec3 col=bg,light=vec3(0.0);vec2 p=(f-uC)/uR;",
3066
+ " if(dot(p,p)<9.0){",
3067
+ " const float K=0.3535534;vec3 ro=vec3(0.0,0.0,3.0),rd=normalize(vec3(p*K,-1.0));",
3068
+ " float rad=1.0+0.028*uLevel;float b=dot(ro,rd),c=dot(ro,ro)-rad*rad,h=b*b-c;",
3069
+ " float dmin=sqrt(max(dot(ro,ro)-b*b,0.0)),e=max(dmin-rad,0.0);",
3070
+ " light+=uHaloCol*uHaloK*(0.16*exp(-e*14.0)+0.06*exp(-e*3.2))*(0.6+0.9*uFill+0.8*uLevel+0.5*uAttend);",
3071
+ // the silhouette is blended over ~1.6 device pixels: never a stair-stepped cut
3072
+ " float ps=tan(asin(rad/3.0))/K,pl=length(p);float cov=smoothstep(ps+0.8/uR,ps-0.8/uR,pl);",
3073
+ " if(cov>0.0){",
3074
+ " float sh=sqrt(max(h,0.0)),t0=-b-sh,t1=-b+sh;vec3 n0=normalize(ro+rd*t0);",
3075
+ " float cosv=max(dot(n0,-rd),0.0),fres=1.0-cosv;float gl=max(dot(n0,uGaze),0.0),ll=max(dot(n0,uLight),0.0);",
3076
+ " float dl=max(ps-pl,0.0)/ps;float lip=0.55+0.45*smoothstep(0.0,0.016,dl);",
3077
+ " vec3 band=vec3(exp(-dl/0.030),exp(-dl/0.037),exp(-dl/0.046))*lip;",
3078
+ // march the folds; each step integrates the sheet glow exactly for a linear field, one offset per colour channel
3079
+ " const int N=44;float dt=(t1-t0)/float(N);float S=mix(56.0,11.0,uBlur),dsp=(0.016+0.085*uBlur)*uDispK;",
3080
+ " vec3 x=ro+rd*t0,q=uRot*x;float fa=sheetA(q),fb=sheetB(q);",
3081
+ " vec3 FA=vec3(Fp(fa+dsp,S),Fp(fa,S),Fp(fa-dsp,S)),FB=vec3(Fp(fb+dsp,S),Fp(fb,S),Fp(fb-dsp,S));",
3082
+ " float pfa=fa,pfb=fb;vec3 acc=vec3(0.0);",
3083
+ " for(int i=1;i<=N;i++){",
3084
+ " x=ro+rd*(t0+float(i)*dt);q=uRot*x;fa=sheetA(q);fb=sheetB(q);",
3085
+ " vec3 nFA=vec3(Fp(fa+dsp,S),Fp(fa,S),Fp(fa-dsp,S)),nFB=vec3(Fp(fb+dsp,S),Fp(fb,S),Fp(fb-dsp,S));",
3086
+ " float da=fa-pfa,db=fb-pfb;",
3087
+ " vec3 ia=abs(da)>1e-4?(nFA-FA)/da:exp(-S*abs(vec3(fa+dsp,fa,fa-dsp)));",
3088
+ " vec3 ib=abs(db)>1e-4?(nFB-FB)/db:exp(-S*abs(vec3(fb+dsp,fb,fb-dsp)));",
3089
+ " vec3 xn=x/rad;float lit=0.3+1.3*smoothstep(-0.3,1.0,dot(xn,uLight))+0.6*uAttend*smoothstep(0.0,1.0,dot(xn,uGaze));",
3090
+ " float ga=1.0-min(abs(da)/dt,1.0),gb=1.0-min(abs(db)/dt,1.0);",
3091
+ " float wa=mix(0.035,1.0,ga*ga*mix(1.0,0.3,uBlur)+uBlur*0.7),wb=mix(0.035,1.0,gb*gb*mix(1.0,0.3,uBlur)+uBlur*0.7);",
3092
+ " acc+=(ia*wa+0.75*ib*wb)*lit;FA=nFA;FB=nFB;pfa=fa;pfb=fb;",
3093
+ " }",
3094
+ " acc*=dt*S*0.11*(1.0+0.8*uLevel+0.35*uSpeak);float thick=t1-t0;",
3095
+ " if(uInk<0.5){",
3096
+ // a dark ground: the ball emits light
3097
+ " float rimW=0.14+3.2*ll*ll*ll+1.3*uAttend*gl*gl+1.4*uPulse*gl+0.9*uLevel;",
3098
+ " vec3 inner=(0.72*band+0.28*vec3(pow(fres,4.0),pow(fres,3.4),pow(fres,2.9)))*uRimCol*rimW*1.9;",
3099
+ " inner+=uOrbCol*0.09*pow(ll,3.0)*(0.3+0.7*fres);inner+=acc*uOrbCol+acc*acc*vec3(0.30,0.32,0.36);",
3100
+ " inner+=uOrbCol*thick*0.08*uFill;light+=inner*cov;col=bg*mix(1.0,exp(-thick*0.9),cov);",
3101
+ " }else{",
3102
+ // a light ground: clear glass refracting the ground, darker toward its edge, folds read as ink, a white crescent
3103
+ " float k=0.55*fres+0.10;vec2 off=-n0.xy*uR*k;float dk=0.05*uDispK;",
3104
+ " vec3 tr=vec3(ground(f+off*(1.0-dk)).r,ground(f+off).g,ground(f+off*(1.0+dk)).b);",
3105
+ " tr*=mix(vec3(1.0),uOrbCol,clamp(thick*0.32,0.0,0.6));tr=mix(tr,vec3(0.96),uFill*0.5*smoothstep(0.0,1.2,thick));",
3106
+ " tr*=1.0-0.45*band;tr*=1.0-clamp(acc*(0.40+0.3*uLevel),0.0,0.85);",
3107
+ " float spec=(0.6*band.g+0.4*pow(fres,3.0))*pow(ll,3.0)*(1.0+1.5*uAttend*gl*gl+uPulse*gl)*smoothstep(0.004,0.02,dl);",
3108
+ " tr+=vec3(1.0)*spec*0.95;tr+=clamp(acc*acc*0.05,0.0,0.5);col=mix(bg,tr,cov);",
3109
+ " }",
3110
+ " }",
3111
+ " }",
3112
+ " gl_FragColor=vec4(col+tm(light)+(hash12(f)-0.5)*(1.5/255.0),1.0);",
3113
+ "}"
3114
+ ].join("\n");
3115
+ function Spring(x, k, zeta) {
3116
+ this.x = x;
3117
+ this.v = 0;
3118
+ this.target = x;
3119
+ this.k = k;
3120
+ this.c = 2 * zeta * Math.sqrt(k);
3121
+ }
3122
+ Spring.prototype.step = function(dt) {
3123
+ var n = Math.max(1, Math.ceil(dt * 240)), h = dt / n;
3124
+ for (var i = 0; i < n; i++) {
3125
+ this.v += (-this.k * (this.x - this.target) - this.c * this.v) * h;
3126
+ this.x += this.v * h;
3127
+ }
3128
+ return this.x;
3129
+ };
3130
+ function damp2(x, t, l, dt) {
3131
+ return x + (t - x) * (1 - Math.exp(-l * dt));
3132
+ }
3133
+ function clamp2(x, a, b) {
3134
+ return Math.min(b, Math.max(a, x));
3135
+ }
3136
+ function smooth(a, b, x) {
3137
+ var t = clamp2((x - a) / (b - a), 0, 1);
3138
+ return t * t * (3 - 2 * t);
3139
+ }
3140
+ function hash1(n) {
3141
+ var s = Math.sin(n * 127.1 + 311.7) * 43758.5453;
3142
+ return s - Math.floor(s);
3143
+ }
3144
+ function vnoise(x) {
3145
+ var i = Math.floor(x), f = x - i, u = f * f * (3 - 2 * f);
3146
+ return hash1(i) * (1 - u) + hash1(i + 1) * u;
3147
+ }
3148
+ function norm(v) {
3149
+ var n = Math.hypot(v[0], v[1], v[2]) || 1;
3150
+ v[0] /= n;
3151
+ v[1] /= n;
3152
+ v[2] /= n;
3153
+ return v;
3154
+ }
3155
+ function frameTo(g, out) {
3156
+ var z = [0, 0, 1], d = g[2];
3157
+ if (d > 0.99999) {
3158
+ out.set([1, 0, 0, 0, 1, 0, 0, 0, 1]);
3159
+ return;
3160
+ }
3161
+ var ax = [-g[1], g[0], 0];
3162
+ norm(ax);
3163
+ var a = Math.acos(clamp2(d, -1, 1)), c = Math.cos(-a), s = Math.sin(-a), t = 1 - c, x = ax[0], y = ax[1], w = ax[2];
3164
+ out[0] = t * x * x + c;
3165
+ out[3] = t * x * y - s * w;
3166
+ out[6] = t * x * w + s * y;
3167
+ out[1] = t * x * y + s * w;
3168
+ out[4] = t * y * y + c;
3169
+ out[7] = t * y * w - s * x;
3170
+ out[2] = t * x * w - s * y;
3171
+ out[5] = t * y * w + s * x;
3172
+ out[8] = t * w * w + c;
3173
+ }
3174
+ function simVoice(t, ai, bands) {
3175
+ var rate = ai ? 3.4 : 4.2;
3176
+ var syl = Math.pow(Math.abs(Math.sin(Math.PI * rate * t + 2.6 * vnoise(t * 0.8 + (ai ? 40 : 0)))), ai ? 1.3 : 1.8);
3177
+ var gate = ai ? smooth(0.18, 0.4, vnoise(t * 0.55 + 7)) : smooth(0.32, 0.52, vnoise(t * 0.7 + 11));
3178
+ var lv = syl * gate * (0.5 + 0.5 * vnoise(t * 2.1 + 5));
3179
+ bands[0] = lv * (0.75 + 0.5 * vnoise(t * 6.5 + 1));
3180
+ bands[1] = lv * (0.45 + 0.5 * vnoise(t * 6.5 + 9));
3181
+ bands[2] = lv * (0.2 + 0.4 * vnoise(t * 6.5 + 17));
3182
+ return lv;
3183
+ }
3184
+ var reduceMQ = typeof matchMedia === "function" ? matchMedia("(prefers-reduced-motion: reduce)") : null;
3185
+ var measureCtx = null;
3186
+ function orb(host, o) {
3187
+ o = o || {};
3188
+ var tone = TONES[o.tone] ? o.tone : "steel", state = STATES[o.state] ? o.state : "idle";
3189
+ host.classList.add("orb");
3190
+ if (!host.hasAttribute("role")) host.setAttribute("role", "img");
3191
+ if (!host.hasAttribute("aria-label")) host.setAttribute("aria-label", o.label || "AI assistant");
3192
+ var canvas = document.createElement("canvas");
3193
+ canvas.className = "orb-canvas";
3194
+ canvas.setAttribute("aria-hidden", "true");
3195
+ host.appendChild(canvas);
3196
+ var gl = canvas.getContext("webgl", { antialias: false, alpha: false, depth: false, stencil: false, premultipliedAlpha: false, powerPreference: "high-performance" });
3197
+ var noop = function() {
3198
+ return api8;
3199
+ };
3200
+ var api8 = { set: noop, tone: noop, level: noop, pulse: noop, lookAt: noop, follow: noop, destroy: function() {
3201
+ canvas.remove();
3202
+ } };
3203
+ if (!gl) {
3204
+ host.classList.add("orb-nogl");
3205
+ return api8;
3206
+ }
3207
+ function sh(type, src) {
3208
+ var s = gl.createShader(type);
3209
+ gl.shaderSource(s, src);
3210
+ gl.compileShader(s);
3211
+ return s;
3212
+ }
3213
+ var prog = gl.createProgram();
3214
+ gl.attachShader(prog, sh(gl.VERTEX_SHADER, VS2));
3215
+ gl.attachShader(prog, sh(gl.FRAGMENT_SHADER, FS2));
3216
+ gl.bindAttribLocation(prog, 0, "p");
3217
+ gl.linkProgram(prog);
3218
+ if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) {
3219
+ host.classList.add("orb-nogl");
3220
+ return api8;
3221
+ }
3222
+ gl.useProgram(prog);
3223
+ var buf = gl.createBuffer();
3224
+ gl.bindBuffer(gl.ARRAY_BUFFER, buf);
3225
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);
3226
+ gl.enableVertexAttribArray(0);
3227
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
3228
+ var U = {};
3229
+ [
3230
+ "uRes",
3231
+ "uC",
3232
+ "uR",
3233
+ "uTop",
3234
+ "uBot",
3235
+ "uFloor",
3236
+ "uShadow",
3237
+ "uVig",
3238
+ "uT",
3239
+ "uAttend",
3240
+ "uLevel",
3241
+ "uPulse",
3242
+ "uBlur",
3243
+ "uPhase",
3244
+ "uFill",
3245
+ "uSpeak",
3246
+ "uInk",
3247
+ "uDispK",
3248
+ "uHaloK",
3249
+ "uBands",
3250
+ "uGaze",
3251
+ "uLight",
3252
+ "uOrbCol",
3253
+ "uRimCol",
3254
+ "uHaloCol",
3255
+ "uRot"
3256
+ ].forEach(function(n) {
3257
+ U[n] = gl.getUniformLocation(prog, n);
3258
+ });
3259
+ var W = 0, H = 0, dpr = 1, cx = 0, cy = 0, R = 1;
3260
+ var t = 0, prev = 0, raf = 0, onScreen = true, dead = false;
3261
+ var gx = new Spring(0, 26, 1), gy = new Spring(0, 26, 1), gz = new Spring(1, 26, 1);
3262
+ var attend = new Spring(0, 46, 1), pulseS = new Spring(0, 150, 1), think = new Spring(0, 22, 1), speak = new Spring(0, 34, 1);
3263
+ var blur = new Spring(0.3, 24, 1), fill = new Spring(0, 22, 1);
3264
+ var phase = 0, pvel = 0.14, kick = 0, lastKey = -99, level = 0, bands = [0, 0, 0], rawB = [0, 0, 0];
3265
+ var gaze = [0, 0, 1], light = norm([0.62, 0.55, 0.35]), lightT = [0, 0, 0], rotM = new Float32Array(9);
3266
+ var cur = JSON.parse(JSON.stringify(TONES[tone])), want = TONES[tone];
3267
+ var extLevel = null, followEl = null, focused = false, look = null;
3268
+ var caret = { x: 0, y: 0 }, sim = { x: -1.7, next: 0.45, pause: 0 };
3269
+ var mic = { on: false, an: null, ctx: null, stream: null, td: null, fd: null, asked: false };
3270
+ var SPEED = { idle: 0.14, typing: 0.2, listening: 0.32, thinking: 1.15, speaking: 0.42 };
3271
+ function size() {
3272
+ var r = host.getBoundingClientRect();
3273
+ dpr = Math.min(typeof devicePixelRatio === "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, 2);
3274
+ W = Math.max(1, Math.round(r.width * dpr));
3275
+ H = Math.max(1, Math.round(r.height * dpr));
3276
+ if (canvas.width !== W || canvas.height !== H) {
3277
+ canvas.width = W;
3278
+ canvas.height = H;
3279
+ }
3280
+ cx = r.width / 2;
3281
+ cy = r.height * 0.46;
3282
+ R = Math.max(8, Math.min(r.width, r.height) * 0.3);
3283
+ }
3284
+ var ro = typeof ResizeObserver === "function" ? new ResizeObserver(size) : null;
3285
+ if (ro) ro.observe(host);
3286
+ else addEventListener("resize", size);
3287
+ var io = typeof IntersectionObserver === "function" ? new IntersectionObserver(function(es) {
3288
+ onScreen = es[0].isIntersecting;
3289
+ }, { rootMargin: "80px" }) : null;
3290
+ if (io) io.observe(host);
3291
+ size();
3292
+ function key() {
3293
+ pulseS.v += 15;
3294
+ kick += 0.55;
3295
+ lastKey = t;
3296
+ }
3297
+ function mode() {
3298
+ return followEl && focused ? "typing" : state;
3299
+ }
3300
+ function readCaret() {
3301
+ if (!followEl) return;
3302
+ var r = host.getBoundingClientRect(), fr = followEl.getBoundingClientRect(), cs = getComputedStyle(followEl);
3303
+ measureCtx = measureCtx || document.createElement("canvas").getContext("2d");
3304
+ measureCtx.font = cs.fontWeight + " " + cs.fontSize + " " + cs.fontFamily;
3305
+ var v = followEl.value || "", at = followEl.selectionStart == null ? v.length : followEl.selectionStart;
3306
+ var w = measureCtx.measureText(v.slice(0, at)).width - (followEl.scrollLeft || 0) + (parseFloat(cs.paddingLeft) || 0);
3307
+ caret.x = fr.left - r.left + clamp2(w, 0, fr.width);
3308
+ caret.y = fr.top - r.top + fr.height / 2;
3309
+ }
3310
+ function onInput() {
3311
+ readCaret();
3312
+ key();
3313
+ }
3314
+ function onFocus() {
3315
+ focused = true;
3316
+ readCaret();
3317
+ }
3318
+ function onBlur() {
3319
+ focused = false;
3320
+ }
3321
+ function startMic() {
3322
+ if (mic.asked || !navigator.mediaDevices) return;
3323
+ mic.asked = true;
3324
+ navigator.mediaDevices.getUserMedia({ audio: { echoCancellation: true, noiseSuppression: true } }).then(function(s) {
3325
+ if (dead) {
3326
+ s.getTracks().forEach(function(k) {
3327
+ k.stop();
3328
+ });
3329
+ return;
3330
+ }
3331
+ var C = new (typeof AudioContext === "function" ? AudioContext : webkitAudioContext)(), an = C.createAnalyser();
3332
+ an.fftSize = 1024;
3333
+ an.smoothingTimeConstant = 0.5;
3334
+ C.createMediaStreamSource(s).connect(an);
3335
+ mic.on = true;
3336
+ mic.ctx = C;
3337
+ mic.an = an;
3338
+ mic.stream = s;
3339
+ mic.td = new Float32Array(an.fftSize);
3340
+ mic.fd = new Uint8Array(an.frequencyBinCount);
3341
+ }).catch(function() {
3342
+ });
3343
+ }
3344
+ function stopMic() {
3345
+ if (mic.stream) mic.stream.getTracks().forEach(function(k) {
3346
+ k.stop();
3347
+ });
3348
+ if (mic.ctx) mic.ctx.close();
3349
+ mic.on = false;
3350
+ mic.asked = false;
3351
+ mic.stream = mic.ctx = mic.an = null;
3352
+ }
3353
+ function readMic(b) {
3354
+ mic.an.getFloatTimeDomainData(mic.td);
3355
+ var s = 0, i;
3356
+ for (i = 0; i < mic.td.length; i++) s += mic.td[i] * mic.td[i];
3357
+ var db = 20 * Math.log10(Math.sqrt(s / mic.td.length) + 1e-7);
3358
+ mic.an.getByteFrequencyData(mic.fd);
3359
+ var hz = mic.ctx.sampleRate / mic.an.fftSize, band = function(lo, hi) {
3360
+ var a = 0, n = 0;
3361
+ for (var k = Math.floor(lo / hz); k <= Math.ceil(hi / hz); k++) {
3362
+ a += mic.fd[k] || 0;
3363
+ n++;
3364
+ }
3365
+ return clamp2((a / n / 255 - 0.28) / 0.5, 0, 1);
3366
+ };
3367
+ b[0] = band(90, 300);
3368
+ b[1] = band(300, 2e3);
3369
+ b[2] = band(2e3, 6500);
3370
+ return clamp2((db + 54) / 34, 0, 1);
3371
+ }
3372
+ function step(dt) {
3373
+ t += dt;
3374
+ var m = mode(), reduce = reduceMQ && reduceMQ.matches, sw = reduce ? 0 : 1;
3375
+ var tx = 0, ty = 0, tz = 1, att = 0;
3376
+ if (m === "typing") {
3377
+ if (followEl && focused) readCaret();
3378
+ else {
3379
+ if (t >= sim.next) {
3380
+ if (sim.x >= 1.7) {
3381
+ sim.x = -1.7;
3382
+ sim.next = t + 1.1;
3383
+ } else {
3384
+ sim.x += 0.11 + 0.06 * hash1(t * 9.1);
3385
+ key();
3386
+ sim.next = t + 0.07 + 0.095 * hash1(t * 3.7) + (hash1(t * 5.3) > 0.82 ? 0.11 : 0);
3387
+ }
3388
+ }
3389
+ caret.x = cx + sim.x * R;
3390
+ caret.y = cy + 3.1 * R;
3391
+ }
3392
+ att = t - lastKey < 1.3 ? 1 : 0.55;
3393
+ tx = (caret.x - cx) / R;
3394
+ ty = -(caret.y - cy) / R;
3395
+ tz = 1.7;
3396
+ } else if (look) {
3397
+ tx = (look[0] - cx) / R;
3398
+ ty = -(look[1] - cy) / R;
3399
+ tz = 1.7;
3400
+ } else if (m === "listening") ty = -0.08;
3401
+ else if (m === "thinking") {
3402
+ tx = 0.34 * Math.cos(t * 0.75);
3403
+ ty = 0.24 * Math.sin(t * 0.97);
3404
+ } else if (m === "speaking") ty = 0.04;
3405
+ else {
3406
+ tx = sw * 0.14 * Math.sin(t / 4.3);
3407
+ ty = sw * 0.09 * Math.sin(t / 5.7 + 1);
3408
+ }
3409
+ var n = Math.hypot(tx, ty, tz) || 1;
3410
+ gx.target = tx / n;
3411
+ gy.target = ty / n;
3412
+ gz.target = tz / n;
3413
+ gx.step(dt);
3414
+ gy.step(dt);
3415
+ gz.step(dt);
3416
+ gaze[0] = gx.x;
3417
+ gaze[1] = gy.x;
3418
+ gaze[2] = gz.x;
3419
+ norm(gaze);
3420
+ attend.target = att;
3421
+ attend.step(dt);
3422
+ pulseS.step(dt);
3423
+ think.target = m === "thinking" ? 1 : 0;
3424
+ think.step(dt);
3425
+ speak.target = m === "speaking" ? 1 : 0;
3426
+ speak.step(dt);
3427
+ var lv = 0;
3428
+ rawB[0] = rawB[1] = rawB[2] = 0;
3429
+ if (m === "listening" || m === "speaking") {
3430
+ if (extLevel != null) {
3431
+ lv = clamp2(extLevel, 0, 1);
3432
+ rawB[0] = lv * 0.9;
3433
+ rawB[1] = lv * 0.6;
3434
+ rawB[2] = lv * 0.3;
3435
+ } else if (m === "listening" && mic.on) lv = readMic(rawB);
3436
+ else lv = simVoice(t, m === "speaking", rawB);
3437
+ }
3438
+ level = damp2(level, lv, lv > level ? 28 : 6, dt);
3439
+ for (var i = 0; i < 3; i++) bands[i] = damp2(bands[i], rawB[i], rawB[i] > bands[i] ? 24 : 7, dt);
3440
+ kick = damp2(kick, 0, 2.2, dt);
3441
+ pvel = damp2(pvel, (reduce ? 0.3 : 1) * SPEED[m] + kick, 5, dt);
3442
+ phase += pvel * dt;
3443
+ blur.target = m === "thinking" ? 1 : m === "typing" ? 0 : m === "listening" ? 0.12 : m === "speaking" ? 0.18 : 0.3;
3444
+ blur.step(dt);
3445
+ fill.target = m === "thinking" ? 1 : m === "speaking" ? 0.12 : 0;
3446
+ fill.step(dt);
3447
+ var k = 1 - Math.exp(-5 * dt);
3448
+ for (var key2 in cur) {
3449
+ if (Array.isArray(cur[key2])) for (var j = 0; j < 3; j++) cur[key2][j] += (want[key2][j] - cur[key2][j]) * k;
3450
+ else cur[key2] += (want[key2] - cur[key2]) * k;
3451
+ }
3452
+ var lx = cur.ink > 0.5 ? -0.55 : 0.62;
3453
+ if (m === "thinking") {
3454
+ lightT[0] = Math.cos(t * 0.9);
3455
+ lightT[1] = Math.sin(t * 0.9);
3456
+ lightT[2] = 0.3;
3457
+ } else {
3458
+ lightT[0] = lx + sw * 0.22 * Math.sin(t / 6.1);
3459
+ lightT[1] = 0.58 + sw * 0.18 * Math.sin(t / 7.3 + 2);
3460
+ lightT[2] = 0.38;
3461
+ }
3462
+ norm(lightT);
3463
+ var a = 0.85 * attend.x;
3464
+ for (i = 0; i < 3; i++) lightT[i] += (gaze[i] - lightT[i]) * a;
3465
+ norm(lightT);
3466
+ var kl = 1 - Math.exp(-2.6 * dt);
3467
+ for (i = 0; i < 3; i++) light[i] += (lightT[i] - light[i]) * kl;
3468
+ norm(light);
3469
+ }
3470
+ function draw() {
3471
+ gl.viewport(0, 0, W, H);
3472
+ gl.uniform2f(U.uRes, W, H);
3473
+ gl.uniform2f(U.uC, cx * dpr, H - cy * dpr);
3474
+ gl.uniform1f(U.uR, R * dpr);
3475
+ gl.uniform3fv(U.uTop, cur.top);
3476
+ gl.uniform3fv(U.uBot, cur.bot);
3477
+ gl.uniform3fv(U.uFloor, cur.floor);
3478
+ gl.uniform1f(U.uShadow, cur.shadow);
3479
+ gl.uniform1f(U.uVig, cur.vig);
3480
+ gl.uniform1f(U.uInk, cur.ink);
3481
+ gl.uniform1f(U.uDispK, cur.disp);
3482
+ gl.uniform1f(U.uHaloK, cur.halo);
3483
+ gl.uniform3fv(U.uOrbCol, cur.orb);
3484
+ gl.uniform3fv(U.uRimCol, cur.rim);
3485
+ gl.uniform3fv(U.uHaloCol, cur.haloC);
3486
+ gl.uniform1f(U.uT, t);
3487
+ gl.uniform1f(U.uAttend, attend.x);
3488
+ gl.uniform1f(U.uLevel, level);
3489
+ gl.uniform1f(U.uPulse, clamp2(pulseS.x, 0, 1.2));
3490
+ gl.uniform1f(U.uBlur, blur.x);
3491
+ gl.uniform1f(U.uPhase, phase);
3492
+ gl.uniform1f(U.uFill, fill.x);
3493
+ gl.uniform1f(U.uSpeak, speak.x);
3494
+ gl.uniform3f(U.uBands, bands[0], bands[1], bands[2]);
3495
+ gl.uniform3fv(U.uGaze, gaze);
3496
+ gl.uniform3fv(U.uLight, light);
3497
+ frameTo(gaze, rotM);
3498
+ gl.uniformMatrix3fv(U.uRot, false, rotM);
3499
+ gl.drawArrays(gl.TRIANGLES, 0, 3);
3500
+ }
3501
+ function frame(now) {
3502
+ if (dead) return;
3503
+ raf = requestAnimationFrame(frame);
3504
+ var dt = prev ? Math.min(1 / 30, Math.max(0, (now - prev) / 1e3)) : 0;
3505
+ prev = now;
3506
+ if (!onScreen || document.hidden) return;
3507
+ step(dt);
3508
+ draw();
3509
+ }
3510
+ step(0);
3511
+ draw();
3512
+ raf = requestAnimationFrame(frame);
3513
+ api8 = {
3514
+ set: function(s) {
3515
+ if (STATES[s]) {
3516
+ state = s;
3517
+ if (s === "listening" && o.mic) startMic();
3518
+ if (s !== "listening") stopMic();
3519
+ }
3520
+ return api8;
3521
+ },
3522
+ tone: function(n) {
3523
+ if (TONES[n]) {
3524
+ tone = n;
3525
+ want = TONES[n];
3526
+ }
3527
+ return api8;
3528
+ },
3529
+ level: function(v) {
3530
+ extLevel = v == null ? null : +v;
3531
+ return api8;
3532
+ },
3533
+ pulse: function() {
3534
+ key();
3535
+ return api8;
3536
+ },
3537
+ lookAt: function(x, y) {
3538
+ if (x == null) {
3539
+ look = null;
3540
+ return api8;
3541
+ }
3542
+ var r = host.getBoundingClientRect();
3543
+ look = [x - r.left, y - r.top];
3544
+ return api8;
3545
+ },
3546
+ follow: function(el) {
3547
+ if (followEl) {
3548
+ followEl.removeEventListener("input", onInput);
3549
+ followEl.removeEventListener("focus", onFocus);
3550
+ followEl.removeEventListener("blur", onBlur);
3551
+ followEl.removeEventListener("keyup", readCaret);
3552
+ followEl.removeEventListener("click", readCaret);
3553
+ }
3554
+ followEl = el || null;
3555
+ focused = !!(followEl && document.activeElement === followEl);
3556
+ if (followEl) {
3557
+ followEl.addEventListener("input", onInput);
3558
+ followEl.addEventListener("focus", onFocus);
3559
+ followEl.addEventListener("blur", onBlur);
3560
+ followEl.addEventListener("keyup", readCaret);
3561
+ followEl.addEventListener("click", readCaret);
3562
+ }
3563
+ return api8;
3564
+ },
3565
+ get state() {
3566
+ return state;
3567
+ },
3568
+ get toneName() {
3569
+ return tone;
3570
+ },
3571
+ destroy: function() {
3572
+ dead = true;
3573
+ cancelAnimationFrame(raf);
3574
+ api8.follow(null);
3575
+ stopMic();
3576
+ if (ro) ro.disconnect();
3577
+ else removeEventListener("resize", size);
3578
+ if (io) io.disconnect();
3579
+ var lose = gl.getExtension("WEBGL_lose_context");
3580
+ if (lose) lose.loseContext();
3581
+ canvas.remove();
3582
+ host.classList.remove("orb");
3583
+ }
3584
+ };
3585
+ if (o.follow) api8.follow(typeof o.follow === "string" ? document.querySelector(o.follow) : o.follow);
3586
+ if (o.level != null) api8.level(o.level);
3587
+ api8.set(state);
3588
+ return api8;
3589
+ }
3590
+ orb.tones = Object.keys(TONES);
3591
+ orb.states = Object.keys(STATES);
3592
+ window2.orb = orb;
3593
+ })();
3594
+ return api6 = window2;
3595
+ }
3596
+ function mountFoldOrb(host, o = {}) {
3597
+ css("craft-orb", CSS7);
3598
+ const E = engine6();
3599
+ host.innerHTML = '<div class="orb"></div>';
3600
+ const el = host.firstChild;
3601
+ const tall = (h) => {
3602
+ if (h != null && h !== "") el.style.setProperty("--orb-height", typeof h === "number" || /^\d+(\.\d+)?$/.test(h) ? h + "px" : String(h));
3603
+ };
3604
+ const field = (f) => typeof f === "string" ? document.querySelector(f) : f && "current" in f ? f.current : f;
3605
+ tall(o.height);
3606
+ const m = E.orb(el, { tone: o.tone, state: o.state, follow: field(o.follow), level: o.level, mic: o.mic, label: o.label });
3607
+ return {
3608
+ element: el,
3609
+ set: (s) => m.set(s),
3610
+ tone: (t) => m.tone(t),
3611
+ level: (v) => m.level(v),
3612
+ pulse: () => m.pulse(),
3613
+ lookAt: (x, y) => m.lookAt(x, y),
3614
+ follow: (f) => m.follow(field(f)),
3615
+ height: tall,
3616
+ destroy() {
3617
+ m.destroy();
3618
+ host.innerHTML = "";
3619
+ }
3620
+ };
3621
+ }
3622
+
3623
+ // src/leporello-assets-cdn.js
3624
+ var me6 = typeof document !== "undefined" && document.currentScript ? document.currentScript.src : "";
3625
+ var ASSETS2 = me6 ? me6.slice(0, me6.lastIndexOf("/") + 1) : "https://cdn.jsdelivr.net/npm/craft-library@0/dist/";
3626
+
3627
+ // dist/leporello.js
3628
+ var CSS8 = `/*! Leporello \xB7 Sara Lobo Library \xB7 https://saralobolibrary.com/leporello \xB7 MIT */
3629
+ /* The brand book in a folded strip: it fills the box it is given and paints its own dark ground. Sizes follow the box
3630
+ (container query units), so the same piece reads in a card, a section or a full screen. */
3631
+ .lep{--lep-ink:#EFE9DC;--lep-mut:#9A9384;--lep-ground:#141310;--lep-paper:#F1EDE5;--lep-ink2:#23241F;--lep-serif:'Cormorant Garamond','Instrument Serif',Georgia,'Times New Roman',serif;--lep-sans:-apple-system,BlinkMacSystemFont,'SF Pro Text','Inter','Helvetica Neue',system-ui,sans-serif;
3632
+ position:relative;width:100%;height:100%;min-height:300px;overflow:hidden;display:flex;flex-direction:column;background:var(--lep-ground);color:var(--lep-ink);container-type:size;font-family:var(--lep-sans);-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;user-select:none;-webkit-user-select:none}
3633
+ .lep *,.lep *::before,.lep *::after{box-sizing:border-box}
3634
+ .lep button{font:inherit;color:inherit;cursor:pointer;border:0;background:none;padding:0;margin:0;-webkit-tap-highlight-color:transparent}
3635
+ .lep img{-webkit-user-drag:none}
3636
+ /* the stage takes the light of the page in the middle */
3637
+ .lep-amb{position:absolute;inset:0;overflow:hidden;pointer-events:none}
3638
+ .lep-amb i{position:absolute;inset:-12%;opacity:0;will-change:opacity}
3639
+ .lep-amb i.blur{filter:blur(48px) saturate(1.1)}
3640
+ .lep-amb::after{content:"";position:absolute;inset:0;background:radial-gradient(85% 75% at 50% 50%,rgba(20,19,16,.45),rgba(20,19,16,.86) 72%,#141310)}
3641
+ .lep-head,.lep-scene,.lep-cap{position:relative;z-index:1}
3642
+ .lep-head{flex:none;display:flex;flex-direction:column;align-items:center;gap:clamp(6px,1.4cqh,10px);padding:clamp(16px,5cqh,30px) 24px 0;text-align:center}
3643
+ .lep-head small{font:600 clamp(10px,1.1cqw,12px)/1 var(--lep-serif);letter-spacing:.5em;padding-left:.5em;color:var(--lep-mut)}
3644
+ .lep-title{margin:0;font:300 clamp(28px,min(5cqw,10cqh),56px)/.95 var(--lep-serif);letter-spacing:-.012em;color:var(--lep-ink)}
3645
+ .lep-title em{font-style:italic;font-weight:300}
3646
+ .lep-cap{flex:none;display:flex;flex-direction:column;align-items:center;gap:clamp(10px,2.4cqh,14px);padding:0 24px clamp(18px,5cqh,28px)}
3647
+ .lep-row{display:flex;align-items:baseline;gap:12px}
3648
+ .lep-num{display:grid;font:italic 400 clamp(14px,1.6cqw,17px) var(--lep-serif);color:var(--lep-mut)}
3649
+ .lep-name{display:grid;font:400 clamp(21px,2.7cqw,29px)/1.1 var(--lep-serif);letter-spacing:-.005em;white-space:nowrap}
3650
+ .lep-mw{grid-area:1/1;white-space:pre}
3651
+ .lep-mw span{display:inline-block}
3652
+ .lep-dots{position:relative;height:1px;overflow:hidden;flex:none}
3653
+ .lep-dt-row{position:absolute;left:0;top:0;display:flex;gap:6px}
3654
+ .lep-dt-row i{width:18px;height:1px;background:rgba(236,231,218,.16)}
3655
+ .lep-dots b{position:absolute;left:0;top:0;width:18px;height:1px;background:#ECE7DA;will-change:transform}
3656
+ /* the strip */
3657
+ .lep-scene{flex:1;min-height:0;overflow:hidden;perspective:1500px;touch-action:pan-y;cursor:grab;-webkit-mask-image:linear-gradient(90deg,transparent,#000 6%,#000 94%,transparent);mask-image:linear-gradient(90deg,transparent,#000 6%,#000 94%,transparent)}
3658
+ .lep-scene.lep-drag{cursor:grabbing}
3659
+ .lep-scene.lep-peek{cursor:none}
3660
+ .lep-scene:focus{outline:none}
3661
+ .lep-scene:focus-visible{outline:1px solid rgba(239,233,220,.3);outline-offset:-10px;border-radius:14px}
3662
+ .lep-world{position:absolute;inset:0;transform-style:preserve-3d;pointer-events:none}
3663
+ .lep-page{position:absolute;left:0;top:0;transform-origin:0 50%;background:#F3F0E9;overflow:hidden;cursor:pointer;pointer-events:auto;will-change:transform}
3664
+ .lep-page.lep-held{visibility:hidden!important}
3665
+ .lep-page::before{content:"";position:absolute;inset:0;border-left:1px solid rgba(0,0,0,.08);pointer-events:none;z-index:2}
3666
+ .lep-img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block}
3667
+ .lep-sh{position:absolute;inset:0;background:#0b0b09;opacity:0;pointer-events:none;z-index:3}
3668
+ .lep-plus{position:absolute;right:9px;bottom:9px;width:26px;height:26px;border-radius:50%;background:rgba(241,237,229,.94);color:#23241F;display:grid;place-items:center;opacity:0;transform:scale(.9);transition:opacity .3s cubic-bezier(.22,1,.36,1),transform .4s cubic-bezier(.22,1,.36,1);z-index:4;box-shadow:0 2px 8px rgba(0,0,0,.22)}
3669
+ .lep-page.lep-center .lep-plus{opacity:1;transform:none}
3670
+ .lep-floor{position:absolute;left:12%;right:12%;height:46px;margin-top:-23px;border-radius:50%;background:radial-gradient(closest-side,rgba(0,0,0,.6),rgba(0,0,0,0));pointer-events:none}
3671
+ .lep-cur{position:absolute;left:0;top:0;width:66px;height:66px;margin:-33px 0 0 -33px;border-radius:50%;background:var(--lep-paper);color:var(--lep-ink2);display:grid;place-items:center;font:600 10px var(--lep-sans);letter-spacing:.18em;padding-left:.18em;text-transform:uppercase;opacity:0;scale:.8;pointer-events:none;z-index:5;transition:opacity .25s cubic-bezier(.22,1,.36,1),scale .45s cubic-bezier(.22,1,.36,1);box-shadow:0 12px 30px -12px rgba(0,0,0,.7);will-change:transform}
3672
+ .lep-cur.lep-on{opacity:1;scale:1}
3673
+ /* pages drawn in type (the demo's cover, palette and specimen) scale with the page */
3674
+ .lep-cover{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:#5E6442;color:#F2EEE3}
3675
+ .lep-cover b{font:400 calc(var(--lep-pw) * .2)/1 var(--lep-serif);letter-spacing:.14em;padding-left:.14em}
3676
+ .lep-pal{position:absolute;inset:0;display:grid;grid-template-rows:1.3fr 1fr 1fr 1fr}
3677
+ .lep-pal div{display:flex;align-items:flex-end;padding:7% 9%;font:400 calc(var(--lep-pw) * .085)/1.1 var(--lep-serif)}
3678
+ .lep-type{position:absolute;inset:0;padding:11% 10%;display:flex;flex-direction:column;justify-content:flex-end;color:#24251F;background:#EDE8DE}
3679
+ .lep-type b{font:300 calc(var(--lep-pw) * .62)/.85 var(--lep-serif)}
3680
+ /* the page of its own */
3681
+ .lep-od{position:absolute;inset:0;z-index:6;pointer-events:none}
3682
+ .lep-od.lep-on{pointer-events:auto}
3683
+ .lep-od-bg{position:absolute;inset:0;background:var(--lep-paper);opacity:0}
3684
+ .lep-od-media{position:absolute;left:0;top:0;overflow:hidden;visibility:hidden;background:#F3F0E9}
3685
+ .lep-od-media>div{position:absolute;inset:0}
3686
+ .lep-od-text{position:absolute;left:calc(58% + 7cqw);right:6cqw;top:0;bottom:0;display:flex;flex-direction:column;justify-content:center;color:var(--lep-ink2);user-select:text;-webkit-user-select:text}
3687
+ .lep-od-text>*{opacity:0;transform:translateY(8px);transition:opacity .16s ease,transform .16s ease}
3688
+ .lep-od.lep-ui .lep-od-text>*{opacity:1;transform:none;transition:opacity .55s cubic-bezier(.2,0,0,1),transform .55s cubic-bezier(.2,0,0,1)}
3689
+ .lep-od.lep-ui .lep-od-text>:nth-child(2){transition-delay:.06s}
3690
+ .lep-od.lep-ui .lep-od-text>:nth-child(3){transition-delay:.12s}
3691
+ .lep-od.lep-ui .lep-od-text>:nth-child(4){transition-delay:.18s}
3692
+ .lep-od-text.lep-swap>*{opacity:0!important;transform:translateY(6px)!important;transition:opacity .16s ease,transform .16s ease!important}
3693
+ .lep-od-k{font:500 11px var(--lep-sans);letter-spacing:.3em;color:#8C8778;font-variant-numeric:tabular-nums}
3694
+ .lep-od-text h4{margin:clamp(8px,2.6cqh,16px) 0 0;font:300 clamp(30px,min(4.8cqw,9.5cqh),54px)/1 var(--lep-serif);letter-spacing:-.012em}
3695
+ .lep-od-text p{margin:clamp(10px,3.4cqh,20px) 0 0;max-width:30ch;font:400 clamp(13px,1.35cqw,15px)/1.65 var(--lep-sans);color:#5C5B52}
3696
+ .lep-od-nav{margin-top:clamp(18px,6cqh,36px);display:flex;gap:10px}
3697
+ .lep-od-nav button{width:42px;height:42px;border-radius:50%;box-shadow:inset 0 0 0 1px rgba(35,36,31,.16);display:grid;place-items:center;color:var(--lep-ink2);transition:background-color .2s ease}
3698
+ .lep-od-nav button:hover{background:rgba(35,36,31,.06)}
3699
+ .lep-od-x{position:absolute;top:18px;right:18px;width:42px;height:42px;border-radius:50%;box-shadow:inset 0 0 0 1px rgba(35,36,31,.16);color:var(--lep-ink2);display:grid;place-items:center;opacity:0;transition:opacity .2s ease}
3700
+ .lep-od.lep-ui .lep-od-x{opacity:1;transition:opacity .4s ease .1s}
3701
+ .lep button:focus-visible{outline:1.5px solid var(--lep-ink2);outline-offset:2px}
3702
+ /* a narrow box: the picture on top, the words under it */
3703
+ @container (max-width:599px){
3704
+ .lep-od-text{left:22px;right:22px;top:calc(52% + 18px);bottom:20px;justify-content:flex-start}
3705
+ .lep-od-nav{margin-top:auto}
3706
+ .lep-od-x{background:rgba(241,237,229,.92);box-shadow:0 2px 12px rgba(0,0,0,.14)}
3707
+ }
3708
+ @media (prefers-reduced-motion:reduce){
3709
+ .lep-plus,.lep-cur,.lep-od-text>*,.lep-od-x{transition-duration:.01s!important}
3710
+ }
3711
+ `;
3712
+ var api7;
3713
+ function engine7() {
3714
+ if (api7) return api7;
3715
+ const window2 = {};
3716
+ (function() {
3717
+ "use strict";
3718
+ var FONTS2 = "https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300;1,400&display=swap";
3719
+ var REDUCE = matchMedia("(prefers-reduced-motion: reduce)").matches;
3720
+ var OLEA = [
3721
+ { title: "Cover", html: '<div class="lep-cover"><b>OLEA</b></div>', ambient: "#5E6442", text: "The brand in one word: the name in a fine serif, with room to breathe." },
3722
+ { title: "Label", image: "olea/rotulo.jpg", ambient: "olea/amb-rotulo.jpg", text: "Cotton paper with a blind emboss, and the harvest printed on every bottle." },
3723
+ { title: "Palette", html: '<div class="lep-pal"><div style="background:#5E6442;color:#F2EEE3">Olive</div><div style="background:#E9E3D6;color:#3B3A33">Stone</div><div style="background:#A66A3F;color:#F6ECE3">Earth</div><div style="background:#23241F;color:#E9E3D6">Ink</div></div>', ambient: "linear-gradient(160deg,#5E6442,#A66A3F)", text: "Four colours taken from the grove: the leaf, the stone, the earth and the ink." },
3724
+ { title: "Full range", image: "olea/linha.jpg", ambient: "olea/amb-linha.jpg", text: "Three sizes and a gift box, in one family of frosted glass." },
3725
+ { title: "Typography", html: '<div class="lep-type"><b>Aa</b></div>', ambient: "#6A645A", text: "A high-contrast serif for headings and a quiet sans for everything else." },
3726
+ { title: "Stationery", image: "olea/papelaria.jpg", ambient: "olea/amb-papelaria.jpg", text: "Linen paper and olive green in a single colour, with no varnish or gloss." },
3727
+ { title: "Tote bag", image: "olea/ecobag.jpg", ambient: "olea/amb-ecobag.jpg", text: "Raw cotton and the name in green, for the market and the shop." },
3728
+ { title: "At the table", image: "olea/mesa.jpg", ambient: "olea/amb-mesa.jpg", text: "The product where it belongs: bread, salt and this year\u2019s oil." }
3729
+ ];
3730
+ var clamp2 = function(x, a, b) {
3731
+ return Math.min(b, Math.max(a, x));
3732
+ };
3733
+ var smooth = function(a, b, x) {
3734
+ var t = clamp2((x - a) / (b - a), 0, 1);
3735
+ return t * t * (3 - 2 * t);
3736
+ };
3737
+ var wrapN = function(x, m) {
3738
+ return (x % m + m) % m;
3739
+ };
3740
+ var wdiff = function(x, m) {
3741
+ return wrapN(x + m / 2, m) - m / 2;
3742
+ };
3743
+ var f2 = function(x) {
3744
+ return x.toFixed(2);
3745
+ };
3746
+ var pad = function(n) {
3747
+ return String(n).padStart(2, "0");
3748
+ };
3749
+ var esc2 = function(s) {
3750
+ return String(s).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3751
+ };
3752
+ var mk = function(cls, tag) {
3753
+ var e = document.createElement(tag || "div");
3754
+ if (cls) e.className = cls;
3755
+ return e;
3756
+ };
3757
+ var bez = function(x1, y1, x2, y2) {
3758
+ var cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx, cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by;
3759
+ return function(x) {
3760
+ if (x <= 0) return 0;
3761
+ if (x >= 1) return 1;
3762
+ var t = x;
3763
+ for (var i = 0; i < 8; i++) {
3764
+ var e = ((ax * t + bx) * t + cx) * t - x, d = (3 * ax * t + 2 * bx) * t + cx;
3765
+ if (Math.abs(e) < 1e-5 || Math.abs(d) < 1e-6) break;
3766
+ t -= e / d;
3767
+ }
3768
+ t = clamp2(t, 0, 1);
3769
+ return ((ay * t + by) * t + cy) * t;
3770
+ };
3771
+ };
3772
+ var EASE_OUT = bez(0.2, 0, 0, 1), EASE_IO = bez(0.45, 0, 0.25, 1);
3773
+ var tween = function(tw, clock) {
3774
+ return tw.from + (tw.to - tw.from) * tw.ease(clamp2((clock - tw.t0) / tw.dur, 0, 1));
3775
+ };
3776
+ function Spring(value, stiffness) {
3777
+ this.x = value;
3778
+ this.v = 0;
3779
+ this.target = value;
3780
+ this.k = stiffness;
3781
+ this.c = 2 * Math.sqrt(stiffness);
3782
+ }
3783
+ Spring.prototype.step = function(dt) {
3784
+ var n = Math.max(1, Math.ceil(dt * 240)), h = dt / n;
3785
+ for (var i = 0; i < n; i++) {
3786
+ this.v += (-this.k * (this.x - this.target) - this.c * this.v) * h;
3787
+ this.x += this.v * h;
3788
+ }
3789
+ return this.x;
3790
+ };
3791
+ function Track(M, period) {
3792
+ this.M = M;
3793
+ this.s = 0;
3794
+ this.vel = 0;
3795
+ this.mode = "auto";
3796
+ this.gain = 0;
3797
+ this.hover = false;
3798
+ this.focus = false;
3799
+ this.paused = REDUCE;
3800
+ this.lock = false;
3801
+ this.idle = 99;
3802
+ this.wheelT = 0;
3803
+ this.eps = 0.12;
3804
+ this.vmax = 1 / Math.sqrt(this.eps) / period;
3805
+ this.sp = new Spring(0, 42);
3806
+ }
3807
+ Track.prototype = {
3808
+ touch: function() {
3809
+ this.idle = 0;
3810
+ },
3811
+ wantAuto: function() {
3812
+ return !this.lock && !this.paused && !this.hover && !this.focus && this.idle > 2.4;
3813
+ },
3814
+ settleTo: function(target, v) {
3815
+ this.mode = "settle";
3816
+ this.sp.x = this.s;
3817
+ this.sp.v = v === void 0 ? this.vel : v;
3818
+ this.sp.target = target;
3819
+ },
3820
+ base: function() {
3821
+ return this.mode === "settle" ? Math.round(this.sp.target) : this.vel > 0.02 ? Math.ceil(this.s - 0.04) : Math.round(this.s);
3822
+ },
3823
+ release: function(v) {
3824
+ this.touch();
3825
+ this.settleTo(Math.round(this.s + clamp2(v * 0.22, -2.5, 2.5)), v);
3826
+ },
3827
+ goto: function(slot) {
3828
+ this.touch();
3829
+ var b = this.base();
3830
+ this.settleTo(b + wdiff(slot - b, this.M));
3831
+ },
3832
+ holdAt: function(slot) {
3833
+ this.touch();
3834
+ this.settleTo(this.s + wdiff(slot - this.s, this.M));
3835
+ },
3836
+ nudge: function(n) {
3837
+ this.touch();
3838
+ this.settleTo(this.base() + n);
3839
+ },
3840
+ wheel: function(ds) {
3841
+ this.touch();
3842
+ if (this.mode !== "settle") this.settleTo(this.s);
3843
+ this.sp.target += ds;
3844
+ this.wheelT = 0.16;
3845
+ },
3846
+ step: function(dt) {
3847
+ this.idle += dt;
3848
+ if (this.mode === "drag") return;
3849
+ if (this.mode === "auto") {
3850
+ if (!this.wantAuto()) {
3851
+ var fr = this.s - Math.floor(this.s);
3852
+ this.settleTo(fr < 0.03 ? Math.floor(this.s) : Math.ceil(this.s), this.vel);
3853
+ this.gain = 0;
3854
+ return;
3855
+ }
3856
+ this.gain += (1 - this.gain) * (1 - Math.exp(-1.6 * dt));
3857
+ var sn = Math.sin(Math.PI * (this.s - Math.round(this.s)));
3858
+ this.vel = this.vmax * (this.eps + (1 - this.eps) * sn * sn) * this.gain;
3859
+ this.s += this.vel * dt;
3860
+ return;
3861
+ }
3862
+ if (this.wheelT > 0) {
3863
+ this.wheelT -= dt;
3864
+ if (this.wheelT <= 0) this.sp.target = Math.round(this.sp.target);
3865
+ }
3866
+ var prev = this.s;
3867
+ this.s = this.sp.step(dt);
3868
+ this.vel = (this.s - prev) / dt;
3869
+ if (this.wheelT <= 0 && Math.abs(this.s - this.sp.target) < 1e-3 && Math.abs(this.sp.v) < 3e-3) {
3870
+ this.s = this.sp.target;
3871
+ this.sp.v = 0;
3872
+ this.vel = 0;
3873
+ if (this.wantAuto()) {
3874
+ this.mode = "auto";
3875
+ this.gain = 0;
3876
+ }
3877
+ }
3878
+ }
3879
+ };
3880
+ function morph(el, text, instant) {
3881
+ var cur = el.querySelector(".lep-mw.on");
3882
+ if (cur && cur.getAttribute("data-t") === text) return;
3883
+ var nw = mk("lep-mw on", "span");
3884
+ nw.setAttribute("data-t", text);
3885
+ Array.from(text).forEach(function(ch) {
3886
+ var s = mk("", "span");
3887
+ s.textContent = ch;
3888
+ nw.appendChild(s);
3889
+ });
3890
+ el.appendChild(nw);
3891
+ if (cur) {
3892
+ cur.classList.remove("on");
3893
+ if (instant || !cur.animate) {
3894
+ cur.remove();
3895
+ return;
3896
+ }
3897
+ var a = cur.animate(
3898
+ REDUCE ? [{ opacity: 1 }, { opacity: 0 }] : [{ opacity: 1, filter: "blur(0px)", transform: "translateY(0)" }, { opacity: 0, filter: "blur(4px)", transform: "translateY(-.22em)" }],
3899
+ { duration: REDUCE ? 160 : 280, easing: "cubic-bezier(.4,0,1,1)", fill: "forwards" }
3900
+ );
3901
+ a.onfinish = function() {
3902
+ cur.remove();
3903
+ };
3904
+ }
3905
+ if (instant || !cur || !nw.animate) return;
3906
+ Array.from(nw.children).forEach(function(s, i) {
3907
+ s.animate(
3908
+ REDUCE ? [{ opacity: 0 }, { opacity: 1 }] : [{ opacity: 0, filter: "blur(5px)", transform: "translateY(.28em)" }, { opacity: 1, filter: "blur(0px)", transform: "translateY(0)" }],
3909
+ { duration: REDUCE ? 200 : 560, delay: REDUCE ? 0 : 70 + i * 14, easing: "cubic-bezier(.22,1,.36,1)", fill: "backwards" }
3910
+ );
3911
+ });
3912
+ }
3913
+ var ARROW_L = '<svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7.5 2.5 4 6l3.5 3.5"/></svg>';
3914
+ var ARROW_R = '<svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4.5 2.5 8 6 4.5 9.5"/></svg>';
3915
+ var PLUS = '<svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true"><path d="M6 2v8M2 6h8"/></svg>';
3916
+ var CLOSE = '<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true"><path d="M3 3l8 8M11 3l-8 8"/></svg>';
3917
+ function leporello(host, o) {
3918
+ o = o || {};
3919
+ var base5 = o.base || "";
3920
+ var src = function(u) {
3921
+ return /^(https?:|data:|blob:|\/)/.test(u) ? u : base5 + u;
3922
+ };
3923
+ var pages = (o.pages && o.pages.length ? o.pages : OLEA).map(function(p2) {
3924
+ return { title: p2.title || "", text: p2.text || "", image: p2.image ? src(p2.image) : "", html: p2.html || "", ambient: p2.ambient ? /\.(jpe?g|png|webp|avif)(\?|$)/i.test(p2.ambient) ? "url('" + src(p2.ambient) + "') center/cover" : p2.ambient : "" };
3925
+ });
3926
+ var N = pages.length, k = Math.ceil(16 / N);
3927
+ if (N * k % 2) k++;
3928
+ var M = N * k;
3929
+ var L = Object.assign({ region: "Brand book", open: "Open", close: "Back to the book", prev: "Previous page", next: "Next page" }, o.labels || {});
3930
+ var kicker = o.kicker === void 0 ? "OLEA" : o.kicker, title = o.title === void 0 ? "Brand <em>book</em>" : o.title;
3931
+ if (o.fonts !== false && !document.querySelector("link[data-leporello-fonts]")) {
3932
+ var ln = document.createElement("link");
3933
+ ln.rel = "stylesheet";
3934
+ ln.href = FONTS2;
3935
+ ln.setAttribute("data-leporello-fonts", "");
3936
+ document.head.appendChild(ln);
3937
+ }
3938
+ var root = mk("lep");
3939
+ root.setAttribute("role", "region");
3940
+ root.setAttribute("aria-roledescription", "carousel");
3941
+ root.setAttribute("aria-label", L.region);
3942
+ var amb = mk("lep-amb");
3943
+ pages.forEach(function(p2) {
3944
+ var i2 = mk("", "i");
3945
+ if (p2.ambient) i2.style.background = p2.ambient;
3946
+ else if (p2.image) {
3947
+ i2.style.background = "url('" + p2.image + "') center/cover";
3948
+ i2.className = "blur";
3949
+ }
3950
+ amb.appendChild(i2);
3951
+ });
3952
+ var head = mk("lep-head");
3953
+ head.innerHTML = (kicker ? "<small>" + esc2(kicker) + "</small>" : "") + (title ? '<h3 class="lep-title">' + title + "</h3>" : "");
3954
+ var scene = mk("lep-scene");
3955
+ scene.tabIndex = 0;
3956
+ var floor = mk("lep-floor"), world = mk("lep-world"), cur = mk("lep-cur");
3957
+ cur.textContent = L.open;
3958
+ scene.append(floor, world, cur);
3959
+ var cap = mk("lep-cap");
3960
+ cap.innerHTML = '<div class="lep-row"><span class="lep-num lep-morph"></span><span class="lep-name lep-morph"></span></div><div class="lep-dots" aria-hidden="true"><span class="lep-dt-row"></span><b></b><b></b></div>';
3961
+ var od = mk("lep-od");
3962
+ od.setAttribute("aria-hidden", "true");
3963
+ od.innerHTML = '<div class="lep-od-bg"></div><div class="lep-od-media"></div><div class="lep-od-text"><span class="lep-od-k"></span><h4></h4><p></p><div class="lep-od-nav"><button type="button" class="lep-od-prev" aria-label="' + esc2(L.prev) + '">' + ARROW_L + '</button><button type="button" class="lep-od-next" aria-label="' + esc2(L.next) + '">' + ARROW_R + '</button></div></div><button type="button" class="lep-od-x" aria-label="' + esc2(L.close) + '">' + CLOSE + "</button>";
3964
+ root.append(amb, head, scene, cap, od);
3965
+ host.innerHTML = "";
3966
+ host.appendChild(root);
3967
+ var items = [];
3968
+ for (var i = 0; i < M; i++) {
3969
+ var p = pages[i % N], el = mk("lep-page");
3970
+ el.setAttribute("data-slot", i);
3971
+ el.innerHTML = (p.html || (p.image ? '<img class="lep-img" src="' + esc2(p.image) + '" alt="" draggable="false" decoding="async">' : "")) + '<div class="lep-sh"></div><span class="lep-plus" aria-hidden="true">' + PLUS + "</span>";
3972
+ world.appendChild(el);
3973
+ items.push({ el, sh: el.querySelector(".lep-sh"), vis: true });
3974
+ }
3975
+ var ambEls = Array.from(amb.children), ambW = new Float64Array(N).fill(-1);
3976
+ var numEl = cap.querySelector(".lep-num"), nameEl = cap.querySelector(".lep-name");
3977
+ var dotRow = cap.querySelector(".lep-dt-row"), pills = cap.querySelectorAll(".lep-dots b");
3978
+ dotRow.innerHTML = new Array(N + 1).join("<i></i>");
3979
+ cap.querySelector(".lep-dots").style.width = N * 24 - 6 + "px";
3980
+ var odBg = od.querySelector(".lep-od-bg"), odMedia = od.querySelector(".lep-od-media"), odText = od.querySelector(".lep-od-text");
3981
+ var odK = od.querySelector(".lep-od-k"), odH = od.querySelector("h4"), odP = od.querySelector("p");
3982
+ var tr = new Track(M, o.period || 3.6);
3983
+ tr.paused = REDUCE || o.autoplay === false;
3984
+ var W = 0, H = 0, Wp = 180, Hp = 240, ppu = 180, ax = new Float64Array(M + 1), px = new Float64Array(M + 1), pz = new Float64Array(M + 1);
3985
+ var dirty = true, lastS = NaN, idx = -1, centre = -1;
3986
+ function measure() {
3987
+ W = scene.clientWidth;
3988
+ H = scene.clientHeight;
3989
+ if (!W || !H) return;
3990
+ Wp = o.page || clamp2(W * 0.2, 104, 240);
3991
+ Hp = Math.min(Wp * 4 / 3, H - 24);
3992
+ Wp = Math.min(Wp, Hp * 0.75);
3993
+ ppu = Wp;
3994
+ root.style.setProperty("--lep-pw", Wp + "px");
3995
+ items.forEach(function(it) {
3996
+ it.el.style.width = Wp + "px";
3997
+ it.el.style.height = Hp + "px";
3998
+ });
3999
+ floor.style.top = H / 2 + Hp / 2 + 12 + "px";
4000
+ if (D.mode === "open") {
4001
+ var t = target();
4002
+ D.X.target = t.x;
4003
+ D.Y.target = t.y;
4004
+ D.Wd.target = t.w;
4005
+ D.Hd.target = t.h;
4006
+ }
4007
+ dirty = true;
4008
+ }
4009
+ function render(s) {
4010
+ var k0 = Math.round(s), u = s - (k0 - 0.5), cx = W / 2, top = H / 2 - Hp / 2 - 4, half = W / 2 + 40;
4011
+ var maxA = 80 * Math.PI / 180, C = M / 2;
4012
+ for (var n = 0; n < M; n++) {
4013
+ var j = k0 - C + n;
4014
+ ax[n] = (wrapN(j, 2) ? -1 : 1) * maxA * smooth(0.3, 3.2, Math.abs(j - s));
4015
+ }
4016
+ px[C] = -u * Wp * Math.cos(ax[C]);
4017
+ pz[C] = -u * Wp * Math.sin(ax[C]);
4018
+ for (n = C; n < M; n++) {
4019
+ px[n + 1] = px[n] + Wp * Math.cos(ax[n]);
4020
+ pz[n + 1] = pz[n] + Wp * Math.sin(ax[n]);
4021
+ }
4022
+ for (n = C; n > 0; n--) {
4023
+ px[n - 1] = px[n] - Wp * Math.cos(ax[n - 1]);
4024
+ pz[n - 1] = pz[n] - Wp * Math.sin(ax[n - 1]);
4025
+ }
4026
+ var z0 = -Wp * 0.25;
4027
+ for (n = 0; n < M; n++) {
4028
+ var it = items[wrapN(k0 - C + n, M)], a = ax[n];
4029
+ if (px[n + 1] < -half || px[n] > half) {
4030
+ if (it.vis) {
4031
+ it.el.style.visibility = "hidden";
4032
+ it.vis = false;
4033
+ }
4034
+ continue;
4035
+ }
4036
+ if (!it.vis) {
4037
+ it.el.style.visibility = "";
4038
+ it.vis = true;
4039
+ }
4040
+ it.el.style.transform = "translate3d(" + f2(cx + px[n]) + "px," + f2(top) + "px," + f2(pz[n] + z0) + "px) rotateY(" + (-a).toFixed(4) + "rad)";
4041
+ it.sh.style.opacity = (0.02 + 0.3 * (1 - Math.cos(a - 0.52))).toFixed(3);
4042
+ }
4043
+ }
4044
+ function captions(s) {
4045
+ var i2 = wrapN(Math.round(s), N);
4046
+ if (i2 !== idx) {
4047
+ var first = idx < 0;
4048
+ idx = i2;
4049
+ morph(numEl, pad(i2 + 1), first);
4050
+ morph(nameEl, pages[i2].title, first);
4051
+ if (!first) host.dispatchEvent(new CustomEvent("leporellochange", { bubbles: true, detail: { index: i2 } }));
4052
+ }
4053
+ var p2 = wrapN(s, N);
4054
+ pills[0].style.transform = "translate3d(" + f2(p2 * 24) + "px,0,0)";
4055
+ pills[1].style.transform = "translate3d(" + f2((p2 - N) * 24) + "px,0,0)";
4056
+ for (var k2 = 0; k2 < N; k2++) {
4057
+ var w = Math.max(0, 1 - Math.abs(wdiff(k2 - s, N)));
4058
+ if (Math.abs(w - ambW[k2]) > 4e-3) {
4059
+ ambW[k2] = w;
4060
+ ambEls[k2].style.opacity = w.toFixed(3);
4061
+ }
4062
+ }
4063
+ var c = wrapN(Math.round(s), M), want = Math.abs(s - Math.round(s)) < 0.18 ? c : -1;
4064
+ if (want !== centre) {
4065
+ if (centre >= 0) items[centre].el.classList.remove("lep-center");
4066
+ if (want >= 0) items[want].el.classList.add("lep-center");
4067
+ centre = want;
4068
+ }
4069
+ }
4070
+ var D = { mode: "closed", clock: 0, queue: [], X: new Spring(0, 150), Y: new Spring(0, 150), Wd: new Spring(0, 150), Hd: new Spring(0, 150), bgT: null, bg: 0, slot: -1 };
4071
+ function local(r) {
4072
+ var b = root.getBoundingClientRect();
4073
+ return { x: r.left - b.left, y: r.top - b.top, w: r.width, h: r.height };
4074
+ }
4075
+ function target() {
4076
+ var w = root.clientWidth, h = root.clientHeight;
4077
+ return w >= 600 ? { x: 0, y: 0, w: Math.round(w * 0.58), h } : { x: 0, y: 0, w, h: Math.round(h * 0.52) };
4078
+ }
4079
+ function fillMedia(i2, fresh) {
4080
+ var box = mk("");
4081
+ box.innerHTML = pages[i2].html || (pages[i2].image ? '<img class="lep-img" src="' + esc2(pages[i2].image) + '" alt="">' : "");
4082
+ if (fresh || !box.animate) {
4083
+ odMedia.innerHTML = "";
4084
+ odMedia.appendChild(box);
4085
+ return;
4086
+ }
4087
+ box.style.opacity = "0";
4088
+ odMedia.appendChild(box);
4089
+ box.animate([{ opacity: 0, filter: "blur(6px)" }, { opacity: 1, filter: "blur(0px)" }], { duration: 420, easing: "cubic-bezier(.2,0,0,1)", fill: "forwards" }).onfinish = function() {
4090
+ box.style.opacity = "1";
4091
+ Array.from(odMedia.children).forEach(function(c) {
4092
+ if (c !== box) c.remove();
4093
+ });
4094
+ };
4095
+ }
4096
+ function fillText(i2) {
4097
+ odK.textContent = pad(i2 + 1) + " / " + pad(N);
4098
+ odH.textContent = pages[i2].title;
4099
+ odP.textContent = pages[i2].text;
4100
+ }
4101
+ function openPage(slot) {
4102
+ if (D.mode !== "closed") return;
4103
+ if (slot === void 0) slot = wrapN(Math.round(tr.s), M);
4104
+ var i2 = slot % N, page = items[slot].el, a = local(page.getBoundingClientRect()), b = target();
4105
+ tr.holdAt(slot);
4106
+ tr.lock = true;
4107
+ D.slot = slot;
4108
+ fillMedia(i2, true);
4109
+ fillText(i2);
4110
+ D.X.x = a.x;
4111
+ D.Y.x = a.y;
4112
+ D.Wd.x = a.w;
4113
+ D.Hd.x = a.h;
4114
+ D.X.v = D.Y.v = D.Wd.v = D.Hd.v = 0;
4115
+ D.X.target = b.x;
4116
+ D.Y.target = b.y;
4117
+ D.Wd.target = b.w;
4118
+ D.Hd.target = b.h;
4119
+ if (REDUCE) {
4120
+ D.X.x = b.x;
4121
+ D.Y.x = b.y;
4122
+ D.Wd.x = b.w;
4123
+ D.Hd.x = b.h;
4124
+ }
4125
+ page.classList.add("lep-held");
4126
+ odMedia.style.visibility = "visible";
4127
+ scene.style.pointerEvents = "none";
4128
+ cur.classList.remove("lep-on");
4129
+ scene.classList.remove("lep-peek");
4130
+ cs.on = false;
4131
+ od.classList.add("lep-on");
4132
+ od.setAttribute("aria-hidden", "false");
4133
+ D.mode = "open";
4134
+ D.clock = 0;
4135
+ D.queue = [];
4136
+ D.bgT = { from: D.bg, to: 1, t0: 60, dur: 520, ease: EASE_OUT };
4137
+ D.queue.push({ at: REDUCE ? 0 : 420, fn: function() {
4138
+ od.classList.add("lep-ui");
4139
+ od.querySelector(".lep-od-x").focus({ preventScroll: true });
4140
+ } });
4141
+ host.dispatchEvent(new CustomEvent("leporelloopen", { bubbles: true, detail: { index: i2 } }));
4142
+ }
4143
+ function closePage() {
4144
+ if (D.mode !== "open") return;
4145
+ od.classList.remove("lep-ui");
4146
+ D.mode = "closing";
4147
+ D.clock = 0;
4148
+ D.queue = [];
4149
+ D.bgT = { from: D.bg, to: 0, t0: 120, dur: 480, ease: EASE_IO };
4150
+ D.queue.push({ at: 120, fn: function() {
4151
+ var a = local(items[D.slot].el.getBoundingClientRect());
4152
+ D.X.target = a.x;
4153
+ D.Y.target = a.y;
4154
+ D.Wd.target = a.w;
4155
+ D.Hd.target = a.h;
4156
+ if (REDUCE) {
4157
+ D.X.x = a.x;
4158
+ D.Y.x = a.y;
4159
+ D.Wd.x = a.w;
4160
+ D.Hd.x = a.h;
4161
+ }
4162
+ } });
4163
+ D.queue.push({ at: REDUCE ? 200 : 900, fn: function() {
4164
+ items[D.slot].el.classList.remove("lep-held");
4165
+ odMedia.style.visibility = "hidden";
4166
+ od.classList.remove("lep-on");
4167
+ od.setAttribute("aria-hidden", "true");
4168
+ D.mode = "closed";
4169
+ tr.lock = false;
4170
+ tr.touch();
4171
+ scene.style.pointerEvents = "";
4172
+ scene.style.opacity = "";
4173
+ scene.focus({ preventScroll: true });
4174
+ } });
4175
+ host.dispatchEvent(new CustomEvent("leporelloclose", { bubbles: true, detail: { index: D.slot % N } }));
4176
+ }
4177
+ function turnPage(dir) {
4178
+ if (D.mode !== "open") return;
4179
+ var slot = wrapN(D.slot + dir, M), i2 = slot % N;
4180
+ items[D.slot].el.classList.remove("lep-held");
4181
+ items[slot].el.classList.add("lep-held");
4182
+ tr.holdAt(slot);
4183
+ D.slot = slot;
4184
+ fillMedia(i2, false);
4185
+ odText.classList.add("lep-swap");
4186
+ setTimeout(function() {
4187
+ fillText(i2);
4188
+ odText.classList.remove("lep-swap");
4189
+ }, 170);
4190
+ }
4191
+ od.querySelector(".lep-od-x").addEventListener("click", closePage);
4192
+ od.querySelector(".lep-od-prev").addEventListener("click", function() {
4193
+ turnPage(-1);
4194
+ });
4195
+ od.querySelector(".lep-od-next").addEventListener("click", function() {
4196
+ turnPage(1);
4197
+ });
4198
+ var cs = { x: 0, y: 0, tx: 0, ty: 0, on: false }, drag = null, engaged = false;
4199
+ scene.addEventListener("pointerenter", function(e) {
4200
+ if (e.pointerType === "mouse") tr.hover = true;
4201
+ });
4202
+ scene.addEventListener("pointerleave", function(e) {
4203
+ if (e.pointerType === "mouse") {
4204
+ tr.hover = false;
4205
+ tr.touch();
4206
+ tr.idle = 1.4;
4207
+ }
4208
+ engaged = false;
4209
+ cs.on = false;
4210
+ cur.classList.remove("lep-on");
4211
+ scene.classList.remove("lep-peek");
4212
+ });
4213
+ scene.addEventListener("focus", function() {
4214
+ tr.focus = scene.matches(":focus-visible");
4215
+ });
4216
+ scene.addEventListener("blur", function() {
4217
+ tr.focus = false;
4218
+ });
4219
+ scene.addEventListener("pointermove", function(e) {
4220
+ if (e.pointerType === "mouse" && !drag) {
4221
+ var r = scene.getBoundingClientRect(), over = !!(e.target.closest && e.target.closest(".lep-page.lep-center")) && D.mode === "closed";
4222
+ cs.tx = e.clientX - r.left;
4223
+ cs.ty = e.clientY - r.top;
4224
+ if (over && !cs.on) {
4225
+ cs.x = cs.tx;
4226
+ cs.y = cs.ty;
4227
+ }
4228
+ cs.on = over;
4229
+ cur.classList.toggle("lep-on", over);
4230
+ scene.classList.toggle("lep-peek", over);
4231
+ }
4232
+ if (!drag || e.pointerId !== drag.id) return;
4233
+ var p2 = e.clientX;
4234
+ if (!drag.moved) {
4235
+ if (Math.abs(p2 - drag.p0) < 5) return;
4236
+ drag.moved = true;
4237
+ drag.p0 = p2;
4238
+ drag.s0 = tr.s;
4239
+ drag.t = e.timeStamp;
4240
+ scene.setPointerCapture(e.pointerId);
4241
+ scene.classList.add("lep-drag");
4242
+ tr.mode = "drag";
4243
+ tr.touch();
4244
+ cs.on = false;
4245
+ cur.classList.remove("lep-on");
4246
+ return;
4247
+ }
4248
+ var dts = Math.max(4, e.timeStamp - drag.t) / 1e3, ns = drag.s0 - (p2 - drag.p0) / ppu;
4249
+ var inst = (ns - tr.s) / dts, kk = 1 - Math.exp(-dts / 0.05);
4250
+ drag.vel += (inst - drag.vel) * kk;
4251
+ tr.s = ns;
4252
+ tr.vel = drag.vel;
4253
+ drag.t = e.timeStamp;
4254
+ });
4255
+ scene.addEventListener("pointerdown", function(e) {
4256
+ if (e.button !== 0) return;
4257
+ engaged = true;
4258
+ drag = { id: e.pointerId, p0: e.clientX, s0: tr.s, moved: false, t: e.timeStamp, vel: 0 };
4259
+ });
4260
+ function end(e) {
4261
+ if (!drag || e.pointerId !== drag.id) return;
4262
+ var d = drag;
4263
+ drag = null;
4264
+ scene.classList.remove("lep-drag");
4265
+ if (d.moved) {
4266
+ tr.release(e.timeStamp - d.t > 90 ? 0 : d.vel);
4267
+ return;
4268
+ }
4269
+ if (e.type !== "pointerup") return;
4270
+ var card = e.target.closest && e.target.closest("[data-slot]");
4271
+ if (!card) return;
4272
+ var slot = +card.getAttribute("data-slot");
4273
+ if (slot === wrapN(Math.round(tr.s), M) && Math.abs(tr.s - Math.round(tr.s)) < 0.2) openPage(slot);
4274
+ else tr.goto(slot);
4275
+ }
4276
+ scene.addEventListener("pointerup", end);
4277
+ scene.addEventListener("pointercancel", end);
4278
+ scene.addEventListener("wheel", function(e) {
4279
+ if (Math.abs(e.deltaX) <= Math.abs(e.deltaY)) return;
4280
+ e.preventDefault();
4281
+ tr.wheel(e.deltaX * (e.deltaMode === 1 ? 16 : 1) / ppu);
4282
+ }, { passive: false });
4283
+ scene.addEventListener("keydown", function(e) {
4284
+ if (e.key === "Enter" || e.key === " ") {
4285
+ e.preventDefault();
4286
+ openPage();
4287
+ return;
4288
+ }
4289
+ var next = e.key === "ArrowRight" || e.key === "ArrowDown", prev = e.key === "ArrowLeft" || e.key === "ArrowUp";
4290
+ if (!next && !prev) return;
4291
+ e.preventDefault();
4292
+ tr.nudge(next ? 1 : -1);
4293
+ });
4294
+ root.addEventListener("keydown", function(e) {
4295
+ if (D.mode !== "open") return;
4296
+ if (e.key === "Escape") closePage();
4297
+ else if (e.key === "ArrowRight") turnPage(1);
4298
+ else if (e.key === "ArrowLeft") turnPage(-1);
4299
+ });
4300
+ var raf = 0, last = performance.now(), visible = true, alive = true;
4301
+ function frame(now) {
4302
+ if (!alive) return;
4303
+ raf = requestAnimationFrame(frame);
4304
+ var dt = Math.min(1 / 30, Math.max(0, (now - last) / 1e3));
4305
+ last = now;
4306
+ if (!visible || document.hidden || dt === 0) return;
4307
+ tr.step(dt);
4308
+ var s = tr.s;
4309
+ if (dirty || s !== lastS) {
4310
+ render(s);
4311
+ captions(s);
4312
+ lastS = s;
4313
+ dirty = false;
4314
+ }
4315
+ if (cs.on) {
4316
+ var kc = 1 - Math.exp(-18 * dt);
4317
+ cs.x += (cs.tx - cs.x) * kc;
4318
+ cs.y += (cs.ty - cs.y) * kc;
4319
+ cur.style.transform = "translate3d(" + f2(cs.x) + "px," + f2(cs.y) + "px,0)";
4320
+ }
4321
+ if (D.mode === "closed") return;
4322
+ D.clock += dt * 1e3;
4323
+ while (D.queue.length && D.queue[0].at <= D.clock) D.queue.shift().fn();
4324
+ D.X.step(dt);
4325
+ D.Y.step(dt);
4326
+ D.Wd.step(dt);
4327
+ D.Hd.step(dt);
4328
+ if (D.bgT) D.bg = tween(D.bgT, D.clock);
4329
+ var m = odMedia.style, mw = Math.max(1, D.Wd.x);
4330
+ m.transform = "translate3d(" + f2(D.X.x) + "px," + f2(D.Y.x) + "px,0)";
4331
+ m.width = f2(mw) + "px";
4332
+ m.height = f2(Math.max(1, D.Hd.x)) + "px";
4333
+ odMedia.style.setProperty("--lep-pw", f2(mw) + "px");
4334
+ odBg.style.opacity = D.bg.toFixed(3);
4335
+ head.style.opacity = (1 - D.bg).toFixed(3);
4336
+ scene.style.opacity = (1 - 0.92 * D.bg).toFixed(3);
4337
+ }
4338
+ var ro = new ResizeObserver(measure);
4339
+ ro.observe(scene);
4340
+ var io = typeof IntersectionObserver !== "undefined" ? new IntersectionObserver(function(es) {
4341
+ visible = es[0].isIntersecting;
4342
+ }, { rootMargin: "120px" }) : null;
4343
+ if (io) io.observe(root);
4344
+ measure();
4345
+ raf = requestAnimationFrame(frame);
4346
+ return {
4347
+ open: function(i2) {
4348
+ if (i2 === void 0) openPage();
4349
+ else {
4350
+ var slot = wrapN(Math.round(tr.s), M);
4351
+ slot += wdiff(i2 - slot % N, N);
4352
+ tr.holdAt(wrapN(slot, M));
4353
+ setTimeout(function() {
4354
+ openPage(wrapN(slot, M));
4355
+ }, REDUCE ? 0 : 700);
4356
+ }
4357
+ },
4358
+ close: closePage,
4359
+ next: function() {
4360
+ if (D.mode === "open") turnPage(1);
4361
+ else tr.nudge(1);
4362
+ },
4363
+ prev: function() {
4364
+ if (D.mode === "open") turnPage(-1);
4365
+ else tr.nudge(-1);
4366
+ },
4367
+ go: function(i2) {
4368
+ var b = Math.round(tr.s);
4369
+ tr.goto(wrapN(b + wdiff(i2 - wrapN(b, N), N), M));
4370
+ },
4371
+ play: function() {
4372
+ closePage();
4373
+ tr.paused = false;
4374
+ tr.idle = 99;
4375
+ },
4376
+ pause: function() {
4377
+ tr.paused = true;
4378
+ },
4379
+ get index() {
4380
+ return idx;
4381
+ },
4382
+ get position() {
4383
+ return tr.s;
4384
+ },
4385
+ get isOpen() {
4386
+ return D.mode === "open";
4387
+ },
4388
+ destroy: function() {
4389
+ alive = false;
4390
+ cancelAnimationFrame(raf);
4391
+ ro.disconnect();
4392
+ if (io) io.disconnect();
4393
+ root.remove();
4394
+ }
4395
+ };
4396
+ }
4397
+ window2.leporello = leporello;
4398
+ })();
4399
+ return api7 = window2;
4400
+ }
4401
+ function mountLeporello(host, o = {}) {
4402
+ css("craft-leporello", CSS8);
4403
+ const E = engine7();
4404
+ const tall = (h) => {
4405
+ if (h != null && h !== "") host.style.height = typeof h === "number" || /^\d+(\.\d+)?$/.test(h) ? h + "px" : String(h);
4406
+ };
4407
+ tall(o.height);
4408
+ const opts = {};
4409
+ for (const k of ["pages", "kicker", "title", "labels", "autoplay", "period", "page", "fonts"]) if (o[k] !== void 0) opts[k] = o[k];
4410
+ opts.base = o.pages ? o.base || "" : ASSETS2;
4411
+ const on = [["leporellochange", o.onChange], ["leporelloopen", o.onOpen], ["leporelloclose", o.onClose]].filter((e) => e[1]);
4412
+ const fns = on.map(([type, fn]) => {
4413
+ const f = (e) => fn(e.detail.index);
4414
+ host.addEventListener(type, f);
4415
+ return [type, f];
4416
+ });
4417
+ const m = E.leporello(host, opts);
4418
+ return {
4419
+ open: (i) => m.open(i),
4420
+ close: () => m.close(),
4421
+ next: () => m.next(),
4422
+ prev: () => m.prev(),
4423
+ go: (i) => m.go(i),
4424
+ play: () => m.play(),
4425
+ pause: () => m.pause(),
4426
+ height: tall,
4427
+ get index() {
4428
+ return m.index;
4429
+ },
4430
+ get isOpen() {
4431
+ return m.isOpen;
4432
+ },
4433
+ destroy() {
4434
+ fns.forEach(([type, f]) => host.removeEventListener(type, f));
4435
+ m.destroy();
4436
+ host.innerHTML = "";
4437
+ }
4438
+ };
4439
+ }
4440
+
3028
4441
  // dist/sign.js
3029
4442
  function sign() {
3030
4443
  if (typeof window === "undefined" || typeof document === "undefined" || window.__craftLibrarySigned) return;
@@ -3044,7 +4457,7 @@ void main() {
3044
4457
  customElements.define(name, class extends HTMLElement {
3045
4458
  connectedCallback() {
3046
4459
  if (this.piece) return;
3047
- css("craft-hosts", "like-button,magnetic-icon,thumbs-reaction{display:inline-block;line-height:0;vertical-align:middle}");
4460
+ css("craft-hosts", "like-button,magnetic-icon,thumbs-reaction{display:inline-block;line-height:0;vertical-align:middle}fold-orb,leporello-book{display:block}");
3048
4461
  this.piece = mount(this, options(this));
3049
4462
  }
3050
4463
  });
@@ -3170,7 +4583,62 @@ void main() {
3170
4583
  label: el.getAttribute("label") || void 0,
3171
4584
  onChange: (value) => send(el, "change", { value })
3172
4585
  }));
4586
+ define("fold-orb", (el, o) => {
4587
+ const m = mountFoldOrb(el, o), num = (v) => v == null || v === "" ? null : +v;
4588
+ const sel = el.getAttribute("follow");
4589
+ if (sel && !o.follow) {
4590
+ const f = () => m.follow(document.querySelector(sel));
4591
+ if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", f, { once: true });
4592
+ else f();
4593
+ }
4594
+ el.pulse = m.pulse;
4595
+ el.lookAt = m.lookAt;
4596
+ el.follow = m.follow;
4597
+ Object.defineProperty(el, "state", { configurable: true, get: () => el.getAttribute("state") || "idle", set: (v) => el.setAttribute("state", v) });
4598
+ Object.defineProperty(el, "tone", { configurable: true, get: () => el.getAttribute("tone") || "steel", set: (v) => el.setAttribute("tone", v) });
4599
+ Object.defineProperty(el, "level", { configurable: true, get: () => num(el.getAttribute("level")), set: (v) => {
4600
+ if (v == null) el.removeAttribute("level");
4601
+ else el.setAttribute("level", v);
4602
+ } });
4603
+ new MutationObserver((list) => list.forEach((r) => {
4604
+ if (r.attributeName === "state") m.set(el.getAttribute("state") || "idle");
4605
+ else if (r.attributeName === "tone") m.tone(el.getAttribute("tone") || "steel");
4606
+ else if (r.attributeName === "level") m.level(num(el.getAttribute("level")));
4607
+ else if (r.attributeName === "height") m.height(el.getAttribute("height"));
4608
+ })).observe(el, { attributes: true, attributeFilter: ["state", "tone", "level", "height"] });
4609
+ return m;
4610
+ }, (el) => ({
4611
+ tone: el.getAttribute("tone") || void 0,
4612
+ state: el.getAttribute("state") || void 0,
4613
+ height: el.getAttribute("height") || void 0,
4614
+ level: el.hasAttribute("level") && el.getAttribute("level") !== "" ? +el.getAttribute("level") : void 0,
4615
+ mic: el.hasAttribute("mic") && el.getAttribute("mic") !== "false",
4616
+ label: el.getAttribute("label") || void 0
4617
+ }));
4618
+ define("leporello-book", (el, o) => {
4619
+ const m = mountLeporello(el, o);
4620
+ ["open", "close", "next", "prev", "go", "play", "pause"].forEach((k) => {
4621
+ el[k] = m[k];
4622
+ });
4623
+ return m;
4624
+ }, (el) => {
4625
+ const a = (n) => el.getAttribute(n), json2 = (v) => {
4626
+ try {
4627
+ return v ? JSON.parse(v) : void 0;
4628
+ } catch (e) {
4629
+ return void 0;
4630
+ }
4631
+ };
4632
+ return {
4633
+ pages: json2(a("pages")),
4634
+ kicker: el.hasAttribute("kicker") ? a("kicker") : void 0,
4635
+ title: el.hasAttribute("heading") ? a("heading") : void 0,
4636
+ autoplay: a("autoplay") === "false" ? false : void 0,
4637
+ height: a("height") || void 0,
4638
+ labels: { open: a("label-open") || void 0, close: a("label-close") || void 0 }
4639
+ };
4640
+ });
3173
4641
 
3174
4642
  // dist/cdn.js
3175
- window.CraftLibrary = { mountLike, mountMagnet, mountGlassNav, mountIridescentCard, mountPiggyBank, mountThinking, mountPanoramaReel, mountMapPin, mountTokenWheel, mountThumbsReaction };
4643
+ window.CraftLibrary = { mountLike, mountMagnet, mountGlassNav, mountIridescentCard, mountPiggyBank, mountThinking, mountPanoramaReel, mountMapPin, mountTokenWheel, mountThumbsReaction, mountFoldOrb, mountLeporello };
3176
4644
  })();